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_
9 #include "lithium-allocator.h"
11 #include "safepoint-table.h"
17 // Forward declarations.
20 #define LITHIUM_CONCRETE_INSTRUCTION_LIST(V) \
21 V(AccessArgumentsAt) \
25 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) \
104 V(LoadGlobalGeneric) \
106 V(LoadKeyedGeneric) \
108 V(LoadNamedGeneric) \
133 V(SeqStringGetChar) \
134 V(SeqStringSetChar) \
140 V(StoreContextSlot) \
143 V(StoreKeyedGeneric) \
145 V(StoreNamedGeneric) \
147 V(StringCharCodeAt) \
148 V(StringCharFromCode) \
149 V(StringCompareAndBranch) \
153 V(ToFastProperties) \
154 V(TransitionElementsKind) \
155 V(TrapAllocationMemento) \
157 V(TypeofIsAndBranch) \
163 #define DECLARE_CONCRETE_INSTRUCTION(type, mnemonic) \
164 virtual Opcode opcode() const V8_FINAL V8_OVERRIDE { \
165 return LInstruction::k##type; \
167 virtual void CompileToNative(LCodeGen* generator) V8_FINAL V8_OVERRIDE; \
168 virtual const char* Mnemonic() const V8_FINAL V8_OVERRIDE { \
171 static L##type* cast(LInstruction* instr) { \
172 ASSERT(instr->Is##type()); \
173 return reinterpret_cast<L##type*>(instr); \
177 #define DECLARE_HYDROGEN_ACCESSOR(type) \
178 H##type* hydrogen() const { \
179 return H##type::cast(hydrogen_value()); \
183 class LInstruction : public ZoneObject {
186 : environment_(NULL),
187 hydrogen_value_(NULL),
188 bit_field_(IsCallBits::encode(false)) {
191 virtual ~LInstruction() {}
193 virtual void CompileToNative(LCodeGen* generator) = 0;
194 virtual const char* Mnemonic() const = 0;
195 virtual void PrintTo(StringStream* stream);
196 virtual void PrintDataTo(StringStream* stream);
197 virtual void PrintOutputOperandTo(StringStream* stream);
200 // Declare a unique enum value for each instruction.
201 #define DECLARE_OPCODE(type) k##type,
202 LITHIUM_CONCRETE_INSTRUCTION_LIST(DECLARE_OPCODE)
203 kNumberOfInstructions
204 #undef DECLARE_OPCODE
207 virtual Opcode opcode() const = 0;
209 // Declare non-virtual type testers for all leaf IR classes.
210 #define DECLARE_PREDICATE(type) \
211 bool Is##type() const { return opcode() == k##type; }
212 LITHIUM_CONCRETE_INSTRUCTION_LIST(DECLARE_PREDICATE)
213 #undef DECLARE_PREDICATE
215 // Declare virtual predicates for instructions that don't have
217 virtual bool IsGap() const { return false; }
219 virtual bool IsControl() const { 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 {
265 friend class InputIterator;
266 virtual int InputCount() = 0;
267 virtual LOperand* InputAt(int i) = 0;
269 friend class TempIterator;
270 virtual int TempCount() = 0;
271 virtual LOperand* TempAt(int i) = 0;
273 class IsCallBits: public BitField<bool, 0, 1> {};
275 LEnvironment* environment_;
276 SetOncePointer<LPointerMap> pointer_map_;
277 HValue* hydrogen_value_;
282 // R = number of result operands (0 or 1).
284 class LTemplateResultInstruction : public LInstruction {
286 // Allow 0 or 1 output operands.
287 STATIC_ASSERT(R == 0 || R == 1);
288 virtual bool HasResult() const V8_FINAL V8_OVERRIDE {
289 return R != 0 && result() != NULL;
291 void set_result(LOperand* operand) { results_[0] = operand; }
292 LOperand* result() const { return results_[0]; }
294 virtual bool MustSignExtendResult(
295 LPlatformChunk* chunk) const V8_FINAL V8_OVERRIDE;
298 EmbeddedContainer<LOperand*, R> results_;
302 // R = number of result operands (0 or 1).
303 // I = number of input operands.
304 // T = number of temporary operands.
305 template<int R, int I, int T>
306 class LTemplateInstruction : public LTemplateResultInstruction<R> {
308 EmbeddedContainer<LOperand*, I> inputs_;
309 EmbeddedContainer<LOperand*, T> temps_;
313 virtual int InputCount() V8_FINAL V8_OVERRIDE { return I; }
314 virtual LOperand* InputAt(int i) V8_FINAL V8_OVERRIDE { return inputs_[i]; }
316 virtual int TempCount() V8_FINAL V8_OVERRIDE { return T; }
317 virtual LOperand* TempAt(int i) V8_FINAL V8_OVERRIDE { return temps_[i]; }
321 class LGap : public LTemplateInstruction<0, 0, 0> {
323 explicit LGap(HBasicBlock* block)
325 parallel_moves_[BEFORE] = NULL;
326 parallel_moves_[START] = NULL;
327 parallel_moves_[END] = NULL;
328 parallel_moves_[AFTER] = NULL;
331 // Can't use the DECLARE-macro here because of sub-classes.
332 virtual bool IsGap() const V8_FINAL V8_OVERRIDE { return true; }
333 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
334 static LGap* cast(LInstruction* instr) {
335 ASSERT(instr->IsGap());
336 return reinterpret_cast<LGap*>(instr);
339 bool IsRedundant() const;
341 HBasicBlock* block() const { return block_; }
348 FIRST_INNER_POSITION = BEFORE,
349 LAST_INNER_POSITION = AFTER
352 LParallelMove* GetOrCreateParallelMove(InnerPosition pos,
354 if (parallel_moves_[pos] == NULL) {
355 parallel_moves_[pos] = new(zone) LParallelMove(zone);
357 return parallel_moves_[pos];
360 LParallelMove* GetParallelMove(InnerPosition pos) {
361 return parallel_moves_[pos];
365 LParallelMove* parallel_moves_[LAST_INNER_POSITION + 1];
370 class LInstructionGap V8_FINAL : public LGap {
372 explicit LInstructionGap(HBasicBlock* block) : LGap(block) { }
374 virtual bool HasInterestingComment(LCodeGen* gen) const V8_OVERRIDE {
375 return !IsRedundant();
378 DECLARE_CONCRETE_INSTRUCTION(InstructionGap, "gap")
382 class LGoto V8_FINAL : public LTemplateInstruction<0, 0, 0> {
384 explicit LGoto(HBasicBlock* block) : block_(block) { }
386 virtual bool HasInterestingComment(LCodeGen* gen) const V8_OVERRIDE;
387 DECLARE_CONCRETE_INSTRUCTION(Goto, "goto")
388 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
389 virtual bool IsControl() const V8_OVERRIDE { return true; }
391 int block_id() const { return block_->block_id(); }
398 class LLazyBailout V8_FINAL : public LTemplateInstruction<0, 0, 0> {
400 LLazyBailout() : gap_instructions_size_(0) { }
402 DECLARE_CONCRETE_INSTRUCTION(LazyBailout, "lazy-bailout")
404 void set_gap_instructions_size(int gap_instructions_size) {
405 gap_instructions_size_ = gap_instructions_size;
407 int gap_instructions_size() { return gap_instructions_size_; }
410 int gap_instructions_size_;
414 class LDummy V8_FINAL : public LTemplateInstruction<1, 0, 0> {
416 explicit LDummy() { }
417 DECLARE_CONCRETE_INSTRUCTION(Dummy, "dummy")
421 class LDummyUse V8_FINAL : public LTemplateInstruction<1, 1, 0> {
423 explicit LDummyUse(LOperand* value) {
426 DECLARE_CONCRETE_INSTRUCTION(DummyUse, "dummy-use")
430 class LDeoptimize V8_FINAL : public LTemplateInstruction<0, 0, 0> {
432 DECLARE_CONCRETE_INSTRUCTION(Deoptimize, "deoptimize")
433 DECLARE_HYDROGEN_ACCESSOR(Deoptimize)
437 class LLabel V8_FINAL : public LGap {
439 explicit LLabel(HBasicBlock* block)
440 : LGap(block), replacement_(NULL) { }
442 virtual bool HasInterestingComment(LCodeGen* gen) const V8_OVERRIDE {
445 DECLARE_CONCRETE_INSTRUCTION(Label, "label")
447 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
449 int block_id() const { return block()->block_id(); }
450 bool is_loop_header() const { return block()->IsLoopHeader(); }
451 bool is_osr_entry() const { return block()->is_osr_entry(); }
452 Label* label() { return &label_; }
453 LLabel* replacement() const { return replacement_; }
454 void set_replacement(LLabel* label) { replacement_ = label; }
455 bool HasReplacement() const { return replacement_ != NULL; }
459 LLabel* replacement_;
463 class LParameter V8_FINAL : public LTemplateInstruction<1, 0, 0> {
465 virtual bool HasInterestingComment(LCodeGen* gen) const V8_OVERRIDE {
468 DECLARE_CONCRETE_INSTRUCTION(Parameter, "parameter")
472 class LCallStub V8_FINAL : public LTemplateInstruction<1, 1, 0> {
474 explicit LCallStub(LOperand* context) {
475 inputs_[0] = context;
478 LOperand* context() { return inputs_[0]; }
480 DECLARE_CONCRETE_INSTRUCTION(CallStub, "call-stub")
481 DECLARE_HYDROGEN_ACCESSOR(CallStub)
485 class LUnknownOSRValue V8_FINAL : public LTemplateInstruction<1, 0, 0> {
487 virtual bool HasInterestingComment(LCodeGen* gen) const V8_OVERRIDE {
490 DECLARE_CONCRETE_INSTRUCTION(UnknownOSRValue, "unknown-osr-value")
494 template<int I, int T>
495 class LControlInstruction : public LTemplateInstruction<0, I, T> {
497 LControlInstruction() : false_label_(NULL), true_label_(NULL) { }
499 virtual bool IsControl() const V8_FINAL V8_OVERRIDE { return true; }
501 int SuccessorCount() { return hydrogen()->SuccessorCount(); }
502 HBasicBlock* SuccessorAt(int i) { return hydrogen()->SuccessorAt(i); }
504 int TrueDestination(LChunk* chunk) {
505 return chunk->LookupDestination(true_block_id());
507 int FalseDestination(LChunk* chunk) {
508 return chunk->LookupDestination(false_block_id());
511 Label* TrueLabel(LChunk* chunk) {
512 if (true_label_ == NULL) {
513 true_label_ = chunk->GetAssemblyLabel(TrueDestination(chunk));
517 Label* FalseLabel(LChunk* chunk) {
518 if (false_label_ == NULL) {
519 false_label_ = chunk->GetAssemblyLabel(FalseDestination(chunk));
525 int true_block_id() { return SuccessorAt(0)->block_id(); }
526 int false_block_id() { return SuccessorAt(1)->block_id(); }
529 HControlInstruction* hydrogen() {
530 return HControlInstruction::cast(this->hydrogen_value());
538 class LWrapReceiver V8_FINAL : public LTemplateInstruction<1, 2, 0> {
540 LWrapReceiver(LOperand* receiver, LOperand* function) {
541 inputs_[0] = receiver;
542 inputs_[1] = function;
545 LOperand* receiver() { return inputs_[0]; }
546 LOperand* function() { return inputs_[1]; }
548 DECLARE_CONCRETE_INSTRUCTION(WrapReceiver, "wrap-receiver")
549 DECLARE_HYDROGEN_ACCESSOR(WrapReceiver)
553 class LApplyArguments V8_FINAL : public LTemplateInstruction<1, 4, 0> {
555 LApplyArguments(LOperand* function,
558 LOperand* elements) {
559 inputs_[0] = function;
560 inputs_[1] = receiver;
562 inputs_[3] = elements;
565 LOperand* function() { return inputs_[0]; }
566 LOperand* receiver() { return inputs_[1]; }
567 LOperand* length() { return inputs_[2]; }
568 LOperand* elements() { return inputs_[3]; }
570 DECLARE_CONCRETE_INSTRUCTION(ApplyArguments, "apply-arguments")
574 class LAccessArgumentsAt V8_FINAL : public LTemplateInstruction<1, 3, 0> {
576 LAccessArgumentsAt(LOperand* arguments, LOperand* length, LOperand* index) {
577 inputs_[0] = arguments;
582 LOperand* arguments() { return inputs_[0]; }
583 LOperand* length() { return inputs_[1]; }
584 LOperand* index() { return inputs_[2]; }
586 DECLARE_CONCRETE_INSTRUCTION(AccessArgumentsAt, "access-arguments-at")
588 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
592 class LArgumentsLength V8_FINAL : public LTemplateInstruction<1, 1, 0> {
594 explicit LArgumentsLength(LOperand* elements) {
595 inputs_[0] = elements;
598 LOperand* elements() { return inputs_[0]; }
600 DECLARE_CONCRETE_INSTRUCTION(ArgumentsLength, "arguments-length")
604 class LArgumentsElements V8_FINAL : public LTemplateInstruction<1, 0, 0> {
606 DECLARE_CONCRETE_INSTRUCTION(ArgumentsElements, "arguments-elements")
607 DECLARE_HYDROGEN_ACCESSOR(ArgumentsElements)
611 class LModByPowerOf2I V8_FINAL : public LTemplateInstruction<1, 1, 0> {
613 LModByPowerOf2I(LOperand* dividend, int32_t divisor) {
614 inputs_[0] = dividend;
618 LOperand* dividend() { return inputs_[0]; }
619 int32_t divisor() const { return divisor_; }
621 DECLARE_CONCRETE_INSTRUCTION(ModByPowerOf2I, "mod-by-power-of-2-i")
622 DECLARE_HYDROGEN_ACCESSOR(Mod)
629 class LModByConstI V8_FINAL : public LTemplateInstruction<1, 1, 2> {
631 LModByConstI(LOperand* dividend,
635 inputs_[0] = dividend;
641 LOperand* dividend() { return inputs_[0]; }
642 int32_t divisor() const { return divisor_; }
643 LOperand* temp1() { return temps_[0]; }
644 LOperand* temp2() { return temps_[1]; }
646 DECLARE_CONCRETE_INSTRUCTION(ModByConstI, "mod-by-const-i")
647 DECLARE_HYDROGEN_ACCESSOR(Mod)
654 class LModI V8_FINAL : public LTemplateInstruction<1, 2, 1> {
656 LModI(LOperand* left, LOperand* right, LOperand* temp) {
662 LOperand* left() { return inputs_[0]; }
663 LOperand* right() { return inputs_[1]; }
664 LOperand* temp() { return temps_[0]; }
666 DECLARE_CONCRETE_INSTRUCTION(ModI, "mod-i")
667 DECLARE_HYDROGEN_ACCESSOR(Mod)
671 class LDivByPowerOf2I V8_FINAL : public LTemplateInstruction<1, 1, 0> {
673 LDivByPowerOf2I(LOperand* dividend, int32_t divisor) {
674 inputs_[0] = dividend;
678 LOperand* dividend() { return inputs_[0]; }
679 int32_t divisor() const { return divisor_; }
681 DECLARE_CONCRETE_INSTRUCTION(DivByPowerOf2I, "div-by-power-of-2-i")
682 DECLARE_HYDROGEN_ACCESSOR(Div)
689 class LDivByConstI V8_FINAL : public LTemplateInstruction<1, 1, 2> {
691 LDivByConstI(LOperand* dividend,
695 inputs_[0] = dividend;
701 LOperand* dividend() { return inputs_[0]; }
702 int32_t divisor() const { return divisor_; }
703 LOperand* temp1() { return temps_[0]; }
704 LOperand* temp2() { return temps_[1]; }
706 DECLARE_CONCRETE_INSTRUCTION(DivByConstI, "div-by-const-i")
707 DECLARE_HYDROGEN_ACCESSOR(Div)
714 class LDivI V8_FINAL : public LTemplateInstruction<1, 2, 1> {
716 LDivI(LOperand* dividend, LOperand* divisor, LOperand* temp) {
717 inputs_[0] = dividend;
718 inputs_[1] = divisor;
722 LOperand* dividend() { return inputs_[0]; }
723 LOperand* divisor() { return inputs_[1]; }
724 LOperand* temp() { return temps_[0]; }
726 DECLARE_CONCRETE_INSTRUCTION(DivI, "div-i")
727 DECLARE_HYDROGEN_ACCESSOR(BinaryOperation)
731 class LFlooringDivByPowerOf2I V8_FINAL : public LTemplateInstruction<1, 1, 0> {
733 LFlooringDivByPowerOf2I(LOperand* dividend, int32_t divisor) {
734 inputs_[0] = dividend;
738 LOperand* dividend() { return inputs_[0]; }
739 int32_t divisor() const { return divisor_; }
741 DECLARE_CONCRETE_INSTRUCTION(FlooringDivByPowerOf2I,
742 "flooring-div-by-power-of-2-i")
743 DECLARE_HYDROGEN_ACCESSOR(MathFloorOfDiv)
750 class LFlooringDivByConstI V8_FINAL : public LTemplateInstruction<1, 1, 3> {
752 LFlooringDivByConstI(LOperand* dividend,
757 inputs_[0] = dividend;
764 LOperand* dividend() { return inputs_[0]; }
765 int32_t divisor() const { return divisor_; }
766 LOperand* temp1() { return temps_[0]; }
767 LOperand* temp2() { return temps_[1]; }
768 LOperand* temp3() { return temps_[2]; }
770 DECLARE_CONCRETE_INSTRUCTION(FlooringDivByConstI, "flooring-div-by-const-i")
771 DECLARE_HYDROGEN_ACCESSOR(MathFloorOfDiv)
778 class LFlooringDivI V8_FINAL : public LTemplateInstruction<1, 2, 1> {
780 LFlooringDivI(LOperand* dividend, LOperand* divisor, LOperand* temp) {
781 inputs_[0] = dividend;
782 inputs_[1] = divisor;
786 LOperand* dividend() { return inputs_[0]; }
787 LOperand* divisor() { return inputs_[1]; }
788 LOperand* temp() { return temps_[0]; }
790 DECLARE_CONCRETE_INSTRUCTION(FlooringDivI, "flooring-div-i")
791 DECLARE_HYDROGEN_ACCESSOR(MathFloorOfDiv)
795 class LMulI V8_FINAL : public LTemplateInstruction<1, 2, 0> {
797 LMulI(LOperand* left, LOperand* right) {
802 LOperand* left() { return inputs_[0]; }
803 LOperand* right() { return inputs_[1]; }
805 DECLARE_CONCRETE_INSTRUCTION(MulI, "mul-i")
806 DECLARE_HYDROGEN_ACCESSOR(Mul)
810 class LCompareNumericAndBranch V8_FINAL : public LControlInstruction<2, 0> {
812 LCompareNumericAndBranch(LOperand* left, LOperand* right) {
817 LOperand* left() { return inputs_[0]; }
818 LOperand* right() { return inputs_[1]; }
820 DECLARE_CONCRETE_INSTRUCTION(CompareNumericAndBranch,
821 "compare-numeric-and-branch")
822 DECLARE_HYDROGEN_ACCESSOR(CompareNumericAndBranch)
824 Token::Value op() const { return hydrogen()->token(); }
825 bool is_double() const {
826 return hydrogen()->representation().IsDouble();
829 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
833 class LMathFloor V8_FINAL : public LTemplateInstruction<1, 1, 0> {
835 explicit LMathFloor(LOperand* value) {
839 LOperand* value() { return inputs_[0]; }
841 DECLARE_CONCRETE_INSTRUCTION(MathFloor, "math-floor")
842 DECLARE_HYDROGEN_ACCESSOR(UnaryMathOperation)
846 class LMathRound V8_FINAL : public LTemplateInstruction<1, 1, 1> {
848 explicit LMathRound(LOperand* value, LOperand* temp) {
853 LOperand* value() { return inputs_[0]; }
854 LOperand* temp() { return temps_[0]; }
856 DECLARE_CONCRETE_INSTRUCTION(MathRound, "math-round")
857 DECLARE_HYDROGEN_ACCESSOR(UnaryMathOperation)
861 class LMathAbs V8_FINAL : public LTemplateInstruction<1, 2, 0> {
863 explicit LMathAbs(LOperand* context, LOperand* value) {
864 inputs_[1] = context;
868 LOperand* context() { return inputs_[1]; }
869 LOperand* value() { return inputs_[0]; }
871 DECLARE_CONCRETE_INSTRUCTION(MathAbs, "math-abs")
872 DECLARE_HYDROGEN_ACCESSOR(UnaryMathOperation)
876 class LMathLog V8_FINAL : public LTemplateInstruction<1, 1, 0> {
878 explicit LMathLog(LOperand* value) {
882 LOperand* value() { return inputs_[0]; }
884 DECLARE_CONCRETE_INSTRUCTION(MathLog, "math-log")
888 class LMathClz32 V8_FINAL : public LTemplateInstruction<1, 1, 0> {
890 explicit LMathClz32(LOperand* value) {
894 LOperand* value() { return inputs_[0]; }
896 DECLARE_CONCRETE_INSTRUCTION(MathClz32, "math-clz32")
900 class LMathExp V8_FINAL : public LTemplateInstruction<1, 1, 2> {
902 LMathExp(LOperand* value, LOperand* temp1, LOperand* temp2) {
906 ExternalReference::InitializeMathExpData();
909 LOperand* value() { return inputs_[0]; }
910 LOperand* temp1() { return temps_[0]; }
911 LOperand* temp2() { return temps_[1]; }
913 DECLARE_CONCRETE_INSTRUCTION(MathExp, "math-exp")
917 class LMathSqrt V8_FINAL : public LTemplateInstruction<1, 1, 0> {
919 explicit LMathSqrt(LOperand* value) {
923 LOperand* value() { return inputs_[0]; }
925 DECLARE_CONCRETE_INSTRUCTION(MathSqrt, "math-sqrt")
929 class LMathPowHalf V8_FINAL : public LTemplateInstruction<1, 1, 0> {
931 explicit LMathPowHalf(LOperand* value) {
935 LOperand* value() { return inputs_[0]; }
937 DECLARE_CONCRETE_INSTRUCTION(MathPowHalf, "math-pow-half")
941 class LCmpObjectEqAndBranch V8_FINAL : public LControlInstruction<2, 0> {
943 LCmpObjectEqAndBranch(LOperand* left, LOperand* right) {
948 LOperand* left() { return inputs_[0]; }
949 LOperand* right() { return inputs_[1]; }
951 DECLARE_CONCRETE_INSTRUCTION(CmpObjectEqAndBranch, "cmp-object-eq-and-branch")
955 class LCmpHoleAndBranch V8_FINAL : public LControlInstruction<1, 0> {
957 explicit LCmpHoleAndBranch(LOperand* object) {
961 LOperand* object() { return inputs_[0]; }
963 DECLARE_CONCRETE_INSTRUCTION(CmpHoleAndBranch, "cmp-hole-and-branch")
964 DECLARE_HYDROGEN_ACCESSOR(CompareHoleAndBranch)
968 class LCompareMinusZeroAndBranch V8_FINAL : public LControlInstruction<1, 0> {
970 explicit LCompareMinusZeroAndBranch(LOperand* value) {
974 LOperand* value() { return inputs_[0]; }
976 DECLARE_CONCRETE_INSTRUCTION(CompareMinusZeroAndBranch,
977 "cmp-minus-zero-and-branch")
978 DECLARE_HYDROGEN_ACCESSOR(CompareMinusZeroAndBranch)
983 class LIsObjectAndBranch V8_FINAL : public LControlInstruction<1, 0> {
985 explicit LIsObjectAndBranch(LOperand* value) {
989 LOperand* value() { return inputs_[0]; }
991 DECLARE_CONCRETE_INSTRUCTION(IsObjectAndBranch, "is-object-and-branch")
992 DECLARE_HYDROGEN_ACCESSOR(IsObjectAndBranch)
994 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
998 class LIsStringAndBranch V8_FINAL : public LControlInstruction<1, 1> {
1000 explicit LIsStringAndBranch(LOperand* value, LOperand* temp) {
1005 LOperand* value() { return inputs_[0]; }
1006 LOperand* temp() { return temps_[0]; }
1008 DECLARE_CONCRETE_INSTRUCTION(IsStringAndBranch, "is-string-and-branch")
1009 DECLARE_HYDROGEN_ACCESSOR(IsStringAndBranch)
1011 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1015 class LIsSmiAndBranch V8_FINAL : public LControlInstruction<1, 0> {
1017 explicit LIsSmiAndBranch(LOperand* value) {
1021 LOperand* value() { return inputs_[0]; }
1023 DECLARE_CONCRETE_INSTRUCTION(IsSmiAndBranch, "is-smi-and-branch")
1024 DECLARE_HYDROGEN_ACCESSOR(IsSmiAndBranch)
1026 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1030 class LIsUndetectableAndBranch V8_FINAL : public LControlInstruction<1, 1> {
1032 explicit LIsUndetectableAndBranch(LOperand* value, LOperand* temp) {
1037 LOperand* value() { return inputs_[0]; }
1038 LOperand* temp() { return temps_[0]; }
1040 DECLARE_CONCRETE_INSTRUCTION(IsUndetectableAndBranch,
1041 "is-undetectable-and-branch")
1042 DECLARE_HYDROGEN_ACCESSOR(IsUndetectableAndBranch)
1044 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1048 class LStringCompareAndBranch V8_FINAL : public LControlInstruction<3, 0> {
1050 explicit LStringCompareAndBranch(LOperand* context,
1053 inputs_[0] = context;
1058 LOperand* context() { return inputs_[0]; }
1059 LOperand* left() { return inputs_[1]; }
1060 LOperand* right() { return inputs_[2]; }
1062 DECLARE_CONCRETE_INSTRUCTION(StringCompareAndBranch,
1063 "string-compare-and-branch")
1064 DECLARE_HYDROGEN_ACCESSOR(StringCompareAndBranch)
1066 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1068 Token::Value op() const { return hydrogen()->token(); }
1072 class LHasInstanceTypeAndBranch V8_FINAL : public LControlInstruction<1, 0> {
1074 explicit LHasInstanceTypeAndBranch(LOperand* value) {
1078 LOperand* value() { return inputs_[0]; }
1080 DECLARE_CONCRETE_INSTRUCTION(HasInstanceTypeAndBranch,
1081 "has-instance-type-and-branch")
1082 DECLARE_HYDROGEN_ACCESSOR(HasInstanceTypeAndBranch)
1084 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1088 class LGetCachedArrayIndex V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1090 explicit LGetCachedArrayIndex(LOperand* value) {
1094 LOperand* value() { return inputs_[0]; }
1096 DECLARE_CONCRETE_INSTRUCTION(GetCachedArrayIndex, "get-cached-array-index")
1097 DECLARE_HYDROGEN_ACCESSOR(GetCachedArrayIndex)
1101 class LHasCachedArrayIndexAndBranch V8_FINAL
1102 : public LControlInstruction<1, 0> {
1104 explicit LHasCachedArrayIndexAndBranch(LOperand* value) {
1108 LOperand* value() { return inputs_[0]; }
1110 DECLARE_CONCRETE_INSTRUCTION(HasCachedArrayIndexAndBranch,
1111 "has-cached-array-index-and-branch")
1112 DECLARE_HYDROGEN_ACCESSOR(HasCachedArrayIndexAndBranch)
1114 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1118 class LClassOfTestAndBranch V8_FINAL : public LControlInstruction<1, 2> {
1120 LClassOfTestAndBranch(LOperand* value, LOperand* temp, LOperand* temp2) {
1126 LOperand* value() { return inputs_[0]; }
1127 LOperand* temp() { return temps_[0]; }
1128 LOperand* temp2() { return temps_[1]; }
1130 DECLARE_CONCRETE_INSTRUCTION(ClassOfTestAndBranch,
1131 "class-of-test-and-branch")
1132 DECLARE_HYDROGEN_ACCESSOR(ClassOfTestAndBranch)
1134 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1138 class LCmpT V8_FINAL : public LTemplateInstruction<1, 3, 0> {
1140 LCmpT(LOperand* context, LOperand* left, LOperand* right) {
1141 inputs_[0] = context;
1146 LOperand* context() { return inputs_[0]; }
1147 LOperand* left() { return inputs_[1]; }
1148 LOperand* right() { return inputs_[2]; }
1150 DECLARE_CONCRETE_INSTRUCTION(CmpT, "cmp-t")
1151 DECLARE_HYDROGEN_ACCESSOR(CompareGeneric)
1153 Token::Value op() const { return hydrogen()->token(); }
1157 class LInstanceOf V8_FINAL : public LTemplateInstruction<1, 3, 0> {
1159 LInstanceOf(LOperand* context, LOperand* left, LOperand* right) {
1160 inputs_[0] = context;
1165 LOperand* context() { return inputs_[0]; }
1166 LOperand* left() { return inputs_[1]; }
1167 LOperand* right() { return inputs_[2]; }
1169 DECLARE_CONCRETE_INSTRUCTION(InstanceOf, "instance-of")
1173 class LInstanceOfKnownGlobal V8_FINAL : public LTemplateInstruction<1, 2, 1> {
1175 LInstanceOfKnownGlobal(LOperand* context, LOperand* value, LOperand* temp) {
1176 inputs_[0] = context;
1181 LOperand* context() { return inputs_[0]; }
1182 LOperand* value() { return inputs_[1]; }
1183 LOperand* temp() { return temps_[0]; }
1185 DECLARE_CONCRETE_INSTRUCTION(InstanceOfKnownGlobal,
1186 "instance-of-known-global")
1187 DECLARE_HYDROGEN_ACCESSOR(InstanceOfKnownGlobal)
1189 Handle<JSFunction> function() const { return hydrogen()->function(); }
1190 LEnvironment* GetDeferredLazyDeoptimizationEnvironment() {
1191 return lazy_deopt_env_;
1193 virtual void SetDeferredLazyDeoptimizationEnvironment(
1194 LEnvironment* env) V8_OVERRIDE {
1195 lazy_deopt_env_ = env;
1199 LEnvironment* lazy_deopt_env_;
1203 class LBoundsCheck V8_FINAL : public LTemplateInstruction<0, 2, 0> {
1205 LBoundsCheck(LOperand* index, LOperand* length) {
1207 inputs_[1] = length;
1210 LOperand* index() { return inputs_[0]; }
1211 LOperand* length() { return inputs_[1]; }
1213 DECLARE_CONCRETE_INSTRUCTION(BoundsCheck, "bounds-check")
1214 DECLARE_HYDROGEN_ACCESSOR(BoundsCheck)
1218 class LBitI V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1220 LBitI(LOperand* left, LOperand* right) {
1225 LOperand* left() { return inputs_[0]; }
1226 LOperand* right() { return inputs_[1]; }
1228 Token::Value op() const { return hydrogen()->op(); }
1229 bool IsInteger32() const {
1230 return hydrogen()->representation().IsInteger32();
1233 DECLARE_CONCRETE_INSTRUCTION(BitI, "bit-i")
1234 DECLARE_HYDROGEN_ACCESSOR(Bitwise)
1238 class LShiftI V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1240 LShiftI(Token::Value op, LOperand* left, LOperand* right, bool can_deopt)
1241 : op_(op), can_deopt_(can_deopt) {
1246 Token::Value op() const { return op_; }
1247 LOperand* left() { return inputs_[0]; }
1248 LOperand* right() { return inputs_[1]; }
1249 bool can_deopt() const { return can_deopt_; }
1251 DECLARE_CONCRETE_INSTRUCTION(ShiftI, "shift-i")
1259 class LSubI V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1261 LSubI(LOperand* left, LOperand* right) {
1266 LOperand* left() { return inputs_[0]; }
1267 LOperand* right() { return inputs_[1]; }
1269 DECLARE_CONCRETE_INSTRUCTION(SubI, "sub-i")
1270 DECLARE_HYDROGEN_ACCESSOR(Sub)
1274 class LConstantI V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1276 DECLARE_CONCRETE_INSTRUCTION(ConstantI, "constant-i")
1277 DECLARE_HYDROGEN_ACCESSOR(Constant)
1279 int32_t value() const { return hydrogen()->Integer32Value(); }
1283 class LConstantS V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1285 DECLARE_CONCRETE_INSTRUCTION(ConstantS, "constant-s")
1286 DECLARE_HYDROGEN_ACCESSOR(Constant)
1288 Smi* value() const { return Smi::FromInt(hydrogen()->Integer32Value()); }
1292 class LConstantD V8_FINAL : public LTemplateInstruction<1, 0, 1> {
1294 explicit LConstantD(LOperand* temp) {
1298 LOperand* temp() { return temps_[0]; }
1300 DECLARE_CONCRETE_INSTRUCTION(ConstantD, "constant-d")
1301 DECLARE_HYDROGEN_ACCESSOR(Constant)
1303 double value() const { return hydrogen()->DoubleValue(); }
1307 class LConstantE V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1309 DECLARE_CONCRETE_INSTRUCTION(ConstantE, "constant-e")
1310 DECLARE_HYDROGEN_ACCESSOR(Constant)
1312 ExternalReference value() const {
1313 return hydrogen()->ExternalReferenceValue();
1318 class LConstantT V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1320 DECLARE_CONCRETE_INSTRUCTION(ConstantT, "constant-t")
1321 DECLARE_HYDROGEN_ACCESSOR(Constant)
1323 Handle<Object> value(Isolate* isolate) const {
1324 return hydrogen()->handle(isolate);
1329 class LBranch V8_FINAL : public LControlInstruction<1, 0> {
1331 explicit LBranch(LOperand* value) {
1335 LOperand* value() { return inputs_[0]; }
1337 DECLARE_CONCRETE_INSTRUCTION(Branch, "branch")
1338 DECLARE_HYDROGEN_ACCESSOR(Branch)
1340 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1344 class LDebugBreak V8_FINAL : public LTemplateInstruction<0, 0, 0> {
1346 DECLARE_CONCRETE_INSTRUCTION(DebugBreak, "break")
1350 class LCmpMapAndBranch V8_FINAL : public LControlInstruction<1, 0> {
1352 explicit LCmpMapAndBranch(LOperand* value) {
1356 LOperand* value() { return inputs_[0]; }
1358 DECLARE_CONCRETE_INSTRUCTION(CmpMapAndBranch, "cmp-map-and-branch")
1359 DECLARE_HYDROGEN_ACCESSOR(CompareMap)
1361 Handle<Map> map() const { return hydrogen()->map().handle(); }
1365 class LMapEnumLength V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1367 explicit LMapEnumLength(LOperand* value) {
1371 LOperand* value() { return inputs_[0]; }
1373 DECLARE_CONCRETE_INSTRUCTION(MapEnumLength, "map-enum-length")
1377 class LDateField V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1379 LDateField(LOperand* date, Smi* index) : index_(index) {
1383 LOperand* date() { return inputs_[0]; }
1384 Smi* index() const { return index_; }
1386 DECLARE_CONCRETE_INSTRUCTION(DateField, "date-field")
1387 DECLARE_HYDROGEN_ACCESSOR(DateField)
1394 class LSeqStringGetChar V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1396 LSeqStringGetChar(LOperand* string, LOperand* index) {
1397 inputs_[0] = string;
1401 LOperand* string() const { return inputs_[0]; }
1402 LOperand* index() const { return inputs_[1]; }
1404 DECLARE_CONCRETE_INSTRUCTION(SeqStringGetChar, "seq-string-get-char")
1405 DECLARE_HYDROGEN_ACCESSOR(SeqStringGetChar)
1409 class LSeqStringSetChar V8_FINAL : public LTemplateInstruction<1, 4, 0> {
1411 LSeqStringSetChar(LOperand* context,
1415 inputs_[0] = context;
1416 inputs_[1] = string;
1421 LOperand* string() { return inputs_[1]; }
1422 LOperand* index() { return inputs_[2]; }
1423 LOperand* value() { return inputs_[3]; }
1425 DECLARE_CONCRETE_INSTRUCTION(SeqStringSetChar, "seq-string-set-char")
1426 DECLARE_HYDROGEN_ACCESSOR(SeqStringSetChar)
1430 class LAddI V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1432 LAddI(LOperand* left, LOperand* right) {
1437 LOperand* left() { return inputs_[0]; }
1438 LOperand* right() { return inputs_[1]; }
1440 static bool UseLea(HAdd* add) {
1441 return !add->CheckFlag(HValue::kCanOverflow) &&
1442 add->BetterLeftOperand()->UseCount() > 1;
1445 DECLARE_CONCRETE_INSTRUCTION(AddI, "add-i")
1446 DECLARE_HYDROGEN_ACCESSOR(Add)
1450 class LMathMinMax V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1452 LMathMinMax(LOperand* left, LOperand* right) {
1457 LOperand* left() { return inputs_[0]; }
1458 LOperand* right() { return inputs_[1]; }
1460 DECLARE_CONCRETE_INSTRUCTION(MathMinMax, "math-min-max")
1461 DECLARE_HYDROGEN_ACCESSOR(MathMinMax)
1465 class LPower V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1467 LPower(LOperand* left, LOperand* right) {
1472 LOperand* left() { return inputs_[0]; }
1473 LOperand* right() { return inputs_[1]; }
1475 DECLARE_CONCRETE_INSTRUCTION(Power, "power")
1476 DECLARE_HYDROGEN_ACCESSOR(Power)
1480 class LArithmeticD V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1482 LArithmeticD(Token::Value op, LOperand* left, LOperand* right)
1488 Token::Value op() const { return op_; }
1489 LOperand* left() { return inputs_[0]; }
1490 LOperand* right() { return inputs_[1]; }
1492 virtual Opcode opcode() const V8_OVERRIDE {
1493 return LInstruction::kArithmeticD;
1495 virtual void CompileToNative(LCodeGen* generator) V8_OVERRIDE;
1496 virtual const char* Mnemonic() const V8_OVERRIDE;
1503 class LArithmeticT V8_FINAL : public LTemplateInstruction<1, 3, 0> {
1505 LArithmeticT(Token::Value op,
1510 inputs_[0] = context;
1515 Token::Value op() const { return op_; }
1516 LOperand* context() { return inputs_[0]; }
1517 LOperand* left() { return inputs_[1]; }
1518 LOperand* right() { return inputs_[2]; }
1520 virtual Opcode opcode() const V8_OVERRIDE {
1521 return LInstruction::kArithmeticT;
1523 virtual void CompileToNative(LCodeGen* generator) V8_OVERRIDE;
1524 virtual const char* Mnemonic() const V8_OVERRIDE;
1531 class LReturn V8_FINAL : public LTemplateInstruction<0, 3, 0> {
1533 explicit LReturn(LOperand* value,
1535 LOperand* parameter_count) {
1537 inputs_[1] = context;
1538 inputs_[2] = parameter_count;
1541 LOperand* value() { return inputs_[0]; }
1542 LOperand* context() { return inputs_[1]; }
1544 bool has_constant_parameter_count() {
1545 return parameter_count()->IsConstantOperand();
1547 LConstantOperand* constant_parameter_count() {
1548 ASSERT(has_constant_parameter_count());
1549 return LConstantOperand::cast(parameter_count());
1551 LOperand* parameter_count() { return inputs_[2]; }
1553 DECLARE_CONCRETE_INSTRUCTION(Return, "return")
1554 DECLARE_HYDROGEN_ACCESSOR(Return)
1558 class LLoadNamedField V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1560 explicit LLoadNamedField(LOperand* object) {
1561 inputs_[0] = object;
1564 LOperand* object() { return inputs_[0]; }
1566 DECLARE_CONCRETE_INSTRUCTION(LoadNamedField, "load-named-field")
1567 DECLARE_HYDROGEN_ACCESSOR(LoadNamedField)
1571 class LLoadNamedGeneric V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1573 explicit LLoadNamedGeneric(LOperand* context, LOperand* object) {
1574 inputs_[0] = context;
1575 inputs_[1] = object;
1578 DECLARE_CONCRETE_INSTRUCTION(LoadNamedGeneric, "load-named-generic")
1579 DECLARE_HYDROGEN_ACCESSOR(LoadNamedGeneric)
1581 LOperand* context() { return inputs_[0]; }
1582 LOperand* object() { return inputs_[1]; }
1583 Handle<Object> name() const { return hydrogen()->name(); }
1587 class LLoadFunctionPrototype V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1589 explicit LLoadFunctionPrototype(LOperand* function) {
1590 inputs_[0] = function;
1593 DECLARE_CONCRETE_INSTRUCTION(LoadFunctionPrototype, "load-function-prototype")
1594 DECLARE_HYDROGEN_ACCESSOR(LoadFunctionPrototype)
1596 LOperand* function() { return inputs_[0]; }
1600 class LLoadRoot V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1602 DECLARE_CONCRETE_INSTRUCTION(LoadRoot, "load-root")
1603 DECLARE_HYDROGEN_ACCESSOR(LoadRoot)
1605 Heap::RootListIndex index() const { return hydrogen()->index(); }
1609 class LLoadKeyed V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1611 LLoadKeyed(LOperand* elements, LOperand* key) {
1612 inputs_[0] = elements;
1616 DECLARE_CONCRETE_INSTRUCTION(LoadKeyed, "load-keyed")
1617 DECLARE_HYDROGEN_ACCESSOR(LoadKeyed)
1619 bool is_external() const {
1620 return hydrogen()->is_external();
1622 bool is_fixed_typed_array() const {
1623 return hydrogen()->is_fixed_typed_array();
1625 bool is_typed_elements() const {
1626 return is_external() || is_fixed_typed_array();
1628 LOperand* elements() { return inputs_[0]; }
1629 LOperand* key() { return inputs_[1]; }
1630 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1631 uint32_t base_offset() const { return hydrogen()->base_offset(); }
1632 ElementsKind elements_kind() const {
1633 return hydrogen()->elements_kind();
1638 class LLoadKeyedGeneric V8_FINAL : public LTemplateInstruction<1, 3, 0> {
1640 LLoadKeyedGeneric(LOperand* context, LOperand* obj, LOperand* key) {
1641 inputs_[0] = context;
1646 DECLARE_CONCRETE_INSTRUCTION(LoadKeyedGeneric, "load-keyed-generic")
1648 LOperand* context() { return inputs_[0]; }
1649 LOperand* object() { return inputs_[1]; }
1650 LOperand* key() { return inputs_[2]; }
1654 class LLoadGlobalCell V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1656 DECLARE_CONCRETE_INSTRUCTION(LoadGlobalCell, "load-global-cell")
1657 DECLARE_HYDROGEN_ACCESSOR(LoadGlobalCell)
1661 class LLoadGlobalGeneric V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1663 explicit LLoadGlobalGeneric(LOperand* context, LOperand* global_object) {
1664 inputs_[0] = context;
1665 inputs_[1] = global_object;
1668 DECLARE_CONCRETE_INSTRUCTION(LoadGlobalGeneric, "load-global-generic")
1669 DECLARE_HYDROGEN_ACCESSOR(LoadGlobalGeneric)
1671 LOperand* context() { return inputs_[0]; }
1672 LOperand* global_object() { return inputs_[1]; }
1673 Handle<Object> name() const { return hydrogen()->name(); }
1674 bool for_typeof() const { return hydrogen()->for_typeof(); }
1678 class LStoreGlobalCell V8_FINAL : public LTemplateInstruction<0, 1, 1> {
1680 explicit LStoreGlobalCell(LOperand* value, LOperand* temp) {
1685 LOperand* value() { return inputs_[0]; }
1686 LOperand* temp() { return temps_[0]; }
1688 DECLARE_CONCRETE_INSTRUCTION(StoreGlobalCell, "store-global-cell")
1689 DECLARE_HYDROGEN_ACCESSOR(StoreGlobalCell)
1693 class LLoadContextSlot V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1695 explicit LLoadContextSlot(LOperand* context) {
1696 inputs_[0] = context;
1699 LOperand* context() { return inputs_[0]; }
1701 DECLARE_CONCRETE_INSTRUCTION(LoadContextSlot, "load-context-slot")
1702 DECLARE_HYDROGEN_ACCESSOR(LoadContextSlot)
1704 int slot_index() { return hydrogen()->slot_index(); }
1706 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1710 class LStoreContextSlot V8_FINAL : public LTemplateInstruction<0, 2, 1> {
1712 LStoreContextSlot(LOperand* context, LOperand* value, LOperand* temp) {
1713 inputs_[0] = context;
1718 LOperand* context() { return inputs_[0]; }
1719 LOperand* value() { return inputs_[1]; }
1720 LOperand* temp() { return temps_[0]; }
1722 DECLARE_CONCRETE_INSTRUCTION(StoreContextSlot, "store-context-slot")
1723 DECLARE_HYDROGEN_ACCESSOR(StoreContextSlot)
1725 int slot_index() { return hydrogen()->slot_index(); }
1727 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1731 class LPushArgument V8_FINAL : public LTemplateInstruction<0, 1, 0> {
1733 explicit LPushArgument(LOperand* value) {
1737 LOperand* value() { return inputs_[0]; }
1739 DECLARE_CONCRETE_INSTRUCTION(PushArgument, "push-argument")
1743 class LDrop V8_FINAL : public LTemplateInstruction<0, 0, 0> {
1745 explicit LDrop(int count) : count_(count) { }
1747 int count() const { return count_; }
1749 DECLARE_CONCRETE_INSTRUCTION(Drop, "drop")
1756 class LStoreCodeEntry V8_FINAL: public LTemplateInstruction<0, 1, 1> {
1758 LStoreCodeEntry(LOperand* function, LOperand* code_object) {
1759 inputs_[0] = function;
1760 temps_[0] = code_object;
1763 LOperand* function() { return inputs_[0]; }
1764 LOperand* code_object() { return temps_[0]; }
1766 virtual void PrintDataTo(StringStream* stream);
1768 DECLARE_CONCRETE_INSTRUCTION(StoreCodeEntry, "store-code-entry")
1769 DECLARE_HYDROGEN_ACCESSOR(StoreCodeEntry)
1773 class LInnerAllocatedObject V8_FINAL: public LTemplateInstruction<1, 2, 0> {
1775 LInnerAllocatedObject(LOperand* base_object, LOperand* offset) {
1776 inputs_[0] = base_object;
1777 inputs_[1] = offset;
1780 LOperand* base_object() const { return inputs_[0]; }
1781 LOperand* offset() const { return inputs_[1]; }
1783 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1785 DECLARE_CONCRETE_INSTRUCTION(InnerAllocatedObject, "inner-allocated-object")
1789 class LThisFunction V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1791 DECLARE_CONCRETE_INSTRUCTION(ThisFunction, "this-function")
1792 DECLARE_HYDROGEN_ACCESSOR(ThisFunction)
1796 class LContext V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1798 DECLARE_CONCRETE_INSTRUCTION(Context, "context")
1799 DECLARE_HYDROGEN_ACCESSOR(Context)
1803 class LDeclareGlobals V8_FINAL : public LTemplateInstruction<0, 1, 0> {
1805 explicit LDeclareGlobals(LOperand* context) {
1806 inputs_[0] = context;
1809 LOperand* context() { return inputs_[0]; }
1811 DECLARE_CONCRETE_INSTRUCTION(DeclareGlobals, "declare-globals")
1812 DECLARE_HYDROGEN_ACCESSOR(DeclareGlobals)
1816 class LCallJSFunction V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1818 explicit LCallJSFunction(LOperand* function) {
1819 inputs_[0] = function;
1822 LOperand* function() { return inputs_[0]; }
1824 DECLARE_CONCRETE_INSTRUCTION(CallJSFunction, "call-js-function")
1825 DECLARE_HYDROGEN_ACCESSOR(CallJSFunction)
1827 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1829 int arity() const { return hydrogen()->argument_count() - 1; }
1833 class LCallWithDescriptor V8_FINAL : public LTemplateResultInstruction<1> {
1835 LCallWithDescriptor(const CallInterfaceDescriptor* descriptor,
1836 ZoneList<LOperand*>& operands,
1838 : inputs_(descriptor->environment_length() + 1, zone) {
1839 ASSERT(descriptor->environment_length() + 1 == operands.length());
1840 inputs_.AddAll(operands, zone);
1843 LOperand* target() const { return inputs_[0]; }
1846 DECLARE_CONCRETE_INSTRUCTION(CallWithDescriptor, "call-with-descriptor")
1847 DECLARE_HYDROGEN_ACCESSOR(CallWithDescriptor)
1849 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1851 int arity() const { return hydrogen()->argument_count() - 1; }
1853 ZoneList<LOperand*> inputs_;
1855 // Iterator support.
1856 virtual int InputCount() V8_FINAL V8_OVERRIDE { return inputs_.length(); }
1857 virtual LOperand* InputAt(int i) V8_FINAL V8_OVERRIDE { return inputs_[i]; }
1859 virtual int TempCount() V8_FINAL V8_OVERRIDE { return 0; }
1860 virtual LOperand* TempAt(int i) V8_FINAL V8_OVERRIDE { return NULL; }
1864 class LInvokeFunction V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1866 LInvokeFunction(LOperand* context, LOperand* function) {
1867 inputs_[0] = context;
1868 inputs_[1] = function;
1871 LOperand* context() { return inputs_[0]; }
1872 LOperand* function() { return inputs_[1]; }
1874 DECLARE_CONCRETE_INSTRUCTION(InvokeFunction, "invoke-function")
1875 DECLARE_HYDROGEN_ACCESSOR(InvokeFunction)
1877 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1879 int arity() const { return hydrogen()->argument_count() - 1; }
1883 class LCallFunction V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1885 LCallFunction(LOperand* context, LOperand* function) {
1886 inputs_[0] = context;
1887 inputs_[1] = function;
1890 DECLARE_CONCRETE_INSTRUCTION(CallFunction, "call-function")
1891 DECLARE_HYDROGEN_ACCESSOR(CallFunction)
1893 LOperand* context() { return inputs_[0]; }
1894 LOperand* function() { return inputs_[1]; }
1895 int arity() const { return hydrogen()->argument_count() - 1; }
1899 class LCallNew V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1901 LCallNew(LOperand* context, LOperand* constructor) {
1902 inputs_[0] = context;
1903 inputs_[1] = constructor;
1906 LOperand* context() { return inputs_[0]; }
1907 LOperand* constructor() { return inputs_[1]; }
1909 DECLARE_CONCRETE_INSTRUCTION(CallNew, "call-new")
1910 DECLARE_HYDROGEN_ACCESSOR(CallNew)
1912 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1914 int arity() const { return hydrogen()->argument_count() - 1; }
1918 class LCallNewArray V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1920 LCallNewArray(LOperand* context, LOperand* constructor) {
1921 inputs_[0] = context;
1922 inputs_[1] = constructor;
1925 LOperand* context() { return inputs_[0]; }
1926 LOperand* constructor() { return inputs_[1]; }
1928 DECLARE_CONCRETE_INSTRUCTION(CallNewArray, "call-new-array")
1929 DECLARE_HYDROGEN_ACCESSOR(CallNewArray)
1931 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1933 int arity() const { return hydrogen()->argument_count() - 1; }
1937 class LCallRuntime V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1939 explicit LCallRuntime(LOperand* context) {
1940 inputs_[0] = context;
1943 LOperand* context() { return inputs_[0]; }
1945 DECLARE_CONCRETE_INSTRUCTION(CallRuntime, "call-runtime")
1946 DECLARE_HYDROGEN_ACCESSOR(CallRuntime)
1948 virtual bool ClobbersDoubleRegisters(Isolate* isolate) const V8_OVERRIDE {
1949 return save_doubles() == kDontSaveFPRegs;
1952 const Runtime::Function* function() const { return hydrogen()->function(); }
1953 int arity() const { return hydrogen()->argument_count(); }
1954 SaveFPRegsMode save_doubles() const { return hydrogen()->save_doubles(); }
1958 class LInteger32ToDouble V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1960 explicit LInteger32ToDouble(LOperand* value) {
1964 LOperand* value() { return inputs_[0]; }
1966 DECLARE_CONCRETE_INSTRUCTION(Integer32ToDouble, "int32-to-double")
1970 class LUint32ToDouble V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1972 explicit LUint32ToDouble(LOperand* value) {
1976 LOperand* value() { return inputs_[0]; }
1978 DECLARE_CONCRETE_INSTRUCTION(Uint32ToDouble, "uint32-to-double")
1982 class LNumberTagI V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1984 explicit LNumberTagI(LOperand* value) {
1988 LOperand* value() { return inputs_[0]; }
1990 DECLARE_CONCRETE_INSTRUCTION(NumberTagI, "number-tag-i")
1994 class LNumberTagU V8_FINAL : public LTemplateInstruction<1, 1, 2> {
1996 LNumberTagU(LOperand* value, LOperand* temp1, LOperand* temp2) {
2002 LOperand* value() { return inputs_[0]; }
2003 LOperand* temp1() { return temps_[0]; }
2004 LOperand* temp2() { return temps_[1]; }
2006 DECLARE_CONCRETE_INSTRUCTION(NumberTagU, "number-tag-u")
2010 class LNumberTagD V8_FINAL : public LTemplateInstruction<1, 1, 1> {
2012 explicit LNumberTagD(LOperand* value, LOperand* temp) {
2017 LOperand* value() { return inputs_[0]; }
2018 LOperand* temp() { return temps_[0]; }
2020 DECLARE_CONCRETE_INSTRUCTION(NumberTagD, "number-tag-d")
2021 DECLARE_HYDROGEN_ACCESSOR(Change)
2025 // Sometimes truncating conversion from a tagged value to an int32.
2026 class LDoubleToI V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2028 explicit LDoubleToI(LOperand* value) {
2032 LOperand* value() { return inputs_[0]; }
2034 DECLARE_CONCRETE_INSTRUCTION(DoubleToI, "double-to-i")
2035 DECLARE_HYDROGEN_ACCESSOR(UnaryOperation)
2037 bool truncating() { return hydrogen()->CanTruncateToInt32(); }
2041 class LDoubleToSmi V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2043 explicit LDoubleToSmi(LOperand* value) {
2047 LOperand* value() { return inputs_[0]; }
2049 DECLARE_CONCRETE_INSTRUCTION(DoubleToSmi, "double-to-smi")
2050 DECLARE_HYDROGEN_ACCESSOR(UnaryOperation)
2054 // Truncating conversion from a tagged value to an int32.
2055 class LTaggedToI V8_FINAL : public LTemplateInstruction<1, 1, 1> {
2057 LTaggedToI(LOperand* value, LOperand* temp) {
2062 LOperand* value() { return inputs_[0]; }
2063 LOperand* temp() { return temps_[0]; }
2065 DECLARE_CONCRETE_INSTRUCTION(TaggedToI, "tagged-to-i")
2066 DECLARE_HYDROGEN_ACCESSOR(Change)
2068 bool truncating() { return hydrogen()->CanTruncateToInt32(); }
2072 class LSmiTag V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2074 explicit LSmiTag(LOperand* value) {
2078 LOperand* value() { return inputs_[0]; }
2080 DECLARE_CONCRETE_INSTRUCTION(SmiTag, "smi-tag")
2081 DECLARE_HYDROGEN_ACCESSOR(Change)
2085 class LNumberUntagD V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2087 explicit LNumberUntagD(LOperand* value) {
2091 LOperand* value() { return inputs_[0]; }
2093 DECLARE_CONCRETE_INSTRUCTION(NumberUntagD, "double-untag")
2094 DECLARE_HYDROGEN_ACCESSOR(Change);
2098 class LSmiUntag V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2100 LSmiUntag(LOperand* value, bool needs_check)
2101 : needs_check_(needs_check) {
2105 LOperand* value() { return inputs_[0]; }
2106 bool needs_check() const { return needs_check_; }
2108 DECLARE_CONCRETE_INSTRUCTION(SmiUntag, "smi-untag")
2115 class LStoreNamedField V8_FINAL : public LTemplateInstruction<0, 2, 1> {
2117 LStoreNamedField(LOperand* object, LOperand* value, LOperand* temp) {
2118 inputs_[0] = object;
2123 LOperand* object() { return inputs_[0]; }
2124 LOperand* value() { return inputs_[1]; }
2125 LOperand* temp() { return temps_[0]; }
2127 DECLARE_CONCRETE_INSTRUCTION(StoreNamedField, "store-named-field")
2128 DECLARE_HYDROGEN_ACCESSOR(StoreNamedField)
2130 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
2132 Representation representation() const {
2133 return hydrogen()->field_representation();
2138 class LStoreNamedGeneric V8_FINAL : public LTemplateInstruction<0, 3, 0> {
2140 LStoreNamedGeneric(LOperand* context, LOperand* object, LOperand* value) {
2141 inputs_[0] = context;
2142 inputs_[1] = object;
2146 LOperand* context() { return inputs_[0]; }
2147 LOperand* object() { return inputs_[1]; }
2148 LOperand* value() { return inputs_[2]; }
2150 DECLARE_CONCRETE_INSTRUCTION(StoreNamedGeneric, "store-named-generic")
2151 DECLARE_HYDROGEN_ACCESSOR(StoreNamedGeneric)
2153 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
2155 Handle<Object> name() const { return hydrogen()->name(); }
2156 StrictMode strict_mode() { return hydrogen()->strict_mode(); }
2160 class LStoreKeyed V8_FINAL : public LTemplateInstruction<0, 3, 0> {
2162 LStoreKeyed(LOperand* object, LOperand* key, LOperand* value) {
2163 inputs_[0] = object;
2168 bool is_external() const { return hydrogen()->is_external(); }
2169 bool is_fixed_typed_array() const {
2170 return hydrogen()->is_fixed_typed_array();
2172 bool is_typed_elements() const {
2173 return is_external() || is_fixed_typed_array();
2175 LOperand* elements() { return inputs_[0]; }
2176 LOperand* key() { return inputs_[1]; }
2177 LOperand* value() { return inputs_[2]; }
2178 ElementsKind elements_kind() const { return hydrogen()->elements_kind(); }
2180 DECLARE_CONCRETE_INSTRUCTION(StoreKeyed, "store-keyed")
2181 DECLARE_HYDROGEN_ACCESSOR(StoreKeyed)
2183 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
2184 bool NeedsCanonicalization() { return hydrogen()->NeedsCanonicalization(); }
2185 uint32_t base_offset() const { return hydrogen()->base_offset(); }
2189 class LStoreKeyedGeneric V8_FINAL : public LTemplateInstruction<0, 4, 0> {
2191 LStoreKeyedGeneric(LOperand* context,
2195 inputs_[0] = context;
2196 inputs_[1] = object;
2201 LOperand* context() { return inputs_[0]; }
2202 LOperand* object() { return inputs_[1]; }
2203 LOperand* key() { return inputs_[2]; }
2204 LOperand* value() { return inputs_[3]; }
2206 DECLARE_CONCRETE_INSTRUCTION(StoreKeyedGeneric, "store-keyed-generic")
2207 DECLARE_HYDROGEN_ACCESSOR(StoreKeyedGeneric)
2209 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
2211 StrictMode strict_mode() { return hydrogen()->strict_mode(); }
2215 class LTransitionElementsKind V8_FINAL : public LTemplateInstruction<0, 2, 2> {
2217 LTransitionElementsKind(LOperand* object,
2219 LOperand* new_map_temp,
2221 inputs_[0] = object;
2222 inputs_[1] = context;
2223 temps_[0] = new_map_temp;
2227 LOperand* object() { return inputs_[0]; }
2228 LOperand* context() { return inputs_[1]; }
2229 LOperand* new_map_temp() { return temps_[0]; }
2230 LOperand* temp() { return temps_[1]; }
2232 DECLARE_CONCRETE_INSTRUCTION(TransitionElementsKind,
2233 "transition-elements-kind")
2234 DECLARE_HYDROGEN_ACCESSOR(TransitionElementsKind)
2236 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
2238 Handle<Map> original_map() { return hydrogen()->original_map().handle(); }
2239 Handle<Map> transitioned_map() {
2240 return hydrogen()->transitioned_map().handle();
2242 ElementsKind from_kind() { return hydrogen()->from_kind(); }
2243 ElementsKind to_kind() { return hydrogen()->to_kind(); }
2247 class LArrayShift V8_FINAL : public LTemplateInstruction<1, 2, 0> {
2249 LArrayShift(LOperand* context, LOperand* object) {
2250 inputs_[0] = context;
2251 inputs_[1] = object;
2254 LOperand* context() const { return inputs_[0]; }
2255 LOperand* object() const { return inputs_[1]; }
2257 DECLARE_CONCRETE_INSTRUCTION(ArrayShift, "array-shift")
2258 DECLARE_HYDROGEN_ACCESSOR(ArrayShift)
2262 class LTrapAllocationMemento V8_FINAL : public LTemplateInstruction<0, 1, 1> {
2264 LTrapAllocationMemento(LOperand* object,
2266 inputs_[0] = object;
2270 LOperand* object() { return inputs_[0]; }
2271 LOperand* temp() { return temps_[0]; }
2273 DECLARE_CONCRETE_INSTRUCTION(TrapAllocationMemento,
2274 "trap-allocation-memento")
2278 class LStringAdd V8_FINAL : public LTemplateInstruction<1, 3, 0> {
2280 LStringAdd(LOperand* context, LOperand* left, LOperand* right) {
2281 inputs_[0] = context;
2286 LOperand* context() { return inputs_[0]; }
2287 LOperand* left() { return inputs_[1]; }
2288 LOperand* right() { return inputs_[2]; }
2290 DECLARE_CONCRETE_INSTRUCTION(StringAdd, "string-add")
2291 DECLARE_HYDROGEN_ACCESSOR(StringAdd)
2295 class LStringCharCodeAt V8_FINAL : public LTemplateInstruction<1, 3, 0> {
2297 LStringCharCodeAt(LOperand* context, LOperand* string, LOperand* index) {
2298 inputs_[0] = context;
2299 inputs_[1] = string;
2303 LOperand* context() { return inputs_[0]; }
2304 LOperand* string() { return inputs_[1]; }
2305 LOperand* index() { return inputs_[2]; }
2307 DECLARE_CONCRETE_INSTRUCTION(StringCharCodeAt, "string-char-code-at")
2308 DECLARE_HYDROGEN_ACCESSOR(StringCharCodeAt)
2312 class LStringCharFromCode V8_FINAL : public LTemplateInstruction<1, 2, 0> {
2314 explicit LStringCharFromCode(LOperand* context, LOperand* char_code) {
2315 inputs_[0] = context;
2316 inputs_[1] = char_code;
2319 LOperand* context() { return inputs_[0]; }
2320 LOperand* char_code() { return inputs_[1]; }
2322 DECLARE_CONCRETE_INSTRUCTION(StringCharFromCode, "string-char-from-code")
2323 DECLARE_HYDROGEN_ACCESSOR(StringCharFromCode)
2327 class LCheckValue V8_FINAL : public LTemplateInstruction<0, 1, 0> {
2329 explicit LCheckValue(LOperand* value) {
2333 LOperand* value() { return inputs_[0]; }
2335 DECLARE_CONCRETE_INSTRUCTION(CheckValue, "check-value")
2336 DECLARE_HYDROGEN_ACCESSOR(CheckValue)
2340 class LCheckInstanceType V8_FINAL : public LTemplateInstruction<0, 1, 0> {
2342 explicit LCheckInstanceType(LOperand* value) {
2346 LOperand* value() { return inputs_[0]; }
2348 DECLARE_CONCRETE_INSTRUCTION(CheckInstanceType, "check-instance-type")
2349 DECLARE_HYDROGEN_ACCESSOR(CheckInstanceType)
2353 class LCheckMaps V8_FINAL : public LTemplateInstruction<0, 1, 0> {
2355 explicit LCheckMaps(LOperand* value = NULL) {
2359 LOperand* value() { return inputs_[0]; }
2361 DECLARE_CONCRETE_INSTRUCTION(CheckMaps, "check-maps")
2362 DECLARE_HYDROGEN_ACCESSOR(CheckMaps)
2366 class LCheckSmi V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2368 explicit LCheckSmi(LOperand* value) {
2372 LOperand* value() { return inputs_[0]; }
2374 DECLARE_CONCRETE_INSTRUCTION(CheckSmi, "check-smi")
2378 class LClampDToUint8 V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2380 explicit LClampDToUint8(LOperand* unclamped) {
2381 inputs_[0] = unclamped;
2384 LOperand* unclamped() { return inputs_[0]; }
2386 DECLARE_CONCRETE_INSTRUCTION(ClampDToUint8, "clamp-d-to-uint8")
2390 class LClampIToUint8 V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2392 explicit LClampIToUint8(LOperand* unclamped) {
2393 inputs_[0] = unclamped;
2396 LOperand* unclamped() { return inputs_[0]; }
2398 DECLARE_CONCRETE_INSTRUCTION(ClampIToUint8, "clamp-i-to-uint8")
2402 class LClampTToUint8 V8_FINAL : public LTemplateInstruction<1, 1, 1> {
2404 LClampTToUint8(LOperand* unclamped,
2405 LOperand* temp_xmm) {
2406 inputs_[0] = unclamped;
2407 temps_[0] = temp_xmm;
2410 LOperand* unclamped() { return inputs_[0]; }
2411 LOperand* temp_xmm() { return temps_[0]; }
2413 DECLARE_CONCRETE_INSTRUCTION(ClampTToUint8, "clamp-t-to-uint8")
2417 class LCheckNonSmi V8_FINAL : public LTemplateInstruction<0, 1, 0> {
2419 explicit LCheckNonSmi(LOperand* value) {
2423 LOperand* value() { return inputs_[0]; }
2425 DECLARE_CONCRETE_INSTRUCTION(CheckNonSmi, "check-non-smi")
2426 DECLARE_HYDROGEN_ACCESSOR(CheckHeapObject)
2430 class LDoubleBits V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2432 explicit LDoubleBits(LOperand* value) {
2436 LOperand* value() { return inputs_[0]; }
2438 DECLARE_CONCRETE_INSTRUCTION(DoubleBits, "double-bits")
2439 DECLARE_HYDROGEN_ACCESSOR(DoubleBits)
2443 class LConstructDouble V8_FINAL : public LTemplateInstruction<1, 2, 0> {
2445 LConstructDouble(LOperand* hi, LOperand* lo) {
2450 LOperand* hi() { return inputs_[0]; }
2451 LOperand* lo() { return inputs_[1]; }
2453 DECLARE_CONCRETE_INSTRUCTION(ConstructDouble, "construct-double")
2457 class LAllocate V8_FINAL : public LTemplateInstruction<1, 2, 1> {
2459 LAllocate(LOperand* context, LOperand* size, LOperand* temp) {
2460 inputs_[0] = context;
2465 LOperand* context() { return inputs_[0]; }
2466 LOperand* size() { return inputs_[1]; }
2467 LOperand* temp() { return temps_[0]; }
2469 DECLARE_CONCRETE_INSTRUCTION(Allocate, "allocate")
2470 DECLARE_HYDROGEN_ACCESSOR(Allocate)
2474 class LRegExpLiteral V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2476 explicit LRegExpLiteral(LOperand* context) {
2477 inputs_[0] = context;
2480 LOperand* context() { return inputs_[0]; }
2482 DECLARE_CONCRETE_INSTRUCTION(RegExpLiteral, "regexp-literal")
2483 DECLARE_HYDROGEN_ACCESSOR(RegExpLiteral)
2487 class LFunctionLiteral V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2489 explicit LFunctionLiteral(LOperand* context) {
2490 inputs_[0] = context;
2493 LOperand* context() { return inputs_[0]; }
2495 DECLARE_CONCRETE_INSTRUCTION(FunctionLiteral, "function-literal")
2496 DECLARE_HYDROGEN_ACCESSOR(FunctionLiteral)
2500 class LToFastProperties V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2502 explicit LToFastProperties(LOperand* value) {
2506 LOperand* value() { return inputs_[0]; }
2508 DECLARE_CONCRETE_INSTRUCTION(ToFastProperties, "to-fast-properties")
2509 DECLARE_HYDROGEN_ACCESSOR(ToFastProperties)
2513 class LTypeof V8_FINAL : public LTemplateInstruction<1, 2, 0> {
2515 LTypeof(LOperand* context, LOperand* value) {
2516 inputs_[0] = context;
2520 LOperand* context() { return inputs_[0]; }
2521 LOperand* value() { return inputs_[1]; }
2523 DECLARE_CONCRETE_INSTRUCTION(Typeof, "typeof")
2527 class LTypeofIsAndBranch V8_FINAL : public LControlInstruction<1, 0> {
2529 explicit LTypeofIsAndBranch(LOperand* value) {
2533 LOperand* value() { return inputs_[0]; }
2535 DECLARE_CONCRETE_INSTRUCTION(TypeofIsAndBranch, "typeof-is-and-branch")
2536 DECLARE_HYDROGEN_ACCESSOR(TypeofIsAndBranch)
2538 Handle<String> type_literal() { return hydrogen()->type_literal(); }
2540 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
2544 class LIsConstructCallAndBranch V8_FINAL : public LControlInstruction<0, 1> {
2546 explicit LIsConstructCallAndBranch(LOperand* temp) {
2550 LOperand* temp() { return temps_[0]; }
2552 DECLARE_CONCRETE_INSTRUCTION(IsConstructCallAndBranch,
2553 "is-construct-call-and-branch")
2554 DECLARE_HYDROGEN_ACCESSOR(IsConstructCallAndBranch)
2558 class LOsrEntry V8_FINAL : public LTemplateInstruction<0, 0, 0> {
2562 virtual bool HasInterestingComment(LCodeGen* gen) const V8_OVERRIDE {
2565 DECLARE_CONCRETE_INSTRUCTION(OsrEntry, "osr-entry")
2569 class LStackCheck V8_FINAL : public LTemplateInstruction<0, 1, 0> {
2571 explicit LStackCheck(LOperand* context) {
2572 inputs_[0] = context;
2575 LOperand* context() { return inputs_[0]; }
2577 DECLARE_CONCRETE_INSTRUCTION(StackCheck, "stack-check")
2578 DECLARE_HYDROGEN_ACCESSOR(StackCheck)
2580 Label* done_label() { return &done_label_; }
2587 class LForInPrepareMap V8_FINAL : public LTemplateInstruction<1, 2, 0> {
2589 LForInPrepareMap(LOperand* context, LOperand* object) {
2590 inputs_[0] = context;
2591 inputs_[1] = object;
2594 LOperand* context() { return inputs_[0]; }
2595 LOperand* object() { return inputs_[1]; }
2597 DECLARE_CONCRETE_INSTRUCTION(ForInPrepareMap, "for-in-prepare-map")
2601 class LForInCacheArray V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2603 explicit LForInCacheArray(LOperand* map) {
2607 LOperand* map() { return inputs_[0]; }
2609 DECLARE_CONCRETE_INSTRUCTION(ForInCacheArray, "for-in-cache-array")
2612 return HForInCacheArray::cast(this->hydrogen_value())->idx();
2617 class LCheckMapValue V8_FINAL : public LTemplateInstruction<0, 2, 0> {
2619 LCheckMapValue(LOperand* value, LOperand* map) {
2624 LOperand* value() { return inputs_[0]; }
2625 LOperand* map() { return inputs_[1]; }
2627 DECLARE_CONCRETE_INSTRUCTION(CheckMapValue, "check-map-value")
2631 class LLoadFieldByIndex V8_FINAL : public LTemplateInstruction<1, 2, 0> {
2633 LLoadFieldByIndex(LOperand* object, LOperand* index) {
2634 inputs_[0] = object;
2638 LOperand* object() { return inputs_[0]; }
2639 LOperand* index() { return inputs_[1]; }
2641 DECLARE_CONCRETE_INSTRUCTION(LoadFieldByIndex, "load-field-by-index")
2645 class LChunkBuilder;
2646 class LPlatformChunk V8_FINAL : public LChunk {
2648 LPlatformChunk(CompilationInfo* info, HGraph* graph)
2649 : LChunk(info, graph),
2650 dehoisted_key_ids_(graph->GetMaximumValueID(), graph->zone()) { }
2652 int GetNextSpillIndex(RegisterKind kind);
2653 LOperand* GetNextSpillSlot(RegisterKind kind);
2654 BitVector* GetDehoistedKeyIds() { return &dehoisted_key_ids_; }
2655 bool IsDehoistedKey(HValue* value) {
2656 return dehoisted_key_ids_.Contains(value->id());
2660 BitVector dehoisted_key_ids_;
2664 class LChunkBuilder V8_FINAL : public LChunkBuilderBase {
2666 LChunkBuilder(CompilationInfo* info, HGraph* graph, LAllocator* allocator)
2667 : LChunkBuilderBase(graph->zone()),
2672 current_instruction_(NULL),
2673 current_block_(NULL),
2675 allocator_(allocator) { }
2677 Isolate* isolate() const { return graph_->isolate(); }
2679 // Build the sequence for the graph.
2680 LPlatformChunk* Build();
2682 LInstruction* CheckElideControlInstruction(HControlInstruction* instr);
2684 // Declare methods that deal with the individual node types.
2685 #define DECLARE_DO(type) LInstruction* Do##type(H##type* node);
2686 HYDROGEN_CONCRETE_INSTRUCTION_LIST(DECLARE_DO)
2689 LInstruction* DoMathFloor(HUnaryMathOperation* instr);
2690 LInstruction* DoMathRound(HUnaryMathOperation* instr);
2691 LInstruction* DoMathAbs(HUnaryMathOperation* instr);
2692 LInstruction* DoMathLog(HUnaryMathOperation* instr);
2693 LInstruction* DoMathExp(HUnaryMathOperation* instr);
2694 LInstruction* DoMathSqrt(HUnaryMathOperation* instr);
2695 LInstruction* DoMathPowHalf(HUnaryMathOperation* instr);
2696 LInstruction* DoMathClz32(HUnaryMathOperation* instr);
2697 LInstruction* DoDivByPowerOf2I(HDiv* instr);
2698 LInstruction* DoDivByConstI(HDiv* instr);
2699 LInstruction* DoDivI(HDiv* instr);
2700 LInstruction* DoModByPowerOf2I(HMod* instr);
2701 LInstruction* DoModByConstI(HMod* instr);
2702 LInstruction* DoModI(HMod* instr);
2703 LInstruction* DoFlooringDivByPowerOf2I(HMathFloorOfDiv* instr);
2704 LInstruction* DoFlooringDivByConstI(HMathFloorOfDiv* instr);
2705 LInstruction* DoFlooringDivI(HMathFloorOfDiv* instr);
2715 LPlatformChunk* chunk() const { return chunk_; }
2716 CompilationInfo* info() const { return info_; }
2717 HGraph* graph() const { return graph_; }
2719 bool is_unused() const { return status_ == UNUSED; }
2720 bool is_building() const { return status_ == BUILDING; }
2721 bool is_done() const { return status_ == DONE; }
2722 bool is_aborted() const { return status_ == ABORTED; }
2724 void Abort(BailoutReason reason);
2726 // Methods for getting operands for Use / Define / Temp.
2727 LUnallocated* ToUnallocated(Register reg);
2728 LUnallocated* ToUnallocated(XMMRegister reg);
2730 // Methods for setting up define-use relationships.
2731 MUST_USE_RESULT LOperand* Use(HValue* value, LUnallocated* operand);
2732 MUST_USE_RESULT LOperand* UseFixed(HValue* value, Register fixed_register);
2733 MUST_USE_RESULT LOperand* UseFixedDouble(HValue* value,
2734 XMMRegister fixed_register);
2736 // A value that is guaranteed to be allocated to a register.
2737 // Operand created by UseRegister is guaranteed to be live until the end of
2738 // instruction. This means that register allocator will not reuse it's
2739 // register for any other operand inside instruction.
2740 // Operand created by UseRegisterAtStart is guaranteed to be live only at
2741 // instruction start. Register allocator is free to assign the same register
2742 // to some other operand used inside instruction (i.e. temporary or
2744 MUST_USE_RESULT LOperand* UseRegister(HValue* value);
2745 MUST_USE_RESULT LOperand* UseRegisterAtStart(HValue* value);
2747 // An input operand in a register that may be trashed.
2748 MUST_USE_RESULT LOperand* UseTempRegister(HValue* value);
2750 // An input operand in a register that may be trashed or a constant operand.
2751 MUST_USE_RESULT LOperand* UseTempRegisterOrConstant(HValue* value);
2753 // An input operand in a register or stack slot.
2754 MUST_USE_RESULT LOperand* Use(HValue* value);
2755 MUST_USE_RESULT LOperand* UseAtStart(HValue* value);
2757 // An input operand in a register, stack slot or a constant operand.
2758 MUST_USE_RESULT LOperand* UseOrConstant(HValue* value);
2759 MUST_USE_RESULT LOperand* UseOrConstantAtStart(HValue* value);
2761 // An input operand in a register or a constant operand.
2762 MUST_USE_RESULT LOperand* UseRegisterOrConstant(HValue* value);
2763 MUST_USE_RESULT LOperand* UseRegisterOrConstantAtStart(HValue* value);
2765 // An input operand in a constant operand.
2766 MUST_USE_RESULT LOperand* UseConstant(HValue* value);
2768 // An input operand in register, stack slot or a constant operand.
2769 // Will not be moved to a register even if one is freely available.
2770 virtual MUST_USE_RESULT LOperand* UseAny(HValue* value) V8_OVERRIDE;
2772 // Temporary operand that must be in a register.
2773 MUST_USE_RESULT LUnallocated* TempRegister();
2774 MUST_USE_RESULT LOperand* FixedTemp(Register reg);
2775 MUST_USE_RESULT LOperand* FixedTemp(XMMRegister reg);
2777 // Methods for setting up define-use relationships.
2778 // Return the same instruction that they are passed.
2779 LInstruction* Define(LTemplateResultInstruction<1>* instr,
2780 LUnallocated* result);
2781 LInstruction* DefineAsRegister(LTemplateResultInstruction<1>* instr);
2782 LInstruction* DefineAsSpilled(LTemplateResultInstruction<1>* instr,
2784 LInstruction* DefineSameAsFirst(LTemplateResultInstruction<1>* instr);
2785 LInstruction* DefineFixed(LTemplateResultInstruction<1>* instr,
2787 LInstruction* DefineFixedDouble(LTemplateResultInstruction<1>* instr,
2789 // Assigns an environment to an instruction. An instruction which can
2790 // deoptimize must have an environment.
2791 LInstruction* AssignEnvironment(LInstruction* instr);
2792 // Assigns a pointer map to an instruction. An instruction which can
2793 // trigger a GC or a lazy deoptimization must have a pointer map.
2794 LInstruction* AssignPointerMap(LInstruction* instr);
2796 enum CanDeoptimize { CAN_DEOPTIMIZE_EAGERLY, CANNOT_DEOPTIMIZE_EAGERLY };
2798 // Marks a call for the register allocator. Assigns a pointer map to
2799 // support GC and lazy deoptimization. Assigns an environment to support
2800 // eager deoptimization if CAN_DEOPTIMIZE_EAGERLY.
2801 LInstruction* MarkAsCall(
2802 LInstruction* instr,
2803 HInstruction* hinstr,
2804 CanDeoptimize can_deoptimize = CANNOT_DEOPTIMIZE_EAGERLY);
2806 void VisitInstruction(HInstruction* current);
2807 void AddInstruction(LInstruction* instr, HInstruction* current);
2809 void DoBasicBlock(HBasicBlock* block, HBasicBlock* next_block);
2810 LInstruction* DoShift(Token::Value op, HBitwiseBinaryOperation* instr);
2811 LInstruction* DoArithmeticD(Token::Value op,
2812 HArithmeticBinaryOperation* instr);
2813 LInstruction* DoArithmeticT(Token::Value op,
2814 HBinaryOperation* instr);
2815 void FindDehoistedKeyDefinitions(HValue* candidate);
2817 LPlatformChunk* chunk_;
2818 CompilationInfo* info_;
2819 HGraph* const graph_;
2821 HInstruction* current_instruction_;
2822 HBasicBlock* current_block_;
2823 HBasicBlock* next_block_;
2824 LAllocator* allocator_;
2826 DISALLOW_COPY_AND_ASSIGN(LChunkBuilder);
2829 #undef DECLARE_HYDROGEN_ACCESSOR
2830 #undef DECLARE_CONCRETE_INSTRUCTION
2832 } } // namespace v8::int
2834 #endif // V8_X64_LITHIUM_X64_H_