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) \
97 V(FlooringDivByConstI) \
98 V(FlooringDivByPowerOf2I) \
102 V(GetCachedArrayIndex) \
104 V(HasCachedArrayIndexAndBranch) \
105 V(HasInstanceTypeAndBranch) \
106 V(InnerAllocatedObject) \
108 V(InstanceOfKnownGlobal) \
110 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) \
153 V(SeqStringGetChar) \
154 V(SeqStringSetChar) \
160 V(StoreContextSlot) \
163 V(StoreKeyedGeneric) \
165 V(StoreNamedGeneric) \
167 V(StringCharCodeAt) \
168 V(StringCharFromCode) \
169 V(StringCompareAndBranch) \
173 V(ToFastProperties) \
174 V(TransitionElementsKind) \
175 V(TrapAllocationMemento) \
177 V(TypeofIsAndBranch) \
184 #define DECLARE_CONCRETE_INSTRUCTION(type, mnemonic) \
185 virtual Opcode opcode() const V8_FINAL V8_OVERRIDE { \
186 return LInstruction::k##type; \
188 virtual void CompileToNative(LCodeGen* generator) V8_FINAL V8_OVERRIDE; \
189 virtual const char* Mnemonic() const V8_FINAL V8_OVERRIDE { \
192 static L##type* cast(LInstruction* instr) { \
193 ASSERT(instr->Is##type()); \
194 return reinterpret_cast<L##type*>(instr); \
198 #define DECLARE_HYDROGEN_ACCESSOR(type) \
199 H##type* hydrogen() const { \
200 return H##type::cast(hydrogen_value()); \
204 class LInstruction : public ZoneObject {
207 : environment_(NULL),
208 hydrogen_value_(NULL),
209 bit_field_(IsCallBits::encode(false)) {
212 virtual ~LInstruction() {}
214 virtual void CompileToNative(LCodeGen* generator) = 0;
215 virtual const char* Mnemonic() const = 0;
216 virtual void PrintTo(StringStream* stream);
217 virtual void PrintDataTo(StringStream* stream);
218 virtual void PrintOutputOperandTo(StringStream* stream);
221 // Declare a unique enum value for each instruction.
222 #define DECLARE_OPCODE(type) k##type,
223 LITHIUM_CONCRETE_INSTRUCTION_LIST(DECLARE_OPCODE)
224 kNumberOfInstructions
225 #undef DECLARE_OPCODE
228 virtual Opcode opcode() const = 0;
230 // Declare non-virtual type testers for all leaf IR classes.
231 #define DECLARE_PREDICATE(type) \
232 bool Is##type() const { return opcode() == k##type; }
233 LITHIUM_CONCRETE_INSTRUCTION_LIST(DECLARE_PREDICATE)
234 #undef DECLARE_PREDICATE
236 // Declare virtual predicates for instructions that don't have
238 virtual bool IsGap() const { return false; }
240 virtual bool IsControl() const { return false; }
242 void set_environment(LEnvironment* env) { environment_ = env; }
243 LEnvironment* environment() const { return environment_; }
244 bool HasEnvironment() const { return environment_ != NULL; }
246 void set_pointer_map(LPointerMap* p) { pointer_map_.set(p); }
247 LPointerMap* pointer_map() const { return pointer_map_.get(); }
248 bool HasPointerMap() const { return pointer_map_.is_set(); }
250 void set_hydrogen_value(HValue* value) { hydrogen_value_ = value; }
251 HValue* hydrogen_value() const { return hydrogen_value_; }
253 void MarkAsCall() { bit_field_ = IsCallBits::update(bit_field_, true); }
254 bool IsCall() const { return IsCallBits::decode(bit_field_); }
256 // Interface to the register allocator and iterators.
257 bool ClobbersTemps() const { return IsCall(); }
258 bool ClobbersRegisters() const { return IsCall(); }
259 virtual bool ClobbersDoubleRegisters() const { return IsCall(); }
261 virtual void SetDeferredLazyDeoptimizationEnvironment(LEnvironment* env) { }
263 // Interface to the register allocator and iterators.
264 bool IsMarkedAsCall() const { return IsCall(); }
266 virtual bool HasResult() const = 0;
267 virtual LOperand* result() const = 0;
269 LOperand* FirstInput() { return InputAt(0); }
270 LOperand* Output() { return HasResult() ? result() : NULL; }
272 virtual bool HasInterestingComment(LCodeGen* gen) const { return true; }
280 friend class InputIterator;
281 virtual int InputCount() = 0;
282 virtual LOperand* InputAt(int i) = 0;
284 friend class TempIterator;
285 virtual int TempCount() = 0;
286 virtual LOperand* TempAt(int i) = 0;
288 class IsCallBits: public BitField<bool, 0, 1> {};
290 LEnvironment* environment_;
291 SetOncePointer<LPointerMap> pointer_map_;
292 HValue* hydrogen_value_;
297 // R = number of result operands (0 or 1).
299 class LTemplateResultInstruction : public LInstruction {
301 // Allow 0 or 1 output operands.
302 STATIC_ASSERT(R == 0 || R == 1);
303 virtual bool HasResult() const V8_FINAL V8_OVERRIDE {
304 return R != 0 && result() != NULL;
306 void set_result(LOperand* operand) { results_[0] = operand; }
307 LOperand* result() const { return results_[0]; }
310 EmbeddedContainer<LOperand*, R> results_;
314 // R = number of result operands (0 or 1).
315 // I = number of input operands.
316 // T = number of temporary operands.
317 template<int R, int I, int T>
318 class LTemplateInstruction : public LTemplateResultInstruction<R> {
320 EmbeddedContainer<LOperand*, I> inputs_;
321 EmbeddedContainer<LOperand*, T> temps_;
325 virtual int InputCount() V8_FINAL V8_OVERRIDE { return I; }
326 virtual LOperand* InputAt(int i) V8_FINAL V8_OVERRIDE { return inputs_[i]; }
328 virtual int TempCount() V8_FINAL V8_OVERRIDE { return T; }
329 virtual LOperand* TempAt(int i) V8_FINAL V8_OVERRIDE { return temps_[i]; }
333 class LGap : public LTemplateInstruction<0, 0, 0> {
335 explicit LGap(HBasicBlock* block)
337 parallel_moves_[BEFORE] = NULL;
338 parallel_moves_[START] = NULL;
339 parallel_moves_[END] = NULL;
340 parallel_moves_[AFTER] = NULL;
343 // Can't use the DECLARE-macro here because of sub-classes.
344 virtual bool IsGap() const V8_FINAL V8_OVERRIDE { return true; }
345 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
346 static LGap* cast(LInstruction* instr) {
347 ASSERT(instr->IsGap());
348 return reinterpret_cast<LGap*>(instr);
351 bool IsRedundant() const;
353 HBasicBlock* block() const { return block_; }
360 FIRST_INNER_POSITION = BEFORE,
361 LAST_INNER_POSITION = AFTER
364 LParallelMove* GetOrCreateParallelMove(InnerPosition pos,
366 if (parallel_moves_[pos] == NULL) {
367 parallel_moves_[pos] = new(zone) LParallelMove(zone);
369 return parallel_moves_[pos];
372 LParallelMove* GetParallelMove(InnerPosition pos) {
373 return parallel_moves_[pos];
377 LParallelMove* parallel_moves_[LAST_INNER_POSITION + 1];
382 class LInstructionGap V8_FINAL : public LGap {
384 explicit LInstructionGap(HBasicBlock* block) : LGap(block) { }
386 virtual bool HasInterestingComment(LCodeGen* gen) const V8_OVERRIDE {
387 return !IsRedundant();
390 DECLARE_CONCRETE_INSTRUCTION(InstructionGap, "gap")
394 class LGoto V8_FINAL : public LTemplateInstruction<0, 0, 0> {
396 explicit LGoto(HBasicBlock* block) : block_(block) { }
398 virtual bool HasInterestingComment(LCodeGen* gen) const V8_OVERRIDE;
399 DECLARE_CONCRETE_INSTRUCTION(Goto, "goto")
400 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
401 virtual bool IsControl() const V8_OVERRIDE { return true; }
403 int block_id() const { return block_->block_id(); }
410 class LLazyBailout V8_FINAL : public LTemplateInstruction<0, 0, 0> {
412 LLazyBailout() : gap_instructions_size_(0) { }
414 DECLARE_CONCRETE_INSTRUCTION(LazyBailout, "lazy-bailout")
416 void set_gap_instructions_size(int gap_instructions_size) {
417 gap_instructions_size_ = gap_instructions_size;
419 int gap_instructions_size() { return gap_instructions_size_; }
422 int gap_instructions_size_;
426 class LDummy V8_FINAL : public LTemplateInstruction<1, 0, 0> {
428 explicit LDummy() { }
429 DECLARE_CONCRETE_INSTRUCTION(Dummy, "dummy")
433 class LDummyUse V8_FINAL : public LTemplateInstruction<1, 1, 0> {
435 explicit LDummyUse(LOperand* value) {
438 DECLARE_CONCRETE_INSTRUCTION(DummyUse, "dummy-use")
442 class LDeoptimize V8_FINAL : public LTemplateInstruction<0, 0, 0> {
444 DECLARE_CONCRETE_INSTRUCTION(Deoptimize, "deoptimize")
445 DECLARE_HYDROGEN_ACCESSOR(Deoptimize)
449 class LLabel V8_FINAL : public LGap {
451 explicit LLabel(HBasicBlock* block)
452 : LGap(block), replacement_(NULL) { }
454 virtual bool HasInterestingComment(LCodeGen* gen) const V8_OVERRIDE {
457 DECLARE_CONCRETE_INSTRUCTION(Label, "label")
459 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
461 int block_id() const { return block()->block_id(); }
462 bool is_loop_header() const { return block()->IsLoopHeader(); }
463 bool is_osr_entry() const { return block()->is_osr_entry(); }
464 Label* label() { return &label_; }
465 LLabel* replacement() const { return replacement_; }
466 void set_replacement(LLabel* label) { replacement_ = label; }
467 bool HasReplacement() const { return replacement_ != NULL; }
471 LLabel* replacement_;
475 class LParameter V8_FINAL : public LTemplateInstruction<1, 0, 0> {
477 virtual bool HasInterestingComment(LCodeGen* gen) const V8_OVERRIDE {
480 DECLARE_CONCRETE_INSTRUCTION(Parameter, "parameter")
484 class LCallStub V8_FINAL : public LTemplateInstruction<1, 1, 0> {
486 explicit LCallStub(LOperand* context) {
487 inputs_[0] = context;
490 LOperand* context() { return inputs_[0]; }
492 DECLARE_CONCRETE_INSTRUCTION(CallStub, "call-stub")
493 DECLARE_HYDROGEN_ACCESSOR(CallStub)
497 class LUnknownOSRValue V8_FINAL : public LTemplateInstruction<1, 0, 0> {
499 virtual bool HasInterestingComment(LCodeGen* gen) const V8_OVERRIDE {
502 DECLARE_CONCRETE_INSTRUCTION(UnknownOSRValue, "unknown-osr-value")
506 template<int I, int T>
507 class LControlInstruction : public LTemplateInstruction<0, I, T> {
509 LControlInstruction() : false_label_(NULL), true_label_(NULL) { }
511 virtual bool IsControl() const V8_FINAL V8_OVERRIDE { return true; }
513 int SuccessorCount() { return hydrogen()->SuccessorCount(); }
514 HBasicBlock* SuccessorAt(int i) { return hydrogen()->SuccessorAt(i); }
516 int TrueDestination(LChunk* chunk) {
517 return chunk->LookupDestination(true_block_id());
519 int FalseDestination(LChunk* chunk) {
520 return chunk->LookupDestination(false_block_id());
523 Label* TrueLabel(LChunk* chunk) {
524 if (true_label_ == NULL) {
525 true_label_ = chunk->GetAssemblyLabel(TrueDestination(chunk));
529 Label* FalseLabel(LChunk* chunk) {
530 if (false_label_ == NULL) {
531 false_label_ = chunk->GetAssemblyLabel(FalseDestination(chunk));
537 int true_block_id() { return SuccessorAt(0)->block_id(); }
538 int false_block_id() { return SuccessorAt(1)->block_id(); }
541 HControlInstruction* hydrogen() {
542 return HControlInstruction::cast(this->hydrogen_value());
550 class LWrapReceiver V8_FINAL : public LTemplateInstruction<1, 2, 0> {
552 LWrapReceiver(LOperand* receiver, LOperand* function) {
553 inputs_[0] = receiver;
554 inputs_[1] = function;
557 LOperand* receiver() { return inputs_[0]; }
558 LOperand* function() { return inputs_[1]; }
560 DECLARE_CONCRETE_INSTRUCTION(WrapReceiver, "wrap-receiver")
561 DECLARE_HYDROGEN_ACCESSOR(WrapReceiver)
565 class LApplyArguments V8_FINAL : public LTemplateInstruction<1, 4, 0> {
567 LApplyArguments(LOperand* function,
570 LOperand* elements) {
571 inputs_[0] = function;
572 inputs_[1] = receiver;
574 inputs_[3] = elements;
577 LOperand* function() { return inputs_[0]; }
578 LOperand* receiver() { return inputs_[1]; }
579 LOperand* length() { return inputs_[2]; }
580 LOperand* elements() { return inputs_[3]; }
582 DECLARE_CONCRETE_INSTRUCTION(ApplyArguments, "apply-arguments")
586 class LAccessArgumentsAt V8_FINAL : public LTemplateInstruction<1, 3, 0> {
588 LAccessArgumentsAt(LOperand* arguments, LOperand* length, LOperand* index) {
589 inputs_[0] = arguments;
594 LOperand* arguments() { return inputs_[0]; }
595 LOperand* length() { return inputs_[1]; }
596 LOperand* index() { return inputs_[2]; }
598 DECLARE_CONCRETE_INSTRUCTION(AccessArgumentsAt, "access-arguments-at")
600 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
604 class LArgumentsLength V8_FINAL : public LTemplateInstruction<1, 1, 0> {
606 explicit LArgumentsLength(LOperand* elements) {
607 inputs_[0] = elements;
610 LOperand* elements() { return inputs_[0]; }
612 DECLARE_CONCRETE_INSTRUCTION(ArgumentsLength, "arguments-length")
616 class LArgumentsElements V8_FINAL : public LTemplateInstruction<1, 0, 0> {
618 DECLARE_CONCRETE_INSTRUCTION(ArgumentsElements, "arguments-elements")
619 DECLARE_HYDROGEN_ACCESSOR(ArgumentsElements)
623 class LModByPowerOf2I V8_FINAL : public LTemplateInstruction<1, 1, 0> {
625 LModByPowerOf2I(LOperand* dividend, int32_t divisor) {
626 inputs_[0] = dividend;
630 LOperand* dividend() { return inputs_[0]; }
631 int32_t divisor() const { return divisor_; }
633 DECLARE_CONCRETE_INSTRUCTION(ModByPowerOf2I, "mod-by-power-of-2-i")
634 DECLARE_HYDROGEN_ACCESSOR(Mod)
641 class LModI V8_FINAL : public LTemplateInstruction<1, 2, 1> {
643 LModI(LOperand* left, LOperand* right, LOperand* temp) {
649 LOperand* left() { return inputs_[0]; }
650 LOperand* right() { return inputs_[1]; }
651 LOperand* temp() { return temps_[0]; }
653 DECLARE_CONCRETE_INSTRUCTION(ModI, "mod-i")
654 DECLARE_HYDROGEN_ACCESSOR(Mod)
658 class LDivByPowerOf2I V8_FINAL : public LTemplateInstruction<1, 1, 0> {
660 LDivByPowerOf2I(LOperand* dividend, int32_t divisor) {
661 inputs_[0] = dividend;
665 LOperand* dividend() { return inputs_[0]; }
666 int32_t divisor() const { return divisor_; }
668 DECLARE_CONCRETE_INSTRUCTION(DivByPowerOf2I, "div-by-power-of-2-i")
669 DECLARE_HYDROGEN_ACCESSOR(Div)
676 class LDivI V8_FINAL : public LTemplateInstruction<1, 2, 1> {
678 LDivI(LOperand* left, LOperand* right, LOperand* temp) {
684 LOperand* left() { return inputs_[0]; }
685 LOperand* right() { return inputs_[1]; }
686 LOperand* temp() { return temps_[0]; }
688 bool is_flooring() { return hydrogen_value()->IsMathFloorOfDiv(); }
690 DECLARE_CONCRETE_INSTRUCTION(DivI, "div-i")
691 DECLARE_HYDROGEN_ACCESSOR(BinaryOperation)
695 class LFlooringDivByPowerOf2I V8_FINAL : public LTemplateInstruction<1, 1, 0> {
697 LFlooringDivByPowerOf2I(LOperand* dividend, int32_t divisor) {
698 inputs_[0] = dividend;
702 LOperand* dividend() { return inputs_[0]; }
703 int32_t divisor() const { return divisor_; }
705 DECLARE_CONCRETE_INSTRUCTION(FlooringDivByPowerOf2I,
706 "flooring-div-by-power-of-2-i")
707 DECLARE_HYDROGEN_ACCESSOR(MathFloorOfDiv)
714 class LFlooringDivByConstI V8_FINAL : public LTemplateInstruction<1, 1, 1> {
716 LFlooringDivByConstI(LOperand* dividend, int32_t divisor, LOperand* temp) {
717 inputs_[0] = dividend;
722 LOperand* dividend() { return inputs_[0]; }
723 int32_t divisor() const { return divisor_; }
724 LOperand* temp() { return temps_[0]; }
726 DECLARE_CONCRETE_INSTRUCTION(FlooringDivByConstI, "flooring-div-by-const-i")
727 DECLARE_HYDROGEN_ACCESSOR(MathFloorOfDiv)
734 class LMulI V8_FINAL : public LTemplateInstruction<1, 2, 0> {
736 LMulI(LOperand* left, LOperand* right) {
741 LOperand* left() { return inputs_[0]; }
742 LOperand* right() { return inputs_[1]; }
744 DECLARE_CONCRETE_INSTRUCTION(MulI, "mul-i")
745 DECLARE_HYDROGEN_ACCESSOR(Mul)
749 class LCompareNumericAndBranch V8_FINAL : public LControlInstruction<2, 0> {
751 LCompareNumericAndBranch(LOperand* left, LOperand* right) {
756 LOperand* left() { return inputs_[0]; }
757 LOperand* right() { return inputs_[1]; }
759 DECLARE_CONCRETE_INSTRUCTION(CompareNumericAndBranch,
760 "compare-numeric-and-branch")
761 DECLARE_HYDROGEN_ACCESSOR(CompareNumericAndBranch)
763 Token::Value op() const { return hydrogen()->token(); }
764 bool is_double() const {
765 return hydrogen()->representation().IsDouble();
768 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
772 class LMathFloor V8_FINAL : public LTemplateInstruction<1, 1, 0> {
774 explicit LMathFloor(LOperand* value) {
778 LOperand* value() { return inputs_[0]; }
780 DECLARE_CONCRETE_INSTRUCTION(MathFloor, "math-floor")
781 DECLARE_HYDROGEN_ACCESSOR(UnaryMathOperation)
785 class LMathRound V8_FINAL : public LTemplateInstruction<1, 1, 0> {
787 explicit LMathRound(LOperand* value) {
791 LOperand* value() { return inputs_[0]; }
793 DECLARE_CONCRETE_INSTRUCTION(MathRound, "math-round")
794 DECLARE_HYDROGEN_ACCESSOR(UnaryMathOperation)
798 class LMathAbs V8_FINAL : public LTemplateInstruction<1, 2, 0> {
800 explicit LMathAbs(LOperand* context, LOperand* value) {
801 inputs_[1] = context;
805 LOperand* context() { return inputs_[1]; }
806 LOperand* value() { return inputs_[0]; }
808 DECLARE_CONCRETE_INSTRUCTION(MathAbs, "math-abs")
809 DECLARE_HYDROGEN_ACCESSOR(UnaryMathOperation)
813 class LMathLog V8_FINAL : public LTemplateInstruction<1, 1, 0> {
815 explicit LMathLog(LOperand* value) {
819 LOperand* value() { return inputs_[0]; }
821 DECLARE_CONCRETE_INSTRUCTION(MathLog, "math-log")
825 class LMathClz32 V8_FINAL : public LTemplateInstruction<1, 1, 0> {
827 explicit LMathClz32(LOperand* value) {
831 LOperand* value() { return inputs_[0]; }
833 DECLARE_CONCRETE_INSTRUCTION(MathClz32, "math-clz32")
837 class LMathExp V8_FINAL : public LTemplateInstruction<1, 1, 2> {
839 LMathExp(LOperand* value, LOperand* temp1, LOperand* temp2) {
843 ExternalReference::InitializeMathExpData();
846 LOperand* value() { return inputs_[0]; }
847 LOperand* temp1() { return temps_[0]; }
848 LOperand* temp2() { return temps_[1]; }
850 DECLARE_CONCRETE_INSTRUCTION(MathExp, "math-exp")
854 class LMathSqrt V8_FINAL : public LTemplateInstruction<1, 1, 0> {
856 explicit LMathSqrt(LOperand* value) {
860 LOperand* value() { return inputs_[0]; }
862 DECLARE_CONCRETE_INSTRUCTION(MathSqrt, "math-sqrt")
866 class LMathPowHalf V8_FINAL : public LTemplateInstruction<1, 1, 0> {
868 explicit LMathPowHalf(LOperand* value) {
872 LOperand* value() { return inputs_[0]; }
874 DECLARE_CONCRETE_INSTRUCTION(MathPowHalf, "math-pow-half")
878 class LCmpObjectEqAndBranch V8_FINAL : public LControlInstruction<2, 0> {
880 LCmpObjectEqAndBranch(LOperand* left, LOperand* right) {
885 LOperand* left() { return inputs_[0]; }
886 LOperand* right() { return inputs_[1]; }
888 DECLARE_CONCRETE_INSTRUCTION(CmpObjectEqAndBranch, "cmp-object-eq-and-branch")
892 class LCmpHoleAndBranch V8_FINAL : public LControlInstruction<1, 0> {
894 explicit LCmpHoleAndBranch(LOperand* object) {
898 LOperand* object() { return inputs_[0]; }
900 DECLARE_CONCRETE_INSTRUCTION(CmpHoleAndBranch, "cmp-hole-and-branch")
901 DECLARE_HYDROGEN_ACCESSOR(CompareHoleAndBranch)
905 class LCompareMinusZeroAndBranch V8_FINAL : public LControlInstruction<1, 0> {
907 explicit LCompareMinusZeroAndBranch(LOperand* value) {
911 LOperand* value() { return inputs_[0]; }
913 DECLARE_CONCRETE_INSTRUCTION(CompareMinusZeroAndBranch,
914 "cmp-minus-zero-and-branch")
915 DECLARE_HYDROGEN_ACCESSOR(CompareMinusZeroAndBranch)
920 class LIsObjectAndBranch V8_FINAL : public LControlInstruction<1, 0> {
922 explicit LIsObjectAndBranch(LOperand* value) {
926 LOperand* value() { return inputs_[0]; }
928 DECLARE_CONCRETE_INSTRUCTION(IsObjectAndBranch, "is-object-and-branch")
929 DECLARE_HYDROGEN_ACCESSOR(IsObjectAndBranch)
931 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
935 class LIsStringAndBranch V8_FINAL : public LControlInstruction<1, 1> {
937 explicit LIsStringAndBranch(LOperand* value, LOperand* temp) {
942 LOperand* value() { return inputs_[0]; }
943 LOperand* temp() { return temps_[0]; }
945 DECLARE_CONCRETE_INSTRUCTION(IsStringAndBranch, "is-string-and-branch")
946 DECLARE_HYDROGEN_ACCESSOR(IsStringAndBranch)
948 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
952 class LIsSmiAndBranch V8_FINAL : public LControlInstruction<1, 0> {
954 explicit LIsSmiAndBranch(LOperand* value) {
958 LOperand* value() { return inputs_[0]; }
960 DECLARE_CONCRETE_INSTRUCTION(IsSmiAndBranch, "is-smi-and-branch")
961 DECLARE_HYDROGEN_ACCESSOR(IsSmiAndBranch)
963 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
967 class LIsUndetectableAndBranch V8_FINAL : public LControlInstruction<1, 1> {
969 explicit LIsUndetectableAndBranch(LOperand* value, LOperand* temp) {
974 LOperand* value() { return inputs_[0]; }
975 LOperand* temp() { return temps_[0]; }
977 DECLARE_CONCRETE_INSTRUCTION(IsUndetectableAndBranch,
978 "is-undetectable-and-branch")
979 DECLARE_HYDROGEN_ACCESSOR(IsUndetectableAndBranch)
981 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
985 class LStringCompareAndBranch V8_FINAL : public LControlInstruction<3, 0> {
987 explicit LStringCompareAndBranch(LOperand* context,
990 inputs_[0] = context;
995 LOperand* context() { return inputs_[0]; }
996 LOperand* left() { return inputs_[1]; }
997 LOperand* right() { return inputs_[2]; }
999 DECLARE_CONCRETE_INSTRUCTION(StringCompareAndBranch,
1000 "string-compare-and-branch")
1001 DECLARE_HYDROGEN_ACCESSOR(StringCompareAndBranch)
1003 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1005 Token::Value op() const { return hydrogen()->token(); }
1009 class LHasInstanceTypeAndBranch V8_FINAL : public LControlInstruction<1, 0> {
1011 explicit LHasInstanceTypeAndBranch(LOperand* value) {
1015 LOperand* value() { return inputs_[0]; }
1017 DECLARE_CONCRETE_INSTRUCTION(HasInstanceTypeAndBranch,
1018 "has-instance-type-and-branch")
1019 DECLARE_HYDROGEN_ACCESSOR(HasInstanceTypeAndBranch)
1021 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1025 class LGetCachedArrayIndex V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1027 explicit LGetCachedArrayIndex(LOperand* value) {
1031 LOperand* value() { return inputs_[0]; }
1033 DECLARE_CONCRETE_INSTRUCTION(GetCachedArrayIndex, "get-cached-array-index")
1034 DECLARE_HYDROGEN_ACCESSOR(GetCachedArrayIndex)
1038 class LHasCachedArrayIndexAndBranch V8_FINAL
1039 : public LControlInstruction<1, 0> {
1041 explicit LHasCachedArrayIndexAndBranch(LOperand* value) {
1045 LOperand* value() { return inputs_[0]; }
1047 DECLARE_CONCRETE_INSTRUCTION(HasCachedArrayIndexAndBranch,
1048 "has-cached-array-index-and-branch")
1049 DECLARE_HYDROGEN_ACCESSOR(HasCachedArrayIndexAndBranch)
1051 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1055 class LClassOfTestAndBranch V8_FINAL : public LControlInstruction<1, 2> {
1057 LClassOfTestAndBranch(LOperand* value, LOperand* temp, LOperand* temp2) {
1063 LOperand* value() { return inputs_[0]; }
1064 LOperand* temp() { return temps_[0]; }
1065 LOperand* temp2() { return temps_[1]; }
1067 DECLARE_CONCRETE_INSTRUCTION(ClassOfTestAndBranch,
1068 "class-of-test-and-branch")
1069 DECLARE_HYDROGEN_ACCESSOR(ClassOfTestAndBranch)
1071 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1075 class LCmpT V8_FINAL : public LTemplateInstruction<1, 3, 0> {
1077 LCmpT(LOperand* context, LOperand* left, LOperand* right) {
1078 inputs_[0] = context;
1083 LOperand* context() { return inputs_[0]; }
1084 LOperand* left() { return inputs_[1]; }
1085 LOperand* right() { return inputs_[2]; }
1087 DECLARE_CONCRETE_INSTRUCTION(CmpT, "cmp-t")
1088 DECLARE_HYDROGEN_ACCESSOR(CompareGeneric)
1090 Token::Value op() const { return hydrogen()->token(); }
1094 class LInstanceOf V8_FINAL : public LTemplateInstruction<1, 3, 0> {
1096 LInstanceOf(LOperand* context, LOperand* left, LOperand* right) {
1097 inputs_[0] = context;
1102 LOperand* context() { return inputs_[0]; }
1103 LOperand* left() { return inputs_[1]; }
1104 LOperand* right() { return inputs_[2]; }
1106 DECLARE_CONCRETE_INSTRUCTION(InstanceOf, "instance-of")
1110 class LInstanceOfKnownGlobal V8_FINAL : public LTemplateInstruction<1, 2, 1> {
1112 LInstanceOfKnownGlobal(LOperand* context, LOperand* value, LOperand* temp) {
1113 inputs_[0] = context;
1118 LOperand* context() { return inputs_[0]; }
1119 LOperand* value() { return inputs_[1]; }
1120 LOperand* temp() { return temps_[0]; }
1122 DECLARE_CONCRETE_INSTRUCTION(InstanceOfKnownGlobal,
1123 "instance-of-known-global")
1124 DECLARE_HYDROGEN_ACCESSOR(InstanceOfKnownGlobal)
1126 Handle<JSFunction> function() const { return hydrogen()->function(); }
1127 LEnvironment* GetDeferredLazyDeoptimizationEnvironment() {
1128 return lazy_deopt_env_;
1130 virtual void SetDeferredLazyDeoptimizationEnvironment(
1131 LEnvironment* env) V8_OVERRIDE {
1132 lazy_deopt_env_ = env;
1136 LEnvironment* lazy_deopt_env_;
1140 class LBoundsCheck V8_FINAL : public LTemplateInstruction<0, 2, 0> {
1142 LBoundsCheck(LOperand* index, LOperand* length) {
1144 inputs_[1] = length;
1147 LOperand* index() { return inputs_[0]; }
1148 LOperand* length() { return inputs_[1]; }
1150 DECLARE_CONCRETE_INSTRUCTION(BoundsCheck, "bounds-check")
1151 DECLARE_HYDROGEN_ACCESSOR(BoundsCheck)
1155 class LBitI V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1157 LBitI(LOperand* left, LOperand* right) {
1162 LOperand* left() { return inputs_[0]; }
1163 LOperand* right() { return inputs_[1]; }
1165 Token::Value op() const { return hydrogen()->op(); }
1167 DECLARE_CONCRETE_INSTRUCTION(BitI, "bit-i")
1168 DECLARE_HYDROGEN_ACCESSOR(Bitwise)
1172 class LShiftI V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1174 LShiftI(Token::Value op, LOperand* left, LOperand* right, bool can_deopt)
1175 : op_(op), can_deopt_(can_deopt) {
1180 Token::Value op() const { return op_; }
1181 LOperand* left() { return inputs_[0]; }
1182 LOperand* right() { return inputs_[1]; }
1183 bool can_deopt() const { return can_deopt_; }
1185 DECLARE_CONCRETE_INSTRUCTION(ShiftI, "shift-i")
1193 class LSubI V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1195 LSubI(LOperand* left, LOperand* right) {
1200 LOperand* left() { return inputs_[0]; }
1201 LOperand* right() { return inputs_[1]; }
1203 DECLARE_CONCRETE_INSTRUCTION(SubI, "sub-i")
1204 DECLARE_HYDROGEN_ACCESSOR(Sub)
1208 class LConstantI V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1210 DECLARE_CONCRETE_INSTRUCTION(ConstantI, "constant-i")
1211 DECLARE_HYDROGEN_ACCESSOR(Constant)
1213 int32_t value() const { return hydrogen()->Integer32Value(); }
1217 class LConstantS V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1219 DECLARE_CONCRETE_INSTRUCTION(ConstantS, "constant-s")
1220 DECLARE_HYDROGEN_ACCESSOR(Constant)
1222 Smi* value() const { return Smi::FromInt(hydrogen()->Integer32Value()); }
1226 class LConstantD V8_FINAL : public LTemplateInstruction<1, 0, 1> {
1228 explicit LConstantD(LOperand* temp) {
1232 LOperand* temp() { return temps_[0]; }
1234 DECLARE_CONCRETE_INSTRUCTION(ConstantD, "constant-d")
1235 DECLARE_HYDROGEN_ACCESSOR(Constant)
1237 double value() const { return hydrogen()->DoubleValue(); }
1241 class LConstantE V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1243 DECLARE_CONCRETE_INSTRUCTION(ConstantE, "constant-e")
1244 DECLARE_HYDROGEN_ACCESSOR(Constant)
1246 ExternalReference value() const {
1247 return hydrogen()->ExternalReferenceValue();
1252 class LConstantT V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1254 DECLARE_CONCRETE_INSTRUCTION(ConstantT, "constant-t")
1255 DECLARE_HYDROGEN_ACCESSOR(Constant)
1257 Handle<Object> value(Isolate* isolate) const {
1258 return hydrogen()->handle(isolate);
1263 class LBranch V8_FINAL : public LControlInstruction<1, 0> {
1265 explicit LBranch(LOperand* value) {
1269 LOperand* value() { return inputs_[0]; }
1271 DECLARE_CONCRETE_INSTRUCTION(Branch, "branch")
1272 DECLARE_HYDROGEN_ACCESSOR(Branch)
1274 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1278 class LDebugBreak V8_FINAL : public LTemplateInstruction<0, 0, 0> {
1280 DECLARE_CONCRETE_INSTRUCTION(DebugBreak, "break")
1284 class LCmpMapAndBranch V8_FINAL : public LControlInstruction<1, 0> {
1286 explicit LCmpMapAndBranch(LOperand* value) {
1290 LOperand* value() { return inputs_[0]; }
1292 DECLARE_CONCRETE_INSTRUCTION(CmpMapAndBranch, "cmp-map-and-branch")
1293 DECLARE_HYDROGEN_ACCESSOR(CompareMap)
1295 Handle<Map> map() const { return hydrogen()->map().handle(); }
1299 class LMapEnumLength V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1301 explicit LMapEnumLength(LOperand* value) {
1305 LOperand* value() { return inputs_[0]; }
1307 DECLARE_CONCRETE_INSTRUCTION(MapEnumLength, "map-enum-length")
1311 class LDateField V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1313 LDateField(LOperand* date, Smi* index) : index_(index) {
1317 LOperand* date() { return inputs_[0]; }
1318 Smi* index() const { return index_; }
1320 DECLARE_CONCRETE_INSTRUCTION(DateField, "date-field")
1321 DECLARE_HYDROGEN_ACCESSOR(DateField)
1328 class LSeqStringGetChar V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1330 LSeqStringGetChar(LOperand* string, LOperand* index) {
1331 inputs_[0] = string;
1335 LOperand* string() const { return inputs_[0]; }
1336 LOperand* index() const { return inputs_[1]; }
1338 DECLARE_CONCRETE_INSTRUCTION(SeqStringGetChar, "seq-string-get-char")
1339 DECLARE_HYDROGEN_ACCESSOR(SeqStringGetChar)
1343 class LSeqStringSetChar V8_FINAL : public LTemplateInstruction<1, 4, 0> {
1345 LSeqStringSetChar(LOperand* context,
1349 inputs_[0] = context;
1350 inputs_[1] = string;
1355 LOperand* string() { return inputs_[1]; }
1356 LOperand* index() { return inputs_[2]; }
1357 LOperand* value() { return inputs_[3]; }
1359 DECLARE_CONCRETE_INSTRUCTION(SeqStringSetChar, "seq-string-set-char")
1360 DECLARE_HYDROGEN_ACCESSOR(SeqStringSetChar)
1364 class LAddI V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1366 LAddI(LOperand* left, LOperand* right) {
1371 LOperand* left() { return inputs_[0]; }
1372 LOperand* right() { return inputs_[1]; }
1374 static bool UseLea(HAdd* add) {
1375 return !add->CheckFlag(HValue::kCanOverflow) &&
1376 add->BetterLeftOperand()->UseCount() > 1;
1379 DECLARE_CONCRETE_INSTRUCTION(AddI, "add-i")
1380 DECLARE_HYDROGEN_ACCESSOR(Add)
1384 class LMathMinMax V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1386 LMathMinMax(LOperand* left, LOperand* right) {
1391 LOperand* left() { return inputs_[0]; }
1392 LOperand* right() { return inputs_[1]; }
1394 DECLARE_CONCRETE_INSTRUCTION(MathMinMax, "math-min-max")
1395 DECLARE_HYDROGEN_ACCESSOR(MathMinMax)
1399 class LPower V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1401 LPower(LOperand* left, LOperand* right) {
1406 LOperand* left() { return inputs_[0]; }
1407 LOperand* right() { return inputs_[1]; }
1409 DECLARE_CONCRETE_INSTRUCTION(Power, "power")
1410 DECLARE_HYDROGEN_ACCESSOR(Power)
1414 class LArithmeticD V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1416 LArithmeticD(Token::Value op, LOperand* left, LOperand* right)
1422 Token::Value op() const { return op_; }
1423 LOperand* left() { return inputs_[0]; }
1424 LOperand* right() { return inputs_[1]; }
1426 virtual Opcode opcode() const V8_OVERRIDE {
1427 return LInstruction::kArithmeticD;
1429 virtual void CompileToNative(LCodeGen* generator) V8_OVERRIDE;
1430 virtual const char* Mnemonic() const V8_OVERRIDE;
1437 class LArithmeticT V8_FINAL : public LTemplateInstruction<1, 3, 0> {
1439 LArithmeticT(Token::Value op,
1444 inputs_[0] = context;
1449 Token::Value op() const { return op_; }
1450 LOperand* context() { return inputs_[0]; }
1451 LOperand* left() { return inputs_[1]; }
1452 LOperand* right() { return inputs_[2]; }
1454 virtual Opcode opcode() const V8_OVERRIDE {
1455 return LInstruction::kArithmeticT;
1457 virtual void CompileToNative(LCodeGen* generator) V8_OVERRIDE;
1458 virtual const char* Mnemonic() const V8_OVERRIDE;
1465 class LReturn V8_FINAL : public LTemplateInstruction<0, 3, 0> {
1467 explicit LReturn(LOperand* value,
1469 LOperand* parameter_count) {
1471 inputs_[1] = context;
1472 inputs_[2] = parameter_count;
1475 LOperand* value() { return inputs_[0]; }
1476 LOperand* context() { return inputs_[1]; }
1478 bool has_constant_parameter_count() {
1479 return parameter_count()->IsConstantOperand();
1481 LConstantOperand* constant_parameter_count() {
1482 ASSERT(has_constant_parameter_count());
1483 return LConstantOperand::cast(parameter_count());
1485 LOperand* parameter_count() { return inputs_[2]; }
1487 DECLARE_CONCRETE_INSTRUCTION(Return, "return")
1488 DECLARE_HYDROGEN_ACCESSOR(Return)
1492 class LLoadNamedField V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1494 explicit LLoadNamedField(LOperand* object) {
1495 inputs_[0] = object;
1498 LOperand* object() { return inputs_[0]; }
1500 DECLARE_CONCRETE_INSTRUCTION(LoadNamedField, "load-named-field")
1501 DECLARE_HYDROGEN_ACCESSOR(LoadNamedField)
1505 class LLoadNamedGeneric V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1507 explicit LLoadNamedGeneric(LOperand* context, LOperand* object) {
1508 inputs_[0] = context;
1509 inputs_[1] = object;
1512 DECLARE_CONCRETE_INSTRUCTION(LoadNamedGeneric, "load-named-generic")
1513 DECLARE_HYDROGEN_ACCESSOR(LoadNamedGeneric)
1515 LOperand* context() { return inputs_[0]; }
1516 LOperand* object() { return inputs_[1]; }
1517 Handle<Object> name() const { return hydrogen()->name(); }
1521 class LLoadFunctionPrototype V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1523 explicit LLoadFunctionPrototype(LOperand* function) {
1524 inputs_[0] = function;
1527 DECLARE_CONCRETE_INSTRUCTION(LoadFunctionPrototype, "load-function-prototype")
1528 DECLARE_HYDROGEN_ACCESSOR(LoadFunctionPrototype)
1530 LOperand* function() { return inputs_[0]; }
1534 class LLoadRoot V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1536 DECLARE_CONCRETE_INSTRUCTION(LoadRoot, "load-root")
1537 DECLARE_HYDROGEN_ACCESSOR(LoadRoot)
1539 Heap::RootListIndex index() const { return hydrogen()->index(); }
1543 class LLoadKeyed V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1545 LLoadKeyed(LOperand* elements, LOperand* key) {
1546 inputs_[0] = elements;
1550 DECLARE_CONCRETE_INSTRUCTION(LoadKeyed, "load-keyed")
1551 DECLARE_HYDROGEN_ACCESSOR(LoadKeyed)
1553 bool is_external() const {
1554 return hydrogen()->is_external();
1556 bool is_fixed_typed_array() const {
1557 return hydrogen()->is_fixed_typed_array();
1559 bool is_typed_elements() const {
1560 return is_external() || is_fixed_typed_array();
1562 LOperand* elements() { return inputs_[0]; }
1563 LOperand* key() { return inputs_[1]; }
1564 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1565 uint32_t additional_index() const { return hydrogen()->index_offset(); }
1566 ElementsKind elements_kind() const {
1567 return hydrogen()->elements_kind();
1572 class LLoadKeyedGeneric V8_FINAL : public LTemplateInstruction<1, 3, 0> {
1574 LLoadKeyedGeneric(LOperand* context, LOperand* obj, LOperand* key) {
1575 inputs_[0] = context;
1580 DECLARE_CONCRETE_INSTRUCTION(LoadKeyedGeneric, "load-keyed-generic")
1582 LOperand* context() { return inputs_[0]; }
1583 LOperand* object() { return inputs_[1]; }
1584 LOperand* key() { return inputs_[2]; }
1588 class LLoadGlobalCell V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1590 DECLARE_CONCRETE_INSTRUCTION(LoadGlobalCell, "load-global-cell")
1591 DECLARE_HYDROGEN_ACCESSOR(LoadGlobalCell)
1595 class LLoadGlobalGeneric V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1597 explicit LLoadGlobalGeneric(LOperand* context, LOperand* global_object) {
1598 inputs_[0] = context;
1599 inputs_[1] = global_object;
1602 DECLARE_CONCRETE_INSTRUCTION(LoadGlobalGeneric, "load-global-generic")
1603 DECLARE_HYDROGEN_ACCESSOR(LoadGlobalGeneric)
1605 LOperand* context() { return inputs_[0]; }
1606 LOperand* global_object() { return inputs_[1]; }
1607 Handle<Object> name() const { return hydrogen()->name(); }
1608 bool for_typeof() const { return hydrogen()->for_typeof(); }
1612 class LStoreGlobalCell V8_FINAL : public LTemplateInstruction<0, 1, 1> {
1614 explicit LStoreGlobalCell(LOperand* value, LOperand* temp) {
1619 LOperand* value() { return inputs_[0]; }
1620 LOperand* temp() { return temps_[0]; }
1622 DECLARE_CONCRETE_INSTRUCTION(StoreGlobalCell, "store-global-cell")
1623 DECLARE_HYDROGEN_ACCESSOR(StoreGlobalCell)
1627 class LLoadContextSlot V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1629 explicit LLoadContextSlot(LOperand* context) {
1630 inputs_[0] = context;
1633 LOperand* context() { return inputs_[0]; }
1635 DECLARE_CONCRETE_INSTRUCTION(LoadContextSlot, "load-context-slot")
1636 DECLARE_HYDROGEN_ACCESSOR(LoadContextSlot)
1638 int slot_index() { return hydrogen()->slot_index(); }
1640 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1644 class LStoreContextSlot V8_FINAL : public LTemplateInstruction<0, 2, 1> {
1646 LStoreContextSlot(LOperand* context, LOperand* value, LOperand* temp) {
1647 inputs_[0] = context;
1652 LOperand* context() { return inputs_[0]; }
1653 LOperand* value() { return inputs_[1]; }
1654 LOperand* temp() { return temps_[0]; }
1656 DECLARE_CONCRETE_INSTRUCTION(StoreContextSlot, "store-context-slot")
1657 DECLARE_HYDROGEN_ACCESSOR(StoreContextSlot)
1659 int slot_index() { return hydrogen()->slot_index(); }
1661 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1665 class LPushArgument V8_FINAL : public LTemplateInstruction<0, 1, 0> {
1667 explicit LPushArgument(LOperand* value) {
1671 LOperand* value() { return inputs_[0]; }
1673 DECLARE_CONCRETE_INSTRUCTION(PushArgument, "push-argument")
1677 class LDrop V8_FINAL : public LTemplateInstruction<0, 0, 0> {
1679 explicit LDrop(int count) : count_(count) { }
1681 int count() const { return count_; }
1683 DECLARE_CONCRETE_INSTRUCTION(Drop, "drop")
1690 class LStoreCodeEntry V8_FINAL: public LTemplateInstruction<0, 1, 1> {
1692 LStoreCodeEntry(LOperand* function, LOperand* code_object) {
1693 inputs_[0] = function;
1694 temps_[0] = code_object;
1697 LOperand* function() { return inputs_[0]; }
1698 LOperand* code_object() { return temps_[0]; }
1700 virtual void PrintDataTo(StringStream* stream);
1702 DECLARE_CONCRETE_INSTRUCTION(StoreCodeEntry, "store-code-entry")
1703 DECLARE_HYDROGEN_ACCESSOR(StoreCodeEntry)
1707 class LInnerAllocatedObject V8_FINAL: public LTemplateInstruction<1, 2, 0> {
1709 LInnerAllocatedObject(LOperand* base_object, LOperand* offset) {
1710 inputs_[0] = base_object;
1711 inputs_[1] = offset;
1714 LOperand* base_object() const { return inputs_[0]; }
1715 LOperand* offset() const { return inputs_[1]; }
1717 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1719 DECLARE_CONCRETE_INSTRUCTION(InnerAllocatedObject, "inner-allocated-object")
1723 class LThisFunction V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1725 DECLARE_CONCRETE_INSTRUCTION(ThisFunction, "this-function")
1726 DECLARE_HYDROGEN_ACCESSOR(ThisFunction)
1730 class LContext V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1732 DECLARE_CONCRETE_INSTRUCTION(Context, "context")
1733 DECLARE_HYDROGEN_ACCESSOR(Context)
1737 class LDeclareGlobals V8_FINAL : public LTemplateInstruction<0, 1, 0> {
1739 explicit LDeclareGlobals(LOperand* context) {
1740 inputs_[0] = context;
1743 LOperand* context() { return inputs_[0]; }
1745 DECLARE_CONCRETE_INSTRUCTION(DeclareGlobals, "declare-globals")
1746 DECLARE_HYDROGEN_ACCESSOR(DeclareGlobals)
1750 class LCallJSFunction V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1752 explicit LCallJSFunction(LOperand* function) {
1753 inputs_[0] = function;
1756 LOperand* function() { return inputs_[0]; }
1758 DECLARE_CONCRETE_INSTRUCTION(CallJSFunction, "call-js-function")
1759 DECLARE_HYDROGEN_ACCESSOR(CallJSFunction)
1761 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1763 int arity() const { return hydrogen()->argument_count() - 1; }
1767 class LCallWithDescriptor V8_FINAL : public LTemplateResultInstruction<1> {
1769 LCallWithDescriptor(const CallInterfaceDescriptor* descriptor,
1770 ZoneList<LOperand*>& operands,
1772 : inputs_(descriptor->environment_length() + 1, zone) {
1773 ASSERT(descriptor->environment_length() + 1 == operands.length());
1774 inputs_.AddAll(operands, zone);
1777 LOperand* target() const { return inputs_[0]; }
1780 DECLARE_CONCRETE_INSTRUCTION(CallWithDescriptor, "call-with-descriptor")
1781 DECLARE_HYDROGEN_ACCESSOR(CallWithDescriptor)
1783 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1785 int arity() const { return hydrogen()->argument_count() - 1; }
1787 ZoneList<LOperand*> inputs_;
1789 // Iterator support.
1790 virtual int InputCount() V8_FINAL V8_OVERRIDE { return inputs_.length(); }
1791 virtual LOperand* InputAt(int i) V8_FINAL V8_OVERRIDE { return inputs_[i]; }
1793 virtual int TempCount() V8_FINAL V8_OVERRIDE { return 0; }
1794 virtual LOperand* TempAt(int i) V8_FINAL V8_OVERRIDE { return NULL; }
1798 class LInvokeFunction V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1800 LInvokeFunction(LOperand* context, LOperand* function) {
1801 inputs_[0] = context;
1802 inputs_[1] = function;
1805 LOperand* context() { return inputs_[0]; }
1806 LOperand* function() { return inputs_[1]; }
1808 DECLARE_CONCRETE_INSTRUCTION(InvokeFunction, "invoke-function")
1809 DECLARE_HYDROGEN_ACCESSOR(InvokeFunction)
1811 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1813 int arity() const { return hydrogen()->argument_count() - 1; }
1817 class LCallFunction V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1819 LCallFunction(LOperand* context, LOperand* function) {
1820 inputs_[0] = context;
1821 inputs_[1] = function;
1824 DECLARE_CONCRETE_INSTRUCTION(CallFunction, "call-function")
1825 DECLARE_HYDROGEN_ACCESSOR(CallFunction)
1827 LOperand* context() { return inputs_[0]; }
1828 LOperand* function() { return inputs_[1]; }
1829 int arity() const { return hydrogen()->argument_count() - 1; }
1833 class LCallNew V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1835 LCallNew(LOperand* context, LOperand* constructor) {
1836 inputs_[0] = context;
1837 inputs_[1] = constructor;
1840 LOperand* context() { return inputs_[0]; }
1841 LOperand* constructor() { return inputs_[1]; }
1843 DECLARE_CONCRETE_INSTRUCTION(CallNew, "call-new")
1844 DECLARE_HYDROGEN_ACCESSOR(CallNew)
1846 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1848 int arity() const { return hydrogen()->argument_count() - 1; }
1852 class LCallNewArray V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1854 LCallNewArray(LOperand* context, LOperand* constructor) {
1855 inputs_[0] = context;
1856 inputs_[1] = constructor;
1859 LOperand* context() { return inputs_[0]; }
1860 LOperand* constructor() { return inputs_[1]; }
1862 DECLARE_CONCRETE_INSTRUCTION(CallNewArray, "call-new-array")
1863 DECLARE_HYDROGEN_ACCESSOR(CallNewArray)
1865 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1867 int arity() const { return hydrogen()->argument_count() - 1; }
1871 class LCallRuntime V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1873 explicit LCallRuntime(LOperand* context) {
1874 inputs_[0] = context;
1877 LOperand* context() { return inputs_[0]; }
1879 DECLARE_CONCRETE_INSTRUCTION(CallRuntime, "call-runtime")
1880 DECLARE_HYDROGEN_ACCESSOR(CallRuntime)
1882 virtual bool ClobbersDoubleRegisters() const V8_OVERRIDE {
1883 return save_doubles() == kDontSaveFPRegs;
1886 const Runtime::Function* function() const { return hydrogen()->function(); }
1887 int arity() const { return hydrogen()->argument_count(); }
1888 SaveFPRegsMode save_doubles() const { return hydrogen()->save_doubles(); }
1892 class LInteger32ToDouble V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1894 explicit LInteger32ToDouble(LOperand* value) {
1898 LOperand* value() { return inputs_[0]; }
1900 DECLARE_CONCRETE_INSTRUCTION(Integer32ToDouble, "int32-to-double")
1904 class LInteger32ToSmi V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1906 explicit LInteger32ToSmi(LOperand* value) {
1910 LOperand* value() { return inputs_[0]; }
1912 DECLARE_CONCRETE_INSTRUCTION(Integer32ToSmi, "int32-to-smi")
1913 DECLARE_HYDROGEN_ACCESSOR(Change)
1917 class LUint32ToDouble V8_FINAL : public LTemplateInstruction<1, 1, 1> {
1919 explicit LUint32ToDouble(LOperand* value, LOperand* temp) {
1924 LOperand* value() { return inputs_[0]; }
1925 LOperand* temp() { return temps_[0]; }
1927 DECLARE_CONCRETE_INSTRUCTION(Uint32ToDouble, "uint32-to-double")
1931 class LUint32ToSmi V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1933 explicit LUint32ToSmi(LOperand* value) {
1937 LOperand* value() { return inputs_[0]; }
1939 DECLARE_CONCRETE_INSTRUCTION(Uint32ToSmi, "uint32-to-smi")
1940 DECLARE_HYDROGEN_ACCESSOR(Change)
1944 class LNumberTagI V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1946 explicit LNumberTagI(LOperand* value) {
1950 LOperand* value() { return inputs_[0]; }
1952 DECLARE_CONCRETE_INSTRUCTION(NumberTagI, "number-tag-i")
1956 class LNumberTagU V8_FINAL : public LTemplateInstruction<1, 1, 2> {
1958 LNumberTagU(LOperand* value, LOperand* temp1, LOperand* temp2) {
1964 LOperand* value() { return inputs_[0]; }
1965 LOperand* temp1() { return temps_[0]; }
1966 LOperand* temp2() { return temps_[1]; }
1968 DECLARE_CONCRETE_INSTRUCTION(NumberTagU, "number-tag-u")
1972 class LNumberTagD V8_FINAL : public LTemplateInstruction<1, 1, 1> {
1974 explicit LNumberTagD(LOperand* value, LOperand* temp) {
1979 LOperand* value() { return inputs_[0]; }
1980 LOperand* temp() { return temps_[0]; }
1982 DECLARE_CONCRETE_INSTRUCTION(NumberTagD, "number-tag-d")
1983 DECLARE_HYDROGEN_ACCESSOR(Change)
1987 // Sometimes truncating conversion from a tagged value to an int32.
1988 class LDoubleToI V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1990 explicit LDoubleToI(LOperand* value) {
1994 LOperand* value() { return inputs_[0]; }
1996 DECLARE_CONCRETE_INSTRUCTION(DoubleToI, "double-to-i")
1997 DECLARE_HYDROGEN_ACCESSOR(UnaryOperation)
1999 bool truncating() { return hydrogen()->CanTruncateToInt32(); }
2003 class LDoubleToSmi V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2005 explicit LDoubleToSmi(LOperand* value) {
2009 LOperand* value() { return inputs_[0]; }
2011 DECLARE_CONCRETE_INSTRUCTION(DoubleToSmi, "double-to-smi")
2012 DECLARE_HYDROGEN_ACCESSOR(UnaryOperation)
2016 // Truncating conversion from a tagged value to an int32.
2017 class LTaggedToI V8_FINAL : public LTemplateInstruction<1, 1, 1> {
2019 LTaggedToI(LOperand* value, LOperand* temp) {
2024 LOperand* value() { return inputs_[0]; }
2025 LOperand* temp() { return temps_[0]; }
2027 DECLARE_CONCRETE_INSTRUCTION(TaggedToI, "tagged-to-i")
2028 DECLARE_HYDROGEN_ACCESSOR(Change)
2030 bool truncating() { return hydrogen()->CanTruncateToInt32(); }
2034 class LSmiTag V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2036 explicit LSmiTag(LOperand* value) {
2040 LOperand* value() { return inputs_[0]; }
2042 DECLARE_CONCRETE_INSTRUCTION(SmiTag, "smi-tag")
2046 class LNumberUntagD V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2048 explicit LNumberUntagD(LOperand* value) {
2052 LOperand* value() { return inputs_[0]; }
2054 DECLARE_CONCRETE_INSTRUCTION(NumberUntagD, "double-untag")
2055 DECLARE_HYDROGEN_ACCESSOR(Change);
2059 class LSmiUntag V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2061 LSmiUntag(LOperand* value, bool needs_check)
2062 : needs_check_(needs_check) {
2066 LOperand* value() { return inputs_[0]; }
2067 bool needs_check() const { return needs_check_; }
2069 DECLARE_CONCRETE_INSTRUCTION(SmiUntag, "smi-untag")
2076 class LStoreNamedField V8_FINAL : public LTemplateInstruction<0, 2, 1> {
2078 LStoreNamedField(LOperand* object, LOperand* value, LOperand* temp) {
2079 inputs_[0] = object;
2084 LOperand* object() { return inputs_[0]; }
2085 LOperand* value() { return inputs_[1]; }
2086 LOperand* temp() { return temps_[0]; }
2088 DECLARE_CONCRETE_INSTRUCTION(StoreNamedField, "store-named-field")
2089 DECLARE_HYDROGEN_ACCESSOR(StoreNamedField)
2091 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
2093 Handle<Map> transition() const { return hydrogen()->transition_map(); }
2094 Representation representation() const {
2095 return hydrogen()->field_representation();
2100 class LStoreNamedGeneric V8_FINAL : public LTemplateInstruction<0, 3, 0> {
2102 LStoreNamedGeneric(LOperand* context, LOperand* object, LOperand* value) {
2103 inputs_[0] = context;
2104 inputs_[1] = object;
2108 LOperand* context() { return inputs_[0]; }
2109 LOperand* object() { return inputs_[1]; }
2110 LOperand* value() { return inputs_[2]; }
2112 DECLARE_CONCRETE_INSTRUCTION(StoreNamedGeneric, "store-named-generic")
2113 DECLARE_HYDROGEN_ACCESSOR(StoreNamedGeneric)
2115 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
2117 Handle<Object> name() const { return hydrogen()->name(); }
2118 StrictModeFlag strict_mode_flag() { return hydrogen()->strict_mode_flag(); }
2122 class LStoreKeyed V8_FINAL : public LTemplateInstruction<0, 3, 0> {
2124 LStoreKeyed(LOperand* object, LOperand* key, LOperand* value) {
2125 inputs_[0] = object;
2130 bool is_external() const { return hydrogen()->is_external(); }
2131 bool is_fixed_typed_array() const {
2132 return hydrogen()->is_fixed_typed_array();
2134 bool is_typed_elements() const {
2135 return is_external() || is_fixed_typed_array();
2137 LOperand* elements() { return inputs_[0]; }
2138 LOperand* key() { return inputs_[1]; }
2139 LOperand* value() { return inputs_[2]; }
2140 ElementsKind elements_kind() const { return hydrogen()->elements_kind(); }
2142 DECLARE_CONCRETE_INSTRUCTION(StoreKeyed, "store-keyed")
2143 DECLARE_HYDROGEN_ACCESSOR(StoreKeyed)
2145 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
2146 bool NeedsCanonicalization() { return hydrogen()->NeedsCanonicalization(); }
2147 uint32_t additional_index() const { return hydrogen()->index_offset(); }
2151 class LStoreKeyedGeneric V8_FINAL : public LTemplateInstruction<0, 4, 0> {
2153 LStoreKeyedGeneric(LOperand* context,
2157 inputs_[0] = context;
2158 inputs_[1] = object;
2163 LOperand* context() { return inputs_[0]; }
2164 LOperand* object() { return inputs_[1]; }
2165 LOperand* key() { return inputs_[2]; }
2166 LOperand* value() { return inputs_[3]; }
2168 DECLARE_CONCRETE_INSTRUCTION(StoreKeyedGeneric, "store-keyed-generic")
2169 DECLARE_HYDROGEN_ACCESSOR(StoreKeyedGeneric)
2171 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
2173 StrictModeFlag strict_mode_flag() { return hydrogen()->strict_mode_flag(); }
2177 class LTransitionElementsKind V8_FINAL : public LTemplateInstruction<0, 2, 2> {
2179 LTransitionElementsKind(LOperand* object,
2181 LOperand* new_map_temp,
2183 inputs_[0] = object;
2184 inputs_[1] = context;
2185 temps_[0] = new_map_temp;
2189 LOperand* object() { return inputs_[0]; }
2190 LOperand* context() { return inputs_[1]; }
2191 LOperand* new_map_temp() { return temps_[0]; }
2192 LOperand* temp() { return temps_[1]; }
2194 DECLARE_CONCRETE_INSTRUCTION(TransitionElementsKind,
2195 "transition-elements-kind")
2196 DECLARE_HYDROGEN_ACCESSOR(TransitionElementsKind)
2198 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
2200 Handle<Map> original_map() { return hydrogen()->original_map().handle(); }
2201 Handle<Map> transitioned_map() {
2202 return hydrogen()->transitioned_map().handle();
2204 ElementsKind from_kind() { return hydrogen()->from_kind(); }
2205 ElementsKind to_kind() { return hydrogen()->to_kind(); }
2209 class LTrapAllocationMemento V8_FINAL : public LTemplateInstruction<0, 1, 1> {
2211 LTrapAllocationMemento(LOperand* object,
2213 inputs_[0] = object;
2217 LOperand* object() { return inputs_[0]; }
2218 LOperand* temp() { return temps_[0]; }
2220 DECLARE_CONCRETE_INSTRUCTION(TrapAllocationMemento,
2221 "trap-allocation-memento")
2225 class LStringAdd V8_FINAL : public LTemplateInstruction<1, 3, 0> {
2227 LStringAdd(LOperand* context, LOperand* left, LOperand* right) {
2228 inputs_[0] = context;
2233 LOperand* context() { return inputs_[0]; }
2234 LOperand* left() { return inputs_[1]; }
2235 LOperand* right() { return inputs_[2]; }
2237 DECLARE_CONCRETE_INSTRUCTION(StringAdd, "string-add")
2238 DECLARE_HYDROGEN_ACCESSOR(StringAdd)
2242 class LStringCharCodeAt V8_FINAL : public LTemplateInstruction<1, 3, 0> {
2244 LStringCharCodeAt(LOperand* context, LOperand* string, LOperand* index) {
2245 inputs_[0] = context;
2246 inputs_[1] = string;
2250 LOperand* context() { return inputs_[0]; }
2251 LOperand* string() { return inputs_[1]; }
2252 LOperand* index() { return inputs_[2]; }
2254 DECLARE_CONCRETE_INSTRUCTION(StringCharCodeAt, "string-char-code-at")
2255 DECLARE_HYDROGEN_ACCESSOR(StringCharCodeAt)
2259 class LStringCharFromCode V8_FINAL : public LTemplateInstruction<1, 2, 0> {
2261 explicit LStringCharFromCode(LOperand* context, LOperand* char_code) {
2262 inputs_[0] = context;
2263 inputs_[1] = char_code;
2266 LOperand* context() { return inputs_[0]; }
2267 LOperand* char_code() { return inputs_[1]; }
2269 DECLARE_CONCRETE_INSTRUCTION(StringCharFromCode, "string-char-from-code")
2270 DECLARE_HYDROGEN_ACCESSOR(StringCharFromCode)
2274 class LCheckValue V8_FINAL : public LTemplateInstruction<0, 1, 0> {
2276 explicit LCheckValue(LOperand* value) {
2280 LOperand* value() { return inputs_[0]; }
2282 DECLARE_CONCRETE_INSTRUCTION(CheckValue, "check-value")
2283 DECLARE_HYDROGEN_ACCESSOR(CheckValue)
2287 class LCheckInstanceType V8_FINAL : public LTemplateInstruction<0, 1, 0> {
2289 explicit LCheckInstanceType(LOperand* value) {
2293 LOperand* value() { return inputs_[0]; }
2295 DECLARE_CONCRETE_INSTRUCTION(CheckInstanceType, "check-instance-type")
2296 DECLARE_HYDROGEN_ACCESSOR(CheckInstanceType)
2300 class LCheckMaps V8_FINAL : public LTemplateInstruction<0, 1, 0> {
2302 explicit LCheckMaps(LOperand* value) {
2306 LOperand* value() { return inputs_[0]; }
2308 DECLARE_CONCRETE_INSTRUCTION(CheckMaps, "check-maps")
2309 DECLARE_HYDROGEN_ACCESSOR(CheckMaps)
2313 class LCheckSmi V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2315 explicit LCheckSmi(LOperand* value) {
2319 LOperand* value() { return inputs_[0]; }
2321 DECLARE_CONCRETE_INSTRUCTION(CheckSmi, "check-smi")
2325 class LClampDToUint8 V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2327 explicit LClampDToUint8(LOperand* unclamped) {
2328 inputs_[0] = unclamped;
2331 LOperand* unclamped() { return inputs_[0]; }
2333 DECLARE_CONCRETE_INSTRUCTION(ClampDToUint8, "clamp-d-to-uint8")
2337 class LClampIToUint8 V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2339 explicit LClampIToUint8(LOperand* unclamped) {
2340 inputs_[0] = unclamped;
2343 LOperand* unclamped() { return inputs_[0]; }
2345 DECLARE_CONCRETE_INSTRUCTION(ClampIToUint8, "clamp-i-to-uint8")
2349 class LClampTToUint8 V8_FINAL : public LTemplateInstruction<1, 1, 1> {
2351 LClampTToUint8(LOperand* unclamped,
2352 LOperand* temp_xmm) {
2353 inputs_[0] = unclamped;
2354 temps_[0] = temp_xmm;
2357 LOperand* unclamped() { return inputs_[0]; }
2358 LOperand* temp_xmm() { return temps_[0]; }
2360 DECLARE_CONCRETE_INSTRUCTION(ClampTToUint8, "clamp-t-to-uint8")
2364 class LCheckNonSmi V8_FINAL : public LTemplateInstruction<0, 1, 0> {
2366 explicit LCheckNonSmi(LOperand* value) {
2370 LOperand* value() { return inputs_[0]; }
2372 DECLARE_CONCRETE_INSTRUCTION(CheckNonSmi, "check-non-smi")
2373 DECLARE_HYDROGEN_ACCESSOR(CheckHeapObject)
2377 class LDoubleBits V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2379 explicit LDoubleBits(LOperand* value) {
2383 LOperand* value() { return inputs_[0]; }
2385 DECLARE_CONCRETE_INSTRUCTION(DoubleBits, "double-bits")
2386 DECLARE_HYDROGEN_ACCESSOR(DoubleBits)
2390 class LConstructDouble V8_FINAL : public LTemplateInstruction<1, 2, 0> {
2392 LConstructDouble(LOperand* hi, LOperand* lo) {
2397 LOperand* hi() { return inputs_[0]; }
2398 LOperand* lo() { return inputs_[1]; }
2400 DECLARE_CONCRETE_INSTRUCTION(ConstructDouble, "construct-double")
2404 class LAllocate V8_FINAL : public LTemplateInstruction<1, 2, 1> {
2406 LAllocate(LOperand* context, LOperand* size, LOperand* temp) {
2407 inputs_[0] = context;
2412 LOperand* context() { return inputs_[0]; }
2413 LOperand* size() { return inputs_[1]; }
2414 LOperand* temp() { return temps_[0]; }
2416 DECLARE_CONCRETE_INSTRUCTION(Allocate, "allocate")
2417 DECLARE_HYDROGEN_ACCESSOR(Allocate)
2421 class LRegExpLiteral V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2423 explicit LRegExpLiteral(LOperand* context) {
2424 inputs_[0] = context;
2427 LOperand* context() { return inputs_[0]; }
2429 DECLARE_CONCRETE_INSTRUCTION(RegExpLiteral, "regexp-literal")
2430 DECLARE_HYDROGEN_ACCESSOR(RegExpLiteral)
2434 class LFunctionLiteral V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2436 explicit LFunctionLiteral(LOperand* context) {
2437 inputs_[0] = context;
2440 LOperand* context() { return inputs_[0]; }
2442 DECLARE_CONCRETE_INSTRUCTION(FunctionLiteral, "function-literal")
2443 DECLARE_HYDROGEN_ACCESSOR(FunctionLiteral)
2447 class LToFastProperties V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2449 explicit LToFastProperties(LOperand* value) {
2453 LOperand* value() { return inputs_[0]; }
2455 DECLARE_CONCRETE_INSTRUCTION(ToFastProperties, "to-fast-properties")
2456 DECLARE_HYDROGEN_ACCESSOR(ToFastProperties)
2460 class LTypeof V8_FINAL : public LTemplateInstruction<1, 2, 0> {
2462 LTypeof(LOperand* context, LOperand* value) {
2463 inputs_[0] = context;
2467 LOperand* context() { return inputs_[0]; }
2468 LOperand* value() { return inputs_[1]; }
2470 DECLARE_CONCRETE_INSTRUCTION(Typeof, "typeof")
2474 class LTypeofIsAndBranch V8_FINAL : public LControlInstruction<1, 0> {
2476 explicit LTypeofIsAndBranch(LOperand* value) {
2480 LOperand* value() { return inputs_[0]; }
2482 DECLARE_CONCRETE_INSTRUCTION(TypeofIsAndBranch, "typeof-is-and-branch")
2483 DECLARE_HYDROGEN_ACCESSOR(TypeofIsAndBranch)
2485 Handle<String> type_literal() { return hydrogen()->type_literal(); }
2487 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
2491 class LIsConstructCallAndBranch V8_FINAL : public LControlInstruction<0, 1> {
2493 explicit LIsConstructCallAndBranch(LOperand* temp) {
2497 LOperand* temp() { return temps_[0]; }
2499 DECLARE_CONCRETE_INSTRUCTION(IsConstructCallAndBranch,
2500 "is-construct-call-and-branch")
2501 DECLARE_HYDROGEN_ACCESSOR(IsConstructCallAndBranch)
2505 class LOsrEntry V8_FINAL : public LTemplateInstruction<0, 0, 0> {
2509 virtual bool HasInterestingComment(LCodeGen* gen) const V8_OVERRIDE {
2512 DECLARE_CONCRETE_INSTRUCTION(OsrEntry, "osr-entry")
2516 class LStackCheck V8_FINAL : public LTemplateInstruction<0, 1, 0> {
2518 explicit LStackCheck(LOperand* context) {
2519 inputs_[0] = context;
2522 LOperand* context() { return inputs_[0]; }
2524 DECLARE_CONCRETE_INSTRUCTION(StackCheck, "stack-check")
2525 DECLARE_HYDROGEN_ACCESSOR(StackCheck)
2527 Label* done_label() { return &done_label_; }
2534 class LForInPrepareMap V8_FINAL : public LTemplateInstruction<1, 2, 0> {
2536 LForInPrepareMap(LOperand* context, LOperand* object) {
2537 inputs_[0] = context;
2538 inputs_[1] = object;
2541 LOperand* context() { return inputs_[0]; }
2542 LOperand* object() { return inputs_[1]; }
2544 DECLARE_CONCRETE_INSTRUCTION(ForInPrepareMap, "for-in-prepare-map")
2548 class LForInCacheArray V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2550 explicit LForInCacheArray(LOperand* map) {
2554 LOperand* map() { return inputs_[0]; }
2556 DECLARE_CONCRETE_INSTRUCTION(ForInCacheArray, "for-in-cache-array")
2559 return HForInCacheArray::cast(this->hydrogen_value())->idx();
2564 class LCheckMapValue V8_FINAL : public LTemplateInstruction<0, 2, 0> {
2566 LCheckMapValue(LOperand* value, LOperand* map) {
2571 LOperand* value() { return inputs_[0]; }
2572 LOperand* map() { return inputs_[1]; }
2574 DECLARE_CONCRETE_INSTRUCTION(CheckMapValue, "check-map-value")
2578 class LLoadFieldByIndex V8_FINAL : public LTemplateInstruction<1, 2, 0> {
2580 LLoadFieldByIndex(LOperand* object, LOperand* index) {
2581 inputs_[0] = object;
2585 LOperand* object() { return inputs_[0]; }
2586 LOperand* index() { return inputs_[1]; }
2588 DECLARE_CONCRETE_INSTRUCTION(LoadFieldByIndex, "load-field-by-index")
2592 class LChunkBuilder;
2593 class LPlatformChunk V8_FINAL : public LChunk {
2595 LPlatformChunk(CompilationInfo* info, HGraph* graph)
2596 : LChunk(info, graph) { }
2598 int GetNextSpillIndex(RegisterKind kind);
2599 LOperand* GetNextSpillSlot(RegisterKind kind);
2603 class LChunkBuilder V8_FINAL : public LChunkBuilderBase {
2605 LChunkBuilder(CompilationInfo* info, HGraph* graph, LAllocator* allocator)
2606 : LChunkBuilderBase(graph->zone()),
2611 current_instruction_(NULL),
2612 current_block_(NULL),
2614 allocator_(allocator),
2615 instruction_pending_deoptimization_environment_(NULL),
2616 pending_deoptimization_ast_id_(BailoutId::None()) { }
2618 // Build the sequence for the graph.
2619 LPlatformChunk* Build();
2621 LInstruction* CheckElideControlInstruction(HControlInstruction* instr);
2623 // Declare methods that deal with the individual node types.
2624 #define DECLARE_DO(type) LInstruction* Do##type(H##type* node);
2625 HYDROGEN_CONCRETE_INSTRUCTION_LIST(DECLARE_DO)
2628 LInstruction* DoMathFloor(HUnaryMathOperation* instr);
2629 LInstruction* DoMathRound(HUnaryMathOperation* instr);
2630 LInstruction* DoMathAbs(HUnaryMathOperation* instr);
2631 LInstruction* DoMathLog(HUnaryMathOperation* instr);
2632 LInstruction* DoMathExp(HUnaryMathOperation* instr);
2633 LInstruction* DoMathSqrt(HUnaryMathOperation* instr);
2634 LInstruction* DoMathPowHalf(HUnaryMathOperation* instr);
2635 LInstruction* DoMathClz32(HUnaryMathOperation* instr);
2636 LInstruction* DoDivByPowerOf2I(HDiv* instr);
2637 LInstruction* DoDivI(HBinaryOperation* instr);
2638 LInstruction* DoModByPowerOf2I(HMod* instr);
2639 LInstruction* DoModI(HMod* instr);
2640 LInstruction* DoFlooringDivByPowerOf2I(HMathFloorOfDiv* instr);
2641 LInstruction* DoFlooringDivByConstI(HMathFloorOfDiv* instr);
2651 LPlatformChunk* chunk() const { return chunk_; }
2652 CompilationInfo* info() const { return info_; }
2653 HGraph* graph() const { return graph_; }
2655 bool is_unused() const { return status_ == UNUSED; }
2656 bool is_building() const { return status_ == BUILDING; }
2657 bool is_done() const { return status_ == DONE; }
2658 bool is_aborted() const { return status_ == ABORTED; }
2660 void Abort(BailoutReason reason);
2662 // Methods for getting operands for Use / Define / Temp.
2663 LUnallocated* ToUnallocated(Register reg);
2664 LUnallocated* ToUnallocated(XMMRegister reg);
2666 // Methods for setting up define-use relationships.
2667 MUST_USE_RESULT LOperand* Use(HValue* value, LUnallocated* operand);
2668 MUST_USE_RESULT LOperand* UseFixed(HValue* value, Register fixed_register);
2669 MUST_USE_RESULT LOperand* UseFixedDouble(HValue* value,
2670 XMMRegister fixed_register);
2672 // A value that is guaranteed to be allocated to a register.
2673 // Operand created by UseRegister is guaranteed to be live until the end of
2674 // instruction. This means that register allocator will not reuse it's
2675 // register for any other operand inside instruction.
2676 // Operand created by UseRegisterAtStart is guaranteed to be live only at
2677 // instruction start. Register allocator is free to assign the same register
2678 // to some other operand used inside instruction (i.e. temporary or
2680 MUST_USE_RESULT LOperand* UseRegister(HValue* value);
2681 MUST_USE_RESULT LOperand* UseRegisterAtStart(HValue* value);
2683 // An input operand in a register that may be trashed.
2684 MUST_USE_RESULT LOperand* UseTempRegister(HValue* value);
2686 // An input operand in a register that may be trashed or a constant operand.
2687 MUST_USE_RESULT LOperand* UseTempRegisterOrConstant(HValue* value);
2689 // An input operand in a register or stack slot.
2690 MUST_USE_RESULT LOperand* Use(HValue* value);
2691 MUST_USE_RESULT LOperand* UseAtStart(HValue* value);
2693 // An input operand in a register, stack slot or a constant operand.
2694 MUST_USE_RESULT LOperand* UseOrConstant(HValue* value);
2695 MUST_USE_RESULT LOperand* UseOrConstantAtStart(HValue* value);
2697 // An input operand in a register or a constant operand.
2698 MUST_USE_RESULT LOperand* UseRegisterOrConstant(HValue* value);
2699 MUST_USE_RESULT LOperand* UseRegisterOrConstantAtStart(HValue* value);
2701 // An input operand in a constant operand.
2702 MUST_USE_RESULT LOperand* UseConstant(HValue* value);
2704 // An input operand in register, stack slot or a constant operand.
2705 // Will not be moved to a register even if one is freely available.
2706 virtual MUST_USE_RESULT LOperand* UseAny(HValue* value) V8_OVERRIDE;
2708 // Temporary operand that must be in a register.
2709 MUST_USE_RESULT LUnallocated* TempRegister();
2710 MUST_USE_RESULT LOperand* FixedTemp(Register reg);
2711 MUST_USE_RESULT LOperand* FixedTemp(XMMRegister reg);
2713 // Methods for setting up define-use relationships.
2714 // Return the same instruction that they are passed.
2715 LInstruction* Define(LTemplateResultInstruction<1>* instr,
2716 LUnallocated* result);
2717 LInstruction* DefineAsRegister(LTemplateResultInstruction<1>* instr);
2718 LInstruction* DefineAsSpilled(LTemplateResultInstruction<1>* instr,
2720 LInstruction* DefineSameAsFirst(LTemplateResultInstruction<1>* instr);
2721 LInstruction* DefineFixed(LTemplateResultInstruction<1>* instr,
2723 LInstruction* DefineFixedDouble(LTemplateResultInstruction<1>* instr,
2725 // Assigns an environment to an instruction. An instruction which can
2726 // deoptimize must have an environment.
2727 LInstruction* AssignEnvironment(LInstruction* instr);
2728 // Assigns a pointer map to an instruction. An instruction which can
2729 // trigger a GC or a lazy deoptimization must have a pointer map.
2730 LInstruction* AssignPointerMap(LInstruction* instr);
2732 enum CanDeoptimize { CAN_DEOPTIMIZE_EAGERLY, CANNOT_DEOPTIMIZE_EAGERLY };
2734 // Marks a call for the register allocator. Assigns a pointer map to
2735 // support GC and lazy deoptimization. Assigns an environment to support
2736 // eager deoptimization if CAN_DEOPTIMIZE_EAGERLY.
2737 LInstruction* MarkAsCall(
2738 LInstruction* instr,
2739 HInstruction* hinstr,
2740 CanDeoptimize can_deoptimize = CANNOT_DEOPTIMIZE_EAGERLY);
2742 void VisitInstruction(HInstruction* current);
2744 void DoBasicBlock(HBasicBlock* block, HBasicBlock* next_block);
2745 LInstruction* DoShift(Token::Value op, HBitwiseBinaryOperation* instr);
2746 LInstruction* DoArithmeticD(Token::Value op,
2747 HArithmeticBinaryOperation* instr);
2748 LInstruction* DoArithmeticT(Token::Value op,
2749 HBinaryOperation* instr);
2751 LPlatformChunk* chunk_;
2752 CompilationInfo* info_;
2753 HGraph* const graph_;
2755 HInstruction* current_instruction_;
2756 HBasicBlock* current_block_;
2757 HBasicBlock* next_block_;
2758 LAllocator* allocator_;
2759 LInstruction* instruction_pending_deoptimization_environment_;
2760 BailoutId pending_deoptimization_ast_id_;
2762 DISALLOW_COPY_AND_ASSIGN(LChunkBuilder);
2765 #undef DECLARE_HYDROGEN_ACCESSOR
2766 #undef DECLARE_CONCRETE_INSTRUCTION
2768 } } // namespace v8::int
2770 #endif // V8_X64_LITHIUM_X64_H_