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 virtual bool IsControl() const V8_OVERRIDE { return true; }
433 DECLARE_CONCRETE_INSTRUCTION(Deoptimize, "deoptimize")
434 DECLARE_HYDROGEN_ACCESSOR(Deoptimize)
438 class LLabel V8_FINAL : public LGap {
440 explicit LLabel(HBasicBlock* block)
441 : LGap(block), replacement_(NULL) { }
443 virtual bool HasInterestingComment(LCodeGen* gen) const V8_OVERRIDE {
446 DECLARE_CONCRETE_INSTRUCTION(Label, "label")
448 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
450 int block_id() const { return block()->block_id(); }
451 bool is_loop_header() const { return block()->IsLoopHeader(); }
452 bool is_osr_entry() const { return block()->is_osr_entry(); }
453 Label* label() { return &label_; }
454 LLabel* replacement() const { return replacement_; }
455 void set_replacement(LLabel* label) { replacement_ = label; }
456 bool HasReplacement() const { return replacement_ != NULL; }
460 LLabel* replacement_;
464 class LParameter V8_FINAL : public LTemplateInstruction<1, 0, 0> {
466 virtual bool HasInterestingComment(LCodeGen* gen) const V8_OVERRIDE {
469 DECLARE_CONCRETE_INSTRUCTION(Parameter, "parameter")
473 class LCallStub V8_FINAL : public LTemplateInstruction<1, 1, 0> {
475 explicit LCallStub(LOperand* context) {
476 inputs_[0] = context;
479 LOperand* context() { return inputs_[0]; }
481 DECLARE_CONCRETE_INSTRUCTION(CallStub, "call-stub")
482 DECLARE_HYDROGEN_ACCESSOR(CallStub)
486 class LUnknownOSRValue V8_FINAL : public LTemplateInstruction<1, 0, 0> {
488 virtual bool HasInterestingComment(LCodeGen* gen) const V8_OVERRIDE {
491 DECLARE_CONCRETE_INSTRUCTION(UnknownOSRValue, "unknown-osr-value")
495 template<int I, int T>
496 class LControlInstruction : public LTemplateInstruction<0, I, T> {
498 LControlInstruction() : false_label_(NULL), true_label_(NULL) { }
500 virtual bool IsControl() const V8_FINAL V8_OVERRIDE { return true; }
502 int SuccessorCount() { return hydrogen()->SuccessorCount(); }
503 HBasicBlock* SuccessorAt(int i) { return hydrogen()->SuccessorAt(i); }
505 int TrueDestination(LChunk* chunk) {
506 return chunk->LookupDestination(true_block_id());
508 int FalseDestination(LChunk* chunk) {
509 return chunk->LookupDestination(false_block_id());
512 Label* TrueLabel(LChunk* chunk) {
513 if (true_label_ == NULL) {
514 true_label_ = chunk->GetAssemblyLabel(TrueDestination(chunk));
518 Label* FalseLabel(LChunk* chunk) {
519 if (false_label_ == NULL) {
520 false_label_ = chunk->GetAssemblyLabel(FalseDestination(chunk));
526 int true_block_id() { return SuccessorAt(0)->block_id(); }
527 int false_block_id() { return SuccessorAt(1)->block_id(); }
530 HControlInstruction* hydrogen() {
531 return HControlInstruction::cast(this->hydrogen_value());
539 class LWrapReceiver V8_FINAL : public LTemplateInstruction<1, 2, 0> {
541 LWrapReceiver(LOperand* receiver, LOperand* function) {
542 inputs_[0] = receiver;
543 inputs_[1] = function;
546 LOperand* receiver() { return inputs_[0]; }
547 LOperand* function() { return inputs_[1]; }
549 DECLARE_CONCRETE_INSTRUCTION(WrapReceiver, "wrap-receiver")
550 DECLARE_HYDROGEN_ACCESSOR(WrapReceiver)
554 class LApplyArguments V8_FINAL : public LTemplateInstruction<1, 4, 0> {
556 LApplyArguments(LOperand* function,
559 LOperand* elements) {
560 inputs_[0] = function;
561 inputs_[1] = receiver;
563 inputs_[3] = elements;
566 LOperand* function() { return inputs_[0]; }
567 LOperand* receiver() { return inputs_[1]; }
568 LOperand* length() { return inputs_[2]; }
569 LOperand* elements() { return inputs_[3]; }
571 DECLARE_CONCRETE_INSTRUCTION(ApplyArguments, "apply-arguments")
575 class LAccessArgumentsAt V8_FINAL : public LTemplateInstruction<1, 3, 0> {
577 LAccessArgumentsAt(LOperand* arguments, LOperand* length, LOperand* index) {
578 inputs_[0] = arguments;
583 LOperand* arguments() { return inputs_[0]; }
584 LOperand* length() { return inputs_[1]; }
585 LOperand* index() { return inputs_[2]; }
587 DECLARE_CONCRETE_INSTRUCTION(AccessArgumentsAt, "access-arguments-at")
589 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
593 class LArgumentsLength V8_FINAL : public LTemplateInstruction<1, 1, 0> {
595 explicit LArgumentsLength(LOperand* elements) {
596 inputs_[0] = elements;
599 LOperand* elements() { return inputs_[0]; }
601 DECLARE_CONCRETE_INSTRUCTION(ArgumentsLength, "arguments-length")
605 class LArgumentsElements V8_FINAL : public LTemplateInstruction<1, 0, 0> {
607 DECLARE_CONCRETE_INSTRUCTION(ArgumentsElements, "arguments-elements")
608 DECLARE_HYDROGEN_ACCESSOR(ArgumentsElements)
612 class LModByPowerOf2I V8_FINAL : public LTemplateInstruction<1, 1, 0> {
614 LModByPowerOf2I(LOperand* dividend, int32_t divisor) {
615 inputs_[0] = dividend;
619 LOperand* dividend() { return inputs_[0]; }
620 int32_t divisor() const { return divisor_; }
622 DECLARE_CONCRETE_INSTRUCTION(ModByPowerOf2I, "mod-by-power-of-2-i")
623 DECLARE_HYDROGEN_ACCESSOR(Mod)
630 class LModByConstI V8_FINAL : public LTemplateInstruction<1, 1, 2> {
632 LModByConstI(LOperand* dividend,
636 inputs_[0] = dividend;
642 LOperand* dividend() { return inputs_[0]; }
643 int32_t divisor() const { return divisor_; }
644 LOperand* temp1() { return temps_[0]; }
645 LOperand* temp2() { return temps_[1]; }
647 DECLARE_CONCRETE_INSTRUCTION(ModByConstI, "mod-by-const-i")
648 DECLARE_HYDROGEN_ACCESSOR(Mod)
655 class LModI V8_FINAL : public LTemplateInstruction<1, 2, 1> {
657 LModI(LOperand* left, LOperand* right, LOperand* temp) {
663 LOperand* left() { return inputs_[0]; }
664 LOperand* right() { return inputs_[1]; }
665 LOperand* temp() { return temps_[0]; }
667 DECLARE_CONCRETE_INSTRUCTION(ModI, "mod-i")
668 DECLARE_HYDROGEN_ACCESSOR(Mod)
672 class LDivByPowerOf2I V8_FINAL : public LTemplateInstruction<1, 1, 0> {
674 LDivByPowerOf2I(LOperand* dividend, int32_t divisor) {
675 inputs_[0] = dividend;
679 LOperand* dividend() { return inputs_[0]; }
680 int32_t divisor() const { return divisor_; }
682 DECLARE_CONCRETE_INSTRUCTION(DivByPowerOf2I, "div-by-power-of-2-i")
683 DECLARE_HYDROGEN_ACCESSOR(Div)
690 class LDivByConstI V8_FINAL : public LTemplateInstruction<1, 1, 2> {
692 LDivByConstI(LOperand* dividend,
696 inputs_[0] = dividend;
702 LOperand* dividend() { return inputs_[0]; }
703 int32_t divisor() const { return divisor_; }
704 LOperand* temp1() { return temps_[0]; }
705 LOperand* temp2() { return temps_[1]; }
707 DECLARE_CONCRETE_INSTRUCTION(DivByConstI, "div-by-const-i")
708 DECLARE_HYDROGEN_ACCESSOR(Div)
715 class LDivI V8_FINAL : public LTemplateInstruction<1, 2, 1> {
717 LDivI(LOperand* dividend, LOperand* divisor, LOperand* temp) {
718 inputs_[0] = dividend;
719 inputs_[1] = divisor;
723 LOperand* dividend() { return inputs_[0]; }
724 LOperand* divisor() { return inputs_[1]; }
725 LOperand* temp() { return temps_[0]; }
727 DECLARE_CONCRETE_INSTRUCTION(DivI, "div-i")
728 DECLARE_HYDROGEN_ACCESSOR(BinaryOperation)
732 class LFlooringDivByPowerOf2I V8_FINAL : public LTemplateInstruction<1, 1, 0> {
734 LFlooringDivByPowerOf2I(LOperand* dividend, int32_t divisor) {
735 inputs_[0] = dividend;
739 LOperand* dividend() { return inputs_[0]; }
740 int32_t divisor() const { return divisor_; }
742 DECLARE_CONCRETE_INSTRUCTION(FlooringDivByPowerOf2I,
743 "flooring-div-by-power-of-2-i")
744 DECLARE_HYDROGEN_ACCESSOR(MathFloorOfDiv)
751 class LFlooringDivByConstI V8_FINAL : public LTemplateInstruction<1, 1, 3> {
753 LFlooringDivByConstI(LOperand* dividend,
758 inputs_[0] = dividend;
765 LOperand* dividend() { return inputs_[0]; }
766 int32_t divisor() const { return divisor_; }
767 LOperand* temp1() { return temps_[0]; }
768 LOperand* temp2() { return temps_[1]; }
769 LOperand* temp3() { return temps_[2]; }
771 DECLARE_CONCRETE_INSTRUCTION(FlooringDivByConstI, "flooring-div-by-const-i")
772 DECLARE_HYDROGEN_ACCESSOR(MathFloorOfDiv)
779 class LFlooringDivI V8_FINAL : public LTemplateInstruction<1, 2, 1> {
781 LFlooringDivI(LOperand* dividend, LOperand* divisor, LOperand* temp) {
782 inputs_[0] = dividend;
783 inputs_[1] = divisor;
787 LOperand* dividend() { return inputs_[0]; }
788 LOperand* divisor() { return inputs_[1]; }
789 LOperand* temp() { return temps_[0]; }
791 DECLARE_CONCRETE_INSTRUCTION(FlooringDivI, "flooring-div-i")
792 DECLARE_HYDROGEN_ACCESSOR(MathFloorOfDiv)
796 class LMulI V8_FINAL : public LTemplateInstruction<1, 2, 0> {
798 LMulI(LOperand* left, LOperand* right) {
803 LOperand* left() { return inputs_[0]; }
804 LOperand* right() { return inputs_[1]; }
806 DECLARE_CONCRETE_INSTRUCTION(MulI, "mul-i")
807 DECLARE_HYDROGEN_ACCESSOR(Mul)
811 class LCompareNumericAndBranch V8_FINAL : public LControlInstruction<2, 0> {
813 LCompareNumericAndBranch(LOperand* left, LOperand* right) {
818 LOperand* left() { return inputs_[0]; }
819 LOperand* right() { return inputs_[1]; }
821 DECLARE_CONCRETE_INSTRUCTION(CompareNumericAndBranch,
822 "compare-numeric-and-branch")
823 DECLARE_HYDROGEN_ACCESSOR(CompareNumericAndBranch)
825 Token::Value op() const { return hydrogen()->token(); }
826 bool is_double() const {
827 return hydrogen()->representation().IsDouble();
830 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
834 class LMathFloor V8_FINAL : public LTemplateInstruction<1, 1, 0> {
836 explicit LMathFloor(LOperand* value) {
840 LOperand* value() { return inputs_[0]; }
842 DECLARE_CONCRETE_INSTRUCTION(MathFloor, "math-floor")
843 DECLARE_HYDROGEN_ACCESSOR(UnaryMathOperation)
847 class LMathRound V8_FINAL : public LTemplateInstruction<1, 1, 1> {
849 explicit LMathRound(LOperand* value, LOperand* temp) {
854 LOperand* value() { return inputs_[0]; }
855 LOperand* temp() { return temps_[0]; }
857 DECLARE_CONCRETE_INSTRUCTION(MathRound, "math-round")
858 DECLARE_HYDROGEN_ACCESSOR(UnaryMathOperation)
862 class LMathAbs V8_FINAL : public LTemplateInstruction<1, 2, 0> {
864 explicit LMathAbs(LOperand* context, LOperand* value) {
865 inputs_[1] = context;
869 LOperand* context() { return inputs_[1]; }
870 LOperand* value() { return inputs_[0]; }
872 DECLARE_CONCRETE_INSTRUCTION(MathAbs, "math-abs")
873 DECLARE_HYDROGEN_ACCESSOR(UnaryMathOperation)
877 class LMathLog V8_FINAL : public LTemplateInstruction<1, 1, 0> {
879 explicit LMathLog(LOperand* value) {
883 LOperand* value() { return inputs_[0]; }
885 DECLARE_CONCRETE_INSTRUCTION(MathLog, "math-log")
889 class LMathClz32 V8_FINAL : public LTemplateInstruction<1, 1, 0> {
891 explicit LMathClz32(LOperand* value) {
895 LOperand* value() { return inputs_[0]; }
897 DECLARE_CONCRETE_INSTRUCTION(MathClz32, "math-clz32")
901 class LMathExp V8_FINAL : public LTemplateInstruction<1, 1, 2> {
903 LMathExp(LOperand* value, LOperand* temp1, LOperand* temp2) {
907 ExternalReference::InitializeMathExpData();
910 LOperand* value() { return inputs_[0]; }
911 LOperand* temp1() { return temps_[0]; }
912 LOperand* temp2() { return temps_[1]; }
914 DECLARE_CONCRETE_INSTRUCTION(MathExp, "math-exp")
918 class LMathSqrt V8_FINAL : public LTemplateInstruction<1, 1, 0> {
920 explicit LMathSqrt(LOperand* value) {
924 LOperand* value() { return inputs_[0]; }
926 DECLARE_CONCRETE_INSTRUCTION(MathSqrt, "math-sqrt")
930 class LMathPowHalf V8_FINAL : public LTemplateInstruction<1, 1, 0> {
932 explicit LMathPowHalf(LOperand* value) {
936 LOperand* value() { return inputs_[0]; }
938 DECLARE_CONCRETE_INSTRUCTION(MathPowHalf, "math-pow-half")
942 class LCmpObjectEqAndBranch V8_FINAL : public LControlInstruction<2, 0> {
944 LCmpObjectEqAndBranch(LOperand* left, LOperand* right) {
949 LOperand* left() { return inputs_[0]; }
950 LOperand* right() { return inputs_[1]; }
952 DECLARE_CONCRETE_INSTRUCTION(CmpObjectEqAndBranch, "cmp-object-eq-and-branch")
956 class LCmpHoleAndBranch V8_FINAL : public LControlInstruction<1, 0> {
958 explicit LCmpHoleAndBranch(LOperand* object) {
962 LOperand* object() { return inputs_[0]; }
964 DECLARE_CONCRETE_INSTRUCTION(CmpHoleAndBranch, "cmp-hole-and-branch")
965 DECLARE_HYDROGEN_ACCESSOR(CompareHoleAndBranch)
969 class LCompareMinusZeroAndBranch V8_FINAL : public LControlInstruction<1, 0> {
971 explicit LCompareMinusZeroAndBranch(LOperand* value) {
975 LOperand* value() { return inputs_[0]; }
977 DECLARE_CONCRETE_INSTRUCTION(CompareMinusZeroAndBranch,
978 "cmp-minus-zero-and-branch")
979 DECLARE_HYDROGEN_ACCESSOR(CompareMinusZeroAndBranch)
984 class LIsObjectAndBranch V8_FINAL : public LControlInstruction<1, 0> {
986 explicit LIsObjectAndBranch(LOperand* value) {
990 LOperand* value() { return inputs_[0]; }
992 DECLARE_CONCRETE_INSTRUCTION(IsObjectAndBranch, "is-object-and-branch")
993 DECLARE_HYDROGEN_ACCESSOR(IsObjectAndBranch)
995 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
999 class LIsStringAndBranch V8_FINAL : public LControlInstruction<1, 1> {
1001 explicit LIsStringAndBranch(LOperand* value, LOperand* temp) {
1006 LOperand* value() { return inputs_[0]; }
1007 LOperand* temp() { return temps_[0]; }
1009 DECLARE_CONCRETE_INSTRUCTION(IsStringAndBranch, "is-string-and-branch")
1010 DECLARE_HYDROGEN_ACCESSOR(IsStringAndBranch)
1012 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1016 class LIsSmiAndBranch V8_FINAL : public LControlInstruction<1, 0> {
1018 explicit LIsSmiAndBranch(LOperand* value) {
1022 LOperand* value() { return inputs_[0]; }
1024 DECLARE_CONCRETE_INSTRUCTION(IsSmiAndBranch, "is-smi-and-branch")
1025 DECLARE_HYDROGEN_ACCESSOR(IsSmiAndBranch)
1027 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1031 class LIsUndetectableAndBranch V8_FINAL : public LControlInstruction<1, 1> {
1033 explicit LIsUndetectableAndBranch(LOperand* value, LOperand* temp) {
1038 LOperand* value() { return inputs_[0]; }
1039 LOperand* temp() { return temps_[0]; }
1041 DECLARE_CONCRETE_INSTRUCTION(IsUndetectableAndBranch,
1042 "is-undetectable-and-branch")
1043 DECLARE_HYDROGEN_ACCESSOR(IsUndetectableAndBranch)
1045 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1049 class LStringCompareAndBranch V8_FINAL : public LControlInstruction<3, 0> {
1051 explicit LStringCompareAndBranch(LOperand* context,
1054 inputs_[0] = context;
1059 LOperand* context() { return inputs_[0]; }
1060 LOperand* left() { return inputs_[1]; }
1061 LOperand* right() { return inputs_[2]; }
1063 DECLARE_CONCRETE_INSTRUCTION(StringCompareAndBranch,
1064 "string-compare-and-branch")
1065 DECLARE_HYDROGEN_ACCESSOR(StringCompareAndBranch)
1067 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1069 Token::Value op() const { return hydrogen()->token(); }
1073 class LHasInstanceTypeAndBranch V8_FINAL : public LControlInstruction<1, 0> {
1075 explicit LHasInstanceTypeAndBranch(LOperand* value) {
1079 LOperand* value() { return inputs_[0]; }
1081 DECLARE_CONCRETE_INSTRUCTION(HasInstanceTypeAndBranch,
1082 "has-instance-type-and-branch")
1083 DECLARE_HYDROGEN_ACCESSOR(HasInstanceTypeAndBranch)
1085 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1089 class LGetCachedArrayIndex V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1091 explicit LGetCachedArrayIndex(LOperand* value) {
1095 LOperand* value() { return inputs_[0]; }
1097 DECLARE_CONCRETE_INSTRUCTION(GetCachedArrayIndex, "get-cached-array-index")
1098 DECLARE_HYDROGEN_ACCESSOR(GetCachedArrayIndex)
1102 class LHasCachedArrayIndexAndBranch V8_FINAL
1103 : public LControlInstruction<1, 0> {
1105 explicit LHasCachedArrayIndexAndBranch(LOperand* value) {
1109 LOperand* value() { return inputs_[0]; }
1111 DECLARE_CONCRETE_INSTRUCTION(HasCachedArrayIndexAndBranch,
1112 "has-cached-array-index-and-branch")
1113 DECLARE_HYDROGEN_ACCESSOR(HasCachedArrayIndexAndBranch)
1115 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1119 class LClassOfTestAndBranch V8_FINAL : public LControlInstruction<1, 2> {
1121 LClassOfTestAndBranch(LOperand* value, LOperand* temp, LOperand* temp2) {
1127 LOperand* value() { return inputs_[0]; }
1128 LOperand* temp() { return temps_[0]; }
1129 LOperand* temp2() { return temps_[1]; }
1131 DECLARE_CONCRETE_INSTRUCTION(ClassOfTestAndBranch,
1132 "class-of-test-and-branch")
1133 DECLARE_HYDROGEN_ACCESSOR(ClassOfTestAndBranch)
1135 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1139 class LCmpT V8_FINAL : public LTemplateInstruction<1, 3, 0> {
1141 LCmpT(LOperand* context, LOperand* left, LOperand* right) {
1142 inputs_[0] = context;
1147 LOperand* context() { return inputs_[0]; }
1148 LOperand* left() { return inputs_[1]; }
1149 LOperand* right() { return inputs_[2]; }
1151 DECLARE_CONCRETE_INSTRUCTION(CmpT, "cmp-t")
1152 DECLARE_HYDROGEN_ACCESSOR(CompareGeneric)
1154 Token::Value op() const { return hydrogen()->token(); }
1158 class LInstanceOf V8_FINAL : public LTemplateInstruction<1, 3, 0> {
1160 LInstanceOf(LOperand* context, LOperand* left, LOperand* right) {
1161 inputs_[0] = context;
1166 LOperand* context() { return inputs_[0]; }
1167 LOperand* left() { return inputs_[1]; }
1168 LOperand* right() { return inputs_[2]; }
1170 DECLARE_CONCRETE_INSTRUCTION(InstanceOf, "instance-of")
1174 class LInstanceOfKnownGlobal V8_FINAL : public LTemplateInstruction<1, 2, 1> {
1176 LInstanceOfKnownGlobal(LOperand* context, LOperand* value, LOperand* temp) {
1177 inputs_[0] = context;
1182 LOperand* context() { return inputs_[0]; }
1183 LOperand* value() { return inputs_[1]; }
1184 LOperand* temp() { return temps_[0]; }
1186 DECLARE_CONCRETE_INSTRUCTION(InstanceOfKnownGlobal,
1187 "instance-of-known-global")
1188 DECLARE_HYDROGEN_ACCESSOR(InstanceOfKnownGlobal)
1190 Handle<JSFunction> function() const { return hydrogen()->function(); }
1191 LEnvironment* GetDeferredLazyDeoptimizationEnvironment() {
1192 return lazy_deopt_env_;
1194 virtual void SetDeferredLazyDeoptimizationEnvironment(
1195 LEnvironment* env) V8_OVERRIDE {
1196 lazy_deopt_env_ = env;
1200 LEnvironment* lazy_deopt_env_;
1204 class LBoundsCheck V8_FINAL : public LTemplateInstruction<0, 2, 0> {
1206 LBoundsCheck(LOperand* index, LOperand* length) {
1208 inputs_[1] = length;
1211 LOperand* index() { return inputs_[0]; }
1212 LOperand* length() { return inputs_[1]; }
1214 DECLARE_CONCRETE_INSTRUCTION(BoundsCheck, "bounds-check")
1215 DECLARE_HYDROGEN_ACCESSOR(BoundsCheck)
1219 class LBitI V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1221 LBitI(LOperand* left, LOperand* right) {
1226 LOperand* left() { return inputs_[0]; }
1227 LOperand* right() { return inputs_[1]; }
1229 Token::Value op() const { return hydrogen()->op(); }
1230 bool IsInteger32() const {
1231 return hydrogen()->representation().IsInteger32();
1234 DECLARE_CONCRETE_INSTRUCTION(BitI, "bit-i")
1235 DECLARE_HYDROGEN_ACCESSOR(Bitwise)
1239 class LShiftI V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1241 LShiftI(Token::Value op, LOperand* left, LOperand* right, bool can_deopt)
1242 : op_(op), can_deopt_(can_deopt) {
1247 Token::Value op() const { return op_; }
1248 LOperand* left() { return inputs_[0]; }
1249 LOperand* right() { return inputs_[1]; }
1250 bool can_deopt() const { return can_deopt_; }
1252 DECLARE_CONCRETE_INSTRUCTION(ShiftI, "shift-i")
1260 class LSubI V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1262 LSubI(LOperand* left, LOperand* right) {
1267 LOperand* left() { return inputs_[0]; }
1268 LOperand* right() { return inputs_[1]; }
1270 DECLARE_CONCRETE_INSTRUCTION(SubI, "sub-i")
1271 DECLARE_HYDROGEN_ACCESSOR(Sub)
1275 class LConstantI V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1277 DECLARE_CONCRETE_INSTRUCTION(ConstantI, "constant-i")
1278 DECLARE_HYDROGEN_ACCESSOR(Constant)
1280 int32_t value() const { return hydrogen()->Integer32Value(); }
1284 class LConstantS V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1286 DECLARE_CONCRETE_INSTRUCTION(ConstantS, "constant-s")
1287 DECLARE_HYDROGEN_ACCESSOR(Constant)
1289 Smi* value() const { return Smi::FromInt(hydrogen()->Integer32Value()); }
1293 class LConstantD V8_FINAL : public LTemplateInstruction<1, 0, 1> {
1295 explicit LConstantD(LOperand* temp) {
1299 LOperand* temp() { return temps_[0]; }
1301 DECLARE_CONCRETE_INSTRUCTION(ConstantD, "constant-d")
1302 DECLARE_HYDROGEN_ACCESSOR(Constant)
1304 double value() const { return hydrogen()->DoubleValue(); }
1308 class LConstantE V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1310 DECLARE_CONCRETE_INSTRUCTION(ConstantE, "constant-e")
1311 DECLARE_HYDROGEN_ACCESSOR(Constant)
1313 ExternalReference value() const {
1314 return hydrogen()->ExternalReferenceValue();
1319 class LConstantT V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1321 DECLARE_CONCRETE_INSTRUCTION(ConstantT, "constant-t")
1322 DECLARE_HYDROGEN_ACCESSOR(Constant)
1324 Handle<Object> value(Isolate* isolate) const {
1325 return hydrogen()->handle(isolate);
1330 class LBranch V8_FINAL : public LControlInstruction<1, 0> {
1332 explicit LBranch(LOperand* value) {
1336 LOperand* value() { return inputs_[0]; }
1338 DECLARE_CONCRETE_INSTRUCTION(Branch, "branch")
1339 DECLARE_HYDROGEN_ACCESSOR(Branch)
1341 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1345 class LDebugBreak V8_FINAL : public LTemplateInstruction<0, 0, 0> {
1347 DECLARE_CONCRETE_INSTRUCTION(DebugBreak, "break")
1351 class LCmpMapAndBranch V8_FINAL : public LControlInstruction<1, 0> {
1353 explicit LCmpMapAndBranch(LOperand* value) {
1357 LOperand* value() { return inputs_[0]; }
1359 DECLARE_CONCRETE_INSTRUCTION(CmpMapAndBranch, "cmp-map-and-branch")
1360 DECLARE_HYDROGEN_ACCESSOR(CompareMap)
1362 Handle<Map> map() const { return hydrogen()->map().handle(); }
1366 class LMapEnumLength V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1368 explicit LMapEnumLength(LOperand* value) {
1372 LOperand* value() { return inputs_[0]; }
1374 DECLARE_CONCRETE_INSTRUCTION(MapEnumLength, "map-enum-length")
1378 class LDateField V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1380 LDateField(LOperand* date, Smi* index) : index_(index) {
1384 LOperand* date() { return inputs_[0]; }
1385 Smi* index() const { return index_; }
1387 DECLARE_CONCRETE_INSTRUCTION(DateField, "date-field")
1388 DECLARE_HYDROGEN_ACCESSOR(DateField)
1395 class LSeqStringGetChar V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1397 LSeqStringGetChar(LOperand* string, LOperand* index) {
1398 inputs_[0] = string;
1402 LOperand* string() const { return inputs_[0]; }
1403 LOperand* index() const { return inputs_[1]; }
1405 DECLARE_CONCRETE_INSTRUCTION(SeqStringGetChar, "seq-string-get-char")
1406 DECLARE_HYDROGEN_ACCESSOR(SeqStringGetChar)
1410 class LSeqStringSetChar V8_FINAL : public LTemplateInstruction<1, 4, 0> {
1412 LSeqStringSetChar(LOperand* context,
1416 inputs_[0] = context;
1417 inputs_[1] = string;
1422 LOperand* string() { return inputs_[1]; }
1423 LOperand* index() { return inputs_[2]; }
1424 LOperand* value() { return inputs_[3]; }
1426 DECLARE_CONCRETE_INSTRUCTION(SeqStringSetChar, "seq-string-set-char")
1427 DECLARE_HYDROGEN_ACCESSOR(SeqStringSetChar)
1431 class LAddI V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1433 LAddI(LOperand* left, LOperand* right) {
1438 LOperand* left() { return inputs_[0]; }
1439 LOperand* right() { return inputs_[1]; }
1441 static bool UseLea(HAdd* add) {
1442 return !add->CheckFlag(HValue::kCanOverflow) &&
1443 add->BetterLeftOperand()->UseCount() > 1;
1446 DECLARE_CONCRETE_INSTRUCTION(AddI, "add-i")
1447 DECLARE_HYDROGEN_ACCESSOR(Add)
1451 class LMathMinMax V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1453 LMathMinMax(LOperand* left, LOperand* right) {
1458 LOperand* left() { return inputs_[0]; }
1459 LOperand* right() { return inputs_[1]; }
1461 DECLARE_CONCRETE_INSTRUCTION(MathMinMax, "math-min-max")
1462 DECLARE_HYDROGEN_ACCESSOR(MathMinMax)
1466 class LPower V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1468 LPower(LOperand* left, LOperand* right) {
1473 LOperand* left() { return inputs_[0]; }
1474 LOperand* right() { return inputs_[1]; }
1476 DECLARE_CONCRETE_INSTRUCTION(Power, "power")
1477 DECLARE_HYDROGEN_ACCESSOR(Power)
1481 class LArithmeticD V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1483 LArithmeticD(Token::Value op, LOperand* left, LOperand* right)
1489 Token::Value op() const { return op_; }
1490 LOperand* left() { return inputs_[0]; }
1491 LOperand* right() { return inputs_[1]; }
1493 virtual Opcode opcode() const V8_OVERRIDE {
1494 return LInstruction::kArithmeticD;
1496 virtual void CompileToNative(LCodeGen* generator) V8_OVERRIDE;
1497 virtual const char* Mnemonic() const V8_OVERRIDE;
1504 class LArithmeticT V8_FINAL : public LTemplateInstruction<1, 3, 0> {
1506 LArithmeticT(Token::Value op,
1511 inputs_[0] = context;
1516 Token::Value op() const { return op_; }
1517 LOperand* context() { return inputs_[0]; }
1518 LOperand* left() { return inputs_[1]; }
1519 LOperand* right() { return inputs_[2]; }
1521 virtual Opcode opcode() const V8_OVERRIDE {
1522 return LInstruction::kArithmeticT;
1524 virtual void CompileToNative(LCodeGen* generator) V8_OVERRIDE;
1525 virtual const char* Mnemonic() const V8_OVERRIDE;
1532 class LReturn V8_FINAL : public LTemplateInstruction<0, 3, 0> {
1534 explicit LReturn(LOperand* value,
1536 LOperand* parameter_count) {
1538 inputs_[1] = context;
1539 inputs_[2] = parameter_count;
1542 LOperand* value() { return inputs_[0]; }
1543 LOperand* context() { return inputs_[1]; }
1545 bool has_constant_parameter_count() {
1546 return parameter_count()->IsConstantOperand();
1548 LConstantOperand* constant_parameter_count() {
1549 ASSERT(has_constant_parameter_count());
1550 return LConstantOperand::cast(parameter_count());
1552 LOperand* parameter_count() { return inputs_[2]; }
1554 DECLARE_CONCRETE_INSTRUCTION(Return, "return")
1555 DECLARE_HYDROGEN_ACCESSOR(Return)
1559 class LLoadNamedField V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1561 explicit LLoadNamedField(LOperand* object) {
1562 inputs_[0] = object;
1565 LOperand* object() { return inputs_[0]; }
1567 DECLARE_CONCRETE_INSTRUCTION(LoadNamedField, "load-named-field")
1568 DECLARE_HYDROGEN_ACCESSOR(LoadNamedField)
1572 class LLoadNamedGeneric V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1574 explicit LLoadNamedGeneric(LOperand* context, LOperand* object) {
1575 inputs_[0] = context;
1576 inputs_[1] = object;
1579 DECLARE_CONCRETE_INSTRUCTION(LoadNamedGeneric, "load-named-generic")
1580 DECLARE_HYDROGEN_ACCESSOR(LoadNamedGeneric)
1582 LOperand* context() { return inputs_[0]; }
1583 LOperand* object() { return inputs_[1]; }
1584 Handle<Object> name() const { return hydrogen()->name(); }
1588 class LLoadFunctionPrototype V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1590 explicit LLoadFunctionPrototype(LOperand* function) {
1591 inputs_[0] = function;
1594 DECLARE_CONCRETE_INSTRUCTION(LoadFunctionPrototype, "load-function-prototype")
1595 DECLARE_HYDROGEN_ACCESSOR(LoadFunctionPrototype)
1597 LOperand* function() { return inputs_[0]; }
1601 class LLoadRoot V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1603 DECLARE_CONCRETE_INSTRUCTION(LoadRoot, "load-root")
1604 DECLARE_HYDROGEN_ACCESSOR(LoadRoot)
1606 Heap::RootListIndex index() const { return hydrogen()->index(); }
1610 class LLoadKeyed V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1612 LLoadKeyed(LOperand* elements, LOperand* key) {
1613 inputs_[0] = elements;
1617 DECLARE_CONCRETE_INSTRUCTION(LoadKeyed, "load-keyed")
1618 DECLARE_HYDROGEN_ACCESSOR(LoadKeyed)
1620 bool is_external() const {
1621 return hydrogen()->is_external();
1623 bool is_fixed_typed_array() const {
1624 return hydrogen()->is_fixed_typed_array();
1626 bool is_typed_elements() const {
1627 return is_external() || is_fixed_typed_array();
1629 LOperand* elements() { return inputs_[0]; }
1630 LOperand* key() { return inputs_[1]; }
1631 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1632 uint32_t base_offset() const { return hydrogen()->base_offset(); }
1633 ElementsKind elements_kind() const {
1634 return hydrogen()->elements_kind();
1639 class LLoadKeyedGeneric V8_FINAL : public LTemplateInstruction<1, 3, 0> {
1641 LLoadKeyedGeneric(LOperand* context, LOperand* obj, LOperand* key) {
1642 inputs_[0] = context;
1647 DECLARE_CONCRETE_INSTRUCTION(LoadKeyedGeneric, "load-keyed-generic")
1649 LOperand* context() { return inputs_[0]; }
1650 LOperand* object() { return inputs_[1]; }
1651 LOperand* key() { return inputs_[2]; }
1655 class LLoadGlobalCell V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1657 DECLARE_CONCRETE_INSTRUCTION(LoadGlobalCell, "load-global-cell")
1658 DECLARE_HYDROGEN_ACCESSOR(LoadGlobalCell)
1662 class LLoadGlobalGeneric V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1664 explicit LLoadGlobalGeneric(LOperand* context, LOperand* global_object) {
1665 inputs_[0] = context;
1666 inputs_[1] = global_object;
1669 DECLARE_CONCRETE_INSTRUCTION(LoadGlobalGeneric, "load-global-generic")
1670 DECLARE_HYDROGEN_ACCESSOR(LoadGlobalGeneric)
1672 LOperand* context() { return inputs_[0]; }
1673 LOperand* global_object() { return inputs_[1]; }
1674 Handle<Object> name() const { return hydrogen()->name(); }
1675 bool for_typeof() const { return hydrogen()->for_typeof(); }
1679 class LStoreGlobalCell V8_FINAL : public LTemplateInstruction<0, 1, 1> {
1681 explicit LStoreGlobalCell(LOperand* value, LOperand* temp) {
1686 LOperand* value() { return inputs_[0]; }
1687 LOperand* temp() { return temps_[0]; }
1689 DECLARE_CONCRETE_INSTRUCTION(StoreGlobalCell, "store-global-cell")
1690 DECLARE_HYDROGEN_ACCESSOR(StoreGlobalCell)
1694 class LLoadContextSlot V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1696 explicit LLoadContextSlot(LOperand* context) {
1697 inputs_[0] = context;
1700 LOperand* context() { return inputs_[0]; }
1702 DECLARE_CONCRETE_INSTRUCTION(LoadContextSlot, "load-context-slot")
1703 DECLARE_HYDROGEN_ACCESSOR(LoadContextSlot)
1705 int slot_index() { return hydrogen()->slot_index(); }
1707 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1711 class LStoreContextSlot V8_FINAL : public LTemplateInstruction<0, 2, 1> {
1713 LStoreContextSlot(LOperand* context, LOperand* value, LOperand* temp) {
1714 inputs_[0] = context;
1719 LOperand* context() { return inputs_[0]; }
1720 LOperand* value() { return inputs_[1]; }
1721 LOperand* temp() { return temps_[0]; }
1723 DECLARE_CONCRETE_INSTRUCTION(StoreContextSlot, "store-context-slot")
1724 DECLARE_HYDROGEN_ACCESSOR(StoreContextSlot)
1726 int slot_index() { return hydrogen()->slot_index(); }
1728 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1732 class LPushArgument V8_FINAL : public LTemplateInstruction<0, 1, 0> {
1734 explicit LPushArgument(LOperand* value) {
1738 LOperand* value() { return inputs_[0]; }
1740 DECLARE_CONCRETE_INSTRUCTION(PushArgument, "push-argument")
1744 class LDrop V8_FINAL : public LTemplateInstruction<0, 0, 0> {
1746 explicit LDrop(int count) : count_(count) { }
1748 int count() const { return count_; }
1750 DECLARE_CONCRETE_INSTRUCTION(Drop, "drop")
1757 class LStoreCodeEntry V8_FINAL: public LTemplateInstruction<0, 1, 1> {
1759 LStoreCodeEntry(LOperand* function, LOperand* code_object) {
1760 inputs_[0] = function;
1761 temps_[0] = code_object;
1764 LOperand* function() { return inputs_[0]; }
1765 LOperand* code_object() { return temps_[0]; }
1767 virtual void PrintDataTo(StringStream* stream);
1769 DECLARE_CONCRETE_INSTRUCTION(StoreCodeEntry, "store-code-entry")
1770 DECLARE_HYDROGEN_ACCESSOR(StoreCodeEntry)
1774 class LInnerAllocatedObject V8_FINAL: public LTemplateInstruction<1, 2, 0> {
1776 LInnerAllocatedObject(LOperand* base_object, LOperand* offset) {
1777 inputs_[0] = base_object;
1778 inputs_[1] = offset;
1781 LOperand* base_object() const { return inputs_[0]; }
1782 LOperand* offset() const { return inputs_[1]; }
1784 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1786 DECLARE_CONCRETE_INSTRUCTION(InnerAllocatedObject, "inner-allocated-object")
1790 class LThisFunction V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1792 DECLARE_CONCRETE_INSTRUCTION(ThisFunction, "this-function")
1793 DECLARE_HYDROGEN_ACCESSOR(ThisFunction)
1797 class LContext V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1799 DECLARE_CONCRETE_INSTRUCTION(Context, "context")
1800 DECLARE_HYDROGEN_ACCESSOR(Context)
1804 class LDeclareGlobals V8_FINAL : public LTemplateInstruction<0, 1, 0> {
1806 explicit LDeclareGlobals(LOperand* context) {
1807 inputs_[0] = context;
1810 LOperand* context() { return inputs_[0]; }
1812 DECLARE_CONCRETE_INSTRUCTION(DeclareGlobals, "declare-globals")
1813 DECLARE_HYDROGEN_ACCESSOR(DeclareGlobals)
1817 class LCallJSFunction V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1819 explicit LCallJSFunction(LOperand* function) {
1820 inputs_[0] = function;
1823 LOperand* function() { return inputs_[0]; }
1825 DECLARE_CONCRETE_INSTRUCTION(CallJSFunction, "call-js-function")
1826 DECLARE_HYDROGEN_ACCESSOR(CallJSFunction)
1828 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1830 int arity() const { return hydrogen()->argument_count() - 1; }
1834 class LCallWithDescriptor V8_FINAL : public LTemplateResultInstruction<1> {
1836 LCallWithDescriptor(const CallInterfaceDescriptor* descriptor,
1837 ZoneList<LOperand*>& operands,
1839 : inputs_(descriptor->environment_length() + 1, zone) {
1840 ASSERT(descriptor->environment_length() + 1 == operands.length());
1841 inputs_.AddAll(operands, zone);
1844 LOperand* target() const { return inputs_[0]; }
1847 DECLARE_CONCRETE_INSTRUCTION(CallWithDescriptor, "call-with-descriptor")
1848 DECLARE_HYDROGEN_ACCESSOR(CallWithDescriptor)
1850 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1852 int arity() const { return hydrogen()->argument_count() - 1; }
1854 ZoneList<LOperand*> inputs_;
1856 // Iterator support.
1857 virtual int InputCount() V8_FINAL V8_OVERRIDE { return inputs_.length(); }
1858 virtual LOperand* InputAt(int i) V8_FINAL V8_OVERRIDE { return inputs_[i]; }
1860 virtual int TempCount() V8_FINAL V8_OVERRIDE { return 0; }
1861 virtual LOperand* TempAt(int i) V8_FINAL V8_OVERRIDE { return NULL; }
1865 class LInvokeFunction V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1867 LInvokeFunction(LOperand* context, LOperand* function) {
1868 inputs_[0] = context;
1869 inputs_[1] = function;
1872 LOperand* context() { return inputs_[0]; }
1873 LOperand* function() { return inputs_[1]; }
1875 DECLARE_CONCRETE_INSTRUCTION(InvokeFunction, "invoke-function")
1876 DECLARE_HYDROGEN_ACCESSOR(InvokeFunction)
1878 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1880 int arity() const { return hydrogen()->argument_count() - 1; }
1884 class LCallFunction V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1886 LCallFunction(LOperand* context, LOperand* function) {
1887 inputs_[0] = context;
1888 inputs_[1] = function;
1891 DECLARE_CONCRETE_INSTRUCTION(CallFunction, "call-function")
1892 DECLARE_HYDROGEN_ACCESSOR(CallFunction)
1894 LOperand* context() { return inputs_[0]; }
1895 LOperand* function() { return inputs_[1]; }
1896 int arity() const { return hydrogen()->argument_count() - 1; }
1900 class LCallNew V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1902 LCallNew(LOperand* context, LOperand* constructor) {
1903 inputs_[0] = context;
1904 inputs_[1] = constructor;
1907 LOperand* context() { return inputs_[0]; }
1908 LOperand* constructor() { return inputs_[1]; }
1910 DECLARE_CONCRETE_INSTRUCTION(CallNew, "call-new")
1911 DECLARE_HYDROGEN_ACCESSOR(CallNew)
1913 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1915 int arity() const { return hydrogen()->argument_count() - 1; }
1919 class LCallNewArray V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1921 LCallNewArray(LOperand* context, LOperand* constructor) {
1922 inputs_[0] = context;
1923 inputs_[1] = constructor;
1926 LOperand* context() { return inputs_[0]; }
1927 LOperand* constructor() { return inputs_[1]; }
1929 DECLARE_CONCRETE_INSTRUCTION(CallNewArray, "call-new-array")
1930 DECLARE_HYDROGEN_ACCESSOR(CallNewArray)
1932 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1934 int arity() const { return hydrogen()->argument_count() - 1; }
1938 class LCallRuntime V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1940 explicit LCallRuntime(LOperand* context) {
1941 inputs_[0] = context;
1944 LOperand* context() { return inputs_[0]; }
1946 DECLARE_CONCRETE_INSTRUCTION(CallRuntime, "call-runtime")
1947 DECLARE_HYDROGEN_ACCESSOR(CallRuntime)
1949 virtual bool ClobbersDoubleRegisters(Isolate* isolate) const V8_OVERRIDE {
1950 return save_doubles() == kDontSaveFPRegs;
1953 const Runtime::Function* function() const { return hydrogen()->function(); }
1954 int arity() const { return hydrogen()->argument_count(); }
1955 SaveFPRegsMode save_doubles() const { return hydrogen()->save_doubles(); }
1959 class LInteger32ToDouble V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1961 explicit LInteger32ToDouble(LOperand* value) {
1965 LOperand* value() { return inputs_[0]; }
1967 DECLARE_CONCRETE_INSTRUCTION(Integer32ToDouble, "int32-to-double")
1971 class LUint32ToDouble V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1973 explicit LUint32ToDouble(LOperand* value) {
1977 LOperand* value() { return inputs_[0]; }
1979 DECLARE_CONCRETE_INSTRUCTION(Uint32ToDouble, "uint32-to-double")
1983 class LNumberTagI V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1985 explicit LNumberTagI(LOperand* value) {
1989 LOperand* value() { return inputs_[0]; }
1991 DECLARE_CONCRETE_INSTRUCTION(NumberTagI, "number-tag-i")
1995 class LNumberTagU V8_FINAL : public LTemplateInstruction<1, 1, 2> {
1997 LNumberTagU(LOperand* value, LOperand* temp1, LOperand* temp2) {
2003 LOperand* value() { return inputs_[0]; }
2004 LOperand* temp1() { return temps_[0]; }
2005 LOperand* temp2() { return temps_[1]; }
2007 DECLARE_CONCRETE_INSTRUCTION(NumberTagU, "number-tag-u")
2011 class LNumberTagD V8_FINAL : public LTemplateInstruction<1, 1, 1> {
2013 explicit LNumberTagD(LOperand* value, LOperand* temp) {
2018 LOperand* value() { return inputs_[0]; }
2019 LOperand* temp() { return temps_[0]; }
2021 DECLARE_CONCRETE_INSTRUCTION(NumberTagD, "number-tag-d")
2022 DECLARE_HYDROGEN_ACCESSOR(Change)
2026 // Sometimes truncating conversion from a tagged value to an int32.
2027 class LDoubleToI V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2029 explicit LDoubleToI(LOperand* value) {
2033 LOperand* value() { return inputs_[0]; }
2035 DECLARE_CONCRETE_INSTRUCTION(DoubleToI, "double-to-i")
2036 DECLARE_HYDROGEN_ACCESSOR(UnaryOperation)
2038 bool truncating() { return hydrogen()->CanTruncateToInt32(); }
2042 class LDoubleToSmi V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2044 explicit LDoubleToSmi(LOperand* value) {
2048 LOperand* value() { return inputs_[0]; }
2050 DECLARE_CONCRETE_INSTRUCTION(DoubleToSmi, "double-to-smi")
2051 DECLARE_HYDROGEN_ACCESSOR(UnaryOperation)
2055 // Truncating conversion from a tagged value to an int32.
2056 class LTaggedToI V8_FINAL : public LTemplateInstruction<1, 1, 1> {
2058 LTaggedToI(LOperand* value, LOperand* temp) {
2063 LOperand* value() { return inputs_[0]; }
2064 LOperand* temp() { return temps_[0]; }
2066 DECLARE_CONCRETE_INSTRUCTION(TaggedToI, "tagged-to-i")
2067 DECLARE_HYDROGEN_ACCESSOR(Change)
2069 bool truncating() { return hydrogen()->CanTruncateToInt32(); }
2073 class LSmiTag V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2075 explicit LSmiTag(LOperand* value) {
2079 LOperand* value() { return inputs_[0]; }
2081 DECLARE_CONCRETE_INSTRUCTION(SmiTag, "smi-tag")
2082 DECLARE_HYDROGEN_ACCESSOR(Change)
2086 class LNumberUntagD V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2088 explicit LNumberUntagD(LOperand* value) {
2092 LOperand* value() { return inputs_[0]; }
2094 DECLARE_CONCRETE_INSTRUCTION(NumberUntagD, "double-untag")
2095 DECLARE_HYDROGEN_ACCESSOR(Change);
2099 class LSmiUntag V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2101 LSmiUntag(LOperand* value, bool needs_check)
2102 : needs_check_(needs_check) {
2106 LOperand* value() { return inputs_[0]; }
2107 bool needs_check() const { return needs_check_; }
2109 DECLARE_CONCRETE_INSTRUCTION(SmiUntag, "smi-untag")
2116 class LStoreNamedField V8_FINAL : public LTemplateInstruction<0, 2, 1> {
2118 LStoreNamedField(LOperand* object, LOperand* value, LOperand* temp) {
2119 inputs_[0] = object;
2124 LOperand* object() { return inputs_[0]; }
2125 LOperand* value() { return inputs_[1]; }
2126 LOperand* temp() { return temps_[0]; }
2128 DECLARE_CONCRETE_INSTRUCTION(StoreNamedField, "store-named-field")
2129 DECLARE_HYDROGEN_ACCESSOR(StoreNamedField)
2131 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
2133 Representation representation() const {
2134 return hydrogen()->field_representation();
2139 class LStoreNamedGeneric V8_FINAL : public LTemplateInstruction<0, 3, 0> {
2141 LStoreNamedGeneric(LOperand* context, LOperand* object, LOperand* value) {
2142 inputs_[0] = context;
2143 inputs_[1] = object;
2147 LOperand* context() { return inputs_[0]; }
2148 LOperand* object() { return inputs_[1]; }
2149 LOperand* value() { return inputs_[2]; }
2151 DECLARE_CONCRETE_INSTRUCTION(StoreNamedGeneric, "store-named-generic")
2152 DECLARE_HYDROGEN_ACCESSOR(StoreNamedGeneric)
2154 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
2156 Handle<Object> name() const { return hydrogen()->name(); }
2157 StrictMode strict_mode() { return hydrogen()->strict_mode(); }
2161 class LStoreKeyed V8_FINAL : public LTemplateInstruction<0, 3, 0> {
2163 LStoreKeyed(LOperand* object, LOperand* key, LOperand* value) {
2164 inputs_[0] = object;
2169 bool is_external() const { return hydrogen()->is_external(); }
2170 bool is_fixed_typed_array() const {
2171 return hydrogen()->is_fixed_typed_array();
2173 bool is_typed_elements() const {
2174 return is_external() || is_fixed_typed_array();
2176 LOperand* elements() { return inputs_[0]; }
2177 LOperand* key() { return inputs_[1]; }
2178 LOperand* value() { return inputs_[2]; }
2179 ElementsKind elements_kind() const { return hydrogen()->elements_kind(); }
2181 DECLARE_CONCRETE_INSTRUCTION(StoreKeyed, "store-keyed")
2182 DECLARE_HYDROGEN_ACCESSOR(StoreKeyed)
2184 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
2185 bool NeedsCanonicalization() { return hydrogen()->NeedsCanonicalization(); }
2186 uint32_t base_offset() const { return hydrogen()->base_offset(); }
2190 class LStoreKeyedGeneric V8_FINAL : public LTemplateInstruction<0, 4, 0> {
2192 LStoreKeyedGeneric(LOperand* context,
2196 inputs_[0] = context;
2197 inputs_[1] = object;
2202 LOperand* context() { return inputs_[0]; }
2203 LOperand* object() { return inputs_[1]; }
2204 LOperand* key() { return inputs_[2]; }
2205 LOperand* value() { return inputs_[3]; }
2207 DECLARE_CONCRETE_INSTRUCTION(StoreKeyedGeneric, "store-keyed-generic")
2208 DECLARE_HYDROGEN_ACCESSOR(StoreKeyedGeneric)
2210 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
2212 StrictMode strict_mode() { return hydrogen()->strict_mode(); }
2216 class LTransitionElementsKind V8_FINAL : public LTemplateInstruction<0, 2, 2> {
2218 LTransitionElementsKind(LOperand* object,
2220 LOperand* new_map_temp,
2222 inputs_[0] = object;
2223 inputs_[1] = context;
2224 temps_[0] = new_map_temp;
2228 LOperand* object() { return inputs_[0]; }
2229 LOperand* context() { return inputs_[1]; }
2230 LOperand* new_map_temp() { return temps_[0]; }
2231 LOperand* temp() { return temps_[1]; }
2233 DECLARE_CONCRETE_INSTRUCTION(TransitionElementsKind,
2234 "transition-elements-kind")
2235 DECLARE_HYDROGEN_ACCESSOR(TransitionElementsKind)
2237 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
2239 Handle<Map> original_map() { return hydrogen()->original_map().handle(); }
2240 Handle<Map> transitioned_map() {
2241 return hydrogen()->transitioned_map().handle();
2243 ElementsKind from_kind() { return hydrogen()->from_kind(); }
2244 ElementsKind to_kind() { return hydrogen()->to_kind(); }
2248 class LArrayShift V8_FINAL : public LTemplateInstruction<1, 2, 0> {
2250 LArrayShift(LOperand* context, LOperand* object) {
2251 inputs_[0] = context;
2252 inputs_[1] = object;
2255 LOperand* context() const { return inputs_[0]; }
2256 LOperand* object() const { return inputs_[1]; }
2258 DECLARE_CONCRETE_INSTRUCTION(ArrayShift, "array-shift")
2259 DECLARE_HYDROGEN_ACCESSOR(ArrayShift)
2263 class LTrapAllocationMemento V8_FINAL : public LTemplateInstruction<0, 1, 1> {
2265 LTrapAllocationMemento(LOperand* object,
2267 inputs_[0] = object;
2271 LOperand* object() { return inputs_[0]; }
2272 LOperand* temp() { return temps_[0]; }
2274 DECLARE_CONCRETE_INSTRUCTION(TrapAllocationMemento,
2275 "trap-allocation-memento")
2279 class LStringAdd V8_FINAL : public LTemplateInstruction<1, 3, 0> {
2281 LStringAdd(LOperand* context, LOperand* left, LOperand* right) {
2282 inputs_[0] = context;
2287 LOperand* context() { return inputs_[0]; }
2288 LOperand* left() { return inputs_[1]; }
2289 LOperand* right() { return inputs_[2]; }
2291 DECLARE_CONCRETE_INSTRUCTION(StringAdd, "string-add")
2292 DECLARE_HYDROGEN_ACCESSOR(StringAdd)
2296 class LStringCharCodeAt V8_FINAL : public LTemplateInstruction<1, 3, 0> {
2298 LStringCharCodeAt(LOperand* context, LOperand* string, LOperand* index) {
2299 inputs_[0] = context;
2300 inputs_[1] = string;
2304 LOperand* context() { return inputs_[0]; }
2305 LOperand* string() { return inputs_[1]; }
2306 LOperand* index() { return inputs_[2]; }
2308 DECLARE_CONCRETE_INSTRUCTION(StringCharCodeAt, "string-char-code-at")
2309 DECLARE_HYDROGEN_ACCESSOR(StringCharCodeAt)
2313 class LStringCharFromCode V8_FINAL : public LTemplateInstruction<1, 2, 0> {
2315 explicit LStringCharFromCode(LOperand* context, LOperand* char_code) {
2316 inputs_[0] = context;
2317 inputs_[1] = char_code;
2320 LOperand* context() { return inputs_[0]; }
2321 LOperand* char_code() { return inputs_[1]; }
2323 DECLARE_CONCRETE_INSTRUCTION(StringCharFromCode, "string-char-from-code")
2324 DECLARE_HYDROGEN_ACCESSOR(StringCharFromCode)
2328 class LCheckValue V8_FINAL : public LTemplateInstruction<0, 1, 0> {
2330 explicit LCheckValue(LOperand* value) {
2334 LOperand* value() { return inputs_[0]; }
2336 DECLARE_CONCRETE_INSTRUCTION(CheckValue, "check-value")
2337 DECLARE_HYDROGEN_ACCESSOR(CheckValue)
2341 class LCheckInstanceType V8_FINAL : public LTemplateInstruction<0, 1, 0> {
2343 explicit LCheckInstanceType(LOperand* value) {
2347 LOperand* value() { return inputs_[0]; }
2349 DECLARE_CONCRETE_INSTRUCTION(CheckInstanceType, "check-instance-type")
2350 DECLARE_HYDROGEN_ACCESSOR(CheckInstanceType)
2354 class LCheckMaps V8_FINAL : public LTemplateInstruction<0, 1, 0> {
2356 explicit LCheckMaps(LOperand* value = NULL) {
2360 LOperand* value() { return inputs_[0]; }
2362 DECLARE_CONCRETE_INSTRUCTION(CheckMaps, "check-maps")
2363 DECLARE_HYDROGEN_ACCESSOR(CheckMaps)
2367 class LCheckSmi V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2369 explicit LCheckSmi(LOperand* value) {
2373 LOperand* value() { return inputs_[0]; }
2375 DECLARE_CONCRETE_INSTRUCTION(CheckSmi, "check-smi")
2379 class LClampDToUint8 V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2381 explicit LClampDToUint8(LOperand* unclamped) {
2382 inputs_[0] = unclamped;
2385 LOperand* unclamped() { return inputs_[0]; }
2387 DECLARE_CONCRETE_INSTRUCTION(ClampDToUint8, "clamp-d-to-uint8")
2391 class LClampIToUint8 V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2393 explicit LClampIToUint8(LOperand* unclamped) {
2394 inputs_[0] = unclamped;
2397 LOperand* unclamped() { return inputs_[0]; }
2399 DECLARE_CONCRETE_INSTRUCTION(ClampIToUint8, "clamp-i-to-uint8")
2403 class LClampTToUint8 V8_FINAL : public LTemplateInstruction<1, 1, 1> {
2405 LClampTToUint8(LOperand* unclamped,
2406 LOperand* temp_xmm) {
2407 inputs_[0] = unclamped;
2408 temps_[0] = temp_xmm;
2411 LOperand* unclamped() { return inputs_[0]; }
2412 LOperand* temp_xmm() { return temps_[0]; }
2414 DECLARE_CONCRETE_INSTRUCTION(ClampTToUint8, "clamp-t-to-uint8")
2418 class LCheckNonSmi V8_FINAL : public LTemplateInstruction<0, 1, 0> {
2420 explicit LCheckNonSmi(LOperand* value) {
2424 LOperand* value() { return inputs_[0]; }
2426 DECLARE_CONCRETE_INSTRUCTION(CheckNonSmi, "check-non-smi")
2427 DECLARE_HYDROGEN_ACCESSOR(CheckHeapObject)
2431 class LDoubleBits V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2433 explicit LDoubleBits(LOperand* value) {
2437 LOperand* value() { return inputs_[0]; }
2439 DECLARE_CONCRETE_INSTRUCTION(DoubleBits, "double-bits")
2440 DECLARE_HYDROGEN_ACCESSOR(DoubleBits)
2444 class LConstructDouble V8_FINAL : public LTemplateInstruction<1, 2, 0> {
2446 LConstructDouble(LOperand* hi, LOperand* lo) {
2451 LOperand* hi() { return inputs_[0]; }
2452 LOperand* lo() { return inputs_[1]; }
2454 DECLARE_CONCRETE_INSTRUCTION(ConstructDouble, "construct-double")
2458 class LAllocate V8_FINAL : public LTemplateInstruction<1, 2, 1> {
2460 LAllocate(LOperand* context, LOperand* size, LOperand* temp) {
2461 inputs_[0] = context;
2466 LOperand* context() { return inputs_[0]; }
2467 LOperand* size() { return inputs_[1]; }
2468 LOperand* temp() { return temps_[0]; }
2470 DECLARE_CONCRETE_INSTRUCTION(Allocate, "allocate")
2471 DECLARE_HYDROGEN_ACCESSOR(Allocate)
2475 class LRegExpLiteral V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2477 explicit LRegExpLiteral(LOperand* context) {
2478 inputs_[0] = context;
2481 LOperand* context() { return inputs_[0]; }
2483 DECLARE_CONCRETE_INSTRUCTION(RegExpLiteral, "regexp-literal")
2484 DECLARE_HYDROGEN_ACCESSOR(RegExpLiteral)
2488 class LFunctionLiteral V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2490 explicit LFunctionLiteral(LOperand* context) {
2491 inputs_[0] = context;
2494 LOperand* context() { return inputs_[0]; }
2496 DECLARE_CONCRETE_INSTRUCTION(FunctionLiteral, "function-literal")
2497 DECLARE_HYDROGEN_ACCESSOR(FunctionLiteral)
2501 class LToFastProperties V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2503 explicit LToFastProperties(LOperand* value) {
2507 LOperand* value() { return inputs_[0]; }
2509 DECLARE_CONCRETE_INSTRUCTION(ToFastProperties, "to-fast-properties")
2510 DECLARE_HYDROGEN_ACCESSOR(ToFastProperties)
2514 class LTypeof V8_FINAL : public LTemplateInstruction<1, 2, 0> {
2516 LTypeof(LOperand* context, LOperand* value) {
2517 inputs_[0] = context;
2521 LOperand* context() { return inputs_[0]; }
2522 LOperand* value() { return inputs_[1]; }
2524 DECLARE_CONCRETE_INSTRUCTION(Typeof, "typeof")
2528 class LTypeofIsAndBranch V8_FINAL : public LControlInstruction<1, 0> {
2530 explicit LTypeofIsAndBranch(LOperand* value) {
2534 LOperand* value() { return inputs_[0]; }
2536 DECLARE_CONCRETE_INSTRUCTION(TypeofIsAndBranch, "typeof-is-and-branch")
2537 DECLARE_HYDROGEN_ACCESSOR(TypeofIsAndBranch)
2539 Handle<String> type_literal() { return hydrogen()->type_literal(); }
2541 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
2545 class LIsConstructCallAndBranch V8_FINAL : public LControlInstruction<0, 1> {
2547 explicit LIsConstructCallAndBranch(LOperand* temp) {
2551 LOperand* temp() { return temps_[0]; }
2553 DECLARE_CONCRETE_INSTRUCTION(IsConstructCallAndBranch,
2554 "is-construct-call-and-branch")
2555 DECLARE_HYDROGEN_ACCESSOR(IsConstructCallAndBranch)
2559 class LOsrEntry V8_FINAL : public LTemplateInstruction<0, 0, 0> {
2563 virtual bool HasInterestingComment(LCodeGen* gen) const V8_OVERRIDE {
2566 DECLARE_CONCRETE_INSTRUCTION(OsrEntry, "osr-entry")
2570 class LStackCheck V8_FINAL : public LTemplateInstruction<0, 1, 0> {
2572 explicit LStackCheck(LOperand* context) {
2573 inputs_[0] = context;
2576 LOperand* context() { return inputs_[0]; }
2578 DECLARE_CONCRETE_INSTRUCTION(StackCheck, "stack-check")
2579 DECLARE_HYDROGEN_ACCESSOR(StackCheck)
2581 Label* done_label() { return &done_label_; }
2588 class LForInPrepareMap V8_FINAL : public LTemplateInstruction<1, 2, 0> {
2590 LForInPrepareMap(LOperand* context, LOperand* object) {
2591 inputs_[0] = context;
2592 inputs_[1] = object;
2595 LOperand* context() { return inputs_[0]; }
2596 LOperand* object() { return inputs_[1]; }
2598 DECLARE_CONCRETE_INSTRUCTION(ForInPrepareMap, "for-in-prepare-map")
2602 class LForInCacheArray V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2604 explicit LForInCacheArray(LOperand* map) {
2608 LOperand* map() { return inputs_[0]; }
2610 DECLARE_CONCRETE_INSTRUCTION(ForInCacheArray, "for-in-cache-array")
2613 return HForInCacheArray::cast(this->hydrogen_value())->idx();
2618 class LCheckMapValue V8_FINAL : public LTemplateInstruction<0, 2, 0> {
2620 LCheckMapValue(LOperand* value, LOperand* map) {
2625 LOperand* value() { return inputs_[0]; }
2626 LOperand* map() { return inputs_[1]; }
2628 DECLARE_CONCRETE_INSTRUCTION(CheckMapValue, "check-map-value")
2632 class LLoadFieldByIndex V8_FINAL : public LTemplateInstruction<1, 2, 0> {
2634 LLoadFieldByIndex(LOperand* object, LOperand* index) {
2635 inputs_[0] = object;
2639 LOperand* object() { return inputs_[0]; }
2640 LOperand* index() { return inputs_[1]; }
2642 DECLARE_CONCRETE_INSTRUCTION(LoadFieldByIndex, "load-field-by-index")
2646 class LChunkBuilder;
2647 class LPlatformChunk V8_FINAL : public LChunk {
2649 LPlatformChunk(CompilationInfo* info, HGraph* graph)
2650 : LChunk(info, graph),
2651 dehoisted_key_ids_(graph->GetMaximumValueID(), graph->zone()) { }
2653 int GetNextSpillIndex(RegisterKind kind);
2654 LOperand* GetNextSpillSlot(RegisterKind kind);
2655 BitVector* GetDehoistedKeyIds() { return &dehoisted_key_ids_; }
2656 bool IsDehoistedKey(HValue* value) {
2657 return dehoisted_key_ids_.Contains(value->id());
2661 BitVector dehoisted_key_ids_;
2665 class LChunkBuilder V8_FINAL : public LChunkBuilderBase {
2667 LChunkBuilder(CompilationInfo* info, HGraph* graph, LAllocator* allocator)
2668 : LChunkBuilderBase(graph->zone()),
2673 current_instruction_(NULL),
2674 current_block_(NULL),
2676 allocator_(allocator) { }
2678 Isolate* isolate() const { return graph_->isolate(); }
2680 // Build the sequence for the graph.
2681 LPlatformChunk* Build();
2683 // Declare methods that deal with the individual node types.
2684 #define DECLARE_DO(type) LInstruction* Do##type(H##type* node);
2685 HYDROGEN_CONCRETE_INSTRUCTION_LIST(DECLARE_DO)
2688 LInstruction* DoMathFloor(HUnaryMathOperation* instr);
2689 LInstruction* DoMathRound(HUnaryMathOperation* instr);
2690 LInstruction* DoMathAbs(HUnaryMathOperation* instr);
2691 LInstruction* DoMathLog(HUnaryMathOperation* instr);
2692 LInstruction* DoMathExp(HUnaryMathOperation* instr);
2693 LInstruction* DoMathSqrt(HUnaryMathOperation* instr);
2694 LInstruction* DoMathPowHalf(HUnaryMathOperation* instr);
2695 LInstruction* DoMathClz32(HUnaryMathOperation* instr);
2696 LInstruction* DoDivByPowerOf2I(HDiv* instr);
2697 LInstruction* DoDivByConstI(HDiv* instr);
2698 LInstruction* DoDivI(HDiv* instr);
2699 LInstruction* DoModByPowerOf2I(HMod* instr);
2700 LInstruction* DoModByConstI(HMod* instr);
2701 LInstruction* DoModI(HMod* instr);
2702 LInstruction* DoFlooringDivByPowerOf2I(HMathFloorOfDiv* instr);
2703 LInstruction* DoFlooringDivByConstI(HMathFloorOfDiv* instr);
2704 LInstruction* DoFlooringDivI(HMathFloorOfDiv* instr);
2714 LPlatformChunk* chunk() const { return chunk_; }
2715 CompilationInfo* info() const { return info_; }
2716 HGraph* graph() const { return graph_; }
2718 bool is_unused() const { return status_ == UNUSED; }
2719 bool is_building() const { return status_ == BUILDING; }
2720 bool is_done() const { return status_ == DONE; }
2721 bool is_aborted() const { return status_ == ABORTED; }
2723 void Abort(BailoutReason reason);
2725 // Methods for getting operands for Use / Define / Temp.
2726 LUnallocated* ToUnallocated(Register reg);
2727 LUnallocated* ToUnallocated(XMMRegister reg);
2729 // Methods for setting up define-use relationships.
2730 MUST_USE_RESULT LOperand* Use(HValue* value, LUnallocated* operand);
2731 MUST_USE_RESULT LOperand* UseFixed(HValue* value, Register fixed_register);
2732 MUST_USE_RESULT LOperand* UseFixedDouble(HValue* value,
2733 XMMRegister fixed_register);
2735 // A value that is guaranteed to be allocated to a register.
2736 // Operand created by UseRegister is guaranteed to be live until the end of
2737 // instruction. This means that register allocator will not reuse it's
2738 // register for any other operand inside instruction.
2739 // Operand created by UseRegisterAtStart is guaranteed to be live only at
2740 // instruction start. Register allocator is free to assign the same register
2741 // to some other operand used inside instruction (i.e. temporary or
2743 MUST_USE_RESULT LOperand* UseRegister(HValue* value);
2744 MUST_USE_RESULT LOperand* UseRegisterAtStart(HValue* value);
2746 // An input operand in a register that may be trashed.
2747 MUST_USE_RESULT LOperand* UseTempRegister(HValue* value);
2749 // An input operand in a register that may be trashed or a constant operand.
2750 MUST_USE_RESULT LOperand* UseTempRegisterOrConstant(HValue* value);
2752 // An input operand in a register or stack slot.
2753 MUST_USE_RESULT LOperand* Use(HValue* value);
2754 MUST_USE_RESULT LOperand* UseAtStart(HValue* value);
2756 // An input operand in a register, stack slot or a constant operand.
2757 MUST_USE_RESULT LOperand* UseOrConstant(HValue* value);
2758 MUST_USE_RESULT LOperand* UseOrConstantAtStart(HValue* value);
2760 // An input operand in a register or a constant operand.
2761 MUST_USE_RESULT LOperand* UseRegisterOrConstant(HValue* value);
2762 MUST_USE_RESULT LOperand* UseRegisterOrConstantAtStart(HValue* value);
2764 // An input operand in a constant operand.
2765 MUST_USE_RESULT LOperand* UseConstant(HValue* value);
2767 // An input operand in register, stack slot or a constant operand.
2768 // Will not be moved to a register even if one is freely available.
2769 virtual MUST_USE_RESULT LOperand* UseAny(HValue* value) V8_OVERRIDE;
2771 // Temporary operand that must be in a register.
2772 MUST_USE_RESULT LUnallocated* TempRegister();
2773 MUST_USE_RESULT LOperand* FixedTemp(Register reg);
2774 MUST_USE_RESULT LOperand* FixedTemp(XMMRegister reg);
2776 // Methods for setting up define-use relationships.
2777 // Return the same instruction that they are passed.
2778 LInstruction* Define(LTemplateResultInstruction<1>* instr,
2779 LUnallocated* result);
2780 LInstruction* DefineAsRegister(LTemplateResultInstruction<1>* instr);
2781 LInstruction* DefineAsSpilled(LTemplateResultInstruction<1>* instr,
2783 LInstruction* DefineSameAsFirst(LTemplateResultInstruction<1>* instr);
2784 LInstruction* DefineFixed(LTemplateResultInstruction<1>* instr,
2786 LInstruction* DefineFixedDouble(LTemplateResultInstruction<1>* instr,
2788 // Assigns an environment to an instruction. An instruction which can
2789 // deoptimize must have an environment.
2790 LInstruction* AssignEnvironment(LInstruction* instr);
2791 // Assigns a pointer map to an instruction. An instruction which can
2792 // trigger a GC or a lazy deoptimization must have a pointer map.
2793 LInstruction* AssignPointerMap(LInstruction* instr);
2795 enum CanDeoptimize { CAN_DEOPTIMIZE_EAGERLY, CANNOT_DEOPTIMIZE_EAGERLY };
2797 // Marks a call for the register allocator. Assigns a pointer map to
2798 // support GC and lazy deoptimization. Assigns an environment to support
2799 // eager deoptimization if CAN_DEOPTIMIZE_EAGERLY.
2800 LInstruction* MarkAsCall(
2801 LInstruction* instr,
2802 HInstruction* hinstr,
2803 CanDeoptimize can_deoptimize = CANNOT_DEOPTIMIZE_EAGERLY);
2805 void VisitInstruction(HInstruction* current);
2806 void AddInstruction(LInstruction* instr, HInstruction* current);
2808 void DoBasicBlock(HBasicBlock* block, HBasicBlock* next_block);
2809 LInstruction* DoShift(Token::Value op, HBitwiseBinaryOperation* instr);
2810 LInstruction* DoArithmeticD(Token::Value op,
2811 HArithmeticBinaryOperation* instr);
2812 LInstruction* DoArithmeticT(Token::Value op,
2813 HBinaryOperation* instr);
2814 void FindDehoistedKeyDefinitions(HValue* candidate);
2816 LPlatformChunk* chunk_;
2817 CompilationInfo* info_;
2818 HGraph* const graph_;
2820 HInstruction* current_instruction_;
2821 HBasicBlock* current_block_;
2822 HBasicBlock* next_block_;
2823 LAllocator* allocator_;
2825 DISALLOW_COPY_AND_ASSIGN(LChunkBuilder);
2828 #undef DECLARE_HYDROGEN_ACCESSOR
2829 #undef DECLARE_CONCRETE_INSTRUCTION
2831 } } // namespace v8::int
2833 #endif // V8_X64_LITHIUM_X64_H_