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) \
24 V(AllocateBlockContext) \
26 V(ArgumentsElements) \
34 V(CallWithDescriptor) \
40 V(CheckArrayBufferNotNeutered) \
41 V(CheckInstanceType) \
50 V(ClassOfTestAndBranch) \
51 V(CompareMinusZeroAndBranch) \
52 V(CompareNumericAndBranch) \
53 V(CmpObjectEqAndBranch) \
77 V(FlooringDivByConstI) \
78 V(FlooringDivByPowerOf2I) \
83 V(GetCachedArrayIndex) \
85 V(HasCachedArrayIndexAndBranch) \
86 V(HasInstanceTypeAndBranch) \
87 V(InnerAllocatedObject) \
89 V(InstanceOfKnownGlobal) \
91 V(Integer32ToDouble) \
93 V(IsConstructCallAndBranch) \
94 V(IsObjectAndBranch) \
95 V(IsStringAndBranch) \
97 V(IsUndetectableAndBranch) \
102 V(LoadFieldByIndex) \
103 V(LoadFunctionPrototype) \
104 V(LoadGlobalGeneric) \
105 V(LoadGlobalViaContext) \
107 V(LoadKeyedGeneric) \
109 V(LoadNamedGeneric) \
121 V(MaybeGrowElements) \
137 V(SeqStringGetChar) \
138 V(SeqStringSetChar) \
144 V(StoreContextSlot) \
145 V(StoreFrameContext) \
146 V(StoreGlobalViaContext) \
148 V(StoreKeyedGeneric) \
150 V(StoreNamedGeneric) \
152 V(StringCharCodeAt) \
153 V(StringCharFromCode) \
154 V(StringCompareAndBranch) \
158 V(ToFastProperties) \
159 V(TransitionElementsKind) \
160 V(TrapAllocationMemento) \
162 V(TypeofIsAndBranch) \
167 #define DECLARE_CONCRETE_INSTRUCTION(type, mnemonic) \
168 Opcode opcode() const final { return LInstruction::k##type; } \
169 void CompileToNative(LCodeGen* generator) final; \
170 const char* Mnemonic() const final { return mnemonic; } \
171 static L##type* cast(LInstruction* instr) { \
172 DCHECK(instr->Is##type()); \
173 return reinterpret_cast<L##type*>(instr); \
177 #define DECLARE_HYDROGEN_ACCESSOR(type) \
178 H##type* hydrogen() const { \
179 return H##type::cast(hydrogen_value()); \
183 class LInstruction : public ZoneObject {
186 : environment_(NULL),
187 hydrogen_value_(NULL),
188 bit_field_(IsCallBits::encode(false)) {
191 virtual ~LInstruction() {}
193 virtual void CompileToNative(LCodeGen* generator) = 0;
194 virtual const char* Mnemonic() const = 0;
195 virtual void PrintTo(StringStream* stream);
196 virtual void PrintDataTo(StringStream* stream);
197 virtual void PrintOutputOperandTo(StringStream* stream);
200 // Declare a unique enum value for each instruction.
201 #define DECLARE_OPCODE(type) k##type,
202 LITHIUM_CONCRETE_INSTRUCTION_LIST(DECLARE_OPCODE)
203 kNumberOfInstructions
204 #undef DECLARE_OPCODE
207 virtual Opcode opcode() const = 0;
209 // Declare non-virtual type testers for all leaf IR classes.
210 #define DECLARE_PREDICATE(type) \
211 bool Is##type() const { return opcode() == k##type; }
212 LITHIUM_CONCRETE_INSTRUCTION_LIST(DECLARE_PREDICATE)
213 #undef DECLARE_PREDICATE
215 // Declare virtual predicates for instructions that don't have
217 virtual bool IsGap() const { return false; }
219 virtual bool IsControl() const { return false; }
221 // Try deleting this instruction if possible.
222 virtual bool TryDelete() { return false; }
224 void set_environment(LEnvironment* env) { environment_ = env; }
225 LEnvironment* environment() const { return environment_; }
226 bool HasEnvironment() const { return environment_ != NULL; }
228 void set_pointer_map(LPointerMap* p) { pointer_map_.set(p); }
229 LPointerMap* pointer_map() const { return pointer_map_.get(); }
230 bool HasPointerMap() const { return pointer_map_.is_set(); }
232 void set_hydrogen_value(HValue* value) { hydrogen_value_ = value; }
233 HValue* hydrogen_value() const { return hydrogen_value_; }
235 virtual void SetDeferredLazyDeoptimizationEnvironment(LEnvironment* env) { }
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 LLazyBailout final : public LTemplateInstruction<0, 0, 0> {
394 LLazyBailout() : gap_instructions_size_(0) { }
396 DECLARE_CONCRETE_INSTRUCTION(LazyBailout, "lazy-bailout")
398 void set_gap_instructions_size(int gap_instructions_size) {
399 gap_instructions_size_ = gap_instructions_size;
401 int gap_instructions_size() { return gap_instructions_size_; }
404 int gap_instructions_size_;
408 class LDummy final : public LTemplateInstruction<1, 0, 0> {
411 DECLARE_CONCRETE_INSTRUCTION(Dummy, "dummy")
415 class LDummyUse final : public LTemplateInstruction<1, 1, 0> {
417 explicit LDummyUse(LOperand* value) {
420 DECLARE_CONCRETE_INSTRUCTION(DummyUse, "dummy-use")
424 class LDeoptimize final : public LTemplateInstruction<0, 0, 0> {
426 bool IsControl() const override { return true; }
427 DECLARE_CONCRETE_INSTRUCTION(Deoptimize, "deoptimize")
428 DECLARE_HYDROGEN_ACCESSOR(Deoptimize)
432 class LLabel final : public LGap {
434 explicit LLabel(HBasicBlock* block)
435 : LGap(block), replacement_(NULL) { }
437 bool HasInterestingComment(LCodeGen* gen) const override { return false; }
438 DECLARE_CONCRETE_INSTRUCTION(Label, "label")
440 void PrintDataTo(StringStream* stream) override;
442 int block_id() const { return block()->block_id(); }
443 bool is_loop_header() const { return block()->IsLoopHeader(); }
444 bool is_osr_entry() const { return block()->is_osr_entry(); }
445 Label* label() { return &label_; }
446 LLabel* replacement() const { return replacement_; }
447 void set_replacement(LLabel* label) { replacement_ = label; }
448 bool HasReplacement() const { return replacement_ != NULL; }
452 LLabel* replacement_;
456 class LParameter final : public LTemplateInstruction<1, 0, 0> {
458 bool HasInterestingComment(LCodeGen* gen) const override { return false; }
459 DECLARE_CONCRETE_INSTRUCTION(Parameter, "parameter")
463 class LCallStub final : public LTemplateInstruction<1, 1, 0> {
465 explicit LCallStub(LOperand* context) {
466 inputs_[0] = context;
469 LOperand* context() { return inputs_[0]; }
471 DECLARE_CONCRETE_INSTRUCTION(CallStub, "call-stub")
472 DECLARE_HYDROGEN_ACCESSOR(CallStub)
476 class LUnknownOSRValue final : public LTemplateInstruction<1, 0, 0> {
478 bool HasInterestingComment(LCodeGen* gen) const override { return false; }
479 DECLARE_CONCRETE_INSTRUCTION(UnknownOSRValue, "unknown-osr-value")
483 template<int I, int T>
484 class LControlInstruction : public LTemplateInstruction<0, I, T> {
486 LControlInstruction() : false_label_(NULL), true_label_(NULL) { }
488 bool IsControl() const final { return true; }
490 int SuccessorCount() { return hydrogen()->SuccessorCount(); }
491 HBasicBlock* SuccessorAt(int i) { return hydrogen()->SuccessorAt(i); }
493 int TrueDestination(LChunk* chunk) {
494 return chunk->LookupDestination(true_block_id());
496 int FalseDestination(LChunk* chunk) {
497 return chunk->LookupDestination(false_block_id());
500 Label* TrueLabel(LChunk* chunk) {
501 if (true_label_ == NULL) {
502 true_label_ = chunk->GetAssemblyLabel(TrueDestination(chunk));
506 Label* FalseLabel(LChunk* chunk) {
507 if (false_label_ == NULL) {
508 false_label_ = chunk->GetAssemblyLabel(FalseDestination(chunk));
514 int true_block_id() { return SuccessorAt(0)->block_id(); }
515 int false_block_id() { return SuccessorAt(1)->block_id(); }
518 HControlInstruction* hydrogen() {
519 return HControlInstruction::cast(this->hydrogen_value());
527 class LWrapReceiver final : public LTemplateInstruction<1, 2, 0> {
529 LWrapReceiver(LOperand* receiver, LOperand* function) {
530 inputs_[0] = receiver;
531 inputs_[1] = function;
534 DECLARE_CONCRETE_INSTRUCTION(WrapReceiver, "wrap-receiver")
535 DECLARE_HYDROGEN_ACCESSOR(WrapReceiver)
537 LOperand* receiver() { return inputs_[0]; }
538 LOperand* function() { return inputs_[1]; }
542 class LApplyArguments final : public LTemplateInstruction<1, 4, 0> {
544 LApplyArguments(LOperand* function,
547 LOperand* elements) {
548 inputs_[0] = function;
549 inputs_[1] = receiver;
551 inputs_[3] = elements;
554 DECLARE_CONCRETE_INSTRUCTION(ApplyArguments, "apply-arguments")
556 LOperand* function() { return inputs_[0]; }
557 LOperand* receiver() { return inputs_[1]; }
558 LOperand* length() { return inputs_[2]; }
559 LOperand* elements() { return inputs_[3]; }
563 class LAccessArgumentsAt final : public LTemplateInstruction<1, 3, 0> {
565 LAccessArgumentsAt(LOperand* arguments, LOperand* length, LOperand* index) {
566 inputs_[0] = arguments;
571 DECLARE_CONCRETE_INSTRUCTION(AccessArgumentsAt, "access-arguments-at")
573 LOperand* arguments() { return inputs_[0]; }
574 LOperand* length() { return inputs_[1]; }
575 LOperand* index() { return inputs_[2]; }
577 void PrintDataTo(StringStream* stream) override;
581 class LArgumentsLength final : public LTemplateInstruction<1, 1, 0> {
583 explicit LArgumentsLength(LOperand* elements) {
584 inputs_[0] = elements;
587 LOperand* elements() { return inputs_[0]; }
589 DECLARE_CONCRETE_INSTRUCTION(ArgumentsLength, "arguments-length")
593 class LArgumentsElements final : public LTemplateInstruction<1, 0, 0> {
595 DECLARE_CONCRETE_INSTRUCTION(ArgumentsElements, "arguments-elements")
596 DECLARE_HYDROGEN_ACCESSOR(ArgumentsElements)
600 class LModByPowerOf2I final : public LTemplateInstruction<1, 1, 0> {
602 LModByPowerOf2I(LOperand* dividend, int32_t divisor) {
603 inputs_[0] = dividend;
607 LOperand* dividend() { return inputs_[0]; }
608 int32_t divisor() const { return divisor_; }
610 DECLARE_CONCRETE_INSTRUCTION(ModByPowerOf2I, "mod-by-power-of-2-i")
611 DECLARE_HYDROGEN_ACCESSOR(Mod)
618 class LModByConstI final : public LTemplateInstruction<1, 1, 0> {
620 LModByConstI(LOperand* dividend, int32_t divisor) {
621 inputs_[0] = dividend;
625 LOperand* dividend() { return inputs_[0]; }
626 int32_t divisor() const { return divisor_; }
628 DECLARE_CONCRETE_INSTRUCTION(ModByConstI, "mod-by-const-i")
629 DECLARE_HYDROGEN_ACCESSOR(Mod)
636 class LModI final : public LTemplateInstruction<1, 2, 3> {
638 LModI(LOperand* left,
644 LOperand* left() { return inputs_[0]; }
645 LOperand* right() { return inputs_[1]; }
647 DECLARE_CONCRETE_INSTRUCTION(ModI, "mod-i")
648 DECLARE_HYDROGEN_ACCESSOR(Mod)
652 class LDivByPowerOf2I final : public LTemplateInstruction<1, 1, 0> {
654 LDivByPowerOf2I(LOperand* dividend, int32_t divisor) {
655 inputs_[0] = dividend;
659 LOperand* dividend() { return inputs_[0]; }
660 int32_t divisor() const { return divisor_; }
662 DECLARE_CONCRETE_INSTRUCTION(DivByPowerOf2I, "div-by-power-of-2-i")
663 DECLARE_HYDROGEN_ACCESSOR(Div)
670 class LDivByConstI final : public LTemplateInstruction<1, 1, 0> {
672 LDivByConstI(LOperand* dividend, int32_t divisor) {
673 inputs_[0] = dividend;
677 LOperand* dividend() { return inputs_[0]; }
678 int32_t divisor() const { return divisor_; }
680 DECLARE_CONCRETE_INSTRUCTION(DivByConstI, "div-by-const-i")
681 DECLARE_HYDROGEN_ACCESSOR(Div)
688 class LDivI final : public LTemplateInstruction<1, 2, 1> {
690 LDivI(LOperand* dividend, LOperand* divisor, LOperand* temp) {
691 inputs_[0] = dividend;
692 inputs_[1] = divisor;
696 LOperand* dividend() { return inputs_[0]; }
697 LOperand* divisor() { return inputs_[1]; }
698 LOperand* temp() { return temps_[0]; }
700 DECLARE_CONCRETE_INSTRUCTION(DivI, "div-i")
701 DECLARE_HYDROGEN_ACCESSOR(BinaryOperation)
705 class LFlooringDivByPowerOf2I final : public LTemplateInstruction<1, 1, 0> {
707 LFlooringDivByPowerOf2I(LOperand* dividend, int32_t divisor) {
708 inputs_[0] = dividend;
712 LOperand* dividend() { return inputs_[0]; }
713 int32_t divisor() { return divisor_; }
715 DECLARE_CONCRETE_INSTRUCTION(FlooringDivByPowerOf2I,
716 "flooring-div-by-power-of-2-i")
717 DECLARE_HYDROGEN_ACCESSOR(MathFloorOfDiv)
724 class LFlooringDivByConstI final : public LTemplateInstruction<1, 1, 2> {
726 LFlooringDivByConstI(LOperand* dividend, int32_t divisor, LOperand* temp) {
727 inputs_[0] = dividend;
732 LOperand* dividend() { return inputs_[0]; }
733 int32_t divisor() const { return divisor_; }
734 LOperand* temp() { return temps_[0]; }
736 DECLARE_CONCRETE_INSTRUCTION(FlooringDivByConstI, "flooring-div-by-const-i")
737 DECLARE_HYDROGEN_ACCESSOR(MathFloorOfDiv)
744 class LFlooringDivI final : public LTemplateInstruction<1, 2, 0> {
746 LFlooringDivI(LOperand* dividend, LOperand* divisor) {
747 inputs_[0] = dividend;
748 inputs_[1] = divisor;
751 LOperand* dividend() { return inputs_[0]; }
752 LOperand* divisor() { return inputs_[1]; }
754 DECLARE_CONCRETE_INSTRUCTION(FlooringDivI, "flooring-div-i")
755 DECLARE_HYDROGEN_ACCESSOR(MathFloorOfDiv)
759 class LMulI final : public LTemplateInstruction<1, 2, 0> {
761 LMulI(LOperand* left, LOperand* right) {
766 LOperand* left() { return inputs_[0]; }
767 LOperand* right() { return inputs_[1]; }
769 DECLARE_CONCRETE_INSTRUCTION(MulI, "mul-i")
770 DECLARE_HYDROGEN_ACCESSOR(Mul)
774 // Instruction for computing multiplier * multiplicand + addend.
775 class LMultiplyAddD final : public LTemplateInstruction<1, 3, 0> {
777 LMultiplyAddD(LOperand* addend, LOperand* multiplier,
778 LOperand* multiplicand) {
780 inputs_[1] = multiplier;
781 inputs_[2] = multiplicand;
784 LOperand* addend() { return inputs_[0]; }
785 LOperand* multiplier() { return inputs_[1]; }
786 LOperand* multiplicand() { return inputs_[2]; }
788 DECLARE_CONCRETE_INSTRUCTION(MultiplyAddD, "multiply-add-d")
792 class LDebugBreak final : public LTemplateInstruction<0, 0, 0> {
794 DECLARE_CONCRETE_INSTRUCTION(DebugBreak, "break")
798 class LCompareNumericAndBranch final : public LControlInstruction<2, 0> {
800 LCompareNumericAndBranch(LOperand* left, LOperand* right) {
805 LOperand* left() { return inputs_[0]; }
806 LOperand* right() { return inputs_[1]; }
808 DECLARE_CONCRETE_INSTRUCTION(CompareNumericAndBranch,
809 "compare-numeric-and-branch")
810 DECLARE_HYDROGEN_ACCESSOR(CompareNumericAndBranch)
812 Token::Value op() const { return hydrogen()->token(); }
813 bool is_double() const {
814 return hydrogen()->representation().IsDouble();
817 void PrintDataTo(StringStream* stream) override;
821 class LMathFloor final : public LTemplateInstruction<1, 1, 1> {
823 LMathFloor(LOperand* value, LOperand* temp) {
828 LOperand* value() { return inputs_[0]; }
829 LOperand* temp() { return temps_[0]; }
831 DECLARE_CONCRETE_INSTRUCTION(MathFloor, "math-floor")
832 DECLARE_HYDROGEN_ACCESSOR(UnaryMathOperation)
836 class LMathRound final : public LTemplateInstruction<1, 1, 1> {
838 LMathRound(LOperand* value, LOperand* temp) {
843 LOperand* value() { return inputs_[0]; }
844 LOperand* temp() { return temps_[0]; }
846 DECLARE_CONCRETE_INSTRUCTION(MathRound, "math-round")
847 DECLARE_HYDROGEN_ACCESSOR(UnaryMathOperation)
851 class LMathFround final : public LTemplateInstruction<1, 1, 0> {
853 explicit LMathFround(LOperand* value) { inputs_[0] = value; }
855 LOperand* value() { return inputs_[0]; }
857 DECLARE_CONCRETE_INSTRUCTION(MathFround, "math-fround")
861 class LMathAbs final : public LTemplateInstruction<1, 2, 0> {
863 LMathAbs(LOperand* context, LOperand* value) {
864 inputs_[1] = context;
868 LOperand* context() { return inputs_[1]; }
869 LOperand* value() { return inputs_[0]; }
871 DECLARE_CONCRETE_INSTRUCTION(MathAbs, "math-abs")
872 DECLARE_HYDROGEN_ACCESSOR(UnaryMathOperation)
876 class LMathLog final : public LTemplateInstruction<1, 1, 0> {
878 explicit LMathLog(LOperand* value) {
882 LOperand* value() { return inputs_[0]; }
884 DECLARE_CONCRETE_INSTRUCTION(MathLog, "math-log")
888 class LMathClz32 final : public LTemplateInstruction<1, 1, 0> {
890 explicit LMathClz32(LOperand* value) {
894 LOperand* value() { return inputs_[0]; }
896 DECLARE_CONCRETE_INSTRUCTION(MathClz32, "math-clz32")
900 class LMathExp final : public LTemplateInstruction<1, 1, 3> {
902 LMathExp(LOperand* value,
903 LOperand* double_temp,
909 temps_[2] = double_temp;
910 ExternalReference::InitializeMathExpData();
913 LOperand* value() { return inputs_[0]; }
914 LOperand* temp1() { return temps_[0]; }
915 LOperand* temp2() { return temps_[1]; }
916 LOperand* double_temp() { return temps_[2]; }
918 DECLARE_CONCRETE_INSTRUCTION(MathExp, "math-exp")
922 class LMathSqrt final : public LTemplateInstruction<1, 1, 0> {
924 explicit LMathSqrt(LOperand* value) {
928 LOperand* value() { return inputs_[0]; }
930 DECLARE_CONCRETE_INSTRUCTION(MathSqrt, "math-sqrt")
934 class LMathPowHalf final : public LTemplateInstruction<1, 1, 1> {
936 LMathPowHalf(LOperand* value, LOperand* temp) {
941 LOperand* value() { return inputs_[0]; }
942 LOperand* temp() { return temps_[0]; }
944 DECLARE_CONCRETE_INSTRUCTION(MathPowHalf, "math-pow-half")
948 class LCmpObjectEqAndBranch final : public LControlInstruction<2, 0> {
950 LCmpObjectEqAndBranch(LOperand* left, LOperand* right) {
955 LOperand* left() { return inputs_[0]; }
956 LOperand* right() { return inputs_[1]; }
958 DECLARE_CONCRETE_INSTRUCTION(CmpObjectEqAndBranch, "cmp-object-eq-and-branch")
959 DECLARE_HYDROGEN_ACCESSOR(CompareObjectEqAndBranch)
963 class LCmpHoleAndBranch final : public LControlInstruction<1, 0> {
965 explicit LCmpHoleAndBranch(LOperand* object) {
969 LOperand* object() { return inputs_[0]; }
971 DECLARE_CONCRETE_INSTRUCTION(CmpHoleAndBranch, "cmp-hole-and-branch")
972 DECLARE_HYDROGEN_ACCESSOR(CompareHoleAndBranch)
976 class LCompareMinusZeroAndBranch final : public LControlInstruction<1, 1> {
978 LCompareMinusZeroAndBranch(LOperand* value, LOperand* temp) {
983 LOperand* value() { return inputs_[0]; }
984 LOperand* temp() { return temps_[0]; }
986 DECLARE_CONCRETE_INSTRUCTION(CompareMinusZeroAndBranch,
987 "cmp-minus-zero-and-branch")
988 DECLARE_HYDROGEN_ACCESSOR(CompareMinusZeroAndBranch)
992 class LIsObjectAndBranch final : public LControlInstruction<1, 1> {
994 LIsObjectAndBranch(LOperand* value, LOperand* temp) {
999 LOperand* value() { return inputs_[0]; }
1000 LOperand* temp() { return temps_[0]; }
1002 DECLARE_CONCRETE_INSTRUCTION(IsObjectAndBranch, "is-object-and-branch")
1003 DECLARE_HYDROGEN_ACCESSOR(IsObjectAndBranch)
1005 void PrintDataTo(StringStream* stream) override;
1009 class LIsStringAndBranch final : public LControlInstruction<1, 1> {
1011 LIsStringAndBranch(LOperand* value, LOperand* temp) {
1016 LOperand* value() { return inputs_[0]; }
1017 LOperand* temp() { return temps_[0]; }
1019 DECLARE_CONCRETE_INSTRUCTION(IsStringAndBranch, "is-string-and-branch")
1020 DECLARE_HYDROGEN_ACCESSOR(IsStringAndBranch)
1022 void PrintDataTo(StringStream* stream) override;
1026 class LIsSmiAndBranch final : public LControlInstruction<1, 0> {
1028 explicit LIsSmiAndBranch(LOperand* value) {
1032 LOperand* value() { return inputs_[0]; }
1034 DECLARE_CONCRETE_INSTRUCTION(IsSmiAndBranch, "is-smi-and-branch")
1035 DECLARE_HYDROGEN_ACCESSOR(IsSmiAndBranch)
1037 void PrintDataTo(StringStream* stream) override;
1041 class LIsUndetectableAndBranch final : public LControlInstruction<1, 1> {
1043 explicit LIsUndetectableAndBranch(LOperand* value, LOperand* temp) {
1048 LOperand* value() { return inputs_[0]; }
1049 LOperand* temp() { return temps_[0]; }
1051 DECLARE_CONCRETE_INSTRUCTION(IsUndetectableAndBranch,
1052 "is-undetectable-and-branch")
1053 DECLARE_HYDROGEN_ACCESSOR(IsUndetectableAndBranch)
1055 void PrintDataTo(StringStream* stream) override;
1059 class LStringCompareAndBranch final : public LControlInstruction<3, 0> {
1061 LStringCompareAndBranch(LOperand* context, LOperand* left, LOperand* right) {
1062 inputs_[0] = context;
1067 LOperand* context() { return inputs_[0]; }
1068 LOperand* left() { return inputs_[1]; }
1069 LOperand* right() { return inputs_[2]; }
1071 DECLARE_CONCRETE_INSTRUCTION(StringCompareAndBranch,
1072 "string-compare-and-branch")
1073 DECLARE_HYDROGEN_ACCESSOR(StringCompareAndBranch)
1075 Token::Value op() const { return hydrogen()->token(); }
1077 void PrintDataTo(StringStream* stream) override;
1081 class LHasInstanceTypeAndBranch final : public LControlInstruction<1, 0> {
1083 explicit LHasInstanceTypeAndBranch(LOperand* value) {
1087 LOperand* value() { return inputs_[0]; }
1089 DECLARE_CONCRETE_INSTRUCTION(HasInstanceTypeAndBranch,
1090 "has-instance-type-and-branch")
1091 DECLARE_HYDROGEN_ACCESSOR(HasInstanceTypeAndBranch)
1093 void PrintDataTo(StringStream* stream) override;
1097 class LGetCachedArrayIndex final : public LTemplateInstruction<1, 1, 0> {
1099 explicit LGetCachedArrayIndex(LOperand* value) {
1103 LOperand* value() { return inputs_[0]; }
1105 DECLARE_CONCRETE_INSTRUCTION(GetCachedArrayIndex, "get-cached-array-index")
1106 DECLARE_HYDROGEN_ACCESSOR(GetCachedArrayIndex)
1110 class LHasCachedArrayIndexAndBranch final : public LControlInstruction<1, 0> {
1112 explicit LHasCachedArrayIndexAndBranch(LOperand* value) {
1116 LOperand* value() { return inputs_[0]; }
1118 DECLARE_CONCRETE_INSTRUCTION(HasCachedArrayIndexAndBranch,
1119 "has-cached-array-index-and-branch")
1120 DECLARE_HYDROGEN_ACCESSOR(HasCachedArrayIndexAndBranch)
1122 void PrintDataTo(StringStream* stream) override;
1126 class LClassOfTestAndBranch final : public LControlInstruction<1, 1> {
1128 LClassOfTestAndBranch(LOperand* value, LOperand* temp) {
1133 LOperand* value() { return inputs_[0]; }
1134 LOperand* temp() { return temps_[0]; }
1136 DECLARE_CONCRETE_INSTRUCTION(ClassOfTestAndBranch,
1137 "class-of-test-and-branch")
1138 DECLARE_HYDROGEN_ACCESSOR(ClassOfTestAndBranch)
1140 void PrintDataTo(StringStream* stream) override;
1144 class LCmpT final : public LTemplateInstruction<1, 3, 0> {
1146 LCmpT(LOperand* context, LOperand* left, LOperand* right) {
1147 inputs_[0] = context;
1152 LOperand* context() { return inputs_[0]; }
1153 LOperand* left() { return inputs_[1]; }
1154 LOperand* right() { return inputs_[2]; }
1156 DECLARE_CONCRETE_INSTRUCTION(CmpT, "cmp-t")
1157 DECLARE_HYDROGEN_ACCESSOR(CompareGeneric)
1159 Strength strength() { return hydrogen()->strength(); }
1161 Token::Value op() const { return hydrogen()->token(); }
1165 class LInstanceOf final : public LTemplateInstruction<1, 3, 0> {
1167 LInstanceOf(LOperand* context, LOperand* left, LOperand* right) {
1168 inputs_[0] = context;
1173 LOperand* context() { return inputs_[0]; }
1174 LOperand* left() { return inputs_[1]; }
1175 LOperand* right() { return inputs_[2]; }
1177 DECLARE_CONCRETE_INSTRUCTION(InstanceOf, "instance-of")
1181 class LInstanceOfKnownGlobal final : public LTemplateInstruction<1, 2, 1> {
1183 LInstanceOfKnownGlobal(LOperand* context, LOperand* value, LOperand* temp) {
1184 inputs_[0] = context;
1189 LOperand* context() { return inputs_[0]; }
1190 LOperand* value() { return inputs_[1]; }
1191 LOperand* temp() { return temps_[0]; }
1193 DECLARE_CONCRETE_INSTRUCTION(InstanceOfKnownGlobal,
1194 "instance-of-known-global")
1195 DECLARE_HYDROGEN_ACCESSOR(InstanceOfKnownGlobal)
1197 Handle<JSFunction> function() const { return hydrogen()->function(); }
1198 LEnvironment* GetDeferredLazyDeoptimizationEnvironment() {
1199 return lazy_deopt_env_;
1201 virtual void SetDeferredLazyDeoptimizationEnvironment(
1202 LEnvironment* env) override {
1203 lazy_deopt_env_ = env;
1207 LEnvironment* lazy_deopt_env_;
1211 class LBoundsCheck final : public LTemplateInstruction<0, 2, 0> {
1213 LBoundsCheck(LOperand* index, LOperand* length) {
1215 inputs_[1] = length;
1218 LOperand* index() { return inputs_[0]; }
1219 LOperand* length() { return inputs_[1]; }
1221 DECLARE_CONCRETE_INSTRUCTION(BoundsCheck, "bounds-check")
1222 DECLARE_HYDROGEN_ACCESSOR(BoundsCheck)
1226 class LBitI final : public LTemplateInstruction<1, 2, 0> {
1228 LBitI(LOperand* left, LOperand* right) {
1233 LOperand* left() { return inputs_[0]; }
1234 LOperand* right() { return inputs_[1]; }
1236 Token::Value op() const { return hydrogen()->op(); }
1238 DECLARE_CONCRETE_INSTRUCTION(BitI, "bit-i")
1239 DECLARE_HYDROGEN_ACCESSOR(Bitwise)
1243 class LShiftI final : public LTemplateInstruction<1, 2, 0> {
1245 LShiftI(Token::Value op, LOperand* left, LOperand* right, bool can_deopt)
1246 : op_(op), can_deopt_(can_deopt) {
1251 Token::Value op() const { return op_; }
1252 LOperand* left() { return inputs_[0]; }
1253 LOperand* right() { return inputs_[1]; }
1254 bool can_deopt() const { return can_deopt_; }
1256 DECLARE_CONCRETE_INSTRUCTION(ShiftI, "shift-i")
1264 class LSubI final : public LTemplateInstruction<1, 2, 0> {
1266 LSubI(LOperand* left, LOperand* right) {
1271 LOperand* left() { return inputs_[0]; }
1272 LOperand* right() { return inputs_[1]; }
1274 DECLARE_CONCRETE_INSTRUCTION(SubI, "sub-i")
1275 DECLARE_HYDROGEN_ACCESSOR(Sub)
1279 class LConstantI final : public LTemplateInstruction<1, 0, 0> {
1281 DECLARE_CONCRETE_INSTRUCTION(ConstantI, "constant-i")
1282 DECLARE_HYDROGEN_ACCESSOR(Constant)
1284 int32_t value() const { return hydrogen()->Integer32Value(); }
1288 class LConstantS final : public LTemplateInstruction<1, 0, 0> {
1290 DECLARE_CONCRETE_INSTRUCTION(ConstantS, "constant-s")
1291 DECLARE_HYDROGEN_ACCESSOR(Constant)
1293 Smi* value() const { return Smi::FromInt(hydrogen()->Integer32Value()); }
1297 class LConstantD final : public LTemplateInstruction<1, 0, 0> {
1299 DECLARE_CONCRETE_INSTRUCTION(ConstantD, "constant-d")
1300 DECLARE_HYDROGEN_ACCESSOR(Constant)
1302 double value() const { return hydrogen()->DoubleValue(); }
1303 uint64_t bits() const { return hydrogen()->DoubleValueAsBits(); }
1307 class LConstantE final : public LTemplateInstruction<1, 0, 0> {
1309 DECLARE_CONCRETE_INSTRUCTION(ConstantE, "constant-e")
1310 DECLARE_HYDROGEN_ACCESSOR(Constant)
1312 ExternalReference value() const {
1313 return hydrogen()->ExternalReferenceValue();
1318 class LConstantT final : public LTemplateInstruction<1, 0, 0> {
1320 DECLARE_CONCRETE_INSTRUCTION(ConstantT, "constant-t")
1321 DECLARE_HYDROGEN_ACCESSOR(Constant)
1323 Handle<Object> value(Isolate* isolate) const {
1324 return hydrogen()->handle(isolate);
1329 class LBranch final : public LControlInstruction<1, 0> {
1331 explicit LBranch(LOperand* value) {
1335 LOperand* value() { return inputs_[0]; }
1337 DECLARE_CONCRETE_INSTRUCTION(Branch, "branch")
1338 DECLARE_HYDROGEN_ACCESSOR(Branch)
1340 void PrintDataTo(StringStream* stream) override;
1344 class LCmpMapAndBranch final : public LControlInstruction<1, 1> {
1346 LCmpMapAndBranch(LOperand* value, LOperand* temp) {
1351 LOperand* value() { return inputs_[0]; }
1352 LOperand* temp() { return temps_[0]; }
1354 DECLARE_CONCRETE_INSTRUCTION(CmpMapAndBranch, "cmp-map-and-branch")
1355 DECLARE_HYDROGEN_ACCESSOR(CompareMap)
1357 Handle<Map> map() const { return hydrogen()->map().handle(); }
1361 class LMapEnumLength final : public LTemplateInstruction<1, 1, 0> {
1363 explicit LMapEnumLength(LOperand* value) {
1367 LOperand* value() { return inputs_[0]; }
1369 DECLARE_CONCRETE_INSTRUCTION(MapEnumLength, "map-enum-length")
1373 class LDateField final : public LTemplateInstruction<1, 1, 1> {
1375 LDateField(LOperand* date, LOperand* temp, Smi* index) : index_(index) {
1380 LOperand* date() { return inputs_[0]; }
1381 LOperand* temp() { return temps_[0]; }
1382 Smi* index() const { return index_; }
1384 DECLARE_CONCRETE_INSTRUCTION(DateField, "date-field")
1385 DECLARE_HYDROGEN_ACCESSOR(DateField)
1392 class LSeqStringGetChar final : public LTemplateInstruction<1, 2, 0> {
1394 LSeqStringGetChar(LOperand* string, LOperand* index) {
1395 inputs_[0] = string;
1399 LOperand* string() const { return inputs_[0]; }
1400 LOperand* index() const { return inputs_[1]; }
1402 DECLARE_CONCRETE_INSTRUCTION(SeqStringGetChar, "seq-string-get-char")
1403 DECLARE_HYDROGEN_ACCESSOR(SeqStringGetChar)
1407 class LSeqStringSetChar final : public LTemplateInstruction<1, 4, 0> {
1409 LSeqStringSetChar(LOperand* context,
1413 inputs_[0] = context;
1414 inputs_[1] = string;
1419 LOperand* string() { return inputs_[1]; }
1420 LOperand* index() { return inputs_[2]; }
1421 LOperand* value() { return inputs_[3]; }
1423 DECLARE_CONCRETE_INSTRUCTION(SeqStringSetChar, "seq-string-set-char")
1424 DECLARE_HYDROGEN_ACCESSOR(SeqStringSetChar)
1428 class LAddI final : public LTemplateInstruction<1, 2, 0> {
1430 LAddI(LOperand* left, LOperand* right) {
1435 LOperand* left() { return inputs_[0]; }
1436 LOperand* right() { return inputs_[1]; }
1438 DECLARE_CONCRETE_INSTRUCTION(AddI, "add-i")
1439 DECLARE_HYDROGEN_ACCESSOR(Add)
1443 class LMathMinMax final : public LTemplateInstruction<1, 2, 0> {
1445 LMathMinMax(LOperand* left, LOperand* right) {
1450 LOperand* left() { return inputs_[0]; }
1451 LOperand* right() { return inputs_[1]; }
1453 DECLARE_CONCRETE_INSTRUCTION(MathMinMax, "math-min-max")
1454 DECLARE_HYDROGEN_ACCESSOR(MathMinMax)
1458 class LPower final : public LTemplateInstruction<1, 2, 0> {
1460 LPower(LOperand* left, LOperand* right) {
1465 LOperand* left() { return inputs_[0]; }
1466 LOperand* right() { return inputs_[1]; }
1468 DECLARE_CONCRETE_INSTRUCTION(Power, "power")
1469 DECLARE_HYDROGEN_ACCESSOR(Power)
1473 class LArithmeticD final : public LTemplateInstruction<1, 2, 0> {
1475 LArithmeticD(Token::Value op, LOperand* left, LOperand* right)
1481 Token::Value op() const { return op_; }
1482 LOperand* left() { return inputs_[0]; }
1483 LOperand* right() { return inputs_[1]; }
1485 Opcode opcode() const override { return LInstruction::kArithmeticD; }
1486 void CompileToNative(LCodeGen* generator) override;
1487 const char* Mnemonic() const override;
1494 class LArithmeticT final : public LTemplateInstruction<1, 3, 0> {
1496 LArithmeticT(Token::Value op,
1501 inputs_[0] = context;
1506 LOperand* context() { return inputs_[0]; }
1507 LOperand* left() { return inputs_[1]; }
1508 LOperand* right() { return inputs_[2]; }
1509 Token::Value op() const { return op_; }
1511 Opcode opcode() const final { return LInstruction::kArithmeticT; }
1512 void CompileToNative(LCodeGen* generator) override;
1513 const char* Mnemonic() const override;
1515 DECLARE_HYDROGEN_ACCESSOR(BinaryOperation)
1517 Strength strength() { return hydrogen()->strength(); }
1524 class LReturn final : public LTemplateInstruction<0, 3, 0> {
1526 LReturn(LOperand* value, LOperand* context, LOperand* parameter_count) {
1528 inputs_[1] = context;
1529 inputs_[2] = parameter_count;
1532 LOperand* value() { return inputs_[0]; }
1534 bool has_constant_parameter_count() {
1535 return parameter_count()->IsConstantOperand();
1537 LConstantOperand* constant_parameter_count() {
1538 DCHECK(has_constant_parameter_count());
1539 return LConstantOperand::cast(parameter_count());
1541 LOperand* parameter_count() { return inputs_[2]; }
1543 DECLARE_CONCRETE_INSTRUCTION(Return, "return")
1547 class LLoadNamedField final : public LTemplateInstruction<1, 1, 0> {
1549 explicit LLoadNamedField(LOperand* object) {
1550 inputs_[0] = object;
1553 LOperand* object() { return inputs_[0]; }
1555 DECLARE_CONCRETE_INSTRUCTION(LoadNamedField, "load-named-field")
1556 DECLARE_HYDROGEN_ACCESSOR(LoadNamedField)
1560 class LLoadNamedGeneric final : public LTemplateInstruction<1, 2, 1> {
1562 LLoadNamedGeneric(LOperand* context, LOperand* object, LOperand* vector) {
1563 inputs_[0] = context;
1564 inputs_[1] = object;
1568 LOperand* context() { return inputs_[0]; }
1569 LOperand* object() { return inputs_[1]; }
1570 LOperand* temp_vector() { return temps_[0]; }
1572 DECLARE_CONCRETE_INSTRUCTION(LoadNamedGeneric, "load-named-generic")
1573 DECLARE_HYDROGEN_ACCESSOR(LoadNamedGeneric)
1575 Handle<Object> name() const { return hydrogen()->name(); }
1579 class LLoadFunctionPrototype final : public LTemplateInstruction<1, 1, 0> {
1581 explicit LLoadFunctionPrototype(LOperand* function) {
1582 inputs_[0] = function;
1585 LOperand* function() { return inputs_[0]; }
1587 DECLARE_CONCRETE_INSTRUCTION(LoadFunctionPrototype, "load-function-prototype")
1588 DECLARE_HYDROGEN_ACCESSOR(LoadFunctionPrototype)
1592 class LLoadRoot final : public LTemplateInstruction<1, 0, 0> {
1594 DECLARE_CONCRETE_INSTRUCTION(LoadRoot, "load-root")
1595 DECLARE_HYDROGEN_ACCESSOR(LoadRoot)
1597 Heap::RootListIndex index() const { return hydrogen()->index(); }
1601 class LLoadKeyed final : public LTemplateInstruction<1, 2, 0> {
1603 LLoadKeyed(LOperand* elements, LOperand* key) {
1604 inputs_[0] = elements;
1608 LOperand* elements() { return inputs_[0]; }
1609 LOperand* key() { return inputs_[1]; }
1610 ElementsKind elements_kind() const {
1611 return hydrogen()->elements_kind();
1613 bool is_external() const {
1614 return hydrogen()->is_external();
1616 bool is_fixed_typed_array() const {
1617 return hydrogen()->is_fixed_typed_array();
1619 bool is_typed_elements() const {
1620 return is_external() || is_fixed_typed_array();
1623 DECLARE_CONCRETE_INSTRUCTION(LoadKeyed, "load-keyed")
1624 DECLARE_HYDROGEN_ACCESSOR(LoadKeyed)
1626 void PrintDataTo(StringStream* stream) override;
1627 uint32_t base_offset() const { return hydrogen()->base_offset(); }
1631 class LLoadKeyedGeneric final : public LTemplateInstruction<1, 3, 1> {
1633 LLoadKeyedGeneric(LOperand* context, LOperand* object, LOperand* key,
1635 inputs_[0] = context;
1636 inputs_[1] = object;
1641 LOperand* context() { return inputs_[0]; }
1642 LOperand* object() { return inputs_[1]; }
1643 LOperand* key() { return inputs_[2]; }
1644 LOperand* temp_vector() { return temps_[0]; }
1646 DECLARE_CONCRETE_INSTRUCTION(LoadKeyedGeneric, "load-keyed-generic")
1647 DECLARE_HYDROGEN_ACCESSOR(LoadKeyedGeneric)
1651 class LLoadGlobalGeneric final : public LTemplateInstruction<1, 2, 1> {
1653 LLoadGlobalGeneric(LOperand* context, LOperand* global_object,
1655 inputs_[0] = context;
1656 inputs_[1] = global_object;
1660 LOperand* context() { return inputs_[0]; }
1661 LOperand* global_object() { return inputs_[1]; }
1662 LOperand* temp_vector() { return temps_[0]; }
1664 DECLARE_CONCRETE_INSTRUCTION(LoadGlobalGeneric, "load-global-generic")
1665 DECLARE_HYDROGEN_ACCESSOR(LoadGlobalGeneric)
1667 Handle<Object> name() const { return hydrogen()->name(); }
1668 TypeofMode typeof_mode() const { return hydrogen()->typeof_mode(); }
1672 class LLoadGlobalViaContext final : public LTemplateInstruction<1, 1, 1> {
1674 explicit LLoadGlobalViaContext(LOperand* context) { inputs_[0] = context; }
1676 DECLARE_CONCRETE_INSTRUCTION(LoadGlobalViaContext, "load-global-via-context")
1677 DECLARE_HYDROGEN_ACCESSOR(LoadGlobalViaContext)
1679 void PrintDataTo(StringStream* stream) override;
1681 LOperand* context() { return inputs_[0]; }
1683 int depth() const { return hydrogen()->depth(); }
1684 int slot_index() const { return hydrogen()->slot_index(); }
1688 class LLoadContextSlot final : public LTemplateInstruction<1, 1, 0> {
1690 explicit LLoadContextSlot(LOperand* context) {
1691 inputs_[0] = context;
1694 LOperand* context() { return inputs_[0]; }
1696 DECLARE_CONCRETE_INSTRUCTION(LoadContextSlot, "load-context-slot")
1697 DECLARE_HYDROGEN_ACCESSOR(LoadContextSlot)
1699 int slot_index() { return hydrogen()->slot_index(); }
1701 void PrintDataTo(StringStream* stream) override;
1705 class LStoreContextSlot final : public LTemplateInstruction<0, 2, 0> {
1707 LStoreContextSlot(LOperand* context, LOperand* value) {
1708 inputs_[0] = context;
1712 LOperand* context() { return inputs_[0]; }
1713 LOperand* value() { return inputs_[1]; }
1715 DECLARE_CONCRETE_INSTRUCTION(StoreContextSlot, "store-context-slot")
1716 DECLARE_HYDROGEN_ACCESSOR(StoreContextSlot)
1718 int slot_index() { return hydrogen()->slot_index(); }
1720 void PrintDataTo(StringStream* stream) override;
1724 class LPushArgument final : public LTemplateInstruction<0, 1, 0> {
1726 explicit LPushArgument(LOperand* value) {
1730 LOperand* value() { return inputs_[0]; }
1732 DECLARE_CONCRETE_INSTRUCTION(PushArgument, "push-argument")
1736 class LDrop final : public LTemplateInstruction<0, 0, 0> {
1738 explicit LDrop(int count) : count_(count) { }
1740 int count() const { return count_; }
1742 DECLARE_CONCRETE_INSTRUCTION(Drop, "drop")
1749 class LStoreCodeEntry final : public LTemplateInstruction<0, 2, 0> {
1751 LStoreCodeEntry(LOperand* function, LOperand* code_object) {
1752 inputs_[0] = function;
1753 inputs_[1] = code_object;
1756 LOperand* function() { return inputs_[0]; }
1757 LOperand* code_object() { return inputs_[1]; }
1759 void PrintDataTo(StringStream* stream) override;
1761 DECLARE_CONCRETE_INSTRUCTION(StoreCodeEntry, "store-code-entry")
1762 DECLARE_HYDROGEN_ACCESSOR(StoreCodeEntry)
1766 class LInnerAllocatedObject final : public LTemplateInstruction<1, 2, 0> {
1768 LInnerAllocatedObject(LOperand* base_object, LOperand* offset) {
1769 inputs_[0] = base_object;
1770 inputs_[1] = offset;
1773 LOperand* base_object() const { return inputs_[0]; }
1774 LOperand* offset() const { return inputs_[1]; }
1776 void PrintDataTo(StringStream* stream) override;
1778 DECLARE_CONCRETE_INSTRUCTION(InnerAllocatedObject, "inner-allocated-object")
1782 class LThisFunction final : public LTemplateInstruction<1, 0, 0> {
1784 DECLARE_CONCRETE_INSTRUCTION(ThisFunction, "this-function")
1785 DECLARE_HYDROGEN_ACCESSOR(ThisFunction)
1789 class LContext final : public LTemplateInstruction<1, 0, 0> {
1791 DECLARE_CONCRETE_INSTRUCTION(Context, "context")
1792 DECLARE_HYDROGEN_ACCESSOR(Context)
1796 class LDeclareGlobals final : public LTemplateInstruction<0, 1, 0> {
1798 explicit LDeclareGlobals(LOperand* context) {
1799 inputs_[0] = context;
1802 LOperand* context() { return inputs_[0]; }
1804 DECLARE_CONCRETE_INSTRUCTION(DeclareGlobals, "declare-globals")
1805 DECLARE_HYDROGEN_ACCESSOR(DeclareGlobals)
1809 class LCallJSFunction final : public LTemplateInstruction<1, 1, 0> {
1811 explicit LCallJSFunction(LOperand* function) {
1812 inputs_[0] = function;
1815 LOperand* function() { return inputs_[0]; }
1817 DECLARE_CONCRETE_INSTRUCTION(CallJSFunction, "call-js-function")
1818 DECLARE_HYDROGEN_ACCESSOR(CallJSFunction)
1820 void PrintDataTo(StringStream* stream) override;
1822 int arity() const { return hydrogen()->argument_count() - 1; }
1826 class LCallWithDescriptor final : public LTemplateResultInstruction<1> {
1828 LCallWithDescriptor(CallInterfaceDescriptor descriptor,
1829 const ZoneList<LOperand*>& operands, Zone* zone)
1830 : descriptor_(descriptor),
1831 inputs_(descriptor.GetRegisterParameterCount() +
1832 kImplicitRegisterParameterCount,
1834 DCHECK(descriptor.GetRegisterParameterCount() +
1835 kImplicitRegisterParameterCount ==
1837 inputs_.AddAll(operands, zone);
1840 LOperand* target() const { return inputs_[0]; }
1842 const CallInterfaceDescriptor descriptor() { return descriptor_; }
1844 DECLARE_HYDROGEN_ACCESSOR(CallWithDescriptor)
1846 // The target and context are passed as implicit parameters that are not
1847 // explicitly listed in the descriptor.
1848 static const int kImplicitRegisterParameterCount = 2;
1851 DECLARE_CONCRETE_INSTRUCTION(CallWithDescriptor, "call-with-descriptor")
1853 void PrintDataTo(StringStream* stream) override;
1855 int arity() const { return hydrogen()->argument_count() - 1; }
1857 CallInterfaceDescriptor descriptor_;
1858 ZoneList<LOperand*> inputs_;
1860 // Iterator support.
1861 int InputCount() final { return inputs_.length(); }
1862 LOperand* InputAt(int i) final { return inputs_[i]; }
1864 int TempCount() final { return 0; }
1865 LOperand* TempAt(int i) final { return NULL; }
1869 class LInvokeFunction final : public LTemplateInstruction<1, 2, 0> {
1871 LInvokeFunction(LOperand* context, LOperand* function) {
1872 inputs_[0] = context;
1873 inputs_[1] = function;
1876 LOperand* context() { return inputs_[0]; }
1877 LOperand* function() { return inputs_[1]; }
1879 DECLARE_CONCRETE_INSTRUCTION(InvokeFunction, "invoke-function")
1880 DECLARE_HYDROGEN_ACCESSOR(InvokeFunction)
1882 void PrintDataTo(StringStream* stream) override;
1884 int arity() const { return hydrogen()->argument_count() - 1; }
1888 class LCallFunction final : public LTemplateInstruction<1, 2, 2> {
1890 LCallFunction(LOperand* context, LOperand* function, LOperand* slot,
1892 inputs_[0] = context;
1893 inputs_[1] = function;
1898 LOperand* context() { return inputs_[0]; }
1899 LOperand* function() { return inputs_[1]; }
1900 LOperand* temp_slot() { return temps_[0]; }
1901 LOperand* temp_vector() { return temps_[1]; }
1903 DECLARE_CONCRETE_INSTRUCTION(CallFunction, "call-function")
1904 DECLARE_HYDROGEN_ACCESSOR(CallFunction)
1906 int arity() const { return hydrogen()->argument_count() - 1; }
1907 void PrintDataTo(StringStream* stream) override;
1911 class LCallNew final : public LTemplateInstruction<1, 2, 0> {
1913 LCallNew(LOperand* context, LOperand* constructor) {
1914 inputs_[0] = context;
1915 inputs_[1] = constructor;
1918 LOperand* context() { return inputs_[0]; }
1919 LOperand* constructor() { return inputs_[1]; }
1921 DECLARE_CONCRETE_INSTRUCTION(CallNew, "call-new")
1922 DECLARE_HYDROGEN_ACCESSOR(CallNew)
1924 void PrintDataTo(StringStream* stream) override;
1926 int arity() const { return hydrogen()->argument_count() - 1; }
1930 class LCallNewArray final : public LTemplateInstruction<1, 2, 0> {
1932 LCallNewArray(LOperand* context, LOperand* constructor) {
1933 inputs_[0] = context;
1934 inputs_[1] = constructor;
1937 LOperand* context() { return inputs_[0]; }
1938 LOperand* constructor() { return inputs_[1]; }
1940 DECLARE_CONCRETE_INSTRUCTION(CallNewArray, "call-new-array")
1941 DECLARE_HYDROGEN_ACCESSOR(CallNewArray)
1943 void PrintDataTo(StringStream* stream) override;
1945 int arity() const { return hydrogen()->argument_count() - 1; }
1949 class LCallRuntime final : public LTemplateInstruction<1, 1, 0> {
1951 explicit LCallRuntime(LOperand* context) {
1952 inputs_[0] = context;
1955 LOperand* context() { return inputs_[0]; }
1957 DECLARE_CONCRETE_INSTRUCTION(CallRuntime, "call-runtime")
1958 DECLARE_HYDROGEN_ACCESSOR(CallRuntime)
1960 bool ClobbersDoubleRegisters(Isolate* isolate) const override {
1961 return save_doubles() == kDontSaveFPRegs;
1964 const Runtime::Function* function() const { return hydrogen()->function(); }
1965 int arity() const { return hydrogen()->argument_count(); }
1966 SaveFPRegsMode save_doubles() const { return hydrogen()->save_doubles(); }
1970 class LInteger32ToDouble final : public LTemplateInstruction<1, 1, 0> {
1972 explicit LInteger32ToDouble(LOperand* value) {
1976 LOperand* value() { return inputs_[0]; }
1978 DECLARE_CONCRETE_INSTRUCTION(Integer32ToDouble, "int32-to-double")
1982 class LUint32ToDouble final : public LTemplateInstruction<1, 1, 0> {
1984 explicit LUint32ToDouble(LOperand* value) {
1988 LOperand* value() { return inputs_[0]; }
1990 DECLARE_CONCRETE_INSTRUCTION(Uint32ToDouble, "uint32-to-double")
1994 class LNumberTagI final : public LTemplateInstruction<1, 1, 2> {
1996 LNumberTagI(LOperand* value, LOperand* temp1, LOperand* temp2) {
2002 LOperand* value() { return inputs_[0]; }
2003 LOperand* temp1() { return temps_[0]; }
2004 LOperand* temp2() { return temps_[1]; }
2006 DECLARE_CONCRETE_INSTRUCTION(NumberTagI, "number-tag-i")
2010 class LNumberTagU final : public LTemplateInstruction<1, 1, 2> {
2012 LNumberTagU(LOperand* value, LOperand* temp1, LOperand* temp2) {
2018 LOperand* value() { return inputs_[0]; }
2019 LOperand* temp1() { return temps_[0]; }
2020 LOperand* temp2() { return temps_[1]; }
2022 DECLARE_CONCRETE_INSTRUCTION(NumberTagU, "number-tag-u")
2026 class LNumberTagD final : public LTemplateInstruction<1, 1, 2> {
2028 LNumberTagD(LOperand* value, LOperand* temp, LOperand* temp2) {
2034 LOperand* value() { return inputs_[0]; }
2035 LOperand* temp() { return temps_[0]; }
2036 LOperand* temp2() { return temps_[1]; }
2038 DECLARE_CONCRETE_INSTRUCTION(NumberTagD, "number-tag-d")
2039 DECLARE_HYDROGEN_ACCESSOR(Change)
2043 class LDoubleToSmi final : public LTemplateInstruction<1, 1, 0> {
2045 explicit LDoubleToSmi(LOperand* value) {
2049 LOperand* value() { return inputs_[0]; }
2051 DECLARE_CONCRETE_INSTRUCTION(DoubleToSmi, "double-to-smi")
2052 DECLARE_HYDROGEN_ACCESSOR(UnaryOperation)
2054 bool truncating() { return hydrogen()->CanTruncateToInt32(); }
2058 // Sometimes truncating conversion from a tagged value to an int32.
2059 class LDoubleToI final : public LTemplateInstruction<1, 1, 0> {
2061 explicit LDoubleToI(LOperand* value) {
2065 LOperand* value() { return inputs_[0]; }
2067 DECLARE_CONCRETE_INSTRUCTION(DoubleToI, "double-to-i")
2068 DECLARE_HYDROGEN_ACCESSOR(UnaryOperation)
2070 bool truncating() { return hydrogen()->CanTruncateToInt32(); }
2074 // Truncating conversion from a tagged value to an int32.
2075 class LTaggedToI final : public LTemplateInstruction<1, 1, 2> {
2077 LTaggedToI(LOperand* value,
2085 LOperand* value() { return inputs_[0]; }
2086 LOperand* temp() { return temps_[0]; }
2087 LOperand* temp2() { return temps_[1]; }
2089 DECLARE_CONCRETE_INSTRUCTION(TaggedToI, "tagged-to-i")
2090 DECLARE_HYDROGEN_ACCESSOR(Change)
2092 bool truncating() { return hydrogen()->CanTruncateToInt32(); }
2096 class LSmiTag final : public LTemplateInstruction<1, 1, 0> {
2098 explicit LSmiTag(LOperand* value) {
2102 LOperand* value() { return inputs_[0]; }
2104 DECLARE_CONCRETE_INSTRUCTION(SmiTag, "smi-tag")
2105 DECLARE_HYDROGEN_ACCESSOR(Change)
2109 class LNumberUntagD final : public LTemplateInstruction<1, 1, 0> {
2111 explicit LNumberUntagD(LOperand* value) {
2115 LOperand* value() { return inputs_[0]; }
2117 DECLARE_CONCRETE_INSTRUCTION(NumberUntagD, "double-untag")
2118 DECLARE_HYDROGEN_ACCESSOR(Change)
2122 class LSmiUntag final : public LTemplateInstruction<1, 1, 0> {
2124 LSmiUntag(LOperand* value, bool needs_check)
2125 : needs_check_(needs_check) {
2129 LOperand* value() { return inputs_[0]; }
2130 bool needs_check() const { return needs_check_; }
2132 DECLARE_CONCRETE_INSTRUCTION(SmiUntag, "smi-untag")
2139 class LStoreNamedField final : public LTemplateInstruction<0, 2, 1> {
2141 LStoreNamedField(LOperand* object, LOperand* value, LOperand* temp) {
2142 inputs_[0] = object;
2147 LOperand* object() { return inputs_[0]; }
2148 LOperand* value() { return inputs_[1]; }
2149 LOperand* temp() { return temps_[0]; }
2151 DECLARE_CONCRETE_INSTRUCTION(StoreNamedField, "store-named-field")
2152 DECLARE_HYDROGEN_ACCESSOR(StoreNamedField)
2154 void PrintDataTo(StringStream* stream) override;
2156 Representation representation() const {
2157 return hydrogen()->field_representation();
2162 class LStoreNamedGeneric final : public LTemplateInstruction<0, 3, 2> {
2164 LStoreNamedGeneric(LOperand* context, LOperand* object, LOperand* value,
2165 LOperand* slot, LOperand* vector) {
2166 inputs_[0] = context;
2167 inputs_[1] = object;
2173 LOperand* context() { return inputs_[0]; }
2174 LOperand* object() { return inputs_[1]; }
2175 LOperand* value() { return inputs_[2]; }
2176 LOperand* temp_slot() { return temps_[0]; }
2177 LOperand* temp_vector() { return temps_[1]; }
2179 DECLARE_CONCRETE_INSTRUCTION(StoreNamedGeneric, "store-named-generic")
2180 DECLARE_HYDROGEN_ACCESSOR(StoreNamedGeneric)
2182 void PrintDataTo(StringStream* stream) override;
2184 Handle<Object> name() const { return hydrogen()->name(); }
2185 LanguageMode language_mode() { return hydrogen()->language_mode(); }
2189 class LStoreGlobalViaContext final : public LTemplateInstruction<0, 2, 0> {
2191 LStoreGlobalViaContext(LOperand* context, LOperand* value) {
2192 inputs_[0] = context;
2196 LOperand* context() { return inputs_[0]; }
2197 LOperand* value() { return inputs_[1]; }
2199 DECLARE_CONCRETE_INSTRUCTION(StoreGlobalViaContext,
2200 "store-global-via-context")
2201 DECLARE_HYDROGEN_ACCESSOR(StoreGlobalViaContext)
2203 void PrintDataTo(StringStream* stream) override;
2205 int depth() { return hydrogen()->depth(); }
2206 int slot_index() { return hydrogen()->slot_index(); }
2207 LanguageMode language_mode() { return hydrogen()->language_mode(); }
2211 class LStoreKeyed final : public LTemplateInstruction<0, 3, 0> {
2213 LStoreKeyed(LOperand* object, LOperand* key, LOperand* value) {
2214 inputs_[0] = object;
2219 bool is_external() const { return hydrogen()->is_external(); }
2220 bool is_fixed_typed_array() const {
2221 return hydrogen()->is_fixed_typed_array();
2223 bool is_typed_elements() const {
2224 return is_external() || is_fixed_typed_array();
2226 LOperand* elements() { return inputs_[0]; }
2227 LOperand* key() { return inputs_[1]; }
2228 LOperand* value() { return inputs_[2]; }
2229 ElementsKind elements_kind() const {
2230 return hydrogen()->elements_kind();
2233 DECLARE_CONCRETE_INSTRUCTION(StoreKeyed, "store-keyed")
2234 DECLARE_HYDROGEN_ACCESSOR(StoreKeyed)
2236 void PrintDataTo(StringStream* stream) override;
2237 bool NeedsCanonicalization() { return hydrogen()->NeedsCanonicalization(); }
2238 uint32_t base_offset() const { return hydrogen()->base_offset(); }
2242 class LStoreKeyedGeneric final : public LTemplateInstruction<0, 4, 2> {
2244 LStoreKeyedGeneric(LOperand* context, LOperand* object, LOperand* key,
2245 LOperand* value, LOperand* slot, LOperand* vector) {
2246 inputs_[0] = context;
2247 inputs_[1] = object;
2254 LOperand* context() { return inputs_[0]; }
2255 LOperand* object() { return inputs_[1]; }
2256 LOperand* key() { return inputs_[2]; }
2257 LOperand* value() { return inputs_[3]; }
2258 LOperand* temp_slot() { return temps_[0]; }
2259 LOperand* temp_vector() { return temps_[1]; }
2261 DECLARE_CONCRETE_INSTRUCTION(StoreKeyedGeneric, "store-keyed-generic")
2262 DECLARE_HYDROGEN_ACCESSOR(StoreKeyedGeneric)
2264 void PrintDataTo(StringStream* stream) override;
2266 LanguageMode language_mode() { return hydrogen()->language_mode(); }
2270 class LTransitionElementsKind final : public LTemplateInstruction<0, 2, 1> {
2272 LTransitionElementsKind(LOperand* object,
2274 LOperand* new_map_temp) {
2275 inputs_[0] = object;
2276 inputs_[1] = context;
2277 temps_[0] = new_map_temp;
2280 LOperand* context() { return inputs_[1]; }
2281 LOperand* object() { return inputs_[0]; }
2282 LOperand* new_map_temp() { return temps_[0]; }
2284 DECLARE_CONCRETE_INSTRUCTION(TransitionElementsKind,
2285 "transition-elements-kind")
2286 DECLARE_HYDROGEN_ACCESSOR(TransitionElementsKind)
2288 void PrintDataTo(StringStream* stream) override;
2290 Handle<Map> original_map() { return hydrogen()->original_map().handle(); }
2291 Handle<Map> transitioned_map() {
2292 return hydrogen()->transitioned_map().handle();
2294 ElementsKind from_kind() { return hydrogen()->from_kind(); }
2295 ElementsKind to_kind() { return hydrogen()->to_kind(); }
2299 class LTrapAllocationMemento final : public LTemplateInstruction<0, 1, 1> {
2301 LTrapAllocationMemento(LOperand* object,
2303 inputs_[0] = object;
2307 LOperand* object() { return inputs_[0]; }
2308 LOperand* temp() { return temps_[0]; }
2310 DECLARE_CONCRETE_INSTRUCTION(TrapAllocationMemento,
2311 "trap-allocation-memento")
2315 class LMaybeGrowElements final : public LTemplateInstruction<1, 5, 0> {
2317 LMaybeGrowElements(LOperand* context, LOperand* object, LOperand* elements,
2318 LOperand* key, LOperand* current_capacity) {
2319 inputs_[0] = context;
2320 inputs_[1] = object;
2321 inputs_[2] = elements;
2323 inputs_[4] = current_capacity;
2326 LOperand* context() { return inputs_[0]; }
2327 LOperand* object() { return inputs_[1]; }
2328 LOperand* elements() { return inputs_[2]; }
2329 LOperand* key() { return inputs_[3]; }
2330 LOperand* current_capacity() { return inputs_[4]; }
2332 DECLARE_HYDROGEN_ACCESSOR(MaybeGrowElements)
2333 DECLARE_CONCRETE_INSTRUCTION(MaybeGrowElements, "maybe-grow-elements")
2337 class LStringAdd final : public LTemplateInstruction<1, 3, 0> {
2339 LStringAdd(LOperand* context, LOperand* left, LOperand* right) {
2340 inputs_[0] = context;
2345 LOperand* context() { return inputs_[0]; }
2346 LOperand* left() { return inputs_[1]; }
2347 LOperand* right() { return inputs_[2]; }
2349 DECLARE_CONCRETE_INSTRUCTION(StringAdd, "string-add")
2350 DECLARE_HYDROGEN_ACCESSOR(StringAdd)
2354 class LStringCharCodeAt final : public LTemplateInstruction<1, 3, 0> {
2356 LStringCharCodeAt(LOperand* context, LOperand* string, LOperand* index) {
2357 inputs_[0] = context;
2358 inputs_[1] = string;
2362 LOperand* context() { return inputs_[0]; }
2363 LOperand* string() { return inputs_[1]; }
2364 LOperand* index() { return inputs_[2]; }
2366 DECLARE_CONCRETE_INSTRUCTION(StringCharCodeAt, "string-char-code-at")
2367 DECLARE_HYDROGEN_ACCESSOR(StringCharCodeAt)
2371 class LStringCharFromCode final : public LTemplateInstruction<1, 2, 0> {
2373 explicit LStringCharFromCode(LOperand* context, LOperand* char_code) {
2374 inputs_[0] = context;
2375 inputs_[1] = char_code;
2378 LOperand* context() { return inputs_[0]; }
2379 LOperand* char_code() { return inputs_[1]; }
2381 DECLARE_CONCRETE_INSTRUCTION(StringCharFromCode, "string-char-from-code")
2382 DECLARE_HYDROGEN_ACCESSOR(StringCharFromCode)
2386 class LCheckValue final : public LTemplateInstruction<0, 1, 0> {
2388 explicit LCheckValue(LOperand* value) {
2392 LOperand* value() { return inputs_[0]; }
2394 DECLARE_CONCRETE_INSTRUCTION(CheckValue, "check-value")
2395 DECLARE_HYDROGEN_ACCESSOR(CheckValue)
2399 class LCheckArrayBufferNotNeutered final
2400 : public LTemplateInstruction<0, 1, 0> {
2402 explicit LCheckArrayBufferNotNeutered(LOperand* view) { inputs_[0] = view; }
2404 LOperand* view() { return inputs_[0]; }
2406 DECLARE_CONCRETE_INSTRUCTION(CheckArrayBufferNotNeutered,
2407 "check-array-buffer-not-neutered")
2408 DECLARE_HYDROGEN_ACCESSOR(CheckArrayBufferNotNeutered)
2412 class LCheckInstanceType final : public LTemplateInstruction<0, 1, 0> {
2414 explicit LCheckInstanceType(LOperand* value) {
2418 LOperand* value() { return inputs_[0]; }
2420 DECLARE_CONCRETE_INSTRUCTION(CheckInstanceType, "check-instance-type")
2421 DECLARE_HYDROGEN_ACCESSOR(CheckInstanceType)
2425 class LCheckMaps final : public LTemplateInstruction<0, 1, 0> {
2427 explicit LCheckMaps(LOperand* value = NULL) {
2431 LOperand* value() { return inputs_[0]; }
2433 DECLARE_CONCRETE_INSTRUCTION(CheckMaps, "check-maps")
2434 DECLARE_HYDROGEN_ACCESSOR(CheckMaps)
2438 class LCheckSmi final : public LTemplateInstruction<1, 1, 0> {
2440 explicit LCheckSmi(LOperand* value) {
2444 LOperand* value() { return inputs_[0]; }
2446 DECLARE_CONCRETE_INSTRUCTION(CheckSmi, "check-smi")
2450 class LCheckNonSmi final : public LTemplateInstruction<0, 1, 0> {
2452 explicit LCheckNonSmi(LOperand* value) {
2456 LOperand* value() { return inputs_[0]; }
2458 DECLARE_CONCRETE_INSTRUCTION(CheckNonSmi, "check-non-smi")
2459 DECLARE_HYDROGEN_ACCESSOR(CheckHeapObject)
2463 class LClampDToUint8 final : public LTemplateInstruction<1, 1, 1> {
2465 LClampDToUint8(LOperand* unclamped, LOperand* temp) {
2466 inputs_[0] = unclamped;
2470 LOperand* unclamped() { return inputs_[0]; }
2471 LOperand* temp() { return temps_[0]; }
2473 DECLARE_CONCRETE_INSTRUCTION(ClampDToUint8, "clamp-d-to-uint8")
2477 class LClampIToUint8 final : public LTemplateInstruction<1, 1, 0> {
2479 explicit LClampIToUint8(LOperand* unclamped) {
2480 inputs_[0] = unclamped;
2483 LOperand* unclamped() { return inputs_[0]; }
2485 DECLARE_CONCRETE_INSTRUCTION(ClampIToUint8, "clamp-i-to-uint8")
2489 class LClampTToUint8 final : public LTemplateInstruction<1, 1, 1> {
2491 LClampTToUint8(LOperand* unclamped, LOperand* temp) {
2492 inputs_[0] = unclamped;
2496 LOperand* unclamped() { return inputs_[0]; }
2497 LOperand* temp() { return temps_[0]; }
2499 DECLARE_CONCRETE_INSTRUCTION(ClampTToUint8, "clamp-t-to-uint8")
2503 class LDoubleBits final : public LTemplateInstruction<1, 1, 0> {
2505 explicit LDoubleBits(LOperand* value) {
2509 LOperand* value() { return inputs_[0]; }
2511 DECLARE_CONCRETE_INSTRUCTION(DoubleBits, "double-bits")
2512 DECLARE_HYDROGEN_ACCESSOR(DoubleBits)
2516 class LConstructDouble final : public LTemplateInstruction<1, 2, 0> {
2518 LConstructDouble(LOperand* hi, LOperand* lo) {
2523 LOperand* hi() { return inputs_[0]; }
2524 LOperand* lo() { return inputs_[1]; }
2526 DECLARE_CONCRETE_INSTRUCTION(ConstructDouble, "construct-double")
2530 class LAllocate final : public LTemplateInstruction<1, 2, 2> {
2532 LAllocate(LOperand* context,
2536 inputs_[0] = context;
2542 LOperand* context() { return inputs_[0]; }
2543 LOperand* size() { return inputs_[1]; }
2544 LOperand* temp1() { return temps_[0]; }
2545 LOperand* temp2() { return temps_[1]; }
2547 DECLARE_CONCRETE_INSTRUCTION(Allocate, "allocate")
2548 DECLARE_HYDROGEN_ACCESSOR(Allocate)
2552 class LRegExpLiteral final : public LTemplateInstruction<1, 1, 0> {
2554 explicit LRegExpLiteral(LOperand* context) {
2555 inputs_[0] = context;
2558 LOperand* context() { return inputs_[0]; }
2560 DECLARE_CONCRETE_INSTRUCTION(RegExpLiteral, "regexp-literal")
2561 DECLARE_HYDROGEN_ACCESSOR(RegExpLiteral)
2565 class LFunctionLiteral final : public LTemplateInstruction<1, 1, 0> {
2567 explicit LFunctionLiteral(LOperand* context) {
2568 inputs_[0] = context;
2571 LOperand* context() { return inputs_[0]; }
2573 DECLARE_CONCRETE_INSTRUCTION(FunctionLiteral, "function-literal")
2574 DECLARE_HYDROGEN_ACCESSOR(FunctionLiteral)
2578 class LToFastProperties final : public LTemplateInstruction<1, 1, 0> {
2580 explicit LToFastProperties(LOperand* value) {
2584 LOperand* value() { return inputs_[0]; }
2586 DECLARE_CONCRETE_INSTRUCTION(ToFastProperties, "to-fast-properties")
2587 DECLARE_HYDROGEN_ACCESSOR(ToFastProperties)
2591 class LTypeof final : public LTemplateInstruction<1, 2, 0> {
2593 LTypeof(LOperand* context, LOperand* value) {
2594 inputs_[0] = context;
2598 LOperand* context() { return inputs_[0]; }
2599 LOperand* value() { return inputs_[1]; }
2601 DECLARE_CONCRETE_INSTRUCTION(Typeof, "typeof")
2605 class LTypeofIsAndBranch final : public LControlInstruction<1, 0> {
2607 explicit LTypeofIsAndBranch(LOperand* value) {
2611 LOperand* value() { return inputs_[0]; }
2613 DECLARE_CONCRETE_INSTRUCTION(TypeofIsAndBranch, "typeof-is-and-branch")
2614 DECLARE_HYDROGEN_ACCESSOR(TypeofIsAndBranch)
2616 Handle<String> type_literal() { return hydrogen()->type_literal(); }
2618 void PrintDataTo(StringStream* stream) override;
2622 class LIsConstructCallAndBranch final : public LControlInstruction<0, 1> {
2624 explicit LIsConstructCallAndBranch(LOperand* temp) {
2628 LOperand* temp() { return temps_[0]; }
2630 DECLARE_CONCRETE_INSTRUCTION(IsConstructCallAndBranch,
2631 "is-construct-call-and-branch")
2635 class LOsrEntry final : public LTemplateInstruction<0, 0, 0> {
2639 bool HasInterestingComment(LCodeGen* gen) const override { return false; }
2640 DECLARE_CONCRETE_INSTRUCTION(OsrEntry, "osr-entry")
2644 class LStackCheck final : public LTemplateInstruction<0, 1, 0> {
2646 explicit LStackCheck(LOperand* context) {
2647 inputs_[0] = context;
2650 LOperand* context() { return inputs_[0]; }
2652 DECLARE_CONCRETE_INSTRUCTION(StackCheck, "stack-check")
2653 DECLARE_HYDROGEN_ACCESSOR(StackCheck)
2655 Label* done_label() { return &done_label_; }
2662 class LForInPrepareMap final : public LTemplateInstruction<1, 2, 0> {
2664 LForInPrepareMap(LOperand* context, LOperand* object) {
2665 inputs_[0] = context;
2666 inputs_[1] = object;
2669 LOperand* context() { return inputs_[0]; }
2670 LOperand* object() { return inputs_[1]; }
2672 DECLARE_CONCRETE_INSTRUCTION(ForInPrepareMap, "for-in-prepare-map")
2676 class LForInCacheArray final : public LTemplateInstruction<1, 1, 0> {
2678 explicit LForInCacheArray(LOperand* map) {
2682 LOperand* map() { return inputs_[0]; }
2684 DECLARE_CONCRETE_INSTRUCTION(ForInCacheArray, "for-in-cache-array")
2687 return HForInCacheArray::cast(this->hydrogen_value())->idx();
2692 class LCheckMapValue final : public LTemplateInstruction<0, 2, 0> {
2694 LCheckMapValue(LOperand* value, LOperand* map) {
2699 LOperand* value() { return inputs_[0]; }
2700 LOperand* map() { return inputs_[1]; }
2702 DECLARE_CONCRETE_INSTRUCTION(CheckMapValue, "check-map-value")
2706 class LLoadFieldByIndex final : public LTemplateInstruction<1, 2, 0> {
2708 LLoadFieldByIndex(LOperand* object, LOperand* index) {
2709 inputs_[0] = object;
2713 LOperand* object() { return inputs_[0]; }
2714 LOperand* index() { return inputs_[1]; }
2716 DECLARE_CONCRETE_INSTRUCTION(LoadFieldByIndex, "load-field-by-index")
2720 class LStoreFrameContext: public LTemplateInstruction<0, 1, 0> {
2722 explicit LStoreFrameContext(LOperand* context) {
2723 inputs_[0] = context;
2726 LOperand* context() { return inputs_[0]; }
2728 DECLARE_CONCRETE_INSTRUCTION(StoreFrameContext, "store-frame-context")
2732 class LAllocateBlockContext: public LTemplateInstruction<1, 2, 0> {
2734 LAllocateBlockContext(LOperand* context, LOperand* function) {
2735 inputs_[0] = context;
2736 inputs_[1] = function;
2739 LOperand* context() { return inputs_[0]; }
2740 LOperand* function() { return inputs_[1]; }
2742 Handle<ScopeInfo> scope_info() { return hydrogen()->scope_info(); }
2744 DECLARE_CONCRETE_INSTRUCTION(AllocateBlockContext, "allocate-block-context")
2745 DECLARE_HYDROGEN_ACCESSOR(AllocateBlockContext)
2749 class LChunkBuilder;
2750 class LPlatformChunk final : public LChunk {
2752 LPlatformChunk(CompilationInfo* info, HGraph* graph)
2753 : LChunk(info, graph) { }
2755 int GetNextSpillIndex(RegisterKind kind);
2756 LOperand* GetNextSpillSlot(RegisterKind kind);
2760 class LChunkBuilder final : public LChunkBuilderBase {
2762 LChunkBuilder(CompilationInfo* info, HGraph* graph, LAllocator* allocator)
2763 : LChunkBuilderBase(info, graph),
2764 current_instruction_(NULL),
2765 current_block_(NULL),
2767 allocator_(allocator) {}
2769 // Build the sequence for the graph.
2770 LPlatformChunk* Build();
2772 // Declare methods that deal with the individual node types.
2773 #define DECLARE_DO(type) LInstruction* Do##type(H##type* node);
2774 HYDROGEN_CONCRETE_INSTRUCTION_LIST(DECLARE_DO)
2777 LInstruction* DoMultiplyAdd(HMul* mul, HValue* addend);
2779 static bool HasMagicNumberForDivisor(int32_t divisor);
2781 LInstruction* DoMathFloor(HUnaryMathOperation* instr);
2782 LInstruction* DoMathRound(HUnaryMathOperation* instr);
2783 LInstruction* DoMathFround(HUnaryMathOperation* instr);
2784 LInstruction* DoMathAbs(HUnaryMathOperation* instr);
2785 LInstruction* DoMathLog(HUnaryMathOperation* instr);
2786 LInstruction* DoMathExp(HUnaryMathOperation* instr);
2787 LInstruction* DoMathSqrt(HUnaryMathOperation* instr);
2788 LInstruction* DoMathPowHalf(HUnaryMathOperation* instr);
2789 LInstruction* DoMathClz32(HUnaryMathOperation* instr);
2790 LInstruction* DoDivByPowerOf2I(HDiv* instr);
2791 LInstruction* DoDivByConstI(HDiv* instr);
2792 LInstruction* DoDivI(HDiv* instr);
2793 LInstruction* DoModByPowerOf2I(HMod* instr);
2794 LInstruction* DoModByConstI(HMod* instr);
2795 LInstruction* DoModI(HMod* instr);
2796 LInstruction* DoFlooringDivByPowerOf2I(HMathFloorOfDiv* instr);
2797 LInstruction* DoFlooringDivByConstI(HMathFloorOfDiv* instr);
2798 LInstruction* DoFlooringDivI(HMathFloorOfDiv* instr);
2801 // Methods for getting operands for Use / Define / Temp.
2802 LUnallocated* ToUnallocated(Register reg);
2803 LUnallocated* ToUnallocated(DoubleRegister reg);
2805 // Methods for setting up define-use relationships.
2806 MUST_USE_RESULT LOperand* Use(HValue* value, LUnallocated* operand);
2807 MUST_USE_RESULT LOperand* UseFixed(HValue* value, Register fixed_register);
2808 MUST_USE_RESULT LOperand* UseFixedDouble(HValue* value,
2809 DoubleRegister fixed_register);
2811 // A value that is guaranteed to be allocated to a register.
2812 // Operand created by UseRegister is guaranteed to be live until the end of
2813 // instruction. This means that register allocator will not reuse it's
2814 // register for any other operand inside instruction.
2815 // Operand created by UseRegisterAtStart is guaranteed to be live only at
2816 // instruction start. Register allocator is free to assign the same register
2817 // to some other operand used inside instruction (i.e. temporary or
2819 MUST_USE_RESULT LOperand* UseRegister(HValue* value);
2820 MUST_USE_RESULT LOperand* UseRegisterAtStart(HValue* value);
2822 // An input operand in a register that may be trashed.
2823 MUST_USE_RESULT LOperand* UseTempRegister(HValue* value);
2825 // An input operand in a register or stack slot.
2826 MUST_USE_RESULT LOperand* Use(HValue* value);
2827 MUST_USE_RESULT LOperand* UseAtStart(HValue* value);
2829 // An input operand in a register, stack slot or a constant operand.
2830 MUST_USE_RESULT LOperand* UseOrConstant(HValue* value);
2831 MUST_USE_RESULT LOperand* UseOrConstantAtStart(HValue* value);
2833 // An input operand in a register or a constant operand.
2834 MUST_USE_RESULT LOperand* UseRegisterOrConstant(HValue* value);
2835 MUST_USE_RESULT LOperand* UseRegisterOrConstantAtStart(HValue* value);
2837 // An input operand in a constant operand.
2838 MUST_USE_RESULT LOperand* UseConstant(HValue* value);
2840 // An input operand in register, stack slot or a constant operand.
2841 // Will not be moved to a register even if one is freely available.
2842 MUST_USE_RESULT LOperand* UseAny(HValue* value) override;
2844 // Temporary operand that must be in a register.
2845 MUST_USE_RESULT LUnallocated* TempRegister();
2846 MUST_USE_RESULT LUnallocated* TempDoubleRegister();
2847 MUST_USE_RESULT LOperand* FixedTemp(Register reg);
2848 MUST_USE_RESULT LOperand* FixedTemp(DoubleRegister reg);
2850 // Methods for setting up define-use relationships.
2851 // Return the same instruction that they are passed.
2852 LInstruction* Define(LTemplateResultInstruction<1>* instr,
2853 LUnallocated* result);
2854 LInstruction* DefineAsRegister(LTemplateResultInstruction<1>* instr);
2855 LInstruction* DefineAsSpilled(LTemplateResultInstruction<1>* instr,
2857 LInstruction* DefineSameAsFirst(LTemplateResultInstruction<1>* instr);
2858 LInstruction* DefineFixed(LTemplateResultInstruction<1>* instr,
2860 LInstruction* DefineFixedDouble(LTemplateResultInstruction<1>* instr,
2861 DoubleRegister reg);
2862 LInstruction* AssignEnvironment(LInstruction* instr);
2863 LInstruction* AssignPointerMap(LInstruction* instr);
2865 enum CanDeoptimize { CAN_DEOPTIMIZE_EAGERLY, CANNOT_DEOPTIMIZE_EAGERLY };
2867 // By default we assume that instruction sequences generated for calls
2868 // cannot deoptimize eagerly and we do not attach environment to this
2870 LInstruction* MarkAsCall(
2871 LInstruction* instr,
2872 HInstruction* hinstr,
2873 CanDeoptimize can_deoptimize = CANNOT_DEOPTIMIZE_EAGERLY);
2875 void VisitInstruction(HInstruction* current);
2876 void AddInstruction(LInstruction* instr, HInstruction* current);
2878 void DoBasicBlock(HBasicBlock* block, HBasicBlock* next_block);
2879 LInstruction* DoBit(Token::Value op, HBitwiseBinaryOperation* instr);
2880 LInstruction* DoShift(Token::Value op, HBitwiseBinaryOperation* instr);
2881 LInstruction* DoArithmeticD(Token::Value op,
2882 HArithmeticBinaryOperation* instr);
2883 LInstruction* DoArithmeticT(Token::Value op,
2884 HBinaryOperation* instr);
2886 HInstruction* current_instruction_;
2887 HBasicBlock* current_block_;
2888 HBasicBlock* next_block_;
2889 LAllocator* allocator_;
2891 DISALLOW_COPY_AND_ASSIGN(LChunkBuilder);
2894 #undef DECLARE_HYDROGEN_ACCESSOR
2895 #undef DECLARE_CONCRETE_INSTRUCTION
2897 } } // namespace v8::internal
2899 #endif // V8_MIPS_LITHIUM_MIPS_H_