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) \
114 V(IsConstructCallAndBranch) \
115 V(IsObjectAndBranch) \
116 V(IsStringAndBranch) \
118 V(IsUndetectableAndBranch) \
123 V(LoadFieldByIndex) \
124 V(LoadFunctionPrototype) \
126 V(LoadGlobalGeneric) \
128 V(LoadKeyedGeneric) \
130 V(LoadNamedGeneric) \
155 V(SeqStringGetChar) \
156 V(SeqStringSetChar) \
162 V(StoreContextSlot) \
165 V(StoreKeyedGeneric) \
167 V(StoreNamedGeneric) \
169 V(StringCharCodeAt) \
170 V(StringCharFromCode) \
171 V(StringCompareAndBranch) \
175 V(ToFastProperties) \
176 V(TransitionElementsKind) \
177 V(TrapAllocationMemento) \
179 V(TypeofIsAndBranch) \
186 #define DECLARE_CONCRETE_INSTRUCTION(type, mnemonic) \
187 virtual Opcode opcode() const V8_FINAL V8_OVERRIDE { \
188 return LInstruction::k##type; \
190 virtual void CompileToNative(LCodeGen* generator) V8_FINAL V8_OVERRIDE; \
191 virtual const char* Mnemonic() const V8_FINAL V8_OVERRIDE { \
194 static L##type* cast(LInstruction* instr) { \
195 ASSERT(instr->Is##type()); \
196 return reinterpret_cast<L##type*>(instr); \
200 #define DECLARE_HYDROGEN_ACCESSOR(type) \
201 H##type* hydrogen() const { \
202 return H##type::cast(hydrogen_value()); \
206 class LInstruction : public ZoneObject {
209 : environment_(NULL),
210 hydrogen_value_(NULL),
211 bit_field_(IsCallBits::encode(false)) {
214 virtual ~LInstruction() {}
216 virtual void CompileToNative(LCodeGen* generator) = 0;
217 virtual const char* Mnemonic() const = 0;
218 virtual void PrintTo(StringStream* stream);
219 virtual void PrintDataTo(StringStream* stream);
220 virtual void PrintOutputOperandTo(StringStream* stream);
223 // Declare a unique enum value for each instruction.
224 #define DECLARE_OPCODE(type) k##type,
225 LITHIUM_CONCRETE_INSTRUCTION_LIST(DECLARE_OPCODE)
226 kNumberOfInstructions
227 #undef DECLARE_OPCODE
230 virtual Opcode opcode() const = 0;
232 // Declare non-virtual type testers for all leaf IR classes.
233 #define DECLARE_PREDICATE(type) \
234 bool Is##type() const { return opcode() == k##type; }
235 LITHIUM_CONCRETE_INSTRUCTION_LIST(DECLARE_PREDICATE)
236 #undef DECLARE_PREDICATE
238 // Declare virtual predicates for instructions that don't have
240 virtual bool IsGap() const { return false; }
242 virtual bool IsControl() const { return false; }
244 void set_environment(LEnvironment* env) { environment_ = env; }
245 LEnvironment* environment() const { return environment_; }
246 bool HasEnvironment() const { return environment_ != NULL; }
248 void set_pointer_map(LPointerMap* p) { pointer_map_.set(p); }
249 LPointerMap* pointer_map() const { return pointer_map_.get(); }
250 bool HasPointerMap() const { return pointer_map_.is_set(); }
252 void set_hydrogen_value(HValue* value) { hydrogen_value_ = value; }
253 HValue* hydrogen_value() const { return hydrogen_value_; }
255 void MarkAsCall() { bit_field_ = IsCallBits::update(bit_field_, true); }
256 bool IsCall() const { return IsCallBits::decode(bit_field_); }
258 // Interface to the register allocator and iterators.
259 bool ClobbersTemps() const { return IsCall(); }
260 bool ClobbersRegisters() const { return IsCall(); }
261 virtual bool ClobbersDoubleRegisters() const { return IsCall(); }
263 virtual void SetDeferredLazyDeoptimizationEnvironment(LEnvironment* env) { }
265 // Interface to the register allocator and iterators.
266 bool IsMarkedAsCall() const { return IsCall(); }
268 virtual bool HasResult() const = 0;
269 virtual LOperand* result() const = 0;
271 LOperand* FirstInput() { return InputAt(0); }
272 LOperand* Output() { return HasResult() ? result() : NULL; }
274 virtual bool HasInterestingComment(LCodeGen* gen) const { return true; }
282 friend class InputIterator;
283 virtual int InputCount() = 0;
284 virtual LOperand* InputAt(int i) = 0;
286 friend class TempIterator;
287 virtual int TempCount() = 0;
288 virtual LOperand* TempAt(int i) = 0;
290 class IsCallBits: public BitField<bool, 0, 1> {};
292 LEnvironment* environment_;
293 SetOncePointer<LPointerMap> pointer_map_;
294 HValue* hydrogen_value_;
299 // R = number of result operands (0 or 1).
301 class LTemplateResultInstruction : public LInstruction {
303 // Allow 0 or 1 output operands.
304 STATIC_ASSERT(R == 0 || R == 1);
305 virtual bool HasResult() const V8_FINAL V8_OVERRIDE {
306 return R != 0 && result() != NULL;
308 void set_result(LOperand* operand) { results_[0] = operand; }
309 LOperand* result() const { return results_[0]; }
312 EmbeddedContainer<LOperand*, R> results_;
316 // R = number of result operands (0 or 1).
317 // I = number of input operands.
318 // T = number of temporary operands.
319 template<int R, int I, int T>
320 class LTemplateInstruction : public LTemplateResultInstruction<R> {
322 EmbeddedContainer<LOperand*, I> inputs_;
323 EmbeddedContainer<LOperand*, T> temps_;
327 virtual int InputCount() V8_FINAL V8_OVERRIDE { return I; }
328 virtual LOperand* InputAt(int i) V8_FINAL V8_OVERRIDE { return inputs_[i]; }
330 virtual int TempCount() V8_FINAL V8_OVERRIDE { return T; }
331 virtual LOperand* TempAt(int i) V8_FINAL V8_OVERRIDE { return temps_[i]; }
335 class LGap : public LTemplateInstruction<0, 0, 0> {
337 explicit LGap(HBasicBlock* block)
339 parallel_moves_[BEFORE] = NULL;
340 parallel_moves_[START] = NULL;
341 parallel_moves_[END] = NULL;
342 parallel_moves_[AFTER] = NULL;
345 // Can't use the DECLARE-macro here because of sub-classes.
346 virtual bool IsGap() const V8_FINAL V8_OVERRIDE { return true; }
347 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
348 static LGap* cast(LInstruction* instr) {
349 ASSERT(instr->IsGap());
350 return reinterpret_cast<LGap*>(instr);
353 bool IsRedundant() const;
355 HBasicBlock* block() const { return block_; }
362 FIRST_INNER_POSITION = BEFORE,
363 LAST_INNER_POSITION = AFTER
366 LParallelMove* GetOrCreateParallelMove(InnerPosition pos,
368 if (parallel_moves_[pos] == NULL) {
369 parallel_moves_[pos] = new(zone) LParallelMove(zone);
371 return parallel_moves_[pos];
374 LParallelMove* GetParallelMove(InnerPosition pos) {
375 return parallel_moves_[pos];
379 LParallelMove* parallel_moves_[LAST_INNER_POSITION + 1];
384 class LInstructionGap V8_FINAL : public LGap {
386 explicit LInstructionGap(HBasicBlock* block) : LGap(block) { }
388 virtual bool HasInterestingComment(LCodeGen* gen) const V8_OVERRIDE {
389 return !IsRedundant();
392 DECLARE_CONCRETE_INSTRUCTION(InstructionGap, "gap")
396 class LGoto V8_FINAL : public LTemplateInstruction<0, 0, 0> {
398 explicit LGoto(HBasicBlock* block) : block_(block) { }
400 virtual bool HasInterestingComment(LCodeGen* gen) const V8_OVERRIDE;
401 DECLARE_CONCRETE_INSTRUCTION(Goto, "goto")
402 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
403 virtual bool IsControl() const V8_OVERRIDE { return true; }
405 int block_id() const { return block_->block_id(); }
412 class LLazyBailout V8_FINAL : public LTemplateInstruction<0, 0, 0> {
414 LLazyBailout() : gap_instructions_size_(0) { }
416 DECLARE_CONCRETE_INSTRUCTION(LazyBailout, "lazy-bailout")
418 void set_gap_instructions_size(int gap_instructions_size) {
419 gap_instructions_size_ = gap_instructions_size;
421 int gap_instructions_size() { return gap_instructions_size_; }
424 int gap_instructions_size_;
428 class LDummy V8_FINAL : public LTemplateInstruction<1, 0, 0> {
430 explicit LDummy() { }
431 DECLARE_CONCRETE_INSTRUCTION(Dummy, "dummy")
435 class LDummyUse V8_FINAL : public LTemplateInstruction<1, 1, 0> {
437 explicit LDummyUse(LOperand* value) {
440 DECLARE_CONCRETE_INSTRUCTION(DummyUse, "dummy-use")
444 class LDeoptimize V8_FINAL : public LTemplateInstruction<0, 0, 0> {
446 DECLARE_CONCRETE_INSTRUCTION(Deoptimize, "deoptimize")
447 DECLARE_HYDROGEN_ACCESSOR(Deoptimize)
451 class LLabel V8_FINAL : public LGap {
453 explicit LLabel(HBasicBlock* block)
454 : LGap(block), replacement_(NULL) { }
456 virtual bool HasInterestingComment(LCodeGen* gen) const V8_OVERRIDE {
459 DECLARE_CONCRETE_INSTRUCTION(Label, "label")
461 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
463 int block_id() const { return block()->block_id(); }
464 bool is_loop_header() const { return block()->IsLoopHeader(); }
465 bool is_osr_entry() const { return block()->is_osr_entry(); }
466 Label* label() { return &label_; }
467 LLabel* replacement() const { return replacement_; }
468 void set_replacement(LLabel* label) { replacement_ = label; }
469 bool HasReplacement() const { return replacement_ != NULL; }
473 LLabel* replacement_;
477 class LParameter V8_FINAL : public LTemplateInstruction<1, 0, 0> {
479 virtual bool HasInterestingComment(LCodeGen* gen) const V8_OVERRIDE {
482 DECLARE_CONCRETE_INSTRUCTION(Parameter, "parameter")
486 class LCallStub V8_FINAL : public LTemplateInstruction<1, 1, 0> {
488 explicit LCallStub(LOperand* context) {
489 inputs_[0] = context;
492 LOperand* context() { return inputs_[0]; }
494 DECLARE_CONCRETE_INSTRUCTION(CallStub, "call-stub")
495 DECLARE_HYDROGEN_ACCESSOR(CallStub)
499 class LUnknownOSRValue V8_FINAL : public LTemplateInstruction<1, 0, 0> {
501 virtual bool HasInterestingComment(LCodeGen* gen) const V8_OVERRIDE {
504 DECLARE_CONCRETE_INSTRUCTION(UnknownOSRValue, "unknown-osr-value")
508 template<int I, int T>
509 class LControlInstruction : public LTemplateInstruction<0, I, T> {
511 LControlInstruction() : false_label_(NULL), true_label_(NULL) { }
513 virtual bool IsControl() const V8_FINAL V8_OVERRIDE { return true; }
515 int SuccessorCount() { return hydrogen()->SuccessorCount(); }
516 HBasicBlock* SuccessorAt(int i) { return hydrogen()->SuccessorAt(i); }
518 int TrueDestination(LChunk* chunk) {
519 return chunk->LookupDestination(true_block_id());
521 int FalseDestination(LChunk* chunk) {
522 return chunk->LookupDestination(false_block_id());
525 Label* TrueLabel(LChunk* chunk) {
526 if (true_label_ == NULL) {
527 true_label_ = chunk->GetAssemblyLabel(TrueDestination(chunk));
531 Label* FalseLabel(LChunk* chunk) {
532 if (false_label_ == NULL) {
533 false_label_ = chunk->GetAssemblyLabel(FalseDestination(chunk));
539 int true_block_id() { return SuccessorAt(0)->block_id(); }
540 int false_block_id() { return SuccessorAt(1)->block_id(); }
543 HControlInstruction* hydrogen() {
544 return HControlInstruction::cast(this->hydrogen_value());
552 class LWrapReceiver V8_FINAL : public LTemplateInstruction<1, 2, 0> {
554 LWrapReceiver(LOperand* receiver, LOperand* function) {
555 inputs_[0] = receiver;
556 inputs_[1] = function;
559 LOperand* receiver() { return inputs_[0]; }
560 LOperand* function() { return inputs_[1]; }
562 DECLARE_CONCRETE_INSTRUCTION(WrapReceiver, "wrap-receiver")
563 DECLARE_HYDROGEN_ACCESSOR(WrapReceiver)
567 class LApplyArguments V8_FINAL : public LTemplateInstruction<1, 4, 0> {
569 LApplyArguments(LOperand* function,
572 LOperand* elements) {
573 inputs_[0] = function;
574 inputs_[1] = receiver;
576 inputs_[3] = elements;
579 LOperand* function() { return inputs_[0]; }
580 LOperand* receiver() { return inputs_[1]; }
581 LOperand* length() { return inputs_[2]; }
582 LOperand* elements() { return inputs_[3]; }
584 DECLARE_CONCRETE_INSTRUCTION(ApplyArguments, "apply-arguments")
588 class LAccessArgumentsAt V8_FINAL : public LTemplateInstruction<1, 3, 0> {
590 LAccessArgumentsAt(LOperand* arguments, LOperand* length, LOperand* index) {
591 inputs_[0] = arguments;
596 LOperand* arguments() { return inputs_[0]; }
597 LOperand* length() { return inputs_[1]; }
598 LOperand* index() { return inputs_[2]; }
600 DECLARE_CONCRETE_INSTRUCTION(AccessArgumentsAt, "access-arguments-at")
602 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
606 class LArgumentsLength V8_FINAL : public LTemplateInstruction<1, 1, 0> {
608 explicit LArgumentsLength(LOperand* elements) {
609 inputs_[0] = elements;
612 LOperand* elements() { return inputs_[0]; }
614 DECLARE_CONCRETE_INSTRUCTION(ArgumentsLength, "arguments-length")
618 class LArgumentsElements V8_FINAL : public LTemplateInstruction<1, 0, 0> {
620 DECLARE_CONCRETE_INSTRUCTION(ArgumentsElements, "arguments-elements")
621 DECLARE_HYDROGEN_ACCESSOR(ArgumentsElements)
625 class LModByPowerOf2I V8_FINAL : public LTemplateInstruction<1, 1, 0> {
627 LModByPowerOf2I(LOperand* dividend, int32_t divisor) {
628 inputs_[0] = dividend;
632 LOperand* dividend() { return inputs_[0]; }
633 int32_t divisor() const { return divisor_; }
635 DECLARE_CONCRETE_INSTRUCTION(ModByPowerOf2I, "mod-by-power-of-2-i")
636 DECLARE_HYDROGEN_ACCESSOR(Mod)
643 class LModByConstI V8_FINAL : public LTemplateInstruction<1, 1, 2> {
645 LModByConstI(LOperand* dividend,
649 inputs_[0] = dividend;
655 LOperand* dividend() { return inputs_[0]; }
656 int32_t divisor() const { return divisor_; }
657 LOperand* temp1() { return temps_[0]; }
658 LOperand* temp2() { return temps_[1]; }
660 DECLARE_CONCRETE_INSTRUCTION(ModByConstI, "mod-by-const-i")
661 DECLARE_HYDROGEN_ACCESSOR(Mod)
668 class LModI V8_FINAL : public LTemplateInstruction<1, 2, 1> {
670 LModI(LOperand* left, LOperand* right, LOperand* temp) {
676 LOperand* left() { return inputs_[0]; }
677 LOperand* right() { return inputs_[1]; }
678 LOperand* temp() { return temps_[0]; }
680 DECLARE_CONCRETE_INSTRUCTION(ModI, "mod-i")
681 DECLARE_HYDROGEN_ACCESSOR(Mod)
685 class LDivByPowerOf2I V8_FINAL : public LTemplateInstruction<1, 1, 0> {
687 LDivByPowerOf2I(LOperand* dividend, int32_t divisor) {
688 inputs_[0] = dividend;
692 LOperand* dividend() { return inputs_[0]; }
693 int32_t divisor() const { return divisor_; }
695 DECLARE_CONCRETE_INSTRUCTION(DivByPowerOf2I, "div-by-power-of-2-i")
696 DECLARE_HYDROGEN_ACCESSOR(Div)
703 class LDivByConstI V8_FINAL : public LTemplateInstruction<1, 1, 2> {
705 LDivByConstI(LOperand* dividend,
709 inputs_[0] = dividend;
715 LOperand* dividend() { return inputs_[0]; }
716 int32_t divisor() const { return divisor_; }
717 LOperand* temp1() { return temps_[0]; }
718 LOperand* temp2() { return temps_[1]; }
720 DECLARE_CONCRETE_INSTRUCTION(DivByConstI, "div-by-const-i")
721 DECLARE_HYDROGEN_ACCESSOR(Div)
728 class LDivI V8_FINAL : public LTemplateInstruction<1, 2, 1> {
730 LDivI(LOperand* left, LOperand* right, LOperand* temp) {
736 LOperand* left() { return inputs_[0]; }
737 LOperand* right() { return inputs_[1]; }
738 LOperand* temp() { return temps_[0]; }
740 DECLARE_CONCRETE_INSTRUCTION(DivI, "div-i")
741 DECLARE_HYDROGEN_ACCESSOR(BinaryOperation)
745 class LFlooringDivByPowerOf2I V8_FINAL : public LTemplateInstruction<1, 1, 0> {
747 LFlooringDivByPowerOf2I(LOperand* dividend, int32_t divisor) {
748 inputs_[0] = dividend;
752 LOperand* dividend() { return inputs_[0]; }
753 int32_t divisor() const { return divisor_; }
755 DECLARE_CONCRETE_INSTRUCTION(FlooringDivByPowerOf2I,
756 "flooring-div-by-power-of-2-i")
757 DECLARE_HYDROGEN_ACCESSOR(MathFloorOfDiv)
764 class LFlooringDivByConstI V8_FINAL : public LTemplateInstruction<1, 1, 2> {
766 LFlooringDivByConstI(LOperand* dividend,
770 inputs_[0] = dividend;
776 LOperand* dividend() { return inputs_[0]; }
777 int32_t divisor() const { return divisor_; }
778 LOperand* temp1() { return temps_[0]; }
779 LOperand* temp2() { return temps_[0]; }
781 DECLARE_CONCRETE_INSTRUCTION(FlooringDivByConstI, "flooring-div-by-const-i")
782 DECLARE_HYDROGEN_ACCESSOR(MathFloorOfDiv)
789 class LMulI V8_FINAL : public LTemplateInstruction<1, 2, 0> {
791 LMulI(LOperand* left, LOperand* right) {
796 LOperand* left() { return inputs_[0]; }
797 LOperand* right() { return inputs_[1]; }
799 DECLARE_CONCRETE_INSTRUCTION(MulI, "mul-i")
800 DECLARE_HYDROGEN_ACCESSOR(Mul)
804 class LCompareNumericAndBranch V8_FINAL : public LControlInstruction<2, 0> {
806 LCompareNumericAndBranch(LOperand* left, LOperand* right) {
811 LOperand* left() { return inputs_[0]; }
812 LOperand* right() { return inputs_[1]; }
814 DECLARE_CONCRETE_INSTRUCTION(CompareNumericAndBranch,
815 "compare-numeric-and-branch")
816 DECLARE_HYDROGEN_ACCESSOR(CompareNumericAndBranch)
818 Token::Value op() const { return hydrogen()->token(); }
819 bool is_double() const {
820 return hydrogen()->representation().IsDouble();
823 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
827 class LMathFloor V8_FINAL : public LTemplateInstruction<1, 1, 0> {
829 explicit LMathFloor(LOperand* value) {
833 LOperand* value() { return inputs_[0]; }
835 DECLARE_CONCRETE_INSTRUCTION(MathFloor, "math-floor")
836 DECLARE_HYDROGEN_ACCESSOR(UnaryMathOperation)
840 class LMathRound V8_FINAL : public LTemplateInstruction<1, 1, 0> {
842 explicit LMathRound(LOperand* value) {
846 LOperand* value() { return inputs_[0]; }
848 DECLARE_CONCRETE_INSTRUCTION(MathRound, "math-round")
849 DECLARE_HYDROGEN_ACCESSOR(UnaryMathOperation)
853 class LMathAbs V8_FINAL : public LTemplateInstruction<1, 2, 0> {
855 explicit LMathAbs(LOperand* context, LOperand* value) {
856 inputs_[1] = context;
860 LOperand* context() { return inputs_[1]; }
861 LOperand* value() { return inputs_[0]; }
863 DECLARE_CONCRETE_INSTRUCTION(MathAbs, "math-abs")
864 DECLARE_HYDROGEN_ACCESSOR(UnaryMathOperation)
868 class LMathLog V8_FINAL : public LTemplateInstruction<1, 1, 0> {
870 explicit LMathLog(LOperand* value) {
874 LOperand* value() { return inputs_[0]; }
876 DECLARE_CONCRETE_INSTRUCTION(MathLog, "math-log")
880 class LMathClz32 V8_FINAL : public LTemplateInstruction<1, 1, 0> {
882 explicit LMathClz32(LOperand* value) {
886 LOperand* value() { return inputs_[0]; }
888 DECLARE_CONCRETE_INSTRUCTION(MathClz32, "math-clz32")
892 class LMathExp V8_FINAL : public LTemplateInstruction<1, 1, 2> {
894 LMathExp(LOperand* value, LOperand* temp1, LOperand* temp2) {
898 ExternalReference::InitializeMathExpData();
901 LOperand* value() { return inputs_[0]; }
902 LOperand* temp1() { return temps_[0]; }
903 LOperand* temp2() { return temps_[1]; }
905 DECLARE_CONCRETE_INSTRUCTION(MathExp, "math-exp")
909 class LMathSqrt V8_FINAL : public LTemplateInstruction<1, 1, 0> {
911 explicit LMathSqrt(LOperand* value) {
915 LOperand* value() { return inputs_[0]; }
917 DECLARE_CONCRETE_INSTRUCTION(MathSqrt, "math-sqrt")
921 class LMathPowHalf V8_FINAL : public LTemplateInstruction<1, 1, 0> {
923 explicit LMathPowHalf(LOperand* value) {
927 LOperand* value() { return inputs_[0]; }
929 DECLARE_CONCRETE_INSTRUCTION(MathPowHalf, "math-pow-half")
933 class LCmpObjectEqAndBranch V8_FINAL : public LControlInstruction<2, 0> {
935 LCmpObjectEqAndBranch(LOperand* left, LOperand* right) {
940 LOperand* left() { return inputs_[0]; }
941 LOperand* right() { return inputs_[1]; }
943 DECLARE_CONCRETE_INSTRUCTION(CmpObjectEqAndBranch, "cmp-object-eq-and-branch")
947 class LCmpHoleAndBranch V8_FINAL : public LControlInstruction<1, 0> {
949 explicit LCmpHoleAndBranch(LOperand* object) {
953 LOperand* object() { return inputs_[0]; }
955 DECLARE_CONCRETE_INSTRUCTION(CmpHoleAndBranch, "cmp-hole-and-branch")
956 DECLARE_HYDROGEN_ACCESSOR(CompareHoleAndBranch)
960 class LCompareMinusZeroAndBranch V8_FINAL : public LControlInstruction<1, 0> {
962 explicit LCompareMinusZeroAndBranch(LOperand* value) {
966 LOperand* value() { return inputs_[0]; }
968 DECLARE_CONCRETE_INSTRUCTION(CompareMinusZeroAndBranch,
969 "cmp-minus-zero-and-branch")
970 DECLARE_HYDROGEN_ACCESSOR(CompareMinusZeroAndBranch)
975 class LIsObjectAndBranch V8_FINAL : public LControlInstruction<1, 0> {
977 explicit LIsObjectAndBranch(LOperand* value) {
981 LOperand* value() { return inputs_[0]; }
983 DECLARE_CONCRETE_INSTRUCTION(IsObjectAndBranch, "is-object-and-branch")
984 DECLARE_HYDROGEN_ACCESSOR(IsObjectAndBranch)
986 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
990 class LIsStringAndBranch V8_FINAL : public LControlInstruction<1, 1> {
992 explicit LIsStringAndBranch(LOperand* value, LOperand* temp) {
997 LOperand* value() { return inputs_[0]; }
998 LOperand* temp() { return temps_[0]; }
1000 DECLARE_CONCRETE_INSTRUCTION(IsStringAndBranch, "is-string-and-branch")
1001 DECLARE_HYDROGEN_ACCESSOR(IsStringAndBranch)
1003 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1007 class LIsSmiAndBranch V8_FINAL : public LControlInstruction<1, 0> {
1009 explicit LIsSmiAndBranch(LOperand* value) {
1013 LOperand* value() { return inputs_[0]; }
1015 DECLARE_CONCRETE_INSTRUCTION(IsSmiAndBranch, "is-smi-and-branch")
1016 DECLARE_HYDROGEN_ACCESSOR(IsSmiAndBranch)
1018 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1022 class LIsUndetectableAndBranch V8_FINAL : public LControlInstruction<1, 1> {
1024 explicit LIsUndetectableAndBranch(LOperand* value, LOperand* temp) {
1029 LOperand* value() { return inputs_[0]; }
1030 LOperand* temp() { return temps_[0]; }
1032 DECLARE_CONCRETE_INSTRUCTION(IsUndetectableAndBranch,
1033 "is-undetectable-and-branch")
1034 DECLARE_HYDROGEN_ACCESSOR(IsUndetectableAndBranch)
1036 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1040 class LStringCompareAndBranch V8_FINAL : public LControlInstruction<3, 0> {
1042 explicit LStringCompareAndBranch(LOperand* context,
1045 inputs_[0] = context;
1050 LOperand* context() { return inputs_[0]; }
1051 LOperand* left() { return inputs_[1]; }
1052 LOperand* right() { return inputs_[2]; }
1054 DECLARE_CONCRETE_INSTRUCTION(StringCompareAndBranch,
1055 "string-compare-and-branch")
1056 DECLARE_HYDROGEN_ACCESSOR(StringCompareAndBranch)
1058 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1060 Token::Value op() const { return hydrogen()->token(); }
1064 class LHasInstanceTypeAndBranch V8_FINAL : public LControlInstruction<1, 0> {
1066 explicit LHasInstanceTypeAndBranch(LOperand* value) {
1070 LOperand* value() { return inputs_[0]; }
1072 DECLARE_CONCRETE_INSTRUCTION(HasInstanceTypeAndBranch,
1073 "has-instance-type-and-branch")
1074 DECLARE_HYDROGEN_ACCESSOR(HasInstanceTypeAndBranch)
1076 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1080 class LGetCachedArrayIndex V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1082 explicit LGetCachedArrayIndex(LOperand* value) {
1086 LOperand* value() { return inputs_[0]; }
1088 DECLARE_CONCRETE_INSTRUCTION(GetCachedArrayIndex, "get-cached-array-index")
1089 DECLARE_HYDROGEN_ACCESSOR(GetCachedArrayIndex)
1093 class LHasCachedArrayIndexAndBranch V8_FINAL
1094 : public LControlInstruction<1, 0> {
1096 explicit LHasCachedArrayIndexAndBranch(LOperand* value) {
1100 LOperand* value() { return inputs_[0]; }
1102 DECLARE_CONCRETE_INSTRUCTION(HasCachedArrayIndexAndBranch,
1103 "has-cached-array-index-and-branch")
1104 DECLARE_HYDROGEN_ACCESSOR(HasCachedArrayIndexAndBranch)
1106 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1110 class LClassOfTestAndBranch V8_FINAL : public LControlInstruction<1, 2> {
1112 LClassOfTestAndBranch(LOperand* value, LOperand* temp, LOperand* temp2) {
1118 LOperand* value() { return inputs_[0]; }
1119 LOperand* temp() { return temps_[0]; }
1120 LOperand* temp2() { return temps_[1]; }
1122 DECLARE_CONCRETE_INSTRUCTION(ClassOfTestAndBranch,
1123 "class-of-test-and-branch")
1124 DECLARE_HYDROGEN_ACCESSOR(ClassOfTestAndBranch)
1126 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1130 class LCmpT V8_FINAL : public LTemplateInstruction<1, 3, 0> {
1132 LCmpT(LOperand* context, LOperand* left, LOperand* right) {
1133 inputs_[0] = context;
1138 LOperand* context() { return inputs_[0]; }
1139 LOperand* left() { return inputs_[1]; }
1140 LOperand* right() { return inputs_[2]; }
1142 DECLARE_CONCRETE_INSTRUCTION(CmpT, "cmp-t")
1143 DECLARE_HYDROGEN_ACCESSOR(CompareGeneric)
1145 Token::Value op() const { return hydrogen()->token(); }
1149 class LInstanceOf V8_FINAL : public LTemplateInstruction<1, 3, 0> {
1151 LInstanceOf(LOperand* context, LOperand* left, LOperand* right) {
1152 inputs_[0] = context;
1157 LOperand* context() { return inputs_[0]; }
1158 LOperand* left() { return inputs_[1]; }
1159 LOperand* right() { return inputs_[2]; }
1161 DECLARE_CONCRETE_INSTRUCTION(InstanceOf, "instance-of")
1165 class LInstanceOfKnownGlobal V8_FINAL : public LTemplateInstruction<1, 2, 1> {
1167 LInstanceOfKnownGlobal(LOperand* context, LOperand* value, LOperand* temp) {
1168 inputs_[0] = context;
1173 LOperand* context() { return inputs_[0]; }
1174 LOperand* value() { return inputs_[1]; }
1175 LOperand* temp() { return temps_[0]; }
1177 DECLARE_CONCRETE_INSTRUCTION(InstanceOfKnownGlobal,
1178 "instance-of-known-global")
1179 DECLARE_HYDROGEN_ACCESSOR(InstanceOfKnownGlobal)
1181 Handle<JSFunction> function() const { return hydrogen()->function(); }
1182 LEnvironment* GetDeferredLazyDeoptimizationEnvironment() {
1183 return lazy_deopt_env_;
1185 virtual void SetDeferredLazyDeoptimizationEnvironment(
1186 LEnvironment* env) V8_OVERRIDE {
1187 lazy_deopt_env_ = env;
1191 LEnvironment* lazy_deopt_env_;
1195 class LBoundsCheck V8_FINAL : public LTemplateInstruction<0, 2, 0> {
1197 LBoundsCheck(LOperand* index, LOperand* length) {
1199 inputs_[1] = length;
1202 LOperand* index() { return inputs_[0]; }
1203 LOperand* length() { return inputs_[1]; }
1205 DECLARE_CONCRETE_INSTRUCTION(BoundsCheck, "bounds-check")
1206 DECLARE_HYDROGEN_ACCESSOR(BoundsCheck)
1210 class LBitI V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1212 LBitI(LOperand* left, LOperand* right) {
1217 LOperand* left() { return inputs_[0]; }
1218 LOperand* right() { return inputs_[1]; }
1220 Token::Value op() const { return hydrogen()->op(); }
1222 DECLARE_CONCRETE_INSTRUCTION(BitI, "bit-i")
1223 DECLARE_HYDROGEN_ACCESSOR(Bitwise)
1227 class LShiftI V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1229 LShiftI(Token::Value op, LOperand* left, LOperand* right, bool can_deopt)
1230 : op_(op), can_deopt_(can_deopt) {
1235 Token::Value op() const { return op_; }
1236 LOperand* left() { return inputs_[0]; }
1237 LOperand* right() { return inputs_[1]; }
1238 bool can_deopt() const { return can_deopt_; }
1240 DECLARE_CONCRETE_INSTRUCTION(ShiftI, "shift-i")
1248 class LSubI V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1250 LSubI(LOperand* left, LOperand* right) {
1255 LOperand* left() { return inputs_[0]; }
1256 LOperand* right() { return inputs_[1]; }
1258 DECLARE_CONCRETE_INSTRUCTION(SubI, "sub-i")
1259 DECLARE_HYDROGEN_ACCESSOR(Sub)
1263 class LConstantI V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1265 DECLARE_CONCRETE_INSTRUCTION(ConstantI, "constant-i")
1266 DECLARE_HYDROGEN_ACCESSOR(Constant)
1268 int32_t value() const { return hydrogen()->Integer32Value(); }
1272 class LConstantS V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1274 DECLARE_CONCRETE_INSTRUCTION(ConstantS, "constant-s")
1275 DECLARE_HYDROGEN_ACCESSOR(Constant)
1277 Smi* value() const { return Smi::FromInt(hydrogen()->Integer32Value()); }
1281 class LConstantD V8_FINAL : public LTemplateInstruction<1, 0, 1> {
1283 explicit LConstantD(LOperand* temp) {
1287 LOperand* temp() { return temps_[0]; }
1289 DECLARE_CONCRETE_INSTRUCTION(ConstantD, "constant-d")
1290 DECLARE_HYDROGEN_ACCESSOR(Constant)
1292 double value() const { return hydrogen()->DoubleValue(); }
1296 class LConstantE V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1298 DECLARE_CONCRETE_INSTRUCTION(ConstantE, "constant-e")
1299 DECLARE_HYDROGEN_ACCESSOR(Constant)
1301 ExternalReference value() const {
1302 return hydrogen()->ExternalReferenceValue();
1307 class LConstantT V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1309 DECLARE_CONCRETE_INSTRUCTION(ConstantT, "constant-t")
1310 DECLARE_HYDROGEN_ACCESSOR(Constant)
1312 Handle<Object> value(Isolate* isolate) const {
1313 return hydrogen()->handle(isolate);
1318 class LBranch V8_FINAL : public LControlInstruction<1, 0> {
1320 explicit LBranch(LOperand* value) {
1324 LOperand* value() { return inputs_[0]; }
1326 DECLARE_CONCRETE_INSTRUCTION(Branch, "branch")
1327 DECLARE_HYDROGEN_ACCESSOR(Branch)
1329 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1333 class LDebugBreak V8_FINAL : public LTemplateInstruction<0, 0, 0> {
1335 DECLARE_CONCRETE_INSTRUCTION(DebugBreak, "break")
1339 class LCmpMapAndBranch V8_FINAL : public LControlInstruction<1, 0> {
1341 explicit LCmpMapAndBranch(LOperand* value) {
1345 LOperand* value() { return inputs_[0]; }
1347 DECLARE_CONCRETE_INSTRUCTION(CmpMapAndBranch, "cmp-map-and-branch")
1348 DECLARE_HYDROGEN_ACCESSOR(CompareMap)
1350 Handle<Map> map() const { return hydrogen()->map().handle(); }
1354 class LMapEnumLength V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1356 explicit LMapEnumLength(LOperand* value) {
1360 LOperand* value() { return inputs_[0]; }
1362 DECLARE_CONCRETE_INSTRUCTION(MapEnumLength, "map-enum-length")
1366 class LDateField V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1368 LDateField(LOperand* date, Smi* index) : index_(index) {
1372 LOperand* date() { return inputs_[0]; }
1373 Smi* index() const { return index_; }
1375 DECLARE_CONCRETE_INSTRUCTION(DateField, "date-field")
1376 DECLARE_HYDROGEN_ACCESSOR(DateField)
1383 class LSeqStringGetChar V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1385 LSeqStringGetChar(LOperand* string, LOperand* index) {
1386 inputs_[0] = string;
1390 LOperand* string() const { return inputs_[0]; }
1391 LOperand* index() const { return inputs_[1]; }
1393 DECLARE_CONCRETE_INSTRUCTION(SeqStringGetChar, "seq-string-get-char")
1394 DECLARE_HYDROGEN_ACCESSOR(SeqStringGetChar)
1398 class LSeqStringSetChar V8_FINAL : public LTemplateInstruction<1, 4, 0> {
1400 LSeqStringSetChar(LOperand* context,
1404 inputs_[0] = context;
1405 inputs_[1] = string;
1410 LOperand* string() { return inputs_[1]; }
1411 LOperand* index() { return inputs_[2]; }
1412 LOperand* value() { return inputs_[3]; }
1414 DECLARE_CONCRETE_INSTRUCTION(SeqStringSetChar, "seq-string-set-char")
1415 DECLARE_HYDROGEN_ACCESSOR(SeqStringSetChar)
1419 class LAddI V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1421 LAddI(LOperand* left, LOperand* right) {
1426 LOperand* left() { return inputs_[0]; }
1427 LOperand* right() { return inputs_[1]; }
1429 static bool UseLea(HAdd* add) {
1430 return !add->CheckFlag(HValue::kCanOverflow) &&
1431 add->BetterLeftOperand()->UseCount() > 1;
1434 DECLARE_CONCRETE_INSTRUCTION(AddI, "add-i")
1435 DECLARE_HYDROGEN_ACCESSOR(Add)
1439 class LMathMinMax V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1441 LMathMinMax(LOperand* left, LOperand* right) {
1446 LOperand* left() { return inputs_[0]; }
1447 LOperand* right() { return inputs_[1]; }
1449 DECLARE_CONCRETE_INSTRUCTION(MathMinMax, "math-min-max")
1450 DECLARE_HYDROGEN_ACCESSOR(MathMinMax)
1454 class LPower V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1456 LPower(LOperand* left, LOperand* right) {
1461 LOperand* left() { return inputs_[0]; }
1462 LOperand* right() { return inputs_[1]; }
1464 DECLARE_CONCRETE_INSTRUCTION(Power, "power")
1465 DECLARE_HYDROGEN_ACCESSOR(Power)
1469 class LArithmeticD V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1471 LArithmeticD(Token::Value op, LOperand* left, LOperand* right)
1477 Token::Value op() const { return op_; }
1478 LOperand* left() { return inputs_[0]; }
1479 LOperand* right() { return inputs_[1]; }
1481 virtual Opcode opcode() const V8_OVERRIDE {
1482 return LInstruction::kArithmeticD;
1484 virtual void CompileToNative(LCodeGen* generator) V8_OVERRIDE;
1485 virtual const char* Mnemonic() const V8_OVERRIDE;
1492 class LArithmeticT V8_FINAL : public LTemplateInstruction<1, 3, 0> {
1494 LArithmeticT(Token::Value op,
1499 inputs_[0] = context;
1504 Token::Value op() const { return op_; }
1505 LOperand* context() { return inputs_[0]; }
1506 LOperand* left() { return inputs_[1]; }
1507 LOperand* right() { return inputs_[2]; }
1509 virtual Opcode opcode() const V8_OVERRIDE {
1510 return LInstruction::kArithmeticT;
1512 virtual void CompileToNative(LCodeGen* generator) V8_OVERRIDE;
1513 virtual const char* Mnemonic() const V8_OVERRIDE;
1520 class LReturn V8_FINAL : public LTemplateInstruction<0, 3, 0> {
1522 explicit LReturn(LOperand* value,
1524 LOperand* parameter_count) {
1526 inputs_[1] = context;
1527 inputs_[2] = parameter_count;
1530 LOperand* value() { return inputs_[0]; }
1531 LOperand* context() { return inputs_[1]; }
1533 bool has_constant_parameter_count() {
1534 return parameter_count()->IsConstantOperand();
1536 LConstantOperand* constant_parameter_count() {
1537 ASSERT(has_constant_parameter_count());
1538 return LConstantOperand::cast(parameter_count());
1540 LOperand* parameter_count() { return inputs_[2]; }
1542 DECLARE_CONCRETE_INSTRUCTION(Return, "return")
1543 DECLARE_HYDROGEN_ACCESSOR(Return)
1547 class LLoadNamedField V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1549 explicit LLoadNamedField(LOperand* object) {
1550 inputs_[0] = object;
1553 LOperand* object() { return inputs_[0]; }
1555 DECLARE_CONCRETE_INSTRUCTION(LoadNamedField, "load-named-field")
1556 DECLARE_HYDROGEN_ACCESSOR(LoadNamedField)
1560 class LLoadNamedGeneric V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1562 explicit LLoadNamedGeneric(LOperand* context, LOperand* object) {
1563 inputs_[0] = context;
1564 inputs_[1] = object;
1567 DECLARE_CONCRETE_INSTRUCTION(LoadNamedGeneric, "load-named-generic")
1568 DECLARE_HYDROGEN_ACCESSOR(LoadNamedGeneric)
1570 LOperand* context() { return inputs_[0]; }
1571 LOperand* object() { return inputs_[1]; }
1572 Handle<Object> name() const { return hydrogen()->name(); }
1576 class LLoadFunctionPrototype V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1578 explicit LLoadFunctionPrototype(LOperand* function) {
1579 inputs_[0] = function;
1582 DECLARE_CONCRETE_INSTRUCTION(LoadFunctionPrototype, "load-function-prototype")
1583 DECLARE_HYDROGEN_ACCESSOR(LoadFunctionPrototype)
1585 LOperand* function() { return inputs_[0]; }
1589 class LLoadRoot V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1591 DECLARE_CONCRETE_INSTRUCTION(LoadRoot, "load-root")
1592 DECLARE_HYDROGEN_ACCESSOR(LoadRoot)
1594 Heap::RootListIndex index() const { return hydrogen()->index(); }
1598 class LLoadKeyed V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1600 LLoadKeyed(LOperand* elements, LOperand* key) {
1601 inputs_[0] = elements;
1605 DECLARE_CONCRETE_INSTRUCTION(LoadKeyed, "load-keyed")
1606 DECLARE_HYDROGEN_ACCESSOR(LoadKeyed)
1608 bool is_external() const {
1609 return hydrogen()->is_external();
1611 bool is_fixed_typed_array() const {
1612 return hydrogen()->is_fixed_typed_array();
1614 bool is_typed_elements() const {
1615 return is_external() || is_fixed_typed_array();
1617 LOperand* elements() { return inputs_[0]; }
1618 LOperand* key() { return inputs_[1]; }
1619 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1620 uint32_t additional_index() const { return hydrogen()->index_offset(); }
1621 ElementsKind elements_kind() const {
1622 return hydrogen()->elements_kind();
1627 class LLoadKeyedGeneric V8_FINAL : public LTemplateInstruction<1, 3, 0> {
1629 LLoadKeyedGeneric(LOperand* context, LOperand* obj, LOperand* key) {
1630 inputs_[0] = context;
1635 DECLARE_CONCRETE_INSTRUCTION(LoadKeyedGeneric, "load-keyed-generic")
1637 LOperand* context() { return inputs_[0]; }
1638 LOperand* object() { return inputs_[1]; }
1639 LOperand* key() { return inputs_[2]; }
1643 class LLoadGlobalCell V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1645 DECLARE_CONCRETE_INSTRUCTION(LoadGlobalCell, "load-global-cell")
1646 DECLARE_HYDROGEN_ACCESSOR(LoadGlobalCell)
1650 class LLoadGlobalGeneric V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1652 explicit LLoadGlobalGeneric(LOperand* context, LOperand* global_object) {
1653 inputs_[0] = context;
1654 inputs_[1] = global_object;
1657 DECLARE_CONCRETE_INSTRUCTION(LoadGlobalGeneric, "load-global-generic")
1658 DECLARE_HYDROGEN_ACCESSOR(LoadGlobalGeneric)
1660 LOperand* context() { return inputs_[0]; }
1661 LOperand* global_object() { return inputs_[1]; }
1662 Handle<Object> name() const { return hydrogen()->name(); }
1663 bool for_typeof() const { return hydrogen()->for_typeof(); }
1667 class LStoreGlobalCell V8_FINAL : public LTemplateInstruction<0, 1, 1> {
1669 explicit LStoreGlobalCell(LOperand* value, LOperand* temp) {
1674 LOperand* value() { return inputs_[0]; }
1675 LOperand* temp() { return temps_[0]; }
1677 DECLARE_CONCRETE_INSTRUCTION(StoreGlobalCell, "store-global-cell")
1678 DECLARE_HYDROGEN_ACCESSOR(StoreGlobalCell)
1682 class LLoadContextSlot V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1684 explicit LLoadContextSlot(LOperand* context) {
1685 inputs_[0] = context;
1688 LOperand* context() { return inputs_[0]; }
1690 DECLARE_CONCRETE_INSTRUCTION(LoadContextSlot, "load-context-slot")
1691 DECLARE_HYDROGEN_ACCESSOR(LoadContextSlot)
1693 int slot_index() { return hydrogen()->slot_index(); }
1695 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1699 class LStoreContextSlot V8_FINAL : public LTemplateInstruction<0, 2, 1> {
1701 LStoreContextSlot(LOperand* context, LOperand* value, LOperand* temp) {
1702 inputs_[0] = context;
1707 LOperand* context() { return inputs_[0]; }
1708 LOperand* value() { return inputs_[1]; }
1709 LOperand* temp() { return temps_[0]; }
1711 DECLARE_CONCRETE_INSTRUCTION(StoreContextSlot, "store-context-slot")
1712 DECLARE_HYDROGEN_ACCESSOR(StoreContextSlot)
1714 int slot_index() { return hydrogen()->slot_index(); }
1716 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1720 class LPushArgument V8_FINAL : public LTemplateInstruction<0, 1, 0> {
1722 explicit LPushArgument(LOperand* value) {
1726 LOperand* value() { return inputs_[0]; }
1728 DECLARE_CONCRETE_INSTRUCTION(PushArgument, "push-argument")
1732 class LDrop V8_FINAL : public LTemplateInstruction<0, 0, 0> {
1734 explicit LDrop(int count) : count_(count) { }
1736 int count() const { return count_; }
1738 DECLARE_CONCRETE_INSTRUCTION(Drop, "drop")
1745 class LStoreCodeEntry V8_FINAL: public LTemplateInstruction<0, 1, 1> {
1747 LStoreCodeEntry(LOperand* function, LOperand* code_object) {
1748 inputs_[0] = function;
1749 temps_[0] = code_object;
1752 LOperand* function() { return inputs_[0]; }
1753 LOperand* code_object() { return temps_[0]; }
1755 virtual void PrintDataTo(StringStream* stream);
1757 DECLARE_CONCRETE_INSTRUCTION(StoreCodeEntry, "store-code-entry")
1758 DECLARE_HYDROGEN_ACCESSOR(StoreCodeEntry)
1762 class LInnerAllocatedObject V8_FINAL: public LTemplateInstruction<1, 2, 0> {
1764 LInnerAllocatedObject(LOperand* base_object, LOperand* offset) {
1765 inputs_[0] = base_object;
1766 inputs_[1] = offset;
1769 LOperand* base_object() const { return inputs_[0]; }
1770 LOperand* offset() const { return inputs_[1]; }
1772 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1774 DECLARE_CONCRETE_INSTRUCTION(InnerAllocatedObject, "inner-allocated-object")
1778 class LThisFunction V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1780 DECLARE_CONCRETE_INSTRUCTION(ThisFunction, "this-function")
1781 DECLARE_HYDROGEN_ACCESSOR(ThisFunction)
1785 class LContext V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1787 DECLARE_CONCRETE_INSTRUCTION(Context, "context")
1788 DECLARE_HYDROGEN_ACCESSOR(Context)
1792 class LDeclareGlobals V8_FINAL : public LTemplateInstruction<0, 1, 0> {
1794 explicit LDeclareGlobals(LOperand* context) {
1795 inputs_[0] = context;
1798 LOperand* context() { return inputs_[0]; }
1800 DECLARE_CONCRETE_INSTRUCTION(DeclareGlobals, "declare-globals")
1801 DECLARE_HYDROGEN_ACCESSOR(DeclareGlobals)
1805 class LCallJSFunction V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1807 explicit LCallJSFunction(LOperand* function) {
1808 inputs_[0] = function;
1811 LOperand* function() { return inputs_[0]; }
1813 DECLARE_CONCRETE_INSTRUCTION(CallJSFunction, "call-js-function")
1814 DECLARE_HYDROGEN_ACCESSOR(CallJSFunction)
1816 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1818 int arity() const { return hydrogen()->argument_count() - 1; }
1822 class LCallWithDescriptor V8_FINAL : public LTemplateResultInstruction<1> {
1824 LCallWithDescriptor(const CallInterfaceDescriptor* descriptor,
1825 ZoneList<LOperand*>& operands,
1827 : inputs_(descriptor->environment_length() + 1, zone) {
1828 ASSERT(descriptor->environment_length() + 1 == operands.length());
1829 inputs_.AddAll(operands, zone);
1832 LOperand* target() const { return inputs_[0]; }
1835 DECLARE_CONCRETE_INSTRUCTION(CallWithDescriptor, "call-with-descriptor")
1836 DECLARE_HYDROGEN_ACCESSOR(CallWithDescriptor)
1838 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1840 int arity() const { return hydrogen()->argument_count() - 1; }
1842 ZoneList<LOperand*> inputs_;
1844 // Iterator support.
1845 virtual int InputCount() V8_FINAL V8_OVERRIDE { return inputs_.length(); }
1846 virtual LOperand* InputAt(int i) V8_FINAL V8_OVERRIDE { return inputs_[i]; }
1848 virtual int TempCount() V8_FINAL V8_OVERRIDE { return 0; }
1849 virtual LOperand* TempAt(int i) V8_FINAL V8_OVERRIDE { return NULL; }
1853 class LInvokeFunction V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1855 LInvokeFunction(LOperand* context, LOperand* function) {
1856 inputs_[0] = context;
1857 inputs_[1] = function;
1860 LOperand* context() { return inputs_[0]; }
1861 LOperand* function() { return inputs_[1]; }
1863 DECLARE_CONCRETE_INSTRUCTION(InvokeFunction, "invoke-function")
1864 DECLARE_HYDROGEN_ACCESSOR(InvokeFunction)
1866 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1868 int arity() const { return hydrogen()->argument_count() - 1; }
1872 class LCallFunction V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1874 LCallFunction(LOperand* context, LOperand* function) {
1875 inputs_[0] = context;
1876 inputs_[1] = function;
1879 DECLARE_CONCRETE_INSTRUCTION(CallFunction, "call-function")
1880 DECLARE_HYDROGEN_ACCESSOR(CallFunction)
1882 LOperand* context() { return inputs_[0]; }
1883 LOperand* function() { return inputs_[1]; }
1884 int arity() const { return hydrogen()->argument_count() - 1; }
1888 class LCallNew V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1890 LCallNew(LOperand* context, LOperand* constructor) {
1891 inputs_[0] = context;
1892 inputs_[1] = constructor;
1895 LOperand* context() { return inputs_[0]; }
1896 LOperand* constructor() { return inputs_[1]; }
1898 DECLARE_CONCRETE_INSTRUCTION(CallNew, "call-new")
1899 DECLARE_HYDROGEN_ACCESSOR(CallNew)
1901 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1903 int arity() const { return hydrogen()->argument_count() - 1; }
1907 class LCallNewArray V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1909 LCallNewArray(LOperand* context, LOperand* constructor) {
1910 inputs_[0] = context;
1911 inputs_[1] = constructor;
1914 LOperand* context() { return inputs_[0]; }
1915 LOperand* constructor() { return inputs_[1]; }
1917 DECLARE_CONCRETE_INSTRUCTION(CallNewArray, "call-new-array")
1918 DECLARE_HYDROGEN_ACCESSOR(CallNewArray)
1920 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1922 int arity() const { return hydrogen()->argument_count() - 1; }
1926 class LCallRuntime V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1928 explicit LCallRuntime(LOperand* context) {
1929 inputs_[0] = context;
1932 LOperand* context() { return inputs_[0]; }
1934 DECLARE_CONCRETE_INSTRUCTION(CallRuntime, "call-runtime")
1935 DECLARE_HYDROGEN_ACCESSOR(CallRuntime)
1937 virtual bool ClobbersDoubleRegisters() const V8_OVERRIDE {
1938 return save_doubles() == kDontSaveFPRegs;
1941 const Runtime::Function* function() const { return hydrogen()->function(); }
1942 int arity() const { return hydrogen()->argument_count(); }
1943 SaveFPRegsMode save_doubles() const { return hydrogen()->save_doubles(); }
1947 class LInteger32ToDouble V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1949 explicit LInteger32ToDouble(LOperand* value) {
1953 LOperand* value() { return inputs_[0]; }
1955 DECLARE_CONCRETE_INSTRUCTION(Integer32ToDouble, "int32-to-double")
1959 class LInteger32ToSmi V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1961 explicit LInteger32ToSmi(LOperand* value) {
1965 LOperand* value() { return inputs_[0]; }
1967 DECLARE_CONCRETE_INSTRUCTION(Integer32ToSmi, "int32-to-smi")
1968 DECLARE_HYDROGEN_ACCESSOR(Change)
1972 class LUint32ToDouble V8_FINAL : public LTemplateInstruction<1, 1, 1> {
1974 explicit LUint32ToDouble(LOperand* value, LOperand* temp) {
1979 LOperand* value() { return inputs_[0]; }
1980 LOperand* temp() { return temps_[0]; }
1982 DECLARE_CONCRETE_INSTRUCTION(Uint32ToDouble, "uint32-to-double")
1986 class LUint32ToSmi V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1988 explicit LUint32ToSmi(LOperand* value) {
1992 LOperand* value() { return inputs_[0]; }
1994 DECLARE_CONCRETE_INSTRUCTION(Uint32ToSmi, "uint32-to-smi")
1995 DECLARE_HYDROGEN_ACCESSOR(Change)
1999 class LNumberTagI V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2001 explicit LNumberTagI(LOperand* value) {
2005 LOperand* value() { return inputs_[0]; }
2007 DECLARE_CONCRETE_INSTRUCTION(NumberTagI, "number-tag-i")
2011 class LNumberTagU V8_FINAL : public LTemplateInstruction<1, 1, 2> {
2013 LNumberTagU(LOperand* value, LOperand* temp1, LOperand* temp2) {
2019 LOperand* value() { return inputs_[0]; }
2020 LOperand* temp1() { return temps_[0]; }
2021 LOperand* temp2() { return temps_[1]; }
2023 DECLARE_CONCRETE_INSTRUCTION(NumberTagU, "number-tag-u")
2027 class LNumberTagD V8_FINAL : public LTemplateInstruction<1, 1, 1> {
2029 explicit LNumberTagD(LOperand* value, LOperand* temp) {
2034 LOperand* value() { return inputs_[0]; }
2035 LOperand* temp() { return temps_[0]; }
2037 DECLARE_CONCRETE_INSTRUCTION(NumberTagD, "number-tag-d")
2038 DECLARE_HYDROGEN_ACCESSOR(Change)
2042 // Sometimes truncating conversion from a tagged value to an int32.
2043 class LDoubleToI V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2045 explicit LDoubleToI(LOperand* value) {
2049 LOperand* value() { return inputs_[0]; }
2051 DECLARE_CONCRETE_INSTRUCTION(DoubleToI, "double-to-i")
2052 DECLARE_HYDROGEN_ACCESSOR(UnaryOperation)
2054 bool truncating() { return hydrogen()->CanTruncateToInt32(); }
2058 class LDoubleToSmi V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2060 explicit LDoubleToSmi(LOperand* value) {
2064 LOperand* value() { return inputs_[0]; }
2066 DECLARE_CONCRETE_INSTRUCTION(DoubleToSmi, "double-to-smi")
2067 DECLARE_HYDROGEN_ACCESSOR(UnaryOperation)
2071 // Truncating conversion from a tagged value to an int32.
2072 class LTaggedToI V8_FINAL : public LTemplateInstruction<1, 1, 1> {
2074 LTaggedToI(LOperand* value, LOperand* temp) {
2079 LOperand* value() { return inputs_[0]; }
2080 LOperand* temp() { return temps_[0]; }
2082 DECLARE_CONCRETE_INSTRUCTION(TaggedToI, "tagged-to-i")
2083 DECLARE_HYDROGEN_ACCESSOR(Change)
2085 bool truncating() { return hydrogen()->CanTruncateToInt32(); }
2089 class LSmiTag V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2091 explicit LSmiTag(LOperand* value) {
2095 LOperand* value() { return inputs_[0]; }
2097 DECLARE_CONCRETE_INSTRUCTION(SmiTag, "smi-tag")
2101 class LNumberUntagD V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2103 explicit LNumberUntagD(LOperand* value) {
2107 LOperand* value() { return inputs_[0]; }
2109 DECLARE_CONCRETE_INSTRUCTION(NumberUntagD, "double-untag")
2110 DECLARE_HYDROGEN_ACCESSOR(Change);
2114 class LSmiUntag V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2116 LSmiUntag(LOperand* value, bool needs_check)
2117 : needs_check_(needs_check) {
2121 LOperand* value() { return inputs_[0]; }
2122 bool needs_check() const { return needs_check_; }
2124 DECLARE_CONCRETE_INSTRUCTION(SmiUntag, "smi-untag")
2131 class LStoreNamedField V8_FINAL : public LTemplateInstruction<0, 2, 1> {
2133 LStoreNamedField(LOperand* object, LOperand* value, LOperand* temp) {
2134 inputs_[0] = object;
2139 LOperand* object() { return inputs_[0]; }
2140 LOperand* value() { return inputs_[1]; }
2141 LOperand* temp() { return temps_[0]; }
2143 DECLARE_CONCRETE_INSTRUCTION(StoreNamedField, "store-named-field")
2144 DECLARE_HYDROGEN_ACCESSOR(StoreNamedField)
2146 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
2148 Handle<Map> transition() const { return hydrogen()->transition_map(); }
2149 Representation representation() const {
2150 return hydrogen()->field_representation();
2155 class LStoreNamedGeneric V8_FINAL : public LTemplateInstruction<0, 3, 0> {
2157 LStoreNamedGeneric(LOperand* context, LOperand* object, LOperand* value) {
2158 inputs_[0] = context;
2159 inputs_[1] = object;
2163 LOperand* context() { return inputs_[0]; }
2164 LOperand* object() { return inputs_[1]; }
2165 LOperand* value() { return inputs_[2]; }
2167 DECLARE_CONCRETE_INSTRUCTION(StoreNamedGeneric, "store-named-generic")
2168 DECLARE_HYDROGEN_ACCESSOR(StoreNamedGeneric)
2170 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
2172 Handle<Object> name() const { return hydrogen()->name(); }
2173 StrictModeFlag strict_mode_flag() { return hydrogen()->strict_mode_flag(); }
2177 class LStoreKeyed V8_FINAL : public LTemplateInstruction<0, 3, 0> {
2179 LStoreKeyed(LOperand* object, LOperand* key, LOperand* value) {
2180 inputs_[0] = object;
2185 bool is_external() const { return hydrogen()->is_external(); }
2186 bool is_fixed_typed_array() const {
2187 return hydrogen()->is_fixed_typed_array();
2189 bool is_typed_elements() const {
2190 return is_external() || is_fixed_typed_array();
2192 LOperand* elements() { return inputs_[0]; }
2193 LOperand* key() { return inputs_[1]; }
2194 LOperand* value() { return inputs_[2]; }
2195 ElementsKind elements_kind() const { return hydrogen()->elements_kind(); }
2197 DECLARE_CONCRETE_INSTRUCTION(StoreKeyed, "store-keyed")
2198 DECLARE_HYDROGEN_ACCESSOR(StoreKeyed)
2200 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
2201 bool NeedsCanonicalization() { return hydrogen()->NeedsCanonicalization(); }
2202 uint32_t additional_index() const { return hydrogen()->index_offset(); }
2206 class LStoreKeyedGeneric V8_FINAL : public LTemplateInstruction<0, 4, 0> {
2208 LStoreKeyedGeneric(LOperand* context,
2212 inputs_[0] = context;
2213 inputs_[1] = object;
2218 LOperand* context() { return inputs_[0]; }
2219 LOperand* object() { return inputs_[1]; }
2220 LOperand* key() { return inputs_[2]; }
2221 LOperand* value() { return inputs_[3]; }
2223 DECLARE_CONCRETE_INSTRUCTION(StoreKeyedGeneric, "store-keyed-generic")
2224 DECLARE_HYDROGEN_ACCESSOR(StoreKeyedGeneric)
2226 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
2228 StrictModeFlag strict_mode_flag() { return hydrogen()->strict_mode_flag(); }
2232 class LTransitionElementsKind V8_FINAL : public LTemplateInstruction<0, 2, 2> {
2234 LTransitionElementsKind(LOperand* object,
2236 LOperand* new_map_temp,
2238 inputs_[0] = object;
2239 inputs_[1] = context;
2240 temps_[0] = new_map_temp;
2244 LOperand* object() { return inputs_[0]; }
2245 LOperand* context() { return inputs_[1]; }
2246 LOperand* new_map_temp() { return temps_[0]; }
2247 LOperand* temp() { return temps_[1]; }
2249 DECLARE_CONCRETE_INSTRUCTION(TransitionElementsKind,
2250 "transition-elements-kind")
2251 DECLARE_HYDROGEN_ACCESSOR(TransitionElementsKind)
2253 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
2255 Handle<Map> original_map() { return hydrogen()->original_map().handle(); }
2256 Handle<Map> transitioned_map() {
2257 return hydrogen()->transitioned_map().handle();
2259 ElementsKind from_kind() { return hydrogen()->from_kind(); }
2260 ElementsKind to_kind() { return hydrogen()->to_kind(); }
2264 class LTrapAllocationMemento V8_FINAL : public LTemplateInstruction<0, 1, 1> {
2266 LTrapAllocationMemento(LOperand* object,
2268 inputs_[0] = object;
2272 LOperand* object() { return inputs_[0]; }
2273 LOperand* temp() { return temps_[0]; }
2275 DECLARE_CONCRETE_INSTRUCTION(TrapAllocationMemento,
2276 "trap-allocation-memento")
2280 class LStringAdd V8_FINAL : public LTemplateInstruction<1, 3, 0> {
2282 LStringAdd(LOperand* context, LOperand* left, LOperand* right) {
2283 inputs_[0] = context;
2288 LOperand* context() { return inputs_[0]; }
2289 LOperand* left() { return inputs_[1]; }
2290 LOperand* right() { return inputs_[2]; }
2292 DECLARE_CONCRETE_INSTRUCTION(StringAdd, "string-add")
2293 DECLARE_HYDROGEN_ACCESSOR(StringAdd)
2297 class LStringCharCodeAt V8_FINAL : public LTemplateInstruction<1, 3, 0> {
2299 LStringCharCodeAt(LOperand* context, LOperand* string, LOperand* index) {
2300 inputs_[0] = context;
2301 inputs_[1] = string;
2305 LOperand* context() { return inputs_[0]; }
2306 LOperand* string() { return inputs_[1]; }
2307 LOperand* index() { return inputs_[2]; }
2309 DECLARE_CONCRETE_INSTRUCTION(StringCharCodeAt, "string-char-code-at")
2310 DECLARE_HYDROGEN_ACCESSOR(StringCharCodeAt)
2314 class LStringCharFromCode V8_FINAL : public LTemplateInstruction<1, 2, 0> {
2316 explicit LStringCharFromCode(LOperand* context, LOperand* char_code) {
2317 inputs_[0] = context;
2318 inputs_[1] = char_code;
2321 LOperand* context() { return inputs_[0]; }
2322 LOperand* char_code() { return inputs_[1]; }
2324 DECLARE_CONCRETE_INSTRUCTION(StringCharFromCode, "string-char-from-code")
2325 DECLARE_HYDROGEN_ACCESSOR(StringCharFromCode)
2329 class LCheckValue V8_FINAL : public LTemplateInstruction<0, 1, 0> {
2331 explicit LCheckValue(LOperand* value) {
2335 LOperand* value() { return inputs_[0]; }
2337 DECLARE_CONCRETE_INSTRUCTION(CheckValue, "check-value")
2338 DECLARE_HYDROGEN_ACCESSOR(CheckValue)
2342 class LCheckInstanceType V8_FINAL : public LTemplateInstruction<0, 1, 0> {
2344 explicit LCheckInstanceType(LOperand* value) {
2348 LOperand* value() { return inputs_[0]; }
2350 DECLARE_CONCRETE_INSTRUCTION(CheckInstanceType, "check-instance-type")
2351 DECLARE_HYDROGEN_ACCESSOR(CheckInstanceType)
2355 class LCheckMaps V8_FINAL : public LTemplateInstruction<0, 1, 0> {
2357 explicit LCheckMaps(LOperand* value) {
2361 LOperand* value() { return inputs_[0]; }
2363 DECLARE_CONCRETE_INSTRUCTION(CheckMaps, "check-maps")
2364 DECLARE_HYDROGEN_ACCESSOR(CheckMaps)
2368 class LCheckSmi V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2370 explicit LCheckSmi(LOperand* value) {
2374 LOperand* value() { return inputs_[0]; }
2376 DECLARE_CONCRETE_INSTRUCTION(CheckSmi, "check-smi")
2380 class LClampDToUint8 V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2382 explicit LClampDToUint8(LOperand* unclamped) {
2383 inputs_[0] = unclamped;
2386 LOperand* unclamped() { return inputs_[0]; }
2388 DECLARE_CONCRETE_INSTRUCTION(ClampDToUint8, "clamp-d-to-uint8")
2392 class LClampIToUint8 V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2394 explicit LClampIToUint8(LOperand* unclamped) {
2395 inputs_[0] = unclamped;
2398 LOperand* unclamped() { return inputs_[0]; }
2400 DECLARE_CONCRETE_INSTRUCTION(ClampIToUint8, "clamp-i-to-uint8")
2404 class LClampTToUint8 V8_FINAL : public LTemplateInstruction<1, 1, 1> {
2406 LClampTToUint8(LOperand* unclamped,
2407 LOperand* temp_xmm) {
2408 inputs_[0] = unclamped;
2409 temps_[0] = temp_xmm;
2412 LOperand* unclamped() { return inputs_[0]; }
2413 LOperand* temp_xmm() { return temps_[0]; }
2415 DECLARE_CONCRETE_INSTRUCTION(ClampTToUint8, "clamp-t-to-uint8")
2419 class LCheckNonSmi V8_FINAL : public LTemplateInstruction<0, 1, 0> {
2421 explicit LCheckNonSmi(LOperand* value) {
2425 LOperand* value() { return inputs_[0]; }
2427 DECLARE_CONCRETE_INSTRUCTION(CheckNonSmi, "check-non-smi")
2428 DECLARE_HYDROGEN_ACCESSOR(CheckHeapObject)
2432 class LDoubleBits V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2434 explicit LDoubleBits(LOperand* value) {
2438 LOperand* value() { return inputs_[0]; }
2440 DECLARE_CONCRETE_INSTRUCTION(DoubleBits, "double-bits")
2441 DECLARE_HYDROGEN_ACCESSOR(DoubleBits)
2445 class LConstructDouble V8_FINAL : public LTemplateInstruction<1, 2, 0> {
2447 LConstructDouble(LOperand* hi, LOperand* lo) {
2452 LOperand* hi() { return inputs_[0]; }
2453 LOperand* lo() { return inputs_[1]; }
2455 DECLARE_CONCRETE_INSTRUCTION(ConstructDouble, "construct-double")
2459 class LAllocate V8_FINAL : public LTemplateInstruction<1, 2, 1> {
2461 LAllocate(LOperand* context, LOperand* size, LOperand* temp) {
2462 inputs_[0] = context;
2467 LOperand* context() { return inputs_[0]; }
2468 LOperand* size() { return inputs_[1]; }
2469 LOperand* temp() { return temps_[0]; }
2471 DECLARE_CONCRETE_INSTRUCTION(Allocate, "allocate")
2472 DECLARE_HYDROGEN_ACCESSOR(Allocate)
2476 class LRegExpLiteral V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2478 explicit LRegExpLiteral(LOperand* context) {
2479 inputs_[0] = context;
2482 LOperand* context() { return inputs_[0]; }
2484 DECLARE_CONCRETE_INSTRUCTION(RegExpLiteral, "regexp-literal")
2485 DECLARE_HYDROGEN_ACCESSOR(RegExpLiteral)
2489 class LFunctionLiteral V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2491 explicit LFunctionLiteral(LOperand* context) {
2492 inputs_[0] = context;
2495 LOperand* context() { return inputs_[0]; }
2497 DECLARE_CONCRETE_INSTRUCTION(FunctionLiteral, "function-literal")
2498 DECLARE_HYDROGEN_ACCESSOR(FunctionLiteral)
2502 class LToFastProperties V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2504 explicit LToFastProperties(LOperand* value) {
2508 LOperand* value() { return inputs_[0]; }
2510 DECLARE_CONCRETE_INSTRUCTION(ToFastProperties, "to-fast-properties")
2511 DECLARE_HYDROGEN_ACCESSOR(ToFastProperties)
2515 class LTypeof V8_FINAL : public LTemplateInstruction<1, 2, 0> {
2517 LTypeof(LOperand* context, LOperand* value) {
2518 inputs_[0] = context;
2522 LOperand* context() { return inputs_[0]; }
2523 LOperand* value() { return inputs_[1]; }
2525 DECLARE_CONCRETE_INSTRUCTION(Typeof, "typeof")
2529 class LTypeofIsAndBranch V8_FINAL : public LControlInstruction<1, 0> {
2531 explicit LTypeofIsAndBranch(LOperand* value) {
2535 LOperand* value() { return inputs_[0]; }
2537 DECLARE_CONCRETE_INSTRUCTION(TypeofIsAndBranch, "typeof-is-and-branch")
2538 DECLARE_HYDROGEN_ACCESSOR(TypeofIsAndBranch)
2540 Handle<String> type_literal() { return hydrogen()->type_literal(); }
2542 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
2546 class LIsConstructCallAndBranch V8_FINAL : public LControlInstruction<0, 1> {
2548 explicit LIsConstructCallAndBranch(LOperand* temp) {
2552 LOperand* temp() { return temps_[0]; }
2554 DECLARE_CONCRETE_INSTRUCTION(IsConstructCallAndBranch,
2555 "is-construct-call-and-branch")
2556 DECLARE_HYDROGEN_ACCESSOR(IsConstructCallAndBranch)
2560 class LOsrEntry V8_FINAL : public LTemplateInstruction<0, 0, 0> {
2564 virtual bool HasInterestingComment(LCodeGen* gen) const V8_OVERRIDE {
2567 DECLARE_CONCRETE_INSTRUCTION(OsrEntry, "osr-entry")
2571 class LStackCheck V8_FINAL : public LTemplateInstruction<0, 1, 0> {
2573 explicit LStackCheck(LOperand* context) {
2574 inputs_[0] = context;
2577 LOperand* context() { return inputs_[0]; }
2579 DECLARE_CONCRETE_INSTRUCTION(StackCheck, "stack-check")
2580 DECLARE_HYDROGEN_ACCESSOR(StackCheck)
2582 Label* done_label() { return &done_label_; }
2589 class LForInPrepareMap V8_FINAL : public LTemplateInstruction<1, 2, 0> {
2591 LForInPrepareMap(LOperand* context, LOperand* object) {
2592 inputs_[0] = context;
2593 inputs_[1] = object;
2596 LOperand* context() { return inputs_[0]; }
2597 LOperand* object() { return inputs_[1]; }
2599 DECLARE_CONCRETE_INSTRUCTION(ForInPrepareMap, "for-in-prepare-map")
2603 class LForInCacheArray V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2605 explicit LForInCacheArray(LOperand* map) {
2609 LOperand* map() { return inputs_[0]; }
2611 DECLARE_CONCRETE_INSTRUCTION(ForInCacheArray, "for-in-cache-array")
2614 return HForInCacheArray::cast(this->hydrogen_value())->idx();
2619 class LCheckMapValue V8_FINAL : public LTemplateInstruction<0, 2, 0> {
2621 LCheckMapValue(LOperand* value, LOperand* map) {
2626 LOperand* value() { return inputs_[0]; }
2627 LOperand* map() { return inputs_[1]; }
2629 DECLARE_CONCRETE_INSTRUCTION(CheckMapValue, "check-map-value")
2633 class LLoadFieldByIndex V8_FINAL : public LTemplateInstruction<1, 2, 0> {
2635 LLoadFieldByIndex(LOperand* object, LOperand* index) {
2636 inputs_[0] = object;
2640 LOperand* object() { return inputs_[0]; }
2641 LOperand* index() { return inputs_[1]; }
2643 DECLARE_CONCRETE_INSTRUCTION(LoadFieldByIndex, "load-field-by-index")
2647 class LChunkBuilder;
2648 class LPlatformChunk V8_FINAL : public LChunk {
2650 LPlatformChunk(CompilationInfo* info, HGraph* graph)
2651 : LChunk(info, graph) { }
2653 int GetNextSpillIndex(RegisterKind kind);
2654 LOperand* GetNextSpillSlot(RegisterKind kind);
2658 class LChunkBuilder V8_FINAL : public LChunkBuilderBase {
2660 LChunkBuilder(CompilationInfo* info, HGraph* graph, LAllocator* allocator)
2661 : LChunkBuilderBase(graph->zone()),
2666 current_instruction_(NULL),
2667 current_block_(NULL),
2669 allocator_(allocator),
2670 instruction_pending_deoptimization_environment_(NULL),
2671 pending_deoptimization_ast_id_(BailoutId::None()) { }
2673 // Build the sequence for the graph.
2674 LPlatformChunk* Build();
2676 LInstruction* CheckElideControlInstruction(HControlInstruction* instr);
2678 // Declare methods that deal with the individual node types.
2679 #define DECLARE_DO(type) LInstruction* Do##type(H##type* node);
2680 HYDROGEN_CONCRETE_INSTRUCTION_LIST(DECLARE_DO)
2683 LInstruction* DoMathFloor(HUnaryMathOperation* instr);
2684 LInstruction* DoMathRound(HUnaryMathOperation* instr);
2685 LInstruction* DoMathAbs(HUnaryMathOperation* instr);
2686 LInstruction* DoMathLog(HUnaryMathOperation* instr);
2687 LInstruction* DoMathExp(HUnaryMathOperation* instr);
2688 LInstruction* DoMathSqrt(HUnaryMathOperation* instr);
2689 LInstruction* DoMathPowHalf(HUnaryMathOperation* instr);
2690 LInstruction* DoMathClz32(HUnaryMathOperation* instr);
2691 LInstruction* DoDivByPowerOf2I(HDiv* instr);
2692 LInstruction* DoDivByConstI(HDiv* instr);
2693 LInstruction* DoDivI(HBinaryOperation* instr);
2694 LInstruction* DoModByPowerOf2I(HMod* instr);
2695 LInstruction* DoModByConstI(HMod* instr);
2696 LInstruction* DoModI(HMod* instr);
2697 LInstruction* DoFlooringDivByPowerOf2I(HMathFloorOfDiv* instr);
2698 LInstruction* DoFlooringDivByConstI(HMathFloorOfDiv* instr);
2708 LPlatformChunk* chunk() const { return chunk_; }
2709 CompilationInfo* info() const { return info_; }
2710 HGraph* graph() const { return graph_; }
2712 bool is_unused() const { return status_ == UNUSED; }
2713 bool is_building() const { return status_ == BUILDING; }
2714 bool is_done() const { return status_ == DONE; }
2715 bool is_aborted() const { return status_ == ABORTED; }
2717 void Abort(BailoutReason reason);
2719 // Methods for getting operands for Use / Define / Temp.
2720 LUnallocated* ToUnallocated(Register reg);
2721 LUnallocated* ToUnallocated(XMMRegister reg);
2723 // Methods for setting up define-use relationships.
2724 MUST_USE_RESULT LOperand* Use(HValue* value, LUnallocated* operand);
2725 MUST_USE_RESULT LOperand* UseFixed(HValue* value, Register fixed_register);
2726 MUST_USE_RESULT LOperand* UseFixedDouble(HValue* value,
2727 XMMRegister fixed_register);
2729 // A value that is guaranteed to be allocated to a register.
2730 // Operand created by UseRegister is guaranteed to be live until the end of
2731 // instruction. This means that register allocator will not reuse it's
2732 // register for any other operand inside instruction.
2733 // Operand created by UseRegisterAtStart is guaranteed to be live only at
2734 // instruction start. Register allocator is free to assign the same register
2735 // to some other operand used inside instruction (i.e. temporary or
2737 MUST_USE_RESULT LOperand* UseRegister(HValue* value);
2738 MUST_USE_RESULT LOperand* UseRegisterAtStart(HValue* value);
2740 // An input operand in a register that may be trashed.
2741 MUST_USE_RESULT LOperand* UseTempRegister(HValue* value);
2743 // An input operand in a register that may be trashed or a constant operand.
2744 MUST_USE_RESULT LOperand* UseTempRegisterOrConstant(HValue* value);
2746 // An input operand in a register or stack slot.
2747 MUST_USE_RESULT LOperand* Use(HValue* value);
2748 MUST_USE_RESULT LOperand* UseAtStart(HValue* value);
2750 // An input operand in a register, stack slot or a constant operand.
2751 MUST_USE_RESULT LOperand* UseOrConstant(HValue* value);
2752 MUST_USE_RESULT LOperand* UseOrConstantAtStart(HValue* value);
2754 // An input operand in a register or a constant operand.
2755 MUST_USE_RESULT LOperand* UseRegisterOrConstant(HValue* value);
2756 MUST_USE_RESULT LOperand* UseRegisterOrConstantAtStart(HValue* value);
2758 // An input operand in a constant operand.
2759 MUST_USE_RESULT LOperand* UseConstant(HValue* value);
2761 // An input operand in register, stack slot or a constant operand.
2762 // Will not be moved to a register even if one is freely available.
2763 virtual MUST_USE_RESULT LOperand* UseAny(HValue* value) V8_OVERRIDE;
2765 // Temporary operand that must be in a register.
2766 MUST_USE_RESULT LUnallocated* TempRegister();
2767 MUST_USE_RESULT LOperand* FixedTemp(Register reg);
2768 MUST_USE_RESULT LOperand* FixedTemp(XMMRegister reg);
2770 // Methods for setting up define-use relationships.
2771 // Return the same instruction that they are passed.
2772 LInstruction* Define(LTemplateResultInstruction<1>* instr,
2773 LUnallocated* result);
2774 LInstruction* DefineAsRegister(LTemplateResultInstruction<1>* instr);
2775 LInstruction* DefineAsSpilled(LTemplateResultInstruction<1>* instr,
2777 LInstruction* DefineSameAsFirst(LTemplateResultInstruction<1>* instr);
2778 LInstruction* DefineFixed(LTemplateResultInstruction<1>* instr,
2780 LInstruction* DefineFixedDouble(LTemplateResultInstruction<1>* instr,
2782 // Assigns an environment to an instruction. An instruction which can
2783 // deoptimize must have an environment.
2784 LInstruction* AssignEnvironment(LInstruction* instr);
2785 // Assigns a pointer map to an instruction. An instruction which can
2786 // trigger a GC or a lazy deoptimization must have a pointer map.
2787 LInstruction* AssignPointerMap(LInstruction* instr);
2789 enum CanDeoptimize { CAN_DEOPTIMIZE_EAGERLY, CANNOT_DEOPTIMIZE_EAGERLY };
2791 // Marks a call for the register allocator. Assigns a pointer map to
2792 // support GC and lazy deoptimization. Assigns an environment to support
2793 // eager deoptimization if CAN_DEOPTIMIZE_EAGERLY.
2794 LInstruction* MarkAsCall(
2795 LInstruction* instr,
2796 HInstruction* hinstr,
2797 CanDeoptimize can_deoptimize = CANNOT_DEOPTIMIZE_EAGERLY);
2799 void VisitInstruction(HInstruction* current);
2801 void DoBasicBlock(HBasicBlock* block, HBasicBlock* next_block);
2802 LInstruction* DoShift(Token::Value op, HBitwiseBinaryOperation* instr);
2803 LInstruction* DoArithmeticD(Token::Value op,
2804 HArithmeticBinaryOperation* instr);
2805 LInstruction* DoArithmeticT(Token::Value op,
2806 HBinaryOperation* instr);
2808 LPlatformChunk* chunk_;
2809 CompilationInfo* info_;
2810 HGraph* const graph_;
2812 HInstruction* current_instruction_;
2813 HBasicBlock* current_block_;
2814 HBasicBlock* next_block_;
2815 LAllocator* allocator_;
2816 LInstruction* instruction_pending_deoptimization_environment_;
2817 BailoutId pending_deoptimization_ast_id_;
2819 DISALLOW_COPY_AND_ASSIGN(LChunkBuilder);
2822 #undef DECLARE_HYDROGEN_ACCESSOR
2823 #undef DECLARE_CONCRETE_INSTRUCTION
2825 } } // namespace v8::int
2827 #endif // V8_X64_LITHIUM_X64_H_