1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef V8_IA32_LITHIUM_IA32_H_
6 #define V8_IA32_LITHIUM_IA32_H_
8 #include "src/hydrogen.h"
9 #include "src/lithium.h"
10 #include "src/lithium-allocator.h"
11 #include "src/safepoint-table.h"
12 #include "src/utils.h"
18 class RCodeVisualizer;
21 // Forward declarations.
24 #define LITHIUM_CONCRETE_INSTRUCTION_LIST(V) \
25 V(AccessArgumentsAt) \
27 V(AllocateBlockContext) \
30 V(ArgumentsElements) \
38 V(CallWithDescriptor) \
44 V(CheckInstanceType) \
53 V(ClassOfTestAndBranch) \
54 V(CompareMinusZeroAndBranch) \
55 V(CompareNumericAndBranch) \
56 V(CmpObjectEqAndBranch) \
80 V(FlooringDivByConstI) \
81 V(FlooringDivByPowerOf2I) \
86 V(GetCachedArrayIndex) \
88 V(HasCachedArrayIndexAndBranch) \
89 V(HasInstanceTypeAndBranch) \
90 V(InnerAllocatedObject) \
92 V(InstanceOfKnownGlobal) \
94 V(Integer32ToDouble) \
96 V(IsConstructCallAndBranch) \
97 V(IsObjectAndBranch) \
98 V(IsStringAndBranch) \
100 V(IsUndetectableAndBranch) \
104 V(LoadFieldByIndex) \
105 V(LoadFunctionPrototype) \
107 V(LoadGlobalGeneric) \
109 V(LoadKeyedGeneric) \
111 V(LoadNamedGeneric) \
126 V(NullarySIMDOperation) \
127 V(UnarySIMDOperation) \
128 V(BinarySIMDOperation) \
129 V(TernarySIMDOperation) \
130 V(QuarternarySIMDOperation) \
145 V(SeqStringGetChar) \
146 V(SeqStringSetChar) \
152 V(StoreContextSlot) \
153 V(StoreFrameContext) \
156 V(StoreKeyedGeneric) \
158 V(StoreNamedGeneric) \
160 V(StringCharCodeAt) \
161 V(StringCharFromCode) \
162 V(StringCompareAndBranch) \
165 V(TailCallThroughMegamorphicCache) \
167 V(ToFastProperties) \
168 V(TransitionElementsKind) \
169 V(TrapAllocationMemento) \
171 V(TypeofIsAndBranch) \
177 #define DECLARE_CONCRETE_INSTRUCTION(type, mnemonic) \
178 virtual Opcode opcode() const FINAL OVERRIDE { \
179 return LInstruction::k##type; \
181 virtual void CompileToNative(LCodeGen* generator) FINAL OVERRIDE; \
182 virtual const char* Mnemonic() const FINAL OVERRIDE { \
185 static L##type* cast(LInstruction* instr) { \
186 DCHECK(instr->Is##type()); \
187 return reinterpret_cast<L##type*>(instr); \
191 #define DECLARE_HYDROGEN_ACCESSOR(type) \
192 H##type* hydrogen() const { \
193 return H##type::cast(hydrogen_value()); \
197 class LInstruction : public ZoneObject {
200 : environment_(NULL),
201 hydrogen_value_(NULL),
202 bit_field_(IsCallBits::encode(false)) {
205 virtual ~LInstruction() {}
207 virtual void CompileToNative(LCodeGen* generator) = 0;
208 virtual const char* Mnemonic() const = 0;
209 virtual void PrintTo(StringStream* stream);
210 virtual void PrintDataTo(StringStream* stream);
211 virtual void PrintOutputOperandTo(StringStream* stream);
214 // Declare a unique enum value for each instruction.
215 #define DECLARE_OPCODE(type) k##type,
216 LITHIUM_CONCRETE_INSTRUCTION_LIST(DECLARE_OPCODE) kAdapter,
217 kNumberOfInstructions
218 #undef DECLARE_OPCODE
221 virtual Opcode opcode() const = 0;
223 // Declare non-virtual type testers for all leaf IR classes.
224 #define DECLARE_PREDICATE(type) \
225 bool Is##type() const { return opcode() == k##type; }
226 LITHIUM_CONCRETE_INSTRUCTION_LIST(DECLARE_PREDICATE)
227 #undef DECLARE_PREDICATE
229 // Declare virtual predicates for instructions that don't have
231 virtual bool IsGap() const { return false; }
233 virtual bool IsControl() const { return false; }
235 // Try deleting this instruction if possible.
236 virtual bool TryDelete() { return false; }
238 void set_environment(LEnvironment* env) { environment_ = env; }
239 LEnvironment* environment() const { return environment_; }
240 bool HasEnvironment() const { return environment_ != NULL; }
242 void set_pointer_map(LPointerMap* p) { pointer_map_.set(p); }
243 LPointerMap* pointer_map() const { return pointer_map_.get(); }
244 bool HasPointerMap() const { return pointer_map_.is_set(); }
246 void set_hydrogen_value(HValue* value) { hydrogen_value_ = value; }
247 HValue* hydrogen_value() const { return hydrogen_value_; }
249 virtual void SetDeferredLazyDeoptimizationEnvironment(LEnvironment* env) { }
251 void MarkAsCall() { bit_field_ = IsCallBits::update(bit_field_, true); }
252 bool IsCall() const { return IsCallBits::decode(bit_field_); }
254 // Interface to the register allocator and iterators.
255 bool ClobbersTemps() const { return IsCall(); }
256 bool ClobbersRegisters() const { return IsCall(); }
257 virtual bool ClobbersDoubleRegisters(Isolate* isolate) const {
261 virtual bool HasResult() const = 0;
262 virtual LOperand* result() const = 0;
264 bool HasDoubleRegisterResult();
265 bool HasDoubleRegisterInput();
267 LOperand* FirstInput() { return InputAt(0); }
268 LOperand* Output() { return HasResult() ? result() : NULL; }
270 virtual bool HasInterestingComment(LCodeGen* gen) const { return true; }
276 virtual int InputCount() = 0;
277 virtual LOperand* InputAt(int i) = 0;
281 friend class InputIterator;
283 friend class TempIterator;
284 virtual int TempCount() = 0;
285 virtual LOperand* TempAt(int i) = 0;
287 class IsCallBits: public BitField<bool, 0, 1> {};
289 LEnvironment* environment_;
290 SetOncePointer<LPointerMap> pointer_map_;
291 HValue* hydrogen_value_;
296 // R = number of result operands (0 or 1).
298 class LTemplateResultInstruction : public LInstruction {
300 // Allow 0 or 1 output operands.
301 STATIC_ASSERT(R == 0 || R == 1);
302 virtual bool HasResult() const FINAL OVERRIDE {
303 return R != 0 && result() != NULL;
305 void set_result(LOperand* operand) { results_[0] = operand; }
306 LOperand* result() const { return results_[0]; }
309 EmbeddedContainer<LOperand*, R> results_;
313 // R = number of result operands (0 or 1).
314 // I = number of input operands.
315 // T = number of temporary operands.
316 template<int R, int I, int T>
317 class LTemplateInstruction : public LTemplateResultInstruction<R> {
319 EmbeddedContainer<LOperand*, I> inputs_;
320 EmbeddedContainer<LOperand*, T> temps_;
324 virtual int InputCount() FINAL OVERRIDE { return I; }
325 virtual LOperand* InputAt(int i) FINAL OVERRIDE { return inputs_[i]; }
327 virtual int TempCount() FINAL OVERRIDE { return T; }
328 virtual LOperand* TempAt(int i) FINAL OVERRIDE { return temps_[i]; }
332 class LGap : public LTemplateInstruction<0, 0, 0> {
334 explicit LGap(HBasicBlock* block) : block_(block) {
335 parallel_moves_[BEFORE] = NULL;
336 parallel_moves_[START] = NULL;
337 parallel_moves_[END] = NULL;
338 parallel_moves_[AFTER] = NULL;
341 // Can't use the DECLARE-macro here because of sub-classes.
342 virtual bool IsGap() const FINAL OVERRIDE { return true; }
343 virtual void PrintDataTo(StringStream* stream) OVERRIDE;
344 static LGap* cast(LInstruction* instr) {
345 DCHECK(instr->IsGap());
346 return reinterpret_cast<LGap*>(instr);
349 bool IsRedundant() const;
351 HBasicBlock* block() const { return block_; }
358 FIRST_INNER_POSITION = BEFORE,
359 LAST_INNER_POSITION = AFTER
362 LParallelMove* GetOrCreateParallelMove(InnerPosition pos, Zone* zone) {
363 if (parallel_moves_[pos] == NULL) {
364 parallel_moves_[pos] = new(zone) LParallelMove(zone);
366 return parallel_moves_[pos];
369 LParallelMove* GetParallelMove(InnerPosition pos) {
370 return parallel_moves_[pos];
374 LParallelMove* parallel_moves_[LAST_INNER_POSITION + 1];
379 class LInstructionGap FINAL : public LGap {
381 explicit LInstructionGap(HBasicBlock* block) : LGap(block) { }
383 virtual bool HasInterestingComment(LCodeGen* gen) const OVERRIDE {
384 return !IsRedundant();
387 DECLARE_CONCRETE_INSTRUCTION(InstructionGap, "gap")
391 class LGoto FINAL : public LTemplateInstruction<0, 0, 0> {
393 explicit LGoto(HBasicBlock* block) : block_(block) { }
395 virtual bool HasInterestingComment(LCodeGen* gen) const OVERRIDE;
396 DECLARE_CONCRETE_INSTRUCTION(Goto, "goto")
397 virtual void PrintDataTo(StringStream* stream) OVERRIDE;
398 virtual bool IsControl() const OVERRIDE { return true; }
400 int block_id() const { return block_->block_id(); }
401 virtual bool ClobbersDoubleRegisters(Isolate* isolate) const OVERRIDE {
405 bool jumps_to_join() const { return block_->predecessors()->length() > 1; }
412 class LLazyBailout FINAL : public LTemplateInstruction<0, 0, 0> {
414 DECLARE_CONCRETE_INSTRUCTION(LazyBailout, "lazy-bailout")
418 class LDummy FINAL : public LTemplateInstruction<1, 0, 0> {
421 DECLARE_CONCRETE_INSTRUCTION(Dummy, "dummy")
425 class LDummyUse FINAL : public LTemplateInstruction<1, 1, 0> {
427 explicit LDummyUse(LOperand* value) {
430 DECLARE_CONCRETE_INSTRUCTION(DummyUse, "dummy-use")
434 class LDeoptimize FINAL : public LTemplateInstruction<0, 0, 0> {
436 virtual bool IsControl() const OVERRIDE { return true; }
437 DECLARE_CONCRETE_INSTRUCTION(Deoptimize, "deoptimize")
438 DECLARE_HYDROGEN_ACCESSOR(Deoptimize)
442 class LLabel FINAL : public LGap {
444 explicit LLabel(HBasicBlock* block)
445 : LGap(block), replacement_(NULL) { }
447 virtual bool HasInterestingComment(LCodeGen* gen) const OVERRIDE {
450 DECLARE_CONCRETE_INSTRUCTION(Label, "label")
452 virtual void PrintDataTo(StringStream* stream) OVERRIDE;
454 int block_id() const { return block()->block_id(); }
455 bool is_loop_header() const { return block()->IsLoopHeader(); }
456 bool is_osr_entry() const { return block()->is_osr_entry(); }
457 Label* label() { return &label_; }
458 LLabel* replacement() const { return replacement_; }
459 void set_replacement(LLabel* label) { replacement_ = label; }
460 bool HasReplacement() const { return replacement_ != NULL; }
464 LLabel* replacement_;
468 class LParameter FINAL : public LTemplateInstruction<1, 0, 0> {
470 virtual bool HasInterestingComment(LCodeGen* gen) const OVERRIDE {
473 DECLARE_CONCRETE_INSTRUCTION(Parameter, "parameter")
477 class LCallStub FINAL : public LTemplateInstruction<1, 1, 0> {
479 explicit LCallStub(LOperand* context) {
480 inputs_[0] = context;
483 LOperand* context() { return inputs_[0]; }
485 DECLARE_CONCRETE_INSTRUCTION(CallStub, "call-stub")
486 DECLARE_HYDROGEN_ACCESSOR(CallStub)
490 class LTailCallThroughMegamorphicCache FINAL
491 : public LTemplateInstruction<0, 3, 0> {
493 explicit LTailCallThroughMegamorphicCache(LOperand* context,
496 inputs_[0] = context;
497 inputs_[1] = receiver;
501 LOperand* context() { return inputs_[0]; }
502 LOperand* receiver() { return inputs_[1]; }
503 LOperand* name() { return inputs_[2]; }
505 DECLARE_CONCRETE_INSTRUCTION(TailCallThroughMegamorphicCache,
506 "tail-call-through-megamorphic-cache")
507 DECLARE_HYDROGEN_ACCESSOR(TailCallThroughMegamorphicCache)
511 class LUnknownOSRValue FINAL : public LTemplateInstruction<1, 0, 0> {
513 virtual bool HasInterestingComment(LCodeGen* gen) const OVERRIDE {
516 DECLARE_CONCRETE_INSTRUCTION(UnknownOSRValue, "unknown-osr-value")
520 template<int I, int T>
521 class LControlInstruction: public LTemplateInstruction<0, I, T> {
523 LControlInstruction() : false_label_(NULL), true_label_(NULL) { }
525 virtual bool IsControl() const FINAL OVERRIDE { return true; }
527 int SuccessorCount() { return hydrogen()->SuccessorCount(); }
528 HBasicBlock* SuccessorAt(int i) { return hydrogen()->SuccessorAt(i); }
530 int TrueDestination(LChunk* chunk) {
531 return chunk->LookupDestination(true_block_id());
533 int FalseDestination(LChunk* chunk) {
534 return chunk->LookupDestination(false_block_id());
537 Label* TrueLabel(LChunk* chunk) {
538 if (true_label_ == NULL) {
539 true_label_ = chunk->GetAssemblyLabel(TrueDestination(chunk));
543 Label* FalseLabel(LChunk* chunk) {
544 if (false_label_ == NULL) {
545 false_label_ = chunk->GetAssemblyLabel(FalseDestination(chunk));
551 int true_block_id() { return SuccessorAt(0)->block_id(); }
552 int false_block_id() { return SuccessorAt(1)->block_id(); }
555 HControlInstruction* hydrogen() {
556 return HControlInstruction::cast(this->hydrogen_value());
564 class LWrapReceiver FINAL : public LTemplateInstruction<1, 2, 1> {
566 LWrapReceiver(LOperand* receiver,
569 inputs_[0] = receiver;
570 inputs_[1] = function;
574 LOperand* receiver() { return inputs_[0]; }
575 LOperand* function() { return inputs_[1]; }
576 LOperand* temp() { return temps_[0]; }
578 DECLARE_CONCRETE_INSTRUCTION(WrapReceiver, "wrap-receiver")
579 DECLARE_HYDROGEN_ACCESSOR(WrapReceiver)
583 class LApplyArguments FINAL : public LTemplateInstruction<1, 4, 0> {
585 LApplyArguments(LOperand* function,
588 LOperand* elements) {
589 inputs_[0] = function;
590 inputs_[1] = receiver;
592 inputs_[3] = elements;
595 LOperand* function() { return inputs_[0]; }
596 LOperand* receiver() { return inputs_[1]; }
597 LOperand* length() { return inputs_[2]; }
598 LOperand* elements() { return inputs_[3]; }
600 DECLARE_CONCRETE_INSTRUCTION(ApplyArguments, "apply-arguments")
604 class LAccessArgumentsAt FINAL : public LTemplateInstruction<1, 3, 0> {
606 LAccessArgumentsAt(LOperand* arguments, LOperand* length, LOperand* index) {
607 inputs_[0] = arguments;
612 LOperand* arguments() { return inputs_[0]; }
613 LOperand* length() { return inputs_[1]; }
614 LOperand* index() { return inputs_[2]; }
616 DECLARE_CONCRETE_INSTRUCTION(AccessArgumentsAt, "access-arguments-at")
618 virtual void PrintDataTo(StringStream* stream) OVERRIDE;
622 class LArgumentsLength FINAL : public LTemplateInstruction<1, 1, 0> {
624 explicit LArgumentsLength(LOperand* elements) {
625 inputs_[0] = elements;
628 LOperand* elements() { return inputs_[0]; }
630 DECLARE_CONCRETE_INSTRUCTION(ArgumentsLength, "arguments-length")
634 class LArgumentsElements FINAL : public LTemplateInstruction<1, 0, 0> {
636 DECLARE_CONCRETE_INSTRUCTION(ArgumentsElements, "arguments-elements")
637 DECLARE_HYDROGEN_ACCESSOR(ArgumentsElements)
641 class LDebugBreak FINAL : public LTemplateInstruction<0, 0, 0> {
643 DECLARE_CONCRETE_INSTRUCTION(DebugBreak, "break")
647 class LModByPowerOf2I FINAL : public LTemplateInstruction<1, 1, 0> {
649 LModByPowerOf2I(LOperand* dividend, int32_t divisor) {
650 inputs_[0] = dividend;
654 LOperand* dividend() { return inputs_[0]; }
655 int32_t divisor() const { return divisor_; }
657 DECLARE_CONCRETE_INSTRUCTION(ModByPowerOf2I, "mod-by-power-of-2-i")
658 DECLARE_HYDROGEN_ACCESSOR(Mod)
665 class LModByConstI FINAL : public LTemplateInstruction<1, 1, 2> {
667 LModByConstI(LOperand* dividend,
671 inputs_[0] = dividend;
677 LOperand* dividend() { return inputs_[0]; }
678 int32_t divisor() const { return divisor_; }
679 LOperand* temp1() { return temps_[0]; }
680 LOperand* temp2() { return temps_[1]; }
682 DECLARE_CONCRETE_INSTRUCTION(ModByConstI, "mod-by-const-i")
683 DECLARE_HYDROGEN_ACCESSOR(Mod)
690 class LModI FINAL : public LTemplateInstruction<1, 2, 1> {
692 LModI(LOperand* left, LOperand* right, LOperand* temp) {
698 LOperand* left() { return inputs_[0]; }
699 LOperand* right() { return inputs_[1]; }
700 LOperand* temp() { return temps_[0]; }
702 DECLARE_CONCRETE_INSTRUCTION(ModI, "mod-i")
703 DECLARE_HYDROGEN_ACCESSOR(Mod)
707 class LDivByPowerOf2I FINAL : public LTemplateInstruction<1, 1, 0> {
709 LDivByPowerOf2I(LOperand* dividend, int32_t divisor) {
710 inputs_[0] = dividend;
714 LOperand* dividend() { return inputs_[0]; }
715 int32_t divisor() const { return divisor_; }
717 DECLARE_CONCRETE_INSTRUCTION(DivByPowerOf2I, "div-by-power-of-2-i")
718 DECLARE_HYDROGEN_ACCESSOR(Div)
725 class LDivByConstI FINAL : public LTemplateInstruction<1, 1, 2> {
727 LDivByConstI(LOperand* dividend,
731 inputs_[0] = dividend;
737 LOperand* dividend() { return inputs_[0]; }
738 int32_t divisor() const { return divisor_; }
739 LOperand* temp1() { return temps_[0]; }
740 LOperand* temp2() { return temps_[1]; }
742 DECLARE_CONCRETE_INSTRUCTION(DivByConstI, "div-by-const-i")
743 DECLARE_HYDROGEN_ACCESSOR(Div)
750 class LDivI FINAL : public LTemplateInstruction<1, 2, 1> {
752 LDivI(LOperand* dividend, LOperand* divisor, LOperand* temp) {
753 inputs_[0] = dividend;
754 inputs_[1] = divisor;
758 LOperand* dividend() { return inputs_[0]; }
759 LOperand* divisor() { return inputs_[1]; }
760 LOperand* temp() { return temps_[0]; }
762 DECLARE_CONCRETE_INSTRUCTION(DivI, "div-i")
763 DECLARE_HYDROGEN_ACCESSOR(BinaryOperation)
767 class LFlooringDivByPowerOf2I FINAL : public LTemplateInstruction<1, 1, 0> {
769 LFlooringDivByPowerOf2I(LOperand* dividend, int32_t divisor) {
770 inputs_[0] = dividend;
774 LOperand* dividend() { return inputs_[0]; }
775 int32_t divisor() const { return divisor_; }
777 DECLARE_CONCRETE_INSTRUCTION(FlooringDivByPowerOf2I,
778 "flooring-div-by-power-of-2-i")
779 DECLARE_HYDROGEN_ACCESSOR(MathFloorOfDiv)
786 class LFlooringDivByConstI FINAL : public LTemplateInstruction<1, 1, 3> {
788 LFlooringDivByConstI(LOperand* dividend,
793 inputs_[0] = dividend;
800 LOperand* dividend() { return inputs_[0]; }
801 int32_t divisor() const { return divisor_; }
802 LOperand* temp1() { return temps_[0]; }
803 LOperand* temp2() { return temps_[1]; }
804 LOperand* temp3() { return temps_[2]; }
806 DECLARE_CONCRETE_INSTRUCTION(FlooringDivByConstI, "flooring-div-by-const-i")
807 DECLARE_HYDROGEN_ACCESSOR(MathFloorOfDiv)
814 class LFlooringDivI FINAL : public LTemplateInstruction<1, 2, 1> {
816 LFlooringDivI(LOperand* dividend, LOperand* divisor, LOperand* temp) {
817 inputs_[0] = dividend;
818 inputs_[1] = divisor;
822 LOperand* dividend() { return inputs_[0]; }
823 LOperand* divisor() { return inputs_[1]; }
824 LOperand* temp() { return temps_[0]; }
826 DECLARE_CONCRETE_INSTRUCTION(FlooringDivI, "flooring-div-i")
827 DECLARE_HYDROGEN_ACCESSOR(MathFloorOfDiv)
831 class LMulI FINAL : public LTemplateInstruction<1, 2, 1> {
833 LMulI(LOperand* left, LOperand* right, LOperand* temp) {
839 LOperand* left() { return inputs_[0]; }
840 LOperand* right() { return inputs_[1]; }
841 LOperand* temp() { return temps_[0]; }
843 DECLARE_CONCRETE_INSTRUCTION(MulI, "mul-i")
844 DECLARE_HYDROGEN_ACCESSOR(Mul)
848 class LCompareNumericAndBranch FINAL : public LControlInstruction<2, 0> {
850 LCompareNumericAndBranch(LOperand* left, LOperand* right) {
855 LOperand* left() { return inputs_[0]; }
856 LOperand* right() { return inputs_[1]; }
858 DECLARE_CONCRETE_INSTRUCTION(CompareNumericAndBranch,
859 "compare-numeric-and-branch")
860 DECLARE_HYDROGEN_ACCESSOR(CompareNumericAndBranch)
862 Token::Value op() const { return hydrogen()->token(); }
863 bool is_double() const {
864 return hydrogen()->representation().IsDouble();
867 virtual void PrintDataTo(StringStream* stream);
871 class LMathFloor FINAL : public LTemplateInstruction<1, 1, 0> {
873 explicit LMathFloor(LOperand* value) {
877 LOperand* value() { return inputs_[0]; }
879 DECLARE_CONCRETE_INSTRUCTION(MathFloor, "math-floor")
880 DECLARE_HYDROGEN_ACCESSOR(UnaryMathOperation)
884 class LMathRound FINAL : public LTemplateInstruction<1, 1, 1> {
886 LMathRound(LOperand* value, LOperand* temp) {
891 LOperand* temp() { return temps_[0]; }
892 LOperand* value() { return inputs_[0]; }
894 DECLARE_CONCRETE_INSTRUCTION(MathRound, "math-round")
895 DECLARE_HYDROGEN_ACCESSOR(UnaryMathOperation)
899 class LMathFround FINAL : public LTemplateInstruction<1, 1, 0> {
901 explicit LMathFround(LOperand* value) { inputs_[0] = value; }
903 LOperand* value() { return inputs_[0]; }
905 DECLARE_CONCRETE_INSTRUCTION(MathFround, "math-fround")
909 class LMathAbs FINAL : public LTemplateInstruction<1, 2, 0> {
911 LMathAbs(LOperand* context, LOperand* value) {
912 inputs_[1] = context;
916 LOperand* context() { return inputs_[1]; }
917 LOperand* value() { return inputs_[0]; }
919 DECLARE_CONCRETE_INSTRUCTION(MathAbs, "math-abs")
920 DECLARE_HYDROGEN_ACCESSOR(UnaryMathOperation)
924 class LMathLog FINAL : public LTemplateInstruction<1, 1, 0> {
926 explicit LMathLog(LOperand* value) {
930 LOperand* value() { return inputs_[0]; }
932 DECLARE_CONCRETE_INSTRUCTION(MathLog, "math-log")
936 class LMathClz32 FINAL : public LTemplateInstruction<1, 1, 0> {
938 explicit LMathClz32(LOperand* value) {
942 LOperand* value() { return inputs_[0]; }
944 DECLARE_CONCRETE_INSTRUCTION(MathClz32, "math-clz32")
948 class LMathExp FINAL : public LTemplateInstruction<1, 1, 2> {
950 LMathExp(LOperand* value,
956 ExternalReference::InitializeMathExpData();
959 LOperand* value() { return inputs_[0]; }
960 LOperand* temp1() { return temps_[0]; }
961 LOperand* temp2() { return temps_[1]; }
963 DECLARE_CONCRETE_INSTRUCTION(MathExp, "math-exp")
967 class LMathSqrt FINAL : public LTemplateInstruction<1, 1, 0> {
969 explicit LMathSqrt(LOperand* value) {
973 LOperand* value() { return inputs_[0]; }
975 DECLARE_CONCRETE_INSTRUCTION(MathSqrt, "math-sqrt")
979 class LMathPowHalf FINAL : public LTemplateInstruction<1, 1, 1> {
981 LMathPowHalf(LOperand* value, LOperand* temp) {
986 LOperand* value() { return inputs_[0]; }
987 LOperand* temp() { return temps_[0]; }
989 DECLARE_CONCRETE_INSTRUCTION(MathPowHalf, "math-pow-half")
993 class LNullarySIMDOperation FINAL : public LTemplateInstruction<1, 0, 0> {
995 explicit LNullarySIMDOperation(BuiltinFunctionId op)
999 BuiltinFunctionId op() const { return op_; }
1001 virtual Opcode opcode() const OVERRIDE {
1002 return LInstruction::kNullarySIMDOperation;
1004 virtual void CompileToNative(LCodeGen* generator) OVERRIDE;
1005 virtual const char* Mnemonic() const OVERRIDE;
1006 static LNullarySIMDOperation* cast(LInstruction* instr) {
1007 DCHECK(instr->IsNullarySIMDOperation());
1008 return reinterpret_cast<LNullarySIMDOperation*>(instr);
1011 DECLARE_HYDROGEN_ACCESSOR(NullarySIMDOperation)
1014 BuiltinFunctionId op_;
1018 class LUnarySIMDOperation FINAL : public LTemplateInstruction<1, 1, 0> {
1020 LUnarySIMDOperation(LOperand* value, BuiltinFunctionId op)
1025 LOperand* value() { return inputs_[0]; }
1026 BuiltinFunctionId op() const { return op_; }
1028 virtual Opcode opcode() const OVERRIDE {
1029 return LInstruction::kUnarySIMDOperation;
1031 virtual void CompileToNative(LCodeGen* generator) OVERRIDE;
1032 virtual const char* Mnemonic() const OVERRIDE;
1033 static LUnarySIMDOperation* cast(LInstruction* instr) {
1034 DCHECK(instr->IsUnarySIMDOperation());
1035 return reinterpret_cast<LUnarySIMDOperation*>(instr);
1038 DECLARE_HYDROGEN_ACCESSOR(UnarySIMDOperation)
1041 BuiltinFunctionId op_;
1045 class LBinarySIMDOperation FINAL : public LTemplateInstruction<1, 2, 0> {
1047 LBinarySIMDOperation(LOperand* left, LOperand* right, BuiltinFunctionId op)
1053 LOperand* left() { return inputs_[0]; }
1054 LOperand* right() { return inputs_[1]; }
1055 BuiltinFunctionId op() const { return op_; }
1057 virtual Opcode opcode() const OVERRIDE {
1058 return LInstruction::kBinarySIMDOperation;
1060 virtual void CompileToNative(LCodeGen* generator) OVERRIDE;
1061 virtual const char* Mnemonic() const OVERRIDE;
1062 static LBinarySIMDOperation* cast(LInstruction* instr) {
1063 DCHECK(instr->IsBinarySIMDOperation());
1064 return reinterpret_cast<LBinarySIMDOperation*>(instr);
1067 DECLARE_HYDROGEN_ACCESSOR(BinarySIMDOperation)
1070 BuiltinFunctionId op_;
1074 class LTernarySIMDOperation FINAL : public LTemplateInstruction<1, 3, 0> {
1076 LTernarySIMDOperation(LOperand* first, LOperand* second, LOperand* third,
1077 BuiltinFunctionId op)
1080 inputs_[1] = second;
1084 LOperand* first() { return inputs_[0]; }
1085 LOperand* second() { return inputs_[1]; }
1086 LOperand* third() { return inputs_[2]; }
1087 BuiltinFunctionId op() const { return op_; }
1089 virtual Opcode opcode() const OVERRIDE {
1090 return LInstruction::kTernarySIMDOperation;
1092 virtual void CompileToNative(LCodeGen* generator) OVERRIDE;
1093 virtual const char* Mnemonic() const OVERRIDE;
1094 static LTernarySIMDOperation* cast(LInstruction* instr) {
1095 DCHECK(instr->IsTernarySIMDOperation());
1096 return reinterpret_cast<LTernarySIMDOperation*>(instr);
1099 DECLARE_HYDROGEN_ACCESSOR(TernarySIMDOperation)
1102 BuiltinFunctionId op_;
1106 class LQuarternarySIMDOperation FINAL
1107 : public LTemplateInstruction<1, 4, 0> {
1109 LQuarternarySIMDOperation(LOperand* x, LOperand* y, LOperand* z,
1110 LOperand* w, BuiltinFunctionId op)
1118 LOperand* x() { return inputs_[0]; }
1119 LOperand* y() { return inputs_[1]; }
1120 LOperand* z() { return inputs_[2]; }
1121 LOperand* w() { return inputs_[3]; }
1122 BuiltinFunctionId op() const { return op_; }
1124 virtual Opcode opcode() const OVERRIDE {
1125 return LInstruction::kQuarternarySIMDOperation;
1127 virtual void CompileToNative(LCodeGen* generator) OVERRIDE;
1128 virtual const char* Mnemonic() const OVERRIDE;
1129 static LQuarternarySIMDOperation* cast(LInstruction* instr) {
1130 DCHECK(instr->IsQuarternarySIMDOperation());
1131 return reinterpret_cast<LQuarternarySIMDOperation*>(instr);
1134 DECLARE_HYDROGEN_ACCESSOR(QuarternarySIMDOperation)
1137 BuiltinFunctionId op_;
1141 class LCmpObjectEqAndBranch FINAL : public LControlInstruction<2, 0> {
1143 LCmpObjectEqAndBranch(LOperand* left, LOperand* right) {
1148 LOperand* left() { return inputs_[0]; }
1149 LOperand* right() { return inputs_[1]; }
1151 DECLARE_CONCRETE_INSTRUCTION(CmpObjectEqAndBranch, "cmp-object-eq-and-branch")
1155 class LCmpHoleAndBranch FINAL : public LControlInstruction<1, 0> {
1157 explicit LCmpHoleAndBranch(LOperand* object) {
1158 inputs_[0] = object;
1161 LOperand* object() { return inputs_[0]; }
1163 DECLARE_CONCRETE_INSTRUCTION(CmpHoleAndBranch, "cmp-hole-and-branch")
1164 DECLARE_HYDROGEN_ACCESSOR(CompareHoleAndBranch)
1168 class LCompareMinusZeroAndBranch FINAL : public LControlInstruction<1, 1> {
1170 LCompareMinusZeroAndBranch(LOperand* value, LOperand* temp) {
1175 LOperand* value() { return inputs_[0]; }
1176 LOperand* temp() { return temps_[0]; }
1178 DECLARE_CONCRETE_INSTRUCTION(CompareMinusZeroAndBranch,
1179 "cmp-minus-zero-and-branch")
1180 DECLARE_HYDROGEN_ACCESSOR(CompareMinusZeroAndBranch)
1184 class LIsObjectAndBranch FINAL : public LControlInstruction<1, 1> {
1186 LIsObjectAndBranch(LOperand* value, LOperand* temp) {
1191 LOperand* value() { return inputs_[0]; }
1192 LOperand* temp() { return temps_[0]; }
1194 DECLARE_CONCRETE_INSTRUCTION(IsObjectAndBranch, "is-object-and-branch")
1196 virtual void PrintDataTo(StringStream* stream) OVERRIDE;
1200 class LIsStringAndBranch FINAL : public LControlInstruction<1, 1> {
1202 LIsStringAndBranch(LOperand* value, LOperand* temp) {
1207 LOperand* value() { return inputs_[0]; }
1208 LOperand* temp() { return temps_[0]; }
1210 DECLARE_CONCRETE_INSTRUCTION(IsStringAndBranch, "is-string-and-branch")
1211 DECLARE_HYDROGEN_ACCESSOR(IsStringAndBranch)
1213 virtual void PrintDataTo(StringStream* stream) OVERRIDE;
1217 class LIsSmiAndBranch FINAL : public LControlInstruction<1, 0> {
1219 explicit LIsSmiAndBranch(LOperand* value) {
1223 LOperand* value() { return inputs_[0]; }
1225 DECLARE_CONCRETE_INSTRUCTION(IsSmiAndBranch, "is-smi-and-branch")
1226 DECLARE_HYDROGEN_ACCESSOR(IsSmiAndBranch)
1228 virtual void PrintDataTo(StringStream* stream) OVERRIDE;
1232 class LIsUndetectableAndBranch FINAL : public LControlInstruction<1, 1> {
1234 LIsUndetectableAndBranch(LOperand* value, LOperand* temp) {
1239 LOperand* value() { return inputs_[0]; }
1240 LOperand* temp() { return temps_[0]; }
1242 DECLARE_CONCRETE_INSTRUCTION(IsUndetectableAndBranch,
1243 "is-undetectable-and-branch")
1244 DECLARE_HYDROGEN_ACCESSOR(IsUndetectableAndBranch)
1246 virtual void PrintDataTo(StringStream* stream) OVERRIDE;
1250 class LStringCompareAndBranch FINAL : public LControlInstruction<3, 0> {
1252 LStringCompareAndBranch(LOperand* context, LOperand* left, LOperand* right) {
1253 inputs_[0] = context;
1258 LOperand* context() { return inputs_[1]; }
1259 LOperand* left() { return inputs_[1]; }
1260 LOperand* right() { return inputs_[2]; }
1262 DECLARE_CONCRETE_INSTRUCTION(StringCompareAndBranch,
1263 "string-compare-and-branch")
1264 DECLARE_HYDROGEN_ACCESSOR(StringCompareAndBranch)
1266 virtual void PrintDataTo(StringStream* stream) OVERRIDE;
1268 Token::Value op() const { return hydrogen()->token(); }
1272 class LHasInstanceTypeAndBranch FINAL : public LControlInstruction<1, 1> {
1274 LHasInstanceTypeAndBranch(LOperand* value, LOperand* temp) {
1279 LOperand* value() { return inputs_[0]; }
1280 LOperand* temp() { return temps_[0]; }
1282 DECLARE_CONCRETE_INSTRUCTION(HasInstanceTypeAndBranch,
1283 "has-instance-type-and-branch")
1284 DECLARE_HYDROGEN_ACCESSOR(HasInstanceTypeAndBranch)
1286 virtual void PrintDataTo(StringStream* stream) OVERRIDE;
1290 class LGetCachedArrayIndex FINAL : public LTemplateInstruction<1, 1, 0> {
1292 explicit LGetCachedArrayIndex(LOperand* value) {
1296 LOperand* value() { return inputs_[0]; }
1298 DECLARE_CONCRETE_INSTRUCTION(GetCachedArrayIndex, "get-cached-array-index")
1299 DECLARE_HYDROGEN_ACCESSOR(GetCachedArrayIndex)
1303 class LHasCachedArrayIndexAndBranch FINAL
1304 : public LControlInstruction<1, 0> {
1306 explicit LHasCachedArrayIndexAndBranch(LOperand* value) {
1310 LOperand* value() { return inputs_[0]; }
1312 DECLARE_CONCRETE_INSTRUCTION(HasCachedArrayIndexAndBranch,
1313 "has-cached-array-index-and-branch")
1315 virtual void PrintDataTo(StringStream* stream) OVERRIDE;
1319 class LIsConstructCallAndBranch FINAL : public LControlInstruction<0, 1> {
1321 explicit LIsConstructCallAndBranch(LOperand* temp) {
1325 LOperand* temp() { return temps_[0]; }
1327 DECLARE_CONCRETE_INSTRUCTION(IsConstructCallAndBranch,
1328 "is-construct-call-and-branch")
1332 class LClassOfTestAndBranch FINAL : public LControlInstruction<1, 2> {
1334 LClassOfTestAndBranch(LOperand* value, LOperand* temp, LOperand* temp2) {
1340 LOperand* value() { return inputs_[0]; }
1341 LOperand* temp() { return temps_[0]; }
1342 LOperand* temp2() { return temps_[1]; }
1344 DECLARE_CONCRETE_INSTRUCTION(ClassOfTestAndBranch,
1345 "class-of-test-and-branch")
1346 DECLARE_HYDROGEN_ACCESSOR(ClassOfTestAndBranch)
1348 virtual void PrintDataTo(StringStream* stream) OVERRIDE;
1352 class LCmpT FINAL : public LTemplateInstruction<1, 3, 0> {
1354 LCmpT(LOperand* context, LOperand* left, LOperand* right) {
1355 inputs_[0] = context;
1360 DECLARE_CONCRETE_INSTRUCTION(CmpT, "cmp-t")
1361 DECLARE_HYDROGEN_ACCESSOR(CompareGeneric)
1363 LOperand* context() { return inputs_[0]; }
1364 Token::Value op() const { return hydrogen()->token(); }
1368 class LInstanceOf FINAL : public LTemplateInstruction<1, 3, 0> {
1370 LInstanceOf(LOperand* context, LOperand* left, LOperand* right) {
1371 inputs_[0] = context;
1376 LOperand* context() { return inputs_[0]; }
1378 DECLARE_CONCRETE_INSTRUCTION(InstanceOf, "instance-of")
1382 class LInstanceOfKnownGlobal FINAL : public LTemplateInstruction<1, 2, 1> {
1384 LInstanceOfKnownGlobal(LOperand* context, LOperand* value, LOperand* temp) {
1385 inputs_[0] = context;
1390 LOperand* context() { return inputs_[0]; }
1391 LOperand* value() { return inputs_[1]; }
1392 LOperand* temp() { return temps_[0]; }
1394 DECLARE_CONCRETE_INSTRUCTION(InstanceOfKnownGlobal,
1395 "instance-of-known-global")
1396 DECLARE_HYDROGEN_ACCESSOR(InstanceOfKnownGlobal)
1398 Handle<JSFunction> function() const { return hydrogen()->function(); }
1399 LEnvironment* GetDeferredLazyDeoptimizationEnvironment() {
1400 return lazy_deopt_env_;
1402 virtual void SetDeferredLazyDeoptimizationEnvironment(
1403 LEnvironment* env) OVERRIDE {
1404 lazy_deopt_env_ = env;
1408 LEnvironment* lazy_deopt_env_;
1412 class LBoundsCheck FINAL : public LTemplateInstruction<0, 2, 0> {
1414 LBoundsCheck(LOperand* index, LOperand* length) {
1416 inputs_[1] = length;
1419 LOperand* index() { return inputs_[0]; }
1420 LOperand* length() { return inputs_[1]; }
1422 DECLARE_CONCRETE_INSTRUCTION(BoundsCheck, "bounds-check")
1423 DECLARE_HYDROGEN_ACCESSOR(BoundsCheck)
1427 class LBitI FINAL : public LTemplateInstruction<1, 2, 0> {
1429 LBitI(LOperand* left, LOperand* right) {
1434 LOperand* left() { return inputs_[0]; }
1435 LOperand* right() { return inputs_[1]; }
1437 DECLARE_CONCRETE_INSTRUCTION(BitI, "bit-i")
1438 DECLARE_HYDROGEN_ACCESSOR(Bitwise)
1440 Token::Value op() const { return hydrogen()->op(); }
1444 class LShiftI FINAL : public LTemplateInstruction<1, 2, 0> {
1446 LShiftI(Token::Value op, LOperand* left, LOperand* right, bool can_deopt)
1447 : op_(op), can_deopt_(can_deopt) {
1452 LOperand* left() { return inputs_[0]; }
1453 LOperand* right() { return inputs_[1]; }
1455 DECLARE_CONCRETE_INSTRUCTION(ShiftI, "shift-i")
1457 Token::Value op() const { return op_; }
1458 bool can_deopt() const { return can_deopt_; }
1466 class LSubI FINAL : public LTemplateInstruction<1, 2, 0> {
1468 LSubI(LOperand* left, LOperand* right) {
1473 LOperand* left() { return inputs_[0]; }
1474 LOperand* right() { return inputs_[1]; }
1476 DECLARE_CONCRETE_INSTRUCTION(SubI, "sub-i")
1477 DECLARE_HYDROGEN_ACCESSOR(Sub)
1481 class LConstantI FINAL : public LTemplateInstruction<1, 0, 0> {
1483 DECLARE_CONCRETE_INSTRUCTION(ConstantI, "constant-i")
1484 DECLARE_HYDROGEN_ACCESSOR(Constant)
1486 int32_t value() const { return hydrogen()->Integer32Value(); }
1490 class LConstantS FINAL : public LTemplateInstruction<1, 0, 0> {
1492 DECLARE_CONCRETE_INSTRUCTION(ConstantS, "constant-s")
1493 DECLARE_HYDROGEN_ACCESSOR(Constant)
1495 Smi* value() const { return Smi::FromInt(hydrogen()->Integer32Value()); }
1499 class LConstantD FINAL : public LTemplateInstruction<1, 0, 1> {
1501 explicit LConstantD(LOperand* temp) {
1505 LOperand* temp() { return temps_[0]; }
1507 DECLARE_CONCRETE_INSTRUCTION(ConstantD, "constant-d")
1508 DECLARE_HYDROGEN_ACCESSOR(Constant)
1510 double value() const { return hydrogen()->DoubleValue(); }
1514 class LConstantE FINAL : public LTemplateInstruction<1, 0, 0> {
1516 DECLARE_CONCRETE_INSTRUCTION(ConstantE, "constant-e")
1517 DECLARE_HYDROGEN_ACCESSOR(Constant)
1519 ExternalReference value() const {
1520 return hydrogen()->ExternalReferenceValue();
1525 class LConstantT FINAL : public LTemplateInstruction<1, 0, 0> {
1527 DECLARE_CONCRETE_INSTRUCTION(ConstantT, "constant-t")
1528 DECLARE_HYDROGEN_ACCESSOR(Constant)
1530 Handle<Object> value(Isolate* isolate) const {
1531 return hydrogen()->handle(isolate);
1536 class LBranch FINAL : public LControlInstruction<1, 1> {
1538 LBranch(LOperand* value, LOperand* temp) {
1543 LOperand* value() { return inputs_[0]; }
1544 LOperand* temp() { return temps_[0]; }
1546 DECLARE_CONCRETE_INSTRUCTION(Branch, "branch")
1547 DECLARE_HYDROGEN_ACCESSOR(Branch)
1549 virtual void PrintDataTo(StringStream* stream) OVERRIDE;
1553 class LCmpMapAndBranch FINAL : public LControlInstruction<1, 0> {
1555 explicit LCmpMapAndBranch(LOperand* value) {
1559 LOperand* value() { return inputs_[0]; }
1561 DECLARE_CONCRETE_INSTRUCTION(CmpMapAndBranch, "cmp-map-and-branch")
1562 DECLARE_HYDROGEN_ACCESSOR(CompareMap)
1564 Handle<Map> map() const { return hydrogen()->map().handle(); }
1568 class LMapEnumLength FINAL : public LTemplateInstruction<1, 1, 0> {
1570 explicit LMapEnumLength(LOperand* value) {
1574 LOperand* value() { return inputs_[0]; }
1576 DECLARE_CONCRETE_INSTRUCTION(MapEnumLength, "map-enum-length")
1580 class LDateField FINAL : public LTemplateInstruction<1, 1, 1> {
1582 LDateField(LOperand* date, LOperand* temp, Smi* index)
1588 LOperand* date() { return inputs_[0]; }
1589 LOperand* temp() { return temps_[0]; }
1591 DECLARE_CONCRETE_INSTRUCTION(DateField, "date-field")
1592 DECLARE_HYDROGEN_ACCESSOR(DateField)
1594 Smi* index() const { return index_; }
1601 class LSeqStringGetChar FINAL : public LTemplateInstruction<1, 2, 0> {
1603 LSeqStringGetChar(LOperand* string, LOperand* index) {
1604 inputs_[0] = string;
1608 LOperand* string() const { return inputs_[0]; }
1609 LOperand* index() const { return inputs_[1]; }
1611 DECLARE_CONCRETE_INSTRUCTION(SeqStringGetChar, "seq-string-get-char")
1612 DECLARE_HYDROGEN_ACCESSOR(SeqStringGetChar)
1616 class LSeqStringSetChar FINAL : public LTemplateInstruction<1, 4, 0> {
1618 LSeqStringSetChar(LOperand* context,
1622 inputs_[0] = context;
1623 inputs_[1] = string;
1628 LOperand* string() { return inputs_[1]; }
1629 LOperand* index() { return inputs_[2]; }
1630 LOperand* value() { return inputs_[3]; }
1632 DECLARE_CONCRETE_INSTRUCTION(SeqStringSetChar, "seq-string-set-char")
1633 DECLARE_HYDROGEN_ACCESSOR(SeqStringSetChar)
1637 class LAddI FINAL : public LTemplateInstruction<1, 2, 0> {
1639 LAddI(LOperand* left, LOperand* right) {
1644 LOperand* left() { return inputs_[0]; }
1645 LOperand* right() { return inputs_[1]; }
1647 static bool UseLea(HAdd* add) {
1648 return !add->CheckFlag(HValue::kCanOverflow) &&
1649 add->BetterLeftOperand()->UseCount() > 1;
1652 DECLARE_CONCRETE_INSTRUCTION(AddI, "add-i")
1653 DECLARE_HYDROGEN_ACCESSOR(Add)
1657 class LMathMinMax FINAL : public LTemplateInstruction<1, 2, 0> {
1659 LMathMinMax(LOperand* left, LOperand* right) {
1664 LOperand* left() { return inputs_[0]; }
1665 LOperand* right() { return inputs_[1]; }
1667 DECLARE_CONCRETE_INSTRUCTION(MathMinMax, "math-min-max")
1668 DECLARE_HYDROGEN_ACCESSOR(MathMinMax)
1672 class LPower FINAL : public LTemplateInstruction<1, 2, 0> {
1674 LPower(LOperand* left, LOperand* right) {
1679 LOperand* left() { return inputs_[0]; }
1680 LOperand* right() { return inputs_[1]; }
1682 DECLARE_CONCRETE_INSTRUCTION(Power, "power")
1683 DECLARE_HYDROGEN_ACCESSOR(Power)
1687 class LArithmeticD FINAL : public LTemplateInstruction<1, 2, 0> {
1689 LArithmeticD(Token::Value op, LOperand* left, LOperand* right)
1695 LOperand* left() { return inputs_[0]; }
1696 LOperand* right() { return inputs_[1]; }
1698 Token::Value op() const { return op_; }
1700 virtual Opcode opcode() const OVERRIDE {
1701 return LInstruction::kArithmeticD;
1703 virtual void CompileToNative(LCodeGen* generator) OVERRIDE;
1704 virtual const char* Mnemonic() const OVERRIDE;
1711 class LArithmeticT FINAL : public LTemplateInstruction<1, 3, 0> {
1713 LArithmeticT(Token::Value op,
1718 inputs_[0] = context;
1723 LOperand* context() { return inputs_[0]; }
1724 LOperand* left() { return inputs_[1]; }
1725 LOperand* right() { return inputs_[2]; }
1727 virtual Opcode opcode() const OVERRIDE {
1728 return LInstruction::kArithmeticT;
1730 virtual void CompileToNative(LCodeGen* generator) OVERRIDE;
1731 virtual const char* Mnemonic() const OVERRIDE;
1733 Token::Value op() const { return op_; }
1740 class LReturn FINAL : public LTemplateInstruction<0, 3, 0> {
1742 explicit LReturn(LOperand* value,
1744 LOperand* parameter_count) {
1746 inputs_[1] = context;
1747 inputs_[2] = parameter_count;
1750 bool has_constant_parameter_count() {
1751 return parameter_count()->IsConstantOperand();
1753 LConstantOperand* constant_parameter_count() {
1754 DCHECK(has_constant_parameter_count());
1755 return LConstantOperand::cast(parameter_count());
1757 LOperand* parameter_count() { return inputs_[2]; }
1759 DECLARE_CONCRETE_INSTRUCTION(Return, "return")
1760 DECLARE_HYDROGEN_ACCESSOR(Return)
1764 class LLoadNamedField FINAL : public LTemplateInstruction<1, 1, 0> {
1766 explicit LLoadNamedField(LOperand* object) {
1767 inputs_[0] = object;
1770 LOperand* object() { return inputs_[0]; }
1772 DECLARE_CONCRETE_INSTRUCTION(LoadNamedField, "load-named-field")
1773 DECLARE_HYDROGEN_ACCESSOR(LoadNamedField)
1777 class LLoadNamedGeneric FINAL : public LTemplateInstruction<1, 2, 1> {
1779 LLoadNamedGeneric(LOperand* context, LOperand* object, LOperand* vector) {
1780 inputs_[0] = context;
1781 inputs_[1] = object;
1785 LOperand* context() { return inputs_[0]; }
1786 LOperand* object() { return inputs_[1]; }
1787 LOperand* temp_vector() { return temps_[0]; }
1789 DECLARE_CONCRETE_INSTRUCTION(LoadNamedGeneric, "load-named-generic")
1790 DECLARE_HYDROGEN_ACCESSOR(LoadNamedGeneric)
1792 Handle<Object> name() const { return hydrogen()->name(); }
1796 class LLoadFunctionPrototype FINAL : public LTemplateInstruction<1, 1, 1> {
1798 LLoadFunctionPrototype(LOperand* function, LOperand* temp) {
1799 inputs_[0] = function;
1803 LOperand* function() { return inputs_[0]; }
1804 LOperand* temp() { return temps_[0]; }
1806 DECLARE_CONCRETE_INSTRUCTION(LoadFunctionPrototype, "load-function-prototype")
1807 DECLARE_HYDROGEN_ACCESSOR(LoadFunctionPrototype)
1811 class LLoadRoot FINAL : public LTemplateInstruction<1, 0, 0> {
1813 DECLARE_CONCRETE_INSTRUCTION(LoadRoot, "load-root")
1814 DECLARE_HYDROGEN_ACCESSOR(LoadRoot)
1816 Heap::RootListIndex index() const { return hydrogen()->index(); }
1820 class LLoadKeyed FINAL : public LTemplateInstruction<1, 2, 0> {
1822 LLoadKeyed(LOperand* elements, LOperand* key) {
1823 inputs_[0] = elements;
1826 LOperand* elements() { return inputs_[0]; }
1827 LOperand* key() { return inputs_[1]; }
1828 ElementsKind elements_kind() const {
1829 return hydrogen()->elements_kind();
1831 bool is_external() const {
1832 return hydrogen()->is_external();
1834 bool is_fixed_typed_array() const {
1835 return hydrogen()->is_fixed_typed_array();
1837 bool is_typed_elements() const {
1838 return is_external() || is_fixed_typed_array();
1841 DECLARE_CONCRETE_INSTRUCTION(LoadKeyed, "load-keyed")
1842 DECLARE_HYDROGEN_ACCESSOR(LoadKeyed)
1844 virtual void PrintDataTo(StringStream* stream) OVERRIDE;
1845 uint32_t base_offset() const { return hydrogen()->base_offset(); }
1847 return hydrogen()->key()->representation().IsTagged();
1852 inline static bool ExternalArrayOpRequiresPreScale(
1853 Representation key_representation,
1854 ElementsKind kind) {
1855 int shift_size = ElementsKindToShiftSize(kind);
1856 return key_representation.IsSmi()
1857 ? shift_size > static_cast<int>(maximal_scale_factor) + kSmiTagSize
1858 : shift_size > static_cast<int>(maximal_scale_factor);
1862 inline static bool ExternalArrayOpRequiresTemp(
1863 Representation key_representation,
1864 ElementsKind elements_kind) {
1865 // Operations that require the key to be scaled by a factor or divided by two
1866 // to be converted into an index cannot fold the scale operation into a load
1867 // and need an extra temp register to do the work.
1868 return ExternalArrayOpRequiresPreScale(key_representation, elements_kind) ||
1869 (key_representation.IsSmi() &&
1870 (elements_kind == EXTERNAL_INT8_ELEMENTS ||
1871 elements_kind == EXTERNAL_UINT8_ELEMENTS ||
1872 elements_kind == EXTERNAL_UINT8_CLAMPED_ELEMENTS ||
1873 elements_kind == UINT8_ELEMENTS ||
1874 elements_kind == INT8_ELEMENTS ||
1875 elements_kind == UINT8_CLAMPED_ELEMENTS));
1879 class LLoadKeyedGeneric FINAL : public LTemplateInstruction<1, 3, 1> {
1881 LLoadKeyedGeneric(LOperand* context, LOperand* obj, LOperand* key,
1883 inputs_[0] = context;
1889 LOperand* context() { return inputs_[0]; }
1890 LOperand* object() { return inputs_[1]; }
1891 LOperand* key() { return inputs_[2]; }
1892 LOperand* temp_vector() { return temps_[0]; }
1894 DECLARE_CONCRETE_INSTRUCTION(LoadKeyedGeneric, "load-keyed-generic")
1895 DECLARE_HYDROGEN_ACCESSOR(LoadKeyedGeneric)
1899 class LLoadGlobalCell FINAL : public LTemplateInstruction<1, 0, 0> {
1901 DECLARE_CONCRETE_INSTRUCTION(LoadGlobalCell, "load-global-cell")
1902 DECLARE_HYDROGEN_ACCESSOR(LoadGlobalCell)
1906 class LLoadGlobalGeneric FINAL : public LTemplateInstruction<1, 2, 1> {
1908 LLoadGlobalGeneric(LOperand* context, LOperand* global_object,
1910 inputs_[0] = context;
1911 inputs_[1] = global_object;
1915 LOperand* context() { return inputs_[0]; }
1916 LOperand* global_object() { return inputs_[1]; }
1917 LOperand* temp_vector() { return temps_[0]; }
1919 DECLARE_CONCRETE_INSTRUCTION(LoadGlobalGeneric, "load-global-generic")
1920 DECLARE_HYDROGEN_ACCESSOR(LoadGlobalGeneric)
1922 Handle<Object> name() const { return hydrogen()->name(); }
1923 bool for_typeof() const { return hydrogen()->for_typeof(); }
1927 class LStoreGlobalCell FINAL : public LTemplateInstruction<0, 1, 0> {
1929 explicit LStoreGlobalCell(LOperand* value) {
1933 LOperand* value() { return inputs_[0]; }
1935 DECLARE_CONCRETE_INSTRUCTION(StoreGlobalCell, "store-global-cell")
1936 DECLARE_HYDROGEN_ACCESSOR(StoreGlobalCell)
1940 class LLoadContextSlot FINAL : public LTemplateInstruction<1, 1, 0> {
1942 explicit LLoadContextSlot(LOperand* context) {
1943 inputs_[0] = context;
1946 LOperand* context() { return inputs_[0]; }
1948 DECLARE_CONCRETE_INSTRUCTION(LoadContextSlot, "load-context-slot")
1949 DECLARE_HYDROGEN_ACCESSOR(LoadContextSlot)
1951 int slot_index() { return hydrogen()->slot_index(); }
1953 virtual void PrintDataTo(StringStream* stream) OVERRIDE;
1957 class LStoreContextSlot FINAL : public LTemplateInstruction<0, 2, 1> {
1959 LStoreContextSlot(LOperand* context, LOperand* value, LOperand* temp) {
1960 inputs_[0] = context;
1965 LOperand* context() { return inputs_[0]; }
1966 LOperand* value() { return inputs_[1]; }
1967 LOperand* temp() { return temps_[0]; }
1969 DECLARE_CONCRETE_INSTRUCTION(StoreContextSlot, "store-context-slot")
1970 DECLARE_HYDROGEN_ACCESSOR(StoreContextSlot)
1972 int slot_index() { return hydrogen()->slot_index(); }
1974 virtual void PrintDataTo(StringStream* stream) OVERRIDE;
1978 class LPushArgument FINAL : public LTemplateInstruction<0, 1, 0> {
1980 explicit LPushArgument(LOperand* value) {
1984 LOperand* value() { return inputs_[0]; }
1986 DECLARE_CONCRETE_INSTRUCTION(PushArgument, "push-argument")
1990 class LDrop FINAL : public LTemplateInstruction<0, 0, 0> {
1992 explicit LDrop(int count) : count_(count) { }
1994 int count() const { return count_; }
1996 DECLARE_CONCRETE_INSTRUCTION(Drop, "drop")
2003 class LStoreCodeEntry FINAL: public LTemplateInstruction<0, 2, 0> {
2005 LStoreCodeEntry(LOperand* function, LOperand* code_object) {
2006 inputs_[0] = function;
2007 inputs_[1] = code_object;
2010 LOperand* function() { return inputs_[0]; }
2011 LOperand* code_object() { return inputs_[1]; }
2013 virtual void PrintDataTo(StringStream* stream);
2015 DECLARE_CONCRETE_INSTRUCTION(StoreCodeEntry, "store-code-entry")
2016 DECLARE_HYDROGEN_ACCESSOR(StoreCodeEntry)
2020 class LInnerAllocatedObject FINAL: public LTemplateInstruction<1, 2, 0> {
2022 LInnerAllocatedObject(LOperand* base_object, LOperand* offset) {
2023 inputs_[0] = base_object;
2024 inputs_[1] = offset;
2027 LOperand* base_object() const { return inputs_[0]; }
2028 LOperand* offset() const { return inputs_[1]; }
2030 virtual void PrintDataTo(StringStream* stream);
2032 DECLARE_CONCRETE_INSTRUCTION(InnerAllocatedObject, "inner-allocated-object")
2036 class LThisFunction FINAL : public LTemplateInstruction<1, 0, 0> {
2038 DECLARE_CONCRETE_INSTRUCTION(ThisFunction, "this-function")
2039 DECLARE_HYDROGEN_ACCESSOR(ThisFunction)
2043 class LContext FINAL : public LTemplateInstruction<1, 0, 0> {
2045 DECLARE_CONCRETE_INSTRUCTION(Context, "context")
2046 DECLARE_HYDROGEN_ACCESSOR(Context)
2050 class LDeclareGlobals FINAL : public LTemplateInstruction<0, 1, 0> {
2052 explicit LDeclareGlobals(LOperand* context) {
2053 inputs_[0] = context;
2056 LOperand* context() { return inputs_[0]; }
2058 DECLARE_CONCRETE_INSTRUCTION(DeclareGlobals, "declare-globals")
2059 DECLARE_HYDROGEN_ACCESSOR(DeclareGlobals)
2063 class LCallJSFunction FINAL : public LTemplateInstruction<1, 1, 0> {
2065 explicit LCallJSFunction(LOperand* function) {
2066 inputs_[0] = function;
2069 LOperand* function() { return inputs_[0]; }
2071 DECLARE_CONCRETE_INSTRUCTION(CallJSFunction, "call-js-function")
2072 DECLARE_HYDROGEN_ACCESSOR(CallJSFunction)
2074 virtual void PrintDataTo(StringStream* stream) OVERRIDE;
2076 int arity() const { return hydrogen()->argument_count() - 1; }
2080 class LCallWithDescriptor FINAL : public LTemplateResultInstruction<1> {
2082 LCallWithDescriptor(CallInterfaceDescriptor descriptor,
2083 const ZoneList<LOperand*>& operands, Zone* zone)
2084 : inputs_(descriptor.GetRegisterParameterCount() + 1, zone) {
2085 DCHECK(descriptor.GetRegisterParameterCount() + 1 == operands.length());
2086 inputs_.AddAll(operands, zone);
2089 LOperand* target() const { return inputs_[0]; }
2091 DECLARE_HYDROGEN_ACCESSOR(CallWithDescriptor)
2094 DECLARE_CONCRETE_INSTRUCTION(CallWithDescriptor, "call-with-descriptor")
2096 virtual void PrintDataTo(StringStream* stream) OVERRIDE;
2098 int arity() const { return hydrogen()->argument_count() - 1; }
2100 ZoneList<LOperand*> inputs_;
2102 // Iterator support.
2103 virtual int InputCount() FINAL OVERRIDE { return inputs_.length(); }
2104 virtual LOperand* InputAt(int i) FINAL OVERRIDE { return inputs_[i]; }
2106 virtual int TempCount() FINAL OVERRIDE { return 0; }
2107 virtual LOperand* TempAt(int i) FINAL OVERRIDE { return NULL; }
2111 class LInvokeFunction FINAL : public LTemplateInstruction<1, 2, 0> {
2113 LInvokeFunction(LOperand* context, LOperand* function) {
2114 inputs_[0] = context;
2115 inputs_[1] = function;
2118 LOperand* context() { return inputs_[0]; }
2119 LOperand* function() { return inputs_[1]; }
2121 DECLARE_CONCRETE_INSTRUCTION(InvokeFunction, "invoke-function")
2122 DECLARE_HYDROGEN_ACCESSOR(InvokeFunction)
2124 virtual void PrintDataTo(StringStream* stream) OVERRIDE;
2126 int arity() const { return hydrogen()->argument_count() - 1; }
2130 class LCallFunction FINAL : public LTemplateInstruction<1, 2, 0> {
2132 explicit LCallFunction(LOperand* context, LOperand* function) {
2133 inputs_[0] = context;
2134 inputs_[1] = function;
2137 LOperand* context() { return inputs_[0]; }
2138 LOperand* function() { return inputs_[1]; }
2140 DECLARE_CONCRETE_INSTRUCTION(CallFunction, "call-function")
2141 DECLARE_HYDROGEN_ACCESSOR(CallFunction)
2143 int arity() const { return hydrogen()->argument_count() - 1; }
2147 class LCallNew FINAL : public LTemplateInstruction<1, 2, 0> {
2149 LCallNew(LOperand* context, LOperand* constructor) {
2150 inputs_[0] = context;
2151 inputs_[1] = constructor;
2154 LOperand* context() { return inputs_[0]; }
2155 LOperand* constructor() { return inputs_[1]; }
2157 DECLARE_CONCRETE_INSTRUCTION(CallNew, "call-new")
2158 DECLARE_HYDROGEN_ACCESSOR(CallNew)
2160 virtual void PrintDataTo(StringStream* stream) OVERRIDE;
2162 int arity() const { return hydrogen()->argument_count() - 1; }
2166 class LCallNewArray FINAL : public LTemplateInstruction<1, 2, 0> {
2168 LCallNewArray(LOperand* context, LOperand* constructor) {
2169 inputs_[0] = context;
2170 inputs_[1] = constructor;
2173 LOperand* context() { return inputs_[0]; }
2174 LOperand* constructor() { return inputs_[1]; }
2176 DECLARE_CONCRETE_INSTRUCTION(CallNewArray, "call-new-array")
2177 DECLARE_HYDROGEN_ACCESSOR(CallNewArray)
2179 virtual void PrintDataTo(StringStream* stream) OVERRIDE;
2181 int arity() const { return hydrogen()->argument_count() - 1; }
2185 class LCallRuntime FINAL : public LTemplateInstruction<1, 1, 0> {
2187 explicit LCallRuntime(LOperand* context) {
2188 inputs_[0] = context;
2191 LOperand* context() { return inputs_[0]; }
2193 DECLARE_CONCRETE_INSTRUCTION(CallRuntime, "call-runtime")
2194 DECLARE_HYDROGEN_ACCESSOR(CallRuntime)
2196 virtual bool ClobbersDoubleRegisters(Isolate* isolate) const OVERRIDE {
2197 return save_doubles() == kDontSaveFPRegs;
2200 const Runtime::Function* function() const { return hydrogen()->function(); }
2201 int arity() const { return hydrogen()->argument_count(); }
2202 SaveFPRegsMode save_doubles() const { return hydrogen()->save_doubles(); }
2206 class LInteger32ToDouble FINAL : public LTemplateInstruction<1, 1, 0> {
2208 explicit LInteger32ToDouble(LOperand* value) {
2212 LOperand* value() { return inputs_[0]; }
2214 DECLARE_CONCRETE_INSTRUCTION(Integer32ToDouble, "int32-to-double")
2218 class LUint32ToDouble FINAL : public LTemplateInstruction<1, 1, 0> {
2220 explicit LUint32ToDouble(LOperand* value) {
2224 LOperand* value() { return inputs_[0]; }
2226 DECLARE_CONCRETE_INSTRUCTION(Uint32ToDouble, "uint32-to-double")
2230 class LNumberTagI FINAL : public LTemplateInstruction<1, 1, 1> {
2232 LNumberTagI(LOperand* value, LOperand* temp) {
2237 LOperand* value() { return inputs_[0]; }
2238 LOperand* temp() { return temps_[0]; }
2240 DECLARE_CONCRETE_INSTRUCTION(NumberTagI, "number-tag-i")
2244 class LNumberTagU FINAL : public LTemplateInstruction<1, 1, 1> {
2246 LNumberTagU(LOperand* value, LOperand* temp) {
2251 LOperand* value() { return inputs_[0]; }
2252 LOperand* temp() { return temps_[0]; }
2254 DECLARE_CONCRETE_INSTRUCTION(NumberTagU, "number-tag-u")
2258 class LNumberTagD FINAL : public LTemplateInstruction<1, 1, 1> {
2260 LNumberTagD(LOperand* value, LOperand* temp) {
2265 LOperand* value() { return inputs_[0]; }
2266 LOperand* temp() { return temps_[0]; }
2268 DECLARE_CONCRETE_INSTRUCTION(NumberTagD, "number-tag-d")
2269 DECLARE_HYDROGEN_ACCESSOR(Change)
2273 class LSIMD128ToTagged FINAL : public LTemplateInstruction<1, 1, 2> {
2275 explicit LSIMD128ToTagged(LOperand* value, LOperand* temp, LOperand* temp2) {
2281 LOperand* value() { return inputs_[0]; }
2282 LOperand* temp() { return temps_[0]; }
2283 LOperand* temp2() { return temps_[1]; }
2285 DECLARE_CONCRETE_INSTRUCTION(SIMD128ToTagged, "simd128-tag")
2286 DECLARE_HYDROGEN_ACCESSOR(Change)
2290 // Sometimes truncating conversion from a tagged value to an int32.
2291 class LDoubleToI FINAL : public LTemplateInstruction<1, 1, 1> {
2293 LDoubleToI(LOperand* value, LOperand* temp) {
2298 LOperand* value() { return inputs_[0]; }
2299 LOperand* temp() { return temps_[0]; }
2301 DECLARE_CONCRETE_INSTRUCTION(DoubleToI, "double-to-i")
2302 DECLARE_HYDROGEN_ACCESSOR(UnaryOperation)
2304 bool truncating() { return hydrogen()->CanTruncateToInt32(); }
2308 class LDoubleToSmi FINAL : public LTemplateInstruction<1, 1, 0> {
2310 explicit LDoubleToSmi(LOperand* value) {
2314 LOperand* value() { return inputs_[0]; }
2316 DECLARE_CONCRETE_INSTRUCTION(DoubleToSmi, "double-to-smi")
2317 DECLARE_HYDROGEN_ACCESSOR(UnaryOperation)
2321 // Truncating conversion from a tagged value to an int32.
2322 class LTaggedToI FINAL : public LTemplateInstruction<1, 1, 1> {
2324 LTaggedToI(LOperand* value, LOperand* temp) {
2329 LOperand* value() { return inputs_[0]; }
2330 LOperand* temp() { return temps_[0]; }
2332 DECLARE_CONCRETE_INSTRUCTION(TaggedToI, "tagged-to-i")
2333 DECLARE_HYDROGEN_ACCESSOR(Change)
2335 bool truncating() { return hydrogen()->CanTruncateToInt32(); }
2339 class LSmiTag FINAL : public LTemplateInstruction<1, 1, 0> {
2341 explicit LSmiTag(LOperand* value) {
2345 LOperand* value() { return inputs_[0]; }
2347 DECLARE_CONCRETE_INSTRUCTION(SmiTag, "smi-tag")
2348 DECLARE_HYDROGEN_ACCESSOR(Change)
2352 class LNumberUntagD FINAL : public LTemplateInstruction<1, 1, 1> {
2354 explicit LNumberUntagD(LOperand* value, LOperand* temp) {
2359 LOperand* value() { return inputs_[0]; }
2360 LOperand* temp() { return temps_[0]; }
2362 DECLARE_CONCRETE_INSTRUCTION(NumberUntagD, "double-untag")
2363 DECLARE_HYDROGEN_ACCESSOR(Change);
2367 class LTaggedToSIMD128 FINAL : public LTemplateInstruction<1, 1, 1> {
2369 explicit LTaggedToSIMD128(LOperand* value, LOperand* temp,
2370 Representation representation)
2371 : representation_(representation) {
2376 LOperand* value() { return inputs_[0]; }
2377 LOperand* temp() { return temps_[0]; }
2378 Representation representation() const { return representation_; }
2380 DECLARE_CONCRETE_INSTRUCTION(TaggedToSIMD128, "simd128-untag")
2381 DECLARE_HYDROGEN_ACCESSOR(Change);
2383 Representation representation_;
2387 class LSmiUntag FINAL : public LTemplateInstruction<1, 1, 0> {
2389 LSmiUntag(LOperand* value, bool needs_check)
2390 : needs_check_(needs_check) {
2394 LOperand* value() { return inputs_[0]; }
2396 DECLARE_CONCRETE_INSTRUCTION(SmiUntag, "smi-untag")
2398 bool needs_check() const { return needs_check_; }
2405 class LStoreNamedField FINAL : public LTemplateInstruction<0, 2, 2> {
2407 LStoreNamedField(LOperand* obj,
2410 LOperand* temp_map) {
2414 temps_[1] = temp_map;
2417 LOperand* object() { return inputs_[0]; }
2418 LOperand* value() { return inputs_[1]; }
2419 LOperand* temp() { return temps_[0]; }
2420 LOperand* temp_map() { return temps_[1]; }
2422 DECLARE_CONCRETE_INSTRUCTION(StoreNamedField, "store-named-field")
2423 DECLARE_HYDROGEN_ACCESSOR(StoreNamedField)
2425 virtual void PrintDataTo(StringStream* stream) OVERRIDE;
2429 class LStoreNamedGeneric FINAL : public LTemplateInstruction<0, 3, 0> {
2431 LStoreNamedGeneric(LOperand* context, LOperand* object, LOperand* value) {
2432 inputs_[0] = context;
2433 inputs_[1] = object;
2437 LOperand* context() { return inputs_[0]; }
2438 LOperand* object() { return inputs_[1]; }
2439 LOperand* value() { return inputs_[2]; }
2441 DECLARE_CONCRETE_INSTRUCTION(StoreNamedGeneric, "store-named-generic")
2442 DECLARE_HYDROGEN_ACCESSOR(StoreNamedGeneric)
2444 virtual void PrintDataTo(StringStream* stream) OVERRIDE;
2445 Handle<Object> name() const { return hydrogen()->name(); }
2446 StrictMode strict_mode() { return hydrogen()->strict_mode(); }
2450 class LStoreKeyed FINAL : public LTemplateInstruction<0, 3, 0> {
2452 LStoreKeyed(LOperand* obj, LOperand* key, LOperand* val) {
2458 bool is_external() const { return hydrogen()->is_external(); }
2459 bool is_fixed_typed_array() const {
2460 return hydrogen()->is_fixed_typed_array();
2462 bool is_typed_elements() const {
2463 return is_external() || is_fixed_typed_array();
2465 LOperand* elements() { return inputs_[0]; }
2466 LOperand* key() { return inputs_[1]; }
2467 LOperand* value() { return inputs_[2]; }
2468 ElementsKind elements_kind() const {
2469 return hydrogen()->elements_kind();
2472 DECLARE_CONCRETE_INSTRUCTION(StoreKeyed, "store-keyed")
2473 DECLARE_HYDROGEN_ACCESSOR(StoreKeyed)
2475 virtual void PrintDataTo(StringStream* stream) OVERRIDE;
2476 uint32_t base_offset() const { return hydrogen()->base_offset(); }
2477 bool NeedsCanonicalization() { return hydrogen()->NeedsCanonicalization(); }
2481 class LStoreKeyedGeneric FINAL : public LTemplateInstruction<0, 4, 0> {
2483 LStoreKeyedGeneric(LOperand* context,
2487 inputs_[0] = context;
2488 inputs_[1] = object;
2493 LOperand* context() { return inputs_[0]; }
2494 LOperand* object() { return inputs_[1]; }
2495 LOperand* key() { return inputs_[2]; }
2496 LOperand* value() { return inputs_[3]; }
2498 DECLARE_CONCRETE_INSTRUCTION(StoreKeyedGeneric, "store-keyed-generic")
2499 DECLARE_HYDROGEN_ACCESSOR(StoreKeyedGeneric)
2501 virtual void PrintDataTo(StringStream* stream) OVERRIDE;
2503 StrictMode strict_mode() { return hydrogen()->strict_mode(); }
2507 class LTransitionElementsKind FINAL : public LTemplateInstruction<0, 2, 2> {
2509 LTransitionElementsKind(LOperand* object,
2511 LOperand* new_map_temp,
2513 inputs_[0] = object;
2514 inputs_[1] = context;
2515 temps_[0] = new_map_temp;
2519 LOperand* context() { return inputs_[1]; }
2520 LOperand* object() { return inputs_[0]; }
2521 LOperand* new_map_temp() { return temps_[0]; }
2522 LOperand* temp() { return temps_[1]; }
2524 DECLARE_CONCRETE_INSTRUCTION(TransitionElementsKind,
2525 "transition-elements-kind")
2526 DECLARE_HYDROGEN_ACCESSOR(TransitionElementsKind)
2528 virtual void PrintDataTo(StringStream* stream) OVERRIDE;
2530 Handle<Map> original_map() { return hydrogen()->original_map().handle(); }
2531 Handle<Map> transitioned_map() {
2532 return hydrogen()->transitioned_map().handle();
2534 ElementsKind from_kind() { return hydrogen()->from_kind(); }
2535 ElementsKind to_kind() { return hydrogen()->to_kind(); }
2539 class LTrapAllocationMemento FINAL : public LTemplateInstruction<0, 1, 1> {
2541 LTrapAllocationMemento(LOperand* object,
2543 inputs_[0] = object;
2547 LOperand* object() { return inputs_[0]; }
2548 LOperand* temp() { return temps_[0]; }
2550 DECLARE_CONCRETE_INSTRUCTION(TrapAllocationMemento,
2551 "trap-allocation-memento")
2555 class LStringAdd FINAL : public LTemplateInstruction<1, 3, 0> {
2557 LStringAdd(LOperand* context, LOperand* left, LOperand* right) {
2558 inputs_[0] = context;
2563 LOperand* context() { return inputs_[0]; }
2564 LOperand* left() { return inputs_[1]; }
2565 LOperand* right() { return inputs_[2]; }
2567 DECLARE_CONCRETE_INSTRUCTION(StringAdd, "string-add")
2568 DECLARE_HYDROGEN_ACCESSOR(StringAdd)
2572 class LStringCharCodeAt FINAL : public LTemplateInstruction<1, 3, 0> {
2574 LStringCharCodeAt(LOperand* context, LOperand* string, LOperand* index) {
2575 inputs_[0] = context;
2576 inputs_[1] = string;
2580 LOperand* context() { return inputs_[0]; }
2581 LOperand* string() { return inputs_[1]; }
2582 LOperand* index() { return inputs_[2]; }
2584 DECLARE_CONCRETE_INSTRUCTION(StringCharCodeAt, "string-char-code-at")
2585 DECLARE_HYDROGEN_ACCESSOR(StringCharCodeAt)
2589 class LStringCharFromCode FINAL : public LTemplateInstruction<1, 2, 0> {
2591 LStringCharFromCode(LOperand* context, LOperand* char_code) {
2592 inputs_[0] = context;
2593 inputs_[1] = char_code;
2596 LOperand* context() { return inputs_[0]; }
2597 LOperand* char_code() { return inputs_[1]; }
2599 DECLARE_CONCRETE_INSTRUCTION(StringCharFromCode, "string-char-from-code")
2600 DECLARE_HYDROGEN_ACCESSOR(StringCharFromCode)
2604 class LCheckValue FINAL : public LTemplateInstruction<0, 1, 0> {
2606 explicit LCheckValue(LOperand* value) {
2610 LOperand* value() { return inputs_[0]; }
2612 DECLARE_CONCRETE_INSTRUCTION(CheckValue, "check-value")
2613 DECLARE_HYDROGEN_ACCESSOR(CheckValue)
2617 class LCheckInstanceType FINAL : public LTemplateInstruction<0, 1, 1> {
2619 LCheckInstanceType(LOperand* value, LOperand* temp) {
2624 LOperand* value() { return inputs_[0]; }
2625 LOperand* temp() { return temps_[0]; }
2627 DECLARE_CONCRETE_INSTRUCTION(CheckInstanceType, "check-instance-type")
2628 DECLARE_HYDROGEN_ACCESSOR(CheckInstanceType)
2632 class LCheckMaps FINAL : public LTemplateInstruction<0, 1, 0> {
2634 explicit LCheckMaps(LOperand* value = NULL) {
2638 LOperand* value() { return inputs_[0]; }
2640 DECLARE_CONCRETE_INSTRUCTION(CheckMaps, "check-maps")
2641 DECLARE_HYDROGEN_ACCESSOR(CheckMaps)
2645 class LCheckSmi FINAL : public LTemplateInstruction<1, 1, 0> {
2647 explicit LCheckSmi(LOperand* value) {
2651 LOperand* value() { return inputs_[0]; }
2653 DECLARE_CONCRETE_INSTRUCTION(CheckSmi, "check-smi")
2657 class LClampDToUint8 FINAL : public LTemplateInstruction<1, 1, 0> {
2659 explicit LClampDToUint8(LOperand* value) {
2663 LOperand* unclamped() { return inputs_[0]; }
2665 DECLARE_CONCRETE_INSTRUCTION(ClampDToUint8, "clamp-d-to-uint8")
2669 class LClampIToUint8 FINAL : public LTemplateInstruction<1, 1, 0> {
2671 explicit LClampIToUint8(LOperand* value) {
2675 LOperand* unclamped() { return inputs_[0]; }
2677 DECLARE_CONCRETE_INSTRUCTION(ClampIToUint8, "clamp-i-to-uint8")
2681 class LClampTToUint8 FINAL : public LTemplateInstruction<1, 1, 1> {
2683 LClampTToUint8(LOperand* value, LOperand* temp_xmm) {
2685 temps_[0] = temp_xmm;
2688 LOperand* unclamped() { return inputs_[0]; }
2689 LOperand* temp_xmm() { return temps_[0]; }
2691 DECLARE_CONCRETE_INSTRUCTION(ClampTToUint8, "clamp-t-to-uint8")
2695 class LCheckNonSmi FINAL : public LTemplateInstruction<0, 1, 0> {
2697 explicit LCheckNonSmi(LOperand* value) {
2701 LOperand* value() { return inputs_[0]; }
2703 DECLARE_CONCRETE_INSTRUCTION(CheckNonSmi, "check-non-smi")
2704 DECLARE_HYDROGEN_ACCESSOR(CheckHeapObject)
2708 class LDoubleBits FINAL : public LTemplateInstruction<1, 1, 0> {
2710 explicit LDoubleBits(LOperand* value) {
2714 LOperand* value() { return inputs_[0]; }
2716 DECLARE_CONCRETE_INSTRUCTION(DoubleBits, "double-bits")
2717 DECLARE_HYDROGEN_ACCESSOR(DoubleBits)
2721 class LConstructDouble FINAL : public LTemplateInstruction<1, 2, 0> {
2723 LConstructDouble(LOperand* hi, LOperand* lo) {
2728 LOperand* hi() { return inputs_[0]; }
2729 LOperand* lo() { return inputs_[1]; }
2731 DECLARE_CONCRETE_INSTRUCTION(ConstructDouble, "construct-double")
2735 class LAllocate FINAL : public LTemplateInstruction<1, 2, 1> {
2737 LAllocate(LOperand* context, LOperand* size, LOperand* temp) {
2738 inputs_[0] = context;
2743 LOperand* context() { return inputs_[0]; }
2744 LOperand* size() { return inputs_[1]; }
2745 LOperand* temp() { return temps_[0]; }
2747 DECLARE_CONCRETE_INSTRUCTION(Allocate, "allocate")
2748 DECLARE_HYDROGEN_ACCESSOR(Allocate)
2752 class LRegExpLiteral FINAL : public LTemplateInstruction<1, 1, 0> {
2754 explicit LRegExpLiteral(LOperand* context) {
2755 inputs_[0] = context;
2758 LOperand* context() { return inputs_[0]; }
2760 DECLARE_CONCRETE_INSTRUCTION(RegExpLiteral, "regexp-literal")
2761 DECLARE_HYDROGEN_ACCESSOR(RegExpLiteral)
2765 class LFunctionLiteral FINAL : public LTemplateInstruction<1, 1, 0> {
2767 explicit LFunctionLiteral(LOperand* context) {
2768 inputs_[0] = context;
2771 LOperand* context() { return inputs_[0]; }
2773 DECLARE_CONCRETE_INSTRUCTION(FunctionLiteral, "function-literal")
2774 DECLARE_HYDROGEN_ACCESSOR(FunctionLiteral)
2778 class LToFastProperties FINAL : public LTemplateInstruction<1, 1, 0> {
2780 explicit LToFastProperties(LOperand* value) {
2784 LOperand* value() { return inputs_[0]; }
2786 DECLARE_CONCRETE_INSTRUCTION(ToFastProperties, "to-fast-properties")
2787 DECLARE_HYDROGEN_ACCESSOR(ToFastProperties)
2791 class LTypeof FINAL : public LTemplateInstruction<1, 2, 0> {
2793 LTypeof(LOperand* context, LOperand* value) {
2794 inputs_[0] = context;
2798 LOperand* context() { return inputs_[0]; }
2799 LOperand* value() { return inputs_[1]; }
2801 DECLARE_CONCRETE_INSTRUCTION(Typeof, "typeof")
2805 class LTypeofIsAndBranch FINAL : public LControlInstruction<1, 0> {
2807 explicit LTypeofIsAndBranch(LOperand* value) {
2811 LOperand* value() { return inputs_[0]; }
2813 DECLARE_CONCRETE_INSTRUCTION(TypeofIsAndBranch, "typeof-is-and-branch")
2814 DECLARE_HYDROGEN_ACCESSOR(TypeofIsAndBranch)
2816 Handle<String> type_literal() { return hydrogen()->type_literal(); }
2818 virtual void PrintDataTo(StringStream* stream) OVERRIDE;
2822 class LOsrEntry FINAL : public LTemplateInstruction<0, 0, 0> {
2824 virtual bool HasInterestingComment(LCodeGen* gen) const OVERRIDE {
2827 DECLARE_CONCRETE_INSTRUCTION(OsrEntry, "osr-entry")
2831 class LStackCheck FINAL : public LTemplateInstruction<0, 1, 0> {
2833 explicit LStackCheck(LOperand* context) {
2834 inputs_[0] = context;
2837 LOperand* context() { return inputs_[0]; }
2839 DECLARE_CONCRETE_INSTRUCTION(StackCheck, "stack-check")
2840 DECLARE_HYDROGEN_ACCESSOR(StackCheck)
2842 Label* done_label() { return &done_label_; }
2849 class LForInPrepareMap FINAL : public LTemplateInstruction<1, 2, 0> {
2851 LForInPrepareMap(LOperand* context, LOperand* object) {
2852 inputs_[0] = context;
2853 inputs_[1] = object;
2856 LOperand* context() { return inputs_[0]; }
2857 LOperand* object() { return inputs_[1]; }
2859 DECLARE_CONCRETE_INSTRUCTION(ForInPrepareMap, "for-in-prepare-map")
2863 class LForInCacheArray FINAL : public LTemplateInstruction<1, 1, 0> {
2865 explicit LForInCacheArray(LOperand* map) {
2869 LOperand* map() { return inputs_[0]; }
2871 DECLARE_CONCRETE_INSTRUCTION(ForInCacheArray, "for-in-cache-array")
2874 return HForInCacheArray::cast(this->hydrogen_value())->idx();
2879 class LCheckMapValue FINAL : public LTemplateInstruction<0, 2, 0> {
2881 LCheckMapValue(LOperand* value, LOperand* map) {
2886 LOperand* value() { return inputs_[0]; }
2887 LOperand* map() { return inputs_[1]; }
2889 DECLARE_CONCRETE_INSTRUCTION(CheckMapValue, "check-map-value")
2893 class LLoadFieldByIndex FINAL : public LTemplateInstruction<1, 2, 0> {
2895 LLoadFieldByIndex(LOperand* object, LOperand* index) {
2896 inputs_[0] = object;
2900 LOperand* object() { return inputs_[0]; }
2901 LOperand* index() { return inputs_[1]; }
2903 DECLARE_CONCRETE_INSTRUCTION(LoadFieldByIndex, "load-field-by-index")
2907 class LStoreFrameContext: public LTemplateInstruction<0, 1, 0> {
2909 explicit LStoreFrameContext(LOperand* context) {
2910 inputs_[0] = context;
2913 LOperand* context() { return inputs_[0]; }
2915 DECLARE_CONCRETE_INSTRUCTION(StoreFrameContext, "store-frame-context")
2919 class LAllocateBlockContext: public LTemplateInstruction<1, 2, 0> {
2921 LAllocateBlockContext(LOperand* context, LOperand* function) {
2922 inputs_[0] = context;
2923 inputs_[1] = function;
2926 LOperand* context() { return inputs_[0]; }
2927 LOperand* function() { return inputs_[1]; }
2929 Handle<ScopeInfo> scope_info() { return hydrogen()->scope_info(); }
2931 DECLARE_CONCRETE_INSTRUCTION(AllocateBlockContext, "allocate-block-context")
2932 DECLARE_HYDROGEN_ACCESSOR(AllocateBlockContext)
2936 class LChunkBuilder;
2937 class LPlatformChunk FINAL : public LChunk {
2939 LPlatformChunk(CompilationInfo* info, HGraph* graph)
2940 : LChunk(info, graph),
2941 num_double_slots_(0) { }
2943 int GetNextSpillIndex(RegisterKind kind);
2944 LOperand* GetNextSpillSlot(RegisterKind kind);
2946 int num_double_slots() const { return num_double_slots_; }
2949 int num_double_slots_;
2953 class LChunkBuilder FINAL : public LChunkBuilderBase {
2955 LChunkBuilder(CompilationInfo* info, HGraph* graph, LAllocator* allocator)
2956 : LChunkBuilderBase(info, graph),
2957 current_instruction_(NULL),
2958 current_block_(NULL),
2960 allocator_(allocator) {}
2962 // Build the sequence for the graph.
2963 LPlatformChunk* Build();
2965 // Declare methods that deal with the individual node types.
2966 #define DECLARE_DO(type) LInstruction* Do##type(H##type* node);
2967 HYDROGEN_CONCRETE_INSTRUCTION_LIST(DECLARE_DO)
2970 LInstruction* DoMathFloor(HUnaryMathOperation* instr);
2971 LInstruction* DoMathRound(HUnaryMathOperation* instr);
2972 LInstruction* DoMathFround(HUnaryMathOperation* instr);
2973 LInstruction* DoMathAbs(HUnaryMathOperation* instr);
2974 LInstruction* DoMathLog(HUnaryMathOperation* instr);
2975 LInstruction* DoMathExp(HUnaryMathOperation* instr);
2976 LInstruction* DoMathSqrt(HUnaryMathOperation* instr);
2977 LInstruction* DoMathPowHalf(HUnaryMathOperation* instr);
2978 LInstruction* DoMathClz32(HUnaryMathOperation* instr);
2979 LInstruction* DoDivByPowerOf2I(HDiv* instr);
2980 LInstruction* DoDivByConstI(HDiv* instr);
2981 LInstruction* DoDivI(HDiv* instr);
2982 LInstruction* DoModByPowerOf2I(HMod* instr);
2983 LInstruction* DoModByConstI(HMod* instr);
2984 LInstruction* DoModI(HMod* instr);
2985 LInstruction* DoFlooringDivByPowerOf2I(HMathFloorOfDiv* instr);
2986 LInstruction* DoFlooringDivByConstI(HMathFloorOfDiv* instr);
2987 LInstruction* DoFlooringDivI(HMathFloorOfDiv* instr);
2990 // Methods for getting operands for Use / Define / Temp.
2991 LUnallocated* ToUnallocated(Register reg);
2992 LUnallocated* ToUnallocated(XMMRegister reg);
2994 // Methods for setting up define-use relationships.
2995 MUST_USE_RESULT LOperand* Use(HValue* value, LUnallocated* operand);
2996 MUST_USE_RESULT LOperand* UseFixed(HValue* value, Register fixed_register);
2997 MUST_USE_RESULT LOperand* UseFixedDouble(HValue* value,
2998 XMMRegister fixed_register);
3000 // A value that is guaranteed to be allocated to a register.
3001 // Operand created by UseRegister is guaranteed to be live until the end of
3002 // instruction. This means that register allocator will not reuse it's
3003 // register for any other operand inside instruction.
3004 // Operand created by UseRegisterAtStart is guaranteed to be live only at
3005 // instruction start. Register allocator is free to assign the same register
3006 // to some other operand used inside instruction (i.e. temporary or
3008 MUST_USE_RESULT LOperand* UseRegister(HValue* value);
3009 MUST_USE_RESULT LOperand* UseRegisterAtStart(HValue* value);
3011 // An input operand in a register that may be trashed.
3012 MUST_USE_RESULT LOperand* UseTempRegister(HValue* value);
3014 // An input operand in a register or stack slot.
3015 MUST_USE_RESULT LOperand* Use(HValue* value);
3016 MUST_USE_RESULT LOperand* UseAtStart(HValue* value);
3018 // An input operand in a register, stack slot or a constant operand.
3019 MUST_USE_RESULT LOperand* UseOrConstant(HValue* value);
3020 MUST_USE_RESULT LOperand* UseOrConstantAtStart(HValue* value);
3022 // An input operand in a fixed register or a constant operand.
3023 MUST_USE_RESULT LOperand* UseFixedOrConstant(HValue* value,
3024 Register fixed_register);
3026 // An input operand in a register or a constant operand.
3027 MUST_USE_RESULT LOperand* UseRegisterOrConstant(HValue* value);
3028 MUST_USE_RESULT LOperand* UseRegisterOrConstantAtStart(HValue* value);
3030 // An input operand in a constant operand.
3031 MUST_USE_RESULT LOperand* UseConstant(HValue* value);
3033 // An input operand in register, stack slot or a constant operand.
3034 // Will not be moved to a register even if one is freely available.
3035 virtual MUST_USE_RESULT LOperand* UseAny(HValue* value) OVERRIDE;
3037 // Temporary operand that must be in a register.
3038 MUST_USE_RESULT LUnallocated* TempRegister();
3039 MUST_USE_RESULT LOperand* FixedTemp(Register reg);
3040 MUST_USE_RESULT LOperand* FixedTemp(XMMRegister reg);
3042 // Methods for setting up define-use relationships.
3043 // Return the same instruction that they are passed.
3044 LInstruction* Define(LTemplateResultInstruction<1>* instr,
3045 LUnallocated* result);
3046 LInstruction* DefineAsRegister(LTemplateResultInstruction<1>* instr);
3047 LInstruction* DefineAsSpilled(LTemplateResultInstruction<1>* instr,
3049 LInstruction* DefineSameAsFirst(LTemplateResultInstruction<1>* instr);
3050 LInstruction* DefineFixed(LTemplateResultInstruction<1>* instr,
3052 LInstruction* DefineFixedDouble(LTemplateResultInstruction<1>* instr,
3054 // Assigns an environment to an instruction. An instruction which can
3055 // deoptimize must have an environment.
3056 LInstruction* AssignEnvironment(LInstruction* instr);
3057 // Assigns a pointer map to an instruction. An instruction which can
3058 // trigger a GC or a lazy deoptimization must have a pointer map.
3059 LInstruction* AssignPointerMap(LInstruction* instr);
3061 enum CanDeoptimize { CAN_DEOPTIMIZE_EAGERLY, CANNOT_DEOPTIMIZE_EAGERLY };
3063 LOperand* GetSeqStringSetCharOperand(HSeqStringSetChar* instr);
3065 // Marks a call for the register allocator. Assigns a pointer map to
3066 // support GC and lazy deoptimization. Assigns an environment to support
3067 // eager deoptimization if CAN_DEOPTIMIZE_EAGERLY.
3068 LInstruction* MarkAsCall(
3069 LInstruction* instr,
3070 HInstruction* hinstr,
3071 CanDeoptimize can_deoptimize = CANNOT_DEOPTIMIZE_EAGERLY);
3073 void VisitInstruction(HInstruction* current);
3074 void AddInstruction(LInstruction* instr, HInstruction* current);
3076 void DoBasicBlock(HBasicBlock* block, HBasicBlock* next_block);
3077 LInstruction* DoShift(Token::Value op, HBitwiseBinaryOperation* instr);
3078 LInstruction* DoArithmeticD(Token::Value op,
3079 HArithmeticBinaryOperation* instr);
3080 LInstruction* DoArithmeticT(Token::Value op,
3081 HBinaryOperation* instr);
3083 LOperand* GetStoreKeyedValueOperand(HStoreKeyed* instr);
3085 HInstruction* current_instruction_;
3086 HBasicBlock* current_block_;
3087 HBasicBlock* next_block_;
3088 LAllocator* allocator_;
3090 DISALLOW_COPY_AND_ASSIGN(LChunkBuilder);
3093 #undef DECLARE_HYDROGEN_ACCESSOR
3094 #undef DECLARE_CONCRETE_INSTRUCTION
3096 } } // namespace v8::internal
3098 #endif // V8_IA32_LITHIUM_IA32_H_