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) \
95 V(FlooringDivByConstI) \
96 V(FlooringDivByPowerOf2I) \
100 V(GetCachedArrayIndex) \
102 V(HasCachedArrayIndexAndBranch) \
103 V(HasInstanceTypeAndBranch) \
104 V(InnerAllocatedObject) \
106 V(InstanceOfKnownGlobal) \
108 V(Integer32ToDouble) \
111 V(IsConstructCallAndBranch) \
112 V(IsObjectAndBranch) \
113 V(IsStringAndBranch) \
115 V(IsUndetectableAndBranch) \
120 V(LoadFieldByIndex) \
121 V(LoadFunctionPrototype) \
123 V(LoadGlobalGeneric) \
125 V(LoadKeyedGeneric) \
127 V(LoadNamedGeneric) \
151 V(SeqStringGetChar) \
152 V(SeqStringSetChar) \
158 V(StoreContextSlot) \
161 V(StoreKeyedGeneric) \
163 V(StoreNamedGeneric) \
165 V(StringCharCodeAt) \
166 V(StringCharFromCode) \
167 V(StringCompareAndBranch) \
171 V(ToFastProperties) \
172 V(TransitionElementsKind) \
173 V(TrapAllocationMemento) \
175 V(TypeofIsAndBranch) \
182 #define DECLARE_CONCRETE_INSTRUCTION(type, mnemonic) \
183 virtual Opcode opcode() const V8_FINAL V8_OVERRIDE { \
184 return LInstruction::k##type; \
186 virtual void CompileToNative(LCodeGen* generator) V8_FINAL V8_OVERRIDE; \
187 virtual const char* Mnemonic() const V8_FINAL V8_OVERRIDE { \
190 static L##type* cast(LInstruction* instr) { \
191 ASSERT(instr->Is##type()); \
192 return reinterpret_cast<L##type*>(instr); \
196 #define DECLARE_HYDROGEN_ACCESSOR(type) \
197 H##type* hydrogen() const { \
198 return H##type::cast(hydrogen_value()); \
202 class LInstruction : public ZoneObject {
205 : environment_(NULL),
206 hydrogen_value_(NULL),
207 bit_field_(IsCallBits::encode(false)) {
210 virtual ~LInstruction() {}
212 virtual void CompileToNative(LCodeGen* generator) = 0;
213 virtual const char* Mnemonic() const = 0;
214 virtual void PrintTo(StringStream* stream);
215 virtual void PrintDataTo(StringStream* stream);
216 virtual void PrintOutputOperandTo(StringStream* stream);
219 // Declare a unique enum value for each instruction.
220 #define DECLARE_OPCODE(type) k##type,
221 LITHIUM_CONCRETE_INSTRUCTION_LIST(DECLARE_OPCODE)
222 kNumberOfInstructions
223 #undef DECLARE_OPCODE
226 virtual Opcode opcode() const = 0;
228 // Declare non-virtual type testers for all leaf IR classes.
229 #define DECLARE_PREDICATE(type) \
230 bool Is##type() const { return opcode() == k##type; }
231 LITHIUM_CONCRETE_INSTRUCTION_LIST(DECLARE_PREDICATE)
232 #undef DECLARE_PREDICATE
234 // Declare virtual predicates for instructions that don't have
236 virtual bool IsGap() const { return false; }
238 virtual bool IsControl() const { return false; }
240 void set_environment(LEnvironment* env) { environment_ = env; }
241 LEnvironment* environment() const { return environment_; }
242 bool HasEnvironment() const { return environment_ != NULL; }
244 void set_pointer_map(LPointerMap* p) { pointer_map_.set(p); }
245 LPointerMap* pointer_map() const { return pointer_map_.get(); }
246 bool HasPointerMap() const { return pointer_map_.is_set(); }
248 void set_hydrogen_value(HValue* value) { hydrogen_value_ = value; }
249 HValue* hydrogen_value() const { return hydrogen_value_; }
251 void MarkAsCall() { bit_field_ = IsCallBits::update(bit_field_, true); }
252 bool IsCall() const { return IsCallBits::decode(bit_field_); }
254 // Interface to the register allocator and iterators.
255 bool ClobbersTemps() const { return IsCall(); }
256 bool ClobbersRegisters() const { return IsCall(); }
257 virtual bool ClobbersDoubleRegisters() const { return IsCall(); }
259 virtual void SetDeferredLazyDeoptimizationEnvironment(LEnvironment* env) { }
261 // Interface to the register allocator and iterators.
262 bool IsMarkedAsCall() const { return IsCall(); }
264 virtual bool HasResult() const = 0;
265 virtual LOperand* result() const = 0;
267 LOperand* FirstInput() { return InputAt(0); }
268 LOperand* Output() { return HasResult() ? result() : NULL; }
270 virtual bool HasInterestingComment(LCodeGen* gen) const { return true; }
278 friend class InputIterator;
279 virtual int InputCount() = 0;
280 virtual LOperand* InputAt(int i) = 0;
282 friend class TempIterator;
283 virtual int TempCount() = 0;
284 virtual LOperand* TempAt(int i) = 0;
286 class IsCallBits: public BitField<bool, 0, 1> {};
288 LEnvironment* environment_;
289 SetOncePointer<LPointerMap> pointer_map_;
290 HValue* hydrogen_value_;
295 // R = number of result operands (0 or 1).
297 class LTemplateResultInstruction : public LInstruction {
299 // Allow 0 or 1 output operands.
300 STATIC_ASSERT(R == 0 || R == 1);
301 virtual bool HasResult() const V8_FINAL V8_OVERRIDE {
302 return R != 0 && result() != NULL;
304 void set_result(LOperand* operand) { results_[0] = operand; }
305 LOperand* result() const { return results_[0]; }
308 EmbeddedContainer<LOperand*, R> results_;
312 // R = number of result operands (0 or 1).
313 // I = number of input operands.
314 // T = number of temporary operands.
315 template<int R, int I, int T>
316 class LTemplateInstruction : public LTemplateResultInstruction<R> {
318 EmbeddedContainer<LOperand*, I> inputs_;
319 EmbeddedContainer<LOperand*, T> temps_;
323 virtual int InputCount() V8_FINAL V8_OVERRIDE { return I; }
324 virtual LOperand* InputAt(int i) V8_FINAL V8_OVERRIDE { return inputs_[i]; }
326 virtual int TempCount() V8_FINAL V8_OVERRIDE { return T; }
327 virtual LOperand* TempAt(int i) V8_FINAL V8_OVERRIDE { return temps_[i]; }
331 class LGap : public LTemplateInstruction<0, 0, 0> {
333 explicit LGap(HBasicBlock* block)
335 parallel_moves_[BEFORE] = NULL;
336 parallel_moves_[START] = NULL;
337 parallel_moves_[END] = NULL;
338 parallel_moves_[AFTER] = NULL;
341 // Can't use the DECLARE-macro here because of sub-classes.
342 virtual bool IsGap() const V8_FINAL V8_OVERRIDE { return true; }
343 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
344 static LGap* cast(LInstruction* instr) {
345 ASSERT(instr->IsGap());
346 return reinterpret_cast<LGap*>(instr);
349 bool IsRedundant() const;
351 HBasicBlock* block() const { return block_; }
358 FIRST_INNER_POSITION = BEFORE,
359 LAST_INNER_POSITION = AFTER
362 LParallelMove* GetOrCreateParallelMove(InnerPosition pos,
364 if (parallel_moves_[pos] == NULL) {
365 parallel_moves_[pos] = new(zone) LParallelMove(zone);
367 return parallel_moves_[pos];
370 LParallelMove* GetParallelMove(InnerPosition pos) {
371 return parallel_moves_[pos];
375 LParallelMove* parallel_moves_[LAST_INNER_POSITION + 1];
380 class LInstructionGap V8_FINAL : public LGap {
382 explicit LInstructionGap(HBasicBlock* block) : LGap(block) { }
384 virtual bool HasInterestingComment(LCodeGen* gen) const V8_OVERRIDE {
385 return !IsRedundant();
388 DECLARE_CONCRETE_INSTRUCTION(InstructionGap, "gap")
392 class LGoto V8_FINAL : public LTemplateInstruction<0, 0, 0> {
394 explicit LGoto(HBasicBlock* block) : block_(block) { }
396 virtual bool HasInterestingComment(LCodeGen* gen) const V8_OVERRIDE;
397 DECLARE_CONCRETE_INSTRUCTION(Goto, "goto")
398 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
399 virtual bool IsControl() const V8_OVERRIDE { return true; }
401 int block_id() const { return block_->block_id(); }
408 class LLazyBailout V8_FINAL : public LTemplateInstruction<0, 0, 0> {
410 LLazyBailout() : gap_instructions_size_(0) { }
412 DECLARE_CONCRETE_INSTRUCTION(LazyBailout, "lazy-bailout")
414 void set_gap_instructions_size(int gap_instructions_size) {
415 gap_instructions_size_ = gap_instructions_size;
417 int gap_instructions_size() { return gap_instructions_size_; }
420 int gap_instructions_size_;
424 class LDummy V8_FINAL : public LTemplateInstruction<1, 0, 0> {
426 explicit LDummy() { }
427 DECLARE_CONCRETE_INSTRUCTION(Dummy, "dummy")
431 class LDummyUse V8_FINAL : public LTemplateInstruction<1, 1, 0> {
433 explicit LDummyUse(LOperand* value) {
436 DECLARE_CONCRETE_INSTRUCTION(DummyUse, "dummy-use")
440 class LDeoptimize V8_FINAL : public LTemplateInstruction<0, 0, 0> {
442 DECLARE_CONCRETE_INSTRUCTION(Deoptimize, "deoptimize")
443 DECLARE_HYDROGEN_ACCESSOR(Deoptimize)
447 class LLabel V8_FINAL : public LGap {
449 explicit LLabel(HBasicBlock* block)
450 : LGap(block), replacement_(NULL) { }
452 virtual bool HasInterestingComment(LCodeGen* gen) const V8_OVERRIDE {
455 DECLARE_CONCRETE_INSTRUCTION(Label, "label")
457 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
459 int block_id() const { return block()->block_id(); }
460 bool is_loop_header() const { return block()->IsLoopHeader(); }
461 bool is_osr_entry() const { return block()->is_osr_entry(); }
462 Label* label() { return &label_; }
463 LLabel* replacement() const { return replacement_; }
464 void set_replacement(LLabel* label) { replacement_ = label; }
465 bool HasReplacement() const { return replacement_ != NULL; }
469 LLabel* replacement_;
473 class LParameter V8_FINAL : public LTemplateInstruction<1, 0, 0> {
475 virtual bool HasInterestingComment(LCodeGen* gen) const V8_OVERRIDE {
478 DECLARE_CONCRETE_INSTRUCTION(Parameter, "parameter")
482 class LCallStub V8_FINAL : public LTemplateInstruction<1, 1, 0> {
484 explicit LCallStub(LOperand* context) {
485 inputs_[0] = context;
488 LOperand* context() { return inputs_[0]; }
490 DECLARE_CONCRETE_INSTRUCTION(CallStub, "call-stub")
491 DECLARE_HYDROGEN_ACCESSOR(CallStub)
495 class LUnknownOSRValue V8_FINAL : public LTemplateInstruction<1, 0, 0> {
497 virtual bool HasInterestingComment(LCodeGen* gen) const V8_OVERRIDE {
500 DECLARE_CONCRETE_INSTRUCTION(UnknownOSRValue, "unknown-osr-value")
504 template<int I, int T>
505 class LControlInstruction : public LTemplateInstruction<0, I, T> {
507 LControlInstruction() : false_label_(NULL), true_label_(NULL) { }
509 virtual bool IsControl() const V8_FINAL V8_OVERRIDE { return true; }
511 int SuccessorCount() { return hydrogen()->SuccessorCount(); }
512 HBasicBlock* SuccessorAt(int i) { return hydrogen()->SuccessorAt(i); }
514 int TrueDestination(LChunk* chunk) {
515 return chunk->LookupDestination(true_block_id());
517 int FalseDestination(LChunk* chunk) {
518 return chunk->LookupDestination(false_block_id());
521 Label* TrueLabel(LChunk* chunk) {
522 if (true_label_ == NULL) {
523 true_label_ = chunk->GetAssemblyLabel(TrueDestination(chunk));
527 Label* FalseLabel(LChunk* chunk) {
528 if (false_label_ == NULL) {
529 false_label_ = chunk->GetAssemblyLabel(FalseDestination(chunk));
535 int true_block_id() { return SuccessorAt(0)->block_id(); }
536 int false_block_id() { return SuccessorAt(1)->block_id(); }
539 HControlInstruction* hydrogen() {
540 return HControlInstruction::cast(this->hydrogen_value());
548 class LWrapReceiver V8_FINAL : public LTemplateInstruction<1, 2, 0> {
550 LWrapReceiver(LOperand* receiver, LOperand* function) {
551 inputs_[0] = receiver;
552 inputs_[1] = function;
555 LOperand* receiver() { return inputs_[0]; }
556 LOperand* function() { return inputs_[1]; }
558 DECLARE_CONCRETE_INSTRUCTION(WrapReceiver, "wrap-receiver")
559 DECLARE_HYDROGEN_ACCESSOR(WrapReceiver)
563 class LApplyArguments V8_FINAL : public LTemplateInstruction<1, 4, 0> {
565 LApplyArguments(LOperand* function,
568 LOperand* elements) {
569 inputs_[0] = function;
570 inputs_[1] = receiver;
572 inputs_[3] = elements;
575 LOperand* function() { return inputs_[0]; }
576 LOperand* receiver() { return inputs_[1]; }
577 LOperand* length() { return inputs_[2]; }
578 LOperand* elements() { return inputs_[3]; }
580 DECLARE_CONCRETE_INSTRUCTION(ApplyArguments, "apply-arguments")
584 class LAccessArgumentsAt V8_FINAL : public LTemplateInstruction<1, 3, 0> {
586 LAccessArgumentsAt(LOperand* arguments, LOperand* length, LOperand* index) {
587 inputs_[0] = arguments;
592 LOperand* arguments() { return inputs_[0]; }
593 LOperand* length() { return inputs_[1]; }
594 LOperand* index() { return inputs_[2]; }
596 DECLARE_CONCRETE_INSTRUCTION(AccessArgumentsAt, "access-arguments-at")
598 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
602 class LArgumentsLength V8_FINAL : public LTemplateInstruction<1, 1, 0> {
604 explicit LArgumentsLength(LOperand* elements) {
605 inputs_[0] = elements;
608 LOperand* elements() { return inputs_[0]; }
610 DECLARE_CONCRETE_INSTRUCTION(ArgumentsLength, "arguments-length")
614 class LArgumentsElements V8_FINAL : public LTemplateInstruction<1, 0, 0> {
616 DECLARE_CONCRETE_INSTRUCTION(ArgumentsElements, "arguments-elements")
617 DECLARE_HYDROGEN_ACCESSOR(ArgumentsElements)
621 class LModByPowerOf2I V8_FINAL : public LTemplateInstruction<1, 1, 0> {
623 LModByPowerOf2I(LOperand* dividend, int32_t divisor) {
624 inputs_[0] = dividend;
628 LOperand* dividend() { return inputs_[0]; }
629 int32_t divisor() const { return divisor_; }
631 DECLARE_CONCRETE_INSTRUCTION(ModByPowerOf2I, "mod-by-power-of-2-i")
632 DECLARE_HYDROGEN_ACCESSOR(Mod)
639 class LModI V8_FINAL : public LTemplateInstruction<1, 2, 1> {
641 LModI(LOperand* left, LOperand* right, LOperand* temp) {
647 LOperand* left() { return inputs_[0]; }
648 LOperand* right() { return inputs_[1]; }
649 LOperand* temp() { return temps_[0]; }
651 DECLARE_CONCRETE_INSTRUCTION(ModI, "mod-i")
652 DECLARE_HYDROGEN_ACCESSOR(Mod)
656 class LDivByPowerOf2I V8_FINAL : public LTemplateInstruction<1, 1, 0> {
658 LDivByPowerOf2I(LOperand* dividend, int32_t divisor) {
659 inputs_[0] = dividend;
663 LOperand* dividend() { return inputs_[0]; }
664 int32_t divisor() const { return divisor_; }
666 DECLARE_CONCRETE_INSTRUCTION(DivByPowerOf2I, "div-by-power-of-2-i")
667 DECLARE_HYDROGEN_ACCESSOR(Div)
674 class LDivI V8_FINAL : public LTemplateInstruction<1, 2, 1> {
676 LDivI(LOperand* left, LOperand* right, LOperand* temp) {
682 LOperand* left() { return inputs_[0]; }
683 LOperand* right() { return inputs_[1]; }
684 LOperand* temp() { return temps_[0]; }
686 bool is_flooring() { return hydrogen_value()->IsMathFloorOfDiv(); }
688 DECLARE_CONCRETE_INSTRUCTION(DivI, "div-i")
689 DECLARE_HYDROGEN_ACCESSOR(BinaryOperation)
693 class LFlooringDivByPowerOf2I V8_FINAL : public LTemplateInstruction<1, 1, 0> {
695 LFlooringDivByPowerOf2I(LOperand* dividend, int32_t divisor) {
696 inputs_[0] = dividend;
700 LOperand* dividend() { return inputs_[0]; }
701 int32_t divisor() const { return divisor_; }
703 DECLARE_CONCRETE_INSTRUCTION(FlooringDivByPowerOf2I,
704 "flooring-div-by-power-of-2-i")
705 DECLARE_HYDROGEN_ACCESSOR(MathFloorOfDiv)
712 class LFlooringDivByConstI V8_FINAL : public LTemplateInstruction<1, 1, 1> {
714 LFlooringDivByConstI(LOperand* dividend, int32_t divisor, LOperand* temp) {
715 inputs_[0] = dividend;
720 LOperand* dividend() { return inputs_[0]; }
721 int32_t divisor() const { return divisor_; }
722 LOperand* temp() { return temps_[0]; }
724 DECLARE_CONCRETE_INSTRUCTION(FlooringDivByConstI, "flooring-div-by-const-i")
725 DECLARE_HYDROGEN_ACCESSOR(MathFloorOfDiv)
732 class LMulI V8_FINAL : public LTemplateInstruction<1, 2, 0> {
734 LMulI(LOperand* left, LOperand* right) {
739 LOperand* left() { return inputs_[0]; }
740 LOperand* right() { return inputs_[1]; }
742 DECLARE_CONCRETE_INSTRUCTION(MulI, "mul-i")
743 DECLARE_HYDROGEN_ACCESSOR(Mul)
747 class LCompareNumericAndBranch V8_FINAL : public LControlInstruction<2, 0> {
749 LCompareNumericAndBranch(LOperand* left, LOperand* right) {
754 LOperand* left() { return inputs_[0]; }
755 LOperand* right() { return inputs_[1]; }
757 DECLARE_CONCRETE_INSTRUCTION(CompareNumericAndBranch,
758 "compare-numeric-and-branch")
759 DECLARE_HYDROGEN_ACCESSOR(CompareNumericAndBranch)
761 Token::Value op() const { return hydrogen()->token(); }
762 bool is_double() const {
763 return hydrogen()->representation().IsDouble();
766 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
770 class LMathFloor V8_FINAL : public LTemplateInstruction<1, 1, 0> {
772 explicit LMathFloor(LOperand* value) {
776 LOperand* value() { return inputs_[0]; }
778 DECLARE_CONCRETE_INSTRUCTION(MathFloor, "math-floor")
779 DECLARE_HYDROGEN_ACCESSOR(UnaryMathOperation)
783 class LMathRound V8_FINAL : public LTemplateInstruction<1, 1, 0> {
785 explicit LMathRound(LOperand* value) {
789 LOperand* value() { return inputs_[0]; }
791 DECLARE_CONCRETE_INSTRUCTION(MathRound, "math-round")
792 DECLARE_HYDROGEN_ACCESSOR(UnaryMathOperation)
796 class LMathAbs V8_FINAL : public LTemplateInstruction<1, 2, 0> {
798 explicit LMathAbs(LOperand* context, LOperand* value) {
799 inputs_[1] = context;
803 LOperand* context() { return inputs_[1]; }
804 LOperand* value() { return inputs_[0]; }
806 DECLARE_CONCRETE_INSTRUCTION(MathAbs, "math-abs")
807 DECLARE_HYDROGEN_ACCESSOR(UnaryMathOperation)
811 class LMathLog V8_FINAL : public LTemplateInstruction<1, 1, 0> {
813 explicit LMathLog(LOperand* value) {
817 LOperand* value() { return inputs_[0]; }
819 DECLARE_CONCRETE_INSTRUCTION(MathLog, "math-log")
823 class LMathClz32 V8_FINAL : public LTemplateInstruction<1, 1, 0> {
825 explicit LMathClz32(LOperand* value) {
829 LOperand* value() { return inputs_[0]; }
831 DECLARE_CONCRETE_INSTRUCTION(MathClz32, "math-clz32")
835 class LMathExp V8_FINAL : public LTemplateInstruction<1, 1, 2> {
837 LMathExp(LOperand* value, LOperand* temp1, LOperand* temp2) {
841 ExternalReference::InitializeMathExpData();
844 LOperand* value() { return inputs_[0]; }
845 LOperand* temp1() { return temps_[0]; }
846 LOperand* temp2() { return temps_[1]; }
848 DECLARE_CONCRETE_INSTRUCTION(MathExp, "math-exp")
852 class LMathSqrt V8_FINAL : public LTemplateInstruction<1, 1, 0> {
854 explicit LMathSqrt(LOperand* value) {
858 LOperand* value() { return inputs_[0]; }
860 DECLARE_CONCRETE_INSTRUCTION(MathSqrt, "math-sqrt")
864 class LMathPowHalf V8_FINAL : public LTemplateInstruction<1, 1, 0> {
866 explicit LMathPowHalf(LOperand* value) {
870 LOperand* value() { return inputs_[0]; }
872 DECLARE_CONCRETE_INSTRUCTION(MathPowHalf, "math-pow-half")
876 class LCmpObjectEqAndBranch V8_FINAL : public LControlInstruction<2, 0> {
878 LCmpObjectEqAndBranch(LOperand* left, LOperand* right) {
883 LOperand* left() { return inputs_[0]; }
884 LOperand* right() { return inputs_[1]; }
886 DECLARE_CONCRETE_INSTRUCTION(CmpObjectEqAndBranch, "cmp-object-eq-and-branch")
890 class LCmpHoleAndBranch V8_FINAL : public LControlInstruction<1, 0> {
892 explicit LCmpHoleAndBranch(LOperand* object) {
896 LOperand* object() { return inputs_[0]; }
898 DECLARE_CONCRETE_INSTRUCTION(CmpHoleAndBranch, "cmp-hole-and-branch")
899 DECLARE_HYDROGEN_ACCESSOR(CompareHoleAndBranch)
903 class LCompareMinusZeroAndBranch V8_FINAL : public LControlInstruction<1, 0> {
905 explicit LCompareMinusZeroAndBranch(LOperand* value) {
909 LOperand* value() { return inputs_[0]; }
911 DECLARE_CONCRETE_INSTRUCTION(CompareMinusZeroAndBranch,
912 "cmp-minus-zero-and-branch")
913 DECLARE_HYDROGEN_ACCESSOR(CompareMinusZeroAndBranch)
918 class LIsObjectAndBranch V8_FINAL : public LControlInstruction<1, 0> {
920 explicit LIsObjectAndBranch(LOperand* value) {
924 LOperand* value() { return inputs_[0]; }
926 DECLARE_CONCRETE_INSTRUCTION(IsObjectAndBranch, "is-object-and-branch")
927 DECLARE_HYDROGEN_ACCESSOR(IsObjectAndBranch)
929 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
933 class LIsStringAndBranch V8_FINAL : public LControlInstruction<1, 1> {
935 explicit LIsStringAndBranch(LOperand* value, LOperand* temp) {
940 LOperand* value() { return inputs_[0]; }
941 LOperand* temp() { return temps_[0]; }
943 DECLARE_CONCRETE_INSTRUCTION(IsStringAndBranch, "is-string-and-branch")
944 DECLARE_HYDROGEN_ACCESSOR(IsStringAndBranch)
946 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
950 class LIsSmiAndBranch V8_FINAL : public LControlInstruction<1, 0> {
952 explicit LIsSmiAndBranch(LOperand* value) {
956 LOperand* value() { return inputs_[0]; }
958 DECLARE_CONCRETE_INSTRUCTION(IsSmiAndBranch, "is-smi-and-branch")
959 DECLARE_HYDROGEN_ACCESSOR(IsSmiAndBranch)
961 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
965 class LIsUndetectableAndBranch V8_FINAL : public LControlInstruction<1, 1> {
967 explicit LIsUndetectableAndBranch(LOperand* value, LOperand* temp) {
972 LOperand* value() { return inputs_[0]; }
973 LOperand* temp() { return temps_[0]; }
975 DECLARE_CONCRETE_INSTRUCTION(IsUndetectableAndBranch,
976 "is-undetectable-and-branch")
977 DECLARE_HYDROGEN_ACCESSOR(IsUndetectableAndBranch)
979 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
983 class LStringCompareAndBranch V8_FINAL : public LControlInstruction<3, 0> {
985 explicit LStringCompareAndBranch(LOperand* context,
988 inputs_[0] = context;
993 LOperand* context() { return inputs_[0]; }
994 LOperand* left() { return inputs_[1]; }
995 LOperand* right() { return inputs_[2]; }
997 DECLARE_CONCRETE_INSTRUCTION(StringCompareAndBranch,
998 "string-compare-and-branch")
999 DECLARE_HYDROGEN_ACCESSOR(StringCompareAndBranch)
1001 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1003 Token::Value op() const { return hydrogen()->token(); }
1007 class LHasInstanceTypeAndBranch V8_FINAL : public LControlInstruction<1, 0> {
1009 explicit LHasInstanceTypeAndBranch(LOperand* value) {
1013 LOperand* value() { return inputs_[0]; }
1015 DECLARE_CONCRETE_INSTRUCTION(HasInstanceTypeAndBranch,
1016 "has-instance-type-and-branch")
1017 DECLARE_HYDROGEN_ACCESSOR(HasInstanceTypeAndBranch)
1019 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1023 class LGetCachedArrayIndex V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1025 explicit LGetCachedArrayIndex(LOperand* value) {
1029 LOperand* value() { return inputs_[0]; }
1031 DECLARE_CONCRETE_INSTRUCTION(GetCachedArrayIndex, "get-cached-array-index")
1032 DECLARE_HYDROGEN_ACCESSOR(GetCachedArrayIndex)
1036 class LHasCachedArrayIndexAndBranch V8_FINAL
1037 : public LControlInstruction<1, 0> {
1039 explicit LHasCachedArrayIndexAndBranch(LOperand* value) {
1043 LOperand* value() { return inputs_[0]; }
1045 DECLARE_CONCRETE_INSTRUCTION(HasCachedArrayIndexAndBranch,
1046 "has-cached-array-index-and-branch")
1047 DECLARE_HYDROGEN_ACCESSOR(HasCachedArrayIndexAndBranch)
1049 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1053 class LClassOfTestAndBranch V8_FINAL : public LControlInstruction<1, 2> {
1055 LClassOfTestAndBranch(LOperand* value, LOperand* temp, LOperand* temp2) {
1061 LOperand* value() { return inputs_[0]; }
1062 LOperand* temp() { return temps_[0]; }
1063 LOperand* temp2() { return temps_[1]; }
1065 DECLARE_CONCRETE_INSTRUCTION(ClassOfTestAndBranch,
1066 "class-of-test-and-branch")
1067 DECLARE_HYDROGEN_ACCESSOR(ClassOfTestAndBranch)
1069 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1073 class LCmpT V8_FINAL : public LTemplateInstruction<1, 3, 0> {
1075 LCmpT(LOperand* context, LOperand* left, LOperand* right) {
1076 inputs_[0] = context;
1081 LOperand* context() { return inputs_[0]; }
1082 LOperand* left() { return inputs_[1]; }
1083 LOperand* right() { return inputs_[2]; }
1085 DECLARE_CONCRETE_INSTRUCTION(CmpT, "cmp-t")
1086 DECLARE_HYDROGEN_ACCESSOR(CompareGeneric)
1088 Token::Value op() const { return hydrogen()->token(); }
1092 class LInstanceOf V8_FINAL : public LTemplateInstruction<1, 3, 0> {
1094 LInstanceOf(LOperand* context, LOperand* left, LOperand* right) {
1095 inputs_[0] = context;
1100 LOperand* context() { return inputs_[0]; }
1101 LOperand* left() { return inputs_[1]; }
1102 LOperand* right() { return inputs_[2]; }
1104 DECLARE_CONCRETE_INSTRUCTION(InstanceOf, "instance-of")
1108 class LInstanceOfKnownGlobal V8_FINAL : public LTemplateInstruction<1, 2, 1> {
1110 LInstanceOfKnownGlobal(LOperand* context, LOperand* value, LOperand* temp) {
1111 inputs_[0] = context;
1116 LOperand* context() { return inputs_[0]; }
1117 LOperand* value() { return inputs_[1]; }
1118 LOperand* temp() { return temps_[0]; }
1120 DECLARE_CONCRETE_INSTRUCTION(InstanceOfKnownGlobal,
1121 "instance-of-known-global")
1122 DECLARE_HYDROGEN_ACCESSOR(InstanceOfKnownGlobal)
1124 Handle<JSFunction> function() const { return hydrogen()->function(); }
1125 LEnvironment* GetDeferredLazyDeoptimizationEnvironment() {
1126 return lazy_deopt_env_;
1128 virtual void SetDeferredLazyDeoptimizationEnvironment(
1129 LEnvironment* env) V8_OVERRIDE {
1130 lazy_deopt_env_ = env;
1134 LEnvironment* lazy_deopt_env_;
1138 class LBoundsCheck V8_FINAL : public LTemplateInstruction<0, 2, 0> {
1140 LBoundsCheck(LOperand* index, LOperand* length) {
1142 inputs_[1] = length;
1145 LOperand* index() { return inputs_[0]; }
1146 LOperand* length() { return inputs_[1]; }
1148 DECLARE_CONCRETE_INSTRUCTION(BoundsCheck, "bounds-check")
1149 DECLARE_HYDROGEN_ACCESSOR(BoundsCheck)
1153 class LBitI V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1155 LBitI(LOperand* left, LOperand* right) {
1160 LOperand* left() { return inputs_[0]; }
1161 LOperand* right() { return inputs_[1]; }
1163 Token::Value op() const { return hydrogen()->op(); }
1165 DECLARE_CONCRETE_INSTRUCTION(BitI, "bit-i")
1166 DECLARE_HYDROGEN_ACCESSOR(Bitwise)
1170 class LShiftI V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1172 LShiftI(Token::Value op, LOperand* left, LOperand* right, bool can_deopt)
1173 : op_(op), can_deopt_(can_deopt) {
1178 Token::Value op() const { return op_; }
1179 LOperand* left() { return inputs_[0]; }
1180 LOperand* right() { return inputs_[1]; }
1181 bool can_deopt() const { return can_deopt_; }
1183 DECLARE_CONCRETE_INSTRUCTION(ShiftI, "shift-i")
1191 class LSubI V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1193 LSubI(LOperand* left, LOperand* right) {
1198 LOperand* left() { return inputs_[0]; }
1199 LOperand* right() { return inputs_[1]; }
1201 DECLARE_CONCRETE_INSTRUCTION(SubI, "sub-i")
1202 DECLARE_HYDROGEN_ACCESSOR(Sub)
1206 class LConstantI V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1208 DECLARE_CONCRETE_INSTRUCTION(ConstantI, "constant-i")
1209 DECLARE_HYDROGEN_ACCESSOR(Constant)
1211 int32_t value() const { return hydrogen()->Integer32Value(); }
1215 class LConstantS V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1217 DECLARE_CONCRETE_INSTRUCTION(ConstantS, "constant-s")
1218 DECLARE_HYDROGEN_ACCESSOR(Constant)
1220 Smi* value() const { return Smi::FromInt(hydrogen()->Integer32Value()); }
1224 class LConstantD V8_FINAL : public LTemplateInstruction<1, 0, 1> {
1226 explicit LConstantD(LOperand* temp) {
1230 LOperand* temp() { return temps_[0]; }
1232 DECLARE_CONCRETE_INSTRUCTION(ConstantD, "constant-d")
1233 DECLARE_HYDROGEN_ACCESSOR(Constant)
1235 double value() const { return hydrogen()->DoubleValue(); }
1239 class LConstantE V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1241 DECLARE_CONCRETE_INSTRUCTION(ConstantE, "constant-e")
1242 DECLARE_HYDROGEN_ACCESSOR(Constant)
1244 ExternalReference value() const {
1245 return hydrogen()->ExternalReferenceValue();
1250 class LConstantT V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1252 DECLARE_CONCRETE_INSTRUCTION(ConstantT, "constant-t")
1253 DECLARE_HYDROGEN_ACCESSOR(Constant)
1255 Handle<Object> value(Isolate* isolate) const {
1256 return hydrogen()->handle(isolate);
1261 class LBranch V8_FINAL : public LControlInstruction<1, 0> {
1263 explicit LBranch(LOperand* value) {
1267 LOperand* value() { return inputs_[0]; }
1269 DECLARE_CONCRETE_INSTRUCTION(Branch, "branch")
1270 DECLARE_HYDROGEN_ACCESSOR(Branch)
1272 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1276 class LDebugBreak V8_FINAL : public LTemplateInstruction<0, 0, 0> {
1278 DECLARE_CONCRETE_INSTRUCTION(DebugBreak, "break")
1282 class LCmpMapAndBranch V8_FINAL : public LControlInstruction<1, 0> {
1284 explicit LCmpMapAndBranch(LOperand* value) {
1288 LOperand* value() { return inputs_[0]; }
1290 DECLARE_CONCRETE_INSTRUCTION(CmpMapAndBranch, "cmp-map-and-branch")
1291 DECLARE_HYDROGEN_ACCESSOR(CompareMap)
1293 Handle<Map> map() const { return hydrogen()->map().handle(); }
1297 class LMapEnumLength V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1299 explicit LMapEnumLength(LOperand* value) {
1303 LOperand* value() { return inputs_[0]; }
1305 DECLARE_CONCRETE_INSTRUCTION(MapEnumLength, "map-enum-length")
1309 class LDateField V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1311 LDateField(LOperand* date, Smi* index) : index_(index) {
1315 LOperand* date() { return inputs_[0]; }
1316 Smi* index() const { return index_; }
1318 DECLARE_CONCRETE_INSTRUCTION(DateField, "date-field")
1319 DECLARE_HYDROGEN_ACCESSOR(DateField)
1326 class LSeqStringGetChar V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1328 LSeqStringGetChar(LOperand* string, LOperand* index) {
1329 inputs_[0] = string;
1333 LOperand* string() const { return inputs_[0]; }
1334 LOperand* index() const { return inputs_[1]; }
1336 DECLARE_CONCRETE_INSTRUCTION(SeqStringGetChar, "seq-string-get-char")
1337 DECLARE_HYDROGEN_ACCESSOR(SeqStringGetChar)
1341 class LSeqStringSetChar V8_FINAL : public LTemplateInstruction<1, 4, 0> {
1343 LSeqStringSetChar(LOperand* context,
1347 inputs_[0] = context;
1348 inputs_[1] = string;
1353 LOperand* string() { return inputs_[1]; }
1354 LOperand* index() { return inputs_[2]; }
1355 LOperand* value() { return inputs_[3]; }
1357 DECLARE_CONCRETE_INSTRUCTION(SeqStringSetChar, "seq-string-set-char")
1358 DECLARE_HYDROGEN_ACCESSOR(SeqStringSetChar)
1362 class LAddI V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1364 LAddI(LOperand* left, LOperand* right) {
1369 LOperand* left() { return inputs_[0]; }
1370 LOperand* right() { return inputs_[1]; }
1372 static bool UseLea(HAdd* add) {
1373 return !add->CheckFlag(HValue::kCanOverflow) &&
1374 add->BetterLeftOperand()->UseCount() > 1;
1377 DECLARE_CONCRETE_INSTRUCTION(AddI, "add-i")
1378 DECLARE_HYDROGEN_ACCESSOR(Add)
1382 class LMathMinMax V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1384 LMathMinMax(LOperand* left, LOperand* right) {
1389 LOperand* left() { return inputs_[0]; }
1390 LOperand* right() { return inputs_[1]; }
1392 DECLARE_CONCRETE_INSTRUCTION(MathMinMax, "math-min-max")
1393 DECLARE_HYDROGEN_ACCESSOR(MathMinMax)
1397 class LPower V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1399 LPower(LOperand* left, LOperand* right) {
1404 LOperand* left() { return inputs_[0]; }
1405 LOperand* right() { return inputs_[1]; }
1407 DECLARE_CONCRETE_INSTRUCTION(Power, "power")
1408 DECLARE_HYDROGEN_ACCESSOR(Power)
1412 class LArithmeticD V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1414 LArithmeticD(Token::Value op, LOperand* left, LOperand* right)
1420 Token::Value op() const { return op_; }
1421 LOperand* left() { return inputs_[0]; }
1422 LOperand* right() { return inputs_[1]; }
1424 virtual Opcode opcode() const V8_OVERRIDE {
1425 return LInstruction::kArithmeticD;
1427 virtual void CompileToNative(LCodeGen* generator) V8_OVERRIDE;
1428 virtual const char* Mnemonic() const V8_OVERRIDE;
1435 class LArithmeticT V8_FINAL : public LTemplateInstruction<1, 3, 0> {
1437 LArithmeticT(Token::Value op,
1442 inputs_[0] = context;
1447 Token::Value op() const { return op_; }
1448 LOperand* context() { return inputs_[0]; }
1449 LOperand* left() { return inputs_[1]; }
1450 LOperand* right() { return inputs_[2]; }
1452 virtual Opcode opcode() const V8_OVERRIDE {
1453 return LInstruction::kArithmeticT;
1455 virtual void CompileToNative(LCodeGen* generator) V8_OVERRIDE;
1456 virtual const char* Mnemonic() const V8_OVERRIDE;
1463 class LReturn V8_FINAL : public LTemplateInstruction<0, 3, 0> {
1465 explicit LReturn(LOperand* value,
1467 LOperand* parameter_count) {
1469 inputs_[1] = context;
1470 inputs_[2] = parameter_count;
1473 LOperand* value() { return inputs_[0]; }
1474 LOperand* context() { return inputs_[1]; }
1476 bool has_constant_parameter_count() {
1477 return parameter_count()->IsConstantOperand();
1479 LConstantOperand* constant_parameter_count() {
1480 ASSERT(has_constant_parameter_count());
1481 return LConstantOperand::cast(parameter_count());
1483 LOperand* parameter_count() { return inputs_[2]; }
1485 DECLARE_CONCRETE_INSTRUCTION(Return, "return")
1486 DECLARE_HYDROGEN_ACCESSOR(Return)
1490 class LLoadNamedField V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1492 explicit LLoadNamedField(LOperand* object) {
1493 inputs_[0] = object;
1496 LOperand* object() { return inputs_[0]; }
1498 DECLARE_CONCRETE_INSTRUCTION(LoadNamedField, "load-named-field")
1499 DECLARE_HYDROGEN_ACCESSOR(LoadNamedField)
1503 class LLoadNamedGeneric V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1505 explicit LLoadNamedGeneric(LOperand* context, LOperand* object) {
1506 inputs_[0] = context;
1507 inputs_[1] = object;
1510 DECLARE_CONCRETE_INSTRUCTION(LoadNamedGeneric, "load-named-generic")
1511 DECLARE_HYDROGEN_ACCESSOR(LoadNamedGeneric)
1513 LOperand* context() { return inputs_[0]; }
1514 LOperand* object() { return inputs_[1]; }
1515 Handle<Object> name() const { return hydrogen()->name(); }
1519 class LLoadFunctionPrototype V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1521 explicit LLoadFunctionPrototype(LOperand* function) {
1522 inputs_[0] = function;
1525 DECLARE_CONCRETE_INSTRUCTION(LoadFunctionPrototype, "load-function-prototype")
1526 DECLARE_HYDROGEN_ACCESSOR(LoadFunctionPrototype)
1528 LOperand* function() { return inputs_[0]; }
1532 class LLoadRoot V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1534 DECLARE_CONCRETE_INSTRUCTION(LoadRoot, "load-root")
1535 DECLARE_HYDROGEN_ACCESSOR(LoadRoot)
1537 Heap::RootListIndex index() const { return hydrogen()->index(); }
1541 class LLoadKeyed V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1543 LLoadKeyed(LOperand* elements, LOperand* key) {
1544 inputs_[0] = elements;
1548 DECLARE_CONCRETE_INSTRUCTION(LoadKeyed, "load-keyed")
1549 DECLARE_HYDROGEN_ACCESSOR(LoadKeyed)
1551 bool is_external() const {
1552 return hydrogen()->is_external();
1554 bool is_fixed_typed_array() const {
1555 return hydrogen()->is_fixed_typed_array();
1557 bool is_typed_elements() const {
1558 return is_external() || is_fixed_typed_array();
1560 LOperand* elements() { return inputs_[0]; }
1561 LOperand* key() { return inputs_[1]; }
1562 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1563 uint32_t additional_index() const { return hydrogen()->index_offset(); }
1564 ElementsKind elements_kind() const {
1565 return hydrogen()->elements_kind();
1570 class LLoadKeyedGeneric V8_FINAL : public LTemplateInstruction<1, 3, 0> {
1572 LLoadKeyedGeneric(LOperand* context, LOperand* obj, LOperand* key) {
1573 inputs_[0] = context;
1578 DECLARE_CONCRETE_INSTRUCTION(LoadKeyedGeneric, "load-keyed-generic")
1580 LOperand* context() { return inputs_[0]; }
1581 LOperand* object() { return inputs_[1]; }
1582 LOperand* key() { return inputs_[2]; }
1586 class LLoadGlobalCell V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1588 DECLARE_CONCRETE_INSTRUCTION(LoadGlobalCell, "load-global-cell")
1589 DECLARE_HYDROGEN_ACCESSOR(LoadGlobalCell)
1593 class LLoadGlobalGeneric V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1595 explicit LLoadGlobalGeneric(LOperand* context, LOperand* global_object) {
1596 inputs_[0] = context;
1597 inputs_[1] = global_object;
1600 DECLARE_CONCRETE_INSTRUCTION(LoadGlobalGeneric, "load-global-generic")
1601 DECLARE_HYDROGEN_ACCESSOR(LoadGlobalGeneric)
1603 LOperand* context() { return inputs_[0]; }
1604 LOperand* global_object() { return inputs_[1]; }
1605 Handle<Object> name() const { return hydrogen()->name(); }
1606 bool for_typeof() const { return hydrogen()->for_typeof(); }
1610 class LStoreGlobalCell V8_FINAL : public LTemplateInstruction<0, 1, 1> {
1612 explicit LStoreGlobalCell(LOperand* value, LOperand* temp) {
1617 LOperand* value() { return inputs_[0]; }
1618 LOperand* temp() { return temps_[0]; }
1620 DECLARE_CONCRETE_INSTRUCTION(StoreGlobalCell, "store-global-cell")
1621 DECLARE_HYDROGEN_ACCESSOR(StoreGlobalCell)
1625 class LLoadContextSlot V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1627 explicit LLoadContextSlot(LOperand* context) {
1628 inputs_[0] = context;
1631 LOperand* context() { return inputs_[0]; }
1633 DECLARE_CONCRETE_INSTRUCTION(LoadContextSlot, "load-context-slot")
1634 DECLARE_HYDROGEN_ACCESSOR(LoadContextSlot)
1636 int slot_index() { return hydrogen()->slot_index(); }
1638 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1642 class LStoreContextSlot V8_FINAL : public LTemplateInstruction<0, 2, 1> {
1644 LStoreContextSlot(LOperand* context, LOperand* value, LOperand* temp) {
1645 inputs_[0] = context;
1650 LOperand* context() { return inputs_[0]; }
1651 LOperand* value() { return inputs_[1]; }
1652 LOperand* temp() { return temps_[0]; }
1654 DECLARE_CONCRETE_INSTRUCTION(StoreContextSlot, "store-context-slot")
1655 DECLARE_HYDROGEN_ACCESSOR(StoreContextSlot)
1657 int slot_index() { return hydrogen()->slot_index(); }
1659 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1663 class LPushArgument V8_FINAL : public LTemplateInstruction<0, 1, 0> {
1665 explicit LPushArgument(LOperand* value) {
1669 LOperand* value() { return inputs_[0]; }
1671 DECLARE_CONCRETE_INSTRUCTION(PushArgument, "push-argument")
1675 class LDrop V8_FINAL : public LTemplateInstruction<0, 0, 0> {
1677 explicit LDrop(int count) : count_(count) { }
1679 int count() const { return count_; }
1681 DECLARE_CONCRETE_INSTRUCTION(Drop, "drop")
1688 class LStoreCodeEntry V8_FINAL: public LTemplateInstruction<0, 1, 1> {
1690 LStoreCodeEntry(LOperand* function, LOperand* code_object) {
1691 inputs_[0] = function;
1692 temps_[0] = code_object;
1695 LOperand* function() { return inputs_[0]; }
1696 LOperand* code_object() { return temps_[0]; }
1698 virtual void PrintDataTo(StringStream* stream);
1700 DECLARE_CONCRETE_INSTRUCTION(StoreCodeEntry, "store-code-entry")
1701 DECLARE_HYDROGEN_ACCESSOR(StoreCodeEntry)
1705 class LInnerAllocatedObject V8_FINAL: public LTemplateInstruction<1, 2, 0> {
1707 LInnerAllocatedObject(LOperand* base_object, LOperand* offset) {
1708 inputs_[0] = base_object;
1709 inputs_[1] = offset;
1712 LOperand* base_object() const { return inputs_[0]; }
1713 LOperand* offset() const { return inputs_[1]; }
1715 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1717 DECLARE_CONCRETE_INSTRUCTION(InnerAllocatedObject, "inner-allocated-object")
1721 class LThisFunction V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1723 DECLARE_CONCRETE_INSTRUCTION(ThisFunction, "this-function")
1724 DECLARE_HYDROGEN_ACCESSOR(ThisFunction)
1728 class LContext V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1730 DECLARE_CONCRETE_INSTRUCTION(Context, "context")
1731 DECLARE_HYDROGEN_ACCESSOR(Context)
1735 class LDeclareGlobals V8_FINAL : public LTemplateInstruction<0, 1, 0> {
1737 explicit LDeclareGlobals(LOperand* context) {
1738 inputs_[0] = context;
1741 LOperand* context() { return inputs_[0]; }
1743 DECLARE_CONCRETE_INSTRUCTION(DeclareGlobals, "declare-globals")
1744 DECLARE_HYDROGEN_ACCESSOR(DeclareGlobals)
1748 class LCallJSFunction V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1750 explicit LCallJSFunction(LOperand* function) {
1751 inputs_[0] = function;
1754 LOperand* function() { return inputs_[0]; }
1756 DECLARE_CONCRETE_INSTRUCTION(CallJSFunction, "call-js-function")
1757 DECLARE_HYDROGEN_ACCESSOR(CallJSFunction)
1759 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1761 int arity() const { return hydrogen()->argument_count() - 1; }
1765 class LCallWithDescriptor V8_FINAL : public LTemplateResultInstruction<1> {
1767 LCallWithDescriptor(const CallInterfaceDescriptor* descriptor,
1768 ZoneList<LOperand*>& operands,
1770 : inputs_(descriptor->environment_length() + 1, zone) {
1771 ASSERT(descriptor->environment_length() + 1 == operands.length());
1772 inputs_.AddAll(operands, zone);
1775 LOperand* target() const { return inputs_[0]; }
1778 DECLARE_CONCRETE_INSTRUCTION(CallWithDescriptor, "call-with-descriptor")
1779 DECLARE_HYDROGEN_ACCESSOR(CallWithDescriptor)
1781 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1783 int arity() const { return hydrogen()->argument_count() - 1; }
1785 ZoneList<LOperand*> inputs_;
1787 // Iterator support.
1788 virtual int InputCount() V8_FINAL V8_OVERRIDE { return inputs_.length(); }
1789 virtual LOperand* InputAt(int i) V8_FINAL V8_OVERRIDE { return inputs_[i]; }
1791 virtual int TempCount() V8_FINAL V8_OVERRIDE { return 0; }
1792 virtual LOperand* TempAt(int i) V8_FINAL V8_OVERRIDE { return NULL; }
1796 class LInvokeFunction V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1798 LInvokeFunction(LOperand* context, LOperand* function) {
1799 inputs_[0] = context;
1800 inputs_[1] = function;
1803 LOperand* context() { return inputs_[0]; }
1804 LOperand* function() { return inputs_[1]; }
1806 DECLARE_CONCRETE_INSTRUCTION(InvokeFunction, "invoke-function")
1807 DECLARE_HYDROGEN_ACCESSOR(InvokeFunction)
1809 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1811 int arity() const { return hydrogen()->argument_count() - 1; }
1815 class LCallFunction V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1817 LCallFunction(LOperand* context, LOperand* function) {
1818 inputs_[0] = context;
1819 inputs_[1] = function;
1822 DECLARE_CONCRETE_INSTRUCTION(CallFunction, "call-function")
1823 DECLARE_HYDROGEN_ACCESSOR(CallFunction)
1825 LOperand* context() { return inputs_[0]; }
1826 LOperand* function() { return inputs_[1]; }
1827 int arity() const { return hydrogen()->argument_count() - 1; }
1831 class LCallNew V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1833 LCallNew(LOperand* context, LOperand* constructor) {
1834 inputs_[0] = context;
1835 inputs_[1] = constructor;
1838 LOperand* context() { return inputs_[0]; }
1839 LOperand* constructor() { return inputs_[1]; }
1841 DECLARE_CONCRETE_INSTRUCTION(CallNew, "call-new")
1842 DECLARE_HYDROGEN_ACCESSOR(CallNew)
1844 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1846 int arity() const { return hydrogen()->argument_count() - 1; }
1850 class LCallNewArray V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1852 LCallNewArray(LOperand* context, LOperand* constructor) {
1853 inputs_[0] = context;
1854 inputs_[1] = constructor;
1857 LOperand* context() { return inputs_[0]; }
1858 LOperand* constructor() { return inputs_[1]; }
1860 DECLARE_CONCRETE_INSTRUCTION(CallNewArray, "call-new-array")
1861 DECLARE_HYDROGEN_ACCESSOR(CallNewArray)
1863 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1865 int arity() const { return hydrogen()->argument_count() - 1; }
1869 class LCallRuntime V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1871 explicit LCallRuntime(LOperand* context) {
1872 inputs_[0] = context;
1875 LOperand* context() { return inputs_[0]; }
1877 DECLARE_CONCRETE_INSTRUCTION(CallRuntime, "call-runtime")
1878 DECLARE_HYDROGEN_ACCESSOR(CallRuntime)
1880 virtual bool ClobbersDoubleRegisters() const V8_OVERRIDE {
1881 return save_doubles() == kDontSaveFPRegs;
1884 const Runtime::Function* function() const { return hydrogen()->function(); }
1885 int arity() const { return hydrogen()->argument_count(); }
1886 SaveFPRegsMode save_doubles() const { return hydrogen()->save_doubles(); }
1890 class LInteger32ToDouble V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1892 explicit LInteger32ToDouble(LOperand* value) {
1896 LOperand* value() { return inputs_[0]; }
1898 DECLARE_CONCRETE_INSTRUCTION(Integer32ToDouble, "int32-to-double")
1902 class LInteger32ToSmi V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1904 explicit LInteger32ToSmi(LOperand* value) {
1908 LOperand* value() { return inputs_[0]; }
1910 DECLARE_CONCRETE_INSTRUCTION(Integer32ToSmi, "int32-to-smi")
1911 DECLARE_HYDROGEN_ACCESSOR(Change)
1915 class LUint32ToDouble V8_FINAL : public LTemplateInstruction<1, 1, 1> {
1917 explicit LUint32ToDouble(LOperand* value, LOperand* temp) {
1922 LOperand* value() { return inputs_[0]; }
1923 LOperand* temp() { return temps_[0]; }
1925 DECLARE_CONCRETE_INSTRUCTION(Uint32ToDouble, "uint32-to-double")
1929 class LUint32ToSmi V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1931 explicit LUint32ToSmi(LOperand* value) {
1935 LOperand* value() { return inputs_[0]; }
1937 DECLARE_CONCRETE_INSTRUCTION(Uint32ToSmi, "uint32-to-smi")
1938 DECLARE_HYDROGEN_ACCESSOR(Change)
1942 class LNumberTagI V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1944 explicit LNumberTagI(LOperand* value) {
1948 LOperand* value() { return inputs_[0]; }
1950 DECLARE_CONCRETE_INSTRUCTION(NumberTagI, "number-tag-i")
1954 class LNumberTagU V8_FINAL : public LTemplateInstruction<1, 1, 2> {
1956 LNumberTagU(LOperand* value, LOperand* temp1, LOperand* temp2) {
1962 LOperand* value() { return inputs_[0]; }
1963 LOperand* temp1() { return temps_[0]; }
1964 LOperand* temp2() { return temps_[1]; }
1966 DECLARE_CONCRETE_INSTRUCTION(NumberTagU, "number-tag-u")
1970 class LNumberTagD V8_FINAL : public LTemplateInstruction<1, 1, 1> {
1972 explicit LNumberTagD(LOperand* value, LOperand* temp) {
1977 LOperand* value() { return inputs_[0]; }
1978 LOperand* temp() { return temps_[0]; }
1980 DECLARE_CONCRETE_INSTRUCTION(NumberTagD, "number-tag-d")
1981 DECLARE_HYDROGEN_ACCESSOR(Change)
1985 // Sometimes truncating conversion from a tagged value to an int32.
1986 class LDoubleToI V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1988 explicit LDoubleToI(LOperand* value) {
1992 LOperand* value() { return inputs_[0]; }
1994 DECLARE_CONCRETE_INSTRUCTION(DoubleToI, "double-to-i")
1995 DECLARE_HYDROGEN_ACCESSOR(UnaryOperation)
1997 bool truncating() { return hydrogen()->CanTruncateToInt32(); }
2001 class LDoubleToSmi V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2003 explicit LDoubleToSmi(LOperand* value) {
2007 LOperand* value() { return inputs_[0]; }
2009 DECLARE_CONCRETE_INSTRUCTION(DoubleToSmi, "double-to-smi")
2010 DECLARE_HYDROGEN_ACCESSOR(UnaryOperation)
2014 // Truncating conversion from a tagged value to an int32.
2015 class LTaggedToI V8_FINAL : public LTemplateInstruction<1, 1, 1> {
2017 LTaggedToI(LOperand* value, LOperand* temp) {
2022 LOperand* value() { return inputs_[0]; }
2023 LOperand* temp() { return temps_[0]; }
2025 DECLARE_CONCRETE_INSTRUCTION(TaggedToI, "tagged-to-i")
2026 DECLARE_HYDROGEN_ACCESSOR(Change)
2028 bool truncating() { return hydrogen()->CanTruncateToInt32(); }
2032 class LSmiTag V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2034 explicit LSmiTag(LOperand* value) {
2038 LOperand* value() { return inputs_[0]; }
2040 DECLARE_CONCRETE_INSTRUCTION(SmiTag, "smi-tag")
2044 class LNumberUntagD V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2046 explicit LNumberUntagD(LOperand* value) {
2050 LOperand* value() { return inputs_[0]; }
2052 DECLARE_CONCRETE_INSTRUCTION(NumberUntagD, "double-untag")
2053 DECLARE_HYDROGEN_ACCESSOR(Change);
2057 class LSmiUntag V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2059 LSmiUntag(LOperand* value, bool needs_check)
2060 : needs_check_(needs_check) {
2064 LOperand* value() { return inputs_[0]; }
2065 bool needs_check() const { return needs_check_; }
2067 DECLARE_CONCRETE_INSTRUCTION(SmiUntag, "smi-untag")
2074 class LStoreNamedField V8_FINAL : public LTemplateInstruction<0, 2, 1> {
2076 LStoreNamedField(LOperand* object, LOperand* value, LOperand* temp) {
2077 inputs_[0] = object;
2082 LOperand* object() { return inputs_[0]; }
2083 LOperand* value() { return inputs_[1]; }
2084 LOperand* temp() { return temps_[0]; }
2086 DECLARE_CONCRETE_INSTRUCTION(StoreNamedField, "store-named-field")
2087 DECLARE_HYDROGEN_ACCESSOR(StoreNamedField)
2089 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
2091 Handle<Map> transition() const { return hydrogen()->transition_map(); }
2092 Representation representation() const {
2093 return hydrogen()->field_representation();
2098 class LStoreNamedGeneric V8_FINAL : public LTemplateInstruction<0, 3, 0> {
2100 LStoreNamedGeneric(LOperand* context, LOperand* object, LOperand* value) {
2101 inputs_[0] = context;
2102 inputs_[1] = object;
2106 LOperand* context() { return inputs_[0]; }
2107 LOperand* object() { return inputs_[1]; }
2108 LOperand* value() { return inputs_[2]; }
2110 DECLARE_CONCRETE_INSTRUCTION(StoreNamedGeneric, "store-named-generic")
2111 DECLARE_HYDROGEN_ACCESSOR(StoreNamedGeneric)
2113 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
2115 Handle<Object> name() const { return hydrogen()->name(); }
2116 StrictModeFlag strict_mode_flag() { return hydrogen()->strict_mode_flag(); }
2120 class LStoreKeyed V8_FINAL : public LTemplateInstruction<0, 3, 0> {
2122 LStoreKeyed(LOperand* object, LOperand* key, LOperand* value) {
2123 inputs_[0] = object;
2128 bool is_external() const { return hydrogen()->is_external(); }
2129 bool is_fixed_typed_array() const {
2130 return hydrogen()->is_fixed_typed_array();
2132 bool is_typed_elements() const {
2133 return is_external() || is_fixed_typed_array();
2135 LOperand* elements() { return inputs_[0]; }
2136 LOperand* key() { return inputs_[1]; }
2137 LOperand* value() { return inputs_[2]; }
2138 ElementsKind elements_kind() const { return hydrogen()->elements_kind(); }
2140 DECLARE_CONCRETE_INSTRUCTION(StoreKeyed, "store-keyed")
2141 DECLARE_HYDROGEN_ACCESSOR(StoreKeyed)
2143 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
2144 bool NeedsCanonicalization() { return hydrogen()->NeedsCanonicalization(); }
2145 uint32_t additional_index() const { return hydrogen()->index_offset(); }
2149 class LStoreKeyedGeneric V8_FINAL : public LTemplateInstruction<0, 4, 0> {
2151 LStoreKeyedGeneric(LOperand* context,
2155 inputs_[0] = context;
2156 inputs_[1] = object;
2161 LOperand* context() { return inputs_[0]; }
2162 LOperand* object() { return inputs_[1]; }
2163 LOperand* key() { return inputs_[2]; }
2164 LOperand* value() { return inputs_[3]; }
2166 DECLARE_CONCRETE_INSTRUCTION(StoreKeyedGeneric, "store-keyed-generic")
2167 DECLARE_HYDROGEN_ACCESSOR(StoreKeyedGeneric)
2169 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
2171 StrictModeFlag strict_mode_flag() { return hydrogen()->strict_mode_flag(); }
2175 class LTransitionElementsKind V8_FINAL : public LTemplateInstruction<0, 2, 2> {
2177 LTransitionElementsKind(LOperand* object,
2179 LOperand* new_map_temp,
2181 inputs_[0] = object;
2182 inputs_[1] = context;
2183 temps_[0] = new_map_temp;
2187 LOperand* object() { return inputs_[0]; }
2188 LOperand* context() { return inputs_[1]; }
2189 LOperand* new_map_temp() { return temps_[0]; }
2190 LOperand* temp() { return temps_[1]; }
2192 DECLARE_CONCRETE_INSTRUCTION(TransitionElementsKind,
2193 "transition-elements-kind")
2194 DECLARE_HYDROGEN_ACCESSOR(TransitionElementsKind)
2196 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
2198 Handle<Map> original_map() { return hydrogen()->original_map().handle(); }
2199 Handle<Map> transitioned_map() {
2200 return hydrogen()->transitioned_map().handle();
2202 ElementsKind from_kind() { return hydrogen()->from_kind(); }
2203 ElementsKind to_kind() { return hydrogen()->to_kind(); }
2207 class LTrapAllocationMemento V8_FINAL : public LTemplateInstruction<0, 1, 1> {
2209 LTrapAllocationMemento(LOperand* object,
2211 inputs_[0] = object;
2215 LOperand* object() { return inputs_[0]; }
2216 LOperand* temp() { return temps_[0]; }
2218 DECLARE_CONCRETE_INSTRUCTION(TrapAllocationMemento,
2219 "trap-allocation-memento")
2223 class LStringAdd V8_FINAL : public LTemplateInstruction<1, 3, 0> {
2225 LStringAdd(LOperand* context, LOperand* left, LOperand* right) {
2226 inputs_[0] = context;
2231 LOperand* context() { return inputs_[0]; }
2232 LOperand* left() { return inputs_[1]; }
2233 LOperand* right() { return inputs_[2]; }
2235 DECLARE_CONCRETE_INSTRUCTION(StringAdd, "string-add")
2236 DECLARE_HYDROGEN_ACCESSOR(StringAdd)
2240 class LStringCharCodeAt V8_FINAL : public LTemplateInstruction<1, 3, 0> {
2242 LStringCharCodeAt(LOperand* context, LOperand* string, LOperand* index) {
2243 inputs_[0] = context;
2244 inputs_[1] = string;
2248 LOperand* context() { return inputs_[0]; }
2249 LOperand* string() { return inputs_[1]; }
2250 LOperand* index() { return inputs_[2]; }
2252 DECLARE_CONCRETE_INSTRUCTION(StringCharCodeAt, "string-char-code-at")
2253 DECLARE_HYDROGEN_ACCESSOR(StringCharCodeAt)
2257 class LStringCharFromCode V8_FINAL : public LTemplateInstruction<1, 2, 0> {
2259 explicit LStringCharFromCode(LOperand* context, LOperand* char_code) {
2260 inputs_[0] = context;
2261 inputs_[1] = char_code;
2264 LOperand* context() { return inputs_[0]; }
2265 LOperand* char_code() { return inputs_[1]; }
2267 DECLARE_CONCRETE_INSTRUCTION(StringCharFromCode, "string-char-from-code")
2268 DECLARE_HYDROGEN_ACCESSOR(StringCharFromCode)
2272 class LCheckValue V8_FINAL : public LTemplateInstruction<0, 1, 0> {
2274 explicit LCheckValue(LOperand* value) {
2278 LOperand* value() { return inputs_[0]; }
2280 DECLARE_CONCRETE_INSTRUCTION(CheckValue, "check-value")
2281 DECLARE_HYDROGEN_ACCESSOR(CheckValue)
2285 class LCheckInstanceType V8_FINAL : public LTemplateInstruction<0, 1, 0> {
2287 explicit LCheckInstanceType(LOperand* value) {
2291 LOperand* value() { return inputs_[0]; }
2293 DECLARE_CONCRETE_INSTRUCTION(CheckInstanceType, "check-instance-type")
2294 DECLARE_HYDROGEN_ACCESSOR(CheckInstanceType)
2298 class LCheckMaps V8_FINAL : public LTemplateInstruction<0, 1, 0> {
2300 explicit LCheckMaps(LOperand* value) {
2304 LOperand* value() { return inputs_[0]; }
2306 DECLARE_CONCRETE_INSTRUCTION(CheckMaps, "check-maps")
2307 DECLARE_HYDROGEN_ACCESSOR(CheckMaps)
2311 class LCheckSmi V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2313 explicit LCheckSmi(LOperand* value) {
2317 LOperand* value() { return inputs_[0]; }
2319 DECLARE_CONCRETE_INSTRUCTION(CheckSmi, "check-smi")
2323 class LClampDToUint8 V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2325 explicit LClampDToUint8(LOperand* unclamped) {
2326 inputs_[0] = unclamped;
2329 LOperand* unclamped() { return inputs_[0]; }
2331 DECLARE_CONCRETE_INSTRUCTION(ClampDToUint8, "clamp-d-to-uint8")
2335 class LClampIToUint8 V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2337 explicit LClampIToUint8(LOperand* unclamped) {
2338 inputs_[0] = unclamped;
2341 LOperand* unclamped() { return inputs_[0]; }
2343 DECLARE_CONCRETE_INSTRUCTION(ClampIToUint8, "clamp-i-to-uint8")
2347 class LClampTToUint8 V8_FINAL : public LTemplateInstruction<1, 1, 1> {
2349 LClampTToUint8(LOperand* unclamped,
2350 LOperand* temp_xmm) {
2351 inputs_[0] = unclamped;
2352 temps_[0] = temp_xmm;
2355 LOperand* unclamped() { return inputs_[0]; }
2356 LOperand* temp_xmm() { return temps_[0]; }
2358 DECLARE_CONCRETE_INSTRUCTION(ClampTToUint8, "clamp-t-to-uint8")
2362 class LCheckNonSmi V8_FINAL : public LTemplateInstruction<0, 1, 0> {
2364 explicit LCheckNonSmi(LOperand* value) {
2368 LOperand* value() { return inputs_[0]; }
2370 DECLARE_CONCRETE_INSTRUCTION(CheckNonSmi, "check-non-smi")
2371 DECLARE_HYDROGEN_ACCESSOR(CheckHeapObject)
2375 class LAllocate V8_FINAL : public LTemplateInstruction<1, 2, 1> {
2377 LAllocate(LOperand* context, LOperand* size, LOperand* temp) {
2378 inputs_[0] = context;
2383 LOperand* context() { return inputs_[0]; }
2384 LOperand* size() { return inputs_[1]; }
2385 LOperand* temp() { return temps_[0]; }
2387 DECLARE_CONCRETE_INSTRUCTION(Allocate, "allocate")
2388 DECLARE_HYDROGEN_ACCESSOR(Allocate)
2392 class LRegExpLiteral V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2394 explicit LRegExpLiteral(LOperand* context) {
2395 inputs_[0] = context;
2398 LOperand* context() { return inputs_[0]; }
2400 DECLARE_CONCRETE_INSTRUCTION(RegExpLiteral, "regexp-literal")
2401 DECLARE_HYDROGEN_ACCESSOR(RegExpLiteral)
2405 class LFunctionLiteral V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2407 explicit LFunctionLiteral(LOperand* context) {
2408 inputs_[0] = context;
2411 LOperand* context() { return inputs_[0]; }
2413 DECLARE_CONCRETE_INSTRUCTION(FunctionLiteral, "function-literal")
2414 DECLARE_HYDROGEN_ACCESSOR(FunctionLiteral)
2418 class LToFastProperties V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2420 explicit LToFastProperties(LOperand* value) {
2424 LOperand* value() { return inputs_[0]; }
2426 DECLARE_CONCRETE_INSTRUCTION(ToFastProperties, "to-fast-properties")
2427 DECLARE_HYDROGEN_ACCESSOR(ToFastProperties)
2431 class LTypeof V8_FINAL : public LTemplateInstruction<1, 2, 0> {
2433 LTypeof(LOperand* context, LOperand* value) {
2434 inputs_[0] = context;
2438 LOperand* context() { return inputs_[0]; }
2439 LOperand* value() { return inputs_[1]; }
2441 DECLARE_CONCRETE_INSTRUCTION(Typeof, "typeof")
2445 class LTypeofIsAndBranch V8_FINAL : public LControlInstruction<1, 0> {
2447 explicit LTypeofIsAndBranch(LOperand* value) {
2451 LOperand* value() { return inputs_[0]; }
2453 DECLARE_CONCRETE_INSTRUCTION(TypeofIsAndBranch, "typeof-is-and-branch")
2454 DECLARE_HYDROGEN_ACCESSOR(TypeofIsAndBranch)
2456 Handle<String> type_literal() { return hydrogen()->type_literal(); }
2458 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
2462 class LIsConstructCallAndBranch V8_FINAL : public LControlInstruction<0, 1> {
2464 explicit LIsConstructCallAndBranch(LOperand* temp) {
2468 LOperand* temp() { return temps_[0]; }
2470 DECLARE_CONCRETE_INSTRUCTION(IsConstructCallAndBranch,
2471 "is-construct-call-and-branch")
2472 DECLARE_HYDROGEN_ACCESSOR(IsConstructCallAndBranch)
2476 class LOsrEntry V8_FINAL : public LTemplateInstruction<0, 0, 0> {
2480 virtual bool HasInterestingComment(LCodeGen* gen) const V8_OVERRIDE {
2483 DECLARE_CONCRETE_INSTRUCTION(OsrEntry, "osr-entry")
2487 class LStackCheck V8_FINAL : public LTemplateInstruction<0, 1, 0> {
2489 explicit LStackCheck(LOperand* context) {
2490 inputs_[0] = context;
2493 LOperand* context() { return inputs_[0]; }
2495 DECLARE_CONCRETE_INSTRUCTION(StackCheck, "stack-check")
2496 DECLARE_HYDROGEN_ACCESSOR(StackCheck)
2498 Label* done_label() { return &done_label_; }
2505 class LForInPrepareMap V8_FINAL : public LTemplateInstruction<1, 2, 0> {
2507 LForInPrepareMap(LOperand* context, LOperand* object) {
2508 inputs_[0] = context;
2509 inputs_[1] = object;
2512 LOperand* context() { return inputs_[0]; }
2513 LOperand* object() { return inputs_[1]; }
2515 DECLARE_CONCRETE_INSTRUCTION(ForInPrepareMap, "for-in-prepare-map")
2519 class LForInCacheArray V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2521 explicit LForInCacheArray(LOperand* map) {
2525 LOperand* map() { return inputs_[0]; }
2527 DECLARE_CONCRETE_INSTRUCTION(ForInCacheArray, "for-in-cache-array")
2530 return HForInCacheArray::cast(this->hydrogen_value())->idx();
2535 class LCheckMapValue V8_FINAL : public LTemplateInstruction<0, 2, 0> {
2537 LCheckMapValue(LOperand* value, LOperand* map) {
2542 LOperand* value() { return inputs_[0]; }
2543 LOperand* map() { return inputs_[1]; }
2545 DECLARE_CONCRETE_INSTRUCTION(CheckMapValue, "check-map-value")
2549 class LLoadFieldByIndex V8_FINAL : public LTemplateInstruction<1, 2, 0> {
2551 LLoadFieldByIndex(LOperand* object, LOperand* index) {
2552 inputs_[0] = object;
2556 LOperand* object() { return inputs_[0]; }
2557 LOperand* index() { return inputs_[1]; }
2559 DECLARE_CONCRETE_INSTRUCTION(LoadFieldByIndex, "load-field-by-index")
2563 class LChunkBuilder;
2564 class LPlatformChunk V8_FINAL : public LChunk {
2566 LPlatformChunk(CompilationInfo* info, HGraph* graph)
2567 : LChunk(info, graph) { }
2569 int GetNextSpillIndex(RegisterKind kind);
2570 LOperand* GetNextSpillSlot(RegisterKind kind);
2574 class LChunkBuilder V8_FINAL : public LChunkBuilderBase {
2576 LChunkBuilder(CompilationInfo* info, HGraph* graph, LAllocator* allocator)
2577 : LChunkBuilderBase(graph->zone()),
2582 current_instruction_(NULL),
2583 current_block_(NULL),
2585 allocator_(allocator),
2586 instruction_pending_deoptimization_environment_(NULL),
2587 pending_deoptimization_ast_id_(BailoutId::None()) { }
2589 // Build the sequence for the graph.
2590 LPlatformChunk* Build();
2592 LInstruction* CheckElideControlInstruction(HControlInstruction* instr);
2594 // Declare methods that deal with the individual node types.
2595 #define DECLARE_DO(type) LInstruction* Do##type(H##type* node);
2596 HYDROGEN_CONCRETE_INSTRUCTION_LIST(DECLARE_DO)
2599 LInstruction* DoMathFloor(HUnaryMathOperation* instr);
2600 LInstruction* DoMathRound(HUnaryMathOperation* instr);
2601 LInstruction* DoMathAbs(HUnaryMathOperation* instr);
2602 LInstruction* DoMathLog(HUnaryMathOperation* instr);
2603 LInstruction* DoMathExp(HUnaryMathOperation* instr);
2604 LInstruction* DoMathSqrt(HUnaryMathOperation* instr);
2605 LInstruction* DoMathPowHalf(HUnaryMathOperation* instr);
2606 LInstruction* DoMathClz32(HUnaryMathOperation* instr);
2607 LInstruction* DoDivByPowerOf2I(HDiv* instr);
2608 LInstruction* DoDivI(HBinaryOperation* instr);
2609 LInstruction* DoModByPowerOf2I(HMod* instr);
2610 LInstruction* DoModI(HMod* instr);
2611 LInstruction* DoFlooringDivByPowerOf2I(HMathFloorOfDiv* instr);
2612 LInstruction* DoFlooringDivByConstI(HMathFloorOfDiv* instr);
2622 LPlatformChunk* chunk() const { return chunk_; }
2623 CompilationInfo* info() const { return info_; }
2624 HGraph* graph() const { return graph_; }
2626 bool is_unused() const { return status_ == UNUSED; }
2627 bool is_building() const { return status_ == BUILDING; }
2628 bool is_done() const { return status_ == DONE; }
2629 bool is_aborted() const { return status_ == ABORTED; }
2631 void Abort(BailoutReason reason);
2633 // Methods for getting operands for Use / Define / Temp.
2634 LUnallocated* ToUnallocated(Register reg);
2635 LUnallocated* ToUnallocated(XMMRegister reg);
2637 // Methods for setting up define-use relationships.
2638 MUST_USE_RESULT LOperand* Use(HValue* value, LUnallocated* operand);
2639 MUST_USE_RESULT LOperand* UseFixed(HValue* value, Register fixed_register);
2640 MUST_USE_RESULT LOperand* UseFixedDouble(HValue* value,
2641 XMMRegister fixed_register);
2643 // A value that is guaranteed to be allocated to a register.
2644 // Operand created by UseRegister is guaranteed to be live until the end of
2645 // instruction. This means that register allocator will not reuse it's
2646 // register for any other operand inside instruction.
2647 // Operand created by UseRegisterAtStart is guaranteed to be live only at
2648 // instruction start. Register allocator is free to assign the same register
2649 // to some other operand used inside instruction (i.e. temporary or
2651 MUST_USE_RESULT LOperand* UseRegister(HValue* value);
2652 MUST_USE_RESULT LOperand* UseRegisterAtStart(HValue* value);
2654 // An input operand in a register that may be trashed.
2655 MUST_USE_RESULT LOperand* UseTempRegister(HValue* value);
2657 // An input operand in a register that may be trashed or a constant operand.
2658 MUST_USE_RESULT LOperand* UseTempRegisterOrConstant(HValue* value);
2660 // An input operand in a register or stack slot.
2661 MUST_USE_RESULT LOperand* Use(HValue* value);
2662 MUST_USE_RESULT LOperand* UseAtStart(HValue* value);
2664 // An input operand in a register, stack slot or a constant operand.
2665 MUST_USE_RESULT LOperand* UseOrConstant(HValue* value);
2666 MUST_USE_RESULT LOperand* UseOrConstantAtStart(HValue* value);
2668 // An input operand in a register or a constant operand.
2669 MUST_USE_RESULT LOperand* UseRegisterOrConstant(HValue* value);
2670 MUST_USE_RESULT LOperand* UseRegisterOrConstantAtStart(HValue* value);
2672 // An input operand in a constant operand.
2673 MUST_USE_RESULT LOperand* UseConstant(HValue* value);
2675 // An input operand in register, stack slot or a constant operand.
2676 // Will not be moved to a register even if one is freely available.
2677 virtual MUST_USE_RESULT LOperand* UseAny(HValue* value) V8_OVERRIDE;
2679 // Temporary operand that must be in a register.
2680 MUST_USE_RESULT LUnallocated* TempRegister();
2681 MUST_USE_RESULT LOperand* FixedTemp(Register reg);
2682 MUST_USE_RESULT LOperand* FixedTemp(XMMRegister reg);
2684 // Methods for setting up define-use relationships.
2685 // Return the same instruction that they are passed.
2686 LInstruction* Define(LTemplateResultInstruction<1>* instr,
2687 LUnallocated* result);
2688 LInstruction* DefineAsRegister(LTemplateResultInstruction<1>* instr);
2689 LInstruction* DefineAsSpilled(LTemplateResultInstruction<1>* instr,
2691 LInstruction* DefineSameAsFirst(LTemplateResultInstruction<1>* instr);
2692 LInstruction* DefineFixed(LTemplateResultInstruction<1>* instr,
2694 LInstruction* DefineFixedDouble(LTemplateResultInstruction<1>* instr,
2696 // Assigns an environment to an instruction. An instruction which can
2697 // deoptimize must have an environment.
2698 LInstruction* AssignEnvironment(LInstruction* instr);
2699 // Assigns a pointer map to an instruction. An instruction which can
2700 // trigger a GC or a lazy deoptimization must have a pointer map.
2701 LInstruction* AssignPointerMap(LInstruction* instr);
2703 enum CanDeoptimize { CAN_DEOPTIMIZE_EAGERLY, CANNOT_DEOPTIMIZE_EAGERLY };
2705 // Marks a call for the register allocator. Assigns a pointer map to
2706 // support GC and lazy deoptimization. Assigns an environment to support
2707 // eager deoptimization if CAN_DEOPTIMIZE_EAGERLY.
2708 LInstruction* MarkAsCall(
2709 LInstruction* instr,
2710 HInstruction* hinstr,
2711 CanDeoptimize can_deoptimize = CANNOT_DEOPTIMIZE_EAGERLY);
2713 void VisitInstruction(HInstruction* current);
2715 void DoBasicBlock(HBasicBlock* block, HBasicBlock* next_block);
2716 LInstruction* DoShift(Token::Value op, HBitwiseBinaryOperation* instr);
2717 LInstruction* DoArithmeticD(Token::Value op,
2718 HArithmeticBinaryOperation* instr);
2719 LInstruction* DoArithmeticT(Token::Value op,
2720 HBinaryOperation* instr);
2722 LPlatformChunk* chunk_;
2723 CompilationInfo* info_;
2724 HGraph* const graph_;
2726 HInstruction* current_instruction_;
2727 HBasicBlock* current_block_;
2728 HBasicBlock* next_block_;
2729 LAllocator* allocator_;
2730 LInstruction* instruction_pending_deoptimization_environment_;
2731 BailoutId pending_deoptimization_ast_id_;
2733 DISALLOW_COPY_AND_ASSIGN(LChunkBuilder);
2736 #undef DECLARE_HYDROGEN_ACCESSOR
2737 #undef DECLARE_CONCRETE_INSTRUCTION
2739 } } // namespace v8::int
2741 #endif // V8_X64_LITHIUM_X64_H_