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_ARM_LITHIUM_ARM_H_
6 #define V8_ARM_LITHIUM_ARM_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) \
82 V(GetCachedArrayIndex) \
84 V(HasCachedArrayIndexAndBranch) \
85 V(HasInPrototypeChainAndBranch) \
86 V(HasInstanceTypeAndBranch) \
87 V(InnerAllocatedObject) \
90 V(Integer32ToDouble) \
92 V(IsConstructCallAndBranch) \
93 V(IsStringAndBranch) \
95 V(IsUndetectableAndBranch) \
100 V(LoadFieldByIndex) \
101 V(LoadFunctionPrototype) \
102 V(LoadGlobalGeneric) \
103 V(LoadGlobalViaContext) \
105 V(LoadKeyedGeneric) \
107 V(LoadNamedGeneric) \
119 V(MaybeGrowElements) \
137 V(SeqStringGetChar) \
138 V(SeqStringSetChar) \
144 V(StoreContextSlot) \
145 V(StoreFrameContext) \
146 V(StoreGlobalViaContext) \
148 V(StoreKeyedGeneric) \
150 V(StoreNamedGeneric) \
152 V(StringCharCodeAt) \
153 V(StringCharFromCode) \
154 V(StringCompareAndBranch) \
159 V(ToFastProperties) \
160 V(TransitionElementsKind) \
161 V(TrapAllocationMemento) \
163 V(TypeofIsAndBranch) \
169 #define DECLARE_CONCRETE_INSTRUCTION(type, mnemonic) \
170 Opcode opcode() const final { return LInstruction::k##type; } \
171 void CompileToNative(LCodeGen* generator) final; \
172 const char* Mnemonic() const final { return mnemonic; } \
173 static L##type* cast(LInstruction* instr) { \
174 DCHECK(instr->Is##type()); \
175 return reinterpret_cast<L##type*>(instr); \
179 #define DECLARE_HYDROGEN_ACCESSOR(type) \
180 H##type* hydrogen() const { \
181 return H##type::cast(hydrogen_value()); \
185 class LInstruction : public ZoneObject {
188 : environment_(NULL),
189 hydrogen_value_(NULL),
190 bit_field_(IsCallBits::encode(false)) {
193 virtual ~LInstruction() {}
195 virtual void CompileToNative(LCodeGen* generator) = 0;
196 virtual const char* Mnemonic() const = 0;
197 virtual void PrintTo(StringStream* stream);
198 virtual void PrintDataTo(StringStream* stream);
199 virtual void PrintOutputOperandTo(StringStream* stream);
202 // Declare a unique enum value for each instruction.
203 #define DECLARE_OPCODE(type) k##type,
204 LITHIUM_CONCRETE_INSTRUCTION_LIST(DECLARE_OPCODE)
205 kNumberOfInstructions
206 #undef DECLARE_OPCODE
209 virtual Opcode opcode() const = 0;
211 // Declare non-virtual type testers for all leaf IR classes.
212 #define DECLARE_PREDICATE(type) \
213 bool Is##type() const { return opcode() == k##type; }
214 LITHIUM_CONCRETE_INSTRUCTION_LIST(DECLARE_PREDICATE)
215 #undef DECLARE_PREDICATE
217 // Declare virtual predicates for instructions that don't have
219 virtual bool IsGap() const { return false; }
221 virtual bool IsControl() const { return false; }
223 // Try deleting this instruction if possible.
224 virtual bool TryDelete() { return false; }
226 void set_environment(LEnvironment* env) { environment_ = env; }
227 LEnvironment* environment() const { return environment_; }
228 bool HasEnvironment() const { return environment_ != NULL; }
230 void set_pointer_map(LPointerMap* p) { pointer_map_.set(p); }
231 LPointerMap* pointer_map() const { return pointer_map_.get(); }
232 bool HasPointerMap() const { return pointer_map_.is_set(); }
234 void set_hydrogen_value(HValue* value) { hydrogen_value_ = value; }
235 HValue* hydrogen_value() const { return hydrogen_value_; }
237 void MarkAsCall() { bit_field_ = IsCallBits::update(bit_field_, true); }
238 bool IsCall() const { return IsCallBits::decode(bit_field_); }
240 // Interface to the register allocator and iterators.
241 bool ClobbersTemps() const { return IsCall(); }
242 bool ClobbersRegisters() const { return IsCall(); }
243 virtual bool ClobbersDoubleRegisters(Isolate* isolate) const {
247 // Interface to the register allocator and iterators.
248 bool IsMarkedAsCall() const { return IsCall(); }
250 virtual bool HasResult() const = 0;
251 virtual LOperand* result() const = 0;
253 LOperand* FirstInput() { return InputAt(0); }
254 LOperand* Output() { return HasResult() ? result() : NULL; }
256 virtual bool HasInterestingComment(LCodeGen* gen) const { return true; }
262 virtual int InputCount() = 0;
263 virtual LOperand* InputAt(int i) = 0;
267 friend class InputIterator;
269 friend class TempIterator;
270 virtual int TempCount() = 0;
271 virtual LOperand* TempAt(int i) = 0;
273 class IsCallBits: public BitField<bool, 0, 1> {};
275 LEnvironment* environment_;
276 SetOncePointer<LPointerMap> pointer_map_;
277 HValue* hydrogen_value_;
282 // R = number of result operands (0 or 1).
284 class LTemplateResultInstruction : public LInstruction {
286 // Allow 0 or 1 output operands.
287 STATIC_ASSERT(R == 0 || R == 1);
288 bool HasResult() const final { return R != 0 && result() != NULL; }
289 void set_result(LOperand* operand) { results_[0] = operand; }
290 LOperand* result() const override { return results_[0]; }
293 EmbeddedContainer<LOperand*, R> results_;
297 // R = number of result operands (0 or 1).
298 // I = number of input operands.
299 // T = number of temporary operands.
300 template<int R, int I, int T>
301 class LTemplateInstruction : public LTemplateResultInstruction<R> {
303 EmbeddedContainer<LOperand*, I> inputs_;
304 EmbeddedContainer<LOperand*, T> temps_;
308 int InputCount() final { return I; }
309 LOperand* InputAt(int i) final { return inputs_[i]; }
311 int TempCount() final { return T; }
312 LOperand* TempAt(int i) final { return temps_[i]; }
316 class LGap : public LTemplateInstruction<0, 0, 0> {
318 explicit LGap(HBasicBlock* block)
320 parallel_moves_[BEFORE] = NULL;
321 parallel_moves_[START] = NULL;
322 parallel_moves_[END] = NULL;
323 parallel_moves_[AFTER] = NULL;
326 // Can't use the DECLARE-macro here because of sub-classes.
327 bool IsGap() const override { return true; }
328 void PrintDataTo(StringStream* stream) override;
329 static LGap* cast(LInstruction* instr) {
330 DCHECK(instr->IsGap());
331 return reinterpret_cast<LGap*>(instr);
334 bool IsRedundant() const;
336 HBasicBlock* block() const { return block_; }
343 FIRST_INNER_POSITION = BEFORE,
344 LAST_INNER_POSITION = AFTER
347 LParallelMove* GetOrCreateParallelMove(InnerPosition pos, Zone* zone) {
348 if (parallel_moves_[pos] == NULL) {
349 parallel_moves_[pos] = new(zone) LParallelMove(zone);
351 return parallel_moves_[pos];
354 LParallelMove* GetParallelMove(InnerPosition pos) {
355 return parallel_moves_[pos];
359 LParallelMove* parallel_moves_[LAST_INNER_POSITION + 1];
364 class LInstructionGap final : public LGap {
366 explicit LInstructionGap(HBasicBlock* block) : LGap(block) { }
368 bool HasInterestingComment(LCodeGen* gen) const override {
369 return !IsRedundant();
372 DECLARE_CONCRETE_INSTRUCTION(InstructionGap, "gap")
376 class LGoto final : public LTemplateInstruction<0, 0, 0> {
378 explicit LGoto(HBasicBlock* block) : block_(block) { }
380 bool HasInterestingComment(LCodeGen* gen) const override;
381 DECLARE_CONCRETE_INSTRUCTION(Goto, "goto")
382 void PrintDataTo(StringStream* stream) override;
383 bool IsControl() const override { return true; }
385 int block_id() const { return block_->block_id(); }
392 class LPrologue final : public LTemplateInstruction<0, 0, 0> {
394 DECLARE_CONCRETE_INSTRUCTION(Prologue, "prologue")
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 LUnknownOSRValue final : public LTemplateInstruction<1, 0, 0> {
484 bool HasInterestingComment(LCodeGen* gen) const override { return false; }
485 DECLARE_CONCRETE_INSTRUCTION(UnknownOSRValue, "unknown-osr-value")
489 template<int I, int T>
490 class LControlInstruction : public LTemplateInstruction<0, I, T> {
492 LControlInstruction() : false_label_(NULL), true_label_(NULL) { }
494 bool IsControl() const final { return true; }
496 int SuccessorCount() { return hydrogen()->SuccessorCount(); }
497 HBasicBlock* SuccessorAt(int i) { return hydrogen()->SuccessorAt(i); }
499 int TrueDestination(LChunk* chunk) {
500 return chunk->LookupDestination(true_block_id());
502 int FalseDestination(LChunk* chunk) {
503 return chunk->LookupDestination(false_block_id());
506 Label* TrueLabel(LChunk* chunk) {
507 if (true_label_ == NULL) {
508 true_label_ = chunk->GetAssemblyLabel(TrueDestination(chunk));
512 Label* FalseLabel(LChunk* chunk) {
513 if (false_label_ == NULL) {
514 false_label_ = chunk->GetAssemblyLabel(FalseDestination(chunk));
520 int true_block_id() { return SuccessorAt(0)->block_id(); }
521 int false_block_id() { return SuccessorAt(1)->block_id(); }
524 HControlInstruction* hydrogen() {
525 return HControlInstruction::cast(this->hydrogen_value());
533 class LWrapReceiver final : public LTemplateInstruction<1, 2, 0> {
535 LWrapReceiver(LOperand* receiver, LOperand* function) {
536 inputs_[0] = receiver;
537 inputs_[1] = function;
540 DECLARE_CONCRETE_INSTRUCTION(WrapReceiver, "wrap-receiver")
541 DECLARE_HYDROGEN_ACCESSOR(WrapReceiver)
543 LOperand* receiver() { return inputs_[0]; }
544 LOperand* function() { return inputs_[1]; }
548 class LApplyArguments final : public LTemplateInstruction<1, 4, 0> {
550 LApplyArguments(LOperand* function,
553 LOperand* elements) {
554 inputs_[0] = function;
555 inputs_[1] = receiver;
557 inputs_[3] = elements;
560 DECLARE_CONCRETE_INSTRUCTION(ApplyArguments, "apply-arguments")
562 LOperand* function() { return inputs_[0]; }
563 LOperand* receiver() { return inputs_[1]; }
564 LOperand* length() { return inputs_[2]; }
565 LOperand* elements() { return inputs_[3]; }
569 class LAccessArgumentsAt final : public LTemplateInstruction<1, 3, 0> {
571 LAccessArgumentsAt(LOperand* arguments, LOperand* length, LOperand* index) {
572 inputs_[0] = arguments;
577 DECLARE_CONCRETE_INSTRUCTION(AccessArgumentsAt, "access-arguments-at")
579 LOperand* arguments() { return inputs_[0]; }
580 LOperand* length() { return inputs_[1]; }
581 LOperand* index() { return inputs_[2]; }
583 void PrintDataTo(StringStream* stream) override;
587 class LArgumentsLength final : public LTemplateInstruction<1, 1, 0> {
589 explicit LArgumentsLength(LOperand* elements) {
590 inputs_[0] = elements;
593 LOperand* elements() { return inputs_[0]; }
595 DECLARE_CONCRETE_INSTRUCTION(ArgumentsLength, "arguments-length")
599 class LArgumentsElements final : public LTemplateInstruction<1, 0, 0> {
601 DECLARE_CONCRETE_INSTRUCTION(ArgumentsElements, "arguments-elements")
602 DECLARE_HYDROGEN_ACCESSOR(ArgumentsElements)
606 class LModByPowerOf2I final : public LTemplateInstruction<1, 1, 0> {
608 LModByPowerOf2I(LOperand* dividend, int32_t divisor) {
609 inputs_[0] = dividend;
613 LOperand* dividend() { return inputs_[0]; }
614 int32_t divisor() const { return divisor_; }
616 DECLARE_CONCRETE_INSTRUCTION(ModByPowerOf2I, "mod-by-power-of-2-i")
617 DECLARE_HYDROGEN_ACCESSOR(Mod)
624 class LModByConstI final : public LTemplateInstruction<1, 1, 0> {
626 LModByConstI(LOperand* dividend, int32_t divisor) {
627 inputs_[0] = dividend;
631 LOperand* dividend() { return inputs_[0]; }
632 int32_t divisor() const { return divisor_; }
634 DECLARE_CONCRETE_INSTRUCTION(ModByConstI, "mod-by-const-i")
635 DECLARE_HYDROGEN_ACCESSOR(Mod)
642 class LModI final : public LTemplateInstruction<1, 2, 2> {
644 LModI(LOperand* left, LOperand* right, LOperand* temp, LOperand* temp2) {
651 LOperand* left() { return inputs_[0]; }
652 LOperand* right() { return inputs_[1]; }
653 LOperand* temp() { return temps_[0]; }
654 LOperand* temp2() { return temps_[1]; }
656 DECLARE_CONCRETE_INSTRUCTION(ModI, "mod-i")
657 DECLARE_HYDROGEN_ACCESSOR(Mod)
661 class LDivByPowerOf2I final : public LTemplateInstruction<1, 1, 0> {
663 LDivByPowerOf2I(LOperand* dividend, int32_t divisor) {
664 inputs_[0] = dividend;
668 LOperand* dividend() { return inputs_[0]; }
669 int32_t divisor() const { return divisor_; }
671 DECLARE_CONCRETE_INSTRUCTION(DivByPowerOf2I, "div-by-power-of-2-i")
672 DECLARE_HYDROGEN_ACCESSOR(Div)
679 class LDivByConstI final : public LTemplateInstruction<1, 1, 0> {
681 LDivByConstI(LOperand* dividend, int32_t divisor) {
682 inputs_[0] = dividend;
686 LOperand* dividend() { return inputs_[0]; }
687 int32_t divisor() const { return divisor_; }
689 DECLARE_CONCRETE_INSTRUCTION(DivByConstI, "div-by-const-i")
690 DECLARE_HYDROGEN_ACCESSOR(Div)
697 class LDivI final : public LTemplateInstruction<1, 2, 1> {
699 LDivI(LOperand* dividend, LOperand* divisor, LOperand* temp) {
700 inputs_[0] = dividend;
701 inputs_[1] = divisor;
705 LOperand* dividend() { return inputs_[0]; }
706 LOperand* divisor() { return inputs_[1]; }
707 LOperand* temp() { return temps_[0]; }
709 DECLARE_CONCRETE_INSTRUCTION(DivI, "div-i")
710 DECLARE_HYDROGEN_ACCESSOR(BinaryOperation)
714 class LFlooringDivByPowerOf2I final : public LTemplateInstruction<1, 1, 0> {
716 LFlooringDivByPowerOf2I(LOperand* dividend, int32_t divisor) {
717 inputs_[0] = dividend;
721 LOperand* dividend() { return inputs_[0]; }
722 int32_t divisor() { return divisor_; }
724 DECLARE_CONCRETE_INSTRUCTION(FlooringDivByPowerOf2I,
725 "flooring-div-by-power-of-2-i")
726 DECLARE_HYDROGEN_ACCESSOR(MathFloorOfDiv)
733 class LFlooringDivByConstI final : public LTemplateInstruction<1, 1, 2> {
735 LFlooringDivByConstI(LOperand* dividend, int32_t divisor, LOperand* temp) {
736 inputs_[0] = dividend;
741 LOperand* dividend() { return inputs_[0]; }
742 int32_t divisor() const { return divisor_; }
743 LOperand* temp() { return temps_[0]; }
745 DECLARE_CONCRETE_INSTRUCTION(FlooringDivByConstI, "flooring-div-by-const-i")
746 DECLARE_HYDROGEN_ACCESSOR(MathFloorOfDiv)
753 class LFlooringDivI final : public LTemplateInstruction<1, 2, 1> {
755 LFlooringDivI(LOperand* dividend, LOperand* divisor, LOperand* temp) {
756 inputs_[0] = dividend;
757 inputs_[1] = divisor;
761 LOperand* dividend() { return inputs_[0]; }
762 LOperand* divisor() { return inputs_[1]; }
763 LOperand* temp() { return temps_[0]; }
765 DECLARE_CONCRETE_INSTRUCTION(FlooringDivI, "flooring-div-i")
766 DECLARE_HYDROGEN_ACCESSOR(MathFloorOfDiv)
770 class LMulI final : public LTemplateInstruction<1, 2, 0> {
772 LMulI(LOperand* left, LOperand* right) {
777 LOperand* left() { return inputs_[0]; }
778 LOperand* right() { return inputs_[1]; }
780 DECLARE_CONCRETE_INSTRUCTION(MulI, "mul-i")
781 DECLARE_HYDROGEN_ACCESSOR(Mul)
785 // Instruction for computing multiplier * multiplicand + addend.
786 class LMultiplyAddD final : public LTemplateInstruction<1, 3, 0> {
788 LMultiplyAddD(LOperand* addend, LOperand* multiplier,
789 LOperand* multiplicand) {
791 inputs_[1] = multiplier;
792 inputs_[2] = multiplicand;
795 LOperand* addend() { return inputs_[0]; }
796 LOperand* multiplier() { return inputs_[1]; }
797 LOperand* multiplicand() { return inputs_[2]; }
799 DECLARE_CONCRETE_INSTRUCTION(MultiplyAddD, "multiply-add-d")
803 // Instruction for computing minuend - multiplier * multiplicand.
804 class LMultiplySubD final : public LTemplateInstruction<1, 3, 0> {
806 LMultiplySubD(LOperand* minuend, LOperand* multiplier,
807 LOperand* multiplicand) {
808 inputs_[0] = minuend;
809 inputs_[1] = multiplier;
810 inputs_[2] = multiplicand;
813 LOperand* minuend() { return inputs_[0]; }
814 LOperand* multiplier() { return inputs_[1]; }
815 LOperand* multiplicand() { return inputs_[2]; }
817 DECLARE_CONCRETE_INSTRUCTION(MultiplySubD, "multiply-sub-d")
821 class LDebugBreak final : public LTemplateInstruction<0, 0, 0> {
823 DECLARE_CONCRETE_INSTRUCTION(DebugBreak, "break")
827 class LCompareNumericAndBranch final : public LControlInstruction<2, 0> {
829 LCompareNumericAndBranch(LOperand* left, LOperand* right) {
834 LOperand* left() { return inputs_[0]; }
835 LOperand* right() { return inputs_[1]; }
837 DECLARE_CONCRETE_INSTRUCTION(CompareNumericAndBranch,
838 "compare-numeric-and-branch")
839 DECLARE_HYDROGEN_ACCESSOR(CompareNumericAndBranch)
841 Token::Value op() const { return hydrogen()->token(); }
842 bool is_double() const {
843 return hydrogen()->representation().IsDouble();
846 void PrintDataTo(StringStream* stream) override;
850 class LMathFloor final : public LTemplateInstruction<1, 1, 0> {
852 explicit LMathFloor(LOperand* value) {
856 LOperand* value() { return inputs_[0]; }
858 DECLARE_CONCRETE_INSTRUCTION(MathFloor, "math-floor")
859 DECLARE_HYDROGEN_ACCESSOR(UnaryMathOperation)
863 class LMathRound final : public LTemplateInstruction<1, 1, 1> {
865 LMathRound(LOperand* value, LOperand* temp) {
870 LOperand* value() { return inputs_[0]; }
871 LOperand* temp() { return temps_[0]; }
873 DECLARE_CONCRETE_INSTRUCTION(MathRound, "math-round")
874 DECLARE_HYDROGEN_ACCESSOR(UnaryMathOperation)
878 class LMathFround final : public LTemplateInstruction<1, 1, 0> {
880 explicit LMathFround(LOperand* value) { inputs_[0] = value; }
882 LOperand* value() { return inputs_[0]; }
884 DECLARE_CONCRETE_INSTRUCTION(MathFround, "math-fround")
888 class LMathAbs final : public LTemplateInstruction<1, 2, 0> {
890 LMathAbs(LOperand* context, LOperand* value) {
891 inputs_[1] = context;
895 LOperand* context() { return inputs_[1]; }
896 LOperand* value() { return inputs_[0]; }
898 DECLARE_CONCRETE_INSTRUCTION(MathAbs, "math-abs")
899 DECLARE_HYDROGEN_ACCESSOR(UnaryMathOperation)
903 class LMathLog final : public LTemplateInstruction<1, 1, 0> {
905 explicit LMathLog(LOperand* value) {
909 LOperand* value() { return inputs_[0]; }
911 DECLARE_CONCRETE_INSTRUCTION(MathLog, "math-log")
915 class LMathClz32 final : public LTemplateInstruction<1, 1, 0> {
917 explicit LMathClz32(LOperand* value) {
921 LOperand* value() { return inputs_[0]; }
923 DECLARE_CONCRETE_INSTRUCTION(MathClz32, "math-clz32")
927 class LMathExp final : public LTemplateInstruction<1, 1, 3> {
929 LMathExp(LOperand* value,
930 LOperand* double_temp,
936 temps_[2] = double_temp;
937 ExternalReference::InitializeMathExpData();
940 LOperand* value() { return inputs_[0]; }
941 LOperand* temp1() { return temps_[0]; }
942 LOperand* temp2() { return temps_[1]; }
943 LOperand* double_temp() { return temps_[2]; }
945 DECLARE_CONCRETE_INSTRUCTION(MathExp, "math-exp")
949 class LMathSqrt final : public LTemplateInstruction<1, 1, 0> {
951 explicit LMathSqrt(LOperand* value) {
955 LOperand* value() { return inputs_[0]; }
957 DECLARE_CONCRETE_INSTRUCTION(MathSqrt, "math-sqrt")
961 class LMathPowHalf final : public LTemplateInstruction<1, 1, 0> {
963 explicit LMathPowHalf(LOperand* value) {
967 LOperand* value() { return inputs_[0]; }
969 DECLARE_CONCRETE_INSTRUCTION(MathPowHalf, "math-pow-half")
973 class LCmpObjectEqAndBranch final : public LControlInstruction<2, 0> {
975 LCmpObjectEqAndBranch(LOperand* left, LOperand* right) {
980 LOperand* left() { return inputs_[0]; }
981 LOperand* right() { return inputs_[1]; }
983 DECLARE_CONCRETE_INSTRUCTION(CmpObjectEqAndBranch, "cmp-object-eq-and-branch")
984 DECLARE_HYDROGEN_ACCESSOR(CompareObjectEqAndBranch)
988 class LCmpHoleAndBranch final : public LControlInstruction<1, 0> {
990 explicit LCmpHoleAndBranch(LOperand* object) {
994 LOperand* object() { return inputs_[0]; }
996 DECLARE_CONCRETE_INSTRUCTION(CmpHoleAndBranch, "cmp-hole-and-branch")
997 DECLARE_HYDROGEN_ACCESSOR(CompareHoleAndBranch)
1001 class LCompareMinusZeroAndBranch final : public LControlInstruction<1, 1> {
1003 LCompareMinusZeroAndBranch(LOperand* value, LOperand* temp) {
1008 LOperand* value() { return inputs_[0]; }
1009 LOperand* temp() { return temps_[0]; }
1011 DECLARE_CONCRETE_INSTRUCTION(CompareMinusZeroAndBranch,
1012 "cmp-minus-zero-and-branch")
1013 DECLARE_HYDROGEN_ACCESSOR(CompareMinusZeroAndBranch)
1017 class LIsStringAndBranch final : public LControlInstruction<1, 1> {
1019 LIsStringAndBranch(LOperand* value, LOperand* temp) {
1024 LOperand* value() { return inputs_[0]; }
1025 LOperand* temp() { return temps_[0]; }
1027 DECLARE_CONCRETE_INSTRUCTION(IsStringAndBranch, "is-string-and-branch")
1028 DECLARE_HYDROGEN_ACCESSOR(IsStringAndBranch)
1030 void PrintDataTo(StringStream* stream) override;
1034 class LIsSmiAndBranch final : public LControlInstruction<1, 0> {
1036 explicit LIsSmiAndBranch(LOperand* value) {
1040 LOperand* value() { return inputs_[0]; }
1042 DECLARE_CONCRETE_INSTRUCTION(IsSmiAndBranch, "is-smi-and-branch")
1043 DECLARE_HYDROGEN_ACCESSOR(IsSmiAndBranch)
1045 void PrintDataTo(StringStream* stream) override;
1049 class LIsUndetectableAndBranch final : public LControlInstruction<1, 1> {
1051 explicit LIsUndetectableAndBranch(LOperand* value, LOperand* temp) {
1056 LOperand* value() { return inputs_[0]; }
1057 LOperand* temp() { return temps_[0]; }
1059 DECLARE_CONCRETE_INSTRUCTION(IsUndetectableAndBranch,
1060 "is-undetectable-and-branch")
1061 DECLARE_HYDROGEN_ACCESSOR(IsUndetectableAndBranch)
1063 void PrintDataTo(StringStream* stream) override;
1067 class LStringCompareAndBranch final : public LControlInstruction<3, 0> {
1069 LStringCompareAndBranch(LOperand* context, LOperand* left, LOperand* right) {
1070 inputs_[0] = context;
1075 LOperand* context() { return inputs_[0]; }
1076 LOperand* left() { return inputs_[1]; }
1077 LOperand* right() { return inputs_[2]; }
1079 DECLARE_CONCRETE_INSTRUCTION(StringCompareAndBranch,
1080 "string-compare-and-branch")
1081 DECLARE_HYDROGEN_ACCESSOR(StringCompareAndBranch)
1083 Token::Value op() const { return hydrogen()->token(); }
1085 void PrintDataTo(StringStream* stream) override;
1089 class LHasInstanceTypeAndBranch final : public LControlInstruction<1, 0> {
1091 explicit LHasInstanceTypeAndBranch(LOperand* value) {
1095 LOperand* value() { return inputs_[0]; }
1097 DECLARE_CONCRETE_INSTRUCTION(HasInstanceTypeAndBranch,
1098 "has-instance-type-and-branch")
1099 DECLARE_HYDROGEN_ACCESSOR(HasInstanceTypeAndBranch)
1101 void PrintDataTo(StringStream* stream) override;
1105 class LGetCachedArrayIndex final : public LTemplateInstruction<1, 1, 0> {
1107 explicit LGetCachedArrayIndex(LOperand* value) {
1111 LOperand* value() { return inputs_[0]; }
1113 DECLARE_CONCRETE_INSTRUCTION(GetCachedArrayIndex, "get-cached-array-index")
1114 DECLARE_HYDROGEN_ACCESSOR(GetCachedArrayIndex)
1118 class LHasCachedArrayIndexAndBranch final : public LControlInstruction<1, 0> {
1120 explicit LHasCachedArrayIndexAndBranch(LOperand* value) {
1124 LOperand* value() { return inputs_[0]; }
1126 DECLARE_CONCRETE_INSTRUCTION(HasCachedArrayIndexAndBranch,
1127 "has-cached-array-index-and-branch")
1128 DECLARE_HYDROGEN_ACCESSOR(HasCachedArrayIndexAndBranch)
1130 void PrintDataTo(StringStream* stream) override;
1134 class LClassOfTestAndBranch final : public LControlInstruction<1, 1> {
1136 LClassOfTestAndBranch(LOperand* value, LOperand* temp) {
1141 LOperand* value() { return inputs_[0]; }
1142 LOperand* temp() { return temps_[0]; }
1144 DECLARE_CONCRETE_INSTRUCTION(ClassOfTestAndBranch,
1145 "class-of-test-and-branch")
1146 DECLARE_HYDROGEN_ACCESSOR(ClassOfTestAndBranch)
1148 void PrintDataTo(StringStream* stream) override;
1152 class LCmpT final : public LTemplateInstruction<1, 3, 0> {
1154 LCmpT(LOperand* context, LOperand* left, LOperand* right) {
1155 inputs_[0] = context;
1160 LOperand* context() { return inputs_[0]; }
1161 LOperand* left() { return inputs_[1]; }
1162 LOperand* right() { return inputs_[2]; }
1164 DECLARE_CONCRETE_INSTRUCTION(CmpT, "cmp-t")
1165 DECLARE_HYDROGEN_ACCESSOR(CompareGeneric)
1167 Strength strength() { return hydrogen()->strength(); }
1169 Token::Value op() const { return hydrogen()->token(); }
1173 class LInstanceOf final : public LTemplateInstruction<1, 3, 0> {
1175 LInstanceOf(LOperand* context, LOperand* left, LOperand* right) {
1176 inputs_[0] = context;
1181 LOperand* context() const { return inputs_[0]; }
1182 LOperand* left() const { return inputs_[1]; }
1183 LOperand* right() const { return inputs_[2]; }
1185 DECLARE_CONCRETE_INSTRUCTION(InstanceOf, "instance-of")
1189 class LHasInPrototypeChainAndBranch final : public LControlInstruction<2, 0> {
1191 LHasInPrototypeChainAndBranch(LOperand* object, LOperand* prototype) {
1192 inputs_[0] = object;
1193 inputs_[1] = prototype;
1196 LOperand* object() const { return inputs_[0]; }
1197 LOperand* prototype() const { return inputs_[1]; }
1199 DECLARE_CONCRETE_INSTRUCTION(HasInPrototypeChainAndBranch,
1200 "has-in-prototype-chain-and-branch")
1201 DECLARE_HYDROGEN_ACCESSOR(HasInPrototypeChainAndBranch)
1205 class LBoundsCheck final : public LTemplateInstruction<0, 2, 0> {
1207 LBoundsCheck(LOperand* index, LOperand* length) {
1209 inputs_[1] = length;
1212 LOperand* index() { return inputs_[0]; }
1213 LOperand* length() { return inputs_[1]; }
1215 DECLARE_CONCRETE_INSTRUCTION(BoundsCheck, "bounds-check")
1216 DECLARE_HYDROGEN_ACCESSOR(BoundsCheck)
1220 class LBitI final : public LTemplateInstruction<1, 2, 0> {
1222 LBitI(LOperand* left, LOperand* right) {
1227 LOperand* left() { return inputs_[0]; }
1228 LOperand* right() { return inputs_[1]; }
1230 Token::Value op() const { return hydrogen()->op(); }
1232 DECLARE_CONCRETE_INSTRUCTION(BitI, "bit-i")
1233 DECLARE_HYDROGEN_ACCESSOR(Bitwise)
1237 class LShiftI final : public LTemplateInstruction<1, 2, 0> {
1239 LShiftI(Token::Value op, LOperand* left, LOperand* right, bool can_deopt)
1240 : op_(op), can_deopt_(can_deopt) {
1245 Token::Value op() const { return op_; }
1246 LOperand* left() { return inputs_[0]; }
1247 LOperand* right() { return inputs_[1]; }
1248 bool can_deopt() const { return can_deopt_; }
1250 DECLARE_CONCRETE_INSTRUCTION(ShiftI, "shift-i")
1258 class LSubI final : public LTemplateInstruction<1, 2, 0> {
1260 LSubI(LOperand* left, LOperand* right) {
1265 LOperand* left() { return inputs_[0]; }
1266 LOperand* right() { return inputs_[1]; }
1268 DECLARE_CONCRETE_INSTRUCTION(SubI, "sub-i")
1269 DECLARE_HYDROGEN_ACCESSOR(Sub)
1273 class LRSubI final : public LTemplateInstruction<1, 2, 0> {
1275 LRSubI(LOperand* left, LOperand* right) {
1280 LOperand* left() { return inputs_[0]; }
1281 LOperand* right() { return inputs_[1]; }
1283 DECLARE_CONCRETE_INSTRUCTION(RSubI, "rsub-i")
1284 DECLARE_HYDROGEN_ACCESSOR(Sub)
1288 class LConstantI final : public LTemplateInstruction<1, 0, 0> {
1290 DECLARE_CONCRETE_INSTRUCTION(ConstantI, "constant-i")
1291 DECLARE_HYDROGEN_ACCESSOR(Constant)
1293 int32_t value() const { return hydrogen()->Integer32Value(); }
1297 class LConstantS final : public LTemplateInstruction<1, 0, 0> {
1299 DECLARE_CONCRETE_INSTRUCTION(ConstantS, "constant-s")
1300 DECLARE_HYDROGEN_ACCESSOR(Constant)
1302 Smi* value() const { return Smi::FromInt(hydrogen()->Integer32Value()); }
1306 class LConstantD final : public LTemplateInstruction<1, 0, 0> {
1308 DECLARE_CONCRETE_INSTRUCTION(ConstantD, "constant-d")
1309 DECLARE_HYDROGEN_ACCESSOR(Constant)
1311 double value() const { return hydrogen()->DoubleValue(); }
1312 uint64_t bits() const { return hydrogen()->DoubleValueAsBits(); }
1316 class LConstantE final : public LTemplateInstruction<1, 0, 0> {
1318 DECLARE_CONCRETE_INSTRUCTION(ConstantE, "constant-e")
1319 DECLARE_HYDROGEN_ACCESSOR(Constant)
1321 ExternalReference value() const {
1322 return hydrogen()->ExternalReferenceValue();
1327 class LConstantT final : public LTemplateInstruction<1, 0, 0> {
1329 DECLARE_CONCRETE_INSTRUCTION(ConstantT, "constant-t")
1330 DECLARE_HYDROGEN_ACCESSOR(Constant)
1332 Handle<Object> value(Isolate* isolate) const {
1333 return hydrogen()->handle(isolate);
1338 class LBranch final : public LControlInstruction<1, 0> {
1340 explicit LBranch(LOperand* value) {
1344 LOperand* value() { return inputs_[0]; }
1346 DECLARE_CONCRETE_INSTRUCTION(Branch, "branch")
1347 DECLARE_HYDROGEN_ACCESSOR(Branch)
1349 void PrintDataTo(StringStream* stream) override;
1353 class LCmpMapAndBranch final : public LControlInstruction<1, 1> {
1355 LCmpMapAndBranch(LOperand* value, LOperand* temp) {
1360 LOperand* value() { return inputs_[0]; }
1361 LOperand* temp() { return temps_[0]; }
1363 DECLARE_CONCRETE_INSTRUCTION(CmpMapAndBranch, "cmp-map-and-branch")
1364 DECLARE_HYDROGEN_ACCESSOR(CompareMap)
1366 Handle<Map> map() const { return hydrogen()->map().handle(); }
1370 class LMapEnumLength final : public LTemplateInstruction<1, 1, 0> {
1372 explicit LMapEnumLength(LOperand* value) {
1376 LOperand* value() { return inputs_[0]; }
1378 DECLARE_CONCRETE_INSTRUCTION(MapEnumLength, "map-enum-length")
1382 class LDateField final : public LTemplateInstruction<1, 1, 1> {
1384 LDateField(LOperand* date, LOperand* temp, Smi* index) : index_(index) {
1389 LOperand* date() { return inputs_[0]; }
1390 LOperand* temp() { return temps_[0]; }
1391 Smi* index() const { return index_; }
1393 DECLARE_CONCRETE_INSTRUCTION(DateField, "date-field")
1394 DECLARE_HYDROGEN_ACCESSOR(DateField)
1401 class LSeqStringGetChar final : public LTemplateInstruction<1, 2, 0> {
1403 LSeqStringGetChar(LOperand* string, LOperand* index) {
1404 inputs_[0] = string;
1408 LOperand* string() const { return inputs_[0]; }
1409 LOperand* index() const { return inputs_[1]; }
1411 DECLARE_CONCRETE_INSTRUCTION(SeqStringGetChar, "seq-string-get-char")
1412 DECLARE_HYDROGEN_ACCESSOR(SeqStringGetChar)
1416 class LSeqStringSetChar final : public LTemplateInstruction<1, 4, 0> {
1418 LSeqStringSetChar(LOperand* context,
1422 inputs_[0] = context;
1423 inputs_[1] = string;
1428 LOperand* string() { return inputs_[1]; }
1429 LOperand* index() { return inputs_[2]; }
1430 LOperand* value() { return inputs_[3]; }
1432 DECLARE_CONCRETE_INSTRUCTION(SeqStringSetChar, "seq-string-set-char")
1433 DECLARE_HYDROGEN_ACCESSOR(SeqStringSetChar)
1437 class LAddI final : public LTemplateInstruction<1, 2, 0> {
1439 LAddI(LOperand* left, LOperand* right) {
1444 LOperand* left() { return inputs_[0]; }
1445 LOperand* right() { return inputs_[1]; }
1447 DECLARE_CONCRETE_INSTRUCTION(AddI, "add-i")
1448 DECLARE_HYDROGEN_ACCESSOR(Add)
1452 class LMathMinMax final : public LTemplateInstruction<1, 2, 0> {
1454 LMathMinMax(LOperand* left, LOperand* right) {
1459 LOperand* left() { return inputs_[0]; }
1460 LOperand* right() { return inputs_[1]; }
1462 DECLARE_CONCRETE_INSTRUCTION(MathMinMax, "math-min-max")
1463 DECLARE_HYDROGEN_ACCESSOR(MathMinMax)
1467 class LPower final : public LTemplateInstruction<1, 2, 0> {
1469 LPower(LOperand* left, LOperand* right) {
1474 LOperand* left() { return inputs_[0]; }
1475 LOperand* right() { return inputs_[1]; }
1477 DECLARE_CONCRETE_INSTRUCTION(Power, "power")
1478 DECLARE_HYDROGEN_ACCESSOR(Power)
1482 class LArithmeticD final : public LTemplateInstruction<1, 2, 0> {
1484 LArithmeticD(Token::Value op, LOperand* left, LOperand* right)
1490 Token::Value op() const { return op_; }
1491 LOperand* left() { return inputs_[0]; }
1492 LOperand* right() { return inputs_[1]; }
1494 Opcode opcode() const override { return LInstruction::kArithmeticD; }
1495 void CompileToNative(LCodeGen* generator) override;
1496 const char* Mnemonic() const override;
1503 class LArithmeticT final : public LTemplateInstruction<1, 3, 0> {
1505 LArithmeticT(Token::Value op,
1510 inputs_[0] = context;
1515 LOperand* context() { return inputs_[0]; }
1516 LOperand* left() { return inputs_[1]; }
1517 LOperand* right() { return inputs_[2]; }
1518 Token::Value op() const { return op_; }
1520 Opcode opcode() const override { return LInstruction::kArithmeticT; }
1521 void CompileToNative(LCodeGen* generator) override;
1522 const char* Mnemonic() const override;
1524 DECLARE_HYDROGEN_ACCESSOR(BinaryOperation)
1526 Strength strength() { return hydrogen()->strength(); }
1533 class LReturn final : public LTemplateInstruction<0, 3, 0> {
1535 LReturn(LOperand* value, LOperand* context, LOperand* parameter_count) {
1537 inputs_[1] = context;
1538 inputs_[2] = parameter_count;
1541 LOperand* value() { return inputs_[0]; }
1543 bool has_constant_parameter_count() {
1544 return parameter_count()->IsConstantOperand();
1546 LConstantOperand* constant_parameter_count() {
1547 DCHECK(has_constant_parameter_count());
1548 return LConstantOperand::cast(parameter_count());
1550 LOperand* parameter_count() { return inputs_[2]; }
1552 DECLARE_CONCRETE_INSTRUCTION(Return, "return")
1556 class LLoadNamedField final : public LTemplateInstruction<1, 1, 0> {
1558 explicit LLoadNamedField(LOperand* object) {
1559 inputs_[0] = object;
1562 LOperand* object() { return inputs_[0]; }
1564 DECLARE_CONCRETE_INSTRUCTION(LoadNamedField, "load-named-field")
1565 DECLARE_HYDROGEN_ACCESSOR(LoadNamedField)
1569 class LLoadNamedGeneric final : public LTemplateInstruction<1, 2, 1> {
1571 LLoadNamedGeneric(LOperand* context, LOperand* object, LOperand* vector) {
1572 inputs_[0] = context;
1573 inputs_[1] = object;
1577 LOperand* context() { return inputs_[0]; }
1578 LOperand* object() { return inputs_[1]; }
1579 LOperand* temp_vector() { return temps_[0]; }
1581 DECLARE_CONCRETE_INSTRUCTION(LoadNamedGeneric, "load-named-generic")
1582 DECLARE_HYDROGEN_ACCESSOR(LoadNamedGeneric)
1584 Handle<Object> name() const { return hydrogen()->name(); }
1588 class LLoadFunctionPrototype final : public LTemplateInstruction<1, 1, 0> {
1590 explicit LLoadFunctionPrototype(LOperand* function) {
1591 inputs_[0] = function;
1594 LOperand* function() { return inputs_[0]; }
1596 DECLARE_CONCRETE_INSTRUCTION(LoadFunctionPrototype, "load-function-prototype")
1597 DECLARE_HYDROGEN_ACCESSOR(LoadFunctionPrototype)
1601 class LLoadRoot final : public LTemplateInstruction<1, 0, 0> {
1603 DECLARE_CONCRETE_INSTRUCTION(LoadRoot, "load-root")
1604 DECLARE_HYDROGEN_ACCESSOR(LoadRoot)
1606 Heap::RootListIndex index() const { return hydrogen()->index(); }
1610 class LLoadKeyed final : public LTemplateInstruction<1, 2, 0> {
1612 LLoadKeyed(LOperand* elements, LOperand* key) {
1613 inputs_[0] = elements;
1617 LOperand* elements() { return inputs_[0]; }
1618 LOperand* key() { return inputs_[1]; }
1619 ElementsKind elements_kind() const {
1620 return hydrogen()->elements_kind();
1622 bool is_fixed_typed_array() const {
1623 return hydrogen()->is_fixed_typed_array();
1626 DECLARE_CONCRETE_INSTRUCTION(LoadKeyed, "load-keyed")
1627 DECLARE_HYDROGEN_ACCESSOR(LoadKeyed)
1629 void PrintDataTo(StringStream* stream) override;
1630 uint32_t base_offset() const { return hydrogen()->base_offset(); }
1634 class LLoadKeyedGeneric final : public LTemplateInstruction<1, 3, 1> {
1636 LLoadKeyedGeneric(LOperand* context, LOperand* object, LOperand* key,
1638 inputs_[0] = context;
1639 inputs_[1] = object;
1644 LOperand* context() { return inputs_[0]; }
1645 LOperand* object() { return inputs_[1]; }
1646 LOperand* key() { return inputs_[2]; }
1647 LOperand* temp_vector() { return temps_[0]; }
1649 DECLARE_CONCRETE_INSTRUCTION(LoadKeyedGeneric, "load-keyed-generic")
1650 DECLARE_HYDROGEN_ACCESSOR(LoadKeyedGeneric)
1654 class LLoadGlobalGeneric final : public LTemplateInstruction<1, 2, 1> {
1656 LLoadGlobalGeneric(LOperand* context, LOperand* global_object,
1658 inputs_[0] = context;
1659 inputs_[1] = global_object;
1663 LOperand* context() { return inputs_[0]; }
1664 LOperand* global_object() { return inputs_[1]; }
1665 LOperand* temp_vector() { return temps_[0]; }
1667 DECLARE_CONCRETE_INSTRUCTION(LoadGlobalGeneric, "load-global-generic")
1668 DECLARE_HYDROGEN_ACCESSOR(LoadGlobalGeneric)
1670 Handle<Object> name() const { return hydrogen()->name(); }
1671 TypeofMode typeof_mode() const { return hydrogen()->typeof_mode(); }
1675 class LLoadGlobalViaContext final : public LTemplateInstruction<1, 1, 1> {
1677 explicit LLoadGlobalViaContext(LOperand* context) { inputs_[0] = context; }
1679 DECLARE_CONCRETE_INSTRUCTION(LoadGlobalViaContext, "load-global-via-context")
1680 DECLARE_HYDROGEN_ACCESSOR(LoadGlobalViaContext)
1682 void PrintDataTo(StringStream* stream) override;
1684 LOperand* context() { return inputs_[0]; }
1686 int depth() const { return hydrogen()->depth(); }
1687 int slot_index() const { return hydrogen()->slot_index(); }
1691 class LLoadContextSlot final : public LTemplateInstruction<1, 1, 0> {
1693 explicit LLoadContextSlot(LOperand* context) {
1694 inputs_[0] = context;
1697 LOperand* context() { return inputs_[0]; }
1699 DECLARE_CONCRETE_INSTRUCTION(LoadContextSlot, "load-context-slot")
1700 DECLARE_HYDROGEN_ACCESSOR(LoadContextSlot)
1702 int slot_index() { return hydrogen()->slot_index(); }
1704 void PrintDataTo(StringStream* stream) override;
1708 class LStoreContextSlot final : public LTemplateInstruction<0, 2, 0> {
1710 LStoreContextSlot(LOperand* context, LOperand* value) {
1711 inputs_[0] = context;
1715 LOperand* context() { return inputs_[0]; }
1716 LOperand* value() { return inputs_[1]; }
1718 DECLARE_CONCRETE_INSTRUCTION(StoreContextSlot, "store-context-slot")
1719 DECLARE_HYDROGEN_ACCESSOR(StoreContextSlot)
1721 int slot_index() { return hydrogen()->slot_index(); }
1723 void PrintDataTo(StringStream* stream) override;
1727 class LPushArgument final : public LTemplateInstruction<0, 1, 0> {
1729 explicit LPushArgument(LOperand* value) {
1733 LOperand* value() { return inputs_[0]; }
1735 DECLARE_CONCRETE_INSTRUCTION(PushArgument, "push-argument")
1739 class LDrop final : public LTemplateInstruction<0, 0, 0> {
1741 explicit LDrop(int count) : count_(count) { }
1743 int count() const { return count_; }
1745 DECLARE_CONCRETE_INSTRUCTION(Drop, "drop")
1752 class LStoreCodeEntry final : public LTemplateInstruction<0, 2, 0> {
1754 LStoreCodeEntry(LOperand* function, LOperand* code_object) {
1755 inputs_[0] = function;
1756 inputs_[1] = code_object;
1759 LOperand* function() { return inputs_[0]; }
1760 LOperand* code_object() { return inputs_[1]; }
1762 void PrintDataTo(StringStream* stream) override;
1764 DECLARE_CONCRETE_INSTRUCTION(StoreCodeEntry, "store-code-entry")
1765 DECLARE_HYDROGEN_ACCESSOR(StoreCodeEntry)
1769 class LInnerAllocatedObject final : public LTemplateInstruction<1, 2, 0> {
1771 LInnerAllocatedObject(LOperand* base_object, LOperand* offset) {
1772 inputs_[0] = base_object;
1773 inputs_[1] = offset;
1776 LOperand* base_object() const { return inputs_[0]; }
1777 LOperand* offset() const { return inputs_[1]; }
1779 void PrintDataTo(StringStream* stream) override;
1781 DECLARE_CONCRETE_INSTRUCTION(InnerAllocatedObject, "inner-allocated-object")
1785 class LThisFunction final : public LTemplateInstruction<1, 0, 0> {
1787 DECLARE_CONCRETE_INSTRUCTION(ThisFunction, "this-function")
1788 DECLARE_HYDROGEN_ACCESSOR(ThisFunction)
1792 class LContext final : public LTemplateInstruction<1, 0, 0> {
1794 DECLARE_CONCRETE_INSTRUCTION(Context, "context")
1795 DECLARE_HYDROGEN_ACCESSOR(Context)
1799 class LDeclareGlobals final : public LTemplateInstruction<0, 1, 0> {
1801 explicit LDeclareGlobals(LOperand* context) {
1802 inputs_[0] = context;
1805 LOperand* context() { return inputs_[0]; }
1807 DECLARE_CONCRETE_INSTRUCTION(DeclareGlobals, "declare-globals")
1808 DECLARE_HYDROGEN_ACCESSOR(DeclareGlobals)
1812 class LCallJSFunction final : public LTemplateInstruction<1, 1, 0> {
1814 explicit LCallJSFunction(LOperand* function) {
1815 inputs_[0] = function;
1818 LOperand* function() { return inputs_[0]; }
1820 DECLARE_CONCRETE_INSTRUCTION(CallJSFunction, "call-js-function")
1821 DECLARE_HYDROGEN_ACCESSOR(CallJSFunction)
1823 void PrintDataTo(StringStream* stream) override;
1825 int arity() const { return hydrogen()->argument_count() - 1; }
1829 class LCallWithDescriptor final : public LTemplateResultInstruction<1> {
1831 LCallWithDescriptor(CallInterfaceDescriptor descriptor,
1832 const ZoneList<LOperand*>& operands, Zone* zone)
1833 : descriptor_(descriptor),
1834 inputs_(descriptor.GetRegisterParameterCount() +
1835 kImplicitRegisterParameterCount,
1837 DCHECK(descriptor.GetRegisterParameterCount() +
1838 kImplicitRegisterParameterCount ==
1840 inputs_.AddAll(operands, zone);
1843 LOperand* target() const { return inputs_[0]; }
1845 const CallInterfaceDescriptor descriptor() { return descriptor_; }
1847 DECLARE_HYDROGEN_ACCESSOR(CallWithDescriptor)
1849 // The target and context are passed as implicit parameters that are not
1850 // explicitly listed in the descriptor.
1851 static const int kImplicitRegisterParameterCount = 2;
1854 DECLARE_CONCRETE_INSTRUCTION(CallWithDescriptor, "call-with-descriptor")
1856 void PrintDataTo(StringStream* stream) override;
1858 int arity() const { return hydrogen()->argument_count() - 1; }
1860 CallInterfaceDescriptor descriptor_;
1861 ZoneList<LOperand*> inputs_;
1863 // Iterator support.
1864 int InputCount() final { return inputs_.length(); }
1865 LOperand* InputAt(int i) final { return inputs_[i]; }
1867 int TempCount() final { return 0; }
1868 LOperand* TempAt(int i) final { return NULL; }
1872 class LInvokeFunction final : public LTemplateInstruction<1, 2, 0> {
1874 LInvokeFunction(LOperand* context, LOperand* function) {
1875 inputs_[0] = context;
1876 inputs_[1] = function;
1879 LOperand* context() { return inputs_[0]; }
1880 LOperand* function() { return inputs_[1]; }
1882 DECLARE_CONCRETE_INSTRUCTION(InvokeFunction, "invoke-function")
1883 DECLARE_HYDROGEN_ACCESSOR(InvokeFunction)
1885 void PrintDataTo(StringStream* stream) override;
1887 int arity() const { return hydrogen()->argument_count() - 1; }
1891 class LCallFunction final : public LTemplateInstruction<1, 2, 2> {
1893 LCallFunction(LOperand* context, LOperand* function, LOperand* slot,
1895 inputs_[0] = context;
1896 inputs_[1] = function;
1901 LOperand* context() { return inputs_[0]; }
1902 LOperand* function() { return inputs_[1]; }
1903 LOperand* temp_slot() { return temps_[0]; }
1904 LOperand* temp_vector() { return temps_[1]; }
1906 DECLARE_CONCRETE_INSTRUCTION(CallFunction, "call-function")
1907 DECLARE_HYDROGEN_ACCESSOR(CallFunction)
1909 int arity() const { return hydrogen()->argument_count() - 1; }
1910 void PrintDataTo(StringStream* stream) override;
1914 class LCallNew final : public LTemplateInstruction<1, 2, 0> {
1916 LCallNew(LOperand* context, LOperand* constructor) {
1917 inputs_[0] = context;
1918 inputs_[1] = constructor;
1921 LOperand* context() { return inputs_[0]; }
1922 LOperand* constructor() { return inputs_[1]; }
1924 DECLARE_CONCRETE_INSTRUCTION(CallNew, "call-new")
1925 DECLARE_HYDROGEN_ACCESSOR(CallNew)
1927 void PrintDataTo(StringStream* stream) override;
1929 int arity() const { return hydrogen()->argument_count() - 1; }
1933 class LCallNewArray final : public LTemplateInstruction<1, 2, 0> {
1935 LCallNewArray(LOperand* context, LOperand* constructor) {
1936 inputs_[0] = context;
1937 inputs_[1] = constructor;
1940 LOperand* context() { return inputs_[0]; }
1941 LOperand* constructor() { return inputs_[1]; }
1943 DECLARE_CONCRETE_INSTRUCTION(CallNewArray, "call-new-array")
1944 DECLARE_HYDROGEN_ACCESSOR(CallNewArray)
1946 void PrintDataTo(StringStream* stream) override;
1948 int arity() const { return hydrogen()->argument_count() - 1; }
1952 class LCallRuntime final : public LTemplateInstruction<1, 1, 0> {
1954 explicit LCallRuntime(LOperand* context) {
1955 inputs_[0] = context;
1958 LOperand* context() { return inputs_[0]; }
1960 DECLARE_CONCRETE_INSTRUCTION(CallRuntime, "call-runtime")
1961 DECLARE_HYDROGEN_ACCESSOR(CallRuntime)
1963 bool ClobbersDoubleRegisters(Isolate* isolate) const override {
1964 return save_doubles() == kDontSaveFPRegs;
1967 const Runtime::Function* function() const { return hydrogen()->function(); }
1968 int arity() const { return hydrogen()->argument_count(); }
1969 SaveFPRegsMode save_doubles() const { return hydrogen()->save_doubles(); }
1973 class LInteger32ToDouble final : public LTemplateInstruction<1, 1, 0> {
1975 explicit LInteger32ToDouble(LOperand* value) {
1979 LOperand* value() { return inputs_[0]; }
1981 DECLARE_CONCRETE_INSTRUCTION(Integer32ToDouble, "int32-to-double")
1985 class LUint32ToDouble final : public LTemplateInstruction<1, 1, 0> {
1987 explicit LUint32ToDouble(LOperand* value) {
1991 LOperand* value() { return inputs_[0]; }
1993 DECLARE_CONCRETE_INSTRUCTION(Uint32ToDouble, "uint32-to-double")
1997 class LNumberTagI final : public LTemplateInstruction<1, 1, 2> {
1999 LNumberTagI(LOperand* value, LOperand* temp1, LOperand* temp2) {
2005 LOperand* value() { return inputs_[0]; }
2006 LOperand* temp1() { return temps_[0]; }
2007 LOperand* temp2() { return temps_[1]; }
2009 DECLARE_CONCRETE_INSTRUCTION(NumberTagI, "number-tag-i")
2013 class LNumberTagU final : public LTemplateInstruction<1, 1, 2> {
2015 LNumberTagU(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(NumberTagU, "number-tag-u")
2029 class LNumberTagD final : public LTemplateInstruction<1, 1, 2> {
2031 LNumberTagD(LOperand* value, LOperand* temp, LOperand* temp2) {
2037 LOperand* value() { return inputs_[0]; }
2038 LOperand* temp() { return temps_[0]; }
2039 LOperand* temp2() { return temps_[1]; }
2041 DECLARE_CONCRETE_INSTRUCTION(NumberTagD, "number-tag-d")
2042 DECLARE_HYDROGEN_ACCESSOR(Change)
2046 class LDoubleToSmi final : public LTemplateInstruction<1, 1, 0> {
2048 explicit LDoubleToSmi(LOperand* value) {
2052 LOperand* value() { return inputs_[0]; }
2054 DECLARE_CONCRETE_INSTRUCTION(DoubleToSmi, "double-to-smi")
2055 DECLARE_HYDROGEN_ACCESSOR(UnaryOperation)
2057 bool truncating() { return hydrogen()->CanTruncateToInt32(); }
2061 // Sometimes truncating conversion from a tagged value to an int32.
2062 class LDoubleToI final : public LTemplateInstruction<1, 1, 0> {
2064 explicit LDoubleToI(LOperand* value) {
2068 LOperand* value() { return inputs_[0]; }
2070 DECLARE_CONCRETE_INSTRUCTION(DoubleToI, "double-to-i")
2071 DECLARE_HYDROGEN_ACCESSOR(UnaryOperation)
2073 bool truncating() { return hydrogen()->CanTruncateToInt32(); }
2077 // Truncating conversion from a tagged value to an int32.
2078 class LTaggedToI final : public LTemplateInstruction<1, 1, 2> {
2080 LTaggedToI(LOperand* value,
2088 LOperand* value() { return inputs_[0]; }
2089 LOperand* temp() { return temps_[0]; }
2090 LOperand* temp2() { return temps_[1]; }
2092 DECLARE_CONCRETE_INSTRUCTION(TaggedToI, "tagged-to-i")
2093 DECLARE_HYDROGEN_ACCESSOR(Change)
2095 bool truncating() { return hydrogen()->CanTruncateToInt32(); }
2099 class LSmiTag final : public LTemplateInstruction<1, 1, 0> {
2101 explicit LSmiTag(LOperand* value) {
2105 LOperand* value() { return inputs_[0]; }
2107 DECLARE_CONCRETE_INSTRUCTION(SmiTag, "smi-tag")
2108 DECLARE_HYDROGEN_ACCESSOR(Change)
2112 class LNumberUntagD final : public LTemplateInstruction<1, 1, 0> {
2114 explicit LNumberUntagD(LOperand* value) {
2118 LOperand* value() { return inputs_[0]; }
2120 DECLARE_CONCRETE_INSTRUCTION(NumberUntagD, "double-untag")
2121 DECLARE_HYDROGEN_ACCESSOR(Change)
2125 class LSmiUntag final : public LTemplateInstruction<1, 1, 0> {
2127 LSmiUntag(LOperand* value, bool needs_check)
2128 : needs_check_(needs_check) {
2132 LOperand* value() { return inputs_[0]; }
2133 bool needs_check() const { return needs_check_; }
2135 DECLARE_CONCRETE_INSTRUCTION(SmiUntag, "smi-untag")
2142 class LStoreNamedField final : public LTemplateInstruction<0, 2, 1> {
2144 LStoreNamedField(LOperand* object, LOperand* value, LOperand* temp) {
2145 inputs_[0] = object;
2150 LOperand* object() { return inputs_[0]; }
2151 LOperand* value() { return inputs_[1]; }
2152 LOperand* temp() { return temps_[0]; }
2154 DECLARE_CONCRETE_INSTRUCTION(StoreNamedField, "store-named-field")
2155 DECLARE_HYDROGEN_ACCESSOR(StoreNamedField)
2157 void PrintDataTo(StringStream* stream) override;
2159 Representation representation() const {
2160 return hydrogen()->field_representation();
2165 class LStoreNamedGeneric final : public LTemplateInstruction<0, 3, 2> {
2167 LStoreNamedGeneric(LOperand* context, LOperand* object, LOperand* value,
2168 LOperand* slot, LOperand* vector) {
2169 inputs_[0] = context;
2170 inputs_[1] = object;
2176 LOperand* context() { return inputs_[0]; }
2177 LOperand* object() { return inputs_[1]; }
2178 LOperand* value() { return inputs_[2]; }
2179 LOperand* temp_slot() { return temps_[0]; }
2180 LOperand* temp_vector() { return temps_[1]; }
2182 DECLARE_CONCRETE_INSTRUCTION(StoreNamedGeneric, "store-named-generic")
2183 DECLARE_HYDROGEN_ACCESSOR(StoreNamedGeneric)
2185 void PrintDataTo(StringStream* stream) override;
2187 Handle<Object> name() const { return hydrogen()->name(); }
2188 LanguageMode language_mode() { return hydrogen()->language_mode(); }
2192 class LStoreGlobalViaContext final : public LTemplateInstruction<0, 2, 0> {
2194 LStoreGlobalViaContext(LOperand* context, LOperand* value) {
2195 inputs_[0] = context;
2199 LOperand* context() { return inputs_[0]; }
2200 LOperand* value() { return inputs_[1]; }
2202 DECLARE_CONCRETE_INSTRUCTION(StoreGlobalViaContext,
2203 "store-global-via-context")
2204 DECLARE_HYDROGEN_ACCESSOR(StoreGlobalViaContext)
2206 void PrintDataTo(StringStream* stream) override;
2208 int depth() { return hydrogen()->depth(); }
2209 int slot_index() { return hydrogen()->slot_index(); }
2210 LanguageMode language_mode() { return hydrogen()->language_mode(); }
2214 class LStoreKeyed final : public LTemplateInstruction<0, 3, 0> {
2216 LStoreKeyed(LOperand* object, LOperand* key, LOperand* value) {
2217 inputs_[0] = object;
2222 bool is_fixed_typed_array() const {
2223 return hydrogen()->is_fixed_typed_array();
2225 LOperand* elements() { return inputs_[0]; }
2226 LOperand* key() { return inputs_[1]; }
2227 LOperand* value() { return inputs_[2]; }
2228 ElementsKind elements_kind() const {
2229 return hydrogen()->elements_kind();
2232 DECLARE_CONCRETE_INSTRUCTION(StoreKeyed, "store-keyed")
2233 DECLARE_HYDROGEN_ACCESSOR(StoreKeyed)
2235 void PrintDataTo(StringStream* stream) override;
2236 bool NeedsCanonicalization() {
2237 if (hydrogen()->value()->IsAdd() || hydrogen()->value()->IsSub() ||
2238 hydrogen()->value()->IsMul() || hydrogen()->value()->IsDiv()) {
2241 return hydrogen()->NeedsCanonicalization();
2243 uint32_t base_offset() const { return hydrogen()->base_offset(); }
2247 class LStoreKeyedGeneric final : public LTemplateInstruction<0, 4, 2> {
2249 LStoreKeyedGeneric(LOperand* context, LOperand* object, LOperand* key,
2250 LOperand* value, LOperand* slot, LOperand* vector) {
2251 inputs_[0] = context;
2252 inputs_[1] = object;
2259 LOperand* context() { return inputs_[0]; }
2260 LOperand* object() { return inputs_[1]; }
2261 LOperand* key() { return inputs_[2]; }
2262 LOperand* value() { return inputs_[3]; }
2263 LOperand* temp_slot() { return temps_[0]; }
2264 LOperand* temp_vector() { return temps_[1]; }
2266 DECLARE_CONCRETE_INSTRUCTION(StoreKeyedGeneric, "store-keyed-generic")
2267 DECLARE_HYDROGEN_ACCESSOR(StoreKeyedGeneric)
2269 void PrintDataTo(StringStream* stream) override;
2271 LanguageMode language_mode() { return hydrogen()->language_mode(); }
2275 class LTransitionElementsKind final : public LTemplateInstruction<0, 2, 1> {
2277 LTransitionElementsKind(LOperand* object,
2279 LOperand* new_map_temp) {
2280 inputs_[0] = object;
2281 inputs_[1] = context;
2282 temps_[0] = new_map_temp;
2285 LOperand* context() { return inputs_[1]; }
2286 LOperand* object() { return inputs_[0]; }
2287 LOperand* new_map_temp() { return temps_[0]; }
2289 DECLARE_CONCRETE_INSTRUCTION(TransitionElementsKind,
2290 "transition-elements-kind")
2291 DECLARE_HYDROGEN_ACCESSOR(TransitionElementsKind)
2293 void PrintDataTo(StringStream* stream) override;
2295 Handle<Map> original_map() { return hydrogen()->original_map().handle(); }
2296 Handle<Map> transitioned_map() {
2297 return hydrogen()->transitioned_map().handle();
2299 ElementsKind from_kind() { return hydrogen()->from_kind(); }
2300 ElementsKind to_kind() { return hydrogen()->to_kind(); }
2304 class LTrapAllocationMemento final : public LTemplateInstruction<0, 1, 1> {
2306 LTrapAllocationMemento(LOperand* object,
2308 inputs_[0] = object;
2312 LOperand* object() { return inputs_[0]; }
2313 LOperand* temp() { return temps_[0]; }
2315 DECLARE_CONCRETE_INSTRUCTION(TrapAllocationMemento,
2316 "trap-allocation-memento")
2320 class LMaybeGrowElements final : public LTemplateInstruction<1, 5, 0> {
2322 LMaybeGrowElements(LOperand* context, LOperand* object, LOperand* elements,
2323 LOperand* key, LOperand* current_capacity) {
2324 inputs_[0] = context;
2325 inputs_[1] = object;
2326 inputs_[2] = elements;
2328 inputs_[4] = current_capacity;
2331 LOperand* context() { return inputs_[0]; }
2332 LOperand* object() { return inputs_[1]; }
2333 LOperand* elements() { return inputs_[2]; }
2334 LOperand* key() { return inputs_[3]; }
2335 LOperand* current_capacity() { return inputs_[4]; }
2337 DECLARE_HYDROGEN_ACCESSOR(MaybeGrowElements)
2338 DECLARE_CONCRETE_INSTRUCTION(MaybeGrowElements, "maybe-grow-elements")
2342 class LStringAdd final : public LTemplateInstruction<1, 3, 0> {
2344 LStringAdd(LOperand* context, LOperand* left, LOperand* right) {
2345 inputs_[0] = context;
2350 LOperand* context() { return inputs_[0]; }
2351 LOperand* left() { return inputs_[1]; }
2352 LOperand* right() { return inputs_[2]; }
2354 DECLARE_CONCRETE_INSTRUCTION(StringAdd, "string-add")
2355 DECLARE_HYDROGEN_ACCESSOR(StringAdd)
2359 class LStringCharCodeAt final : public LTemplateInstruction<1, 3, 0> {
2361 LStringCharCodeAt(LOperand* context, LOperand* string, LOperand* index) {
2362 inputs_[0] = context;
2363 inputs_[1] = string;
2367 LOperand* context() { return inputs_[0]; }
2368 LOperand* string() { return inputs_[1]; }
2369 LOperand* index() { return inputs_[2]; }
2371 DECLARE_CONCRETE_INSTRUCTION(StringCharCodeAt, "string-char-code-at")
2372 DECLARE_HYDROGEN_ACCESSOR(StringCharCodeAt)
2376 class LStringCharFromCode final : public LTemplateInstruction<1, 2, 0> {
2378 explicit LStringCharFromCode(LOperand* context, LOperand* char_code) {
2379 inputs_[0] = context;
2380 inputs_[1] = char_code;
2383 LOperand* context() { return inputs_[0]; }
2384 LOperand* char_code() { return inputs_[1]; }
2386 DECLARE_CONCRETE_INSTRUCTION(StringCharFromCode, "string-char-from-code")
2387 DECLARE_HYDROGEN_ACCESSOR(StringCharFromCode)
2391 class LCheckValue final : public LTemplateInstruction<0, 1, 0> {
2393 explicit LCheckValue(LOperand* value) {
2397 LOperand* value() { return inputs_[0]; }
2399 DECLARE_CONCRETE_INSTRUCTION(CheckValue, "check-value")
2400 DECLARE_HYDROGEN_ACCESSOR(CheckValue)
2404 class LCheckArrayBufferNotNeutered final
2405 : public LTemplateInstruction<0, 1, 0> {
2407 explicit LCheckArrayBufferNotNeutered(LOperand* view) { inputs_[0] = view; }
2409 LOperand* view() { return inputs_[0]; }
2411 DECLARE_CONCRETE_INSTRUCTION(CheckArrayBufferNotNeutered,
2412 "check-array-buffer-not-neutered")
2413 DECLARE_HYDROGEN_ACCESSOR(CheckArrayBufferNotNeutered)
2417 class LCheckInstanceType final : public LTemplateInstruction<0, 1, 0> {
2419 explicit LCheckInstanceType(LOperand* value) {
2423 LOperand* value() { return inputs_[0]; }
2425 DECLARE_CONCRETE_INSTRUCTION(CheckInstanceType, "check-instance-type")
2426 DECLARE_HYDROGEN_ACCESSOR(CheckInstanceType)
2430 class LCheckMaps final : public LTemplateInstruction<0, 1, 0> {
2432 explicit LCheckMaps(LOperand* value = NULL) {
2436 LOperand* value() { return inputs_[0]; }
2438 DECLARE_CONCRETE_INSTRUCTION(CheckMaps, "check-maps")
2439 DECLARE_HYDROGEN_ACCESSOR(CheckMaps)
2443 class LCheckSmi final : public LTemplateInstruction<1, 1, 0> {
2445 explicit LCheckSmi(LOperand* value) {
2449 LOperand* value() { return inputs_[0]; }
2451 DECLARE_CONCRETE_INSTRUCTION(CheckSmi, "check-smi")
2455 class LCheckNonSmi final : public LTemplateInstruction<0, 1, 0> {
2457 explicit LCheckNonSmi(LOperand* value) {
2461 LOperand* value() { return inputs_[0]; }
2463 DECLARE_CONCRETE_INSTRUCTION(CheckNonSmi, "check-non-smi")
2464 DECLARE_HYDROGEN_ACCESSOR(CheckHeapObject)
2468 class LClampDToUint8 final : public LTemplateInstruction<1, 1, 0> {
2470 explicit LClampDToUint8(LOperand* unclamped) {
2471 inputs_[0] = unclamped;
2474 LOperand* unclamped() { return inputs_[0]; }
2476 DECLARE_CONCRETE_INSTRUCTION(ClampDToUint8, "clamp-d-to-uint8")
2480 class LClampIToUint8 final : public LTemplateInstruction<1, 1, 0> {
2482 explicit LClampIToUint8(LOperand* unclamped) {
2483 inputs_[0] = unclamped;
2486 LOperand* unclamped() { return inputs_[0]; }
2488 DECLARE_CONCRETE_INSTRUCTION(ClampIToUint8, "clamp-i-to-uint8")
2492 class LClampTToUint8 final : public LTemplateInstruction<1, 1, 1> {
2494 LClampTToUint8(LOperand* unclamped, LOperand* temp) {
2495 inputs_[0] = unclamped;
2499 LOperand* unclamped() { return inputs_[0]; }
2500 LOperand* temp() { return temps_[0]; }
2502 DECLARE_CONCRETE_INSTRUCTION(ClampTToUint8, "clamp-t-to-uint8")
2506 class LDoubleBits final : public LTemplateInstruction<1, 1, 0> {
2508 explicit LDoubleBits(LOperand* value) {
2512 LOperand* value() { return inputs_[0]; }
2514 DECLARE_CONCRETE_INSTRUCTION(DoubleBits, "double-bits")
2515 DECLARE_HYDROGEN_ACCESSOR(DoubleBits)
2519 class LConstructDouble final : public LTemplateInstruction<1, 2, 0> {
2521 LConstructDouble(LOperand* hi, LOperand* lo) {
2526 LOperand* hi() { return inputs_[0]; }
2527 LOperand* lo() { return inputs_[1]; }
2529 DECLARE_CONCRETE_INSTRUCTION(ConstructDouble, "construct-double")
2533 class LAllocate final : public LTemplateInstruction<1, 2, 2> {
2535 LAllocate(LOperand* context,
2539 inputs_[0] = context;
2545 LOperand* context() { return inputs_[0]; }
2546 LOperand* size() { return inputs_[1]; }
2547 LOperand* temp1() { return temps_[0]; }
2548 LOperand* temp2() { return temps_[1]; }
2550 DECLARE_CONCRETE_INSTRUCTION(Allocate, "allocate")
2551 DECLARE_HYDROGEN_ACCESSOR(Allocate)
2555 class LRegExpLiteral final : public LTemplateInstruction<1, 1, 0> {
2557 explicit LRegExpLiteral(LOperand* context) {
2558 inputs_[0] = context;
2561 LOperand* context() { return inputs_[0]; }
2563 DECLARE_CONCRETE_INSTRUCTION(RegExpLiteral, "regexp-literal")
2564 DECLARE_HYDROGEN_ACCESSOR(RegExpLiteral)
2568 class LToFastProperties final : public LTemplateInstruction<1, 1, 0> {
2570 explicit LToFastProperties(LOperand* value) {
2574 LOperand* value() { return inputs_[0]; }
2576 DECLARE_CONCRETE_INSTRUCTION(ToFastProperties, "to-fast-properties")
2577 DECLARE_HYDROGEN_ACCESSOR(ToFastProperties)
2581 class LTypeof final : public LTemplateInstruction<1, 2, 0> {
2583 LTypeof(LOperand* context, LOperand* value) {
2584 inputs_[0] = context;
2588 LOperand* context() { return inputs_[0]; }
2589 LOperand* value() { return inputs_[1]; }
2591 DECLARE_CONCRETE_INSTRUCTION(Typeof, "typeof")
2595 class LTypeofIsAndBranch final : public LControlInstruction<1, 0> {
2597 explicit LTypeofIsAndBranch(LOperand* value) {
2601 LOperand* value() { return inputs_[0]; }
2603 DECLARE_CONCRETE_INSTRUCTION(TypeofIsAndBranch, "typeof-is-and-branch")
2604 DECLARE_HYDROGEN_ACCESSOR(TypeofIsAndBranch)
2606 Handle<String> type_literal() { return hydrogen()->type_literal(); }
2608 void PrintDataTo(StringStream* stream) override;
2612 class LIsConstructCallAndBranch final : public LControlInstruction<0, 1> {
2614 explicit LIsConstructCallAndBranch(LOperand* temp) {
2618 LOperand* temp() { return temps_[0]; }
2620 DECLARE_CONCRETE_INSTRUCTION(IsConstructCallAndBranch,
2621 "is-construct-call-and-branch")
2625 class LOsrEntry final : public LTemplateInstruction<0, 0, 0> {
2629 bool HasInterestingComment(LCodeGen* gen) const override { return false; }
2630 DECLARE_CONCRETE_INSTRUCTION(OsrEntry, "osr-entry")
2634 class LStackCheck final : public LTemplateInstruction<0, 1, 0> {
2636 explicit LStackCheck(LOperand* context) {
2637 inputs_[0] = context;
2640 LOperand* context() { return inputs_[0]; }
2642 DECLARE_CONCRETE_INSTRUCTION(StackCheck, "stack-check")
2643 DECLARE_HYDROGEN_ACCESSOR(StackCheck)
2645 Label* done_label() { return &done_label_; }
2652 class LForInPrepareMap final : public LTemplateInstruction<1, 2, 0> {
2654 LForInPrepareMap(LOperand* context, LOperand* object) {
2655 inputs_[0] = context;
2656 inputs_[1] = object;
2659 LOperand* context() { return inputs_[0]; }
2660 LOperand* object() { return inputs_[1]; }
2662 DECLARE_CONCRETE_INSTRUCTION(ForInPrepareMap, "for-in-prepare-map")
2666 class LForInCacheArray final : public LTemplateInstruction<1, 1, 0> {
2668 explicit LForInCacheArray(LOperand* map) {
2672 LOperand* map() { return inputs_[0]; }
2674 DECLARE_CONCRETE_INSTRUCTION(ForInCacheArray, "for-in-cache-array")
2677 return HForInCacheArray::cast(this->hydrogen_value())->idx();
2682 class LCheckMapValue final : public LTemplateInstruction<0, 2, 0> {
2684 LCheckMapValue(LOperand* value, LOperand* map) {
2689 LOperand* value() { return inputs_[0]; }
2690 LOperand* map() { return inputs_[1]; }
2692 DECLARE_CONCRETE_INSTRUCTION(CheckMapValue, "check-map-value")
2696 class LLoadFieldByIndex final : public LTemplateInstruction<1, 2, 0> {
2698 LLoadFieldByIndex(LOperand* object, LOperand* index) {
2699 inputs_[0] = object;
2703 LOperand* object() { return inputs_[0]; }
2704 LOperand* index() { return inputs_[1]; }
2706 DECLARE_CONCRETE_INSTRUCTION(LoadFieldByIndex, "load-field-by-index")
2710 class LStoreFrameContext: public LTemplateInstruction<0, 1, 0> {
2712 explicit LStoreFrameContext(LOperand* context) {
2713 inputs_[0] = context;
2716 LOperand* context() { return inputs_[0]; }
2718 DECLARE_CONCRETE_INSTRUCTION(StoreFrameContext, "store-frame-context")
2722 class LAllocateBlockContext: public LTemplateInstruction<1, 2, 0> {
2724 LAllocateBlockContext(LOperand* context, LOperand* function) {
2725 inputs_[0] = context;
2726 inputs_[1] = function;
2729 LOperand* context() { return inputs_[0]; }
2730 LOperand* function() { return inputs_[1]; }
2732 Handle<ScopeInfo> scope_info() { return hydrogen()->scope_info(); }
2734 DECLARE_CONCRETE_INSTRUCTION(AllocateBlockContext, "allocate-block-context")
2735 DECLARE_HYDROGEN_ACCESSOR(AllocateBlockContext)
2739 class LChunkBuilder;
2740 class LPlatformChunk final : public LChunk {
2742 LPlatformChunk(CompilationInfo* info, HGraph* graph)
2743 : LChunk(info, graph) { }
2745 int GetNextSpillIndex(RegisterKind kind);
2746 LOperand* GetNextSpillSlot(RegisterKind kind);
2750 class LChunkBuilder final : public LChunkBuilderBase {
2752 LChunkBuilder(CompilationInfo* info, HGraph* graph, LAllocator* allocator)
2753 : LChunkBuilderBase(info, graph),
2754 current_instruction_(NULL),
2755 current_block_(NULL),
2757 allocator_(allocator) {}
2759 // Build the sequence for the graph.
2760 LPlatformChunk* Build();
2762 // Declare methods that deal with the individual node types.
2763 #define DECLARE_DO(type) LInstruction* Do##type(H##type* node);
2764 HYDROGEN_CONCRETE_INSTRUCTION_LIST(DECLARE_DO)
2767 LInstruction* DoMultiplyAdd(HMul* mul, HValue* addend);
2768 LInstruction* DoMultiplySub(HValue* minuend, HMul* mul);
2769 LInstruction* DoRSub(HSub* instr);
2771 static bool HasMagicNumberForDivisor(int32_t divisor);
2773 LInstruction* DoMathFloor(HUnaryMathOperation* instr);
2774 LInstruction* DoMathRound(HUnaryMathOperation* instr);
2775 LInstruction* DoMathFround(HUnaryMathOperation* instr);
2776 LInstruction* DoMathAbs(HUnaryMathOperation* instr);
2777 LInstruction* DoMathLog(HUnaryMathOperation* instr);
2778 LInstruction* DoMathExp(HUnaryMathOperation* instr);
2779 LInstruction* DoMathSqrt(HUnaryMathOperation* instr);
2780 LInstruction* DoMathPowHalf(HUnaryMathOperation* instr);
2781 LInstruction* DoMathClz32(HUnaryMathOperation* instr);
2782 LInstruction* DoDivByPowerOf2I(HDiv* instr);
2783 LInstruction* DoDivByConstI(HDiv* instr);
2784 LInstruction* DoDivI(HDiv* instr);
2785 LInstruction* DoModByPowerOf2I(HMod* instr);
2786 LInstruction* DoModByConstI(HMod* instr);
2787 LInstruction* DoModI(HMod* instr);
2788 LInstruction* DoFlooringDivByPowerOf2I(HMathFloorOfDiv* instr);
2789 LInstruction* DoFlooringDivByConstI(HMathFloorOfDiv* instr);
2790 LInstruction* DoFlooringDivI(HMathFloorOfDiv* instr);
2793 // Methods for getting operands for Use / Define / Temp.
2794 LUnallocated* ToUnallocated(Register reg);
2795 LUnallocated* ToUnallocated(DoubleRegister reg);
2797 // Methods for setting up define-use relationships.
2798 MUST_USE_RESULT LOperand* Use(HValue* value, LUnallocated* operand);
2799 MUST_USE_RESULT LOperand* UseFixed(HValue* value, Register fixed_register);
2800 MUST_USE_RESULT LOperand* UseFixedDouble(HValue* value,
2801 DoubleRegister fixed_register);
2803 // A value that is guaranteed to be allocated to a register.
2804 // Operand created by UseRegister is guaranteed to be live until the end of
2805 // instruction. This means that register allocator will not reuse it's
2806 // register for any other operand inside instruction.
2807 // Operand created by UseRegisterAtStart is guaranteed to be live only at
2808 // instruction start. Register allocator is free to assign the same register
2809 // to some other operand used inside instruction (i.e. temporary or
2811 MUST_USE_RESULT LOperand* UseRegister(HValue* value);
2812 MUST_USE_RESULT LOperand* UseRegisterAtStart(HValue* value);
2814 // An input operand in a register that may be trashed.
2815 MUST_USE_RESULT LOperand* UseTempRegister(HValue* value);
2817 // An input operand in a register or stack slot.
2818 MUST_USE_RESULT LOperand* Use(HValue* value);
2819 MUST_USE_RESULT LOperand* UseAtStart(HValue* value);
2821 // An input operand in a register, stack slot or a constant operand.
2822 MUST_USE_RESULT LOperand* UseOrConstant(HValue* value);
2823 MUST_USE_RESULT LOperand* UseOrConstantAtStart(HValue* value);
2825 // An input operand in a register or a constant operand.
2826 MUST_USE_RESULT LOperand* UseRegisterOrConstant(HValue* value);
2827 MUST_USE_RESULT LOperand* UseRegisterOrConstantAtStart(HValue* value);
2829 // An input operand in a constant operand.
2830 MUST_USE_RESULT LOperand* UseConstant(HValue* value);
2832 // An input operand in register, stack slot or a constant operand.
2833 // Will not be moved to a register even if one is freely available.
2834 MUST_USE_RESULT LOperand* UseAny(HValue* value) override;
2836 // Temporary operand that must be in a register.
2837 MUST_USE_RESULT LUnallocated* TempRegister();
2838 MUST_USE_RESULT LUnallocated* TempDoubleRegister();
2839 MUST_USE_RESULT LOperand* FixedTemp(Register reg);
2840 MUST_USE_RESULT LOperand* FixedTemp(DoubleRegister reg);
2842 // Methods for setting up define-use relationships.
2843 // Return the same instruction that they are passed.
2844 LInstruction* Define(LTemplateResultInstruction<1>* instr,
2845 LUnallocated* result);
2846 LInstruction* DefineAsRegister(LTemplateResultInstruction<1>* instr);
2847 LInstruction* DefineAsSpilled(LTemplateResultInstruction<1>* instr,
2849 LInstruction* DefineSameAsFirst(LTemplateResultInstruction<1>* instr);
2850 LInstruction* DefineFixed(LTemplateResultInstruction<1>* instr,
2852 LInstruction* DefineFixedDouble(LTemplateResultInstruction<1>* instr,
2853 DoubleRegister reg);
2854 LInstruction* AssignEnvironment(LInstruction* instr);
2855 LInstruction* AssignPointerMap(LInstruction* instr);
2857 enum CanDeoptimize { CAN_DEOPTIMIZE_EAGERLY, CANNOT_DEOPTIMIZE_EAGERLY };
2859 // By default we assume that instruction sequences generated for calls
2860 // cannot deoptimize eagerly and we do not attach environment to this
2862 LInstruction* MarkAsCall(
2863 LInstruction* instr,
2864 HInstruction* hinstr,
2865 CanDeoptimize can_deoptimize = CANNOT_DEOPTIMIZE_EAGERLY);
2867 void VisitInstruction(HInstruction* current);
2868 void AddInstruction(LInstruction* instr, HInstruction* current);
2870 void DoBasicBlock(HBasicBlock* block, HBasicBlock* next_block);
2871 LInstruction* DoShift(Token::Value op, HBitwiseBinaryOperation* instr);
2872 LInstruction* DoArithmeticD(Token::Value op,
2873 HArithmeticBinaryOperation* instr);
2874 LInstruction* DoArithmeticT(Token::Value op,
2875 HBinaryOperation* instr);
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 internal
2891 #endif // V8_ARM_LITHIUM_ARM_H_