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.h"
10 #include "src/lithium-allocator.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) \
134 V(SeqStringGetChar) \
135 V(SeqStringSetChar) \
141 V(StoreContextSlot) \
142 V(StoreFrameContext) \
145 V(StoreKeyedGeneric) \
147 V(StoreNamedGeneric) \
149 V(StringCharCodeAt) \
150 V(StringCharFromCode) \
151 V(StringCompareAndBranch) \
154 V(TailCallThroughMegamorphicCache) \
156 V(ToFastProperties) \
157 V(TransitionElementsKind) \
158 V(TrapAllocationMemento) \
160 V(TypeofIsAndBranch) \
166 #define DECLARE_CONCRETE_INSTRUCTION(type, mnemonic) \
167 virtual Opcode opcode() const FINAL OVERRIDE { \
168 return LInstruction::k##type; \
170 virtual void CompileToNative(LCodeGen* generator) FINAL OVERRIDE; \
171 virtual const char* Mnemonic() const FINAL OVERRIDE { \
174 static L##type* cast(LInstruction* instr) { \
175 DCHECK(instr->Is##type()); \
176 return reinterpret_cast<L##type*>(instr); \
180 #define DECLARE_HYDROGEN_ACCESSOR(type) \
181 H##type* hydrogen() const { \
182 return H##type::cast(hydrogen_value()); \
186 class LInstruction : public ZoneObject {
189 : environment_(NULL),
190 hydrogen_value_(NULL),
191 bit_field_(IsCallBits::encode(false)) {
194 virtual ~LInstruction() {}
196 virtual void CompileToNative(LCodeGen* generator) = 0;
197 virtual const char* Mnemonic() const = 0;
198 virtual void PrintTo(StringStream* stream);
199 virtual void PrintDataTo(StringStream* stream);
200 virtual void PrintOutputOperandTo(StringStream* stream);
203 // Declare a unique enum value for each instruction.
204 #define DECLARE_OPCODE(type) k##type,
205 LITHIUM_CONCRETE_INSTRUCTION_LIST(DECLARE_OPCODE)
206 kNumberOfInstructions
207 #undef DECLARE_OPCODE
210 virtual Opcode opcode() const = 0;
212 // Declare non-virtual type testers for all leaf IR classes.
213 #define DECLARE_PREDICATE(type) \
214 bool Is##type() const { return opcode() == k##type; }
215 LITHIUM_CONCRETE_INSTRUCTION_LIST(DECLARE_PREDICATE)
216 #undef DECLARE_PREDICATE
218 // Declare virtual predicates for instructions that don't have
220 virtual bool IsGap() const { return false; }
222 virtual bool IsControl() const { return false; }
224 // Try deleting this instruction if possible.
225 virtual bool TryDelete() { return false; }
227 void set_environment(LEnvironment* env) { environment_ = env; }
228 LEnvironment* environment() const { return environment_; }
229 bool HasEnvironment() const { return environment_ != NULL; }
231 void set_pointer_map(LPointerMap* p) { pointer_map_.set(p); }
232 LPointerMap* pointer_map() const { return pointer_map_.get(); }
233 bool HasPointerMap() const { return pointer_map_.is_set(); }
235 void set_hydrogen_value(HValue* value) { hydrogen_value_ = value; }
236 HValue* hydrogen_value() const { return hydrogen_value_; }
238 void MarkAsCall() { bit_field_ = IsCallBits::update(bit_field_, true); }
239 bool IsCall() const { return IsCallBits::decode(bit_field_); }
241 // Interface to the register allocator and iterators.
242 bool ClobbersTemps() const { return IsCall(); }
243 bool ClobbersRegisters() const { return IsCall(); }
244 virtual bool ClobbersDoubleRegisters(Isolate* isolate) const {
248 virtual void SetDeferredLazyDeoptimizationEnvironment(LEnvironment* env) { }
250 // Interface to the register allocator and iterators.
251 bool IsMarkedAsCall() const { return IsCall(); }
253 virtual bool HasResult() const = 0;
254 virtual LOperand* result() const = 0;
256 LOperand* FirstInput() { return InputAt(0); }
257 LOperand* Output() { return HasResult() ? result() : NULL; }
259 virtual bool HasInterestingComment(LCodeGen* gen) const { return true; }
261 virtual bool MustSignExtendResult(LPlatformChunk* chunk) const {
269 virtual int InputCount() = 0;
270 virtual LOperand* InputAt(int i) = 0;
274 friend class InputIterator;
276 friend class TempIterator;
277 virtual int TempCount() = 0;
278 virtual LOperand* TempAt(int i) = 0;
280 class IsCallBits: public BitField<bool, 0, 1> {};
282 LEnvironment* environment_;
283 SetOncePointer<LPointerMap> pointer_map_;
284 HValue* hydrogen_value_;
289 // R = number of result operands (0 or 1).
291 class LTemplateResultInstruction : public LInstruction {
293 // Allow 0 or 1 output operands.
294 STATIC_ASSERT(R == 0 || R == 1);
295 virtual bool HasResult() const FINAL OVERRIDE {
296 return R != 0 && result() != NULL;
298 void set_result(LOperand* operand) { results_[0] = operand; }
299 LOperand* result() const { return results_[0]; }
301 virtual bool MustSignExtendResult(
302 LPlatformChunk* chunk) const FINAL OVERRIDE;
305 EmbeddedContainer<LOperand*, R> results_;
309 // R = number of result operands (0 or 1).
310 // I = number of input operands.
311 // T = number of temporary operands.
312 template<int R, int I, int T>
313 class LTemplateInstruction : public LTemplateResultInstruction<R> {
315 EmbeddedContainer<LOperand*, I> inputs_;
316 EmbeddedContainer<LOperand*, T> temps_;
320 virtual int InputCount() FINAL OVERRIDE { return I; }
321 virtual LOperand* InputAt(int i) FINAL OVERRIDE { return inputs_[i]; }
323 virtual int TempCount() FINAL OVERRIDE { return T; }
324 virtual LOperand* TempAt(int i) FINAL OVERRIDE { return temps_[i]; }
328 class LGap : public LTemplateInstruction<0, 0, 0> {
330 explicit LGap(HBasicBlock* block)
332 parallel_moves_[BEFORE] = NULL;
333 parallel_moves_[START] = NULL;
334 parallel_moves_[END] = NULL;
335 parallel_moves_[AFTER] = NULL;
338 // Can't use the DECLARE-macro here because of sub-classes.
339 virtual bool IsGap() const FINAL OVERRIDE { return true; }
340 virtual void PrintDataTo(StringStream* stream) OVERRIDE;
341 static LGap* cast(LInstruction* instr) {
342 DCHECK(instr->IsGap());
343 return reinterpret_cast<LGap*>(instr);
346 bool IsRedundant() const;
348 HBasicBlock* block() const { return block_; }
355 FIRST_INNER_POSITION = BEFORE,
356 LAST_INNER_POSITION = AFTER
359 LParallelMove* GetOrCreateParallelMove(InnerPosition pos,
361 if (parallel_moves_[pos] == NULL) {
362 parallel_moves_[pos] = new(zone) LParallelMove(zone);
364 return parallel_moves_[pos];
367 LParallelMove* GetParallelMove(InnerPosition pos) {
368 return parallel_moves_[pos];
372 LParallelMove* parallel_moves_[LAST_INNER_POSITION + 1];
377 class LInstructionGap FINAL : public LGap {
379 explicit LInstructionGap(HBasicBlock* block) : LGap(block) { }
381 virtual bool HasInterestingComment(LCodeGen* gen) const OVERRIDE {
382 return !IsRedundant();
385 DECLARE_CONCRETE_INSTRUCTION(InstructionGap, "gap")
389 class LGoto FINAL : public LTemplateInstruction<0, 0, 0> {
391 explicit LGoto(HBasicBlock* block) : block_(block) { }
393 virtual bool HasInterestingComment(LCodeGen* gen) const OVERRIDE;
394 DECLARE_CONCRETE_INSTRUCTION(Goto, "goto")
395 virtual void PrintDataTo(StringStream* stream) OVERRIDE;
396 virtual bool IsControl() const OVERRIDE { return true; }
398 int block_id() const { return block_->block_id(); }
405 class LLazyBailout FINAL : public LTemplateInstruction<0, 0, 0> {
407 LLazyBailout() : gap_instructions_size_(0) { }
409 DECLARE_CONCRETE_INSTRUCTION(LazyBailout, "lazy-bailout")
411 void set_gap_instructions_size(int gap_instructions_size) {
412 gap_instructions_size_ = gap_instructions_size;
414 int gap_instructions_size() { return gap_instructions_size_; }
417 int gap_instructions_size_;
421 class LDummy FINAL : public LTemplateInstruction<1, 0, 0> {
424 DECLARE_CONCRETE_INSTRUCTION(Dummy, "dummy")
428 class LDummyUse FINAL : public LTemplateInstruction<1, 1, 0> {
430 explicit LDummyUse(LOperand* value) {
433 DECLARE_CONCRETE_INSTRUCTION(DummyUse, "dummy-use")
437 class LDeoptimize FINAL : public LTemplateInstruction<0, 0, 0> {
439 virtual bool IsControl() const OVERRIDE { return true; }
440 DECLARE_CONCRETE_INSTRUCTION(Deoptimize, "deoptimize")
441 DECLARE_HYDROGEN_ACCESSOR(Deoptimize)
445 class LLabel FINAL : public LGap {
447 explicit LLabel(HBasicBlock* block)
448 : LGap(block), replacement_(NULL) { }
450 virtual bool HasInterestingComment(LCodeGen* gen) const OVERRIDE {
453 DECLARE_CONCRETE_INSTRUCTION(Label, "label")
455 virtual void PrintDataTo(StringStream* stream) OVERRIDE;
457 int block_id() const { return block()->block_id(); }
458 bool is_loop_header() const { return block()->IsLoopHeader(); }
459 bool is_osr_entry() const { return block()->is_osr_entry(); }
460 Label* label() { return &label_; }
461 LLabel* replacement() const { return replacement_; }
462 void set_replacement(LLabel* label) { replacement_ = label; }
463 bool HasReplacement() const { return replacement_ != NULL; }
467 LLabel* replacement_;
471 class LParameter FINAL : public LTemplateInstruction<1, 0, 0> {
473 virtual bool HasInterestingComment(LCodeGen* gen) const OVERRIDE {
476 DECLARE_CONCRETE_INSTRUCTION(Parameter, "parameter")
480 class LCallStub FINAL : public LTemplateInstruction<1, 1, 0> {
482 explicit LCallStub(LOperand* context) {
483 inputs_[0] = context;
486 LOperand* context() { return inputs_[0]; }
488 DECLARE_CONCRETE_INSTRUCTION(CallStub, "call-stub")
489 DECLARE_HYDROGEN_ACCESSOR(CallStub)
493 class LTailCallThroughMegamorphicCache FINAL
494 : public LTemplateInstruction<0, 3, 0> {
496 explicit LTailCallThroughMegamorphicCache(LOperand* context,
499 inputs_[0] = context;
500 inputs_[1] = receiver;
504 LOperand* context() { return inputs_[0]; }
505 LOperand* receiver() { return inputs_[1]; }
506 LOperand* name() { return inputs_[2]; }
508 DECLARE_CONCRETE_INSTRUCTION(TailCallThroughMegamorphicCache,
509 "tail-call-through-megamorphic-cache")
510 DECLARE_HYDROGEN_ACCESSOR(TailCallThroughMegamorphicCache)
514 class LUnknownOSRValue FINAL : public LTemplateInstruction<1, 0, 0> {
516 virtual bool HasInterestingComment(LCodeGen* gen) const OVERRIDE {
519 DECLARE_CONCRETE_INSTRUCTION(UnknownOSRValue, "unknown-osr-value")
523 template<int I, int T>
524 class LControlInstruction : public LTemplateInstruction<0, I, T> {
526 LControlInstruction() : false_label_(NULL), true_label_(NULL) { }
528 virtual bool IsControl() const FINAL OVERRIDE { return true; }
530 int SuccessorCount() { return hydrogen()->SuccessorCount(); }
531 HBasicBlock* SuccessorAt(int i) { return hydrogen()->SuccessorAt(i); }
533 int TrueDestination(LChunk* chunk) {
534 return chunk->LookupDestination(true_block_id());
536 int FalseDestination(LChunk* chunk) {
537 return chunk->LookupDestination(false_block_id());
540 Label* TrueLabel(LChunk* chunk) {
541 if (true_label_ == NULL) {
542 true_label_ = chunk->GetAssemblyLabel(TrueDestination(chunk));
546 Label* FalseLabel(LChunk* chunk) {
547 if (false_label_ == NULL) {
548 false_label_ = chunk->GetAssemblyLabel(FalseDestination(chunk));
554 int true_block_id() { return SuccessorAt(0)->block_id(); }
555 int false_block_id() { return SuccessorAt(1)->block_id(); }
558 HControlInstruction* hydrogen() {
559 return HControlInstruction::cast(this->hydrogen_value());
567 class LWrapReceiver FINAL : public LTemplateInstruction<1, 2, 0> {
569 LWrapReceiver(LOperand* receiver, LOperand* function) {
570 inputs_[0] = receiver;
571 inputs_[1] = function;
574 LOperand* receiver() { return inputs_[0]; }
575 LOperand* function() { return inputs_[1]; }
577 DECLARE_CONCRETE_INSTRUCTION(WrapReceiver, "wrap-receiver")
578 DECLARE_HYDROGEN_ACCESSOR(WrapReceiver)
582 class LApplyArguments FINAL : public LTemplateInstruction<1, 4, 0> {
584 LApplyArguments(LOperand* function,
587 LOperand* elements) {
588 inputs_[0] = function;
589 inputs_[1] = receiver;
591 inputs_[3] = elements;
594 LOperand* function() { return inputs_[0]; }
595 LOperand* receiver() { return inputs_[1]; }
596 LOperand* length() { return inputs_[2]; }
597 LOperand* elements() { return inputs_[3]; }
599 DECLARE_CONCRETE_INSTRUCTION(ApplyArguments, "apply-arguments")
603 class LAccessArgumentsAt FINAL : public LTemplateInstruction<1, 3, 0> {
605 LAccessArgumentsAt(LOperand* arguments, LOperand* length, LOperand* index) {
606 inputs_[0] = arguments;
611 LOperand* arguments() { return inputs_[0]; }
612 LOperand* length() { return inputs_[1]; }
613 LOperand* index() { return inputs_[2]; }
615 DECLARE_CONCRETE_INSTRUCTION(AccessArgumentsAt, "access-arguments-at")
617 virtual void PrintDataTo(StringStream* stream) OVERRIDE;
621 class LArgumentsLength FINAL : public LTemplateInstruction<1, 1, 0> {
623 explicit LArgumentsLength(LOperand* elements) {
624 inputs_[0] = elements;
627 LOperand* elements() { return inputs_[0]; }
629 DECLARE_CONCRETE_INSTRUCTION(ArgumentsLength, "arguments-length")
633 class LArgumentsElements FINAL : public LTemplateInstruction<1, 0, 0> {
635 DECLARE_CONCRETE_INSTRUCTION(ArgumentsElements, "arguments-elements")
636 DECLARE_HYDROGEN_ACCESSOR(ArgumentsElements)
640 class LModByPowerOf2I FINAL : public LTemplateInstruction<1, 1, 0> {
642 LModByPowerOf2I(LOperand* dividend, int32_t divisor) {
643 inputs_[0] = dividend;
647 LOperand* dividend() { return inputs_[0]; }
648 int32_t divisor() const { return divisor_; }
650 DECLARE_CONCRETE_INSTRUCTION(ModByPowerOf2I, "mod-by-power-of-2-i")
651 DECLARE_HYDROGEN_ACCESSOR(Mod)
658 class LModByConstI FINAL : public LTemplateInstruction<1, 1, 2> {
660 LModByConstI(LOperand* dividend,
664 inputs_[0] = dividend;
670 LOperand* dividend() { return inputs_[0]; }
671 int32_t divisor() const { return divisor_; }
672 LOperand* temp1() { return temps_[0]; }
673 LOperand* temp2() { return temps_[1]; }
675 DECLARE_CONCRETE_INSTRUCTION(ModByConstI, "mod-by-const-i")
676 DECLARE_HYDROGEN_ACCESSOR(Mod)
683 class LModI FINAL : public LTemplateInstruction<1, 2, 1> {
685 LModI(LOperand* left, LOperand* right, LOperand* temp) {
691 LOperand* left() { return inputs_[0]; }
692 LOperand* right() { return inputs_[1]; }
693 LOperand* temp() { return temps_[0]; }
695 DECLARE_CONCRETE_INSTRUCTION(ModI, "mod-i")
696 DECLARE_HYDROGEN_ACCESSOR(Mod)
700 class LDivByPowerOf2I FINAL : public LTemplateInstruction<1, 1, 0> {
702 LDivByPowerOf2I(LOperand* dividend, int32_t divisor) {
703 inputs_[0] = dividend;
707 LOperand* dividend() { return inputs_[0]; }
708 int32_t divisor() const { return divisor_; }
710 DECLARE_CONCRETE_INSTRUCTION(DivByPowerOf2I, "div-by-power-of-2-i")
711 DECLARE_HYDROGEN_ACCESSOR(Div)
718 class LDivByConstI FINAL : public LTemplateInstruction<1, 1, 2> {
720 LDivByConstI(LOperand* dividend,
724 inputs_[0] = dividend;
730 LOperand* dividend() { return inputs_[0]; }
731 int32_t divisor() const { return divisor_; }
732 LOperand* temp1() { return temps_[0]; }
733 LOperand* temp2() { return temps_[1]; }
735 DECLARE_CONCRETE_INSTRUCTION(DivByConstI, "div-by-const-i")
736 DECLARE_HYDROGEN_ACCESSOR(Div)
743 class LDivI FINAL : public LTemplateInstruction<1, 2, 1> {
745 LDivI(LOperand* dividend, LOperand* divisor, LOperand* temp) {
746 inputs_[0] = dividend;
747 inputs_[1] = divisor;
751 LOperand* dividend() { return inputs_[0]; }
752 LOperand* divisor() { return inputs_[1]; }
753 LOperand* temp() { return temps_[0]; }
755 DECLARE_CONCRETE_INSTRUCTION(DivI, "div-i")
756 DECLARE_HYDROGEN_ACCESSOR(BinaryOperation)
760 class LFlooringDivByPowerOf2I FINAL : public LTemplateInstruction<1, 1, 0> {
762 LFlooringDivByPowerOf2I(LOperand* dividend, int32_t divisor) {
763 inputs_[0] = dividend;
767 LOperand* dividend() { return inputs_[0]; }
768 int32_t divisor() const { return divisor_; }
770 DECLARE_CONCRETE_INSTRUCTION(FlooringDivByPowerOf2I,
771 "flooring-div-by-power-of-2-i")
772 DECLARE_HYDROGEN_ACCESSOR(MathFloorOfDiv)
779 class LFlooringDivByConstI FINAL : public LTemplateInstruction<1, 1, 3> {
781 LFlooringDivByConstI(LOperand* dividend,
786 inputs_[0] = dividend;
793 LOperand* dividend() { return inputs_[0]; }
794 int32_t divisor() const { return divisor_; }
795 LOperand* temp1() { return temps_[0]; }
796 LOperand* temp2() { return temps_[1]; }
797 LOperand* temp3() { return temps_[2]; }
799 DECLARE_CONCRETE_INSTRUCTION(FlooringDivByConstI, "flooring-div-by-const-i")
800 DECLARE_HYDROGEN_ACCESSOR(MathFloorOfDiv)
807 class LFlooringDivI FINAL : public LTemplateInstruction<1, 2, 1> {
809 LFlooringDivI(LOperand* dividend, LOperand* divisor, LOperand* temp) {
810 inputs_[0] = dividend;
811 inputs_[1] = divisor;
815 LOperand* dividend() { return inputs_[0]; }
816 LOperand* divisor() { return inputs_[1]; }
817 LOperand* temp() { return temps_[0]; }
819 DECLARE_CONCRETE_INSTRUCTION(FlooringDivI, "flooring-div-i")
820 DECLARE_HYDROGEN_ACCESSOR(MathFloorOfDiv)
824 class LMulI FINAL : public LTemplateInstruction<1, 2, 0> {
826 LMulI(LOperand* left, LOperand* right) {
831 LOperand* left() { return inputs_[0]; }
832 LOperand* right() { return inputs_[1]; }
834 DECLARE_CONCRETE_INSTRUCTION(MulI, "mul-i")
835 DECLARE_HYDROGEN_ACCESSOR(Mul)
839 class LCompareNumericAndBranch FINAL : public LControlInstruction<2, 0> {
841 LCompareNumericAndBranch(LOperand* left, LOperand* right) {
846 LOperand* left() { return inputs_[0]; }
847 LOperand* right() { return inputs_[1]; }
849 DECLARE_CONCRETE_INSTRUCTION(CompareNumericAndBranch,
850 "compare-numeric-and-branch")
851 DECLARE_HYDROGEN_ACCESSOR(CompareNumericAndBranch)
853 Token::Value op() const { return hydrogen()->token(); }
854 bool is_double() const {
855 return hydrogen()->representation().IsDouble();
858 virtual void PrintDataTo(StringStream* stream) OVERRIDE;
862 class LMathFloor FINAL : public LTemplateInstruction<1, 1, 0> {
864 explicit LMathFloor(LOperand* value) {
868 LOperand* value() { return inputs_[0]; }
870 DECLARE_CONCRETE_INSTRUCTION(MathFloor, "math-floor")
871 DECLARE_HYDROGEN_ACCESSOR(UnaryMathOperation)
875 class LMathRound FINAL : public LTemplateInstruction<1, 1, 1> {
877 LMathRound(LOperand* value, LOperand* temp) {
882 LOperand* value() { return inputs_[0]; }
883 LOperand* temp() { return temps_[0]; }
885 DECLARE_CONCRETE_INSTRUCTION(MathRound, "math-round")
886 DECLARE_HYDROGEN_ACCESSOR(UnaryMathOperation)
890 class LMathFround FINAL : public LTemplateInstruction<1, 1, 0> {
892 explicit LMathFround(LOperand* value) { inputs_[0] = value; }
894 LOperand* value() { return inputs_[0]; }
896 DECLARE_CONCRETE_INSTRUCTION(MathFround, "math-fround")
900 class LMathAbs FINAL : public LTemplateInstruction<1, 2, 0> {
902 explicit LMathAbs(LOperand* context, LOperand* value) {
903 inputs_[1] = context;
907 LOperand* context() { return inputs_[1]; }
908 LOperand* value() { return inputs_[0]; }
910 DECLARE_CONCRETE_INSTRUCTION(MathAbs, "math-abs")
911 DECLARE_HYDROGEN_ACCESSOR(UnaryMathOperation)
915 class LMathLog FINAL : public LTemplateInstruction<1, 1, 0> {
917 explicit LMathLog(LOperand* value) {
921 LOperand* value() { return inputs_[0]; }
923 DECLARE_CONCRETE_INSTRUCTION(MathLog, "math-log")
927 class LMathClz32 FINAL : public LTemplateInstruction<1, 1, 0> {
929 explicit LMathClz32(LOperand* value) {
933 LOperand* value() { return inputs_[0]; }
935 DECLARE_CONCRETE_INSTRUCTION(MathClz32, "math-clz32")
939 class LMathExp FINAL : public LTemplateInstruction<1, 1, 2> {
941 LMathExp(LOperand* value, LOperand* temp1, LOperand* temp2) {
945 ExternalReference::InitializeMathExpData();
948 LOperand* value() { return inputs_[0]; }
949 LOperand* temp1() { return temps_[0]; }
950 LOperand* temp2() { return temps_[1]; }
952 DECLARE_CONCRETE_INSTRUCTION(MathExp, "math-exp")
956 class LMathSqrt FINAL : public LTemplateInstruction<1, 1, 0> {
958 explicit LMathSqrt(LOperand* value) {
962 LOperand* value() { return inputs_[0]; }
964 DECLARE_CONCRETE_INSTRUCTION(MathSqrt, "math-sqrt")
968 class LMathPowHalf FINAL : public LTemplateInstruction<1, 1, 0> {
970 explicit LMathPowHalf(LOperand* value) {
974 LOperand* value() { return inputs_[0]; }
976 DECLARE_CONCRETE_INSTRUCTION(MathPowHalf, "math-pow-half")
980 class LCmpObjectEqAndBranch FINAL : public LControlInstruction<2, 0> {
982 LCmpObjectEqAndBranch(LOperand* left, LOperand* right) {
987 LOperand* left() { return inputs_[0]; }
988 LOperand* right() { return inputs_[1]; }
990 DECLARE_CONCRETE_INSTRUCTION(CmpObjectEqAndBranch, "cmp-object-eq-and-branch")
994 class LCmpHoleAndBranch FINAL : public LControlInstruction<1, 0> {
996 explicit LCmpHoleAndBranch(LOperand* object) {
1000 LOperand* object() { return inputs_[0]; }
1002 DECLARE_CONCRETE_INSTRUCTION(CmpHoleAndBranch, "cmp-hole-and-branch")
1003 DECLARE_HYDROGEN_ACCESSOR(CompareHoleAndBranch)
1007 class LCompareMinusZeroAndBranch FINAL : public LControlInstruction<1, 0> {
1009 explicit LCompareMinusZeroAndBranch(LOperand* value) {
1013 LOperand* value() { return inputs_[0]; }
1015 DECLARE_CONCRETE_INSTRUCTION(CompareMinusZeroAndBranch,
1016 "cmp-minus-zero-and-branch")
1017 DECLARE_HYDROGEN_ACCESSOR(CompareMinusZeroAndBranch)
1022 class LIsObjectAndBranch FINAL : public LControlInstruction<1, 0> {
1024 explicit LIsObjectAndBranch(LOperand* value) {
1028 LOperand* value() { return inputs_[0]; }
1030 DECLARE_CONCRETE_INSTRUCTION(IsObjectAndBranch, "is-object-and-branch")
1031 DECLARE_HYDROGEN_ACCESSOR(IsObjectAndBranch)
1033 virtual void PrintDataTo(StringStream* stream) OVERRIDE;
1037 class LIsStringAndBranch FINAL : public LControlInstruction<1, 1> {
1039 explicit LIsStringAndBranch(LOperand* value, LOperand* temp) {
1044 LOperand* value() { return inputs_[0]; }
1045 LOperand* temp() { return temps_[0]; }
1047 DECLARE_CONCRETE_INSTRUCTION(IsStringAndBranch, "is-string-and-branch")
1048 DECLARE_HYDROGEN_ACCESSOR(IsStringAndBranch)
1050 virtual void PrintDataTo(StringStream* stream) OVERRIDE;
1054 class LIsSmiAndBranch FINAL : public LControlInstruction<1, 0> {
1056 explicit LIsSmiAndBranch(LOperand* value) {
1060 LOperand* value() { return inputs_[0]; }
1062 DECLARE_CONCRETE_INSTRUCTION(IsSmiAndBranch, "is-smi-and-branch")
1063 DECLARE_HYDROGEN_ACCESSOR(IsSmiAndBranch)
1065 virtual void PrintDataTo(StringStream* stream) OVERRIDE;
1069 class LIsUndetectableAndBranch FINAL : public LControlInstruction<1, 1> {
1071 explicit LIsUndetectableAndBranch(LOperand* value, LOperand* temp) {
1076 LOperand* value() { return inputs_[0]; }
1077 LOperand* temp() { return temps_[0]; }
1079 DECLARE_CONCRETE_INSTRUCTION(IsUndetectableAndBranch,
1080 "is-undetectable-and-branch")
1081 DECLARE_HYDROGEN_ACCESSOR(IsUndetectableAndBranch)
1083 virtual void PrintDataTo(StringStream* stream) OVERRIDE;
1087 class LStringCompareAndBranch FINAL : public LControlInstruction<3, 0> {
1089 explicit LStringCompareAndBranch(LOperand* context,
1092 inputs_[0] = context;
1097 LOperand* context() { return inputs_[0]; }
1098 LOperand* left() { return inputs_[1]; }
1099 LOperand* right() { return inputs_[2]; }
1101 DECLARE_CONCRETE_INSTRUCTION(StringCompareAndBranch,
1102 "string-compare-and-branch")
1103 DECLARE_HYDROGEN_ACCESSOR(StringCompareAndBranch)
1105 virtual void PrintDataTo(StringStream* stream) OVERRIDE;
1107 Token::Value op() const { return hydrogen()->token(); }
1111 class LHasInstanceTypeAndBranch FINAL : public LControlInstruction<1, 0> {
1113 explicit LHasInstanceTypeAndBranch(LOperand* value) {
1117 LOperand* value() { return inputs_[0]; }
1119 DECLARE_CONCRETE_INSTRUCTION(HasInstanceTypeAndBranch,
1120 "has-instance-type-and-branch")
1121 DECLARE_HYDROGEN_ACCESSOR(HasInstanceTypeAndBranch)
1123 virtual void PrintDataTo(StringStream* stream) OVERRIDE;
1127 class LGetCachedArrayIndex FINAL : public LTemplateInstruction<1, 1, 0> {
1129 explicit LGetCachedArrayIndex(LOperand* value) {
1133 LOperand* value() { return inputs_[0]; }
1135 DECLARE_CONCRETE_INSTRUCTION(GetCachedArrayIndex, "get-cached-array-index")
1136 DECLARE_HYDROGEN_ACCESSOR(GetCachedArrayIndex)
1140 class LHasCachedArrayIndexAndBranch FINAL
1141 : public LControlInstruction<1, 0> {
1143 explicit LHasCachedArrayIndexAndBranch(LOperand* value) {
1147 LOperand* value() { return inputs_[0]; }
1149 DECLARE_CONCRETE_INSTRUCTION(HasCachedArrayIndexAndBranch,
1150 "has-cached-array-index-and-branch")
1151 DECLARE_HYDROGEN_ACCESSOR(HasCachedArrayIndexAndBranch)
1153 virtual void PrintDataTo(StringStream* stream) OVERRIDE;
1157 class LClassOfTestAndBranch FINAL : public LControlInstruction<1, 2> {
1159 LClassOfTestAndBranch(LOperand* value, LOperand* temp, LOperand* temp2) {
1165 LOperand* value() { return inputs_[0]; }
1166 LOperand* temp() { return temps_[0]; }
1167 LOperand* temp2() { return temps_[1]; }
1169 DECLARE_CONCRETE_INSTRUCTION(ClassOfTestAndBranch,
1170 "class-of-test-and-branch")
1171 DECLARE_HYDROGEN_ACCESSOR(ClassOfTestAndBranch)
1173 virtual void PrintDataTo(StringStream* stream) OVERRIDE;
1177 class LCmpT FINAL : public LTemplateInstruction<1, 3, 0> {
1179 LCmpT(LOperand* context, LOperand* left, LOperand* right) {
1180 inputs_[0] = context;
1185 LOperand* context() { return inputs_[0]; }
1186 LOperand* left() { return inputs_[1]; }
1187 LOperand* right() { return inputs_[2]; }
1189 DECLARE_CONCRETE_INSTRUCTION(CmpT, "cmp-t")
1190 DECLARE_HYDROGEN_ACCESSOR(CompareGeneric)
1192 Token::Value op() const { return hydrogen()->token(); }
1196 class LInstanceOf FINAL : public LTemplateInstruction<1, 3, 0> {
1198 LInstanceOf(LOperand* context, LOperand* left, LOperand* right) {
1199 inputs_[0] = context;
1204 LOperand* context() { return inputs_[0]; }
1205 LOperand* left() { return inputs_[1]; }
1206 LOperand* right() { return inputs_[2]; }
1208 DECLARE_CONCRETE_INSTRUCTION(InstanceOf, "instance-of")
1212 class LInstanceOfKnownGlobal FINAL : public LTemplateInstruction<1, 2, 1> {
1214 LInstanceOfKnownGlobal(LOperand* context, LOperand* value, LOperand* temp) {
1215 inputs_[0] = context;
1220 LOperand* context() { return inputs_[0]; }
1221 LOperand* value() { return inputs_[1]; }
1222 LOperand* temp() { return temps_[0]; }
1224 DECLARE_CONCRETE_INSTRUCTION(InstanceOfKnownGlobal,
1225 "instance-of-known-global")
1226 DECLARE_HYDROGEN_ACCESSOR(InstanceOfKnownGlobal)
1228 Handle<JSFunction> function() const { return hydrogen()->function(); }
1229 LEnvironment* GetDeferredLazyDeoptimizationEnvironment() {
1230 return lazy_deopt_env_;
1232 virtual void SetDeferredLazyDeoptimizationEnvironment(
1233 LEnvironment* env) OVERRIDE {
1234 lazy_deopt_env_ = env;
1238 LEnvironment* lazy_deopt_env_;
1242 class LBoundsCheck FINAL : public LTemplateInstruction<0, 2, 0> {
1244 LBoundsCheck(LOperand* index, LOperand* length) {
1246 inputs_[1] = length;
1249 LOperand* index() { return inputs_[0]; }
1250 LOperand* length() { return inputs_[1]; }
1252 DECLARE_CONCRETE_INSTRUCTION(BoundsCheck, "bounds-check")
1253 DECLARE_HYDROGEN_ACCESSOR(BoundsCheck)
1257 class LBitI FINAL : public LTemplateInstruction<1, 2, 0> {
1259 LBitI(LOperand* left, LOperand* right) {
1264 LOperand* left() { return inputs_[0]; }
1265 LOperand* right() { return inputs_[1]; }
1267 Token::Value op() const { return hydrogen()->op(); }
1268 bool IsInteger32() const {
1269 return hydrogen()->representation().IsInteger32();
1272 DECLARE_CONCRETE_INSTRUCTION(BitI, "bit-i")
1273 DECLARE_HYDROGEN_ACCESSOR(Bitwise)
1277 class LShiftI FINAL : public LTemplateInstruction<1, 2, 0> {
1279 LShiftI(Token::Value op, LOperand* left, LOperand* right, bool can_deopt)
1280 : op_(op), can_deopt_(can_deopt) {
1285 Token::Value op() const { return op_; }
1286 LOperand* left() { return inputs_[0]; }
1287 LOperand* right() { return inputs_[1]; }
1288 bool can_deopt() const { return can_deopt_; }
1290 DECLARE_CONCRETE_INSTRUCTION(ShiftI, "shift-i")
1298 class LSubI FINAL : public LTemplateInstruction<1, 2, 0> {
1300 LSubI(LOperand* left, LOperand* right) {
1305 LOperand* left() { return inputs_[0]; }
1306 LOperand* right() { return inputs_[1]; }
1308 DECLARE_CONCRETE_INSTRUCTION(SubI, "sub-i")
1309 DECLARE_HYDROGEN_ACCESSOR(Sub)
1313 class LConstantI FINAL : public LTemplateInstruction<1, 0, 0> {
1315 DECLARE_CONCRETE_INSTRUCTION(ConstantI, "constant-i")
1316 DECLARE_HYDROGEN_ACCESSOR(Constant)
1318 int32_t value() const { return hydrogen()->Integer32Value(); }
1322 class LConstantS FINAL : public LTemplateInstruction<1, 0, 0> {
1324 DECLARE_CONCRETE_INSTRUCTION(ConstantS, "constant-s")
1325 DECLARE_HYDROGEN_ACCESSOR(Constant)
1327 Smi* value() const { return Smi::FromInt(hydrogen()->Integer32Value()); }
1331 class LConstantD FINAL : public LTemplateInstruction<1, 0, 1> {
1333 explicit LConstantD(LOperand* temp) {
1337 LOperand* temp() { return temps_[0]; }
1339 DECLARE_CONCRETE_INSTRUCTION(ConstantD, "constant-d")
1340 DECLARE_HYDROGEN_ACCESSOR(Constant)
1342 double value() const { return hydrogen()->DoubleValue(); }
1346 class LConstantE FINAL : public LTemplateInstruction<1, 0, 0> {
1348 DECLARE_CONCRETE_INSTRUCTION(ConstantE, "constant-e")
1349 DECLARE_HYDROGEN_ACCESSOR(Constant)
1351 ExternalReference value() const {
1352 return hydrogen()->ExternalReferenceValue();
1357 class LConstantT FINAL : public LTemplateInstruction<1, 0, 0> {
1359 DECLARE_CONCRETE_INSTRUCTION(ConstantT, "constant-t")
1360 DECLARE_HYDROGEN_ACCESSOR(Constant)
1362 Handle<Object> value(Isolate* isolate) const {
1363 return hydrogen()->handle(isolate);
1368 class LBranch FINAL : public LControlInstruction<1, 0> {
1370 explicit LBranch(LOperand* value) {
1374 LOperand* value() { return inputs_[0]; }
1376 DECLARE_CONCRETE_INSTRUCTION(Branch, "branch")
1377 DECLARE_HYDROGEN_ACCESSOR(Branch)
1379 virtual void PrintDataTo(StringStream* stream) OVERRIDE;
1383 class LDebugBreak FINAL : public LTemplateInstruction<0, 0, 0> {
1385 DECLARE_CONCRETE_INSTRUCTION(DebugBreak, "break")
1389 class LCmpMapAndBranch FINAL : public LControlInstruction<1, 0> {
1391 explicit LCmpMapAndBranch(LOperand* value) {
1395 LOperand* value() { return inputs_[0]; }
1397 DECLARE_CONCRETE_INSTRUCTION(CmpMapAndBranch, "cmp-map-and-branch")
1398 DECLARE_HYDROGEN_ACCESSOR(CompareMap)
1400 Handle<Map> map() const { return hydrogen()->map().handle(); }
1404 class LMapEnumLength FINAL : public LTemplateInstruction<1, 1, 0> {
1406 explicit LMapEnumLength(LOperand* value) {
1410 LOperand* value() { return inputs_[0]; }
1412 DECLARE_CONCRETE_INSTRUCTION(MapEnumLength, "map-enum-length")
1416 class LDateField FINAL : public LTemplateInstruction<1, 1, 0> {
1418 LDateField(LOperand* date, Smi* index) : index_(index) {
1422 LOperand* date() { return inputs_[0]; }
1423 Smi* index() const { return index_; }
1425 DECLARE_CONCRETE_INSTRUCTION(DateField, "date-field")
1426 DECLARE_HYDROGEN_ACCESSOR(DateField)
1433 class LSeqStringGetChar FINAL : public LTemplateInstruction<1, 2, 0> {
1435 LSeqStringGetChar(LOperand* string, LOperand* index) {
1436 inputs_[0] = string;
1440 LOperand* string() const { return inputs_[0]; }
1441 LOperand* index() const { return inputs_[1]; }
1443 DECLARE_CONCRETE_INSTRUCTION(SeqStringGetChar, "seq-string-get-char")
1444 DECLARE_HYDROGEN_ACCESSOR(SeqStringGetChar)
1448 class LSeqStringSetChar FINAL : public LTemplateInstruction<1, 4, 0> {
1450 LSeqStringSetChar(LOperand* context,
1454 inputs_[0] = context;
1455 inputs_[1] = string;
1460 LOperand* string() { return inputs_[1]; }
1461 LOperand* index() { return inputs_[2]; }
1462 LOperand* value() { return inputs_[3]; }
1464 DECLARE_CONCRETE_INSTRUCTION(SeqStringSetChar, "seq-string-set-char")
1465 DECLARE_HYDROGEN_ACCESSOR(SeqStringSetChar)
1469 class LAddI FINAL : public LTemplateInstruction<1, 2, 0> {
1471 LAddI(LOperand* left, LOperand* right) {
1476 LOperand* left() { return inputs_[0]; }
1477 LOperand* right() { return inputs_[1]; }
1479 static bool UseLea(HAdd* add) {
1480 return !add->CheckFlag(HValue::kCanOverflow) &&
1481 add->BetterLeftOperand()->UseCount() > 1;
1484 DECLARE_CONCRETE_INSTRUCTION(AddI, "add-i")
1485 DECLARE_HYDROGEN_ACCESSOR(Add)
1489 class LMathMinMax FINAL : public LTemplateInstruction<1, 2, 0> {
1491 LMathMinMax(LOperand* left, LOperand* right) {
1496 LOperand* left() { return inputs_[0]; }
1497 LOperand* right() { return inputs_[1]; }
1499 DECLARE_CONCRETE_INSTRUCTION(MathMinMax, "math-min-max")
1500 DECLARE_HYDROGEN_ACCESSOR(MathMinMax)
1504 class LPower FINAL : public LTemplateInstruction<1, 2, 0> {
1506 LPower(LOperand* left, LOperand* right) {
1511 LOperand* left() { return inputs_[0]; }
1512 LOperand* right() { return inputs_[1]; }
1514 DECLARE_CONCRETE_INSTRUCTION(Power, "power")
1515 DECLARE_HYDROGEN_ACCESSOR(Power)
1519 class LArithmeticD FINAL : public LTemplateInstruction<1, 2, 0> {
1521 LArithmeticD(Token::Value op, LOperand* left, LOperand* right)
1527 Token::Value op() const { return op_; }
1528 LOperand* left() { return inputs_[0]; }
1529 LOperand* right() { return inputs_[1]; }
1531 virtual Opcode opcode() const OVERRIDE {
1532 return LInstruction::kArithmeticD;
1534 virtual void CompileToNative(LCodeGen* generator) OVERRIDE;
1535 virtual const char* Mnemonic() const OVERRIDE;
1542 class LArithmeticT FINAL : public LTemplateInstruction<1, 3, 0> {
1544 LArithmeticT(Token::Value op,
1549 inputs_[0] = context;
1554 Token::Value op() const { return op_; }
1555 LOperand* context() { return inputs_[0]; }
1556 LOperand* left() { return inputs_[1]; }
1557 LOperand* right() { return inputs_[2]; }
1559 virtual Opcode opcode() const OVERRIDE {
1560 return LInstruction::kArithmeticT;
1562 virtual void CompileToNative(LCodeGen* generator) OVERRIDE;
1563 virtual const char* Mnemonic() const OVERRIDE;
1570 class LReturn FINAL : public LTemplateInstruction<0, 3, 0> {
1572 explicit LReturn(LOperand* value,
1574 LOperand* parameter_count) {
1576 inputs_[1] = context;
1577 inputs_[2] = parameter_count;
1580 LOperand* value() { return inputs_[0]; }
1581 LOperand* context() { return inputs_[1]; }
1583 bool has_constant_parameter_count() {
1584 return parameter_count()->IsConstantOperand();
1586 LConstantOperand* constant_parameter_count() {
1587 DCHECK(has_constant_parameter_count());
1588 return LConstantOperand::cast(parameter_count());
1590 LOperand* parameter_count() { return inputs_[2]; }
1592 DECLARE_CONCRETE_INSTRUCTION(Return, "return")
1593 DECLARE_HYDROGEN_ACCESSOR(Return)
1597 class LLoadNamedField FINAL : public LTemplateInstruction<1, 1, 0> {
1599 explicit LLoadNamedField(LOperand* object) {
1600 inputs_[0] = object;
1603 LOperand* object() { return inputs_[0]; }
1605 DECLARE_CONCRETE_INSTRUCTION(LoadNamedField, "load-named-field")
1606 DECLARE_HYDROGEN_ACCESSOR(LoadNamedField)
1610 class LLoadNamedGeneric FINAL : public LTemplateInstruction<1, 2, 1> {
1612 explicit LLoadNamedGeneric(LOperand* context, LOperand* object,
1614 inputs_[0] = context;
1615 inputs_[1] = object;
1619 DECLARE_CONCRETE_INSTRUCTION(LoadNamedGeneric, "load-named-generic")
1620 DECLARE_HYDROGEN_ACCESSOR(LoadNamedGeneric)
1622 LOperand* context() { return inputs_[0]; }
1623 LOperand* object() { return inputs_[1]; }
1624 LOperand* temp_vector() { return temps_[0]; }
1626 Handle<Object> name() const { return hydrogen()->name(); }
1630 class LLoadFunctionPrototype FINAL : public LTemplateInstruction<1, 1, 0> {
1632 explicit LLoadFunctionPrototype(LOperand* function) {
1633 inputs_[0] = function;
1636 DECLARE_CONCRETE_INSTRUCTION(LoadFunctionPrototype, "load-function-prototype")
1637 DECLARE_HYDROGEN_ACCESSOR(LoadFunctionPrototype)
1639 LOperand* function() { return inputs_[0]; }
1643 class LLoadRoot FINAL : public LTemplateInstruction<1, 0, 0> {
1645 DECLARE_CONCRETE_INSTRUCTION(LoadRoot, "load-root")
1646 DECLARE_HYDROGEN_ACCESSOR(LoadRoot)
1648 Heap::RootListIndex index() const { return hydrogen()->index(); }
1652 inline static bool ExternalArrayOpRequiresTemp(
1653 Representation key_representation,
1654 ElementsKind elements_kind) {
1655 // Operations that require the key to be divided by two to be converted into
1656 // an index cannot fold the scale operation into a load and need an extra
1657 // temp register to do the work.
1658 return SmiValuesAre31Bits() && key_representation.IsSmi() &&
1659 (elements_kind == EXTERNAL_INT8_ELEMENTS ||
1660 elements_kind == EXTERNAL_UINT8_ELEMENTS ||
1661 elements_kind == EXTERNAL_UINT8_CLAMPED_ELEMENTS ||
1662 elements_kind == UINT8_ELEMENTS ||
1663 elements_kind == INT8_ELEMENTS ||
1664 elements_kind == UINT8_CLAMPED_ELEMENTS);
1668 class LLoadKeyed FINAL : public LTemplateInstruction<1, 2, 0> {
1670 LLoadKeyed(LOperand* elements, LOperand* key) {
1671 inputs_[0] = elements;
1675 DECLARE_CONCRETE_INSTRUCTION(LoadKeyed, "load-keyed")
1676 DECLARE_HYDROGEN_ACCESSOR(LoadKeyed)
1678 bool is_external() const {
1679 return hydrogen()->is_external();
1681 bool is_fixed_typed_array() const {
1682 return hydrogen()->is_fixed_typed_array();
1684 bool is_typed_elements() const {
1685 return is_external() || is_fixed_typed_array();
1687 LOperand* elements() { return inputs_[0]; }
1688 LOperand* key() { return inputs_[1]; }
1689 virtual void PrintDataTo(StringStream* stream) OVERRIDE;
1690 uint32_t base_offset() const { return hydrogen()->base_offset(); }
1691 ElementsKind elements_kind() const {
1692 return hydrogen()->elements_kind();
1697 class LLoadKeyedGeneric FINAL : public LTemplateInstruction<1, 3, 1> {
1699 LLoadKeyedGeneric(LOperand* context, LOperand* obj, LOperand* key,
1701 inputs_[0] = context;
1707 DECLARE_CONCRETE_INSTRUCTION(LoadKeyedGeneric, "load-keyed-generic")
1708 DECLARE_HYDROGEN_ACCESSOR(LoadKeyedGeneric)
1710 LOperand* context() { return inputs_[0]; }
1711 LOperand* object() { return inputs_[1]; }
1712 LOperand* key() { return inputs_[2]; }
1713 LOperand* temp_vector() { return temps_[0]; }
1717 class LLoadGlobalCell FINAL : public LTemplateInstruction<1, 0, 0> {
1719 DECLARE_CONCRETE_INSTRUCTION(LoadGlobalCell, "load-global-cell")
1720 DECLARE_HYDROGEN_ACCESSOR(LoadGlobalCell)
1724 class LLoadGlobalGeneric FINAL : public LTemplateInstruction<1, 2, 1> {
1726 explicit LLoadGlobalGeneric(LOperand* context, LOperand* global_object,
1728 inputs_[0] = context;
1729 inputs_[1] = global_object;
1733 DECLARE_CONCRETE_INSTRUCTION(LoadGlobalGeneric, "load-global-generic")
1734 DECLARE_HYDROGEN_ACCESSOR(LoadGlobalGeneric)
1736 LOperand* context() { return inputs_[0]; }
1737 LOperand* global_object() { return inputs_[1]; }
1738 LOperand* temp_vector() { return temps_[0]; }
1740 Handle<Object> name() const { return hydrogen()->name(); }
1741 bool for_typeof() const { return hydrogen()->for_typeof(); }
1745 class LStoreGlobalCell FINAL : public LTemplateInstruction<0, 1, 1> {
1747 explicit LStoreGlobalCell(LOperand* value, LOperand* temp) {
1752 LOperand* value() { return inputs_[0]; }
1753 LOperand* temp() { return temps_[0]; }
1755 DECLARE_CONCRETE_INSTRUCTION(StoreGlobalCell, "store-global-cell")
1756 DECLARE_HYDROGEN_ACCESSOR(StoreGlobalCell)
1760 class LLoadContextSlot FINAL : public LTemplateInstruction<1, 1, 0> {
1762 explicit LLoadContextSlot(LOperand* context) {
1763 inputs_[0] = context;
1766 LOperand* context() { return inputs_[0]; }
1768 DECLARE_CONCRETE_INSTRUCTION(LoadContextSlot, "load-context-slot")
1769 DECLARE_HYDROGEN_ACCESSOR(LoadContextSlot)
1771 int slot_index() { return hydrogen()->slot_index(); }
1773 virtual void PrintDataTo(StringStream* stream) OVERRIDE;
1777 class LStoreContextSlot FINAL : public LTemplateInstruction<0, 2, 1> {
1779 LStoreContextSlot(LOperand* context, LOperand* value, LOperand* temp) {
1780 inputs_[0] = context;
1785 LOperand* context() { return inputs_[0]; }
1786 LOperand* value() { return inputs_[1]; }
1787 LOperand* temp() { return temps_[0]; }
1789 DECLARE_CONCRETE_INSTRUCTION(StoreContextSlot, "store-context-slot")
1790 DECLARE_HYDROGEN_ACCESSOR(StoreContextSlot)
1792 int slot_index() { return hydrogen()->slot_index(); }
1794 virtual void PrintDataTo(StringStream* stream) OVERRIDE;
1798 class LPushArgument FINAL : public LTemplateInstruction<0, 1, 0> {
1800 explicit LPushArgument(LOperand* value) {
1804 LOperand* value() { return inputs_[0]; }
1806 DECLARE_CONCRETE_INSTRUCTION(PushArgument, "push-argument")
1810 class LDrop FINAL : public LTemplateInstruction<0, 0, 0> {
1812 explicit LDrop(int count) : count_(count) { }
1814 int count() const { return count_; }
1816 DECLARE_CONCRETE_INSTRUCTION(Drop, "drop")
1823 class LStoreCodeEntry FINAL: public LTemplateInstruction<0, 2, 0> {
1825 LStoreCodeEntry(LOperand* function, LOperand* code_object) {
1826 inputs_[0] = function;
1827 inputs_[1] = code_object;
1830 LOperand* function() { return inputs_[0]; }
1831 LOperand* code_object() { return inputs_[1]; }
1833 virtual void PrintDataTo(StringStream* stream);
1835 DECLARE_CONCRETE_INSTRUCTION(StoreCodeEntry, "store-code-entry")
1836 DECLARE_HYDROGEN_ACCESSOR(StoreCodeEntry)
1840 class LInnerAllocatedObject FINAL: public LTemplateInstruction<1, 2, 0> {
1842 LInnerAllocatedObject(LOperand* base_object, LOperand* offset) {
1843 inputs_[0] = base_object;
1844 inputs_[1] = offset;
1847 LOperand* base_object() const { return inputs_[0]; }
1848 LOperand* offset() const { return inputs_[1]; }
1850 virtual void PrintDataTo(StringStream* stream) OVERRIDE;
1852 DECLARE_CONCRETE_INSTRUCTION(InnerAllocatedObject, "inner-allocated-object")
1856 class LThisFunction FINAL : public LTemplateInstruction<1, 0, 0> {
1858 DECLARE_CONCRETE_INSTRUCTION(ThisFunction, "this-function")
1859 DECLARE_HYDROGEN_ACCESSOR(ThisFunction)
1863 class LContext FINAL : public LTemplateInstruction<1, 0, 0> {
1865 DECLARE_CONCRETE_INSTRUCTION(Context, "context")
1866 DECLARE_HYDROGEN_ACCESSOR(Context)
1870 class LDeclareGlobals FINAL : public LTemplateInstruction<0, 1, 0> {
1872 explicit LDeclareGlobals(LOperand* context) {
1873 inputs_[0] = context;
1876 LOperand* context() { return inputs_[0]; }
1878 DECLARE_CONCRETE_INSTRUCTION(DeclareGlobals, "declare-globals")
1879 DECLARE_HYDROGEN_ACCESSOR(DeclareGlobals)
1883 class LCallJSFunction FINAL : public LTemplateInstruction<1, 1, 0> {
1885 explicit LCallJSFunction(LOperand* function) {
1886 inputs_[0] = function;
1889 LOperand* function() { return inputs_[0]; }
1891 DECLARE_CONCRETE_INSTRUCTION(CallJSFunction, "call-js-function")
1892 DECLARE_HYDROGEN_ACCESSOR(CallJSFunction)
1894 virtual void PrintDataTo(StringStream* stream) OVERRIDE;
1896 int arity() const { return hydrogen()->argument_count() - 1; }
1900 class LCallWithDescriptor FINAL : public LTemplateResultInstruction<1> {
1902 LCallWithDescriptor(CallInterfaceDescriptor descriptor,
1903 const ZoneList<LOperand*>& operands, Zone* zone)
1904 : inputs_(descriptor.GetRegisterParameterCount() + 1, zone) {
1905 DCHECK(descriptor.GetRegisterParameterCount() + 1 == operands.length());
1906 inputs_.AddAll(operands, zone);
1909 LOperand* target() const { return inputs_[0]; }
1911 DECLARE_HYDROGEN_ACCESSOR(CallWithDescriptor)
1914 DECLARE_CONCRETE_INSTRUCTION(CallWithDescriptor, "call-with-descriptor")
1916 virtual void PrintDataTo(StringStream* stream) OVERRIDE;
1918 int arity() const { return hydrogen()->argument_count() - 1; }
1920 ZoneList<LOperand*> inputs_;
1922 // Iterator support.
1923 virtual int InputCount() FINAL OVERRIDE { return inputs_.length(); }
1924 virtual LOperand* InputAt(int i) FINAL OVERRIDE { return inputs_[i]; }
1926 virtual int TempCount() FINAL OVERRIDE { return 0; }
1927 virtual LOperand* TempAt(int i) FINAL OVERRIDE { return NULL; }
1931 class LInvokeFunction FINAL : public LTemplateInstruction<1, 2, 0> {
1933 LInvokeFunction(LOperand* context, LOperand* function) {
1934 inputs_[0] = context;
1935 inputs_[1] = function;
1938 LOperand* context() { return inputs_[0]; }
1939 LOperand* function() { return inputs_[1]; }
1941 DECLARE_CONCRETE_INSTRUCTION(InvokeFunction, "invoke-function")
1942 DECLARE_HYDROGEN_ACCESSOR(InvokeFunction)
1944 virtual void PrintDataTo(StringStream* stream) OVERRIDE;
1946 int arity() const { return hydrogen()->argument_count() - 1; }
1950 class LCallFunction FINAL : public LTemplateInstruction<1, 2, 0> {
1952 LCallFunction(LOperand* context, LOperand* function) {
1953 inputs_[0] = context;
1954 inputs_[1] = function;
1957 DECLARE_CONCRETE_INSTRUCTION(CallFunction, "call-function")
1958 DECLARE_HYDROGEN_ACCESSOR(CallFunction)
1960 LOperand* context() { return inputs_[0]; }
1961 LOperand* function() { return inputs_[1]; }
1962 int arity() const { return hydrogen()->argument_count() - 1; }
1966 class LCallNew FINAL : public LTemplateInstruction<1, 2, 0> {
1968 LCallNew(LOperand* context, LOperand* constructor) {
1969 inputs_[0] = context;
1970 inputs_[1] = constructor;
1973 LOperand* context() { return inputs_[0]; }
1974 LOperand* constructor() { return inputs_[1]; }
1976 DECLARE_CONCRETE_INSTRUCTION(CallNew, "call-new")
1977 DECLARE_HYDROGEN_ACCESSOR(CallNew)
1979 virtual void PrintDataTo(StringStream* stream) OVERRIDE;
1981 int arity() const { return hydrogen()->argument_count() - 1; }
1985 class LCallNewArray FINAL : public LTemplateInstruction<1, 2, 0> {
1987 LCallNewArray(LOperand* context, LOperand* constructor) {
1988 inputs_[0] = context;
1989 inputs_[1] = constructor;
1992 LOperand* context() { return inputs_[0]; }
1993 LOperand* constructor() { return inputs_[1]; }
1995 DECLARE_CONCRETE_INSTRUCTION(CallNewArray, "call-new-array")
1996 DECLARE_HYDROGEN_ACCESSOR(CallNewArray)
1998 virtual void PrintDataTo(StringStream* stream) OVERRIDE;
2000 int arity() const { return hydrogen()->argument_count() - 1; }
2004 class LCallRuntime FINAL : public LTemplateInstruction<1, 1, 0> {
2006 explicit LCallRuntime(LOperand* context) {
2007 inputs_[0] = context;
2010 LOperand* context() { return inputs_[0]; }
2012 DECLARE_CONCRETE_INSTRUCTION(CallRuntime, "call-runtime")
2013 DECLARE_HYDROGEN_ACCESSOR(CallRuntime)
2015 virtual bool ClobbersDoubleRegisters(Isolate* isolate) const OVERRIDE {
2016 return save_doubles() == kDontSaveFPRegs;
2019 const Runtime::Function* function() const { return hydrogen()->function(); }
2020 int arity() const { return hydrogen()->argument_count(); }
2021 SaveFPRegsMode save_doubles() const { return hydrogen()->save_doubles(); }
2025 class LInteger32ToDouble FINAL : public LTemplateInstruction<1, 1, 0> {
2027 explicit LInteger32ToDouble(LOperand* value) {
2031 LOperand* value() { return inputs_[0]; }
2033 DECLARE_CONCRETE_INSTRUCTION(Integer32ToDouble, "int32-to-double")
2037 class LUint32ToDouble FINAL : public LTemplateInstruction<1, 1, 0> {
2039 explicit LUint32ToDouble(LOperand* value) {
2043 LOperand* value() { return inputs_[0]; }
2045 DECLARE_CONCRETE_INSTRUCTION(Uint32ToDouble, "uint32-to-double")
2049 class LNumberTagI FINAL : public LTemplateInstruction<1, 1, 2> {
2051 LNumberTagI(LOperand* value, LOperand* temp1, LOperand* temp2) {
2057 LOperand* value() { return inputs_[0]; }
2058 LOperand* temp1() { return temps_[0]; }
2059 LOperand* temp2() { return temps_[1]; }
2061 DECLARE_CONCRETE_INSTRUCTION(NumberTagI, "number-tag-i")
2065 class LNumberTagU FINAL : public LTemplateInstruction<1, 1, 2> {
2067 LNumberTagU(LOperand* value, LOperand* temp1, LOperand* temp2) {
2073 LOperand* value() { return inputs_[0]; }
2074 LOperand* temp1() { return temps_[0]; }
2075 LOperand* temp2() { return temps_[1]; }
2077 DECLARE_CONCRETE_INSTRUCTION(NumberTagU, "number-tag-u")
2081 class LNumberTagD FINAL : public LTemplateInstruction<1, 1, 1> {
2083 explicit LNumberTagD(LOperand* value, LOperand* temp) {
2088 LOperand* value() { return inputs_[0]; }
2089 LOperand* temp() { return temps_[0]; }
2091 DECLARE_CONCRETE_INSTRUCTION(NumberTagD, "number-tag-d")
2092 DECLARE_HYDROGEN_ACCESSOR(Change)
2096 // Sometimes truncating conversion from a tagged value to an int32.
2097 class LDoubleToI FINAL : public LTemplateInstruction<1, 1, 0> {
2099 explicit LDoubleToI(LOperand* value) {
2103 LOperand* value() { return inputs_[0]; }
2105 DECLARE_CONCRETE_INSTRUCTION(DoubleToI, "double-to-i")
2106 DECLARE_HYDROGEN_ACCESSOR(UnaryOperation)
2108 bool truncating() { return hydrogen()->CanTruncateToInt32(); }
2112 class LDoubleToSmi FINAL : public LTemplateInstruction<1, 1, 0> {
2114 explicit LDoubleToSmi(LOperand* value) {
2118 LOperand* value() { return inputs_[0]; }
2120 DECLARE_CONCRETE_INSTRUCTION(DoubleToSmi, "double-to-smi")
2121 DECLARE_HYDROGEN_ACCESSOR(UnaryOperation)
2125 // Truncating conversion from a tagged value to an int32.
2126 class LTaggedToI FINAL : public LTemplateInstruction<1, 1, 1> {
2128 LTaggedToI(LOperand* value, LOperand* temp) {
2133 LOperand* value() { return inputs_[0]; }
2134 LOperand* temp() { return temps_[0]; }
2136 DECLARE_CONCRETE_INSTRUCTION(TaggedToI, "tagged-to-i")
2137 DECLARE_HYDROGEN_ACCESSOR(Change)
2139 bool truncating() { return hydrogen()->CanTruncateToInt32(); }
2143 class LSmiTag FINAL : public LTemplateInstruction<1, 1, 0> {
2145 explicit LSmiTag(LOperand* value) {
2149 LOperand* value() { return inputs_[0]; }
2151 DECLARE_CONCRETE_INSTRUCTION(SmiTag, "smi-tag")
2152 DECLARE_HYDROGEN_ACCESSOR(Change)
2156 class LNumberUntagD FINAL : public LTemplateInstruction<1, 1, 0> {
2158 explicit LNumberUntagD(LOperand* value) {
2162 LOperand* value() { return inputs_[0]; }
2164 DECLARE_CONCRETE_INSTRUCTION(NumberUntagD, "double-untag")
2165 DECLARE_HYDROGEN_ACCESSOR(Change);
2169 class LSmiUntag FINAL : public LTemplateInstruction<1, 1, 0> {
2171 LSmiUntag(LOperand* value, bool needs_check)
2172 : needs_check_(needs_check) {
2176 LOperand* value() { return inputs_[0]; }
2177 bool needs_check() const { return needs_check_; }
2179 DECLARE_CONCRETE_INSTRUCTION(SmiUntag, "smi-untag")
2186 class LStoreNamedField FINAL : public LTemplateInstruction<0, 2, 1> {
2188 LStoreNamedField(LOperand* object, LOperand* value, LOperand* temp) {
2189 inputs_[0] = object;
2194 LOperand* object() { return inputs_[0]; }
2195 LOperand* value() { return inputs_[1]; }
2196 LOperand* temp() { return temps_[0]; }
2198 DECLARE_CONCRETE_INSTRUCTION(StoreNamedField, "store-named-field")
2199 DECLARE_HYDROGEN_ACCESSOR(StoreNamedField)
2201 virtual void PrintDataTo(StringStream* stream) OVERRIDE;
2203 Representation representation() const {
2204 return hydrogen()->field_representation();
2209 class LStoreNamedGeneric FINAL : public LTemplateInstruction<0, 3, 0> {
2211 LStoreNamedGeneric(LOperand* context, LOperand* object, LOperand* value) {
2212 inputs_[0] = context;
2213 inputs_[1] = object;
2217 LOperand* context() { return inputs_[0]; }
2218 LOperand* object() { return inputs_[1]; }
2219 LOperand* value() { return inputs_[2]; }
2221 DECLARE_CONCRETE_INSTRUCTION(StoreNamedGeneric, "store-named-generic")
2222 DECLARE_HYDROGEN_ACCESSOR(StoreNamedGeneric)
2224 virtual void PrintDataTo(StringStream* stream) OVERRIDE;
2226 Handle<Object> name() const { return hydrogen()->name(); }
2227 StrictMode strict_mode() { return hydrogen()->strict_mode(); }
2231 class LStoreKeyed FINAL : public LTemplateInstruction<0, 3, 0> {
2233 LStoreKeyed(LOperand* object, LOperand* key, LOperand* value) {
2234 inputs_[0] = object;
2239 bool is_external() const { return hydrogen()->is_external(); }
2240 bool is_fixed_typed_array() const {
2241 return hydrogen()->is_fixed_typed_array();
2243 bool is_typed_elements() const {
2244 return is_external() || is_fixed_typed_array();
2246 LOperand* elements() { return inputs_[0]; }
2247 LOperand* key() { return inputs_[1]; }
2248 LOperand* value() { return inputs_[2]; }
2249 ElementsKind elements_kind() const { return hydrogen()->elements_kind(); }
2251 DECLARE_CONCRETE_INSTRUCTION(StoreKeyed, "store-keyed")
2252 DECLARE_HYDROGEN_ACCESSOR(StoreKeyed)
2254 virtual void PrintDataTo(StringStream* stream) OVERRIDE;
2255 bool NeedsCanonicalization() { return hydrogen()->NeedsCanonicalization(); }
2256 uint32_t base_offset() const { return hydrogen()->base_offset(); }
2260 class LStoreKeyedGeneric FINAL : public LTemplateInstruction<0, 4, 0> {
2262 LStoreKeyedGeneric(LOperand* context,
2266 inputs_[0] = context;
2267 inputs_[1] = object;
2272 LOperand* context() { return inputs_[0]; }
2273 LOperand* object() { return inputs_[1]; }
2274 LOperand* key() { return inputs_[2]; }
2275 LOperand* value() { return inputs_[3]; }
2277 DECLARE_CONCRETE_INSTRUCTION(StoreKeyedGeneric, "store-keyed-generic")
2278 DECLARE_HYDROGEN_ACCESSOR(StoreKeyedGeneric)
2280 virtual void PrintDataTo(StringStream* stream) OVERRIDE;
2282 StrictMode strict_mode() { return hydrogen()->strict_mode(); }
2286 class LTransitionElementsKind FINAL : public LTemplateInstruction<0, 2, 2> {
2288 LTransitionElementsKind(LOperand* object,
2290 LOperand* new_map_temp,
2292 inputs_[0] = object;
2293 inputs_[1] = context;
2294 temps_[0] = new_map_temp;
2298 LOperand* object() { return inputs_[0]; }
2299 LOperand* context() { return inputs_[1]; }
2300 LOperand* new_map_temp() { return temps_[0]; }
2301 LOperand* temp() { return temps_[1]; }
2303 DECLARE_CONCRETE_INSTRUCTION(TransitionElementsKind,
2304 "transition-elements-kind")
2305 DECLARE_HYDROGEN_ACCESSOR(TransitionElementsKind)
2307 virtual void PrintDataTo(StringStream* stream) OVERRIDE;
2309 Handle<Map> original_map() { return hydrogen()->original_map().handle(); }
2310 Handle<Map> transitioned_map() {
2311 return hydrogen()->transitioned_map().handle();
2313 ElementsKind from_kind() { return hydrogen()->from_kind(); }
2314 ElementsKind to_kind() { return hydrogen()->to_kind(); }
2318 class LTrapAllocationMemento FINAL : public LTemplateInstruction<0, 1, 1> {
2320 LTrapAllocationMemento(LOperand* object,
2322 inputs_[0] = object;
2326 LOperand* object() { return inputs_[0]; }
2327 LOperand* temp() { return temps_[0]; }
2329 DECLARE_CONCRETE_INSTRUCTION(TrapAllocationMemento,
2330 "trap-allocation-memento")
2334 class LStringAdd FINAL : public LTemplateInstruction<1, 3, 0> {
2336 LStringAdd(LOperand* context, LOperand* left, LOperand* right) {
2337 inputs_[0] = context;
2342 LOperand* context() { return inputs_[0]; }
2343 LOperand* left() { return inputs_[1]; }
2344 LOperand* right() { return inputs_[2]; }
2346 DECLARE_CONCRETE_INSTRUCTION(StringAdd, "string-add")
2347 DECLARE_HYDROGEN_ACCESSOR(StringAdd)
2351 class LStringCharCodeAt FINAL : public LTemplateInstruction<1, 3, 0> {
2353 LStringCharCodeAt(LOperand* context, LOperand* string, LOperand* index) {
2354 inputs_[0] = context;
2355 inputs_[1] = string;
2359 LOperand* context() { return inputs_[0]; }
2360 LOperand* string() { return inputs_[1]; }
2361 LOperand* index() { return inputs_[2]; }
2363 DECLARE_CONCRETE_INSTRUCTION(StringCharCodeAt, "string-char-code-at")
2364 DECLARE_HYDROGEN_ACCESSOR(StringCharCodeAt)
2368 class LStringCharFromCode FINAL : public LTemplateInstruction<1, 2, 0> {
2370 explicit LStringCharFromCode(LOperand* context, LOperand* char_code) {
2371 inputs_[0] = context;
2372 inputs_[1] = char_code;
2375 LOperand* context() { return inputs_[0]; }
2376 LOperand* char_code() { return inputs_[1]; }
2378 DECLARE_CONCRETE_INSTRUCTION(StringCharFromCode, "string-char-from-code")
2379 DECLARE_HYDROGEN_ACCESSOR(StringCharFromCode)
2383 class LCheckValue FINAL : public LTemplateInstruction<0, 1, 0> {
2385 explicit LCheckValue(LOperand* value) {
2389 LOperand* value() { return inputs_[0]; }
2391 DECLARE_CONCRETE_INSTRUCTION(CheckValue, "check-value")
2392 DECLARE_HYDROGEN_ACCESSOR(CheckValue)
2396 class LCheckInstanceType FINAL : public LTemplateInstruction<0, 1, 0> {
2398 explicit LCheckInstanceType(LOperand* value) {
2402 LOperand* value() { return inputs_[0]; }
2404 DECLARE_CONCRETE_INSTRUCTION(CheckInstanceType, "check-instance-type")
2405 DECLARE_HYDROGEN_ACCESSOR(CheckInstanceType)
2409 class LCheckMaps FINAL : public LTemplateInstruction<0, 1, 0> {
2411 explicit LCheckMaps(LOperand* value = NULL) {
2415 LOperand* value() { return inputs_[0]; }
2417 DECLARE_CONCRETE_INSTRUCTION(CheckMaps, "check-maps")
2418 DECLARE_HYDROGEN_ACCESSOR(CheckMaps)
2422 class LCheckSmi FINAL : public LTemplateInstruction<1, 1, 0> {
2424 explicit LCheckSmi(LOperand* value) {
2428 LOperand* value() { return inputs_[0]; }
2430 DECLARE_CONCRETE_INSTRUCTION(CheckSmi, "check-smi")
2434 class LClampDToUint8 FINAL : public LTemplateInstruction<1, 1, 0> {
2436 explicit LClampDToUint8(LOperand* unclamped) {
2437 inputs_[0] = unclamped;
2440 LOperand* unclamped() { return inputs_[0]; }
2442 DECLARE_CONCRETE_INSTRUCTION(ClampDToUint8, "clamp-d-to-uint8")
2446 class LClampIToUint8 FINAL : public LTemplateInstruction<1, 1, 0> {
2448 explicit LClampIToUint8(LOperand* unclamped) {
2449 inputs_[0] = unclamped;
2452 LOperand* unclamped() { return inputs_[0]; }
2454 DECLARE_CONCRETE_INSTRUCTION(ClampIToUint8, "clamp-i-to-uint8")
2458 class LClampTToUint8 FINAL : public LTemplateInstruction<1, 1, 1> {
2460 LClampTToUint8(LOperand* unclamped,
2461 LOperand* temp_xmm) {
2462 inputs_[0] = unclamped;
2463 temps_[0] = temp_xmm;
2466 LOperand* unclamped() { return inputs_[0]; }
2467 LOperand* temp_xmm() { return temps_[0]; }
2469 DECLARE_CONCRETE_INSTRUCTION(ClampTToUint8, "clamp-t-to-uint8")
2473 class LCheckNonSmi FINAL : public LTemplateInstruction<0, 1, 0> {
2475 explicit LCheckNonSmi(LOperand* value) {
2479 LOperand* value() { return inputs_[0]; }
2481 DECLARE_CONCRETE_INSTRUCTION(CheckNonSmi, "check-non-smi")
2482 DECLARE_HYDROGEN_ACCESSOR(CheckHeapObject)
2486 class LDoubleBits FINAL : public LTemplateInstruction<1, 1, 0> {
2488 explicit LDoubleBits(LOperand* value) {
2492 LOperand* value() { return inputs_[0]; }
2494 DECLARE_CONCRETE_INSTRUCTION(DoubleBits, "double-bits")
2495 DECLARE_HYDROGEN_ACCESSOR(DoubleBits)
2499 class LConstructDouble FINAL : public LTemplateInstruction<1, 2, 0> {
2501 LConstructDouble(LOperand* hi, LOperand* lo) {
2506 LOperand* hi() { return inputs_[0]; }
2507 LOperand* lo() { return inputs_[1]; }
2509 DECLARE_CONCRETE_INSTRUCTION(ConstructDouble, "construct-double")
2513 class LAllocate FINAL : public LTemplateInstruction<1, 2, 1> {
2515 LAllocate(LOperand* context, LOperand* size, LOperand* temp) {
2516 inputs_[0] = context;
2521 LOperand* context() { return inputs_[0]; }
2522 LOperand* size() { return inputs_[1]; }
2523 LOperand* temp() { return temps_[0]; }
2525 DECLARE_CONCRETE_INSTRUCTION(Allocate, "allocate")
2526 DECLARE_HYDROGEN_ACCESSOR(Allocate)
2530 class LRegExpLiteral FINAL : public LTemplateInstruction<1, 1, 0> {
2532 explicit LRegExpLiteral(LOperand* context) {
2533 inputs_[0] = context;
2536 LOperand* context() { return inputs_[0]; }
2538 DECLARE_CONCRETE_INSTRUCTION(RegExpLiteral, "regexp-literal")
2539 DECLARE_HYDROGEN_ACCESSOR(RegExpLiteral)
2543 class LFunctionLiteral FINAL : public LTemplateInstruction<1, 1, 0> {
2545 explicit LFunctionLiteral(LOperand* context) {
2546 inputs_[0] = context;
2549 LOperand* context() { return inputs_[0]; }
2551 DECLARE_CONCRETE_INSTRUCTION(FunctionLiteral, "function-literal")
2552 DECLARE_HYDROGEN_ACCESSOR(FunctionLiteral)
2556 class LToFastProperties FINAL : public LTemplateInstruction<1, 1, 0> {
2558 explicit LToFastProperties(LOperand* value) {
2562 LOperand* value() { return inputs_[0]; }
2564 DECLARE_CONCRETE_INSTRUCTION(ToFastProperties, "to-fast-properties")
2565 DECLARE_HYDROGEN_ACCESSOR(ToFastProperties)
2569 class LTypeof FINAL : public LTemplateInstruction<1, 2, 0> {
2571 LTypeof(LOperand* context, LOperand* value) {
2572 inputs_[0] = context;
2576 LOperand* context() { return inputs_[0]; }
2577 LOperand* value() { return inputs_[1]; }
2579 DECLARE_CONCRETE_INSTRUCTION(Typeof, "typeof")
2583 class LTypeofIsAndBranch FINAL : public LControlInstruction<1, 0> {
2585 explicit LTypeofIsAndBranch(LOperand* value) {
2589 LOperand* value() { return inputs_[0]; }
2591 DECLARE_CONCRETE_INSTRUCTION(TypeofIsAndBranch, "typeof-is-and-branch")
2592 DECLARE_HYDROGEN_ACCESSOR(TypeofIsAndBranch)
2594 Handle<String> type_literal() { return hydrogen()->type_literal(); }
2596 virtual void PrintDataTo(StringStream* stream) OVERRIDE;
2600 class LIsConstructCallAndBranch FINAL : public LControlInstruction<0, 1> {
2602 explicit LIsConstructCallAndBranch(LOperand* temp) {
2606 LOperand* temp() { return temps_[0]; }
2608 DECLARE_CONCRETE_INSTRUCTION(IsConstructCallAndBranch,
2609 "is-construct-call-and-branch")
2610 DECLARE_HYDROGEN_ACCESSOR(IsConstructCallAndBranch)
2614 class LOsrEntry FINAL : public LTemplateInstruction<0, 0, 0> {
2618 virtual bool HasInterestingComment(LCodeGen* gen) const OVERRIDE {
2621 DECLARE_CONCRETE_INSTRUCTION(OsrEntry, "osr-entry")
2625 class LStackCheck FINAL : public LTemplateInstruction<0, 1, 0> {
2627 explicit LStackCheck(LOperand* context) {
2628 inputs_[0] = context;
2631 LOperand* context() { return inputs_[0]; }
2633 DECLARE_CONCRETE_INSTRUCTION(StackCheck, "stack-check")
2634 DECLARE_HYDROGEN_ACCESSOR(StackCheck)
2636 Label* done_label() { return &done_label_; }
2643 class LForInPrepareMap FINAL : public LTemplateInstruction<1, 2, 0> {
2645 LForInPrepareMap(LOperand* context, LOperand* object) {
2646 inputs_[0] = context;
2647 inputs_[1] = object;
2650 LOperand* context() { return inputs_[0]; }
2651 LOperand* object() { return inputs_[1]; }
2653 DECLARE_CONCRETE_INSTRUCTION(ForInPrepareMap, "for-in-prepare-map")
2657 class LForInCacheArray FINAL : public LTemplateInstruction<1, 1, 0> {
2659 explicit LForInCacheArray(LOperand* map) {
2663 LOperand* map() { return inputs_[0]; }
2665 DECLARE_CONCRETE_INSTRUCTION(ForInCacheArray, "for-in-cache-array")
2668 return HForInCacheArray::cast(this->hydrogen_value())->idx();
2673 class LCheckMapValue FINAL : public LTemplateInstruction<0, 2, 0> {
2675 LCheckMapValue(LOperand* value, LOperand* map) {
2680 LOperand* value() { return inputs_[0]; }
2681 LOperand* map() { return inputs_[1]; }
2683 DECLARE_CONCRETE_INSTRUCTION(CheckMapValue, "check-map-value")
2687 class LLoadFieldByIndex FINAL : public LTemplateInstruction<1, 2, 0> {
2689 LLoadFieldByIndex(LOperand* object, LOperand* index) {
2690 inputs_[0] = object;
2694 LOperand* object() { return inputs_[0]; }
2695 LOperand* index() { return inputs_[1]; }
2697 DECLARE_CONCRETE_INSTRUCTION(LoadFieldByIndex, "load-field-by-index")
2701 class LStoreFrameContext: public LTemplateInstruction<0, 1, 0> {
2703 explicit LStoreFrameContext(LOperand* context) {
2704 inputs_[0] = context;
2707 LOperand* context() { return inputs_[0]; }
2709 DECLARE_CONCRETE_INSTRUCTION(StoreFrameContext, "store-frame-context")
2713 class LAllocateBlockContext: public LTemplateInstruction<1, 2, 0> {
2715 LAllocateBlockContext(LOperand* context, LOperand* function) {
2716 inputs_[0] = context;
2717 inputs_[1] = function;
2720 LOperand* context() { return inputs_[0]; }
2721 LOperand* function() { return inputs_[1]; }
2723 Handle<ScopeInfo> scope_info() { return hydrogen()->scope_info(); }
2725 DECLARE_CONCRETE_INSTRUCTION(AllocateBlockContext, "allocate-block-context")
2726 DECLARE_HYDROGEN_ACCESSOR(AllocateBlockContext)
2730 class LChunkBuilder;
2731 class LPlatformChunk FINAL : public LChunk {
2733 LPlatformChunk(CompilationInfo* info, HGraph* graph)
2734 : LChunk(info, graph),
2735 dehoisted_key_ids_(graph->GetMaximumValueID(), graph->zone()) { }
2737 int GetNextSpillIndex(RegisterKind kind);
2738 LOperand* GetNextSpillSlot(RegisterKind kind);
2739 BitVector* GetDehoistedKeyIds() { return &dehoisted_key_ids_; }
2740 bool IsDehoistedKey(HValue* value) {
2741 return dehoisted_key_ids_.Contains(value->id());
2745 BitVector dehoisted_key_ids_;
2749 class LChunkBuilder FINAL : public LChunkBuilderBase {
2751 LChunkBuilder(CompilationInfo* info, HGraph* graph, LAllocator* allocator)
2752 : LChunkBuilderBase(info, graph),
2753 current_instruction_(NULL),
2754 current_block_(NULL),
2756 allocator_(allocator) {}
2758 // Build the sequence for the graph.
2759 LPlatformChunk* Build();
2761 // Declare methods that deal with the individual node types.
2762 #define DECLARE_DO(type) LInstruction* Do##type(H##type* node);
2763 HYDROGEN_CONCRETE_INSTRUCTION_LIST(DECLARE_DO)
2766 LInstruction* DoMathFloor(HUnaryMathOperation* instr);
2767 LInstruction* DoMathRound(HUnaryMathOperation* instr);
2768 LInstruction* DoMathFround(HUnaryMathOperation* instr);
2769 LInstruction* DoMathAbs(HUnaryMathOperation* instr);
2770 LInstruction* DoMathLog(HUnaryMathOperation* instr);
2771 LInstruction* DoMathExp(HUnaryMathOperation* instr);
2772 LInstruction* DoMathSqrt(HUnaryMathOperation* instr);
2773 LInstruction* DoMathPowHalf(HUnaryMathOperation* instr);
2774 LInstruction* DoMathClz32(HUnaryMathOperation* instr);
2775 LInstruction* DoDivByPowerOf2I(HDiv* instr);
2776 LInstruction* DoDivByConstI(HDiv* instr);
2777 LInstruction* DoDivI(HDiv* instr);
2778 LInstruction* DoModByPowerOf2I(HMod* instr);
2779 LInstruction* DoModByConstI(HMod* instr);
2780 LInstruction* DoModI(HMod* instr);
2781 LInstruction* DoFlooringDivByPowerOf2I(HMathFloorOfDiv* instr);
2782 LInstruction* DoFlooringDivByConstI(HMathFloorOfDiv* instr);
2783 LInstruction* DoFlooringDivI(HMathFloorOfDiv* instr);
2786 // Methods for getting operands for Use / Define / Temp.
2787 LUnallocated* ToUnallocated(Register reg);
2788 LUnallocated* ToUnallocated(XMMRegister reg);
2790 // Methods for setting up define-use relationships.
2791 MUST_USE_RESULT LOperand* Use(HValue* value, LUnallocated* operand);
2792 MUST_USE_RESULT LOperand* UseFixed(HValue* value, Register fixed_register);
2793 MUST_USE_RESULT LOperand* UseFixedDouble(HValue* value,
2794 XMMRegister fixed_register);
2796 // A value that is guaranteed to be allocated to a register.
2797 // Operand created by UseRegister is guaranteed to be live until the end of
2798 // instruction. This means that register allocator will not reuse it's
2799 // register for any other operand inside instruction.
2800 // Operand created by UseRegisterAtStart is guaranteed to be live only at
2801 // instruction start. Register allocator is free to assign the same register
2802 // to some other operand used inside instruction (i.e. temporary or
2804 MUST_USE_RESULT LOperand* UseRegister(HValue* value);
2805 MUST_USE_RESULT LOperand* UseRegisterAtStart(HValue* value);
2807 // An input operand in a register that may be trashed.
2808 MUST_USE_RESULT LOperand* UseTempRegister(HValue* value);
2810 // An input operand in a register that may be trashed or a constant operand.
2811 MUST_USE_RESULT LOperand* UseTempRegisterOrConstant(HValue* value);
2813 // An input operand in a register or stack slot.
2814 MUST_USE_RESULT LOperand* Use(HValue* value);
2815 MUST_USE_RESULT LOperand* UseAtStart(HValue* value);
2817 // An input operand in a register, stack slot or a constant operand.
2818 MUST_USE_RESULT LOperand* UseOrConstant(HValue* value);
2819 MUST_USE_RESULT LOperand* UseOrConstantAtStart(HValue* value);
2821 // An input operand in a register or a constant operand.
2822 MUST_USE_RESULT LOperand* UseRegisterOrConstant(HValue* value);
2823 MUST_USE_RESULT LOperand* UseRegisterOrConstantAtStart(HValue* value);
2825 // An input operand in a constant operand.
2826 MUST_USE_RESULT LOperand* UseConstant(HValue* value);
2828 // An input operand in register, stack slot or a constant operand.
2829 // Will not be moved to a register even if one is freely available.
2830 virtual MUST_USE_RESULT LOperand* UseAny(HValue* value) OVERRIDE;
2832 // Temporary operand that must be in a register.
2833 MUST_USE_RESULT LUnallocated* TempRegister();
2834 MUST_USE_RESULT LOperand* FixedTemp(Register reg);
2835 MUST_USE_RESULT LOperand* FixedTemp(XMMRegister reg);
2837 // Methods for setting up define-use relationships.
2838 // Return the same instruction that they are passed.
2839 LInstruction* Define(LTemplateResultInstruction<1>* instr,
2840 LUnallocated* result);
2841 LInstruction* DefineAsRegister(LTemplateResultInstruction<1>* instr);
2842 LInstruction* DefineAsSpilled(LTemplateResultInstruction<1>* instr,
2844 LInstruction* DefineSameAsFirst(LTemplateResultInstruction<1>* instr);
2845 LInstruction* DefineFixed(LTemplateResultInstruction<1>* instr,
2847 LInstruction* DefineFixedDouble(LTemplateResultInstruction<1>* instr,
2849 // Assigns an environment to an instruction. An instruction which can
2850 // deoptimize must have an environment.
2851 LInstruction* AssignEnvironment(LInstruction* instr);
2852 // Assigns a pointer map to an instruction. An instruction which can
2853 // trigger a GC or a lazy deoptimization must have a pointer map.
2854 LInstruction* AssignPointerMap(LInstruction* instr);
2856 enum CanDeoptimize { CAN_DEOPTIMIZE_EAGERLY, CANNOT_DEOPTIMIZE_EAGERLY };
2858 // Marks a call for the register allocator. Assigns a pointer map to
2859 // support GC and lazy deoptimization. Assigns an environment to support
2860 // eager deoptimization if CAN_DEOPTIMIZE_EAGERLY.
2861 LInstruction* MarkAsCall(
2862 LInstruction* instr,
2863 HInstruction* hinstr,
2864 CanDeoptimize can_deoptimize = CANNOT_DEOPTIMIZE_EAGERLY);
2866 void VisitInstruction(HInstruction* current);
2867 void AddInstruction(LInstruction* instr, HInstruction* current);
2869 void DoBasicBlock(HBasicBlock* block, HBasicBlock* next_block);
2870 LInstruction* DoShift(Token::Value op, HBitwiseBinaryOperation* instr);
2871 LInstruction* DoArithmeticD(Token::Value op,
2872 HArithmeticBinaryOperation* instr);
2873 LInstruction* DoArithmeticT(Token::Value op,
2874 HBinaryOperation* instr);
2875 void FindDehoistedKeyDefinitions(HValue* candidate);
2877 HInstruction* current_instruction_;
2878 HBasicBlock* current_block_;
2879 HBasicBlock* next_block_;
2880 LAllocator* allocator_;
2882 DISALLOW_COPY_AND_ASSIGN(LChunkBuilder);
2885 #undef DECLARE_HYDROGEN_ACCESSOR
2886 #undef DECLARE_CONCRETE_INSTRUCTION
2888 } } // namespace v8::int
2890 #endif // V8_X64_LITHIUM_X64_H_