1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef V8_X64_LITHIUM_X64_H_
6 #define V8_X64_LITHIUM_X64_H_
8 #include "src/hydrogen.h"
9 #include "src/lithium-allocator.h"
10 #include "src/lithium.h"
11 #include "src/safepoint-table.h"
12 #include "src/utils.h"
17 // Forward declarations.
20 #define LITHIUM_CONCRETE_INSTRUCTION_LIST(V) \
21 V(AccessArgumentsAt) \
24 V(AllocateBlockContext) \
26 V(ArgumentsElements) \
34 V(CallWithDescriptor) \
40 V(CheckInstanceType) \
49 V(ClassOfTestAndBranch) \
50 V(CompareMinusZeroAndBranch) \
51 V(CompareNumericAndBranch) \
52 V(CmpObjectEqAndBranch) \
76 V(FlooringDivByConstI) \
77 V(FlooringDivByPowerOf2I) \
82 V(GetCachedArrayIndex) \
84 V(HasCachedArrayIndexAndBranch) \
85 V(HasInstanceTypeAndBranch) \
86 V(InnerAllocatedObject) \
88 V(InstanceOfKnownGlobal) \
90 V(Integer32ToDouble) \
92 V(IsConstructCallAndBranch) \
93 V(IsObjectAndBranch) \
94 V(IsStringAndBranch) \
96 V(IsUndetectableAndBranch) \
101 V(LoadFieldByIndex) \
102 V(LoadFunctionPrototype) \
104 V(LoadGlobalGeneric) \
106 V(LoadKeyedGeneric) \
108 V(LoadNamedGeneric) \
133 V(SeqStringGetChar) \
134 V(SeqStringSetChar) \
140 V(StoreContextSlot) \
141 V(StoreFrameContext) \
144 V(StoreKeyedGeneric) \
146 V(StoreNamedGeneric) \
148 V(StringCharCodeAt) \
149 V(StringCharFromCode) \
150 V(StringCompareAndBranch) \
154 V(ToFastProperties) \
155 V(TransitionElementsKind) \
156 V(TrapAllocationMemento) \
158 V(TypeofIsAndBranch) \
164 #define DECLARE_CONCRETE_INSTRUCTION(type, mnemonic) \
165 virtual Opcode opcode() const V8_FINAL V8_OVERRIDE { \
166 return LInstruction::k##type; \
168 virtual void CompileToNative(LCodeGen* generator) V8_FINAL V8_OVERRIDE; \
169 virtual const char* Mnemonic() const V8_FINAL V8_OVERRIDE { \
172 static L##type* cast(LInstruction* instr) { \
173 ASSERT(instr->Is##type()); \
174 return reinterpret_cast<L##type*>(instr); \
178 #define DECLARE_HYDROGEN_ACCESSOR(type) \
179 H##type* hydrogen() const { \
180 return H##type::cast(hydrogen_value()); \
184 class LInstruction : public ZoneObject {
187 : environment_(NULL),
188 hydrogen_value_(NULL),
189 bit_field_(IsCallBits::encode(false)) {
192 virtual ~LInstruction() {}
194 virtual void CompileToNative(LCodeGen* generator) = 0;
195 virtual const char* Mnemonic() const = 0;
196 virtual void PrintTo(StringStream* stream);
197 virtual void PrintDataTo(StringStream* stream);
198 virtual void PrintOutputOperandTo(StringStream* stream);
201 // Declare a unique enum value for each instruction.
202 #define DECLARE_OPCODE(type) k##type,
203 LITHIUM_CONCRETE_INSTRUCTION_LIST(DECLARE_OPCODE)
204 kNumberOfInstructions
205 #undef DECLARE_OPCODE
208 virtual Opcode opcode() const = 0;
210 // Declare non-virtual type testers for all leaf IR classes.
211 #define DECLARE_PREDICATE(type) \
212 bool Is##type() const { return opcode() == k##type; }
213 LITHIUM_CONCRETE_INSTRUCTION_LIST(DECLARE_PREDICATE)
214 #undef DECLARE_PREDICATE
216 // Declare virtual predicates for instructions that don't have
218 virtual bool IsGap() const { return false; }
220 virtual bool IsControl() const { return false; }
222 void set_environment(LEnvironment* env) { environment_ = env; }
223 LEnvironment* environment() const { return environment_; }
224 bool HasEnvironment() const { return environment_ != NULL; }
226 void set_pointer_map(LPointerMap* p) { pointer_map_.set(p); }
227 LPointerMap* pointer_map() const { return pointer_map_.get(); }
228 bool HasPointerMap() const { return pointer_map_.is_set(); }
230 void set_hydrogen_value(HValue* value) { hydrogen_value_ = value; }
231 HValue* hydrogen_value() const { return hydrogen_value_; }
233 void MarkAsCall() { bit_field_ = IsCallBits::update(bit_field_, true); }
234 bool IsCall() const { return IsCallBits::decode(bit_field_); }
236 // Interface to the register allocator and iterators.
237 bool ClobbersTemps() const { return IsCall(); }
238 bool ClobbersRegisters() const { return IsCall(); }
239 virtual bool ClobbersDoubleRegisters(Isolate* isolate) const {
243 virtual void SetDeferredLazyDeoptimizationEnvironment(LEnvironment* env) { }
245 // Interface to the register allocator and iterators.
246 bool IsMarkedAsCall() const { return IsCall(); }
248 virtual bool HasResult() const = 0;
249 virtual LOperand* result() const = 0;
251 LOperand* FirstInput() { return InputAt(0); }
252 LOperand* Output() { return HasResult() ? result() : NULL; }
254 virtual bool HasInterestingComment(LCodeGen* gen) const { return true; }
256 virtual bool MustSignExtendResult(LPlatformChunk* chunk) const {
266 friend class InputIterator;
267 virtual int InputCount() = 0;
268 virtual LOperand* InputAt(int i) = 0;
270 friend class TempIterator;
271 virtual int TempCount() = 0;
272 virtual LOperand* TempAt(int i) = 0;
274 class IsCallBits: public BitField<bool, 0, 1> {};
276 LEnvironment* environment_;
277 SetOncePointer<LPointerMap> pointer_map_;
278 HValue* hydrogen_value_;
283 // R = number of result operands (0 or 1).
285 class LTemplateResultInstruction : public LInstruction {
287 // Allow 0 or 1 output operands.
288 STATIC_ASSERT(R == 0 || R == 1);
289 virtual bool HasResult() const V8_FINAL V8_OVERRIDE {
290 return R != 0 && result() != NULL;
292 void set_result(LOperand* operand) { results_[0] = operand; }
293 LOperand* result() const { return results_[0]; }
295 virtual bool MustSignExtendResult(
296 LPlatformChunk* chunk) const V8_FINAL V8_OVERRIDE;
299 EmbeddedContainer<LOperand*, R> results_;
303 // R = number of result operands (0 or 1).
304 // I = number of input operands.
305 // T = number of temporary operands.
306 template<int R, int I, int T>
307 class LTemplateInstruction : public LTemplateResultInstruction<R> {
309 EmbeddedContainer<LOperand*, I> inputs_;
310 EmbeddedContainer<LOperand*, T> temps_;
314 virtual int InputCount() V8_FINAL V8_OVERRIDE { return I; }
315 virtual LOperand* InputAt(int i) V8_FINAL V8_OVERRIDE { return inputs_[i]; }
317 virtual int TempCount() V8_FINAL V8_OVERRIDE { return T; }
318 virtual LOperand* TempAt(int i) V8_FINAL V8_OVERRIDE { return temps_[i]; }
322 class LGap : public LTemplateInstruction<0, 0, 0> {
324 explicit LGap(HBasicBlock* block)
326 parallel_moves_[BEFORE] = NULL;
327 parallel_moves_[START] = NULL;
328 parallel_moves_[END] = NULL;
329 parallel_moves_[AFTER] = NULL;
332 // Can't use the DECLARE-macro here because of sub-classes.
333 virtual bool IsGap() const V8_FINAL V8_OVERRIDE { return true; }
334 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
335 static LGap* cast(LInstruction* instr) {
336 ASSERT(instr->IsGap());
337 return reinterpret_cast<LGap*>(instr);
340 bool IsRedundant() const;
342 HBasicBlock* block() const { return block_; }
349 FIRST_INNER_POSITION = BEFORE,
350 LAST_INNER_POSITION = AFTER
353 LParallelMove* GetOrCreateParallelMove(InnerPosition pos,
355 if (parallel_moves_[pos] == NULL) {
356 parallel_moves_[pos] = new(zone) LParallelMove(zone);
358 return parallel_moves_[pos];
361 LParallelMove* GetParallelMove(InnerPosition pos) {
362 return parallel_moves_[pos];
366 LParallelMove* parallel_moves_[LAST_INNER_POSITION + 1];
371 class LInstructionGap V8_FINAL : public LGap {
373 explicit LInstructionGap(HBasicBlock* block) : LGap(block) { }
375 virtual bool HasInterestingComment(LCodeGen* gen) const V8_OVERRIDE {
376 return !IsRedundant();
379 DECLARE_CONCRETE_INSTRUCTION(InstructionGap, "gap")
383 class LGoto V8_FINAL : public LTemplateInstruction<0, 0, 0> {
385 explicit LGoto(HBasicBlock* block) : block_(block) { }
387 virtual bool HasInterestingComment(LCodeGen* gen) const V8_OVERRIDE;
388 DECLARE_CONCRETE_INSTRUCTION(Goto, "goto")
389 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
390 virtual bool IsControl() const V8_OVERRIDE { return true; }
392 int block_id() const { return block_->block_id(); }
399 class LLazyBailout V8_FINAL : public LTemplateInstruction<0, 0, 0> {
401 LLazyBailout() : gap_instructions_size_(0) { }
403 DECLARE_CONCRETE_INSTRUCTION(LazyBailout, "lazy-bailout")
405 void set_gap_instructions_size(int gap_instructions_size) {
406 gap_instructions_size_ = gap_instructions_size;
408 int gap_instructions_size() { return gap_instructions_size_; }
411 int gap_instructions_size_;
415 class LDummy V8_FINAL : public LTemplateInstruction<1, 0, 0> {
417 explicit LDummy() { }
418 DECLARE_CONCRETE_INSTRUCTION(Dummy, "dummy")
422 class LDummyUse V8_FINAL : public LTemplateInstruction<1, 1, 0> {
424 explicit LDummyUse(LOperand* value) {
427 DECLARE_CONCRETE_INSTRUCTION(DummyUse, "dummy-use")
431 class LDeoptimize V8_FINAL : public LTemplateInstruction<0, 0, 0> {
433 virtual bool IsControl() const V8_OVERRIDE { return true; }
434 DECLARE_CONCRETE_INSTRUCTION(Deoptimize, "deoptimize")
435 DECLARE_HYDROGEN_ACCESSOR(Deoptimize)
439 class LLabel V8_FINAL : public LGap {
441 explicit LLabel(HBasicBlock* block)
442 : LGap(block), replacement_(NULL) { }
444 virtual bool HasInterestingComment(LCodeGen* gen) const V8_OVERRIDE {
447 DECLARE_CONCRETE_INSTRUCTION(Label, "label")
449 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
451 int block_id() const { return block()->block_id(); }
452 bool is_loop_header() const { return block()->IsLoopHeader(); }
453 bool is_osr_entry() const { return block()->is_osr_entry(); }
454 Label* label() { return &label_; }
455 LLabel* replacement() const { return replacement_; }
456 void set_replacement(LLabel* label) { replacement_ = label; }
457 bool HasReplacement() const { return replacement_ != NULL; }
461 LLabel* replacement_;
465 class LParameter V8_FINAL : public LTemplateInstruction<1, 0, 0> {
467 virtual bool HasInterestingComment(LCodeGen* gen) const V8_OVERRIDE {
470 DECLARE_CONCRETE_INSTRUCTION(Parameter, "parameter")
474 class LCallStub V8_FINAL : public LTemplateInstruction<1, 1, 0> {
476 explicit LCallStub(LOperand* context) {
477 inputs_[0] = context;
480 LOperand* context() { return inputs_[0]; }
482 DECLARE_CONCRETE_INSTRUCTION(CallStub, "call-stub")
483 DECLARE_HYDROGEN_ACCESSOR(CallStub)
487 class LUnknownOSRValue V8_FINAL : public LTemplateInstruction<1, 0, 0> {
489 virtual bool HasInterestingComment(LCodeGen* gen) const V8_OVERRIDE {
492 DECLARE_CONCRETE_INSTRUCTION(UnknownOSRValue, "unknown-osr-value")
496 template<int I, int T>
497 class LControlInstruction : public LTemplateInstruction<0, I, T> {
499 LControlInstruction() : false_label_(NULL), true_label_(NULL) { }
501 virtual bool IsControl() const V8_FINAL V8_OVERRIDE { return true; }
503 int SuccessorCount() { return hydrogen()->SuccessorCount(); }
504 HBasicBlock* SuccessorAt(int i) { return hydrogen()->SuccessorAt(i); }
506 int TrueDestination(LChunk* chunk) {
507 return chunk->LookupDestination(true_block_id());
509 int FalseDestination(LChunk* chunk) {
510 return chunk->LookupDestination(false_block_id());
513 Label* TrueLabel(LChunk* chunk) {
514 if (true_label_ == NULL) {
515 true_label_ = chunk->GetAssemblyLabel(TrueDestination(chunk));
519 Label* FalseLabel(LChunk* chunk) {
520 if (false_label_ == NULL) {
521 false_label_ = chunk->GetAssemblyLabel(FalseDestination(chunk));
527 int true_block_id() { return SuccessorAt(0)->block_id(); }
528 int false_block_id() { return SuccessorAt(1)->block_id(); }
531 HControlInstruction* hydrogen() {
532 return HControlInstruction::cast(this->hydrogen_value());
540 class LWrapReceiver V8_FINAL : public LTemplateInstruction<1, 2, 0> {
542 LWrapReceiver(LOperand* receiver, LOperand* function) {
543 inputs_[0] = receiver;
544 inputs_[1] = function;
547 LOperand* receiver() { return inputs_[0]; }
548 LOperand* function() { return inputs_[1]; }
550 DECLARE_CONCRETE_INSTRUCTION(WrapReceiver, "wrap-receiver")
551 DECLARE_HYDROGEN_ACCESSOR(WrapReceiver)
555 class LApplyArguments V8_FINAL : public LTemplateInstruction<1, 4, 0> {
557 LApplyArguments(LOperand* function,
560 LOperand* elements) {
561 inputs_[0] = function;
562 inputs_[1] = receiver;
564 inputs_[3] = elements;
567 LOperand* function() { return inputs_[0]; }
568 LOperand* receiver() { return inputs_[1]; }
569 LOperand* length() { return inputs_[2]; }
570 LOperand* elements() { return inputs_[3]; }
572 DECLARE_CONCRETE_INSTRUCTION(ApplyArguments, "apply-arguments")
576 class LAccessArgumentsAt V8_FINAL : public LTemplateInstruction<1, 3, 0> {
578 LAccessArgumentsAt(LOperand* arguments, LOperand* length, LOperand* index) {
579 inputs_[0] = arguments;
584 LOperand* arguments() { return inputs_[0]; }
585 LOperand* length() { return inputs_[1]; }
586 LOperand* index() { return inputs_[2]; }
588 DECLARE_CONCRETE_INSTRUCTION(AccessArgumentsAt, "access-arguments-at")
590 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
594 class LArgumentsLength V8_FINAL : public LTemplateInstruction<1, 1, 0> {
596 explicit LArgumentsLength(LOperand* elements) {
597 inputs_[0] = elements;
600 LOperand* elements() { return inputs_[0]; }
602 DECLARE_CONCRETE_INSTRUCTION(ArgumentsLength, "arguments-length")
606 class LArgumentsElements V8_FINAL : public LTemplateInstruction<1, 0, 0> {
608 DECLARE_CONCRETE_INSTRUCTION(ArgumentsElements, "arguments-elements")
609 DECLARE_HYDROGEN_ACCESSOR(ArgumentsElements)
613 class LModByPowerOf2I V8_FINAL : public LTemplateInstruction<1, 1, 0> {
615 LModByPowerOf2I(LOperand* dividend, int32_t divisor) {
616 inputs_[0] = dividend;
620 LOperand* dividend() { return inputs_[0]; }
621 int32_t divisor() const { return divisor_; }
623 DECLARE_CONCRETE_INSTRUCTION(ModByPowerOf2I, "mod-by-power-of-2-i")
624 DECLARE_HYDROGEN_ACCESSOR(Mod)
631 class LModByConstI V8_FINAL : public LTemplateInstruction<1, 1, 2> {
633 LModByConstI(LOperand* dividend,
637 inputs_[0] = dividend;
643 LOperand* dividend() { return inputs_[0]; }
644 int32_t divisor() const { return divisor_; }
645 LOperand* temp1() { return temps_[0]; }
646 LOperand* temp2() { return temps_[1]; }
648 DECLARE_CONCRETE_INSTRUCTION(ModByConstI, "mod-by-const-i")
649 DECLARE_HYDROGEN_ACCESSOR(Mod)
656 class LModI V8_FINAL : public LTemplateInstruction<1, 2, 1> {
658 LModI(LOperand* left, LOperand* right, LOperand* temp) {
664 LOperand* left() { return inputs_[0]; }
665 LOperand* right() { return inputs_[1]; }
666 LOperand* temp() { return temps_[0]; }
668 DECLARE_CONCRETE_INSTRUCTION(ModI, "mod-i")
669 DECLARE_HYDROGEN_ACCESSOR(Mod)
673 class LDivByPowerOf2I V8_FINAL : public LTemplateInstruction<1, 1, 0> {
675 LDivByPowerOf2I(LOperand* dividend, int32_t divisor) {
676 inputs_[0] = dividend;
680 LOperand* dividend() { return inputs_[0]; }
681 int32_t divisor() const { return divisor_; }
683 DECLARE_CONCRETE_INSTRUCTION(DivByPowerOf2I, "div-by-power-of-2-i")
684 DECLARE_HYDROGEN_ACCESSOR(Div)
691 class LDivByConstI V8_FINAL : public LTemplateInstruction<1, 1, 2> {
693 LDivByConstI(LOperand* dividend,
697 inputs_[0] = dividend;
703 LOperand* dividend() { return inputs_[0]; }
704 int32_t divisor() const { return divisor_; }
705 LOperand* temp1() { return temps_[0]; }
706 LOperand* temp2() { return temps_[1]; }
708 DECLARE_CONCRETE_INSTRUCTION(DivByConstI, "div-by-const-i")
709 DECLARE_HYDROGEN_ACCESSOR(Div)
716 class LDivI V8_FINAL : public LTemplateInstruction<1, 2, 1> {
718 LDivI(LOperand* dividend, LOperand* divisor, LOperand* temp) {
719 inputs_[0] = dividend;
720 inputs_[1] = divisor;
724 LOperand* dividend() { return inputs_[0]; }
725 LOperand* divisor() { return inputs_[1]; }
726 LOperand* temp() { return temps_[0]; }
728 DECLARE_CONCRETE_INSTRUCTION(DivI, "div-i")
729 DECLARE_HYDROGEN_ACCESSOR(BinaryOperation)
733 class LFlooringDivByPowerOf2I V8_FINAL : public LTemplateInstruction<1, 1, 0> {
735 LFlooringDivByPowerOf2I(LOperand* dividend, int32_t divisor) {
736 inputs_[0] = dividend;
740 LOperand* dividend() { return inputs_[0]; }
741 int32_t divisor() const { return divisor_; }
743 DECLARE_CONCRETE_INSTRUCTION(FlooringDivByPowerOf2I,
744 "flooring-div-by-power-of-2-i")
745 DECLARE_HYDROGEN_ACCESSOR(MathFloorOfDiv)
752 class LFlooringDivByConstI V8_FINAL : public LTemplateInstruction<1, 1, 3> {
754 LFlooringDivByConstI(LOperand* dividend,
759 inputs_[0] = dividend;
766 LOperand* dividend() { return inputs_[0]; }
767 int32_t divisor() const { return divisor_; }
768 LOperand* temp1() { return temps_[0]; }
769 LOperand* temp2() { return temps_[1]; }
770 LOperand* temp3() { return temps_[2]; }
772 DECLARE_CONCRETE_INSTRUCTION(FlooringDivByConstI, "flooring-div-by-const-i")
773 DECLARE_HYDROGEN_ACCESSOR(MathFloorOfDiv)
780 class LFlooringDivI V8_FINAL : public LTemplateInstruction<1, 2, 1> {
782 LFlooringDivI(LOperand* dividend, LOperand* divisor, LOperand* temp) {
783 inputs_[0] = dividend;
784 inputs_[1] = divisor;
788 LOperand* dividend() { return inputs_[0]; }
789 LOperand* divisor() { return inputs_[1]; }
790 LOperand* temp() { return temps_[0]; }
792 DECLARE_CONCRETE_INSTRUCTION(FlooringDivI, "flooring-div-i")
793 DECLARE_HYDROGEN_ACCESSOR(MathFloorOfDiv)
797 class LMulI V8_FINAL : public LTemplateInstruction<1, 2, 0> {
799 LMulI(LOperand* left, LOperand* right) {
804 LOperand* left() { return inputs_[0]; }
805 LOperand* right() { return inputs_[1]; }
807 DECLARE_CONCRETE_INSTRUCTION(MulI, "mul-i")
808 DECLARE_HYDROGEN_ACCESSOR(Mul)
812 class LCompareNumericAndBranch V8_FINAL : public LControlInstruction<2, 0> {
814 LCompareNumericAndBranch(LOperand* left, LOperand* right) {
819 LOperand* left() { return inputs_[0]; }
820 LOperand* right() { return inputs_[1]; }
822 DECLARE_CONCRETE_INSTRUCTION(CompareNumericAndBranch,
823 "compare-numeric-and-branch")
824 DECLARE_HYDROGEN_ACCESSOR(CompareNumericAndBranch)
826 Token::Value op() const { return hydrogen()->token(); }
827 bool is_double() const {
828 return hydrogen()->representation().IsDouble();
831 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
835 class LMathFloor V8_FINAL : public LTemplateInstruction<1, 1, 0> {
837 explicit LMathFloor(LOperand* value) {
841 LOperand* value() { return inputs_[0]; }
843 DECLARE_CONCRETE_INSTRUCTION(MathFloor, "math-floor")
844 DECLARE_HYDROGEN_ACCESSOR(UnaryMathOperation)
848 class LMathRound V8_FINAL : public LTemplateInstruction<1, 1, 1> {
850 explicit LMathRound(LOperand* value, LOperand* temp) {
855 LOperand* value() { return inputs_[0]; }
856 LOperand* temp() { return temps_[0]; }
858 DECLARE_CONCRETE_INSTRUCTION(MathRound, "math-round")
859 DECLARE_HYDROGEN_ACCESSOR(UnaryMathOperation)
863 class LMathAbs V8_FINAL : public LTemplateInstruction<1, 2, 0> {
865 explicit LMathAbs(LOperand* context, LOperand* value) {
866 inputs_[1] = context;
870 LOperand* context() { return inputs_[1]; }
871 LOperand* value() { return inputs_[0]; }
873 DECLARE_CONCRETE_INSTRUCTION(MathAbs, "math-abs")
874 DECLARE_HYDROGEN_ACCESSOR(UnaryMathOperation)
878 class LMathLog V8_FINAL : public LTemplateInstruction<1, 1, 0> {
880 explicit LMathLog(LOperand* value) {
884 LOperand* value() { return inputs_[0]; }
886 DECLARE_CONCRETE_INSTRUCTION(MathLog, "math-log")
890 class LMathClz32 V8_FINAL : public LTemplateInstruction<1, 1, 0> {
892 explicit LMathClz32(LOperand* value) {
896 LOperand* value() { return inputs_[0]; }
898 DECLARE_CONCRETE_INSTRUCTION(MathClz32, "math-clz32")
902 class LMathExp V8_FINAL : public LTemplateInstruction<1, 1, 2> {
904 LMathExp(LOperand* value, LOperand* temp1, LOperand* temp2) {
908 ExternalReference::InitializeMathExpData();
911 LOperand* value() { return inputs_[0]; }
912 LOperand* temp1() { return temps_[0]; }
913 LOperand* temp2() { return temps_[1]; }
915 DECLARE_CONCRETE_INSTRUCTION(MathExp, "math-exp")
919 class LMathSqrt V8_FINAL : public LTemplateInstruction<1, 1, 0> {
921 explicit LMathSqrt(LOperand* value) {
925 LOperand* value() { return inputs_[0]; }
927 DECLARE_CONCRETE_INSTRUCTION(MathSqrt, "math-sqrt")
931 class LMathPowHalf V8_FINAL : public LTemplateInstruction<1, 1, 0> {
933 explicit LMathPowHalf(LOperand* value) {
937 LOperand* value() { return inputs_[0]; }
939 DECLARE_CONCRETE_INSTRUCTION(MathPowHalf, "math-pow-half")
943 class LCmpObjectEqAndBranch V8_FINAL : public LControlInstruction<2, 0> {
945 LCmpObjectEqAndBranch(LOperand* left, LOperand* right) {
950 LOperand* left() { return inputs_[0]; }
951 LOperand* right() { return inputs_[1]; }
953 DECLARE_CONCRETE_INSTRUCTION(CmpObjectEqAndBranch, "cmp-object-eq-and-branch")
957 class LCmpHoleAndBranch V8_FINAL : public LControlInstruction<1, 0> {
959 explicit LCmpHoleAndBranch(LOperand* object) {
963 LOperand* object() { return inputs_[0]; }
965 DECLARE_CONCRETE_INSTRUCTION(CmpHoleAndBranch, "cmp-hole-and-branch")
966 DECLARE_HYDROGEN_ACCESSOR(CompareHoleAndBranch)
970 class LCompareMinusZeroAndBranch V8_FINAL : public LControlInstruction<1, 0> {
972 explicit LCompareMinusZeroAndBranch(LOperand* value) {
976 LOperand* value() { return inputs_[0]; }
978 DECLARE_CONCRETE_INSTRUCTION(CompareMinusZeroAndBranch,
979 "cmp-minus-zero-and-branch")
980 DECLARE_HYDROGEN_ACCESSOR(CompareMinusZeroAndBranch)
985 class LIsObjectAndBranch V8_FINAL : public LControlInstruction<1, 0> {
987 explicit LIsObjectAndBranch(LOperand* value) {
991 LOperand* value() { return inputs_[0]; }
993 DECLARE_CONCRETE_INSTRUCTION(IsObjectAndBranch, "is-object-and-branch")
994 DECLARE_HYDROGEN_ACCESSOR(IsObjectAndBranch)
996 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1000 class LIsStringAndBranch V8_FINAL : public LControlInstruction<1, 1> {
1002 explicit LIsStringAndBranch(LOperand* value, LOperand* temp) {
1007 LOperand* value() { return inputs_[0]; }
1008 LOperand* temp() { return temps_[0]; }
1010 DECLARE_CONCRETE_INSTRUCTION(IsStringAndBranch, "is-string-and-branch")
1011 DECLARE_HYDROGEN_ACCESSOR(IsStringAndBranch)
1013 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1017 class LIsSmiAndBranch V8_FINAL : public LControlInstruction<1, 0> {
1019 explicit LIsSmiAndBranch(LOperand* value) {
1023 LOperand* value() { return inputs_[0]; }
1025 DECLARE_CONCRETE_INSTRUCTION(IsSmiAndBranch, "is-smi-and-branch")
1026 DECLARE_HYDROGEN_ACCESSOR(IsSmiAndBranch)
1028 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1032 class LIsUndetectableAndBranch V8_FINAL : public LControlInstruction<1, 1> {
1034 explicit LIsUndetectableAndBranch(LOperand* value, LOperand* temp) {
1039 LOperand* value() { return inputs_[0]; }
1040 LOperand* temp() { return temps_[0]; }
1042 DECLARE_CONCRETE_INSTRUCTION(IsUndetectableAndBranch,
1043 "is-undetectable-and-branch")
1044 DECLARE_HYDROGEN_ACCESSOR(IsUndetectableAndBranch)
1046 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1050 class LStringCompareAndBranch V8_FINAL : public LControlInstruction<3, 0> {
1052 explicit LStringCompareAndBranch(LOperand* context,
1055 inputs_[0] = context;
1060 LOperand* context() { return inputs_[0]; }
1061 LOperand* left() { return inputs_[1]; }
1062 LOperand* right() { return inputs_[2]; }
1064 DECLARE_CONCRETE_INSTRUCTION(StringCompareAndBranch,
1065 "string-compare-and-branch")
1066 DECLARE_HYDROGEN_ACCESSOR(StringCompareAndBranch)
1068 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1070 Token::Value op() const { return hydrogen()->token(); }
1074 class LHasInstanceTypeAndBranch V8_FINAL : public LControlInstruction<1, 0> {
1076 explicit LHasInstanceTypeAndBranch(LOperand* value) {
1080 LOperand* value() { return inputs_[0]; }
1082 DECLARE_CONCRETE_INSTRUCTION(HasInstanceTypeAndBranch,
1083 "has-instance-type-and-branch")
1084 DECLARE_HYDROGEN_ACCESSOR(HasInstanceTypeAndBranch)
1086 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1090 class LGetCachedArrayIndex V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1092 explicit LGetCachedArrayIndex(LOperand* value) {
1096 LOperand* value() { return inputs_[0]; }
1098 DECLARE_CONCRETE_INSTRUCTION(GetCachedArrayIndex, "get-cached-array-index")
1099 DECLARE_HYDROGEN_ACCESSOR(GetCachedArrayIndex)
1103 class LHasCachedArrayIndexAndBranch V8_FINAL
1104 : public LControlInstruction<1, 0> {
1106 explicit LHasCachedArrayIndexAndBranch(LOperand* value) {
1110 LOperand* value() { return inputs_[0]; }
1112 DECLARE_CONCRETE_INSTRUCTION(HasCachedArrayIndexAndBranch,
1113 "has-cached-array-index-and-branch")
1114 DECLARE_HYDROGEN_ACCESSOR(HasCachedArrayIndexAndBranch)
1116 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1120 class LClassOfTestAndBranch V8_FINAL : public LControlInstruction<1, 2> {
1122 LClassOfTestAndBranch(LOperand* value, LOperand* temp, LOperand* temp2) {
1128 LOperand* value() { return inputs_[0]; }
1129 LOperand* temp() { return temps_[0]; }
1130 LOperand* temp2() { return temps_[1]; }
1132 DECLARE_CONCRETE_INSTRUCTION(ClassOfTestAndBranch,
1133 "class-of-test-and-branch")
1134 DECLARE_HYDROGEN_ACCESSOR(ClassOfTestAndBranch)
1136 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1140 class LCmpT V8_FINAL : public LTemplateInstruction<1, 3, 0> {
1142 LCmpT(LOperand* context, LOperand* left, LOperand* right) {
1143 inputs_[0] = context;
1148 LOperand* context() { return inputs_[0]; }
1149 LOperand* left() { return inputs_[1]; }
1150 LOperand* right() { return inputs_[2]; }
1152 DECLARE_CONCRETE_INSTRUCTION(CmpT, "cmp-t")
1153 DECLARE_HYDROGEN_ACCESSOR(CompareGeneric)
1155 Token::Value op() const { return hydrogen()->token(); }
1159 class LInstanceOf V8_FINAL : public LTemplateInstruction<1, 3, 0> {
1161 LInstanceOf(LOperand* context, LOperand* left, LOperand* right) {
1162 inputs_[0] = context;
1167 LOperand* context() { return inputs_[0]; }
1168 LOperand* left() { return inputs_[1]; }
1169 LOperand* right() { return inputs_[2]; }
1171 DECLARE_CONCRETE_INSTRUCTION(InstanceOf, "instance-of")
1175 class LInstanceOfKnownGlobal V8_FINAL : public LTemplateInstruction<1, 2, 1> {
1177 LInstanceOfKnownGlobal(LOperand* context, LOperand* value, LOperand* temp) {
1178 inputs_[0] = context;
1183 LOperand* context() { return inputs_[0]; }
1184 LOperand* value() { return inputs_[1]; }
1185 LOperand* temp() { return temps_[0]; }
1187 DECLARE_CONCRETE_INSTRUCTION(InstanceOfKnownGlobal,
1188 "instance-of-known-global")
1189 DECLARE_HYDROGEN_ACCESSOR(InstanceOfKnownGlobal)
1191 Handle<JSFunction> function() const { return hydrogen()->function(); }
1192 LEnvironment* GetDeferredLazyDeoptimizationEnvironment() {
1193 return lazy_deopt_env_;
1195 virtual void SetDeferredLazyDeoptimizationEnvironment(
1196 LEnvironment* env) V8_OVERRIDE {
1197 lazy_deopt_env_ = env;
1201 LEnvironment* lazy_deopt_env_;
1205 class LBoundsCheck V8_FINAL : public LTemplateInstruction<0, 2, 0> {
1207 LBoundsCheck(LOperand* index, LOperand* length) {
1209 inputs_[1] = length;
1212 LOperand* index() { return inputs_[0]; }
1213 LOperand* length() { return inputs_[1]; }
1215 DECLARE_CONCRETE_INSTRUCTION(BoundsCheck, "bounds-check")
1216 DECLARE_HYDROGEN_ACCESSOR(BoundsCheck)
1220 class LBitI V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1222 LBitI(LOperand* left, LOperand* right) {
1227 LOperand* left() { return inputs_[0]; }
1228 LOperand* right() { return inputs_[1]; }
1230 Token::Value op() const { return hydrogen()->op(); }
1231 bool IsInteger32() const {
1232 return hydrogen()->representation().IsInteger32();
1235 DECLARE_CONCRETE_INSTRUCTION(BitI, "bit-i")
1236 DECLARE_HYDROGEN_ACCESSOR(Bitwise)
1240 class LShiftI V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1242 LShiftI(Token::Value op, LOperand* left, LOperand* right, bool can_deopt)
1243 : op_(op), can_deopt_(can_deopt) {
1248 Token::Value op() const { return op_; }
1249 LOperand* left() { return inputs_[0]; }
1250 LOperand* right() { return inputs_[1]; }
1251 bool can_deopt() const { return can_deopt_; }
1253 DECLARE_CONCRETE_INSTRUCTION(ShiftI, "shift-i")
1261 class LSubI V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1263 LSubI(LOperand* left, LOperand* right) {
1268 LOperand* left() { return inputs_[0]; }
1269 LOperand* right() { return inputs_[1]; }
1271 DECLARE_CONCRETE_INSTRUCTION(SubI, "sub-i")
1272 DECLARE_HYDROGEN_ACCESSOR(Sub)
1276 class LConstantI V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1278 DECLARE_CONCRETE_INSTRUCTION(ConstantI, "constant-i")
1279 DECLARE_HYDROGEN_ACCESSOR(Constant)
1281 int32_t value() const { return hydrogen()->Integer32Value(); }
1285 class LConstantS V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1287 DECLARE_CONCRETE_INSTRUCTION(ConstantS, "constant-s")
1288 DECLARE_HYDROGEN_ACCESSOR(Constant)
1290 Smi* value() const { return Smi::FromInt(hydrogen()->Integer32Value()); }
1294 class LConstantD V8_FINAL : public LTemplateInstruction<1, 0, 1> {
1296 explicit LConstantD(LOperand* temp) {
1300 LOperand* temp() { return temps_[0]; }
1302 DECLARE_CONCRETE_INSTRUCTION(ConstantD, "constant-d")
1303 DECLARE_HYDROGEN_ACCESSOR(Constant)
1305 double value() const { return hydrogen()->DoubleValue(); }
1309 class LConstantE V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1311 DECLARE_CONCRETE_INSTRUCTION(ConstantE, "constant-e")
1312 DECLARE_HYDROGEN_ACCESSOR(Constant)
1314 ExternalReference value() const {
1315 return hydrogen()->ExternalReferenceValue();
1320 class LConstantT V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1322 DECLARE_CONCRETE_INSTRUCTION(ConstantT, "constant-t")
1323 DECLARE_HYDROGEN_ACCESSOR(Constant)
1325 Handle<Object> value(Isolate* isolate) const {
1326 return hydrogen()->handle(isolate);
1331 class LBranch V8_FINAL : public LControlInstruction<1, 0> {
1333 explicit LBranch(LOperand* value) {
1337 LOperand* value() { return inputs_[0]; }
1339 DECLARE_CONCRETE_INSTRUCTION(Branch, "branch")
1340 DECLARE_HYDROGEN_ACCESSOR(Branch)
1342 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1346 class LDebugBreak V8_FINAL : public LTemplateInstruction<0, 0, 0> {
1348 DECLARE_CONCRETE_INSTRUCTION(DebugBreak, "break")
1352 class LCmpMapAndBranch V8_FINAL : public LControlInstruction<1, 0> {
1354 explicit LCmpMapAndBranch(LOperand* value) {
1358 LOperand* value() { return inputs_[0]; }
1360 DECLARE_CONCRETE_INSTRUCTION(CmpMapAndBranch, "cmp-map-and-branch")
1361 DECLARE_HYDROGEN_ACCESSOR(CompareMap)
1363 Handle<Map> map() const { return hydrogen()->map().handle(); }
1367 class LMapEnumLength V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1369 explicit LMapEnumLength(LOperand* value) {
1373 LOperand* value() { return inputs_[0]; }
1375 DECLARE_CONCRETE_INSTRUCTION(MapEnumLength, "map-enum-length")
1379 class LDateField V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1381 LDateField(LOperand* date, Smi* index) : index_(index) {
1385 LOperand* date() { return inputs_[0]; }
1386 Smi* index() const { return index_; }
1388 DECLARE_CONCRETE_INSTRUCTION(DateField, "date-field")
1389 DECLARE_HYDROGEN_ACCESSOR(DateField)
1396 class LSeqStringGetChar V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1398 LSeqStringGetChar(LOperand* string, LOperand* index) {
1399 inputs_[0] = string;
1403 LOperand* string() const { return inputs_[0]; }
1404 LOperand* index() const { return inputs_[1]; }
1406 DECLARE_CONCRETE_INSTRUCTION(SeqStringGetChar, "seq-string-get-char")
1407 DECLARE_HYDROGEN_ACCESSOR(SeqStringGetChar)
1411 class LSeqStringSetChar V8_FINAL : public LTemplateInstruction<1, 4, 0> {
1413 LSeqStringSetChar(LOperand* context,
1417 inputs_[0] = context;
1418 inputs_[1] = string;
1423 LOperand* string() { return inputs_[1]; }
1424 LOperand* index() { return inputs_[2]; }
1425 LOperand* value() { return inputs_[3]; }
1427 DECLARE_CONCRETE_INSTRUCTION(SeqStringSetChar, "seq-string-set-char")
1428 DECLARE_HYDROGEN_ACCESSOR(SeqStringSetChar)
1432 class LAddI V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1434 LAddI(LOperand* left, LOperand* right) {
1439 LOperand* left() { return inputs_[0]; }
1440 LOperand* right() { return inputs_[1]; }
1442 static bool UseLea(HAdd* add) {
1443 return !add->CheckFlag(HValue::kCanOverflow) &&
1444 add->BetterLeftOperand()->UseCount() > 1;
1447 DECLARE_CONCRETE_INSTRUCTION(AddI, "add-i")
1448 DECLARE_HYDROGEN_ACCESSOR(Add)
1452 class LMathMinMax V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1454 LMathMinMax(LOperand* left, LOperand* right) {
1459 LOperand* left() { return inputs_[0]; }
1460 LOperand* right() { return inputs_[1]; }
1462 DECLARE_CONCRETE_INSTRUCTION(MathMinMax, "math-min-max")
1463 DECLARE_HYDROGEN_ACCESSOR(MathMinMax)
1467 class LPower V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1469 LPower(LOperand* left, LOperand* right) {
1474 LOperand* left() { return inputs_[0]; }
1475 LOperand* right() { return inputs_[1]; }
1477 DECLARE_CONCRETE_INSTRUCTION(Power, "power")
1478 DECLARE_HYDROGEN_ACCESSOR(Power)
1482 class LArithmeticD V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1484 LArithmeticD(Token::Value op, LOperand* left, LOperand* right)
1490 Token::Value op() const { return op_; }
1491 LOperand* left() { return inputs_[0]; }
1492 LOperand* right() { return inputs_[1]; }
1494 virtual Opcode opcode() const V8_OVERRIDE {
1495 return LInstruction::kArithmeticD;
1497 virtual void CompileToNative(LCodeGen* generator) V8_OVERRIDE;
1498 virtual const char* Mnemonic() const V8_OVERRIDE;
1505 class LArithmeticT V8_FINAL : public LTemplateInstruction<1, 3, 0> {
1507 LArithmeticT(Token::Value op,
1512 inputs_[0] = context;
1517 Token::Value op() const { return op_; }
1518 LOperand* context() { return inputs_[0]; }
1519 LOperand* left() { return inputs_[1]; }
1520 LOperand* right() { return inputs_[2]; }
1522 virtual Opcode opcode() const V8_OVERRIDE {
1523 return LInstruction::kArithmeticT;
1525 virtual void CompileToNative(LCodeGen* generator) V8_OVERRIDE;
1526 virtual const char* Mnemonic() const V8_OVERRIDE;
1533 class LReturn V8_FINAL : public LTemplateInstruction<0, 3, 0> {
1535 explicit LReturn(LOperand* value,
1537 LOperand* parameter_count) {
1539 inputs_[1] = context;
1540 inputs_[2] = parameter_count;
1543 LOperand* value() { return inputs_[0]; }
1544 LOperand* context() { return inputs_[1]; }
1546 bool has_constant_parameter_count() {
1547 return parameter_count()->IsConstantOperand();
1549 LConstantOperand* constant_parameter_count() {
1550 ASSERT(has_constant_parameter_count());
1551 return LConstantOperand::cast(parameter_count());
1553 LOperand* parameter_count() { return inputs_[2]; }
1555 DECLARE_CONCRETE_INSTRUCTION(Return, "return")
1556 DECLARE_HYDROGEN_ACCESSOR(Return)
1560 class LLoadNamedField V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1562 explicit LLoadNamedField(LOperand* object) {
1563 inputs_[0] = object;
1566 LOperand* object() { return inputs_[0]; }
1568 DECLARE_CONCRETE_INSTRUCTION(LoadNamedField, "load-named-field")
1569 DECLARE_HYDROGEN_ACCESSOR(LoadNamedField)
1573 class LLoadNamedGeneric V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1575 explicit LLoadNamedGeneric(LOperand* context, LOperand* object) {
1576 inputs_[0] = context;
1577 inputs_[1] = object;
1580 DECLARE_CONCRETE_INSTRUCTION(LoadNamedGeneric, "load-named-generic")
1581 DECLARE_HYDROGEN_ACCESSOR(LoadNamedGeneric)
1583 LOperand* context() { return inputs_[0]; }
1584 LOperand* object() { return inputs_[1]; }
1585 Handle<Object> name() const { return hydrogen()->name(); }
1589 class LLoadFunctionPrototype V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1591 explicit LLoadFunctionPrototype(LOperand* function) {
1592 inputs_[0] = function;
1595 DECLARE_CONCRETE_INSTRUCTION(LoadFunctionPrototype, "load-function-prototype")
1596 DECLARE_HYDROGEN_ACCESSOR(LoadFunctionPrototype)
1598 LOperand* function() { return inputs_[0]; }
1602 class LLoadRoot V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1604 DECLARE_CONCRETE_INSTRUCTION(LoadRoot, "load-root")
1605 DECLARE_HYDROGEN_ACCESSOR(LoadRoot)
1607 Heap::RootListIndex index() const { return hydrogen()->index(); }
1611 class LLoadKeyed V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1613 LLoadKeyed(LOperand* elements, LOperand* key) {
1614 inputs_[0] = elements;
1618 DECLARE_CONCRETE_INSTRUCTION(LoadKeyed, "load-keyed")
1619 DECLARE_HYDROGEN_ACCESSOR(LoadKeyed)
1621 bool is_external() const {
1622 return hydrogen()->is_external();
1624 bool is_fixed_typed_array() const {
1625 return hydrogen()->is_fixed_typed_array();
1627 bool is_typed_elements() const {
1628 return is_external() || is_fixed_typed_array();
1630 LOperand* elements() { return inputs_[0]; }
1631 LOperand* key() { return inputs_[1]; }
1632 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1633 uint32_t base_offset() const { return hydrogen()->base_offset(); }
1634 ElementsKind elements_kind() const {
1635 return hydrogen()->elements_kind();
1640 class LLoadKeyedGeneric V8_FINAL : public LTemplateInstruction<1, 3, 0> {
1642 LLoadKeyedGeneric(LOperand* context, LOperand* obj, LOperand* key) {
1643 inputs_[0] = context;
1648 DECLARE_CONCRETE_INSTRUCTION(LoadKeyedGeneric, "load-keyed-generic")
1650 LOperand* context() { return inputs_[0]; }
1651 LOperand* object() { return inputs_[1]; }
1652 LOperand* key() { return inputs_[2]; }
1656 class LLoadGlobalCell V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1658 DECLARE_CONCRETE_INSTRUCTION(LoadGlobalCell, "load-global-cell")
1659 DECLARE_HYDROGEN_ACCESSOR(LoadGlobalCell)
1663 class LLoadGlobalGeneric V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1665 explicit LLoadGlobalGeneric(LOperand* context, LOperand* global_object) {
1666 inputs_[0] = context;
1667 inputs_[1] = global_object;
1670 DECLARE_CONCRETE_INSTRUCTION(LoadGlobalGeneric, "load-global-generic")
1671 DECLARE_HYDROGEN_ACCESSOR(LoadGlobalGeneric)
1673 LOperand* context() { return inputs_[0]; }
1674 LOperand* global_object() { return inputs_[1]; }
1675 Handle<Object> name() const { return hydrogen()->name(); }
1676 bool for_typeof() const { return hydrogen()->for_typeof(); }
1680 class LStoreGlobalCell V8_FINAL : public LTemplateInstruction<0, 1, 1> {
1682 explicit LStoreGlobalCell(LOperand* value, LOperand* temp) {
1687 LOperand* value() { return inputs_[0]; }
1688 LOperand* temp() { return temps_[0]; }
1690 DECLARE_CONCRETE_INSTRUCTION(StoreGlobalCell, "store-global-cell")
1691 DECLARE_HYDROGEN_ACCESSOR(StoreGlobalCell)
1695 class LLoadContextSlot V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1697 explicit LLoadContextSlot(LOperand* context) {
1698 inputs_[0] = context;
1701 LOperand* context() { return inputs_[0]; }
1703 DECLARE_CONCRETE_INSTRUCTION(LoadContextSlot, "load-context-slot")
1704 DECLARE_HYDROGEN_ACCESSOR(LoadContextSlot)
1706 int slot_index() { return hydrogen()->slot_index(); }
1708 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1712 class LStoreContextSlot V8_FINAL : public LTemplateInstruction<0, 2, 1> {
1714 LStoreContextSlot(LOperand* context, LOperand* value, LOperand* temp) {
1715 inputs_[0] = context;
1720 LOperand* context() { return inputs_[0]; }
1721 LOperand* value() { return inputs_[1]; }
1722 LOperand* temp() { return temps_[0]; }
1724 DECLARE_CONCRETE_INSTRUCTION(StoreContextSlot, "store-context-slot")
1725 DECLARE_HYDROGEN_ACCESSOR(StoreContextSlot)
1727 int slot_index() { return hydrogen()->slot_index(); }
1729 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1733 class LPushArgument V8_FINAL : public LTemplateInstruction<0, 1, 0> {
1735 explicit LPushArgument(LOperand* value) {
1739 LOperand* value() { return inputs_[0]; }
1741 DECLARE_CONCRETE_INSTRUCTION(PushArgument, "push-argument")
1745 class LDrop V8_FINAL : public LTemplateInstruction<0, 0, 0> {
1747 explicit LDrop(int count) : count_(count) { }
1749 int count() const { return count_; }
1751 DECLARE_CONCRETE_INSTRUCTION(Drop, "drop")
1758 class LStoreCodeEntry V8_FINAL: public LTemplateInstruction<0, 1, 1> {
1760 LStoreCodeEntry(LOperand* function, LOperand* code_object) {
1761 inputs_[0] = function;
1762 temps_[0] = code_object;
1765 LOperand* function() { return inputs_[0]; }
1766 LOperand* code_object() { return temps_[0]; }
1768 virtual void PrintDataTo(StringStream* stream);
1770 DECLARE_CONCRETE_INSTRUCTION(StoreCodeEntry, "store-code-entry")
1771 DECLARE_HYDROGEN_ACCESSOR(StoreCodeEntry)
1775 class LInnerAllocatedObject V8_FINAL: public LTemplateInstruction<1, 2, 0> {
1777 LInnerAllocatedObject(LOperand* base_object, LOperand* offset) {
1778 inputs_[0] = base_object;
1779 inputs_[1] = offset;
1782 LOperand* base_object() const { return inputs_[0]; }
1783 LOperand* offset() const { return inputs_[1]; }
1785 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1787 DECLARE_CONCRETE_INSTRUCTION(InnerAllocatedObject, "inner-allocated-object")
1791 class LThisFunction V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1793 DECLARE_CONCRETE_INSTRUCTION(ThisFunction, "this-function")
1794 DECLARE_HYDROGEN_ACCESSOR(ThisFunction)
1798 class LContext V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1800 DECLARE_CONCRETE_INSTRUCTION(Context, "context")
1801 DECLARE_HYDROGEN_ACCESSOR(Context)
1805 class LDeclareGlobals V8_FINAL : public LTemplateInstruction<0, 1, 0> {
1807 explicit LDeclareGlobals(LOperand* context) {
1808 inputs_[0] = context;
1811 LOperand* context() { return inputs_[0]; }
1813 DECLARE_CONCRETE_INSTRUCTION(DeclareGlobals, "declare-globals")
1814 DECLARE_HYDROGEN_ACCESSOR(DeclareGlobals)
1818 class LCallJSFunction V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1820 explicit LCallJSFunction(LOperand* function) {
1821 inputs_[0] = function;
1824 LOperand* function() { return inputs_[0]; }
1826 DECLARE_CONCRETE_INSTRUCTION(CallJSFunction, "call-js-function")
1827 DECLARE_HYDROGEN_ACCESSOR(CallJSFunction)
1829 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1831 int arity() const { return hydrogen()->argument_count() - 1; }
1835 class LCallWithDescriptor V8_FINAL : public LTemplateResultInstruction<1> {
1837 LCallWithDescriptor(const CallInterfaceDescriptor* descriptor,
1838 const ZoneList<LOperand*>& operands,
1840 : inputs_(descriptor->environment_length() + 1, zone) {
1841 ASSERT(descriptor->environment_length() + 1 == operands.length());
1842 inputs_.AddAll(operands, zone);
1845 LOperand* target() const { return inputs_[0]; }
1848 DECLARE_CONCRETE_INSTRUCTION(CallWithDescriptor, "call-with-descriptor")
1849 DECLARE_HYDROGEN_ACCESSOR(CallWithDescriptor)
1851 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1853 int arity() const { return hydrogen()->argument_count() - 1; }
1855 ZoneList<LOperand*> inputs_;
1857 // Iterator support.
1858 virtual int InputCount() V8_FINAL V8_OVERRIDE { return inputs_.length(); }
1859 virtual LOperand* InputAt(int i) V8_FINAL V8_OVERRIDE { return inputs_[i]; }
1861 virtual int TempCount() V8_FINAL V8_OVERRIDE { return 0; }
1862 virtual LOperand* TempAt(int i) V8_FINAL V8_OVERRIDE { return NULL; }
1866 class LInvokeFunction V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1868 LInvokeFunction(LOperand* context, LOperand* function) {
1869 inputs_[0] = context;
1870 inputs_[1] = function;
1873 LOperand* context() { return inputs_[0]; }
1874 LOperand* function() { return inputs_[1]; }
1876 DECLARE_CONCRETE_INSTRUCTION(InvokeFunction, "invoke-function")
1877 DECLARE_HYDROGEN_ACCESSOR(InvokeFunction)
1879 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1881 int arity() const { return hydrogen()->argument_count() - 1; }
1885 class LCallFunction V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1887 LCallFunction(LOperand* context, LOperand* function) {
1888 inputs_[0] = context;
1889 inputs_[1] = function;
1892 DECLARE_CONCRETE_INSTRUCTION(CallFunction, "call-function")
1893 DECLARE_HYDROGEN_ACCESSOR(CallFunction)
1895 LOperand* context() { return inputs_[0]; }
1896 LOperand* function() { return inputs_[1]; }
1897 int arity() const { return hydrogen()->argument_count() - 1; }
1901 class LCallNew V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1903 LCallNew(LOperand* context, LOperand* constructor) {
1904 inputs_[0] = context;
1905 inputs_[1] = constructor;
1908 LOperand* context() { return inputs_[0]; }
1909 LOperand* constructor() { return inputs_[1]; }
1911 DECLARE_CONCRETE_INSTRUCTION(CallNew, "call-new")
1912 DECLARE_HYDROGEN_ACCESSOR(CallNew)
1914 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1916 int arity() const { return hydrogen()->argument_count() - 1; }
1920 class LCallNewArray V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1922 LCallNewArray(LOperand* context, LOperand* constructor) {
1923 inputs_[0] = context;
1924 inputs_[1] = constructor;
1927 LOperand* context() { return inputs_[0]; }
1928 LOperand* constructor() { return inputs_[1]; }
1930 DECLARE_CONCRETE_INSTRUCTION(CallNewArray, "call-new-array")
1931 DECLARE_HYDROGEN_ACCESSOR(CallNewArray)
1933 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1935 int arity() const { return hydrogen()->argument_count() - 1; }
1939 class LCallRuntime V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1941 explicit LCallRuntime(LOperand* context) {
1942 inputs_[0] = context;
1945 LOperand* context() { return inputs_[0]; }
1947 DECLARE_CONCRETE_INSTRUCTION(CallRuntime, "call-runtime")
1948 DECLARE_HYDROGEN_ACCESSOR(CallRuntime)
1950 virtual bool ClobbersDoubleRegisters(Isolate* isolate) const V8_OVERRIDE {
1951 return save_doubles() == kDontSaveFPRegs;
1954 const Runtime::Function* function() const { return hydrogen()->function(); }
1955 int arity() const { return hydrogen()->argument_count(); }
1956 SaveFPRegsMode save_doubles() const { return hydrogen()->save_doubles(); }
1960 class LInteger32ToDouble V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1962 explicit LInteger32ToDouble(LOperand* value) {
1966 LOperand* value() { return inputs_[0]; }
1968 DECLARE_CONCRETE_INSTRUCTION(Integer32ToDouble, "int32-to-double")
1972 class LUint32ToDouble V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1974 explicit LUint32ToDouble(LOperand* value) {
1978 LOperand* value() { return inputs_[0]; }
1980 DECLARE_CONCRETE_INSTRUCTION(Uint32ToDouble, "uint32-to-double")
1984 class LNumberTagI V8_FINAL : public LTemplateInstruction<1, 1, 2> {
1986 LNumberTagI(LOperand* value, LOperand* temp1, LOperand* temp2) {
1992 LOperand* value() { return inputs_[0]; }
1993 LOperand* temp1() { return temps_[0]; }
1994 LOperand* temp2() { return temps_[1]; }
1996 DECLARE_CONCRETE_INSTRUCTION(NumberTagI, "number-tag-i")
2000 class LNumberTagU V8_FINAL : public LTemplateInstruction<1, 1, 2> {
2002 LNumberTagU(LOperand* value, LOperand* temp1, LOperand* temp2) {
2008 LOperand* value() { return inputs_[0]; }
2009 LOperand* temp1() { return temps_[0]; }
2010 LOperand* temp2() { return temps_[1]; }
2012 DECLARE_CONCRETE_INSTRUCTION(NumberTagU, "number-tag-u")
2016 class LNumberTagD V8_FINAL : public LTemplateInstruction<1, 1, 1> {
2018 explicit LNumberTagD(LOperand* value, LOperand* temp) {
2023 LOperand* value() { return inputs_[0]; }
2024 LOperand* temp() { return temps_[0]; }
2026 DECLARE_CONCRETE_INSTRUCTION(NumberTagD, "number-tag-d")
2027 DECLARE_HYDROGEN_ACCESSOR(Change)
2031 // Sometimes truncating conversion from a tagged value to an int32.
2032 class LDoubleToI V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2034 explicit LDoubleToI(LOperand* value) {
2038 LOperand* value() { return inputs_[0]; }
2040 DECLARE_CONCRETE_INSTRUCTION(DoubleToI, "double-to-i")
2041 DECLARE_HYDROGEN_ACCESSOR(UnaryOperation)
2043 bool truncating() { return hydrogen()->CanTruncateToInt32(); }
2047 class LDoubleToSmi V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2049 explicit LDoubleToSmi(LOperand* value) {
2053 LOperand* value() { return inputs_[0]; }
2055 DECLARE_CONCRETE_INSTRUCTION(DoubleToSmi, "double-to-smi")
2056 DECLARE_HYDROGEN_ACCESSOR(UnaryOperation)
2060 // Truncating conversion from a tagged value to an int32.
2061 class LTaggedToI V8_FINAL : public LTemplateInstruction<1, 1, 1> {
2063 LTaggedToI(LOperand* value, LOperand* temp) {
2068 LOperand* value() { return inputs_[0]; }
2069 LOperand* temp() { return temps_[0]; }
2071 DECLARE_CONCRETE_INSTRUCTION(TaggedToI, "tagged-to-i")
2072 DECLARE_HYDROGEN_ACCESSOR(Change)
2074 bool truncating() { return hydrogen()->CanTruncateToInt32(); }
2078 class LSmiTag V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2080 explicit LSmiTag(LOperand* value) {
2084 LOperand* value() { return inputs_[0]; }
2086 DECLARE_CONCRETE_INSTRUCTION(SmiTag, "smi-tag")
2087 DECLARE_HYDROGEN_ACCESSOR(Change)
2091 class LNumberUntagD V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2093 explicit LNumberUntagD(LOperand* value) {
2097 LOperand* value() { return inputs_[0]; }
2099 DECLARE_CONCRETE_INSTRUCTION(NumberUntagD, "double-untag")
2100 DECLARE_HYDROGEN_ACCESSOR(Change);
2104 class LSmiUntag V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2106 LSmiUntag(LOperand* value, bool needs_check)
2107 : needs_check_(needs_check) {
2111 LOperand* value() { return inputs_[0]; }
2112 bool needs_check() const { return needs_check_; }
2114 DECLARE_CONCRETE_INSTRUCTION(SmiUntag, "smi-untag")
2121 class LStoreNamedField V8_FINAL : public LTemplateInstruction<0, 2, 1> {
2123 LStoreNamedField(LOperand* object, LOperand* value, LOperand* temp) {
2124 inputs_[0] = object;
2129 LOperand* object() { return inputs_[0]; }
2130 LOperand* value() { return inputs_[1]; }
2131 LOperand* temp() { return temps_[0]; }
2133 DECLARE_CONCRETE_INSTRUCTION(StoreNamedField, "store-named-field")
2134 DECLARE_HYDROGEN_ACCESSOR(StoreNamedField)
2136 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
2138 Representation representation() const {
2139 return hydrogen()->field_representation();
2144 class LStoreNamedGeneric V8_FINAL : public LTemplateInstruction<0, 3, 0> {
2146 LStoreNamedGeneric(LOperand* context, LOperand* object, LOperand* value) {
2147 inputs_[0] = context;
2148 inputs_[1] = object;
2152 LOperand* context() { return inputs_[0]; }
2153 LOperand* object() { return inputs_[1]; }
2154 LOperand* value() { return inputs_[2]; }
2156 DECLARE_CONCRETE_INSTRUCTION(StoreNamedGeneric, "store-named-generic")
2157 DECLARE_HYDROGEN_ACCESSOR(StoreNamedGeneric)
2159 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
2161 Handle<Object> name() const { return hydrogen()->name(); }
2162 StrictMode strict_mode() { return hydrogen()->strict_mode(); }
2166 class LStoreKeyed V8_FINAL : public LTemplateInstruction<0, 3, 0> {
2168 LStoreKeyed(LOperand* object, LOperand* key, LOperand* value) {
2169 inputs_[0] = object;
2174 bool is_external() const { return hydrogen()->is_external(); }
2175 bool is_fixed_typed_array() const {
2176 return hydrogen()->is_fixed_typed_array();
2178 bool is_typed_elements() const {
2179 return is_external() || is_fixed_typed_array();
2181 LOperand* elements() { return inputs_[0]; }
2182 LOperand* key() { return inputs_[1]; }
2183 LOperand* value() { return inputs_[2]; }
2184 ElementsKind elements_kind() const { return hydrogen()->elements_kind(); }
2186 DECLARE_CONCRETE_INSTRUCTION(StoreKeyed, "store-keyed")
2187 DECLARE_HYDROGEN_ACCESSOR(StoreKeyed)
2189 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
2190 bool NeedsCanonicalization() { return hydrogen()->NeedsCanonicalization(); }
2191 uint32_t base_offset() const { return hydrogen()->base_offset(); }
2195 class LStoreKeyedGeneric V8_FINAL : public LTemplateInstruction<0, 4, 0> {
2197 LStoreKeyedGeneric(LOperand* context,
2201 inputs_[0] = context;
2202 inputs_[1] = object;
2207 LOperand* context() { return inputs_[0]; }
2208 LOperand* object() { return inputs_[1]; }
2209 LOperand* key() { return inputs_[2]; }
2210 LOperand* value() { return inputs_[3]; }
2212 DECLARE_CONCRETE_INSTRUCTION(StoreKeyedGeneric, "store-keyed-generic")
2213 DECLARE_HYDROGEN_ACCESSOR(StoreKeyedGeneric)
2215 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
2217 StrictMode strict_mode() { return hydrogen()->strict_mode(); }
2221 class LTransitionElementsKind V8_FINAL : public LTemplateInstruction<0, 2, 2> {
2223 LTransitionElementsKind(LOperand* object,
2225 LOperand* new_map_temp,
2227 inputs_[0] = object;
2228 inputs_[1] = context;
2229 temps_[0] = new_map_temp;
2233 LOperand* object() { return inputs_[0]; }
2234 LOperand* context() { return inputs_[1]; }
2235 LOperand* new_map_temp() { return temps_[0]; }
2236 LOperand* temp() { return temps_[1]; }
2238 DECLARE_CONCRETE_INSTRUCTION(TransitionElementsKind,
2239 "transition-elements-kind")
2240 DECLARE_HYDROGEN_ACCESSOR(TransitionElementsKind)
2242 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
2244 Handle<Map> original_map() { return hydrogen()->original_map().handle(); }
2245 Handle<Map> transitioned_map() {
2246 return hydrogen()->transitioned_map().handle();
2248 ElementsKind from_kind() { return hydrogen()->from_kind(); }
2249 ElementsKind to_kind() { return hydrogen()->to_kind(); }
2253 class LTrapAllocationMemento V8_FINAL : public LTemplateInstruction<0, 1, 1> {
2255 LTrapAllocationMemento(LOperand* object,
2257 inputs_[0] = object;
2261 LOperand* object() { return inputs_[0]; }
2262 LOperand* temp() { return temps_[0]; }
2264 DECLARE_CONCRETE_INSTRUCTION(TrapAllocationMemento,
2265 "trap-allocation-memento")
2269 class LStringAdd V8_FINAL : public LTemplateInstruction<1, 3, 0> {
2271 LStringAdd(LOperand* context, LOperand* left, LOperand* right) {
2272 inputs_[0] = context;
2277 LOperand* context() { return inputs_[0]; }
2278 LOperand* left() { return inputs_[1]; }
2279 LOperand* right() { return inputs_[2]; }
2281 DECLARE_CONCRETE_INSTRUCTION(StringAdd, "string-add")
2282 DECLARE_HYDROGEN_ACCESSOR(StringAdd)
2286 class LStringCharCodeAt V8_FINAL : public LTemplateInstruction<1, 3, 0> {
2288 LStringCharCodeAt(LOperand* context, LOperand* string, LOperand* index) {
2289 inputs_[0] = context;
2290 inputs_[1] = string;
2294 LOperand* context() { return inputs_[0]; }
2295 LOperand* string() { return inputs_[1]; }
2296 LOperand* index() { return inputs_[2]; }
2298 DECLARE_CONCRETE_INSTRUCTION(StringCharCodeAt, "string-char-code-at")
2299 DECLARE_HYDROGEN_ACCESSOR(StringCharCodeAt)
2303 class LStringCharFromCode V8_FINAL : public LTemplateInstruction<1, 2, 0> {
2305 explicit LStringCharFromCode(LOperand* context, LOperand* char_code) {
2306 inputs_[0] = context;
2307 inputs_[1] = char_code;
2310 LOperand* context() { return inputs_[0]; }
2311 LOperand* char_code() { return inputs_[1]; }
2313 DECLARE_CONCRETE_INSTRUCTION(StringCharFromCode, "string-char-from-code")
2314 DECLARE_HYDROGEN_ACCESSOR(StringCharFromCode)
2318 class LCheckValue V8_FINAL : public LTemplateInstruction<0, 1, 0> {
2320 explicit LCheckValue(LOperand* value) {
2324 LOperand* value() { return inputs_[0]; }
2326 DECLARE_CONCRETE_INSTRUCTION(CheckValue, "check-value")
2327 DECLARE_HYDROGEN_ACCESSOR(CheckValue)
2331 class LCheckInstanceType V8_FINAL : public LTemplateInstruction<0, 1, 0> {
2333 explicit LCheckInstanceType(LOperand* value) {
2337 LOperand* value() { return inputs_[0]; }
2339 DECLARE_CONCRETE_INSTRUCTION(CheckInstanceType, "check-instance-type")
2340 DECLARE_HYDROGEN_ACCESSOR(CheckInstanceType)
2344 class LCheckMaps V8_FINAL : public LTemplateInstruction<0, 1, 0> {
2346 explicit LCheckMaps(LOperand* value = NULL) {
2350 LOperand* value() { return inputs_[0]; }
2352 DECLARE_CONCRETE_INSTRUCTION(CheckMaps, "check-maps")
2353 DECLARE_HYDROGEN_ACCESSOR(CheckMaps)
2357 class LCheckSmi V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2359 explicit LCheckSmi(LOperand* value) {
2363 LOperand* value() { return inputs_[0]; }
2365 DECLARE_CONCRETE_INSTRUCTION(CheckSmi, "check-smi")
2369 class LClampDToUint8 V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2371 explicit LClampDToUint8(LOperand* unclamped) {
2372 inputs_[0] = unclamped;
2375 LOperand* unclamped() { return inputs_[0]; }
2377 DECLARE_CONCRETE_INSTRUCTION(ClampDToUint8, "clamp-d-to-uint8")
2381 class LClampIToUint8 V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2383 explicit LClampIToUint8(LOperand* unclamped) {
2384 inputs_[0] = unclamped;
2387 LOperand* unclamped() { return inputs_[0]; }
2389 DECLARE_CONCRETE_INSTRUCTION(ClampIToUint8, "clamp-i-to-uint8")
2393 class LClampTToUint8 V8_FINAL : public LTemplateInstruction<1, 1, 1> {
2395 LClampTToUint8(LOperand* unclamped,
2396 LOperand* temp_xmm) {
2397 inputs_[0] = unclamped;
2398 temps_[0] = temp_xmm;
2401 LOperand* unclamped() { return inputs_[0]; }
2402 LOperand* temp_xmm() { return temps_[0]; }
2404 DECLARE_CONCRETE_INSTRUCTION(ClampTToUint8, "clamp-t-to-uint8")
2408 class LCheckNonSmi V8_FINAL : public LTemplateInstruction<0, 1, 0> {
2410 explicit LCheckNonSmi(LOperand* value) {
2414 LOperand* value() { return inputs_[0]; }
2416 DECLARE_CONCRETE_INSTRUCTION(CheckNonSmi, "check-non-smi")
2417 DECLARE_HYDROGEN_ACCESSOR(CheckHeapObject)
2421 class LDoubleBits V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2423 explicit LDoubleBits(LOperand* value) {
2427 LOperand* value() { return inputs_[0]; }
2429 DECLARE_CONCRETE_INSTRUCTION(DoubleBits, "double-bits")
2430 DECLARE_HYDROGEN_ACCESSOR(DoubleBits)
2434 class LConstructDouble V8_FINAL : public LTemplateInstruction<1, 2, 0> {
2436 LConstructDouble(LOperand* hi, LOperand* lo) {
2441 LOperand* hi() { return inputs_[0]; }
2442 LOperand* lo() { return inputs_[1]; }
2444 DECLARE_CONCRETE_INSTRUCTION(ConstructDouble, "construct-double")
2448 class LAllocate V8_FINAL : public LTemplateInstruction<1, 2, 1> {
2450 LAllocate(LOperand* context, LOperand* size, LOperand* temp) {
2451 inputs_[0] = context;
2456 LOperand* context() { return inputs_[0]; }
2457 LOperand* size() { return inputs_[1]; }
2458 LOperand* temp() { return temps_[0]; }
2460 DECLARE_CONCRETE_INSTRUCTION(Allocate, "allocate")
2461 DECLARE_HYDROGEN_ACCESSOR(Allocate)
2465 class LRegExpLiteral V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2467 explicit LRegExpLiteral(LOperand* context) {
2468 inputs_[0] = context;
2471 LOperand* context() { return inputs_[0]; }
2473 DECLARE_CONCRETE_INSTRUCTION(RegExpLiteral, "regexp-literal")
2474 DECLARE_HYDROGEN_ACCESSOR(RegExpLiteral)
2478 class LFunctionLiteral V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2480 explicit LFunctionLiteral(LOperand* context) {
2481 inputs_[0] = context;
2484 LOperand* context() { return inputs_[0]; }
2486 DECLARE_CONCRETE_INSTRUCTION(FunctionLiteral, "function-literal")
2487 DECLARE_HYDROGEN_ACCESSOR(FunctionLiteral)
2491 class LToFastProperties V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2493 explicit LToFastProperties(LOperand* value) {
2497 LOperand* value() { return inputs_[0]; }
2499 DECLARE_CONCRETE_INSTRUCTION(ToFastProperties, "to-fast-properties")
2500 DECLARE_HYDROGEN_ACCESSOR(ToFastProperties)
2504 class LTypeof V8_FINAL : public LTemplateInstruction<1, 2, 0> {
2506 LTypeof(LOperand* context, LOperand* value) {
2507 inputs_[0] = context;
2511 LOperand* context() { return inputs_[0]; }
2512 LOperand* value() { return inputs_[1]; }
2514 DECLARE_CONCRETE_INSTRUCTION(Typeof, "typeof")
2518 class LTypeofIsAndBranch V8_FINAL : public LControlInstruction<1, 0> {
2520 explicit LTypeofIsAndBranch(LOperand* value) {
2524 LOperand* value() { return inputs_[0]; }
2526 DECLARE_CONCRETE_INSTRUCTION(TypeofIsAndBranch, "typeof-is-and-branch")
2527 DECLARE_HYDROGEN_ACCESSOR(TypeofIsAndBranch)
2529 Handle<String> type_literal() { return hydrogen()->type_literal(); }
2531 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
2535 class LIsConstructCallAndBranch V8_FINAL : public LControlInstruction<0, 1> {
2537 explicit LIsConstructCallAndBranch(LOperand* temp) {
2541 LOperand* temp() { return temps_[0]; }
2543 DECLARE_CONCRETE_INSTRUCTION(IsConstructCallAndBranch,
2544 "is-construct-call-and-branch")
2545 DECLARE_HYDROGEN_ACCESSOR(IsConstructCallAndBranch)
2549 class LOsrEntry V8_FINAL : public LTemplateInstruction<0, 0, 0> {
2553 virtual bool HasInterestingComment(LCodeGen* gen) const V8_OVERRIDE {
2556 DECLARE_CONCRETE_INSTRUCTION(OsrEntry, "osr-entry")
2560 class LStackCheck V8_FINAL : public LTemplateInstruction<0, 1, 0> {
2562 explicit LStackCheck(LOperand* context) {
2563 inputs_[0] = context;
2566 LOperand* context() { return inputs_[0]; }
2568 DECLARE_CONCRETE_INSTRUCTION(StackCheck, "stack-check")
2569 DECLARE_HYDROGEN_ACCESSOR(StackCheck)
2571 Label* done_label() { return &done_label_; }
2578 class LForInPrepareMap V8_FINAL : public LTemplateInstruction<1, 2, 0> {
2580 LForInPrepareMap(LOperand* context, LOperand* object) {
2581 inputs_[0] = context;
2582 inputs_[1] = object;
2585 LOperand* context() { return inputs_[0]; }
2586 LOperand* object() { return inputs_[1]; }
2588 DECLARE_CONCRETE_INSTRUCTION(ForInPrepareMap, "for-in-prepare-map")
2592 class LForInCacheArray V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2594 explicit LForInCacheArray(LOperand* map) {
2598 LOperand* map() { return inputs_[0]; }
2600 DECLARE_CONCRETE_INSTRUCTION(ForInCacheArray, "for-in-cache-array")
2603 return HForInCacheArray::cast(this->hydrogen_value())->idx();
2608 class LCheckMapValue V8_FINAL : public LTemplateInstruction<0, 2, 0> {
2610 LCheckMapValue(LOperand* value, LOperand* map) {
2615 LOperand* value() { return inputs_[0]; }
2616 LOperand* map() { return inputs_[1]; }
2618 DECLARE_CONCRETE_INSTRUCTION(CheckMapValue, "check-map-value")
2622 class LLoadFieldByIndex V8_FINAL : public LTemplateInstruction<1, 2, 0> {
2624 LLoadFieldByIndex(LOperand* object, LOperand* index) {
2625 inputs_[0] = object;
2629 LOperand* object() { return inputs_[0]; }
2630 LOperand* index() { return inputs_[1]; }
2632 DECLARE_CONCRETE_INSTRUCTION(LoadFieldByIndex, "load-field-by-index")
2636 class LStoreFrameContext: public LTemplateInstruction<0, 1, 0> {
2638 explicit LStoreFrameContext(LOperand* context) {
2639 inputs_[0] = context;
2642 LOperand* context() { return inputs_[0]; }
2644 DECLARE_CONCRETE_INSTRUCTION(StoreFrameContext, "store-frame-context")
2648 class LAllocateBlockContext: public LTemplateInstruction<1, 2, 0> {
2650 LAllocateBlockContext(LOperand* context, LOperand* function) {
2651 inputs_[0] = context;
2652 inputs_[1] = function;
2655 LOperand* context() { return inputs_[0]; }
2656 LOperand* function() { return inputs_[1]; }
2658 Handle<ScopeInfo> scope_info() { return hydrogen()->scope_info(); }
2660 DECLARE_CONCRETE_INSTRUCTION(AllocateBlockContext, "allocate-block-context")
2661 DECLARE_HYDROGEN_ACCESSOR(AllocateBlockContext)
2665 class LChunkBuilder;
2666 class LPlatformChunk V8_FINAL : public LChunk {
2668 LPlatformChunk(CompilationInfo* info, HGraph* graph)
2669 : LChunk(info, graph),
2670 dehoisted_key_ids_(graph->GetMaximumValueID(), graph->zone()) { }
2672 int GetNextSpillIndex(RegisterKind kind);
2673 LOperand* GetNextSpillSlot(RegisterKind kind);
2674 BitVector* GetDehoistedKeyIds() { return &dehoisted_key_ids_; }
2675 bool IsDehoistedKey(HValue* value) {
2676 return dehoisted_key_ids_.Contains(value->id());
2680 BitVector dehoisted_key_ids_;
2684 class LChunkBuilder V8_FINAL : public LChunkBuilderBase {
2686 LChunkBuilder(CompilationInfo* info, HGraph* graph, LAllocator* allocator)
2687 : LChunkBuilderBase(graph->zone()),
2692 current_instruction_(NULL),
2693 current_block_(NULL),
2695 allocator_(allocator) { }
2697 Isolate* isolate() const { return graph_->isolate(); }
2699 // Build the sequence for the graph.
2700 LPlatformChunk* Build();
2702 // Declare methods that deal with the individual node types.
2703 #define DECLARE_DO(type) LInstruction* Do##type(H##type* node);
2704 HYDROGEN_CONCRETE_INSTRUCTION_LIST(DECLARE_DO)
2707 LInstruction* DoMathFloor(HUnaryMathOperation* instr);
2708 LInstruction* DoMathRound(HUnaryMathOperation* instr);
2709 LInstruction* DoMathAbs(HUnaryMathOperation* instr);
2710 LInstruction* DoMathLog(HUnaryMathOperation* instr);
2711 LInstruction* DoMathExp(HUnaryMathOperation* instr);
2712 LInstruction* DoMathSqrt(HUnaryMathOperation* instr);
2713 LInstruction* DoMathPowHalf(HUnaryMathOperation* instr);
2714 LInstruction* DoMathClz32(HUnaryMathOperation* instr);
2715 LInstruction* DoDivByPowerOf2I(HDiv* instr);
2716 LInstruction* DoDivByConstI(HDiv* instr);
2717 LInstruction* DoDivI(HDiv* instr);
2718 LInstruction* DoModByPowerOf2I(HMod* instr);
2719 LInstruction* DoModByConstI(HMod* instr);
2720 LInstruction* DoModI(HMod* instr);
2721 LInstruction* DoFlooringDivByPowerOf2I(HMathFloorOfDiv* instr);
2722 LInstruction* DoFlooringDivByConstI(HMathFloorOfDiv* instr);
2723 LInstruction* DoFlooringDivI(HMathFloorOfDiv* instr);
2733 LPlatformChunk* chunk() const { return chunk_; }
2734 CompilationInfo* info() const { return info_; }
2735 HGraph* graph() const { return graph_; }
2737 bool is_unused() const { return status_ == UNUSED; }
2738 bool is_building() const { return status_ == BUILDING; }
2739 bool is_done() const { return status_ == DONE; }
2740 bool is_aborted() const { return status_ == ABORTED; }
2742 void Abort(BailoutReason reason);
2744 // Methods for getting operands for Use / Define / Temp.
2745 LUnallocated* ToUnallocated(Register reg);
2746 LUnallocated* ToUnallocated(XMMRegister reg);
2748 // Methods for setting up define-use relationships.
2749 MUST_USE_RESULT LOperand* Use(HValue* value, LUnallocated* operand);
2750 MUST_USE_RESULT LOperand* UseFixed(HValue* value, Register fixed_register);
2751 MUST_USE_RESULT LOperand* UseFixedDouble(HValue* value,
2752 XMMRegister fixed_register);
2754 // A value that is guaranteed to be allocated to a register.
2755 // Operand created by UseRegister is guaranteed to be live until the end of
2756 // instruction. This means that register allocator will not reuse it's
2757 // register for any other operand inside instruction.
2758 // Operand created by UseRegisterAtStart is guaranteed to be live only at
2759 // instruction start. Register allocator is free to assign the same register
2760 // to some other operand used inside instruction (i.e. temporary or
2762 MUST_USE_RESULT LOperand* UseRegister(HValue* value);
2763 MUST_USE_RESULT LOperand* UseRegisterAtStart(HValue* value);
2765 // An input operand in a register that may be trashed.
2766 MUST_USE_RESULT LOperand* UseTempRegister(HValue* value);
2768 // An input operand in a register that may be trashed or a constant operand.
2769 MUST_USE_RESULT LOperand* UseTempRegisterOrConstant(HValue* value);
2771 // An input operand in a register or stack slot.
2772 MUST_USE_RESULT LOperand* Use(HValue* value);
2773 MUST_USE_RESULT LOperand* UseAtStart(HValue* value);
2775 // An input operand in a register, stack slot or a constant operand.
2776 MUST_USE_RESULT LOperand* UseOrConstant(HValue* value);
2777 MUST_USE_RESULT LOperand* UseOrConstantAtStart(HValue* value);
2779 // An input operand in a register or a constant operand.
2780 MUST_USE_RESULT LOperand* UseRegisterOrConstant(HValue* value);
2781 MUST_USE_RESULT LOperand* UseRegisterOrConstantAtStart(HValue* value);
2783 // An input operand in a constant operand.
2784 MUST_USE_RESULT LOperand* UseConstant(HValue* value);
2786 // An input operand in register, stack slot or a constant operand.
2787 // Will not be moved to a register even if one is freely available.
2788 virtual MUST_USE_RESULT LOperand* UseAny(HValue* value) V8_OVERRIDE;
2790 // Temporary operand that must be in a register.
2791 MUST_USE_RESULT LUnallocated* TempRegister();
2792 MUST_USE_RESULT LOperand* FixedTemp(Register reg);
2793 MUST_USE_RESULT LOperand* FixedTemp(XMMRegister reg);
2795 // Methods for setting up define-use relationships.
2796 // Return the same instruction that they are passed.
2797 LInstruction* Define(LTemplateResultInstruction<1>* instr,
2798 LUnallocated* result);
2799 LInstruction* DefineAsRegister(LTemplateResultInstruction<1>* instr);
2800 LInstruction* DefineAsSpilled(LTemplateResultInstruction<1>* instr,
2802 LInstruction* DefineSameAsFirst(LTemplateResultInstruction<1>* instr);
2803 LInstruction* DefineFixed(LTemplateResultInstruction<1>* instr,
2805 LInstruction* DefineFixedDouble(LTemplateResultInstruction<1>* instr,
2807 // Assigns an environment to an instruction. An instruction which can
2808 // deoptimize must have an environment.
2809 LInstruction* AssignEnvironment(LInstruction* instr);
2810 // Assigns a pointer map to an instruction. An instruction which can
2811 // trigger a GC or a lazy deoptimization must have a pointer map.
2812 LInstruction* AssignPointerMap(LInstruction* instr);
2814 enum CanDeoptimize { CAN_DEOPTIMIZE_EAGERLY, CANNOT_DEOPTIMIZE_EAGERLY };
2816 // Marks a call for the register allocator. Assigns a pointer map to
2817 // support GC and lazy deoptimization. Assigns an environment to support
2818 // eager deoptimization if CAN_DEOPTIMIZE_EAGERLY.
2819 LInstruction* MarkAsCall(
2820 LInstruction* instr,
2821 HInstruction* hinstr,
2822 CanDeoptimize can_deoptimize = CANNOT_DEOPTIMIZE_EAGERLY);
2824 void VisitInstruction(HInstruction* current);
2825 void AddInstruction(LInstruction* instr, HInstruction* current);
2827 void DoBasicBlock(HBasicBlock* block, HBasicBlock* next_block);
2828 LInstruction* DoShift(Token::Value op, HBitwiseBinaryOperation* instr);
2829 LInstruction* DoArithmeticD(Token::Value op,
2830 HArithmeticBinaryOperation* instr);
2831 LInstruction* DoArithmeticT(Token::Value op,
2832 HBinaryOperation* instr);
2833 void FindDehoistedKeyDefinitions(HValue* candidate);
2835 LPlatformChunk* chunk_;
2836 CompilationInfo* info_;
2837 HGraph* const graph_;
2839 HInstruction* current_instruction_;
2840 HBasicBlock* current_block_;
2841 HBasicBlock* next_block_;
2842 LAllocator* allocator_;
2844 DISALLOW_COPY_AND_ASSIGN(LChunkBuilder);
2847 #undef DECLARE_HYDROGEN_ACCESSOR
2848 #undef DECLARE_CONCRETE_INSTRUCTION
2850 } } // namespace v8::int
2852 #endif // V8_X64_LITHIUM_X64_H_