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) \
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) \
105 V(LoadGlobalViaContext) \
107 V(LoadKeyedGeneric) \
109 V(LoadNamedGeneric) \
121 V(MaybeGrowElements) \
138 V(SeqStringGetChar) \
139 V(SeqStringSetChar) \
145 V(StoreContextSlot) \
146 V(StoreFrameContext) \
147 V(StoreGlobalViaContext) \
149 V(StoreKeyedGeneric) \
151 V(StoreNamedGeneric) \
153 V(StringCharCodeAt) \
154 V(StringCharFromCode) \
155 V(StringCompareAndBranch) \
160 V(ToFastProperties) \
161 V(TransitionElementsKind) \
162 V(TrapAllocationMemento) \
164 V(TypeofIsAndBranch) \
170 #define DECLARE_CONCRETE_INSTRUCTION(type, mnemonic) \
171 Opcode opcode() const final { return LInstruction::k##type; } \
172 void CompileToNative(LCodeGen* generator) final; \
173 const char* Mnemonic() const final { return mnemonic; } \
174 static L##type* cast(LInstruction* instr) { \
175 DCHECK(instr->Is##type()); \
176 return reinterpret_cast<L##type*>(instr); \
180 #define DECLARE_HYDROGEN_ACCESSOR(type) \
181 H##type* hydrogen() const { \
182 return H##type::cast(hydrogen_value()); \
186 class LInstruction : public ZoneObject {
189 : environment_(NULL),
190 hydrogen_value_(NULL),
191 bit_field_(IsCallBits::encode(false)) {
194 virtual ~LInstruction() {}
196 virtual void CompileToNative(LCodeGen* generator) = 0;
197 virtual const char* Mnemonic() const = 0;
198 virtual void PrintTo(StringStream* stream);
199 virtual void PrintDataTo(StringStream* stream);
200 virtual void PrintOutputOperandTo(StringStream* stream);
203 // Declare a unique enum value for each instruction.
204 #define DECLARE_OPCODE(type) k##type,
205 LITHIUM_CONCRETE_INSTRUCTION_LIST(DECLARE_OPCODE)
206 kNumberOfInstructions
207 #undef DECLARE_OPCODE
210 virtual Opcode opcode() const = 0;
212 // Declare non-virtual type testers for all leaf IR classes.
213 #define DECLARE_PREDICATE(type) \
214 bool Is##type() const { return opcode() == k##type; }
215 LITHIUM_CONCRETE_INSTRUCTION_LIST(DECLARE_PREDICATE)
216 #undef DECLARE_PREDICATE
218 // Declare virtual predicates for instructions that don't have
220 virtual bool IsGap() const { return false; }
222 virtual bool IsControl() const { return false; }
224 // Try deleting this instruction if possible.
225 virtual bool TryDelete() { return false; }
227 void set_environment(LEnvironment* env) { environment_ = env; }
228 LEnvironment* environment() const { return environment_; }
229 bool HasEnvironment() const { return environment_ != NULL; }
231 void set_pointer_map(LPointerMap* p) { pointer_map_.set(p); }
232 LPointerMap* pointer_map() const { return pointer_map_.get(); }
233 bool HasPointerMap() const { return pointer_map_.is_set(); }
235 void set_hydrogen_value(HValue* value) { hydrogen_value_ = value; }
236 HValue* hydrogen_value() const { return hydrogen_value_; }
238 virtual void SetDeferredLazyDeoptimizationEnvironment(LEnvironment* env) { }
240 void MarkAsCall() { bit_field_ = IsCallBits::update(bit_field_, true); }
241 bool IsCall() const { return IsCallBits::decode(bit_field_); }
243 // Interface to the register allocator and iterators.
244 bool ClobbersTemps() const { return IsCall(); }
245 bool ClobbersRegisters() const { return IsCall(); }
246 virtual bool ClobbersDoubleRegisters(Isolate* isolate) const {
250 // Interface to the register allocator and iterators.
251 bool IsMarkedAsCall() const { return IsCall(); }
253 virtual bool HasResult() const = 0;
254 virtual LOperand* result() const = 0;
256 LOperand* FirstInput() { return InputAt(0); }
257 LOperand* Output() { return HasResult() ? result() : NULL; }
259 virtual bool HasInterestingComment(LCodeGen* gen) const { return true; }
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]; }
296 EmbeddedContainer<LOperand*, R> results_;
300 // R = number of result operands (0 or 1).
301 // I = number of input operands.
302 // T = number of temporary operands.
303 template<int R, int I, int T>
304 class LTemplateInstruction : public LTemplateResultInstruction<R> {
306 EmbeddedContainer<LOperand*, I> inputs_;
307 EmbeddedContainer<LOperand*, T> temps_;
311 int InputCount() final { return I; }
312 LOperand* InputAt(int i) final { return inputs_[i]; }
314 int TempCount() final { return T; }
315 LOperand* TempAt(int i) final { return temps_[i]; }
319 class LGap : public LTemplateInstruction<0, 0, 0> {
321 explicit LGap(HBasicBlock* block)
323 parallel_moves_[BEFORE] = NULL;
324 parallel_moves_[START] = NULL;
325 parallel_moves_[END] = NULL;
326 parallel_moves_[AFTER] = NULL;
329 // Can't use the DECLARE-macro here because of sub-classes.
330 bool IsGap() const override { return true; }
331 void PrintDataTo(StringStream* stream) override;
332 static LGap* cast(LInstruction* instr) {
333 DCHECK(instr->IsGap());
334 return reinterpret_cast<LGap*>(instr);
337 bool IsRedundant() const;
339 HBasicBlock* block() const { return block_; }
346 FIRST_INNER_POSITION = BEFORE,
347 LAST_INNER_POSITION = AFTER
350 LParallelMove* GetOrCreateParallelMove(InnerPosition pos, Zone* zone) {
351 if (parallel_moves_[pos] == NULL) {
352 parallel_moves_[pos] = new(zone) LParallelMove(zone);
354 return parallel_moves_[pos];
357 LParallelMove* GetParallelMove(InnerPosition pos) {
358 return parallel_moves_[pos];
362 LParallelMove* parallel_moves_[LAST_INNER_POSITION + 1];
367 class LInstructionGap final : public LGap {
369 explicit LInstructionGap(HBasicBlock* block) : LGap(block) { }
371 bool HasInterestingComment(LCodeGen* gen) const override {
372 return !IsRedundant();
375 DECLARE_CONCRETE_INSTRUCTION(InstructionGap, "gap")
379 class LGoto final : public LTemplateInstruction<0, 0, 0> {
381 explicit LGoto(HBasicBlock* block) : block_(block) { }
383 bool HasInterestingComment(LCodeGen* gen) const override;
384 DECLARE_CONCRETE_INSTRUCTION(Goto, "goto")
385 void PrintDataTo(StringStream* stream) override;
386 bool IsControl() const override { return true; }
388 int block_id() const { return block_->block_id(); }
395 class LLazyBailout final : public LTemplateInstruction<0, 0, 0> {
397 LLazyBailout() : gap_instructions_size_(0) { }
399 DECLARE_CONCRETE_INSTRUCTION(LazyBailout, "lazy-bailout")
401 void set_gap_instructions_size(int gap_instructions_size) {
402 gap_instructions_size_ = gap_instructions_size;
404 int gap_instructions_size() { return gap_instructions_size_; }
407 int gap_instructions_size_;
411 class LDummy final : public LTemplateInstruction<1, 0, 0> {
414 DECLARE_CONCRETE_INSTRUCTION(Dummy, "dummy")
418 class LDummyUse final : public LTemplateInstruction<1, 1, 0> {
420 explicit LDummyUse(LOperand* value) {
423 DECLARE_CONCRETE_INSTRUCTION(DummyUse, "dummy-use")
427 class LDeoptimize final : public LTemplateInstruction<0, 0, 0> {
429 bool IsControl() const override { return true; }
430 DECLARE_CONCRETE_INSTRUCTION(Deoptimize, "deoptimize")
431 DECLARE_HYDROGEN_ACCESSOR(Deoptimize)
435 class LLabel final : public LGap {
437 explicit LLabel(HBasicBlock* block)
438 : LGap(block), replacement_(NULL) { }
440 bool HasInterestingComment(LCodeGen* gen) const override { return false; }
441 DECLARE_CONCRETE_INSTRUCTION(Label, "label")
443 void PrintDataTo(StringStream* stream) override;
445 int block_id() const { return block()->block_id(); }
446 bool is_loop_header() const { return block()->IsLoopHeader(); }
447 bool is_osr_entry() const { return block()->is_osr_entry(); }
448 Label* label() { return &label_; }
449 LLabel* replacement() const { return replacement_; }
450 void set_replacement(LLabel* label) { replacement_ = label; }
451 bool HasReplacement() const { return replacement_ != NULL; }
455 LLabel* replacement_;
459 class LParameter final : public LTemplateInstruction<1, 0, 0> {
461 bool HasInterestingComment(LCodeGen* gen) const override { return false; }
462 DECLARE_CONCRETE_INSTRUCTION(Parameter, "parameter")
466 class LCallStub final : public LTemplateInstruction<1, 1, 0> {
468 explicit LCallStub(LOperand* context) {
469 inputs_[0] = context;
472 LOperand* context() { return inputs_[0]; }
474 DECLARE_CONCRETE_INSTRUCTION(CallStub, "call-stub")
475 DECLARE_HYDROGEN_ACCESSOR(CallStub)
479 class LUnknownOSRValue final : public LTemplateInstruction<1, 0, 0> {
481 bool HasInterestingComment(LCodeGen* gen) const override { return false; }
482 DECLARE_CONCRETE_INSTRUCTION(UnknownOSRValue, "unknown-osr-value")
486 template<int I, int T>
487 class LControlInstruction : public LTemplateInstruction<0, I, T> {
489 LControlInstruction() : false_label_(NULL), true_label_(NULL) { }
491 bool IsControl() const final { return true; }
493 int SuccessorCount() { return hydrogen()->SuccessorCount(); }
494 HBasicBlock* SuccessorAt(int i) { return hydrogen()->SuccessorAt(i); }
496 int TrueDestination(LChunk* chunk) {
497 return chunk->LookupDestination(true_block_id());
499 int FalseDestination(LChunk* chunk) {
500 return chunk->LookupDestination(false_block_id());
503 Label* TrueLabel(LChunk* chunk) {
504 if (true_label_ == NULL) {
505 true_label_ = chunk->GetAssemblyLabel(TrueDestination(chunk));
509 Label* FalseLabel(LChunk* chunk) {
510 if (false_label_ == NULL) {
511 false_label_ = chunk->GetAssemblyLabel(FalseDestination(chunk));
517 int true_block_id() { return SuccessorAt(0)->block_id(); }
518 int false_block_id() { return SuccessorAt(1)->block_id(); }
521 HControlInstruction* hydrogen() {
522 return HControlInstruction::cast(this->hydrogen_value());
530 class LWrapReceiver final : public LTemplateInstruction<1, 2, 0> {
532 LWrapReceiver(LOperand* receiver, LOperand* function) {
533 inputs_[0] = receiver;
534 inputs_[1] = function;
537 DECLARE_CONCRETE_INSTRUCTION(WrapReceiver, "wrap-receiver")
538 DECLARE_HYDROGEN_ACCESSOR(WrapReceiver)
540 LOperand* receiver() { return inputs_[0]; }
541 LOperand* function() { return inputs_[1]; }
545 class LApplyArguments final : public LTemplateInstruction<1, 4, 0> {
547 LApplyArguments(LOperand* function,
550 LOperand* elements) {
551 inputs_[0] = function;
552 inputs_[1] = receiver;
554 inputs_[3] = elements;
557 DECLARE_CONCRETE_INSTRUCTION(ApplyArguments, "apply-arguments")
559 LOperand* function() { return inputs_[0]; }
560 LOperand* receiver() { return inputs_[1]; }
561 LOperand* length() { return inputs_[2]; }
562 LOperand* elements() { return inputs_[3]; }
566 class LAccessArgumentsAt final : public LTemplateInstruction<1, 3, 0> {
568 LAccessArgumentsAt(LOperand* arguments, LOperand* length, LOperand* index) {
569 inputs_[0] = arguments;
574 DECLARE_CONCRETE_INSTRUCTION(AccessArgumentsAt, "access-arguments-at")
576 LOperand* arguments() { return inputs_[0]; }
577 LOperand* length() { return inputs_[1]; }
578 LOperand* index() { return inputs_[2]; }
580 void PrintDataTo(StringStream* stream) override;
584 class LArgumentsLength final : public LTemplateInstruction<1, 1, 0> {
586 explicit LArgumentsLength(LOperand* elements) {
587 inputs_[0] = elements;
590 LOperand* elements() { return inputs_[0]; }
592 DECLARE_CONCRETE_INSTRUCTION(ArgumentsLength, "arguments-length")
596 class LArgumentsElements final : public LTemplateInstruction<1, 0, 0> {
598 DECLARE_CONCRETE_INSTRUCTION(ArgumentsElements, "arguments-elements")
599 DECLARE_HYDROGEN_ACCESSOR(ArgumentsElements)
603 class LModByPowerOf2I final : public LTemplateInstruction<1, 1, 0> {
605 LModByPowerOf2I(LOperand* dividend, int32_t divisor) {
606 inputs_[0] = dividend;
610 LOperand* dividend() { return inputs_[0]; }
611 int32_t divisor() const { return divisor_; }
613 DECLARE_CONCRETE_INSTRUCTION(ModByPowerOf2I, "mod-by-power-of-2-i")
614 DECLARE_HYDROGEN_ACCESSOR(Mod)
621 class LModByConstI final : public LTemplateInstruction<1, 1, 0> {
623 LModByConstI(LOperand* dividend, int32_t divisor) {
624 inputs_[0] = dividend;
628 LOperand* dividend() { return inputs_[0]; }
629 int32_t divisor() const { return divisor_; }
631 DECLARE_CONCRETE_INSTRUCTION(ModByConstI, "mod-by-const-i")
632 DECLARE_HYDROGEN_ACCESSOR(Mod)
639 class LModI final : public LTemplateInstruction<1, 2, 2> {
641 LModI(LOperand* left, LOperand* right, LOperand* temp, LOperand* temp2) {
648 LOperand* left() { return inputs_[0]; }
649 LOperand* right() { return inputs_[1]; }
650 LOperand* temp() { return temps_[0]; }
651 LOperand* temp2() { return temps_[1]; }
653 DECLARE_CONCRETE_INSTRUCTION(ModI, "mod-i")
654 DECLARE_HYDROGEN_ACCESSOR(Mod)
658 class LDivByPowerOf2I final : public LTemplateInstruction<1, 1, 0> {
660 LDivByPowerOf2I(LOperand* dividend, int32_t divisor) {
661 inputs_[0] = dividend;
665 LOperand* dividend() { return inputs_[0]; }
666 int32_t divisor() const { return divisor_; }
668 DECLARE_CONCRETE_INSTRUCTION(DivByPowerOf2I, "div-by-power-of-2-i")
669 DECLARE_HYDROGEN_ACCESSOR(Div)
676 class LDivByConstI final : public LTemplateInstruction<1, 1, 0> {
678 LDivByConstI(LOperand* dividend, int32_t divisor) {
679 inputs_[0] = dividend;
683 LOperand* dividend() { return inputs_[0]; }
684 int32_t divisor() const { return divisor_; }
686 DECLARE_CONCRETE_INSTRUCTION(DivByConstI, "div-by-const-i")
687 DECLARE_HYDROGEN_ACCESSOR(Div)
694 class LDivI final : public LTemplateInstruction<1, 2, 1> {
696 LDivI(LOperand* dividend, LOperand* divisor, LOperand* temp) {
697 inputs_[0] = dividend;
698 inputs_[1] = divisor;
702 LOperand* dividend() { return inputs_[0]; }
703 LOperand* divisor() { return inputs_[1]; }
704 LOperand* temp() { return temps_[0]; }
706 DECLARE_CONCRETE_INSTRUCTION(DivI, "div-i")
707 DECLARE_HYDROGEN_ACCESSOR(BinaryOperation)
711 class LFlooringDivByPowerOf2I final : public LTemplateInstruction<1, 1, 0> {
713 LFlooringDivByPowerOf2I(LOperand* dividend, int32_t divisor) {
714 inputs_[0] = dividend;
718 LOperand* dividend() { return inputs_[0]; }
719 int32_t divisor() { return divisor_; }
721 DECLARE_CONCRETE_INSTRUCTION(FlooringDivByPowerOf2I,
722 "flooring-div-by-power-of-2-i")
723 DECLARE_HYDROGEN_ACCESSOR(MathFloorOfDiv)
730 class LFlooringDivByConstI final : public LTemplateInstruction<1, 1, 2> {
732 LFlooringDivByConstI(LOperand* dividend, int32_t divisor, LOperand* temp) {
733 inputs_[0] = dividend;
738 LOperand* dividend() { return inputs_[0]; }
739 int32_t divisor() const { return divisor_; }
740 LOperand* temp() { return temps_[0]; }
742 DECLARE_CONCRETE_INSTRUCTION(FlooringDivByConstI, "flooring-div-by-const-i")
743 DECLARE_HYDROGEN_ACCESSOR(MathFloorOfDiv)
750 class LFlooringDivI final : public LTemplateInstruction<1, 2, 1> {
752 LFlooringDivI(LOperand* dividend, LOperand* divisor, LOperand* temp) {
753 inputs_[0] = dividend;
754 inputs_[1] = divisor;
758 LOperand* dividend() { return inputs_[0]; }
759 LOperand* divisor() { return inputs_[1]; }
760 LOperand* temp() { return temps_[0]; }
762 DECLARE_CONCRETE_INSTRUCTION(FlooringDivI, "flooring-div-i")
763 DECLARE_HYDROGEN_ACCESSOR(MathFloorOfDiv)
767 class LMulI final : public LTemplateInstruction<1, 2, 0> {
769 LMulI(LOperand* left, LOperand* right) {
774 LOperand* left() { return inputs_[0]; }
775 LOperand* right() { return inputs_[1]; }
777 DECLARE_CONCRETE_INSTRUCTION(MulI, "mul-i")
778 DECLARE_HYDROGEN_ACCESSOR(Mul)
782 // Instruction for computing multiplier * multiplicand + addend.
783 class LMultiplyAddD final : public LTemplateInstruction<1, 3, 0> {
785 LMultiplyAddD(LOperand* addend, LOperand* multiplier,
786 LOperand* multiplicand) {
788 inputs_[1] = multiplier;
789 inputs_[2] = multiplicand;
792 LOperand* addend() { return inputs_[0]; }
793 LOperand* multiplier() { return inputs_[1]; }
794 LOperand* multiplicand() { return inputs_[2]; }
796 DECLARE_CONCRETE_INSTRUCTION(MultiplyAddD, "multiply-add-d")
800 // Instruction for computing minuend - multiplier * multiplicand.
801 class LMultiplySubD final : public LTemplateInstruction<1, 3, 0> {
803 LMultiplySubD(LOperand* minuend, LOperand* multiplier,
804 LOperand* multiplicand) {
805 inputs_[0] = minuend;
806 inputs_[1] = multiplier;
807 inputs_[2] = multiplicand;
810 LOperand* minuend() { return inputs_[0]; }
811 LOperand* multiplier() { return inputs_[1]; }
812 LOperand* multiplicand() { return inputs_[2]; }
814 DECLARE_CONCRETE_INSTRUCTION(MultiplySubD, "multiply-sub-d")
818 class LDebugBreak final : public LTemplateInstruction<0, 0, 0> {
820 DECLARE_CONCRETE_INSTRUCTION(DebugBreak, "break")
824 class LCompareNumericAndBranch final : public LControlInstruction<2, 0> {
826 LCompareNumericAndBranch(LOperand* left, LOperand* right) {
831 LOperand* left() { return inputs_[0]; }
832 LOperand* right() { return inputs_[1]; }
834 DECLARE_CONCRETE_INSTRUCTION(CompareNumericAndBranch,
835 "compare-numeric-and-branch")
836 DECLARE_HYDROGEN_ACCESSOR(CompareNumericAndBranch)
838 Token::Value op() const { return hydrogen()->token(); }
839 bool is_double() const {
840 return hydrogen()->representation().IsDouble();
843 void PrintDataTo(StringStream* stream) override;
847 class LMathFloor final : public LTemplateInstruction<1, 1, 0> {
849 explicit LMathFloor(LOperand* value) {
853 LOperand* value() { return inputs_[0]; }
855 DECLARE_CONCRETE_INSTRUCTION(MathFloor, "math-floor")
856 DECLARE_HYDROGEN_ACCESSOR(UnaryMathOperation)
860 class LMathRound final : public LTemplateInstruction<1, 1, 1> {
862 LMathRound(LOperand* value, LOperand* temp) {
867 LOperand* value() { return inputs_[0]; }
868 LOperand* temp() { return temps_[0]; }
870 DECLARE_CONCRETE_INSTRUCTION(MathRound, "math-round")
871 DECLARE_HYDROGEN_ACCESSOR(UnaryMathOperation)
875 class LMathFround final : public LTemplateInstruction<1, 1, 0> {
877 explicit LMathFround(LOperand* value) { inputs_[0] = value; }
879 LOperand* value() { return inputs_[0]; }
881 DECLARE_CONCRETE_INSTRUCTION(MathFround, "math-fround")
885 class LMathAbs final : public LTemplateInstruction<1, 2, 0> {
887 LMathAbs(LOperand* context, LOperand* value) {
888 inputs_[1] = context;
892 LOperand* context() { return inputs_[1]; }
893 LOperand* value() { return inputs_[0]; }
895 DECLARE_CONCRETE_INSTRUCTION(MathAbs, "math-abs")
896 DECLARE_HYDROGEN_ACCESSOR(UnaryMathOperation)
900 class LMathLog final : public LTemplateInstruction<1, 1, 0> {
902 explicit LMathLog(LOperand* value) {
906 LOperand* value() { return inputs_[0]; }
908 DECLARE_CONCRETE_INSTRUCTION(MathLog, "math-log")
912 class LMathClz32 final : public LTemplateInstruction<1, 1, 0> {
914 explicit LMathClz32(LOperand* value) {
918 LOperand* value() { return inputs_[0]; }
920 DECLARE_CONCRETE_INSTRUCTION(MathClz32, "math-clz32")
924 class LMathExp final : public LTemplateInstruction<1, 1, 3> {
926 LMathExp(LOperand* value,
927 LOperand* double_temp,
933 temps_[2] = double_temp;
934 ExternalReference::InitializeMathExpData();
937 LOperand* value() { return inputs_[0]; }
938 LOperand* temp1() { return temps_[0]; }
939 LOperand* temp2() { return temps_[1]; }
940 LOperand* double_temp() { return temps_[2]; }
942 DECLARE_CONCRETE_INSTRUCTION(MathExp, "math-exp")
946 class LMathSqrt final : public LTemplateInstruction<1, 1, 0> {
948 explicit LMathSqrt(LOperand* value) {
952 LOperand* value() { return inputs_[0]; }
954 DECLARE_CONCRETE_INSTRUCTION(MathSqrt, "math-sqrt")
958 class LMathPowHalf final : public LTemplateInstruction<1, 1, 0> {
960 explicit LMathPowHalf(LOperand* value) {
964 LOperand* value() { return inputs_[0]; }
966 DECLARE_CONCRETE_INSTRUCTION(MathPowHalf, "math-pow-half")
970 class LCmpObjectEqAndBranch final : public LControlInstruction<2, 0> {
972 LCmpObjectEqAndBranch(LOperand* left, LOperand* right) {
977 LOperand* left() { return inputs_[0]; }
978 LOperand* right() { return inputs_[1]; }
980 DECLARE_CONCRETE_INSTRUCTION(CmpObjectEqAndBranch, "cmp-object-eq-and-branch")
981 DECLARE_HYDROGEN_ACCESSOR(CompareObjectEqAndBranch)
985 class LCmpHoleAndBranch final : public LControlInstruction<1, 0> {
987 explicit LCmpHoleAndBranch(LOperand* object) {
991 LOperand* object() { return inputs_[0]; }
993 DECLARE_CONCRETE_INSTRUCTION(CmpHoleAndBranch, "cmp-hole-and-branch")
994 DECLARE_HYDROGEN_ACCESSOR(CompareHoleAndBranch)
998 class LCompareMinusZeroAndBranch final : public LControlInstruction<1, 1> {
1000 LCompareMinusZeroAndBranch(LOperand* value, LOperand* temp) {
1005 LOperand* value() { return inputs_[0]; }
1006 LOperand* temp() { return temps_[0]; }
1008 DECLARE_CONCRETE_INSTRUCTION(CompareMinusZeroAndBranch,
1009 "cmp-minus-zero-and-branch")
1010 DECLARE_HYDROGEN_ACCESSOR(CompareMinusZeroAndBranch)
1014 class LIsObjectAndBranch final : public LControlInstruction<1, 1> {
1016 LIsObjectAndBranch(LOperand* value, LOperand* temp) {
1021 LOperand* value() { return inputs_[0]; }
1022 LOperand* temp() { return temps_[0]; }
1024 DECLARE_CONCRETE_INSTRUCTION(IsObjectAndBranch, "is-object-and-branch")
1025 DECLARE_HYDROGEN_ACCESSOR(IsObjectAndBranch)
1027 void PrintDataTo(StringStream* stream) override;
1031 class LIsStringAndBranch final : public LControlInstruction<1, 1> {
1033 LIsStringAndBranch(LOperand* value, LOperand* temp) {
1038 LOperand* value() { return inputs_[0]; }
1039 LOperand* temp() { return temps_[0]; }
1041 DECLARE_CONCRETE_INSTRUCTION(IsStringAndBranch, "is-string-and-branch")
1042 DECLARE_HYDROGEN_ACCESSOR(IsStringAndBranch)
1044 void PrintDataTo(StringStream* stream) override;
1048 class LIsSmiAndBranch final : public LControlInstruction<1, 0> {
1050 explicit LIsSmiAndBranch(LOperand* value) {
1054 LOperand* value() { return inputs_[0]; }
1056 DECLARE_CONCRETE_INSTRUCTION(IsSmiAndBranch, "is-smi-and-branch")
1057 DECLARE_HYDROGEN_ACCESSOR(IsSmiAndBranch)
1059 void PrintDataTo(StringStream* stream) override;
1063 class LIsUndetectableAndBranch final : public LControlInstruction<1, 1> {
1065 explicit LIsUndetectableAndBranch(LOperand* value, LOperand* temp) {
1070 LOperand* value() { return inputs_[0]; }
1071 LOperand* temp() { return temps_[0]; }
1073 DECLARE_CONCRETE_INSTRUCTION(IsUndetectableAndBranch,
1074 "is-undetectable-and-branch")
1075 DECLARE_HYDROGEN_ACCESSOR(IsUndetectableAndBranch)
1077 void PrintDataTo(StringStream* stream) override;
1081 class LStringCompareAndBranch final : public LControlInstruction<3, 0> {
1083 LStringCompareAndBranch(LOperand* context, LOperand* left, LOperand* right) {
1084 inputs_[0] = context;
1089 LOperand* context() { return inputs_[0]; }
1090 LOperand* left() { return inputs_[1]; }
1091 LOperand* right() { return inputs_[2]; }
1093 DECLARE_CONCRETE_INSTRUCTION(StringCompareAndBranch,
1094 "string-compare-and-branch")
1095 DECLARE_HYDROGEN_ACCESSOR(StringCompareAndBranch)
1097 Token::Value op() const { return hydrogen()->token(); }
1099 void PrintDataTo(StringStream* stream) override;
1103 class LHasInstanceTypeAndBranch final : public LControlInstruction<1, 0> {
1105 explicit LHasInstanceTypeAndBranch(LOperand* value) {
1109 LOperand* value() { return inputs_[0]; }
1111 DECLARE_CONCRETE_INSTRUCTION(HasInstanceTypeAndBranch,
1112 "has-instance-type-and-branch")
1113 DECLARE_HYDROGEN_ACCESSOR(HasInstanceTypeAndBranch)
1115 void PrintDataTo(StringStream* stream) override;
1119 class LGetCachedArrayIndex final : public LTemplateInstruction<1, 1, 0> {
1121 explicit LGetCachedArrayIndex(LOperand* value) {
1125 LOperand* value() { return inputs_[0]; }
1127 DECLARE_CONCRETE_INSTRUCTION(GetCachedArrayIndex, "get-cached-array-index")
1128 DECLARE_HYDROGEN_ACCESSOR(GetCachedArrayIndex)
1132 class LHasCachedArrayIndexAndBranch final : public LControlInstruction<1, 0> {
1134 explicit LHasCachedArrayIndexAndBranch(LOperand* value) {
1138 LOperand* value() { return inputs_[0]; }
1140 DECLARE_CONCRETE_INSTRUCTION(HasCachedArrayIndexAndBranch,
1141 "has-cached-array-index-and-branch")
1142 DECLARE_HYDROGEN_ACCESSOR(HasCachedArrayIndexAndBranch)
1144 void PrintDataTo(StringStream* stream) override;
1148 class LClassOfTestAndBranch final : public LControlInstruction<1, 1> {
1150 LClassOfTestAndBranch(LOperand* value, LOperand* temp) {
1155 LOperand* value() { return inputs_[0]; }
1156 LOperand* temp() { return temps_[0]; }
1158 DECLARE_CONCRETE_INSTRUCTION(ClassOfTestAndBranch,
1159 "class-of-test-and-branch")
1160 DECLARE_HYDROGEN_ACCESSOR(ClassOfTestAndBranch)
1162 void PrintDataTo(StringStream* stream) override;
1166 class LCmpT final : public LTemplateInstruction<1, 3, 0> {
1168 LCmpT(LOperand* context, LOperand* left, LOperand* right) {
1169 inputs_[0] = context;
1174 LOperand* context() { return inputs_[0]; }
1175 LOperand* left() { return inputs_[1]; }
1176 LOperand* right() { return inputs_[2]; }
1178 DECLARE_CONCRETE_INSTRUCTION(CmpT, "cmp-t")
1179 DECLARE_HYDROGEN_ACCESSOR(CompareGeneric)
1181 Strength strength() { return hydrogen()->strength(); }
1183 Token::Value op() const { return hydrogen()->token(); }
1187 class LInstanceOf final : public LTemplateInstruction<1, 3, 0> {
1189 LInstanceOf(LOperand* context, LOperand* left, LOperand* right) {
1190 inputs_[0] = context;
1195 LOperand* context() { return inputs_[0]; }
1196 LOperand* left() { return inputs_[1]; }
1197 LOperand* right() { return inputs_[2]; }
1199 DECLARE_CONCRETE_INSTRUCTION(InstanceOf, "instance-of")
1203 class LInstanceOfKnownGlobal final : public LTemplateInstruction<1, 2, 1> {
1205 LInstanceOfKnownGlobal(LOperand* context, LOperand* value, LOperand* temp) {
1206 inputs_[0] = context;
1211 LOperand* context() { return inputs_[0]; }
1212 LOperand* value() { return inputs_[1]; }
1213 LOperand* temp() { return temps_[0]; }
1215 DECLARE_CONCRETE_INSTRUCTION(InstanceOfKnownGlobal,
1216 "instance-of-known-global")
1217 DECLARE_HYDROGEN_ACCESSOR(InstanceOfKnownGlobal)
1219 Handle<JSFunction> function() const { return hydrogen()->function(); }
1220 LEnvironment* GetDeferredLazyDeoptimizationEnvironment() {
1221 return lazy_deopt_env_;
1223 virtual void SetDeferredLazyDeoptimizationEnvironment(
1224 LEnvironment* env) override {
1225 lazy_deopt_env_ = env;
1229 LEnvironment* lazy_deopt_env_;
1233 class LBoundsCheck final : public LTemplateInstruction<0, 2, 0> {
1235 LBoundsCheck(LOperand* index, LOperand* length) {
1237 inputs_[1] = length;
1240 LOperand* index() { return inputs_[0]; }
1241 LOperand* length() { return inputs_[1]; }
1243 DECLARE_CONCRETE_INSTRUCTION(BoundsCheck, "bounds-check")
1244 DECLARE_HYDROGEN_ACCESSOR(BoundsCheck)
1248 class LBitI final : public LTemplateInstruction<1, 2, 0> {
1250 LBitI(LOperand* left, LOperand* right) {
1255 LOperand* left() { return inputs_[0]; }
1256 LOperand* right() { return inputs_[1]; }
1258 Token::Value op() const { return hydrogen()->op(); }
1260 DECLARE_CONCRETE_INSTRUCTION(BitI, "bit-i")
1261 DECLARE_HYDROGEN_ACCESSOR(Bitwise)
1265 class LShiftI final : public LTemplateInstruction<1, 2, 0> {
1267 LShiftI(Token::Value op, LOperand* left, LOperand* right, bool can_deopt)
1268 : op_(op), can_deopt_(can_deopt) {
1273 Token::Value op() const { return op_; }
1274 LOperand* left() { return inputs_[0]; }
1275 LOperand* right() { return inputs_[1]; }
1276 bool can_deopt() const { return can_deopt_; }
1278 DECLARE_CONCRETE_INSTRUCTION(ShiftI, "shift-i")
1286 class LSubI final : public LTemplateInstruction<1, 2, 0> {
1288 LSubI(LOperand* left, LOperand* right) {
1293 LOperand* left() { return inputs_[0]; }
1294 LOperand* right() { return inputs_[1]; }
1296 DECLARE_CONCRETE_INSTRUCTION(SubI, "sub-i")
1297 DECLARE_HYDROGEN_ACCESSOR(Sub)
1301 class LRSubI final : public LTemplateInstruction<1, 2, 0> {
1303 LRSubI(LOperand* left, LOperand* right) {
1308 LOperand* left() { return inputs_[0]; }
1309 LOperand* right() { return inputs_[1]; }
1311 DECLARE_CONCRETE_INSTRUCTION(RSubI, "rsub-i")
1312 DECLARE_HYDROGEN_ACCESSOR(Sub)
1316 class LConstantI final : public LTemplateInstruction<1, 0, 0> {
1318 DECLARE_CONCRETE_INSTRUCTION(ConstantI, "constant-i")
1319 DECLARE_HYDROGEN_ACCESSOR(Constant)
1321 int32_t value() const { return hydrogen()->Integer32Value(); }
1325 class LConstantS final : public LTemplateInstruction<1, 0, 0> {
1327 DECLARE_CONCRETE_INSTRUCTION(ConstantS, "constant-s")
1328 DECLARE_HYDROGEN_ACCESSOR(Constant)
1330 Smi* value() const { return Smi::FromInt(hydrogen()->Integer32Value()); }
1334 class LConstantD final : public LTemplateInstruction<1, 0, 0> {
1336 DECLARE_CONCRETE_INSTRUCTION(ConstantD, "constant-d")
1337 DECLARE_HYDROGEN_ACCESSOR(Constant)
1339 double value() const { return hydrogen()->DoubleValue(); }
1340 uint64_t bits() const { return hydrogen()->DoubleValueAsBits(); }
1344 class LConstantE final : public LTemplateInstruction<1, 0, 0> {
1346 DECLARE_CONCRETE_INSTRUCTION(ConstantE, "constant-e")
1347 DECLARE_HYDROGEN_ACCESSOR(Constant)
1349 ExternalReference value() const {
1350 return hydrogen()->ExternalReferenceValue();
1355 class LConstantT final : public LTemplateInstruction<1, 0, 0> {
1357 DECLARE_CONCRETE_INSTRUCTION(ConstantT, "constant-t")
1358 DECLARE_HYDROGEN_ACCESSOR(Constant)
1360 Handle<Object> value(Isolate* isolate) const {
1361 return hydrogen()->handle(isolate);
1366 class LBranch final : public LControlInstruction<1, 0> {
1368 explicit LBranch(LOperand* value) {
1372 LOperand* value() { return inputs_[0]; }
1374 DECLARE_CONCRETE_INSTRUCTION(Branch, "branch")
1375 DECLARE_HYDROGEN_ACCESSOR(Branch)
1377 void PrintDataTo(StringStream* stream) override;
1381 class LCmpMapAndBranch final : public LControlInstruction<1, 1> {
1383 LCmpMapAndBranch(LOperand* value, LOperand* temp) {
1388 LOperand* value() { return inputs_[0]; }
1389 LOperand* temp() { return temps_[0]; }
1391 DECLARE_CONCRETE_INSTRUCTION(CmpMapAndBranch, "cmp-map-and-branch")
1392 DECLARE_HYDROGEN_ACCESSOR(CompareMap)
1394 Handle<Map> map() const { return hydrogen()->map().handle(); }
1398 class LMapEnumLength final : public LTemplateInstruction<1, 1, 0> {
1400 explicit LMapEnumLength(LOperand* value) {
1404 LOperand* value() { return inputs_[0]; }
1406 DECLARE_CONCRETE_INSTRUCTION(MapEnumLength, "map-enum-length")
1410 class LDateField final : public LTemplateInstruction<1, 1, 1> {
1412 LDateField(LOperand* date, LOperand* temp, Smi* index) : index_(index) {
1417 LOperand* date() { return inputs_[0]; }
1418 LOperand* temp() { return temps_[0]; }
1419 Smi* index() const { return index_; }
1421 DECLARE_CONCRETE_INSTRUCTION(DateField, "date-field")
1422 DECLARE_HYDROGEN_ACCESSOR(DateField)
1429 class LSeqStringGetChar final : public LTemplateInstruction<1, 2, 0> {
1431 LSeqStringGetChar(LOperand* string, LOperand* index) {
1432 inputs_[0] = string;
1436 LOperand* string() const { return inputs_[0]; }
1437 LOperand* index() const { return inputs_[1]; }
1439 DECLARE_CONCRETE_INSTRUCTION(SeqStringGetChar, "seq-string-get-char")
1440 DECLARE_HYDROGEN_ACCESSOR(SeqStringGetChar)
1444 class LSeqStringSetChar final : public LTemplateInstruction<1, 4, 0> {
1446 LSeqStringSetChar(LOperand* context,
1450 inputs_[0] = context;
1451 inputs_[1] = string;
1456 LOperand* string() { return inputs_[1]; }
1457 LOperand* index() { return inputs_[2]; }
1458 LOperand* value() { return inputs_[3]; }
1460 DECLARE_CONCRETE_INSTRUCTION(SeqStringSetChar, "seq-string-set-char")
1461 DECLARE_HYDROGEN_ACCESSOR(SeqStringSetChar)
1465 class LAddI final : public LTemplateInstruction<1, 2, 0> {
1467 LAddI(LOperand* left, LOperand* right) {
1472 LOperand* left() { return inputs_[0]; }
1473 LOperand* right() { return inputs_[1]; }
1475 DECLARE_CONCRETE_INSTRUCTION(AddI, "add-i")
1476 DECLARE_HYDROGEN_ACCESSOR(Add)
1480 class LMathMinMax final : public LTemplateInstruction<1, 2, 0> {
1482 LMathMinMax(LOperand* left, LOperand* right) {
1487 LOperand* left() { return inputs_[0]; }
1488 LOperand* right() { return inputs_[1]; }
1490 DECLARE_CONCRETE_INSTRUCTION(MathMinMax, "math-min-max")
1491 DECLARE_HYDROGEN_ACCESSOR(MathMinMax)
1495 class LPower final : public LTemplateInstruction<1, 2, 0> {
1497 LPower(LOperand* left, LOperand* right) {
1502 LOperand* left() { return inputs_[0]; }
1503 LOperand* right() { return inputs_[1]; }
1505 DECLARE_CONCRETE_INSTRUCTION(Power, "power")
1506 DECLARE_HYDROGEN_ACCESSOR(Power)
1510 class LArithmeticD final : public LTemplateInstruction<1, 2, 0> {
1512 LArithmeticD(Token::Value op, LOperand* left, LOperand* right)
1518 Token::Value op() const { return op_; }
1519 LOperand* left() { return inputs_[0]; }
1520 LOperand* right() { return inputs_[1]; }
1522 Opcode opcode() const override { return LInstruction::kArithmeticD; }
1523 void CompileToNative(LCodeGen* generator) override;
1524 const char* Mnemonic() const override;
1531 class LArithmeticT final : public LTemplateInstruction<1, 3, 0> {
1533 LArithmeticT(Token::Value op,
1538 inputs_[0] = context;
1543 LOperand* context() { return inputs_[0]; }
1544 LOperand* left() { return inputs_[1]; }
1545 LOperand* right() { return inputs_[2]; }
1546 Token::Value op() const { return op_; }
1548 Opcode opcode() const override { return LInstruction::kArithmeticT; }
1549 void CompileToNative(LCodeGen* generator) override;
1550 const char* Mnemonic() const override;
1552 DECLARE_HYDROGEN_ACCESSOR(BinaryOperation)
1554 Strength strength() { return hydrogen()->strength(); }
1561 class LReturn final : public LTemplateInstruction<0, 3, 0> {
1563 LReturn(LOperand* value, LOperand* context, LOperand* parameter_count) {
1565 inputs_[1] = context;
1566 inputs_[2] = parameter_count;
1569 LOperand* value() { return inputs_[0]; }
1571 bool has_constant_parameter_count() {
1572 return parameter_count()->IsConstantOperand();
1574 LConstantOperand* constant_parameter_count() {
1575 DCHECK(has_constant_parameter_count());
1576 return LConstantOperand::cast(parameter_count());
1578 LOperand* parameter_count() { return inputs_[2]; }
1580 DECLARE_CONCRETE_INSTRUCTION(Return, "return")
1584 class LLoadNamedField final : public LTemplateInstruction<1, 1, 0> {
1586 explicit LLoadNamedField(LOperand* object) {
1587 inputs_[0] = object;
1590 LOperand* object() { return inputs_[0]; }
1592 DECLARE_CONCRETE_INSTRUCTION(LoadNamedField, "load-named-field")
1593 DECLARE_HYDROGEN_ACCESSOR(LoadNamedField)
1597 class LLoadNamedGeneric final : public LTemplateInstruction<1, 2, 1> {
1599 LLoadNamedGeneric(LOperand* context, LOperand* object, LOperand* vector) {
1600 inputs_[0] = context;
1601 inputs_[1] = object;
1605 LOperand* context() { return inputs_[0]; }
1606 LOperand* object() { return inputs_[1]; }
1607 LOperand* temp_vector() { return temps_[0]; }
1609 DECLARE_CONCRETE_INSTRUCTION(LoadNamedGeneric, "load-named-generic")
1610 DECLARE_HYDROGEN_ACCESSOR(LoadNamedGeneric)
1612 Handle<Object> name() const { return hydrogen()->name(); }
1616 class LLoadFunctionPrototype final : public LTemplateInstruction<1, 1, 0> {
1618 explicit LLoadFunctionPrototype(LOperand* function) {
1619 inputs_[0] = function;
1622 LOperand* function() { return inputs_[0]; }
1624 DECLARE_CONCRETE_INSTRUCTION(LoadFunctionPrototype, "load-function-prototype")
1625 DECLARE_HYDROGEN_ACCESSOR(LoadFunctionPrototype)
1629 class LLoadRoot final : public LTemplateInstruction<1, 0, 0> {
1631 DECLARE_CONCRETE_INSTRUCTION(LoadRoot, "load-root")
1632 DECLARE_HYDROGEN_ACCESSOR(LoadRoot)
1634 Heap::RootListIndex index() const { return hydrogen()->index(); }
1638 class LLoadKeyed final : public LTemplateInstruction<1, 2, 0> {
1640 LLoadKeyed(LOperand* elements, LOperand* key) {
1641 inputs_[0] = elements;
1645 LOperand* elements() { return inputs_[0]; }
1646 LOperand* key() { return inputs_[1]; }
1647 ElementsKind elements_kind() const {
1648 return hydrogen()->elements_kind();
1650 bool is_fixed_typed_array() const {
1651 return hydrogen()->is_fixed_typed_array();
1654 DECLARE_CONCRETE_INSTRUCTION(LoadKeyed, "load-keyed")
1655 DECLARE_HYDROGEN_ACCESSOR(LoadKeyed)
1657 void PrintDataTo(StringStream* stream) override;
1658 uint32_t base_offset() const { return hydrogen()->base_offset(); }
1662 class LLoadKeyedGeneric final : public LTemplateInstruction<1, 3, 1> {
1664 LLoadKeyedGeneric(LOperand* context, LOperand* object, LOperand* key,
1666 inputs_[0] = context;
1667 inputs_[1] = object;
1672 LOperand* context() { return inputs_[0]; }
1673 LOperand* object() { return inputs_[1]; }
1674 LOperand* key() { return inputs_[2]; }
1675 LOperand* temp_vector() { return temps_[0]; }
1677 DECLARE_CONCRETE_INSTRUCTION(LoadKeyedGeneric, "load-keyed-generic")
1678 DECLARE_HYDROGEN_ACCESSOR(LoadKeyedGeneric)
1682 class LLoadGlobalGeneric final : public LTemplateInstruction<1, 2, 1> {
1684 LLoadGlobalGeneric(LOperand* context, LOperand* global_object,
1686 inputs_[0] = context;
1687 inputs_[1] = global_object;
1691 LOperand* context() { return inputs_[0]; }
1692 LOperand* global_object() { return inputs_[1]; }
1693 LOperand* temp_vector() { return temps_[0]; }
1695 DECLARE_CONCRETE_INSTRUCTION(LoadGlobalGeneric, "load-global-generic")
1696 DECLARE_HYDROGEN_ACCESSOR(LoadGlobalGeneric)
1698 Handle<Object> name() const { return hydrogen()->name(); }
1699 TypeofMode typeof_mode() const { return hydrogen()->typeof_mode(); }
1703 class LLoadGlobalViaContext final : public LTemplateInstruction<1, 1, 1> {
1705 explicit LLoadGlobalViaContext(LOperand* context) { inputs_[0] = context; }
1707 DECLARE_CONCRETE_INSTRUCTION(LoadGlobalViaContext, "load-global-via-context")
1708 DECLARE_HYDROGEN_ACCESSOR(LoadGlobalViaContext)
1710 void PrintDataTo(StringStream* stream) override;
1712 LOperand* context() { return inputs_[0]; }
1714 int depth() const { return hydrogen()->depth(); }
1715 int slot_index() const { return hydrogen()->slot_index(); }
1719 class LLoadContextSlot final : public LTemplateInstruction<1, 1, 0> {
1721 explicit LLoadContextSlot(LOperand* context) {
1722 inputs_[0] = context;
1725 LOperand* context() { return inputs_[0]; }
1727 DECLARE_CONCRETE_INSTRUCTION(LoadContextSlot, "load-context-slot")
1728 DECLARE_HYDROGEN_ACCESSOR(LoadContextSlot)
1730 int slot_index() { return hydrogen()->slot_index(); }
1732 void PrintDataTo(StringStream* stream) override;
1736 class LStoreContextSlot final : public LTemplateInstruction<0, 2, 0> {
1738 LStoreContextSlot(LOperand* context, LOperand* value) {
1739 inputs_[0] = context;
1743 LOperand* context() { return inputs_[0]; }
1744 LOperand* value() { return inputs_[1]; }
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 : descriptor_(descriptor),
1862 inputs_(descriptor.GetRegisterParameterCount() +
1863 kImplicitRegisterParameterCount,
1865 DCHECK(descriptor.GetRegisterParameterCount() +
1866 kImplicitRegisterParameterCount ==
1868 inputs_.AddAll(operands, zone);
1871 LOperand* target() const { return inputs_[0]; }
1873 const CallInterfaceDescriptor descriptor() { return descriptor_; }
1875 DECLARE_HYDROGEN_ACCESSOR(CallWithDescriptor)
1877 // The target and context are passed as implicit parameters that are not
1878 // explicitly listed in the descriptor.
1879 static const int kImplicitRegisterParameterCount = 2;
1882 DECLARE_CONCRETE_INSTRUCTION(CallWithDescriptor, "call-with-descriptor")
1884 void PrintDataTo(StringStream* stream) override;
1886 int arity() const { return hydrogen()->argument_count() - 1; }
1888 CallInterfaceDescriptor descriptor_;
1889 ZoneList<LOperand*> inputs_;
1891 // Iterator support.
1892 int InputCount() final { return inputs_.length(); }
1893 LOperand* InputAt(int i) final { return inputs_[i]; }
1895 int TempCount() final { return 0; }
1896 LOperand* TempAt(int i) final { return NULL; }
1900 class LInvokeFunction final : public LTemplateInstruction<1, 2, 0> {
1902 LInvokeFunction(LOperand* context, LOperand* function) {
1903 inputs_[0] = context;
1904 inputs_[1] = function;
1907 LOperand* context() { return inputs_[0]; }
1908 LOperand* function() { return inputs_[1]; }
1910 DECLARE_CONCRETE_INSTRUCTION(InvokeFunction, "invoke-function")
1911 DECLARE_HYDROGEN_ACCESSOR(InvokeFunction)
1913 void PrintDataTo(StringStream* stream) override;
1915 int arity() const { return hydrogen()->argument_count() - 1; }
1919 class LCallFunction final : public LTemplateInstruction<1, 2, 2> {
1921 LCallFunction(LOperand* context, LOperand* function, LOperand* slot,
1923 inputs_[0] = context;
1924 inputs_[1] = function;
1929 LOperand* context() { return inputs_[0]; }
1930 LOperand* function() { return inputs_[1]; }
1931 LOperand* temp_slot() { return temps_[0]; }
1932 LOperand* temp_vector() { return temps_[1]; }
1934 DECLARE_CONCRETE_INSTRUCTION(CallFunction, "call-function")
1935 DECLARE_HYDROGEN_ACCESSOR(CallFunction)
1937 int arity() const { return hydrogen()->argument_count() - 1; }
1938 void PrintDataTo(StringStream* stream) override;
1942 class LCallNew final : public LTemplateInstruction<1, 2, 0> {
1944 LCallNew(LOperand* context, LOperand* constructor) {
1945 inputs_[0] = context;
1946 inputs_[1] = constructor;
1949 LOperand* context() { return inputs_[0]; }
1950 LOperand* constructor() { return inputs_[1]; }
1952 DECLARE_CONCRETE_INSTRUCTION(CallNew, "call-new")
1953 DECLARE_HYDROGEN_ACCESSOR(CallNew)
1955 void PrintDataTo(StringStream* stream) override;
1957 int arity() const { return hydrogen()->argument_count() - 1; }
1961 class LCallNewArray final : public LTemplateInstruction<1, 2, 0> {
1963 LCallNewArray(LOperand* context, LOperand* constructor) {
1964 inputs_[0] = context;
1965 inputs_[1] = constructor;
1968 LOperand* context() { return inputs_[0]; }
1969 LOperand* constructor() { return inputs_[1]; }
1971 DECLARE_CONCRETE_INSTRUCTION(CallNewArray, "call-new-array")
1972 DECLARE_HYDROGEN_ACCESSOR(CallNewArray)
1974 void PrintDataTo(StringStream* stream) override;
1976 int arity() const { return hydrogen()->argument_count() - 1; }
1980 class LCallRuntime final : public LTemplateInstruction<1, 1, 0> {
1982 explicit LCallRuntime(LOperand* context) {
1983 inputs_[0] = context;
1986 LOperand* context() { return inputs_[0]; }
1988 DECLARE_CONCRETE_INSTRUCTION(CallRuntime, "call-runtime")
1989 DECLARE_HYDROGEN_ACCESSOR(CallRuntime)
1991 bool ClobbersDoubleRegisters(Isolate* isolate) const override {
1992 return save_doubles() == kDontSaveFPRegs;
1995 const Runtime::Function* function() const { return hydrogen()->function(); }
1996 int arity() const { return hydrogen()->argument_count(); }
1997 SaveFPRegsMode save_doubles() const { return hydrogen()->save_doubles(); }
2001 class LInteger32ToDouble final : public LTemplateInstruction<1, 1, 0> {
2003 explicit LInteger32ToDouble(LOperand* value) {
2007 LOperand* value() { return inputs_[0]; }
2009 DECLARE_CONCRETE_INSTRUCTION(Integer32ToDouble, "int32-to-double")
2013 class LUint32ToDouble final : public LTemplateInstruction<1, 1, 0> {
2015 explicit LUint32ToDouble(LOperand* value) {
2019 LOperand* value() { return inputs_[0]; }
2021 DECLARE_CONCRETE_INSTRUCTION(Uint32ToDouble, "uint32-to-double")
2025 class LNumberTagI final : public LTemplateInstruction<1, 1, 2> {
2027 LNumberTagI(LOperand* value, LOperand* temp1, LOperand* temp2) {
2033 LOperand* value() { return inputs_[0]; }
2034 LOperand* temp1() { return temps_[0]; }
2035 LOperand* temp2() { return temps_[1]; }
2037 DECLARE_CONCRETE_INSTRUCTION(NumberTagI, "number-tag-i")
2041 class LNumberTagU final : public LTemplateInstruction<1, 1, 2> {
2043 LNumberTagU(LOperand* value, LOperand* temp1, LOperand* temp2) {
2049 LOperand* value() { return inputs_[0]; }
2050 LOperand* temp1() { return temps_[0]; }
2051 LOperand* temp2() { return temps_[1]; }
2053 DECLARE_CONCRETE_INSTRUCTION(NumberTagU, "number-tag-u")
2057 class LNumberTagD final : public LTemplateInstruction<1, 1, 2> {
2059 LNumberTagD(LOperand* value, LOperand* temp, LOperand* temp2) {
2065 LOperand* value() { return inputs_[0]; }
2066 LOperand* temp() { return temps_[0]; }
2067 LOperand* temp2() { return temps_[1]; }
2069 DECLARE_CONCRETE_INSTRUCTION(NumberTagD, "number-tag-d")
2070 DECLARE_HYDROGEN_ACCESSOR(Change)
2074 class LDoubleToSmi final : public LTemplateInstruction<1, 1, 0> {
2076 explicit LDoubleToSmi(LOperand* value) {
2080 LOperand* value() { return inputs_[0]; }
2082 DECLARE_CONCRETE_INSTRUCTION(DoubleToSmi, "double-to-smi")
2083 DECLARE_HYDROGEN_ACCESSOR(UnaryOperation)
2085 bool truncating() { return hydrogen()->CanTruncateToInt32(); }
2089 // Sometimes truncating conversion from a tagged value to an int32.
2090 class LDoubleToI final : public LTemplateInstruction<1, 1, 0> {
2092 explicit LDoubleToI(LOperand* value) {
2096 LOperand* value() { return inputs_[0]; }
2098 DECLARE_CONCRETE_INSTRUCTION(DoubleToI, "double-to-i")
2099 DECLARE_HYDROGEN_ACCESSOR(UnaryOperation)
2101 bool truncating() { return hydrogen()->CanTruncateToInt32(); }
2105 // Truncating conversion from a tagged value to an int32.
2106 class LTaggedToI final : public LTemplateInstruction<1, 1, 2> {
2108 LTaggedToI(LOperand* value,
2116 LOperand* value() { return inputs_[0]; }
2117 LOperand* temp() { return temps_[0]; }
2118 LOperand* temp2() { return temps_[1]; }
2120 DECLARE_CONCRETE_INSTRUCTION(TaggedToI, "tagged-to-i")
2121 DECLARE_HYDROGEN_ACCESSOR(Change)
2123 bool truncating() { return hydrogen()->CanTruncateToInt32(); }
2127 class LSmiTag final : public LTemplateInstruction<1, 1, 0> {
2129 explicit LSmiTag(LOperand* value) {
2133 LOperand* value() { return inputs_[0]; }
2135 DECLARE_CONCRETE_INSTRUCTION(SmiTag, "smi-tag")
2136 DECLARE_HYDROGEN_ACCESSOR(Change)
2140 class LNumberUntagD final : public LTemplateInstruction<1, 1, 0> {
2142 explicit LNumberUntagD(LOperand* value) {
2146 LOperand* value() { return inputs_[0]; }
2148 DECLARE_CONCRETE_INSTRUCTION(NumberUntagD, "double-untag")
2149 DECLARE_HYDROGEN_ACCESSOR(Change)
2153 class LSmiUntag final : public LTemplateInstruction<1, 1, 0> {
2155 LSmiUntag(LOperand* value, bool needs_check)
2156 : needs_check_(needs_check) {
2160 LOperand* value() { return inputs_[0]; }
2161 bool needs_check() const { return needs_check_; }
2163 DECLARE_CONCRETE_INSTRUCTION(SmiUntag, "smi-untag")
2170 class LStoreNamedField final : public LTemplateInstruction<0, 2, 1> {
2172 LStoreNamedField(LOperand* object, LOperand* value, LOperand* temp) {
2173 inputs_[0] = object;
2178 LOperand* object() { return inputs_[0]; }
2179 LOperand* value() { return inputs_[1]; }
2180 LOperand* temp() { return temps_[0]; }
2182 DECLARE_CONCRETE_INSTRUCTION(StoreNamedField, "store-named-field")
2183 DECLARE_HYDROGEN_ACCESSOR(StoreNamedField)
2185 void PrintDataTo(StringStream* stream) override;
2187 Representation representation() const {
2188 return hydrogen()->field_representation();
2193 class LStoreNamedGeneric final : public LTemplateInstruction<0, 3, 2> {
2195 LStoreNamedGeneric(LOperand* context, LOperand* object, LOperand* value,
2196 LOperand* slot, LOperand* vector) {
2197 inputs_[0] = context;
2198 inputs_[1] = object;
2204 LOperand* context() { return inputs_[0]; }
2205 LOperand* object() { return inputs_[1]; }
2206 LOperand* value() { return inputs_[2]; }
2207 LOperand* temp_slot() { return temps_[0]; }
2208 LOperand* temp_vector() { return temps_[1]; }
2210 DECLARE_CONCRETE_INSTRUCTION(StoreNamedGeneric, "store-named-generic")
2211 DECLARE_HYDROGEN_ACCESSOR(StoreNamedGeneric)
2213 void PrintDataTo(StringStream* stream) override;
2215 Handle<Object> name() const { return hydrogen()->name(); }
2216 LanguageMode language_mode() { return hydrogen()->language_mode(); }
2220 class LStoreGlobalViaContext final : public LTemplateInstruction<0, 2, 0> {
2222 LStoreGlobalViaContext(LOperand* context, LOperand* value) {
2223 inputs_[0] = context;
2227 LOperand* context() { return inputs_[0]; }
2228 LOperand* value() { return inputs_[1]; }
2230 DECLARE_CONCRETE_INSTRUCTION(StoreGlobalViaContext,
2231 "store-global-via-context")
2232 DECLARE_HYDROGEN_ACCESSOR(StoreGlobalViaContext)
2234 void PrintDataTo(StringStream* stream) override;
2236 int depth() { return hydrogen()->depth(); }
2237 int slot_index() { return hydrogen()->slot_index(); }
2238 LanguageMode language_mode() { return hydrogen()->language_mode(); }
2242 class LStoreKeyed final : public LTemplateInstruction<0, 3, 0> {
2244 LStoreKeyed(LOperand* object, LOperand* key, LOperand* value) {
2245 inputs_[0] = object;
2250 bool is_fixed_typed_array() const {
2251 return hydrogen()->is_fixed_typed_array();
2253 LOperand* elements() { return inputs_[0]; }
2254 LOperand* key() { return inputs_[1]; }
2255 LOperand* value() { return inputs_[2]; }
2256 ElementsKind elements_kind() const {
2257 return hydrogen()->elements_kind();
2260 DECLARE_CONCRETE_INSTRUCTION(StoreKeyed, "store-keyed")
2261 DECLARE_HYDROGEN_ACCESSOR(StoreKeyed)
2263 void PrintDataTo(StringStream* stream) override;
2264 bool NeedsCanonicalization() {
2265 if (hydrogen()->value()->IsAdd() || hydrogen()->value()->IsSub() ||
2266 hydrogen()->value()->IsMul() || hydrogen()->value()->IsDiv()) {
2269 return hydrogen()->NeedsCanonicalization();
2271 uint32_t base_offset() const { return hydrogen()->base_offset(); }
2275 class LStoreKeyedGeneric final : public LTemplateInstruction<0, 4, 2> {
2277 LStoreKeyedGeneric(LOperand* context, LOperand* object, LOperand* key,
2278 LOperand* value, LOperand* slot, LOperand* vector) {
2279 inputs_[0] = context;
2280 inputs_[1] = object;
2287 LOperand* context() { return inputs_[0]; }
2288 LOperand* object() { return inputs_[1]; }
2289 LOperand* key() { return inputs_[2]; }
2290 LOperand* value() { return inputs_[3]; }
2291 LOperand* temp_slot() { return temps_[0]; }
2292 LOperand* temp_vector() { return temps_[1]; }
2294 DECLARE_CONCRETE_INSTRUCTION(StoreKeyedGeneric, "store-keyed-generic")
2295 DECLARE_HYDROGEN_ACCESSOR(StoreKeyedGeneric)
2297 void PrintDataTo(StringStream* stream) override;
2299 LanguageMode language_mode() { return hydrogen()->language_mode(); }
2303 class LTransitionElementsKind final : public LTemplateInstruction<0, 2, 1> {
2305 LTransitionElementsKind(LOperand* object,
2307 LOperand* new_map_temp) {
2308 inputs_[0] = object;
2309 inputs_[1] = context;
2310 temps_[0] = new_map_temp;
2313 LOperand* context() { return inputs_[1]; }
2314 LOperand* object() { return inputs_[0]; }
2315 LOperand* new_map_temp() { return temps_[0]; }
2317 DECLARE_CONCRETE_INSTRUCTION(TransitionElementsKind,
2318 "transition-elements-kind")
2319 DECLARE_HYDROGEN_ACCESSOR(TransitionElementsKind)
2321 void PrintDataTo(StringStream* stream) override;
2323 Handle<Map> original_map() { return hydrogen()->original_map().handle(); }
2324 Handle<Map> transitioned_map() {
2325 return hydrogen()->transitioned_map().handle();
2327 ElementsKind from_kind() { return hydrogen()->from_kind(); }
2328 ElementsKind to_kind() { return hydrogen()->to_kind(); }
2332 class LTrapAllocationMemento final : public LTemplateInstruction<0, 1, 1> {
2334 LTrapAllocationMemento(LOperand* object,
2336 inputs_[0] = object;
2340 LOperand* object() { return inputs_[0]; }
2341 LOperand* temp() { return temps_[0]; }
2343 DECLARE_CONCRETE_INSTRUCTION(TrapAllocationMemento,
2344 "trap-allocation-memento")
2348 class LMaybeGrowElements final : public LTemplateInstruction<1, 5, 0> {
2350 LMaybeGrowElements(LOperand* context, LOperand* object, LOperand* elements,
2351 LOperand* key, LOperand* current_capacity) {
2352 inputs_[0] = context;
2353 inputs_[1] = object;
2354 inputs_[2] = elements;
2356 inputs_[4] = current_capacity;
2359 LOperand* context() { return inputs_[0]; }
2360 LOperand* object() { return inputs_[1]; }
2361 LOperand* elements() { return inputs_[2]; }
2362 LOperand* key() { return inputs_[3]; }
2363 LOperand* current_capacity() { return inputs_[4]; }
2365 DECLARE_HYDROGEN_ACCESSOR(MaybeGrowElements)
2366 DECLARE_CONCRETE_INSTRUCTION(MaybeGrowElements, "maybe-grow-elements")
2370 class LStringAdd final : public LTemplateInstruction<1, 3, 0> {
2372 LStringAdd(LOperand* context, LOperand* left, LOperand* right) {
2373 inputs_[0] = context;
2378 LOperand* context() { return inputs_[0]; }
2379 LOperand* left() { return inputs_[1]; }
2380 LOperand* right() { return inputs_[2]; }
2382 DECLARE_CONCRETE_INSTRUCTION(StringAdd, "string-add")
2383 DECLARE_HYDROGEN_ACCESSOR(StringAdd)
2387 class LStringCharCodeAt final : public LTemplateInstruction<1, 3, 0> {
2389 LStringCharCodeAt(LOperand* context, LOperand* string, LOperand* index) {
2390 inputs_[0] = context;
2391 inputs_[1] = string;
2395 LOperand* context() { return inputs_[0]; }
2396 LOperand* string() { return inputs_[1]; }
2397 LOperand* index() { return inputs_[2]; }
2399 DECLARE_CONCRETE_INSTRUCTION(StringCharCodeAt, "string-char-code-at")
2400 DECLARE_HYDROGEN_ACCESSOR(StringCharCodeAt)
2404 class LStringCharFromCode final : public LTemplateInstruction<1, 2, 0> {
2406 explicit LStringCharFromCode(LOperand* context, LOperand* char_code) {
2407 inputs_[0] = context;
2408 inputs_[1] = char_code;
2411 LOperand* context() { return inputs_[0]; }
2412 LOperand* char_code() { return inputs_[1]; }
2414 DECLARE_CONCRETE_INSTRUCTION(StringCharFromCode, "string-char-from-code")
2415 DECLARE_HYDROGEN_ACCESSOR(StringCharFromCode)
2419 class LCheckValue final : public LTemplateInstruction<0, 1, 0> {
2421 explicit LCheckValue(LOperand* value) {
2425 LOperand* value() { return inputs_[0]; }
2427 DECLARE_CONCRETE_INSTRUCTION(CheckValue, "check-value")
2428 DECLARE_HYDROGEN_ACCESSOR(CheckValue)
2432 class LCheckArrayBufferNotNeutered final
2433 : public LTemplateInstruction<0, 1, 0> {
2435 explicit LCheckArrayBufferNotNeutered(LOperand* view) { inputs_[0] = view; }
2437 LOperand* view() { return inputs_[0]; }
2439 DECLARE_CONCRETE_INSTRUCTION(CheckArrayBufferNotNeutered,
2440 "check-array-buffer-not-neutered")
2441 DECLARE_HYDROGEN_ACCESSOR(CheckArrayBufferNotNeutered)
2445 class LCheckInstanceType final : public LTemplateInstruction<0, 1, 0> {
2447 explicit LCheckInstanceType(LOperand* value) {
2451 LOperand* value() { return inputs_[0]; }
2453 DECLARE_CONCRETE_INSTRUCTION(CheckInstanceType, "check-instance-type")
2454 DECLARE_HYDROGEN_ACCESSOR(CheckInstanceType)
2458 class LCheckMaps final : public LTemplateInstruction<0, 1, 0> {
2460 explicit LCheckMaps(LOperand* value = NULL) {
2464 LOperand* value() { return inputs_[0]; }
2466 DECLARE_CONCRETE_INSTRUCTION(CheckMaps, "check-maps")
2467 DECLARE_HYDROGEN_ACCESSOR(CheckMaps)
2471 class LCheckSmi final : public LTemplateInstruction<1, 1, 0> {
2473 explicit LCheckSmi(LOperand* value) {
2477 LOperand* value() { return inputs_[0]; }
2479 DECLARE_CONCRETE_INSTRUCTION(CheckSmi, "check-smi")
2483 class LCheckNonSmi final : public LTemplateInstruction<0, 1, 0> {
2485 explicit LCheckNonSmi(LOperand* value) {
2489 LOperand* value() { return inputs_[0]; }
2491 DECLARE_CONCRETE_INSTRUCTION(CheckNonSmi, "check-non-smi")
2492 DECLARE_HYDROGEN_ACCESSOR(CheckHeapObject)
2496 class LClampDToUint8 final : public LTemplateInstruction<1, 1, 0> {
2498 explicit LClampDToUint8(LOperand* unclamped) {
2499 inputs_[0] = unclamped;
2502 LOperand* unclamped() { return inputs_[0]; }
2504 DECLARE_CONCRETE_INSTRUCTION(ClampDToUint8, "clamp-d-to-uint8")
2508 class LClampIToUint8 final : public LTemplateInstruction<1, 1, 0> {
2510 explicit LClampIToUint8(LOperand* unclamped) {
2511 inputs_[0] = unclamped;
2514 LOperand* unclamped() { return inputs_[0]; }
2516 DECLARE_CONCRETE_INSTRUCTION(ClampIToUint8, "clamp-i-to-uint8")
2520 class LClampTToUint8 final : public LTemplateInstruction<1, 1, 1> {
2522 LClampTToUint8(LOperand* unclamped, LOperand* temp) {
2523 inputs_[0] = unclamped;
2527 LOperand* unclamped() { return inputs_[0]; }
2528 LOperand* temp() { return temps_[0]; }
2530 DECLARE_CONCRETE_INSTRUCTION(ClampTToUint8, "clamp-t-to-uint8")
2534 class LDoubleBits final : public LTemplateInstruction<1, 1, 0> {
2536 explicit LDoubleBits(LOperand* value) {
2540 LOperand* value() { return inputs_[0]; }
2542 DECLARE_CONCRETE_INSTRUCTION(DoubleBits, "double-bits")
2543 DECLARE_HYDROGEN_ACCESSOR(DoubleBits)
2547 class LConstructDouble final : public LTemplateInstruction<1, 2, 0> {
2549 LConstructDouble(LOperand* hi, LOperand* lo) {
2554 LOperand* hi() { return inputs_[0]; }
2555 LOperand* lo() { return inputs_[1]; }
2557 DECLARE_CONCRETE_INSTRUCTION(ConstructDouble, "construct-double")
2561 class LAllocate final : public LTemplateInstruction<1, 2, 2> {
2563 LAllocate(LOperand* context,
2567 inputs_[0] = context;
2573 LOperand* context() { return inputs_[0]; }
2574 LOperand* size() { return inputs_[1]; }
2575 LOperand* temp1() { return temps_[0]; }
2576 LOperand* temp2() { return temps_[1]; }
2578 DECLARE_CONCRETE_INSTRUCTION(Allocate, "allocate")
2579 DECLARE_HYDROGEN_ACCESSOR(Allocate)
2583 class LRegExpLiteral final : public LTemplateInstruction<1, 1, 0> {
2585 explicit LRegExpLiteral(LOperand* context) {
2586 inputs_[0] = context;
2589 LOperand* context() { return inputs_[0]; }
2591 DECLARE_CONCRETE_INSTRUCTION(RegExpLiteral, "regexp-literal")
2592 DECLARE_HYDROGEN_ACCESSOR(RegExpLiteral)
2596 class LFunctionLiteral final : public LTemplateInstruction<1, 1, 0> {
2598 explicit LFunctionLiteral(LOperand* context) {
2599 inputs_[0] = context;
2602 LOperand* context() { return inputs_[0]; }
2604 DECLARE_CONCRETE_INSTRUCTION(FunctionLiteral, "function-literal")
2605 DECLARE_HYDROGEN_ACCESSOR(FunctionLiteral)
2609 class LToFastProperties final : public LTemplateInstruction<1, 1, 0> {
2611 explicit LToFastProperties(LOperand* value) {
2615 LOperand* value() { return inputs_[0]; }
2617 DECLARE_CONCRETE_INSTRUCTION(ToFastProperties, "to-fast-properties")
2618 DECLARE_HYDROGEN_ACCESSOR(ToFastProperties)
2622 class LTypeof final : public LTemplateInstruction<1, 2, 0> {
2624 LTypeof(LOperand* context, LOperand* value) {
2625 inputs_[0] = context;
2629 LOperand* context() { return inputs_[0]; }
2630 LOperand* value() { return inputs_[1]; }
2632 DECLARE_CONCRETE_INSTRUCTION(Typeof, "typeof")
2636 class LTypeofIsAndBranch final : public LControlInstruction<1, 0> {
2638 explicit LTypeofIsAndBranch(LOperand* value) {
2642 LOperand* value() { return inputs_[0]; }
2644 DECLARE_CONCRETE_INSTRUCTION(TypeofIsAndBranch, "typeof-is-and-branch")
2645 DECLARE_HYDROGEN_ACCESSOR(TypeofIsAndBranch)
2647 Handle<String> type_literal() { return hydrogen()->type_literal(); }
2649 void PrintDataTo(StringStream* stream) override;
2653 class LIsConstructCallAndBranch final : public LControlInstruction<0, 1> {
2655 explicit LIsConstructCallAndBranch(LOperand* temp) {
2659 LOperand* temp() { return temps_[0]; }
2661 DECLARE_CONCRETE_INSTRUCTION(IsConstructCallAndBranch,
2662 "is-construct-call-and-branch")
2666 class LOsrEntry final : public LTemplateInstruction<0, 0, 0> {
2670 bool HasInterestingComment(LCodeGen* gen) const override { return false; }
2671 DECLARE_CONCRETE_INSTRUCTION(OsrEntry, "osr-entry")
2675 class LStackCheck final : public LTemplateInstruction<0, 1, 0> {
2677 explicit LStackCheck(LOperand* context) {
2678 inputs_[0] = context;
2681 LOperand* context() { return inputs_[0]; }
2683 DECLARE_CONCRETE_INSTRUCTION(StackCheck, "stack-check")
2684 DECLARE_HYDROGEN_ACCESSOR(StackCheck)
2686 Label* done_label() { return &done_label_; }
2693 class LForInPrepareMap final : public LTemplateInstruction<1, 2, 0> {
2695 LForInPrepareMap(LOperand* context, LOperand* object) {
2696 inputs_[0] = context;
2697 inputs_[1] = object;
2700 LOperand* context() { return inputs_[0]; }
2701 LOperand* object() { return inputs_[1]; }
2703 DECLARE_CONCRETE_INSTRUCTION(ForInPrepareMap, "for-in-prepare-map")
2707 class LForInCacheArray final : public LTemplateInstruction<1, 1, 0> {
2709 explicit LForInCacheArray(LOperand* map) {
2713 LOperand* map() { return inputs_[0]; }
2715 DECLARE_CONCRETE_INSTRUCTION(ForInCacheArray, "for-in-cache-array")
2718 return HForInCacheArray::cast(this->hydrogen_value())->idx();
2723 class LCheckMapValue final : public LTemplateInstruction<0, 2, 0> {
2725 LCheckMapValue(LOperand* value, LOperand* map) {
2730 LOperand* value() { return inputs_[0]; }
2731 LOperand* map() { return inputs_[1]; }
2733 DECLARE_CONCRETE_INSTRUCTION(CheckMapValue, "check-map-value")
2737 class LLoadFieldByIndex final : public LTemplateInstruction<1, 2, 0> {
2739 LLoadFieldByIndex(LOperand* object, LOperand* index) {
2740 inputs_[0] = object;
2744 LOperand* object() { return inputs_[0]; }
2745 LOperand* index() { return inputs_[1]; }
2747 DECLARE_CONCRETE_INSTRUCTION(LoadFieldByIndex, "load-field-by-index")
2751 class LStoreFrameContext: public LTemplateInstruction<0, 1, 0> {
2753 explicit LStoreFrameContext(LOperand* context) {
2754 inputs_[0] = context;
2757 LOperand* context() { return inputs_[0]; }
2759 DECLARE_CONCRETE_INSTRUCTION(StoreFrameContext, "store-frame-context")
2763 class LAllocateBlockContext: public LTemplateInstruction<1, 2, 0> {
2765 LAllocateBlockContext(LOperand* context, LOperand* function) {
2766 inputs_[0] = context;
2767 inputs_[1] = function;
2770 LOperand* context() { return inputs_[0]; }
2771 LOperand* function() { return inputs_[1]; }
2773 Handle<ScopeInfo> scope_info() { return hydrogen()->scope_info(); }
2775 DECLARE_CONCRETE_INSTRUCTION(AllocateBlockContext, "allocate-block-context")
2776 DECLARE_HYDROGEN_ACCESSOR(AllocateBlockContext)
2780 class LChunkBuilder;
2781 class LPlatformChunk final : public LChunk {
2783 LPlatformChunk(CompilationInfo* info, HGraph* graph)
2784 : LChunk(info, graph) { }
2786 int GetNextSpillIndex(RegisterKind kind);
2787 LOperand* GetNextSpillSlot(RegisterKind kind);
2791 class LChunkBuilder final : public LChunkBuilderBase {
2793 LChunkBuilder(CompilationInfo* info, HGraph* graph, LAllocator* allocator)
2794 : LChunkBuilderBase(info, graph),
2795 current_instruction_(NULL),
2796 current_block_(NULL),
2798 allocator_(allocator) {}
2800 // Build the sequence for the graph.
2801 LPlatformChunk* Build();
2803 // Declare methods that deal with the individual node types.
2804 #define DECLARE_DO(type) LInstruction* Do##type(H##type* node);
2805 HYDROGEN_CONCRETE_INSTRUCTION_LIST(DECLARE_DO)
2808 LInstruction* DoMultiplyAdd(HMul* mul, HValue* addend);
2809 LInstruction* DoMultiplySub(HValue* minuend, HMul* mul);
2810 LInstruction* DoRSub(HSub* instr);
2812 static bool HasMagicNumberForDivisor(int32_t divisor);
2814 LInstruction* DoMathFloor(HUnaryMathOperation* instr);
2815 LInstruction* DoMathRound(HUnaryMathOperation* instr);
2816 LInstruction* DoMathFround(HUnaryMathOperation* instr);
2817 LInstruction* DoMathAbs(HUnaryMathOperation* instr);
2818 LInstruction* DoMathLog(HUnaryMathOperation* instr);
2819 LInstruction* DoMathExp(HUnaryMathOperation* instr);
2820 LInstruction* DoMathSqrt(HUnaryMathOperation* instr);
2821 LInstruction* DoMathPowHalf(HUnaryMathOperation* instr);
2822 LInstruction* DoMathClz32(HUnaryMathOperation* instr);
2823 LInstruction* DoDivByPowerOf2I(HDiv* instr);
2824 LInstruction* DoDivByConstI(HDiv* instr);
2825 LInstruction* DoDivI(HDiv* instr);
2826 LInstruction* DoModByPowerOf2I(HMod* instr);
2827 LInstruction* DoModByConstI(HMod* instr);
2828 LInstruction* DoModI(HMod* instr);
2829 LInstruction* DoFlooringDivByPowerOf2I(HMathFloorOfDiv* instr);
2830 LInstruction* DoFlooringDivByConstI(HMathFloorOfDiv* instr);
2831 LInstruction* DoFlooringDivI(HMathFloorOfDiv* instr);
2834 // Methods for getting operands for Use / Define / Temp.
2835 LUnallocated* ToUnallocated(Register reg);
2836 LUnallocated* ToUnallocated(DoubleRegister reg);
2838 // Methods for setting up define-use relationships.
2839 MUST_USE_RESULT LOperand* Use(HValue* value, LUnallocated* operand);
2840 MUST_USE_RESULT LOperand* UseFixed(HValue* value, Register fixed_register);
2841 MUST_USE_RESULT LOperand* UseFixedDouble(HValue* value,
2842 DoubleRegister fixed_register);
2844 // A value that is guaranteed to be allocated to a register.
2845 // Operand created by UseRegister is guaranteed to be live until the end of
2846 // instruction. This means that register allocator will not reuse it's
2847 // register for any other operand inside instruction.
2848 // Operand created by UseRegisterAtStart is guaranteed to be live only at
2849 // instruction start. Register allocator is free to assign the same register
2850 // to some other operand used inside instruction (i.e. temporary or
2852 MUST_USE_RESULT LOperand* UseRegister(HValue* value);
2853 MUST_USE_RESULT LOperand* UseRegisterAtStart(HValue* value);
2855 // An input operand in a register that may be trashed.
2856 MUST_USE_RESULT LOperand* UseTempRegister(HValue* value);
2858 // An input operand in a register or stack slot.
2859 MUST_USE_RESULT LOperand* Use(HValue* value);
2860 MUST_USE_RESULT LOperand* UseAtStart(HValue* value);
2862 // An input operand in a register, stack slot or a constant operand.
2863 MUST_USE_RESULT LOperand* UseOrConstant(HValue* value);
2864 MUST_USE_RESULT LOperand* UseOrConstantAtStart(HValue* value);
2866 // An input operand in a register or a constant operand.
2867 MUST_USE_RESULT LOperand* UseRegisterOrConstant(HValue* value);
2868 MUST_USE_RESULT LOperand* UseRegisterOrConstantAtStart(HValue* value);
2870 // An input operand in a constant operand.
2871 MUST_USE_RESULT LOperand* UseConstant(HValue* value);
2873 // An input operand in register, stack slot or a constant operand.
2874 // Will not be moved to a register even if one is freely available.
2875 MUST_USE_RESULT LOperand* UseAny(HValue* value) override;
2877 // Temporary operand that must be in a register.
2878 MUST_USE_RESULT LUnallocated* TempRegister();
2879 MUST_USE_RESULT LUnallocated* TempDoubleRegister();
2880 MUST_USE_RESULT LOperand* FixedTemp(Register reg);
2881 MUST_USE_RESULT LOperand* FixedTemp(DoubleRegister reg);
2883 // Methods for setting up define-use relationships.
2884 // Return the same instruction that they are passed.
2885 LInstruction* Define(LTemplateResultInstruction<1>* instr,
2886 LUnallocated* result);
2887 LInstruction* DefineAsRegister(LTemplateResultInstruction<1>* instr);
2888 LInstruction* DefineAsSpilled(LTemplateResultInstruction<1>* instr,
2890 LInstruction* DefineSameAsFirst(LTemplateResultInstruction<1>* instr);
2891 LInstruction* DefineFixed(LTemplateResultInstruction<1>* instr,
2893 LInstruction* DefineFixedDouble(LTemplateResultInstruction<1>* instr,
2894 DoubleRegister reg);
2895 LInstruction* AssignEnvironment(LInstruction* instr);
2896 LInstruction* AssignPointerMap(LInstruction* instr);
2898 enum CanDeoptimize { CAN_DEOPTIMIZE_EAGERLY, CANNOT_DEOPTIMIZE_EAGERLY };
2900 // By default we assume that instruction sequences generated for calls
2901 // cannot deoptimize eagerly and we do not attach environment to this
2903 LInstruction* MarkAsCall(
2904 LInstruction* instr,
2905 HInstruction* hinstr,
2906 CanDeoptimize can_deoptimize = CANNOT_DEOPTIMIZE_EAGERLY);
2908 void VisitInstruction(HInstruction* current);
2909 void AddInstruction(LInstruction* instr, HInstruction* current);
2911 void DoBasicBlock(HBasicBlock* block, HBasicBlock* next_block);
2912 LInstruction* DoShift(Token::Value op, HBitwiseBinaryOperation* instr);
2913 LInstruction* DoArithmeticD(Token::Value op,
2914 HArithmeticBinaryOperation* instr);
2915 LInstruction* DoArithmeticT(Token::Value op,
2916 HBinaryOperation* instr);
2918 HInstruction* current_instruction_;
2919 HBasicBlock* current_block_;
2920 HBasicBlock* next_block_;
2921 LAllocator* allocator_;
2923 DISALLOW_COPY_AND_ASSIGN(LChunkBuilder);
2926 #undef DECLARE_HYDROGEN_ACCESSOR
2927 #undef DECLARE_CONCRETE_INSTRUCTION
2929 } } // namespace v8::internal
2931 #endif // V8_ARM_LITHIUM_ARM_H_