1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are
6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided
11 // with the distribution.
12 // * Neither the name of Google Inc. nor the names of its
13 // contributors may be used to endorse or promote products derived
14 // from this software without specific prior written permission.
16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 #ifndef V8_X64_LITHIUM_X64_H_
29 #define V8_X64_LITHIUM_X64_H_
32 #include "lithium-allocator.h"
34 #include "safepoint-table.h"
40 // Forward declarations.
43 #define LITHIUM_CONCRETE_INSTRUCTION_LIST(V) \
44 V(AccessArgumentsAt) \
48 V(ArgumentsElements) \
56 V(CallWithDescriptor) \
62 V(CheckInstanceType) \
71 V(ClassOfTestAndBranch) \
72 V(CompareMinusZeroAndBranch) \
73 V(CompareNumericAndBranch) \
74 V(CmpObjectEqAndBranch) \
96 V(FlooringDivByConstI) \
97 V(FlooringDivByPowerOf2I) \
101 V(GetCachedArrayIndex) \
103 V(HasCachedArrayIndexAndBranch) \
104 V(HasInstanceTypeAndBranch) \
105 V(InnerAllocatedObject) \
107 V(InstanceOfKnownGlobal) \
109 V(Integer32ToDouble) \
112 V(IsConstructCallAndBranch) \
113 V(IsObjectAndBranch) \
114 V(IsStringAndBranch) \
116 V(IsUndetectableAndBranch) \
121 V(LoadFieldByIndex) \
122 V(LoadFunctionPrototype) \
124 V(LoadGlobalGeneric) \
126 V(LoadKeyedGeneric) \
128 V(LoadNamedGeneric) \
153 V(SeqStringGetChar) \
154 V(SeqStringSetChar) \
160 V(StoreContextSlot) \
163 V(StoreKeyedGeneric) \
165 V(StoreNamedGeneric) \
167 V(StringCharCodeAt) \
168 V(StringCharFromCode) \
169 V(StringCompareAndBranch) \
173 V(ToFastProperties) \
174 V(TransitionElementsKind) \
175 V(TrapAllocationMemento) \
177 V(TypeofIsAndBranch) \
184 #define DECLARE_CONCRETE_INSTRUCTION(type, mnemonic) \
185 virtual Opcode opcode() const V8_FINAL V8_OVERRIDE { \
186 return LInstruction::k##type; \
188 virtual void CompileToNative(LCodeGen* generator) V8_FINAL V8_OVERRIDE; \
189 virtual const char* Mnemonic() const V8_FINAL V8_OVERRIDE { \
192 static L##type* cast(LInstruction* instr) { \
193 ASSERT(instr->Is##type()); \
194 return reinterpret_cast<L##type*>(instr); \
198 #define DECLARE_HYDROGEN_ACCESSOR(type) \
199 H##type* hydrogen() const { \
200 return H##type::cast(hydrogen_value()); \
204 class LInstruction : public ZoneObject {
207 : environment_(NULL),
208 hydrogen_value_(NULL),
209 bit_field_(IsCallBits::encode(false)) {
212 virtual ~LInstruction() {}
214 virtual void CompileToNative(LCodeGen* generator) = 0;
215 virtual const char* Mnemonic() const = 0;
216 virtual void PrintTo(StringStream* stream);
217 virtual void PrintDataTo(StringStream* stream);
218 virtual void PrintOutputOperandTo(StringStream* stream);
221 // Declare a unique enum value for each instruction.
222 #define DECLARE_OPCODE(type) k##type,
223 LITHIUM_CONCRETE_INSTRUCTION_LIST(DECLARE_OPCODE)
224 kNumberOfInstructions
225 #undef DECLARE_OPCODE
228 virtual Opcode opcode() const = 0;
230 // Declare non-virtual type testers for all leaf IR classes.
231 #define DECLARE_PREDICATE(type) \
232 bool Is##type() const { return opcode() == k##type; }
233 LITHIUM_CONCRETE_INSTRUCTION_LIST(DECLARE_PREDICATE)
234 #undef DECLARE_PREDICATE
236 // Declare virtual predicates for instructions that don't have
238 virtual bool IsGap() const { return false; }
240 virtual bool IsControl() const { return false; }
242 void set_environment(LEnvironment* env) { environment_ = env; }
243 LEnvironment* environment() const { return environment_; }
244 bool HasEnvironment() const { return environment_ != NULL; }
246 void set_pointer_map(LPointerMap* p) { pointer_map_.set(p); }
247 LPointerMap* pointer_map() const { return pointer_map_.get(); }
248 bool HasPointerMap() const { return pointer_map_.is_set(); }
250 void set_hydrogen_value(HValue* value) { hydrogen_value_ = value; }
251 HValue* hydrogen_value() const { return hydrogen_value_; }
253 void MarkAsCall() { bit_field_ = IsCallBits::update(bit_field_, true); }
254 bool IsCall() const { return IsCallBits::decode(bit_field_); }
256 // Interface to the register allocator and iterators.
257 bool ClobbersTemps() const { return IsCall(); }
258 bool ClobbersRegisters() const { return IsCall(); }
259 virtual bool ClobbersDoubleRegisters() const { return IsCall(); }
261 virtual void SetDeferredLazyDeoptimizationEnvironment(LEnvironment* env) { }
263 // Interface to the register allocator and iterators.
264 bool IsMarkedAsCall() const { return IsCall(); }
266 virtual bool HasResult() const = 0;
267 virtual LOperand* result() const = 0;
269 LOperand* FirstInput() { return InputAt(0); }
270 LOperand* Output() { return HasResult() ? result() : NULL; }
272 virtual bool HasInterestingComment(LCodeGen* gen) const { return true; }
280 friend class InputIterator;
281 virtual int InputCount() = 0;
282 virtual LOperand* InputAt(int i) = 0;
284 friend class TempIterator;
285 virtual int TempCount() = 0;
286 virtual LOperand* TempAt(int i) = 0;
288 class IsCallBits: public BitField<bool, 0, 1> {};
290 LEnvironment* environment_;
291 SetOncePointer<LPointerMap> pointer_map_;
292 HValue* hydrogen_value_;
297 // R = number of result operands (0 or 1).
299 class LTemplateResultInstruction : public LInstruction {
301 // Allow 0 or 1 output operands.
302 STATIC_ASSERT(R == 0 || R == 1);
303 virtual bool HasResult() const V8_FINAL V8_OVERRIDE {
304 return R != 0 && result() != NULL;
306 void set_result(LOperand* operand) { results_[0] = operand; }
307 LOperand* result() const { return results_[0]; }
310 EmbeddedContainer<LOperand*, R> results_;
314 // R = number of result operands (0 or 1).
315 // I = number of input operands.
316 // T = number of temporary operands.
317 template<int R, int I, int T>
318 class LTemplateInstruction : public LTemplateResultInstruction<R> {
320 EmbeddedContainer<LOperand*, I> inputs_;
321 EmbeddedContainer<LOperand*, T> temps_;
325 virtual int InputCount() V8_FINAL V8_OVERRIDE { return I; }
326 virtual LOperand* InputAt(int i) V8_FINAL V8_OVERRIDE { return inputs_[i]; }
328 virtual int TempCount() V8_FINAL V8_OVERRIDE { return T; }
329 virtual LOperand* TempAt(int i) V8_FINAL V8_OVERRIDE { return temps_[i]; }
333 class LGap : public LTemplateInstruction<0, 0, 0> {
335 explicit LGap(HBasicBlock* block)
337 parallel_moves_[BEFORE] = NULL;
338 parallel_moves_[START] = NULL;
339 parallel_moves_[END] = NULL;
340 parallel_moves_[AFTER] = NULL;
343 // Can't use the DECLARE-macro here because of sub-classes.
344 virtual bool IsGap() const V8_FINAL V8_OVERRIDE { return true; }
345 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
346 static LGap* cast(LInstruction* instr) {
347 ASSERT(instr->IsGap());
348 return reinterpret_cast<LGap*>(instr);
351 bool IsRedundant() const;
353 HBasicBlock* block() const { return block_; }
360 FIRST_INNER_POSITION = BEFORE,
361 LAST_INNER_POSITION = AFTER
364 LParallelMove* GetOrCreateParallelMove(InnerPosition pos,
366 if (parallel_moves_[pos] == NULL) {
367 parallel_moves_[pos] = new(zone) LParallelMove(zone);
369 return parallel_moves_[pos];
372 LParallelMove* GetParallelMove(InnerPosition pos) {
373 return parallel_moves_[pos];
377 LParallelMove* parallel_moves_[LAST_INNER_POSITION + 1];
382 class LInstructionGap V8_FINAL : public LGap {
384 explicit LInstructionGap(HBasicBlock* block) : LGap(block) { }
386 virtual bool HasInterestingComment(LCodeGen* gen) const V8_OVERRIDE {
387 return !IsRedundant();
390 DECLARE_CONCRETE_INSTRUCTION(InstructionGap, "gap")
394 class LGoto V8_FINAL : public LTemplateInstruction<0, 0, 0> {
396 explicit LGoto(HBasicBlock* block) : block_(block) { }
398 virtual bool HasInterestingComment(LCodeGen* gen) const V8_OVERRIDE;
399 DECLARE_CONCRETE_INSTRUCTION(Goto, "goto")
400 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
401 virtual bool IsControl() const V8_OVERRIDE { return true; }
403 int block_id() const { return block_->block_id(); }
410 class LLazyBailout V8_FINAL : public LTemplateInstruction<0, 0, 0> {
412 LLazyBailout() : gap_instructions_size_(0) { }
414 DECLARE_CONCRETE_INSTRUCTION(LazyBailout, "lazy-bailout")
416 void set_gap_instructions_size(int gap_instructions_size) {
417 gap_instructions_size_ = gap_instructions_size;
419 int gap_instructions_size() { return gap_instructions_size_; }
422 int gap_instructions_size_;
426 class LDummy V8_FINAL : public LTemplateInstruction<1, 0, 0> {
428 explicit LDummy() { }
429 DECLARE_CONCRETE_INSTRUCTION(Dummy, "dummy")
433 class LDummyUse V8_FINAL : public LTemplateInstruction<1, 1, 0> {
435 explicit LDummyUse(LOperand* value) {
438 DECLARE_CONCRETE_INSTRUCTION(DummyUse, "dummy-use")
442 class LDeoptimize V8_FINAL : public LTemplateInstruction<0, 0, 0> {
444 DECLARE_CONCRETE_INSTRUCTION(Deoptimize, "deoptimize")
445 DECLARE_HYDROGEN_ACCESSOR(Deoptimize)
449 class LLabel V8_FINAL : public LGap {
451 explicit LLabel(HBasicBlock* block)
452 : LGap(block), replacement_(NULL) { }
454 virtual bool HasInterestingComment(LCodeGen* gen) const V8_OVERRIDE {
457 DECLARE_CONCRETE_INSTRUCTION(Label, "label")
459 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
461 int block_id() const { return block()->block_id(); }
462 bool is_loop_header() const { return block()->IsLoopHeader(); }
463 bool is_osr_entry() const { return block()->is_osr_entry(); }
464 Label* label() { return &label_; }
465 LLabel* replacement() const { return replacement_; }
466 void set_replacement(LLabel* label) { replacement_ = label; }
467 bool HasReplacement() const { return replacement_ != NULL; }
471 LLabel* replacement_;
475 class LParameter V8_FINAL : public LTemplateInstruction<1, 0, 0> {
477 virtual bool HasInterestingComment(LCodeGen* gen) const V8_OVERRIDE {
480 DECLARE_CONCRETE_INSTRUCTION(Parameter, "parameter")
484 class LCallStub V8_FINAL : public LTemplateInstruction<1, 1, 0> {
486 explicit LCallStub(LOperand* context) {
487 inputs_[0] = context;
490 LOperand* context() { return inputs_[0]; }
492 DECLARE_CONCRETE_INSTRUCTION(CallStub, "call-stub")
493 DECLARE_HYDROGEN_ACCESSOR(CallStub)
497 class LUnknownOSRValue V8_FINAL : public LTemplateInstruction<1, 0, 0> {
499 virtual bool HasInterestingComment(LCodeGen* gen) const V8_OVERRIDE {
502 DECLARE_CONCRETE_INSTRUCTION(UnknownOSRValue, "unknown-osr-value")
506 template<int I, int T>
507 class LControlInstruction : public LTemplateInstruction<0, I, T> {
509 LControlInstruction() : false_label_(NULL), true_label_(NULL) { }
511 virtual bool IsControl() const V8_FINAL V8_OVERRIDE { return true; }
513 int SuccessorCount() { return hydrogen()->SuccessorCount(); }
514 HBasicBlock* SuccessorAt(int i) { return hydrogen()->SuccessorAt(i); }
516 int TrueDestination(LChunk* chunk) {
517 return chunk->LookupDestination(true_block_id());
519 int FalseDestination(LChunk* chunk) {
520 return chunk->LookupDestination(false_block_id());
523 Label* TrueLabel(LChunk* chunk) {
524 if (true_label_ == NULL) {
525 true_label_ = chunk->GetAssemblyLabel(TrueDestination(chunk));
529 Label* FalseLabel(LChunk* chunk) {
530 if (false_label_ == NULL) {
531 false_label_ = chunk->GetAssemblyLabel(FalseDestination(chunk));
537 int true_block_id() { return SuccessorAt(0)->block_id(); }
538 int false_block_id() { return SuccessorAt(1)->block_id(); }
541 HControlInstruction* hydrogen() {
542 return HControlInstruction::cast(this->hydrogen_value());
550 class LWrapReceiver V8_FINAL : public LTemplateInstruction<1, 2, 0> {
552 LWrapReceiver(LOperand* receiver, LOperand* function) {
553 inputs_[0] = receiver;
554 inputs_[1] = function;
557 LOperand* receiver() { return inputs_[0]; }
558 LOperand* function() { return inputs_[1]; }
560 DECLARE_CONCRETE_INSTRUCTION(WrapReceiver, "wrap-receiver")
561 DECLARE_HYDROGEN_ACCESSOR(WrapReceiver)
565 class LApplyArguments V8_FINAL : public LTemplateInstruction<1, 4, 0> {
567 LApplyArguments(LOperand* function,
570 LOperand* elements) {
571 inputs_[0] = function;
572 inputs_[1] = receiver;
574 inputs_[3] = elements;
577 LOperand* function() { return inputs_[0]; }
578 LOperand* receiver() { return inputs_[1]; }
579 LOperand* length() { return inputs_[2]; }
580 LOperand* elements() { return inputs_[3]; }
582 DECLARE_CONCRETE_INSTRUCTION(ApplyArguments, "apply-arguments")
586 class LAccessArgumentsAt V8_FINAL : public LTemplateInstruction<1, 3, 0> {
588 LAccessArgumentsAt(LOperand* arguments, LOperand* length, LOperand* index) {
589 inputs_[0] = arguments;
594 LOperand* arguments() { return inputs_[0]; }
595 LOperand* length() { return inputs_[1]; }
596 LOperand* index() { return inputs_[2]; }
598 DECLARE_CONCRETE_INSTRUCTION(AccessArgumentsAt, "access-arguments-at")
600 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
604 class LArgumentsLength V8_FINAL : public LTemplateInstruction<1, 1, 0> {
606 explicit LArgumentsLength(LOperand* elements) {
607 inputs_[0] = elements;
610 LOperand* elements() { return inputs_[0]; }
612 DECLARE_CONCRETE_INSTRUCTION(ArgumentsLength, "arguments-length")
616 class LArgumentsElements V8_FINAL : public LTemplateInstruction<1, 0, 0> {
618 DECLARE_CONCRETE_INSTRUCTION(ArgumentsElements, "arguments-elements")
619 DECLARE_HYDROGEN_ACCESSOR(ArgumentsElements)
623 class LModByPowerOf2I V8_FINAL : public LTemplateInstruction<1, 1, 0> {
625 LModByPowerOf2I(LOperand* dividend, int32_t divisor) {
626 inputs_[0] = dividend;
630 LOperand* dividend() { return inputs_[0]; }
631 int32_t divisor() const { return divisor_; }
633 DECLARE_CONCRETE_INSTRUCTION(ModByPowerOf2I, "mod-by-power-of-2-i")
634 DECLARE_HYDROGEN_ACCESSOR(Mod)
641 class LModByConstI V8_FINAL : public LTemplateInstruction<1, 1, 2> {
643 LModByConstI(LOperand* dividend,
647 inputs_[0] = dividend;
653 LOperand* dividend() { return inputs_[0]; }
654 int32_t divisor() const { return divisor_; }
655 LOperand* temp1() { return temps_[0]; }
656 LOperand* temp2() { return temps_[1]; }
658 DECLARE_CONCRETE_INSTRUCTION(ModByConstI, "mod-by-const-i")
659 DECLARE_HYDROGEN_ACCESSOR(Mod)
666 class LModI V8_FINAL : public LTemplateInstruction<1, 2, 1> {
668 LModI(LOperand* left, LOperand* right, LOperand* temp) {
674 LOperand* left() { return inputs_[0]; }
675 LOperand* right() { return inputs_[1]; }
676 LOperand* temp() { return temps_[0]; }
678 DECLARE_CONCRETE_INSTRUCTION(ModI, "mod-i")
679 DECLARE_HYDROGEN_ACCESSOR(Mod)
683 class LDivByPowerOf2I V8_FINAL : public LTemplateInstruction<1, 1, 0> {
685 LDivByPowerOf2I(LOperand* dividend, int32_t divisor) {
686 inputs_[0] = dividend;
690 LOperand* dividend() { return inputs_[0]; }
691 int32_t divisor() const { return divisor_; }
693 DECLARE_CONCRETE_INSTRUCTION(DivByPowerOf2I, "div-by-power-of-2-i")
694 DECLARE_HYDROGEN_ACCESSOR(Div)
701 class LDivByConstI V8_FINAL : public LTemplateInstruction<1, 1, 2> {
703 LDivByConstI(LOperand* dividend,
707 inputs_[0] = dividend;
713 LOperand* dividend() { return inputs_[0]; }
714 int32_t divisor() const { return divisor_; }
715 LOperand* temp1() { return temps_[0]; }
716 LOperand* temp2() { return temps_[1]; }
718 DECLARE_CONCRETE_INSTRUCTION(DivByConstI, "div-by-const-i")
719 DECLARE_HYDROGEN_ACCESSOR(Div)
726 class LDivI V8_FINAL : public LTemplateInstruction<1, 2, 1> {
728 LDivI(LOperand* left, LOperand* right, LOperand* temp) {
734 LOperand* left() { return inputs_[0]; }
735 LOperand* right() { return inputs_[1]; }
736 LOperand* temp() { return temps_[0]; }
738 bool is_flooring() { return hydrogen_value()->IsMathFloorOfDiv(); }
740 DECLARE_CONCRETE_INSTRUCTION(DivI, "div-i")
741 DECLARE_HYDROGEN_ACCESSOR(BinaryOperation)
745 class LFlooringDivByPowerOf2I V8_FINAL : public LTemplateInstruction<1, 1, 0> {
747 LFlooringDivByPowerOf2I(LOperand* dividend, int32_t divisor) {
748 inputs_[0] = dividend;
752 LOperand* dividend() { return inputs_[0]; }
753 int32_t divisor() const { return divisor_; }
755 DECLARE_CONCRETE_INSTRUCTION(FlooringDivByPowerOf2I,
756 "flooring-div-by-power-of-2-i")
757 DECLARE_HYDROGEN_ACCESSOR(MathFloorOfDiv)
764 class LFlooringDivByConstI V8_FINAL : public LTemplateInstruction<1, 1, 2> {
766 LFlooringDivByConstI(LOperand* dividend,
770 inputs_[0] = dividend;
776 LOperand* dividend() { return inputs_[0]; }
777 int32_t divisor() const { return divisor_; }
778 LOperand* temp1() { return temps_[0]; }
779 LOperand* temp2() { return temps_[0]; }
781 DECLARE_CONCRETE_INSTRUCTION(FlooringDivByConstI, "flooring-div-by-const-i")
782 DECLARE_HYDROGEN_ACCESSOR(MathFloorOfDiv)
789 class LMulI V8_FINAL : public LTemplateInstruction<1, 2, 0> {
791 LMulI(LOperand* left, LOperand* right) {
796 LOperand* left() { return inputs_[0]; }
797 LOperand* right() { return inputs_[1]; }
799 DECLARE_CONCRETE_INSTRUCTION(MulI, "mul-i")
800 DECLARE_HYDROGEN_ACCESSOR(Mul)
804 class LCompareNumericAndBranch V8_FINAL : public LControlInstruction<2, 0> {
806 LCompareNumericAndBranch(LOperand* left, LOperand* right) {
811 LOperand* left() { return inputs_[0]; }
812 LOperand* right() { return inputs_[1]; }
814 DECLARE_CONCRETE_INSTRUCTION(CompareNumericAndBranch,
815 "compare-numeric-and-branch")
816 DECLARE_HYDROGEN_ACCESSOR(CompareNumericAndBranch)
818 Token::Value op() const { return hydrogen()->token(); }
819 bool is_double() const {
820 return hydrogen()->representation().IsDouble();
823 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
827 class LMathFloor V8_FINAL : public LTemplateInstruction<1, 1, 0> {
829 explicit LMathFloor(LOperand* value) {
833 LOperand* value() { return inputs_[0]; }
835 DECLARE_CONCRETE_INSTRUCTION(MathFloor, "math-floor")
836 DECLARE_HYDROGEN_ACCESSOR(UnaryMathOperation)
840 class LMathRound V8_FINAL : public LTemplateInstruction<1, 1, 0> {
842 explicit LMathRound(LOperand* value) {
846 LOperand* value() { return inputs_[0]; }
848 DECLARE_CONCRETE_INSTRUCTION(MathRound, "math-round")
849 DECLARE_HYDROGEN_ACCESSOR(UnaryMathOperation)
853 class LMathAbs V8_FINAL : public LTemplateInstruction<1, 2, 0> {
855 explicit LMathAbs(LOperand* context, LOperand* value) {
856 inputs_[1] = context;
860 LOperand* context() { return inputs_[1]; }
861 LOperand* value() { return inputs_[0]; }
863 DECLARE_CONCRETE_INSTRUCTION(MathAbs, "math-abs")
864 DECLARE_HYDROGEN_ACCESSOR(UnaryMathOperation)
868 class LMathLog V8_FINAL : public LTemplateInstruction<1, 1, 0> {
870 explicit LMathLog(LOperand* value) {
874 LOperand* value() { return inputs_[0]; }
876 DECLARE_CONCRETE_INSTRUCTION(MathLog, "math-log")
880 class LMathClz32 V8_FINAL : public LTemplateInstruction<1, 1, 0> {
882 explicit LMathClz32(LOperand* value) {
886 LOperand* value() { return inputs_[0]; }
888 DECLARE_CONCRETE_INSTRUCTION(MathClz32, "math-clz32")
892 class LMathExp V8_FINAL : public LTemplateInstruction<1, 1, 2> {
894 LMathExp(LOperand* value, LOperand* temp1, LOperand* temp2) {
898 ExternalReference::InitializeMathExpData();
901 LOperand* value() { return inputs_[0]; }
902 LOperand* temp1() { return temps_[0]; }
903 LOperand* temp2() { return temps_[1]; }
905 DECLARE_CONCRETE_INSTRUCTION(MathExp, "math-exp")
909 class LMathSqrt V8_FINAL : public LTemplateInstruction<1, 1, 0> {
911 explicit LMathSqrt(LOperand* value) {
915 LOperand* value() { return inputs_[0]; }
917 DECLARE_CONCRETE_INSTRUCTION(MathSqrt, "math-sqrt")
921 class LMathPowHalf V8_FINAL : public LTemplateInstruction<1, 1, 0> {
923 explicit LMathPowHalf(LOperand* value) {
927 LOperand* value() { return inputs_[0]; }
929 DECLARE_CONCRETE_INSTRUCTION(MathPowHalf, "math-pow-half")
933 class LCmpObjectEqAndBranch V8_FINAL : public LControlInstruction<2, 0> {
935 LCmpObjectEqAndBranch(LOperand* left, LOperand* right) {
940 LOperand* left() { return inputs_[0]; }
941 LOperand* right() { return inputs_[1]; }
943 DECLARE_CONCRETE_INSTRUCTION(CmpObjectEqAndBranch, "cmp-object-eq-and-branch")
947 class LCmpHoleAndBranch V8_FINAL : public LControlInstruction<1, 0> {
949 explicit LCmpHoleAndBranch(LOperand* object) {
953 LOperand* object() { return inputs_[0]; }
955 DECLARE_CONCRETE_INSTRUCTION(CmpHoleAndBranch, "cmp-hole-and-branch")
956 DECLARE_HYDROGEN_ACCESSOR(CompareHoleAndBranch)
960 class LCompareMinusZeroAndBranch V8_FINAL : public LControlInstruction<1, 0> {
962 explicit LCompareMinusZeroAndBranch(LOperand* value) {
966 LOperand* value() { return inputs_[0]; }
968 DECLARE_CONCRETE_INSTRUCTION(CompareMinusZeroAndBranch,
969 "cmp-minus-zero-and-branch")
970 DECLARE_HYDROGEN_ACCESSOR(CompareMinusZeroAndBranch)
975 class LIsObjectAndBranch V8_FINAL : public LControlInstruction<1, 0> {
977 explicit LIsObjectAndBranch(LOperand* value) {
981 LOperand* value() { return inputs_[0]; }
983 DECLARE_CONCRETE_INSTRUCTION(IsObjectAndBranch, "is-object-and-branch")
984 DECLARE_HYDROGEN_ACCESSOR(IsObjectAndBranch)
986 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
990 class LIsStringAndBranch V8_FINAL : public LControlInstruction<1, 1> {
992 explicit LIsStringAndBranch(LOperand* value, LOperand* temp) {
997 LOperand* value() { return inputs_[0]; }
998 LOperand* temp() { return temps_[0]; }
1000 DECLARE_CONCRETE_INSTRUCTION(IsStringAndBranch, "is-string-and-branch")
1001 DECLARE_HYDROGEN_ACCESSOR(IsStringAndBranch)
1003 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1007 class LIsSmiAndBranch V8_FINAL : public LControlInstruction<1, 0> {
1009 explicit LIsSmiAndBranch(LOperand* value) {
1013 LOperand* value() { return inputs_[0]; }
1015 DECLARE_CONCRETE_INSTRUCTION(IsSmiAndBranch, "is-smi-and-branch")
1016 DECLARE_HYDROGEN_ACCESSOR(IsSmiAndBranch)
1018 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1022 class LIsUndetectableAndBranch V8_FINAL : public LControlInstruction<1, 1> {
1024 explicit LIsUndetectableAndBranch(LOperand* value, LOperand* temp) {
1029 LOperand* value() { return inputs_[0]; }
1030 LOperand* temp() { return temps_[0]; }
1032 DECLARE_CONCRETE_INSTRUCTION(IsUndetectableAndBranch,
1033 "is-undetectable-and-branch")
1034 DECLARE_HYDROGEN_ACCESSOR(IsUndetectableAndBranch)
1036 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1040 class LStringCompareAndBranch V8_FINAL : public LControlInstruction<3, 0> {
1042 explicit LStringCompareAndBranch(LOperand* context,
1045 inputs_[0] = context;
1050 LOperand* context() { return inputs_[0]; }
1051 LOperand* left() { return inputs_[1]; }
1052 LOperand* right() { return inputs_[2]; }
1054 DECLARE_CONCRETE_INSTRUCTION(StringCompareAndBranch,
1055 "string-compare-and-branch")
1056 DECLARE_HYDROGEN_ACCESSOR(StringCompareAndBranch)
1058 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1060 Token::Value op() const { return hydrogen()->token(); }
1064 class LHasInstanceTypeAndBranch V8_FINAL : public LControlInstruction<1, 0> {
1066 explicit LHasInstanceTypeAndBranch(LOperand* value) {
1070 LOperand* value() { return inputs_[0]; }
1072 DECLARE_CONCRETE_INSTRUCTION(HasInstanceTypeAndBranch,
1073 "has-instance-type-and-branch")
1074 DECLARE_HYDROGEN_ACCESSOR(HasInstanceTypeAndBranch)
1076 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1080 class LGetCachedArrayIndex V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1082 explicit LGetCachedArrayIndex(LOperand* value) {
1086 LOperand* value() { return inputs_[0]; }
1088 DECLARE_CONCRETE_INSTRUCTION(GetCachedArrayIndex, "get-cached-array-index")
1089 DECLARE_HYDROGEN_ACCESSOR(GetCachedArrayIndex)
1093 class LHasCachedArrayIndexAndBranch V8_FINAL
1094 : public LControlInstruction<1, 0> {
1096 explicit LHasCachedArrayIndexAndBranch(LOperand* value) {
1100 LOperand* value() { return inputs_[0]; }
1102 DECLARE_CONCRETE_INSTRUCTION(HasCachedArrayIndexAndBranch,
1103 "has-cached-array-index-and-branch")
1104 DECLARE_HYDROGEN_ACCESSOR(HasCachedArrayIndexAndBranch)
1106 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1110 class LClassOfTestAndBranch V8_FINAL : public LControlInstruction<1, 2> {
1112 LClassOfTestAndBranch(LOperand* value, LOperand* temp, LOperand* temp2) {
1118 LOperand* value() { return inputs_[0]; }
1119 LOperand* temp() { return temps_[0]; }
1120 LOperand* temp2() { return temps_[1]; }
1122 DECLARE_CONCRETE_INSTRUCTION(ClassOfTestAndBranch,
1123 "class-of-test-and-branch")
1124 DECLARE_HYDROGEN_ACCESSOR(ClassOfTestAndBranch)
1126 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1130 class LCmpT V8_FINAL : public LTemplateInstruction<1, 3, 0> {
1132 LCmpT(LOperand* context, LOperand* left, LOperand* right) {
1133 inputs_[0] = context;
1138 LOperand* context() { return inputs_[0]; }
1139 LOperand* left() { return inputs_[1]; }
1140 LOperand* right() { return inputs_[2]; }
1142 DECLARE_CONCRETE_INSTRUCTION(CmpT, "cmp-t")
1143 DECLARE_HYDROGEN_ACCESSOR(CompareGeneric)
1145 Token::Value op() const { return hydrogen()->token(); }
1149 class LInstanceOf V8_FINAL : public LTemplateInstruction<1, 3, 0> {
1151 LInstanceOf(LOperand* context, LOperand* left, LOperand* right) {
1152 inputs_[0] = context;
1157 LOperand* context() { return inputs_[0]; }
1158 LOperand* left() { return inputs_[1]; }
1159 LOperand* right() { return inputs_[2]; }
1161 DECLARE_CONCRETE_INSTRUCTION(InstanceOf, "instance-of")
1165 class LInstanceOfKnownGlobal V8_FINAL : public LTemplateInstruction<1, 2, 1> {
1167 LInstanceOfKnownGlobal(LOperand* context, LOperand* value, LOperand* temp) {
1168 inputs_[0] = context;
1173 LOperand* context() { return inputs_[0]; }
1174 LOperand* value() { return inputs_[1]; }
1175 LOperand* temp() { return temps_[0]; }
1177 DECLARE_CONCRETE_INSTRUCTION(InstanceOfKnownGlobal,
1178 "instance-of-known-global")
1179 DECLARE_HYDROGEN_ACCESSOR(InstanceOfKnownGlobal)
1181 Handle<JSFunction> function() const { return hydrogen()->function(); }
1182 LEnvironment* GetDeferredLazyDeoptimizationEnvironment() {
1183 return lazy_deopt_env_;
1185 virtual void SetDeferredLazyDeoptimizationEnvironment(
1186 LEnvironment* env) V8_OVERRIDE {
1187 lazy_deopt_env_ = env;
1191 LEnvironment* lazy_deopt_env_;
1195 class LBoundsCheck V8_FINAL : public LTemplateInstruction<0, 2, 0> {
1197 LBoundsCheck(LOperand* index, LOperand* length) {
1199 inputs_[1] = length;
1202 LOperand* index() { return inputs_[0]; }
1203 LOperand* length() { return inputs_[1]; }
1205 DECLARE_CONCRETE_INSTRUCTION(BoundsCheck, "bounds-check")
1206 DECLARE_HYDROGEN_ACCESSOR(BoundsCheck)
1210 class LBitI V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1212 LBitI(LOperand* left, LOperand* right) {
1217 LOperand* left() { return inputs_[0]; }
1218 LOperand* right() { return inputs_[1]; }
1220 Token::Value op() const { return hydrogen()->op(); }
1222 DECLARE_CONCRETE_INSTRUCTION(BitI, "bit-i")
1223 DECLARE_HYDROGEN_ACCESSOR(Bitwise)
1227 class LShiftI V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1229 LShiftI(Token::Value op, LOperand* left, LOperand* right, bool can_deopt)
1230 : op_(op), can_deopt_(can_deopt) {
1235 Token::Value op() const { return op_; }
1236 LOperand* left() { return inputs_[0]; }
1237 LOperand* right() { return inputs_[1]; }
1238 bool can_deopt() const { return can_deopt_; }
1240 DECLARE_CONCRETE_INSTRUCTION(ShiftI, "shift-i")
1248 class LSubI V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1250 LSubI(LOperand* left, LOperand* right) {
1255 LOperand* left() { return inputs_[0]; }
1256 LOperand* right() { return inputs_[1]; }
1258 DECLARE_CONCRETE_INSTRUCTION(SubI, "sub-i")
1259 DECLARE_HYDROGEN_ACCESSOR(Sub)
1263 class LConstantI V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1265 DECLARE_CONCRETE_INSTRUCTION(ConstantI, "constant-i")
1266 DECLARE_HYDROGEN_ACCESSOR(Constant)
1268 int32_t value() const { return hydrogen()->Integer32Value(); }
1272 class LConstantS V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1274 DECLARE_CONCRETE_INSTRUCTION(ConstantS, "constant-s")
1275 DECLARE_HYDROGEN_ACCESSOR(Constant)
1277 Smi* value() const { return Smi::FromInt(hydrogen()->Integer32Value()); }
1281 class LConstantD V8_FINAL : public LTemplateInstruction<1, 0, 1> {
1283 explicit LConstantD(LOperand* temp) {
1287 LOperand* temp() { return temps_[0]; }
1289 DECLARE_CONCRETE_INSTRUCTION(ConstantD, "constant-d")
1290 DECLARE_HYDROGEN_ACCESSOR(Constant)
1292 double value() const { return hydrogen()->DoubleValue(); }
1296 class LConstantE V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1298 DECLARE_CONCRETE_INSTRUCTION(ConstantE, "constant-e")
1299 DECLARE_HYDROGEN_ACCESSOR(Constant)
1301 ExternalReference value() const {
1302 return hydrogen()->ExternalReferenceValue();
1307 class LConstantT V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1309 DECLARE_CONCRETE_INSTRUCTION(ConstantT, "constant-t")
1310 DECLARE_HYDROGEN_ACCESSOR(Constant)
1312 Handle<Object> value(Isolate* isolate) const {
1313 return hydrogen()->handle(isolate);
1318 class LBranch V8_FINAL : public LControlInstruction<1, 0> {
1320 explicit LBranch(LOperand* value) {
1324 LOperand* value() { return inputs_[0]; }
1326 DECLARE_CONCRETE_INSTRUCTION(Branch, "branch")
1327 DECLARE_HYDROGEN_ACCESSOR(Branch)
1329 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1333 class LDebugBreak V8_FINAL : public LTemplateInstruction<0, 0, 0> {
1335 DECLARE_CONCRETE_INSTRUCTION(DebugBreak, "break")
1339 class LCmpMapAndBranch V8_FINAL : public LControlInstruction<1, 0> {
1341 explicit LCmpMapAndBranch(LOperand* value) {
1345 LOperand* value() { return inputs_[0]; }
1347 DECLARE_CONCRETE_INSTRUCTION(CmpMapAndBranch, "cmp-map-and-branch")
1348 DECLARE_HYDROGEN_ACCESSOR(CompareMap)
1350 Handle<Map> map() const { return hydrogen()->map().handle(); }
1354 class LMapEnumLength V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1356 explicit LMapEnumLength(LOperand* value) {
1360 LOperand* value() { return inputs_[0]; }
1362 DECLARE_CONCRETE_INSTRUCTION(MapEnumLength, "map-enum-length")
1366 class LDateField V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1368 LDateField(LOperand* date, Smi* index) : index_(index) {
1372 LOperand* date() { return inputs_[0]; }
1373 Smi* index() const { return index_; }
1375 DECLARE_CONCRETE_INSTRUCTION(DateField, "date-field")
1376 DECLARE_HYDROGEN_ACCESSOR(DateField)
1383 class LSeqStringGetChar V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1385 LSeqStringGetChar(LOperand* string, LOperand* index) {
1386 inputs_[0] = string;
1390 LOperand* string() const { return inputs_[0]; }
1391 LOperand* index() const { return inputs_[1]; }
1393 DECLARE_CONCRETE_INSTRUCTION(SeqStringGetChar, "seq-string-get-char")
1394 DECLARE_HYDROGEN_ACCESSOR(SeqStringGetChar)
1398 class LSeqStringSetChar V8_FINAL : public LTemplateInstruction<1, 4, 0> {
1400 LSeqStringSetChar(LOperand* context,
1404 inputs_[0] = context;
1405 inputs_[1] = string;
1410 LOperand* string() { return inputs_[1]; }
1411 LOperand* index() { return inputs_[2]; }
1412 LOperand* value() { return inputs_[3]; }
1414 DECLARE_CONCRETE_INSTRUCTION(SeqStringSetChar, "seq-string-set-char")
1415 DECLARE_HYDROGEN_ACCESSOR(SeqStringSetChar)
1419 class LAddI V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1421 LAddI(LOperand* left, LOperand* right) {
1426 LOperand* left() { return inputs_[0]; }
1427 LOperand* right() { return inputs_[1]; }
1429 static bool UseLea(HAdd* add) {
1430 return !add->CheckFlag(HValue::kCanOverflow) &&
1431 add->BetterLeftOperand()->UseCount() > 1;
1434 DECLARE_CONCRETE_INSTRUCTION(AddI, "add-i")
1435 DECLARE_HYDROGEN_ACCESSOR(Add)
1439 class LMathMinMax V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1441 LMathMinMax(LOperand* left, LOperand* right) {
1446 LOperand* left() { return inputs_[0]; }
1447 LOperand* right() { return inputs_[1]; }
1449 DECLARE_CONCRETE_INSTRUCTION(MathMinMax, "math-min-max")
1450 DECLARE_HYDROGEN_ACCESSOR(MathMinMax)
1454 class LPower V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1456 LPower(LOperand* left, LOperand* right) {
1461 LOperand* left() { return inputs_[0]; }
1462 LOperand* right() { return inputs_[1]; }
1464 DECLARE_CONCRETE_INSTRUCTION(Power, "power")
1465 DECLARE_HYDROGEN_ACCESSOR(Power)
1469 class LArithmeticD V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1471 LArithmeticD(Token::Value op, LOperand* left, LOperand* right)
1477 Token::Value op() const { return op_; }
1478 LOperand* left() { return inputs_[0]; }
1479 LOperand* right() { return inputs_[1]; }
1481 virtual Opcode opcode() const V8_OVERRIDE {
1482 return LInstruction::kArithmeticD;
1484 virtual void CompileToNative(LCodeGen* generator) V8_OVERRIDE;
1485 virtual const char* Mnemonic() const V8_OVERRIDE;
1492 class LArithmeticT V8_FINAL : public LTemplateInstruction<1, 3, 0> {
1494 LArithmeticT(Token::Value op,
1499 inputs_[0] = context;
1504 Token::Value op() const { return op_; }
1505 LOperand* context() { return inputs_[0]; }
1506 LOperand* left() { return inputs_[1]; }
1507 LOperand* right() { return inputs_[2]; }
1509 virtual Opcode opcode() const V8_OVERRIDE {
1510 return LInstruction::kArithmeticT;
1512 virtual void CompileToNative(LCodeGen* generator) V8_OVERRIDE;
1513 virtual const char* Mnemonic() const V8_OVERRIDE;
1520 class LReturn V8_FINAL : public LTemplateInstruction<0, 3, 0> {
1522 explicit LReturn(LOperand* value,
1524 LOperand* parameter_count) {
1526 inputs_[1] = context;
1527 inputs_[2] = parameter_count;
1530 LOperand* value() { return inputs_[0]; }
1531 LOperand* context() { return inputs_[1]; }
1533 bool has_constant_parameter_count() {
1534 return parameter_count()->IsConstantOperand();
1536 LConstantOperand* constant_parameter_count() {
1537 ASSERT(has_constant_parameter_count());
1538 return LConstantOperand::cast(parameter_count());
1540 LOperand* parameter_count() { return inputs_[2]; }
1542 DECLARE_CONCRETE_INSTRUCTION(Return, "return")
1543 DECLARE_HYDROGEN_ACCESSOR(Return)
1547 class LLoadNamedField V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1549 explicit LLoadNamedField(LOperand* object) {
1550 inputs_[0] = object;
1553 LOperand* object() { return inputs_[0]; }
1555 DECLARE_CONCRETE_INSTRUCTION(LoadNamedField, "load-named-field")
1556 DECLARE_HYDROGEN_ACCESSOR(LoadNamedField)
1560 class LLoadNamedGeneric V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1562 explicit LLoadNamedGeneric(LOperand* context, LOperand* object) {
1563 inputs_[0] = context;
1564 inputs_[1] = object;
1567 DECLARE_CONCRETE_INSTRUCTION(LoadNamedGeneric, "load-named-generic")
1568 DECLARE_HYDROGEN_ACCESSOR(LoadNamedGeneric)
1570 LOperand* context() { return inputs_[0]; }
1571 LOperand* object() { return inputs_[1]; }
1572 Handle<Object> name() const { return hydrogen()->name(); }
1576 class LLoadFunctionPrototype V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1578 explicit LLoadFunctionPrototype(LOperand* function) {
1579 inputs_[0] = function;
1582 DECLARE_CONCRETE_INSTRUCTION(LoadFunctionPrototype, "load-function-prototype")
1583 DECLARE_HYDROGEN_ACCESSOR(LoadFunctionPrototype)
1585 LOperand* function() { return inputs_[0]; }
1589 class LLoadRoot V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1591 DECLARE_CONCRETE_INSTRUCTION(LoadRoot, "load-root")
1592 DECLARE_HYDROGEN_ACCESSOR(LoadRoot)
1594 Heap::RootListIndex index() const { return hydrogen()->index(); }
1598 class LLoadKeyed V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1600 LLoadKeyed(LOperand* elements, LOperand* key) {
1601 inputs_[0] = elements;
1605 DECLARE_CONCRETE_INSTRUCTION(LoadKeyed, "load-keyed")
1606 DECLARE_HYDROGEN_ACCESSOR(LoadKeyed)
1608 bool is_external() const {
1609 return hydrogen()->is_external();
1611 bool is_fixed_typed_array() const {
1612 return hydrogen()->is_fixed_typed_array();
1614 bool is_typed_elements() const {
1615 return is_external() || is_fixed_typed_array();
1617 LOperand* elements() { return inputs_[0]; }
1618 LOperand* key() { return inputs_[1]; }
1619 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1620 uint32_t additional_index() const { return hydrogen()->index_offset(); }
1621 ElementsKind elements_kind() const {
1622 return hydrogen()->elements_kind();
1627 class LLoadKeyedGeneric V8_FINAL : public LTemplateInstruction<1, 3, 0> {
1629 LLoadKeyedGeneric(LOperand* context, LOperand* obj, LOperand* key) {
1630 inputs_[0] = context;
1635 DECLARE_CONCRETE_INSTRUCTION(LoadKeyedGeneric, "load-keyed-generic")
1637 LOperand* context() { return inputs_[0]; }
1638 LOperand* object() { return inputs_[1]; }
1639 LOperand* key() { return inputs_[2]; }
1643 class LLoadGlobalCell V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1645 DECLARE_CONCRETE_INSTRUCTION(LoadGlobalCell, "load-global-cell")
1646 DECLARE_HYDROGEN_ACCESSOR(LoadGlobalCell)
1650 class LLoadGlobalGeneric V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1652 explicit LLoadGlobalGeneric(LOperand* context, LOperand* global_object) {
1653 inputs_[0] = context;
1654 inputs_[1] = global_object;
1657 DECLARE_CONCRETE_INSTRUCTION(LoadGlobalGeneric, "load-global-generic")
1658 DECLARE_HYDROGEN_ACCESSOR(LoadGlobalGeneric)
1660 LOperand* context() { return inputs_[0]; }
1661 LOperand* global_object() { return inputs_[1]; }
1662 Handle<Object> name() const { return hydrogen()->name(); }
1663 bool for_typeof() const { return hydrogen()->for_typeof(); }
1667 class LStoreGlobalCell V8_FINAL : public LTemplateInstruction<0, 1, 1> {
1669 explicit LStoreGlobalCell(LOperand* value, LOperand* temp) {
1674 LOperand* value() { return inputs_[0]; }
1675 LOperand* temp() { return temps_[0]; }
1677 DECLARE_CONCRETE_INSTRUCTION(StoreGlobalCell, "store-global-cell")
1678 DECLARE_HYDROGEN_ACCESSOR(StoreGlobalCell)
1682 class LLoadContextSlot V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1684 explicit LLoadContextSlot(LOperand* context) {
1685 inputs_[0] = context;
1688 LOperand* context() { return inputs_[0]; }
1690 DECLARE_CONCRETE_INSTRUCTION(LoadContextSlot, "load-context-slot")
1691 DECLARE_HYDROGEN_ACCESSOR(LoadContextSlot)
1693 int slot_index() { return hydrogen()->slot_index(); }
1695 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1699 class LStoreContextSlot V8_FINAL : public LTemplateInstruction<0, 2, 1> {
1701 LStoreContextSlot(LOperand* context, LOperand* value, LOperand* temp) {
1702 inputs_[0] = context;
1707 LOperand* context() { return inputs_[0]; }
1708 LOperand* value() { return inputs_[1]; }
1709 LOperand* temp() { return temps_[0]; }
1711 DECLARE_CONCRETE_INSTRUCTION(StoreContextSlot, "store-context-slot")
1712 DECLARE_HYDROGEN_ACCESSOR(StoreContextSlot)
1714 int slot_index() { return hydrogen()->slot_index(); }
1716 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1720 class LPushArgument V8_FINAL : public LTemplateInstruction<0, 1, 0> {
1722 explicit LPushArgument(LOperand* value) {
1726 LOperand* value() { return inputs_[0]; }
1728 DECLARE_CONCRETE_INSTRUCTION(PushArgument, "push-argument")
1732 class LDrop V8_FINAL : public LTemplateInstruction<0, 0, 0> {
1734 explicit LDrop(int count) : count_(count) { }
1736 int count() const { return count_; }
1738 DECLARE_CONCRETE_INSTRUCTION(Drop, "drop")
1745 class LStoreCodeEntry V8_FINAL: public LTemplateInstruction<0, 1, 1> {
1747 LStoreCodeEntry(LOperand* function, LOperand* code_object) {
1748 inputs_[0] = function;
1749 temps_[0] = code_object;
1752 LOperand* function() { return inputs_[0]; }
1753 LOperand* code_object() { return temps_[0]; }
1755 virtual void PrintDataTo(StringStream* stream);
1757 DECLARE_CONCRETE_INSTRUCTION(StoreCodeEntry, "store-code-entry")
1758 DECLARE_HYDROGEN_ACCESSOR(StoreCodeEntry)
1762 class LInnerAllocatedObject V8_FINAL: public LTemplateInstruction<1, 2, 0> {
1764 LInnerAllocatedObject(LOperand* base_object, LOperand* offset) {
1765 inputs_[0] = base_object;
1766 inputs_[1] = offset;
1769 LOperand* base_object() const { return inputs_[0]; }
1770 LOperand* offset() const { return inputs_[1]; }
1772 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1774 DECLARE_CONCRETE_INSTRUCTION(InnerAllocatedObject, "inner-allocated-object")
1778 class LThisFunction V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1780 DECLARE_CONCRETE_INSTRUCTION(ThisFunction, "this-function")
1781 DECLARE_HYDROGEN_ACCESSOR(ThisFunction)
1785 class LContext V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1787 DECLARE_CONCRETE_INSTRUCTION(Context, "context")
1788 DECLARE_HYDROGEN_ACCESSOR(Context)
1792 class LDeclareGlobals V8_FINAL : public LTemplateInstruction<0, 1, 0> {
1794 explicit LDeclareGlobals(LOperand* context) {
1795 inputs_[0] = context;
1798 LOperand* context() { return inputs_[0]; }
1800 DECLARE_CONCRETE_INSTRUCTION(DeclareGlobals, "declare-globals")
1801 DECLARE_HYDROGEN_ACCESSOR(DeclareGlobals)
1805 class LCallJSFunction V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1807 explicit LCallJSFunction(LOperand* function) {
1808 inputs_[0] = function;
1811 LOperand* function() { return inputs_[0]; }
1813 DECLARE_CONCRETE_INSTRUCTION(CallJSFunction, "call-js-function")
1814 DECLARE_HYDROGEN_ACCESSOR(CallJSFunction)
1816 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1818 int arity() const { return hydrogen()->argument_count() - 1; }
1822 class LCallWithDescriptor V8_FINAL : public LTemplateResultInstruction<1> {
1824 LCallWithDescriptor(const CallInterfaceDescriptor* descriptor,
1825 ZoneList<LOperand*>& operands,
1827 : inputs_(descriptor->environment_length() + 1, zone) {
1828 ASSERT(descriptor->environment_length() + 1 == operands.length());
1829 inputs_.AddAll(operands, zone);
1832 LOperand* target() const { return inputs_[0]; }
1835 DECLARE_CONCRETE_INSTRUCTION(CallWithDescriptor, "call-with-descriptor")
1836 DECLARE_HYDROGEN_ACCESSOR(CallWithDescriptor)
1838 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1840 int arity() const { return hydrogen()->argument_count() - 1; }
1842 ZoneList<LOperand*> inputs_;
1844 // Iterator support.
1845 virtual int InputCount() V8_FINAL V8_OVERRIDE { return inputs_.length(); }
1846 virtual LOperand* InputAt(int i) V8_FINAL V8_OVERRIDE { return inputs_[i]; }
1848 virtual int TempCount() V8_FINAL V8_OVERRIDE { return 0; }
1849 virtual LOperand* TempAt(int i) V8_FINAL V8_OVERRIDE { return NULL; }
1853 class LInvokeFunction V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1855 LInvokeFunction(LOperand* context, LOperand* function) {
1856 inputs_[0] = context;
1857 inputs_[1] = function;
1860 LOperand* context() { return inputs_[0]; }
1861 LOperand* function() { return inputs_[1]; }
1863 DECLARE_CONCRETE_INSTRUCTION(InvokeFunction, "invoke-function")
1864 DECLARE_HYDROGEN_ACCESSOR(InvokeFunction)
1866 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1868 int arity() const { return hydrogen()->argument_count() - 1; }
1872 class LCallFunction V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1874 LCallFunction(LOperand* context, LOperand* function) {
1875 inputs_[0] = context;
1876 inputs_[1] = function;
1879 DECLARE_CONCRETE_INSTRUCTION(CallFunction, "call-function")
1880 DECLARE_HYDROGEN_ACCESSOR(CallFunction)
1882 LOperand* context() { return inputs_[0]; }
1883 LOperand* function() { return inputs_[1]; }
1884 int arity() const { return hydrogen()->argument_count() - 1; }
1888 class LCallNew V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1890 LCallNew(LOperand* context, LOperand* constructor) {
1891 inputs_[0] = context;
1892 inputs_[1] = constructor;
1895 LOperand* context() { return inputs_[0]; }
1896 LOperand* constructor() { return inputs_[1]; }
1898 DECLARE_CONCRETE_INSTRUCTION(CallNew, "call-new")
1899 DECLARE_HYDROGEN_ACCESSOR(CallNew)
1901 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1903 int arity() const { return hydrogen()->argument_count() - 1; }
1907 class LCallNewArray V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1909 LCallNewArray(LOperand* context, LOperand* constructor) {
1910 inputs_[0] = context;
1911 inputs_[1] = constructor;
1914 LOperand* context() { return inputs_[0]; }
1915 LOperand* constructor() { return inputs_[1]; }
1917 DECLARE_CONCRETE_INSTRUCTION(CallNewArray, "call-new-array")
1918 DECLARE_HYDROGEN_ACCESSOR(CallNewArray)
1920 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1922 int arity() const { return hydrogen()->argument_count() - 1; }
1926 class LCallRuntime V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1928 explicit LCallRuntime(LOperand* context) {
1929 inputs_[0] = context;
1932 LOperand* context() { return inputs_[0]; }
1934 DECLARE_CONCRETE_INSTRUCTION(CallRuntime, "call-runtime")
1935 DECLARE_HYDROGEN_ACCESSOR(CallRuntime)
1937 virtual bool ClobbersDoubleRegisters() const V8_OVERRIDE {
1938 return save_doubles() == kDontSaveFPRegs;
1941 const Runtime::Function* function() const { return hydrogen()->function(); }
1942 int arity() const { return hydrogen()->argument_count(); }
1943 SaveFPRegsMode save_doubles() const { return hydrogen()->save_doubles(); }
1947 class LInteger32ToDouble V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1949 explicit LInteger32ToDouble(LOperand* value) {
1953 LOperand* value() { return inputs_[0]; }
1955 DECLARE_CONCRETE_INSTRUCTION(Integer32ToDouble, "int32-to-double")
1959 class LInteger32ToSmi V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1961 explicit LInteger32ToSmi(LOperand* value) {
1965 LOperand* value() { return inputs_[0]; }
1967 DECLARE_CONCRETE_INSTRUCTION(Integer32ToSmi, "int32-to-smi")
1968 DECLARE_HYDROGEN_ACCESSOR(Change)
1972 class LUint32ToDouble V8_FINAL : public LTemplateInstruction<1, 1, 1> {
1974 explicit LUint32ToDouble(LOperand* value, LOperand* temp) {
1979 LOperand* value() { return inputs_[0]; }
1980 LOperand* temp() { return temps_[0]; }
1982 DECLARE_CONCRETE_INSTRUCTION(Uint32ToDouble, "uint32-to-double")
1986 class LUint32ToSmi V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1988 explicit LUint32ToSmi(LOperand* value) {
1992 LOperand* value() { return inputs_[0]; }
1994 DECLARE_CONCRETE_INSTRUCTION(Uint32ToSmi, "uint32-to-smi")
1995 DECLARE_HYDROGEN_ACCESSOR(Change)
1999 class LNumberTagI V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2001 explicit LNumberTagI(LOperand* value) {
2005 LOperand* value() { return inputs_[0]; }
2007 DECLARE_CONCRETE_INSTRUCTION(NumberTagI, "number-tag-i")
2011 class LNumberTagU V8_FINAL : public LTemplateInstruction<1, 1, 2> {
2013 LNumberTagU(LOperand* value, LOperand* temp1, LOperand* temp2) {
2019 LOperand* value() { return inputs_[0]; }
2020 LOperand* temp1() { return temps_[0]; }
2021 LOperand* temp2() { return temps_[1]; }
2023 DECLARE_CONCRETE_INSTRUCTION(NumberTagU, "number-tag-u")
2027 class LNumberTagD V8_FINAL : public LTemplateInstruction<1, 1, 1> {
2029 explicit LNumberTagD(LOperand* value, LOperand* temp) {
2034 LOperand* value() { return inputs_[0]; }
2035 LOperand* temp() { return temps_[0]; }
2037 DECLARE_CONCRETE_INSTRUCTION(NumberTagD, "number-tag-d")
2038 DECLARE_HYDROGEN_ACCESSOR(Change)
2042 // Sometimes truncating conversion from a tagged value to an int32.
2043 class LDoubleToI V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2045 explicit LDoubleToI(LOperand* value) {
2049 LOperand* value() { return inputs_[0]; }
2051 DECLARE_CONCRETE_INSTRUCTION(DoubleToI, "double-to-i")
2052 DECLARE_HYDROGEN_ACCESSOR(UnaryOperation)
2054 bool truncating() { return hydrogen()->CanTruncateToInt32(); }
2058 class LDoubleToSmi V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2060 explicit LDoubleToSmi(LOperand* value) {
2064 LOperand* value() { return inputs_[0]; }
2066 DECLARE_CONCRETE_INSTRUCTION(DoubleToSmi, "double-to-smi")
2067 DECLARE_HYDROGEN_ACCESSOR(UnaryOperation)
2071 // Truncating conversion from a tagged value to an int32.
2072 class LTaggedToI V8_FINAL : public LTemplateInstruction<1, 1, 1> {
2074 LTaggedToI(LOperand* value, LOperand* temp) {
2079 LOperand* value() { return inputs_[0]; }
2080 LOperand* temp() { return temps_[0]; }
2082 DECLARE_CONCRETE_INSTRUCTION(TaggedToI, "tagged-to-i")
2083 DECLARE_HYDROGEN_ACCESSOR(Change)
2085 bool truncating() { return hydrogen()->CanTruncateToInt32(); }
2089 class LSmiTag V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2091 explicit LSmiTag(LOperand* value) {
2095 LOperand* value() { return inputs_[0]; }
2097 DECLARE_CONCRETE_INSTRUCTION(SmiTag, "smi-tag")
2101 class LNumberUntagD V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2103 explicit LNumberUntagD(LOperand* value) {
2107 LOperand* value() { return inputs_[0]; }
2109 DECLARE_CONCRETE_INSTRUCTION(NumberUntagD, "double-untag")
2110 DECLARE_HYDROGEN_ACCESSOR(Change);
2114 class LSmiUntag V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2116 LSmiUntag(LOperand* value, bool needs_check)
2117 : needs_check_(needs_check) {
2121 LOperand* value() { return inputs_[0]; }
2122 bool needs_check() const { return needs_check_; }
2124 DECLARE_CONCRETE_INSTRUCTION(SmiUntag, "smi-untag")
2131 class LStoreNamedField V8_FINAL : public LTemplateInstruction<0, 2, 1> {
2133 LStoreNamedField(LOperand* object, LOperand* value, LOperand* temp) {
2134 inputs_[0] = object;
2139 LOperand* object() { return inputs_[0]; }
2140 LOperand* value() { return inputs_[1]; }
2141 LOperand* temp() { return temps_[0]; }
2143 DECLARE_CONCRETE_INSTRUCTION(StoreNamedField, "store-named-field")
2144 DECLARE_HYDROGEN_ACCESSOR(StoreNamedField)
2146 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
2148 Handle<Map> transition() const { return hydrogen()->transition_map(); }
2149 Representation representation() const {
2150 return hydrogen()->field_representation();
2155 class LStoreNamedGeneric V8_FINAL : public LTemplateInstruction<0, 3, 0> {
2157 LStoreNamedGeneric(LOperand* context, LOperand* object, LOperand* value) {
2158 inputs_[0] = context;
2159 inputs_[1] = object;
2163 LOperand* context() { return inputs_[0]; }
2164 LOperand* object() { return inputs_[1]; }
2165 LOperand* value() { return inputs_[2]; }
2167 DECLARE_CONCRETE_INSTRUCTION(StoreNamedGeneric, "store-named-generic")
2168 DECLARE_HYDROGEN_ACCESSOR(StoreNamedGeneric)
2170 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
2172 Handle<Object> name() const { return hydrogen()->name(); }
2173 StrictModeFlag strict_mode_flag() { return hydrogen()->strict_mode_flag(); }
2177 class LStoreKeyed V8_FINAL : public LTemplateInstruction<0, 3, 0> {
2179 LStoreKeyed(LOperand* object, LOperand* key, LOperand* value) {
2180 inputs_[0] = object;
2185 bool is_external() const { return hydrogen()->is_external(); }
2186 bool is_fixed_typed_array() const {
2187 return hydrogen()->is_fixed_typed_array();
2189 bool is_typed_elements() const {
2190 return is_external() || is_fixed_typed_array();
2192 LOperand* elements() { return inputs_[0]; }
2193 LOperand* key() { return inputs_[1]; }
2194 LOperand* value() { return inputs_[2]; }
2195 ElementsKind elements_kind() const { return hydrogen()->elements_kind(); }
2197 DECLARE_CONCRETE_INSTRUCTION(StoreKeyed, "store-keyed")
2198 DECLARE_HYDROGEN_ACCESSOR(StoreKeyed)
2200 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
2201 bool NeedsCanonicalization() { return hydrogen()->NeedsCanonicalization(); }
2202 uint32_t additional_index() const { return hydrogen()->index_offset(); }
2206 class LStoreKeyedGeneric V8_FINAL : public LTemplateInstruction<0, 4, 0> {
2208 LStoreKeyedGeneric(LOperand* context,
2212 inputs_[0] = context;
2213 inputs_[1] = object;
2218 LOperand* context() { return inputs_[0]; }
2219 LOperand* object() { return inputs_[1]; }
2220 LOperand* key() { return inputs_[2]; }
2221 LOperand* value() { return inputs_[3]; }
2223 DECLARE_CONCRETE_INSTRUCTION(StoreKeyedGeneric, "store-keyed-generic")
2224 DECLARE_HYDROGEN_ACCESSOR(StoreKeyedGeneric)
2226 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
2228 StrictModeFlag strict_mode_flag() { return hydrogen()->strict_mode_flag(); }
2232 class LTransitionElementsKind V8_FINAL : public LTemplateInstruction<0, 2, 2> {
2234 LTransitionElementsKind(LOperand* object,
2236 LOperand* new_map_temp,
2238 inputs_[0] = object;
2239 inputs_[1] = context;
2240 temps_[0] = new_map_temp;
2244 LOperand* object() { return inputs_[0]; }
2245 LOperand* context() { return inputs_[1]; }
2246 LOperand* new_map_temp() { return temps_[0]; }
2247 LOperand* temp() { return temps_[1]; }
2249 DECLARE_CONCRETE_INSTRUCTION(TransitionElementsKind,
2250 "transition-elements-kind")
2251 DECLARE_HYDROGEN_ACCESSOR(TransitionElementsKind)
2253 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
2255 Handle<Map> original_map() { return hydrogen()->original_map().handle(); }
2256 Handle<Map> transitioned_map() {
2257 return hydrogen()->transitioned_map().handle();
2259 ElementsKind from_kind() { return hydrogen()->from_kind(); }
2260 ElementsKind to_kind() { return hydrogen()->to_kind(); }
2264 class LTrapAllocationMemento V8_FINAL : public LTemplateInstruction<0, 1, 1> {
2266 LTrapAllocationMemento(LOperand* object,
2268 inputs_[0] = object;
2272 LOperand* object() { return inputs_[0]; }
2273 LOperand* temp() { return temps_[0]; }
2275 DECLARE_CONCRETE_INSTRUCTION(TrapAllocationMemento,
2276 "trap-allocation-memento")
2280 class LStringAdd V8_FINAL : public LTemplateInstruction<1, 3, 0> {
2282 LStringAdd(LOperand* context, LOperand* left, LOperand* right) {
2283 inputs_[0] = context;
2288 LOperand* context() { return inputs_[0]; }
2289 LOperand* left() { return inputs_[1]; }
2290 LOperand* right() { return inputs_[2]; }
2292 DECLARE_CONCRETE_INSTRUCTION(StringAdd, "string-add")
2293 DECLARE_HYDROGEN_ACCESSOR(StringAdd)
2297 class LStringCharCodeAt V8_FINAL : public LTemplateInstruction<1, 3, 0> {
2299 LStringCharCodeAt(LOperand* context, LOperand* string, LOperand* index) {
2300 inputs_[0] = context;
2301 inputs_[1] = string;
2305 LOperand* context() { return inputs_[0]; }
2306 LOperand* string() { return inputs_[1]; }
2307 LOperand* index() { return inputs_[2]; }
2309 DECLARE_CONCRETE_INSTRUCTION(StringCharCodeAt, "string-char-code-at")
2310 DECLARE_HYDROGEN_ACCESSOR(StringCharCodeAt)
2314 class LStringCharFromCode V8_FINAL : public LTemplateInstruction<1, 2, 0> {
2316 explicit LStringCharFromCode(LOperand* context, LOperand* char_code) {
2317 inputs_[0] = context;
2318 inputs_[1] = char_code;
2321 LOperand* context() { return inputs_[0]; }
2322 LOperand* char_code() { return inputs_[1]; }
2324 DECLARE_CONCRETE_INSTRUCTION(StringCharFromCode, "string-char-from-code")
2325 DECLARE_HYDROGEN_ACCESSOR(StringCharFromCode)
2329 class LCheckValue V8_FINAL : public LTemplateInstruction<0, 1, 0> {
2331 explicit LCheckValue(LOperand* value) {
2335 LOperand* value() { return inputs_[0]; }
2337 DECLARE_CONCRETE_INSTRUCTION(CheckValue, "check-value")
2338 DECLARE_HYDROGEN_ACCESSOR(CheckValue)
2342 class LCheckInstanceType V8_FINAL : public LTemplateInstruction<0, 1, 0> {
2344 explicit LCheckInstanceType(LOperand* value) {
2348 LOperand* value() { return inputs_[0]; }
2350 DECLARE_CONCRETE_INSTRUCTION(CheckInstanceType, "check-instance-type")
2351 DECLARE_HYDROGEN_ACCESSOR(CheckInstanceType)
2355 class LCheckMaps V8_FINAL : public LTemplateInstruction<0, 1, 0> {
2357 explicit LCheckMaps(LOperand* value) {
2361 LOperand* value() { return inputs_[0]; }
2363 DECLARE_CONCRETE_INSTRUCTION(CheckMaps, "check-maps")
2364 DECLARE_HYDROGEN_ACCESSOR(CheckMaps)
2368 class LCheckSmi V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2370 explicit LCheckSmi(LOperand* value) {
2374 LOperand* value() { return inputs_[0]; }
2376 DECLARE_CONCRETE_INSTRUCTION(CheckSmi, "check-smi")
2380 class LClampDToUint8 V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2382 explicit LClampDToUint8(LOperand* unclamped) {
2383 inputs_[0] = unclamped;
2386 LOperand* unclamped() { return inputs_[0]; }
2388 DECLARE_CONCRETE_INSTRUCTION(ClampDToUint8, "clamp-d-to-uint8")
2392 class LClampIToUint8 V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2394 explicit LClampIToUint8(LOperand* unclamped) {
2395 inputs_[0] = unclamped;
2398 LOperand* unclamped() { return inputs_[0]; }
2400 DECLARE_CONCRETE_INSTRUCTION(ClampIToUint8, "clamp-i-to-uint8")
2404 class LClampTToUint8 V8_FINAL : public LTemplateInstruction<1, 1, 1> {
2406 LClampTToUint8(LOperand* unclamped,
2407 LOperand* temp_xmm) {
2408 inputs_[0] = unclamped;
2409 temps_[0] = temp_xmm;
2412 LOperand* unclamped() { return inputs_[0]; }
2413 LOperand* temp_xmm() { return temps_[0]; }
2415 DECLARE_CONCRETE_INSTRUCTION(ClampTToUint8, "clamp-t-to-uint8")
2419 class LCheckNonSmi V8_FINAL : public LTemplateInstruction<0, 1, 0> {
2421 explicit LCheckNonSmi(LOperand* value) {
2425 LOperand* value() { return inputs_[0]; }
2427 DECLARE_CONCRETE_INSTRUCTION(CheckNonSmi, "check-non-smi")
2428 DECLARE_HYDROGEN_ACCESSOR(CheckHeapObject)
2432 class LAllocate V8_FINAL : public LTemplateInstruction<1, 2, 1> {
2434 LAllocate(LOperand* context, LOperand* size, LOperand* temp) {
2435 inputs_[0] = context;
2440 LOperand* context() { return inputs_[0]; }
2441 LOperand* size() { return inputs_[1]; }
2442 LOperand* temp() { return temps_[0]; }
2444 DECLARE_CONCRETE_INSTRUCTION(Allocate, "allocate")
2445 DECLARE_HYDROGEN_ACCESSOR(Allocate)
2449 class LRegExpLiteral V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2451 explicit LRegExpLiteral(LOperand* context) {
2452 inputs_[0] = context;
2455 LOperand* context() { return inputs_[0]; }
2457 DECLARE_CONCRETE_INSTRUCTION(RegExpLiteral, "regexp-literal")
2458 DECLARE_HYDROGEN_ACCESSOR(RegExpLiteral)
2462 class LFunctionLiteral V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2464 explicit LFunctionLiteral(LOperand* context) {
2465 inputs_[0] = context;
2468 LOperand* context() { return inputs_[0]; }
2470 DECLARE_CONCRETE_INSTRUCTION(FunctionLiteral, "function-literal")
2471 DECLARE_HYDROGEN_ACCESSOR(FunctionLiteral)
2475 class LToFastProperties V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2477 explicit LToFastProperties(LOperand* value) {
2481 LOperand* value() { return inputs_[0]; }
2483 DECLARE_CONCRETE_INSTRUCTION(ToFastProperties, "to-fast-properties")
2484 DECLARE_HYDROGEN_ACCESSOR(ToFastProperties)
2488 class LTypeof V8_FINAL : public LTemplateInstruction<1, 2, 0> {
2490 LTypeof(LOperand* context, LOperand* value) {
2491 inputs_[0] = context;
2495 LOperand* context() { return inputs_[0]; }
2496 LOperand* value() { return inputs_[1]; }
2498 DECLARE_CONCRETE_INSTRUCTION(Typeof, "typeof")
2502 class LTypeofIsAndBranch V8_FINAL : public LControlInstruction<1, 0> {
2504 explicit LTypeofIsAndBranch(LOperand* value) {
2508 LOperand* value() { return inputs_[0]; }
2510 DECLARE_CONCRETE_INSTRUCTION(TypeofIsAndBranch, "typeof-is-and-branch")
2511 DECLARE_HYDROGEN_ACCESSOR(TypeofIsAndBranch)
2513 Handle<String> type_literal() { return hydrogen()->type_literal(); }
2515 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
2519 class LIsConstructCallAndBranch V8_FINAL : public LControlInstruction<0, 1> {
2521 explicit LIsConstructCallAndBranch(LOperand* temp) {
2525 LOperand* temp() { return temps_[0]; }
2527 DECLARE_CONCRETE_INSTRUCTION(IsConstructCallAndBranch,
2528 "is-construct-call-and-branch")
2529 DECLARE_HYDROGEN_ACCESSOR(IsConstructCallAndBranch)
2533 class LOsrEntry V8_FINAL : public LTemplateInstruction<0, 0, 0> {
2537 virtual bool HasInterestingComment(LCodeGen* gen) const V8_OVERRIDE {
2540 DECLARE_CONCRETE_INSTRUCTION(OsrEntry, "osr-entry")
2544 class LStackCheck V8_FINAL : public LTemplateInstruction<0, 1, 0> {
2546 explicit LStackCheck(LOperand* context) {
2547 inputs_[0] = context;
2550 LOperand* context() { return inputs_[0]; }
2552 DECLARE_CONCRETE_INSTRUCTION(StackCheck, "stack-check")
2553 DECLARE_HYDROGEN_ACCESSOR(StackCheck)
2555 Label* done_label() { return &done_label_; }
2562 class LForInPrepareMap V8_FINAL : public LTemplateInstruction<1, 2, 0> {
2564 LForInPrepareMap(LOperand* context, LOperand* object) {
2565 inputs_[0] = context;
2566 inputs_[1] = object;
2569 LOperand* context() { return inputs_[0]; }
2570 LOperand* object() { return inputs_[1]; }
2572 DECLARE_CONCRETE_INSTRUCTION(ForInPrepareMap, "for-in-prepare-map")
2576 class LForInCacheArray V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2578 explicit LForInCacheArray(LOperand* map) {
2582 LOperand* map() { return inputs_[0]; }
2584 DECLARE_CONCRETE_INSTRUCTION(ForInCacheArray, "for-in-cache-array")
2587 return HForInCacheArray::cast(this->hydrogen_value())->idx();
2592 class LCheckMapValue V8_FINAL : public LTemplateInstruction<0, 2, 0> {
2594 LCheckMapValue(LOperand* value, LOperand* map) {
2599 LOperand* value() { return inputs_[0]; }
2600 LOperand* map() { return inputs_[1]; }
2602 DECLARE_CONCRETE_INSTRUCTION(CheckMapValue, "check-map-value")
2606 class LLoadFieldByIndex V8_FINAL : public LTemplateInstruction<1, 2, 0> {
2608 LLoadFieldByIndex(LOperand* object, LOperand* index) {
2609 inputs_[0] = object;
2613 LOperand* object() { return inputs_[0]; }
2614 LOperand* index() { return inputs_[1]; }
2616 DECLARE_CONCRETE_INSTRUCTION(LoadFieldByIndex, "load-field-by-index")
2620 class LChunkBuilder;
2621 class LPlatformChunk V8_FINAL : public LChunk {
2623 LPlatformChunk(CompilationInfo* info, HGraph* graph)
2624 : LChunk(info, graph) { }
2626 int GetNextSpillIndex(RegisterKind kind);
2627 LOperand* GetNextSpillSlot(RegisterKind kind);
2631 class LChunkBuilder V8_FINAL : public LChunkBuilderBase {
2633 LChunkBuilder(CompilationInfo* info, HGraph* graph, LAllocator* allocator)
2634 : LChunkBuilderBase(graph->zone()),
2639 current_instruction_(NULL),
2640 current_block_(NULL),
2642 allocator_(allocator),
2643 instruction_pending_deoptimization_environment_(NULL),
2644 pending_deoptimization_ast_id_(BailoutId::None()) { }
2646 // Build the sequence for the graph.
2647 LPlatformChunk* Build();
2649 LInstruction* CheckElideControlInstruction(HControlInstruction* instr);
2651 // Declare methods that deal with the individual node types.
2652 #define DECLARE_DO(type) LInstruction* Do##type(H##type* node);
2653 HYDROGEN_CONCRETE_INSTRUCTION_LIST(DECLARE_DO)
2656 LInstruction* DoMathFloor(HUnaryMathOperation* instr);
2657 LInstruction* DoMathRound(HUnaryMathOperation* instr);
2658 LInstruction* DoMathAbs(HUnaryMathOperation* instr);
2659 LInstruction* DoMathLog(HUnaryMathOperation* instr);
2660 LInstruction* DoMathExp(HUnaryMathOperation* instr);
2661 LInstruction* DoMathSqrt(HUnaryMathOperation* instr);
2662 LInstruction* DoMathPowHalf(HUnaryMathOperation* instr);
2663 LInstruction* DoMathClz32(HUnaryMathOperation* instr);
2664 LInstruction* DoDivByPowerOf2I(HDiv* instr);
2665 LInstruction* DoDivByConstI(HDiv* instr);
2666 LInstruction* DoDivI(HBinaryOperation* instr);
2667 LInstruction* DoModByPowerOf2I(HMod* instr);
2668 LInstruction* DoModByConstI(HMod* instr);
2669 LInstruction* DoModI(HMod* instr);
2670 LInstruction* DoFlooringDivByPowerOf2I(HMathFloorOfDiv* instr);
2671 LInstruction* DoFlooringDivByConstI(HMathFloorOfDiv* instr);
2681 LPlatformChunk* chunk() const { return chunk_; }
2682 CompilationInfo* info() const { return info_; }
2683 HGraph* graph() const { return graph_; }
2685 bool is_unused() const { return status_ == UNUSED; }
2686 bool is_building() const { return status_ == BUILDING; }
2687 bool is_done() const { return status_ == DONE; }
2688 bool is_aborted() const { return status_ == ABORTED; }
2690 void Abort(BailoutReason reason);
2692 // Methods for getting operands for Use / Define / Temp.
2693 LUnallocated* ToUnallocated(Register reg);
2694 LUnallocated* ToUnallocated(XMMRegister reg);
2696 // Methods for setting up define-use relationships.
2697 MUST_USE_RESULT LOperand* Use(HValue* value, LUnallocated* operand);
2698 MUST_USE_RESULT LOperand* UseFixed(HValue* value, Register fixed_register);
2699 MUST_USE_RESULT LOperand* UseFixedDouble(HValue* value,
2700 XMMRegister fixed_register);
2702 // A value that is guaranteed to be allocated to a register.
2703 // Operand created by UseRegister is guaranteed to be live until the end of
2704 // instruction. This means that register allocator will not reuse it's
2705 // register for any other operand inside instruction.
2706 // Operand created by UseRegisterAtStart is guaranteed to be live only at
2707 // instruction start. Register allocator is free to assign the same register
2708 // to some other operand used inside instruction (i.e. temporary or
2710 MUST_USE_RESULT LOperand* UseRegister(HValue* value);
2711 MUST_USE_RESULT LOperand* UseRegisterAtStart(HValue* value);
2713 // An input operand in a register that may be trashed.
2714 MUST_USE_RESULT LOperand* UseTempRegister(HValue* value);
2716 // An input operand in a register that may be trashed or a constant operand.
2717 MUST_USE_RESULT LOperand* UseTempRegisterOrConstant(HValue* value);
2719 // An input operand in a register or stack slot.
2720 MUST_USE_RESULT LOperand* Use(HValue* value);
2721 MUST_USE_RESULT LOperand* UseAtStart(HValue* value);
2723 // An input operand in a register, stack slot or a constant operand.
2724 MUST_USE_RESULT LOperand* UseOrConstant(HValue* value);
2725 MUST_USE_RESULT LOperand* UseOrConstantAtStart(HValue* value);
2727 // An input operand in a register or a constant operand.
2728 MUST_USE_RESULT LOperand* UseRegisterOrConstant(HValue* value);
2729 MUST_USE_RESULT LOperand* UseRegisterOrConstantAtStart(HValue* value);
2731 // An input operand in a constant operand.
2732 MUST_USE_RESULT LOperand* UseConstant(HValue* value);
2734 // An input operand in register, stack slot or a constant operand.
2735 // Will not be moved to a register even if one is freely available.
2736 virtual MUST_USE_RESULT LOperand* UseAny(HValue* value) V8_OVERRIDE;
2738 // Temporary operand that must be in a register.
2739 MUST_USE_RESULT LUnallocated* TempRegister();
2740 MUST_USE_RESULT LOperand* FixedTemp(Register reg);
2741 MUST_USE_RESULT LOperand* FixedTemp(XMMRegister reg);
2743 // Methods for setting up define-use relationships.
2744 // Return the same instruction that they are passed.
2745 LInstruction* Define(LTemplateResultInstruction<1>* instr,
2746 LUnallocated* result);
2747 LInstruction* DefineAsRegister(LTemplateResultInstruction<1>* instr);
2748 LInstruction* DefineAsSpilled(LTemplateResultInstruction<1>* instr,
2750 LInstruction* DefineSameAsFirst(LTemplateResultInstruction<1>* instr);
2751 LInstruction* DefineFixed(LTemplateResultInstruction<1>* instr,
2753 LInstruction* DefineFixedDouble(LTemplateResultInstruction<1>* instr,
2755 // Assigns an environment to an instruction. An instruction which can
2756 // deoptimize must have an environment.
2757 LInstruction* AssignEnvironment(LInstruction* instr);
2758 // Assigns a pointer map to an instruction. An instruction which can
2759 // trigger a GC or a lazy deoptimization must have a pointer map.
2760 LInstruction* AssignPointerMap(LInstruction* instr);
2762 enum CanDeoptimize { CAN_DEOPTIMIZE_EAGERLY, CANNOT_DEOPTIMIZE_EAGERLY };
2764 // Marks a call for the register allocator. Assigns a pointer map to
2765 // support GC and lazy deoptimization. Assigns an environment to support
2766 // eager deoptimization if CAN_DEOPTIMIZE_EAGERLY.
2767 LInstruction* MarkAsCall(
2768 LInstruction* instr,
2769 HInstruction* hinstr,
2770 CanDeoptimize can_deoptimize = CANNOT_DEOPTIMIZE_EAGERLY);
2772 void VisitInstruction(HInstruction* current);
2774 void DoBasicBlock(HBasicBlock* block, HBasicBlock* next_block);
2775 LInstruction* DoShift(Token::Value op, HBitwiseBinaryOperation* instr);
2776 LInstruction* DoArithmeticD(Token::Value op,
2777 HArithmeticBinaryOperation* instr);
2778 LInstruction* DoArithmeticT(Token::Value op,
2779 HBinaryOperation* instr);
2781 LPlatformChunk* chunk_;
2782 CompilationInfo* info_;
2783 HGraph* const graph_;
2785 HInstruction* current_instruction_;
2786 HBasicBlock* current_block_;
2787 HBasicBlock* next_block_;
2788 LAllocator* allocator_;
2789 LInstruction* instruction_pending_deoptimization_environment_;
2790 BailoutId pending_deoptimization_ast_id_;
2792 DISALLOW_COPY_AND_ASSIGN(LChunkBuilder);
2795 #undef DECLARE_HYDROGEN_ACCESSOR
2796 #undef DECLARE_CONCRETE_INSTRUCTION
2798 } } // namespace v8::int
2800 #endif // V8_X64_LITHIUM_X64_H_