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_X64_LITHIUM_X64_H_
6 #define V8_X64_LITHIUM_X64_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"
17 // Forward declarations.
20 #define LITHIUM_CONCRETE_INSTRUCTION_LIST(V) \
21 V(AccessArgumentsAt) \
24 V(AllocateBlockContext) \
26 V(ArgumentsElements) \
34 V(CallWithDescriptor) \
40 V(CheckInstanceType) \
49 V(ClassOfTestAndBranch) \
50 V(CompareMinusZeroAndBranch) \
51 V(CompareNumericAndBranch) \
52 V(CmpObjectEqAndBranch) \
76 V(FlooringDivByConstI) \
77 V(FlooringDivByPowerOf2I) \
82 V(GetCachedArrayIndex) \
84 V(HasCachedArrayIndexAndBranch) \
85 V(HasInstanceTypeAndBranch) \
86 V(InnerAllocatedObject) \
88 V(InstanceOfKnownGlobal) \
90 V(Integer32ToDouble) \
92 V(IsConstructCallAndBranch) \
93 V(IsObjectAndBranch) \
94 V(IsStringAndBranch) \
96 V(IsUndetectableAndBranch) \
101 V(LoadFieldByIndex) \
102 V(LoadFunctionPrototype) \
103 V(LoadGlobalGeneric) \
105 V(LoadKeyedGeneric) \
107 V(LoadNamedGeneric) \
133 V(SeqStringGetChar) \
134 V(SeqStringSetChar) \
140 V(StoreContextSlot) \
141 V(StoreFrameContext) \
143 V(StoreKeyedGeneric) \
145 V(StoreNamedGeneric) \
147 V(StringCharCodeAt) \
148 V(StringCharFromCode) \
149 V(StringCompareAndBranch) \
152 V(TailCallThroughMegamorphicCache) \
154 V(ToFastProperties) \
155 V(TransitionElementsKind) \
156 V(TrapAllocationMemento) \
158 V(TypeofIsAndBranch) \
164 #define DECLARE_CONCRETE_INSTRUCTION(type, mnemonic) \
165 Opcode opcode() const FINAL { return LInstruction::k##type; } \
166 void CompileToNative(LCodeGen* generator) FINAL; \
167 const char* Mnemonic() const FINAL { return mnemonic; } \
168 static L##type* cast(LInstruction* instr) { \
169 DCHECK(instr->Is##type()); \
170 return reinterpret_cast<L##type*>(instr); \
174 #define DECLARE_HYDROGEN_ACCESSOR(type) \
175 H##type* hydrogen() const { \
176 return H##type::cast(hydrogen_value()); \
180 class LInstruction : public ZoneObject {
183 : environment_(NULL),
184 hydrogen_value_(NULL),
185 bit_field_(IsCallBits::encode(false)) {
188 virtual ~LInstruction() {}
190 virtual void CompileToNative(LCodeGen* generator) = 0;
191 virtual const char* Mnemonic() const = 0;
192 virtual void PrintTo(StringStream* stream);
193 virtual void PrintDataTo(StringStream* stream);
194 virtual void PrintOutputOperandTo(StringStream* stream);
197 // Declare a unique enum value for each instruction.
198 #define DECLARE_OPCODE(type) k##type,
199 LITHIUM_CONCRETE_INSTRUCTION_LIST(DECLARE_OPCODE)
200 kNumberOfInstructions
201 #undef DECLARE_OPCODE
204 virtual Opcode opcode() const = 0;
206 // Declare non-virtual type testers for all leaf IR classes.
207 #define DECLARE_PREDICATE(type) \
208 bool Is##type() const { return opcode() == k##type; }
209 LITHIUM_CONCRETE_INSTRUCTION_LIST(DECLARE_PREDICATE)
210 #undef DECLARE_PREDICATE
212 // Declare virtual predicates for instructions that don't have
214 virtual bool IsGap() const { return false; }
216 virtual bool IsControl() const { return false; }
218 // Try deleting this instruction if possible.
219 virtual bool TryDelete() { return false; }
221 void set_environment(LEnvironment* env) { environment_ = env; }
222 LEnvironment* environment() const { return environment_; }
223 bool HasEnvironment() const { return environment_ != NULL; }
225 void set_pointer_map(LPointerMap* p) { pointer_map_.set(p); }
226 LPointerMap* pointer_map() const { return pointer_map_.get(); }
227 bool HasPointerMap() const { return pointer_map_.is_set(); }
229 void set_hydrogen_value(HValue* value) { hydrogen_value_ = value; }
230 HValue* hydrogen_value() const { return hydrogen_value_; }
232 void MarkAsCall() { bit_field_ = IsCallBits::update(bit_field_, true); }
233 bool IsCall() const { return IsCallBits::decode(bit_field_); }
235 // Interface to the register allocator and iterators.
236 bool ClobbersTemps() const { return IsCall(); }
237 bool ClobbersRegisters() const { return IsCall(); }
238 virtual bool ClobbersDoubleRegisters(Isolate* isolate) const {
242 virtual void SetDeferredLazyDeoptimizationEnvironment(LEnvironment* env) { }
244 // Interface to the register allocator and iterators.
245 bool IsMarkedAsCall() const { return IsCall(); }
247 virtual bool HasResult() const = 0;
248 virtual LOperand* result() const = 0;
250 LOperand* FirstInput() { return InputAt(0); }
251 LOperand* Output() { return HasResult() ? result() : NULL; }
253 virtual bool HasInterestingComment(LCodeGen* gen) const { return true; }
255 virtual bool MustSignExtendResult(LPlatformChunk* chunk) const {
263 virtual int InputCount() = 0;
264 virtual LOperand* InputAt(int i) = 0;
268 friend class InputIterator;
270 friend class TempIterator;
271 virtual int TempCount() = 0;
272 virtual LOperand* TempAt(int i) = 0;
274 class IsCallBits: public BitField<bool, 0, 1> {};
276 LEnvironment* environment_;
277 SetOncePointer<LPointerMap> pointer_map_;
278 HValue* hydrogen_value_;
283 // R = number of result operands (0 or 1).
285 class LTemplateResultInstruction : public LInstruction {
287 // Allow 0 or 1 output operands.
288 STATIC_ASSERT(R == 0 || R == 1);
289 bool HasResult() const FINAL { return R != 0 && result() != NULL; }
290 void set_result(LOperand* operand) { results_[0] = operand; }
291 LOperand* result() const OVERRIDE { return results_[0]; }
293 bool MustSignExtendResult(LPlatformChunk* chunk) const FINAL;
296 EmbeddedContainer<LOperand*, R> results_;
300 // R = number of result operands (0 or 1).
301 // I = number of input operands.
302 // T = number of temporary operands.
303 template<int R, int I, int T>
304 class LTemplateInstruction : public LTemplateResultInstruction<R> {
306 EmbeddedContainer<LOperand*, I> inputs_;
307 EmbeddedContainer<LOperand*, T> temps_;
311 int InputCount() FINAL { return I; }
312 LOperand* InputAt(int i) FINAL { return inputs_[i]; }
314 int TempCount() FINAL { return T; }
315 LOperand* TempAt(int i) FINAL { return temps_[i]; }
319 class LGap : public LTemplateInstruction<0, 0, 0> {
321 explicit LGap(HBasicBlock* block)
323 parallel_moves_[BEFORE] = NULL;
324 parallel_moves_[START] = NULL;
325 parallel_moves_[END] = NULL;
326 parallel_moves_[AFTER] = NULL;
329 // Can't use the DECLARE-macro here because of sub-classes.
330 bool IsGap() const FINAL { return true; }
331 void PrintDataTo(StringStream* stream) OVERRIDE;
332 static LGap* cast(LInstruction* instr) {
333 DCHECK(instr->IsGap());
334 return reinterpret_cast<LGap*>(instr);
337 bool IsRedundant() const;
339 HBasicBlock* block() const { return block_; }
346 FIRST_INNER_POSITION = BEFORE,
347 LAST_INNER_POSITION = AFTER
350 LParallelMove* GetOrCreateParallelMove(InnerPosition pos,
352 if (parallel_moves_[pos] == NULL) {
353 parallel_moves_[pos] = new(zone) LParallelMove(zone);
355 return parallel_moves_[pos];
358 LParallelMove* GetParallelMove(InnerPosition pos) {
359 return parallel_moves_[pos];
363 LParallelMove* parallel_moves_[LAST_INNER_POSITION + 1];
368 class LInstructionGap FINAL : public LGap {
370 explicit LInstructionGap(HBasicBlock* block) : LGap(block) { }
372 bool HasInterestingComment(LCodeGen* gen) const OVERRIDE {
373 return !IsRedundant();
376 DECLARE_CONCRETE_INSTRUCTION(InstructionGap, "gap")
380 class LGoto FINAL : public LTemplateInstruction<0, 0, 0> {
382 explicit LGoto(HBasicBlock* block) : block_(block) { }
384 bool HasInterestingComment(LCodeGen* gen) const OVERRIDE;
385 DECLARE_CONCRETE_INSTRUCTION(Goto, "goto")
386 void PrintDataTo(StringStream* stream) OVERRIDE;
387 bool IsControl() const OVERRIDE { return true; }
389 int block_id() const { return block_->block_id(); }
396 class LLazyBailout FINAL : public LTemplateInstruction<0, 0, 0> {
398 LLazyBailout() : gap_instructions_size_(0) { }
400 DECLARE_CONCRETE_INSTRUCTION(LazyBailout, "lazy-bailout")
402 void set_gap_instructions_size(int gap_instructions_size) {
403 gap_instructions_size_ = gap_instructions_size;
405 int gap_instructions_size() { return gap_instructions_size_; }
408 int gap_instructions_size_;
412 class LDummy FINAL : public LTemplateInstruction<1, 0, 0> {
415 DECLARE_CONCRETE_INSTRUCTION(Dummy, "dummy")
419 class LDummyUse FINAL : public LTemplateInstruction<1, 1, 0> {
421 explicit LDummyUse(LOperand* value) {
424 DECLARE_CONCRETE_INSTRUCTION(DummyUse, "dummy-use")
428 class LDeoptimize FINAL : public LTemplateInstruction<0, 0, 0> {
430 bool IsControl() const OVERRIDE { return true; }
431 DECLARE_CONCRETE_INSTRUCTION(Deoptimize, "deoptimize")
432 DECLARE_HYDROGEN_ACCESSOR(Deoptimize)
436 class LLabel FINAL : public LGap {
438 explicit LLabel(HBasicBlock* block)
439 : LGap(block), replacement_(NULL) { }
441 bool HasInterestingComment(LCodeGen* gen) const OVERRIDE { return false; }
442 DECLARE_CONCRETE_INSTRUCTION(Label, "label")
444 void PrintDataTo(StringStream* stream) OVERRIDE;
446 int block_id() const { return block()->block_id(); }
447 bool is_loop_header() const { return block()->IsLoopHeader(); }
448 bool is_osr_entry() const { return block()->is_osr_entry(); }
449 Label* label() { return &label_; }
450 LLabel* replacement() const { return replacement_; }
451 void set_replacement(LLabel* label) { replacement_ = label; }
452 bool HasReplacement() const { return replacement_ != NULL; }
456 LLabel* replacement_;
460 class LParameter FINAL : public LTemplateInstruction<1, 0, 0> {
462 bool HasInterestingComment(LCodeGen* gen) const OVERRIDE { return false; }
463 DECLARE_CONCRETE_INSTRUCTION(Parameter, "parameter")
467 class LCallStub FINAL : public LTemplateInstruction<1, 1, 0> {
469 explicit LCallStub(LOperand* context) {
470 inputs_[0] = context;
473 LOperand* context() { return inputs_[0]; }
475 DECLARE_CONCRETE_INSTRUCTION(CallStub, "call-stub")
476 DECLARE_HYDROGEN_ACCESSOR(CallStub)
480 class LTailCallThroughMegamorphicCache FINAL
481 : public LTemplateInstruction<0, 5, 0> {
483 explicit LTailCallThroughMegamorphicCache(LOperand* context,
484 LOperand* receiver, LOperand* name,
485 LOperand* slot, LOperand* vector) {
486 inputs_[0] = context;
487 inputs_[1] = receiver;
493 LOperand* context() { return inputs_[0]; }
494 LOperand* receiver() { return inputs_[1]; }
495 LOperand* name() { return inputs_[2]; }
496 LOperand* slot() { return inputs_[3]; }
497 LOperand* vector() { return inputs_[4]; }
499 DECLARE_CONCRETE_INSTRUCTION(TailCallThroughMegamorphicCache,
500 "tail-call-through-megamorphic-cache")
501 DECLARE_HYDROGEN_ACCESSOR(TailCallThroughMegamorphicCache)
505 class LUnknownOSRValue FINAL : public LTemplateInstruction<1, 0, 0> {
507 bool HasInterestingComment(LCodeGen* gen) const OVERRIDE { return false; }
508 DECLARE_CONCRETE_INSTRUCTION(UnknownOSRValue, "unknown-osr-value")
512 template<int I, int T>
513 class LControlInstruction : public LTemplateInstruction<0, I, T> {
515 LControlInstruction() : false_label_(NULL), true_label_(NULL) { }
517 bool IsControl() const FINAL { return true; }
519 int SuccessorCount() { return hydrogen()->SuccessorCount(); }
520 HBasicBlock* SuccessorAt(int i) { return hydrogen()->SuccessorAt(i); }
522 int TrueDestination(LChunk* chunk) {
523 return chunk->LookupDestination(true_block_id());
525 int FalseDestination(LChunk* chunk) {
526 return chunk->LookupDestination(false_block_id());
529 Label* TrueLabel(LChunk* chunk) {
530 if (true_label_ == NULL) {
531 true_label_ = chunk->GetAssemblyLabel(TrueDestination(chunk));
535 Label* FalseLabel(LChunk* chunk) {
536 if (false_label_ == NULL) {
537 false_label_ = chunk->GetAssemblyLabel(FalseDestination(chunk));
543 int true_block_id() { return SuccessorAt(0)->block_id(); }
544 int false_block_id() { return SuccessorAt(1)->block_id(); }
547 HControlInstruction* hydrogen() {
548 return HControlInstruction::cast(this->hydrogen_value());
556 class LWrapReceiver FINAL : public LTemplateInstruction<1, 2, 0> {
558 LWrapReceiver(LOperand* receiver, LOperand* function) {
559 inputs_[0] = receiver;
560 inputs_[1] = function;
563 LOperand* receiver() { return inputs_[0]; }
564 LOperand* function() { return inputs_[1]; }
566 DECLARE_CONCRETE_INSTRUCTION(WrapReceiver, "wrap-receiver")
567 DECLARE_HYDROGEN_ACCESSOR(WrapReceiver)
571 class LApplyArguments FINAL : public LTemplateInstruction<1, 4, 0> {
573 LApplyArguments(LOperand* function,
576 LOperand* elements) {
577 inputs_[0] = function;
578 inputs_[1] = receiver;
580 inputs_[3] = elements;
583 LOperand* function() { return inputs_[0]; }
584 LOperand* receiver() { return inputs_[1]; }
585 LOperand* length() { return inputs_[2]; }
586 LOperand* elements() { return inputs_[3]; }
588 DECLARE_CONCRETE_INSTRUCTION(ApplyArguments, "apply-arguments")
592 class LAccessArgumentsAt FINAL : public LTemplateInstruction<1, 3, 0> {
594 LAccessArgumentsAt(LOperand* arguments, LOperand* length, LOperand* index) {
595 inputs_[0] = arguments;
600 LOperand* arguments() { return inputs_[0]; }
601 LOperand* length() { return inputs_[1]; }
602 LOperand* index() { return inputs_[2]; }
604 DECLARE_CONCRETE_INSTRUCTION(AccessArgumentsAt, "access-arguments-at")
606 void PrintDataTo(StringStream* stream) OVERRIDE;
610 class LArgumentsLength FINAL : public LTemplateInstruction<1, 1, 0> {
612 explicit LArgumentsLength(LOperand* elements) {
613 inputs_[0] = elements;
616 LOperand* elements() { return inputs_[0]; }
618 DECLARE_CONCRETE_INSTRUCTION(ArgumentsLength, "arguments-length")
622 class LArgumentsElements FINAL : public LTemplateInstruction<1, 0, 0> {
624 DECLARE_CONCRETE_INSTRUCTION(ArgumentsElements, "arguments-elements")
625 DECLARE_HYDROGEN_ACCESSOR(ArgumentsElements)
629 class LModByPowerOf2I FINAL : public LTemplateInstruction<1, 1, 0> {
631 LModByPowerOf2I(LOperand* dividend, int32_t divisor) {
632 inputs_[0] = dividend;
636 LOperand* dividend() { return inputs_[0]; }
637 int32_t divisor() const { return divisor_; }
639 DECLARE_CONCRETE_INSTRUCTION(ModByPowerOf2I, "mod-by-power-of-2-i")
640 DECLARE_HYDROGEN_ACCESSOR(Mod)
647 class LModByConstI FINAL : public LTemplateInstruction<1, 1, 2> {
649 LModByConstI(LOperand* dividend,
653 inputs_[0] = dividend;
659 LOperand* dividend() { return inputs_[0]; }
660 int32_t divisor() const { return divisor_; }
661 LOperand* temp1() { return temps_[0]; }
662 LOperand* temp2() { return temps_[1]; }
664 DECLARE_CONCRETE_INSTRUCTION(ModByConstI, "mod-by-const-i")
665 DECLARE_HYDROGEN_ACCESSOR(Mod)
672 class LModI FINAL : public LTemplateInstruction<1, 2, 1> {
674 LModI(LOperand* left, LOperand* right, LOperand* temp) {
680 LOperand* left() { return inputs_[0]; }
681 LOperand* right() { return inputs_[1]; }
682 LOperand* temp() { return temps_[0]; }
684 DECLARE_CONCRETE_INSTRUCTION(ModI, "mod-i")
685 DECLARE_HYDROGEN_ACCESSOR(Mod)
689 class LDivByPowerOf2I FINAL : public LTemplateInstruction<1, 1, 0> {
691 LDivByPowerOf2I(LOperand* dividend, int32_t divisor) {
692 inputs_[0] = dividend;
696 LOperand* dividend() { return inputs_[0]; }
697 int32_t divisor() const { return divisor_; }
699 DECLARE_CONCRETE_INSTRUCTION(DivByPowerOf2I, "div-by-power-of-2-i")
700 DECLARE_HYDROGEN_ACCESSOR(Div)
707 class LDivByConstI FINAL : public LTemplateInstruction<1, 1, 2> {
709 LDivByConstI(LOperand* dividend,
713 inputs_[0] = dividend;
719 LOperand* dividend() { return inputs_[0]; }
720 int32_t divisor() const { return divisor_; }
721 LOperand* temp1() { return temps_[0]; }
722 LOperand* temp2() { return temps_[1]; }
724 DECLARE_CONCRETE_INSTRUCTION(DivByConstI, "div-by-const-i")
725 DECLARE_HYDROGEN_ACCESSOR(Div)
732 class LDivI FINAL : public LTemplateInstruction<1, 2, 1> {
734 LDivI(LOperand* dividend, LOperand* divisor, LOperand* temp) {
735 inputs_[0] = dividend;
736 inputs_[1] = divisor;
740 LOperand* dividend() { return inputs_[0]; }
741 LOperand* divisor() { return inputs_[1]; }
742 LOperand* temp() { return temps_[0]; }
744 DECLARE_CONCRETE_INSTRUCTION(DivI, "div-i")
745 DECLARE_HYDROGEN_ACCESSOR(BinaryOperation)
749 class LFlooringDivByPowerOf2I FINAL : public LTemplateInstruction<1, 1, 0> {
751 LFlooringDivByPowerOf2I(LOperand* dividend, int32_t divisor) {
752 inputs_[0] = dividend;
756 LOperand* dividend() { return inputs_[0]; }
757 int32_t divisor() const { return divisor_; }
759 DECLARE_CONCRETE_INSTRUCTION(FlooringDivByPowerOf2I,
760 "flooring-div-by-power-of-2-i")
761 DECLARE_HYDROGEN_ACCESSOR(MathFloorOfDiv)
768 class LFlooringDivByConstI FINAL : public LTemplateInstruction<1, 1, 3> {
770 LFlooringDivByConstI(LOperand* dividend,
775 inputs_[0] = dividend;
782 LOperand* dividend() { return inputs_[0]; }
783 int32_t divisor() const { return divisor_; }
784 LOperand* temp1() { return temps_[0]; }
785 LOperand* temp2() { return temps_[1]; }
786 LOperand* temp3() { return temps_[2]; }
788 DECLARE_CONCRETE_INSTRUCTION(FlooringDivByConstI, "flooring-div-by-const-i")
789 DECLARE_HYDROGEN_ACCESSOR(MathFloorOfDiv)
796 class LFlooringDivI FINAL : public LTemplateInstruction<1, 2, 1> {
798 LFlooringDivI(LOperand* dividend, LOperand* divisor, LOperand* temp) {
799 inputs_[0] = dividend;
800 inputs_[1] = divisor;
804 LOperand* dividend() { return inputs_[0]; }
805 LOperand* divisor() { return inputs_[1]; }
806 LOperand* temp() { return temps_[0]; }
808 DECLARE_CONCRETE_INSTRUCTION(FlooringDivI, "flooring-div-i")
809 DECLARE_HYDROGEN_ACCESSOR(MathFloorOfDiv)
813 class LMulI FINAL : public LTemplateInstruction<1, 2, 0> {
815 LMulI(LOperand* left, LOperand* right) {
820 LOperand* left() { return inputs_[0]; }
821 LOperand* right() { return inputs_[1]; }
823 DECLARE_CONCRETE_INSTRUCTION(MulI, "mul-i")
824 DECLARE_HYDROGEN_ACCESSOR(Mul)
828 class LCompareNumericAndBranch FINAL : public LControlInstruction<2, 0> {
830 LCompareNumericAndBranch(LOperand* left, LOperand* right) {
835 LOperand* left() { return inputs_[0]; }
836 LOperand* right() { return inputs_[1]; }
838 DECLARE_CONCRETE_INSTRUCTION(CompareNumericAndBranch,
839 "compare-numeric-and-branch")
840 DECLARE_HYDROGEN_ACCESSOR(CompareNumericAndBranch)
842 Token::Value op() const { return hydrogen()->token(); }
843 bool is_double() const {
844 return hydrogen()->representation().IsDouble();
847 void PrintDataTo(StringStream* stream) OVERRIDE;
851 class LMathFloor FINAL : public LTemplateInstruction<1, 1, 0> {
853 explicit LMathFloor(LOperand* value) {
857 LOperand* value() { return inputs_[0]; }
859 DECLARE_CONCRETE_INSTRUCTION(MathFloor, "math-floor")
860 DECLARE_HYDROGEN_ACCESSOR(UnaryMathOperation)
864 class LMathRound FINAL : public LTemplateInstruction<1, 1, 1> {
866 LMathRound(LOperand* value, LOperand* temp) {
871 LOperand* value() { return inputs_[0]; }
872 LOperand* temp() { return temps_[0]; }
874 DECLARE_CONCRETE_INSTRUCTION(MathRound, "math-round")
875 DECLARE_HYDROGEN_ACCESSOR(UnaryMathOperation)
879 class LMathFround FINAL : public LTemplateInstruction<1, 1, 0> {
881 explicit LMathFround(LOperand* value) { inputs_[0] = value; }
883 LOperand* value() { return inputs_[0]; }
885 DECLARE_CONCRETE_INSTRUCTION(MathFround, "math-fround")
889 class LMathAbs FINAL : public LTemplateInstruction<1, 2, 0> {
891 explicit LMathAbs(LOperand* context, LOperand* value) {
892 inputs_[1] = context;
896 LOperand* context() { return inputs_[1]; }
897 LOperand* value() { return inputs_[0]; }
899 DECLARE_CONCRETE_INSTRUCTION(MathAbs, "math-abs")
900 DECLARE_HYDROGEN_ACCESSOR(UnaryMathOperation)
904 class LMathLog FINAL : public LTemplateInstruction<1, 1, 0> {
906 explicit LMathLog(LOperand* value) {
910 LOperand* value() { return inputs_[0]; }
912 DECLARE_CONCRETE_INSTRUCTION(MathLog, "math-log")
916 class LMathClz32 FINAL : public LTemplateInstruction<1, 1, 0> {
918 explicit LMathClz32(LOperand* value) {
922 LOperand* value() { return inputs_[0]; }
924 DECLARE_CONCRETE_INSTRUCTION(MathClz32, "math-clz32")
928 class LMathExp FINAL : public LTemplateInstruction<1, 1, 2> {
930 LMathExp(LOperand* value, LOperand* temp1, LOperand* temp2) {
934 ExternalReference::InitializeMathExpData();
937 LOperand* value() { return inputs_[0]; }
938 LOperand* temp1() { return temps_[0]; }
939 LOperand* temp2() { return temps_[1]; }
941 DECLARE_CONCRETE_INSTRUCTION(MathExp, "math-exp")
945 class LMathSqrt FINAL : public LTemplateInstruction<1, 1, 0> {
947 explicit LMathSqrt(LOperand* value) {
951 LOperand* value() { return inputs_[0]; }
953 DECLARE_CONCRETE_INSTRUCTION(MathSqrt, "math-sqrt")
957 class LMathPowHalf FINAL : public LTemplateInstruction<1, 1, 0> {
959 explicit LMathPowHalf(LOperand* value) {
963 LOperand* value() { return inputs_[0]; }
965 DECLARE_CONCRETE_INSTRUCTION(MathPowHalf, "math-pow-half")
969 class LCmpObjectEqAndBranch FINAL : public LControlInstruction<2, 0> {
971 LCmpObjectEqAndBranch(LOperand* left, LOperand* right) {
976 LOperand* left() { return inputs_[0]; }
977 LOperand* right() { return inputs_[1]; }
979 DECLARE_CONCRETE_INSTRUCTION(CmpObjectEqAndBranch, "cmp-object-eq-and-branch")
983 class LCmpHoleAndBranch FINAL : public LControlInstruction<1, 0> {
985 explicit LCmpHoleAndBranch(LOperand* object) {
989 LOperand* object() { return inputs_[0]; }
991 DECLARE_CONCRETE_INSTRUCTION(CmpHoleAndBranch, "cmp-hole-and-branch")
992 DECLARE_HYDROGEN_ACCESSOR(CompareHoleAndBranch)
996 class LCompareMinusZeroAndBranch FINAL : public LControlInstruction<1, 0> {
998 explicit LCompareMinusZeroAndBranch(LOperand* value) {
1002 LOperand* value() { return inputs_[0]; }
1004 DECLARE_CONCRETE_INSTRUCTION(CompareMinusZeroAndBranch,
1005 "cmp-minus-zero-and-branch")
1006 DECLARE_HYDROGEN_ACCESSOR(CompareMinusZeroAndBranch)
1011 class LIsObjectAndBranch FINAL : public LControlInstruction<1, 0> {
1013 explicit LIsObjectAndBranch(LOperand* value) {
1017 LOperand* value() { return inputs_[0]; }
1019 DECLARE_CONCRETE_INSTRUCTION(IsObjectAndBranch, "is-object-and-branch")
1020 DECLARE_HYDROGEN_ACCESSOR(IsObjectAndBranch)
1022 void PrintDataTo(StringStream* stream) OVERRIDE;
1026 class LIsStringAndBranch FINAL : public LControlInstruction<1, 1> {
1028 explicit LIsStringAndBranch(LOperand* value, LOperand* temp) {
1033 LOperand* value() { return inputs_[0]; }
1034 LOperand* temp() { return temps_[0]; }
1036 DECLARE_CONCRETE_INSTRUCTION(IsStringAndBranch, "is-string-and-branch")
1037 DECLARE_HYDROGEN_ACCESSOR(IsStringAndBranch)
1039 void PrintDataTo(StringStream* stream) OVERRIDE;
1043 class LIsSmiAndBranch FINAL : public LControlInstruction<1, 0> {
1045 explicit LIsSmiAndBranch(LOperand* value) {
1049 LOperand* value() { return inputs_[0]; }
1051 DECLARE_CONCRETE_INSTRUCTION(IsSmiAndBranch, "is-smi-and-branch")
1052 DECLARE_HYDROGEN_ACCESSOR(IsSmiAndBranch)
1054 void PrintDataTo(StringStream* stream) OVERRIDE;
1058 class LIsUndetectableAndBranch FINAL : public LControlInstruction<1, 1> {
1060 explicit LIsUndetectableAndBranch(LOperand* value, LOperand* temp) {
1065 LOperand* value() { return inputs_[0]; }
1066 LOperand* temp() { return temps_[0]; }
1068 DECLARE_CONCRETE_INSTRUCTION(IsUndetectableAndBranch,
1069 "is-undetectable-and-branch")
1070 DECLARE_HYDROGEN_ACCESSOR(IsUndetectableAndBranch)
1072 void PrintDataTo(StringStream* stream) OVERRIDE;
1076 class LStringCompareAndBranch FINAL : public LControlInstruction<3, 0> {
1078 explicit LStringCompareAndBranch(LOperand* context,
1081 inputs_[0] = context;
1086 LOperand* context() { return inputs_[0]; }
1087 LOperand* left() { return inputs_[1]; }
1088 LOperand* right() { return inputs_[2]; }
1090 DECLARE_CONCRETE_INSTRUCTION(StringCompareAndBranch,
1091 "string-compare-and-branch")
1092 DECLARE_HYDROGEN_ACCESSOR(StringCompareAndBranch)
1094 void PrintDataTo(StringStream* stream) OVERRIDE;
1096 Token::Value op() const { return hydrogen()->token(); }
1100 class LHasInstanceTypeAndBranch FINAL : public LControlInstruction<1, 0> {
1102 explicit LHasInstanceTypeAndBranch(LOperand* value) {
1106 LOperand* value() { return inputs_[0]; }
1108 DECLARE_CONCRETE_INSTRUCTION(HasInstanceTypeAndBranch,
1109 "has-instance-type-and-branch")
1110 DECLARE_HYDROGEN_ACCESSOR(HasInstanceTypeAndBranch)
1112 void PrintDataTo(StringStream* stream) OVERRIDE;
1116 class LGetCachedArrayIndex FINAL : public LTemplateInstruction<1, 1, 0> {
1118 explicit LGetCachedArrayIndex(LOperand* value) {
1122 LOperand* value() { return inputs_[0]; }
1124 DECLARE_CONCRETE_INSTRUCTION(GetCachedArrayIndex, "get-cached-array-index")
1125 DECLARE_HYDROGEN_ACCESSOR(GetCachedArrayIndex)
1129 class LHasCachedArrayIndexAndBranch FINAL
1130 : public LControlInstruction<1, 0> {
1132 explicit LHasCachedArrayIndexAndBranch(LOperand* value) {
1136 LOperand* value() { return inputs_[0]; }
1138 DECLARE_CONCRETE_INSTRUCTION(HasCachedArrayIndexAndBranch,
1139 "has-cached-array-index-and-branch")
1140 DECLARE_HYDROGEN_ACCESSOR(HasCachedArrayIndexAndBranch)
1142 void PrintDataTo(StringStream* stream) OVERRIDE;
1146 class LClassOfTestAndBranch FINAL : public LControlInstruction<1, 2> {
1148 LClassOfTestAndBranch(LOperand* value, LOperand* temp, LOperand* temp2) {
1154 LOperand* value() { return inputs_[0]; }
1155 LOperand* temp() { return temps_[0]; }
1156 LOperand* temp2() { return temps_[1]; }
1158 DECLARE_CONCRETE_INSTRUCTION(ClassOfTestAndBranch,
1159 "class-of-test-and-branch")
1160 DECLARE_HYDROGEN_ACCESSOR(ClassOfTestAndBranch)
1162 void PrintDataTo(StringStream* stream) OVERRIDE;
1166 class LCmpT FINAL : public LTemplateInstruction<1, 3, 0> {
1168 LCmpT(LOperand* context, LOperand* left, LOperand* right) {
1169 inputs_[0] = context;
1174 LOperand* context() { return inputs_[0]; }
1175 LOperand* left() { return inputs_[1]; }
1176 LOperand* right() { return inputs_[2]; }
1178 DECLARE_CONCRETE_INSTRUCTION(CmpT, "cmp-t")
1179 DECLARE_HYDROGEN_ACCESSOR(CompareGeneric)
1181 Token::Value op() const { return hydrogen()->token(); }
1185 class LInstanceOf FINAL : public LTemplateInstruction<1, 3, 0> {
1187 LInstanceOf(LOperand* context, LOperand* left, LOperand* right) {
1188 inputs_[0] = context;
1193 LOperand* context() { return inputs_[0]; }
1194 LOperand* left() { return inputs_[1]; }
1195 LOperand* right() { return inputs_[2]; }
1197 DECLARE_CONCRETE_INSTRUCTION(InstanceOf, "instance-of")
1201 class LInstanceOfKnownGlobal FINAL : public LTemplateInstruction<1, 2, 1> {
1203 LInstanceOfKnownGlobal(LOperand* context, LOperand* value, LOperand* temp) {
1204 inputs_[0] = context;
1209 LOperand* context() { return inputs_[0]; }
1210 LOperand* value() { return inputs_[1]; }
1211 LOperand* temp() { return temps_[0]; }
1213 DECLARE_CONCRETE_INSTRUCTION(InstanceOfKnownGlobal,
1214 "instance-of-known-global")
1215 DECLARE_HYDROGEN_ACCESSOR(InstanceOfKnownGlobal)
1217 Handle<JSFunction> function() const { return hydrogen()->function(); }
1218 LEnvironment* GetDeferredLazyDeoptimizationEnvironment() {
1219 return lazy_deopt_env_;
1221 virtual void SetDeferredLazyDeoptimizationEnvironment(
1222 LEnvironment* env) OVERRIDE {
1223 lazy_deopt_env_ = env;
1227 LEnvironment* lazy_deopt_env_;
1231 class LBoundsCheck FINAL : public LTemplateInstruction<0, 2, 0> {
1233 LBoundsCheck(LOperand* index, LOperand* length) {
1235 inputs_[1] = length;
1238 LOperand* index() { return inputs_[0]; }
1239 LOperand* length() { return inputs_[1]; }
1241 DECLARE_CONCRETE_INSTRUCTION(BoundsCheck, "bounds-check")
1242 DECLARE_HYDROGEN_ACCESSOR(BoundsCheck)
1246 class LBitI FINAL : public LTemplateInstruction<1, 2, 0> {
1248 LBitI(LOperand* left, LOperand* right) {
1253 LOperand* left() { return inputs_[0]; }
1254 LOperand* right() { return inputs_[1]; }
1256 Token::Value op() const { return hydrogen()->op(); }
1257 bool IsInteger32() const {
1258 return hydrogen()->representation().IsInteger32();
1261 DECLARE_CONCRETE_INSTRUCTION(BitI, "bit-i")
1262 DECLARE_HYDROGEN_ACCESSOR(Bitwise)
1266 class LShiftI FINAL : public LTemplateInstruction<1, 2, 0> {
1268 LShiftI(Token::Value op, LOperand* left, LOperand* right, bool can_deopt)
1269 : op_(op), can_deopt_(can_deopt) {
1274 Token::Value op() const { return op_; }
1275 LOperand* left() { return inputs_[0]; }
1276 LOperand* right() { return inputs_[1]; }
1277 bool can_deopt() const { return can_deopt_; }
1279 DECLARE_CONCRETE_INSTRUCTION(ShiftI, "shift-i")
1287 class LSubI FINAL : public LTemplateInstruction<1, 2, 0> {
1289 LSubI(LOperand* left, LOperand* right) {
1294 LOperand* left() { return inputs_[0]; }
1295 LOperand* right() { return inputs_[1]; }
1297 DECLARE_CONCRETE_INSTRUCTION(SubI, "sub-i")
1298 DECLARE_HYDROGEN_ACCESSOR(Sub)
1302 class LConstantI FINAL : public LTemplateInstruction<1, 0, 0> {
1304 DECLARE_CONCRETE_INSTRUCTION(ConstantI, "constant-i")
1305 DECLARE_HYDROGEN_ACCESSOR(Constant)
1307 int32_t value() const { return hydrogen()->Integer32Value(); }
1311 class LConstantS FINAL : public LTemplateInstruction<1, 0, 0> {
1313 DECLARE_CONCRETE_INSTRUCTION(ConstantS, "constant-s")
1314 DECLARE_HYDROGEN_ACCESSOR(Constant)
1316 Smi* value() const { return Smi::FromInt(hydrogen()->Integer32Value()); }
1320 class LConstantD FINAL : public LTemplateInstruction<1, 0, 0> {
1322 DECLARE_CONCRETE_INSTRUCTION(ConstantD, "constant-d")
1323 DECLARE_HYDROGEN_ACCESSOR(Constant)
1325 uint64_t bits() const { return hydrogen()->DoubleValueAsBits(); }
1329 class LConstantE FINAL : public LTemplateInstruction<1, 0, 0> {
1331 DECLARE_CONCRETE_INSTRUCTION(ConstantE, "constant-e")
1332 DECLARE_HYDROGEN_ACCESSOR(Constant)
1334 ExternalReference value() const {
1335 return hydrogen()->ExternalReferenceValue();
1340 class LConstantT FINAL : public LTemplateInstruction<1, 0, 0> {
1342 DECLARE_CONCRETE_INSTRUCTION(ConstantT, "constant-t")
1343 DECLARE_HYDROGEN_ACCESSOR(Constant)
1345 Handle<Object> value(Isolate* isolate) const {
1346 return hydrogen()->handle(isolate);
1351 class LBranch FINAL : public LControlInstruction<1, 0> {
1353 explicit LBranch(LOperand* value) {
1357 LOperand* value() { return inputs_[0]; }
1359 DECLARE_CONCRETE_INSTRUCTION(Branch, "branch")
1360 DECLARE_HYDROGEN_ACCESSOR(Branch)
1362 void PrintDataTo(StringStream* stream) OVERRIDE;
1366 class LDebugBreak FINAL : public LTemplateInstruction<0, 0, 0> {
1368 DECLARE_CONCRETE_INSTRUCTION(DebugBreak, "break")
1372 class LCmpMapAndBranch FINAL : public LControlInstruction<1, 0> {
1374 explicit LCmpMapAndBranch(LOperand* value) {
1378 LOperand* value() { return inputs_[0]; }
1380 DECLARE_CONCRETE_INSTRUCTION(CmpMapAndBranch, "cmp-map-and-branch")
1381 DECLARE_HYDROGEN_ACCESSOR(CompareMap)
1383 Handle<Map> map() const { return hydrogen()->map().handle(); }
1387 class LMapEnumLength FINAL : public LTemplateInstruction<1, 1, 0> {
1389 explicit LMapEnumLength(LOperand* value) {
1393 LOperand* value() { return inputs_[0]; }
1395 DECLARE_CONCRETE_INSTRUCTION(MapEnumLength, "map-enum-length")
1399 class LDateField FINAL : public LTemplateInstruction<1, 1, 0> {
1401 LDateField(LOperand* date, Smi* index) : index_(index) {
1405 LOperand* date() { return inputs_[0]; }
1406 Smi* index() const { return index_; }
1408 DECLARE_CONCRETE_INSTRUCTION(DateField, "date-field")
1409 DECLARE_HYDROGEN_ACCESSOR(DateField)
1416 class LSeqStringGetChar FINAL : public LTemplateInstruction<1, 2, 0> {
1418 LSeqStringGetChar(LOperand* string, LOperand* index) {
1419 inputs_[0] = string;
1423 LOperand* string() const { return inputs_[0]; }
1424 LOperand* index() const { return inputs_[1]; }
1426 DECLARE_CONCRETE_INSTRUCTION(SeqStringGetChar, "seq-string-get-char")
1427 DECLARE_HYDROGEN_ACCESSOR(SeqStringGetChar)
1431 class LSeqStringSetChar FINAL : public LTemplateInstruction<1, 4, 0> {
1433 LSeqStringSetChar(LOperand* context,
1437 inputs_[0] = context;
1438 inputs_[1] = string;
1443 LOperand* string() { return inputs_[1]; }
1444 LOperand* index() { return inputs_[2]; }
1445 LOperand* value() { return inputs_[3]; }
1447 DECLARE_CONCRETE_INSTRUCTION(SeqStringSetChar, "seq-string-set-char")
1448 DECLARE_HYDROGEN_ACCESSOR(SeqStringSetChar)
1452 class LAddI FINAL : public LTemplateInstruction<1, 2, 0> {
1454 LAddI(LOperand* left, LOperand* right) {
1459 LOperand* left() { return inputs_[0]; }
1460 LOperand* right() { return inputs_[1]; }
1462 static bool UseLea(HAdd* add) {
1463 return !add->CheckFlag(HValue::kCanOverflow) &&
1464 add->BetterLeftOperand()->UseCount() > 1;
1467 DECLARE_CONCRETE_INSTRUCTION(AddI, "add-i")
1468 DECLARE_HYDROGEN_ACCESSOR(Add)
1472 class LMathMinMax FINAL : public LTemplateInstruction<1, 2, 0> {
1474 LMathMinMax(LOperand* left, LOperand* right) {
1479 LOperand* left() { return inputs_[0]; }
1480 LOperand* right() { return inputs_[1]; }
1482 DECLARE_CONCRETE_INSTRUCTION(MathMinMax, "math-min-max")
1483 DECLARE_HYDROGEN_ACCESSOR(MathMinMax)
1487 class LPower FINAL : public LTemplateInstruction<1, 2, 0> {
1489 LPower(LOperand* left, LOperand* right) {
1494 LOperand* left() { return inputs_[0]; }
1495 LOperand* right() { return inputs_[1]; }
1497 DECLARE_CONCRETE_INSTRUCTION(Power, "power")
1498 DECLARE_HYDROGEN_ACCESSOR(Power)
1502 class LArithmeticD FINAL : public LTemplateInstruction<1, 2, 0> {
1504 LArithmeticD(Token::Value op, LOperand* left, LOperand* right)
1510 Token::Value op() const { return op_; }
1511 LOperand* left() { return inputs_[0]; }
1512 LOperand* right() { return inputs_[1]; }
1514 Opcode opcode() const OVERRIDE { return LInstruction::kArithmeticD; }
1515 void CompileToNative(LCodeGen* generator) OVERRIDE;
1516 const char* Mnemonic() const OVERRIDE;
1523 class LArithmeticT FINAL : public LTemplateInstruction<1, 3, 0> {
1525 LArithmeticT(Token::Value op,
1530 inputs_[0] = context;
1535 Token::Value op() const { return op_; }
1536 LOperand* context() { return inputs_[0]; }
1537 LOperand* left() { return inputs_[1]; }
1538 LOperand* right() { return inputs_[2]; }
1540 Opcode opcode() const OVERRIDE { return LInstruction::kArithmeticT; }
1541 void CompileToNative(LCodeGen* generator) OVERRIDE;
1542 const char* Mnemonic() const OVERRIDE;
1549 class LReturn FINAL : public LTemplateInstruction<0, 3, 0> {
1551 explicit LReturn(LOperand* value,
1553 LOperand* parameter_count) {
1555 inputs_[1] = context;
1556 inputs_[2] = parameter_count;
1559 LOperand* value() { return inputs_[0]; }
1560 LOperand* context() { return inputs_[1]; }
1562 bool has_constant_parameter_count() {
1563 return parameter_count()->IsConstantOperand();
1565 LConstantOperand* constant_parameter_count() {
1566 DCHECK(has_constant_parameter_count());
1567 return LConstantOperand::cast(parameter_count());
1569 LOperand* parameter_count() { return inputs_[2]; }
1571 DECLARE_CONCRETE_INSTRUCTION(Return, "return")
1572 DECLARE_HYDROGEN_ACCESSOR(Return)
1576 class LLoadNamedField FINAL : public LTemplateInstruction<1, 1, 0> {
1578 explicit LLoadNamedField(LOperand* object) {
1579 inputs_[0] = object;
1582 LOperand* object() { return inputs_[0]; }
1584 DECLARE_CONCRETE_INSTRUCTION(LoadNamedField, "load-named-field")
1585 DECLARE_HYDROGEN_ACCESSOR(LoadNamedField)
1589 class LLoadNamedGeneric FINAL : public LTemplateInstruction<1, 2, 1> {
1591 explicit LLoadNamedGeneric(LOperand* context, LOperand* object,
1593 inputs_[0] = context;
1594 inputs_[1] = object;
1598 DECLARE_CONCRETE_INSTRUCTION(LoadNamedGeneric, "load-named-generic")
1599 DECLARE_HYDROGEN_ACCESSOR(LoadNamedGeneric)
1601 LOperand* context() { return inputs_[0]; }
1602 LOperand* object() { return inputs_[1]; }
1603 LOperand* temp_vector() { return temps_[0]; }
1605 Handle<Object> name() const { return hydrogen()->name(); }
1609 class LLoadFunctionPrototype FINAL : public LTemplateInstruction<1, 1, 0> {
1611 explicit LLoadFunctionPrototype(LOperand* function) {
1612 inputs_[0] = function;
1615 DECLARE_CONCRETE_INSTRUCTION(LoadFunctionPrototype, "load-function-prototype")
1616 DECLARE_HYDROGEN_ACCESSOR(LoadFunctionPrototype)
1618 LOperand* function() { return inputs_[0]; }
1622 class LLoadRoot FINAL : public LTemplateInstruction<1, 0, 0> {
1624 DECLARE_CONCRETE_INSTRUCTION(LoadRoot, "load-root")
1625 DECLARE_HYDROGEN_ACCESSOR(LoadRoot)
1627 Heap::RootListIndex index() const { return hydrogen()->index(); }
1631 inline static bool ExternalArrayOpRequiresTemp(
1632 Representation key_representation,
1633 ElementsKind elements_kind) {
1634 // Operations that require the key to be divided by two to be converted into
1635 // an index cannot fold the scale operation into a load and need an extra
1636 // temp register to do the work.
1637 return SmiValuesAre31Bits() && key_representation.IsSmi() &&
1638 (elements_kind == EXTERNAL_INT8_ELEMENTS ||
1639 elements_kind == EXTERNAL_UINT8_ELEMENTS ||
1640 elements_kind == EXTERNAL_UINT8_CLAMPED_ELEMENTS ||
1641 elements_kind == UINT8_ELEMENTS ||
1642 elements_kind == INT8_ELEMENTS ||
1643 elements_kind == UINT8_CLAMPED_ELEMENTS);
1647 class LLoadKeyed FINAL : public LTemplateInstruction<1, 2, 0> {
1649 LLoadKeyed(LOperand* elements, LOperand* key) {
1650 inputs_[0] = elements;
1654 DECLARE_CONCRETE_INSTRUCTION(LoadKeyed, "load-keyed")
1655 DECLARE_HYDROGEN_ACCESSOR(LoadKeyed)
1657 bool is_external() const {
1658 return hydrogen()->is_external();
1660 bool is_fixed_typed_array() const {
1661 return hydrogen()->is_fixed_typed_array();
1663 bool is_typed_elements() const {
1664 return is_external() || is_fixed_typed_array();
1666 LOperand* elements() { return inputs_[0]; }
1667 LOperand* key() { return inputs_[1]; }
1668 void PrintDataTo(StringStream* stream) OVERRIDE;
1669 uint32_t base_offset() const { return hydrogen()->base_offset(); }
1670 ElementsKind elements_kind() const {
1671 return hydrogen()->elements_kind();
1676 class LLoadKeyedGeneric FINAL : public LTemplateInstruction<1, 3, 1> {
1678 LLoadKeyedGeneric(LOperand* context, LOperand* obj, LOperand* key,
1680 inputs_[0] = context;
1686 DECLARE_CONCRETE_INSTRUCTION(LoadKeyedGeneric, "load-keyed-generic")
1687 DECLARE_HYDROGEN_ACCESSOR(LoadKeyedGeneric)
1689 LOperand* context() { return inputs_[0]; }
1690 LOperand* object() { return inputs_[1]; }
1691 LOperand* key() { return inputs_[2]; }
1692 LOperand* temp_vector() { return temps_[0]; }
1696 class LLoadGlobalGeneric FINAL : public LTemplateInstruction<1, 2, 1> {
1698 explicit LLoadGlobalGeneric(LOperand* context, LOperand* global_object,
1700 inputs_[0] = context;
1701 inputs_[1] = global_object;
1705 DECLARE_CONCRETE_INSTRUCTION(LoadGlobalGeneric, "load-global-generic")
1706 DECLARE_HYDROGEN_ACCESSOR(LoadGlobalGeneric)
1708 LOperand* context() { return inputs_[0]; }
1709 LOperand* global_object() { return inputs_[1]; }
1710 LOperand* temp_vector() { return temps_[0]; }
1712 Handle<Object> name() const { return hydrogen()->name(); }
1713 bool for_typeof() const { return hydrogen()->for_typeof(); }
1717 class LLoadContextSlot FINAL : public LTemplateInstruction<1, 1, 0> {
1719 explicit LLoadContextSlot(LOperand* context) {
1720 inputs_[0] = context;
1723 LOperand* context() { return inputs_[0]; }
1725 DECLARE_CONCRETE_INSTRUCTION(LoadContextSlot, "load-context-slot")
1726 DECLARE_HYDROGEN_ACCESSOR(LoadContextSlot)
1728 int slot_index() { return hydrogen()->slot_index(); }
1730 void PrintDataTo(StringStream* stream) OVERRIDE;
1734 class LStoreContextSlot FINAL : public LTemplateInstruction<0, 2, 1> {
1736 LStoreContextSlot(LOperand* context, LOperand* value, LOperand* temp) {
1737 inputs_[0] = context;
1742 LOperand* context() { return inputs_[0]; }
1743 LOperand* value() { return inputs_[1]; }
1744 LOperand* temp() { return temps_[0]; }
1746 DECLARE_CONCRETE_INSTRUCTION(StoreContextSlot, "store-context-slot")
1747 DECLARE_HYDROGEN_ACCESSOR(StoreContextSlot)
1749 int slot_index() { return hydrogen()->slot_index(); }
1751 void PrintDataTo(StringStream* stream) OVERRIDE;
1755 class LPushArgument FINAL : public LTemplateInstruction<0, 1, 0> {
1757 explicit LPushArgument(LOperand* value) {
1761 LOperand* value() { return inputs_[0]; }
1763 DECLARE_CONCRETE_INSTRUCTION(PushArgument, "push-argument")
1767 class LDrop FINAL : public LTemplateInstruction<0, 0, 0> {
1769 explicit LDrop(int count) : count_(count) { }
1771 int count() const { return count_; }
1773 DECLARE_CONCRETE_INSTRUCTION(Drop, "drop")
1780 class LStoreCodeEntry FINAL: public LTemplateInstruction<0, 2, 0> {
1782 LStoreCodeEntry(LOperand* function, LOperand* code_object) {
1783 inputs_[0] = function;
1784 inputs_[1] = code_object;
1787 LOperand* function() { return inputs_[0]; }
1788 LOperand* code_object() { return inputs_[1]; }
1790 void PrintDataTo(StringStream* stream) OVERRIDE;
1792 DECLARE_CONCRETE_INSTRUCTION(StoreCodeEntry, "store-code-entry")
1793 DECLARE_HYDROGEN_ACCESSOR(StoreCodeEntry)
1797 class LInnerAllocatedObject FINAL: public LTemplateInstruction<1, 2, 0> {
1799 LInnerAllocatedObject(LOperand* base_object, LOperand* offset) {
1800 inputs_[0] = base_object;
1801 inputs_[1] = offset;
1804 LOperand* base_object() const { return inputs_[0]; }
1805 LOperand* offset() const { return inputs_[1]; }
1807 void PrintDataTo(StringStream* stream) OVERRIDE;
1809 DECLARE_CONCRETE_INSTRUCTION(InnerAllocatedObject, "inner-allocated-object")
1813 class LThisFunction FINAL : public LTemplateInstruction<1, 0, 0> {
1815 DECLARE_CONCRETE_INSTRUCTION(ThisFunction, "this-function")
1816 DECLARE_HYDROGEN_ACCESSOR(ThisFunction)
1820 class LContext FINAL : public LTemplateInstruction<1, 0, 0> {
1822 DECLARE_CONCRETE_INSTRUCTION(Context, "context")
1823 DECLARE_HYDROGEN_ACCESSOR(Context)
1827 class LDeclareGlobals FINAL : public LTemplateInstruction<0, 1, 0> {
1829 explicit LDeclareGlobals(LOperand* context) {
1830 inputs_[0] = context;
1833 LOperand* context() { return inputs_[0]; }
1835 DECLARE_CONCRETE_INSTRUCTION(DeclareGlobals, "declare-globals")
1836 DECLARE_HYDROGEN_ACCESSOR(DeclareGlobals)
1840 class LCallJSFunction FINAL : public LTemplateInstruction<1, 1, 0> {
1842 explicit LCallJSFunction(LOperand* function) {
1843 inputs_[0] = function;
1846 LOperand* function() { return inputs_[0]; }
1848 DECLARE_CONCRETE_INSTRUCTION(CallJSFunction, "call-js-function")
1849 DECLARE_HYDROGEN_ACCESSOR(CallJSFunction)
1851 void PrintDataTo(StringStream* stream) OVERRIDE;
1853 int arity() const { return hydrogen()->argument_count() - 1; }
1857 class LCallWithDescriptor FINAL : public LTemplateResultInstruction<1> {
1859 LCallWithDescriptor(CallInterfaceDescriptor descriptor,
1860 const ZoneList<LOperand*>& operands, Zone* zone)
1861 : inputs_(descriptor.GetRegisterParameterCount() + 1, zone) {
1862 DCHECK(descriptor.GetRegisterParameterCount() + 1 == operands.length());
1863 inputs_.AddAll(operands, zone);
1866 LOperand* target() const { return inputs_[0]; }
1868 DECLARE_HYDROGEN_ACCESSOR(CallWithDescriptor)
1871 DECLARE_CONCRETE_INSTRUCTION(CallWithDescriptor, "call-with-descriptor")
1873 void PrintDataTo(StringStream* stream) OVERRIDE;
1875 int arity() const { return hydrogen()->argument_count() - 1; }
1877 ZoneList<LOperand*> inputs_;
1879 // Iterator support.
1880 int InputCount() FINAL { return inputs_.length(); }
1881 LOperand* InputAt(int i) FINAL { return inputs_[i]; }
1883 int TempCount() FINAL { return 0; }
1884 LOperand* TempAt(int i) FINAL { return NULL; }
1888 class LInvokeFunction FINAL : public LTemplateInstruction<1, 2, 0> {
1890 LInvokeFunction(LOperand* context, LOperand* function) {
1891 inputs_[0] = context;
1892 inputs_[1] = function;
1895 LOperand* context() { return inputs_[0]; }
1896 LOperand* function() { return inputs_[1]; }
1898 DECLARE_CONCRETE_INSTRUCTION(InvokeFunction, "invoke-function")
1899 DECLARE_HYDROGEN_ACCESSOR(InvokeFunction)
1901 void PrintDataTo(StringStream* stream) OVERRIDE;
1903 int arity() const { return hydrogen()->argument_count() - 1; }
1907 class LCallFunction FINAL : public LTemplateInstruction<1, 2, 2> {
1909 LCallFunction(LOperand* context, LOperand* function, LOperand* slot,
1911 inputs_[0] = context;
1912 inputs_[1] = function;
1917 DECLARE_CONCRETE_INSTRUCTION(CallFunction, "call-function")
1918 DECLARE_HYDROGEN_ACCESSOR(CallFunction)
1920 LOperand* context() { return inputs_[0]; }
1921 LOperand* function() { return inputs_[1]; }
1922 LOperand* temp_slot() { return temps_[0]; }
1923 LOperand* temp_vector() { return temps_[1]; }
1924 int arity() const { return hydrogen()->argument_count() - 1; }
1926 void PrintDataTo(StringStream* stream) OVERRIDE;
1930 class LCallNew FINAL : public LTemplateInstruction<1, 2, 0> {
1932 LCallNew(LOperand* context, LOperand* constructor) {
1933 inputs_[0] = context;
1934 inputs_[1] = constructor;
1937 LOperand* context() { return inputs_[0]; }
1938 LOperand* constructor() { return inputs_[1]; }
1940 DECLARE_CONCRETE_INSTRUCTION(CallNew, "call-new")
1941 DECLARE_HYDROGEN_ACCESSOR(CallNew)
1943 void PrintDataTo(StringStream* stream) OVERRIDE;
1945 int arity() const { return hydrogen()->argument_count() - 1; }
1949 class LCallNewArray FINAL : public LTemplateInstruction<1, 2, 0> {
1951 LCallNewArray(LOperand* context, LOperand* constructor) {
1952 inputs_[0] = context;
1953 inputs_[1] = constructor;
1956 LOperand* context() { return inputs_[0]; }
1957 LOperand* constructor() { return inputs_[1]; }
1959 DECLARE_CONCRETE_INSTRUCTION(CallNewArray, "call-new-array")
1960 DECLARE_HYDROGEN_ACCESSOR(CallNewArray)
1962 void PrintDataTo(StringStream* stream) OVERRIDE;
1964 int arity() const { return hydrogen()->argument_count() - 1; }
1968 class LCallRuntime FINAL : public LTemplateInstruction<1, 1, 0> {
1970 explicit LCallRuntime(LOperand* context) {
1971 inputs_[0] = context;
1974 LOperand* context() { return inputs_[0]; }
1976 DECLARE_CONCRETE_INSTRUCTION(CallRuntime, "call-runtime")
1977 DECLARE_HYDROGEN_ACCESSOR(CallRuntime)
1979 bool ClobbersDoubleRegisters(Isolate* isolate) const OVERRIDE {
1980 return save_doubles() == kDontSaveFPRegs;
1983 const Runtime::Function* function() const { return hydrogen()->function(); }
1984 int arity() const { return hydrogen()->argument_count(); }
1985 SaveFPRegsMode save_doubles() const { return hydrogen()->save_doubles(); }
1989 class LInteger32ToDouble FINAL : public LTemplateInstruction<1, 1, 0> {
1991 explicit LInteger32ToDouble(LOperand* value) {
1995 LOperand* value() { return inputs_[0]; }
1997 DECLARE_CONCRETE_INSTRUCTION(Integer32ToDouble, "int32-to-double")
2001 class LUint32ToDouble FINAL : public LTemplateInstruction<1, 1, 0> {
2003 explicit LUint32ToDouble(LOperand* value) {
2007 LOperand* value() { return inputs_[0]; }
2009 DECLARE_CONCRETE_INSTRUCTION(Uint32ToDouble, "uint32-to-double")
2013 class LNumberTagI FINAL : public LTemplateInstruction<1, 1, 2> {
2015 LNumberTagI(LOperand* value, LOperand* temp1, LOperand* temp2) {
2021 LOperand* value() { return inputs_[0]; }
2022 LOperand* temp1() { return temps_[0]; }
2023 LOperand* temp2() { return temps_[1]; }
2025 DECLARE_CONCRETE_INSTRUCTION(NumberTagI, "number-tag-i")
2029 class LNumberTagU FINAL : public LTemplateInstruction<1, 1, 2> {
2031 LNumberTagU(LOperand* value, LOperand* temp1, LOperand* temp2) {
2037 LOperand* value() { return inputs_[0]; }
2038 LOperand* temp1() { return temps_[0]; }
2039 LOperand* temp2() { return temps_[1]; }
2041 DECLARE_CONCRETE_INSTRUCTION(NumberTagU, "number-tag-u")
2045 class LNumberTagD FINAL : public LTemplateInstruction<1, 1, 1> {
2047 explicit LNumberTagD(LOperand* value, LOperand* temp) {
2052 LOperand* value() { return inputs_[0]; }
2053 LOperand* temp() { return temps_[0]; }
2055 DECLARE_CONCRETE_INSTRUCTION(NumberTagD, "number-tag-d")
2056 DECLARE_HYDROGEN_ACCESSOR(Change)
2060 // Sometimes truncating conversion from a tagged value to an int32.
2061 class LDoubleToI FINAL : public LTemplateInstruction<1, 1, 0> {
2063 explicit LDoubleToI(LOperand* value) {
2067 LOperand* value() { return inputs_[0]; }
2069 DECLARE_CONCRETE_INSTRUCTION(DoubleToI, "double-to-i")
2070 DECLARE_HYDROGEN_ACCESSOR(UnaryOperation)
2072 bool truncating() { return hydrogen()->CanTruncateToInt32(); }
2076 class LDoubleToSmi FINAL : public LTemplateInstruction<1, 1, 0> {
2078 explicit LDoubleToSmi(LOperand* value) {
2082 LOperand* value() { return inputs_[0]; }
2084 DECLARE_CONCRETE_INSTRUCTION(DoubleToSmi, "double-to-smi")
2085 DECLARE_HYDROGEN_ACCESSOR(UnaryOperation)
2089 // Truncating conversion from a tagged value to an int32.
2090 class LTaggedToI FINAL : public LTemplateInstruction<1, 1, 1> {
2092 LTaggedToI(LOperand* value, LOperand* temp) {
2097 LOperand* value() { return inputs_[0]; }
2098 LOperand* temp() { return temps_[0]; }
2100 DECLARE_CONCRETE_INSTRUCTION(TaggedToI, "tagged-to-i")
2101 DECLARE_HYDROGEN_ACCESSOR(Change)
2103 bool truncating() { return hydrogen()->CanTruncateToInt32(); }
2107 class LSmiTag FINAL : public LTemplateInstruction<1, 1, 0> {
2109 explicit LSmiTag(LOperand* value) {
2113 LOperand* value() { return inputs_[0]; }
2115 DECLARE_CONCRETE_INSTRUCTION(SmiTag, "smi-tag")
2116 DECLARE_HYDROGEN_ACCESSOR(Change)
2120 class LNumberUntagD FINAL : public LTemplateInstruction<1, 1, 0> {
2122 explicit LNumberUntagD(LOperand* value) {
2126 LOperand* value() { return inputs_[0]; }
2128 DECLARE_CONCRETE_INSTRUCTION(NumberUntagD, "double-untag")
2129 DECLARE_HYDROGEN_ACCESSOR(Change);
2133 class LSmiUntag FINAL : public LTemplateInstruction<1, 1, 0> {
2135 LSmiUntag(LOperand* value, bool needs_check)
2136 : needs_check_(needs_check) {
2140 LOperand* value() { return inputs_[0]; }
2141 bool needs_check() const { return needs_check_; }
2143 DECLARE_CONCRETE_INSTRUCTION(SmiUntag, "smi-untag")
2150 class LStoreNamedField FINAL : public LTemplateInstruction<0, 2, 1> {
2152 LStoreNamedField(LOperand* object, LOperand* value, LOperand* temp) {
2153 inputs_[0] = object;
2158 LOperand* object() { return inputs_[0]; }
2159 LOperand* value() { return inputs_[1]; }
2160 LOperand* temp() { return temps_[0]; }
2162 DECLARE_CONCRETE_INSTRUCTION(StoreNamedField, "store-named-field")
2163 DECLARE_HYDROGEN_ACCESSOR(StoreNamedField)
2165 void PrintDataTo(StringStream* stream) OVERRIDE;
2167 Representation representation() const {
2168 return hydrogen()->field_representation();
2173 class LStoreNamedGeneric FINAL : public LTemplateInstruction<0, 3, 0> {
2175 LStoreNamedGeneric(LOperand* context, LOperand* object, LOperand* value) {
2176 inputs_[0] = context;
2177 inputs_[1] = object;
2181 LOperand* context() { return inputs_[0]; }
2182 LOperand* object() { return inputs_[1]; }
2183 LOperand* value() { return inputs_[2]; }
2185 DECLARE_CONCRETE_INSTRUCTION(StoreNamedGeneric, "store-named-generic")
2186 DECLARE_HYDROGEN_ACCESSOR(StoreNamedGeneric)
2188 void PrintDataTo(StringStream* stream) OVERRIDE;
2190 Handle<Object> name() const { return hydrogen()->name(); }
2191 LanguageMode language_mode() { return hydrogen()->language_mode(); }
2195 class LStoreKeyed FINAL : public LTemplateInstruction<0, 3, 0> {
2197 LStoreKeyed(LOperand* object, LOperand* key, LOperand* value) {
2198 inputs_[0] = object;
2203 bool is_external() const { return hydrogen()->is_external(); }
2204 bool is_fixed_typed_array() const {
2205 return hydrogen()->is_fixed_typed_array();
2207 bool is_typed_elements() const {
2208 return is_external() || is_fixed_typed_array();
2210 LOperand* elements() { return inputs_[0]; }
2211 LOperand* key() { return inputs_[1]; }
2212 LOperand* value() { return inputs_[2]; }
2213 ElementsKind elements_kind() const { return hydrogen()->elements_kind(); }
2215 DECLARE_CONCRETE_INSTRUCTION(StoreKeyed, "store-keyed")
2216 DECLARE_HYDROGEN_ACCESSOR(StoreKeyed)
2218 void PrintDataTo(StringStream* stream) OVERRIDE;
2219 bool NeedsCanonicalization() { return hydrogen()->NeedsCanonicalization(); }
2220 uint32_t base_offset() const { return hydrogen()->base_offset(); }
2224 class LStoreKeyedGeneric FINAL : public LTemplateInstruction<0, 4, 0> {
2226 LStoreKeyedGeneric(LOperand* context,
2230 inputs_[0] = context;
2231 inputs_[1] = object;
2236 LOperand* context() { return inputs_[0]; }
2237 LOperand* object() { return inputs_[1]; }
2238 LOperand* key() { return inputs_[2]; }
2239 LOperand* value() { return inputs_[3]; }
2241 DECLARE_CONCRETE_INSTRUCTION(StoreKeyedGeneric, "store-keyed-generic")
2242 DECLARE_HYDROGEN_ACCESSOR(StoreKeyedGeneric)
2244 void PrintDataTo(StringStream* stream) OVERRIDE;
2246 LanguageMode language_mode() { return hydrogen()->language_mode(); }
2250 class LTransitionElementsKind FINAL : public LTemplateInstruction<0, 2, 2> {
2252 LTransitionElementsKind(LOperand* object,
2254 LOperand* new_map_temp,
2256 inputs_[0] = object;
2257 inputs_[1] = context;
2258 temps_[0] = new_map_temp;
2262 LOperand* object() { return inputs_[0]; }
2263 LOperand* context() { return inputs_[1]; }
2264 LOperand* new_map_temp() { return temps_[0]; }
2265 LOperand* temp() { return temps_[1]; }
2267 DECLARE_CONCRETE_INSTRUCTION(TransitionElementsKind,
2268 "transition-elements-kind")
2269 DECLARE_HYDROGEN_ACCESSOR(TransitionElementsKind)
2271 void PrintDataTo(StringStream* stream) OVERRIDE;
2273 Handle<Map> original_map() { return hydrogen()->original_map().handle(); }
2274 Handle<Map> transitioned_map() {
2275 return hydrogen()->transitioned_map().handle();
2277 ElementsKind from_kind() { return hydrogen()->from_kind(); }
2278 ElementsKind to_kind() { return hydrogen()->to_kind(); }
2282 class LTrapAllocationMemento FINAL : public LTemplateInstruction<0, 1, 1> {
2284 LTrapAllocationMemento(LOperand* object,
2286 inputs_[0] = object;
2290 LOperand* object() { return inputs_[0]; }
2291 LOperand* temp() { return temps_[0]; }
2293 DECLARE_CONCRETE_INSTRUCTION(TrapAllocationMemento,
2294 "trap-allocation-memento")
2298 class LStringAdd FINAL : public LTemplateInstruction<1, 3, 0> {
2300 LStringAdd(LOperand* context, LOperand* left, LOperand* right) {
2301 inputs_[0] = context;
2306 LOperand* context() { return inputs_[0]; }
2307 LOperand* left() { return inputs_[1]; }
2308 LOperand* right() { return inputs_[2]; }
2310 DECLARE_CONCRETE_INSTRUCTION(StringAdd, "string-add")
2311 DECLARE_HYDROGEN_ACCESSOR(StringAdd)
2315 class LStringCharCodeAt FINAL : public LTemplateInstruction<1, 3, 0> {
2317 LStringCharCodeAt(LOperand* context, LOperand* string, LOperand* index) {
2318 inputs_[0] = context;
2319 inputs_[1] = string;
2323 LOperand* context() { return inputs_[0]; }
2324 LOperand* string() { return inputs_[1]; }
2325 LOperand* index() { return inputs_[2]; }
2327 DECLARE_CONCRETE_INSTRUCTION(StringCharCodeAt, "string-char-code-at")
2328 DECLARE_HYDROGEN_ACCESSOR(StringCharCodeAt)
2332 class LStringCharFromCode FINAL : public LTemplateInstruction<1, 2, 0> {
2334 explicit LStringCharFromCode(LOperand* context, LOperand* char_code) {
2335 inputs_[0] = context;
2336 inputs_[1] = char_code;
2339 LOperand* context() { return inputs_[0]; }
2340 LOperand* char_code() { return inputs_[1]; }
2342 DECLARE_CONCRETE_INSTRUCTION(StringCharFromCode, "string-char-from-code")
2343 DECLARE_HYDROGEN_ACCESSOR(StringCharFromCode)
2347 class LCheckValue FINAL : public LTemplateInstruction<0, 1, 0> {
2349 explicit LCheckValue(LOperand* value) {
2353 LOperand* value() { return inputs_[0]; }
2355 DECLARE_CONCRETE_INSTRUCTION(CheckValue, "check-value")
2356 DECLARE_HYDROGEN_ACCESSOR(CheckValue)
2360 class LCheckInstanceType FINAL : public LTemplateInstruction<0, 1, 0> {
2362 explicit LCheckInstanceType(LOperand* value) {
2366 LOperand* value() { return inputs_[0]; }
2368 DECLARE_CONCRETE_INSTRUCTION(CheckInstanceType, "check-instance-type")
2369 DECLARE_HYDROGEN_ACCESSOR(CheckInstanceType)
2373 class LCheckMaps FINAL : public LTemplateInstruction<0, 1, 0> {
2375 explicit LCheckMaps(LOperand* value = NULL) {
2379 LOperand* value() { return inputs_[0]; }
2381 DECLARE_CONCRETE_INSTRUCTION(CheckMaps, "check-maps")
2382 DECLARE_HYDROGEN_ACCESSOR(CheckMaps)
2386 class LCheckSmi FINAL : public LTemplateInstruction<1, 1, 0> {
2388 explicit LCheckSmi(LOperand* value) {
2392 LOperand* value() { return inputs_[0]; }
2394 DECLARE_CONCRETE_INSTRUCTION(CheckSmi, "check-smi")
2398 class LClampDToUint8 FINAL : public LTemplateInstruction<1, 1, 0> {
2400 explicit LClampDToUint8(LOperand* unclamped) {
2401 inputs_[0] = unclamped;
2404 LOperand* unclamped() { return inputs_[0]; }
2406 DECLARE_CONCRETE_INSTRUCTION(ClampDToUint8, "clamp-d-to-uint8")
2410 class LClampIToUint8 FINAL : public LTemplateInstruction<1, 1, 0> {
2412 explicit LClampIToUint8(LOperand* unclamped) {
2413 inputs_[0] = unclamped;
2416 LOperand* unclamped() { return inputs_[0]; }
2418 DECLARE_CONCRETE_INSTRUCTION(ClampIToUint8, "clamp-i-to-uint8")
2422 class LClampTToUint8 FINAL : public LTemplateInstruction<1, 1, 1> {
2424 LClampTToUint8(LOperand* unclamped,
2425 LOperand* temp_xmm) {
2426 inputs_[0] = unclamped;
2427 temps_[0] = temp_xmm;
2430 LOperand* unclamped() { return inputs_[0]; }
2431 LOperand* temp_xmm() { return temps_[0]; }
2433 DECLARE_CONCRETE_INSTRUCTION(ClampTToUint8, "clamp-t-to-uint8")
2437 class LCheckNonSmi FINAL : public LTemplateInstruction<0, 1, 0> {
2439 explicit LCheckNonSmi(LOperand* value) {
2443 LOperand* value() { return inputs_[0]; }
2445 DECLARE_CONCRETE_INSTRUCTION(CheckNonSmi, "check-non-smi")
2446 DECLARE_HYDROGEN_ACCESSOR(CheckHeapObject)
2450 class LDoubleBits FINAL : public LTemplateInstruction<1, 1, 0> {
2452 explicit LDoubleBits(LOperand* value) {
2456 LOperand* value() { return inputs_[0]; }
2458 DECLARE_CONCRETE_INSTRUCTION(DoubleBits, "double-bits")
2459 DECLARE_HYDROGEN_ACCESSOR(DoubleBits)
2463 class LConstructDouble FINAL : public LTemplateInstruction<1, 2, 0> {
2465 LConstructDouble(LOperand* hi, LOperand* lo) {
2470 LOperand* hi() { return inputs_[0]; }
2471 LOperand* lo() { return inputs_[1]; }
2473 DECLARE_CONCRETE_INSTRUCTION(ConstructDouble, "construct-double")
2477 class LAllocate FINAL : public LTemplateInstruction<1, 2, 1> {
2479 LAllocate(LOperand* context, LOperand* size, LOperand* temp) {
2480 inputs_[0] = context;
2485 LOperand* context() { return inputs_[0]; }
2486 LOperand* size() { return inputs_[1]; }
2487 LOperand* temp() { return temps_[0]; }
2489 DECLARE_CONCRETE_INSTRUCTION(Allocate, "allocate")
2490 DECLARE_HYDROGEN_ACCESSOR(Allocate)
2494 class LRegExpLiteral FINAL : public LTemplateInstruction<1, 1, 0> {
2496 explicit LRegExpLiteral(LOperand* context) {
2497 inputs_[0] = context;
2500 LOperand* context() { return inputs_[0]; }
2502 DECLARE_CONCRETE_INSTRUCTION(RegExpLiteral, "regexp-literal")
2503 DECLARE_HYDROGEN_ACCESSOR(RegExpLiteral)
2507 class LFunctionLiteral FINAL : public LTemplateInstruction<1, 1, 0> {
2509 explicit LFunctionLiteral(LOperand* context) {
2510 inputs_[0] = context;
2513 LOperand* context() { return inputs_[0]; }
2515 DECLARE_CONCRETE_INSTRUCTION(FunctionLiteral, "function-literal")
2516 DECLARE_HYDROGEN_ACCESSOR(FunctionLiteral)
2520 class LToFastProperties FINAL : public LTemplateInstruction<1, 1, 0> {
2522 explicit LToFastProperties(LOperand* value) {
2526 LOperand* value() { return inputs_[0]; }
2528 DECLARE_CONCRETE_INSTRUCTION(ToFastProperties, "to-fast-properties")
2529 DECLARE_HYDROGEN_ACCESSOR(ToFastProperties)
2533 class LTypeof FINAL : public LTemplateInstruction<1, 2, 0> {
2535 LTypeof(LOperand* context, LOperand* value) {
2536 inputs_[0] = context;
2540 LOperand* context() { return inputs_[0]; }
2541 LOperand* value() { return inputs_[1]; }
2543 DECLARE_CONCRETE_INSTRUCTION(Typeof, "typeof")
2547 class LTypeofIsAndBranch FINAL : public LControlInstruction<1, 0> {
2549 explicit LTypeofIsAndBranch(LOperand* value) {
2553 LOperand* value() { return inputs_[0]; }
2555 DECLARE_CONCRETE_INSTRUCTION(TypeofIsAndBranch, "typeof-is-and-branch")
2556 DECLARE_HYDROGEN_ACCESSOR(TypeofIsAndBranch)
2558 Handle<String> type_literal() { return hydrogen()->type_literal(); }
2560 void PrintDataTo(StringStream* stream) OVERRIDE;
2564 class LIsConstructCallAndBranch FINAL : public LControlInstruction<0, 1> {
2566 explicit LIsConstructCallAndBranch(LOperand* temp) {
2570 LOperand* temp() { return temps_[0]; }
2572 DECLARE_CONCRETE_INSTRUCTION(IsConstructCallAndBranch,
2573 "is-construct-call-and-branch")
2574 DECLARE_HYDROGEN_ACCESSOR(IsConstructCallAndBranch)
2578 class LOsrEntry FINAL : public LTemplateInstruction<0, 0, 0> {
2582 bool HasInterestingComment(LCodeGen* gen) const OVERRIDE { return false; }
2583 DECLARE_CONCRETE_INSTRUCTION(OsrEntry, "osr-entry")
2587 class LStackCheck FINAL : public LTemplateInstruction<0, 1, 0> {
2589 explicit LStackCheck(LOperand* context) {
2590 inputs_[0] = context;
2593 LOperand* context() { return inputs_[0]; }
2595 DECLARE_CONCRETE_INSTRUCTION(StackCheck, "stack-check")
2596 DECLARE_HYDROGEN_ACCESSOR(StackCheck)
2598 Label* done_label() { return &done_label_; }
2605 class LForInPrepareMap FINAL : public LTemplateInstruction<1, 2, 0> {
2607 LForInPrepareMap(LOperand* context, LOperand* object) {
2608 inputs_[0] = context;
2609 inputs_[1] = object;
2612 LOperand* context() { return inputs_[0]; }
2613 LOperand* object() { return inputs_[1]; }
2615 DECLARE_CONCRETE_INSTRUCTION(ForInPrepareMap, "for-in-prepare-map")
2619 class LForInCacheArray FINAL : public LTemplateInstruction<1, 1, 0> {
2621 explicit LForInCacheArray(LOperand* map) {
2625 LOperand* map() { return inputs_[0]; }
2627 DECLARE_CONCRETE_INSTRUCTION(ForInCacheArray, "for-in-cache-array")
2630 return HForInCacheArray::cast(this->hydrogen_value())->idx();
2635 class LCheckMapValue FINAL : public LTemplateInstruction<0, 2, 0> {
2637 LCheckMapValue(LOperand* value, LOperand* map) {
2642 LOperand* value() { return inputs_[0]; }
2643 LOperand* map() { return inputs_[1]; }
2645 DECLARE_CONCRETE_INSTRUCTION(CheckMapValue, "check-map-value")
2649 class LLoadFieldByIndex FINAL : public LTemplateInstruction<1, 2, 0> {
2651 LLoadFieldByIndex(LOperand* object, LOperand* index) {
2652 inputs_[0] = object;
2656 LOperand* object() { return inputs_[0]; }
2657 LOperand* index() { return inputs_[1]; }
2659 DECLARE_CONCRETE_INSTRUCTION(LoadFieldByIndex, "load-field-by-index")
2663 class LStoreFrameContext: public LTemplateInstruction<0, 1, 0> {
2665 explicit LStoreFrameContext(LOperand* context) {
2666 inputs_[0] = context;
2669 LOperand* context() { return inputs_[0]; }
2671 DECLARE_CONCRETE_INSTRUCTION(StoreFrameContext, "store-frame-context")
2675 class LAllocateBlockContext: public LTemplateInstruction<1, 2, 0> {
2677 LAllocateBlockContext(LOperand* context, LOperand* function) {
2678 inputs_[0] = context;
2679 inputs_[1] = function;
2682 LOperand* context() { return inputs_[0]; }
2683 LOperand* function() { return inputs_[1]; }
2685 Handle<ScopeInfo> scope_info() { return hydrogen()->scope_info(); }
2687 DECLARE_CONCRETE_INSTRUCTION(AllocateBlockContext, "allocate-block-context")
2688 DECLARE_HYDROGEN_ACCESSOR(AllocateBlockContext)
2692 class LChunkBuilder;
2693 class LPlatformChunk FINAL : public LChunk {
2695 LPlatformChunk(CompilationInfo* info, HGraph* graph)
2696 : LChunk(info, graph),
2697 dehoisted_key_ids_(graph->GetMaximumValueID(), graph->zone()) { }
2699 int GetNextSpillIndex(RegisterKind kind);
2700 LOperand* GetNextSpillSlot(RegisterKind kind);
2701 BitVector* GetDehoistedKeyIds() { return &dehoisted_key_ids_; }
2702 bool IsDehoistedKey(HValue* value) {
2703 return dehoisted_key_ids_.Contains(value->id());
2707 BitVector dehoisted_key_ids_;
2711 class LChunkBuilder FINAL : public LChunkBuilderBase {
2713 LChunkBuilder(CompilationInfo* info, HGraph* graph, LAllocator* allocator)
2714 : LChunkBuilderBase(info, graph),
2715 current_instruction_(NULL),
2716 current_block_(NULL),
2718 allocator_(allocator) {}
2720 // Build the sequence for the graph.
2721 LPlatformChunk* Build();
2723 // Declare methods that deal with the individual node types.
2724 #define DECLARE_DO(type) LInstruction* Do##type(H##type* node);
2725 HYDROGEN_CONCRETE_INSTRUCTION_LIST(DECLARE_DO)
2728 LInstruction* DoMathFloor(HUnaryMathOperation* instr);
2729 LInstruction* DoMathRound(HUnaryMathOperation* instr);
2730 LInstruction* DoMathFround(HUnaryMathOperation* instr);
2731 LInstruction* DoMathAbs(HUnaryMathOperation* instr);
2732 LInstruction* DoMathLog(HUnaryMathOperation* instr);
2733 LInstruction* DoMathExp(HUnaryMathOperation* instr);
2734 LInstruction* DoMathSqrt(HUnaryMathOperation* instr);
2735 LInstruction* DoMathPowHalf(HUnaryMathOperation* instr);
2736 LInstruction* DoMathClz32(HUnaryMathOperation* instr);
2737 LInstruction* DoDivByPowerOf2I(HDiv* instr);
2738 LInstruction* DoDivByConstI(HDiv* instr);
2739 LInstruction* DoDivI(HDiv* instr);
2740 LInstruction* DoModByPowerOf2I(HMod* instr);
2741 LInstruction* DoModByConstI(HMod* instr);
2742 LInstruction* DoModI(HMod* instr);
2743 LInstruction* DoFlooringDivByPowerOf2I(HMathFloorOfDiv* instr);
2744 LInstruction* DoFlooringDivByConstI(HMathFloorOfDiv* instr);
2745 LInstruction* DoFlooringDivI(HMathFloorOfDiv* instr);
2748 // Methods for getting operands for Use / Define / Temp.
2749 LUnallocated* ToUnallocated(Register reg);
2750 LUnallocated* ToUnallocated(XMMRegister reg);
2752 // Methods for setting up define-use relationships.
2753 MUST_USE_RESULT LOperand* Use(HValue* value, LUnallocated* operand);
2754 MUST_USE_RESULT LOperand* UseFixed(HValue* value, Register fixed_register);
2755 MUST_USE_RESULT LOperand* UseFixedDouble(HValue* value,
2756 XMMRegister fixed_register);
2758 // A value that is guaranteed to be allocated to a register.
2759 // Operand created by UseRegister is guaranteed to be live until the end of
2760 // instruction. This means that register allocator will not reuse it's
2761 // register for any other operand inside instruction.
2762 // Operand created by UseRegisterAtStart is guaranteed to be live only at
2763 // instruction start. Register allocator is free to assign the same register
2764 // to some other operand used inside instruction (i.e. temporary or
2766 MUST_USE_RESULT LOperand* UseRegister(HValue* value);
2767 MUST_USE_RESULT LOperand* UseRegisterAtStart(HValue* value);
2769 // An input operand in a register that may be trashed.
2770 MUST_USE_RESULT LOperand* UseTempRegister(HValue* value);
2772 // An input operand in a register that may be trashed or a constant operand.
2773 MUST_USE_RESULT LOperand* UseTempRegisterOrConstant(HValue* value);
2775 // An input operand in a register or stack slot.
2776 MUST_USE_RESULT LOperand* Use(HValue* value);
2777 MUST_USE_RESULT LOperand* UseAtStart(HValue* value);
2779 // An input operand in a register, stack slot or a constant operand.
2780 MUST_USE_RESULT LOperand* UseOrConstant(HValue* value);
2781 MUST_USE_RESULT LOperand* UseOrConstantAtStart(HValue* value);
2783 // An input operand in a register or a constant operand.
2784 MUST_USE_RESULT LOperand* UseRegisterOrConstant(HValue* value);
2785 MUST_USE_RESULT LOperand* UseRegisterOrConstantAtStart(HValue* value);
2787 // An input operand in a constant operand.
2788 MUST_USE_RESULT LOperand* UseConstant(HValue* value);
2790 // An input operand in register, stack slot or a constant operand.
2791 // Will not be moved to a register even if one is freely available.
2792 MUST_USE_RESULT LOperand* UseAny(HValue* value) OVERRIDE;
2794 // Temporary operand that must be in a register.
2795 MUST_USE_RESULT LUnallocated* TempRegister();
2796 MUST_USE_RESULT LOperand* FixedTemp(Register reg);
2797 MUST_USE_RESULT LOperand* FixedTemp(XMMRegister reg);
2799 // Methods for setting up define-use relationships.
2800 // Return the same instruction that they are passed.
2801 LInstruction* Define(LTemplateResultInstruction<1>* instr,
2802 LUnallocated* result);
2803 LInstruction* DefineAsRegister(LTemplateResultInstruction<1>* instr);
2804 LInstruction* DefineAsSpilled(LTemplateResultInstruction<1>* instr,
2806 LInstruction* DefineSameAsFirst(LTemplateResultInstruction<1>* instr);
2807 LInstruction* DefineFixed(LTemplateResultInstruction<1>* instr,
2809 LInstruction* DefineFixedDouble(LTemplateResultInstruction<1>* instr,
2811 // Assigns an environment to an instruction. An instruction which can
2812 // deoptimize must have an environment.
2813 LInstruction* AssignEnvironment(LInstruction* instr);
2814 // Assigns a pointer map to an instruction. An instruction which can
2815 // trigger a GC or a lazy deoptimization must have a pointer map.
2816 LInstruction* AssignPointerMap(LInstruction* instr);
2818 enum CanDeoptimize { CAN_DEOPTIMIZE_EAGERLY, CANNOT_DEOPTIMIZE_EAGERLY };
2820 // Marks a call for the register allocator. Assigns a pointer map to
2821 // support GC and lazy deoptimization. Assigns an environment to support
2822 // eager deoptimization if CAN_DEOPTIMIZE_EAGERLY.
2823 LInstruction* MarkAsCall(
2824 LInstruction* instr,
2825 HInstruction* hinstr,
2826 CanDeoptimize can_deoptimize = CANNOT_DEOPTIMIZE_EAGERLY);
2828 void VisitInstruction(HInstruction* current);
2829 void AddInstruction(LInstruction* instr, HInstruction* current);
2831 void DoBasicBlock(HBasicBlock* block, HBasicBlock* next_block);
2832 LInstruction* DoShift(Token::Value op, HBitwiseBinaryOperation* instr);
2833 LInstruction* DoArithmeticD(Token::Value op,
2834 HArithmeticBinaryOperation* instr);
2835 LInstruction* DoArithmeticT(Token::Value op,
2836 HBinaryOperation* instr);
2837 void FindDehoistedKeyDefinitions(HValue* candidate);
2839 HInstruction* current_instruction_;
2840 HBasicBlock* current_block_;
2841 HBasicBlock* next_block_;
2842 LAllocator* allocator_;
2844 DISALLOW_COPY_AND_ASSIGN(LChunkBuilder);
2847 #undef DECLARE_HYDROGEN_ACCESSOR
2848 #undef DECLARE_CONCRETE_INSTRUCTION
2850 } } // namespace v8::int
2852 #endif // V8_X64_LITHIUM_X64_H_