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_MIPS_LITHIUM_MIPS_H_
6 #define V8_MIPS_LITHIUM_MIPS_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) \
26 V(AllocateBlockContext) \
28 V(ArgumentsElements) \
36 V(CallWithDescriptor) \
42 V(CheckArrayBufferNotNeutered) \
43 V(CheckInstanceType) \
52 V(ClassOfTestAndBranch) \
53 V(CompareMinusZeroAndBranch) \
54 V(CompareNumericAndBranch) \
55 V(CmpObjectEqAndBranch) \
79 V(FlooringDivByConstI) \
80 V(FlooringDivByPowerOf2I) \
84 V(GetCachedArrayIndex) \
86 V(HasCachedArrayIndexAndBranch) \
87 V(HasInPrototypeChainAndBranch) \
88 V(HasInstanceTypeAndBranch) \
89 V(InnerAllocatedObject) \
92 V(Integer32ToDouble) \
94 V(IsConstructCallAndBranch) \
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) \
169 #define DECLARE_CONCRETE_INSTRUCTION(type, mnemonic) \
170 Opcode opcode() const final { return LInstruction::k##type; } \
171 void CompileToNative(LCodeGen* generator) final; \
172 const char* Mnemonic() const final { return mnemonic; } \
173 static L##type* cast(LInstruction* instr) { \
174 DCHECK(instr->Is##type()); \
175 return reinterpret_cast<L##type*>(instr); \
179 #define DECLARE_HYDROGEN_ACCESSOR(type) \
180 H##type* hydrogen() const { \
181 return H##type::cast(hydrogen_value()); \
185 class LInstruction : public ZoneObject {
188 : environment_(NULL),
189 hydrogen_value_(NULL),
190 bit_field_(IsCallBits::encode(false)) {
193 virtual ~LInstruction() {}
195 virtual void CompileToNative(LCodeGen* generator) = 0;
196 virtual const char* Mnemonic() const = 0;
197 virtual void PrintTo(StringStream* stream);
198 virtual void PrintDataTo(StringStream* stream);
199 virtual void PrintOutputOperandTo(StringStream* stream);
202 // Declare a unique enum value for each instruction.
203 #define DECLARE_OPCODE(type) k##type,
204 LITHIUM_CONCRETE_INSTRUCTION_LIST(DECLARE_OPCODE)
205 kNumberOfInstructions
206 #undef DECLARE_OPCODE
209 virtual Opcode opcode() const = 0;
211 // Declare non-virtual type testers for all leaf IR classes.
212 #define DECLARE_PREDICATE(type) \
213 bool Is##type() const { return opcode() == k##type; }
214 LITHIUM_CONCRETE_INSTRUCTION_LIST(DECLARE_PREDICATE)
215 #undef DECLARE_PREDICATE
217 // Declare virtual predicates for instructions that don't have
219 virtual bool IsGap() const { return false; }
221 virtual bool IsControl() const { return false; }
223 // Try deleting this instruction if possible.
224 virtual bool TryDelete() { return false; }
226 void set_environment(LEnvironment* env) { environment_ = env; }
227 LEnvironment* environment() const { return environment_; }
228 bool HasEnvironment() const { return environment_ != NULL; }
230 void set_pointer_map(LPointerMap* p) { pointer_map_.set(p); }
231 LPointerMap* pointer_map() const { return pointer_map_.get(); }
232 bool HasPointerMap() const { return pointer_map_.is_set(); }
234 void set_hydrogen_value(HValue* value) { hydrogen_value_ = value; }
235 HValue* hydrogen_value() const { return hydrogen_value_; }
237 void MarkAsCall() { bit_field_ = IsCallBits::update(bit_field_, true); }
238 bool IsCall() const { return IsCallBits::decode(bit_field_); }
240 // Interface to the register allocator and iterators.
241 bool ClobbersTemps() const { return IsCall(); }
242 bool ClobbersRegisters() const { return IsCall(); }
243 virtual bool ClobbersDoubleRegisters(Isolate* isolate) const {
247 // Interface to the register allocator and iterators.
248 bool IsMarkedAsCall() const { return IsCall(); }
250 virtual bool HasResult() const = 0;
251 virtual LOperand* result() const = 0;
253 LOperand* FirstInput() { return InputAt(0); }
254 LOperand* Output() { return HasResult() ? result() : NULL; }
256 virtual bool HasInterestingComment(LCodeGen* gen) const { return true; }
262 virtual int InputCount() = 0;
263 virtual LOperand* InputAt(int i) = 0;
266 // Iterator interface.
267 friend class InputIterator;
269 friend class TempIterator;
270 virtual int TempCount() = 0;
271 virtual LOperand* TempAt(int i) = 0;
273 class IsCallBits: public BitField<bool, 0, 1> {};
275 LEnvironment* environment_;
276 SetOncePointer<LPointerMap> pointer_map_;
277 HValue* hydrogen_value_;
282 // R = number of result operands (0 or 1).
284 class LTemplateResultInstruction : public LInstruction {
286 // Allow 0 or 1 output operands.
287 STATIC_ASSERT(R == 0 || R == 1);
288 bool HasResult() const final { return R != 0 && result() != NULL; }
289 void set_result(LOperand* operand) { results_[0] = operand; }
290 LOperand* result() const override { return results_[0]; }
293 EmbeddedContainer<LOperand*, R> results_;
297 // R = number of result operands (0 or 1).
298 // I = number of input operands.
299 // T = number of temporary operands.
300 template<int R, int I, int T>
301 class LTemplateInstruction : public LTemplateResultInstruction<R> {
303 EmbeddedContainer<LOperand*, I> inputs_;
304 EmbeddedContainer<LOperand*, T> temps_;
308 int InputCount() final { return I; }
309 LOperand* InputAt(int i) final { return inputs_[i]; }
311 int TempCount() final { return T; }
312 LOperand* TempAt(int i) final { return temps_[i]; }
316 class LGap : public LTemplateInstruction<0, 0, 0> {
318 explicit LGap(HBasicBlock* block)
320 parallel_moves_[BEFORE] = NULL;
321 parallel_moves_[START] = NULL;
322 parallel_moves_[END] = NULL;
323 parallel_moves_[AFTER] = NULL;
326 // Can't use the DECLARE-macro here because of sub-classes.
327 bool IsGap() const final { return true; }
328 void PrintDataTo(StringStream* stream) override;
329 static LGap* cast(LInstruction* instr) {
330 DCHECK(instr->IsGap());
331 return reinterpret_cast<LGap*>(instr);
334 bool IsRedundant() const;
336 HBasicBlock* block() const { return block_; }
343 FIRST_INNER_POSITION = BEFORE,
344 LAST_INNER_POSITION = AFTER
347 LParallelMove* GetOrCreateParallelMove(InnerPosition pos, Zone* zone) {
348 if (parallel_moves_[pos] == NULL) {
349 parallel_moves_[pos] = new(zone) LParallelMove(zone);
351 return parallel_moves_[pos];
354 LParallelMove* GetParallelMove(InnerPosition pos) {
355 return parallel_moves_[pos];
359 LParallelMove* parallel_moves_[LAST_INNER_POSITION + 1];
364 class LInstructionGap final : public LGap {
366 explicit LInstructionGap(HBasicBlock* block) : LGap(block) { }
368 bool HasInterestingComment(LCodeGen* gen) const override {
369 return !IsRedundant();
372 DECLARE_CONCRETE_INSTRUCTION(InstructionGap, "gap")
376 class LGoto final : public LTemplateInstruction<0, 0, 0> {
378 explicit LGoto(HBasicBlock* block) : block_(block) { }
380 bool HasInterestingComment(LCodeGen* gen) const override;
381 DECLARE_CONCRETE_INSTRUCTION(Goto, "goto")
382 void PrintDataTo(StringStream* stream) override;
383 bool IsControl() const override { return true; }
385 int block_id() const { return block_->block_id(); }
392 class LPrologue final : public LTemplateInstruction<0, 0, 0> {
394 DECLARE_CONCRETE_INSTRUCTION(Prologue, "prologue")
398 class LLazyBailout final : public LTemplateInstruction<0, 0, 0> {
400 LLazyBailout() : gap_instructions_size_(0) { }
402 DECLARE_CONCRETE_INSTRUCTION(LazyBailout, "lazy-bailout")
404 void set_gap_instructions_size(int gap_instructions_size) {
405 gap_instructions_size_ = gap_instructions_size;
407 int gap_instructions_size() { return gap_instructions_size_; }
410 int gap_instructions_size_;
414 class LDummy final : public LTemplateInstruction<1, 0, 0> {
417 DECLARE_CONCRETE_INSTRUCTION(Dummy, "dummy")
421 class LDummyUse final : public LTemplateInstruction<1, 1, 0> {
423 explicit LDummyUse(LOperand* value) {
426 DECLARE_CONCRETE_INSTRUCTION(DummyUse, "dummy-use")
430 class LDeoptimize final : public LTemplateInstruction<0, 0, 0> {
432 bool IsControl() const override { return true; }
433 DECLARE_CONCRETE_INSTRUCTION(Deoptimize, "deoptimize")
434 DECLARE_HYDROGEN_ACCESSOR(Deoptimize)
438 class LLabel final : public LGap {
440 explicit LLabel(HBasicBlock* block)
441 : LGap(block), replacement_(NULL) { }
443 bool HasInterestingComment(LCodeGen* gen) const override { return false; }
444 DECLARE_CONCRETE_INSTRUCTION(Label, "label")
446 void PrintDataTo(StringStream* stream) override;
448 int block_id() const { return block()->block_id(); }
449 bool is_loop_header() const { return block()->IsLoopHeader(); }
450 bool is_osr_entry() const { return block()->is_osr_entry(); }
451 Label* label() { return &label_; }
452 LLabel* replacement() const { return replacement_; }
453 void set_replacement(LLabel* label) { replacement_ = label; }
454 bool HasReplacement() const { return replacement_ != NULL; }
458 LLabel* replacement_;
462 class LParameter final : public LTemplateInstruction<1, 0, 0> {
464 bool HasInterestingComment(LCodeGen* gen) const override { return false; }
465 DECLARE_CONCRETE_INSTRUCTION(Parameter, "parameter")
469 class LCallStub final : public LTemplateInstruction<1, 1, 0> {
471 explicit LCallStub(LOperand* context) {
472 inputs_[0] = context;
475 LOperand* context() { return inputs_[0]; }
477 DECLARE_CONCRETE_INSTRUCTION(CallStub, "call-stub")
478 DECLARE_HYDROGEN_ACCESSOR(CallStub)
482 class LUnknownOSRValue final : public LTemplateInstruction<1, 0, 0> {
484 bool HasInterestingComment(LCodeGen* gen) const override { return false; }
485 DECLARE_CONCRETE_INSTRUCTION(UnknownOSRValue, "unknown-osr-value")
489 template<int I, int T>
490 class LControlInstruction : public LTemplateInstruction<0, I, T> {
492 LControlInstruction() : false_label_(NULL), true_label_(NULL) { }
494 bool IsControl() const final { return true; }
496 int SuccessorCount() { return hydrogen()->SuccessorCount(); }
497 HBasicBlock* SuccessorAt(int i) { return hydrogen()->SuccessorAt(i); }
499 int TrueDestination(LChunk* chunk) {
500 return chunk->LookupDestination(true_block_id());
502 int FalseDestination(LChunk* chunk) {
503 return chunk->LookupDestination(false_block_id());
506 Label* TrueLabel(LChunk* chunk) {
507 if (true_label_ == NULL) {
508 true_label_ = chunk->GetAssemblyLabel(TrueDestination(chunk));
512 Label* FalseLabel(LChunk* chunk) {
513 if (false_label_ == NULL) {
514 false_label_ = chunk->GetAssemblyLabel(FalseDestination(chunk));
520 int true_block_id() { return SuccessorAt(0)->block_id(); }
521 int false_block_id() { return SuccessorAt(1)->block_id(); }
524 HControlInstruction* hydrogen() {
525 return HControlInstruction::cast(this->hydrogen_value());
533 class LWrapReceiver final : public LTemplateInstruction<1, 2, 0> {
535 LWrapReceiver(LOperand* receiver, LOperand* function) {
536 inputs_[0] = receiver;
537 inputs_[1] = function;
540 DECLARE_CONCRETE_INSTRUCTION(WrapReceiver, "wrap-receiver")
541 DECLARE_HYDROGEN_ACCESSOR(WrapReceiver)
543 LOperand* receiver() { return inputs_[0]; }
544 LOperand* function() { return inputs_[1]; }
548 class LApplyArguments final : public LTemplateInstruction<1, 4, 0> {
550 LApplyArguments(LOperand* function,
553 LOperand* elements) {
554 inputs_[0] = function;
555 inputs_[1] = receiver;
557 inputs_[3] = elements;
560 DECLARE_CONCRETE_INSTRUCTION(ApplyArguments, "apply-arguments")
562 LOperand* function() { return inputs_[0]; }
563 LOperand* receiver() { return inputs_[1]; }
564 LOperand* length() { return inputs_[2]; }
565 LOperand* elements() { return inputs_[3]; }
569 class LAccessArgumentsAt final : public LTemplateInstruction<1, 3, 0> {
571 LAccessArgumentsAt(LOperand* arguments, LOperand* length, LOperand* index) {
572 inputs_[0] = arguments;
577 DECLARE_CONCRETE_INSTRUCTION(AccessArgumentsAt, "access-arguments-at")
579 LOperand* arguments() { return inputs_[0]; }
580 LOperand* length() { return inputs_[1]; }
581 LOperand* index() { return inputs_[2]; }
583 void PrintDataTo(StringStream* stream) override;
587 class LArgumentsLength final : public LTemplateInstruction<1, 1, 0> {
589 explicit LArgumentsLength(LOperand* elements) {
590 inputs_[0] = elements;
593 LOperand* elements() { return inputs_[0]; }
595 DECLARE_CONCRETE_INSTRUCTION(ArgumentsLength, "arguments-length")
599 class LArgumentsElements final : public LTemplateInstruction<1, 0, 0> {
601 DECLARE_CONCRETE_INSTRUCTION(ArgumentsElements, "arguments-elements")
602 DECLARE_HYDROGEN_ACCESSOR(ArgumentsElements)
606 class LModByPowerOf2I final : public LTemplateInstruction<1, 1, 0> {
608 LModByPowerOf2I(LOperand* dividend, int32_t divisor) {
609 inputs_[0] = dividend;
613 LOperand* dividend() { return inputs_[0]; }
614 int32_t divisor() const { return divisor_; }
616 DECLARE_CONCRETE_INSTRUCTION(ModByPowerOf2I, "mod-by-power-of-2-i")
617 DECLARE_HYDROGEN_ACCESSOR(Mod)
624 class LModByConstI final : public LTemplateInstruction<1, 1, 0> {
626 LModByConstI(LOperand* dividend, int32_t divisor) {
627 inputs_[0] = dividend;
631 LOperand* dividend() { return inputs_[0]; }
632 int32_t divisor() const { return divisor_; }
634 DECLARE_CONCRETE_INSTRUCTION(ModByConstI, "mod-by-const-i")
635 DECLARE_HYDROGEN_ACCESSOR(Mod)
642 class LModI final : public LTemplateInstruction<1, 2, 3> {
644 LModI(LOperand* left,
650 LOperand* left() { return inputs_[0]; }
651 LOperand* right() { return inputs_[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, 0> {
752 LFlooringDivI(LOperand* dividend, LOperand* divisor) {
753 inputs_[0] = dividend;
754 inputs_[1] = divisor;
757 LOperand* dividend() { return inputs_[0]; }
758 LOperand* divisor() { return inputs_[1]; }
760 DECLARE_CONCRETE_INSTRUCTION(FlooringDivI, "flooring-div-i")
761 DECLARE_HYDROGEN_ACCESSOR(MathFloorOfDiv)
765 class LMulS final : public LTemplateInstruction<1, 2, 0> {
767 LMulS(LOperand* left, LOperand* right) {
772 LOperand* left() { return inputs_[0]; }
773 LOperand* right() { return inputs_[1]; }
775 DECLARE_CONCRETE_INSTRUCTION(MulS, "mul-s")
776 DECLARE_HYDROGEN_ACCESSOR(Mul)
780 class LMulI final : public LTemplateInstruction<1, 2, 0> {
782 LMulI(LOperand* left, LOperand* right) {
787 LOperand* left() { return inputs_[0]; }
788 LOperand* right() { return inputs_[1]; }
790 DECLARE_CONCRETE_INSTRUCTION(MulI, "mul-i")
791 DECLARE_HYDROGEN_ACCESSOR(Mul)
795 // Instruction for computing multiplier * multiplicand + addend.
796 class LMultiplyAddD final : public LTemplateInstruction<1, 3, 0> {
798 LMultiplyAddD(LOperand* addend, LOperand* multiplier,
799 LOperand* multiplicand) {
801 inputs_[1] = multiplier;
802 inputs_[2] = multiplicand;
805 LOperand* addend() { return inputs_[0]; }
806 LOperand* multiplier() { return inputs_[1]; }
807 LOperand* multiplicand() { return inputs_[2]; }
809 DECLARE_CONCRETE_INSTRUCTION(MultiplyAddD, "multiply-add-d")
813 class LDebugBreak final : public LTemplateInstruction<0, 0, 0> {
815 DECLARE_CONCRETE_INSTRUCTION(DebugBreak, "break")
819 class LCompareNumericAndBranch final : public LControlInstruction<2, 0> {
821 LCompareNumericAndBranch(LOperand* left, LOperand* right) {
826 LOperand* left() { return inputs_[0]; }
827 LOperand* right() { return inputs_[1]; }
829 DECLARE_CONCRETE_INSTRUCTION(CompareNumericAndBranch,
830 "compare-numeric-and-branch")
831 DECLARE_HYDROGEN_ACCESSOR(CompareNumericAndBranch)
833 Token::Value op() const { return hydrogen()->token(); }
834 bool is_double() const {
835 return hydrogen()->representation().IsDouble();
838 void PrintDataTo(StringStream* stream) override;
842 class LMathFloor final : public LTemplateInstruction<1, 1, 1> {
844 LMathFloor(LOperand* value, LOperand* temp) {
849 LOperand* value() { return inputs_[0]; }
850 LOperand* temp() { return temps_[0]; }
852 DECLARE_CONCRETE_INSTRUCTION(MathFloor, "math-floor")
853 DECLARE_HYDROGEN_ACCESSOR(UnaryMathOperation)
857 class LMathRound final : public LTemplateInstruction<1, 1, 1> {
859 LMathRound(LOperand* value, LOperand* temp) {
864 LOperand* value() { return inputs_[0]; }
865 LOperand* temp() { return temps_[0]; }
867 DECLARE_CONCRETE_INSTRUCTION(MathRound, "math-round")
868 DECLARE_HYDROGEN_ACCESSOR(UnaryMathOperation)
872 class LMathFround final : public LTemplateInstruction<1, 1, 0> {
874 explicit LMathFround(LOperand* value) { inputs_[0] = value; }
876 LOperand* value() { return inputs_[0]; }
878 DECLARE_CONCRETE_INSTRUCTION(MathFround, "math-fround")
882 class LMathAbs final : public LTemplateInstruction<1, 2, 0> {
884 LMathAbs(LOperand* context, LOperand* value) {
885 inputs_[1] = context;
889 LOperand* context() { return inputs_[1]; }
890 LOperand* value() { return inputs_[0]; }
892 DECLARE_CONCRETE_INSTRUCTION(MathAbs, "math-abs")
893 DECLARE_HYDROGEN_ACCESSOR(UnaryMathOperation)
897 class LMathLog final : public LTemplateInstruction<1, 1, 0> {
899 explicit LMathLog(LOperand* value) {
903 LOperand* value() { return inputs_[0]; }
905 DECLARE_CONCRETE_INSTRUCTION(MathLog, "math-log")
909 class LMathClz32 final : public LTemplateInstruction<1, 1, 0> {
911 explicit LMathClz32(LOperand* value) {
915 LOperand* value() { return inputs_[0]; }
917 DECLARE_CONCRETE_INSTRUCTION(MathClz32, "math-clz32")
921 class LMathExp final : public LTemplateInstruction<1, 1, 3> {
923 LMathExp(LOperand* value,
924 LOperand* double_temp,
930 temps_[2] = double_temp;
931 ExternalReference::InitializeMathExpData();
934 LOperand* value() { return inputs_[0]; }
935 LOperand* temp1() { return temps_[0]; }
936 LOperand* temp2() { return temps_[1]; }
937 LOperand* double_temp() { return temps_[2]; }
939 DECLARE_CONCRETE_INSTRUCTION(MathExp, "math-exp")
943 class LMathSqrt final : public LTemplateInstruction<1, 1, 0> {
945 explicit LMathSqrt(LOperand* value) {
949 LOperand* value() { return inputs_[0]; }
951 DECLARE_CONCRETE_INSTRUCTION(MathSqrt, "math-sqrt")
955 class LMathPowHalf final : public LTemplateInstruction<1, 1, 1> {
957 LMathPowHalf(LOperand* value, LOperand* temp) {
962 LOperand* value() { return inputs_[0]; }
963 LOperand* temp() { return temps_[0]; }
965 DECLARE_CONCRETE_INSTRUCTION(MathPowHalf, "math-pow-half")
969 class LCmpObjectEqAndBranch final : public LControlInstruction<2, 0> {
971 LCmpObjectEqAndBranch(LOperand* left, LOperand* right) {
976 LOperand* left() { return inputs_[0]; }
977 LOperand* right() { return inputs_[1]; }
979 DECLARE_CONCRETE_INSTRUCTION(CmpObjectEqAndBranch, "cmp-object-eq-and-branch")
980 DECLARE_HYDROGEN_ACCESSOR(CompareObjectEqAndBranch)
984 class LCmpHoleAndBranch final : public LControlInstruction<1, 0> {
986 explicit LCmpHoleAndBranch(LOperand* object) {
990 LOperand* object() { return inputs_[0]; }
992 DECLARE_CONCRETE_INSTRUCTION(CmpHoleAndBranch, "cmp-hole-and-branch")
993 DECLARE_HYDROGEN_ACCESSOR(CompareHoleAndBranch)
997 class LCompareMinusZeroAndBranch final : public LControlInstruction<1, 1> {
999 LCompareMinusZeroAndBranch(LOperand* value, LOperand* temp) {
1004 LOperand* value() { return inputs_[0]; }
1005 LOperand* temp() { return temps_[0]; }
1007 DECLARE_CONCRETE_INSTRUCTION(CompareMinusZeroAndBranch,
1008 "cmp-minus-zero-and-branch")
1009 DECLARE_HYDROGEN_ACCESSOR(CompareMinusZeroAndBranch)
1013 class LIsStringAndBranch final : public LControlInstruction<1, 1> {
1015 LIsStringAndBranch(LOperand* value, LOperand* temp) {
1020 LOperand* value() { return inputs_[0]; }
1021 LOperand* temp() { return temps_[0]; }
1023 DECLARE_CONCRETE_INSTRUCTION(IsStringAndBranch, "is-string-and-branch")
1024 DECLARE_HYDROGEN_ACCESSOR(IsStringAndBranch)
1026 void PrintDataTo(StringStream* stream) override;
1030 class LIsSmiAndBranch final : public LControlInstruction<1, 0> {
1032 explicit LIsSmiAndBranch(LOperand* value) {
1036 LOperand* value() { return inputs_[0]; }
1038 DECLARE_CONCRETE_INSTRUCTION(IsSmiAndBranch, "is-smi-and-branch")
1039 DECLARE_HYDROGEN_ACCESSOR(IsSmiAndBranch)
1041 void PrintDataTo(StringStream* stream) override;
1045 class LIsUndetectableAndBranch final : public LControlInstruction<1, 1> {
1047 explicit LIsUndetectableAndBranch(LOperand* value, LOperand* temp) {
1052 LOperand* value() { return inputs_[0]; }
1053 LOperand* temp() { return temps_[0]; }
1055 DECLARE_CONCRETE_INSTRUCTION(IsUndetectableAndBranch,
1056 "is-undetectable-and-branch")
1057 DECLARE_HYDROGEN_ACCESSOR(IsUndetectableAndBranch)
1059 void PrintDataTo(StringStream* stream) override;
1063 class LStringCompareAndBranch final : public LControlInstruction<3, 0> {
1065 LStringCompareAndBranch(LOperand* context, LOperand* left, LOperand* right) {
1066 inputs_[0] = context;
1071 LOperand* context() { return inputs_[0]; }
1072 LOperand* left() { return inputs_[1]; }
1073 LOperand* right() { return inputs_[2]; }
1075 DECLARE_CONCRETE_INSTRUCTION(StringCompareAndBranch,
1076 "string-compare-and-branch")
1077 DECLARE_HYDROGEN_ACCESSOR(StringCompareAndBranch)
1079 Token::Value op() const { return hydrogen()->token(); }
1081 void PrintDataTo(StringStream* stream) override;
1085 class LHasInstanceTypeAndBranch final : public LControlInstruction<1, 0> {
1087 explicit LHasInstanceTypeAndBranch(LOperand* value) {
1091 LOperand* value() { return inputs_[0]; }
1093 DECLARE_CONCRETE_INSTRUCTION(HasInstanceTypeAndBranch,
1094 "has-instance-type-and-branch")
1095 DECLARE_HYDROGEN_ACCESSOR(HasInstanceTypeAndBranch)
1097 void PrintDataTo(StringStream* stream) override;
1101 class LGetCachedArrayIndex final : public LTemplateInstruction<1, 1, 0> {
1103 explicit LGetCachedArrayIndex(LOperand* value) {
1107 LOperand* value() { return inputs_[0]; }
1109 DECLARE_CONCRETE_INSTRUCTION(GetCachedArrayIndex, "get-cached-array-index")
1110 DECLARE_HYDROGEN_ACCESSOR(GetCachedArrayIndex)
1114 class LHasCachedArrayIndexAndBranch final : public LControlInstruction<1, 0> {
1116 explicit LHasCachedArrayIndexAndBranch(LOperand* value) {
1120 LOperand* value() { return inputs_[0]; }
1122 DECLARE_CONCRETE_INSTRUCTION(HasCachedArrayIndexAndBranch,
1123 "has-cached-array-index-and-branch")
1124 DECLARE_HYDROGEN_ACCESSOR(HasCachedArrayIndexAndBranch)
1126 void PrintDataTo(StringStream* stream) override;
1130 class LClassOfTestAndBranch final : public LControlInstruction<1, 1> {
1132 LClassOfTestAndBranch(LOperand* value, LOperand* temp) {
1137 LOperand* value() { return inputs_[0]; }
1138 LOperand* temp() { return temps_[0]; }
1140 DECLARE_CONCRETE_INSTRUCTION(ClassOfTestAndBranch,
1141 "class-of-test-and-branch")
1142 DECLARE_HYDROGEN_ACCESSOR(ClassOfTestAndBranch)
1144 void PrintDataTo(StringStream* stream) override;
1148 class LCmpT final : public LTemplateInstruction<1, 3, 0> {
1150 LCmpT(LOperand* context, LOperand* left, LOperand* right) {
1151 inputs_[0] = context;
1156 LOperand* context() { return inputs_[0]; }
1157 LOperand* left() { return inputs_[1]; }
1158 LOperand* right() { return inputs_[2]; }
1160 DECLARE_CONCRETE_INSTRUCTION(CmpT, "cmp-t")
1161 DECLARE_HYDROGEN_ACCESSOR(CompareGeneric)
1163 Strength strength() { return hydrogen()->strength(); }
1165 Token::Value op() const { return hydrogen()->token(); }
1169 class LInstanceOf final : public LTemplateInstruction<1, 3, 0> {
1171 LInstanceOf(LOperand* context, LOperand* left, LOperand* right) {
1172 inputs_[0] = context;
1177 LOperand* context() const { return inputs_[0]; }
1178 LOperand* left() const { return inputs_[1]; }
1179 LOperand* right() const { return inputs_[2]; }
1181 DECLARE_CONCRETE_INSTRUCTION(InstanceOf, "instance-of")
1185 class LHasInPrototypeChainAndBranch final : public LControlInstruction<2, 0> {
1187 LHasInPrototypeChainAndBranch(LOperand* object, LOperand* prototype) {
1188 inputs_[0] = object;
1189 inputs_[1] = prototype;
1192 LOperand* object() const { return inputs_[0]; }
1193 LOperand* prototype() const { return inputs_[1]; }
1195 DECLARE_CONCRETE_INSTRUCTION(HasInPrototypeChainAndBranch,
1196 "has-in-prototype-chain-and-branch")
1197 DECLARE_HYDROGEN_ACCESSOR(HasInPrototypeChainAndBranch)
1201 class LBoundsCheck final : public LTemplateInstruction<0, 2, 0> {
1203 LBoundsCheck(LOperand* index, LOperand* length) {
1205 inputs_[1] = length;
1208 LOperand* index() { return inputs_[0]; }
1209 LOperand* length() { return inputs_[1]; }
1211 DECLARE_CONCRETE_INSTRUCTION(BoundsCheck, "bounds-check")
1212 DECLARE_HYDROGEN_ACCESSOR(BoundsCheck)
1216 class LBitI final : public LTemplateInstruction<1, 2, 0> {
1218 LBitI(LOperand* left, LOperand* right) {
1223 LOperand* left() { return inputs_[0]; }
1224 LOperand* right() { return inputs_[1]; }
1226 Token::Value op() const { return hydrogen()->op(); }
1228 DECLARE_CONCRETE_INSTRUCTION(BitI, "bit-i")
1229 DECLARE_HYDROGEN_ACCESSOR(Bitwise)
1233 class LShiftI final : public LTemplateInstruction<1, 2, 0> {
1235 LShiftI(Token::Value op, LOperand* left, LOperand* right, bool can_deopt)
1236 : op_(op), can_deopt_(can_deopt) {
1241 Token::Value op() const { return op_; }
1242 LOperand* left() { return inputs_[0]; }
1243 LOperand* right() { return inputs_[1]; }
1244 bool can_deopt() const { return can_deopt_; }
1246 DECLARE_CONCRETE_INSTRUCTION(ShiftI, "shift-i")
1254 class LSubI final : public LTemplateInstruction<1, 2, 0> {
1256 LSubI(LOperand* left, LOperand* right) {
1261 LOperand* left() { return inputs_[0]; }
1262 LOperand* right() { return inputs_[1]; }
1264 DECLARE_CONCRETE_INSTRUCTION(SubI, "sub-i")
1265 DECLARE_HYDROGEN_ACCESSOR(Sub)
1269 class LSubS final : public LTemplateInstruction<1, 2, 0> {
1271 LSubS(LOperand* left, LOperand* right) {
1276 LOperand* left() { return inputs_[0]; }
1277 LOperand* right() { return inputs_[1]; }
1279 DECLARE_CONCRETE_INSTRUCTION(SubS, "sub-s")
1280 DECLARE_HYDROGEN_ACCESSOR(Sub)
1284 class LConstantI final : public LTemplateInstruction<1, 0, 0> {
1286 DECLARE_CONCRETE_INSTRUCTION(ConstantI, "constant-i")
1287 DECLARE_HYDROGEN_ACCESSOR(Constant)
1289 int32_t value() const { return hydrogen()->Integer32Value(); }
1293 class LConstantS final : public LTemplateInstruction<1, 0, 0> {
1295 DECLARE_CONCRETE_INSTRUCTION(ConstantS, "constant-s")
1296 DECLARE_HYDROGEN_ACCESSOR(Constant)
1298 Smi* value() const { return Smi::FromInt(hydrogen()->Integer32Value()); }
1302 class LConstantD final : public LTemplateInstruction<1, 0, 0> {
1304 DECLARE_CONCRETE_INSTRUCTION(ConstantD, "constant-d")
1305 DECLARE_HYDROGEN_ACCESSOR(Constant)
1307 double value() const { return hydrogen()->DoubleValue(); }
1311 class LConstantE final : public LTemplateInstruction<1, 0, 0> {
1313 DECLARE_CONCRETE_INSTRUCTION(ConstantE, "constant-e")
1314 DECLARE_HYDROGEN_ACCESSOR(Constant)
1316 ExternalReference value() const {
1317 return hydrogen()->ExternalReferenceValue();
1322 class LConstantT final : public LTemplateInstruction<1, 0, 0> {
1324 DECLARE_CONCRETE_INSTRUCTION(ConstantT, "constant-t")
1325 DECLARE_HYDROGEN_ACCESSOR(Constant)
1327 Handle<Object> value(Isolate* isolate) const {
1328 return hydrogen()->handle(isolate);
1333 class LBranch final : public LControlInstruction<1, 0> {
1335 explicit LBranch(LOperand* value) {
1339 LOperand* value() { return inputs_[0]; }
1341 DECLARE_CONCRETE_INSTRUCTION(Branch, "branch")
1342 DECLARE_HYDROGEN_ACCESSOR(Branch)
1344 void PrintDataTo(StringStream* stream) override;
1348 class LCmpMapAndBranch final : public LControlInstruction<1, 1> {
1350 LCmpMapAndBranch(LOperand* value, LOperand* temp) {
1355 LOperand* value() { return inputs_[0]; }
1356 LOperand* temp() { return temps_[0]; }
1358 DECLARE_CONCRETE_INSTRUCTION(CmpMapAndBranch, "cmp-map-and-branch")
1359 DECLARE_HYDROGEN_ACCESSOR(CompareMap)
1361 Handle<Map> map() const { return hydrogen()->map().handle(); }
1365 class LMapEnumLength final : public LTemplateInstruction<1, 1, 0> {
1367 explicit LMapEnumLength(LOperand* value) {
1371 LOperand* value() { return inputs_[0]; }
1373 DECLARE_CONCRETE_INSTRUCTION(MapEnumLength, "map-enum-length")
1377 class LDateField final : public LTemplateInstruction<1, 1, 1> {
1379 LDateField(LOperand* date, LOperand* temp, Smi* index) : index_(index) {
1384 LOperand* date() { return inputs_[0]; }
1385 LOperand* temp() { return temps_[0]; }
1386 Smi* index() const { return index_; }
1388 DECLARE_CONCRETE_INSTRUCTION(DateField, "date-field")
1389 DECLARE_HYDROGEN_ACCESSOR(DateField)
1396 class LSeqStringGetChar final : public LTemplateInstruction<1, 2, 0> {
1398 LSeqStringGetChar(LOperand* string, LOperand* index) {
1399 inputs_[0] = string;
1403 LOperand* string() const { return inputs_[0]; }
1404 LOperand* index() const { return inputs_[1]; }
1406 DECLARE_CONCRETE_INSTRUCTION(SeqStringGetChar, "seq-string-get-char")
1407 DECLARE_HYDROGEN_ACCESSOR(SeqStringGetChar)
1411 class LSeqStringSetChar final : public LTemplateInstruction<1, 4, 0> {
1413 LSeqStringSetChar(LOperand* context,
1417 inputs_[0] = context;
1418 inputs_[1] = string;
1423 LOperand* string() { return inputs_[1]; }
1424 LOperand* index() { return inputs_[2]; }
1425 LOperand* value() { return inputs_[3]; }
1427 DECLARE_CONCRETE_INSTRUCTION(SeqStringSetChar, "seq-string-set-char")
1428 DECLARE_HYDROGEN_ACCESSOR(SeqStringSetChar)
1432 class LAddE final : public LTemplateInstruction<1, 2, 0> {
1434 LAddE(LOperand* left, LOperand* right) {
1439 LOperand* left() { return inputs_[0]; }
1440 LOperand* right() { return inputs_[1]; }
1442 DECLARE_CONCRETE_INSTRUCTION(AddE, "add-e")
1443 DECLARE_HYDROGEN_ACCESSOR(Add)
1447 class LAddI final : public LTemplateInstruction<1, 2, 0> {
1449 LAddI(LOperand* left, LOperand* right) {
1454 LOperand* left() { return inputs_[0]; }
1455 LOperand* right() { return inputs_[1]; }
1457 DECLARE_CONCRETE_INSTRUCTION(AddI, "add-i")
1458 DECLARE_HYDROGEN_ACCESSOR(Add)
1462 class LAddS final : public LTemplateInstruction<1, 2, 0> {
1464 LAddS(LOperand* left, LOperand* right) {
1469 LOperand* left() { return inputs_[0]; }
1470 LOperand* right() { return inputs_[1]; }
1472 DECLARE_CONCRETE_INSTRUCTION(AddS, "add-s")
1473 DECLARE_HYDROGEN_ACCESSOR(Add)
1477 class LMathMinMax final : public LTemplateInstruction<1, 2, 0> {
1479 LMathMinMax(LOperand* left, LOperand* right) {
1484 LOperand* left() { return inputs_[0]; }
1485 LOperand* right() { return inputs_[1]; }
1487 DECLARE_CONCRETE_INSTRUCTION(MathMinMax, "math-min-max")
1488 DECLARE_HYDROGEN_ACCESSOR(MathMinMax)
1492 class LPower final : public LTemplateInstruction<1, 2, 0> {
1494 LPower(LOperand* left, LOperand* right) {
1499 LOperand* left() { return inputs_[0]; }
1500 LOperand* right() { return inputs_[1]; }
1502 DECLARE_CONCRETE_INSTRUCTION(Power, "power")
1503 DECLARE_HYDROGEN_ACCESSOR(Power)
1507 class LArithmeticD final : public LTemplateInstruction<1, 2, 0> {
1509 LArithmeticD(Token::Value op, LOperand* left, LOperand* right)
1515 Token::Value op() const { return op_; }
1516 LOperand* left() { return inputs_[0]; }
1517 LOperand* right() { return inputs_[1]; }
1519 Opcode opcode() const override { return LInstruction::kArithmeticD; }
1520 void CompileToNative(LCodeGen* generator) override;
1521 const char* Mnemonic() const override;
1528 class LArithmeticT final : public LTemplateInstruction<1, 3, 0> {
1530 LArithmeticT(Token::Value op,
1535 inputs_[0] = context;
1540 LOperand* context() { return inputs_[0]; }
1541 LOperand* left() { return inputs_[1]; }
1542 LOperand* right() { return inputs_[2]; }
1543 Token::Value op() const { return op_; }
1545 Opcode opcode() const final { return LInstruction::kArithmeticT; }
1546 void CompileToNative(LCodeGen* generator) override;
1547 const char* Mnemonic() const override;
1549 DECLARE_HYDROGEN_ACCESSOR(BinaryOperation)
1551 Strength strength() { return hydrogen()->strength(); }
1558 class LReturn final : public LTemplateInstruction<0, 3, 0> {
1560 LReturn(LOperand* value, LOperand* context, LOperand* parameter_count) {
1562 inputs_[1] = context;
1563 inputs_[2] = parameter_count;
1566 LOperand* value() { return inputs_[0]; }
1568 bool has_constant_parameter_count() {
1569 return parameter_count()->IsConstantOperand();
1571 LConstantOperand* constant_parameter_count() {
1572 DCHECK(has_constant_parameter_count());
1573 return LConstantOperand::cast(parameter_count());
1575 LOperand* parameter_count() { return inputs_[2]; }
1577 DECLARE_CONCRETE_INSTRUCTION(Return, "return")
1581 class LLoadNamedField final : public LTemplateInstruction<1, 1, 0> {
1583 explicit LLoadNamedField(LOperand* object) {
1584 inputs_[0] = object;
1587 LOperand* object() { return inputs_[0]; }
1589 DECLARE_CONCRETE_INSTRUCTION(LoadNamedField, "load-named-field")
1590 DECLARE_HYDROGEN_ACCESSOR(LoadNamedField)
1594 class LLoadNamedGeneric final : public LTemplateInstruction<1, 2, 1> {
1596 LLoadNamedGeneric(LOperand* context, LOperand* object, LOperand* vector) {
1597 inputs_[0] = context;
1598 inputs_[1] = object;
1602 LOperand* context() { return inputs_[0]; }
1603 LOperand* object() { return inputs_[1]; }
1604 LOperand* temp_vector() { return temps_[0]; }
1606 DECLARE_CONCRETE_INSTRUCTION(LoadNamedGeneric, "load-named-generic")
1607 DECLARE_HYDROGEN_ACCESSOR(LoadNamedGeneric)
1609 Handle<Object> name() const { return hydrogen()->name(); }
1613 class LLoadFunctionPrototype final : public LTemplateInstruction<1, 1, 0> {
1615 explicit LLoadFunctionPrototype(LOperand* function) {
1616 inputs_[0] = function;
1619 LOperand* function() { return inputs_[0]; }
1621 DECLARE_CONCRETE_INSTRUCTION(LoadFunctionPrototype, "load-function-prototype")
1622 DECLARE_HYDROGEN_ACCESSOR(LoadFunctionPrototype)
1626 class LLoadRoot final : public LTemplateInstruction<1, 0, 0> {
1628 DECLARE_CONCRETE_INSTRUCTION(LoadRoot, "load-root")
1629 DECLARE_HYDROGEN_ACCESSOR(LoadRoot)
1631 Heap::RootListIndex index() const { return hydrogen()->index(); }
1635 class LLoadKeyed final : public LTemplateInstruction<1, 2, 0> {
1637 LLoadKeyed(LOperand* elements, LOperand* key) {
1638 inputs_[0] = elements;
1642 LOperand* elements() { return inputs_[0]; }
1643 LOperand* key() { return inputs_[1]; }
1644 ElementsKind elements_kind() const {
1645 return hydrogen()->elements_kind();
1647 bool is_fixed_typed_array() const {
1648 return hydrogen()->is_fixed_typed_array();
1651 DECLARE_CONCRETE_INSTRUCTION(LoadKeyed, "load-keyed")
1652 DECLARE_HYDROGEN_ACCESSOR(LoadKeyed)
1654 void PrintDataTo(StringStream* stream) override;
1655 uint32_t base_offset() const { return hydrogen()->base_offset(); }
1659 class LLoadKeyedGeneric final : public LTemplateInstruction<1, 3, 1> {
1661 LLoadKeyedGeneric(LOperand* context, LOperand* object, LOperand* key,
1663 inputs_[0] = context;
1664 inputs_[1] = object;
1669 LOperand* context() { return inputs_[0]; }
1670 LOperand* object() { return inputs_[1]; }
1671 LOperand* key() { return inputs_[2]; }
1672 LOperand* temp_vector() { return temps_[0]; }
1674 DECLARE_CONCRETE_INSTRUCTION(LoadKeyedGeneric, "load-keyed-generic")
1675 DECLARE_HYDROGEN_ACCESSOR(LoadKeyedGeneric)
1679 class LLoadGlobalGeneric final : public LTemplateInstruction<1, 2, 1> {
1681 LLoadGlobalGeneric(LOperand* context, LOperand* global_object,
1683 inputs_[0] = context;
1684 inputs_[1] = global_object;
1688 LOperand* context() { return inputs_[0]; }
1689 LOperand* global_object() { return inputs_[1]; }
1690 LOperand* temp_vector() { return temps_[0]; }
1692 DECLARE_CONCRETE_INSTRUCTION(LoadGlobalGeneric, "load-global-generic")
1693 DECLARE_HYDROGEN_ACCESSOR(LoadGlobalGeneric)
1695 Handle<Object> name() const { return hydrogen()->name(); }
1696 TypeofMode typeof_mode() const { return hydrogen()->typeof_mode(); }
1700 class LLoadGlobalViaContext final : public LTemplateInstruction<1, 1, 1> {
1702 explicit LLoadGlobalViaContext(LOperand* context) { inputs_[0] = context; }
1704 DECLARE_CONCRETE_INSTRUCTION(LoadGlobalViaContext, "load-global-via-context")
1705 DECLARE_HYDROGEN_ACCESSOR(LoadGlobalViaContext)
1707 void PrintDataTo(StringStream* stream) override;
1709 LOperand* context() { return inputs_[0]; }
1711 int depth() const { return hydrogen()->depth(); }
1712 int slot_index() const { return hydrogen()->slot_index(); }
1716 class LLoadContextSlot final : public LTemplateInstruction<1, 1, 0> {
1718 explicit LLoadContextSlot(LOperand* context) {
1719 inputs_[0] = context;
1722 LOperand* context() { return inputs_[0]; }
1724 DECLARE_CONCRETE_INSTRUCTION(LoadContextSlot, "load-context-slot")
1725 DECLARE_HYDROGEN_ACCESSOR(LoadContextSlot)
1727 int slot_index() { return hydrogen()->slot_index(); }
1729 void PrintDataTo(StringStream* stream) override;
1733 class LStoreContextSlot final : public LTemplateInstruction<0, 2, 0> {
1735 LStoreContextSlot(LOperand* context, LOperand* value) {
1736 inputs_[0] = context;
1740 LOperand* context() { return inputs_[0]; }
1741 LOperand* value() { return inputs_[1]; }
1743 DECLARE_CONCRETE_INSTRUCTION(StoreContextSlot, "store-context-slot")
1744 DECLARE_HYDROGEN_ACCESSOR(StoreContextSlot)
1746 int slot_index() { return hydrogen()->slot_index(); }
1748 void PrintDataTo(StringStream* stream) override;
1752 class LPushArgument final : public LTemplateInstruction<0, 1, 0> {
1754 explicit LPushArgument(LOperand* value) {
1758 LOperand* value() { return inputs_[0]; }
1760 DECLARE_CONCRETE_INSTRUCTION(PushArgument, "push-argument")
1764 class LDrop final : public LTemplateInstruction<0, 0, 0> {
1766 explicit LDrop(int count) : count_(count) { }
1768 int count() const { return count_; }
1770 DECLARE_CONCRETE_INSTRUCTION(Drop, "drop")
1777 class LStoreCodeEntry final : public LTemplateInstruction<0, 2, 0> {
1779 LStoreCodeEntry(LOperand* function, LOperand* code_object) {
1780 inputs_[0] = function;
1781 inputs_[1] = code_object;
1784 LOperand* function() { return inputs_[0]; }
1785 LOperand* code_object() { return inputs_[1]; }
1787 void PrintDataTo(StringStream* stream) override;
1789 DECLARE_CONCRETE_INSTRUCTION(StoreCodeEntry, "store-code-entry")
1790 DECLARE_HYDROGEN_ACCESSOR(StoreCodeEntry)
1794 class LInnerAllocatedObject final : public LTemplateInstruction<1, 2, 0> {
1796 LInnerAllocatedObject(LOperand* base_object, LOperand* offset) {
1797 inputs_[0] = base_object;
1798 inputs_[1] = offset;
1801 LOperand* base_object() const { return inputs_[0]; }
1802 LOperand* offset() const { return inputs_[1]; }
1804 void PrintDataTo(StringStream* stream) override;
1806 DECLARE_CONCRETE_INSTRUCTION(InnerAllocatedObject, "inner-allocated-object")
1810 class LThisFunction final : public LTemplateInstruction<1, 0, 0> {
1812 DECLARE_CONCRETE_INSTRUCTION(ThisFunction, "this-function")
1813 DECLARE_HYDROGEN_ACCESSOR(ThisFunction)
1817 class LContext final : public LTemplateInstruction<1, 0, 0> {
1819 DECLARE_CONCRETE_INSTRUCTION(Context, "context")
1820 DECLARE_HYDROGEN_ACCESSOR(Context)
1824 class LDeclareGlobals final : public LTemplateInstruction<0, 1, 0> {
1826 explicit LDeclareGlobals(LOperand* context) {
1827 inputs_[0] = context;
1830 LOperand* context() { return inputs_[0]; }
1832 DECLARE_CONCRETE_INSTRUCTION(DeclareGlobals, "declare-globals")
1833 DECLARE_HYDROGEN_ACCESSOR(DeclareGlobals)
1837 class LCallJSFunction final : public LTemplateInstruction<1, 1, 0> {
1839 explicit LCallJSFunction(LOperand* function) {
1840 inputs_[0] = function;
1843 LOperand* function() { return inputs_[0]; }
1845 DECLARE_CONCRETE_INSTRUCTION(CallJSFunction, "call-js-function")
1846 DECLARE_HYDROGEN_ACCESSOR(CallJSFunction)
1848 void PrintDataTo(StringStream* stream) override;
1850 int arity() const { return hydrogen()->argument_count() - 1; }
1854 class LCallWithDescriptor final : public LTemplateResultInstruction<1> {
1856 LCallWithDescriptor(CallInterfaceDescriptor descriptor,
1857 const ZoneList<LOperand*>& operands, Zone* zone)
1858 : descriptor_(descriptor),
1859 inputs_(descriptor.GetRegisterParameterCount() +
1860 kImplicitRegisterParameterCount,
1862 DCHECK(descriptor.GetRegisterParameterCount() +
1863 kImplicitRegisterParameterCount ==
1865 inputs_.AddAll(operands, zone);
1868 LOperand* target() const { return inputs_[0]; }
1870 const CallInterfaceDescriptor descriptor() { return descriptor_; }
1872 DECLARE_HYDROGEN_ACCESSOR(CallWithDescriptor)
1874 // The target and context are passed as implicit parameters that are not
1875 // explicitly listed in the descriptor.
1876 static const int kImplicitRegisterParameterCount = 2;
1879 DECLARE_CONCRETE_INSTRUCTION(CallWithDescriptor, "call-with-descriptor")
1881 void PrintDataTo(StringStream* stream) override;
1883 int arity() const { return hydrogen()->argument_count() - 1; }
1885 CallInterfaceDescriptor descriptor_;
1886 ZoneList<LOperand*> inputs_;
1888 // Iterator support.
1889 int InputCount() final { return inputs_.length(); }
1890 LOperand* InputAt(int i) final { return inputs_[i]; }
1892 int TempCount() final { return 0; }
1893 LOperand* TempAt(int i) final { return NULL; }
1897 class LInvokeFunction final : public LTemplateInstruction<1, 2, 0> {
1899 LInvokeFunction(LOperand* context, LOperand* function) {
1900 inputs_[0] = context;
1901 inputs_[1] = function;
1904 LOperand* context() { return inputs_[0]; }
1905 LOperand* function() { return inputs_[1]; }
1907 DECLARE_CONCRETE_INSTRUCTION(InvokeFunction, "invoke-function")
1908 DECLARE_HYDROGEN_ACCESSOR(InvokeFunction)
1910 void PrintDataTo(StringStream* stream) override;
1912 int arity() const { return hydrogen()->argument_count() - 1; }
1916 class LCallFunction final : public LTemplateInstruction<1, 2, 2> {
1918 LCallFunction(LOperand* context, LOperand* function, LOperand* slot,
1920 inputs_[0] = context;
1921 inputs_[1] = function;
1926 LOperand* context() { return inputs_[0]; }
1927 LOperand* function() { return inputs_[1]; }
1928 LOperand* temp_slot() { return temps_[0]; }
1929 LOperand* temp_vector() { return temps_[1]; }
1931 DECLARE_CONCRETE_INSTRUCTION(CallFunction, "call-function")
1932 DECLARE_HYDROGEN_ACCESSOR(CallFunction)
1934 int arity() const { return hydrogen()->argument_count() - 1; }
1935 void PrintDataTo(StringStream* stream) override;
1939 class LCallNew final : public LTemplateInstruction<1, 2, 0> {
1941 LCallNew(LOperand* context, LOperand* constructor) {
1942 inputs_[0] = context;
1943 inputs_[1] = constructor;
1946 LOperand* context() { return inputs_[0]; }
1947 LOperand* constructor() { return inputs_[1]; }
1949 DECLARE_CONCRETE_INSTRUCTION(CallNew, "call-new")
1950 DECLARE_HYDROGEN_ACCESSOR(CallNew)
1952 void PrintDataTo(StringStream* stream) override;
1954 int arity() const { return hydrogen()->argument_count() - 1; }
1958 class LCallNewArray final : public LTemplateInstruction<1, 2, 0> {
1960 LCallNewArray(LOperand* context, LOperand* constructor) {
1961 inputs_[0] = context;
1962 inputs_[1] = constructor;
1965 LOperand* context() { return inputs_[0]; }
1966 LOperand* constructor() { return inputs_[1]; }
1968 DECLARE_CONCRETE_INSTRUCTION(CallNewArray, "call-new-array")
1969 DECLARE_HYDROGEN_ACCESSOR(CallNewArray)
1971 void PrintDataTo(StringStream* stream) override;
1973 int arity() const { return hydrogen()->argument_count() - 1; }
1977 class LCallRuntime final : public LTemplateInstruction<1, 1, 0> {
1979 explicit LCallRuntime(LOperand* context) {
1980 inputs_[0] = context;
1983 LOperand* context() { return inputs_[0]; }
1985 DECLARE_CONCRETE_INSTRUCTION(CallRuntime, "call-runtime")
1986 DECLARE_HYDROGEN_ACCESSOR(CallRuntime)
1988 bool ClobbersDoubleRegisters(Isolate* isolate) const override {
1989 return save_doubles() == kDontSaveFPRegs;
1992 const Runtime::Function* function() const { return hydrogen()->function(); }
1993 int arity() const { return hydrogen()->argument_count(); }
1994 SaveFPRegsMode save_doubles() const { return hydrogen()->save_doubles(); }
1998 class LInteger32ToDouble final : public LTemplateInstruction<1, 1, 0> {
2000 explicit LInteger32ToDouble(LOperand* value) {
2004 LOperand* value() { return inputs_[0]; }
2006 DECLARE_CONCRETE_INSTRUCTION(Integer32ToDouble, "int32-to-double")
2010 class LUint32ToDouble final : public LTemplateInstruction<1, 1, 0> {
2012 explicit LUint32ToDouble(LOperand* value) {
2016 LOperand* value() { return inputs_[0]; }
2018 DECLARE_CONCRETE_INSTRUCTION(Uint32ToDouble, "uint32-to-double")
2022 class LNumberTagU final : public LTemplateInstruction<1, 1, 2> {
2024 LNumberTagU(LOperand* value, LOperand* temp1, LOperand* temp2) {
2030 LOperand* value() { return inputs_[0]; }
2031 LOperand* temp1() { return temps_[0]; }
2032 LOperand* temp2() { return temps_[1]; }
2034 DECLARE_CONCRETE_INSTRUCTION(NumberTagU, "number-tag-u")
2038 class LNumberTagD final : public LTemplateInstruction<1, 1, 2> {
2040 LNumberTagD(LOperand* value, LOperand* temp, LOperand* temp2) {
2046 LOperand* value() { return inputs_[0]; }
2047 LOperand* temp() { return temps_[0]; }
2048 LOperand* temp2() { return temps_[1]; }
2050 DECLARE_CONCRETE_INSTRUCTION(NumberTagD, "number-tag-d")
2051 DECLARE_HYDROGEN_ACCESSOR(Change)
2055 class LDoubleToSmi final : public LTemplateInstruction<1, 1, 0> {
2057 explicit LDoubleToSmi(LOperand* value) {
2061 LOperand* value() { return inputs_[0]; }
2063 DECLARE_CONCRETE_INSTRUCTION(DoubleToSmi, "double-to-smi")
2064 DECLARE_HYDROGEN_ACCESSOR(UnaryOperation)
2066 bool truncating() { return hydrogen()->CanTruncateToInt32(); }
2070 // Sometimes truncating conversion from a tagged value to an int32.
2071 class LDoubleToI final : public LTemplateInstruction<1, 1, 0> {
2073 explicit LDoubleToI(LOperand* value) {
2077 LOperand* value() { return inputs_[0]; }
2079 DECLARE_CONCRETE_INSTRUCTION(DoubleToI, "double-to-i")
2080 DECLARE_HYDROGEN_ACCESSOR(UnaryOperation)
2082 bool truncating() { return hydrogen()->CanTruncateToInt32(); }
2086 // Truncating conversion from a tagged value to an int32.
2087 class LTaggedToI final : public LTemplateInstruction<1, 1, 2> {
2089 LTaggedToI(LOperand* value,
2097 LOperand* value() { return inputs_[0]; }
2098 LOperand* temp() { return temps_[0]; }
2099 LOperand* temp2() { return temps_[1]; }
2101 DECLARE_CONCRETE_INSTRUCTION(TaggedToI, "tagged-to-i")
2102 DECLARE_HYDROGEN_ACCESSOR(Change)
2104 bool truncating() { return hydrogen()->CanTruncateToInt32(); }
2108 class LSmiTag final : public LTemplateInstruction<1, 1, 0> {
2110 explicit LSmiTag(LOperand* value) {
2114 LOperand* value() { return inputs_[0]; }
2116 DECLARE_CONCRETE_INSTRUCTION(SmiTag, "smi-tag")
2117 DECLARE_HYDROGEN_ACCESSOR(Change)
2121 class LNumberUntagD final : public LTemplateInstruction<1, 1, 0> {
2123 explicit LNumberUntagD(LOperand* value) {
2127 LOperand* value() { return inputs_[0]; }
2129 DECLARE_CONCRETE_INSTRUCTION(NumberUntagD, "double-untag")
2130 DECLARE_HYDROGEN_ACCESSOR(Change)
2134 class LSmiUntag final : public LTemplateInstruction<1, 1, 0> {
2136 LSmiUntag(LOperand* value, bool needs_check)
2137 : needs_check_(needs_check) {
2141 LOperand* value() { return inputs_[0]; }
2142 bool needs_check() const { return needs_check_; }
2144 DECLARE_CONCRETE_INSTRUCTION(SmiUntag, "smi-untag")
2151 class LStoreNamedField final : public LTemplateInstruction<0, 2, 1> {
2153 LStoreNamedField(LOperand* object, LOperand* value, LOperand* temp) {
2154 inputs_[0] = object;
2159 LOperand* object() { return inputs_[0]; }
2160 LOperand* value() { return inputs_[1]; }
2161 LOperand* temp() { return temps_[0]; }
2163 DECLARE_CONCRETE_INSTRUCTION(StoreNamedField, "store-named-field")
2164 DECLARE_HYDROGEN_ACCESSOR(StoreNamedField)
2166 void PrintDataTo(StringStream* stream) override;
2168 Representation representation() const {
2169 return hydrogen()->field_representation();
2174 class LStoreNamedGeneric final : public LTemplateInstruction<0, 3, 2> {
2176 LStoreNamedGeneric(LOperand* context, LOperand* object, LOperand* value,
2177 LOperand* slot, LOperand* vector) {
2178 inputs_[0] = context;
2179 inputs_[1] = object;
2185 LOperand* context() { return inputs_[0]; }
2186 LOperand* object() { return inputs_[1]; }
2187 LOperand* value() { return inputs_[2]; }
2188 LOperand* temp_slot() { return temps_[0]; }
2189 LOperand* temp_vector() { return temps_[1]; }
2191 DECLARE_CONCRETE_INSTRUCTION(StoreNamedGeneric, "store-named-generic")
2192 DECLARE_HYDROGEN_ACCESSOR(StoreNamedGeneric)
2194 void PrintDataTo(StringStream* stream) override;
2196 Handle<Object> name() const { return hydrogen()->name(); }
2197 LanguageMode language_mode() { return hydrogen()->language_mode(); }
2201 class LStoreGlobalViaContext final : public LTemplateInstruction<0, 2, 0> {
2203 LStoreGlobalViaContext(LOperand* context, LOperand* value) {
2204 inputs_[0] = context;
2208 LOperand* context() { return inputs_[0]; }
2209 LOperand* value() { return inputs_[1]; }
2211 DECLARE_CONCRETE_INSTRUCTION(StoreGlobalViaContext,
2212 "store-global-via-context")
2213 DECLARE_HYDROGEN_ACCESSOR(StoreGlobalViaContext)
2215 void PrintDataTo(StringStream* stream) override;
2217 int depth() { return hydrogen()->depth(); }
2218 int slot_index() { return hydrogen()->slot_index(); }
2219 LanguageMode language_mode() { return hydrogen()->language_mode(); }
2223 class LStoreKeyed final : public LTemplateInstruction<0, 3, 0> {
2225 LStoreKeyed(LOperand* object, LOperand* key, LOperand* value) {
2226 inputs_[0] = object;
2231 bool is_fixed_typed_array() const {
2232 return hydrogen()->is_fixed_typed_array();
2234 LOperand* elements() { return inputs_[0]; }
2235 LOperand* key() { return inputs_[1]; }
2236 LOperand* value() { return inputs_[2]; }
2237 ElementsKind elements_kind() const {
2238 return hydrogen()->elements_kind();
2241 DECLARE_CONCRETE_INSTRUCTION(StoreKeyed, "store-keyed")
2242 DECLARE_HYDROGEN_ACCESSOR(StoreKeyed)
2244 void PrintDataTo(StringStream* stream) override;
2245 bool NeedsCanonicalization() { return hydrogen()->NeedsCanonicalization(); }
2246 uint32_t base_offset() const { return hydrogen()->base_offset(); }
2250 class LStoreKeyedGeneric final : public LTemplateInstruction<0, 4, 2> {
2252 LStoreKeyedGeneric(LOperand* context, LOperand* object, LOperand* key,
2253 LOperand* value, LOperand* slot, LOperand* vector) {
2254 inputs_[0] = context;
2255 inputs_[1] = object;
2262 LOperand* context() { return inputs_[0]; }
2263 LOperand* object() { return inputs_[1]; }
2264 LOperand* key() { return inputs_[2]; }
2265 LOperand* value() { return inputs_[3]; }
2266 LOperand* temp_slot() { return temps_[0]; }
2267 LOperand* temp_vector() { return temps_[1]; }
2269 DECLARE_CONCRETE_INSTRUCTION(StoreKeyedGeneric, "store-keyed-generic")
2270 DECLARE_HYDROGEN_ACCESSOR(StoreKeyedGeneric)
2272 void PrintDataTo(StringStream* stream) override;
2274 LanguageMode language_mode() { return hydrogen()->language_mode(); }
2278 class LTransitionElementsKind final : public LTemplateInstruction<0, 2, 1> {
2280 LTransitionElementsKind(LOperand* object,
2282 LOperand* new_map_temp) {
2283 inputs_[0] = object;
2284 inputs_[1] = context;
2285 temps_[0] = new_map_temp;
2288 LOperand* context() { return inputs_[1]; }
2289 LOperand* object() { return inputs_[0]; }
2290 LOperand* new_map_temp() { return temps_[0]; }
2292 DECLARE_CONCRETE_INSTRUCTION(TransitionElementsKind,
2293 "transition-elements-kind")
2294 DECLARE_HYDROGEN_ACCESSOR(TransitionElementsKind)
2296 void PrintDataTo(StringStream* stream) override;
2298 Handle<Map> original_map() { return hydrogen()->original_map().handle(); }
2299 Handle<Map> transitioned_map() {
2300 return hydrogen()->transitioned_map().handle();
2302 ElementsKind from_kind() { return hydrogen()->from_kind(); }
2303 ElementsKind to_kind() { return hydrogen()->to_kind(); }
2307 class LTrapAllocationMemento final : public LTemplateInstruction<0, 1, 1> {
2309 LTrapAllocationMemento(LOperand* object,
2311 inputs_[0] = object;
2315 LOperand* object() { return inputs_[0]; }
2316 LOperand* temp() { return temps_[0]; }
2318 DECLARE_CONCRETE_INSTRUCTION(TrapAllocationMemento,
2319 "trap-allocation-memento")
2323 class LMaybeGrowElements final : public LTemplateInstruction<1, 5, 0> {
2325 LMaybeGrowElements(LOperand* context, LOperand* object, LOperand* elements,
2326 LOperand* key, LOperand* current_capacity) {
2327 inputs_[0] = context;
2328 inputs_[1] = object;
2329 inputs_[2] = elements;
2331 inputs_[4] = current_capacity;
2334 LOperand* context() { return inputs_[0]; }
2335 LOperand* object() { return inputs_[1]; }
2336 LOperand* elements() { return inputs_[2]; }
2337 LOperand* key() { return inputs_[3]; }
2338 LOperand* current_capacity() { return inputs_[4]; }
2340 DECLARE_HYDROGEN_ACCESSOR(MaybeGrowElements)
2341 DECLARE_CONCRETE_INSTRUCTION(MaybeGrowElements, "maybe-grow-elements")
2345 class LStringAdd final : public LTemplateInstruction<1, 3, 0> {
2347 LStringAdd(LOperand* context, LOperand* left, LOperand* right) {
2348 inputs_[0] = context;
2353 LOperand* context() { return inputs_[0]; }
2354 LOperand* left() { return inputs_[1]; }
2355 LOperand* right() { return inputs_[2]; }
2357 DECLARE_CONCRETE_INSTRUCTION(StringAdd, "string-add")
2358 DECLARE_HYDROGEN_ACCESSOR(StringAdd)
2362 class LStringCharCodeAt final : public LTemplateInstruction<1, 3, 0> {
2364 LStringCharCodeAt(LOperand* context, LOperand* string, LOperand* index) {
2365 inputs_[0] = context;
2366 inputs_[1] = string;
2370 LOperand* context() { return inputs_[0]; }
2371 LOperand* string() { return inputs_[1]; }
2372 LOperand* index() { return inputs_[2]; }
2374 DECLARE_CONCRETE_INSTRUCTION(StringCharCodeAt, "string-char-code-at")
2375 DECLARE_HYDROGEN_ACCESSOR(StringCharCodeAt)
2379 class LStringCharFromCode final : public LTemplateInstruction<1, 2, 0> {
2381 explicit LStringCharFromCode(LOperand* context, LOperand* char_code) {
2382 inputs_[0] = context;
2383 inputs_[1] = char_code;
2386 LOperand* context() { return inputs_[0]; }
2387 LOperand* char_code() { return inputs_[1]; }
2389 DECLARE_CONCRETE_INSTRUCTION(StringCharFromCode, "string-char-from-code")
2390 DECLARE_HYDROGEN_ACCESSOR(StringCharFromCode)
2394 class LCheckValue final : public LTemplateInstruction<0, 1, 0> {
2396 explicit LCheckValue(LOperand* value) {
2400 LOperand* value() { return inputs_[0]; }
2402 DECLARE_CONCRETE_INSTRUCTION(CheckValue, "check-value")
2403 DECLARE_HYDROGEN_ACCESSOR(CheckValue)
2407 class LCheckArrayBufferNotNeutered final
2408 : public LTemplateInstruction<0, 1, 0> {
2410 explicit LCheckArrayBufferNotNeutered(LOperand* view) { inputs_[0] = view; }
2412 LOperand* view() { return inputs_[0]; }
2414 DECLARE_CONCRETE_INSTRUCTION(CheckArrayBufferNotNeutered,
2415 "check-array-buffer-not-neutered")
2416 DECLARE_HYDROGEN_ACCESSOR(CheckArrayBufferNotNeutered)
2420 class LCheckInstanceType final : public LTemplateInstruction<0, 1, 0> {
2422 explicit LCheckInstanceType(LOperand* value) {
2426 LOperand* value() { return inputs_[0]; }
2428 DECLARE_CONCRETE_INSTRUCTION(CheckInstanceType, "check-instance-type")
2429 DECLARE_HYDROGEN_ACCESSOR(CheckInstanceType)
2433 class LCheckMaps final : public LTemplateInstruction<0, 1, 0> {
2435 explicit LCheckMaps(LOperand* value = NULL) {
2439 LOperand* value() { return inputs_[0]; }
2441 DECLARE_CONCRETE_INSTRUCTION(CheckMaps, "check-maps")
2442 DECLARE_HYDROGEN_ACCESSOR(CheckMaps)
2446 class LCheckSmi final : public LTemplateInstruction<1, 1, 0> {
2448 explicit LCheckSmi(LOperand* value) {
2452 LOperand* value() { return inputs_[0]; }
2454 DECLARE_CONCRETE_INSTRUCTION(CheckSmi, "check-smi")
2458 class LCheckNonSmi final : public LTemplateInstruction<0, 1, 0> {
2460 explicit LCheckNonSmi(LOperand* value) {
2464 LOperand* value() { return inputs_[0]; }
2466 DECLARE_CONCRETE_INSTRUCTION(CheckNonSmi, "check-non-smi")
2467 DECLARE_HYDROGEN_ACCESSOR(CheckHeapObject)
2471 class LClampDToUint8 final : public LTemplateInstruction<1, 1, 1> {
2473 LClampDToUint8(LOperand* unclamped, LOperand* temp) {
2474 inputs_[0] = unclamped;
2478 LOperand* unclamped() { return inputs_[0]; }
2479 LOperand* temp() { return temps_[0]; }
2481 DECLARE_CONCRETE_INSTRUCTION(ClampDToUint8, "clamp-d-to-uint8")
2485 class LClampIToUint8 final : public LTemplateInstruction<1, 1, 0> {
2487 explicit LClampIToUint8(LOperand* unclamped) {
2488 inputs_[0] = unclamped;
2491 LOperand* unclamped() { return inputs_[0]; }
2493 DECLARE_CONCRETE_INSTRUCTION(ClampIToUint8, "clamp-i-to-uint8")
2497 class LClampTToUint8 final : public LTemplateInstruction<1, 1, 1> {
2499 LClampTToUint8(LOperand* unclamped, LOperand* temp) {
2500 inputs_[0] = unclamped;
2504 LOperand* unclamped() { return inputs_[0]; }
2505 LOperand* temp() { return temps_[0]; }
2507 DECLARE_CONCRETE_INSTRUCTION(ClampTToUint8, "clamp-t-to-uint8")
2511 class LDoubleBits final : public LTemplateInstruction<1, 1, 0> {
2513 explicit LDoubleBits(LOperand* value) {
2517 LOperand* value() { return inputs_[0]; }
2519 DECLARE_CONCRETE_INSTRUCTION(DoubleBits, "double-bits")
2520 DECLARE_HYDROGEN_ACCESSOR(DoubleBits)
2524 class LConstructDouble final : public LTemplateInstruction<1, 2, 0> {
2526 LConstructDouble(LOperand* hi, LOperand* lo) {
2531 LOperand* hi() { return inputs_[0]; }
2532 LOperand* lo() { return inputs_[1]; }
2534 DECLARE_CONCRETE_INSTRUCTION(ConstructDouble, "construct-double")
2538 class LAllocate final : public LTemplateInstruction<1, 2, 2> {
2540 LAllocate(LOperand* context,
2544 inputs_[0] = context;
2550 LOperand* context() { return inputs_[0]; }
2551 LOperand* size() { return inputs_[1]; }
2552 LOperand* temp1() { return temps_[0]; }
2553 LOperand* temp2() { return temps_[1]; }
2555 DECLARE_CONCRETE_INSTRUCTION(Allocate, "allocate")
2556 DECLARE_HYDROGEN_ACCESSOR(Allocate)
2560 class LRegExpLiteral final : public LTemplateInstruction<1, 1, 0> {
2562 explicit LRegExpLiteral(LOperand* context) {
2563 inputs_[0] = context;
2566 LOperand* context() { return inputs_[0]; }
2568 DECLARE_CONCRETE_INSTRUCTION(RegExpLiteral, "regexp-literal")
2569 DECLARE_HYDROGEN_ACCESSOR(RegExpLiteral)
2573 class LToFastProperties final : public LTemplateInstruction<1, 1, 0> {
2575 explicit LToFastProperties(LOperand* value) {
2579 LOperand* value() { return inputs_[0]; }
2581 DECLARE_CONCRETE_INSTRUCTION(ToFastProperties, "to-fast-properties")
2582 DECLARE_HYDROGEN_ACCESSOR(ToFastProperties)
2586 class LTypeof final : public LTemplateInstruction<1, 2, 0> {
2588 LTypeof(LOperand* context, LOperand* value) {
2589 inputs_[0] = context;
2593 LOperand* context() { return inputs_[0]; }
2594 LOperand* value() { return inputs_[1]; }
2596 DECLARE_CONCRETE_INSTRUCTION(Typeof, "typeof")
2600 class LTypeofIsAndBranch final : public LControlInstruction<1, 0> {
2602 explicit LTypeofIsAndBranch(LOperand* value) {
2606 LOperand* value() { return inputs_[0]; }
2608 DECLARE_CONCRETE_INSTRUCTION(TypeofIsAndBranch, "typeof-is-and-branch")
2609 DECLARE_HYDROGEN_ACCESSOR(TypeofIsAndBranch)
2611 Handle<String> type_literal() { return hydrogen()->type_literal(); }
2613 void PrintDataTo(StringStream* stream) override;
2617 class LIsConstructCallAndBranch final : public LControlInstruction<0, 1> {
2619 explicit LIsConstructCallAndBranch(LOperand* temp) {
2623 LOperand* temp() { return temps_[0]; }
2625 DECLARE_CONCRETE_INSTRUCTION(IsConstructCallAndBranch,
2626 "is-construct-call-and-branch")
2630 class LOsrEntry final : public LTemplateInstruction<0, 0, 0> {
2634 bool HasInterestingComment(LCodeGen* gen) const override { return false; }
2635 DECLARE_CONCRETE_INSTRUCTION(OsrEntry, "osr-entry")
2639 class LStackCheck final : public LTemplateInstruction<0, 1, 0> {
2641 explicit LStackCheck(LOperand* context) {
2642 inputs_[0] = context;
2645 LOperand* context() { return inputs_[0]; }
2647 DECLARE_CONCRETE_INSTRUCTION(StackCheck, "stack-check")
2648 DECLARE_HYDROGEN_ACCESSOR(StackCheck)
2650 Label* done_label() { return &done_label_; }
2657 class LForInPrepareMap final : public LTemplateInstruction<1, 2, 0> {
2659 LForInPrepareMap(LOperand* context, LOperand* object) {
2660 inputs_[0] = context;
2661 inputs_[1] = object;
2664 LOperand* context() { return inputs_[0]; }
2665 LOperand* object() { return inputs_[1]; }
2667 DECLARE_CONCRETE_INSTRUCTION(ForInPrepareMap, "for-in-prepare-map")
2671 class LForInCacheArray final : public LTemplateInstruction<1, 1, 0> {
2673 explicit LForInCacheArray(LOperand* map) {
2677 LOperand* map() { return inputs_[0]; }
2679 DECLARE_CONCRETE_INSTRUCTION(ForInCacheArray, "for-in-cache-array")
2682 return HForInCacheArray::cast(this->hydrogen_value())->idx();
2687 class LCheckMapValue final : public LTemplateInstruction<0, 2, 0> {
2689 LCheckMapValue(LOperand* value, LOperand* map) {
2694 LOperand* value() { return inputs_[0]; }
2695 LOperand* map() { return inputs_[1]; }
2697 DECLARE_CONCRETE_INSTRUCTION(CheckMapValue, "check-map-value")
2701 class LLoadFieldByIndex final : public LTemplateInstruction<1, 2, 0> {
2703 LLoadFieldByIndex(LOperand* object, LOperand* index) {
2704 inputs_[0] = object;
2708 LOperand* object() { return inputs_[0]; }
2709 LOperand* index() { return inputs_[1]; }
2711 DECLARE_CONCRETE_INSTRUCTION(LoadFieldByIndex, "load-field-by-index")
2715 class LStoreFrameContext: public LTemplateInstruction<0, 1, 0> {
2717 explicit LStoreFrameContext(LOperand* context) {
2718 inputs_[0] = context;
2721 LOperand* context() { return inputs_[0]; }
2723 DECLARE_CONCRETE_INSTRUCTION(StoreFrameContext, "store-frame-context")
2727 class LAllocateBlockContext: public LTemplateInstruction<1, 2, 0> {
2729 LAllocateBlockContext(LOperand* context, LOperand* function) {
2730 inputs_[0] = context;
2731 inputs_[1] = function;
2734 LOperand* context() { return inputs_[0]; }
2735 LOperand* function() { return inputs_[1]; }
2737 Handle<ScopeInfo> scope_info() { return hydrogen()->scope_info(); }
2739 DECLARE_CONCRETE_INSTRUCTION(AllocateBlockContext, "allocate-block-context")
2740 DECLARE_HYDROGEN_ACCESSOR(AllocateBlockContext)
2744 class LChunkBuilder;
2745 class LPlatformChunk final : public LChunk {
2747 LPlatformChunk(CompilationInfo* info, HGraph* graph)
2748 : LChunk(info, graph) { }
2750 int GetNextSpillIndex(RegisterKind kind);
2751 LOperand* GetNextSpillSlot(RegisterKind kind);
2755 class LChunkBuilder final : public LChunkBuilderBase {
2757 LChunkBuilder(CompilationInfo* info, HGraph* graph, LAllocator* allocator)
2758 : LChunkBuilderBase(info, graph),
2759 current_instruction_(NULL),
2760 current_block_(NULL),
2762 allocator_(allocator) {}
2764 // Build the sequence for the graph.
2765 LPlatformChunk* Build();
2767 // Declare methods that deal with the individual node types.
2768 #define DECLARE_DO(type) LInstruction* Do##type(H##type* node);
2769 HYDROGEN_CONCRETE_INSTRUCTION_LIST(DECLARE_DO)
2772 LInstruction* DoMultiplyAdd(HMul* mul, HValue* addend);
2774 static bool HasMagicNumberForDivisor(int32_t divisor);
2776 LInstruction* DoMathFloor(HUnaryMathOperation* instr);
2777 LInstruction* DoMathRound(HUnaryMathOperation* instr);
2778 LInstruction* DoMathFround(HUnaryMathOperation* instr);
2779 LInstruction* DoMathAbs(HUnaryMathOperation* instr);
2780 LInstruction* DoMathLog(HUnaryMathOperation* instr);
2781 LInstruction* DoMathExp(HUnaryMathOperation* instr);
2782 LInstruction* DoMathSqrt(HUnaryMathOperation* instr);
2783 LInstruction* DoMathPowHalf(HUnaryMathOperation* instr);
2784 LInstruction* DoMathClz32(HUnaryMathOperation* instr);
2785 LInstruction* DoDivByPowerOf2I(HDiv* instr);
2786 LInstruction* DoDivByConstI(HDiv* instr);
2787 LInstruction* DoDivI(HDiv* instr);
2788 LInstruction* DoModByPowerOf2I(HMod* instr);
2789 LInstruction* DoModByConstI(HMod* instr);
2790 LInstruction* DoModI(HMod* instr);
2791 LInstruction* DoFlooringDivByPowerOf2I(HMathFloorOfDiv* instr);
2792 LInstruction* DoFlooringDivByConstI(HMathFloorOfDiv* instr);
2793 LInstruction* DoFlooringDivI(HMathFloorOfDiv* instr);
2796 // Methods for getting operands for Use / Define / Temp.
2797 LUnallocated* ToUnallocated(Register reg);
2798 LUnallocated* ToUnallocated(DoubleRegister reg);
2800 // Methods for setting up define-use relationships.
2801 MUST_USE_RESULT LOperand* Use(HValue* value, LUnallocated* operand);
2802 MUST_USE_RESULT LOperand* UseFixed(HValue* value, Register fixed_register);
2803 MUST_USE_RESULT LOperand* UseFixedDouble(HValue* value,
2804 DoubleRegister fixed_register);
2806 // A value that is guaranteed to be allocated to a register.
2807 // Operand created by UseRegister is guaranteed to be live until the end of
2808 // instruction. This means that register allocator will not reuse it's
2809 // register for any other operand inside instruction.
2810 // Operand created by UseRegisterAtStart is guaranteed to be live only at
2811 // instruction start. Register allocator is free to assign the same register
2812 // to some other operand used inside instruction (i.e. temporary or
2814 MUST_USE_RESULT LOperand* UseRegister(HValue* value);
2815 MUST_USE_RESULT LOperand* UseRegisterAtStart(HValue* value);
2817 // An input operand in a register that may be trashed.
2818 MUST_USE_RESULT LOperand* UseTempRegister(HValue* value);
2820 // An input operand in a register or stack slot.
2821 MUST_USE_RESULT LOperand* Use(HValue* value);
2822 MUST_USE_RESULT LOperand* UseAtStart(HValue* value);
2824 // An input operand in a register, stack slot or a constant operand.
2825 MUST_USE_RESULT LOperand* UseOrConstant(HValue* value);
2826 MUST_USE_RESULT LOperand* UseOrConstantAtStart(HValue* value);
2828 // An input operand in a register or a constant operand.
2829 MUST_USE_RESULT LOperand* UseRegisterOrConstant(HValue* value);
2830 MUST_USE_RESULT LOperand* UseRegisterOrConstantAtStart(HValue* value);
2832 // An input operand in a constant operand.
2833 MUST_USE_RESULT LOperand* UseConstant(HValue* value);
2835 // An input operand in register, stack slot or a constant operand.
2836 // Will not be moved to a register even if one is freely available.
2837 MUST_USE_RESULT LOperand* UseAny(HValue* value) override;
2839 // Temporary operand that must be in a register.
2840 MUST_USE_RESULT LUnallocated* TempRegister();
2841 MUST_USE_RESULT LUnallocated* TempDoubleRegister();
2842 MUST_USE_RESULT LOperand* FixedTemp(Register reg);
2843 MUST_USE_RESULT LOperand* FixedTemp(DoubleRegister reg);
2845 // Methods for setting up define-use relationships.
2846 // Return the same instruction that they are passed.
2847 LInstruction* Define(LTemplateResultInstruction<1>* instr,
2848 LUnallocated* result);
2849 LInstruction* DefineAsRegister(LTemplateResultInstruction<1>* instr);
2850 LInstruction* DefineAsSpilled(LTemplateResultInstruction<1>* instr,
2852 LInstruction* DefineSameAsFirst(LTemplateResultInstruction<1>* instr);
2853 LInstruction* DefineFixed(LTemplateResultInstruction<1>* instr,
2855 LInstruction* DefineFixedDouble(LTemplateResultInstruction<1>* instr,
2856 DoubleRegister reg);
2857 LInstruction* AssignEnvironment(LInstruction* instr);
2858 LInstruction* AssignPointerMap(LInstruction* instr);
2860 enum CanDeoptimize { CAN_DEOPTIMIZE_EAGERLY, CANNOT_DEOPTIMIZE_EAGERLY };
2862 // By default we assume that instruction sequences generated for calls
2863 // cannot deoptimize eagerly and we do not attach environment to this
2865 LInstruction* MarkAsCall(
2866 LInstruction* instr,
2867 HInstruction* hinstr,
2868 CanDeoptimize can_deoptimize = CANNOT_DEOPTIMIZE_EAGERLY);
2870 void VisitInstruction(HInstruction* current);
2871 void AddInstruction(LInstruction* instr, HInstruction* current);
2873 void DoBasicBlock(HBasicBlock* block, HBasicBlock* next_block);
2874 LInstruction* DoBit(Token::Value op, HBitwiseBinaryOperation* instr);
2875 LInstruction* DoShift(Token::Value op, HBitwiseBinaryOperation* instr);
2876 LInstruction* DoArithmeticD(Token::Value op,
2877 HArithmeticBinaryOperation* instr);
2878 LInstruction* DoArithmeticT(Token::Value op,
2879 HBinaryOperation* instr);
2881 HInstruction* current_instruction_;
2882 HBasicBlock* current_block_;
2883 HBasicBlock* next_block_;
2884 LAllocator* allocator_;
2886 DISALLOW_COPY_AND_ASSIGN(LChunkBuilder);
2889 #undef DECLARE_HYDROGEN_ACCESSOR
2890 #undef DECLARE_CONCRETE_INSTRUCTION
2892 } } // namespace v8::internal
2894 #endif // V8_MIPS_LITHIUM_MIPS_H_