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-allocator.h"
10 #include "src/lithium.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) \
25 V(ArgumentsElements) \
33 V(CallWithDescriptor) \
39 V(CheckInstanceType) \
48 V(ClassOfTestAndBranch) \
49 V(CompareMinusZeroAndBranch) \
50 V(CompareNumericAndBranch) \
51 V(CmpObjectEqAndBranch) \
75 V(FlooringDivByConstI) \
76 V(FlooringDivByPowerOf2I) \
81 V(GetCachedArrayIndex) \
83 V(HasCachedArrayIndexAndBranch) \
84 V(HasInstanceTypeAndBranch) \
85 V(InnerAllocatedObject) \
87 V(InstanceOfKnownGlobal) \
89 V(Integer32ToDouble) \
91 V(IsConstructCallAndBranch) \
92 V(IsObjectAndBranch) \
93 V(IsStringAndBranch) \
95 V(IsUndetectableAndBranch) \
100 V(LoadFieldByIndex) \
101 V(LoadFunctionPrototype) \
103 V(LoadGlobalGeneric) \
105 V(LoadKeyedGeneric) \
107 V(LoadNamedGeneric) \
132 V(SeqStringGetChar) \
133 V(SeqStringSetChar) \
139 V(StoreContextSlot) \
142 V(StoreKeyedGeneric) \
144 V(StoreNamedGeneric) \
146 V(StringCharCodeAt) \
147 V(StringCharFromCode) \
148 V(StringCompareAndBranch) \
152 V(ToFastProperties) \
153 V(TransitionElementsKind) \
154 V(TrapAllocationMemento) \
156 V(TypeofIsAndBranch) \
162 #define DECLARE_CONCRETE_INSTRUCTION(type, mnemonic) \
163 virtual Opcode opcode() const V8_FINAL V8_OVERRIDE { \
164 return LInstruction::k##type; \
166 virtual void CompileToNative(LCodeGen* generator) V8_FINAL V8_OVERRIDE; \
167 virtual const char* Mnemonic() const V8_FINAL V8_OVERRIDE { \
170 static L##type* cast(LInstruction* instr) { \
171 ASSERT(instr->Is##type()); \
172 return reinterpret_cast<L##type*>(instr); \
176 #define DECLARE_HYDROGEN_ACCESSOR(type) \
177 H##type* hydrogen() const { \
178 return H##type::cast(hydrogen_value()); \
182 class LInstruction : public ZoneObject {
185 : environment_(NULL),
186 hydrogen_value_(NULL),
187 bit_field_(IsCallBits::encode(false)) {
190 virtual ~LInstruction() {}
192 virtual void CompileToNative(LCodeGen* generator) = 0;
193 virtual const char* Mnemonic() const = 0;
194 virtual void PrintTo(StringStream* stream);
195 virtual void PrintDataTo(StringStream* stream);
196 virtual void PrintOutputOperandTo(StringStream* stream);
199 // Declare a unique enum value for each instruction.
200 #define DECLARE_OPCODE(type) k##type,
201 LITHIUM_CONCRETE_INSTRUCTION_LIST(DECLARE_OPCODE)
202 kNumberOfInstructions
203 #undef DECLARE_OPCODE
206 virtual Opcode opcode() const = 0;
208 // Declare non-virtual type testers for all leaf IR classes.
209 #define DECLARE_PREDICATE(type) \
210 bool Is##type() const { return opcode() == k##type; }
211 LITHIUM_CONCRETE_INSTRUCTION_LIST(DECLARE_PREDICATE)
212 #undef DECLARE_PREDICATE
214 // Declare virtual predicates for instructions that don't have
216 virtual bool IsGap() const { return false; }
218 virtual bool IsControl() const { return false; }
220 void set_environment(LEnvironment* env) { environment_ = env; }
221 LEnvironment* environment() const { return environment_; }
222 bool HasEnvironment() const { return environment_ != NULL; }
224 void set_pointer_map(LPointerMap* p) { pointer_map_.set(p); }
225 LPointerMap* pointer_map() const { return pointer_map_.get(); }
226 bool HasPointerMap() const { return pointer_map_.is_set(); }
228 void set_hydrogen_value(HValue* value) { hydrogen_value_ = value; }
229 HValue* hydrogen_value() const { return hydrogen_value_; }
231 void MarkAsCall() { bit_field_ = IsCallBits::update(bit_field_, true); }
232 bool IsCall() const { return IsCallBits::decode(bit_field_); }
234 // Interface to the register allocator and iterators.
235 bool ClobbersTemps() const { return IsCall(); }
236 bool ClobbersRegisters() const { return IsCall(); }
237 virtual bool ClobbersDoubleRegisters(Isolate* isolate) const {
241 virtual void SetDeferredLazyDeoptimizationEnvironment(LEnvironment* env) { }
243 // Interface to the register allocator and iterators.
244 bool IsMarkedAsCall() const { return IsCall(); }
246 virtual bool HasResult() const = 0;
247 virtual LOperand* result() const = 0;
249 LOperand* FirstInput() { return InputAt(0); }
250 LOperand* Output() { return HasResult() ? result() : NULL; }
252 virtual bool HasInterestingComment(LCodeGen* gen) const { return true; }
254 virtual bool MustSignExtendResult(LPlatformChunk* chunk) const {
264 friend class InputIterator;
265 virtual int InputCount() = 0;
266 virtual LOperand* InputAt(int i) = 0;
268 friend class TempIterator;
269 virtual int TempCount() = 0;
270 virtual LOperand* TempAt(int i) = 0;
272 class IsCallBits: public BitField<bool, 0, 1> {};
274 LEnvironment* environment_;
275 SetOncePointer<LPointerMap> pointer_map_;
276 HValue* hydrogen_value_;
281 // R = number of result operands (0 or 1).
283 class LTemplateResultInstruction : public LInstruction {
285 // Allow 0 or 1 output operands.
286 STATIC_ASSERT(R == 0 || R == 1);
287 virtual bool HasResult() const V8_FINAL V8_OVERRIDE {
288 return R != 0 && result() != NULL;
290 void set_result(LOperand* operand) { results_[0] = operand; }
291 LOperand* result() const { return results_[0]; }
293 virtual bool MustSignExtendResult(
294 LPlatformChunk* chunk) const V8_FINAL V8_OVERRIDE;
297 EmbeddedContainer<LOperand*, R> results_;
301 // R = number of result operands (0 or 1).
302 // I = number of input operands.
303 // T = number of temporary operands.
304 template<int R, int I, int T>
305 class LTemplateInstruction : public LTemplateResultInstruction<R> {
307 EmbeddedContainer<LOperand*, I> inputs_;
308 EmbeddedContainer<LOperand*, T> temps_;
312 virtual int InputCount() V8_FINAL V8_OVERRIDE { return I; }
313 virtual LOperand* InputAt(int i) V8_FINAL V8_OVERRIDE { return inputs_[i]; }
315 virtual int TempCount() V8_FINAL V8_OVERRIDE { return T; }
316 virtual LOperand* TempAt(int i) V8_FINAL V8_OVERRIDE { return temps_[i]; }
320 class LGap : public LTemplateInstruction<0, 0, 0> {
322 explicit LGap(HBasicBlock* block)
324 parallel_moves_[BEFORE] = NULL;
325 parallel_moves_[START] = NULL;
326 parallel_moves_[END] = NULL;
327 parallel_moves_[AFTER] = NULL;
330 // Can't use the DECLARE-macro here because of sub-classes.
331 virtual bool IsGap() const V8_FINAL V8_OVERRIDE { return true; }
332 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
333 static LGap* cast(LInstruction* instr) {
334 ASSERT(instr->IsGap());
335 return reinterpret_cast<LGap*>(instr);
338 bool IsRedundant() const;
340 HBasicBlock* block() const { return block_; }
347 FIRST_INNER_POSITION = BEFORE,
348 LAST_INNER_POSITION = AFTER
351 LParallelMove* GetOrCreateParallelMove(InnerPosition pos,
353 if (parallel_moves_[pos] == NULL) {
354 parallel_moves_[pos] = new(zone) LParallelMove(zone);
356 return parallel_moves_[pos];
359 LParallelMove* GetParallelMove(InnerPosition pos) {
360 return parallel_moves_[pos];
364 LParallelMove* parallel_moves_[LAST_INNER_POSITION + 1];
369 class LInstructionGap V8_FINAL : public LGap {
371 explicit LInstructionGap(HBasicBlock* block) : LGap(block) { }
373 virtual bool HasInterestingComment(LCodeGen* gen) const V8_OVERRIDE {
374 return !IsRedundant();
377 DECLARE_CONCRETE_INSTRUCTION(InstructionGap, "gap")
381 class LGoto V8_FINAL : public LTemplateInstruction<0, 0, 0> {
383 explicit LGoto(HBasicBlock* block) : block_(block) { }
385 virtual bool HasInterestingComment(LCodeGen* gen) const V8_OVERRIDE;
386 DECLARE_CONCRETE_INSTRUCTION(Goto, "goto")
387 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
388 virtual bool IsControl() const V8_OVERRIDE { return true; }
390 int block_id() const { return block_->block_id(); }
397 class LLazyBailout V8_FINAL : public LTemplateInstruction<0, 0, 0> {
399 LLazyBailout() : gap_instructions_size_(0) { }
401 DECLARE_CONCRETE_INSTRUCTION(LazyBailout, "lazy-bailout")
403 void set_gap_instructions_size(int gap_instructions_size) {
404 gap_instructions_size_ = gap_instructions_size;
406 int gap_instructions_size() { return gap_instructions_size_; }
409 int gap_instructions_size_;
413 class LDummy V8_FINAL : public LTemplateInstruction<1, 0, 0> {
415 explicit LDummy() { }
416 DECLARE_CONCRETE_INSTRUCTION(Dummy, "dummy")
420 class LDummyUse V8_FINAL : public LTemplateInstruction<1, 1, 0> {
422 explicit LDummyUse(LOperand* value) {
425 DECLARE_CONCRETE_INSTRUCTION(DummyUse, "dummy-use")
429 class LDeoptimize V8_FINAL : public LTemplateInstruction<0, 0, 0> {
431 virtual bool IsControl() const V8_OVERRIDE { return true; }
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 LTrapAllocationMemento V8_FINAL : public LTemplateInstruction<0, 1, 1> {
2249 LTrapAllocationMemento(LOperand* object,
2251 inputs_[0] = object;
2255 LOperand* object() { return inputs_[0]; }
2256 LOperand* temp() { return temps_[0]; }
2258 DECLARE_CONCRETE_INSTRUCTION(TrapAllocationMemento,
2259 "trap-allocation-memento")
2263 class LStringAdd V8_FINAL : public LTemplateInstruction<1, 3, 0> {
2265 LStringAdd(LOperand* context, LOperand* left, LOperand* right) {
2266 inputs_[0] = context;
2271 LOperand* context() { return inputs_[0]; }
2272 LOperand* left() { return inputs_[1]; }
2273 LOperand* right() { return inputs_[2]; }
2275 DECLARE_CONCRETE_INSTRUCTION(StringAdd, "string-add")
2276 DECLARE_HYDROGEN_ACCESSOR(StringAdd)
2280 class LStringCharCodeAt V8_FINAL : public LTemplateInstruction<1, 3, 0> {
2282 LStringCharCodeAt(LOperand* context, LOperand* string, LOperand* index) {
2283 inputs_[0] = context;
2284 inputs_[1] = string;
2288 LOperand* context() { return inputs_[0]; }
2289 LOperand* string() { return inputs_[1]; }
2290 LOperand* index() { return inputs_[2]; }
2292 DECLARE_CONCRETE_INSTRUCTION(StringCharCodeAt, "string-char-code-at")
2293 DECLARE_HYDROGEN_ACCESSOR(StringCharCodeAt)
2297 class LStringCharFromCode V8_FINAL : public LTemplateInstruction<1, 2, 0> {
2299 explicit LStringCharFromCode(LOperand* context, LOperand* char_code) {
2300 inputs_[0] = context;
2301 inputs_[1] = char_code;
2304 LOperand* context() { return inputs_[0]; }
2305 LOperand* char_code() { return inputs_[1]; }
2307 DECLARE_CONCRETE_INSTRUCTION(StringCharFromCode, "string-char-from-code")
2308 DECLARE_HYDROGEN_ACCESSOR(StringCharFromCode)
2312 class LCheckValue V8_FINAL : public LTemplateInstruction<0, 1, 0> {
2314 explicit LCheckValue(LOperand* value) {
2318 LOperand* value() { return inputs_[0]; }
2320 DECLARE_CONCRETE_INSTRUCTION(CheckValue, "check-value")
2321 DECLARE_HYDROGEN_ACCESSOR(CheckValue)
2325 class LCheckInstanceType V8_FINAL : public LTemplateInstruction<0, 1, 0> {
2327 explicit LCheckInstanceType(LOperand* value) {
2331 LOperand* value() { return inputs_[0]; }
2333 DECLARE_CONCRETE_INSTRUCTION(CheckInstanceType, "check-instance-type")
2334 DECLARE_HYDROGEN_ACCESSOR(CheckInstanceType)
2338 class LCheckMaps V8_FINAL : public LTemplateInstruction<0, 1, 0> {
2340 explicit LCheckMaps(LOperand* value = NULL) {
2344 LOperand* value() { return inputs_[0]; }
2346 DECLARE_CONCRETE_INSTRUCTION(CheckMaps, "check-maps")
2347 DECLARE_HYDROGEN_ACCESSOR(CheckMaps)
2351 class LCheckSmi V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2353 explicit LCheckSmi(LOperand* value) {
2357 LOperand* value() { return inputs_[0]; }
2359 DECLARE_CONCRETE_INSTRUCTION(CheckSmi, "check-smi")
2363 class LClampDToUint8 V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2365 explicit LClampDToUint8(LOperand* unclamped) {
2366 inputs_[0] = unclamped;
2369 LOperand* unclamped() { return inputs_[0]; }
2371 DECLARE_CONCRETE_INSTRUCTION(ClampDToUint8, "clamp-d-to-uint8")
2375 class LClampIToUint8 V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2377 explicit LClampIToUint8(LOperand* unclamped) {
2378 inputs_[0] = unclamped;
2381 LOperand* unclamped() { return inputs_[0]; }
2383 DECLARE_CONCRETE_INSTRUCTION(ClampIToUint8, "clamp-i-to-uint8")
2387 class LClampTToUint8 V8_FINAL : public LTemplateInstruction<1, 1, 1> {
2389 LClampTToUint8(LOperand* unclamped,
2390 LOperand* temp_xmm) {
2391 inputs_[0] = unclamped;
2392 temps_[0] = temp_xmm;
2395 LOperand* unclamped() { return inputs_[0]; }
2396 LOperand* temp_xmm() { return temps_[0]; }
2398 DECLARE_CONCRETE_INSTRUCTION(ClampTToUint8, "clamp-t-to-uint8")
2402 class LCheckNonSmi V8_FINAL : public LTemplateInstruction<0, 1, 0> {
2404 explicit LCheckNonSmi(LOperand* value) {
2408 LOperand* value() { return inputs_[0]; }
2410 DECLARE_CONCRETE_INSTRUCTION(CheckNonSmi, "check-non-smi")
2411 DECLARE_HYDROGEN_ACCESSOR(CheckHeapObject)
2415 class LDoubleBits V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2417 explicit LDoubleBits(LOperand* value) {
2421 LOperand* value() { return inputs_[0]; }
2423 DECLARE_CONCRETE_INSTRUCTION(DoubleBits, "double-bits")
2424 DECLARE_HYDROGEN_ACCESSOR(DoubleBits)
2428 class LConstructDouble V8_FINAL : public LTemplateInstruction<1, 2, 0> {
2430 LConstructDouble(LOperand* hi, LOperand* lo) {
2435 LOperand* hi() { return inputs_[0]; }
2436 LOperand* lo() { return inputs_[1]; }
2438 DECLARE_CONCRETE_INSTRUCTION(ConstructDouble, "construct-double")
2442 class LAllocate V8_FINAL : public LTemplateInstruction<1, 2, 1> {
2444 LAllocate(LOperand* context, LOperand* size, LOperand* temp) {
2445 inputs_[0] = context;
2450 LOperand* context() { return inputs_[0]; }
2451 LOperand* size() { return inputs_[1]; }
2452 LOperand* temp() { return temps_[0]; }
2454 DECLARE_CONCRETE_INSTRUCTION(Allocate, "allocate")
2455 DECLARE_HYDROGEN_ACCESSOR(Allocate)
2459 class LRegExpLiteral V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2461 explicit LRegExpLiteral(LOperand* context) {
2462 inputs_[0] = context;
2465 LOperand* context() { return inputs_[0]; }
2467 DECLARE_CONCRETE_INSTRUCTION(RegExpLiteral, "regexp-literal")
2468 DECLARE_HYDROGEN_ACCESSOR(RegExpLiteral)
2472 class LFunctionLiteral V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2474 explicit LFunctionLiteral(LOperand* context) {
2475 inputs_[0] = context;
2478 LOperand* context() { return inputs_[0]; }
2480 DECLARE_CONCRETE_INSTRUCTION(FunctionLiteral, "function-literal")
2481 DECLARE_HYDROGEN_ACCESSOR(FunctionLiteral)
2485 class LToFastProperties V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2487 explicit LToFastProperties(LOperand* value) {
2491 LOperand* value() { return inputs_[0]; }
2493 DECLARE_CONCRETE_INSTRUCTION(ToFastProperties, "to-fast-properties")
2494 DECLARE_HYDROGEN_ACCESSOR(ToFastProperties)
2498 class LTypeof V8_FINAL : public LTemplateInstruction<1, 2, 0> {
2500 LTypeof(LOperand* context, LOperand* value) {
2501 inputs_[0] = context;
2505 LOperand* context() { return inputs_[0]; }
2506 LOperand* value() { return inputs_[1]; }
2508 DECLARE_CONCRETE_INSTRUCTION(Typeof, "typeof")
2512 class LTypeofIsAndBranch V8_FINAL : public LControlInstruction<1, 0> {
2514 explicit LTypeofIsAndBranch(LOperand* value) {
2518 LOperand* value() { return inputs_[0]; }
2520 DECLARE_CONCRETE_INSTRUCTION(TypeofIsAndBranch, "typeof-is-and-branch")
2521 DECLARE_HYDROGEN_ACCESSOR(TypeofIsAndBranch)
2523 Handle<String> type_literal() { return hydrogen()->type_literal(); }
2525 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
2529 class LIsConstructCallAndBranch V8_FINAL : public LControlInstruction<0, 1> {
2531 explicit LIsConstructCallAndBranch(LOperand* temp) {
2535 LOperand* temp() { return temps_[0]; }
2537 DECLARE_CONCRETE_INSTRUCTION(IsConstructCallAndBranch,
2538 "is-construct-call-and-branch")
2539 DECLARE_HYDROGEN_ACCESSOR(IsConstructCallAndBranch)
2543 class LOsrEntry V8_FINAL : public LTemplateInstruction<0, 0, 0> {
2547 virtual bool HasInterestingComment(LCodeGen* gen) const V8_OVERRIDE {
2550 DECLARE_CONCRETE_INSTRUCTION(OsrEntry, "osr-entry")
2554 class LStackCheck V8_FINAL : public LTemplateInstruction<0, 1, 0> {
2556 explicit LStackCheck(LOperand* context) {
2557 inputs_[0] = context;
2560 LOperand* context() { return inputs_[0]; }
2562 DECLARE_CONCRETE_INSTRUCTION(StackCheck, "stack-check")
2563 DECLARE_HYDROGEN_ACCESSOR(StackCheck)
2565 Label* done_label() { return &done_label_; }
2572 class LForInPrepareMap V8_FINAL : public LTemplateInstruction<1, 2, 0> {
2574 LForInPrepareMap(LOperand* context, LOperand* object) {
2575 inputs_[0] = context;
2576 inputs_[1] = object;
2579 LOperand* context() { return inputs_[0]; }
2580 LOperand* object() { return inputs_[1]; }
2582 DECLARE_CONCRETE_INSTRUCTION(ForInPrepareMap, "for-in-prepare-map")
2586 class LForInCacheArray V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2588 explicit LForInCacheArray(LOperand* map) {
2592 LOperand* map() { return inputs_[0]; }
2594 DECLARE_CONCRETE_INSTRUCTION(ForInCacheArray, "for-in-cache-array")
2597 return HForInCacheArray::cast(this->hydrogen_value())->idx();
2602 class LCheckMapValue V8_FINAL : public LTemplateInstruction<0, 2, 0> {
2604 LCheckMapValue(LOperand* value, LOperand* map) {
2609 LOperand* value() { return inputs_[0]; }
2610 LOperand* map() { return inputs_[1]; }
2612 DECLARE_CONCRETE_INSTRUCTION(CheckMapValue, "check-map-value")
2616 class LLoadFieldByIndex V8_FINAL : public LTemplateInstruction<1, 2, 0> {
2618 LLoadFieldByIndex(LOperand* object, LOperand* index) {
2619 inputs_[0] = object;
2623 LOperand* object() { return inputs_[0]; }
2624 LOperand* index() { return inputs_[1]; }
2626 DECLARE_CONCRETE_INSTRUCTION(LoadFieldByIndex, "load-field-by-index")
2630 class LChunkBuilder;
2631 class LPlatformChunk V8_FINAL : public LChunk {
2633 LPlatformChunk(CompilationInfo* info, HGraph* graph)
2634 : LChunk(info, graph),
2635 dehoisted_key_ids_(graph->GetMaximumValueID(), graph->zone()) { }
2637 int GetNextSpillIndex(RegisterKind kind);
2638 LOperand* GetNextSpillSlot(RegisterKind kind);
2639 BitVector* GetDehoistedKeyIds() { return &dehoisted_key_ids_; }
2640 bool IsDehoistedKey(HValue* value) {
2641 return dehoisted_key_ids_.Contains(value->id());
2645 BitVector dehoisted_key_ids_;
2649 class LChunkBuilder V8_FINAL : public LChunkBuilderBase {
2651 LChunkBuilder(CompilationInfo* info, HGraph* graph, LAllocator* allocator)
2652 : LChunkBuilderBase(graph->zone()),
2657 current_instruction_(NULL),
2658 current_block_(NULL),
2660 allocator_(allocator) { }
2662 Isolate* isolate() const { return graph_->isolate(); }
2664 // Build the sequence for the graph.
2665 LPlatformChunk* Build();
2667 // Declare methods that deal with the individual node types.
2668 #define DECLARE_DO(type) LInstruction* Do##type(H##type* node);
2669 HYDROGEN_CONCRETE_INSTRUCTION_LIST(DECLARE_DO)
2672 LInstruction* DoMathFloor(HUnaryMathOperation* instr);
2673 LInstruction* DoMathRound(HUnaryMathOperation* instr);
2674 LInstruction* DoMathAbs(HUnaryMathOperation* instr);
2675 LInstruction* DoMathLog(HUnaryMathOperation* instr);
2676 LInstruction* DoMathExp(HUnaryMathOperation* instr);
2677 LInstruction* DoMathSqrt(HUnaryMathOperation* instr);
2678 LInstruction* DoMathPowHalf(HUnaryMathOperation* instr);
2679 LInstruction* DoMathClz32(HUnaryMathOperation* instr);
2680 LInstruction* DoDivByPowerOf2I(HDiv* instr);
2681 LInstruction* DoDivByConstI(HDiv* instr);
2682 LInstruction* DoDivI(HDiv* instr);
2683 LInstruction* DoModByPowerOf2I(HMod* instr);
2684 LInstruction* DoModByConstI(HMod* instr);
2685 LInstruction* DoModI(HMod* instr);
2686 LInstruction* DoFlooringDivByPowerOf2I(HMathFloorOfDiv* instr);
2687 LInstruction* DoFlooringDivByConstI(HMathFloorOfDiv* instr);
2688 LInstruction* DoFlooringDivI(HMathFloorOfDiv* instr);
2698 LPlatformChunk* chunk() const { return chunk_; }
2699 CompilationInfo* info() const { return info_; }
2700 HGraph* graph() const { return graph_; }
2702 bool is_unused() const { return status_ == UNUSED; }
2703 bool is_building() const { return status_ == BUILDING; }
2704 bool is_done() const { return status_ == DONE; }
2705 bool is_aborted() const { return status_ == ABORTED; }
2707 void Abort(BailoutReason reason);
2709 // Methods for getting operands for Use / Define / Temp.
2710 LUnallocated* ToUnallocated(Register reg);
2711 LUnallocated* ToUnallocated(XMMRegister reg);
2713 // Methods for setting up define-use relationships.
2714 MUST_USE_RESULT LOperand* Use(HValue* value, LUnallocated* operand);
2715 MUST_USE_RESULT LOperand* UseFixed(HValue* value, Register fixed_register);
2716 MUST_USE_RESULT LOperand* UseFixedDouble(HValue* value,
2717 XMMRegister fixed_register);
2719 // A value that is guaranteed to be allocated to a register.
2720 // Operand created by UseRegister is guaranteed to be live until the end of
2721 // instruction. This means that register allocator will not reuse it's
2722 // register for any other operand inside instruction.
2723 // Operand created by UseRegisterAtStart is guaranteed to be live only at
2724 // instruction start. Register allocator is free to assign the same register
2725 // to some other operand used inside instruction (i.e. temporary or
2727 MUST_USE_RESULT LOperand* UseRegister(HValue* value);
2728 MUST_USE_RESULT LOperand* UseRegisterAtStart(HValue* value);
2730 // An input operand in a register that may be trashed.
2731 MUST_USE_RESULT LOperand* UseTempRegister(HValue* value);
2733 // An input operand in a register that may be trashed or a constant operand.
2734 MUST_USE_RESULT LOperand* UseTempRegisterOrConstant(HValue* value);
2736 // An input operand in a register or stack slot.
2737 MUST_USE_RESULT LOperand* Use(HValue* value);
2738 MUST_USE_RESULT LOperand* UseAtStart(HValue* value);
2740 // An input operand in a register, stack slot or a constant operand.
2741 MUST_USE_RESULT LOperand* UseOrConstant(HValue* value);
2742 MUST_USE_RESULT LOperand* UseOrConstantAtStart(HValue* value);
2744 // An input operand in a register or a constant operand.
2745 MUST_USE_RESULT LOperand* UseRegisterOrConstant(HValue* value);
2746 MUST_USE_RESULT LOperand* UseRegisterOrConstantAtStart(HValue* value);
2748 // An input operand in a constant operand.
2749 MUST_USE_RESULT LOperand* UseConstant(HValue* value);
2751 // An input operand in register, stack slot or a constant operand.
2752 // Will not be moved to a register even if one is freely available.
2753 virtual MUST_USE_RESULT LOperand* UseAny(HValue* value) V8_OVERRIDE;
2755 // Temporary operand that must be in a register.
2756 MUST_USE_RESULT LUnallocated* TempRegister();
2757 MUST_USE_RESULT LOperand* FixedTemp(Register reg);
2758 MUST_USE_RESULT LOperand* FixedTemp(XMMRegister reg);
2760 // Methods for setting up define-use relationships.
2761 // Return the same instruction that they are passed.
2762 LInstruction* Define(LTemplateResultInstruction<1>* instr,
2763 LUnallocated* result);
2764 LInstruction* DefineAsRegister(LTemplateResultInstruction<1>* instr);
2765 LInstruction* DefineAsSpilled(LTemplateResultInstruction<1>* instr,
2767 LInstruction* DefineSameAsFirst(LTemplateResultInstruction<1>* instr);
2768 LInstruction* DefineFixed(LTemplateResultInstruction<1>* instr,
2770 LInstruction* DefineFixedDouble(LTemplateResultInstruction<1>* instr,
2772 // Assigns an environment to an instruction. An instruction which can
2773 // deoptimize must have an environment.
2774 LInstruction* AssignEnvironment(LInstruction* instr);
2775 // Assigns a pointer map to an instruction. An instruction which can
2776 // trigger a GC or a lazy deoptimization must have a pointer map.
2777 LInstruction* AssignPointerMap(LInstruction* instr);
2779 enum CanDeoptimize { CAN_DEOPTIMIZE_EAGERLY, CANNOT_DEOPTIMIZE_EAGERLY };
2781 // Marks a call for the register allocator. Assigns a pointer map to
2782 // support GC and lazy deoptimization. Assigns an environment to support
2783 // eager deoptimization if CAN_DEOPTIMIZE_EAGERLY.
2784 LInstruction* MarkAsCall(
2785 LInstruction* instr,
2786 HInstruction* hinstr,
2787 CanDeoptimize can_deoptimize = CANNOT_DEOPTIMIZE_EAGERLY);
2789 void VisitInstruction(HInstruction* current);
2790 void AddInstruction(LInstruction* instr, HInstruction* current);
2792 void DoBasicBlock(HBasicBlock* block, HBasicBlock* next_block);
2793 LInstruction* DoShift(Token::Value op, HBitwiseBinaryOperation* instr);
2794 LInstruction* DoArithmeticD(Token::Value op,
2795 HArithmeticBinaryOperation* instr);
2796 LInstruction* DoArithmeticT(Token::Value op,
2797 HBinaryOperation* instr);
2798 void FindDehoistedKeyDefinitions(HValue* candidate);
2800 LPlatformChunk* chunk_;
2801 CompilationInfo* info_;
2802 HGraph* const graph_;
2804 HInstruction* current_instruction_;
2805 HBasicBlock* current_block_;
2806 HBasicBlock* next_block_;
2807 LAllocator* allocator_;
2809 DISALLOW_COPY_AND_ASSIGN(LChunkBuilder);
2812 #undef DECLARE_HYDROGEN_ACCESSOR
2813 #undef DECLARE_CONCRETE_INSTRUCTION
2815 } } // namespace v8::int
2817 #endif // V8_X64_LITHIUM_X64_H_