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) \
106 V(LoadKeyedGeneric) \
108 V(LoadNamedGeneric) \
120 V(MaybeGrowElements) \
137 V(SeqStringGetChar) \
138 V(SeqStringSetChar) \
144 V(StoreContextSlot) \
145 V(StoreFrameContext) \
147 V(StoreKeyedGeneric) \
149 V(StoreNamedGeneric) \
151 V(StringCharCodeAt) \
152 V(StringCharFromCode) \
153 V(StringCompareAndBranch) \
158 V(ToFastProperties) \
159 V(TransitionElementsKind) \
160 V(TrapAllocationMemento) \
162 V(TypeofIsAndBranch) \
168 #define DECLARE_CONCRETE_INSTRUCTION(type, mnemonic) \
169 Opcode opcode() const final { return LInstruction::k##type; } \
170 void CompileToNative(LCodeGen* generator) final; \
171 const char* Mnemonic() const final { return mnemonic; } \
172 static L##type* cast(LInstruction* instr) { \
173 DCHECK(instr->Is##type()); \
174 return reinterpret_cast<L##type*>(instr); \
178 #define DECLARE_HYDROGEN_ACCESSOR(type) \
179 H##type* hydrogen() const { \
180 return H##type::cast(hydrogen_value()); \
184 class LInstruction : public ZoneObject {
187 : environment_(NULL),
188 hydrogen_value_(NULL),
189 bit_field_(IsCallBits::encode(false)) {
192 virtual ~LInstruction() {}
194 virtual void CompileToNative(LCodeGen* generator) = 0;
195 virtual const char* Mnemonic() const = 0;
196 virtual void PrintTo(StringStream* stream);
197 virtual void PrintDataTo(StringStream* stream);
198 virtual void PrintOutputOperandTo(StringStream* stream);
201 // Declare a unique enum value for each instruction.
202 #define DECLARE_OPCODE(type) k##type,
203 LITHIUM_CONCRETE_INSTRUCTION_LIST(DECLARE_OPCODE)
204 kNumberOfInstructions
205 #undef DECLARE_OPCODE
208 virtual Opcode opcode() const = 0;
210 // Declare non-virtual type testers for all leaf IR classes.
211 #define DECLARE_PREDICATE(type) \
212 bool Is##type() const { return opcode() == k##type; }
213 LITHIUM_CONCRETE_INSTRUCTION_LIST(DECLARE_PREDICATE)
214 #undef DECLARE_PREDICATE
216 // Declare virtual predicates for instructions that don't have
218 virtual bool IsGap() const { return false; }
220 virtual bool IsControl() const { return false; }
222 // Try deleting this instruction if possible.
223 virtual bool TryDelete() { return false; }
225 void set_environment(LEnvironment* env) { environment_ = env; }
226 LEnvironment* environment() const { return environment_; }
227 bool HasEnvironment() const { return environment_ != NULL; }
229 void set_pointer_map(LPointerMap* p) { pointer_map_.set(p); }
230 LPointerMap* pointer_map() const { return pointer_map_.get(); }
231 bool HasPointerMap() const { return pointer_map_.is_set(); }
233 void set_hydrogen_value(HValue* value) { hydrogen_value_ = value; }
234 HValue* hydrogen_value() const { return hydrogen_value_; }
236 virtual void SetDeferredLazyDeoptimizationEnvironment(LEnvironment* env) { }
238 void MarkAsCall() { bit_field_ = IsCallBits::update(bit_field_, true); }
239 bool IsCall() const { return IsCallBits::decode(bit_field_); }
241 // Interface to the register allocator and iterators.
242 bool ClobbersTemps() const { return IsCall(); }
243 bool ClobbersRegisters() const { return IsCall(); }
244 virtual bool ClobbersDoubleRegisters(Isolate* isolate) const {
248 // Interface to the register allocator and iterators.
249 bool IsMarkedAsCall() const { return IsCall(); }
251 virtual bool HasResult() const = 0;
252 virtual LOperand* result() const = 0;
254 LOperand* FirstInput() { return InputAt(0); }
255 LOperand* Output() { return HasResult() ? result() : NULL; }
257 virtual bool HasInterestingComment(LCodeGen* gen) const { return true; }
263 virtual int InputCount() = 0;
264 virtual LOperand* InputAt(int i) = 0;
268 friend class InputIterator;
270 friend class TempIterator;
271 virtual int TempCount() = 0;
272 virtual LOperand* TempAt(int i) = 0;
274 class IsCallBits: public BitField<bool, 0, 1> {};
276 LEnvironment* environment_;
277 SetOncePointer<LPointerMap> pointer_map_;
278 HValue* hydrogen_value_;
283 // R = number of result operands (0 or 1).
285 class LTemplateResultInstruction : public LInstruction {
287 // Allow 0 or 1 output operands.
288 STATIC_ASSERT(R == 0 || R == 1);
289 bool HasResult() const final { return R != 0 && result() != NULL; }
290 void set_result(LOperand* operand) { results_[0] = operand; }
291 LOperand* result() const override { return results_[0]; }
294 EmbeddedContainer<LOperand*, R> results_;
298 // R = number of result operands (0 or 1).
299 // I = number of input operands.
300 // T = number of temporary operands.
301 template<int R, int I, int T>
302 class LTemplateInstruction : public LTemplateResultInstruction<R> {
304 EmbeddedContainer<LOperand*, I> inputs_;
305 EmbeddedContainer<LOperand*, T> temps_;
309 int InputCount() final { return I; }
310 LOperand* InputAt(int i) final { return inputs_[i]; }
312 int TempCount() final { return T; }
313 LOperand* TempAt(int i) final { return temps_[i]; }
317 class LGap : public LTemplateInstruction<0, 0, 0> {
319 explicit LGap(HBasicBlock* block)
321 parallel_moves_[BEFORE] = NULL;
322 parallel_moves_[START] = NULL;
323 parallel_moves_[END] = NULL;
324 parallel_moves_[AFTER] = NULL;
327 // Can't use the DECLARE-macro here because of sub-classes.
328 bool IsGap() const override { return true; }
329 void PrintDataTo(StringStream* stream) override;
330 static LGap* cast(LInstruction* instr) {
331 DCHECK(instr->IsGap());
332 return reinterpret_cast<LGap*>(instr);
335 bool IsRedundant() const;
337 HBasicBlock* block() const { return block_; }
344 FIRST_INNER_POSITION = BEFORE,
345 LAST_INNER_POSITION = AFTER
348 LParallelMove* GetOrCreateParallelMove(InnerPosition pos, Zone* zone) {
349 if (parallel_moves_[pos] == NULL) {
350 parallel_moves_[pos] = new(zone) LParallelMove(zone);
352 return parallel_moves_[pos];
355 LParallelMove* GetParallelMove(InnerPosition pos) {
356 return parallel_moves_[pos];
360 LParallelMove* parallel_moves_[LAST_INNER_POSITION + 1];
365 class LInstructionGap final : public LGap {
367 explicit LInstructionGap(HBasicBlock* block) : LGap(block) { }
369 bool HasInterestingComment(LCodeGen* gen) const override {
370 return !IsRedundant();
373 DECLARE_CONCRETE_INSTRUCTION(InstructionGap, "gap")
377 class LGoto final : public LTemplateInstruction<0, 0, 0> {
379 explicit LGoto(HBasicBlock* block) : block_(block) { }
381 bool HasInterestingComment(LCodeGen* gen) const override;
382 DECLARE_CONCRETE_INSTRUCTION(Goto, "goto")
383 void PrintDataTo(StringStream* stream) override;
384 bool IsControl() const override { return true; }
386 int block_id() const { return block_->block_id(); }
393 class LLazyBailout final : public LTemplateInstruction<0, 0, 0> {
395 LLazyBailout() : gap_instructions_size_(0) { }
397 DECLARE_CONCRETE_INSTRUCTION(LazyBailout, "lazy-bailout")
399 void set_gap_instructions_size(int gap_instructions_size) {
400 gap_instructions_size_ = gap_instructions_size;
402 int gap_instructions_size() { return gap_instructions_size_; }
405 int gap_instructions_size_;
409 class LDummy final : public LTemplateInstruction<1, 0, 0> {
412 DECLARE_CONCRETE_INSTRUCTION(Dummy, "dummy")
416 class LDummyUse final : public LTemplateInstruction<1, 1, 0> {
418 explicit LDummyUse(LOperand* value) {
421 DECLARE_CONCRETE_INSTRUCTION(DummyUse, "dummy-use")
425 class LDeoptimize final : public LTemplateInstruction<0, 0, 0> {
427 bool IsControl() const override { return true; }
428 DECLARE_CONCRETE_INSTRUCTION(Deoptimize, "deoptimize")
429 DECLARE_HYDROGEN_ACCESSOR(Deoptimize)
433 class LLabel final : public LGap {
435 explicit LLabel(HBasicBlock* block)
436 : LGap(block), replacement_(NULL) { }
438 bool HasInterestingComment(LCodeGen* gen) const override { return false; }
439 DECLARE_CONCRETE_INSTRUCTION(Label, "label")
441 void PrintDataTo(StringStream* stream) override;
443 int block_id() const { return block()->block_id(); }
444 bool is_loop_header() const { return block()->IsLoopHeader(); }
445 bool is_osr_entry() const { return block()->is_osr_entry(); }
446 Label* label() { return &label_; }
447 LLabel* replacement() const { return replacement_; }
448 void set_replacement(LLabel* label) { replacement_ = label; }
449 bool HasReplacement() const { return replacement_ != NULL; }
453 LLabel* replacement_;
457 class LParameter final : public LTemplateInstruction<1, 0, 0> {
459 bool HasInterestingComment(LCodeGen* gen) const override { return false; }
460 DECLARE_CONCRETE_INSTRUCTION(Parameter, "parameter")
464 class LCallStub final : public LTemplateInstruction<1, 1, 0> {
466 explicit LCallStub(LOperand* context) {
467 inputs_[0] = context;
470 LOperand* context() { return inputs_[0]; }
472 DECLARE_CONCRETE_INSTRUCTION(CallStub, "call-stub")
473 DECLARE_HYDROGEN_ACCESSOR(CallStub)
477 class LUnknownOSRValue final : public LTemplateInstruction<1, 0, 0> {
479 bool HasInterestingComment(LCodeGen* gen) const override { return false; }
480 DECLARE_CONCRETE_INSTRUCTION(UnknownOSRValue, "unknown-osr-value")
484 template<int I, int T>
485 class LControlInstruction : public LTemplateInstruction<0, I, T> {
487 LControlInstruction() : false_label_(NULL), true_label_(NULL) { }
489 bool IsControl() const final { return true; }
491 int SuccessorCount() { return hydrogen()->SuccessorCount(); }
492 HBasicBlock* SuccessorAt(int i) { return hydrogen()->SuccessorAt(i); }
494 int TrueDestination(LChunk* chunk) {
495 return chunk->LookupDestination(true_block_id());
497 int FalseDestination(LChunk* chunk) {
498 return chunk->LookupDestination(false_block_id());
501 Label* TrueLabel(LChunk* chunk) {
502 if (true_label_ == NULL) {
503 true_label_ = chunk->GetAssemblyLabel(TrueDestination(chunk));
507 Label* FalseLabel(LChunk* chunk) {
508 if (false_label_ == NULL) {
509 false_label_ = chunk->GetAssemblyLabel(FalseDestination(chunk));
515 int true_block_id() { return SuccessorAt(0)->block_id(); }
516 int false_block_id() { return SuccessorAt(1)->block_id(); }
519 HControlInstruction* hydrogen() {
520 return HControlInstruction::cast(this->hydrogen_value());
528 class LWrapReceiver final : public LTemplateInstruction<1, 2, 0> {
530 LWrapReceiver(LOperand* receiver, LOperand* function) {
531 inputs_[0] = receiver;
532 inputs_[1] = function;
535 DECLARE_CONCRETE_INSTRUCTION(WrapReceiver, "wrap-receiver")
536 DECLARE_HYDROGEN_ACCESSOR(WrapReceiver)
538 LOperand* receiver() { return inputs_[0]; }
539 LOperand* function() { return inputs_[1]; }
543 class LApplyArguments final : public LTemplateInstruction<1, 4, 0> {
545 LApplyArguments(LOperand* function,
548 LOperand* elements) {
549 inputs_[0] = function;
550 inputs_[1] = receiver;
552 inputs_[3] = elements;
555 DECLARE_CONCRETE_INSTRUCTION(ApplyArguments, "apply-arguments")
557 LOperand* function() { return inputs_[0]; }
558 LOperand* receiver() { return inputs_[1]; }
559 LOperand* length() { return inputs_[2]; }
560 LOperand* elements() { return inputs_[3]; }
564 class LAccessArgumentsAt final : public LTemplateInstruction<1, 3, 0> {
566 LAccessArgumentsAt(LOperand* arguments, LOperand* length, LOperand* index) {
567 inputs_[0] = arguments;
572 DECLARE_CONCRETE_INSTRUCTION(AccessArgumentsAt, "access-arguments-at")
574 LOperand* arguments() { return inputs_[0]; }
575 LOperand* length() { return inputs_[1]; }
576 LOperand* index() { return inputs_[2]; }
578 void PrintDataTo(StringStream* stream) override;
582 class LArgumentsLength final : public LTemplateInstruction<1, 1, 0> {
584 explicit LArgumentsLength(LOperand* elements) {
585 inputs_[0] = elements;
588 LOperand* elements() { return inputs_[0]; }
590 DECLARE_CONCRETE_INSTRUCTION(ArgumentsLength, "arguments-length")
594 class LArgumentsElements final : public LTemplateInstruction<1, 0, 0> {
596 DECLARE_CONCRETE_INSTRUCTION(ArgumentsElements, "arguments-elements")
597 DECLARE_HYDROGEN_ACCESSOR(ArgumentsElements)
601 class LModByPowerOf2I final : public LTemplateInstruction<1, 1, 0> {
603 LModByPowerOf2I(LOperand* dividend, int32_t divisor) {
604 inputs_[0] = dividend;
608 LOperand* dividend() { return inputs_[0]; }
609 int32_t divisor() const { return divisor_; }
611 DECLARE_CONCRETE_INSTRUCTION(ModByPowerOf2I, "mod-by-power-of-2-i")
612 DECLARE_HYDROGEN_ACCESSOR(Mod)
619 class LModByConstI final : public LTemplateInstruction<1, 1, 0> {
621 LModByConstI(LOperand* dividend, int32_t divisor) {
622 inputs_[0] = dividend;
626 LOperand* dividend() { return inputs_[0]; }
627 int32_t divisor() const { return divisor_; }
629 DECLARE_CONCRETE_INSTRUCTION(ModByConstI, "mod-by-const-i")
630 DECLARE_HYDROGEN_ACCESSOR(Mod)
637 class LModI final : public LTemplateInstruction<1, 2, 2> {
639 LModI(LOperand* left, LOperand* right, LOperand* temp, LOperand* temp2) {
646 LOperand* left() { return inputs_[0]; }
647 LOperand* right() { return inputs_[1]; }
648 LOperand* temp() { return temps_[0]; }
649 LOperand* temp2() { return temps_[1]; }
651 DECLARE_CONCRETE_INSTRUCTION(ModI, "mod-i")
652 DECLARE_HYDROGEN_ACCESSOR(Mod)
656 class LDivByPowerOf2I final : public LTemplateInstruction<1, 1, 0> {
658 LDivByPowerOf2I(LOperand* dividend, int32_t divisor) {
659 inputs_[0] = dividend;
663 LOperand* dividend() { return inputs_[0]; }
664 int32_t divisor() const { return divisor_; }
666 DECLARE_CONCRETE_INSTRUCTION(DivByPowerOf2I, "div-by-power-of-2-i")
667 DECLARE_HYDROGEN_ACCESSOR(Div)
674 class LDivByConstI final : public LTemplateInstruction<1, 1, 0> {
676 LDivByConstI(LOperand* dividend, int32_t divisor) {
677 inputs_[0] = dividend;
681 LOperand* dividend() { return inputs_[0]; }
682 int32_t divisor() const { return divisor_; }
684 DECLARE_CONCRETE_INSTRUCTION(DivByConstI, "div-by-const-i")
685 DECLARE_HYDROGEN_ACCESSOR(Div)
692 class LDivI final : public LTemplateInstruction<1, 2, 1> {
694 LDivI(LOperand* dividend, LOperand* divisor, LOperand* temp) {
695 inputs_[0] = dividend;
696 inputs_[1] = divisor;
700 LOperand* dividend() { return inputs_[0]; }
701 LOperand* divisor() { return inputs_[1]; }
702 LOperand* temp() { return temps_[0]; }
704 DECLARE_CONCRETE_INSTRUCTION(DivI, "div-i")
705 DECLARE_HYDROGEN_ACCESSOR(BinaryOperation)
709 class LFlooringDivByPowerOf2I final : public LTemplateInstruction<1, 1, 0> {
711 LFlooringDivByPowerOf2I(LOperand* dividend, int32_t divisor) {
712 inputs_[0] = dividend;
716 LOperand* dividend() { return inputs_[0]; }
717 int32_t divisor() { return divisor_; }
719 DECLARE_CONCRETE_INSTRUCTION(FlooringDivByPowerOf2I,
720 "flooring-div-by-power-of-2-i")
721 DECLARE_HYDROGEN_ACCESSOR(MathFloorOfDiv)
728 class LFlooringDivByConstI final : public LTemplateInstruction<1, 1, 2> {
730 LFlooringDivByConstI(LOperand* dividend, int32_t divisor, LOperand* temp) {
731 inputs_[0] = dividend;
736 LOperand* dividend() { return inputs_[0]; }
737 int32_t divisor() const { return divisor_; }
738 LOperand* temp() { return temps_[0]; }
740 DECLARE_CONCRETE_INSTRUCTION(FlooringDivByConstI, "flooring-div-by-const-i")
741 DECLARE_HYDROGEN_ACCESSOR(MathFloorOfDiv)
748 class LFlooringDivI final : public LTemplateInstruction<1, 2, 1> {
750 LFlooringDivI(LOperand* dividend, LOperand* divisor, LOperand* temp) {
751 inputs_[0] = dividend;
752 inputs_[1] = divisor;
756 LOperand* dividend() { return inputs_[0]; }
757 LOperand* divisor() { return inputs_[1]; }
758 LOperand* temp() { return temps_[0]; }
760 DECLARE_CONCRETE_INSTRUCTION(FlooringDivI, "flooring-div-i")
761 DECLARE_HYDROGEN_ACCESSOR(MathFloorOfDiv)
765 class LMulI final : public LTemplateInstruction<1, 2, 0> {
767 LMulI(LOperand* left, LOperand* right) {
772 LOperand* left() { return inputs_[0]; }
773 LOperand* right() { return inputs_[1]; }
775 DECLARE_CONCRETE_INSTRUCTION(MulI, "mul-i")
776 DECLARE_HYDROGEN_ACCESSOR(Mul)
780 // Instruction for computing multiplier * multiplicand + addend.
781 class LMultiplyAddD final : public LTemplateInstruction<1, 3, 0> {
783 LMultiplyAddD(LOperand* addend, LOperand* multiplier,
784 LOperand* multiplicand) {
786 inputs_[1] = multiplier;
787 inputs_[2] = multiplicand;
790 LOperand* addend() { return inputs_[0]; }
791 LOperand* multiplier() { return inputs_[1]; }
792 LOperand* multiplicand() { return inputs_[2]; }
794 DECLARE_CONCRETE_INSTRUCTION(MultiplyAddD, "multiply-add-d")
798 // Instruction for computing minuend - multiplier * multiplicand.
799 class LMultiplySubD final : public LTemplateInstruction<1, 3, 0> {
801 LMultiplySubD(LOperand* minuend, LOperand* multiplier,
802 LOperand* multiplicand) {
803 inputs_[0] = minuend;
804 inputs_[1] = multiplier;
805 inputs_[2] = multiplicand;
808 LOperand* minuend() { return inputs_[0]; }
809 LOperand* multiplier() { return inputs_[1]; }
810 LOperand* multiplicand() { return inputs_[2]; }
812 DECLARE_CONCRETE_INSTRUCTION(MultiplySubD, "multiply-sub-d")
816 class LDebugBreak final : public LTemplateInstruction<0, 0, 0> {
818 DECLARE_CONCRETE_INSTRUCTION(DebugBreak, "break")
822 class LCompareNumericAndBranch final : public LControlInstruction<2, 0> {
824 LCompareNumericAndBranch(LOperand* left, LOperand* right) {
829 LOperand* left() { return inputs_[0]; }
830 LOperand* right() { return inputs_[1]; }
832 DECLARE_CONCRETE_INSTRUCTION(CompareNumericAndBranch,
833 "compare-numeric-and-branch")
834 DECLARE_HYDROGEN_ACCESSOR(CompareNumericAndBranch)
836 Token::Value op() const { return hydrogen()->token(); }
837 bool is_double() const {
838 return hydrogen()->representation().IsDouble();
841 void PrintDataTo(StringStream* stream) override;
845 class LMathFloor final : public LTemplateInstruction<1, 1, 0> {
847 explicit LMathFloor(LOperand* value) {
851 LOperand* value() { return inputs_[0]; }
853 DECLARE_CONCRETE_INSTRUCTION(MathFloor, "math-floor")
854 DECLARE_HYDROGEN_ACCESSOR(UnaryMathOperation)
858 class LMathRound final : public LTemplateInstruction<1, 1, 1> {
860 LMathRound(LOperand* value, LOperand* temp) {
865 LOperand* value() { return inputs_[0]; }
866 LOperand* temp() { return temps_[0]; }
868 DECLARE_CONCRETE_INSTRUCTION(MathRound, "math-round")
869 DECLARE_HYDROGEN_ACCESSOR(UnaryMathOperation)
873 class LMathFround final : public LTemplateInstruction<1, 1, 0> {
875 explicit LMathFround(LOperand* value) { inputs_[0] = value; }
877 LOperand* value() { return inputs_[0]; }
879 DECLARE_CONCRETE_INSTRUCTION(MathFround, "math-fround")
883 class LMathAbs final : public LTemplateInstruction<1, 2, 0> {
885 LMathAbs(LOperand* context, LOperand* value) {
886 inputs_[1] = context;
890 LOperand* context() { return inputs_[1]; }
891 LOperand* value() { return inputs_[0]; }
893 DECLARE_CONCRETE_INSTRUCTION(MathAbs, "math-abs")
894 DECLARE_HYDROGEN_ACCESSOR(UnaryMathOperation)
898 class LMathLog final : public LTemplateInstruction<1, 1, 0> {
900 explicit LMathLog(LOperand* value) {
904 LOperand* value() { return inputs_[0]; }
906 DECLARE_CONCRETE_INSTRUCTION(MathLog, "math-log")
910 class LMathClz32 final : public LTemplateInstruction<1, 1, 0> {
912 explicit LMathClz32(LOperand* value) {
916 LOperand* value() { return inputs_[0]; }
918 DECLARE_CONCRETE_INSTRUCTION(MathClz32, "math-clz32")
922 class LMathExp final : public LTemplateInstruction<1, 1, 3> {
924 LMathExp(LOperand* value,
925 LOperand* double_temp,
931 temps_[2] = double_temp;
932 ExternalReference::InitializeMathExpData();
935 LOperand* value() { return inputs_[0]; }
936 LOperand* temp1() { return temps_[0]; }
937 LOperand* temp2() { return temps_[1]; }
938 LOperand* double_temp() { return temps_[2]; }
940 DECLARE_CONCRETE_INSTRUCTION(MathExp, "math-exp")
944 class LMathSqrt final : public LTemplateInstruction<1, 1, 0> {
946 explicit LMathSqrt(LOperand* value) {
950 LOperand* value() { return inputs_[0]; }
952 DECLARE_CONCRETE_INSTRUCTION(MathSqrt, "math-sqrt")
956 class LMathPowHalf final : public LTemplateInstruction<1, 1, 0> {
958 explicit LMathPowHalf(LOperand* value) {
962 LOperand* value() { return inputs_[0]; }
964 DECLARE_CONCRETE_INSTRUCTION(MathPowHalf, "math-pow-half")
968 class LCmpObjectEqAndBranch final : public LControlInstruction<2, 0> {
970 LCmpObjectEqAndBranch(LOperand* left, LOperand* right) {
975 LOperand* left() { return inputs_[0]; }
976 LOperand* right() { return inputs_[1]; }
978 DECLARE_CONCRETE_INSTRUCTION(CmpObjectEqAndBranch, "cmp-object-eq-and-branch")
979 DECLARE_HYDROGEN_ACCESSOR(CompareObjectEqAndBranch)
983 class LCmpHoleAndBranch final : public LControlInstruction<1, 0> {
985 explicit LCmpHoleAndBranch(LOperand* object) {
989 LOperand* object() { return inputs_[0]; }
991 DECLARE_CONCRETE_INSTRUCTION(CmpHoleAndBranch, "cmp-hole-and-branch")
992 DECLARE_HYDROGEN_ACCESSOR(CompareHoleAndBranch)
996 class LCompareMinusZeroAndBranch final : public LControlInstruction<1, 1> {
998 LCompareMinusZeroAndBranch(LOperand* value, LOperand* temp) {
1003 LOperand* value() { return inputs_[0]; }
1004 LOperand* temp() { return temps_[0]; }
1006 DECLARE_CONCRETE_INSTRUCTION(CompareMinusZeroAndBranch,
1007 "cmp-minus-zero-and-branch")
1008 DECLARE_HYDROGEN_ACCESSOR(CompareMinusZeroAndBranch)
1012 class LIsObjectAndBranch final : public LControlInstruction<1, 1> {
1014 LIsObjectAndBranch(LOperand* value, LOperand* temp) {
1019 LOperand* value() { return inputs_[0]; }
1020 LOperand* temp() { return temps_[0]; }
1022 DECLARE_CONCRETE_INSTRUCTION(IsObjectAndBranch, "is-object-and-branch")
1023 DECLARE_HYDROGEN_ACCESSOR(IsObjectAndBranch)
1025 void PrintDataTo(StringStream* stream) override;
1029 class LIsStringAndBranch final : public LControlInstruction<1, 1> {
1031 LIsStringAndBranch(LOperand* value, LOperand* temp) {
1036 LOperand* value() { return inputs_[0]; }
1037 LOperand* temp() { return temps_[0]; }
1039 DECLARE_CONCRETE_INSTRUCTION(IsStringAndBranch, "is-string-and-branch")
1040 DECLARE_HYDROGEN_ACCESSOR(IsStringAndBranch)
1042 void PrintDataTo(StringStream* stream) override;
1046 class LIsSmiAndBranch final : public LControlInstruction<1, 0> {
1048 explicit LIsSmiAndBranch(LOperand* value) {
1052 LOperand* value() { return inputs_[0]; }
1054 DECLARE_CONCRETE_INSTRUCTION(IsSmiAndBranch, "is-smi-and-branch")
1055 DECLARE_HYDROGEN_ACCESSOR(IsSmiAndBranch)
1057 void PrintDataTo(StringStream* stream) override;
1061 class LIsUndetectableAndBranch final : public LControlInstruction<1, 1> {
1063 explicit LIsUndetectableAndBranch(LOperand* value, LOperand* temp) {
1068 LOperand* value() { return inputs_[0]; }
1069 LOperand* temp() { return temps_[0]; }
1071 DECLARE_CONCRETE_INSTRUCTION(IsUndetectableAndBranch,
1072 "is-undetectable-and-branch")
1073 DECLARE_HYDROGEN_ACCESSOR(IsUndetectableAndBranch)
1075 void PrintDataTo(StringStream* stream) override;
1079 class LStringCompareAndBranch final : public LControlInstruction<3, 0> {
1081 LStringCompareAndBranch(LOperand* context, LOperand* left, LOperand* right) {
1082 inputs_[0] = context;
1087 LOperand* context() { return inputs_[0]; }
1088 LOperand* left() { return inputs_[1]; }
1089 LOperand* right() { return inputs_[2]; }
1091 DECLARE_CONCRETE_INSTRUCTION(StringCompareAndBranch,
1092 "string-compare-and-branch")
1093 DECLARE_HYDROGEN_ACCESSOR(StringCompareAndBranch)
1095 Token::Value op() const { return hydrogen()->token(); }
1097 void PrintDataTo(StringStream* stream) override;
1101 class LHasInstanceTypeAndBranch final : public LControlInstruction<1, 0> {
1103 explicit LHasInstanceTypeAndBranch(LOperand* value) {
1107 LOperand* value() { return inputs_[0]; }
1109 DECLARE_CONCRETE_INSTRUCTION(HasInstanceTypeAndBranch,
1110 "has-instance-type-and-branch")
1111 DECLARE_HYDROGEN_ACCESSOR(HasInstanceTypeAndBranch)
1113 void PrintDataTo(StringStream* stream) override;
1117 class LGetCachedArrayIndex final : public LTemplateInstruction<1, 1, 0> {
1119 explicit LGetCachedArrayIndex(LOperand* value) {
1123 LOperand* value() { return inputs_[0]; }
1125 DECLARE_CONCRETE_INSTRUCTION(GetCachedArrayIndex, "get-cached-array-index")
1126 DECLARE_HYDROGEN_ACCESSOR(GetCachedArrayIndex)
1130 class LHasCachedArrayIndexAndBranch final : public LControlInstruction<1, 0> {
1132 explicit LHasCachedArrayIndexAndBranch(LOperand* value) {
1136 LOperand* value() { return inputs_[0]; }
1138 DECLARE_CONCRETE_INSTRUCTION(HasCachedArrayIndexAndBranch,
1139 "has-cached-array-index-and-branch")
1140 DECLARE_HYDROGEN_ACCESSOR(HasCachedArrayIndexAndBranch)
1142 void PrintDataTo(StringStream* stream) override;
1146 class LClassOfTestAndBranch final : public LControlInstruction<1, 1> {
1148 LClassOfTestAndBranch(LOperand* value, LOperand* temp) {
1153 LOperand* value() { return inputs_[0]; }
1154 LOperand* temp() { return temps_[0]; }
1156 DECLARE_CONCRETE_INSTRUCTION(ClassOfTestAndBranch,
1157 "class-of-test-and-branch")
1158 DECLARE_HYDROGEN_ACCESSOR(ClassOfTestAndBranch)
1160 void PrintDataTo(StringStream* stream) override;
1164 class LCmpT final : public LTemplateInstruction<1, 3, 0> {
1166 LCmpT(LOperand* context, LOperand* left, LOperand* right) {
1167 inputs_[0] = context;
1172 LOperand* context() { return inputs_[0]; }
1173 LOperand* left() { return inputs_[1]; }
1174 LOperand* right() { return inputs_[2]; }
1176 DECLARE_CONCRETE_INSTRUCTION(CmpT, "cmp-t")
1177 DECLARE_HYDROGEN_ACCESSOR(CompareGeneric)
1179 LanguageMode language_mode() { return hydrogen()->language_mode(); }
1181 Token::Value op() const { return hydrogen()->token(); }
1185 class LInstanceOf final : public LTemplateInstruction<1, 3, 0> {
1187 LInstanceOf(LOperand* context, LOperand* left, LOperand* right) {
1188 inputs_[0] = context;
1193 LOperand* context() { return inputs_[0]; }
1194 LOperand* left() { return inputs_[1]; }
1195 LOperand* right() { return inputs_[2]; }
1197 DECLARE_CONCRETE_INSTRUCTION(InstanceOf, "instance-of")
1201 class LInstanceOfKnownGlobal final : public LTemplateInstruction<1, 2, 1> {
1203 LInstanceOfKnownGlobal(LOperand* context, LOperand* value, LOperand* temp) {
1204 inputs_[0] = context;
1209 LOperand* context() { return inputs_[0]; }
1210 LOperand* value() { return inputs_[1]; }
1211 LOperand* temp() { return temps_[0]; }
1213 DECLARE_CONCRETE_INSTRUCTION(InstanceOfKnownGlobal,
1214 "instance-of-known-global")
1215 DECLARE_HYDROGEN_ACCESSOR(InstanceOfKnownGlobal)
1217 Handle<JSFunction> function() const { return hydrogen()->function(); }
1218 LEnvironment* GetDeferredLazyDeoptimizationEnvironment() {
1219 return lazy_deopt_env_;
1221 virtual void SetDeferredLazyDeoptimizationEnvironment(
1222 LEnvironment* env) override {
1223 lazy_deopt_env_ = env;
1227 LEnvironment* lazy_deopt_env_;
1231 class LBoundsCheck final : public LTemplateInstruction<0, 2, 0> {
1233 LBoundsCheck(LOperand* index, LOperand* length) {
1235 inputs_[1] = length;
1238 LOperand* index() { return inputs_[0]; }
1239 LOperand* length() { return inputs_[1]; }
1241 DECLARE_CONCRETE_INSTRUCTION(BoundsCheck, "bounds-check")
1242 DECLARE_HYDROGEN_ACCESSOR(BoundsCheck)
1246 class LBitI final : public LTemplateInstruction<1, 2, 0> {
1248 LBitI(LOperand* left, LOperand* right) {
1253 LOperand* left() { return inputs_[0]; }
1254 LOperand* right() { return inputs_[1]; }
1256 Token::Value op() const { return hydrogen()->op(); }
1258 DECLARE_CONCRETE_INSTRUCTION(BitI, "bit-i")
1259 DECLARE_HYDROGEN_ACCESSOR(Bitwise)
1263 class LShiftI final : public LTemplateInstruction<1, 2, 0> {
1265 LShiftI(Token::Value op, LOperand* left, LOperand* right, bool can_deopt)
1266 : op_(op), can_deopt_(can_deopt) {
1271 Token::Value op() const { return op_; }
1272 LOperand* left() { return inputs_[0]; }
1273 LOperand* right() { return inputs_[1]; }
1274 bool can_deopt() const { return can_deopt_; }
1276 DECLARE_CONCRETE_INSTRUCTION(ShiftI, "shift-i")
1284 class LSubI final : public LTemplateInstruction<1, 2, 0> {
1286 LSubI(LOperand* left, LOperand* right) {
1291 LOperand* left() { return inputs_[0]; }
1292 LOperand* right() { return inputs_[1]; }
1294 DECLARE_CONCRETE_INSTRUCTION(SubI, "sub-i")
1295 DECLARE_HYDROGEN_ACCESSOR(Sub)
1299 class LRSubI final : public LTemplateInstruction<1, 2, 0> {
1301 LRSubI(LOperand* left, LOperand* right) {
1306 LOperand* left() { return inputs_[0]; }
1307 LOperand* right() { return inputs_[1]; }
1309 DECLARE_CONCRETE_INSTRUCTION(RSubI, "rsub-i")
1310 DECLARE_HYDROGEN_ACCESSOR(Sub)
1314 class LConstantI final : public LTemplateInstruction<1, 0, 0> {
1316 DECLARE_CONCRETE_INSTRUCTION(ConstantI, "constant-i")
1317 DECLARE_HYDROGEN_ACCESSOR(Constant)
1319 int32_t value() const { return hydrogen()->Integer32Value(); }
1323 class LConstantS final : public LTemplateInstruction<1, 0, 0> {
1325 DECLARE_CONCRETE_INSTRUCTION(ConstantS, "constant-s")
1326 DECLARE_HYDROGEN_ACCESSOR(Constant)
1328 Smi* value() const { return Smi::FromInt(hydrogen()->Integer32Value()); }
1332 class LConstantD final : public LTemplateInstruction<1, 0, 0> {
1334 DECLARE_CONCRETE_INSTRUCTION(ConstantD, "constant-d")
1335 DECLARE_HYDROGEN_ACCESSOR(Constant)
1337 double value() const { return hydrogen()->DoubleValue(); }
1338 uint64_t bits() const { return hydrogen()->DoubleValueAsBits(); }
1342 class LConstantE final : public LTemplateInstruction<1, 0, 0> {
1344 DECLARE_CONCRETE_INSTRUCTION(ConstantE, "constant-e")
1345 DECLARE_HYDROGEN_ACCESSOR(Constant)
1347 ExternalReference value() const {
1348 return hydrogen()->ExternalReferenceValue();
1353 class LConstantT final : public LTemplateInstruction<1, 0, 0> {
1355 DECLARE_CONCRETE_INSTRUCTION(ConstantT, "constant-t")
1356 DECLARE_HYDROGEN_ACCESSOR(Constant)
1358 Handle<Object> value(Isolate* isolate) const {
1359 return hydrogen()->handle(isolate);
1364 class LBranch final : public LControlInstruction<1, 0> {
1366 explicit LBranch(LOperand* value) {
1370 LOperand* value() { return inputs_[0]; }
1372 DECLARE_CONCRETE_INSTRUCTION(Branch, "branch")
1373 DECLARE_HYDROGEN_ACCESSOR(Branch)
1375 void PrintDataTo(StringStream* stream) override;
1379 class LCmpMapAndBranch final : public LControlInstruction<1, 1> {
1381 LCmpMapAndBranch(LOperand* value, LOperand* temp) {
1386 LOperand* value() { return inputs_[0]; }
1387 LOperand* temp() { return temps_[0]; }
1389 DECLARE_CONCRETE_INSTRUCTION(CmpMapAndBranch, "cmp-map-and-branch")
1390 DECLARE_HYDROGEN_ACCESSOR(CompareMap)
1392 Handle<Map> map() const { return hydrogen()->map().handle(); }
1396 class LMapEnumLength final : public LTemplateInstruction<1, 1, 0> {
1398 explicit LMapEnumLength(LOperand* value) {
1402 LOperand* value() { return inputs_[0]; }
1404 DECLARE_CONCRETE_INSTRUCTION(MapEnumLength, "map-enum-length")
1408 class LDateField final : public LTemplateInstruction<1, 1, 1> {
1410 LDateField(LOperand* date, LOperand* temp, Smi* index) : index_(index) {
1415 LOperand* date() { return inputs_[0]; }
1416 LOperand* temp() { return temps_[0]; }
1417 Smi* index() const { return index_; }
1419 DECLARE_CONCRETE_INSTRUCTION(DateField, "date-field")
1420 DECLARE_HYDROGEN_ACCESSOR(DateField)
1427 class LSeqStringGetChar final : public LTemplateInstruction<1, 2, 0> {
1429 LSeqStringGetChar(LOperand* string, LOperand* index) {
1430 inputs_[0] = string;
1434 LOperand* string() const { return inputs_[0]; }
1435 LOperand* index() const { return inputs_[1]; }
1437 DECLARE_CONCRETE_INSTRUCTION(SeqStringGetChar, "seq-string-get-char")
1438 DECLARE_HYDROGEN_ACCESSOR(SeqStringGetChar)
1442 class LSeqStringSetChar final : public LTemplateInstruction<1, 4, 0> {
1444 LSeqStringSetChar(LOperand* context,
1448 inputs_[0] = context;
1449 inputs_[1] = string;
1454 LOperand* string() { return inputs_[1]; }
1455 LOperand* index() { return inputs_[2]; }
1456 LOperand* value() { return inputs_[3]; }
1458 DECLARE_CONCRETE_INSTRUCTION(SeqStringSetChar, "seq-string-set-char")
1459 DECLARE_HYDROGEN_ACCESSOR(SeqStringSetChar)
1463 class LAddI final : public LTemplateInstruction<1, 2, 0> {
1465 LAddI(LOperand* left, LOperand* right) {
1470 LOperand* left() { return inputs_[0]; }
1471 LOperand* right() { return inputs_[1]; }
1473 DECLARE_CONCRETE_INSTRUCTION(AddI, "add-i")
1474 DECLARE_HYDROGEN_ACCESSOR(Add)
1478 class LMathMinMax final : public LTemplateInstruction<1, 2, 0> {
1480 LMathMinMax(LOperand* left, LOperand* right) {
1485 LOperand* left() { return inputs_[0]; }
1486 LOperand* right() { return inputs_[1]; }
1488 DECLARE_CONCRETE_INSTRUCTION(MathMinMax, "math-min-max")
1489 DECLARE_HYDROGEN_ACCESSOR(MathMinMax)
1493 class LPower final : public LTemplateInstruction<1, 2, 0> {
1495 LPower(LOperand* left, LOperand* right) {
1500 LOperand* left() { return inputs_[0]; }
1501 LOperand* right() { return inputs_[1]; }
1503 DECLARE_CONCRETE_INSTRUCTION(Power, "power")
1504 DECLARE_HYDROGEN_ACCESSOR(Power)
1508 class LArithmeticD final : public LTemplateInstruction<1, 2, 0> {
1510 LArithmeticD(Token::Value op, LOperand* left, LOperand* right)
1516 Token::Value op() const { return op_; }
1517 LOperand* left() { return inputs_[0]; }
1518 LOperand* right() { return inputs_[1]; }
1520 Opcode opcode() const override { return LInstruction::kArithmeticD; }
1521 void CompileToNative(LCodeGen* generator) override;
1522 const char* Mnemonic() const override;
1529 class LArithmeticT final : public LTemplateInstruction<1, 3, 0> {
1531 LArithmeticT(Token::Value op,
1536 inputs_[0] = context;
1541 LOperand* context() { return inputs_[0]; }
1542 LOperand* left() { return inputs_[1]; }
1543 LOperand* right() { return inputs_[2]; }
1544 Token::Value op() const { return op_; }
1546 Opcode opcode() const override { return LInstruction::kArithmeticT; }
1547 void CompileToNative(LCodeGen* generator) override;
1548 const char* Mnemonic() const override;
1550 DECLARE_HYDROGEN_ACCESSOR(BinaryOperation)
1552 LanguageMode language_mode() { return hydrogen()->language_mode(); }
1559 class LReturn final : public LTemplateInstruction<0, 3, 0> {
1561 LReturn(LOperand* value, LOperand* context, LOperand* parameter_count) {
1563 inputs_[1] = context;
1564 inputs_[2] = parameter_count;
1567 LOperand* value() { return inputs_[0]; }
1569 bool has_constant_parameter_count() {
1570 return parameter_count()->IsConstantOperand();
1572 LConstantOperand* constant_parameter_count() {
1573 DCHECK(has_constant_parameter_count());
1574 return LConstantOperand::cast(parameter_count());
1576 LOperand* parameter_count() { return inputs_[2]; }
1578 DECLARE_CONCRETE_INSTRUCTION(Return, "return")
1582 class LLoadNamedField final : public LTemplateInstruction<1, 1, 0> {
1584 explicit LLoadNamedField(LOperand* object) {
1585 inputs_[0] = object;
1588 LOperand* object() { return inputs_[0]; }
1590 DECLARE_CONCRETE_INSTRUCTION(LoadNamedField, "load-named-field")
1591 DECLARE_HYDROGEN_ACCESSOR(LoadNamedField)
1595 class LLoadNamedGeneric final : public LTemplateInstruction<1, 2, 1> {
1597 LLoadNamedGeneric(LOperand* context, LOperand* object, LOperand* vector) {
1598 inputs_[0] = context;
1599 inputs_[1] = object;
1603 LOperand* context() { return inputs_[0]; }
1604 LOperand* object() { return inputs_[1]; }
1605 LOperand* temp_vector() { return temps_[0]; }
1607 DECLARE_CONCRETE_INSTRUCTION(LoadNamedGeneric, "load-named-generic")
1608 DECLARE_HYDROGEN_ACCESSOR(LoadNamedGeneric)
1610 Handle<Object> name() const { return hydrogen()->name(); }
1614 class LLoadFunctionPrototype final : public LTemplateInstruction<1, 1, 0> {
1616 explicit LLoadFunctionPrototype(LOperand* function) {
1617 inputs_[0] = function;
1620 LOperand* function() { return inputs_[0]; }
1622 DECLARE_CONCRETE_INSTRUCTION(LoadFunctionPrototype, "load-function-prototype")
1623 DECLARE_HYDROGEN_ACCESSOR(LoadFunctionPrototype)
1627 class LLoadRoot final : public LTemplateInstruction<1, 0, 0> {
1629 DECLARE_CONCRETE_INSTRUCTION(LoadRoot, "load-root")
1630 DECLARE_HYDROGEN_ACCESSOR(LoadRoot)
1632 Heap::RootListIndex index() const { return hydrogen()->index(); }
1636 class LLoadKeyed final : public LTemplateInstruction<1, 2, 0> {
1638 LLoadKeyed(LOperand* elements, LOperand* key) {
1639 inputs_[0] = elements;
1643 LOperand* elements() { return inputs_[0]; }
1644 LOperand* key() { return inputs_[1]; }
1645 ElementsKind elements_kind() const {
1646 return hydrogen()->elements_kind();
1648 bool is_external() const {
1649 return hydrogen()->is_external();
1651 bool is_fixed_typed_array() const {
1652 return hydrogen()->is_fixed_typed_array();
1654 bool is_typed_elements() const {
1655 return is_external() || is_fixed_typed_array();
1658 DECLARE_CONCRETE_INSTRUCTION(LoadKeyed, "load-keyed")
1659 DECLARE_HYDROGEN_ACCESSOR(LoadKeyed)
1661 void PrintDataTo(StringStream* stream) override;
1662 uint32_t base_offset() const { return hydrogen()->base_offset(); }
1666 class LLoadKeyedGeneric final : public LTemplateInstruction<1, 3, 1> {
1668 LLoadKeyedGeneric(LOperand* context, LOperand* object, LOperand* key,
1670 inputs_[0] = context;
1671 inputs_[1] = object;
1676 LOperand* context() { return inputs_[0]; }
1677 LOperand* object() { return inputs_[1]; }
1678 LOperand* key() { return inputs_[2]; }
1679 LOperand* temp_vector() { return temps_[0]; }
1681 DECLARE_CONCRETE_INSTRUCTION(LoadKeyedGeneric, "load-keyed-generic")
1682 DECLARE_HYDROGEN_ACCESSOR(LoadKeyedGeneric)
1686 class LLoadGlobalGeneric final : public LTemplateInstruction<1, 2, 1> {
1688 LLoadGlobalGeneric(LOperand* context, LOperand* global_object,
1690 inputs_[0] = context;
1691 inputs_[1] = global_object;
1695 LOperand* context() { return inputs_[0]; }
1696 LOperand* global_object() { return inputs_[1]; }
1697 LOperand* temp_vector() { return temps_[0]; }
1699 DECLARE_CONCRETE_INSTRUCTION(LoadGlobalGeneric, "load-global-generic")
1700 DECLARE_HYDROGEN_ACCESSOR(LoadGlobalGeneric)
1702 Handle<Object> name() const { return hydrogen()->name(); }
1703 bool for_typeof() const { return hydrogen()->for_typeof(); }
1707 class LLoadContextSlot final : public LTemplateInstruction<1, 1, 0> {
1709 explicit LLoadContextSlot(LOperand* context) {
1710 inputs_[0] = context;
1713 LOperand* context() { return inputs_[0]; }
1715 DECLARE_CONCRETE_INSTRUCTION(LoadContextSlot, "load-context-slot")
1716 DECLARE_HYDROGEN_ACCESSOR(LoadContextSlot)
1718 int slot_index() { return hydrogen()->slot_index(); }
1720 void PrintDataTo(StringStream* stream) override;
1724 class LStoreContextSlot final : public LTemplateInstruction<0, 2, 0> {
1726 LStoreContextSlot(LOperand* context, LOperand* value) {
1727 inputs_[0] = context;
1731 LOperand* context() { return inputs_[0]; }
1732 LOperand* value() { return inputs_[1]; }
1734 DECLARE_CONCRETE_INSTRUCTION(StoreContextSlot, "store-context-slot")
1735 DECLARE_HYDROGEN_ACCESSOR(StoreContextSlot)
1737 int slot_index() { return hydrogen()->slot_index(); }
1739 void PrintDataTo(StringStream* stream) override;
1743 class LPushArgument final : public LTemplateInstruction<0, 1, 0> {
1745 explicit LPushArgument(LOperand* value) {
1749 LOperand* value() { return inputs_[0]; }
1751 DECLARE_CONCRETE_INSTRUCTION(PushArgument, "push-argument")
1755 class LDrop final : public LTemplateInstruction<0, 0, 0> {
1757 explicit LDrop(int count) : count_(count) { }
1759 int count() const { return count_; }
1761 DECLARE_CONCRETE_INSTRUCTION(Drop, "drop")
1768 class LStoreCodeEntry final : public LTemplateInstruction<0, 2, 0> {
1770 LStoreCodeEntry(LOperand* function, LOperand* code_object) {
1771 inputs_[0] = function;
1772 inputs_[1] = code_object;
1775 LOperand* function() { return inputs_[0]; }
1776 LOperand* code_object() { return inputs_[1]; }
1778 void PrintDataTo(StringStream* stream) override;
1780 DECLARE_CONCRETE_INSTRUCTION(StoreCodeEntry, "store-code-entry")
1781 DECLARE_HYDROGEN_ACCESSOR(StoreCodeEntry)
1785 class LInnerAllocatedObject final : public LTemplateInstruction<1, 2, 0> {
1787 LInnerAllocatedObject(LOperand* base_object, LOperand* offset) {
1788 inputs_[0] = base_object;
1789 inputs_[1] = offset;
1792 LOperand* base_object() const { return inputs_[0]; }
1793 LOperand* offset() const { return inputs_[1]; }
1795 void PrintDataTo(StringStream* stream) override;
1797 DECLARE_CONCRETE_INSTRUCTION(InnerAllocatedObject, "inner-allocated-object")
1801 class LThisFunction final : public LTemplateInstruction<1, 0, 0> {
1803 DECLARE_CONCRETE_INSTRUCTION(ThisFunction, "this-function")
1804 DECLARE_HYDROGEN_ACCESSOR(ThisFunction)
1808 class LContext final : public LTemplateInstruction<1, 0, 0> {
1810 DECLARE_CONCRETE_INSTRUCTION(Context, "context")
1811 DECLARE_HYDROGEN_ACCESSOR(Context)
1815 class LDeclareGlobals final : public LTemplateInstruction<0, 1, 0> {
1817 explicit LDeclareGlobals(LOperand* context) {
1818 inputs_[0] = context;
1821 LOperand* context() { return inputs_[0]; }
1823 DECLARE_CONCRETE_INSTRUCTION(DeclareGlobals, "declare-globals")
1824 DECLARE_HYDROGEN_ACCESSOR(DeclareGlobals)
1828 class LCallJSFunction final : public LTemplateInstruction<1, 1, 0> {
1830 explicit LCallJSFunction(LOperand* function) {
1831 inputs_[0] = function;
1834 LOperand* function() { return inputs_[0]; }
1836 DECLARE_CONCRETE_INSTRUCTION(CallJSFunction, "call-js-function")
1837 DECLARE_HYDROGEN_ACCESSOR(CallJSFunction)
1839 void PrintDataTo(StringStream* stream) override;
1841 int arity() const { return hydrogen()->argument_count() - 1; }
1845 class LCallWithDescriptor final : public LTemplateResultInstruction<1> {
1847 LCallWithDescriptor(CallInterfaceDescriptor descriptor,
1848 const ZoneList<LOperand*>& operands, Zone* zone)
1849 : descriptor_(descriptor),
1850 inputs_(descriptor.GetRegisterParameterCount() + 1, zone) {
1851 DCHECK(descriptor.GetRegisterParameterCount() + 1 == operands.length());
1852 inputs_.AddAll(operands, zone);
1855 LOperand* target() const { return inputs_[0]; }
1857 const CallInterfaceDescriptor descriptor() { return descriptor_; }
1859 DECLARE_HYDROGEN_ACCESSOR(CallWithDescriptor)
1862 DECLARE_CONCRETE_INSTRUCTION(CallWithDescriptor, "call-with-descriptor")
1864 void PrintDataTo(StringStream* stream) override;
1866 int arity() const { return hydrogen()->argument_count() - 1; }
1868 CallInterfaceDescriptor descriptor_;
1869 ZoneList<LOperand*> inputs_;
1871 // Iterator support.
1872 int InputCount() final { return inputs_.length(); }
1873 LOperand* InputAt(int i) final { return inputs_[i]; }
1875 int TempCount() final { return 0; }
1876 LOperand* TempAt(int i) final { return NULL; }
1880 class LInvokeFunction final : public LTemplateInstruction<1, 2, 0> {
1882 LInvokeFunction(LOperand* context, LOperand* function) {
1883 inputs_[0] = context;
1884 inputs_[1] = function;
1887 LOperand* context() { return inputs_[0]; }
1888 LOperand* function() { return inputs_[1]; }
1890 DECLARE_CONCRETE_INSTRUCTION(InvokeFunction, "invoke-function")
1891 DECLARE_HYDROGEN_ACCESSOR(InvokeFunction)
1893 void PrintDataTo(StringStream* stream) override;
1895 int arity() const { return hydrogen()->argument_count() - 1; }
1899 class LCallFunction final : public LTemplateInstruction<1, 2, 2> {
1901 LCallFunction(LOperand* context, LOperand* function, LOperand* slot,
1903 inputs_[0] = context;
1904 inputs_[1] = function;
1909 LOperand* context() { return inputs_[0]; }
1910 LOperand* function() { return inputs_[1]; }
1911 LOperand* temp_slot() { return temps_[0]; }
1912 LOperand* temp_vector() { return temps_[1]; }
1914 DECLARE_CONCRETE_INSTRUCTION(CallFunction, "call-function")
1915 DECLARE_HYDROGEN_ACCESSOR(CallFunction)
1917 int arity() const { return hydrogen()->argument_count() - 1; }
1918 void PrintDataTo(StringStream* stream) override;
1922 class LCallNew final : public LTemplateInstruction<1, 2, 0> {
1924 LCallNew(LOperand* context, LOperand* constructor) {
1925 inputs_[0] = context;
1926 inputs_[1] = constructor;
1929 LOperand* context() { return inputs_[0]; }
1930 LOperand* constructor() { return inputs_[1]; }
1932 DECLARE_CONCRETE_INSTRUCTION(CallNew, "call-new")
1933 DECLARE_HYDROGEN_ACCESSOR(CallNew)
1935 void PrintDataTo(StringStream* stream) override;
1937 int arity() const { return hydrogen()->argument_count() - 1; }
1941 class LCallNewArray final : public LTemplateInstruction<1, 2, 0> {
1943 LCallNewArray(LOperand* context, LOperand* constructor) {
1944 inputs_[0] = context;
1945 inputs_[1] = constructor;
1948 LOperand* context() { return inputs_[0]; }
1949 LOperand* constructor() { return inputs_[1]; }
1951 DECLARE_CONCRETE_INSTRUCTION(CallNewArray, "call-new-array")
1952 DECLARE_HYDROGEN_ACCESSOR(CallNewArray)
1954 void PrintDataTo(StringStream* stream) override;
1956 int arity() const { return hydrogen()->argument_count() - 1; }
1960 class LCallRuntime final : public LTemplateInstruction<1, 1, 0> {
1962 explicit LCallRuntime(LOperand* context) {
1963 inputs_[0] = context;
1966 LOperand* context() { return inputs_[0]; }
1968 DECLARE_CONCRETE_INSTRUCTION(CallRuntime, "call-runtime")
1969 DECLARE_HYDROGEN_ACCESSOR(CallRuntime)
1971 bool ClobbersDoubleRegisters(Isolate* isolate) const override {
1972 return save_doubles() == kDontSaveFPRegs;
1975 const Runtime::Function* function() const { return hydrogen()->function(); }
1976 int arity() const { return hydrogen()->argument_count(); }
1977 SaveFPRegsMode save_doubles() const { return hydrogen()->save_doubles(); }
1981 class LInteger32ToDouble final : public LTemplateInstruction<1, 1, 0> {
1983 explicit LInteger32ToDouble(LOperand* value) {
1987 LOperand* value() { return inputs_[0]; }
1989 DECLARE_CONCRETE_INSTRUCTION(Integer32ToDouble, "int32-to-double")
1993 class LUint32ToDouble final : public LTemplateInstruction<1, 1, 0> {
1995 explicit LUint32ToDouble(LOperand* value) {
1999 LOperand* value() { return inputs_[0]; }
2001 DECLARE_CONCRETE_INSTRUCTION(Uint32ToDouble, "uint32-to-double")
2005 class LNumberTagI final : public LTemplateInstruction<1, 1, 2> {
2007 LNumberTagI(LOperand* value, LOperand* temp1, LOperand* temp2) {
2013 LOperand* value() { return inputs_[0]; }
2014 LOperand* temp1() { return temps_[0]; }
2015 LOperand* temp2() { return temps_[1]; }
2017 DECLARE_CONCRETE_INSTRUCTION(NumberTagI, "number-tag-i")
2021 class LNumberTagU final : public LTemplateInstruction<1, 1, 2> {
2023 LNumberTagU(LOperand* value, LOperand* temp1, LOperand* temp2) {
2029 LOperand* value() { return inputs_[0]; }
2030 LOperand* temp1() { return temps_[0]; }
2031 LOperand* temp2() { return temps_[1]; }
2033 DECLARE_CONCRETE_INSTRUCTION(NumberTagU, "number-tag-u")
2037 class LNumberTagD final : public LTemplateInstruction<1, 1, 2> {
2039 LNumberTagD(LOperand* value, LOperand* temp, LOperand* temp2) {
2045 LOperand* value() { return inputs_[0]; }
2046 LOperand* temp() { return temps_[0]; }
2047 LOperand* temp2() { return temps_[1]; }
2049 DECLARE_CONCRETE_INSTRUCTION(NumberTagD, "number-tag-d")
2050 DECLARE_HYDROGEN_ACCESSOR(Change)
2054 class LDoubleToSmi final : public LTemplateInstruction<1, 1, 0> {
2056 explicit LDoubleToSmi(LOperand* value) {
2060 LOperand* value() { return inputs_[0]; }
2062 DECLARE_CONCRETE_INSTRUCTION(DoubleToSmi, "double-to-smi")
2063 DECLARE_HYDROGEN_ACCESSOR(UnaryOperation)
2065 bool truncating() { return hydrogen()->CanTruncateToInt32(); }
2069 // Sometimes truncating conversion from a tagged value to an int32.
2070 class LDoubleToI final : public LTemplateInstruction<1, 1, 0> {
2072 explicit LDoubleToI(LOperand* value) {
2076 LOperand* value() { return inputs_[0]; }
2078 DECLARE_CONCRETE_INSTRUCTION(DoubleToI, "double-to-i")
2079 DECLARE_HYDROGEN_ACCESSOR(UnaryOperation)
2081 bool truncating() { return hydrogen()->CanTruncateToInt32(); }
2085 // Truncating conversion from a tagged value to an int32.
2086 class LTaggedToI final : public LTemplateInstruction<1, 1, 2> {
2088 LTaggedToI(LOperand* value,
2096 LOperand* value() { return inputs_[0]; }
2097 LOperand* temp() { return temps_[0]; }
2098 LOperand* temp2() { return temps_[1]; }
2100 DECLARE_CONCRETE_INSTRUCTION(TaggedToI, "tagged-to-i")
2101 DECLARE_HYDROGEN_ACCESSOR(Change)
2103 bool truncating() { return hydrogen()->CanTruncateToInt32(); }
2107 class LSmiTag final : public LTemplateInstruction<1, 1, 0> {
2109 explicit LSmiTag(LOperand* value) {
2113 LOperand* value() { return inputs_[0]; }
2115 DECLARE_CONCRETE_INSTRUCTION(SmiTag, "smi-tag")
2116 DECLARE_HYDROGEN_ACCESSOR(Change)
2120 class LNumberUntagD final : public LTemplateInstruction<1, 1, 0> {
2122 explicit LNumberUntagD(LOperand* value) {
2126 LOperand* value() { return inputs_[0]; }
2128 DECLARE_CONCRETE_INSTRUCTION(NumberUntagD, "double-untag")
2129 DECLARE_HYDROGEN_ACCESSOR(Change)
2133 class LSmiUntag final : public LTemplateInstruction<1, 1, 0> {
2135 LSmiUntag(LOperand* value, bool needs_check)
2136 : needs_check_(needs_check) {
2140 LOperand* value() { return inputs_[0]; }
2141 bool needs_check() const { return needs_check_; }
2143 DECLARE_CONCRETE_INSTRUCTION(SmiUntag, "smi-untag")
2150 class LStoreNamedField final : public LTemplateInstruction<0, 2, 1> {
2152 LStoreNamedField(LOperand* object, LOperand* value, LOperand* temp) {
2153 inputs_[0] = object;
2158 LOperand* object() { return inputs_[0]; }
2159 LOperand* value() { return inputs_[1]; }
2160 LOperand* temp() { return temps_[0]; }
2162 DECLARE_CONCRETE_INSTRUCTION(StoreNamedField, "store-named-field")
2163 DECLARE_HYDROGEN_ACCESSOR(StoreNamedField)
2165 void PrintDataTo(StringStream* stream) override;
2167 Representation representation() const {
2168 return hydrogen()->field_representation();
2173 class LStoreNamedGeneric final : public LTemplateInstruction<0, 3, 0> {
2175 LStoreNamedGeneric(LOperand* context, LOperand* object, LOperand* value) {
2176 inputs_[0] = context;
2177 inputs_[1] = object;
2181 LOperand* context() { return inputs_[0]; }
2182 LOperand* object() { return inputs_[1]; }
2183 LOperand* value() { return inputs_[2]; }
2185 DECLARE_CONCRETE_INSTRUCTION(StoreNamedGeneric, "store-named-generic")
2186 DECLARE_HYDROGEN_ACCESSOR(StoreNamedGeneric)
2188 void PrintDataTo(StringStream* stream) override;
2190 Handle<Object> name() const { return hydrogen()->name(); }
2191 LanguageMode language_mode() { return hydrogen()->language_mode(); }
2195 class LStoreKeyed final : public LTemplateInstruction<0, 3, 0> {
2197 LStoreKeyed(LOperand* object, LOperand* key, LOperand* value) {
2198 inputs_[0] = object;
2203 bool is_external() const { return hydrogen()->is_external(); }
2204 bool is_fixed_typed_array() const {
2205 return hydrogen()->is_fixed_typed_array();
2207 bool is_typed_elements() const {
2208 return is_external() || is_fixed_typed_array();
2210 LOperand* elements() { return inputs_[0]; }
2211 LOperand* key() { return inputs_[1]; }
2212 LOperand* value() { return inputs_[2]; }
2213 ElementsKind elements_kind() const {
2214 return hydrogen()->elements_kind();
2217 DECLARE_CONCRETE_INSTRUCTION(StoreKeyed, "store-keyed")
2218 DECLARE_HYDROGEN_ACCESSOR(StoreKeyed)
2220 void PrintDataTo(StringStream* stream) override;
2221 bool NeedsCanonicalization() {
2222 if (hydrogen()->value()->IsAdd() || hydrogen()->value()->IsSub() ||
2223 hydrogen()->value()->IsMul() || hydrogen()->value()->IsDiv()) {
2226 return hydrogen()->NeedsCanonicalization();
2228 uint32_t base_offset() const { return hydrogen()->base_offset(); }
2232 class LStoreKeyedGeneric final : public LTemplateInstruction<0, 4, 0> {
2234 LStoreKeyedGeneric(LOperand* context,
2238 inputs_[0] = context;
2244 LOperand* context() { return inputs_[0]; }
2245 LOperand* object() { return inputs_[1]; }
2246 LOperand* key() { return inputs_[2]; }
2247 LOperand* value() { return inputs_[3]; }
2249 DECLARE_CONCRETE_INSTRUCTION(StoreKeyedGeneric, "store-keyed-generic")
2250 DECLARE_HYDROGEN_ACCESSOR(StoreKeyedGeneric)
2252 void PrintDataTo(StringStream* stream) override;
2254 LanguageMode language_mode() { return hydrogen()->language_mode(); }
2258 class LTransitionElementsKind final : public LTemplateInstruction<0, 2, 1> {
2260 LTransitionElementsKind(LOperand* object,
2262 LOperand* new_map_temp) {
2263 inputs_[0] = object;
2264 inputs_[1] = context;
2265 temps_[0] = new_map_temp;
2268 LOperand* context() { return inputs_[1]; }
2269 LOperand* object() { return inputs_[0]; }
2270 LOperand* new_map_temp() { return temps_[0]; }
2272 DECLARE_CONCRETE_INSTRUCTION(TransitionElementsKind,
2273 "transition-elements-kind")
2274 DECLARE_HYDROGEN_ACCESSOR(TransitionElementsKind)
2276 void PrintDataTo(StringStream* stream) override;
2278 Handle<Map> original_map() { return hydrogen()->original_map().handle(); }
2279 Handle<Map> transitioned_map() {
2280 return hydrogen()->transitioned_map().handle();
2282 ElementsKind from_kind() { return hydrogen()->from_kind(); }
2283 ElementsKind to_kind() { return hydrogen()->to_kind(); }
2287 class LTrapAllocationMemento final : public LTemplateInstruction<0, 1, 1> {
2289 LTrapAllocationMemento(LOperand* object,
2291 inputs_[0] = object;
2295 LOperand* object() { return inputs_[0]; }
2296 LOperand* temp() { return temps_[0]; }
2298 DECLARE_CONCRETE_INSTRUCTION(TrapAllocationMemento,
2299 "trap-allocation-memento")
2303 class LMaybeGrowElements final : public LTemplateInstruction<1, 5, 0> {
2305 LMaybeGrowElements(LOperand* context, LOperand* object, LOperand* elements,
2306 LOperand* key, LOperand* current_capacity) {
2307 inputs_[0] = context;
2308 inputs_[1] = object;
2309 inputs_[2] = elements;
2311 inputs_[4] = current_capacity;
2314 LOperand* context() { return inputs_[0]; }
2315 LOperand* object() { return inputs_[1]; }
2316 LOperand* elements() { return inputs_[2]; }
2317 LOperand* key() { return inputs_[3]; }
2318 LOperand* current_capacity() { return inputs_[4]; }
2320 DECLARE_HYDROGEN_ACCESSOR(MaybeGrowElements)
2321 DECLARE_CONCRETE_INSTRUCTION(MaybeGrowElements, "maybe-grow-elements")
2325 class LStringAdd final : public LTemplateInstruction<1, 3, 0> {
2327 LStringAdd(LOperand* context, LOperand* left, LOperand* right) {
2328 inputs_[0] = context;
2333 LOperand* context() { return inputs_[0]; }
2334 LOperand* left() { return inputs_[1]; }
2335 LOperand* right() { return inputs_[2]; }
2337 DECLARE_CONCRETE_INSTRUCTION(StringAdd, "string-add")
2338 DECLARE_HYDROGEN_ACCESSOR(StringAdd)
2342 class LStringCharCodeAt final : public LTemplateInstruction<1, 3, 0> {
2344 LStringCharCodeAt(LOperand* context, LOperand* string, LOperand* index) {
2345 inputs_[0] = context;
2346 inputs_[1] = string;
2350 LOperand* context() { return inputs_[0]; }
2351 LOperand* string() { return inputs_[1]; }
2352 LOperand* index() { return inputs_[2]; }
2354 DECLARE_CONCRETE_INSTRUCTION(StringCharCodeAt, "string-char-code-at")
2355 DECLARE_HYDROGEN_ACCESSOR(StringCharCodeAt)
2359 class LStringCharFromCode final : public LTemplateInstruction<1, 2, 0> {
2361 explicit LStringCharFromCode(LOperand* context, LOperand* char_code) {
2362 inputs_[0] = context;
2363 inputs_[1] = char_code;
2366 LOperand* context() { return inputs_[0]; }
2367 LOperand* char_code() { return inputs_[1]; }
2369 DECLARE_CONCRETE_INSTRUCTION(StringCharFromCode, "string-char-from-code")
2370 DECLARE_HYDROGEN_ACCESSOR(StringCharFromCode)
2374 class LCheckValue final : public LTemplateInstruction<0, 1, 0> {
2376 explicit LCheckValue(LOperand* value) {
2380 LOperand* value() { return inputs_[0]; }
2382 DECLARE_CONCRETE_INSTRUCTION(CheckValue, "check-value")
2383 DECLARE_HYDROGEN_ACCESSOR(CheckValue)
2387 class LCheckArrayBufferNotNeutered final
2388 : public LTemplateInstruction<0, 1, 0> {
2390 explicit LCheckArrayBufferNotNeutered(LOperand* view) { inputs_[0] = view; }
2392 LOperand* view() { return inputs_[0]; }
2394 DECLARE_CONCRETE_INSTRUCTION(CheckArrayBufferNotNeutered,
2395 "check-array-buffer-not-neutered")
2396 DECLARE_HYDROGEN_ACCESSOR(CheckArrayBufferNotNeutered)
2400 class LCheckInstanceType final : public LTemplateInstruction<0, 1, 0> {
2402 explicit LCheckInstanceType(LOperand* value) {
2406 LOperand* value() { return inputs_[0]; }
2408 DECLARE_CONCRETE_INSTRUCTION(CheckInstanceType, "check-instance-type")
2409 DECLARE_HYDROGEN_ACCESSOR(CheckInstanceType)
2413 class LCheckMaps final : public LTemplateInstruction<0, 1, 0> {
2415 explicit LCheckMaps(LOperand* value = NULL) {
2419 LOperand* value() { return inputs_[0]; }
2421 DECLARE_CONCRETE_INSTRUCTION(CheckMaps, "check-maps")
2422 DECLARE_HYDROGEN_ACCESSOR(CheckMaps)
2426 class LCheckSmi final : public LTemplateInstruction<1, 1, 0> {
2428 explicit LCheckSmi(LOperand* value) {
2432 LOperand* value() { return inputs_[0]; }
2434 DECLARE_CONCRETE_INSTRUCTION(CheckSmi, "check-smi")
2438 class LCheckNonSmi final : public LTemplateInstruction<0, 1, 0> {
2440 explicit LCheckNonSmi(LOperand* value) {
2444 LOperand* value() { return inputs_[0]; }
2446 DECLARE_CONCRETE_INSTRUCTION(CheckNonSmi, "check-non-smi")
2447 DECLARE_HYDROGEN_ACCESSOR(CheckHeapObject)
2451 class LClampDToUint8 final : public LTemplateInstruction<1, 1, 0> {
2453 explicit LClampDToUint8(LOperand* unclamped) {
2454 inputs_[0] = unclamped;
2457 LOperand* unclamped() { return inputs_[0]; }
2459 DECLARE_CONCRETE_INSTRUCTION(ClampDToUint8, "clamp-d-to-uint8")
2463 class LClampIToUint8 final : public LTemplateInstruction<1, 1, 0> {
2465 explicit LClampIToUint8(LOperand* unclamped) {
2466 inputs_[0] = unclamped;
2469 LOperand* unclamped() { return inputs_[0]; }
2471 DECLARE_CONCRETE_INSTRUCTION(ClampIToUint8, "clamp-i-to-uint8")
2475 class LClampTToUint8 final : public LTemplateInstruction<1, 1, 1> {
2477 LClampTToUint8(LOperand* unclamped, LOperand* temp) {
2478 inputs_[0] = unclamped;
2482 LOperand* unclamped() { return inputs_[0]; }
2483 LOperand* temp() { return temps_[0]; }
2485 DECLARE_CONCRETE_INSTRUCTION(ClampTToUint8, "clamp-t-to-uint8")
2489 class LDoubleBits final : public LTemplateInstruction<1, 1, 0> {
2491 explicit LDoubleBits(LOperand* value) {
2495 LOperand* value() { return inputs_[0]; }
2497 DECLARE_CONCRETE_INSTRUCTION(DoubleBits, "double-bits")
2498 DECLARE_HYDROGEN_ACCESSOR(DoubleBits)
2502 class LConstructDouble final : public LTemplateInstruction<1, 2, 0> {
2504 LConstructDouble(LOperand* hi, LOperand* lo) {
2509 LOperand* hi() { return inputs_[0]; }
2510 LOperand* lo() { return inputs_[1]; }
2512 DECLARE_CONCRETE_INSTRUCTION(ConstructDouble, "construct-double")
2516 class LAllocate final : public LTemplateInstruction<1, 2, 2> {
2518 LAllocate(LOperand* context,
2522 inputs_[0] = context;
2528 LOperand* context() { return inputs_[0]; }
2529 LOperand* size() { return inputs_[1]; }
2530 LOperand* temp1() { return temps_[0]; }
2531 LOperand* temp2() { return temps_[1]; }
2533 DECLARE_CONCRETE_INSTRUCTION(Allocate, "allocate")
2534 DECLARE_HYDROGEN_ACCESSOR(Allocate)
2538 class LRegExpLiteral final : public LTemplateInstruction<1, 1, 0> {
2540 explicit LRegExpLiteral(LOperand* context) {
2541 inputs_[0] = context;
2544 LOperand* context() { return inputs_[0]; }
2546 DECLARE_CONCRETE_INSTRUCTION(RegExpLiteral, "regexp-literal")
2547 DECLARE_HYDROGEN_ACCESSOR(RegExpLiteral)
2551 class LFunctionLiteral final : public LTemplateInstruction<1, 1, 0> {
2553 explicit LFunctionLiteral(LOperand* context) {
2554 inputs_[0] = context;
2557 LOperand* context() { return inputs_[0]; }
2559 DECLARE_CONCRETE_INSTRUCTION(FunctionLiteral, "function-literal")
2560 DECLARE_HYDROGEN_ACCESSOR(FunctionLiteral)
2564 class LToFastProperties final : public LTemplateInstruction<1, 1, 0> {
2566 explicit LToFastProperties(LOperand* value) {
2570 LOperand* value() { return inputs_[0]; }
2572 DECLARE_CONCRETE_INSTRUCTION(ToFastProperties, "to-fast-properties")
2573 DECLARE_HYDROGEN_ACCESSOR(ToFastProperties)
2577 class LTypeof final : public LTemplateInstruction<1, 2, 0> {
2579 LTypeof(LOperand* context, LOperand* value) {
2580 inputs_[0] = context;
2584 LOperand* context() { return inputs_[0]; }
2585 LOperand* value() { return inputs_[1]; }
2587 DECLARE_CONCRETE_INSTRUCTION(Typeof, "typeof")
2591 class LTypeofIsAndBranch final : public LControlInstruction<1, 0> {
2593 explicit LTypeofIsAndBranch(LOperand* value) {
2597 LOperand* value() { return inputs_[0]; }
2599 DECLARE_CONCRETE_INSTRUCTION(TypeofIsAndBranch, "typeof-is-and-branch")
2600 DECLARE_HYDROGEN_ACCESSOR(TypeofIsAndBranch)
2602 Handle<String> type_literal() { return hydrogen()->type_literal(); }
2604 void PrintDataTo(StringStream* stream) override;
2608 class LIsConstructCallAndBranch final : public LControlInstruction<0, 1> {
2610 explicit LIsConstructCallAndBranch(LOperand* temp) {
2614 LOperand* temp() { return temps_[0]; }
2616 DECLARE_CONCRETE_INSTRUCTION(IsConstructCallAndBranch,
2617 "is-construct-call-and-branch")
2621 class LOsrEntry final : public LTemplateInstruction<0, 0, 0> {
2625 bool HasInterestingComment(LCodeGen* gen) const override { return false; }
2626 DECLARE_CONCRETE_INSTRUCTION(OsrEntry, "osr-entry")
2630 class LStackCheck final : public LTemplateInstruction<0, 1, 0> {
2632 explicit LStackCheck(LOperand* context) {
2633 inputs_[0] = context;
2636 LOperand* context() { return inputs_[0]; }
2638 DECLARE_CONCRETE_INSTRUCTION(StackCheck, "stack-check")
2639 DECLARE_HYDROGEN_ACCESSOR(StackCheck)
2641 Label* done_label() { return &done_label_; }
2648 class LForInPrepareMap final : public LTemplateInstruction<1, 2, 0> {
2650 LForInPrepareMap(LOperand* context, LOperand* object) {
2651 inputs_[0] = context;
2652 inputs_[1] = object;
2655 LOperand* context() { return inputs_[0]; }
2656 LOperand* object() { return inputs_[1]; }
2658 DECLARE_CONCRETE_INSTRUCTION(ForInPrepareMap, "for-in-prepare-map")
2662 class LForInCacheArray final : public LTemplateInstruction<1, 1, 0> {
2664 explicit LForInCacheArray(LOperand* map) {
2668 LOperand* map() { return inputs_[0]; }
2670 DECLARE_CONCRETE_INSTRUCTION(ForInCacheArray, "for-in-cache-array")
2673 return HForInCacheArray::cast(this->hydrogen_value())->idx();
2678 class LCheckMapValue final : public LTemplateInstruction<0, 2, 0> {
2680 LCheckMapValue(LOperand* value, LOperand* map) {
2685 LOperand* value() { return inputs_[0]; }
2686 LOperand* map() { return inputs_[1]; }
2688 DECLARE_CONCRETE_INSTRUCTION(CheckMapValue, "check-map-value")
2692 class LLoadFieldByIndex final : public LTemplateInstruction<1, 2, 0> {
2694 LLoadFieldByIndex(LOperand* object, LOperand* index) {
2695 inputs_[0] = object;
2699 LOperand* object() { return inputs_[0]; }
2700 LOperand* index() { return inputs_[1]; }
2702 DECLARE_CONCRETE_INSTRUCTION(LoadFieldByIndex, "load-field-by-index")
2706 class LStoreFrameContext: public LTemplateInstruction<0, 1, 0> {
2708 explicit LStoreFrameContext(LOperand* context) {
2709 inputs_[0] = context;
2712 LOperand* context() { return inputs_[0]; }
2714 DECLARE_CONCRETE_INSTRUCTION(StoreFrameContext, "store-frame-context")
2718 class LAllocateBlockContext: public LTemplateInstruction<1, 2, 0> {
2720 LAllocateBlockContext(LOperand* context, LOperand* function) {
2721 inputs_[0] = context;
2722 inputs_[1] = function;
2725 LOperand* context() { return inputs_[0]; }
2726 LOperand* function() { return inputs_[1]; }
2728 Handle<ScopeInfo> scope_info() { return hydrogen()->scope_info(); }
2730 DECLARE_CONCRETE_INSTRUCTION(AllocateBlockContext, "allocate-block-context")
2731 DECLARE_HYDROGEN_ACCESSOR(AllocateBlockContext)
2735 class LChunkBuilder;
2736 class LPlatformChunk final : public LChunk {
2738 LPlatformChunk(CompilationInfo* info, HGraph* graph)
2739 : LChunk(info, graph) { }
2741 int GetNextSpillIndex(RegisterKind kind);
2742 LOperand* GetNextSpillSlot(RegisterKind kind);
2746 class LChunkBuilder final : public LChunkBuilderBase {
2748 LChunkBuilder(CompilationInfo* info, HGraph* graph, LAllocator* allocator)
2749 : LChunkBuilderBase(info, graph),
2750 current_instruction_(NULL),
2751 current_block_(NULL),
2753 allocator_(allocator) {}
2755 // Build the sequence for the graph.
2756 LPlatformChunk* Build();
2758 // Declare methods that deal with the individual node types.
2759 #define DECLARE_DO(type) LInstruction* Do##type(H##type* node);
2760 HYDROGEN_CONCRETE_INSTRUCTION_LIST(DECLARE_DO)
2763 LInstruction* DoMultiplyAdd(HMul* mul, HValue* addend);
2764 LInstruction* DoMultiplySub(HValue* minuend, HMul* mul);
2765 LInstruction* DoRSub(HSub* instr);
2767 static bool HasMagicNumberForDivisor(int32_t divisor);
2769 LInstruction* DoMathFloor(HUnaryMathOperation* instr);
2770 LInstruction* DoMathRound(HUnaryMathOperation* instr);
2771 LInstruction* DoMathFround(HUnaryMathOperation* instr);
2772 LInstruction* DoMathAbs(HUnaryMathOperation* instr);
2773 LInstruction* DoMathLog(HUnaryMathOperation* instr);
2774 LInstruction* DoMathExp(HUnaryMathOperation* instr);
2775 LInstruction* DoMathSqrt(HUnaryMathOperation* instr);
2776 LInstruction* DoMathPowHalf(HUnaryMathOperation* instr);
2777 LInstruction* DoMathClz32(HUnaryMathOperation* instr);
2778 LInstruction* DoDivByPowerOf2I(HDiv* instr);
2779 LInstruction* DoDivByConstI(HDiv* instr);
2780 LInstruction* DoDivI(HDiv* instr);
2781 LInstruction* DoModByPowerOf2I(HMod* instr);
2782 LInstruction* DoModByConstI(HMod* instr);
2783 LInstruction* DoModI(HMod* instr);
2784 LInstruction* DoFlooringDivByPowerOf2I(HMathFloorOfDiv* instr);
2785 LInstruction* DoFlooringDivByConstI(HMathFloorOfDiv* instr);
2786 LInstruction* DoFlooringDivI(HMathFloorOfDiv* instr);
2789 // Methods for getting operands for Use / Define / Temp.
2790 LUnallocated* ToUnallocated(Register reg);
2791 LUnallocated* ToUnallocated(DoubleRegister reg);
2793 // Methods for setting up define-use relationships.
2794 MUST_USE_RESULT LOperand* Use(HValue* value, LUnallocated* operand);
2795 MUST_USE_RESULT LOperand* UseFixed(HValue* value, Register fixed_register);
2796 MUST_USE_RESULT LOperand* UseFixedDouble(HValue* value,
2797 DoubleRegister fixed_register);
2799 // A value that is guaranteed to be allocated to a register.
2800 // Operand created by UseRegister is guaranteed to be live until the end of
2801 // instruction. This means that register allocator will not reuse it's
2802 // register for any other operand inside instruction.
2803 // Operand created by UseRegisterAtStart is guaranteed to be live only at
2804 // instruction start. Register allocator is free to assign the same register
2805 // to some other operand used inside instruction (i.e. temporary or
2807 MUST_USE_RESULT LOperand* UseRegister(HValue* value);
2808 MUST_USE_RESULT LOperand* UseRegisterAtStart(HValue* value);
2810 // An input operand in a register that may be trashed.
2811 MUST_USE_RESULT LOperand* UseTempRegister(HValue* value);
2813 // An input operand in a register or stack slot.
2814 MUST_USE_RESULT LOperand* Use(HValue* value);
2815 MUST_USE_RESULT LOperand* UseAtStart(HValue* value);
2817 // An input operand in a register, stack slot or a constant operand.
2818 MUST_USE_RESULT LOperand* UseOrConstant(HValue* value);
2819 MUST_USE_RESULT LOperand* UseOrConstantAtStart(HValue* value);
2821 // An input operand in a register or a constant operand.
2822 MUST_USE_RESULT LOperand* UseRegisterOrConstant(HValue* value);
2823 MUST_USE_RESULT LOperand* UseRegisterOrConstantAtStart(HValue* value);
2825 // An input operand in a constant operand.
2826 MUST_USE_RESULT LOperand* UseConstant(HValue* value);
2828 // An input operand in register, stack slot or a constant operand.
2829 // Will not be moved to a register even if one is freely available.
2830 MUST_USE_RESULT LOperand* UseAny(HValue* value) override;
2832 // Temporary operand that must be in a register.
2833 MUST_USE_RESULT LUnallocated* TempRegister();
2834 MUST_USE_RESULT LUnallocated* TempDoubleRegister();
2835 MUST_USE_RESULT LOperand* FixedTemp(Register reg);
2836 MUST_USE_RESULT LOperand* FixedTemp(DoubleRegister reg);
2838 // Methods for setting up define-use relationships.
2839 // Return the same instruction that they are passed.
2840 LInstruction* Define(LTemplateResultInstruction<1>* instr,
2841 LUnallocated* result);
2842 LInstruction* DefineAsRegister(LTemplateResultInstruction<1>* instr);
2843 LInstruction* DefineAsSpilled(LTemplateResultInstruction<1>* instr,
2845 LInstruction* DefineSameAsFirst(LTemplateResultInstruction<1>* instr);
2846 LInstruction* DefineFixed(LTemplateResultInstruction<1>* instr,
2848 LInstruction* DefineFixedDouble(LTemplateResultInstruction<1>* instr,
2849 DoubleRegister reg);
2850 LInstruction* AssignEnvironment(LInstruction* instr);
2851 LInstruction* AssignPointerMap(LInstruction* instr);
2853 enum CanDeoptimize { CAN_DEOPTIMIZE_EAGERLY, CANNOT_DEOPTIMIZE_EAGERLY };
2855 // By default we assume that instruction sequences generated for calls
2856 // cannot deoptimize eagerly and we do not attach environment to this
2858 LInstruction* MarkAsCall(
2859 LInstruction* instr,
2860 HInstruction* hinstr,
2861 CanDeoptimize can_deoptimize = CANNOT_DEOPTIMIZE_EAGERLY);
2863 void VisitInstruction(HInstruction* current);
2864 void AddInstruction(LInstruction* instr, HInstruction* current);
2866 void DoBasicBlock(HBasicBlock* block, HBasicBlock* next_block);
2867 LInstruction* DoShift(Token::Value op, HBitwiseBinaryOperation* instr);
2868 LInstruction* DoArithmeticD(Token::Value op,
2869 HArithmeticBinaryOperation* instr);
2870 LInstruction* DoArithmeticT(Token::Value op,
2871 HBinaryOperation* instr);
2873 HInstruction* current_instruction_;
2874 HBasicBlock* current_block_;
2875 HBasicBlock* next_block_;
2876 LAllocator* allocator_;
2878 DISALLOW_COPY_AND_ASSIGN(LChunkBuilder);
2881 #undef DECLARE_HYDROGEN_ACCESSOR
2882 #undef DECLARE_CONCRETE_INSTRUCTION
2884 } } // namespace v8::internal
2886 #endif // V8_ARM_LITHIUM_ARM_H_