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) \
98 V(FlooringDivByConstI) \
99 V(FlooringDivByPowerOf2I) \
103 V(GetCachedArrayIndex) \
105 V(HasCachedArrayIndexAndBranch) \
106 V(HasInstanceTypeAndBranch) \
107 V(InnerAllocatedObject) \
109 V(InstanceOfKnownGlobal) \
111 V(Integer32ToDouble) \
113 V(IsConstructCallAndBranch) \
114 V(IsObjectAndBranch) \
115 V(IsStringAndBranch) \
117 V(IsUndetectableAndBranch) \
122 V(LoadFieldByIndex) \
123 V(LoadFunctionPrototype) \
125 V(LoadGlobalGeneric) \
127 V(LoadKeyedGeneric) \
129 V(LoadNamedGeneric) \
154 V(SeqStringGetChar) \
155 V(SeqStringSetChar) \
161 V(StoreContextSlot) \
164 V(StoreKeyedGeneric) \
166 V(StoreNamedGeneric) \
168 V(StringCharCodeAt) \
169 V(StringCharFromCode) \
170 V(StringCompareAndBranch) \
174 V(ToFastProperties) \
175 V(TransitionElementsKind) \
176 V(TrapAllocationMemento) \
178 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 DECLARE_CONCRETE_INSTRUCTION(DivI, "div-i")
739 DECLARE_HYDROGEN_ACCESSOR(BinaryOperation)
743 class LFlooringDivByPowerOf2I V8_FINAL : public LTemplateInstruction<1, 1, 0> {
745 LFlooringDivByPowerOf2I(LOperand* dividend, int32_t divisor) {
746 inputs_[0] = dividend;
750 LOperand* dividend() { return inputs_[0]; }
751 int32_t divisor() const { return divisor_; }
753 DECLARE_CONCRETE_INSTRUCTION(FlooringDivByPowerOf2I,
754 "flooring-div-by-power-of-2-i")
755 DECLARE_HYDROGEN_ACCESSOR(MathFloorOfDiv)
762 class LFlooringDivByConstI V8_FINAL : public LTemplateInstruction<1, 1, 2> {
764 LFlooringDivByConstI(LOperand* dividend,
768 inputs_[0] = dividend;
774 LOperand* dividend() { return inputs_[0]; }
775 int32_t divisor() const { return divisor_; }
776 LOperand* temp1() { return temps_[0]; }
777 LOperand* temp2() { return temps_[0]; }
779 DECLARE_CONCRETE_INSTRUCTION(FlooringDivByConstI, "flooring-div-by-const-i")
780 DECLARE_HYDROGEN_ACCESSOR(MathFloorOfDiv)
787 class LMulI V8_FINAL : public LTemplateInstruction<1, 2, 0> {
789 LMulI(LOperand* left, LOperand* right) {
794 LOperand* left() { return inputs_[0]; }
795 LOperand* right() { return inputs_[1]; }
797 DECLARE_CONCRETE_INSTRUCTION(MulI, "mul-i")
798 DECLARE_HYDROGEN_ACCESSOR(Mul)
802 class LCompareNumericAndBranch V8_FINAL : public LControlInstruction<2, 0> {
804 LCompareNumericAndBranch(LOperand* left, LOperand* right) {
809 LOperand* left() { return inputs_[0]; }
810 LOperand* right() { return inputs_[1]; }
812 DECLARE_CONCRETE_INSTRUCTION(CompareNumericAndBranch,
813 "compare-numeric-and-branch")
814 DECLARE_HYDROGEN_ACCESSOR(CompareNumericAndBranch)
816 Token::Value op() const { return hydrogen()->token(); }
817 bool is_double() const {
818 return hydrogen()->representation().IsDouble();
821 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
825 class LMathFloor V8_FINAL : public LTemplateInstruction<1, 1, 0> {
827 explicit LMathFloor(LOperand* value) {
831 LOperand* value() { return inputs_[0]; }
833 DECLARE_CONCRETE_INSTRUCTION(MathFloor, "math-floor")
834 DECLARE_HYDROGEN_ACCESSOR(UnaryMathOperation)
838 class LMathRound V8_FINAL : public LTemplateInstruction<1, 1, 0> {
840 explicit LMathRound(LOperand* value) {
844 LOperand* value() { return inputs_[0]; }
846 DECLARE_CONCRETE_INSTRUCTION(MathRound, "math-round")
847 DECLARE_HYDROGEN_ACCESSOR(UnaryMathOperation)
851 class LMathAbs V8_FINAL : public LTemplateInstruction<1, 2, 0> {
853 explicit LMathAbs(LOperand* context, LOperand* value) {
854 inputs_[1] = context;
858 LOperand* context() { return inputs_[1]; }
859 LOperand* value() { return inputs_[0]; }
861 DECLARE_CONCRETE_INSTRUCTION(MathAbs, "math-abs")
862 DECLARE_HYDROGEN_ACCESSOR(UnaryMathOperation)
866 class LMathLog V8_FINAL : public LTemplateInstruction<1, 1, 0> {
868 explicit LMathLog(LOperand* value) {
872 LOperand* value() { return inputs_[0]; }
874 DECLARE_CONCRETE_INSTRUCTION(MathLog, "math-log")
878 class LMathClz32 V8_FINAL : public LTemplateInstruction<1, 1, 0> {
880 explicit LMathClz32(LOperand* value) {
884 LOperand* value() { return inputs_[0]; }
886 DECLARE_CONCRETE_INSTRUCTION(MathClz32, "math-clz32")
890 class LMathExp V8_FINAL : public LTemplateInstruction<1, 1, 2> {
892 LMathExp(LOperand* value, LOperand* temp1, LOperand* temp2) {
896 ExternalReference::InitializeMathExpData();
899 LOperand* value() { return inputs_[0]; }
900 LOperand* temp1() { return temps_[0]; }
901 LOperand* temp2() { return temps_[1]; }
903 DECLARE_CONCRETE_INSTRUCTION(MathExp, "math-exp")
907 class LMathSqrt V8_FINAL : public LTemplateInstruction<1, 1, 0> {
909 explicit LMathSqrt(LOperand* value) {
913 LOperand* value() { return inputs_[0]; }
915 DECLARE_CONCRETE_INSTRUCTION(MathSqrt, "math-sqrt")
919 class LMathPowHalf V8_FINAL : public LTemplateInstruction<1, 1, 0> {
921 explicit LMathPowHalf(LOperand* value) {
925 LOperand* value() { return inputs_[0]; }
927 DECLARE_CONCRETE_INSTRUCTION(MathPowHalf, "math-pow-half")
931 class LCmpObjectEqAndBranch V8_FINAL : public LControlInstruction<2, 0> {
933 LCmpObjectEqAndBranch(LOperand* left, LOperand* right) {
938 LOperand* left() { return inputs_[0]; }
939 LOperand* right() { return inputs_[1]; }
941 DECLARE_CONCRETE_INSTRUCTION(CmpObjectEqAndBranch, "cmp-object-eq-and-branch")
945 class LCmpHoleAndBranch V8_FINAL : public LControlInstruction<1, 0> {
947 explicit LCmpHoleAndBranch(LOperand* object) {
951 LOperand* object() { return inputs_[0]; }
953 DECLARE_CONCRETE_INSTRUCTION(CmpHoleAndBranch, "cmp-hole-and-branch")
954 DECLARE_HYDROGEN_ACCESSOR(CompareHoleAndBranch)
958 class LCompareMinusZeroAndBranch V8_FINAL : public LControlInstruction<1, 0> {
960 explicit LCompareMinusZeroAndBranch(LOperand* value) {
964 LOperand* value() { return inputs_[0]; }
966 DECLARE_CONCRETE_INSTRUCTION(CompareMinusZeroAndBranch,
967 "cmp-minus-zero-and-branch")
968 DECLARE_HYDROGEN_ACCESSOR(CompareMinusZeroAndBranch)
973 class LIsObjectAndBranch V8_FINAL : public LControlInstruction<1, 0> {
975 explicit LIsObjectAndBranch(LOperand* value) {
979 LOperand* value() { return inputs_[0]; }
981 DECLARE_CONCRETE_INSTRUCTION(IsObjectAndBranch, "is-object-and-branch")
982 DECLARE_HYDROGEN_ACCESSOR(IsObjectAndBranch)
984 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
988 class LIsStringAndBranch V8_FINAL : public LControlInstruction<1, 1> {
990 explicit LIsStringAndBranch(LOperand* value, LOperand* temp) {
995 LOperand* value() { return inputs_[0]; }
996 LOperand* temp() { return temps_[0]; }
998 DECLARE_CONCRETE_INSTRUCTION(IsStringAndBranch, "is-string-and-branch")
999 DECLARE_HYDROGEN_ACCESSOR(IsStringAndBranch)
1001 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1005 class LIsSmiAndBranch V8_FINAL : public LControlInstruction<1, 0> {
1007 explicit LIsSmiAndBranch(LOperand* value) {
1011 LOperand* value() { return inputs_[0]; }
1013 DECLARE_CONCRETE_INSTRUCTION(IsSmiAndBranch, "is-smi-and-branch")
1014 DECLARE_HYDROGEN_ACCESSOR(IsSmiAndBranch)
1016 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1020 class LIsUndetectableAndBranch V8_FINAL : public LControlInstruction<1, 1> {
1022 explicit LIsUndetectableAndBranch(LOperand* value, LOperand* temp) {
1027 LOperand* value() { return inputs_[0]; }
1028 LOperand* temp() { return temps_[0]; }
1030 DECLARE_CONCRETE_INSTRUCTION(IsUndetectableAndBranch,
1031 "is-undetectable-and-branch")
1032 DECLARE_HYDROGEN_ACCESSOR(IsUndetectableAndBranch)
1034 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1038 class LStringCompareAndBranch V8_FINAL : public LControlInstruction<3, 0> {
1040 explicit LStringCompareAndBranch(LOperand* context,
1043 inputs_[0] = context;
1048 LOperand* context() { return inputs_[0]; }
1049 LOperand* left() { return inputs_[1]; }
1050 LOperand* right() { return inputs_[2]; }
1052 DECLARE_CONCRETE_INSTRUCTION(StringCompareAndBranch,
1053 "string-compare-and-branch")
1054 DECLARE_HYDROGEN_ACCESSOR(StringCompareAndBranch)
1056 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1058 Token::Value op() const { return hydrogen()->token(); }
1062 class LHasInstanceTypeAndBranch V8_FINAL : public LControlInstruction<1, 0> {
1064 explicit LHasInstanceTypeAndBranch(LOperand* value) {
1068 LOperand* value() { return inputs_[0]; }
1070 DECLARE_CONCRETE_INSTRUCTION(HasInstanceTypeAndBranch,
1071 "has-instance-type-and-branch")
1072 DECLARE_HYDROGEN_ACCESSOR(HasInstanceTypeAndBranch)
1074 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1078 class LGetCachedArrayIndex V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1080 explicit LGetCachedArrayIndex(LOperand* value) {
1084 LOperand* value() { return inputs_[0]; }
1086 DECLARE_CONCRETE_INSTRUCTION(GetCachedArrayIndex, "get-cached-array-index")
1087 DECLARE_HYDROGEN_ACCESSOR(GetCachedArrayIndex)
1091 class LHasCachedArrayIndexAndBranch V8_FINAL
1092 : public LControlInstruction<1, 0> {
1094 explicit LHasCachedArrayIndexAndBranch(LOperand* value) {
1098 LOperand* value() { return inputs_[0]; }
1100 DECLARE_CONCRETE_INSTRUCTION(HasCachedArrayIndexAndBranch,
1101 "has-cached-array-index-and-branch")
1102 DECLARE_HYDROGEN_ACCESSOR(HasCachedArrayIndexAndBranch)
1104 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1108 class LClassOfTestAndBranch V8_FINAL : public LControlInstruction<1, 2> {
1110 LClassOfTestAndBranch(LOperand* value, LOperand* temp, LOperand* temp2) {
1116 LOperand* value() { return inputs_[0]; }
1117 LOperand* temp() { return temps_[0]; }
1118 LOperand* temp2() { return temps_[1]; }
1120 DECLARE_CONCRETE_INSTRUCTION(ClassOfTestAndBranch,
1121 "class-of-test-and-branch")
1122 DECLARE_HYDROGEN_ACCESSOR(ClassOfTestAndBranch)
1124 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1128 class LCmpT V8_FINAL : public LTemplateInstruction<1, 3, 0> {
1130 LCmpT(LOperand* context, LOperand* left, LOperand* right) {
1131 inputs_[0] = context;
1136 LOperand* context() { return inputs_[0]; }
1137 LOperand* left() { return inputs_[1]; }
1138 LOperand* right() { return inputs_[2]; }
1140 DECLARE_CONCRETE_INSTRUCTION(CmpT, "cmp-t")
1141 DECLARE_HYDROGEN_ACCESSOR(CompareGeneric)
1143 Token::Value op() const { return hydrogen()->token(); }
1147 class LInstanceOf V8_FINAL : public LTemplateInstruction<1, 3, 0> {
1149 LInstanceOf(LOperand* context, LOperand* left, LOperand* right) {
1150 inputs_[0] = context;
1155 LOperand* context() { return inputs_[0]; }
1156 LOperand* left() { return inputs_[1]; }
1157 LOperand* right() { return inputs_[2]; }
1159 DECLARE_CONCRETE_INSTRUCTION(InstanceOf, "instance-of")
1163 class LInstanceOfKnownGlobal V8_FINAL : public LTemplateInstruction<1, 2, 1> {
1165 LInstanceOfKnownGlobal(LOperand* context, LOperand* value, LOperand* temp) {
1166 inputs_[0] = context;
1171 LOperand* context() { return inputs_[0]; }
1172 LOperand* value() { return inputs_[1]; }
1173 LOperand* temp() { return temps_[0]; }
1175 DECLARE_CONCRETE_INSTRUCTION(InstanceOfKnownGlobal,
1176 "instance-of-known-global")
1177 DECLARE_HYDROGEN_ACCESSOR(InstanceOfKnownGlobal)
1179 Handle<JSFunction> function() const { return hydrogen()->function(); }
1180 LEnvironment* GetDeferredLazyDeoptimizationEnvironment() {
1181 return lazy_deopt_env_;
1183 virtual void SetDeferredLazyDeoptimizationEnvironment(
1184 LEnvironment* env) V8_OVERRIDE {
1185 lazy_deopt_env_ = env;
1189 LEnvironment* lazy_deopt_env_;
1193 class LBoundsCheck V8_FINAL : public LTemplateInstruction<0, 2, 0> {
1195 LBoundsCheck(LOperand* index, LOperand* length) {
1197 inputs_[1] = length;
1200 LOperand* index() { return inputs_[0]; }
1201 LOperand* length() { return inputs_[1]; }
1203 DECLARE_CONCRETE_INSTRUCTION(BoundsCheck, "bounds-check")
1204 DECLARE_HYDROGEN_ACCESSOR(BoundsCheck)
1208 class LBitI V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1210 LBitI(LOperand* left, LOperand* right) {
1215 LOperand* left() { return inputs_[0]; }
1216 LOperand* right() { return inputs_[1]; }
1218 Token::Value op() const { return hydrogen()->op(); }
1220 DECLARE_CONCRETE_INSTRUCTION(BitI, "bit-i")
1221 DECLARE_HYDROGEN_ACCESSOR(Bitwise)
1225 class LShiftI V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1227 LShiftI(Token::Value op, LOperand* left, LOperand* right, bool can_deopt)
1228 : op_(op), can_deopt_(can_deopt) {
1233 Token::Value op() const { return op_; }
1234 LOperand* left() { return inputs_[0]; }
1235 LOperand* right() { return inputs_[1]; }
1236 bool can_deopt() const { return can_deopt_; }
1238 DECLARE_CONCRETE_INSTRUCTION(ShiftI, "shift-i")
1246 class LSubI V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1248 LSubI(LOperand* left, LOperand* right) {
1253 LOperand* left() { return inputs_[0]; }
1254 LOperand* right() { return inputs_[1]; }
1256 DECLARE_CONCRETE_INSTRUCTION(SubI, "sub-i")
1257 DECLARE_HYDROGEN_ACCESSOR(Sub)
1261 class LConstantI V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1263 DECLARE_CONCRETE_INSTRUCTION(ConstantI, "constant-i")
1264 DECLARE_HYDROGEN_ACCESSOR(Constant)
1266 int32_t value() const { return hydrogen()->Integer32Value(); }
1270 class LConstantS V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1272 DECLARE_CONCRETE_INSTRUCTION(ConstantS, "constant-s")
1273 DECLARE_HYDROGEN_ACCESSOR(Constant)
1275 Smi* value() const { return Smi::FromInt(hydrogen()->Integer32Value()); }
1279 class LConstantD V8_FINAL : public LTemplateInstruction<1, 0, 1> {
1281 explicit LConstantD(LOperand* temp) {
1285 LOperand* temp() { return temps_[0]; }
1287 DECLARE_CONCRETE_INSTRUCTION(ConstantD, "constant-d")
1288 DECLARE_HYDROGEN_ACCESSOR(Constant)
1290 double value() const { return hydrogen()->DoubleValue(); }
1294 class LConstantE V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1296 DECLARE_CONCRETE_INSTRUCTION(ConstantE, "constant-e")
1297 DECLARE_HYDROGEN_ACCESSOR(Constant)
1299 ExternalReference value() const {
1300 return hydrogen()->ExternalReferenceValue();
1305 class LConstantT V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1307 DECLARE_CONCRETE_INSTRUCTION(ConstantT, "constant-t")
1308 DECLARE_HYDROGEN_ACCESSOR(Constant)
1310 Handle<Object> value(Isolate* isolate) const {
1311 return hydrogen()->handle(isolate);
1316 class LBranch V8_FINAL : public LControlInstruction<1, 0> {
1318 explicit LBranch(LOperand* value) {
1322 LOperand* value() { return inputs_[0]; }
1324 DECLARE_CONCRETE_INSTRUCTION(Branch, "branch")
1325 DECLARE_HYDROGEN_ACCESSOR(Branch)
1327 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1331 class LDebugBreak V8_FINAL : public LTemplateInstruction<0, 0, 0> {
1333 DECLARE_CONCRETE_INSTRUCTION(DebugBreak, "break")
1337 class LCmpMapAndBranch V8_FINAL : public LControlInstruction<1, 0> {
1339 explicit LCmpMapAndBranch(LOperand* value) {
1343 LOperand* value() { return inputs_[0]; }
1345 DECLARE_CONCRETE_INSTRUCTION(CmpMapAndBranch, "cmp-map-and-branch")
1346 DECLARE_HYDROGEN_ACCESSOR(CompareMap)
1348 Handle<Map> map() const { return hydrogen()->map().handle(); }
1352 class LMapEnumLength V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1354 explicit LMapEnumLength(LOperand* value) {
1358 LOperand* value() { return inputs_[0]; }
1360 DECLARE_CONCRETE_INSTRUCTION(MapEnumLength, "map-enum-length")
1364 class LDateField V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1366 LDateField(LOperand* date, Smi* index) : index_(index) {
1370 LOperand* date() { return inputs_[0]; }
1371 Smi* index() const { return index_; }
1373 DECLARE_CONCRETE_INSTRUCTION(DateField, "date-field")
1374 DECLARE_HYDROGEN_ACCESSOR(DateField)
1381 class LSeqStringGetChar V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1383 LSeqStringGetChar(LOperand* string, LOperand* index) {
1384 inputs_[0] = string;
1388 LOperand* string() const { return inputs_[0]; }
1389 LOperand* index() const { return inputs_[1]; }
1391 DECLARE_CONCRETE_INSTRUCTION(SeqStringGetChar, "seq-string-get-char")
1392 DECLARE_HYDROGEN_ACCESSOR(SeqStringGetChar)
1396 class LSeqStringSetChar V8_FINAL : public LTemplateInstruction<1, 4, 0> {
1398 LSeqStringSetChar(LOperand* context,
1402 inputs_[0] = context;
1403 inputs_[1] = string;
1408 LOperand* string() { return inputs_[1]; }
1409 LOperand* index() { return inputs_[2]; }
1410 LOperand* value() { return inputs_[3]; }
1412 DECLARE_CONCRETE_INSTRUCTION(SeqStringSetChar, "seq-string-set-char")
1413 DECLARE_HYDROGEN_ACCESSOR(SeqStringSetChar)
1417 class LAddI V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1419 LAddI(LOperand* left, LOperand* right) {
1424 LOperand* left() { return inputs_[0]; }
1425 LOperand* right() { return inputs_[1]; }
1427 static bool UseLea(HAdd* add) {
1428 return !add->CheckFlag(HValue::kCanOverflow) &&
1429 add->BetterLeftOperand()->UseCount() > 1;
1432 DECLARE_CONCRETE_INSTRUCTION(AddI, "add-i")
1433 DECLARE_HYDROGEN_ACCESSOR(Add)
1437 class LMathMinMax V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1439 LMathMinMax(LOperand* left, LOperand* right) {
1444 LOperand* left() { return inputs_[0]; }
1445 LOperand* right() { return inputs_[1]; }
1447 DECLARE_CONCRETE_INSTRUCTION(MathMinMax, "math-min-max")
1448 DECLARE_HYDROGEN_ACCESSOR(MathMinMax)
1452 class LPower V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1454 LPower(LOperand* left, LOperand* right) {
1459 LOperand* left() { return inputs_[0]; }
1460 LOperand* right() { return inputs_[1]; }
1462 DECLARE_CONCRETE_INSTRUCTION(Power, "power")
1463 DECLARE_HYDROGEN_ACCESSOR(Power)
1467 class LArithmeticD V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1469 LArithmeticD(Token::Value op, LOperand* left, LOperand* right)
1475 Token::Value op() const { return op_; }
1476 LOperand* left() { return inputs_[0]; }
1477 LOperand* right() { return inputs_[1]; }
1479 virtual Opcode opcode() const V8_OVERRIDE {
1480 return LInstruction::kArithmeticD;
1482 virtual void CompileToNative(LCodeGen* generator) V8_OVERRIDE;
1483 virtual const char* Mnemonic() const V8_OVERRIDE;
1490 class LArithmeticT V8_FINAL : public LTemplateInstruction<1, 3, 0> {
1492 LArithmeticT(Token::Value op,
1497 inputs_[0] = context;
1502 Token::Value op() const { return op_; }
1503 LOperand* context() { return inputs_[0]; }
1504 LOperand* left() { return inputs_[1]; }
1505 LOperand* right() { return inputs_[2]; }
1507 virtual Opcode opcode() const V8_OVERRIDE {
1508 return LInstruction::kArithmeticT;
1510 virtual void CompileToNative(LCodeGen* generator) V8_OVERRIDE;
1511 virtual const char* Mnemonic() const V8_OVERRIDE;
1518 class LReturn V8_FINAL : public LTemplateInstruction<0, 3, 0> {
1520 explicit LReturn(LOperand* value,
1522 LOperand* parameter_count) {
1524 inputs_[1] = context;
1525 inputs_[2] = parameter_count;
1528 LOperand* value() { return inputs_[0]; }
1529 LOperand* context() { return inputs_[1]; }
1531 bool has_constant_parameter_count() {
1532 return parameter_count()->IsConstantOperand();
1534 LConstantOperand* constant_parameter_count() {
1535 ASSERT(has_constant_parameter_count());
1536 return LConstantOperand::cast(parameter_count());
1538 LOperand* parameter_count() { return inputs_[2]; }
1540 DECLARE_CONCRETE_INSTRUCTION(Return, "return")
1541 DECLARE_HYDROGEN_ACCESSOR(Return)
1545 class LLoadNamedField V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1547 explicit LLoadNamedField(LOperand* object) {
1548 inputs_[0] = object;
1551 LOperand* object() { return inputs_[0]; }
1553 DECLARE_CONCRETE_INSTRUCTION(LoadNamedField, "load-named-field")
1554 DECLARE_HYDROGEN_ACCESSOR(LoadNamedField)
1558 class LLoadNamedGeneric V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1560 explicit LLoadNamedGeneric(LOperand* context, LOperand* object) {
1561 inputs_[0] = context;
1562 inputs_[1] = object;
1565 DECLARE_CONCRETE_INSTRUCTION(LoadNamedGeneric, "load-named-generic")
1566 DECLARE_HYDROGEN_ACCESSOR(LoadNamedGeneric)
1568 LOperand* context() { return inputs_[0]; }
1569 LOperand* object() { return inputs_[1]; }
1570 Handle<Object> name() const { return hydrogen()->name(); }
1574 class LLoadFunctionPrototype V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1576 explicit LLoadFunctionPrototype(LOperand* function) {
1577 inputs_[0] = function;
1580 DECLARE_CONCRETE_INSTRUCTION(LoadFunctionPrototype, "load-function-prototype")
1581 DECLARE_HYDROGEN_ACCESSOR(LoadFunctionPrototype)
1583 LOperand* function() { return inputs_[0]; }
1587 class LLoadRoot V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1589 DECLARE_CONCRETE_INSTRUCTION(LoadRoot, "load-root")
1590 DECLARE_HYDROGEN_ACCESSOR(LoadRoot)
1592 Heap::RootListIndex index() const { return hydrogen()->index(); }
1596 class LLoadKeyed V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1598 LLoadKeyed(LOperand* elements, LOperand* key) {
1599 inputs_[0] = elements;
1603 DECLARE_CONCRETE_INSTRUCTION(LoadKeyed, "load-keyed")
1604 DECLARE_HYDROGEN_ACCESSOR(LoadKeyed)
1606 bool is_external() const {
1607 return hydrogen()->is_external();
1609 bool is_fixed_typed_array() const {
1610 return hydrogen()->is_fixed_typed_array();
1612 bool is_typed_elements() const {
1613 return is_external() || is_fixed_typed_array();
1615 LOperand* elements() { return inputs_[0]; }
1616 LOperand* key() { return inputs_[1]; }
1617 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1618 uint32_t additional_index() const { return hydrogen()->index_offset(); }
1619 ElementsKind elements_kind() const {
1620 return hydrogen()->elements_kind();
1625 class LLoadKeyedGeneric V8_FINAL : public LTemplateInstruction<1, 3, 0> {
1627 LLoadKeyedGeneric(LOperand* context, LOperand* obj, LOperand* key) {
1628 inputs_[0] = context;
1633 DECLARE_CONCRETE_INSTRUCTION(LoadKeyedGeneric, "load-keyed-generic")
1635 LOperand* context() { return inputs_[0]; }
1636 LOperand* object() { return inputs_[1]; }
1637 LOperand* key() { return inputs_[2]; }
1641 class LLoadGlobalCell V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1643 DECLARE_CONCRETE_INSTRUCTION(LoadGlobalCell, "load-global-cell")
1644 DECLARE_HYDROGEN_ACCESSOR(LoadGlobalCell)
1648 class LLoadGlobalGeneric V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1650 explicit LLoadGlobalGeneric(LOperand* context, LOperand* global_object) {
1651 inputs_[0] = context;
1652 inputs_[1] = global_object;
1655 DECLARE_CONCRETE_INSTRUCTION(LoadGlobalGeneric, "load-global-generic")
1656 DECLARE_HYDROGEN_ACCESSOR(LoadGlobalGeneric)
1658 LOperand* context() { return inputs_[0]; }
1659 LOperand* global_object() { return inputs_[1]; }
1660 Handle<Object> name() const { return hydrogen()->name(); }
1661 bool for_typeof() const { return hydrogen()->for_typeof(); }
1665 class LStoreGlobalCell V8_FINAL : public LTemplateInstruction<0, 1, 1> {
1667 explicit LStoreGlobalCell(LOperand* value, LOperand* temp) {
1672 LOperand* value() { return inputs_[0]; }
1673 LOperand* temp() { return temps_[0]; }
1675 DECLARE_CONCRETE_INSTRUCTION(StoreGlobalCell, "store-global-cell")
1676 DECLARE_HYDROGEN_ACCESSOR(StoreGlobalCell)
1680 class LLoadContextSlot V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1682 explicit LLoadContextSlot(LOperand* context) {
1683 inputs_[0] = context;
1686 LOperand* context() { return inputs_[0]; }
1688 DECLARE_CONCRETE_INSTRUCTION(LoadContextSlot, "load-context-slot")
1689 DECLARE_HYDROGEN_ACCESSOR(LoadContextSlot)
1691 int slot_index() { return hydrogen()->slot_index(); }
1693 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1697 class LStoreContextSlot V8_FINAL : public LTemplateInstruction<0, 2, 1> {
1699 LStoreContextSlot(LOperand* context, LOperand* value, LOperand* temp) {
1700 inputs_[0] = context;
1705 LOperand* context() { return inputs_[0]; }
1706 LOperand* value() { return inputs_[1]; }
1707 LOperand* temp() { return temps_[0]; }
1709 DECLARE_CONCRETE_INSTRUCTION(StoreContextSlot, "store-context-slot")
1710 DECLARE_HYDROGEN_ACCESSOR(StoreContextSlot)
1712 int slot_index() { return hydrogen()->slot_index(); }
1714 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1718 class LPushArgument V8_FINAL : public LTemplateInstruction<0, 1, 0> {
1720 explicit LPushArgument(LOperand* value) {
1724 LOperand* value() { return inputs_[0]; }
1726 DECLARE_CONCRETE_INSTRUCTION(PushArgument, "push-argument")
1730 class LDrop V8_FINAL : public LTemplateInstruction<0, 0, 0> {
1732 explicit LDrop(int count) : count_(count) { }
1734 int count() const { return count_; }
1736 DECLARE_CONCRETE_INSTRUCTION(Drop, "drop")
1743 class LStoreCodeEntry V8_FINAL: public LTemplateInstruction<0, 1, 1> {
1745 LStoreCodeEntry(LOperand* function, LOperand* code_object) {
1746 inputs_[0] = function;
1747 temps_[0] = code_object;
1750 LOperand* function() { return inputs_[0]; }
1751 LOperand* code_object() { return temps_[0]; }
1753 virtual void PrintDataTo(StringStream* stream);
1755 DECLARE_CONCRETE_INSTRUCTION(StoreCodeEntry, "store-code-entry")
1756 DECLARE_HYDROGEN_ACCESSOR(StoreCodeEntry)
1760 class LInnerAllocatedObject V8_FINAL: public LTemplateInstruction<1, 2, 0> {
1762 LInnerAllocatedObject(LOperand* base_object, LOperand* offset) {
1763 inputs_[0] = base_object;
1764 inputs_[1] = offset;
1767 LOperand* base_object() const { return inputs_[0]; }
1768 LOperand* offset() const { return inputs_[1]; }
1770 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1772 DECLARE_CONCRETE_INSTRUCTION(InnerAllocatedObject, "inner-allocated-object")
1776 class LThisFunction V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1778 DECLARE_CONCRETE_INSTRUCTION(ThisFunction, "this-function")
1779 DECLARE_HYDROGEN_ACCESSOR(ThisFunction)
1783 class LContext V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1785 DECLARE_CONCRETE_INSTRUCTION(Context, "context")
1786 DECLARE_HYDROGEN_ACCESSOR(Context)
1790 class LDeclareGlobals V8_FINAL : public LTemplateInstruction<0, 1, 0> {
1792 explicit LDeclareGlobals(LOperand* context) {
1793 inputs_[0] = context;
1796 LOperand* context() { return inputs_[0]; }
1798 DECLARE_CONCRETE_INSTRUCTION(DeclareGlobals, "declare-globals")
1799 DECLARE_HYDROGEN_ACCESSOR(DeclareGlobals)
1803 class LCallJSFunction V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1805 explicit LCallJSFunction(LOperand* function) {
1806 inputs_[0] = function;
1809 LOperand* function() { return inputs_[0]; }
1811 DECLARE_CONCRETE_INSTRUCTION(CallJSFunction, "call-js-function")
1812 DECLARE_HYDROGEN_ACCESSOR(CallJSFunction)
1814 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1816 int arity() const { return hydrogen()->argument_count() - 1; }
1820 class LCallWithDescriptor V8_FINAL : public LTemplateResultInstruction<1> {
1822 LCallWithDescriptor(const CallInterfaceDescriptor* descriptor,
1823 ZoneList<LOperand*>& operands,
1825 : inputs_(descriptor->environment_length() + 1, zone) {
1826 ASSERT(descriptor->environment_length() + 1 == operands.length());
1827 inputs_.AddAll(operands, zone);
1830 LOperand* target() const { return inputs_[0]; }
1833 DECLARE_CONCRETE_INSTRUCTION(CallWithDescriptor, "call-with-descriptor")
1834 DECLARE_HYDROGEN_ACCESSOR(CallWithDescriptor)
1836 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1838 int arity() const { return hydrogen()->argument_count() - 1; }
1840 ZoneList<LOperand*> inputs_;
1842 // Iterator support.
1843 virtual int InputCount() V8_FINAL V8_OVERRIDE { return inputs_.length(); }
1844 virtual LOperand* InputAt(int i) V8_FINAL V8_OVERRIDE { return inputs_[i]; }
1846 virtual int TempCount() V8_FINAL V8_OVERRIDE { return 0; }
1847 virtual LOperand* TempAt(int i) V8_FINAL V8_OVERRIDE { return NULL; }
1851 class LInvokeFunction V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1853 LInvokeFunction(LOperand* context, LOperand* function) {
1854 inputs_[0] = context;
1855 inputs_[1] = function;
1858 LOperand* context() { return inputs_[0]; }
1859 LOperand* function() { return inputs_[1]; }
1861 DECLARE_CONCRETE_INSTRUCTION(InvokeFunction, "invoke-function")
1862 DECLARE_HYDROGEN_ACCESSOR(InvokeFunction)
1864 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1866 int arity() const { return hydrogen()->argument_count() - 1; }
1870 class LCallFunction V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1872 LCallFunction(LOperand* context, LOperand* function) {
1873 inputs_[0] = context;
1874 inputs_[1] = function;
1877 DECLARE_CONCRETE_INSTRUCTION(CallFunction, "call-function")
1878 DECLARE_HYDROGEN_ACCESSOR(CallFunction)
1880 LOperand* context() { return inputs_[0]; }
1881 LOperand* function() { return inputs_[1]; }
1882 int arity() const { return hydrogen()->argument_count() - 1; }
1886 class LCallNew V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1888 LCallNew(LOperand* context, LOperand* constructor) {
1889 inputs_[0] = context;
1890 inputs_[1] = constructor;
1893 LOperand* context() { return inputs_[0]; }
1894 LOperand* constructor() { return inputs_[1]; }
1896 DECLARE_CONCRETE_INSTRUCTION(CallNew, "call-new")
1897 DECLARE_HYDROGEN_ACCESSOR(CallNew)
1899 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1901 int arity() const { return hydrogen()->argument_count() - 1; }
1905 class LCallNewArray V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1907 LCallNewArray(LOperand* context, LOperand* constructor) {
1908 inputs_[0] = context;
1909 inputs_[1] = constructor;
1912 LOperand* context() { return inputs_[0]; }
1913 LOperand* constructor() { return inputs_[1]; }
1915 DECLARE_CONCRETE_INSTRUCTION(CallNewArray, "call-new-array")
1916 DECLARE_HYDROGEN_ACCESSOR(CallNewArray)
1918 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1920 int arity() const { return hydrogen()->argument_count() - 1; }
1924 class LCallRuntime V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1926 explicit LCallRuntime(LOperand* context) {
1927 inputs_[0] = context;
1930 LOperand* context() { return inputs_[0]; }
1932 DECLARE_CONCRETE_INSTRUCTION(CallRuntime, "call-runtime")
1933 DECLARE_HYDROGEN_ACCESSOR(CallRuntime)
1935 virtual bool ClobbersDoubleRegisters() const V8_OVERRIDE {
1936 return save_doubles() == kDontSaveFPRegs;
1939 const Runtime::Function* function() const { return hydrogen()->function(); }
1940 int arity() const { return hydrogen()->argument_count(); }
1941 SaveFPRegsMode save_doubles() const { return hydrogen()->save_doubles(); }
1945 class LInteger32ToDouble V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1947 explicit LInteger32ToDouble(LOperand* value) {
1951 LOperand* value() { return inputs_[0]; }
1953 DECLARE_CONCRETE_INSTRUCTION(Integer32ToDouble, "int32-to-double")
1957 class LUint32ToDouble V8_FINAL : public LTemplateInstruction<1, 1, 1> {
1959 explicit LUint32ToDouble(LOperand* value, LOperand* temp) {
1964 LOperand* value() { return inputs_[0]; }
1965 LOperand* temp() { return temps_[0]; }
1967 DECLARE_CONCRETE_INSTRUCTION(Uint32ToDouble, "uint32-to-double")
1971 class LNumberTagI V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1973 explicit LNumberTagI(LOperand* value) {
1977 LOperand* value() { return inputs_[0]; }
1979 DECLARE_CONCRETE_INSTRUCTION(NumberTagI, "number-tag-i")
1983 class LNumberTagU V8_FINAL : public LTemplateInstruction<1, 1, 2> {
1985 LNumberTagU(LOperand* value, LOperand* temp1, LOperand* temp2) {
1991 LOperand* value() { return inputs_[0]; }
1992 LOperand* temp1() { return temps_[0]; }
1993 LOperand* temp2() { return temps_[1]; }
1995 DECLARE_CONCRETE_INSTRUCTION(NumberTagU, "number-tag-u")
1999 class LNumberTagD V8_FINAL : public LTemplateInstruction<1, 1, 1> {
2001 explicit LNumberTagD(LOperand* value, LOperand* temp) {
2006 LOperand* value() { return inputs_[0]; }
2007 LOperand* temp() { return temps_[0]; }
2009 DECLARE_CONCRETE_INSTRUCTION(NumberTagD, "number-tag-d")
2010 DECLARE_HYDROGEN_ACCESSOR(Change)
2014 // Sometimes truncating conversion from a tagged value to an int32.
2015 class LDoubleToI V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2017 explicit LDoubleToI(LOperand* value) {
2021 LOperand* value() { return inputs_[0]; }
2023 DECLARE_CONCRETE_INSTRUCTION(DoubleToI, "double-to-i")
2024 DECLARE_HYDROGEN_ACCESSOR(UnaryOperation)
2026 bool truncating() { return hydrogen()->CanTruncateToInt32(); }
2030 class LDoubleToSmi V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2032 explicit LDoubleToSmi(LOperand* value) {
2036 LOperand* value() { return inputs_[0]; }
2038 DECLARE_CONCRETE_INSTRUCTION(DoubleToSmi, "double-to-smi")
2039 DECLARE_HYDROGEN_ACCESSOR(UnaryOperation)
2043 // Truncating conversion from a tagged value to an int32.
2044 class LTaggedToI V8_FINAL : public LTemplateInstruction<1, 1, 1> {
2046 LTaggedToI(LOperand* value, LOperand* temp) {
2051 LOperand* value() { return inputs_[0]; }
2052 LOperand* temp() { return temps_[0]; }
2054 DECLARE_CONCRETE_INSTRUCTION(TaggedToI, "tagged-to-i")
2055 DECLARE_HYDROGEN_ACCESSOR(Change)
2057 bool truncating() { return hydrogen()->CanTruncateToInt32(); }
2061 class LSmiTag V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2063 explicit LSmiTag(LOperand* value) {
2067 LOperand* value() { return inputs_[0]; }
2069 DECLARE_CONCRETE_INSTRUCTION(SmiTag, "smi-tag")
2070 DECLARE_HYDROGEN_ACCESSOR(Change)
2074 class LNumberUntagD V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2076 explicit LNumberUntagD(LOperand* value) {
2080 LOperand* value() { return inputs_[0]; }
2082 DECLARE_CONCRETE_INSTRUCTION(NumberUntagD, "double-untag")
2083 DECLARE_HYDROGEN_ACCESSOR(Change);
2087 class LSmiUntag V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2089 LSmiUntag(LOperand* value, bool needs_check)
2090 : needs_check_(needs_check) {
2094 LOperand* value() { return inputs_[0]; }
2095 bool needs_check() const { return needs_check_; }
2097 DECLARE_CONCRETE_INSTRUCTION(SmiUntag, "smi-untag")
2104 class LStoreNamedField V8_FINAL : public LTemplateInstruction<0, 2, 1> {
2106 LStoreNamedField(LOperand* object, LOperand* value, LOperand* temp) {
2107 inputs_[0] = object;
2112 LOperand* object() { return inputs_[0]; }
2113 LOperand* value() { return inputs_[1]; }
2114 LOperand* temp() { return temps_[0]; }
2116 DECLARE_CONCRETE_INSTRUCTION(StoreNamedField, "store-named-field")
2117 DECLARE_HYDROGEN_ACCESSOR(StoreNamedField)
2119 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
2121 Handle<Map> transition() const { return hydrogen()->transition_map(); }
2122 Representation representation() const {
2123 return hydrogen()->field_representation();
2128 class LStoreNamedGeneric V8_FINAL : public LTemplateInstruction<0, 3, 0> {
2130 LStoreNamedGeneric(LOperand* context, LOperand* object, LOperand* value) {
2131 inputs_[0] = context;
2132 inputs_[1] = object;
2136 LOperand* context() { return inputs_[0]; }
2137 LOperand* object() { return inputs_[1]; }
2138 LOperand* value() { return inputs_[2]; }
2140 DECLARE_CONCRETE_INSTRUCTION(StoreNamedGeneric, "store-named-generic")
2141 DECLARE_HYDROGEN_ACCESSOR(StoreNamedGeneric)
2143 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
2145 Handle<Object> name() const { return hydrogen()->name(); }
2146 StrictMode strict_mode() { return hydrogen()->strict_mode(); }
2150 class LStoreKeyed V8_FINAL : public LTemplateInstruction<0, 3, 0> {
2152 LStoreKeyed(LOperand* object, LOperand* key, LOperand* value) {
2153 inputs_[0] = object;
2158 bool is_external() const { return hydrogen()->is_external(); }
2159 bool is_fixed_typed_array() const {
2160 return hydrogen()->is_fixed_typed_array();
2162 bool is_typed_elements() const {
2163 return is_external() || is_fixed_typed_array();
2165 LOperand* elements() { return inputs_[0]; }
2166 LOperand* key() { return inputs_[1]; }
2167 LOperand* value() { return inputs_[2]; }
2168 ElementsKind elements_kind() const { return hydrogen()->elements_kind(); }
2170 DECLARE_CONCRETE_INSTRUCTION(StoreKeyed, "store-keyed")
2171 DECLARE_HYDROGEN_ACCESSOR(StoreKeyed)
2173 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
2174 bool NeedsCanonicalization() { return hydrogen()->NeedsCanonicalization(); }
2175 uint32_t additional_index() const { return hydrogen()->index_offset(); }
2179 class LStoreKeyedGeneric V8_FINAL : public LTemplateInstruction<0, 4, 0> {
2181 LStoreKeyedGeneric(LOperand* context,
2185 inputs_[0] = context;
2186 inputs_[1] = object;
2191 LOperand* context() { return inputs_[0]; }
2192 LOperand* object() { return inputs_[1]; }
2193 LOperand* key() { return inputs_[2]; }
2194 LOperand* value() { return inputs_[3]; }
2196 DECLARE_CONCRETE_INSTRUCTION(StoreKeyedGeneric, "store-keyed-generic")
2197 DECLARE_HYDROGEN_ACCESSOR(StoreKeyedGeneric)
2199 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
2201 StrictMode strict_mode() { return hydrogen()->strict_mode(); }
2205 class LTransitionElementsKind V8_FINAL : public LTemplateInstruction<0, 2, 2> {
2207 LTransitionElementsKind(LOperand* object,
2209 LOperand* new_map_temp,
2211 inputs_[0] = object;
2212 inputs_[1] = context;
2213 temps_[0] = new_map_temp;
2217 LOperand* object() { return inputs_[0]; }
2218 LOperand* context() { return inputs_[1]; }
2219 LOperand* new_map_temp() { return temps_[0]; }
2220 LOperand* temp() { return temps_[1]; }
2222 DECLARE_CONCRETE_INSTRUCTION(TransitionElementsKind,
2223 "transition-elements-kind")
2224 DECLARE_HYDROGEN_ACCESSOR(TransitionElementsKind)
2226 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
2228 Handle<Map> original_map() { return hydrogen()->original_map().handle(); }
2229 Handle<Map> transitioned_map() {
2230 return hydrogen()->transitioned_map().handle();
2232 ElementsKind from_kind() { return hydrogen()->from_kind(); }
2233 ElementsKind to_kind() { return hydrogen()->to_kind(); }
2237 class LTrapAllocationMemento V8_FINAL : public LTemplateInstruction<0, 1, 1> {
2239 LTrapAllocationMemento(LOperand* object,
2241 inputs_[0] = object;
2245 LOperand* object() { return inputs_[0]; }
2246 LOperand* temp() { return temps_[0]; }
2248 DECLARE_CONCRETE_INSTRUCTION(TrapAllocationMemento,
2249 "trap-allocation-memento")
2253 class LStringAdd V8_FINAL : public LTemplateInstruction<1, 3, 0> {
2255 LStringAdd(LOperand* context, LOperand* left, LOperand* right) {
2256 inputs_[0] = context;
2261 LOperand* context() { return inputs_[0]; }
2262 LOperand* left() { return inputs_[1]; }
2263 LOperand* right() { return inputs_[2]; }
2265 DECLARE_CONCRETE_INSTRUCTION(StringAdd, "string-add")
2266 DECLARE_HYDROGEN_ACCESSOR(StringAdd)
2270 class LStringCharCodeAt V8_FINAL : public LTemplateInstruction<1, 3, 0> {
2272 LStringCharCodeAt(LOperand* context, LOperand* string, LOperand* index) {
2273 inputs_[0] = context;
2274 inputs_[1] = string;
2278 LOperand* context() { return inputs_[0]; }
2279 LOperand* string() { return inputs_[1]; }
2280 LOperand* index() { return inputs_[2]; }
2282 DECLARE_CONCRETE_INSTRUCTION(StringCharCodeAt, "string-char-code-at")
2283 DECLARE_HYDROGEN_ACCESSOR(StringCharCodeAt)
2287 class LStringCharFromCode V8_FINAL : public LTemplateInstruction<1, 2, 0> {
2289 explicit LStringCharFromCode(LOperand* context, LOperand* char_code) {
2290 inputs_[0] = context;
2291 inputs_[1] = char_code;
2294 LOperand* context() { return inputs_[0]; }
2295 LOperand* char_code() { return inputs_[1]; }
2297 DECLARE_CONCRETE_INSTRUCTION(StringCharFromCode, "string-char-from-code")
2298 DECLARE_HYDROGEN_ACCESSOR(StringCharFromCode)
2302 class LCheckValue V8_FINAL : public LTemplateInstruction<0, 1, 0> {
2304 explicit LCheckValue(LOperand* value) {
2308 LOperand* value() { return inputs_[0]; }
2310 DECLARE_CONCRETE_INSTRUCTION(CheckValue, "check-value")
2311 DECLARE_HYDROGEN_ACCESSOR(CheckValue)
2315 class LCheckInstanceType V8_FINAL : public LTemplateInstruction<0, 1, 0> {
2317 explicit LCheckInstanceType(LOperand* value) {
2321 LOperand* value() { return inputs_[0]; }
2323 DECLARE_CONCRETE_INSTRUCTION(CheckInstanceType, "check-instance-type")
2324 DECLARE_HYDROGEN_ACCESSOR(CheckInstanceType)
2328 class LCheckMaps V8_FINAL : public LTemplateInstruction<0, 1, 0> {
2330 explicit LCheckMaps(LOperand* value) {
2334 LOperand* value() { return inputs_[0]; }
2336 DECLARE_CONCRETE_INSTRUCTION(CheckMaps, "check-maps")
2337 DECLARE_HYDROGEN_ACCESSOR(CheckMaps)
2341 class LCheckSmi V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2343 explicit LCheckSmi(LOperand* value) {
2347 LOperand* value() { return inputs_[0]; }
2349 DECLARE_CONCRETE_INSTRUCTION(CheckSmi, "check-smi")
2353 class LClampDToUint8 V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2355 explicit LClampDToUint8(LOperand* unclamped) {
2356 inputs_[0] = unclamped;
2359 LOperand* unclamped() { return inputs_[0]; }
2361 DECLARE_CONCRETE_INSTRUCTION(ClampDToUint8, "clamp-d-to-uint8")
2365 class LClampIToUint8 V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2367 explicit LClampIToUint8(LOperand* unclamped) {
2368 inputs_[0] = unclamped;
2371 LOperand* unclamped() { return inputs_[0]; }
2373 DECLARE_CONCRETE_INSTRUCTION(ClampIToUint8, "clamp-i-to-uint8")
2377 class LClampTToUint8 V8_FINAL : public LTemplateInstruction<1, 1, 1> {
2379 LClampTToUint8(LOperand* unclamped,
2380 LOperand* temp_xmm) {
2381 inputs_[0] = unclamped;
2382 temps_[0] = temp_xmm;
2385 LOperand* unclamped() { return inputs_[0]; }
2386 LOperand* temp_xmm() { return temps_[0]; }
2388 DECLARE_CONCRETE_INSTRUCTION(ClampTToUint8, "clamp-t-to-uint8")
2392 class LCheckNonSmi V8_FINAL : public LTemplateInstruction<0, 1, 0> {
2394 explicit LCheckNonSmi(LOperand* value) {
2398 LOperand* value() { return inputs_[0]; }
2400 DECLARE_CONCRETE_INSTRUCTION(CheckNonSmi, "check-non-smi")
2401 DECLARE_HYDROGEN_ACCESSOR(CheckHeapObject)
2405 class LDoubleBits V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2407 explicit LDoubleBits(LOperand* value) {
2411 LOperand* value() { return inputs_[0]; }
2413 DECLARE_CONCRETE_INSTRUCTION(DoubleBits, "double-bits")
2414 DECLARE_HYDROGEN_ACCESSOR(DoubleBits)
2418 class LConstructDouble V8_FINAL : public LTemplateInstruction<1, 2, 0> {
2420 LConstructDouble(LOperand* hi, LOperand* lo) {
2425 LOperand* hi() { return inputs_[0]; }
2426 LOperand* lo() { return inputs_[1]; }
2428 DECLARE_CONCRETE_INSTRUCTION(ConstructDouble, "construct-double")
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) { }
2644 // Build the sequence for the graph.
2645 LPlatformChunk* Build();
2647 LInstruction* CheckElideControlInstruction(HControlInstruction* instr);
2649 // Declare methods that deal with the individual node types.
2650 #define DECLARE_DO(type) LInstruction* Do##type(H##type* node);
2651 HYDROGEN_CONCRETE_INSTRUCTION_LIST(DECLARE_DO)
2654 LInstruction* DoMathFloor(HUnaryMathOperation* instr);
2655 LInstruction* DoMathRound(HUnaryMathOperation* instr);
2656 LInstruction* DoMathAbs(HUnaryMathOperation* instr);
2657 LInstruction* DoMathLog(HUnaryMathOperation* instr);
2658 LInstruction* DoMathExp(HUnaryMathOperation* instr);
2659 LInstruction* DoMathSqrt(HUnaryMathOperation* instr);
2660 LInstruction* DoMathPowHalf(HUnaryMathOperation* instr);
2661 LInstruction* DoMathClz32(HUnaryMathOperation* instr);
2662 LInstruction* DoDivByPowerOf2I(HDiv* instr);
2663 LInstruction* DoDivByConstI(HDiv* instr);
2664 LInstruction* DoDivI(HBinaryOperation* instr);
2665 LInstruction* DoModByPowerOf2I(HMod* instr);
2666 LInstruction* DoModByConstI(HMod* instr);
2667 LInstruction* DoModI(HMod* instr);
2668 LInstruction* DoFlooringDivByPowerOf2I(HMathFloorOfDiv* instr);
2669 LInstruction* DoFlooringDivByConstI(HMathFloorOfDiv* instr);
2679 LPlatformChunk* chunk() const { return chunk_; }
2680 CompilationInfo* info() const { return info_; }
2681 HGraph* graph() const { return graph_; }
2683 bool is_unused() const { return status_ == UNUSED; }
2684 bool is_building() const { return status_ == BUILDING; }
2685 bool is_done() const { return status_ == DONE; }
2686 bool is_aborted() const { return status_ == ABORTED; }
2688 void Abort(BailoutReason reason);
2690 // Methods for getting operands for Use / Define / Temp.
2691 LUnallocated* ToUnallocated(Register reg);
2692 LUnallocated* ToUnallocated(XMMRegister reg);
2694 // Methods for setting up define-use relationships.
2695 MUST_USE_RESULT LOperand* Use(HValue* value, LUnallocated* operand);
2696 MUST_USE_RESULT LOperand* UseFixed(HValue* value, Register fixed_register);
2697 MUST_USE_RESULT LOperand* UseFixedDouble(HValue* value,
2698 XMMRegister fixed_register);
2700 // A value that is guaranteed to be allocated to a register.
2701 // Operand created by UseRegister is guaranteed to be live until the end of
2702 // instruction. This means that register allocator will not reuse it's
2703 // register for any other operand inside instruction.
2704 // Operand created by UseRegisterAtStart is guaranteed to be live only at
2705 // instruction start. Register allocator is free to assign the same register
2706 // to some other operand used inside instruction (i.e. temporary or
2708 MUST_USE_RESULT LOperand* UseRegister(HValue* value);
2709 MUST_USE_RESULT LOperand* UseRegisterAtStart(HValue* value);
2711 // An input operand in a register that may be trashed.
2712 MUST_USE_RESULT LOperand* UseTempRegister(HValue* value);
2714 // An input operand in a register that may be trashed or a constant operand.
2715 MUST_USE_RESULT LOperand* UseTempRegisterOrConstant(HValue* value);
2717 // An input operand in a register or stack slot.
2718 MUST_USE_RESULT LOperand* Use(HValue* value);
2719 MUST_USE_RESULT LOperand* UseAtStart(HValue* value);
2721 // An input operand in a register, stack slot or a constant operand.
2722 MUST_USE_RESULT LOperand* UseOrConstant(HValue* value);
2723 MUST_USE_RESULT LOperand* UseOrConstantAtStart(HValue* value);
2725 // An input operand in a register or a constant operand.
2726 MUST_USE_RESULT LOperand* UseRegisterOrConstant(HValue* value);
2727 MUST_USE_RESULT LOperand* UseRegisterOrConstantAtStart(HValue* value);
2729 // An input operand in a constant operand.
2730 MUST_USE_RESULT LOperand* UseConstant(HValue* value);
2732 // An input operand in register, stack slot or a constant operand.
2733 // Will not be moved to a register even if one is freely available.
2734 virtual MUST_USE_RESULT LOperand* UseAny(HValue* value) V8_OVERRIDE;
2736 // Temporary operand that must be in a register.
2737 MUST_USE_RESULT LUnallocated* TempRegister();
2738 MUST_USE_RESULT LOperand* FixedTemp(Register reg);
2739 MUST_USE_RESULT LOperand* FixedTemp(XMMRegister reg);
2741 // Methods for setting up define-use relationships.
2742 // Return the same instruction that they are passed.
2743 LInstruction* Define(LTemplateResultInstruction<1>* instr,
2744 LUnallocated* result);
2745 LInstruction* DefineAsRegister(LTemplateResultInstruction<1>* instr);
2746 LInstruction* DefineAsSpilled(LTemplateResultInstruction<1>* instr,
2748 LInstruction* DefineSameAsFirst(LTemplateResultInstruction<1>* instr);
2749 LInstruction* DefineFixed(LTemplateResultInstruction<1>* instr,
2751 LInstruction* DefineFixedDouble(LTemplateResultInstruction<1>* instr,
2753 // Assigns an environment to an instruction. An instruction which can
2754 // deoptimize must have an environment.
2755 LInstruction* AssignEnvironment(LInstruction* instr);
2756 // Assigns a pointer map to an instruction. An instruction which can
2757 // trigger a GC or a lazy deoptimization must have a pointer map.
2758 LInstruction* AssignPointerMap(LInstruction* instr);
2760 enum CanDeoptimize { CAN_DEOPTIMIZE_EAGERLY, CANNOT_DEOPTIMIZE_EAGERLY };
2762 // Marks a call for the register allocator. Assigns a pointer map to
2763 // support GC and lazy deoptimization. Assigns an environment to support
2764 // eager deoptimization if CAN_DEOPTIMIZE_EAGERLY.
2765 LInstruction* MarkAsCall(
2766 LInstruction* instr,
2767 HInstruction* hinstr,
2768 CanDeoptimize can_deoptimize = CANNOT_DEOPTIMIZE_EAGERLY);
2770 void VisitInstruction(HInstruction* current);
2772 void DoBasicBlock(HBasicBlock* block, HBasicBlock* next_block);
2773 LInstruction* DoShift(Token::Value op, HBitwiseBinaryOperation* instr);
2774 LInstruction* DoArithmeticD(Token::Value op,
2775 HArithmeticBinaryOperation* instr);
2776 LInstruction* DoArithmeticT(Token::Value op,
2777 HBinaryOperation* instr);
2779 LPlatformChunk* chunk_;
2780 CompilationInfo* info_;
2781 HGraph* const graph_;
2783 HInstruction* current_instruction_;
2784 HBasicBlock* current_block_;
2785 HBasicBlock* next_block_;
2786 LAllocator* allocator_;
2788 DISALLOW_COPY_AND_ASSIGN(LChunkBuilder);
2791 #undef DECLARE_HYDROGEN_ACCESSOR
2792 #undef DECLARE_CONCRETE_INSTRUCTION
2794 } } // namespace v8::int
2796 #endif // V8_X64_LITHIUM_X64_H_