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) \
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 DECLARE_CONCRETE_INSTRUCTION(Deoptimize, "deoptimize")
432 DECLARE_HYDROGEN_ACCESSOR(Deoptimize)
436 class LLabel V8_FINAL : public LGap {
438 explicit LLabel(HBasicBlock* block)
439 : LGap(block), replacement_(NULL) { }
441 virtual bool HasInterestingComment(LCodeGen* gen) const V8_OVERRIDE {
444 DECLARE_CONCRETE_INSTRUCTION(Label, "label")
446 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
448 int block_id() const { return block()->block_id(); }
449 bool is_loop_header() const { return block()->IsLoopHeader(); }
450 bool is_osr_entry() const { return block()->is_osr_entry(); }
451 Label* label() { return &label_; }
452 LLabel* replacement() const { return replacement_; }
453 void set_replacement(LLabel* label) { replacement_ = label; }
454 bool HasReplacement() const { return replacement_ != NULL; }
458 LLabel* replacement_;
462 class LParameter V8_FINAL : public LTemplateInstruction<1, 0, 0> {
464 virtual bool HasInterestingComment(LCodeGen* gen) const V8_OVERRIDE {
467 DECLARE_CONCRETE_INSTRUCTION(Parameter, "parameter")
471 class LCallStub V8_FINAL : public LTemplateInstruction<1, 1, 0> {
473 explicit LCallStub(LOperand* context) {
474 inputs_[0] = context;
477 LOperand* context() { return inputs_[0]; }
479 DECLARE_CONCRETE_INSTRUCTION(CallStub, "call-stub")
480 DECLARE_HYDROGEN_ACCESSOR(CallStub)
484 class LUnknownOSRValue V8_FINAL : public LTemplateInstruction<1, 0, 0> {
486 virtual bool HasInterestingComment(LCodeGen* gen) const V8_OVERRIDE {
489 DECLARE_CONCRETE_INSTRUCTION(UnknownOSRValue, "unknown-osr-value")
493 template<int I, int T>
494 class LControlInstruction : public LTemplateInstruction<0, I, T> {
496 LControlInstruction() : false_label_(NULL), true_label_(NULL) { }
498 virtual bool IsControl() const V8_FINAL V8_OVERRIDE { return true; }
500 int SuccessorCount() { return hydrogen()->SuccessorCount(); }
501 HBasicBlock* SuccessorAt(int i) { return hydrogen()->SuccessorAt(i); }
503 int TrueDestination(LChunk* chunk) {
504 return chunk->LookupDestination(true_block_id());
506 int FalseDestination(LChunk* chunk) {
507 return chunk->LookupDestination(false_block_id());
510 Label* TrueLabel(LChunk* chunk) {
511 if (true_label_ == NULL) {
512 true_label_ = chunk->GetAssemblyLabel(TrueDestination(chunk));
516 Label* FalseLabel(LChunk* chunk) {
517 if (false_label_ == NULL) {
518 false_label_ = chunk->GetAssemblyLabel(FalseDestination(chunk));
524 int true_block_id() { return SuccessorAt(0)->block_id(); }
525 int false_block_id() { return SuccessorAt(1)->block_id(); }
528 HControlInstruction* hydrogen() {
529 return HControlInstruction::cast(this->hydrogen_value());
537 class LWrapReceiver V8_FINAL : public LTemplateInstruction<1, 2, 0> {
539 LWrapReceiver(LOperand* receiver, LOperand* function) {
540 inputs_[0] = receiver;
541 inputs_[1] = function;
544 LOperand* receiver() { return inputs_[0]; }
545 LOperand* function() { return inputs_[1]; }
547 DECLARE_CONCRETE_INSTRUCTION(WrapReceiver, "wrap-receiver")
548 DECLARE_HYDROGEN_ACCESSOR(WrapReceiver)
552 class LApplyArguments V8_FINAL : public LTemplateInstruction<1, 4, 0> {
554 LApplyArguments(LOperand* function,
557 LOperand* elements) {
558 inputs_[0] = function;
559 inputs_[1] = receiver;
561 inputs_[3] = elements;
564 LOperand* function() { return inputs_[0]; }
565 LOperand* receiver() { return inputs_[1]; }
566 LOperand* length() { return inputs_[2]; }
567 LOperand* elements() { return inputs_[3]; }
569 DECLARE_CONCRETE_INSTRUCTION(ApplyArguments, "apply-arguments")
573 class LAccessArgumentsAt V8_FINAL : public LTemplateInstruction<1, 3, 0> {
575 LAccessArgumentsAt(LOperand* arguments, LOperand* length, LOperand* index) {
576 inputs_[0] = arguments;
581 LOperand* arguments() { return inputs_[0]; }
582 LOperand* length() { return inputs_[1]; }
583 LOperand* index() { return inputs_[2]; }
585 DECLARE_CONCRETE_INSTRUCTION(AccessArgumentsAt, "access-arguments-at")
587 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
591 class LArgumentsLength V8_FINAL : public LTemplateInstruction<1, 1, 0> {
593 explicit LArgumentsLength(LOperand* elements) {
594 inputs_[0] = elements;
597 LOperand* elements() { return inputs_[0]; }
599 DECLARE_CONCRETE_INSTRUCTION(ArgumentsLength, "arguments-length")
603 class LArgumentsElements V8_FINAL : public LTemplateInstruction<1, 0, 0> {
605 DECLARE_CONCRETE_INSTRUCTION(ArgumentsElements, "arguments-elements")
606 DECLARE_HYDROGEN_ACCESSOR(ArgumentsElements)
610 class LModByPowerOf2I V8_FINAL : public LTemplateInstruction<1, 1, 0> {
612 LModByPowerOf2I(LOperand* dividend, int32_t divisor) {
613 inputs_[0] = dividend;
617 LOperand* dividend() { return inputs_[0]; }
618 int32_t divisor() const { return divisor_; }
620 DECLARE_CONCRETE_INSTRUCTION(ModByPowerOf2I, "mod-by-power-of-2-i")
621 DECLARE_HYDROGEN_ACCESSOR(Mod)
628 class LModByConstI V8_FINAL : public LTemplateInstruction<1, 1, 2> {
630 LModByConstI(LOperand* dividend,
634 inputs_[0] = dividend;
640 LOperand* dividend() { return inputs_[0]; }
641 int32_t divisor() const { return divisor_; }
642 LOperand* temp1() { return temps_[0]; }
643 LOperand* temp2() { return temps_[1]; }
645 DECLARE_CONCRETE_INSTRUCTION(ModByConstI, "mod-by-const-i")
646 DECLARE_HYDROGEN_ACCESSOR(Mod)
653 class LModI V8_FINAL : public LTemplateInstruction<1, 2, 1> {
655 LModI(LOperand* left, LOperand* right, LOperand* temp) {
661 LOperand* left() { return inputs_[0]; }
662 LOperand* right() { return inputs_[1]; }
663 LOperand* temp() { return temps_[0]; }
665 DECLARE_CONCRETE_INSTRUCTION(ModI, "mod-i")
666 DECLARE_HYDROGEN_ACCESSOR(Mod)
670 class LDivByPowerOf2I V8_FINAL : public LTemplateInstruction<1, 1, 0> {
672 LDivByPowerOf2I(LOperand* dividend, int32_t divisor) {
673 inputs_[0] = dividend;
677 LOperand* dividend() { return inputs_[0]; }
678 int32_t divisor() const { return divisor_; }
680 DECLARE_CONCRETE_INSTRUCTION(DivByPowerOf2I, "div-by-power-of-2-i")
681 DECLARE_HYDROGEN_ACCESSOR(Div)
688 class LDivByConstI V8_FINAL : public LTemplateInstruction<1, 1, 2> {
690 LDivByConstI(LOperand* dividend,
694 inputs_[0] = dividend;
700 LOperand* dividend() { return inputs_[0]; }
701 int32_t divisor() const { return divisor_; }
702 LOperand* temp1() { return temps_[0]; }
703 LOperand* temp2() { return temps_[1]; }
705 DECLARE_CONCRETE_INSTRUCTION(DivByConstI, "div-by-const-i")
706 DECLARE_HYDROGEN_ACCESSOR(Div)
713 class LDivI V8_FINAL : public LTemplateInstruction<1, 2, 1> {
715 LDivI(LOperand* dividend, LOperand* divisor, LOperand* temp) {
716 inputs_[0] = dividend;
717 inputs_[1] = divisor;
721 LOperand* dividend() { return inputs_[0]; }
722 LOperand* divisor() { return inputs_[1]; }
723 LOperand* temp() { return temps_[0]; }
725 DECLARE_CONCRETE_INSTRUCTION(DivI, "div-i")
726 DECLARE_HYDROGEN_ACCESSOR(BinaryOperation)
730 class LFlooringDivByPowerOf2I V8_FINAL : public LTemplateInstruction<1, 1, 0> {
732 LFlooringDivByPowerOf2I(LOperand* dividend, int32_t divisor) {
733 inputs_[0] = dividend;
737 LOperand* dividend() { return inputs_[0]; }
738 int32_t divisor() const { return divisor_; }
740 DECLARE_CONCRETE_INSTRUCTION(FlooringDivByPowerOf2I,
741 "flooring-div-by-power-of-2-i")
742 DECLARE_HYDROGEN_ACCESSOR(MathFloorOfDiv)
749 class LFlooringDivByConstI V8_FINAL : public LTemplateInstruction<1, 1, 3> {
751 LFlooringDivByConstI(LOperand* dividend,
756 inputs_[0] = dividend;
763 LOperand* dividend() { return inputs_[0]; }
764 int32_t divisor() const { return divisor_; }
765 LOperand* temp1() { return temps_[0]; }
766 LOperand* temp2() { return temps_[1]; }
767 LOperand* temp3() { return temps_[2]; }
769 DECLARE_CONCRETE_INSTRUCTION(FlooringDivByConstI, "flooring-div-by-const-i")
770 DECLARE_HYDROGEN_ACCESSOR(MathFloorOfDiv)
777 class LFlooringDivI V8_FINAL : public LTemplateInstruction<1, 2, 1> {
779 LFlooringDivI(LOperand* dividend, LOperand* divisor, LOperand* temp) {
780 inputs_[0] = dividend;
781 inputs_[1] = divisor;
785 LOperand* dividend() { return inputs_[0]; }
786 LOperand* divisor() { return inputs_[1]; }
787 LOperand* temp() { return temps_[0]; }
789 DECLARE_CONCRETE_INSTRUCTION(FlooringDivI, "flooring-div-i")
790 DECLARE_HYDROGEN_ACCESSOR(MathFloorOfDiv)
794 class LMulI V8_FINAL : public LTemplateInstruction<1, 2, 0> {
796 LMulI(LOperand* left, LOperand* right) {
801 LOperand* left() { return inputs_[0]; }
802 LOperand* right() { return inputs_[1]; }
804 DECLARE_CONCRETE_INSTRUCTION(MulI, "mul-i")
805 DECLARE_HYDROGEN_ACCESSOR(Mul)
809 class LCompareNumericAndBranch V8_FINAL : public LControlInstruction<2, 0> {
811 LCompareNumericAndBranch(LOperand* left, LOperand* right) {
816 LOperand* left() { return inputs_[0]; }
817 LOperand* right() { return inputs_[1]; }
819 DECLARE_CONCRETE_INSTRUCTION(CompareNumericAndBranch,
820 "compare-numeric-and-branch")
821 DECLARE_HYDROGEN_ACCESSOR(CompareNumericAndBranch)
823 Token::Value op() const { return hydrogen()->token(); }
824 bool is_double() const {
825 return hydrogen()->representation().IsDouble();
828 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
832 class LMathFloor V8_FINAL : public LTemplateInstruction<1, 1, 0> {
834 explicit LMathFloor(LOperand* value) {
838 LOperand* value() { return inputs_[0]; }
840 DECLARE_CONCRETE_INSTRUCTION(MathFloor, "math-floor")
841 DECLARE_HYDROGEN_ACCESSOR(UnaryMathOperation)
845 class LMathRound V8_FINAL : public LTemplateInstruction<1, 1, 1> {
847 explicit LMathRound(LOperand* value, LOperand* temp) {
852 LOperand* value() { return inputs_[0]; }
853 LOperand* temp() { return temps_[0]; }
855 DECLARE_CONCRETE_INSTRUCTION(MathRound, "math-round")
856 DECLARE_HYDROGEN_ACCESSOR(UnaryMathOperation)
860 class LMathAbs V8_FINAL : public LTemplateInstruction<1, 2, 0> {
862 explicit LMathAbs(LOperand* context, LOperand* value) {
863 inputs_[1] = context;
867 LOperand* context() { return inputs_[1]; }
868 LOperand* value() { return inputs_[0]; }
870 DECLARE_CONCRETE_INSTRUCTION(MathAbs, "math-abs")
871 DECLARE_HYDROGEN_ACCESSOR(UnaryMathOperation)
875 class LMathLog V8_FINAL : public LTemplateInstruction<1, 1, 0> {
877 explicit LMathLog(LOperand* value) {
881 LOperand* value() { return inputs_[0]; }
883 DECLARE_CONCRETE_INSTRUCTION(MathLog, "math-log")
887 class LMathClz32 V8_FINAL : public LTemplateInstruction<1, 1, 0> {
889 explicit LMathClz32(LOperand* value) {
893 LOperand* value() { return inputs_[0]; }
895 DECLARE_CONCRETE_INSTRUCTION(MathClz32, "math-clz32")
899 class LMathExp V8_FINAL : public LTemplateInstruction<1, 1, 2> {
901 LMathExp(LOperand* value, LOperand* temp1, LOperand* temp2) {
905 ExternalReference::InitializeMathExpData();
908 LOperand* value() { return inputs_[0]; }
909 LOperand* temp1() { return temps_[0]; }
910 LOperand* temp2() { return temps_[1]; }
912 DECLARE_CONCRETE_INSTRUCTION(MathExp, "math-exp")
916 class LMathSqrt V8_FINAL : public LTemplateInstruction<1, 1, 0> {
918 explicit LMathSqrt(LOperand* value) {
922 LOperand* value() { return inputs_[0]; }
924 DECLARE_CONCRETE_INSTRUCTION(MathSqrt, "math-sqrt")
928 class LMathPowHalf V8_FINAL : public LTemplateInstruction<1, 1, 0> {
930 explicit LMathPowHalf(LOperand* value) {
934 LOperand* value() { return inputs_[0]; }
936 DECLARE_CONCRETE_INSTRUCTION(MathPowHalf, "math-pow-half")
940 class LCmpObjectEqAndBranch V8_FINAL : public LControlInstruction<2, 0> {
942 LCmpObjectEqAndBranch(LOperand* left, LOperand* right) {
947 LOperand* left() { return inputs_[0]; }
948 LOperand* right() { return inputs_[1]; }
950 DECLARE_CONCRETE_INSTRUCTION(CmpObjectEqAndBranch, "cmp-object-eq-and-branch")
954 class LCmpHoleAndBranch V8_FINAL : public LControlInstruction<1, 0> {
956 explicit LCmpHoleAndBranch(LOperand* object) {
960 LOperand* object() { return inputs_[0]; }
962 DECLARE_CONCRETE_INSTRUCTION(CmpHoleAndBranch, "cmp-hole-and-branch")
963 DECLARE_HYDROGEN_ACCESSOR(CompareHoleAndBranch)
967 class LCompareMinusZeroAndBranch V8_FINAL : public LControlInstruction<1, 0> {
969 explicit LCompareMinusZeroAndBranch(LOperand* value) {
973 LOperand* value() { return inputs_[0]; }
975 DECLARE_CONCRETE_INSTRUCTION(CompareMinusZeroAndBranch,
976 "cmp-minus-zero-and-branch")
977 DECLARE_HYDROGEN_ACCESSOR(CompareMinusZeroAndBranch)
982 class LIsObjectAndBranch V8_FINAL : public LControlInstruction<1, 0> {
984 explicit LIsObjectAndBranch(LOperand* value) {
988 LOperand* value() { return inputs_[0]; }
990 DECLARE_CONCRETE_INSTRUCTION(IsObjectAndBranch, "is-object-and-branch")
991 DECLARE_HYDROGEN_ACCESSOR(IsObjectAndBranch)
993 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
997 class LIsStringAndBranch V8_FINAL : public LControlInstruction<1, 1> {
999 explicit LIsStringAndBranch(LOperand* value, LOperand* temp) {
1004 LOperand* value() { return inputs_[0]; }
1005 LOperand* temp() { return temps_[0]; }
1007 DECLARE_CONCRETE_INSTRUCTION(IsStringAndBranch, "is-string-and-branch")
1008 DECLARE_HYDROGEN_ACCESSOR(IsStringAndBranch)
1010 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1014 class LIsSmiAndBranch V8_FINAL : public LControlInstruction<1, 0> {
1016 explicit LIsSmiAndBranch(LOperand* value) {
1020 LOperand* value() { return inputs_[0]; }
1022 DECLARE_CONCRETE_INSTRUCTION(IsSmiAndBranch, "is-smi-and-branch")
1023 DECLARE_HYDROGEN_ACCESSOR(IsSmiAndBranch)
1025 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1029 class LIsUndetectableAndBranch V8_FINAL : public LControlInstruction<1, 1> {
1031 explicit LIsUndetectableAndBranch(LOperand* value, LOperand* temp) {
1036 LOperand* value() { return inputs_[0]; }
1037 LOperand* temp() { return temps_[0]; }
1039 DECLARE_CONCRETE_INSTRUCTION(IsUndetectableAndBranch,
1040 "is-undetectable-and-branch")
1041 DECLARE_HYDROGEN_ACCESSOR(IsUndetectableAndBranch)
1043 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1047 class LStringCompareAndBranch V8_FINAL : public LControlInstruction<3, 0> {
1049 explicit LStringCompareAndBranch(LOperand* context,
1052 inputs_[0] = context;
1057 LOperand* context() { return inputs_[0]; }
1058 LOperand* left() { return inputs_[1]; }
1059 LOperand* right() { return inputs_[2]; }
1061 DECLARE_CONCRETE_INSTRUCTION(StringCompareAndBranch,
1062 "string-compare-and-branch")
1063 DECLARE_HYDROGEN_ACCESSOR(StringCompareAndBranch)
1065 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1067 Token::Value op() const { return hydrogen()->token(); }
1071 class LHasInstanceTypeAndBranch V8_FINAL : public LControlInstruction<1, 0> {
1073 explicit LHasInstanceTypeAndBranch(LOperand* value) {
1077 LOperand* value() { return inputs_[0]; }
1079 DECLARE_CONCRETE_INSTRUCTION(HasInstanceTypeAndBranch,
1080 "has-instance-type-and-branch")
1081 DECLARE_HYDROGEN_ACCESSOR(HasInstanceTypeAndBranch)
1083 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1087 class LGetCachedArrayIndex V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1089 explicit LGetCachedArrayIndex(LOperand* value) {
1093 LOperand* value() { return inputs_[0]; }
1095 DECLARE_CONCRETE_INSTRUCTION(GetCachedArrayIndex, "get-cached-array-index")
1096 DECLARE_HYDROGEN_ACCESSOR(GetCachedArrayIndex)
1100 class LHasCachedArrayIndexAndBranch V8_FINAL
1101 : public LControlInstruction<1, 0> {
1103 explicit LHasCachedArrayIndexAndBranch(LOperand* value) {
1107 LOperand* value() { return inputs_[0]; }
1109 DECLARE_CONCRETE_INSTRUCTION(HasCachedArrayIndexAndBranch,
1110 "has-cached-array-index-and-branch")
1111 DECLARE_HYDROGEN_ACCESSOR(HasCachedArrayIndexAndBranch)
1113 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1117 class LClassOfTestAndBranch V8_FINAL : public LControlInstruction<1, 2> {
1119 LClassOfTestAndBranch(LOperand* value, LOperand* temp, LOperand* temp2) {
1125 LOperand* value() { return inputs_[0]; }
1126 LOperand* temp() { return temps_[0]; }
1127 LOperand* temp2() { return temps_[1]; }
1129 DECLARE_CONCRETE_INSTRUCTION(ClassOfTestAndBranch,
1130 "class-of-test-and-branch")
1131 DECLARE_HYDROGEN_ACCESSOR(ClassOfTestAndBranch)
1133 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1137 class LCmpT V8_FINAL : public LTemplateInstruction<1, 3, 0> {
1139 LCmpT(LOperand* context, LOperand* left, LOperand* right) {
1140 inputs_[0] = context;
1145 LOperand* context() { return inputs_[0]; }
1146 LOperand* left() { return inputs_[1]; }
1147 LOperand* right() { return inputs_[2]; }
1149 DECLARE_CONCRETE_INSTRUCTION(CmpT, "cmp-t")
1150 DECLARE_HYDROGEN_ACCESSOR(CompareGeneric)
1152 Token::Value op() const { return hydrogen()->token(); }
1156 class LInstanceOf V8_FINAL : public LTemplateInstruction<1, 3, 0> {
1158 LInstanceOf(LOperand* context, LOperand* left, LOperand* right) {
1159 inputs_[0] = context;
1164 LOperand* context() { return inputs_[0]; }
1165 LOperand* left() { return inputs_[1]; }
1166 LOperand* right() { return inputs_[2]; }
1168 DECLARE_CONCRETE_INSTRUCTION(InstanceOf, "instance-of")
1172 class LInstanceOfKnownGlobal V8_FINAL : public LTemplateInstruction<1, 2, 1> {
1174 LInstanceOfKnownGlobal(LOperand* context, LOperand* value, LOperand* temp) {
1175 inputs_[0] = context;
1180 LOperand* context() { return inputs_[0]; }
1181 LOperand* value() { return inputs_[1]; }
1182 LOperand* temp() { return temps_[0]; }
1184 DECLARE_CONCRETE_INSTRUCTION(InstanceOfKnownGlobal,
1185 "instance-of-known-global")
1186 DECLARE_HYDROGEN_ACCESSOR(InstanceOfKnownGlobal)
1188 Handle<JSFunction> function() const { return hydrogen()->function(); }
1189 LEnvironment* GetDeferredLazyDeoptimizationEnvironment() {
1190 return lazy_deopt_env_;
1192 virtual void SetDeferredLazyDeoptimizationEnvironment(
1193 LEnvironment* env) V8_OVERRIDE {
1194 lazy_deopt_env_ = env;
1198 LEnvironment* lazy_deopt_env_;
1202 class LBoundsCheck V8_FINAL : public LTemplateInstruction<0, 2, 0> {
1204 LBoundsCheck(LOperand* index, LOperand* length) {
1206 inputs_[1] = length;
1209 LOperand* index() { return inputs_[0]; }
1210 LOperand* length() { return inputs_[1]; }
1212 DECLARE_CONCRETE_INSTRUCTION(BoundsCheck, "bounds-check")
1213 DECLARE_HYDROGEN_ACCESSOR(BoundsCheck)
1217 class LBitI V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1219 LBitI(LOperand* left, LOperand* right) {
1224 LOperand* left() { return inputs_[0]; }
1225 LOperand* right() { return inputs_[1]; }
1227 Token::Value op() const { return hydrogen()->op(); }
1228 bool IsInteger32() const {
1229 return hydrogen()->representation().IsInteger32();
1232 DECLARE_CONCRETE_INSTRUCTION(BitI, "bit-i")
1233 DECLARE_HYDROGEN_ACCESSOR(Bitwise)
1237 class LShiftI V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1239 LShiftI(Token::Value op, LOperand* left, LOperand* right, bool can_deopt)
1240 : op_(op), can_deopt_(can_deopt) {
1245 Token::Value op() const { return op_; }
1246 LOperand* left() { return inputs_[0]; }
1247 LOperand* right() { return inputs_[1]; }
1248 bool can_deopt() const { return can_deopt_; }
1250 DECLARE_CONCRETE_INSTRUCTION(ShiftI, "shift-i")
1258 class LSubI V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1260 LSubI(LOperand* left, LOperand* right) {
1265 LOperand* left() { return inputs_[0]; }
1266 LOperand* right() { return inputs_[1]; }
1268 DECLARE_CONCRETE_INSTRUCTION(SubI, "sub-i")
1269 DECLARE_HYDROGEN_ACCESSOR(Sub)
1273 class LConstantI V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1275 DECLARE_CONCRETE_INSTRUCTION(ConstantI, "constant-i")
1276 DECLARE_HYDROGEN_ACCESSOR(Constant)
1278 int32_t value() const { return hydrogen()->Integer32Value(); }
1282 class LConstantS V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1284 DECLARE_CONCRETE_INSTRUCTION(ConstantS, "constant-s")
1285 DECLARE_HYDROGEN_ACCESSOR(Constant)
1287 Smi* value() const { return Smi::FromInt(hydrogen()->Integer32Value()); }
1291 class LConstantD V8_FINAL : public LTemplateInstruction<1, 0, 1> {
1293 explicit LConstantD(LOperand* temp) {
1297 LOperand* temp() { return temps_[0]; }
1299 DECLARE_CONCRETE_INSTRUCTION(ConstantD, "constant-d")
1300 DECLARE_HYDROGEN_ACCESSOR(Constant)
1302 double value() const { return hydrogen()->DoubleValue(); }
1306 class LConstantE V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1308 DECLARE_CONCRETE_INSTRUCTION(ConstantE, "constant-e")
1309 DECLARE_HYDROGEN_ACCESSOR(Constant)
1311 ExternalReference value() const {
1312 return hydrogen()->ExternalReferenceValue();
1317 class LConstantT V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1319 DECLARE_CONCRETE_INSTRUCTION(ConstantT, "constant-t")
1320 DECLARE_HYDROGEN_ACCESSOR(Constant)
1322 Handle<Object> value(Isolate* isolate) const {
1323 return hydrogen()->handle(isolate);
1328 class LBranch V8_FINAL : public LControlInstruction<1, 0> {
1330 explicit LBranch(LOperand* value) {
1334 LOperand* value() { return inputs_[0]; }
1336 DECLARE_CONCRETE_INSTRUCTION(Branch, "branch")
1337 DECLARE_HYDROGEN_ACCESSOR(Branch)
1339 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1343 class LDebugBreak V8_FINAL : public LTemplateInstruction<0, 0, 0> {
1345 DECLARE_CONCRETE_INSTRUCTION(DebugBreak, "break")
1349 class LCmpMapAndBranch V8_FINAL : public LControlInstruction<1, 0> {
1351 explicit LCmpMapAndBranch(LOperand* value) {
1355 LOperand* value() { return inputs_[0]; }
1357 DECLARE_CONCRETE_INSTRUCTION(CmpMapAndBranch, "cmp-map-and-branch")
1358 DECLARE_HYDROGEN_ACCESSOR(CompareMap)
1360 Handle<Map> map() const { return hydrogen()->map().handle(); }
1364 class LMapEnumLength V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1366 explicit LMapEnumLength(LOperand* value) {
1370 LOperand* value() { return inputs_[0]; }
1372 DECLARE_CONCRETE_INSTRUCTION(MapEnumLength, "map-enum-length")
1376 class LDateField V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1378 LDateField(LOperand* date, Smi* index) : index_(index) {
1382 LOperand* date() { return inputs_[0]; }
1383 Smi* index() const { return index_; }
1385 DECLARE_CONCRETE_INSTRUCTION(DateField, "date-field")
1386 DECLARE_HYDROGEN_ACCESSOR(DateField)
1393 class LSeqStringGetChar V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1395 LSeqStringGetChar(LOperand* string, LOperand* index) {
1396 inputs_[0] = string;
1400 LOperand* string() const { return inputs_[0]; }
1401 LOperand* index() const { return inputs_[1]; }
1403 DECLARE_CONCRETE_INSTRUCTION(SeqStringGetChar, "seq-string-get-char")
1404 DECLARE_HYDROGEN_ACCESSOR(SeqStringGetChar)
1408 class LSeqStringSetChar V8_FINAL : public LTemplateInstruction<1, 4, 0> {
1410 LSeqStringSetChar(LOperand* context,
1414 inputs_[0] = context;
1415 inputs_[1] = string;
1420 LOperand* string() { return inputs_[1]; }
1421 LOperand* index() { return inputs_[2]; }
1422 LOperand* value() { return inputs_[3]; }
1424 DECLARE_CONCRETE_INSTRUCTION(SeqStringSetChar, "seq-string-set-char")
1425 DECLARE_HYDROGEN_ACCESSOR(SeqStringSetChar)
1429 class LAddI V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1431 LAddI(LOperand* left, LOperand* right) {
1436 LOperand* left() { return inputs_[0]; }
1437 LOperand* right() { return inputs_[1]; }
1439 static bool UseLea(HAdd* add) {
1440 return !add->CheckFlag(HValue::kCanOverflow) &&
1441 add->BetterLeftOperand()->UseCount() > 1;
1444 DECLARE_CONCRETE_INSTRUCTION(AddI, "add-i")
1445 DECLARE_HYDROGEN_ACCESSOR(Add)
1449 class LMathMinMax V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1451 LMathMinMax(LOperand* left, LOperand* right) {
1456 LOperand* left() { return inputs_[0]; }
1457 LOperand* right() { return inputs_[1]; }
1459 DECLARE_CONCRETE_INSTRUCTION(MathMinMax, "math-min-max")
1460 DECLARE_HYDROGEN_ACCESSOR(MathMinMax)
1464 class LPower V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1466 LPower(LOperand* left, LOperand* right) {
1471 LOperand* left() { return inputs_[0]; }
1472 LOperand* right() { return inputs_[1]; }
1474 DECLARE_CONCRETE_INSTRUCTION(Power, "power")
1475 DECLARE_HYDROGEN_ACCESSOR(Power)
1479 class LArithmeticD V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1481 LArithmeticD(Token::Value op, LOperand* left, LOperand* right)
1487 Token::Value op() const { return op_; }
1488 LOperand* left() { return inputs_[0]; }
1489 LOperand* right() { return inputs_[1]; }
1491 virtual Opcode opcode() const V8_OVERRIDE {
1492 return LInstruction::kArithmeticD;
1494 virtual void CompileToNative(LCodeGen* generator) V8_OVERRIDE;
1495 virtual const char* Mnemonic() const V8_OVERRIDE;
1502 class LArithmeticT V8_FINAL : public LTemplateInstruction<1, 3, 0> {
1504 LArithmeticT(Token::Value op,
1509 inputs_[0] = context;
1514 Token::Value op() const { return op_; }
1515 LOperand* context() { return inputs_[0]; }
1516 LOperand* left() { return inputs_[1]; }
1517 LOperand* right() { return inputs_[2]; }
1519 virtual Opcode opcode() const V8_OVERRIDE {
1520 return LInstruction::kArithmeticT;
1522 virtual void CompileToNative(LCodeGen* generator) V8_OVERRIDE;
1523 virtual const char* Mnemonic() const V8_OVERRIDE;
1530 class LReturn V8_FINAL : public LTemplateInstruction<0, 3, 0> {
1532 explicit LReturn(LOperand* value,
1534 LOperand* parameter_count) {
1536 inputs_[1] = context;
1537 inputs_[2] = parameter_count;
1540 LOperand* value() { return inputs_[0]; }
1541 LOperand* context() { return inputs_[1]; }
1543 bool has_constant_parameter_count() {
1544 return parameter_count()->IsConstantOperand();
1546 LConstantOperand* constant_parameter_count() {
1547 ASSERT(has_constant_parameter_count());
1548 return LConstantOperand::cast(parameter_count());
1550 LOperand* parameter_count() { return inputs_[2]; }
1552 DECLARE_CONCRETE_INSTRUCTION(Return, "return")
1553 DECLARE_HYDROGEN_ACCESSOR(Return)
1557 class LLoadNamedField V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1559 explicit LLoadNamedField(LOperand* object) {
1560 inputs_[0] = object;
1563 LOperand* object() { return inputs_[0]; }
1565 DECLARE_CONCRETE_INSTRUCTION(LoadNamedField, "load-named-field")
1566 DECLARE_HYDROGEN_ACCESSOR(LoadNamedField)
1570 class LLoadNamedGeneric V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1572 explicit LLoadNamedGeneric(LOperand* context, LOperand* object) {
1573 inputs_[0] = context;
1574 inputs_[1] = object;
1577 DECLARE_CONCRETE_INSTRUCTION(LoadNamedGeneric, "load-named-generic")
1578 DECLARE_HYDROGEN_ACCESSOR(LoadNamedGeneric)
1580 LOperand* context() { return inputs_[0]; }
1581 LOperand* object() { return inputs_[1]; }
1582 Handle<Object> name() const { return hydrogen()->name(); }
1586 class LLoadFunctionPrototype V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1588 explicit LLoadFunctionPrototype(LOperand* function) {
1589 inputs_[0] = function;
1592 DECLARE_CONCRETE_INSTRUCTION(LoadFunctionPrototype, "load-function-prototype")
1593 DECLARE_HYDROGEN_ACCESSOR(LoadFunctionPrototype)
1595 LOperand* function() { return inputs_[0]; }
1599 class LLoadRoot V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1601 DECLARE_CONCRETE_INSTRUCTION(LoadRoot, "load-root")
1602 DECLARE_HYDROGEN_ACCESSOR(LoadRoot)
1604 Heap::RootListIndex index() const { return hydrogen()->index(); }
1608 class LLoadKeyed V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1610 LLoadKeyed(LOperand* elements, LOperand* key) {
1611 inputs_[0] = elements;
1615 DECLARE_CONCRETE_INSTRUCTION(LoadKeyed, "load-keyed")
1616 DECLARE_HYDROGEN_ACCESSOR(LoadKeyed)
1618 bool is_external() const {
1619 return hydrogen()->is_external();
1621 bool is_fixed_typed_array() const {
1622 return hydrogen()->is_fixed_typed_array();
1624 bool is_typed_elements() const {
1625 return is_external() || is_fixed_typed_array();
1627 LOperand* elements() { return inputs_[0]; }
1628 LOperand* key() { return inputs_[1]; }
1629 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1630 uint32_t additional_index() const { return hydrogen()->index_offset(); }
1631 ElementsKind elements_kind() const {
1632 return hydrogen()->elements_kind();
1637 class LLoadKeyedGeneric V8_FINAL : public LTemplateInstruction<1, 3, 0> {
1639 LLoadKeyedGeneric(LOperand* context, LOperand* obj, LOperand* key) {
1640 inputs_[0] = context;
1645 DECLARE_CONCRETE_INSTRUCTION(LoadKeyedGeneric, "load-keyed-generic")
1647 LOperand* context() { return inputs_[0]; }
1648 LOperand* object() { return inputs_[1]; }
1649 LOperand* key() { return inputs_[2]; }
1653 class LLoadGlobalCell V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1655 DECLARE_CONCRETE_INSTRUCTION(LoadGlobalCell, "load-global-cell")
1656 DECLARE_HYDROGEN_ACCESSOR(LoadGlobalCell)
1660 class LLoadGlobalGeneric V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1662 explicit LLoadGlobalGeneric(LOperand* context, LOperand* global_object) {
1663 inputs_[0] = context;
1664 inputs_[1] = global_object;
1667 DECLARE_CONCRETE_INSTRUCTION(LoadGlobalGeneric, "load-global-generic")
1668 DECLARE_HYDROGEN_ACCESSOR(LoadGlobalGeneric)
1670 LOperand* context() { return inputs_[0]; }
1671 LOperand* global_object() { return inputs_[1]; }
1672 Handle<Object> name() const { return hydrogen()->name(); }
1673 bool for_typeof() const { return hydrogen()->for_typeof(); }
1677 class LStoreGlobalCell V8_FINAL : public LTemplateInstruction<0, 1, 1> {
1679 explicit LStoreGlobalCell(LOperand* value, LOperand* temp) {
1684 LOperand* value() { return inputs_[0]; }
1685 LOperand* temp() { return temps_[0]; }
1687 DECLARE_CONCRETE_INSTRUCTION(StoreGlobalCell, "store-global-cell")
1688 DECLARE_HYDROGEN_ACCESSOR(StoreGlobalCell)
1692 class LLoadContextSlot V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1694 explicit LLoadContextSlot(LOperand* context) {
1695 inputs_[0] = context;
1698 LOperand* context() { return inputs_[0]; }
1700 DECLARE_CONCRETE_INSTRUCTION(LoadContextSlot, "load-context-slot")
1701 DECLARE_HYDROGEN_ACCESSOR(LoadContextSlot)
1703 int slot_index() { return hydrogen()->slot_index(); }
1705 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1709 class LStoreContextSlot V8_FINAL : public LTemplateInstruction<0, 2, 1> {
1711 LStoreContextSlot(LOperand* context, LOperand* value, LOperand* temp) {
1712 inputs_[0] = context;
1717 LOperand* context() { return inputs_[0]; }
1718 LOperand* value() { return inputs_[1]; }
1719 LOperand* temp() { return temps_[0]; }
1721 DECLARE_CONCRETE_INSTRUCTION(StoreContextSlot, "store-context-slot")
1722 DECLARE_HYDROGEN_ACCESSOR(StoreContextSlot)
1724 int slot_index() { return hydrogen()->slot_index(); }
1726 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1730 class LPushArgument V8_FINAL : public LTemplateInstruction<0, 1, 0> {
1732 explicit LPushArgument(LOperand* value) {
1736 LOperand* value() { return inputs_[0]; }
1738 DECLARE_CONCRETE_INSTRUCTION(PushArgument, "push-argument")
1742 class LDrop V8_FINAL : public LTemplateInstruction<0, 0, 0> {
1744 explicit LDrop(int count) : count_(count) { }
1746 int count() const { return count_; }
1748 DECLARE_CONCRETE_INSTRUCTION(Drop, "drop")
1755 class LStoreCodeEntry V8_FINAL: public LTemplateInstruction<0, 1, 1> {
1757 LStoreCodeEntry(LOperand* function, LOperand* code_object) {
1758 inputs_[0] = function;
1759 temps_[0] = code_object;
1762 LOperand* function() { return inputs_[0]; }
1763 LOperand* code_object() { return temps_[0]; }
1765 virtual void PrintDataTo(StringStream* stream);
1767 DECLARE_CONCRETE_INSTRUCTION(StoreCodeEntry, "store-code-entry")
1768 DECLARE_HYDROGEN_ACCESSOR(StoreCodeEntry)
1772 class LInnerAllocatedObject V8_FINAL: public LTemplateInstruction<1, 2, 0> {
1774 LInnerAllocatedObject(LOperand* base_object, LOperand* offset) {
1775 inputs_[0] = base_object;
1776 inputs_[1] = offset;
1779 LOperand* base_object() const { return inputs_[0]; }
1780 LOperand* offset() const { return inputs_[1]; }
1782 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1784 DECLARE_CONCRETE_INSTRUCTION(InnerAllocatedObject, "inner-allocated-object")
1788 class LThisFunction V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1790 DECLARE_CONCRETE_INSTRUCTION(ThisFunction, "this-function")
1791 DECLARE_HYDROGEN_ACCESSOR(ThisFunction)
1795 class LContext V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1797 DECLARE_CONCRETE_INSTRUCTION(Context, "context")
1798 DECLARE_HYDROGEN_ACCESSOR(Context)
1802 class LDeclareGlobals V8_FINAL : public LTemplateInstruction<0, 1, 0> {
1804 explicit LDeclareGlobals(LOperand* context) {
1805 inputs_[0] = context;
1808 LOperand* context() { return inputs_[0]; }
1810 DECLARE_CONCRETE_INSTRUCTION(DeclareGlobals, "declare-globals")
1811 DECLARE_HYDROGEN_ACCESSOR(DeclareGlobals)
1815 class LCallJSFunction V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1817 explicit LCallJSFunction(LOperand* function) {
1818 inputs_[0] = function;
1821 LOperand* function() { return inputs_[0]; }
1823 DECLARE_CONCRETE_INSTRUCTION(CallJSFunction, "call-js-function")
1824 DECLARE_HYDROGEN_ACCESSOR(CallJSFunction)
1826 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1828 int arity() const { return hydrogen()->argument_count() - 1; }
1832 class LCallWithDescriptor V8_FINAL : public LTemplateResultInstruction<1> {
1834 LCallWithDescriptor(const CallInterfaceDescriptor* descriptor,
1835 ZoneList<LOperand*>& operands,
1837 : inputs_(descriptor->environment_length() + 1, zone) {
1838 ASSERT(descriptor->environment_length() + 1 == operands.length());
1839 inputs_.AddAll(operands, zone);
1842 LOperand* target() const { return inputs_[0]; }
1845 DECLARE_CONCRETE_INSTRUCTION(CallWithDescriptor, "call-with-descriptor")
1846 DECLARE_HYDROGEN_ACCESSOR(CallWithDescriptor)
1848 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1850 int arity() const { return hydrogen()->argument_count() - 1; }
1852 ZoneList<LOperand*> inputs_;
1854 // Iterator support.
1855 virtual int InputCount() V8_FINAL V8_OVERRIDE { return inputs_.length(); }
1856 virtual LOperand* InputAt(int i) V8_FINAL V8_OVERRIDE { return inputs_[i]; }
1858 virtual int TempCount() V8_FINAL V8_OVERRIDE { return 0; }
1859 virtual LOperand* TempAt(int i) V8_FINAL V8_OVERRIDE { return NULL; }
1863 class LInvokeFunction V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1865 LInvokeFunction(LOperand* context, LOperand* function) {
1866 inputs_[0] = context;
1867 inputs_[1] = function;
1870 LOperand* context() { return inputs_[0]; }
1871 LOperand* function() { return inputs_[1]; }
1873 DECLARE_CONCRETE_INSTRUCTION(InvokeFunction, "invoke-function")
1874 DECLARE_HYDROGEN_ACCESSOR(InvokeFunction)
1876 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1878 int arity() const { return hydrogen()->argument_count() - 1; }
1882 class LCallFunction V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1884 LCallFunction(LOperand* context, LOperand* function) {
1885 inputs_[0] = context;
1886 inputs_[1] = function;
1889 DECLARE_CONCRETE_INSTRUCTION(CallFunction, "call-function")
1890 DECLARE_HYDROGEN_ACCESSOR(CallFunction)
1892 LOperand* context() { return inputs_[0]; }
1893 LOperand* function() { return inputs_[1]; }
1894 int arity() const { return hydrogen()->argument_count() - 1; }
1898 class LCallNew V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1900 LCallNew(LOperand* context, LOperand* constructor) {
1901 inputs_[0] = context;
1902 inputs_[1] = constructor;
1905 LOperand* context() { return inputs_[0]; }
1906 LOperand* constructor() { return inputs_[1]; }
1908 DECLARE_CONCRETE_INSTRUCTION(CallNew, "call-new")
1909 DECLARE_HYDROGEN_ACCESSOR(CallNew)
1911 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1913 int arity() const { return hydrogen()->argument_count() - 1; }
1917 class LCallNewArray V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1919 LCallNewArray(LOperand* context, LOperand* constructor) {
1920 inputs_[0] = context;
1921 inputs_[1] = constructor;
1924 LOperand* context() { return inputs_[0]; }
1925 LOperand* constructor() { return inputs_[1]; }
1927 DECLARE_CONCRETE_INSTRUCTION(CallNewArray, "call-new-array")
1928 DECLARE_HYDROGEN_ACCESSOR(CallNewArray)
1930 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1932 int arity() const { return hydrogen()->argument_count() - 1; }
1936 class LCallRuntime V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1938 explicit LCallRuntime(LOperand* context) {
1939 inputs_[0] = context;
1942 LOperand* context() { return inputs_[0]; }
1944 DECLARE_CONCRETE_INSTRUCTION(CallRuntime, "call-runtime")
1945 DECLARE_HYDROGEN_ACCESSOR(CallRuntime)
1947 virtual bool ClobbersDoubleRegisters(Isolate* isolate) const V8_OVERRIDE {
1948 return save_doubles() == kDontSaveFPRegs;
1951 const Runtime::Function* function() const { return hydrogen()->function(); }
1952 int arity() const { return hydrogen()->argument_count(); }
1953 SaveFPRegsMode save_doubles() const { return hydrogen()->save_doubles(); }
1957 class LInteger32ToDouble V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1959 explicit LInteger32ToDouble(LOperand* value) {
1963 LOperand* value() { return inputs_[0]; }
1965 DECLARE_CONCRETE_INSTRUCTION(Integer32ToDouble, "int32-to-double")
1969 class LUint32ToDouble V8_FINAL : public LTemplateInstruction<1, 1, 1> {
1971 explicit LUint32ToDouble(LOperand* value, LOperand* temp) {
1976 LOperand* value() { return inputs_[0]; }
1977 LOperand* temp() { return temps_[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 Handle<Map> transition() const { return hydrogen()->transition_map(); }
2134 Representation representation() const {
2135 return hydrogen()->field_representation();
2140 class LStoreNamedGeneric V8_FINAL : public LTemplateInstruction<0, 3, 0> {
2142 LStoreNamedGeneric(LOperand* context, LOperand* object, LOperand* value) {
2143 inputs_[0] = context;
2144 inputs_[1] = object;
2148 LOperand* context() { return inputs_[0]; }
2149 LOperand* object() { return inputs_[1]; }
2150 LOperand* value() { return inputs_[2]; }
2152 DECLARE_CONCRETE_INSTRUCTION(StoreNamedGeneric, "store-named-generic")
2153 DECLARE_HYDROGEN_ACCESSOR(StoreNamedGeneric)
2155 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
2157 Handle<Object> name() const { return hydrogen()->name(); }
2158 StrictMode strict_mode() { return hydrogen()->strict_mode(); }
2162 class LStoreKeyed V8_FINAL : public LTemplateInstruction<0, 3, 0> {
2164 LStoreKeyed(LOperand* object, LOperand* key, LOperand* value) {
2165 inputs_[0] = object;
2170 bool is_external() const { return hydrogen()->is_external(); }
2171 bool is_fixed_typed_array() const {
2172 return hydrogen()->is_fixed_typed_array();
2174 bool is_typed_elements() const {
2175 return is_external() || is_fixed_typed_array();
2177 LOperand* elements() { return inputs_[0]; }
2178 LOperand* key() { return inputs_[1]; }
2179 LOperand* value() { return inputs_[2]; }
2180 ElementsKind elements_kind() const { return hydrogen()->elements_kind(); }
2182 DECLARE_CONCRETE_INSTRUCTION(StoreKeyed, "store-keyed")
2183 DECLARE_HYDROGEN_ACCESSOR(StoreKeyed)
2185 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
2186 bool NeedsCanonicalization() { return hydrogen()->NeedsCanonicalization(); }
2187 uint32_t additional_index() const { return hydrogen()->index_offset(); }
2191 class LStoreKeyedGeneric V8_FINAL : public LTemplateInstruction<0, 4, 0> {
2193 LStoreKeyedGeneric(LOperand* context,
2197 inputs_[0] = context;
2198 inputs_[1] = object;
2203 LOperand* context() { return inputs_[0]; }
2204 LOperand* object() { return inputs_[1]; }
2205 LOperand* key() { return inputs_[2]; }
2206 LOperand* value() { return inputs_[3]; }
2208 DECLARE_CONCRETE_INSTRUCTION(StoreKeyedGeneric, "store-keyed-generic")
2209 DECLARE_HYDROGEN_ACCESSOR(StoreKeyedGeneric)
2211 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
2213 StrictMode strict_mode() { return hydrogen()->strict_mode(); }
2217 class LTransitionElementsKind V8_FINAL : public LTemplateInstruction<0, 2, 2> {
2219 LTransitionElementsKind(LOperand* object,
2221 LOperand* new_map_temp,
2223 inputs_[0] = object;
2224 inputs_[1] = context;
2225 temps_[0] = new_map_temp;
2229 LOperand* object() { return inputs_[0]; }
2230 LOperand* context() { return inputs_[1]; }
2231 LOperand* new_map_temp() { return temps_[0]; }
2232 LOperand* temp() { return temps_[1]; }
2234 DECLARE_CONCRETE_INSTRUCTION(TransitionElementsKind,
2235 "transition-elements-kind")
2236 DECLARE_HYDROGEN_ACCESSOR(TransitionElementsKind)
2238 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
2240 Handle<Map> original_map() { return hydrogen()->original_map().handle(); }
2241 Handle<Map> transitioned_map() {
2242 return hydrogen()->transitioned_map().handle();
2244 ElementsKind from_kind() { return hydrogen()->from_kind(); }
2245 ElementsKind to_kind() { return hydrogen()->to_kind(); }
2249 class LTrapAllocationMemento V8_FINAL : public LTemplateInstruction<0, 1, 1> {
2251 LTrapAllocationMemento(LOperand* object,
2253 inputs_[0] = object;
2257 LOperand* object() { return inputs_[0]; }
2258 LOperand* temp() { return temps_[0]; }
2260 DECLARE_CONCRETE_INSTRUCTION(TrapAllocationMemento,
2261 "trap-allocation-memento")
2265 class LStringAdd V8_FINAL : public LTemplateInstruction<1, 3, 0> {
2267 LStringAdd(LOperand* context, LOperand* left, LOperand* right) {
2268 inputs_[0] = context;
2273 LOperand* context() { return inputs_[0]; }
2274 LOperand* left() { return inputs_[1]; }
2275 LOperand* right() { return inputs_[2]; }
2277 DECLARE_CONCRETE_INSTRUCTION(StringAdd, "string-add")
2278 DECLARE_HYDROGEN_ACCESSOR(StringAdd)
2282 class LStringCharCodeAt V8_FINAL : public LTemplateInstruction<1, 3, 0> {
2284 LStringCharCodeAt(LOperand* context, LOperand* string, LOperand* index) {
2285 inputs_[0] = context;
2286 inputs_[1] = string;
2290 LOperand* context() { return inputs_[0]; }
2291 LOperand* string() { return inputs_[1]; }
2292 LOperand* index() { return inputs_[2]; }
2294 DECLARE_CONCRETE_INSTRUCTION(StringCharCodeAt, "string-char-code-at")
2295 DECLARE_HYDROGEN_ACCESSOR(StringCharCodeAt)
2299 class LStringCharFromCode V8_FINAL : public LTemplateInstruction<1, 2, 0> {
2301 explicit LStringCharFromCode(LOperand* context, LOperand* char_code) {
2302 inputs_[0] = context;
2303 inputs_[1] = char_code;
2306 LOperand* context() { return inputs_[0]; }
2307 LOperand* char_code() { return inputs_[1]; }
2309 DECLARE_CONCRETE_INSTRUCTION(StringCharFromCode, "string-char-from-code")
2310 DECLARE_HYDROGEN_ACCESSOR(StringCharFromCode)
2314 class LCheckValue V8_FINAL : public LTemplateInstruction<0, 1, 0> {
2316 explicit LCheckValue(LOperand* value) {
2320 LOperand* value() { return inputs_[0]; }
2322 DECLARE_CONCRETE_INSTRUCTION(CheckValue, "check-value")
2323 DECLARE_HYDROGEN_ACCESSOR(CheckValue)
2327 class LCheckInstanceType V8_FINAL : public LTemplateInstruction<0, 1, 0> {
2329 explicit LCheckInstanceType(LOperand* value) {
2333 LOperand* value() { return inputs_[0]; }
2335 DECLARE_CONCRETE_INSTRUCTION(CheckInstanceType, "check-instance-type")
2336 DECLARE_HYDROGEN_ACCESSOR(CheckInstanceType)
2340 class LCheckMaps V8_FINAL : public LTemplateInstruction<0, 1, 0> {
2342 explicit LCheckMaps(LOperand* value) {
2346 LOperand* value() { return inputs_[0]; }
2348 DECLARE_CONCRETE_INSTRUCTION(CheckMaps, "check-maps")
2349 DECLARE_HYDROGEN_ACCESSOR(CheckMaps)
2353 class LCheckSmi V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2355 explicit LCheckSmi(LOperand* value) {
2359 LOperand* value() { return inputs_[0]; }
2361 DECLARE_CONCRETE_INSTRUCTION(CheckSmi, "check-smi")
2365 class LClampDToUint8 V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2367 explicit LClampDToUint8(LOperand* unclamped) {
2368 inputs_[0] = unclamped;
2371 LOperand* unclamped() { return inputs_[0]; }
2373 DECLARE_CONCRETE_INSTRUCTION(ClampDToUint8, "clamp-d-to-uint8")
2377 class LClampIToUint8 V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2379 explicit LClampIToUint8(LOperand* unclamped) {
2380 inputs_[0] = unclamped;
2383 LOperand* unclamped() { return inputs_[0]; }
2385 DECLARE_CONCRETE_INSTRUCTION(ClampIToUint8, "clamp-i-to-uint8")
2389 class LClampTToUint8 V8_FINAL : public LTemplateInstruction<1, 1, 1> {
2391 LClampTToUint8(LOperand* unclamped,
2392 LOperand* temp_xmm) {
2393 inputs_[0] = unclamped;
2394 temps_[0] = temp_xmm;
2397 LOperand* unclamped() { return inputs_[0]; }
2398 LOperand* temp_xmm() { return temps_[0]; }
2400 DECLARE_CONCRETE_INSTRUCTION(ClampTToUint8, "clamp-t-to-uint8")
2404 class LCheckNonSmi V8_FINAL : public LTemplateInstruction<0, 1, 0> {
2406 explicit LCheckNonSmi(LOperand* value) {
2410 LOperand* value() { return inputs_[0]; }
2412 DECLARE_CONCRETE_INSTRUCTION(CheckNonSmi, "check-non-smi")
2413 DECLARE_HYDROGEN_ACCESSOR(CheckHeapObject)
2417 class LDoubleBits V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2419 explicit LDoubleBits(LOperand* value) {
2423 LOperand* value() { return inputs_[0]; }
2425 DECLARE_CONCRETE_INSTRUCTION(DoubleBits, "double-bits")
2426 DECLARE_HYDROGEN_ACCESSOR(DoubleBits)
2430 class LConstructDouble V8_FINAL : public LTemplateInstruction<1, 2, 0> {
2432 LConstructDouble(LOperand* hi, LOperand* lo) {
2437 LOperand* hi() { return inputs_[0]; }
2438 LOperand* lo() { return inputs_[1]; }
2440 DECLARE_CONCRETE_INSTRUCTION(ConstructDouble, "construct-double")
2444 class LAllocate V8_FINAL : public LTemplateInstruction<1, 2, 1> {
2446 LAllocate(LOperand* context, LOperand* size, LOperand* temp) {
2447 inputs_[0] = context;
2452 LOperand* context() { return inputs_[0]; }
2453 LOperand* size() { return inputs_[1]; }
2454 LOperand* temp() { return temps_[0]; }
2456 DECLARE_CONCRETE_INSTRUCTION(Allocate, "allocate")
2457 DECLARE_HYDROGEN_ACCESSOR(Allocate)
2461 class LRegExpLiteral V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2463 explicit LRegExpLiteral(LOperand* context) {
2464 inputs_[0] = context;
2467 LOperand* context() { return inputs_[0]; }
2469 DECLARE_CONCRETE_INSTRUCTION(RegExpLiteral, "regexp-literal")
2470 DECLARE_HYDROGEN_ACCESSOR(RegExpLiteral)
2474 class LFunctionLiteral V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2476 explicit LFunctionLiteral(LOperand* context) {
2477 inputs_[0] = context;
2480 LOperand* context() { return inputs_[0]; }
2482 DECLARE_CONCRETE_INSTRUCTION(FunctionLiteral, "function-literal")
2483 DECLARE_HYDROGEN_ACCESSOR(FunctionLiteral)
2487 class LToFastProperties V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2489 explicit LToFastProperties(LOperand* value) {
2493 LOperand* value() { return inputs_[0]; }
2495 DECLARE_CONCRETE_INSTRUCTION(ToFastProperties, "to-fast-properties")
2496 DECLARE_HYDROGEN_ACCESSOR(ToFastProperties)
2500 class LTypeof V8_FINAL : public LTemplateInstruction<1, 2, 0> {
2502 LTypeof(LOperand* context, LOperand* value) {
2503 inputs_[0] = context;
2507 LOperand* context() { return inputs_[0]; }
2508 LOperand* value() { return inputs_[1]; }
2510 DECLARE_CONCRETE_INSTRUCTION(Typeof, "typeof")
2514 class LTypeofIsAndBranch V8_FINAL : public LControlInstruction<1, 0> {
2516 explicit LTypeofIsAndBranch(LOperand* value) {
2520 LOperand* value() { return inputs_[0]; }
2522 DECLARE_CONCRETE_INSTRUCTION(TypeofIsAndBranch, "typeof-is-and-branch")
2523 DECLARE_HYDROGEN_ACCESSOR(TypeofIsAndBranch)
2525 Handle<String> type_literal() { return hydrogen()->type_literal(); }
2527 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
2531 class LIsConstructCallAndBranch V8_FINAL : public LControlInstruction<0, 1> {
2533 explicit LIsConstructCallAndBranch(LOperand* temp) {
2537 LOperand* temp() { return temps_[0]; }
2539 DECLARE_CONCRETE_INSTRUCTION(IsConstructCallAndBranch,
2540 "is-construct-call-and-branch")
2541 DECLARE_HYDROGEN_ACCESSOR(IsConstructCallAndBranch)
2545 class LOsrEntry V8_FINAL : public LTemplateInstruction<0, 0, 0> {
2549 virtual bool HasInterestingComment(LCodeGen* gen) const V8_OVERRIDE {
2552 DECLARE_CONCRETE_INSTRUCTION(OsrEntry, "osr-entry")
2556 class LStackCheck V8_FINAL : public LTemplateInstruction<0, 1, 0> {
2558 explicit LStackCheck(LOperand* context) {
2559 inputs_[0] = context;
2562 LOperand* context() { return inputs_[0]; }
2564 DECLARE_CONCRETE_INSTRUCTION(StackCheck, "stack-check")
2565 DECLARE_HYDROGEN_ACCESSOR(StackCheck)
2567 Label* done_label() { return &done_label_; }
2574 class LForInPrepareMap V8_FINAL : public LTemplateInstruction<1, 2, 0> {
2576 LForInPrepareMap(LOperand* context, LOperand* object) {
2577 inputs_[0] = context;
2578 inputs_[1] = object;
2581 LOperand* context() { return inputs_[0]; }
2582 LOperand* object() { return inputs_[1]; }
2584 DECLARE_CONCRETE_INSTRUCTION(ForInPrepareMap, "for-in-prepare-map")
2588 class LForInCacheArray V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2590 explicit LForInCacheArray(LOperand* map) {
2594 LOperand* map() { return inputs_[0]; }
2596 DECLARE_CONCRETE_INSTRUCTION(ForInCacheArray, "for-in-cache-array")
2599 return HForInCacheArray::cast(this->hydrogen_value())->idx();
2604 class LCheckMapValue V8_FINAL : public LTemplateInstruction<0, 2, 0> {
2606 LCheckMapValue(LOperand* value, LOperand* map) {
2611 LOperand* value() { return inputs_[0]; }
2612 LOperand* map() { return inputs_[1]; }
2614 DECLARE_CONCRETE_INSTRUCTION(CheckMapValue, "check-map-value")
2618 class LLoadFieldByIndex V8_FINAL : public LTemplateInstruction<1, 2, 0> {
2620 LLoadFieldByIndex(LOperand* object, LOperand* index) {
2621 inputs_[0] = object;
2625 LOperand* object() { return inputs_[0]; }
2626 LOperand* index() { return inputs_[1]; }
2628 DECLARE_CONCRETE_INSTRUCTION(LoadFieldByIndex, "load-field-by-index")
2632 class LChunkBuilder;
2633 class LPlatformChunk V8_FINAL : public LChunk {
2635 LPlatformChunk(CompilationInfo* info, HGraph* graph)
2636 : LChunk(info, graph),
2637 dehoisted_key_ids_(graph->GetMaximumValueID(), graph->zone()) { }
2639 int GetNextSpillIndex(RegisterKind kind);
2640 LOperand* GetNextSpillSlot(RegisterKind kind);
2641 BitVector* GetDehoistedKeyIds() { return &dehoisted_key_ids_; }
2642 bool IsDehoistedKey(HValue* value) {
2643 return dehoisted_key_ids_.Contains(value->id());
2647 BitVector dehoisted_key_ids_;
2651 class LChunkBuilder V8_FINAL : public LChunkBuilderBase {
2653 LChunkBuilder(CompilationInfo* info, HGraph* graph, LAllocator* allocator)
2654 : LChunkBuilderBase(graph->zone()),
2659 current_instruction_(NULL),
2660 current_block_(NULL),
2662 allocator_(allocator) { }
2664 Isolate* isolate() const { return graph_->isolate(); }
2666 // Build the sequence for the graph.
2667 LPlatformChunk* Build();
2669 LInstruction* CheckElideControlInstruction(HControlInstruction* instr);
2671 // Declare methods that deal with the individual node types.
2672 #define DECLARE_DO(type) LInstruction* Do##type(H##type* node);
2673 HYDROGEN_CONCRETE_INSTRUCTION_LIST(DECLARE_DO)
2676 LInstruction* DoMathFloor(HUnaryMathOperation* instr);
2677 LInstruction* DoMathRound(HUnaryMathOperation* instr);
2678 LInstruction* DoMathAbs(HUnaryMathOperation* instr);
2679 LInstruction* DoMathLog(HUnaryMathOperation* instr);
2680 LInstruction* DoMathExp(HUnaryMathOperation* instr);
2681 LInstruction* DoMathSqrt(HUnaryMathOperation* instr);
2682 LInstruction* DoMathPowHalf(HUnaryMathOperation* instr);
2683 LInstruction* DoMathClz32(HUnaryMathOperation* instr);
2684 LInstruction* DoDivByPowerOf2I(HDiv* instr);
2685 LInstruction* DoDivByConstI(HDiv* instr);
2686 LInstruction* DoDivI(HDiv* instr);
2687 LInstruction* DoModByPowerOf2I(HMod* instr);
2688 LInstruction* DoModByConstI(HMod* instr);
2689 LInstruction* DoModI(HMod* instr);
2690 LInstruction* DoFlooringDivByPowerOf2I(HMathFloorOfDiv* instr);
2691 LInstruction* DoFlooringDivByConstI(HMathFloorOfDiv* instr);
2692 LInstruction* DoFlooringDivI(HMathFloorOfDiv* instr);
2702 LPlatformChunk* chunk() const { return chunk_; }
2703 CompilationInfo* info() const { return info_; }
2704 HGraph* graph() const { return graph_; }
2706 bool is_unused() const { return status_ == UNUSED; }
2707 bool is_building() const { return status_ == BUILDING; }
2708 bool is_done() const { return status_ == DONE; }
2709 bool is_aborted() const { return status_ == ABORTED; }
2711 void Abort(BailoutReason reason);
2713 // Methods for code dependencies.
2714 void AddDeprecationDependency(Handle<Map> map);
2716 // Methods for getting operands for Use / Define / Temp.
2717 LUnallocated* ToUnallocated(Register reg);
2718 LUnallocated* ToUnallocated(XMMRegister reg);
2720 // Methods for setting up define-use relationships.
2721 MUST_USE_RESULT LOperand* Use(HValue* value, LUnallocated* operand);
2722 MUST_USE_RESULT LOperand* UseFixed(HValue* value, Register fixed_register);
2723 MUST_USE_RESULT LOperand* UseFixedDouble(HValue* value,
2724 XMMRegister fixed_register);
2726 // A value that is guaranteed to be allocated to a register.
2727 // Operand created by UseRegister is guaranteed to be live until the end of
2728 // instruction. This means that register allocator will not reuse it's
2729 // register for any other operand inside instruction.
2730 // Operand created by UseRegisterAtStart is guaranteed to be live only at
2731 // instruction start. Register allocator is free to assign the same register
2732 // to some other operand used inside instruction (i.e. temporary or
2734 MUST_USE_RESULT LOperand* UseRegister(HValue* value);
2735 MUST_USE_RESULT LOperand* UseRegisterAtStart(HValue* value);
2737 // An input operand in a register that may be trashed.
2738 MUST_USE_RESULT LOperand* UseTempRegister(HValue* value);
2740 // An input operand in a register that may be trashed or a constant operand.
2741 MUST_USE_RESULT LOperand* UseTempRegisterOrConstant(HValue* value);
2743 // An input operand in a register or stack slot.
2744 MUST_USE_RESULT LOperand* Use(HValue* value);
2745 MUST_USE_RESULT LOperand* UseAtStart(HValue* value);
2747 // An input operand in a register, stack slot or a constant operand.
2748 MUST_USE_RESULT LOperand* UseOrConstant(HValue* value);
2749 MUST_USE_RESULT LOperand* UseOrConstantAtStart(HValue* value);
2751 // An input operand in a register or a constant operand.
2752 MUST_USE_RESULT LOperand* UseRegisterOrConstant(HValue* value);
2753 MUST_USE_RESULT LOperand* UseRegisterOrConstantAtStart(HValue* value);
2755 // An input operand in a constant operand.
2756 MUST_USE_RESULT LOperand* UseConstant(HValue* value);
2758 // An input operand in register, stack slot or a constant operand.
2759 // Will not be moved to a register even if one is freely available.
2760 virtual MUST_USE_RESULT LOperand* UseAny(HValue* value) V8_OVERRIDE;
2762 // Temporary operand that must be in a register.
2763 MUST_USE_RESULT LUnallocated* TempRegister();
2764 MUST_USE_RESULT LOperand* FixedTemp(Register reg);
2765 MUST_USE_RESULT LOperand* FixedTemp(XMMRegister reg);
2767 // Methods for setting up define-use relationships.
2768 // Return the same instruction that they are passed.
2769 LInstruction* Define(LTemplateResultInstruction<1>* instr,
2770 LUnallocated* result);
2771 LInstruction* DefineAsRegister(LTemplateResultInstruction<1>* instr);
2772 LInstruction* DefineAsSpilled(LTemplateResultInstruction<1>* instr,
2774 LInstruction* DefineSameAsFirst(LTemplateResultInstruction<1>* instr);
2775 LInstruction* DefineFixed(LTemplateResultInstruction<1>* instr,
2777 LInstruction* DefineFixedDouble(LTemplateResultInstruction<1>* instr,
2779 // Assigns an environment to an instruction. An instruction which can
2780 // deoptimize must have an environment.
2781 LInstruction* AssignEnvironment(LInstruction* instr);
2782 // Assigns a pointer map to an instruction. An instruction which can
2783 // trigger a GC or a lazy deoptimization must have a pointer map.
2784 LInstruction* AssignPointerMap(LInstruction* instr);
2786 enum CanDeoptimize { CAN_DEOPTIMIZE_EAGERLY, CANNOT_DEOPTIMIZE_EAGERLY };
2788 // Marks a call for the register allocator. Assigns a pointer map to
2789 // support GC and lazy deoptimization. Assigns an environment to support
2790 // eager deoptimization if CAN_DEOPTIMIZE_EAGERLY.
2791 LInstruction* MarkAsCall(
2792 LInstruction* instr,
2793 HInstruction* hinstr,
2794 CanDeoptimize can_deoptimize = CANNOT_DEOPTIMIZE_EAGERLY);
2796 void VisitInstruction(HInstruction* current);
2798 void DoBasicBlock(HBasicBlock* block, HBasicBlock* next_block);
2799 LInstruction* DoShift(Token::Value op, HBitwiseBinaryOperation* instr);
2800 LInstruction* DoArithmeticD(Token::Value op,
2801 HArithmeticBinaryOperation* instr);
2802 LInstruction* DoArithmeticT(Token::Value op,
2803 HBinaryOperation* instr);
2804 void FindDehoistedKeyDefinitions(HValue* candidate);
2806 LPlatformChunk* chunk_;
2807 CompilationInfo* info_;
2808 HGraph* const graph_;
2810 HInstruction* current_instruction_;
2811 HBasicBlock* current_block_;
2812 HBasicBlock* next_block_;
2813 LAllocator* allocator_;
2815 DISALLOW_COPY_AND_ASSIGN(LChunkBuilder);
2818 #undef DECLARE_HYDROGEN_ACCESSOR
2819 #undef DECLARE_CONCRETE_INSTRUCTION
2821 } } // namespace v8::int
2823 #endif // V8_X64_LITHIUM_X64_H_