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) \
85 V(GetCachedArrayIndex) \
87 V(HasCachedArrayIndexAndBranch) \
88 V(HasInstanceTypeAndBranch) \
89 V(InnerAllocatedObject) \
91 V(InstanceOfKnownGlobal) \
93 V(Integer32ToDouble) \
95 V(IsConstructCallAndBranch) \
96 V(IsObjectAndBranch) \
97 V(IsStringAndBranch) \
99 V(IsUndetectableAndBranch) \
104 V(LoadFieldByIndex) \
105 V(LoadFunctionPrototype) \
106 V(LoadGlobalGeneric) \
107 V(LoadGlobalViaContext) \
109 V(LoadKeyedGeneric) \
111 V(LoadNamedGeneric) \
123 V(MaybeGrowElements) \
139 V(SeqStringGetChar) \
140 V(SeqStringSetChar) \
146 V(StoreContextSlot) \
147 V(StoreFrameContext) \
148 V(StoreGlobalViaContext) \
150 V(StoreKeyedGeneric) \
152 V(StoreNamedGeneric) \
154 V(StringCharCodeAt) \
155 V(StringCharFromCode) \
156 V(StringCompareAndBranch) \
161 V(ToFastProperties) \
162 V(TransitionElementsKind) \
163 V(TrapAllocationMemento) \
165 V(TypeofIsAndBranch) \
170 #define DECLARE_CONCRETE_INSTRUCTION(type, mnemonic) \
171 Opcode opcode() const final { return LInstruction::k##type; } \
172 void CompileToNative(LCodeGen* generator) final; \
173 const char* Mnemonic() const final { return mnemonic; } \
174 static L##type* cast(LInstruction* instr) { \
175 DCHECK(instr->Is##type()); \
176 return reinterpret_cast<L##type*>(instr); \
180 #define DECLARE_HYDROGEN_ACCESSOR(type) \
181 H##type* hydrogen() const { \
182 return H##type::cast(hydrogen_value()); \
186 class LInstruction : public ZoneObject {
189 : environment_(NULL),
190 hydrogen_value_(NULL),
191 bit_field_(IsCallBits::encode(false)) {
194 virtual ~LInstruction() {}
196 virtual void CompileToNative(LCodeGen* generator) = 0;
197 virtual const char* Mnemonic() const = 0;
198 virtual void PrintTo(StringStream* stream);
199 virtual void PrintDataTo(StringStream* stream);
200 virtual void PrintOutputOperandTo(StringStream* stream);
203 // Declare a unique enum value for each instruction.
204 #define DECLARE_OPCODE(type) k##type,
205 LITHIUM_CONCRETE_INSTRUCTION_LIST(DECLARE_OPCODE)
206 kNumberOfInstructions
207 #undef DECLARE_OPCODE
210 virtual Opcode opcode() const = 0;
212 // Declare non-virtual type testers for all leaf IR classes.
213 #define DECLARE_PREDICATE(type) \
214 bool Is##type() const { return opcode() == k##type; }
215 LITHIUM_CONCRETE_INSTRUCTION_LIST(DECLARE_PREDICATE)
216 #undef DECLARE_PREDICATE
218 // Declare virtual predicates for instructions that don't have
220 virtual bool IsGap() const { return false; }
222 virtual bool IsControl() const { return false; }
224 // Try deleting this instruction if possible.
225 virtual bool TryDelete() { return false; }
227 void set_environment(LEnvironment* env) { environment_ = env; }
228 LEnvironment* environment() const { return environment_; }
229 bool HasEnvironment() const { return environment_ != NULL; }
231 void set_pointer_map(LPointerMap* p) { pointer_map_.set(p); }
232 LPointerMap* pointer_map() const { return pointer_map_.get(); }
233 bool HasPointerMap() const { return pointer_map_.is_set(); }
235 void set_hydrogen_value(HValue* value) { hydrogen_value_ = value; }
236 HValue* hydrogen_value() const { return hydrogen_value_; }
238 virtual void SetDeferredLazyDeoptimizationEnvironment(LEnvironment* env) { }
240 void MarkAsCall() { bit_field_ = IsCallBits::update(bit_field_, true); }
241 bool IsCall() const { return IsCallBits::decode(bit_field_); }
243 // Interface to the register allocator and iterators.
244 bool ClobbersTemps() const { return IsCall(); }
245 bool ClobbersRegisters() const { return IsCall(); }
246 virtual bool ClobbersDoubleRegisters(Isolate* isolate) const {
250 // Interface to the register allocator and iterators.
251 bool IsMarkedAsCall() const { return IsCall(); }
253 virtual bool HasResult() const = 0;
254 virtual LOperand* result() const = 0;
256 LOperand* FirstInput() { return InputAt(0); }
257 LOperand* Output() { return HasResult() ? result() : NULL; }
259 virtual bool HasInterestingComment(LCodeGen* gen) const { return true; }
265 virtual int InputCount() = 0;
266 virtual LOperand* InputAt(int i) = 0;
269 // Iterator interface.
270 friend class InputIterator;
272 friend class TempIterator;
273 virtual int TempCount() = 0;
274 virtual LOperand* TempAt(int i) = 0;
276 class IsCallBits: public BitField<bool, 0, 1> {};
278 LEnvironment* environment_;
279 SetOncePointer<LPointerMap> pointer_map_;
280 HValue* hydrogen_value_;
285 // R = number of result operands (0 or 1).
287 class LTemplateResultInstruction : public LInstruction {
289 // Allow 0 or 1 output operands.
290 STATIC_ASSERT(R == 0 || R == 1);
291 bool HasResult() const final { return R != 0 && result() != NULL; }
292 void set_result(LOperand* operand) { results_[0] = operand; }
293 LOperand* result() const override { return results_[0]; }
296 EmbeddedContainer<LOperand*, R> results_;
300 // R = number of result operands (0 or 1).
301 // I = number of input operands.
302 // T = number of temporary operands.
303 template<int R, int I, int T>
304 class LTemplateInstruction : public LTemplateResultInstruction<R> {
306 EmbeddedContainer<LOperand*, I> inputs_;
307 EmbeddedContainer<LOperand*, T> temps_;
311 int InputCount() final { return I; }
312 LOperand* InputAt(int i) final { return inputs_[i]; }
314 int TempCount() final { return T; }
315 LOperand* TempAt(int i) final { return temps_[i]; }
319 class LGap : public LTemplateInstruction<0, 0, 0> {
321 explicit LGap(HBasicBlock* block)
323 parallel_moves_[BEFORE] = NULL;
324 parallel_moves_[START] = NULL;
325 parallel_moves_[END] = NULL;
326 parallel_moves_[AFTER] = NULL;
329 // Can't use the DECLARE-macro here because of sub-classes.
330 bool IsGap() const final { return true; }
331 void PrintDataTo(StringStream* stream) override;
332 static LGap* cast(LInstruction* instr) {
333 DCHECK(instr->IsGap());
334 return reinterpret_cast<LGap*>(instr);
337 bool IsRedundant() const;
339 HBasicBlock* block() const { return block_; }
346 FIRST_INNER_POSITION = BEFORE,
347 LAST_INNER_POSITION = AFTER
350 LParallelMove* GetOrCreateParallelMove(InnerPosition pos, Zone* zone) {
351 if (parallel_moves_[pos] == NULL) {
352 parallel_moves_[pos] = new(zone) LParallelMove(zone);
354 return parallel_moves_[pos];
357 LParallelMove* GetParallelMove(InnerPosition pos) {
358 return parallel_moves_[pos];
362 LParallelMove* parallel_moves_[LAST_INNER_POSITION + 1];
367 class LInstructionGap final : public LGap {
369 explicit LInstructionGap(HBasicBlock* block) : LGap(block) { }
371 bool HasInterestingComment(LCodeGen* gen) const override {
372 return !IsRedundant();
375 DECLARE_CONCRETE_INSTRUCTION(InstructionGap, "gap")
379 class LGoto final : public LTemplateInstruction<0, 0, 0> {
381 explicit LGoto(HBasicBlock* block) : block_(block) { }
383 bool HasInterestingComment(LCodeGen* gen) const override;
384 DECLARE_CONCRETE_INSTRUCTION(Goto, "goto")
385 void PrintDataTo(StringStream* stream) override;
386 bool IsControl() const override { return true; }
388 int block_id() const { return block_->block_id(); }
395 class LLazyBailout final : public LTemplateInstruction<0, 0, 0> {
397 LLazyBailout() : gap_instructions_size_(0) { }
399 DECLARE_CONCRETE_INSTRUCTION(LazyBailout, "lazy-bailout")
401 void set_gap_instructions_size(int gap_instructions_size) {
402 gap_instructions_size_ = gap_instructions_size;
404 int gap_instructions_size() { return gap_instructions_size_; }
407 int gap_instructions_size_;
411 class LDummy final : public LTemplateInstruction<1, 0, 0> {
414 DECLARE_CONCRETE_INSTRUCTION(Dummy, "dummy")
418 class LDummyUse final : public LTemplateInstruction<1, 1, 0> {
420 explicit LDummyUse(LOperand* value) {
423 DECLARE_CONCRETE_INSTRUCTION(DummyUse, "dummy-use")
427 class LDeoptimize final : public LTemplateInstruction<0, 0, 0> {
429 bool IsControl() const override { return true; }
430 DECLARE_CONCRETE_INSTRUCTION(Deoptimize, "deoptimize")
431 DECLARE_HYDROGEN_ACCESSOR(Deoptimize)
435 class LLabel final : public LGap {
437 explicit LLabel(HBasicBlock* block)
438 : LGap(block), replacement_(NULL) { }
440 bool HasInterestingComment(LCodeGen* gen) const override { return false; }
441 DECLARE_CONCRETE_INSTRUCTION(Label, "label")
443 void PrintDataTo(StringStream* stream) override;
445 int block_id() const { return block()->block_id(); }
446 bool is_loop_header() const { return block()->IsLoopHeader(); }
447 bool is_osr_entry() const { return block()->is_osr_entry(); }
448 Label* label() { return &label_; }
449 LLabel* replacement() const { return replacement_; }
450 void set_replacement(LLabel* label) { replacement_ = label; }
451 bool HasReplacement() const { return replacement_ != NULL; }
455 LLabel* replacement_;
459 class LParameter final : public LTemplateInstruction<1, 0, 0> {
461 bool HasInterestingComment(LCodeGen* gen) const override { return false; }
462 DECLARE_CONCRETE_INSTRUCTION(Parameter, "parameter")
466 class LCallStub final : public LTemplateInstruction<1, 1, 0> {
468 explicit LCallStub(LOperand* context) {
469 inputs_[0] = context;
472 LOperand* context() { return inputs_[0]; }
474 DECLARE_CONCRETE_INSTRUCTION(CallStub, "call-stub")
475 DECLARE_HYDROGEN_ACCESSOR(CallStub)
479 class LUnknownOSRValue final : public LTemplateInstruction<1, 0, 0> {
481 bool HasInterestingComment(LCodeGen* gen) const override { return false; }
482 DECLARE_CONCRETE_INSTRUCTION(UnknownOSRValue, "unknown-osr-value")
486 template<int I, int T>
487 class LControlInstruction : public LTemplateInstruction<0, I, T> {
489 LControlInstruction() : false_label_(NULL), true_label_(NULL) { }
491 bool IsControl() const final { return true; }
493 int SuccessorCount() { return hydrogen()->SuccessorCount(); }
494 HBasicBlock* SuccessorAt(int i) { return hydrogen()->SuccessorAt(i); }
496 int TrueDestination(LChunk* chunk) {
497 return chunk->LookupDestination(true_block_id());
499 int FalseDestination(LChunk* chunk) {
500 return chunk->LookupDestination(false_block_id());
503 Label* TrueLabel(LChunk* chunk) {
504 if (true_label_ == NULL) {
505 true_label_ = chunk->GetAssemblyLabel(TrueDestination(chunk));
509 Label* FalseLabel(LChunk* chunk) {
510 if (false_label_ == NULL) {
511 false_label_ = chunk->GetAssemblyLabel(FalseDestination(chunk));
517 int true_block_id() { return SuccessorAt(0)->block_id(); }
518 int false_block_id() { return SuccessorAt(1)->block_id(); }
521 HControlInstruction* hydrogen() {
522 return HControlInstruction::cast(this->hydrogen_value());
530 class LWrapReceiver final : public LTemplateInstruction<1, 2, 0> {
532 LWrapReceiver(LOperand* receiver, LOperand* function) {
533 inputs_[0] = receiver;
534 inputs_[1] = function;
537 DECLARE_CONCRETE_INSTRUCTION(WrapReceiver, "wrap-receiver")
538 DECLARE_HYDROGEN_ACCESSOR(WrapReceiver)
540 LOperand* receiver() { return inputs_[0]; }
541 LOperand* function() { return inputs_[1]; }
545 class LApplyArguments final : public LTemplateInstruction<1, 4, 0> {
547 LApplyArguments(LOperand* function,
550 LOperand* elements) {
551 inputs_[0] = function;
552 inputs_[1] = receiver;
554 inputs_[3] = elements;
557 DECLARE_CONCRETE_INSTRUCTION(ApplyArguments, "apply-arguments")
559 LOperand* function() { return inputs_[0]; }
560 LOperand* receiver() { return inputs_[1]; }
561 LOperand* length() { return inputs_[2]; }
562 LOperand* elements() { return inputs_[3]; }
566 class LAccessArgumentsAt final : public LTemplateInstruction<1, 3, 0> {
568 LAccessArgumentsAt(LOperand* arguments, LOperand* length, LOperand* index) {
569 inputs_[0] = arguments;
574 DECLARE_CONCRETE_INSTRUCTION(AccessArgumentsAt, "access-arguments-at")
576 LOperand* arguments() { return inputs_[0]; }
577 LOperand* length() { return inputs_[1]; }
578 LOperand* index() { return inputs_[2]; }
580 void PrintDataTo(StringStream* stream) override;
584 class LArgumentsLength final : public LTemplateInstruction<1, 1, 0> {
586 explicit LArgumentsLength(LOperand* elements) {
587 inputs_[0] = elements;
590 LOperand* elements() { return inputs_[0]; }
592 DECLARE_CONCRETE_INSTRUCTION(ArgumentsLength, "arguments-length")
596 class LArgumentsElements final : public LTemplateInstruction<1, 0, 0> {
598 DECLARE_CONCRETE_INSTRUCTION(ArgumentsElements, "arguments-elements")
599 DECLARE_HYDROGEN_ACCESSOR(ArgumentsElements)
603 class LModByPowerOf2I final : public LTemplateInstruction<1, 1, 0> {
605 LModByPowerOf2I(LOperand* dividend, int32_t divisor) {
606 inputs_[0] = dividend;
610 LOperand* dividend() { return inputs_[0]; }
611 int32_t divisor() const { return divisor_; }
613 DECLARE_CONCRETE_INSTRUCTION(ModByPowerOf2I, "mod-by-power-of-2-i")
614 DECLARE_HYDROGEN_ACCESSOR(Mod)
621 class LModByConstI final : public LTemplateInstruction<1, 1, 0> {
623 LModByConstI(LOperand* dividend, int32_t divisor) {
624 inputs_[0] = dividend;
628 LOperand* dividend() { return inputs_[0]; }
629 int32_t divisor() const { return divisor_; }
631 DECLARE_CONCRETE_INSTRUCTION(ModByConstI, "mod-by-const-i")
632 DECLARE_HYDROGEN_ACCESSOR(Mod)
639 class LModI final : public LTemplateInstruction<1, 2, 3> {
641 LModI(LOperand* left,
647 LOperand* left() { return inputs_[0]; }
648 LOperand* right() { return inputs_[1]; }
650 DECLARE_CONCRETE_INSTRUCTION(ModI, "mod-i")
651 DECLARE_HYDROGEN_ACCESSOR(Mod)
655 class LDivByPowerOf2I final : public LTemplateInstruction<1, 1, 0> {
657 LDivByPowerOf2I(LOperand* dividend, int32_t divisor) {
658 inputs_[0] = dividend;
662 LOperand* dividend() { return inputs_[0]; }
663 int32_t divisor() const { return divisor_; }
665 DECLARE_CONCRETE_INSTRUCTION(DivByPowerOf2I, "div-by-power-of-2-i")
666 DECLARE_HYDROGEN_ACCESSOR(Div)
673 class LDivByConstI final : public LTemplateInstruction<1, 1, 0> {
675 LDivByConstI(LOperand* dividend, int32_t divisor) {
676 inputs_[0] = dividend;
680 LOperand* dividend() { return inputs_[0]; }
681 int32_t divisor() const { return divisor_; }
683 DECLARE_CONCRETE_INSTRUCTION(DivByConstI, "div-by-const-i")
684 DECLARE_HYDROGEN_ACCESSOR(Div)
691 class LDivI final : public LTemplateInstruction<1, 2, 1> {
693 LDivI(LOperand* dividend, LOperand* divisor, LOperand* temp) {
694 inputs_[0] = dividend;
695 inputs_[1] = divisor;
699 LOperand* dividend() { return inputs_[0]; }
700 LOperand* divisor() { return inputs_[1]; }
701 LOperand* temp() { return temps_[0]; }
703 DECLARE_CONCRETE_INSTRUCTION(DivI, "div-i")
704 DECLARE_HYDROGEN_ACCESSOR(BinaryOperation)
708 class LFlooringDivByPowerOf2I final : public LTemplateInstruction<1, 1, 0> {
710 LFlooringDivByPowerOf2I(LOperand* dividend, int32_t divisor) {
711 inputs_[0] = dividend;
715 LOperand* dividend() { return inputs_[0]; }
716 int32_t divisor() { return divisor_; }
718 DECLARE_CONCRETE_INSTRUCTION(FlooringDivByPowerOf2I,
719 "flooring-div-by-power-of-2-i")
720 DECLARE_HYDROGEN_ACCESSOR(MathFloorOfDiv)
727 class LFlooringDivByConstI final : public LTemplateInstruction<1, 1, 2> {
729 LFlooringDivByConstI(LOperand* dividend, int32_t divisor, LOperand* temp) {
730 inputs_[0] = dividend;
735 LOperand* dividend() { return inputs_[0]; }
736 int32_t divisor() const { return divisor_; }
737 LOperand* temp() { return temps_[0]; }
739 DECLARE_CONCRETE_INSTRUCTION(FlooringDivByConstI, "flooring-div-by-const-i")
740 DECLARE_HYDROGEN_ACCESSOR(MathFloorOfDiv)
747 class LFlooringDivI final : public LTemplateInstruction<1, 2, 0> {
749 LFlooringDivI(LOperand* dividend, LOperand* divisor) {
750 inputs_[0] = dividend;
751 inputs_[1] = divisor;
754 LOperand* dividend() { return inputs_[0]; }
755 LOperand* divisor() { return inputs_[1]; }
757 DECLARE_CONCRETE_INSTRUCTION(FlooringDivI, "flooring-div-i")
758 DECLARE_HYDROGEN_ACCESSOR(MathFloorOfDiv)
762 class LMulS final : public LTemplateInstruction<1, 2, 0> {
764 LMulS(LOperand* left, LOperand* right) {
769 LOperand* left() { return inputs_[0]; }
770 LOperand* right() { return inputs_[1]; }
772 DECLARE_CONCRETE_INSTRUCTION(MulS, "mul-s")
773 DECLARE_HYDROGEN_ACCESSOR(Mul)
777 class LMulI final : public LTemplateInstruction<1, 2, 0> {
779 LMulI(LOperand* left, LOperand* right) {
784 LOperand* left() { return inputs_[0]; }
785 LOperand* right() { return inputs_[1]; }
787 DECLARE_CONCRETE_INSTRUCTION(MulI, "mul-i")
788 DECLARE_HYDROGEN_ACCESSOR(Mul)
792 // Instruction for computing multiplier * multiplicand + addend.
793 class LMultiplyAddD final : public LTemplateInstruction<1, 3, 0> {
795 LMultiplyAddD(LOperand* addend, LOperand* multiplier,
796 LOperand* multiplicand) {
798 inputs_[1] = multiplier;
799 inputs_[2] = multiplicand;
802 LOperand* addend() { return inputs_[0]; }
803 LOperand* multiplier() { return inputs_[1]; }
804 LOperand* multiplicand() { return inputs_[2]; }
806 DECLARE_CONCRETE_INSTRUCTION(MultiplyAddD, "multiply-add-d")
810 class LDebugBreak final : public LTemplateInstruction<0, 0, 0> {
812 DECLARE_CONCRETE_INSTRUCTION(DebugBreak, "break")
816 class LCompareNumericAndBranch final : public LControlInstruction<2, 0> {
818 LCompareNumericAndBranch(LOperand* left, LOperand* right) {
823 LOperand* left() { return inputs_[0]; }
824 LOperand* right() { return inputs_[1]; }
826 DECLARE_CONCRETE_INSTRUCTION(CompareNumericAndBranch,
827 "compare-numeric-and-branch")
828 DECLARE_HYDROGEN_ACCESSOR(CompareNumericAndBranch)
830 Token::Value op() const { return hydrogen()->token(); }
831 bool is_double() const {
832 return hydrogen()->representation().IsDouble();
835 void PrintDataTo(StringStream* stream) override;
839 class LMathFloor final : public LTemplateInstruction<1, 1, 1> {
841 LMathFloor(LOperand* value, LOperand* temp) {
846 LOperand* value() { return inputs_[0]; }
847 LOperand* temp() { return temps_[0]; }
849 DECLARE_CONCRETE_INSTRUCTION(MathFloor, "math-floor")
850 DECLARE_HYDROGEN_ACCESSOR(UnaryMathOperation)
854 class LMathRound final : public LTemplateInstruction<1, 1, 1> {
856 LMathRound(LOperand* value, LOperand* temp) {
861 LOperand* value() { return inputs_[0]; }
862 LOperand* temp() { return temps_[0]; }
864 DECLARE_CONCRETE_INSTRUCTION(MathRound, "math-round")
865 DECLARE_HYDROGEN_ACCESSOR(UnaryMathOperation)
869 class LMathFround final : public LTemplateInstruction<1, 1, 0> {
871 explicit LMathFround(LOperand* value) { inputs_[0] = value; }
873 LOperand* value() { return inputs_[0]; }
875 DECLARE_CONCRETE_INSTRUCTION(MathFround, "math-fround")
879 class LMathAbs final : public LTemplateInstruction<1, 2, 0> {
881 LMathAbs(LOperand* context, LOperand* value) {
882 inputs_[1] = context;
886 LOperand* context() { return inputs_[1]; }
887 LOperand* value() { return inputs_[0]; }
889 DECLARE_CONCRETE_INSTRUCTION(MathAbs, "math-abs")
890 DECLARE_HYDROGEN_ACCESSOR(UnaryMathOperation)
894 class LMathLog final : public LTemplateInstruction<1, 1, 0> {
896 explicit LMathLog(LOperand* value) {
900 LOperand* value() { return inputs_[0]; }
902 DECLARE_CONCRETE_INSTRUCTION(MathLog, "math-log")
906 class LMathClz32 final : public LTemplateInstruction<1, 1, 0> {
908 explicit LMathClz32(LOperand* value) {
912 LOperand* value() { return inputs_[0]; }
914 DECLARE_CONCRETE_INSTRUCTION(MathClz32, "math-clz32")
918 class LMathExp final : public LTemplateInstruction<1, 1, 3> {
920 LMathExp(LOperand* value,
921 LOperand* double_temp,
927 temps_[2] = double_temp;
928 ExternalReference::InitializeMathExpData();
931 LOperand* value() { return inputs_[0]; }
932 LOperand* temp1() { return temps_[0]; }
933 LOperand* temp2() { return temps_[1]; }
934 LOperand* double_temp() { return temps_[2]; }
936 DECLARE_CONCRETE_INSTRUCTION(MathExp, "math-exp")
940 class LMathSqrt final : public LTemplateInstruction<1, 1, 0> {
942 explicit LMathSqrt(LOperand* value) {
946 LOperand* value() { return inputs_[0]; }
948 DECLARE_CONCRETE_INSTRUCTION(MathSqrt, "math-sqrt")
952 class LMathPowHalf final : public LTemplateInstruction<1, 1, 1> {
954 LMathPowHalf(LOperand* value, LOperand* temp) {
959 LOperand* value() { return inputs_[0]; }
960 LOperand* temp() { return temps_[0]; }
962 DECLARE_CONCRETE_INSTRUCTION(MathPowHalf, "math-pow-half")
966 class LCmpObjectEqAndBranch final : public LControlInstruction<2, 0> {
968 LCmpObjectEqAndBranch(LOperand* left, LOperand* right) {
973 LOperand* left() { return inputs_[0]; }
974 LOperand* right() { return inputs_[1]; }
976 DECLARE_CONCRETE_INSTRUCTION(CmpObjectEqAndBranch, "cmp-object-eq-and-branch")
977 DECLARE_HYDROGEN_ACCESSOR(CompareObjectEqAndBranch)
981 class LCmpHoleAndBranch final : public LControlInstruction<1, 0> {
983 explicit LCmpHoleAndBranch(LOperand* object) {
987 LOperand* object() { return inputs_[0]; }
989 DECLARE_CONCRETE_INSTRUCTION(CmpHoleAndBranch, "cmp-hole-and-branch")
990 DECLARE_HYDROGEN_ACCESSOR(CompareHoleAndBranch)
994 class LCompareMinusZeroAndBranch final : public LControlInstruction<1, 1> {
996 LCompareMinusZeroAndBranch(LOperand* value, LOperand* temp) {
1001 LOperand* value() { return inputs_[0]; }
1002 LOperand* temp() { return temps_[0]; }
1004 DECLARE_CONCRETE_INSTRUCTION(CompareMinusZeroAndBranch,
1005 "cmp-minus-zero-and-branch")
1006 DECLARE_HYDROGEN_ACCESSOR(CompareMinusZeroAndBranch)
1010 class LIsObjectAndBranch final : public LControlInstruction<1, 1> {
1012 LIsObjectAndBranch(LOperand* value, LOperand* temp) {
1017 LOperand* value() { return inputs_[0]; }
1018 LOperand* temp() { return temps_[0]; }
1020 DECLARE_CONCRETE_INSTRUCTION(IsObjectAndBranch, "is-object-and-branch")
1021 DECLARE_HYDROGEN_ACCESSOR(IsObjectAndBranch)
1023 void PrintDataTo(StringStream* stream) override;
1027 class LIsStringAndBranch final : public LControlInstruction<1, 1> {
1029 LIsStringAndBranch(LOperand* value, LOperand* temp) {
1034 LOperand* value() { return inputs_[0]; }
1035 LOperand* temp() { return temps_[0]; }
1037 DECLARE_CONCRETE_INSTRUCTION(IsStringAndBranch, "is-string-and-branch")
1038 DECLARE_HYDROGEN_ACCESSOR(IsStringAndBranch)
1040 void PrintDataTo(StringStream* stream) override;
1044 class LIsSmiAndBranch final : public LControlInstruction<1, 0> {
1046 explicit LIsSmiAndBranch(LOperand* value) {
1050 LOperand* value() { return inputs_[0]; }
1052 DECLARE_CONCRETE_INSTRUCTION(IsSmiAndBranch, "is-smi-and-branch")
1053 DECLARE_HYDROGEN_ACCESSOR(IsSmiAndBranch)
1055 void PrintDataTo(StringStream* stream) override;
1059 class LIsUndetectableAndBranch final : public LControlInstruction<1, 1> {
1061 explicit LIsUndetectableAndBranch(LOperand* value, LOperand* temp) {
1066 LOperand* value() { return inputs_[0]; }
1067 LOperand* temp() { return temps_[0]; }
1069 DECLARE_CONCRETE_INSTRUCTION(IsUndetectableAndBranch,
1070 "is-undetectable-and-branch")
1071 DECLARE_HYDROGEN_ACCESSOR(IsUndetectableAndBranch)
1073 void PrintDataTo(StringStream* stream) override;
1077 class LStringCompareAndBranch final : public LControlInstruction<3, 0> {
1079 LStringCompareAndBranch(LOperand* context, LOperand* left, LOperand* right) {
1080 inputs_[0] = context;
1085 LOperand* context() { return inputs_[0]; }
1086 LOperand* left() { return inputs_[1]; }
1087 LOperand* right() { return inputs_[2]; }
1089 DECLARE_CONCRETE_INSTRUCTION(StringCompareAndBranch,
1090 "string-compare-and-branch")
1091 DECLARE_HYDROGEN_ACCESSOR(StringCompareAndBranch)
1093 Token::Value op() const { return hydrogen()->token(); }
1095 void PrintDataTo(StringStream* stream) override;
1099 class LHasInstanceTypeAndBranch final : public LControlInstruction<1, 0> {
1101 explicit LHasInstanceTypeAndBranch(LOperand* value) {
1105 LOperand* value() { return inputs_[0]; }
1107 DECLARE_CONCRETE_INSTRUCTION(HasInstanceTypeAndBranch,
1108 "has-instance-type-and-branch")
1109 DECLARE_HYDROGEN_ACCESSOR(HasInstanceTypeAndBranch)
1111 void PrintDataTo(StringStream* stream) override;
1115 class LGetCachedArrayIndex final : public LTemplateInstruction<1, 1, 0> {
1117 explicit LGetCachedArrayIndex(LOperand* value) {
1121 LOperand* value() { return inputs_[0]; }
1123 DECLARE_CONCRETE_INSTRUCTION(GetCachedArrayIndex, "get-cached-array-index")
1124 DECLARE_HYDROGEN_ACCESSOR(GetCachedArrayIndex)
1128 class LHasCachedArrayIndexAndBranch final : public LControlInstruction<1, 0> {
1130 explicit LHasCachedArrayIndexAndBranch(LOperand* value) {
1134 LOperand* value() { return inputs_[0]; }
1136 DECLARE_CONCRETE_INSTRUCTION(HasCachedArrayIndexAndBranch,
1137 "has-cached-array-index-and-branch")
1138 DECLARE_HYDROGEN_ACCESSOR(HasCachedArrayIndexAndBranch)
1140 void PrintDataTo(StringStream* stream) override;
1144 class LClassOfTestAndBranch final : public LControlInstruction<1, 1> {
1146 LClassOfTestAndBranch(LOperand* value, LOperand* temp) {
1151 LOperand* value() { return inputs_[0]; }
1152 LOperand* temp() { return temps_[0]; }
1154 DECLARE_CONCRETE_INSTRUCTION(ClassOfTestAndBranch,
1155 "class-of-test-and-branch")
1156 DECLARE_HYDROGEN_ACCESSOR(ClassOfTestAndBranch)
1158 void PrintDataTo(StringStream* stream) override;
1162 class LCmpT final : public LTemplateInstruction<1, 3, 0> {
1164 LCmpT(LOperand* context, LOperand* left, LOperand* right) {
1165 inputs_[0] = context;
1170 LOperand* context() { return inputs_[0]; }
1171 LOperand* left() { return inputs_[1]; }
1172 LOperand* right() { return inputs_[2]; }
1174 DECLARE_CONCRETE_INSTRUCTION(CmpT, "cmp-t")
1175 DECLARE_HYDROGEN_ACCESSOR(CompareGeneric)
1177 Strength strength() { return hydrogen()->strength(); }
1179 Token::Value op() const { return hydrogen()->token(); }
1183 class LInstanceOf final : public LTemplateInstruction<1, 3, 0> {
1185 LInstanceOf(LOperand* context, LOperand* left, LOperand* right) {
1186 inputs_[0] = context;
1191 LOperand* context() { return inputs_[0]; }
1192 LOperand* left() { return inputs_[1]; }
1193 LOperand* right() { return inputs_[2]; }
1195 DECLARE_CONCRETE_INSTRUCTION(InstanceOf, "instance-of")
1199 class LInstanceOfKnownGlobal final : public LTemplateInstruction<1, 2, 1> {
1201 LInstanceOfKnownGlobal(LOperand* context, LOperand* value, LOperand* temp) {
1202 inputs_[0] = context;
1207 LOperand* context() { return inputs_[0]; }
1208 LOperand* value() { return inputs_[1]; }
1209 LOperand* temp() { return temps_[0]; }
1211 DECLARE_CONCRETE_INSTRUCTION(InstanceOfKnownGlobal,
1212 "instance-of-known-global")
1213 DECLARE_HYDROGEN_ACCESSOR(InstanceOfKnownGlobal)
1215 Handle<JSFunction> function() const { return hydrogen()->function(); }
1216 LEnvironment* GetDeferredLazyDeoptimizationEnvironment() {
1217 return lazy_deopt_env_;
1219 virtual void SetDeferredLazyDeoptimizationEnvironment(
1220 LEnvironment* env) override {
1221 lazy_deopt_env_ = env;
1225 LEnvironment* lazy_deopt_env_;
1229 class LBoundsCheck final : public LTemplateInstruction<0, 2, 0> {
1231 LBoundsCheck(LOperand* index, LOperand* length) {
1233 inputs_[1] = length;
1236 LOperand* index() { return inputs_[0]; }
1237 LOperand* length() { return inputs_[1]; }
1239 DECLARE_CONCRETE_INSTRUCTION(BoundsCheck, "bounds-check")
1240 DECLARE_HYDROGEN_ACCESSOR(BoundsCheck)
1244 class LBitI final : public LTemplateInstruction<1, 2, 0> {
1246 LBitI(LOperand* left, LOperand* right) {
1251 LOperand* left() { return inputs_[0]; }
1252 LOperand* right() { return inputs_[1]; }
1254 Token::Value op() const { return hydrogen()->op(); }
1256 DECLARE_CONCRETE_INSTRUCTION(BitI, "bit-i")
1257 DECLARE_HYDROGEN_ACCESSOR(Bitwise)
1261 class LShiftI final : public LTemplateInstruction<1, 2, 0> {
1263 LShiftI(Token::Value op, LOperand* left, LOperand* right, bool can_deopt)
1264 : op_(op), can_deopt_(can_deopt) {
1269 Token::Value op() const { return op_; }
1270 LOperand* left() { return inputs_[0]; }
1271 LOperand* right() { return inputs_[1]; }
1272 bool can_deopt() const { return can_deopt_; }
1274 DECLARE_CONCRETE_INSTRUCTION(ShiftI, "shift-i")
1282 class LSubI final : public LTemplateInstruction<1, 2, 0> {
1284 LSubI(LOperand* left, LOperand* right) {
1289 LOperand* left() { return inputs_[0]; }
1290 LOperand* right() { return inputs_[1]; }
1292 DECLARE_CONCRETE_INSTRUCTION(SubI, "sub-i")
1293 DECLARE_HYDROGEN_ACCESSOR(Sub)
1297 class LSubS final : public LTemplateInstruction<1, 2, 0> {
1299 LSubS(LOperand* left, LOperand* right) {
1304 LOperand* left() { return inputs_[0]; }
1305 LOperand* right() { return inputs_[1]; }
1307 DECLARE_CONCRETE_INSTRUCTION(SubS, "sub-s")
1308 DECLARE_HYDROGEN_ACCESSOR(Sub)
1312 class LConstantI final : public LTemplateInstruction<1, 0, 0> {
1314 DECLARE_CONCRETE_INSTRUCTION(ConstantI, "constant-i")
1315 DECLARE_HYDROGEN_ACCESSOR(Constant)
1317 int32_t value() const { return hydrogen()->Integer32Value(); }
1321 class LConstantS final : public LTemplateInstruction<1, 0, 0> {
1323 DECLARE_CONCRETE_INSTRUCTION(ConstantS, "constant-s")
1324 DECLARE_HYDROGEN_ACCESSOR(Constant)
1326 Smi* value() const { return Smi::FromInt(hydrogen()->Integer32Value()); }
1330 class LConstantD final : public LTemplateInstruction<1, 0, 0> {
1332 DECLARE_CONCRETE_INSTRUCTION(ConstantD, "constant-d")
1333 DECLARE_HYDROGEN_ACCESSOR(Constant)
1335 double value() const { return hydrogen()->DoubleValue(); }
1339 class LConstantE final : public LTemplateInstruction<1, 0, 0> {
1341 DECLARE_CONCRETE_INSTRUCTION(ConstantE, "constant-e")
1342 DECLARE_HYDROGEN_ACCESSOR(Constant)
1344 ExternalReference value() const {
1345 return hydrogen()->ExternalReferenceValue();
1350 class LConstantT final : public LTemplateInstruction<1, 0, 0> {
1352 DECLARE_CONCRETE_INSTRUCTION(ConstantT, "constant-t")
1353 DECLARE_HYDROGEN_ACCESSOR(Constant)
1355 Handle<Object> value(Isolate* isolate) const {
1356 return hydrogen()->handle(isolate);
1361 class LBranch final : public LControlInstruction<1, 0> {
1363 explicit LBranch(LOperand* value) {
1367 LOperand* value() { return inputs_[0]; }
1369 DECLARE_CONCRETE_INSTRUCTION(Branch, "branch")
1370 DECLARE_HYDROGEN_ACCESSOR(Branch)
1372 void PrintDataTo(StringStream* stream) override;
1376 class LCmpMapAndBranch final : public LControlInstruction<1, 1> {
1378 LCmpMapAndBranch(LOperand* value, LOperand* temp) {
1383 LOperand* value() { return inputs_[0]; }
1384 LOperand* temp() { return temps_[0]; }
1386 DECLARE_CONCRETE_INSTRUCTION(CmpMapAndBranch, "cmp-map-and-branch")
1387 DECLARE_HYDROGEN_ACCESSOR(CompareMap)
1389 Handle<Map> map() const { return hydrogen()->map().handle(); }
1393 class LMapEnumLength final : public LTemplateInstruction<1, 1, 0> {
1395 explicit LMapEnumLength(LOperand* value) {
1399 LOperand* value() { return inputs_[0]; }
1401 DECLARE_CONCRETE_INSTRUCTION(MapEnumLength, "map-enum-length")
1405 class LDateField final : public LTemplateInstruction<1, 1, 1> {
1407 LDateField(LOperand* date, LOperand* temp, Smi* index) : index_(index) {
1412 LOperand* date() { return inputs_[0]; }
1413 LOperand* temp() { return temps_[0]; }
1414 Smi* index() const { return index_; }
1416 DECLARE_CONCRETE_INSTRUCTION(DateField, "date-field")
1417 DECLARE_HYDROGEN_ACCESSOR(DateField)
1424 class LSeqStringGetChar final : public LTemplateInstruction<1, 2, 0> {
1426 LSeqStringGetChar(LOperand* string, LOperand* index) {
1427 inputs_[0] = string;
1431 LOperand* string() const { return inputs_[0]; }
1432 LOperand* index() const { return inputs_[1]; }
1434 DECLARE_CONCRETE_INSTRUCTION(SeqStringGetChar, "seq-string-get-char")
1435 DECLARE_HYDROGEN_ACCESSOR(SeqStringGetChar)
1439 class LSeqStringSetChar final : public LTemplateInstruction<1, 4, 0> {
1441 LSeqStringSetChar(LOperand* context,
1445 inputs_[0] = context;
1446 inputs_[1] = string;
1451 LOperand* string() { return inputs_[1]; }
1452 LOperand* index() { return inputs_[2]; }
1453 LOperand* value() { return inputs_[3]; }
1455 DECLARE_CONCRETE_INSTRUCTION(SeqStringSetChar, "seq-string-set-char")
1456 DECLARE_HYDROGEN_ACCESSOR(SeqStringSetChar)
1460 class LAddE final : public LTemplateInstruction<1, 2, 0> {
1462 LAddE(LOperand* left, LOperand* right) {
1467 LOperand* left() { return inputs_[0]; }
1468 LOperand* right() { return inputs_[1]; }
1470 DECLARE_CONCRETE_INSTRUCTION(AddE, "add-e")
1471 DECLARE_HYDROGEN_ACCESSOR(Add)
1475 class LAddI final : public LTemplateInstruction<1, 2, 0> {
1477 LAddI(LOperand* left, LOperand* right) {
1482 LOperand* left() { return inputs_[0]; }
1483 LOperand* right() { return inputs_[1]; }
1485 DECLARE_CONCRETE_INSTRUCTION(AddI, "add-i")
1486 DECLARE_HYDROGEN_ACCESSOR(Add)
1490 class LAddS final : public LTemplateInstruction<1, 2, 0> {
1492 LAddS(LOperand* left, LOperand* right) {
1497 LOperand* left() { return inputs_[0]; }
1498 LOperand* right() { return inputs_[1]; }
1500 DECLARE_CONCRETE_INSTRUCTION(AddS, "add-s")
1501 DECLARE_HYDROGEN_ACCESSOR(Add)
1505 class LMathMinMax final : public LTemplateInstruction<1, 2, 0> {
1507 LMathMinMax(LOperand* left, LOperand* right) {
1512 LOperand* left() { return inputs_[0]; }
1513 LOperand* right() { return inputs_[1]; }
1515 DECLARE_CONCRETE_INSTRUCTION(MathMinMax, "math-min-max")
1516 DECLARE_HYDROGEN_ACCESSOR(MathMinMax)
1520 class LPower final : public LTemplateInstruction<1, 2, 0> {
1522 LPower(LOperand* left, LOperand* right) {
1527 LOperand* left() { return inputs_[0]; }
1528 LOperand* right() { return inputs_[1]; }
1530 DECLARE_CONCRETE_INSTRUCTION(Power, "power")
1531 DECLARE_HYDROGEN_ACCESSOR(Power)
1535 class LArithmeticD final : public LTemplateInstruction<1, 2, 0> {
1537 LArithmeticD(Token::Value op, LOperand* left, LOperand* right)
1543 Token::Value op() const { return op_; }
1544 LOperand* left() { return inputs_[0]; }
1545 LOperand* right() { return inputs_[1]; }
1547 Opcode opcode() const override { return LInstruction::kArithmeticD; }
1548 void CompileToNative(LCodeGen* generator) override;
1549 const char* Mnemonic() const override;
1556 class LArithmeticT final : public LTemplateInstruction<1, 3, 0> {
1558 LArithmeticT(Token::Value op,
1563 inputs_[0] = context;
1568 LOperand* context() { return inputs_[0]; }
1569 LOperand* left() { return inputs_[1]; }
1570 LOperand* right() { return inputs_[2]; }
1571 Token::Value op() const { return op_; }
1573 Opcode opcode() const final { return LInstruction::kArithmeticT; }
1574 void CompileToNative(LCodeGen* generator) override;
1575 const char* Mnemonic() const override;
1577 DECLARE_HYDROGEN_ACCESSOR(BinaryOperation)
1579 Strength strength() { return hydrogen()->strength(); }
1586 class LReturn final : public LTemplateInstruction<0, 3, 0> {
1588 LReturn(LOperand* value, LOperand* context, LOperand* parameter_count) {
1590 inputs_[1] = context;
1591 inputs_[2] = parameter_count;
1594 LOperand* value() { return inputs_[0]; }
1596 bool has_constant_parameter_count() {
1597 return parameter_count()->IsConstantOperand();
1599 LConstantOperand* constant_parameter_count() {
1600 DCHECK(has_constant_parameter_count());
1601 return LConstantOperand::cast(parameter_count());
1603 LOperand* parameter_count() { return inputs_[2]; }
1605 DECLARE_CONCRETE_INSTRUCTION(Return, "return")
1609 class LLoadNamedField final : public LTemplateInstruction<1, 1, 0> {
1611 explicit LLoadNamedField(LOperand* object) {
1612 inputs_[0] = object;
1615 LOperand* object() { return inputs_[0]; }
1617 DECLARE_CONCRETE_INSTRUCTION(LoadNamedField, "load-named-field")
1618 DECLARE_HYDROGEN_ACCESSOR(LoadNamedField)
1622 class LLoadNamedGeneric final : public LTemplateInstruction<1, 2, 1> {
1624 LLoadNamedGeneric(LOperand* context, LOperand* object, LOperand* vector) {
1625 inputs_[0] = context;
1626 inputs_[1] = object;
1630 LOperand* context() { return inputs_[0]; }
1631 LOperand* object() { return inputs_[1]; }
1632 LOperand* temp_vector() { return temps_[0]; }
1634 DECLARE_CONCRETE_INSTRUCTION(LoadNamedGeneric, "load-named-generic")
1635 DECLARE_HYDROGEN_ACCESSOR(LoadNamedGeneric)
1637 Handle<Object> name() const { return hydrogen()->name(); }
1641 class LLoadFunctionPrototype final : public LTemplateInstruction<1, 1, 0> {
1643 explicit LLoadFunctionPrototype(LOperand* function) {
1644 inputs_[0] = function;
1647 LOperand* function() { return inputs_[0]; }
1649 DECLARE_CONCRETE_INSTRUCTION(LoadFunctionPrototype, "load-function-prototype")
1650 DECLARE_HYDROGEN_ACCESSOR(LoadFunctionPrototype)
1654 class LLoadRoot final : public LTemplateInstruction<1, 0, 0> {
1656 DECLARE_CONCRETE_INSTRUCTION(LoadRoot, "load-root")
1657 DECLARE_HYDROGEN_ACCESSOR(LoadRoot)
1659 Heap::RootListIndex index() const { return hydrogen()->index(); }
1663 class LLoadKeyed final : public LTemplateInstruction<1, 2, 0> {
1665 LLoadKeyed(LOperand* elements, LOperand* key) {
1666 inputs_[0] = elements;
1670 LOperand* elements() { return inputs_[0]; }
1671 LOperand* key() { return inputs_[1]; }
1672 ElementsKind elements_kind() const {
1673 return hydrogen()->elements_kind();
1675 bool is_fixed_typed_array() const {
1676 return hydrogen()->is_fixed_typed_array();
1679 DECLARE_CONCRETE_INSTRUCTION(LoadKeyed, "load-keyed")
1680 DECLARE_HYDROGEN_ACCESSOR(LoadKeyed)
1682 void PrintDataTo(StringStream* stream) override;
1683 uint32_t base_offset() const { return hydrogen()->base_offset(); }
1687 class LLoadKeyedGeneric final : public LTemplateInstruction<1, 3, 1> {
1689 LLoadKeyedGeneric(LOperand* context, LOperand* object, LOperand* key,
1691 inputs_[0] = context;
1692 inputs_[1] = object;
1697 LOperand* context() { return inputs_[0]; }
1698 LOperand* object() { return inputs_[1]; }
1699 LOperand* key() { return inputs_[2]; }
1700 LOperand* temp_vector() { return temps_[0]; }
1702 DECLARE_CONCRETE_INSTRUCTION(LoadKeyedGeneric, "load-keyed-generic")
1703 DECLARE_HYDROGEN_ACCESSOR(LoadKeyedGeneric)
1707 class LLoadGlobalGeneric final : public LTemplateInstruction<1, 2, 1> {
1709 LLoadGlobalGeneric(LOperand* context, LOperand* global_object,
1711 inputs_[0] = context;
1712 inputs_[1] = global_object;
1716 LOperand* context() { return inputs_[0]; }
1717 LOperand* global_object() { return inputs_[1]; }
1718 LOperand* temp_vector() { return temps_[0]; }
1720 DECLARE_CONCRETE_INSTRUCTION(LoadGlobalGeneric, "load-global-generic")
1721 DECLARE_HYDROGEN_ACCESSOR(LoadGlobalGeneric)
1723 Handle<Object> name() const { return hydrogen()->name(); }
1724 TypeofMode typeof_mode() const { return hydrogen()->typeof_mode(); }
1728 class LLoadGlobalViaContext final : public LTemplateInstruction<1, 1, 1> {
1730 explicit LLoadGlobalViaContext(LOperand* context) { inputs_[0] = context; }
1732 DECLARE_CONCRETE_INSTRUCTION(LoadGlobalViaContext, "load-global-via-context")
1733 DECLARE_HYDROGEN_ACCESSOR(LoadGlobalViaContext)
1735 void PrintDataTo(StringStream* stream) override;
1737 LOperand* context() { return inputs_[0]; }
1739 int depth() const { return hydrogen()->depth(); }
1740 int slot_index() const { return hydrogen()->slot_index(); }
1744 class LLoadContextSlot final : public LTemplateInstruction<1, 1, 0> {
1746 explicit LLoadContextSlot(LOperand* context) {
1747 inputs_[0] = context;
1750 LOperand* context() { return inputs_[0]; }
1752 DECLARE_CONCRETE_INSTRUCTION(LoadContextSlot, "load-context-slot")
1753 DECLARE_HYDROGEN_ACCESSOR(LoadContextSlot)
1755 int slot_index() { return hydrogen()->slot_index(); }
1757 void PrintDataTo(StringStream* stream) override;
1761 class LStoreContextSlot final : public LTemplateInstruction<0, 2, 0> {
1763 LStoreContextSlot(LOperand* context, LOperand* value) {
1764 inputs_[0] = context;
1768 LOperand* context() { return inputs_[0]; }
1769 LOperand* value() { return inputs_[1]; }
1771 DECLARE_CONCRETE_INSTRUCTION(StoreContextSlot, "store-context-slot")
1772 DECLARE_HYDROGEN_ACCESSOR(StoreContextSlot)
1774 int slot_index() { return hydrogen()->slot_index(); }
1776 void PrintDataTo(StringStream* stream) override;
1780 class LPushArgument final : public LTemplateInstruction<0, 1, 0> {
1782 explicit LPushArgument(LOperand* value) {
1786 LOperand* value() { return inputs_[0]; }
1788 DECLARE_CONCRETE_INSTRUCTION(PushArgument, "push-argument")
1792 class LDrop final : public LTemplateInstruction<0, 0, 0> {
1794 explicit LDrop(int count) : count_(count) { }
1796 int count() const { return count_; }
1798 DECLARE_CONCRETE_INSTRUCTION(Drop, "drop")
1805 class LStoreCodeEntry final : public LTemplateInstruction<0, 2, 0> {
1807 LStoreCodeEntry(LOperand* function, LOperand* code_object) {
1808 inputs_[0] = function;
1809 inputs_[1] = code_object;
1812 LOperand* function() { return inputs_[0]; }
1813 LOperand* code_object() { return inputs_[1]; }
1815 void PrintDataTo(StringStream* stream) override;
1817 DECLARE_CONCRETE_INSTRUCTION(StoreCodeEntry, "store-code-entry")
1818 DECLARE_HYDROGEN_ACCESSOR(StoreCodeEntry)
1822 class LInnerAllocatedObject final : public LTemplateInstruction<1, 2, 0> {
1824 LInnerAllocatedObject(LOperand* base_object, LOperand* offset) {
1825 inputs_[0] = base_object;
1826 inputs_[1] = offset;
1829 LOperand* base_object() const { return inputs_[0]; }
1830 LOperand* offset() const { return inputs_[1]; }
1832 void PrintDataTo(StringStream* stream) override;
1834 DECLARE_CONCRETE_INSTRUCTION(InnerAllocatedObject, "inner-allocated-object")
1838 class LThisFunction final : public LTemplateInstruction<1, 0, 0> {
1840 DECLARE_CONCRETE_INSTRUCTION(ThisFunction, "this-function")
1841 DECLARE_HYDROGEN_ACCESSOR(ThisFunction)
1845 class LContext final : public LTemplateInstruction<1, 0, 0> {
1847 DECLARE_CONCRETE_INSTRUCTION(Context, "context")
1848 DECLARE_HYDROGEN_ACCESSOR(Context)
1852 class LDeclareGlobals final : public LTemplateInstruction<0, 1, 0> {
1854 explicit LDeclareGlobals(LOperand* context) {
1855 inputs_[0] = context;
1858 LOperand* context() { return inputs_[0]; }
1860 DECLARE_CONCRETE_INSTRUCTION(DeclareGlobals, "declare-globals")
1861 DECLARE_HYDROGEN_ACCESSOR(DeclareGlobals)
1865 class LCallJSFunction final : public LTemplateInstruction<1, 1, 0> {
1867 explicit LCallJSFunction(LOperand* function) {
1868 inputs_[0] = function;
1871 LOperand* function() { return inputs_[0]; }
1873 DECLARE_CONCRETE_INSTRUCTION(CallJSFunction, "call-js-function")
1874 DECLARE_HYDROGEN_ACCESSOR(CallJSFunction)
1876 void PrintDataTo(StringStream* stream) override;
1878 int arity() const { return hydrogen()->argument_count() - 1; }
1882 class LCallWithDescriptor final : public LTemplateResultInstruction<1> {
1884 LCallWithDescriptor(CallInterfaceDescriptor descriptor,
1885 const ZoneList<LOperand*>& operands, Zone* zone)
1886 : descriptor_(descriptor),
1887 inputs_(descriptor.GetRegisterParameterCount() +
1888 kImplicitRegisterParameterCount,
1890 DCHECK(descriptor.GetRegisterParameterCount() +
1891 kImplicitRegisterParameterCount ==
1893 inputs_.AddAll(operands, zone);
1896 LOperand* target() const { return inputs_[0]; }
1898 const CallInterfaceDescriptor descriptor() { return descriptor_; }
1900 DECLARE_HYDROGEN_ACCESSOR(CallWithDescriptor)
1902 // The target and context are passed as implicit parameters that are not
1903 // explicitly listed in the descriptor.
1904 static const int kImplicitRegisterParameterCount = 2;
1907 DECLARE_CONCRETE_INSTRUCTION(CallWithDescriptor, "call-with-descriptor")
1909 void PrintDataTo(StringStream* stream) override;
1911 int arity() const { return hydrogen()->argument_count() - 1; }
1913 CallInterfaceDescriptor descriptor_;
1914 ZoneList<LOperand*> inputs_;
1916 // Iterator support.
1917 int InputCount() final { return inputs_.length(); }
1918 LOperand* InputAt(int i) final { return inputs_[i]; }
1920 int TempCount() final { return 0; }
1921 LOperand* TempAt(int i) final { return NULL; }
1925 class LInvokeFunction final : public LTemplateInstruction<1, 2, 0> {
1927 LInvokeFunction(LOperand* context, LOperand* function) {
1928 inputs_[0] = context;
1929 inputs_[1] = function;
1932 LOperand* context() { return inputs_[0]; }
1933 LOperand* function() { return inputs_[1]; }
1935 DECLARE_CONCRETE_INSTRUCTION(InvokeFunction, "invoke-function")
1936 DECLARE_HYDROGEN_ACCESSOR(InvokeFunction)
1938 void PrintDataTo(StringStream* stream) override;
1940 int arity() const { return hydrogen()->argument_count() - 1; }
1944 class LCallFunction final : public LTemplateInstruction<1, 2, 2> {
1946 LCallFunction(LOperand* context, LOperand* function, LOperand* slot,
1948 inputs_[0] = context;
1949 inputs_[1] = function;
1954 LOperand* context() { return inputs_[0]; }
1955 LOperand* function() { return inputs_[1]; }
1956 LOperand* temp_slot() { return temps_[0]; }
1957 LOperand* temp_vector() { return temps_[1]; }
1959 DECLARE_CONCRETE_INSTRUCTION(CallFunction, "call-function")
1960 DECLARE_HYDROGEN_ACCESSOR(CallFunction)
1962 int arity() const { return hydrogen()->argument_count() - 1; }
1963 void PrintDataTo(StringStream* stream) override;
1967 class LCallNew final : public LTemplateInstruction<1, 2, 0> {
1969 LCallNew(LOperand* context, LOperand* constructor) {
1970 inputs_[0] = context;
1971 inputs_[1] = constructor;
1974 LOperand* context() { return inputs_[0]; }
1975 LOperand* constructor() { return inputs_[1]; }
1977 DECLARE_CONCRETE_INSTRUCTION(CallNew, "call-new")
1978 DECLARE_HYDROGEN_ACCESSOR(CallNew)
1980 void PrintDataTo(StringStream* stream) override;
1982 int arity() const { return hydrogen()->argument_count() - 1; }
1986 class LCallNewArray final : public LTemplateInstruction<1, 2, 0> {
1988 LCallNewArray(LOperand* context, LOperand* constructor) {
1989 inputs_[0] = context;
1990 inputs_[1] = constructor;
1993 LOperand* context() { return inputs_[0]; }
1994 LOperand* constructor() { return inputs_[1]; }
1996 DECLARE_CONCRETE_INSTRUCTION(CallNewArray, "call-new-array")
1997 DECLARE_HYDROGEN_ACCESSOR(CallNewArray)
1999 void PrintDataTo(StringStream* stream) override;
2001 int arity() const { return hydrogen()->argument_count() - 1; }
2005 class LCallRuntime final : public LTemplateInstruction<1, 1, 0> {
2007 explicit LCallRuntime(LOperand* context) {
2008 inputs_[0] = context;
2011 LOperand* context() { return inputs_[0]; }
2013 DECLARE_CONCRETE_INSTRUCTION(CallRuntime, "call-runtime")
2014 DECLARE_HYDROGEN_ACCESSOR(CallRuntime)
2016 bool ClobbersDoubleRegisters(Isolate* isolate) const override {
2017 return save_doubles() == kDontSaveFPRegs;
2020 const Runtime::Function* function() const { return hydrogen()->function(); }
2021 int arity() const { return hydrogen()->argument_count(); }
2022 SaveFPRegsMode save_doubles() const { return hydrogen()->save_doubles(); }
2026 class LInteger32ToDouble final : public LTemplateInstruction<1, 1, 0> {
2028 explicit LInteger32ToDouble(LOperand* value) {
2032 LOperand* value() { return inputs_[0]; }
2034 DECLARE_CONCRETE_INSTRUCTION(Integer32ToDouble, "int32-to-double")
2038 class LUint32ToDouble final : public LTemplateInstruction<1, 1, 0> {
2040 explicit LUint32ToDouble(LOperand* value) {
2044 LOperand* value() { return inputs_[0]; }
2046 DECLARE_CONCRETE_INSTRUCTION(Uint32ToDouble, "uint32-to-double")
2050 class LNumberTagU final : public LTemplateInstruction<1, 1, 2> {
2052 LNumberTagU(LOperand* value, LOperand* temp1, LOperand* temp2) {
2058 LOperand* value() { return inputs_[0]; }
2059 LOperand* temp1() { return temps_[0]; }
2060 LOperand* temp2() { return temps_[1]; }
2062 DECLARE_CONCRETE_INSTRUCTION(NumberTagU, "number-tag-u")
2066 class LNumberTagD final : public LTemplateInstruction<1, 1, 2> {
2068 LNumberTagD(LOperand* value, LOperand* temp, LOperand* temp2) {
2074 LOperand* value() { return inputs_[0]; }
2075 LOperand* temp() { return temps_[0]; }
2076 LOperand* temp2() { return temps_[1]; }
2078 DECLARE_CONCRETE_INSTRUCTION(NumberTagD, "number-tag-d")
2079 DECLARE_HYDROGEN_ACCESSOR(Change)
2083 class LDoubleToSmi final : public LTemplateInstruction<1, 1, 0> {
2085 explicit LDoubleToSmi(LOperand* value) {
2089 LOperand* value() { return inputs_[0]; }
2091 DECLARE_CONCRETE_INSTRUCTION(DoubleToSmi, "double-to-smi")
2092 DECLARE_HYDROGEN_ACCESSOR(UnaryOperation)
2094 bool truncating() { return hydrogen()->CanTruncateToInt32(); }
2098 // Sometimes truncating conversion from a tagged value to an int32.
2099 class LDoubleToI final : public LTemplateInstruction<1, 1, 0> {
2101 explicit LDoubleToI(LOperand* value) {
2105 LOperand* value() { return inputs_[0]; }
2107 DECLARE_CONCRETE_INSTRUCTION(DoubleToI, "double-to-i")
2108 DECLARE_HYDROGEN_ACCESSOR(UnaryOperation)
2110 bool truncating() { return hydrogen()->CanTruncateToInt32(); }
2114 // Truncating conversion from a tagged value to an int32.
2115 class LTaggedToI final : public LTemplateInstruction<1, 1, 2> {
2117 LTaggedToI(LOperand* value,
2125 LOperand* value() { return inputs_[0]; }
2126 LOperand* temp() { return temps_[0]; }
2127 LOperand* temp2() { return temps_[1]; }
2129 DECLARE_CONCRETE_INSTRUCTION(TaggedToI, "tagged-to-i")
2130 DECLARE_HYDROGEN_ACCESSOR(Change)
2132 bool truncating() { return hydrogen()->CanTruncateToInt32(); }
2136 class LSmiTag final : public LTemplateInstruction<1, 1, 0> {
2138 explicit LSmiTag(LOperand* value) {
2142 LOperand* value() { return inputs_[0]; }
2144 DECLARE_CONCRETE_INSTRUCTION(SmiTag, "smi-tag")
2145 DECLARE_HYDROGEN_ACCESSOR(Change)
2149 class LNumberUntagD final : public LTemplateInstruction<1, 1, 0> {
2151 explicit LNumberUntagD(LOperand* value) {
2155 LOperand* value() { return inputs_[0]; }
2157 DECLARE_CONCRETE_INSTRUCTION(NumberUntagD, "double-untag")
2158 DECLARE_HYDROGEN_ACCESSOR(Change)
2162 class LSmiUntag final : public LTemplateInstruction<1, 1, 0> {
2164 LSmiUntag(LOperand* value, bool needs_check)
2165 : needs_check_(needs_check) {
2169 LOperand* value() { return inputs_[0]; }
2170 bool needs_check() const { return needs_check_; }
2172 DECLARE_CONCRETE_INSTRUCTION(SmiUntag, "smi-untag")
2179 class LStoreNamedField final : public LTemplateInstruction<0, 2, 1> {
2181 LStoreNamedField(LOperand* object, LOperand* value, LOperand* temp) {
2182 inputs_[0] = object;
2187 LOperand* object() { return inputs_[0]; }
2188 LOperand* value() { return inputs_[1]; }
2189 LOperand* temp() { return temps_[0]; }
2191 DECLARE_CONCRETE_INSTRUCTION(StoreNamedField, "store-named-field")
2192 DECLARE_HYDROGEN_ACCESSOR(StoreNamedField)
2194 void PrintDataTo(StringStream* stream) override;
2196 Representation representation() const {
2197 return hydrogen()->field_representation();
2202 class LStoreNamedGeneric final : public LTemplateInstruction<0, 3, 2> {
2204 LStoreNamedGeneric(LOperand* context, LOperand* object, LOperand* value,
2205 LOperand* slot, LOperand* vector) {
2206 inputs_[0] = context;
2207 inputs_[1] = object;
2213 LOperand* context() { return inputs_[0]; }
2214 LOperand* object() { return inputs_[1]; }
2215 LOperand* value() { return inputs_[2]; }
2216 LOperand* temp_slot() { return temps_[0]; }
2217 LOperand* temp_vector() { return temps_[1]; }
2219 DECLARE_CONCRETE_INSTRUCTION(StoreNamedGeneric, "store-named-generic")
2220 DECLARE_HYDROGEN_ACCESSOR(StoreNamedGeneric)
2222 void PrintDataTo(StringStream* stream) override;
2224 Handle<Object> name() const { return hydrogen()->name(); }
2225 LanguageMode language_mode() { return hydrogen()->language_mode(); }
2229 class LStoreGlobalViaContext final : public LTemplateInstruction<0, 2, 0> {
2231 LStoreGlobalViaContext(LOperand* context, LOperand* value) {
2232 inputs_[0] = context;
2236 LOperand* context() { return inputs_[0]; }
2237 LOperand* value() { return inputs_[1]; }
2239 DECLARE_CONCRETE_INSTRUCTION(StoreGlobalViaContext,
2240 "store-global-via-context")
2241 DECLARE_HYDROGEN_ACCESSOR(StoreGlobalViaContext)
2243 void PrintDataTo(StringStream* stream) override;
2245 int depth() { return hydrogen()->depth(); }
2246 int slot_index() { return hydrogen()->slot_index(); }
2247 LanguageMode language_mode() { return hydrogen()->language_mode(); }
2251 class LStoreKeyed final : public LTemplateInstruction<0, 3, 0> {
2253 LStoreKeyed(LOperand* object, LOperand* key, LOperand* value) {
2254 inputs_[0] = object;
2259 bool is_fixed_typed_array() const {
2260 return hydrogen()->is_fixed_typed_array();
2262 LOperand* elements() { return inputs_[0]; }
2263 LOperand* key() { return inputs_[1]; }
2264 LOperand* value() { return inputs_[2]; }
2265 ElementsKind elements_kind() const {
2266 return hydrogen()->elements_kind();
2269 DECLARE_CONCRETE_INSTRUCTION(StoreKeyed, "store-keyed")
2270 DECLARE_HYDROGEN_ACCESSOR(StoreKeyed)
2272 void PrintDataTo(StringStream* stream) override;
2273 bool NeedsCanonicalization() { return hydrogen()->NeedsCanonicalization(); }
2274 uint32_t base_offset() const { return hydrogen()->base_offset(); }
2278 class LStoreKeyedGeneric final : public LTemplateInstruction<0, 4, 2> {
2280 LStoreKeyedGeneric(LOperand* context, LOperand* object, LOperand* key,
2281 LOperand* value, LOperand* slot, LOperand* vector) {
2282 inputs_[0] = context;
2283 inputs_[1] = object;
2290 LOperand* context() { return inputs_[0]; }
2291 LOperand* object() { return inputs_[1]; }
2292 LOperand* key() { return inputs_[2]; }
2293 LOperand* value() { return inputs_[3]; }
2294 LOperand* temp_slot() { return temps_[0]; }
2295 LOperand* temp_vector() { return temps_[1]; }
2297 DECLARE_CONCRETE_INSTRUCTION(StoreKeyedGeneric, "store-keyed-generic")
2298 DECLARE_HYDROGEN_ACCESSOR(StoreKeyedGeneric)
2300 void PrintDataTo(StringStream* stream) override;
2302 LanguageMode language_mode() { return hydrogen()->language_mode(); }
2306 class LTransitionElementsKind final : public LTemplateInstruction<0, 2, 1> {
2308 LTransitionElementsKind(LOperand* object,
2310 LOperand* new_map_temp) {
2311 inputs_[0] = object;
2312 inputs_[1] = context;
2313 temps_[0] = new_map_temp;
2316 LOperand* context() { return inputs_[1]; }
2317 LOperand* object() { return inputs_[0]; }
2318 LOperand* new_map_temp() { return temps_[0]; }
2320 DECLARE_CONCRETE_INSTRUCTION(TransitionElementsKind,
2321 "transition-elements-kind")
2322 DECLARE_HYDROGEN_ACCESSOR(TransitionElementsKind)
2324 void PrintDataTo(StringStream* stream) override;
2326 Handle<Map> original_map() { return hydrogen()->original_map().handle(); }
2327 Handle<Map> transitioned_map() {
2328 return hydrogen()->transitioned_map().handle();
2330 ElementsKind from_kind() { return hydrogen()->from_kind(); }
2331 ElementsKind to_kind() { return hydrogen()->to_kind(); }
2335 class LTrapAllocationMemento final : public LTemplateInstruction<0, 1, 1> {
2337 LTrapAllocationMemento(LOperand* object,
2339 inputs_[0] = object;
2343 LOperand* object() { return inputs_[0]; }
2344 LOperand* temp() { return temps_[0]; }
2346 DECLARE_CONCRETE_INSTRUCTION(TrapAllocationMemento,
2347 "trap-allocation-memento")
2351 class LMaybeGrowElements final : public LTemplateInstruction<1, 5, 0> {
2353 LMaybeGrowElements(LOperand* context, LOperand* object, LOperand* elements,
2354 LOperand* key, LOperand* current_capacity) {
2355 inputs_[0] = context;
2356 inputs_[1] = object;
2357 inputs_[2] = elements;
2359 inputs_[4] = current_capacity;
2362 LOperand* context() { return inputs_[0]; }
2363 LOperand* object() { return inputs_[1]; }
2364 LOperand* elements() { return inputs_[2]; }
2365 LOperand* key() { return inputs_[3]; }
2366 LOperand* current_capacity() { return inputs_[4]; }
2368 DECLARE_HYDROGEN_ACCESSOR(MaybeGrowElements)
2369 DECLARE_CONCRETE_INSTRUCTION(MaybeGrowElements, "maybe-grow-elements")
2373 class LStringAdd final : public LTemplateInstruction<1, 3, 0> {
2375 LStringAdd(LOperand* context, LOperand* left, LOperand* right) {
2376 inputs_[0] = context;
2381 LOperand* context() { return inputs_[0]; }
2382 LOperand* left() { return inputs_[1]; }
2383 LOperand* right() { return inputs_[2]; }
2385 DECLARE_CONCRETE_INSTRUCTION(StringAdd, "string-add")
2386 DECLARE_HYDROGEN_ACCESSOR(StringAdd)
2390 class LStringCharCodeAt final : public LTemplateInstruction<1, 3, 0> {
2392 LStringCharCodeAt(LOperand* context, LOperand* string, LOperand* index) {
2393 inputs_[0] = context;
2394 inputs_[1] = string;
2398 LOperand* context() { return inputs_[0]; }
2399 LOperand* string() { return inputs_[1]; }
2400 LOperand* index() { return inputs_[2]; }
2402 DECLARE_CONCRETE_INSTRUCTION(StringCharCodeAt, "string-char-code-at")
2403 DECLARE_HYDROGEN_ACCESSOR(StringCharCodeAt)
2407 class LStringCharFromCode final : public LTemplateInstruction<1, 2, 0> {
2409 explicit LStringCharFromCode(LOperand* context, LOperand* char_code) {
2410 inputs_[0] = context;
2411 inputs_[1] = char_code;
2414 LOperand* context() { return inputs_[0]; }
2415 LOperand* char_code() { return inputs_[1]; }
2417 DECLARE_CONCRETE_INSTRUCTION(StringCharFromCode, "string-char-from-code")
2418 DECLARE_HYDROGEN_ACCESSOR(StringCharFromCode)
2422 class LCheckValue final : public LTemplateInstruction<0, 1, 0> {
2424 explicit LCheckValue(LOperand* value) {
2428 LOperand* value() { return inputs_[0]; }
2430 DECLARE_CONCRETE_INSTRUCTION(CheckValue, "check-value")
2431 DECLARE_HYDROGEN_ACCESSOR(CheckValue)
2435 class LCheckArrayBufferNotNeutered final
2436 : public LTemplateInstruction<0, 1, 0> {
2438 explicit LCheckArrayBufferNotNeutered(LOperand* view) { inputs_[0] = view; }
2440 LOperand* view() { return inputs_[0]; }
2442 DECLARE_CONCRETE_INSTRUCTION(CheckArrayBufferNotNeutered,
2443 "check-array-buffer-not-neutered")
2444 DECLARE_HYDROGEN_ACCESSOR(CheckArrayBufferNotNeutered)
2448 class LCheckInstanceType final : public LTemplateInstruction<0, 1, 0> {
2450 explicit LCheckInstanceType(LOperand* value) {
2454 LOperand* value() { return inputs_[0]; }
2456 DECLARE_CONCRETE_INSTRUCTION(CheckInstanceType, "check-instance-type")
2457 DECLARE_HYDROGEN_ACCESSOR(CheckInstanceType)
2461 class LCheckMaps final : public LTemplateInstruction<0, 1, 0> {
2463 explicit LCheckMaps(LOperand* value = NULL) {
2467 LOperand* value() { return inputs_[0]; }
2469 DECLARE_CONCRETE_INSTRUCTION(CheckMaps, "check-maps")
2470 DECLARE_HYDROGEN_ACCESSOR(CheckMaps)
2474 class LCheckSmi final : public LTemplateInstruction<1, 1, 0> {
2476 explicit LCheckSmi(LOperand* value) {
2480 LOperand* value() { return inputs_[0]; }
2482 DECLARE_CONCRETE_INSTRUCTION(CheckSmi, "check-smi")
2486 class LCheckNonSmi final : public LTemplateInstruction<0, 1, 0> {
2488 explicit LCheckNonSmi(LOperand* value) {
2492 LOperand* value() { return inputs_[0]; }
2494 DECLARE_CONCRETE_INSTRUCTION(CheckNonSmi, "check-non-smi")
2495 DECLARE_HYDROGEN_ACCESSOR(CheckHeapObject)
2499 class LClampDToUint8 final : public LTemplateInstruction<1, 1, 1> {
2501 LClampDToUint8(LOperand* unclamped, LOperand* temp) {
2502 inputs_[0] = unclamped;
2506 LOperand* unclamped() { return inputs_[0]; }
2507 LOperand* temp() { return temps_[0]; }
2509 DECLARE_CONCRETE_INSTRUCTION(ClampDToUint8, "clamp-d-to-uint8")
2513 class LClampIToUint8 final : public LTemplateInstruction<1, 1, 0> {
2515 explicit LClampIToUint8(LOperand* unclamped) {
2516 inputs_[0] = unclamped;
2519 LOperand* unclamped() { return inputs_[0]; }
2521 DECLARE_CONCRETE_INSTRUCTION(ClampIToUint8, "clamp-i-to-uint8")
2525 class LClampTToUint8 final : public LTemplateInstruction<1, 1, 1> {
2527 LClampTToUint8(LOperand* unclamped, LOperand* temp) {
2528 inputs_[0] = unclamped;
2532 LOperand* unclamped() { return inputs_[0]; }
2533 LOperand* temp() { return temps_[0]; }
2535 DECLARE_CONCRETE_INSTRUCTION(ClampTToUint8, "clamp-t-to-uint8")
2539 class LDoubleBits final : public LTemplateInstruction<1, 1, 0> {
2541 explicit LDoubleBits(LOperand* value) {
2545 LOperand* value() { return inputs_[0]; }
2547 DECLARE_CONCRETE_INSTRUCTION(DoubleBits, "double-bits")
2548 DECLARE_HYDROGEN_ACCESSOR(DoubleBits)
2552 class LConstructDouble final : public LTemplateInstruction<1, 2, 0> {
2554 LConstructDouble(LOperand* hi, LOperand* lo) {
2559 LOperand* hi() { return inputs_[0]; }
2560 LOperand* lo() { return inputs_[1]; }
2562 DECLARE_CONCRETE_INSTRUCTION(ConstructDouble, "construct-double")
2566 class LAllocate final : public LTemplateInstruction<1, 2, 2> {
2568 LAllocate(LOperand* context,
2572 inputs_[0] = context;
2578 LOperand* context() { return inputs_[0]; }
2579 LOperand* size() { return inputs_[1]; }
2580 LOperand* temp1() { return temps_[0]; }
2581 LOperand* temp2() { return temps_[1]; }
2583 DECLARE_CONCRETE_INSTRUCTION(Allocate, "allocate")
2584 DECLARE_HYDROGEN_ACCESSOR(Allocate)
2588 class LRegExpLiteral final : public LTemplateInstruction<1, 1, 0> {
2590 explicit LRegExpLiteral(LOperand* context) {
2591 inputs_[0] = context;
2594 LOperand* context() { return inputs_[0]; }
2596 DECLARE_CONCRETE_INSTRUCTION(RegExpLiteral, "regexp-literal")
2597 DECLARE_HYDROGEN_ACCESSOR(RegExpLiteral)
2601 class LFunctionLiteral final : public LTemplateInstruction<1, 1, 0> {
2603 explicit LFunctionLiteral(LOperand* context) {
2604 inputs_[0] = context;
2607 LOperand* context() { return inputs_[0]; }
2609 DECLARE_CONCRETE_INSTRUCTION(FunctionLiteral, "function-literal")
2610 DECLARE_HYDROGEN_ACCESSOR(FunctionLiteral)
2614 class LToFastProperties final : public LTemplateInstruction<1, 1, 0> {
2616 explicit LToFastProperties(LOperand* value) {
2620 LOperand* value() { return inputs_[0]; }
2622 DECLARE_CONCRETE_INSTRUCTION(ToFastProperties, "to-fast-properties")
2623 DECLARE_HYDROGEN_ACCESSOR(ToFastProperties)
2627 class LTypeof final : public LTemplateInstruction<1, 2, 0> {
2629 LTypeof(LOperand* context, LOperand* value) {
2630 inputs_[0] = context;
2634 LOperand* context() { return inputs_[0]; }
2635 LOperand* value() { return inputs_[1]; }
2637 DECLARE_CONCRETE_INSTRUCTION(Typeof, "typeof")
2641 class LTypeofIsAndBranch final : public LControlInstruction<1, 0> {
2643 explicit LTypeofIsAndBranch(LOperand* value) {
2647 LOperand* value() { return inputs_[0]; }
2649 DECLARE_CONCRETE_INSTRUCTION(TypeofIsAndBranch, "typeof-is-and-branch")
2650 DECLARE_HYDROGEN_ACCESSOR(TypeofIsAndBranch)
2652 Handle<String> type_literal() { return hydrogen()->type_literal(); }
2654 void PrintDataTo(StringStream* stream) override;
2658 class LIsConstructCallAndBranch final : public LControlInstruction<0, 1> {
2660 explicit LIsConstructCallAndBranch(LOperand* temp) {
2664 LOperand* temp() { return temps_[0]; }
2666 DECLARE_CONCRETE_INSTRUCTION(IsConstructCallAndBranch,
2667 "is-construct-call-and-branch")
2671 class LOsrEntry final : public LTemplateInstruction<0, 0, 0> {
2675 bool HasInterestingComment(LCodeGen* gen) const override { return false; }
2676 DECLARE_CONCRETE_INSTRUCTION(OsrEntry, "osr-entry")
2680 class LStackCheck final : public LTemplateInstruction<0, 1, 0> {
2682 explicit LStackCheck(LOperand* context) {
2683 inputs_[0] = context;
2686 LOperand* context() { return inputs_[0]; }
2688 DECLARE_CONCRETE_INSTRUCTION(StackCheck, "stack-check")
2689 DECLARE_HYDROGEN_ACCESSOR(StackCheck)
2691 Label* done_label() { return &done_label_; }
2698 class LForInPrepareMap final : public LTemplateInstruction<1, 2, 0> {
2700 LForInPrepareMap(LOperand* context, LOperand* object) {
2701 inputs_[0] = context;
2702 inputs_[1] = object;
2705 LOperand* context() { return inputs_[0]; }
2706 LOperand* object() { return inputs_[1]; }
2708 DECLARE_CONCRETE_INSTRUCTION(ForInPrepareMap, "for-in-prepare-map")
2712 class LForInCacheArray final : public LTemplateInstruction<1, 1, 0> {
2714 explicit LForInCacheArray(LOperand* map) {
2718 LOperand* map() { return inputs_[0]; }
2720 DECLARE_CONCRETE_INSTRUCTION(ForInCacheArray, "for-in-cache-array")
2723 return HForInCacheArray::cast(this->hydrogen_value())->idx();
2728 class LCheckMapValue final : public LTemplateInstruction<0, 2, 0> {
2730 LCheckMapValue(LOperand* value, LOperand* map) {
2735 LOperand* value() { return inputs_[0]; }
2736 LOperand* map() { return inputs_[1]; }
2738 DECLARE_CONCRETE_INSTRUCTION(CheckMapValue, "check-map-value")
2742 class LLoadFieldByIndex final : public LTemplateInstruction<1, 2, 0> {
2744 LLoadFieldByIndex(LOperand* object, LOperand* index) {
2745 inputs_[0] = object;
2749 LOperand* object() { return inputs_[0]; }
2750 LOperand* index() { return inputs_[1]; }
2752 DECLARE_CONCRETE_INSTRUCTION(LoadFieldByIndex, "load-field-by-index")
2756 class LStoreFrameContext: public LTemplateInstruction<0, 1, 0> {
2758 explicit LStoreFrameContext(LOperand* context) {
2759 inputs_[0] = context;
2762 LOperand* context() { return inputs_[0]; }
2764 DECLARE_CONCRETE_INSTRUCTION(StoreFrameContext, "store-frame-context")
2768 class LAllocateBlockContext: public LTemplateInstruction<1, 2, 0> {
2770 LAllocateBlockContext(LOperand* context, LOperand* function) {
2771 inputs_[0] = context;
2772 inputs_[1] = function;
2775 LOperand* context() { return inputs_[0]; }
2776 LOperand* function() { return inputs_[1]; }
2778 Handle<ScopeInfo> scope_info() { return hydrogen()->scope_info(); }
2780 DECLARE_CONCRETE_INSTRUCTION(AllocateBlockContext, "allocate-block-context")
2781 DECLARE_HYDROGEN_ACCESSOR(AllocateBlockContext)
2785 class LChunkBuilder;
2786 class LPlatformChunk final : public LChunk {
2788 LPlatformChunk(CompilationInfo* info, HGraph* graph)
2789 : LChunk(info, graph) { }
2791 int GetNextSpillIndex(RegisterKind kind);
2792 LOperand* GetNextSpillSlot(RegisterKind kind);
2796 class LChunkBuilder final : public LChunkBuilderBase {
2798 LChunkBuilder(CompilationInfo* info, HGraph* graph, LAllocator* allocator)
2799 : LChunkBuilderBase(info, graph),
2800 current_instruction_(NULL),
2801 current_block_(NULL),
2803 allocator_(allocator) {}
2805 // Build the sequence for the graph.
2806 LPlatformChunk* Build();
2808 // Declare methods that deal with the individual node types.
2809 #define DECLARE_DO(type) LInstruction* Do##type(H##type* node);
2810 HYDROGEN_CONCRETE_INSTRUCTION_LIST(DECLARE_DO)
2813 LInstruction* DoMultiplyAdd(HMul* mul, HValue* addend);
2815 static bool HasMagicNumberForDivisor(int32_t divisor);
2817 LInstruction* DoMathFloor(HUnaryMathOperation* instr);
2818 LInstruction* DoMathRound(HUnaryMathOperation* instr);
2819 LInstruction* DoMathFround(HUnaryMathOperation* instr);
2820 LInstruction* DoMathAbs(HUnaryMathOperation* instr);
2821 LInstruction* DoMathLog(HUnaryMathOperation* instr);
2822 LInstruction* DoMathExp(HUnaryMathOperation* instr);
2823 LInstruction* DoMathSqrt(HUnaryMathOperation* instr);
2824 LInstruction* DoMathPowHalf(HUnaryMathOperation* instr);
2825 LInstruction* DoMathClz32(HUnaryMathOperation* instr);
2826 LInstruction* DoDivByPowerOf2I(HDiv* instr);
2827 LInstruction* DoDivByConstI(HDiv* instr);
2828 LInstruction* DoDivI(HDiv* instr);
2829 LInstruction* DoModByPowerOf2I(HMod* instr);
2830 LInstruction* DoModByConstI(HMod* instr);
2831 LInstruction* DoModI(HMod* instr);
2832 LInstruction* DoFlooringDivByPowerOf2I(HMathFloorOfDiv* instr);
2833 LInstruction* DoFlooringDivByConstI(HMathFloorOfDiv* instr);
2834 LInstruction* DoFlooringDivI(HMathFloorOfDiv* instr);
2837 // Methods for getting operands for Use / Define / Temp.
2838 LUnallocated* ToUnallocated(Register reg);
2839 LUnallocated* ToUnallocated(DoubleRegister reg);
2841 // Methods for setting up define-use relationships.
2842 MUST_USE_RESULT LOperand* Use(HValue* value, LUnallocated* operand);
2843 MUST_USE_RESULT LOperand* UseFixed(HValue* value, Register fixed_register);
2844 MUST_USE_RESULT LOperand* UseFixedDouble(HValue* value,
2845 DoubleRegister fixed_register);
2847 // A value that is guaranteed to be allocated to a register.
2848 // Operand created by UseRegister is guaranteed to be live until the end of
2849 // instruction. This means that register allocator will not reuse it's
2850 // register for any other operand inside instruction.
2851 // Operand created by UseRegisterAtStart is guaranteed to be live only at
2852 // instruction start. Register allocator is free to assign the same register
2853 // to some other operand used inside instruction (i.e. temporary or
2855 MUST_USE_RESULT LOperand* UseRegister(HValue* value);
2856 MUST_USE_RESULT LOperand* UseRegisterAtStart(HValue* value);
2858 // An input operand in a register that may be trashed.
2859 MUST_USE_RESULT LOperand* UseTempRegister(HValue* value);
2861 // An input operand in a register or stack slot.
2862 MUST_USE_RESULT LOperand* Use(HValue* value);
2863 MUST_USE_RESULT LOperand* UseAtStart(HValue* value);
2865 // An input operand in a register, stack slot or a constant operand.
2866 MUST_USE_RESULT LOperand* UseOrConstant(HValue* value);
2867 MUST_USE_RESULT LOperand* UseOrConstantAtStart(HValue* value);
2869 // An input operand in a register or a constant operand.
2870 MUST_USE_RESULT LOperand* UseRegisterOrConstant(HValue* value);
2871 MUST_USE_RESULT LOperand* UseRegisterOrConstantAtStart(HValue* value);
2873 // An input operand in a constant operand.
2874 MUST_USE_RESULT LOperand* UseConstant(HValue* value);
2876 // An input operand in register, stack slot or a constant operand.
2877 // Will not be moved to a register even if one is freely available.
2878 MUST_USE_RESULT LOperand* UseAny(HValue* value) override;
2880 // Temporary operand that must be in a register.
2881 MUST_USE_RESULT LUnallocated* TempRegister();
2882 MUST_USE_RESULT LUnallocated* TempDoubleRegister();
2883 MUST_USE_RESULT LOperand* FixedTemp(Register reg);
2884 MUST_USE_RESULT LOperand* FixedTemp(DoubleRegister reg);
2886 // Methods for setting up define-use relationships.
2887 // Return the same instruction that they are passed.
2888 LInstruction* Define(LTemplateResultInstruction<1>* instr,
2889 LUnallocated* result);
2890 LInstruction* DefineAsRegister(LTemplateResultInstruction<1>* instr);
2891 LInstruction* DefineAsSpilled(LTemplateResultInstruction<1>* instr,
2893 LInstruction* DefineSameAsFirst(LTemplateResultInstruction<1>* instr);
2894 LInstruction* DefineFixed(LTemplateResultInstruction<1>* instr,
2896 LInstruction* DefineFixedDouble(LTemplateResultInstruction<1>* instr,
2897 DoubleRegister reg);
2898 LInstruction* AssignEnvironment(LInstruction* instr);
2899 LInstruction* AssignPointerMap(LInstruction* instr);
2901 enum CanDeoptimize { CAN_DEOPTIMIZE_EAGERLY, CANNOT_DEOPTIMIZE_EAGERLY };
2903 // By default we assume that instruction sequences generated for calls
2904 // cannot deoptimize eagerly and we do not attach environment to this
2906 LInstruction* MarkAsCall(
2907 LInstruction* instr,
2908 HInstruction* hinstr,
2909 CanDeoptimize can_deoptimize = CANNOT_DEOPTIMIZE_EAGERLY);
2911 void VisitInstruction(HInstruction* current);
2912 void AddInstruction(LInstruction* instr, HInstruction* current);
2914 void DoBasicBlock(HBasicBlock* block, HBasicBlock* next_block);
2915 LInstruction* DoBit(Token::Value op, HBitwiseBinaryOperation* instr);
2916 LInstruction* DoShift(Token::Value op, HBitwiseBinaryOperation* instr);
2917 LInstruction* DoArithmeticD(Token::Value op,
2918 HArithmeticBinaryOperation* instr);
2919 LInstruction* DoArithmeticT(Token::Value op,
2920 HBinaryOperation* instr);
2922 HInstruction* current_instruction_;
2923 HBasicBlock* current_block_;
2924 HBasicBlock* next_block_;
2925 LAllocator* allocator_;
2927 DISALLOW_COPY_AND_ASSIGN(LChunkBuilder);
2930 #undef DECLARE_HYDROGEN_ACCESSOR
2931 #undef DECLARE_CONCRETE_INSTRUCTION
2933 } } // namespace v8::internal
2935 #endif // V8_MIPS_LITHIUM_MIPS_H_