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, 3, 0> {
483 explicit LTailCallThroughMegamorphicCache(LOperand* context,
486 inputs_[0] = context;
487 inputs_[1] = receiver;
491 LOperand* context() { return inputs_[0]; }
492 LOperand* receiver() { return inputs_[1]; }
493 LOperand* name() { return inputs_[2]; }
495 DECLARE_CONCRETE_INSTRUCTION(TailCallThroughMegamorphicCache,
496 "tail-call-through-megamorphic-cache")
497 DECLARE_HYDROGEN_ACCESSOR(TailCallThroughMegamorphicCache)
501 class LUnknownOSRValue FINAL : public LTemplateInstruction<1, 0, 0> {
503 bool HasInterestingComment(LCodeGen* gen) const OVERRIDE { return false; }
504 DECLARE_CONCRETE_INSTRUCTION(UnknownOSRValue, "unknown-osr-value")
508 template<int I, int T>
509 class LControlInstruction : public LTemplateInstruction<0, I, T> {
511 LControlInstruction() : false_label_(NULL), true_label_(NULL) { }
513 bool IsControl() const FINAL { return true; }
515 int SuccessorCount() { return hydrogen()->SuccessorCount(); }
516 HBasicBlock* SuccessorAt(int i) { return hydrogen()->SuccessorAt(i); }
518 int TrueDestination(LChunk* chunk) {
519 return chunk->LookupDestination(true_block_id());
521 int FalseDestination(LChunk* chunk) {
522 return chunk->LookupDestination(false_block_id());
525 Label* TrueLabel(LChunk* chunk) {
526 if (true_label_ == NULL) {
527 true_label_ = chunk->GetAssemblyLabel(TrueDestination(chunk));
531 Label* FalseLabel(LChunk* chunk) {
532 if (false_label_ == NULL) {
533 false_label_ = chunk->GetAssemblyLabel(FalseDestination(chunk));
539 int true_block_id() { return SuccessorAt(0)->block_id(); }
540 int false_block_id() { return SuccessorAt(1)->block_id(); }
543 HControlInstruction* hydrogen() {
544 return HControlInstruction::cast(this->hydrogen_value());
552 class LWrapReceiver FINAL : public LTemplateInstruction<1, 2, 0> {
554 LWrapReceiver(LOperand* receiver, LOperand* function) {
555 inputs_[0] = receiver;
556 inputs_[1] = function;
559 LOperand* receiver() { return inputs_[0]; }
560 LOperand* function() { return inputs_[1]; }
562 DECLARE_CONCRETE_INSTRUCTION(WrapReceiver, "wrap-receiver")
563 DECLARE_HYDROGEN_ACCESSOR(WrapReceiver)
567 class LApplyArguments FINAL : public LTemplateInstruction<1, 4, 0> {
569 LApplyArguments(LOperand* function,
572 LOperand* elements) {
573 inputs_[0] = function;
574 inputs_[1] = receiver;
576 inputs_[3] = elements;
579 LOperand* function() { return inputs_[0]; }
580 LOperand* receiver() { return inputs_[1]; }
581 LOperand* length() { return inputs_[2]; }
582 LOperand* elements() { return inputs_[3]; }
584 DECLARE_CONCRETE_INSTRUCTION(ApplyArguments, "apply-arguments")
588 class LAccessArgumentsAt FINAL : public LTemplateInstruction<1, 3, 0> {
590 LAccessArgumentsAt(LOperand* arguments, LOperand* length, LOperand* index) {
591 inputs_[0] = arguments;
596 LOperand* arguments() { return inputs_[0]; }
597 LOperand* length() { return inputs_[1]; }
598 LOperand* index() { return inputs_[2]; }
600 DECLARE_CONCRETE_INSTRUCTION(AccessArgumentsAt, "access-arguments-at")
602 void PrintDataTo(StringStream* stream) OVERRIDE;
606 class LArgumentsLength FINAL : public LTemplateInstruction<1, 1, 0> {
608 explicit LArgumentsLength(LOperand* elements) {
609 inputs_[0] = elements;
612 LOperand* elements() { return inputs_[0]; }
614 DECLARE_CONCRETE_INSTRUCTION(ArgumentsLength, "arguments-length")
618 class LArgumentsElements FINAL : public LTemplateInstruction<1, 0, 0> {
620 DECLARE_CONCRETE_INSTRUCTION(ArgumentsElements, "arguments-elements")
621 DECLARE_HYDROGEN_ACCESSOR(ArgumentsElements)
625 class LModByPowerOf2I FINAL : public LTemplateInstruction<1, 1, 0> {
627 LModByPowerOf2I(LOperand* dividend, int32_t divisor) {
628 inputs_[0] = dividend;
632 LOperand* dividend() { return inputs_[0]; }
633 int32_t divisor() const { return divisor_; }
635 DECLARE_CONCRETE_INSTRUCTION(ModByPowerOf2I, "mod-by-power-of-2-i")
636 DECLARE_HYDROGEN_ACCESSOR(Mod)
643 class LModByConstI FINAL : public LTemplateInstruction<1, 1, 2> {
645 LModByConstI(LOperand* dividend,
649 inputs_[0] = dividend;
655 LOperand* dividend() { return inputs_[0]; }
656 int32_t divisor() const { return divisor_; }
657 LOperand* temp1() { return temps_[0]; }
658 LOperand* temp2() { return temps_[1]; }
660 DECLARE_CONCRETE_INSTRUCTION(ModByConstI, "mod-by-const-i")
661 DECLARE_HYDROGEN_ACCESSOR(Mod)
668 class LModI FINAL : public LTemplateInstruction<1, 2, 1> {
670 LModI(LOperand* left, LOperand* right, LOperand* temp) {
676 LOperand* left() { return inputs_[0]; }
677 LOperand* right() { return inputs_[1]; }
678 LOperand* temp() { return temps_[0]; }
680 DECLARE_CONCRETE_INSTRUCTION(ModI, "mod-i")
681 DECLARE_HYDROGEN_ACCESSOR(Mod)
685 class LDivByPowerOf2I FINAL : public LTemplateInstruction<1, 1, 0> {
687 LDivByPowerOf2I(LOperand* dividend, int32_t divisor) {
688 inputs_[0] = dividend;
692 LOperand* dividend() { return inputs_[0]; }
693 int32_t divisor() const { return divisor_; }
695 DECLARE_CONCRETE_INSTRUCTION(DivByPowerOf2I, "div-by-power-of-2-i")
696 DECLARE_HYDROGEN_ACCESSOR(Div)
703 class LDivByConstI FINAL : public LTemplateInstruction<1, 1, 2> {
705 LDivByConstI(LOperand* dividend,
709 inputs_[0] = dividend;
715 LOperand* dividend() { return inputs_[0]; }
716 int32_t divisor() const { return divisor_; }
717 LOperand* temp1() { return temps_[0]; }
718 LOperand* temp2() { return temps_[1]; }
720 DECLARE_CONCRETE_INSTRUCTION(DivByConstI, "div-by-const-i")
721 DECLARE_HYDROGEN_ACCESSOR(Div)
728 class LDivI FINAL : public LTemplateInstruction<1, 2, 1> {
730 LDivI(LOperand* dividend, LOperand* divisor, LOperand* temp) {
731 inputs_[0] = dividend;
732 inputs_[1] = divisor;
736 LOperand* dividend() { return inputs_[0]; }
737 LOperand* divisor() { return inputs_[1]; }
738 LOperand* temp() { return temps_[0]; }
740 DECLARE_CONCRETE_INSTRUCTION(DivI, "div-i")
741 DECLARE_HYDROGEN_ACCESSOR(BinaryOperation)
745 class LFlooringDivByPowerOf2I FINAL : public LTemplateInstruction<1, 1, 0> {
747 LFlooringDivByPowerOf2I(LOperand* dividend, int32_t divisor) {
748 inputs_[0] = dividend;
752 LOperand* dividend() { return inputs_[0]; }
753 int32_t divisor() const { return divisor_; }
755 DECLARE_CONCRETE_INSTRUCTION(FlooringDivByPowerOf2I,
756 "flooring-div-by-power-of-2-i")
757 DECLARE_HYDROGEN_ACCESSOR(MathFloorOfDiv)
764 class LFlooringDivByConstI FINAL : public LTemplateInstruction<1, 1, 3> {
766 LFlooringDivByConstI(LOperand* dividend,
771 inputs_[0] = dividend;
778 LOperand* dividend() { return inputs_[0]; }
779 int32_t divisor() const { return divisor_; }
780 LOperand* temp1() { return temps_[0]; }
781 LOperand* temp2() { return temps_[1]; }
782 LOperand* temp3() { return temps_[2]; }
784 DECLARE_CONCRETE_INSTRUCTION(FlooringDivByConstI, "flooring-div-by-const-i")
785 DECLARE_HYDROGEN_ACCESSOR(MathFloorOfDiv)
792 class LFlooringDivI FINAL : public LTemplateInstruction<1, 2, 1> {
794 LFlooringDivI(LOperand* dividend, LOperand* divisor, LOperand* temp) {
795 inputs_[0] = dividend;
796 inputs_[1] = divisor;
800 LOperand* dividend() { return inputs_[0]; }
801 LOperand* divisor() { return inputs_[1]; }
802 LOperand* temp() { return temps_[0]; }
804 DECLARE_CONCRETE_INSTRUCTION(FlooringDivI, "flooring-div-i")
805 DECLARE_HYDROGEN_ACCESSOR(MathFloorOfDiv)
809 class LMulI FINAL : public LTemplateInstruction<1, 2, 0> {
811 LMulI(LOperand* left, LOperand* right) {
816 LOperand* left() { return inputs_[0]; }
817 LOperand* right() { return inputs_[1]; }
819 DECLARE_CONCRETE_INSTRUCTION(MulI, "mul-i")
820 DECLARE_HYDROGEN_ACCESSOR(Mul)
824 class LCompareNumericAndBranch FINAL : public LControlInstruction<2, 0> {
826 LCompareNumericAndBranch(LOperand* left, LOperand* right) {
831 LOperand* left() { return inputs_[0]; }
832 LOperand* right() { return inputs_[1]; }
834 DECLARE_CONCRETE_INSTRUCTION(CompareNumericAndBranch,
835 "compare-numeric-and-branch")
836 DECLARE_HYDROGEN_ACCESSOR(CompareNumericAndBranch)
838 Token::Value op() const { return hydrogen()->token(); }
839 bool is_double() const {
840 return hydrogen()->representation().IsDouble();
843 void PrintDataTo(StringStream* stream) OVERRIDE;
847 class LMathFloor FINAL : public LTemplateInstruction<1, 1, 0> {
849 explicit LMathFloor(LOperand* value) {
853 LOperand* value() { return inputs_[0]; }
855 DECLARE_CONCRETE_INSTRUCTION(MathFloor, "math-floor")
856 DECLARE_HYDROGEN_ACCESSOR(UnaryMathOperation)
860 class LMathRound FINAL : public LTemplateInstruction<1, 1, 1> {
862 LMathRound(LOperand* value, LOperand* temp) {
867 LOperand* value() { return inputs_[0]; }
868 LOperand* temp() { return temps_[0]; }
870 DECLARE_CONCRETE_INSTRUCTION(MathRound, "math-round")
871 DECLARE_HYDROGEN_ACCESSOR(UnaryMathOperation)
875 class LMathFround FINAL : public LTemplateInstruction<1, 1, 0> {
877 explicit LMathFround(LOperand* value) { inputs_[0] = value; }
879 LOperand* value() { return inputs_[0]; }
881 DECLARE_CONCRETE_INSTRUCTION(MathFround, "math-fround")
885 class LMathAbs FINAL : public LTemplateInstruction<1, 2, 0> {
887 explicit LMathAbs(LOperand* context, LOperand* value) {
888 inputs_[1] = context;
892 LOperand* context() { return inputs_[1]; }
893 LOperand* value() { return inputs_[0]; }
895 DECLARE_CONCRETE_INSTRUCTION(MathAbs, "math-abs")
896 DECLARE_HYDROGEN_ACCESSOR(UnaryMathOperation)
900 class LMathLog FINAL : public LTemplateInstruction<1, 1, 0> {
902 explicit LMathLog(LOperand* value) {
906 LOperand* value() { return inputs_[0]; }
908 DECLARE_CONCRETE_INSTRUCTION(MathLog, "math-log")
912 class LMathClz32 FINAL : public LTemplateInstruction<1, 1, 0> {
914 explicit LMathClz32(LOperand* value) {
918 LOperand* value() { return inputs_[0]; }
920 DECLARE_CONCRETE_INSTRUCTION(MathClz32, "math-clz32")
924 class LMathExp FINAL : public LTemplateInstruction<1, 1, 2> {
926 LMathExp(LOperand* value, LOperand* temp1, LOperand* temp2) {
930 ExternalReference::InitializeMathExpData();
933 LOperand* value() { return inputs_[0]; }
934 LOperand* temp1() { return temps_[0]; }
935 LOperand* temp2() { return temps_[1]; }
937 DECLARE_CONCRETE_INSTRUCTION(MathExp, "math-exp")
941 class LMathSqrt FINAL : public LTemplateInstruction<1, 1, 0> {
943 explicit LMathSqrt(LOperand* value) {
947 LOperand* value() { return inputs_[0]; }
949 DECLARE_CONCRETE_INSTRUCTION(MathSqrt, "math-sqrt")
953 class LMathPowHalf FINAL : public LTemplateInstruction<1, 1, 0> {
955 explicit LMathPowHalf(LOperand* value) {
959 LOperand* value() { return inputs_[0]; }
961 DECLARE_CONCRETE_INSTRUCTION(MathPowHalf, "math-pow-half")
965 class LCmpObjectEqAndBranch FINAL : public LControlInstruction<2, 0> {
967 LCmpObjectEqAndBranch(LOperand* left, LOperand* right) {
972 LOperand* left() { return inputs_[0]; }
973 LOperand* right() { return inputs_[1]; }
975 DECLARE_CONCRETE_INSTRUCTION(CmpObjectEqAndBranch, "cmp-object-eq-and-branch")
979 class LCmpHoleAndBranch FINAL : public LControlInstruction<1, 0> {
981 explicit LCmpHoleAndBranch(LOperand* object) {
985 LOperand* object() { return inputs_[0]; }
987 DECLARE_CONCRETE_INSTRUCTION(CmpHoleAndBranch, "cmp-hole-and-branch")
988 DECLARE_HYDROGEN_ACCESSOR(CompareHoleAndBranch)
992 class LCompareMinusZeroAndBranch FINAL : public LControlInstruction<1, 0> {
994 explicit LCompareMinusZeroAndBranch(LOperand* value) {
998 LOperand* value() { return inputs_[0]; }
1000 DECLARE_CONCRETE_INSTRUCTION(CompareMinusZeroAndBranch,
1001 "cmp-minus-zero-and-branch")
1002 DECLARE_HYDROGEN_ACCESSOR(CompareMinusZeroAndBranch)
1007 class LIsObjectAndBranch FINAL : public LControlInstruction<1, 0> {
1009 explicit LIsObjectAndBranch(LOperand* value) {
1013 LOperand* value() { return inputs_[0]; }
1015 DECLARE_CONCRETE_INSTRUCTION(IsObjectAndBranch, "is-object-and-branch")
1016 DECLARE_HYDROGEN_ACCESSOR(IsObjectAndBranch)
1018 void PrintDataTo(StringStream* stream) OVERRIDE;
1022 class LIsStringAndBranch FINAL : public LControlInstruction<1, 1> {
1024 explicit LIsStringAndBranch(LOperand* value, LOperand* temp) {
1029 LOperand* value() { return inputs_[0]; }
1030 LOperand* temp() { return temps_[0]; }
1032 DECLARE_CONCRETE_INSTRUCTION(IsStringAndBranch, "is-string-and-branch")
1033 DECLARE_HYDROGEN_ACCESSOR(IsStringAndBranch)
1035 void PrintDataTo(StringStream* stream) OVERRIDE;
1039 class LIsSmiAndBranch FINAL : public LControlInstruction<1, 0> {
1041 explicit LIsSmiAndBranch(LOperand* value) {
1045 LOperand* value() { return inputs_[0]; }
1047 DECLARE_CONCRETE_INSTRUCTION(IsSmiAndBranch, "is-smi-and-branch")
1048 DECLARE_HYDROGEN_ACCESSOR(IsSmiAndBranch)
1050 void PrintDataTo(StringStream* stream) OVERRIDE;
1054 class LIsUndetectableAndBranch FINAL : public LControlInstruction<1, 1> {
1056 explicit LIsUndetectableAndBranch(LOperand* value, LOperand* temp) {
1061 LOperand* value() { return inputs_[0]; }
1062 LOperand* temp() { return temps_[0]; }
1064 DECLARE_CONCRETE_INSTRUCTION(IsUndetectableAndBranch,
1065 "is-undetectable-and-branch")
1066 DECLARE_HYDROGEN_ACCESSOR(IsUndetectableAndBranch)
1068 void PrintDataTo(StringStream* stream) OVERRIDE;
1072 class LStringCompareAndBranch FINAL : public LControlInstruction<3, 0> {
1074 explicit LStringCompareAndBranch(LOperand* context,
1077 inputs_[0] = context;
1082 LOperand* context() { return inputs_[0]; }
1083 LOperand* left() { return inputs_[1]; }
1084 LOperand* right() { return inputs_[2]; }
1086 DECLARE_CONCRETE_INSTRUCTION(StringCompareAndBranch,
1087 "string-compare-and-branch")
1088 DECLARE_HYDROGEN_ACCESSOR(StringCompareAndBranch)
1090 void PrintDataTo(StringStream* stream) OVERRIDE;
1092 Token::Value op() const { return hydrogen()->token(); }
1096 class LHasInstanceTypeAndBranch FINAL : public LControlInstruction<1, 0> {
1098 explicit LHasInstanceTypeAndBranch(LOperand* value) {
1102 LOperand* value() { return inputs_[0]; }
1104 DECLARE_CONCRETE_INSTRUCTION(HasInstanceTypeAndBranch,
1105 "has-instance-type-and-branch")
1106 DECLARE_HYDROGEN_ACCESSOR(HasInstanceTypeAndBranch)
1108 void PrintDataTo(StringStream* stream) OVERRIDE;
1112 class LGetCachedArrayIndex FINAL : public LTemplateInstruction<1, 1, 0> {
1114 explicit LGetCachedArrayIndex(LOperand* value) {
1118 LOperand* value() { return inputs_[0]; }
1120 DECLARE_CONCRETE_INSTRUCTION(GetCachedArrayIndex, "get-cached-array-index")
1121 DECLARE_HYDROGEN_ACCESSOR(GetCachedArrayIndex)
1125 class LHasCachedArrayIndexAndBranch FINAL
1126 : public LControlInstruction<1, 0> {
1128 explicit LHasCachedArrayIndexAndBranch(LOperand* value) {
1132 LOperand* value() { return inputs_[0]; }
1134 DECLARE_CONCRETE_INSTRUCTION(HasCachedArrayIndexAndBranch,
1135 "has-cached-array-index-and-branch")
1136 DECLARE_HYDROGEN_ACCESSOR(HasCachedArrayIndexAndBranch)
1138 void PrintDataTo(StringStream* stream) OVERRIDE;
1142 class LClassOfTestAndBranch FINAL : public LControlInstruction<1, 2> {
1144 LClassOfTestAndBranch(LOperand* value, LOperand* temp, LOperand* temp2) {
1150 LOperand* value() { return inputs_[0]; }
1151 LOperand* temp() { return temps_[0]; }
1152 LOperand* temp2() { return temps_[1]; }
1154 DECLARE_CONCRETE_INSTRUCTION(ClassOfTestAndBranch,
1155 "class-of-test-and-branch")
1156 DECLARE_HYDROGEN_ACCESSOR(ClassOfTestAndBranch)
1158 void PrintDataTo(StringStream* stream) OVERRIDE;
1162 class LCmpT FINAL : public LTemplateInstruction<1, 3, 0> {
1164 LCmpT(LOperand* context, LOperand* left, LOperand* right) {
1165 inputs_[0] = context;
1170 LOperand* context() { return inputs_[0]; }
1171 LOperand* left() { return inputs_[1]; }
1172 LOperand* right() { return inputs_[2]; }
1174 DECLARE_CONCRETE_INSTRUCTION(CmpT, "cmp-t")
1175 DECLARE_HYDROGEN_ACCESSOR(CompareGeneric)
1177 Token::Value op() const { return hydrogen()->token(); }
1181 class LInstanceOf FINAL : public LTemplateInstruction<1, 3, 0> {
1183 LInstanceOf(LOperand* context, LOperand* left, LOperand* right) {
1184 inputs_[0] = context;
1189 LOperand* context() { return inputs_[0]; }
1190 LOperand* left() { return inputs_[1]; }
1191 LOperand* right() { return inputs_[2]; }
1193 DECLARE_CONCRETE_INSTRUCTION(InstanceOf, "instance-of")
1197 class LInstanceOfKnownGlobal FINAL : public LTemplateInstruction<1, 2, 1> {
1199 LInstanceOfKnownGlobal(LOperand* context, LOperand* value, LOperand* temp) {
1200 inputs_[0] = context;
1205 LOperand* context() { return inputs_[0]; }
1206 LOperand* value() { return inputs_[1]; }
1207 LOperand* temp() { return temps_[0]; }
1209 DECLARE_CONCRETE_INSTRUCTION(InstanceOfKnownGlobal,
1210 "instance-of-known-global")
1211 DECLARE_HYDROGEN_ACCESSOR(InstanceOfKnownGlobal)
1213 Handle<JSFunction> function() const { return hydrogen()->function(); }
1214 LEnvironment* GetDeferredLazyDeoptimizationEnvironment() {
1215 return lazy_deopt_env_;
1217 virtual void SetDeferredLazyDeoptimizationEnvironment(
1218 LEnvironment* env) OVERRIDE {
1219 lazy_deopt_env_ = env;
1223 LEnvironment* lazy_deopt_env_;
1227 class LBoundsCheck FINAL : public LTemplateInstruction<0, 2, 0> {
1229 LBoundsCheck(LOperand* index, LOperand* length) {
1231 inputs_[1] = length;
1234 LOperand* index() { return inputs_[0]; }
1235 LOperand* length() { return inputs_[1]; }
1237 DECLARE_CONCRETE_INSTRUCTION(BoundsCheck, "bounds-check")
1238 DECLARE_HYDROGEN_ACCESSOR(BoundsCheck)
1242 class LBitI FINAL : public LTemplateInstruction<1, 2, 0> {
1244 LBitI(LOperand* left, LOperand* right) {
1249 LOperand* left() { return inputs_[0]; }
1250 LOperand* right() { return inputs_[1]; }
1252 Token::Value op() const { return hydrogen()->op(); }
1253 bool IsInteger32() const {
1254 return hydrogen()->representation().IsInteger32();
1257 DECLARE_CONCRETE_INSTRUCTION(BitI, "bit-i")
1258 DECLARE_HYDROGEN_ACCESSOR(Bitwise)
1262 class LShiftI FINAL : public LTemplateInstruction<1, 2, 0> {
1264 LShiftI(Token::Value op, LOperand* left, LOperand* right, bool can_deopt)
1265 : op_(op), can_deopt_(can_deopt) {
1270 Token::Value op() const { return op_; }
1271 LOperand* left() { return inputs_[0]; }
1272 LOperand* right() { return inputs_[1]; }
1273 bool can_deopt() const { return can_deopt_; }
1275 DECLARE_CONCRETE_INSTRUCTION(ShiftI, "shift-i")
1283 class LSubI FINAL : public LTemplateInstruction<1, 2, 0> {
1285 LSubI(LOperand* left, LOperand* right) {
1290 LOperand* left() { return inputs_[0]; }
1291 LOperand* right() { return inputs_[1]; }
1293 DECLARE_CONCRETE_INSTRUCTION(SubI, "sub-i")
1294 DECLARE_HYDROGEN_ACCESSOR(Sub)
1298 class LConstantI FINAL : public LTemplateInstruction<1, 0, 0> {
1300 DECLARE_CONCRETE_INSTRUCTION(ConstantI, "constant-i")
1301 DECLARE_HYDROGEN_ACCESSOR(Constant)
1303 int32_t value() const { return hydrogen()->Integer32Value(); }
1307 class LConstantS FINAL : public LTemplateInstruction<1, 0, 0> {
1309 DECLARE_CONCRETE_INSTRUCTION(ConstantS, "constant-s")
1310 DECLARE_HYDROGEN_ACCESSOR(Constant)
1312 Smi* value() const { return Smi::FromInt(hydrogen()->Integer32Value()); }
1316 class LConstantD FINAL : public LTemplateInstruction<1, 0, 0> {
1318 DECLARE_CONCRETE_INSTRUCTION(ConstantD, "constant-d")
1319 DECLARE_HYDROGEN_ACCESSOR(Constant)
1321 uint64_t bits() const { return hydrogen()->DoubleValueAsBits(); }
1325 class LConstantE FINAL : public LTemplateInstruction<1, 0, 0> {
1327 DECLARE_CONCRETE_INSTRUCTION(ConstantE, "constant-e")
1328 DECLARE_HYDROGEN_ACCESSOR(Constant)
1330 ExternalReference value() const {
1331 return hydrogen()->ExternalReferenceValue();
1336 class LConstantT FINAL : public LTemplateInstruction<1, 0, 0> {
1338 DECLARE_CONCRETE_INSTRUCTION(ConstantT, "constant-t")
1339 DECLARE_HYDROGEN_ACCESSOR(Constant)
1341 Handle<Object> value(Isolate* isolate) const {
1342 return hydrogen()->handle(isolate);
1347 class LBranch FINAL : public LControlInstruction<1, 0> {
1349 explicit LBranch(LOperand* value) {
1353 LOperand* value() { return inputs_[0]; }
1355 DECLARE_CONCRETE_INSTRUCTION(Branch, "branch")
1356 DECLARE_HYDROGEN_ACCESSOR(Branch)
1358 void PrintDataTo(StringStream* stream) OVERRIDE;
1362 class LDebugBreak FINAL : public LTemplateInstruction<0, 0, 0> {
1364 DECLARE_CONCRETE_INSTRUCTION(DebugBreak, "break")
1368 class LCmpMapAndBranch FINAL : public LControlInstruction<1, 0> {
1370 explicit LCmpMapAndBranch(LOperand* value) {
1374 LOperand* value() { return inputs_[0]; }
1376 DECLARE_CONCRETE_INSTRUCTION(CmpMapAndBranch, "cmp-map-and-branch")
1377 DECLARE_HYDROGEN_ACCESSOR(CompareMap)
1379 Handle<Map> map() const { return hydrogen()->map().handle(); }
1383 class LMapEnumLength FINAL : public LTemplateInstruction<1, 1, 0> {
1385 explicit LMapEnumLength(LOperand* value) {
1389 LOperand* value() { return inputs_[0]; }
1391 DECLARE_CONCRETE_INSTRUCTION(MapEnumLength, "map-enum-length")
1395 class LDateField FINAL : public LTemplateInstruction<1, 1, 0> {
1397 LDateField(LOperand* date, Smi* index) : index_(index) {
1401 LOperand* date() { return inputs_[0]; }
1402 Smi* index() const { return index_; }
1404 DECLARE_CONCRETE_INSTRUCTION(DateField, "date-field")
1405 DECLARE_HYDROGEN_ACCESSOR(DateField)
1412 class LSeqStringGetChar FINAL : public LTemplateInstruction<1, 2, 0> {
1414 LSeqStringGetChar(LOperand* string, LOperand* index) {
1415 inputs_[0] = string;
1419 LOperand* string() const { return inputs_[0]; }
1420 LOperand* index() const { return inputs_[1]; }
1422 DECLARE_CONCRETE_INSTRUCTION(SeqStringGetChar, "seq-string-get-char")
1423 DECLARE_HYDROGEN_ACCESSOR(SeqStringGetChar)
1427 class LSeqStringSetChar FINAL : public LTemplateInstruction<1, 4, 0> {
1429 LSeqStringSetChar(LOperand* context,
1433 inputs_[0] = context;
1434 inputs_[1] = string;
1439 LOperand* string() { return inputs_[1]; }
1440 LOperand* index() { return inputs_[2]; }
1441 LOperand* value() { return inputs_[3]; }
1443 DECLARE_CONCRETE_INSTRUCTION(SeqStringSetChar, "seq-string-set-char")
1444 DECLARE_HYDROGEN_ACCESSOR(SeqStringSetChar)
1448 class LAddI FINAL : public LTemplateInstruction<1, 2, 0> {
1450 LAddI(LOperand* left, LOperand* right) {
1455 LOperand* left() { return inputs_[0]; }
1456 LOperand* right() { return inputs_[1]; }
1458 static bool UseLea(HAdd* add) {
1459 return !add->CheckFlag(HValue::kCanOverflow) &&
1460 add->BetterLeftOperand()->UseCount() > 1;
1463 DECLARE_CONCRETE_INSTRUCTION(AddI, "add-i")
1464 DECLARE_HYDROGEN_ACCESSOR(Add)
1468 class LMathMinMax FINAL : public LTemplateInstruction<1, 2, 0> {
1470 LMathMinMax(LOperand* left, LOperand* right) {
1475 LOperand* left() { return inputs_[0]; }
1476 LOperand* right() { return inputs_[1]; }
1478 DECLARE_CONCRETE_INSTRUCTION(MathMinMax, "math-min-max")
1479 DECLARE_HYDROGEN_ACCESSOR(MathMinMax)
1483 class LPower FINAL : public LTemplateInstruction<1, 2, 0> {
1485 LPower(LOperand* left, LOperand* right) {
1490 LOperand* left() { return inputs_[0]; }
1491 LOperand* right() { return inputs_[1]; }
1493 DECLARE_CONCRETE_INSTRUCTION(Power, "power")
1494 DECLARE_HYDROGEN_ACCESSOR(Power)
1498 class LArithmeticD FINAL : public LTemplateInstruction<1, 2, 0> {
1500 LArithmeticD(Token::Value op, LOperand* left, LOperand* right)
1506 Token::Value op() const { return op_; }
1507 LOperand* left() { return inputs_[0]; }
1508 LOperand* right() { return inputs_[1]; }
1510 Opcode opcode() const OVERRIDE { return LInstruction::kArithmeticD; }
1511 void CompileToNative(LCodeGen* generator) OVERRIDE;
1512 const char* Mnemonic() const OVERRIDE;
1519 class LArithmeticT FINAL : public LTemplateInstruction<1, 3, 0> {
1521 LArithmeticT(Token::Value op,
1526 inputs_[0] = context;
1531 Token::Value op() const { return op_; }
1532 LOperand* context() { return inputs_[0]; }
1533 LOperand* left() { return inputs_[1]; }
1534 LOperand* right() { return inputs_[2]; }
1536 Opcode opcode() const OVERRIDE { return LInstruction::kArithmeticT; }
1537 void CompileToNative(LCodeGen* generator) OVERRIDE;
1538 const char* Mnemonic() const OVERRIDE;
1545 class LReturn FINAL : public LTemplateInstruction<0, 3, 0> {
1547 explicit LReturn(LOperand* value,
1549 LOperand* parameter_count) {
1551 inputs_[1] = context;
1552 inputs_[2] = parameter_count;
1555 LOperand* value() { return inputs_[0]; }
1556 LOperand* context() { return inputs_[1]; }
1558 bool has_constant_parameter_count() {
1559 return parameter_count()->IsConstantOperand();
1561 LConstantOperand* constant_parameter_count() {
1562 DCHECK(has_constant_parameter_count());
1563 return LConstantOperand::cast(parameter_count());
1565 LOperand* parameter_count() { return inputs_[2]; }
1567 DECLARE_CONCRETE_INSTRUCTION(Return, "return")
1568 DECLARE_HYDROGEN_ACCESSOR(Return)
1572 class LLoadNamedField FINAL : public LTemplateInstruction<1, 1, 0> {
1574 explicit LLoadNamedField(LOperand* object) {
1575 inputs_[0] = object;
1578 LOperand* object() { return inputs_[0]; }
1580 DECLARE_CONCRETE_INSTRUCTION(LoadNamedField, "load-named-field")
1581 DECLARE_HYDROGEN_ACCESSOR(LoadNamedField)
1585 class LLoadNamedGeneric FINAL : public LTemplateInstruction<1, 2, 1> {
1587 explicit LLoadNamedGeneric(LOperand* context, LOperand* object,
1589 inputs_[0] = context;
1590 inputs_[1] = object;
1594 DECLARE_CONCRETE_INSTRUCTION(LoadNamedGeneric, "load-named-generic")
1595 DECLARE_HYDROGEN_ACCESSOR(LoadNamedGeneric)
1597 LOperand* context() { return inputs_[0]; }
1598 LOperand* object() { return inputs_[1]; }
1599 LOperand* temp_vector() { return temps_[0]; }
1601 Handle<Object> name() const { return hydrogen()->name(); }
1605 class LLoadFunctionPrototype FINAL : public LTemplateInstruction<1, 1, 0> {
1607 explicit LLoadFunctionPrototype(LOperand* function) {
1608 inputs_[0] = function;
1611 DECLARE_CONCRETE_INSTRUCTION(LoadFunctionPrototype, "load-function-prototype")
1612 DECLARE_HYDROGEN_ACCESSOR(LoadFunctionPrototype)
1614 LOperand* function() { return inputs_[0]; }
1618 class LLoadRoot FINAL : public LTemplateInstruction<1, 0, 0> {
1620 DECLARE_CONCRETE_INSTRUCTION(LoadRoot, "load-root")
1621 DECLARE_HYDROGEN_ACCESSOR(LoadRoot)
1623 Heap::RootListIndex index() const { return hydrogen()->index(); }
1627 inline static bool ExternalArrayOpRequiresTemp(
1628 Representation key_representation,
1629 ElementsKind elements_kind) {
1630 // Operations that require the key to be divided by two to be converted into
1631 // an index cannot fold the scale operation into a load and need an extra
1632 // temp register to do the work.
1633 return SmiValuesAre31Bits() && key_representation.IsSmi() &&
1634 (elements_kind == EXTERNAL_INT8_ELEMENTS ||
1635 elements_kind == EXTERNAL_UINT8_ELEMENTS ||
1636 elements_kind == EXTERNAL_UINT8_CLAMPED_ELEMENTS ||
1637 elements_kind == UINT8_ELEMENTS ||
1638 elements_kind == INT8_ELEMENTS ||
1639 elements_kind == UINT8_CLAMPED_ELEMENTS);
1643 class LLoadKeyed FINAL : public LTemplateInstruction<1, 2, 0> {
1645 LLoadKeyed(LOperand* elements, LOperand* key) {
1646 inputs_[0] = elements;
1650 DECLARE_CONCRETE_INSTRUCTION(LoadKeyed, "load-keyed")
1651 DECLARE_HYDROGEN_ACCESSOR(LoadKeyed)
1653 bool is_external() const {
1654 return hydrogen()->is_external();
1656 bool is_fixed_typed_array() const {
1657 return hydrogen()->is_fixed_typed_array();
1659 bool is_typed_elements() const {
1660 return is_external() || is_fixed_typed_array();
1662 LOperand* elements() { return inputs_[0]; }
1663 LOperand* key() { return inputs_[1]; }
1664 void PrintDataTo(StringStream* stream) OVERRIDE;
1665 uint32_t base_offset() const { return hydrogen()->base_offset(); }
1666 ElementsKind elements_kind() const {
1667 return hydrogen()->elements_kind();
1672 class LLoadKeyedGeneric FINAL : public LTemplateInstruction<1, 3, 1> {
1674 LLoadKeyedGeneric(LOperand* context, LOperand* obj, LOperand* key,
1676 inputs_[0] = context;
1682 DECLARE_CONCRETE_INSTRUCTION(LoadKeyedGeneric, "load-keyed-generic")
1683 DECLARE_HYDROGEN_ACCESSOR(LoadKeyedGeneric)
1685 LOperand* context() { return inputs_[0]; }
1686 LOperand* object() { return inputs_[1]; }
1687 LOperand* key() { return inputs_[2]; }
1688 LOperand* temp_vector() { return temps_[0]; }
1692 class LLoadGlobalGeneric FINAL : public LTemplateInstruction<1, 2, 1> {
1694 explicit LLoadGlobalGeneric(LOperand* context, LOperand* global_object,
1696 inputs_[0] = context;
1697 inputs_[1] = global_object;
1701 DECLARE_CONCRETE_INSTRUCTION(LoadGlobalGeneric, "load-global-generic")
1702 DECLARE_HYDROGEN_ACCESSOR(LoadGlobalGeneric)
1704 LOperand* context() { return inputs_[0]; }
1705 LOperand* global_object() { return inputs_[1]; }
1706 LOperand* temp_vector() { return temps_[0]; }
1708 Handle<Object> name() const { return hydrogen()->name(); }
1709 bool for_typeof() const { return hydrogen()->for_typeof(); }
1713 class LLoadContextSlot FINAL : public LTemplateInstruction<1, 1, 0> {
1715 explicit LLoadContextSlot(LOperand* context) {
1716 inputs_[0] = context;
1719 LOperand* context() { return inputs_[0]; }
1721 DECLARE_CONCRETE_INSTRUCTION(LoadContextSlot, "load-context-slot")
1722 DECLARE_HYDROGEN_ACCESSOR(LoadContextSlot)
1724 int slot_index() { return hydrogen()->slot_index(); }
1726 void PrintDataTo(StringStream* stream) OVERRIDE;
1730 class LStoreContextSlot FINAL : public LTemplateInstruction<0, 2, 1> {
1732 LStoreContextSlot(LOperand* context, LOperand* value, LOperand* temp) {
1733 inputs_[0] = context;
1738 LOperand* context() { return inputs_[0]; }
1739 LOperand* value() { return inputs_[1]; }
1740 LOperand* temp() { return temps_[0]; }
1742 DECLARE_CONCRETE_INSTRUCTION(StoreContextSlot, "store-context-slot")
1743 DECLARE_HYDROGEN_ACCESSOR(StoreContextSlot)
1745 int slot_index() { return hydrogen()->slot_index(); }
1747 void PrintDataTo(StringStream* stream) OVERRIDE;
1751 class LPushArgument FINAL : public LTemplateInstruction<0, 1, 0> {
1753 explicit LPushArgument(LOperand* value) {
1757 LOperand* value() { return inputs_[0]; }
1759 DECLARE_CONCRETE_INSTRUCTION(PushArgument, "push-argument")
1763 class LDrop FINAL : public LTemplateInstruction<0, 0, 0> {
1765 explicit LDrop(int count) : count_(count) { }
1767 int count() const { return count_; }
1769 DECLARE_CONCRETE_INSTRUCTION(Drop, "drop")
1776 class LStoreCodeEntry FINAL: public LTemplateInstruction<0, 2, 0> {
1778 LStoreCodeEntry(LOperand* function, LOperand* code_object) {
1779 inputs_[0] = function;
1780 inputs_[1] = code_object;
1783 LOperand* function() { return inputs_[0]; }
1784 LOperand* code_object() { return inputs_[1]; }
1786 void PrintDataTo(StringStream* stream) OVERRIDE;
1788 DECLARE_CONCRETE_INSTRUCTION(StoreCodeEntry, "store-code-entry")
1789 DECLARE_HYDROGEN_ACCESSOR(StoreCodeEntry)
1793 class LInnerAllocatedObject FINAL: public LTemplateInstruction<1, 2, 0> {
1795 LInnerAllocatedObject(LOperand* base_object, LOperand* offset) {
1796 inputs_[0] = base_object;
1797 inputs_[1] = offset;
1800 LOperand* base_object() const { return inputs_[0]; }
1801 LOperand* offset() const { return inputs_[1]; }
1803 void PrintDataTo(StringStream* stream) OVERRIDE;
1805 DECLARE_CONCRETE_INSTRUCTION(InnerAllocatedObject, "inner-allocated-object")
1809 class LThisFunction FINAL : public LTemplateInstruction<1, 0, 0> {
1811 DECLARE_CONCRETE_INSTRUCTION(ThisFunction, "this-function")
1812 DECLARE_HYDROGEN_ACCESSOR(ThisFunction)
1816 class LContext FINAL : public LTemplateInstruction<1, 0, 0> {
1818 DECLARE_CONCRETE_INSTRUCTION(Context, "context")
1819 DECLARE_HYDROGEN_ACCESSOR(Context)
1823 class LDeclareGlobals FINAL : public LTemplateInstruction<0, 1, 0> {
1825 explicit LDeclareGlobals(LOperand* context) {
1826 inputs_[0] = context;
1829 LOperand* context() { return inputs_[0]; }
1831 DECLARE_CONCRETE_INSTRUCTION(DeclareGlobals, "declare-globals")
1832 DECLARE_HYDROGEN_ACCESSOR(DeclareGlobals)
1836 class LCallJSFunction FINAL : public LTemplateInstruction<1, 1, 0> {
1838 explicit LCallJSFunction(LOperand* function) {
1839 inputs_[0] = function;
1842 LOperand* function() { return inputs_[0]; }
1844 DECLARE_CONCRETE_INSTRUCTION(CallJSFunction, "call-js-function")
1845 DECLARE_HYDROGEN_ACCESSOR(CallJSFunction)
1847 void PrintDataTo(StringStream* stream) OVERRIDE;
1849 int arity() const { return hydrogen()->argument_count() - 1; }
1853 class LCallWithDescriptor FINAL : public LTemplateResultInstruction<1> {
1855 LCallWithDescriptor(CallInterfaceDescriptor descriptor,
1856 const ZoneList<LOperand*>& operands, Zone* zone)
1857 : inputs_(descriptor.GetRegisterParameterCount() + 1, zone) {
1858 DCHECK(descriptor.GetRegisterParameterCount() + 1 == operands.length());
1859 inputs_.AddAll(operands, zone);
1862 LOperand* target() const { return inputs_[0]; }
1864 DECLARE_HYDROGEN_ACCESSOR(CallWithDescriptor)
1867 DECLARE_CONCRETE_INSTRUCTION(CallWithDescriptor, "call-with-descriptor")
1869 void PrintDataTo(StringStream* stream) OVERRIDE;
1871 int arity() const { return hydrogen()->argument_count() - 1; }
1873 ZoneList<LOperand*> inputs_;
1875 // Iterator support.
1876 int InputCount() FINAL { return inputs_.length(); }
1877 LOperand* InputAt(int i) FINAL { return inputs_[i]; }
1879 int TempCount() FINAL { return 0; }
1880 LOperand* TempAt(int i) FINAL { return NULL; }
1884 class LInvokeFunction FINAL : public LTemplateInstruction<1, 2, 0> {
1886 LInvokeFunction(LOperand* context, LOperand* function) {
1887 inputs_[0] = context;
1888 inputs_[1] = function;
1891 LOperand* context() { return inputs_[0]; }
1892 LOperand* function() { return inputs_[1]; }
1894 DECLARE_CONCRETE_INSTRUCTION(InvokeFunction, "invoke-function")
1895 DECLARE_HYDROGEN_ACCESSOR(InvokeFunction)
1897 void PrintDataTo(StringStream* stream) OVERRIDE;
1899 int arity() const { return hydrogen()->argument_count() - 1; }
1903 class LCallFunction FINAL : public LTemplateInstruction<1, 2, 2> {
1905 LCallFunction(LOperand* context, LOperand* function, LOperand* slot,
1907 inputs_[0] = context;
1908 inputs_[1] = function;
1913 DECLARE_CONCRETE_INSTRUCTION(CallFunction, "call-function")
1914 DECLARE_HYDROGEN_ACCESSOR(CallFunction)
1916 LOperand* context() { return inputs_[0]; }
1917 LOperand* function() { return inputs_[1]; }
1918 LOperand* temp_slot() { return temps_[0]; }
1919 LOperand* temp_vector() { return temps_[1]; }
1920 int arity() const { return hydrogen()->argument_count() - 1; }
1922 void PrintDataTo(StringStream* stream) OVERRIDE;
1926 class LCallNew FINAL : public LTemplateInstruction<1, 2, 0> {
1928 LCallNew(LOperand* context, LOperand* constructor) {
1929 inputs_[0] = context;
1930 inputs_[1] = constructor;
1933 LOperand* context() { return inputs_[0]; }
1934 LOperand* constructor() { return inputs_[1]; }
1936 DECLARE_CONCRETE_INSTRUCTION(CallNew, "call-new")
1937 DECLARE_HYDROGEN_ACCESSOR(CallNew)
1939 void PrintDataTo(StringStream* stream) OVERRIDE;
1941 int arity() const { return hydrogen()->argument_count() - 1; }
1945 class LCallNewArray FINAL : public LTemplateInstruction<1, 2, 0> {
1947 LCallNewArray(LOperand* context, LOperand* constructor) {
1948 inputs_[0] = context;
1949 inputs_[1] = constructor;
1952 LOperand* context() { return inputs_[0]; }
1953 LOperand* constructor() { return inputs_[1]; }
1955 DECLARE_CONCRETE_INSTRUCTION(CallNewArray, "call-new-array")
1956 DECLARE_HYDROGEN_ACCESSOR(CallNewArray)
1958 void PrintDataTo(StringStream* stream) OVERRIDE;
1960 int arity() const { return hydrogen()->argument_count() - 1; }
1964 class LCallRuntime FINAL : public LTemplateInstruction<1, 1, 0> {
1966 explicit LCallRuntime(LOperand* context) {
1967 inputs_[0] = context;
1970 LOperand* context() { return inputs_[0]; }
1972 DECLARE_CONCRETE_INSTRUCTION(CallRuntime, "call-runtime")
1973 DECLARE_HYDROGEN_ACCESSOR(CallRuntime)
1975 bool ClobbersDoubleRegisters(Isolate* isolate) const OVERRIDE {
1976 return save_doubles() == kDontSaveFPRegs;
1979 const Runtime::Function* function() const { return hydrogen()->function(); }
1980 int arity() const { return hydrogen()->argument_count(); }
1981 SaveFPRegsMode save_doubles() const { return hydrogen()->save_doubles(); }
1985 class LInteger32ToDouble FINAL : public LTemplateInstruction<1, 1, 0> {
1987 explicit LInteger32ToDouble(LOperand* value) {
1991 LOperand* value() { return inputs_[0]; }
1993 DECLARE_CONCRETE_INSTRUCTION(Integer32ToDouble, "int32-to-double")
1997 class LUint32ToDouble FINAL : public LTemplateInstruction<1, 1, 0> {
1999 explicit LUint32ToDouble(LOperand* value) {
2003 LOperand* value() { return inputs_[0]; }
2005 DECLARE_CONCRETE_INSTRUCTION(Uint32ToDouble, "uint32-to-double")
2009 class LNumberTagI FINAL : public LTemplateInstruction<1, 1, 2> {
2011 LNumberTagI(LOperand* value, LOperand* temp1, LOperand* temp2) {
2017 LOperand* value() { return inputs_[0]; }
2018 LOperand* temp1() { return temps_[0]; }
2019 LOperand* temp2() { return temps_[1]; }
2021 DECLARE_CONCRETE_INSTRUCTION(NumberTagI, "number-tag-i")
2025 class LNumberTagU FINAL : public LTemplateInstruction<1, 1, 2> {
2027 LNumberTagU(LOperand* value, LOperand* temp1, LOperand* temp2) {
2033 LOperand* value() { return inputs_[0]; }
2034 LOperand* temp1() { return temps_[0]; }
2035 LOperand* temp2() { return temps_[1]; }
2037 DECLARE_CONCRETE_INSTRUCTION(NumberTagU, "number-tag-u")
2041 class LNumberTagD FINAL : public LTemplateInstruction<1, 1, 1> {
2043 explicit LNumberTagD(LOperand* value, LOperand* temp) {
2048 LOperand* value() { return inputs_[0]; }
2049 LOperand* temp() { return temps_[0]; }
2051 DECLARE_CONCRETE_INSTRUCTION(NumberTagD, "number-tag-d")
2052 DECLARE_HYDROGEN_ACCESSOR(Change)
2056 // Sometimes truncating conversion from a tagged value to an int32.
2057 class LDoubleToI FINAL : public LTemplateInstruction<1, 1, 0> {
2059 explicit LDoubleToI(LOperand* value) {
2063 LOperand* value() { return inputs_[0]; }
2065 DECLARE_CONCRETE_INSTRUCTION(DoubleToI, "double-to-i")
2066 DECLARE_HYDROGEN_ACCESSOR(UnaryOperation)
2068 bool truncating() { return hydrogen()->CanTruncateToInt32(); }
2072 class LDoubleToSmi FINAL : public LTemplateInstruction<1, 1, 0> {
2074 explicit LDoubleToSmi(LOperand* value) {
2078 LOperand* value() { return inputs_[0]; }
2080 DECLARE_CONCRETE_INSTRUCTION(DoubleToSmi, "double-to-smi")
2081 DECLARE_HYDROGEN_ACCESSOR(UnaryOperation)
2085 // Truncating conversion from a tagged value to an int32.
2086 class LTaggedToI FINAL : public LTemplateInstruction<1, 1, 1> {
2088 LTaggedToI(LOperand* value, LOperand* temp) {
2093 LOperand* value() { return inputs_[0]; }
2094 LOperand* temp() { return temps_[0]; }
2096 DECLARE_CONCRETE_INSTRUCTION(TaggedToI, "tagged-to-i")
2097 DECLARE_HYDROGEN_ACCESSOR(Change)
2099 bool truncating() { return hydrogen()->CanTruncateToInt32(); }
2103 class LSmiTag FINAL : public LTemplateInstruction<1, 1, 0> {
2105 explicit LSmiTag(LOperand* value) {
2109 LOperand* value() { return inputs_[0]; }
2111 DECLARE_CONCRETE_INSTRUCTION(SmiTag, "smi-tag")
2112 DECLARE_HYDROGEN_ACCESSOR(Change)
2116 class LNumberUntagD FINAL : public LTemplateInstruction<1, 1, 0> {
2118 explicit LNumberUntagD(LOperand* value) {
2122 LOperand* value() { return inputs_[0]; }
2124 DECLARE_CONCRETE_INSTRUCTION(NumberUntagD, "double-untag")
2125 DECLARE_HYDROGEN_ACCESSOR(Change);
2129 class LSmiUntag FINAL : public LTemplateInstruction<1, 1, 0> {
2131 LSmiUntag(LOperand* value, bool needs_check)
2132 : needs_check_(needs_check) {
2136 LOperand* value() { return inputs_[0]; }
2137 bool needs_check() const { return needs_check_; }
2139 DECLARE_CONCRETE_INSTRUCTION(SmiUntag, "smi-untag")
2146 class LStoreNamedField FINAL : public LTemplateInstruction<0, 2, 1> {
2148 LStoreNamedField(LOperand* object, LOperand* value, LOperand* temp) {
2149 inputs_[0] = object;
2154 LOperand* object() { return inputs_[0]; }
2155 LOperand* value() { return inputs_[1]; }
2156 LOperand* temp() { return temps_[0]; }
2158 DECLARE_CONCRETE_INSTRUCTION(StoreNamedField, "store-named-field")
2159 DECLARE_HYDROGEN_ACCESSOR(StoreNamedField)
2161 void PrintDataTo(StringStream* stream) OVERRIDE;
2163 Representation representation() const {
2164 return hydrogen()->field_representation();
2169 class LStoreNamedGeneric FINAL : public LTemplateInstruction<0, 3, 0> {
2171 LStoreNamedGeneric(LOperand* context, LOperand* object, LOperand* value) {
2172 inputs_[0] = context;
2173 inputs_[1] = object;
2177 LOperand* context() { return inputs_[0]; }
2178 LOperand* object() { return inputs_[1]; }
2179 LOperand* value() { return inputs_[2]; }
2181 DECLARE_CONCRETE_INSTRUCTION(StoreNamedGeneric, "store-named-generic")
2182 DECLARE_HYDROGEN_ACCESSOR(StoreNamedGeneric)
2184 void PrintDataTo(StringStream* stream) OVERRIDE;
2186 Handle<Object> name() const { return hydrogen()->name(); }
2187 LanguageMode language_mode() { return hydrogen()->language_mode(); }
2191 class LStoreKeyed FINAL : public LTemplateInstruction<0, 3, 0> {
2193 LStoreKeyed(LOperand* object, LOperand* key, LOperand* value) {
2194 inputs_[0] = object;
2199 bool is_external() const { return hydrogen()->is_external(); }
2200 bool is_fixed_typed_array() const {
2201 return hydrogen()->is_fixed_typed_array();
2203 bool is_typed_elements() const {
2204 return is_external() || is_fixed_typed_array();
2206 LOperand* elements() { return inputs_[0]; }
2207 LOperand* key() { return inputs_[1]; }
2208 LOperand* value() { return inputs_[2]; }
2209 ElementsKind elements_kind() const { return hydrogen()->elements_kind(); }
2211 DECLARE_CONCRETE_INSTRUCTION(StoreKeyed, "store-keyed")
2212 DECLARE_HYDROGEN_ACCESSOR(StoreKeyed)
2214 void PrintDataTo(StringStream* stream) OVERRIDE;
2215 bool NeedsCanonicalization() { return hydrogen()->NeedsCanonicalization(); }
2216 uint32_t base_offset() const { return hydrogen()->base_offset(); }
2220 class LStoreKeyedGeneric FINAL : public LTemplateInstruction<0, 4, 0> {
2222 LStoreKeyedGeneric(LOperand* context,
2226 inputs_[0] = context;
2227 inputs_[1] = object;
2232 LOperand* context() { return inputs_[0]; }
2233 LOperand* object() { return inputs_[1]; }
2234 LOperand* key() { return inputs_[2]; }
2235 LOperand* value() { return inputs_[3]; }
2237 DECLARE_CONCRETE_INSTRUCTION(StoreKeyedGeneric, "store-keyed-generic")
2238 DECLARE_HYDROGEN_ACCESSOR(StoreKeyedGeneric)
2240 void PrintDataTo(StringStream* stream) OVERRIDE;
2242 LanguageMode language_mode() { return hydrogen()->language_mode(); }
2246 class LTransitionElementsKind FINAL : public LTemplateInstruction<0, 2, 2> {
2248 LTransitionElementsKind(LOperand* object,
2250 LOperand* new_map_temp,
2252 inputs_[0] = object;
2253 inputs_[1] = context;
2254 temps_[0] = new_map_temp;
2258 LOperand* object() { return inputs_[0]; }
2259 LOperand* context() { return inputs_[1]; }
2260 LOperand* new_map_temp() { return temps_[0]; }
2261 LOperand* temp() { return temps_[1]; }
2263 DECLARE_CONCRETE_INSTRUCTION(TransitionElementsKind,
2264 "transition-elements-kind")
2265 DECLARE_HYDROGEN_ACCESSOR(TransitionElementsKind)
2267 void PrintDataTo(StringStream* stream) OVERRIDE;
2269 Handle<Map> original_map() { return hydrogen()->original_map().handle(); }
2270 Handle<Map> transitioned_map() {
2271 return hydrogen()->transitioned_map().handle();
2273 ElementsKind from_kind() { return hydrogen()->from_kind(); }
2274 ElementsKind to_kind() { return hydrogen()->to_kind(); }
2278 class LTrapAllocationMemento FINAL : public LTemplateInstruction<0, 1, 1> {
2280 LTrapAllocationMemento(LOperand* object,
2282 inputs_[0] = object;
2286 LOperand* object() { return inputs_[0]; }
2287 LOperand* temp() { return temps_[0]; }
2289 DECLARE_CONCRETE_INSTRUCTION(TrapAllocationMemento,
2290 "trap-allocation-memento")
2294 class LStringAdd FINAL : public LTemplateInstruction<1, 3, 0> {
2296 LStringAdd(LOperand* context, LOperand* left, LOperand* right) {
2297 inputs_[0] = context;
2302 LOperand* context() { return inputs_[0]; }
2303 LOperand* left() { return inputs_[1]; }
2304 LOperand* right() { return inputs_[2]; }
2306 DECLARE_CONCRETE_INSTRUCTION(StringAdd, "string-add")
2307 DECLARE_HYDROGEN_ACCESSOR(StringAdd)
2311 class LStringCharCodeAt FINAL : public LTemplateInstruction<1, 3, 0> {
2313 LStringCharCodeAt(LOperand* context, LOperand* string, LOperand* index) {
2314 inputs_[0] = context;
2315 inputs_[1] = string;
2319 LOperand* context() { return inputs_[0]; }
2320 LOperand* string() { return inputs_[1]; }
2321 LOperand* index() { return inputs_[2]; }
2323 DECLARE_CONCRETE_INSTRUCTION(StringCharCodeAt, "string-char-code-at")
2324 DECLARE_HYDROGEN_ACCESSOR(StringCharCodeAt)
2328 class LStringCharFromCode FINAL : public LTemplateInstruction<1, 2, 0> {
2330 explicit LStringCharFromCode(LOperand* context, LOperand* char_code) {
2331 inputs_[0] = context;
2332 inputs_[1] = char_code;
2335 LOperand* context() { return inputs_[0]; }
2336 LOperand* char_code() { return inputs_[1]; }
2338 DECLARE_CONCRETE_INSTRUCTION(StringCharFromCode, "string-char-from-code")
2339 DECLARE_HYDROGEN_ACCESSOR(StringCharFromCode)
2343 class LCheckValue FINAL : public LTemplateInstruction<0, 1, 0> {
2345 explicit LCheckValue(LOperand* value) {
2349 LOperand* value() { return inputs_[0]; }
2351 DECLARE_CONCRETE_INSTRUCTION(CheckValue, "check-value")
2352 DECLARE_HYDROGEN_ACCESSOR(CheckValue)
2356 class LCheckInstanceType FINAL : public LTemplateInstruction<0, 1, 0> {
2358 explicit LCheckInstanceType(LOperand* value) {
2362 LOperand* value() { return inputs_[0]; }
2364 DECLARE_CONCRETE_INSTRUCTION(CheckInstanceType, "check-instance-type")
2365 DECLARE_HYDROGEN_ACCESSOR(CheckInstanceType)
2369 class LCheckMaps FINAL : public LTemplateInstruction<0, 1, 0> {
2371 explicit LCheckMaps(LOperand* value = NULL) {
2375 LOperand* value() { return inputs_[0]; }
2377 DECLARE_CONCRETE_INSTRUCTION(CheckMaps, "check-maps")
2378 DECLARE_HYDROGEN_ACCESSOR(CheckMaps)
2382 class LCheckSmi FINAL : public LTemplateInstruction<1, 1, 0> {
2384 explicit LCheckSmi(LOperand* value) {
2388 LOperand* value() { return inputs_[0]; }
2390 DECLARE_CONCRETE_INSTRUCTION(CheckSmi, "check-smi")
2394 class LClampDToUint8 FINAL : public LTemplateInstruction<1, 1, 0> {
2396 explicit LClampDToUint8(LOperand* unclamped) {
2397 inputs_[0] = unclamped;
2400 LOperand* unclamped() { return inputs_[0]; }
2402 DECLARE_CONCRETE_INSTRUCTION(ClampDToUint8, "clamp-d-to-uint8")
2406 class LClampIToUint8 FINAL : public LTemplateInstruction<1, 1, 0> {
2408 explicit LClampIToUint8(LOperand* unclamped) {
2409 inputs_[0] = unclamped;
2412 LOperand* unclamped() { return inputs_[0]; }
2414 DECLARE_CONCRETE_INSTRUCTION(ClampIToUint8, "clamp-i-to-uint8")
2418 class LClampTToUint8 FINAL : public LTemplateInstruction<1, 1, 1> {
2420 LClampTToUint8(LOperand* unclamped,
2421 LOperand* temp_xmm) {
2422 inputs_[0] = unclamped;
2423 temps_[0] = temp_xmm;
2426 LOperand* unclamped() { return inputs_[0]; }
2427 LOperand* temp_xmm() { return temps_[0]; }
2429 DECLARE_CONCRETE_INSTRUCTION(ClampTToUint8, "clamp-t-to-uint8")
2433 class LCheckNonSmi FINAL : public LTemplateInstruction<0, 1, 0> {
2435 explicit LCheckNonSmi(LOperand* value) {
2439 LOperand* value() { return inputs_[0]; }
2441 DECLARE_CONCRETE_INSTRUCTION(CheckNonSmi, "check-non-smi")
2442 DECLARE_HYDROGEN_ACCESSOR(CheckHeapObject)
2446 class LDoubleBits FINAL : public LTemplateInstruction<1, 1, 0> {
2448 explicit LDoubleBits(LOperand* value) {
2452 LOperand* value() { return inputs_[0]; }
2454 DECLARE_CONCRETE_INSTRUCTION(DoubleBits, "double-bits")
2455 DECLARE_HYDROGEN_ACCESSOR(DoubleBits)
2459 class LConstructDouble FINAL : public LTemplateInstruction<1, 2, 0> {
2461 LConstructDouble(LOperand* hi, LOperand* lo) {
2466 LOperand* hi() { return inputs_[0]; }
2467 LOperand* lo() { return inputs_[1]; }
2469 DECLARE_CONCRETE_INSTRUCTION(ConstructDouble, "construct-double")
2473 class LAllocate FINAL : public LTemplateInstruction<1, 2, 1> {
2475 LAllocate(LOperand* context, LOperand* size, LOperand* temp) {
2476 inputs_[0] = context;
2481 LOperand* context() { return inputs_[0]; }
2482 LOperand* size() { return inputs_[1]; }
2483 LOperand* temp() { return temps_[0]; }
2485 DECLARE_CONCRETE_INSTRUCTION(Allocate, "allocate")
2486 DECLARE_HYDROGEN_ACCESSOR(Allocate)
2490 class LRegExpLiteral FINAL : public LTemplateInstruction<1, 1, 0> {
2492 explicit LRegExpLiteral(LOperand* context) {
2493 inputs_[0] = context;
2496 LOperand* context() { return inputs_[0]; }
2498 DECLARE_CONCRETE_INSTRUCTION(RegExpLiteral, "regexp-literal")
2499 DECLARE_HYDROGEN_ACCESSOR(RegExpLiteral)
2503 class LFunctionLiteral FINAL : public LTemplateInstruction<1, 1, 0> {
2505 explicit LFunctionLiteral(LOperand* context) {
2506 inputs_[0] = context;
2509 LOperand* context() { return inputs_[0]; }
2511 DECLARE_CONCRETE_INSTRUCTION(FunctionLiteral, "function-literal")
2512 DECLARE_HYDROGEN_ACCESSOR(FunctionLiteral)
2516 class LToFastProperties FINAL : public LTemplateInstruction<1, 1, 0> {
2518 explicit LToFastProperties(LOperand* value) {
2522 LOperand* value() { return inputs_[0]; }
2524 DECLARE_CONCRETE_INSTRUCTION(ToFastProperties, "to-fast-properties")
2525 DECLARE_HYDROGEN_ACCESSOR(ToFastProperties)
2529 class LTypeof FINAL : public LTemplateInstruction<1, 2, 0> {
2531 LTypeof(LOperand* context, LOperand* value) {
2532 inputs_[0] = context;
2536 LOperand* context() { return inputs_[0]; }
2537 LOperand* value() { return inputs_[1]; }
2539 DECLARE_CONCRETE_INSTRUCTION(Typeof, "typeof")
2543 class LTypeofIsAndBranch FINAL : public LControlInstruction<1, 0> {
2545 explicit LTypeofIsAndBranch(LOperand* value) {
2549 LOperand* value() { return inputs_[0]; }
2551 DECLARE_CONCRETE_INSTRUCTION(TypeofIsAndBranch, "typeof-is-and-branch")
2552 DECLARE_HYDROGEN_ACCESSOR(TypeofIsAndBranch)
2554 Handle<String> type_literal() { return hydrogen()->type_literal(); }
2556 void PrintDataTo(StringStream* stream) OVERRIDE;
2560 class LIsConstructCallAndBranch FINAL : public LControlInstruction<0, 1> {
2562 explicit LIsConstructCallAndBranch(LOperand* temp) {
2566 LOperand* temp() { return temps_[0]; }
2568 DECLARE_CONCRETE_INSTRUCTION(IsConstructCallAndBranch,
2569 "is-construct-call-and-branch")
2570 DECLARE_HYDROGEN_ACCESSOR(IsConstructCallAndBranch)
2574 class LOsrEntry FINAL : public LTemplateInstruction<0, 0, 0> {
2578 bool HasInterestingComment(LCodeGen* gen) const OVERRIDE { return false; }
2579 DECLARE_CONCRETE_INSTRUCTION(OsrEntry, "osr-entry")
2583 class LStackCheck FINAL : public LTemplateInstruction<0, 1, 0> {
2585 explicit LStackCheck(LOperand* context) {
2586 inputs_[0] = context;
2589 LOperand* context() { return inputs_[0]; }
2591 DECLARE_CONCRETE_INSTRUCTION(StackCheck, "stack-check")
2592 DECLARE_HYDROGEN_ACCESSOR(StackCheck)
2594 Label* done_label() { return &done_label_; }
2601 class LForInPrepareMap FINAL : public LTemplateInstruction<1, 2, 0> {
2603 LForInPrepareMap(LOperand* context, LOperand* object) {
2604 inputs_[0] = context;
2605 inputs_[1] = object;
2608 LOperand* context() { return inputs_[0]; }
2609 LOperand* object() { return inputs_[1]; }
2611 DECLARE_CONCRETE_INSTRUCTION(ForInPrepareMap, "for-in-prepare-map")
2615 class LForInCacheArray FINAL : public LTemplateInstruction<1, 1, 0> {
2617 explicit LForInCacheArray(LOperand* map) {
2621 LOperand* map() { return inputs_[0]; }
2623 DECLARE_CONCRETE_INSTRUCTION(ForInCacheArray, "for-in-cache-array")
2626 return HForInCacheArray::cast(this->hydrogen_value())->idx();
2631 class LCheckMapValue FINAL : public LTemplateInstruction<0, 2, 0> {
2633 LCheckMapValue(LOperand* value, LOperand* map) {
2638 LOperand* value() { return inputs_[0]; }
2639 LOperand* map() { return inputs_[1]; }
2641 DECLARE_CONCRETE_INSTRUCTION(CheckMapValue, "check-map-value")
2645 class LLoadFieldByIndex FINAL : public LTemplateInstruction<1, 2, 0> {
2647 LLoadFieldByIndex(LOperand* object, LOperand* index) {
2648 inputs_[0] = object;
2652 LOperand* object() { return inputs_[0]; }
2653 LOperand* index() { return inputs_[1]; }
2655 DECLARE_CONCRETE_INSTRUCTION(LoadFieldByIndex, "load-field-by-index")
2659 class LStoreFrameContext: public LTemplateInstruction<0, 1, 0> {
2661 explicit LStoreFrameContext(LOperand* context) {
2662 inputs_[0] = context;
2665 LOperand* context() { return inputs_[0]; }
2667 DECLARE_CONCRETE_INSTRUCTION(StoreFrameContext, "store-frame-context")
2671 class LAllocateBlockContext: public LTemplateInstruction<1, 2, 0> {
2673 LAllocateBlockContext(LOperand* context, LOperand* function) {
2674 inputs_[0] = context;
2675 inputs_[1] = function;
2678 LOperand* context() { return inputs_[0]; }
2679 LOperand* function() { return inputs_[1]; }
2681 Handle<ScopeInfo> scope_info() { return hydrogen()->scope_info(); }
2683 DECLARE_CONCRETE_INSTRUCTION(AllocateBlockContext, "allocate-block-context")
2684 DECLARE_HYDROGEN_ACCESSOR(AllocateBlockContext)
2688 class LChunkBuilder;
2689 class LPlatformChunk FINAL : public LChunk {
2691 LPlatformChunk(CompilationInfo* info, HGraph* graph)
2692 : LChunk(info, graph),
2693 dehoisted_key_ids_(graph->GetMaximumValueID(), graph->zone()) { }
2695 int GetNextSpillIndex(RegisterKind kind);
2696 LOperand* GetNextSpillSlot(RegisterKind kind);
2697 BitVector* GetDehoistedKeyIds() { return &dehoisted_key_ids_; }
2698 bool IsDehoistedKey(HValue* value) {
2699 return dehoisted_key_ids_.Contains(value->id());
2703 BitVector dehoisted_key_ids_;
2707 class LChunkBuilder FINAL : public LChunkBuilderBase {
2709 LChunkBuilder(CompilationInfo* info, HGraph* graph, LAllocator* allocator)
2710 : LChunkBuilderBase(info, graph),
2711 current_instruction_(NULL),
2712 current_block_(NULL),
2714 allocator_(allocator) {}
2716 // Build the sequence for the graph.
2717 LPlatformChunk* Build();
2719 // Declare methods that deal with the individual node types.
2720 #define DECLARE_DO(type) LInstruction* Do##type(H##type* node);
2721 HYDROGEN_CONCRETE_INSTRUCTION_LIST(DECLARE_DO)
2724 LInstruction* DoMathFloor(HUnaryMathOperation* instr);
2725 LInstruction* DoMathRound(HUnaryMathOperation* instr);
2726 LInstruction* DoMathFround(HUnaryMathOperation* instr);
2727 LInstruction* DoMathAbs(HUnaryMathOperation* instr);
2728 LInstruction* DoMathLog(HUnaryMathOperation* instr);
2729 LInstruction* DoMathExp(HUnaryMathOperation* instr);
2730 LInstruction* DoMathSqrt(HUnaryMathOperation* instr);
2731 LInstruction* DoMathPowHalf(HUnaryMathOperation* instr);
2732 LInstruction* DoMathClz32(HUnaryMathOperation* instr);
2733 LInstruction* DoDivByPowerOf2I(HDiv* instr);
2734 LInstruction* DoDivByConstI(HDiv* instr);
2735 LInstruction* DoDivI(HDiv* instr);
2736 LInstruction* DoModByPowerOf2I(HMod* instr);
2737 LInstruction* DoModByConstI(HMod* instr);
2738 LInstruction* DoModI(HMod* instr);
2739 LInstruction* DoFlooringDivByPowerOf2I(HMathFloorOfDiv* instr);
2740 LInstruction* DoFlooringDivByConstI(HMathFloorOfDiv* instr);
2741 LInstruction* DoFlooringDivI(HMathFloorOfDiv* instr);
2744 // Methods for getting operands for Use / Define / Temp.
2745 LUnallocated* ToUnallocated(Register reg);
2746 LUnallocated* ToUnallocated(XMMRegister reg);
2748 // Methods for setting up define-use relationships.
2749 MUST_USE_RESULT LOperand* Use(HValue* value, LUnallocated* operand);
2750 MUST_USE_RESULT LOperand* UseFixed(HValue* value, Register fixed_register);
2751 MUST_USE_RESULT LOperand* UseFixedDouble(HValue* value,
2752 XMMRegister fixed_register);
2754 // A value that is guaranteed to be allocated to a register.
2755 // Operand created by UseRegister is guaranteed to be live until the end of
2756 // instruction. This means that register allocator will not reuse it's
2757 // register for any other operand inside instruction.
2758 // Operand created by UseRegisterAtStart is guaranteed to be live only at
2759 // instruction start. Register allocator is free to assign the same register
2760 // to some other operand used inside instruction (i.e. temporary or
2762 MUST_USE_RESULT LOperand* UseRegister(HValue* value);
2763 MUST_USE_RESULT LOperand* UseRegisterAtStart(HValue* value);
2765 // An input operand in a register that may be trashed.
2766 MUST_USE_RESULT LOperand* UseTempRegister(HValue* value);
2768 // An input operand in a register that may be trashed or a constant operand.
2769 MUST_USE_RESULT LOperand* UseTempRegisterOrConstant(HValue* value);
2771 // An input operand in a register or stack slot.
2772 MUST_USE_RESULT LOperand* Use(HValue* value);
2773 MUST_USE_RESULT LOperand* UseAtStart(HValue* value);
2775 // An input operand in a register, stack slot or a constant operand.
2776 MUST_USE_RESULT LOperand* UseOrConstant(HValue* value);
2777 MUST_USE_RESULT LOperand* UseOrConstantAtStart(HValue* value);
2779 // An input operand in a register or a constant operand.
2780 MUST_USE_RESULT LOperand* UseRegisterOrConstant(HValue* value);
2781 MUST_USE_RESULT LOperand* UseRegisterOrConstantAtStart(HValue* value);
2783 // An input operand in a constant operand.
2784 MUST_USE_RESULT LOperand* UseConstant(HValue* value);
2786 // An input operand in register, stack slot or a constant operand.
2787 // Will not be moved to a register even if one is freely available.
2788 MUST_USE_RESULT LOperand* UseAny(HValue* value) OVERRIDE;
2790 // Temporary operand that must be in a register.
2791 MUST_USE_RESULT LUnallocated* TempRegister();
2792 MUST_USE_RESULT LOperand* FixedTemp(Register reg);
2793 MUST_USE_RESULT LOperand* FixedTemp(XMMRegister reg);
2795 // Methods for setting up define-use relationships.
2796 // Return the same instruction that they are passed.
2797 LInstruction* Define(LTemplateResultInstruction<1>* instr,
2798 LUnallocated* result);
2799 LInstruction* DefineAsRegister(LTemplateResultInstruction<1>* instr);
2800 LInstruction* DefineAsSpilled(LTemplateResultInstruction<1>* instr,
2802 LInstruction* DefineSameAsFirst(LTemplateResultInstruction<1>* instr);
2803 LInstruction* DefineFixed(LTemplateResultInstruction<1>* instr,
2805 LInstruction* DefineFixedDouble(LTemplateResultInstruction<1>* instr,
2807 // Assigns an environment to an instruction. An instruction which can
2808 // deoptimize must have an environment.
2809 LInstruction* AssignEnvironment(LInstruction* instr);
2810 // Assigns a pointer map to an instruction. An instruction which can
2811 // trigger a GC or a lazy deoptimization must have a pointer map.
2812 LInstruction* AssignPointerMap(LInstruction* instr);
2814 enum CanDeoptimize { CAN_DEOPTIMIZE_EAGERLY, CANNOT_DEOPTIMIZE_EAGERLY };
2816 // Marks a call for the register allocator. Assigns a pointer map to
2817 // support GC and lazy deoptimization. Assigns an environment to support
2818 // eager deoptimization if CAN_DEOPTIMIZE_EAGERLY.
2819 LInstruction* MarkAsCall(
2820 LInstruction* instr,
2821 HInstruction* hinstr,
2822 CanDeoptimize can_deoptimize = CANNOT_DEOPTIMIZE_EAGERLY);
2824 void VisitInstruction(HInstruction* current);
2825 void AddInstruction(LInstruction* instr, HInstruction* current);
2827 void DoBasicBlock(HBasicBlock* block, HBasicBlock* next_block);
2828 LInstruction* DoShift(Token::Value op, HBitwiseBinaryOperation* instr);
2829 LInstruction* DoArithmeticD(Token::Value op,
2830 HArithmeticBinaryOperation* instr);
2831 LInstruction* DoArithmeticT(Token::Value op,
2832 HBinaryOperation* instr);
2833 void FindDehoistedKeyDefinitions(HValue* candidate);
2835 HInstruction* current_instruction_;
2836 HBasicBlock* current_block_;
2837 HBasicBlock* next_block_;
2838 LAllocator* allocator_;
2840 DISALLOW_COPY_AND_ASSIGN(LChunkBuilder);
2843 #undef DECLARE_HYDROGEN_ACCESSOR
2844 #undef DECLARE_CONCRETE_INSTRUCTION
2846 } } // namespace v8::int
2848 #endif // V8_X64_LITHIUM_X64_H_