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(CheckArrayBufferNotNeutered) \
41 V(CheckInstanceType) \
50 V(ClassOfTestAndBranch) \
51 V(CompareMinusZeroAndBranch) \
52 V(CompareNumericAndBranch) \
53 V(CmpObjectEqAndBranch) \
77 V(FlooringDivByConstI) \
78 V(FlooringDivByPowerOf2I) \
83 V(GetCachedArrayIndex) \
85 V(HasCachedArrayIndexAndBranch) \
86 V(HasInstanceTypeAndBranch) \
87 V(InnerAllocatedObject) \
89 V(InstanceOfKnownGlobal) \
91 V(Integer32ToDouble) \
93 V(IsConstructCallAndBranch) \
94 V(IsObjectAndBranch) \
95 V(IsStringAndBranch) \
97 V(IsUndetectableAndBranch) \
102 V(LoadFieldByIndex) \
103 V(LoadFunctionPrototype) \
104 V(LoadGlobalGeneric) \
106 V(LoadKeyedGeneric) \
108 V(LoadNamedGeneric) \
120 V(MaybeGrowElements) \
135 V(SeqStringGetChar) \
136 V(SeqStringSetChar) \
142 V(StoreContextSlot) \
143 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 Opcode opcode() const final { return LInstruction::k##type; } \
168 void CompileToNative(LCodeGen* generator) final; \
169 const char* Mnemonic() const final { return mnemonic; } \
170 static L##type* cast(LInstruction* instr) { \
171 DCHECK(instr->Is##type()); \
172 return reinterpret_cast<L##type*>(instr); \
176 #define DECLARE_HYDROGEN_ACCESSOR(type) \
177 H##type* hydrogen() const { \
178 return H##type::cast(hydrogen_value()); \
182 class LInstruction : public ZoneObject {
185 : environment_(NULL),
186 hydrogen_value_(NULL),
187 bit_field_(IsCallBits::encode(false)) {
190 virtual ~LInstruction() {}
192 virtual void CompileToNative(LCodeGen* generator) = 0;
193 virtual const char* Mnemonic() const = 0;
194 virtual void PrintTo(StringStream* stream);
195 virtual void PrintDataTo(StringStream* stream);
196 virtual void PrintOutputOperandTo(StringStream* stream);
199 // Declare a unique enum value for each instruction.
200 #define DECLARE_OPCODE(type) k##type,
201 LITHIUM_CONCRETE_INSTRUCTION_LIST(DECLARE_OPCODE)
202 kNumberOfInstructions
203 #undef DECLARE_OPCODE
206 virtual Opcode opcode() const = 0;
208 // Declare non-virtual type testers for all leaf IR classes.
209 #define DECLARE_PREDICATE(type) \
210 bool Is##type() const { return opcode() == k##type; }
211 LITHIUM_CONCRETE_INSTRUCTION_LIST(DECLARE_PREDICATE)
212 #undef DECLARE_PREDICATE
214 // Declare virtual predicates for instructions that don't have
216 virtual bool IsGap() const { return false; }
218 virtual bool IsControl() const { return false; }
220 // Try deleting this instruction if possible.
221 virtual bool TryDelete() { return false; }
223 void set_environment(LEnvironment* env) { environment_ = env; }
224 LEnvironment* environment() const { return environment_; }
225 bool HasEnvironment() const { return environment_ != NULL; }
227 void set_pointer_map(LPointerMap* p) { pointer_map_.set(p); }
228 LPointerMap* pointer_map() const { return pointer_map_.get(); }
229 bool HasPointerMap() const { return pointer_map_.is_set(); }
231 void set_hydrogen_value(HValue* value) { hydrogen_value_ = value; }
232 HValue* hydrogen_value() const { return hydrogen_value_; }
234 void MarkAsCall() { bit_field_ = IsCallBits::update(bit_field_, true); }
235 bool IsCall() const { return IsCallBits::decode(bit_field_); }
237 // Interface to the register allocator and iterators.
238 bool ClobbersTemps() const { return IsCall(); }
239 bool ClobbersRegisters() const { return IsCall(); }
240 virtual bool ClobbersDoubleRegisters(Isolate* isolate) const {
244 virtual void SetDeferredLazyDeoptimizationEnvironment(LEnvironment* env) { }
246 // Interface to the register allocator and iterators.
247 bool IsMarkedAsCall() const { return IsCall(); }
249 virtual bool HasResult() const = 0;
250 virtual LOperand* result() const = 0;
252 LOperand* FirstInput() { return InputAt(0); }
253 LOperand* Output() { return HasResult() ? result() : NULL; }
255 virtual bool HasInterestingComment(LCodeGen* gen) const { return true; }
257 virtual bool MustSignExtendResult(LPlatformChunk* chunk) const {
265 virtual int InputCount() = 0;
266 virtual LOperand* InputAt(int i) = 0;
270 friend class InputIterator;
272 friend class TempIterator;
273 virtual int TempCount() = 0;
274 virtual LOperand* TempAt(int i) = 0;
276 class IsCallBits: public BitField<bool, 0, 1> {};
278 LEnvironment* environment_;
279 SetOncePointer<LPointerMap> pointer_map_;
280 HValue* hydrogen_value_;
285 // R = number of result operands (0 or 1).
287 class LTemplateResultInstruction : public LInstruction {
289 // Allow 0 or 1 output operands.
290 STATIC_ASSERT(R == 0 || R == 1);
291 bool HasResult() const final { return R != 0 && result() != NULL; }
292 void set_result(LOperand* operand) { results_[0] = operand; }
293 LOperand* result() const override { return results_[0]; }
295 bool MustSignExtendResult(LPlatformChunk* chunk) const final;
298 EmbeddedContainer<LOperand*, R> results_;
302 // R = number of result operands (0 or 1).
303 // I = number of input operands.
304 // T = number of temporary operands.
305 template<int R, int I, int T>
306 class LTemplateInstruction : public LTemplateResultInstruction<R> {
308 EmbeddedContainer<LOperand*, I> inputs_;
309 EmbeddedContainer<LOperand*, T> temps_;
313 int InputCount() final { return I; }
314 LOperand* InputAt(int i) final { return inputs_[i]; }
316 int TempCount() final { return T; }
317 LOperand* TempAt(int i) final { return temps_[i]; }
321 class LGap : public LTemplateInstruction<0, 0, 0> {
323 explicit LGap(HBasicBlock* block)
325 parallel_moves_[BEFORE] = NULL;
326 parallel_moves_[START] = NULL;
327 parallel_moves_[END] = NULL;
328 parallel_moves_[AFTER] = NULL;
331 // Can't use the DECLARE-macro here because of sub-classes.
332 bool IsGap() const final { return true; }
333 void PrintDataTo(StringStream* stream) override;
334 static LGap* cast(LInstruction* instr) {
335 DCHECK(instr->IsGap());
336 return reinterpret_cast<LGap*>(instr);
339 bool IsRedundant() const;
341 HBasicBlock* block() const { return block_; }
348 FIRST_INNER_POSITION = BEFORE,
349 LAST_INNER_POSITION = AFTER
352 LParallelMove* GetOrCreateParallelMove(InnerPosition pos,
354 if (parallel_moves_[pos] == NULL) {
355 parallel_moves_[pos] = new(zone) LParallelMove(zone);
357 return parallel_moves_[pos];
360 LParallelMove* GetParallelMove(InnerPosition pos) {
361 return parallel_moves_[pos];
365 LParallelMove* parallel_moves_[LAST_INNER_POSITION + 1];
370 class LInstructionGap final : public LGap {
372 explicit LInstructionGap(HBasicBlock* block) : LGap(block) { }
374 bool HasInterestingComment(LCodeGen* gen) const override {
375 return !IsRedundant();
378 DECLARE_CONCRETE_INSTRUCTION(InstructionGap, "gap")
382 class LGoto final : public LTemplateInstruction<0, 0, 0> {
384 explicit LGoto(HBasicBlock* block) : block_(block) { }
386 bool HasInterestingComment(LCodeGen* gen) const override;
387 DECLARE_CONCRETE_INSTRUCTION(Goto, "goto")
388 void PrintDataTo(StringStream* stream) override;
389 bool IsControl() const override { return true; }
391 int block_id() const { return block_->block_id(); }
398 class LLazyBailout final : public LTemplateInstruction<0, 0, 0> {
400 LLazyBailout() : gap_instructions_size_(0) { }
402 DECLARE_CONCRETE_INSTRUCTION(LazyBailout, "lazy-bailout")
404 void set_gap_instructions_size(int gap_instructions_size) {
405 gap_instructions_size_ = gap_instructions_size;
407 int gap_instructions_size() { return gap_instructions_size_; }
410 int gap_instructions_size_;
414 class LDummy final : public LTemplateInstruction<1, 0, 0> {
417 DECLARE_CONCRETE_INSTRUCTION(Dummy, "dummy")
421 class LDummyUse final : public LTemplateInstruction<1, 1, 0> {
423 explicit LDummyUse(LOperand* value) {
426 DECLARE_CONCRETE_INSTRUCTION(DummyUse, "dummy-use")
430 class LDeoptimize final : public LTemplateInstruction<0, 0, 0> {
432 bool IsControl() const override { return true; }
433 DECLARE_CONCRETE_INSTRUCTION(Deoptimize, "deoptimize")
434 DECLARE_HYDROGEN_ACCESSOR(Deoptimize)
438 class LLabel final : public LGap {
440 explicit LLabel(HBasicBlock* block)
441 : LGap(block), replacement_(NULL) { }
443 bool HasInterestingComment(LCodeGen* gen) const override { return false; }
444 DECLARE_CONCRETE_INSTRUCTION(Label, "label")
446 void PrintDataTo(StringStream* stream) override;
448 int block_id() const { return block()->block_id(); }
449 bool is_loop_header() const { return block()->IsLoopHeader(); }
450 bool is_osr_entry() const { return block()->is_osr_entry(); }
451 Label* label() { return &label_; }
452 LLabel* replacement() const { return replacement_; }
453 void set_replacement(LLabel* label) { replacement_ = label; }
454 bool HasReplacement() const { return replacement_ != NULL; }
458 LLabel* replacement_;
462 class LParameter final : public LTemplateInstruction<1, 0, 0> {
464 bool HasInterestingComment(LCodeGen* gen) const override { return false; }
465 DECLARE_CONCRETE_INSTRUCTION(Parameter, "parameter")
469 class LCallStub final : public LTemplateInstruction<1, 1, 0> {
471 explicit LCallStub(LOperand* context) {
472 inputs_[0] = context;
475 LOperand* context() { return inputs_[0]; }
477 DECLARE_CONCRETE_INSTRUCTION(CallStub, "call-stub")
478 DECLARE_HYDROGEN_ACCESSOR(CallStub)
482 class LTailCallThroughMegamorphicCache final
483 : public LTemplateInstruction<0, 3, 0> {
485 explicit LTailCallThroughMegamorphicCache(LOperand* context,
488 inputs_[0] = context;
489 inputs_[1] = receiver;
493 LOperand* context() { return inputs_[0]; }
494 LOperand* receiver() { return inputs_[1]; }
495 LOperand* name() { return inputs_[2]; }
497 DECLARE_CONCRETE_INSTRUCTION(TailCallThroughMegamorphicCache,
498 "tail-call-through-megamorphic-cache")
499 DECLARE_HYDROGEN_ACCESSOR(TailCallThroughMegamorphicCache)
503 class LUnknownOSRValue final : public LTemplateInstruction<1, 0, 0> {
505 bool HasInterestingComment(LCodeGen* gen) const override { return false; }
506 DECLARE_CONCRETE_INSTRUCTION(UnknownOSRValue, "unknown-osr-value")
510 template<int I, int T>
511 class LControlInstruction : public LTemplateInstruction<0, I, T> {
513 LControlInstruction() : false_label_(NULL), true_label_(NULL) { }
515 bool IsControl() const final { return true; }
517 int SuccessorCount() { return hydrogen()->SuccessorCount(); }
518 HBasicBlock* SuccessorAt(int i) { return hydrogen()->SuccessorAt(i); }
520 int TrueDestination(LChunk* chunk) {
521 return chunk->LookupDestination(true_block_id());
523 int FalseDestination(LChunk* chunk) {
524 return chunk->LookupDestination(false_block_id());
527 Label* TrueLabel(LChunk* chunk) {
528 if (true_label_ == NULL) {
529 true_label_ = chunk->GetAssemblyLabel(TrueDestination(chunk));
533 Label* FalseLabel(LChunk* chunk) {
534 if (false_label_ == NULL) {
535 false_label_ = chunk->GetAssemblyLabel(FalseDestination(chunk));
541 int true_block_id() { return SuccessorAt(0)->block_id(); }
542 int false_block_id() { return SuccessorAt(1)->block_id(); }
545 HControlInstruction* hydrogen() {
546 return HControlInstruction::cast(this->hydrogen_value());
554 class LWrapReceiver final : public LTemplateInstruction<1, 2, 0> {
556 LWrapReceiver(LOperand* receiver, LOperand* function) {
557 inputs_[0] = receiver;
558 inputs_[1] = function;
561 LOperand* receiver() { return inputs_[0]; }
562 LOperand* function() { return inputs_[1]; }
564 DECLARE_CONCRETE_INSTRUCTION(WrapReceiver, "wrap-receiver")
565 DECLARE_HYDROGEN_ACCESSOR(WrapReceiver)
569 class LApplyArguments final : public LTemplateInstruction<1, 4, 0> {
571 LApplyArguments(LOperand* function,
574 LOperand* elements) {
575 inputs_[0] = function;
576 inputs_[1] = receiver;
578 inputs_[3] = elements;
581 LOperand* function() { return inputs_[0]; }
582 LOperand* receiver() { return inputs_[1]; }
583 LOperand* length() { return inputs_[2]; }
584 LOperand* elements() { return inputs_[3]; }
586 DECLARE_CONCRETE_INSTRUCTION(ApplyArguments, "apply-arguments")
590 class LAccessArgumentsAt final : public LTemplateInstruction<1, 3, 0> {
592 LAccessArgumentsAt(LOperand* arguments, LOperand* length, LOperand* index) {
593 inputs_[0] = arguments;
598 LOperand* arguments() { return inputs_[0]; }
599 LOperand* length() { return inputs_[1]; }
600 LOperand* index() { return inputs_[2]; }
602 DECLARE_CONCRETE_INSTRUCTION(AccessArgumentsAt, "access-arguments-at")
604 void PrintDataTo(StringStream* stream) override;
608 class LArgumentsLength final : public LTemplateInstruction<1, 1, 0> {
610 explicit LArgumentsLength(LOperand* elements) {
611 inputs_[0] = elements;
614 LOperand* elements() { return inputs_[0]; }
616 DECLARE_CONCRETE_INSTRUCTION(ArgumentsLength, "arguments-length")
620 class LArgumentsElements final : public LTemplateInstruction<1, 0, 0> {
622 DECLARE_CONCRETE_INSTRUCTION(ArgumentsElements, "arguments-elements")
623 DECLARE_HYDROGEN_ACCESSOR(ArgumentsElements)
627 class LModByPowerOf2I final : public LTemplateInstruction<1, 1, 0> {
629 LModByPowerOf2I(LOperand* dividend, int32_t divisor) {
630 inputs_[0] = dividend;
634 LOperand* dividend() { return inputs_[0]; }
635 int32_t divisor() const { return divisor_; }
637 DECLARE_CONCRETE_INSTRUCTION(ModByPowerOf2I, "mod-by-power-of-2-i")
638 DECLARE_HYDROGEN_ACCESSOR(Mod)
645 class LModByConstI final : public LTemplateInstruction<1, 1, 2> {
647 LModByConstI(LOperand* dividend,
651 inputs_[0] = dividend;
657 LOperand* dividend() { return inputs_[0]; }
658 int32_t divisor() const { return divisor_; }
659 LOperand* temp1() { return temps_[0]; }
660 LOperand* temp2() { return temps_[1]; }
662 DECLARE_CONCRETE_INSTRUCTION(ModByConstI, "mod-by-const-i")
663 DECLARE_HYDROGEN_ACCESSOR(Mod)
670 class LModI final : public LTemplateInstruction<1, 2, 1> {
672 LModI(LOperand* left, LOperand* right, LOperand* temp) {
678 LOperand* left() { return inputs_[0]; }
679 LOperand* right() { return inputs_[1]; }
680 LOperand* temp() { return temps_[0]; }
682 DECLARE_CONCRETE_INSTRUCTION(ModI, "mod-i")
683 DECLARE_HYDROGEN_ACCESSOR(Mod)
687 class LDivByPowerOf2I final : public LTemplateInstruction<1, 1, 0> {
689 LDivByPowerOf2I(LOperand* dividend, int32_t divisor) {
690 inputs_[0] = dividend;
694 LOperand* dividend() { return inputs_[0]; }
695 int32_t divisor() const { return divisor_; }
697 DECLARE_CONCRETE_INSTRUCTION(DivByPowerOf2I, "div-by-power-of-2-i")
698 DECLARE_HYDROGEN_ACCESSOR(Div)
705 class LDivByConstI final : public LTemplateInstruction<1, 1, 2> {
707 LDivByConstI(LOperand* dividend,
711 inputs_[0] = dividend;
717 LOperand* dividend() { return inputs_[0]; }
718 int32_t divisor() const { return divisor_; }
719 LOperand* temp1() { return temps_[0]; }
720 LOperand* temp2() { return temps_[1]; }
722 DECLARE_CONCRETE_INSTRUCTION(DivByConstI, "div-by-const-i")
723 DECLARE_HYDROGEN_ACCESSOR(Div)
730 class LDivI final : public LTemplateInstruction<1, 2, 1> {
732 LDivI(LOperand* dividend, LOperand* divisor, LOperand* temp) {
733 inputs_[0] = dividend;
734 inputs_[1] = divisor;
738 LOperand* dividend() { return inputs_[0]; }
739 LOperand* divisor() { return inputs_[1]; }
740 LOperand* temp() { return temps_[0]; }
742 DECLARE_CONCRETE_INSTRUCTION(DivI, "div-i")
743 DECLARE_HYDROGEN_ACCESSOR(BinaryOperation)
747 class LFlooringDivByPowerOf2I final : public LTemplateInstruction<1, 1, 0> {
749 LFlooringDivByPowerOf2I(LOperand* dividend, int32_t divisor) {
750 inputs_[0] = dividend;
754 LOperand* dividend() { return inputs_[0]; }
755 int32_t divisor() const { return divisor_; }
757 DECLARE_CONCRETE_INSTRUCTION(FlooringDivByPowerOf2I,
758 "flooring-div-by-power-of-2-i")
759 DECLARE_HYDROGEN_ACCESSOR(MathFloorOfDiv)
766 class LFlooringDivByConstI final : public LTemplateInstruction<1, 1, 3> {
768 LFlooringDivByConstI(LOperand* dividend,
773 inputs_[0] = dividend;
780 LOperand* dividend() { return inputs_[0]; }
781 int32_t divisor() const { return divisor_; }
782 LOperand* temp1() { return temps_[0]; }
783 LOperand* temp2() { return temps_[1]; }
784 LOperand* temp3() { return temps_[2]; }
786 DECLARE_CONCRETE_INSTRUCTION(FlooringDivByConstI, "flooring-div-by-const-i")
787 DECLARE_HYDROGEN_ACCESSOR(MathFloorOfDiv)
794 class LFlooringDivI final : public LTemplateInstruction<1, 2, 1> {
796 LFlooringDivI(LOperand* dividend, LOperand* divisor, LOperand* temp) {
797 inputs_[0] = dividend;
798 inputs_[1] = divisor;
802 LOperand* dividend() { return inputs_[0]; }
803 LOperand* divisor() { return inputs_[1]; }
804 LOperand* temp() { return temps_[0]; }
806 DECLARE_CONCRETE_INSTRUCTION(FlooringDivI, "flooring-div-i")
807 DECLARE_HYDROGEN_ACCESSOR(MathFloorOfDiv)
811 class LMulI final : public LTemplateInstruction<1, 2, 0> {
813 LMulI(LOperand* left, LOperand* right) {
818 LOperand* left() { return inputs_[0]; }
819 LOperand* right() { return inputs_[1]; }
821 DECLARE_CONCRETE_INSTRUCTION(MulI, "mul-i")
822 DECLARE_HYDROGEN_ACCESSOR(Mul)
826 class LCompareNumericAndBranch final : public LControlInstruction<2, 0> {
828 LCompareNumericAndBranch(LOperand* left, LOperand* right) {
833 LOperand* left() { return inputs_[0]; }
834 LOperand* right() { return inputs_[1]; }
836 DECLARE_CONCRETE_INSTRUCTION(CompareNumericAndBranch,
837 "compare-numeric-and-branch")
838 DECLARE_HYDROGEN_ACCESSOR(CompareNumericAndBranch)
840 Token::Value op() const { return hydrogen()->token(); }
841 bool is_double() const {
842 return hydrogen()->representation().IsDouble();
845 void PrintDataTo(StringStream* stream) override;
849 class LMathFloor final : public LTemplateInstruction<1, 1, 0> {
851 explicit LMathFloor(LOperand* value) {
855 LOperand* value() { return inputs_[0]; }
857 DECLARE_CONCRETE_INSTRUCTION(MathFloor, "math-floor")
858 DECLARE_HYDROGEN_ACCESSOR(UnaryMathOperation)
862 class LMathRound final : public LTemplateInstruction<1, 1, 1> {
864 LMathRound(LOperand* value, LOperand* temp) {
869 LOperand* value() { return inputs_[0]; }
870 LOperand* temp() { return temps_[0]; }
872 DECLARE_CONCRETE_INSTRUCTION(MathRound, "math-round")
873 DECLARE_HYDROGEN_ACCESSOR(UnaryMathOperation)
877 class LMathFround final : public LTemplateInstruction<1, 1, 0> {
879 explicit LMathFround(LOperand* value) { inputs_[0] = value; }
881 LOperand* value() { return inputs_[0]; }
883 DECLARE_CONCRETE_INSTRUCTION(MathFround, "math-fround")
887 class LMathAbs final : public LTemplateInstruction<1, 2, 0> {
889 explicit LMathAbs(LOperand* context, LOperand* value) {
890 inputs_[1] = context;
894 LOperand* context() { return inputs_[1]; }
895 LOperand* value() { return inputs_[0]; }
897 DECLARE_CONCRETE_INSTRUCTION(MathAbs, "math-abs")
898 DECLARE_HYDROGEN_ACCESSOR(UnaryMathOperation)
902 class LMathLog final : public LTemplateInstruction<1, 1, 0> {
904 explicit LMathLog(LOperand* value) {
908 LOperand* value() { return inputs_[0]; }
910 DECLARE_CONCRETE_INSTRUCTION(MathLog, "math-log")
914 class LMathClz32 final : public LTemplateInstruction<1, 1, 0> {
916 explicit LMathClz32(LOperand* value) {
920 LOperand* value() { return inputs_[0]; }
922 DECLARE_CONCRETE_INSTRUCTION(MathClz32, "math-clz32")
926 class LMathExp final : public LTemplateInstruction<1, 1, 2> {
928 LMathExp(LOperand* value, LOperand* temp1, LOperand* temp2) {
932 ExternalReference::InitializeMathExpData();
935 LOperand* value() { return inputs_[0]; }
936 LOperand* temp1() { return temps_[0]; }
937 LOperand* temp2() { return temps_[1]; }
939 DECLARE_CONCRETE_INSTRUCTION(MathExp, "math-exp")
943 class LMathSqrt final : public LTemplateInstruction<1, 1, 0> {
945 explicit LMathSqrt(LOperand* value) {
949 LOperand* value() { return inputs_[0]; }
951 DECLARE_CONCRETE_INSTRUCTION(MathSqrt, "math-sqrt")
955 class LMathPowHalf final : public LTemplateInstruction<1, 1, 0> {
957 explicit LMathPowHalf(LOperand* value) {
961 LOperand* value() { return inputs_[0]; }
963 DECLARE_CONCRETE_INSTRUCTION(MathPowHalf, "math-pow-half")
967 class LCmpObjectEqAndBranch final : public LControlInstruction<2, 0> {
969 LCmpObjectEqAndBranch(LOperand* left, LOperand* right) {
974 LOperand* left() { return inputs_[0]; }
975 LOperand* right() { return inputs_[1]; }
977 DECLARE_CONCRETE_INSTRUCTION(CmpObjectEqAndBranch, "cmp-object-eq-and-branch")
981 class LCmpHoleAndBranch final : public LControlInstruction<1, 0> {
983 explicit LCmpHoleAndBranch(LOperand* object) {
987 LOperand* object() { return inputs_[0]; }
989 DECLARE_CONCRETE_INSTRUCTION(CmpHoleAndBranch, "cmp-hole-and-branch")
990 DECLARE_HYDROGEN_ACCESSOR(CompareHoleAndBranch)
994 class LCompareMinusZeroAndBranch final : public LControlInstruction<1, 0> {
996 explicit LCompareMinusZeroAndBranch(LOperand* value) {
1000 LOperand* value() { return inputs_[0]; }
1002 DECLARE_CONCRETE_INSTRUCTION(CompareMinusZeroAndBranch,
1003 "cmp-minus-zero-and-branch")
1004 DECLARE_HYDROGEN_ACCESSOR(CompareMinusZeroAndBranch)
1008 class LIsObjectAndBranch final : public LControlInstruction<1, 0> {
1010 explicit LIsObjectAndBranch(LOperand* value) {
1014 LOperand* value() { return inputs_[0]; }
1016 DECLARE_CONCRETE_INSTRUCTION(IsObjectAndBranch, "is-object-and-branch")
1017 DECLARE_HYDROGEN_ACCESSOR(IsObjectAndBranch)
1019 void PrintDataTo(StringStream* stream) override;
1023 class LIsStringAndBranch final : public LControlInstruction<1, 1> {
1025 explicit LIsStringAndBranch(LOperand* value, LOperand* temp) {
1030 LOperand* value() { return inputs_[0]; }
1031 LOperand* temp() { return temps_[0]; }
1033 DECLARE_CONCRETE_INSTRUCTION(IsStringAndBranch, "is-string-and-branch")
1034 DECLARE_HYDROGEN_ACCESSOR(IsStringAndBranch)
1036 void PrintDataTo(StringStream* stream) override;
1040 class LIsSmiAndBranch final : public LControlInstruction<1, 0> {
1042 explicit LIsSmiAndBranch(LOperand* value) {
1046 LOperand* value() { return inputs_[0]; }
1048 DECLARE_CONCRETE_INSTRUCTION(IsSmiAndBranch, "is-smi-and-branch")
1049 DECLARE_HYDROGEN_ACCESSOR(IsSmiAndBranch)
1051 void PrintDataTo(StringStream* stream) override;
1055 class LIsUndetectableAndBranch final : public LControlInstruction<1, 1> {
1057 explicit LIsUndetectableAndBranch(LOperand* value, LOperand* temp) {
1062 LOperand* value() { return inputs_[0]; }
1063 LOperand* temp() { return temps_[0]; }
1065 DECLARE_CONCRETE_INSTRUCTION(IsUndetectableAndBranch,
1066 "is-undetectable-and-branch")
1067 DECLARE_HYDROGEN_ACCESSOR(IsUndetectableAndBranch)
1069 void PrintDataTo(StringStream* stream) override;
1073 class LStringCompareAndBranch final : public LControlInstruction<3, 0> {
1075 explicit LStringCompareAndBranch(LOperand* context,
1078 inputs_[0] = context;
1083 LOperand* context() { return inputs_[0]; }
1084 LOperand* left() { return inputs_[1]; }
1085 LOperand* right() { return inputs_[2]; }
1087 DECLARE_CONCRETE_INSTRUCTION(StringCompareAndBranch,
1088 "string-compare-and-branch")
1089 DECLARE_HYDROGEN_ACCESSOR(StringCompareAndBranch)
1091 void PrintDataTo(StringStream* stream) override;
1093 Token::Value op() const { return hydrogen()->token(); }
1097 class LHasInstanceTypeAndBranch final : public LControlInstruction<1, 0> {
1099 explicit LHasInstanceTypeAndBranch(LOperand* value) {
1103 LOperand* value() { return inputs_[0]; }
1105 DECLARE_CONCRETE_INSTRUCTION(HasInstanceTypeAndBranch,
1106 "has-instance-type-and-branch")
1107 DECLARE_HYDROGEN_ACCESSOR(HasInstanceTypeAndBranch)
1109 void PrintDataTo(StringStream* stream) override;
1113 class LGetCachedArrayIndex final : public LTemplateInstruction<1, 1, 0> {
1115 explicit LGetCachedArrayIndex(LOperand* value) {
1119 LOperand* value() { return inputs_[0]; }
1121 DECLARE_CONCRETE_INSTRUCTION(GetCachedArrayIndex, "get-cached-array-index")
1122 DECLARE_HYDROGEN_ACCESSOR(GetCachedArrayIndex)
1126 class LHasCachedArrayIndexAndBranch final : public LControlInstruction<1, 0> {
1128 explicit LHasCachedArrayIndexAndBranch(LOperand* value) {
1132 LOperand* value() { return inputs_[0]; }
1134 DECLARE_CONCRETE_INSTRUCTION(HasCachedArrayIndexAndBranch,
1135 "has-cached-array-index-and-branch")
1136 DECLARE_HYDROGEN_ACCESSOR(HasCachedArrayIndexAndBranch)
1138 void PrintDataTo(StringStream* stream) override;
1142 class LClassOfTestAndBranch final : public LControlInstruction<1, 2> {
1144 LClassOfTestAndBranch(LOperand* value, LOperand* temp, LOperand* temp2) {
1150 LOperand* value() { return inputs_[0]; }
1151 LOperand* temp() { return temps_[0]; }
1152 LOperand* temp2() { return temps_[1]; }
1154 DECLARE_CONCRETE_INSTRUCTION(ClassOfTestAndBranch,
1155 "class-of-test-and-branch")
1156 DECLARE_HYDROGEN_ACCESSOR(ClassOfTestAndBranch)
1158 void PrintDataTo(StringStream* stream) override;
1162 class LCmpT final : public LTemplateInstruction<1, 3, 0> {
1164 LCmpT(LOperand* context, LOperand* left, LOperand* right) {
1165 inputs_[0] = context;
1170 LOperand* context() { return inputs_[0]; }
1171 LOperand* left() { return inputs_[1]; }
1172 LOperand* right() { return inputs_[2]; }
1174 DECLARE_CONCRETE_INSTRUCTION(CmpT, "cmp-t")
1175 DECLARE_HYDROGEN_ACCESSOR(CompareGeneric)
1177 Token::Value op() const { return hydrogen()->token(); }
1181 class LInstanceOf final : public LTemplateInstruction<1, 3, 0> {
1183 LInstanceOf(LOperand* context, LOperand* left, LOperand* right) {
1184 inputs_[0] = context;
1189 LOperand* context() { return inputs_[0]; }
1190 LOperand* left() { return inputs_[1]; }
1191 LOperand* right() { return inputs_[2]; }
1193 DECLARE_CONCRETE_INSTRUCTION(InstanceOf, "instance-of")
1197 class LInstanceOfKnownGlobal final : public LTemplateInstruction<1, 2, 1> {
1199 LInstanceOfKnownGlobal(LOperand* context, LOperand* value, LOperand* temp) {
1200 inputs_[0] = context;
1205 LOperand* context() { return inputs_[0]; }
1206 LOperand* value() { return inputs_[1]; }
1207 LOperand* temp() { return temps_[0]; }
1209 DECLARE_CONCRETE_INSTRUCTION(InstanceOfKnownGlobal,
1210 "instance-of-known-global")
1211 DECLARE_HYDROGEN_ACCESSOR(InstanceOfKnownGlobal)
1213 Handle<JSFunction> function() const { return hydrogen()->function(); }
1214 LEnvironment* GetDeferredLazyDeoptimizationEnvironment() {
1215 return lazy_deopt_env_;
1217 virtual void SetDeferredLazyDeoptimizationEnvironment(
1218 LEnvironment* env) override {
1219 lazy_deopt_env_ = env;
1223 LEnvironment* lazy_deopt_env_;
1227 class LBoundsCheck final : public LTemplateInstruction<0, 2, 0> {
1229 LBoundsCheck(LOperand* index, LOperand* length) {
1231 inputs_[1] = length;
1234 LOperand* index() { return inputs_[0]; }
1235 LOperand* length() { return inputs_[1]; }
1237 DECLARE_CONCRETE_INSTRUCTION(BoundsCheck, "bounds-check")
1238 DECLARE_HYDROGEN_ACCESSOR(BoundsCheck)
1242 class LBitI final : public LTemplateInstruction<1, 2, 0> {
1244 LBitI(LOperand* left, LOperand* right) {
1249 LOperand* left() { return inputs_[0]; }
1250 LOperand* right() { return inputs_[1]; }
1252 Token::Value op() const { return hydrogen()->op(); }
1253 bool IsInteger32() const {
1254 return hydrogen()->representation().IsInteger32();
1257 DECLARE_CONCRETE_INSTRUCTION(BitI, "bit-i")
1258 DECLARE_HYDROGEN_ACCESSOR(Bitwise)
1262 class LShiftI final : public LTemplateInstruction<1, 2, 0> {
1264 LShiftI(Token::Value op, LOperand* left, LOperand* right, bool can_deopt)
1265 : op_(op), can_deopt_(can_deopt) {
1270 Token::Value op() const { return op_; }
1271 LOperand* left() { return inputs_[0]; }
1272 LOperand* right() { return inputs_[1]; }
1273 bool can_deopt() const { return can_deopt_; }
1275 DECLARE_CONCRETE_INSTRUCTION(ShiftI, "shift-i")
1283 class LSubI final : public LTemplateInstruction<1, 2, 0> {
1285 LSubI(LOperand* left, LOperand* right) {
1290 LOperand* left() { return inputs_[0]; }
1291 LOperand* right() { return inputs_[1]; }
1293 DECLARE_CONCRETE_INSTRUCTION(SubI, "sub-i")
1294 DECLARE_HYDROGEN_ACCESSOR(Sub)
1298 class LConstantI final : public LTemplateInstruction<1, 0, 0> {
1300 DECLARE_CONCRETE_INSTRUCTION(ConstantI, "constant-i")
1301 DECLARE_HYDROGEN_ACCESSOR(Constant)
1303 int32_t value() const { return hydrogen()->Integer32Value(); }
1307 class LConstantS final : public LTemplateInstruction<1, 0, 0> {
1309 DECLARE_CONCRETE_INSTRUCTION(ConstantS, "constant-s")
1310 DECLARE_HYDROGEN_ACCESSOR(Constant)
1312 Smi* value() const { return Smi::FromInt(hydrogen()->Integer32Value()); }
1316 class LConstantD final : public LTemplateInstruction<1, 0, 0> {
1318 DECLARE_CONCRETE_INSTRUCTION(ConstantD, "constant-d")
1319 DECLARE_HYDROGEN_ACCESSOR(Constant)
1321 uint64_t bits() const { return hydrogen()->DoubleValueAsBits(); }
1325 class LConstantE final : public LTemplateInstruction<1, 0, 0> {
1327 DECLARE_CONCRETE_INSTRUCTION(ConstantE, "constant-e")
1328 DECLARE_HYDROGEN_ACCESSOR(Constant)
1330 ExternalReference value() const {
1331 return hydrogen()->ExternalReferenceValue();
1336 class LConstantT final : public LTemplateInstruction<1, 0, 0> {
1338 DECLARE_CONCRETE_INSTRUCTION(ConstantT, "constant-t")
1339 DECLARE_HYDROGEN_ACCESSOR(Constant)
1341 Handle<Object> value(Isolate* isolate) const {
1342 return hydrogen()->handle(isolate);
1347 class LBranch final : public LControlInstruction<1, 0> {
1349 explicit LBranch(LOperand* value) {
1353 LOperand* value() { return inputs_[0]; }
1355 DECLARE_CONCRETE_INSTRUCTION(Branch, "branch")
1356 DECLARE_HYDROGEN_ACCESSOR(Branch)
1358 void PrintDataTo(StringStream* stream) override;
1362 class LDebugBreak final : public LTemplateInstruction<0, 0, 0> {
1364 DECLARE_CONCRETE_INSTRUCTION(DebugBreak, "break")
1368 class LCmpMapAndBranch final : public LControlInstruction<1, 0> {
1370 explicit LCmpMapAndBranch(LOperand* value) {
1374 LOperand* value() { return inputs_[0]; }
1376 DECLARE_CONCRETE_INSTRUCTION(CmpMapAndBranch, "cmp-map-and-branch")
1377 DECLARE_HYDROGEN_ACCESSOR(CompareMap)
1379 Handle<Map> map() const { return hydrogen()->map().handle(); }
1383 class LMapEnumLength final : public LTemplateInstruction<1, 1, 0> {
1385 explicit LMapEnumLength(LOperand* value) {
1389 LOperand* value() { return inputs_[0]; }
1391 DECLARE_CONCRETE_INSTRUCTION(MapEnumLength, "map-enum-length")
1395 class LDateField final : public LTemplateInstruction<1, 1, 0> {
1397 LDateField(LOperand* date, Smi* index) : index_(index) {
1401 LOperand* date() { return inputs_[0]; }
1402 Smi* index() const { return index_; }
1404 DECLARE_CONCRETE_INSTRUCTION(DateField, "date-field")
1405 DECLARE_HYDROGEN_ACCESSOR(DateField)
1412 class LSeqStringGetChar final : public LTemplateInstruction<1, 2, 0> {
1414 LSeqStringGetChar(LOperand* string, LOperand* index) {
1415 inputs_[0] = string;
1419 LOperand* string() const { return inputs_[0]; }
1420 LOperand* index() const { return inputs_[1]; }
1422 DECLARE_CONCRETE_INSTRUCTION(SeqStringGetChar, "seq-string-get-char")
1423 DECLARE_HYDROGEN_ACCESSOR(SeqStringGetChar)
1427 class LSeqStringSetChar final : public LTemplateInstruction<1, 4, 0> {
1429 LSeqStringSetChar(LOperand* context,
1433 inputs_[0] = context;
1434 inputs_[1] = string;
1439 LOperand* string() { return inputs_[1]; }
1440 LOperand* index() { return inputs_[2]; }
1441 LOperand* value() { return inputs_[3]; }
1443 DECLARE_CONCRETE_INSTRUCTION(SeqStringSetChar, "seq-string-set-char")
1444 DECLARE_HYDROGEN_ACCESSOR(SeqStringSetChar)
1448 class LAddI final : public LTemplateInstruction<1, 2, 0> {
1450 LAddI(LOperand* left, LOperand* right) {
1455 LOperand* left() { return inputs_[0]; }
1456 LOperand* right() { return inputs_[1]; }
1458 static bool UseLea(HAdd* add) {
1459 return !add->CheckFlag(HValue::kCanOverflow) &&
1460 add->BetterLeftOperand()->UseCount() > 1;
1463 DECLARE_CONCRETE_INSTRUCTION(AddI, "add-i")
1464 DECLARE_HYDROGEN_ACCESSOR(Add)
1468 class LMathMinMax final : public LTemplateInstruction<1, 2, 0> {
1470 LMathMinMax(LOperand* left, LOperand* right) {
1475 LOperand* left() { return inputs_[0]; }
1476 LOperand* right() { return inputs_[1]; }
1478 DECLARE_CONCRETE_INSTRUCTION(MathMinMax, "math-min-max")
1479 DECLARE_HYDROGEN_ACCESSOR(MathMinMax)
1483 class LPower final : public LTemplateInstruction<1, 2, 0> {
1485 LPower(LOperand* left, LOperand* right) {
1490 LOperand* left() { return inputs_[0]; }
1491 LOperand* right() { return inputs_[1]; }
1493 DECLARE_CONCRETE_INSTRUCTION(Power, "power")
1494 DECLARE_HYDROGEN_ACCESSOR(Power)
1498 class LArithmeticD final : public LTemplateInstruction<1, 2, 0> {
1500 LArithmeticD(Token::Value op, LOperand* left, LOperand* right)
1506 Token::Value op() const { return op_; }
1507 LOperand* left() { return inputs_[0]; }
1508 LOperand* right() { return inputs_[1]; }
1510 Opcode opcode() const override { return LInstruction::kArithmeticD; }
1511 void CompileToNative(LCodeGen* generator) override;
1512 const char* Mnemonic() const override;
1519 class LArithmeticT final : public LTemplateInstruction<1, 3, 0> {
1521 LArithmeticT(Token::Value op,
1526 inputs_[0] = context;
1531 Token::Value op() const { return op_; }
1532 LOperand* context() { return inputs_[0]; }
1533 LOperand* left() { return inputs_[1]; }
1534 LOperand* right() { return inputs_[2]; }
1536 Opcode opcode() const override { return LInstruction::kArithmeticT; }
1537 void CompileToNative(LCodeGen* generator) override;
1538 const char* Mnemonic() const override;
1540 DECLARE_HYDROGEN_ACCESSOR(BinaryOperation)
1542 LanguageMode language_mode() { return hydrogen()->language_mode(); }
1549 class LReturn final : public LTemplateInstruction<0, 3, 0> {
1551 explicit LReturn(LOperand* value,
1553 LOperand* parameter_count) {
1555 inputs_[1] = context;
1556 inputs_[2] = parameter_count;
1559 LOperand* value() { return inputs_[0]; }
1560 LOperand* context() { return inputs_[1]; }
1562 bool has_constant_parameter_count() {
1563 return parameter_count()->IsConstantOperand();
1565 LConstantOperand* constant_parameter_count() {
1566 DCHECK(has_constant_parameter_count());
1567 return LConstantOperand::cast(parameter_count());
1569 LOperand* parameter_count() { return inputs_[2]; }
1571 DECLARE_CONCRETE_INSTRUCTION(Return, "return")
1572 DECLARE_HYDROGEN_ACCESSOR(Return)
1576 class LLoadNamedField final : public LTemplateInstruction<1, 1, 0> {
1578 explicit LLoadNamedField(LOperand* object) {
1579 inputs_[0] = object;
1582 LOperand* object() { return inputs_[0]; }
1584 DECLARE_CONCRETE_INSTRUCTION(LoadNamedField, "load-named-field")
1585 DECLARE_HYDROGEN_ACCESSOR(LoadNamedField)
1589 class LLoadNamedGeneric final : public LTemplateInstruction<1, 2, 1> {
1591 explicit LLoadNamedGeneric(LOperand* context, LOperand* object,
1593 inputs_[0] = context;
1594 inputs_[1] = object;
1598 DECLARE_CONCRETE_INSTRUCTION(LoadNamedGeneric, "load-named-generic")
1599 DECLARE_HYDROGEN_ACCESSOR(LoadNamedGeneric)
1601 LOperand* context() { return inputs_[0]; }
1602 LOperand* object() { return inputs_[1]; }
1603 LOperand* temp_vector() { return temps_[0]; }
1605 Handle<Object> name() const { return hydrogen()->name(); }
1609 class LLoadFunctionPrototype final : public LTemplateInstruction<1, 1, 0> {
1611 explicit LLoadFunctionPrototype(LOperand* function) {
1612 inputs_[0] = function;
1615 DECLARE_CONCRETE_INSTRUCTION(LoadFunctionPrototype, "load-function-prototype")
1616 DECLARE_HYDROGEN_ACCESSOR(LoadFunctionPrototype)
1618 LOperand* function() { return inputs_[0]; }
1622 class LLoadRoot final : public LTemplateInstruction<1, 0, 0> {
1624 DECLARE_CONCRETE_INSTRUCTION(LoadRoot, "load-root")
1625 DECLARE_HYDROGEN_ACCESSOR(LoadRoot)
1627 Heap::RootListIndex index() const { return hydrogen()->index(); }
1631 inline static bool ExternalArrayOpRequiresTemp(
1632 Representation key_representation,
1633 ElementsKind elements_kind) {
1634 // Operations that require the key to be divided by two to be converted into
1635 // an index cannot fold the scale operation into a load and need an extra
1636 // temp register to do the work.
1637 return SmiValuesAre31Bits() && key_representation.IsSmi() &&
1638 (elements_kind == EXTERNAL_INT8_ELEMENTS ||
1639 elements_kind == EXTERNAL_UINT8_ELEMENTS ||
1640 elements_kind == EXTERNAL_UINT8_CLAMPED_ELEMENTS ||
1641 elements_kind == UINT8_ELEMENTS ||
1642 elements_kind == INT8_ELEMENTS ||
1643 elements_kind == UINT8_CLAMPED_ELEMENTS);
1647 class LLoadKeyed final : public LTemplateInstruction<1, 2, 0> {
1649 LLoadKeyed(LOperand* elements, LOperand* key) {
1650 inputs_[0] = elements;
1654 DECLARE_CONCRETE_INSTRUCTION(LoadKeyed, "load-keyed")
1655 DECLARE_HYDROGEN_ACCESSOR(LoadKeyed)
1657 bool is_external() const {
1658 return hydrogen()->is_external();
1660 bool is_fixed_typed_array() const {
1661 return hydrogen()->is_fixed_typed_array();
1663 bool is_typed_elements() const {
1664 return is_external() || is_fixed_typed_array();
1666 LOperand* elements() { return inputs_[0]; }
1667 LOperand* key() { return inputs_[1]; }
1668 void PrintDataTo(StringStream* stream) override;
1669 uint32_t base_offset() const { return hydrogen()->base_offset(); }
1670 ElementsKind elements_kind() const {
1671 return hydrogen()->elements_kind();
1676 class LLoadKeyedGeneric final : public LTemplateInstruction<1, 3, 1> {
1678 LLoadKeyedGeneric(LOperand* context, LOperand* obj, LOperand* key,
1680 inputs_[0] = context;
1686 DECLARE_CONCRETE_INSTRUCTION(LoadKeyedGeneric, "load-keyed-generic")
1687 DECLARE_HYDROGEN_ACCESSOR(LoadKeyedGeneric)
1689 LOperand* context() { return inputs_[0]; }
1690 LOperand* object() { return inputs_[1]; }
1691 LOperand* key() { return inputs_[2]; }
1692 LOperand* temp_vector() { return temps_[0]; }
1696 class LLoadGlobalGeneric final : public LTemplateInstruction<1, 2, 1> {
1698 explicit LLoadGlobalGeneric(LOperand* context, LOperand* global_object,
1700 inputs_[0] = context;
1701 inputs_[1] = global_object;
1705 DECLARE_CONCRETE_INSTRUCTION(LoadGlobalGeneric, "load-global-generic")
1706 DECLARE_HYDROGEN_ACCESSOR(LoadGlobalGeneric)
1708 LOperand* context() { return inputs_[0]; }
1709 LOperand* global_object() { return inputs_[1]; }
1710 LOperand* temp_vector() { return temps_[0]; }
1712 Handle<Object> name() const { return hydrogen()->name(); }
1713 bool for_typeof() const { return hydrogen()->for_typeof(); }
1717 class LLoadContextSlot final : public LTemplateInstruction<1, 1, 0> {
1719 explicit LLoadContextSlot(LOperand* context) {
1720 inputs_[0] = context;
1723 LOperand* context() { return inputs_[0]; }
1725 DECLARE_CONCRETE_INSTRUCTION(LoadContextSlot, "load-context-slot")
1726 DECLARE_HYDROGEN_ACCESSOR(LoadContextSlot)
1728 int slot_index() { return hydrogen()->slot_index(); }
1730 void PrintDataTo(StringStream* stream) override;
1734 class LStoreContextSlot final : public LTemplateInstruction<0, 2, 1> {
1736 LStoreContextSlot(LOperand* context, LOperand* value, LOperand* temp) {
1737 inputs_[0] = context;
1742 LOperand* context() { return inputs_[0]; }
1743 LOperand* value() { return inputs_[1]; }
1744 LOperand* temp() { return temps_[0]; }
1746 DECLARE_CONCRETE_INSTRUCTION(StoreContextSlot, "store-context-slot")
1747 DECLARE_HYDROGEN_ACCESSOR(StoreContextSlot)
1749 int slot_index() { return hydrogen()->slot_index(); }
1751 void PrintDataTo(StringStream* stream) override;
1755 class LPushArgument final : public LTemplateInstruction<0, 1, 0> {
1757 explicit LPushArgument(LOperand* value) {
1761 LOperand* value() { return inputs_[0]; }
1763 DECLARE_CONCRETE_INSTRUCTION(PushArgument, "push-argument")
1767 class LDrop final : public LTemplateInstruction<0, 0, 0> {
1769 explicit LDrop(int count) : count_(count) { }
1771 int count() const { return count_; }
1773 DECLARE_CONCRETE_INSTRUCTION(Drop, "drop")
1780 class LStoreCodeEntry final : public LTemplateInstruction<0, 2, 0> {
1782 LStoreCodeEntry(LOperand* function, LOperand* code_object) {
1783 inputs_[0] = function;
1784 inputs_[1] = code_object;
1787 LOperand* function() { return inputs_[0]; }
1788 LOperand* code_object() { return inputs_[1]; }
1790 void PrintDataTo(StringStream* stream) override;
1792 DECLARE_CONCRETE_INSTRUCTION(StoreCodeEntry, "store-code-entry")
1793 DECLARE_HYDROGEN_ACCESSOR(StoreCodeEntry)
1797 class LInnerAllocatedObject final : public LTemplateInstruction<1, 2, 0> {
1799 LInnerAllocatedObject(LOperand* base_object, LOperand* offset) {
1800 inputs_[0] = base_object;
1801 inputs_[1] = offset;
1804 LOperand* base_object() const { return inputs_[0]; }
1805 LOperand* offset() const { return inputs_[1]; }
1807 void PrintDataTo(StringStream* stream) override;
1809 DECLARE_CONCRETE_INSTRUCTION(InnerAllocatedObject, "inner-allocated-object")
1813 class LThisFunction final : public LTemplateInstruction<1, 0, 0> {
1815 DECLARE_CONCRETE_INSTRUCTION(ThisFunction, "this-function")
1816 DECLARE_HYDROGEN_ACCESSOR(ThisFunction)
1820 class LContext final : public LTemplateInstruction<1, 0, 0> {
1822 DECLARE_CONCRETE_INSTRUCTION(Context, "context")
1823 DECLARE_HYDROGEN_ACCESSOR(Context)
1827 class LDeclareGlobals final : public LTemplateInstruction<0, 1, 0> {
1829 explicit LDeclareGlobals(LOperand* context) {
1830 inputs_[0] = context;
1833 LOperand* context() { return inputs_[0]; }
1835 DECLARE_CONCRETE_INSTRUCTION(DeclareGlobals, "declare-globals")
1836 DECLARE_HYDROGEN_ACCESSOR(DeclareGlobals)
1840 class LCallJSFunction final : public LTemplateInstruction<1, 1, 0> {
1842 explicit LCallJSFunction(LOperand* function) {
1843 inputs_[0] = function;
1846 LOperand* function() { return inputs_[0]; }
1848 DECLARE_CONCRETE_INSTRUCTION(CallJSFunction, "call-js-function")
1849 DECLARE_HYDROGEN_ACCESSOR(CallJSFunction)
1851 void PrintDataTo(StringStream* stream) override;
1853 int arity() const { return hydrogen()->argument_count() - 1; }
1857 class LCallWithDescriptor final : public LTemplateResultInstruction<1> {
1859 LCallWithDescriptor(CallInterfaceDescriptor descriptor,
1860 const ZoneList<LOperand*>& operands, Zone* zone)
1861 : inputs_(descriptor.GetRegisterParameterCount() + 1, zone) {
1862 DCHECK(descriptor.GetRegisterParameterCount() + 1 == operands.length());
1863 inputs_.AddAll(operands, zone);
1866 LOperand* target() const { return inputs_[0]; }
1868 DECLARE_HYDROGEN_ACCESSOR(CallWithDescriptor)
1871 DECLARE_CONCRETE_INSTRUCTION(CallWithDescriptor, "call-with-descriptor")
1873 void PrintDataTo(StringStream* stream) override;
1875 int arity() const { return hydrogen()->argument_count() - 1; }
1877 ZoneList<LOperand*> inputs_;
1879 // Iterator support.
1880 int InputCount() final { return inputs_.length(); }
1881 LOperand* InputAt(int i) final { return inputs_[i]; }
1883 int TempCount() final { return 0; }
1884 LOperand* TempAt(int i) final { return NULL; }
1888 class LInvokeFunction final : public LTemplateInstruction<1, 2, 0> {
1890 LInvokeFunction(LOperand* context, LOperand* function) {
1891 inputs_[0] = context;
1892 inputs_[1] = function;
1895 LOperand* context() { return inputs_[0]; }
1896 LOperand* function() { return inputs_[1]; }
1898 DECLARE_CONCRETE_INSTRUCTION(InvokeFunction, "invoke-function")
1899 DECLARE_HYDROGEN_ACCESSOR(InvokeFunction)
1901 void PrintDataTo(StringStream* stream) override;
1903 int arity() const { return hydrogen()->argument_count() - 1; }
1907 class LCallFunction final : public LTemplateInstruction<1, 2, 2> {
1909 LCallFunction(LOperand* context, LOperand* function, LOperand* slot,
1911 inputs_[0] = context;
1912 inputs_[1] = function;
1917 DECLARE_CONCRETE_INSTRUCTION(CallFunction, "call-function")
1918 DECLARE_HYDROGEN_ACCESSOR(CallFunction)
1920 LOperand* context() { return inputs_[0]; }
1921 LOperand* function() { return inputs_[1]; }
1922 LOperand* temp_slot() { return temps_[0]; }
1923 LOperand* temp_vector() { return temps_[1]; }
1924 int arity() const { return hydrogen()->argument_count() - 1; }
1926 void PrintDataTo(StringStream* stream) override;
1930 class LCallNew final : public LTemplateInstruction<1, 2, 0> {
1932 LCallNew(LOperand* context, LOperand* constructor) {
1933 inputs_[0] = context;
1934 inputs_[1] = constructor;
1937 LOperand* context() { return inputs_[0]; }
1938 LOperand* constructor() { return inputs_[1]; }
1940 DECLARE_CONCRETE_INSTRUCTION(CallNew, "call-new")
1941 DECLARE_HYDROGEN_ACCESSOR(CallNew)
1943 void PrintDataTo(StringStream* stream) override;
1945 int arity() const { return hydrogen()->argument_count() - 1; }
1949 class LCallNewArray final : public LTemplateInstruction<1, 2, 0> {
1951 LCallNewArray(LOperand* context, LOperand* constructor) {
1952 inputs_[0] = context;
1953 inputs_[1] = constructor;
1956 LOperand* context() { return inputs_[0]; }
1957 LOperand* constructor() { return inputs_[1]; }
1959 DECLARE_CONCRETE_INSTRUCTION(CallNewArray, "call-new-array")
1960 DECLARE_HYDROGEN_ACCESSOR(CallNewArray)
1962 void PrintDataTo(StringStream* stream) override;
1964 int arity() const { return hydrogen()->argument_count() - 1; }
1968 class LCallRuntime final : public LTemplateInstruction<1, 1, 0> {
1970 explicit LCallRuntime(LOperand* context) {
1971 inputs_[0] = context;
1974 LOperand* context() { return inputs_[0]; }
1976 DECLARE_CONCRETE_INSTRUCTION(CallRuntime, "call-runtime")
1977 DECLARE_HYDROGEN_ACCESSOR(CallRuntime)
1979 bool ClobbersDoubleRegisters(Isolate* isolate) const override {
1980 return save_doubles() == kDontSaveFPRegs;
1983 const Runtime::Function* function() const { return hydrogen()->function(); }
1984 int arity() const { return hydrogen()->argument_count(); }
1985 SaveFPRegsMode save_doubles() const { return hydrogen()->save_doubles(); }
1989 class LInteger32ToDouble final : public LTemplateInstruction<1, 1, 0> {
1991 explicit LInteger32ToDouble(LOperand* value) {
1995 LOperand* value() { return inputs_[0]; }
1997 DECLARE_CONCRETE_INSTRUCTION(Integer32ToDouble, "int32-to-double")
2001 class LUint32ToDouble final : public LTemplateInstruction<1, 1, 0> {
2003 explicit LUint32ToDouble(LOperand* value) {
2007 LOperand* value() { return inputs_[0]; }
2009 DECLARE_CONCRETE_INSTRUCTION(Uint32ToDouble, "uint32-to-double")
2013 class LNumberTagI final : public LTemplateInstruction<1, 1, 2> {
2015 LNumberTagI(LOperand* value, LOperand* temp1, LOperand* temp2) {
2021 LOperand* value() { return inputs_[0]; }
2022 LOperand* temp1() { return temps_[0]; }
2023 LOperand* temp2() { return temps_[1]; }
2025 DECLARE_CONCRETE_INSTRUCTION(NumberTagI, "number-tag-i")
2029 class LNumberTagU final : public LTemplateInstruction<1, 1, 2> {
2031 LNumberTagU(LOperand* value, LOperand* temp1, LOperand* temp2) {
2037 LOperand* value() { return inputs_[0]; }
2038 LOperand* temp1() { return temps_[0]; }
2039 LOperand* temp2() { return temps_[1]; }
2041 DECLARE_CONCRETE_INSTRUCTION(NumberTagU, "number-tag-u")
2045 class LNumberTagD final : public LTemplateInstruction<1, 1, 1> {
2047 explicit LNumberTagD(LOperand* value, LOperand* temp) {
2052 LOperand* value() { return inputs_[0]; }
2053 LOperand* temp() { return temps_[0]; }
2055 DECLARE_CONCRETE_INSTRUCTION(NumberTagD, "number-tag-d")
2056 DECLARE_HYDROGEN_ACCESSOR(Change)
2060 // Sometimes truncating conversion from a tagged value to an int32.
2061 class LDoubleToI final : public LTemplateInstruction<1, 1, 0> {
2063 explicit LDoubleToI(LOperand* value) {
2067 LOperand* value() { return inputs_[0]; }
2069 DECLARE_CONCRETE_INSTRUCTION(DoubleToI, "double-to-i")
2070 DECLARE_HYDROGEN_ACCESSOR(UnaryOperation)
2072 bool truncating() { return hydrogen()->CanTruncateToInt32(); }
2076 class LDoubleToSmi final : public LTemplateInstruction<1, 1, 0> {
2078 explicit LDoubleToSmi(LOperand* value) {
2082 LOperand* value() { return inputs_[0]; }
2084 DECLARE_CONCRETE_INSTRUCTION(DoubleToSmi, "double-to-smi")
2085 DECLARE_HYDROGEN_ACCESSOR(UnaryOperation)
2089 // Truncating conversion from a tagged value to an int32.
2090 class LTaggedToI final : public LTemplateInstruction<1, 1, 1> {
2092 LTaggedToI(LOperand* value, LOperand* temp) {
2097 LOperand* value() { return inputs_[0]; }
2098 LOperand* temp() { return temps_[0]; }
2100 DECLARE_CONCRETE_INSTRUCTION(TaggedToI, "tagged-to-i")
2101 DECLARE_HYDROGEN_ACCESSOR(Change)
2103 bool truncating() { return hydrogen()->CanTruncateToInt32(); }
2107 class LSmiTag final : public LTemplateInstruction<1, 1, 0> {
2109 explicit LSmiTag(LOperand* value) {
2113 LOperand* value() { return inputs_[0]; }
2115 DECLARE_CONCRETE_INSTRUCTION(SmiTag, "smi-tag")
2116 DECLARE_HYDROGEN_ACCESSOR(Change)
2120 class LNumberUntagD final : public LTemplateInstruction<1, 1, 0> {
2122 explicit LNumberUntagD(LOperand* value) {
2126 LOperand* value() { return inputs_[0]; }
2128 DECLARE_CONCRETE_INSTRUCTION(NumberUntagD, "double-untag")
2129 DECLARE_HYDROGEN_ACCESSOR(Change);
2133 class LSmiUntag final : public LTemplateInstruction<1, 1, 0> {
2135 LSmiUntag(LOperand* value, bool needs_check)
2136 : needs_check_(needs_check) {
2140 LOperand* value() { return inputs_[0]; }
2141 bool needs_check() const { return needs_check_; }
2143 DECLARE_CONCRETE_INSTRUCTION(SmiUntag, "smi-untag")
2150 class LStoreNamedField final : public LTemplateInstruction<0, 2, 1> {
2152 LStoreNamedField(LOperand* object, LOperand* value, LOperand* temp) {
2153 inputs_[0] = object;
2158 LOperand* object() { return inputs_[0]; }
2159 LOperand* value() { return inputs_[1]; }
2160 LOperand* temp() { return temps_[0]; }
2162 DECLARE_CONCRETE_INSTRUCTION(StoreNamedField, "store-named-field")
2163 DECLARE_HYDROGEN_ACCESSOR(StoreNamedField)
2165 void PrintDataTo(StringStream* stream) override;
2167 Representation representation() const {
2168 return hydrogen()->field_representation();
2173 class LStoreNamedGeneric final : public LTemplateInstruction<0, 3, 0> {
2175 LStoreNamedGeneric(LOperand* context, LOperand* object, LOperand* value) {
2176 inputs_[0] = context;
2177 inputs_[1] = object;
2181 LOperand* context() { return inputs_[0]; }
2182 LOperand* object() { return inputs_[1]; }
2183 LOperand* value() { return inputs_[2]; }
2185 DECLARE_CONCRETE_INSTRUCTION(StoreNamedGeneric, "store-named-generic")
2186 DECLARE_HYDROGEN_ACCESSOR(StoreNamedGeneric)
2188 void PrintDataTo(StringStream* stream) override;
2190 Handle<Object> name() const { return hydrogen()->name(); }
2191 LanguageMode language_mode() { return hydrogen()->language_mode(); }
2195 class LStoreKeyed final : public LTemplateInstruction<0, 3, 0> {
2197 LStoreKeyed(LOperand* object, LOperand* key, LOperand* value) {
2198 inputs_[0] = object;
2203 bool is_external() const { return hydrogen()->is_external(); }
2204 bool is_fixed_typed_array() const {
2205 return hydrogen()->is_fixed_typed_array();
2207 bool is_typed_elements() const {
2208 return is_external() || is_fixed_typed_array();
2210 LOperand* elements() { return inputs_[0]; }
2211 LOperand* key() { return inputs_[1]; }
2212 LOperand* value() { return inputs_[2]; }
2213 ElementsKind elements_kind() const { return hydrogen()->elements_kind(); }
2215 DECLARE_CONCRETE_INSTRUCTION(StoreKeyed, "store-keyed")
2216 DECLARE_HYDROGEN_ACCESSOR(StoreKeyed)
2218 void PrintDataTo(StringStream* stream) override;
2219 bool NeedsCanonicalization() { return hydrogen()->NeedsCanonicalization(); }
2220 uint32_t base_offset() const { return hydrogen()->base_offset(); }
2224 class LStoreKeyedGeneric final : public LTemplateInstruction<0, 4, 0> {
2226 LStoreKeyedGeneric(LOperand* context,
2230 inputs_[0] = context;
2231 inputs_[1] = object;
2236 LOperand* context() { return inputs_[0]; }
2237 LOperand* object() { return inputs_[1]; }
2238 LOperand* key() { return inputs_[2]; }
2239 LOperand* value() { return inputs_[3]; }
2241 DECLARE_CONCRETE_INSTRUCTION(StoreKeyedGeneric, "store-keyed-generic")
2242 DECLARE_HYDROGEN_ACCESSOR(StoreKeyedGeneric)
2244 void PrintDataTo(StringStream* stream) override;
2246 LanguageMode language_mode() { return hydrogen()->language_mode(); }
2250 class LTransitionElementsKind final : public LTemplateInstruction<0, 2, 2> {
2252 LTransitionElementsKind(LOperand* object,
2254 LOperand* new_map_temp,
2256 inputs_[0] = object;
2257 inputs_[1] = context;
2258 temps_[0] = new_map_temp;
2262 LOperand* object() { return inputs_[0]; }
2263 LOperand* context() { return inputs_[1]; }
2264 LOperand* new_map_temp() { return temps_[0]; }
2265 LOperand* temp() { return temps_[1]; }
2267 DECLARE_CONCRETE_INSTRUCTION(TransitionElementsKind,
2268 "transition-elements-kind")
2269 DECLARE_HYDROGEN_ACCESSOR(TransitionElementsKind)
2271 void PrintDataTo(StringStream* stream) override;
2273 Handle<Map> original_map() { return hydrogen()->original_map().handle(); }
2274 Handle<Map> transitioned_map() {
2275 return hydrogen()->transitioned_map().handle();
2277 ElementsKind from_kind() { return hydrogen()->from_kind(); }
2278 ElementsKind to_kind() { return hydrogen()->to_kind(); }
2282 class LTrapAllocationMemento final : public LTemplateInstruction<0, 1, 1> {
2284 LTrapAllocationMemento(LOperand* object,
2286 inputs_[0] = object;
2290 LOperand* object() { return inputs_[0]; }
2291 LOperand* temp() { return temps_[0]; }
2293 DECLARE_CONCRETE_INSTRUCTION(TrapAllocationMemento,
2294 "trap-allocation-memento")
2298 class LMaybeGrowElements final : public LTemplateInstruction<1, 5, 0> {
2300 LMaybeGrowElements(LOperand* context, LOperand* object, LOperand* elements,
2301 LOperand* key, LOperand* current_capacity) {
2302 inputs_[0] = context;
2303 inputs_[1] = object;
2304 inputs_[2] = elements;
2306 inputs_[4] = current_capacity;
2309 LOperand* context() { return inputs_[0]; }
2310 LOperand* object() { return inputs_[1]; }
2311 LOperand* elements() { return inputs_[2]; }
2312 LOperand* key() { return inputs_[3]; }
2313 LOperand* current_capacity() { return inputs_[4]; }
2315 DECLARE_HYDROGEN_ACCESSOR(MaybeGrowElements)
2316 DECLARE_CONCRETE_INSTRUCTION(MaybeGrowElements, "maybe-grow-elements")
2320 class LStringAdd final : public LTemplateInstruction<1, 3, 0> {
2322 LStringAdd(LOperand* context, LOperand* left, LOperand* right) {
2323 inputs_[0] = context;
2328 LOperand* context() { return inputs_[0]; }
2329 LOperand* left() { return inputs_[1]; }
2330 LOperand* right() { return inputs_[2]; }
2332 DECLARE_CONCRETE_INSTRUCTION(StringAdd, "string-add")
2333 DECLARE_HYDROGEN_ACCESSOR(StringAdd)
2337 class LStringCharCodeAt final : public LTemplateInstruction<1, 3, 0> {
2339 LStringCharCodeAt(LOperand* context, LOperand* string, LOperand* index) {
2340 inputs_[0] = context;
2341 inputs_[1] = string;
2345 LOperand* context() { return inputs_[0]; }
2346 LOperand* string() { return inputs_[1]; }
2347 LOperand* index() { return inputs_[2]; }
2349 DECLARE_CONCRETE_INSTRUCTION(StringCharCodeAt, "string-char-code-at")
2350 DECLARE_HYDROGEN_ACCESSOR(StringCharCodeAt)
2354 class LStringCharFromCode final : public LTemplateInstruction<1, 2, 0> {
2356 explicit LStringCharFromCode(LOperand* context, LOperand* char_code) {
2357 inputs_[0] = context;
2358 inputs_[1] = char_code;
2361 LOperand* context() { return inputs_[0]; }
2362 LOperand* char_code() { return inputs_[1]; }
2364 DECLARE_CONCRETE_INSTRUCTION(StringCharFromCode, "string-char-from-code")
2365 DECLARE_HYDROGEN_ACCESSOR(StringCharFromCode)
2369 class LCheckValue final : public LTemplateInstruction<0, 1, 0> {
2371 explicit LCheckValue(LOperand* value) {
2375 LOperand* value() { return inputs_[0]; }
2377 DECLARE_CONCRETE_INSTRUCTION(CheckValue, "check-value")
2378 DECLARE_HYDROGEN_ACCESSOR(CheckValue)
2382 class LCheckArrayBufferNotNeutered final
2383 : public LTemplateInstruction<0, 1, 0> {
2385 explicit LCheckArrayBufferNotNeutered(LOperand* view) { inputs_[0] = view; }
2387 LOperand* view() { return inputs_[0]; }
2389 DECLARE_CONCRETE_INSTRUCTION(CheckArrayBufferNotNeutered,
2390 "check-array-buffer-not-neutered")
2391 DECLARE_HYDROGEN_ACCESSOR(CheckArrayBufferNotNeutered)
2395 class LCheckInstanceType final : public LTemplateInstruction<0, 1, 0> {
2397 explicit LCheckInstanceType(LOperand* value) {
2401 LOperand* value() { return inputs_[0]; }
2403 DECLARE_CONCRETE_INSTRUCTION(CheckInstanceType, "check-instance-type")
2404 DECLARE_HYDROGEN_ACCESSOR(CheckInstanceType)
2408 class LCheckMaps final : public LTemplateInstruction<0, 1, 0> {
2410 explicit LCheckMaps(LOperand* value = NULL) {
2414 LOperand* value() { return inputs_[0]; }
2416 DECLARE_CONCRETE_INSTRUCTION(CheckMaps, "check-maps")
2417 DECLARE_HYDROGEN_ACCESSOR(CheckMaps)
2421 class LCheckSmi final : public LTemplateInstruction<1, 1, 0> {
2423 explicit LCheckSmi(LOperand* value) {
2427 LOperand* value() { return inputs_[0]; }
2429 DECLARE_CONCRETE_INSTRUCTION(CheckSmi, "check-smi")
2433 class LClampDToUint8 final : public LTemplateInstruction<1, 1, 0> {
2435 explicit LClampDToUint8(LOperand* unclamped) {
2436 inputs_[0] = unclamped;
2439 LOperand* unclamped() { return inputs_[0]; }
2441 DECLARE_CONCRETE_INSTRUCTION(ClampDToUint8, "clamp-d-to-uint8")
2445 class LClampIToUint8 final : public LTemplateInstruction<1, 1, 0> {
2447 explicit LClampIToUint8(LOperand* unclamped) {
2448 inputs_[0] = unclamped;
2451 LOperand* unclamped() { return inputs_[0]; }
2453 DECLARE_CONCRETE_INSTRUCTION(ClampIToUint8, "clamp-i-to-uint8")
2457 class LClampTToUint8 final : public LTemplateInstruction<1, 1, 1> {
2459 LClampTToUint8(LOperand* unclamped,
2460 LOperand* temp_xmm) {
2461 inputs_[0] = unclamped;
2462 temps_[0] = temp_xmm;
2465 LOperand* unclamped() { return inputs_[0]; }
2466 LOperand* temp_xmm() { return temps_[0]; }
2468 DECLARE_CONCRETE_INSTRUCTION(ClampTToUint8, "clamp-t-to-uint8")
2472 class LCheckNonSmi final : public LTemplateInstruction<0, 1, 0> {
2474 explicit LCheckNonSmi(LOperand* value) {
2478 LOperand* value() { return inputs_[0]; }
2480 DECLARE_CONCRETE_INSTRUCTION(CheckNonSmi, "check-non-smi")
2481 DECLARE_HYDROGEN_ACCESSOR(CheckHeapObject)
2485 class LDoubleBits final : public LTemplateInstruction<1, 1, 0> {
2487 explicit LDoubleBits(LOperand* value) {
2491 LOperand* value() { return inputs_[0]; }
2493 DECLARE_CONCRETE_INSTRUCTION(DoubleBits, "double-bits")
2494 DECLARE_HYDROGEN_ACCESSOR(DoubleBits)
2498 class LConstructDouble final : public LTemplateInstruction<1, 2, 0> {
2500 LConstructDouble(LOperand* hi, LOperand* lo) {
2505 LOperand* hi() { return inputs_[0]; }
2506 LOperand* lo() { return inputs_[1]; }
2508 DECLARE_CONCRETE_INSTRUCTION(ConstructDouble, "construct-double")
2512 class LAllocate final : public LTemplateInstruction<1, 2, 1> {
2514 LAllocate(LOperand* context, LOperand* size, LOperand* temp) {
2515 inputs_[0] = context;
2520 LOperand* context() { return inputs_[0]; }
2521 LOperand* size() { return inputs_[1]; }
2522 LOperand* temp() { return temps_[0]; }
2524 DECLARE_CONCRETE_INSTRUCTION(Allocate, "allocate")
2525 DECLARE_HYDROGEN_ACCESSOR(Allocate)
2529 class LRegExpLiteral final : public LTemplateInstruction<1, 1, 0> {
2531 explicit LRegExpLiteral(LOperand* context) {
2532 inputs_[0] = context;
2535 LOperand* context() { return inputs_[0]; }
2537 DECLARE_CONCRETE_INSTRUCTION(RegExpLiteral, "regexp-literal")
2538 DECLARE_HYDROGEN_ACCESSOR(RegExpLiteral)
2542 class LFunctionLiteral final : public LTemplateInstruction<1, 1, 0> {
2544 explicit LFunctionLiteral(LOperand* context) {
2545 inputs_[0] = context;
2548 LOperand* context() { return inputs_[0]; }
2550 DECLARE_CONCRETE_INSTRUCTION(FunctionLiteral, "function-literal")
2551 DECLARE_HYDROGEN_ACCESSOR(FunctionLiteral)
2555 class LToFastProperties final : public LTemplateInstruction<1, 1, 0> {
2557 explicit LToFastProperties(LOperand* value) {
2561 LOperand* value() { return inputs_[0]; }
2563 DECLARE_CONCRETE_INSTRUCTION(ToFastProperties, "to-fast-properties")
2564 DECLARE_HYDROGEN_ACCESSOR(ToFastProperties)
2568 class LTypeof final : public LTemplateInstruction<1, 2, 0> {
2570 LTypeof(LOperand* context, LOperand* value) {
2571 inputs_[0] = context;
2575 LOperand* context() { return inputs_[0]; }
2576 LOperand* value() { return inputs_[1]; }
2578 DECLARE_CONCRETE_INSTRUCTION(Typeof, "typeof")
2582 class LTypeofIsAndBranch final : public LControlInstruction<1, 0> {
2584 explicit LTypeofIsAndBranch(LOperand* value) {
2588 LOperand* value() { return inputs_[0]; }
2590 DECLARE_CONCRETE_INSTRUCTION(TypeofIsAndBranch, "typeof-is-and-branch")
2591 DECLARE_HYDROGEN_ACCESSOR(TypeofIsAndBranch)
2593 Handle<String> type_literal() { return hydrogen()->type_literal(); }
2595 void PrintDataTo(StringStream* stream) override;
2599 class LIsConstructCallAndBranch final : public LControlInstruction<0, 1> {
2601 explicit LIsConstructCallAndBranch(LOperand* temp) {
2605 LOperand* temp() { return temps_[0]; }
2607 DECLARE_CONCRETE_INSTRUCTION(IsConstructCallAndBranch,
2608 "is-construct-call-and-branch")
2609 DECLARE_HYDROGEN_ACCESSOR(IsConstructCallAndBranch)
2613 class LOsrEntry final : public LTemplateInstruction<0, 0, 0> {
2617 bool HasInterestingComment(LCodeGen* gen) const override { return false; }
2618 DECLARE_CONCRETE_INSTRUCTION(OsrEntry, "osr-entry")
2622 class LStackCheck final : public LTemplateInstruction<0, 1, 0> {
2624 explicit LStackCheck(LOperand* context) {
2625 inputs_[0] = context;
2628 LOperand* context() { return inputs_[0]; }
2630 DECLARE_CONCRETE_INSTRUCTION(StackCheck, "stack-check")
2631 DECLARE_HYDROGEN_ACCESSOR(StackCheck)
2633 Label* done_label() { return &done_label_; }
2640 class LForInPrepareMap final : public LTemplateInstruction<1, 2, 0> {
2642 LForInPrepareMap(LOperand* context, LOperand* object) {
2643 inputs_[0] = context;
2644 inputs_[1] = object;
2647 LOperand* context() { return inputs_[0]; }
2648 LOperand* object() { return inputs_[1]; }
2650 DECLARE_CONCRETE_INSTRUCTION(ForInPrepareMap, "for-in-prepare-map")
2654 class LForInCacheArray final : public LTemplateInstruction<1, 1, 0> {
2656 explicit LForInCacheArray(LOperand* map) {
2660 LOperand* map() { return inputs_[0]; }
2662 DECLARE_CONCRETE_INSTRUCTION(ForInCacheArray, "for-in-cache-array")
2665 return HForInCacheArray::cast(this->hydrogen_value())->idx();
2670 class LCheckMapValue final : public LTemplateInstruction<0, 2, 0> {
2672 LCheckMapValue(LOperand* value, LOperand* map) {
2677 LOperand* value() { return inputs_[0]; }
2678 LOperand* map() { return inputs_[1]; }
2680 DECLARE_CONCRETE_INSTRUCTION(CheckMapValue, "check-map-value")
2684 class LLoadFieldByIndex final : public LTemplateInstruction<1, 2, 0> {
2686 LLoadFieldByIndex(LOperand* object, LOperand* index) {
2687 inputs_[0] = object;
2691 LOperand* object() { return inputs_[0]; }
2692 LOperand* index() { return inputs_[1]; }
2694 DECLARE_CONCRETE_INSTRUCTION(LoadFieldByIndex, "load-field-by-index")
2698 class LStoreFrameContext: public LTemplateInstruction<0, 1, 0> {
2700 explicit LStoreFrameContext(LOperand* context) {
2701 inputs_[0] = context;
2704 LOperand* context() { return inputs_[0]; }
2706 DECLARE_CONCRETE_INSTRUCTION(StoreFrameContext, "store-frame-context")
2710 class LAllocateBlockContext: public LTemplateInstruction<1, 2, 0> {
2712 LAllocateBlockContext(LOperand* context, LOperand* function) {
2713 inputs_[0] = context;
2714 inputs_[1] = function;
2717 LOperand* context() { return inputs_[0]; }
2718 LOperand* function() { return inputs_[1]; }
2720 Handle<ScopeInfo> scope_info() { return hydrogen()->scope_info(); }
2722 DECLARE_CONCRETE_INSTRUCTION(AllocateBlockContext, "allocate-block-context")
2723 DECLARE_HYDROGEN_ACCESSOR(AllocateBlockContext)
2727 class LChunkBuilder;
2728 class LPlatformChunk final : public LChunk {
2730 LPlatformChunk(CompilationInfo* info, HGraph* graph)
2731 : LChunk(info, graph),
2732 dehoisted_key_ids_(graph->GetMaximumValueID(), graph->zone()) { }
2734 int GetNextSpillIndex(RegisterKind kind);
2735 LOperand* GetNextSpillSlot(RegisterKind kind);
2736 BitVector* GetDehoistedKeyIds() { return &dehoisted_key_ids_; }
2737 bool IsDehoistedKey(HValue* value) {
2738 return dehoisted_key_ids_.Contains(value->id());
2742 BitVector dehoisted_key_ids_;
2746 class LChunkBuilder final : public LChunkBuilderBase {
2748 LChunkBuilder(CompilationInfo* info, HGraph* graph, LAllocator* allocator)
2749 : LChunkBuilderBase(info, graph),
2750 current_instruction_(NULL),
2751 current_block_(NULL),
2753 allocator_(allocator) {}
2755 // Build the sequence for the graph.
2756 LPlatformChunk* Build();
2758 // Declare methods that deal with the individual node types.
2759 #define DECLARE_DO(type) LInstruction* Do##type(H##type* node);
2760 HYDROGEN_CONCRETE_INSTRUCTION_LIST(DECLARE_DO)
2763 LInstruction* DoMathFloor(HUnaryMathOperation* instr);
2764 LInstruction* DoMathRound(HUnaryMathOperation* instr);
2765 LInstruction* DoMathFround(HUnaryMathOperation* instr);
2766 LInstruction* DoMathAbs(HUnaryMathOperation* instr);
2767 LInstruction* DoMathLog(HUnaryMathOperation* instr);
2768 LInstruction* DoMathExp(HUnaryMathOperation* instr);
2769 LInstruction* DoMathSqrt(HUnaryMathOperation* instr);
2770 LInstruction* DoMathPowHalf(HUnaryMathOperation* instr);
2771 LInstruction* DoMathClz32(HUnaryMathOperation* instr);
2772 LInstruction* DoDivByPowerOf2I(HDiv* instr);
2773 LInstruction* DoDivByConstI(HDiv* instr);
2774 LInstruction* DoDivI(HDiv* instr);
2775 LInstruction* DoModByPowerOf2I(HMod* instr);
2776 LInstruction* DoModByConstI(HMod* instr);
2777 LInstruction* DoModI(HMod* instr);
2778 LInstruction* DoFlooringDivByPowerOf2I(HMathFloorOfDiv* instr);
2779 LInstruction* DoFlooringDivByConstI(HMathFloorOfDiv* instr);
2780 LInstruction* DoFlooringDivI(HMathFloorOfDiv* instr);
2783 // Methods for getting operands for Use / Define / Temp.
2784 LUnallocated* ToUnallocated(Register reg);
2785 LUnallocated* ToUnallocated(XMMRegister reg);
2787 // Methods for setting up define-use relationships.
2788 MUST_USE_RESULT LOperand* Use(HValue* value, LUnallocated* operand);
2789 MUST_USE_RESULT LOperand* UseFixed(HValue* value, Register fixed_register);
2790 MUST_USE_RESULT LOperand* UseFixedDouble(HValue* value,
2791 XMMRegister fixed_register);
2793 // A value that is guaranteed to be allocated to a register.
2794 // Operand created by UseRegister is guaranteed to be live until the end of
2795 // instruction. This means that register allocator will not reuse it's
2796 // register for any other operand inside instruction.
2797 // Operand created by UseRegisterAtStart is guaranteed to be live only at
2798 // instruction start. Register allocator is free to assign the same register
2799 // to some other operand used inside instruction (i.e. temporary or
2801 MUST_USE_RESULT LOperand* UseRegister(HValue* value);
2802 MUST_USE_RESULT LOperand* UseRegisterAtStart(HValue* value);
2804 // An input operand in a register that may be trashed.
2805 MUST_USE_RESULT LOperand* UseTempRegister(HValue* value);
2807 // An input operand in a register that may be trashed or a constant operand.
2808 MUST_USE_RESULT LOperand* UseTempRegisterOrConstant(HValue* value);
2810 // An input operand in a register or stack slot.
2811 MUST_USE_RESULT LOperand* Use(HValue* value);
2812 MUST_USE_RESULT LOperand* UseAtStart(HValue* value);
2814 // An input operand in a register, stack slot or a constant operand.
2815 MUST_USE_RESULT LOperand* UseOrConstant(HValue* value);
2816 MUST_USE_RESULT LOperand* UseOrConstantAtStart(HValue* value);
2818 // An input operand in a register or a constant operand.
2819 MUST_USE_RESULT LOperand* UseRegisterOrConstant(HValue* value);
2820 MUST_USE_RESULT LOperand* UseRegisterOrConstantAtStart(HValue* value);
2822 // An input operand in a constant operand.
2823 MUST_USE_RESULT LOperand* UseConstant(HValue* value);
2825 // An input operand in register, stack slot or a constant operand.
2826 // Will not be moved to a register even if one is freely available.
2827 MUST_USE_RESULT LOperand* UseAny(HValue* value) override;
2829 // Temporary operand that must be in a register.
2830 MUST_USE_RESULT LUnallocated* TempRegister();
2831 MUST_USE_RESULT LOperand* FixedTemp(Register reg);
2832 MUST_USE_RESULT LOperand* FixedTemp(XMMRegister reg);
2834 // Methods for setting up define-use relationships.
2835 // Return the same instruction that they are passed.
2836 LInstruction* Define(LTemplateResultInstruction<1>* instr,
2837 LUnallocated* result);
2838 LInstruction* DefineAsRegister(LTemplateResultInstruction<1>* instr);
2839 LInstruction* DefineAsSpilled(LTemplateResultInstruction<1>* instr,
2841 LInstruction* DefineSameAsFirst(LTemplateResultInstruction<1>* instr);
2842 LInstruction* DefineFixed(LTemplateResultInstruction<1>* instr,
2844 LInstruction* DefineFixedDouble(LTemplateResultInstruction<1>* instr,
2846 // Assigns an environment to an instruction. An instruction which can
2847 // deoptimize must have an environment.
2848 LInstruction* AssignEnvironment(LInstruction* instr);
2849 // Assigns a pointer map to an instruction. An instruction which can
2850 // trigger a GC or a lazy deoptimization must have a pointer map.
2851 LInstruction* AssignPointerMap(LInstruction* instr);
2853 enum CanDeoptimize { CAN_DEOPTIMIZE_EAGERLY, CANNOT_DEOPTIMIZE_EAGERLY };
2855 // Marks a call for the register allocator. Assigns a pointer map to
2856 // support GC and lazy deoptimization. Assigns an environment to support
2857 // eager deoptimization if CAN_DEOPTIMIZE_EAGERLY.
2858 LInstruction* MarkAsCall(
2859 LInstruction* instr,
2860 HInstruction* hinstr,
2861 CanDeoptimize can_deoptimize = CANNOT_DEOPTIMIZE_EAGERLY);
2863 void VisitInstruction(HInstruction* current);
2864 void AddInstruction(LInstruction* instr, HInstruction* current);
2866 void DoBasicBlock(HBasicBlock* block, HBasicBlock* next_block);
2867 LInstruction* DoShift(Token::Value op, HBitwiseBinaryOperation* instr);
2868 LInstruction* DoArithmeticD(Token::Value op,
2869 HArithmeticBinaryOperation* instr);
2870 LInstruction* DoArithmeticT(Token::Value op,
2871 HBinaryOperation* instr);
2872 void FindDehoistedKeyDefinitions(HValue* candidate);
2874 HInstruction* current_instruction_;
2875 HBasicBlock* current_block_;
2876 HBasicBlock* next_block_;
2877 LAllocator* allocator_;
2879 DISALLOW_COPY_AND_ASSIGN(LChunkBuilder);
2882 #undef DECLARE_HYDROGEN_ACCESSOR
2883 #undef DECLARE_CONCRETE_INSTRUCTION
2885 } } // namespace v8::int
2887 #endif // V8_X64_LITHIUM_X64_H_