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) \
106 V(LoadKeyedGeneric) \
108 V(LoadNamedGeneric) \
120 V(MaybeGrowElements) \
136 V(SeqStringGetChar) \
137 V(SeqStringSetChar) \
143 V(StoreContextSlot) \
144 V(StoreFrameContext) \
146 V(StoreKeyedGeneric) \
148 V(StoreNamedGeneric) \
150 V(StringCharCodeAt) \
151 V(StringCharFromCode) \
152 V(StringCompareAndBranch) \
156 V(ToFastProperties) \
157 V(TransitionElementsKind) \
158 V(TrapAllocationMemento) \
160 V(TypeofIsAndBranch) \
165 #define DECLARE_CONCRETE_INSTRUCTION(type, mnemonic) \
166 Opcode opcode() const final { return LInstruction::k##type; } \
167 void CompileToNative(LCodeGen* generator) final; \
168 const char* Mnemonic() const final { return mnemonic; } \
169 static L##type* cast(LInstruction* instr) { \
170 DCHECK(instr->Is##type()); \
171 return reinterpret_cast<L##type*>(instr); \
175 #define DECLARE_HYDROGEN_ACCESSOR(type) \
176 H##type* hydrogen() const { \
177 return H##type::cast(hydrogen_value()); \
181 class LInstruction : public ZoneObject {
184 : environment_(NULL),
185 hydrogen_value_(NULL),
186 bit_field_(IsCallBits::encode(false)) {
189 virtual ~LInstruction() {}
191 virtual void CompileToNative(LCodeGen* generator) = 0;
192 virtual const char* Mnemonic() const = 0;
193 virtual void PrintTo(StringStream* stream);
194 virtual void PrintDataTo(StringStream* stream);
195 virtual void PrintOutputOperandTo(StringStream* stream);
198 // Declare a unique enum value for each instruction.
199 #define DECLARE_OPCODE(type) k##type,
200 LITHIUM_CONCRETE_INSTRUCTION_LIST(DECLARE_OPCODE)
201 kNumberOfInstructions
202 #undef DECLARE_OPCODE
205 virtual Opcode opcode() const = 0;
207 // Declare non-virtual type testers for all leaf IR classes.
208 #define DECLARE_PREDICATE(type) \
209 bool Is##type() const { return opcode() == k##type; }
210 LITHIUM_CONCRETE_INSTRUCTION_LIST(DECLARE_PREDICATE)
211 #undef DECLARE_PREDICATE
213 // Declare virtual predicates for instructions that don't have
215 virtual bool IsGap() const { return false; }
217 virtual bool IsControl() const { return false; }
219 // Try deleting this instruction if possible.
220 virtual bool TryDelete() { return false; }
222 void set_environment(LEnvironment* env) { environment_ = env; }
223 LEnvironment* environment() const { return environment_; }
224 bool HasEnvironment() const { return environment_ != NULL; }
226 void set_pointer_map(LPointerMap* p) { pointer_map_.set(p); }
227 LPointerMap* pointer_map() const { return pointer_map_.get(); }
228 bool HasPointerMap() const { return pointer_map_.is_set(); }
230 void set_hydrogen_value(HValue* value) { hydrogen_value_ = value; }
231 HValue* hydrogen_value() const { return hydrogen_value_; }
233 virtual void SetDeferredLazyDeoptimizationEnvironment(LEnvironment* env) { }
235 void MarkAsCall() { bit_field_ = IsCallBits::update(bit_field_, true); }
236 bool IsCall() const { return IsCallBits::decode(bit_field_); }
238 // Interface to the register allocator and iterators.
239 bool ClobbersTemps() const { return IsCall(); }
240 bool ClobbersRegisters() const { return IsCall(); }
241 virtual bool ClobbersDoubleRegisters(Isolate* isolate) const {
245 // Interface to the register allocator and iterators.
246 bool IsMarkedAsCall() const { return IsCall(); }
248 virtual bool HasResult() const = 0;
249 virtual LOperand* result() const = 0;
251 LOperand* FirstInput() { return InputAt(0); }
252 LOperand* Output() { return HasResult() ? result() : NULL; }
254 virtual bool HasInterestingComment(LCodeGen* gen) const { return true; }
260 virtual int InputCount() = 0;
261 virtual LOperand* InputAt(int i) = 0;
264 // Iterator interface.
265 friend class InputIterator;
267 friend class TempIterator;
268 virtual int TempCount() = 0;
269 virtual LOperand* TempAt(int i) = 0;
271 class IsCallBits: public BitField<bool, 0, 1> {};
273 LEnvironment* environment_;
274 SetOncePointer<LPointerMap> pointer_map_;
275 HValue* hydrogen_value_;
280 // R = number of result operands (0 or 1).
282 class LTemplateResultInstruction : public LInstruction {
284 // Allow 0 or 1 output operands.
285 STATIC_ASSERT(R == 0 || R == 1);
286 bool HasResult() const final { return R != 0 && result() != NULL; }
287 void set_result(LOperand* operand) { results_[0] = operand; }
288 LOperand* result() const override { return results_[0]; }
291 EmbeddedContainer<LOperand*, R> results_;
295 // R = number of result operands (0 or 1).
296 // I = number of input operands.
297 // T = number of temporary operands.
298 template<int R, int I, int T>
299 class LTemplateInstruction : public LTemplateResultInstruction<R> {
301 EmbeddedContainer<LOperand*, I> inputs_;
302 EmbeddedContainer<LOperand*, T> temps_;
306 int InputCount() final { return I; }
307 LOperand* InputAt(int i) final { return inputs_[i]; }
309 int TempCount() final { return T; }
310 LOperand* TempAt(int i) final { return temps_[i]; }
314 class LGap : public LTemplateInstruction<0, 0, 0> {
316 explicit LGap(HBasicBlock* block)
318 parallel_moves_[BEFORE] = NULL;
319 parallel_moves_[START] = NULL;
320 parallel_moves_[END] = NULL;
321 parallel_moves_[AFTER] = NULL;
324 // Can't use the DECLARE-macro here because of sub-classes.
325 bool IsGap() const final { return true; }
326 void PrintDataTo(StringStream* stream) override;
327 static LGap* cast(LInstruction* instr) {
328 DCHECK(instr->IsGap());
329 return reinterpret_cast<LGap*>(instr);
332 bool IsRedundant() const;
334 HBasicBlock* block() const { return block_; }
341 FIRST_INNER_POSITION = BEFORE,
342 LAST_INNER_POSITION = AFTER
345 LParallelMove* GetOrCreateParallelMove(InnerPosition pos, Zone* zone) {
346 if (parallel_moves_[pos] == NULL) {
347 parallel_moves_[pos] = new(zone) LParallelMove(zone);
349 return parallel_moves_[pos];
352 LParallelMove* GetParallelMove(InnerPosition pos) {
353 return parallel_moves_[pos];
357 LParallelMove* parallel_moves_[LAST_INNER_POSITION + 1];
362 class LInstructionGap final : public LGap {
364 explicit LInstructionGap(HBasicBlock* block) : LGap(block) { }
366 bool HasInterestingComment(LCodeGen* gen) const override {
367 return !IsRedundant();
370 DECLARE_CONCRETE_INSTRUCTION(InstructionGap, "gap")
374 class LGoto final : public LTemplateInstruction<0, 0, 0> {
376 explicit LGoto(HBasicBlock* block) : block_(block) { }
378 bool HasInterestingComment(LCodeGen* gen) const override;
379 DECLARE_CONCRETE_INSTRUCTION(Goto, "goto")
380 void PrintDataTo(StringStream* stream) override;
381 bool IsControl() const override { return true; }
383 int block_id() const { return block_->block_id(); }
390 class LLazyBailout final : public LTemplateInstruction<0, 0, 0> {
392 LLazyBailout() : gap_instructions_size_(0) { }
394 DECLARE_CONCRETE_INSTRUCTION(LazyBailout, "lazy-bailout")
396 void set_gap_instructions_size(int gap_instructions_size) {
397 gap_instructions_size_ = gap_instructions_size;
399 int gap_instructions_size() { return gap_instructions_size_; }
402 int gap_instructions_size_;
406 class LDummy final : public LTemplateInstruction<1, 0, 0> {
409 DECLARE_CONCRETE_INSTRUCTION(Dummy, "dummy")
413 class LDummyUse final : public LTemplateInstruction<1, 1, 0> {
415 explicit LDummyUse(LOperand* value) {
418 DECLARE_CONCRETE_INSTRUCTION(DummyUse, "dummy-use")
422 class LDeoptimize final : public LTemplateInstruction<0, 0, 0> {
424 bool IsControl() const override { return true; }
425 DECLARE_CONCRETE_INSTRUCTION(Deoptimize, "deoptimize")
426 DECLARE_HYDROGEN_ACCESSOR(Deoptimize)
430 class LLabel final : public LGap {
432 explicit LLabel(HBasicBlock* block)
433 : LGap(block), replacement_(NULL) { }
435 bool HasInterestingComment(LCodeGen* gen) const override { return false; }
436 DECLARE_CONCRETE_INSTRUCTION(Label, "label")
438 void PrintDataTo(StringStream* stream) override;
440 int block_id() const { return block()->block_id(); }
441 bool is_loop_header() const { return block()->IsLoopHeader(); }
442 bool is_osr_entry() const { return block()->is_osr_entry(); }
443 Label* label() { return &label_; }
444 LLabel* replacement() const { return replacement_; }
445 void set_replacement(LLabel* label) { replacement_ = label; }
446 bool HasReplacement() const { return replacement_ != NULL; }
450 LLabel* replacement_;
454 class LParameter final : public LTemplateInstruction<1, 0, 0> {
456 bool HasInterestingComment(LCodeGen* gen) const override { return false; }
457 DECLARE_CONCRETE_INSTRUCTION(Parameter, "parameter")
461 class LCallStub final : public LTemplateInstruction<1, 1, 0> {
463 explicit LCallStub(LOperand* context) {
464 inputs_[0] = context;
467 LOperand* context() { return inputs_[0]; }
469 DECLARE_CONCRETE_INSTRUCTION(CallStub, "call-stub")
470 DECLARE_HYDROGEN_ACCESSOR(CallStub)
474 class LUnknownOSRValue final : public LTemplateInstruction<1, 0, 0> {
476 bool HasInterestingComment(LCodeGen* gen) const override { return false; }
477 DECLARE_CONCRETE_INSTRUCTION(UnknownOSRValue, "unknown-osr-value")
481 template<int I, int T>
482 class LControlInstruction : public LTemplateInstruction<0, I, T> {
484 LControlInstruction() : false_label_(NULL), true_label_(NULL) { }
486 bool IsControl() const final { return true; }
488 int SuccessorCount() { return hydrogen()->SuccessorCount(); }
489 HBasicBlock* SuccessorAt(int i) { return hydrogen()->SuccessorAt(i); }
491 int TrueDestination(LChunk* chunk) {
492 return chunk->LookupDestination(true_block_id());
494 int FalseDestination(LChunk* chunk) {
495 return chunk->LookupDestination(false_block_id());
498 Label* TrueLabel(LChunk* chunk) {
499 if (true_label_ == NULL) {
500 true_label_ = chunk->GetAssemblyLabel(TrueDestination(chunk));
504 Label* FalseLabel(LChunk* chunk) {
505 if (false_label_ == NULL) {
506 false_label_ = chunk->GetAssemblyLabel(FalseDestination(chunk));
512 int true_block_id() { return SuccessorAt(0)->block_id(); }
513 int false_block_id() { return SuccessorAt(1)->block_id(); }
516 HControlInstruction* hydrogen() {
517 return HControlInstruction::cast(this->hydrogen_value());
525 class LWrapReceiver final : public LTemplateInstruction<1, 2, 0> {
527 LWrapReceiver(LOperand* receiver, LOperand* function) {
528 inputs_[0] = receiver;
529 inputs_[1] = function;
532 DECLARE_CONCRETE_INSTRUCTION(WrapReceiver, "wrap-receiver")
533 DECLARE_HYDROGEN_ACCESSOR(WrapReceiver)
535 LOperand* receiver() { return inputs_[0]; }
536 LOperand* function() { return inputs_[1]; }
540 class LApplyArguments final : public LTemplateInstruction<1, 4, 0> {
542 LApplyArguments(LOperand* function,
545 LOperand* elements) {
546 inputs_[0] = function;
547 inputs_[1] = receiver;
549 inputs_[3] = elements;
552 DECLARE_CONCRETE_INSTRUCTION(ApplyArguments, "apply-arguments")
554 LOperand* function() { return inputs_[0]; }
555 LOperand* receiver() { return inputs_[1]; }
556 LOperand* length() { return inputs_[2]; }
557 LOperand* elements() { return inputs_[3]; }
561 class LAccessArgumentsAt final : public LTemplateInstruction<1, 3, 0> {
563 LAccessArgumentsAt(LOperand* arguments, LOperand* length, LOperand* index) {
564 inputs_[0] = arguments;
569 DECLARE_CONCRETE_INSTRUCTION(AccessArgumentsAt, "access-arguments-at")
571 LOperand* arguments() { return inputs_[0]; }
572 LOperand* length() { return inputs_[1]; }
573 LOperand* index() { return inputs_[2]; }
575 void PrintDataTo(StringStream* stream) override;
579 class LArgumentsLength final : public LTemplateInstruction<1, 1, 0> {
581 explicit LArgumentsLength(LOperand* elements) {
582 inputs_[0] = elements;
585 LOperand* elements() { return inputs_[0]; }
587 DECLARE_CONCRETE_INSTRUCTION(ArgumentsLength, "arguments-length")
591 class LArgumentsElements final : public LTemplateInstruction<1, 0, 0> {
593 DECLARE_CONCRETE_INSTRUCTION(ArgumentsElements, "arguments-elements")
594 DECLARE_HYDROGEN_ACCESSOR(ArgumentsElements)
598 class LModByPowerOf2I final : public LTemplateInstruction<1, 1, 0> {
600 LModByPowerOf2I(LOperand* dividend, int32_t divisor) {
601 inputs_[0] = dividend;
605 LOperand* dividend() { return inputs_[0]; }
606 int32_t divisor() const { return divisor_; }
608 DECLARE_CONCRETE_INSTRUCTION(ModByPowerOf2I, "mod-by-power-of-2-i")
609 DECLARE_HYDROGEN_ACCESSOR(Mod)
616 class LModByConstI final : public LTemplateInstruction<1, 1, 0> {
618 LModByConstI(LOperand* dividend, int32_t divisor) {
619 inputs_[0] = dividend;
623 LOperand* dividend() { return inputs_[0]; }
624 int32_t divisor() const { return divisor_; }
626 DECLARE_CONCRETE_INSTRUCTION(ModByConstI, "mod-by-const-i")
627 DECLARE_HYDROGEN_ACCESSOR(Mod)
634 class LModI final : public LTemplateInstruction<1, 2, 3> {
636 LModI(LOperand* left,
642 LOperand* left() { return inputs_[0]; }
643 LOperand* right() { return inputs_[1]; }
645 DECLARE_CONCRETE_INSTRUCTION(ModI, "mod-i")
646 DECLARE_HYDROGEN_ACCESSOR(Mod)
650 class LDivByPowerOf2I final : public LTemplateInstruction<1, 1, 0> {
652 LDivByPowerOf2I(LOperand* dividend, int32_t divisor) {
653 inputs_[0] = dividend;
657 LOperand* dividend() { return inputs_[0]; }
658 int32_t divisor() const { return divisor_; }
660 DECLARE_CONCRETE_INSTRUCTION(DivByPowerOf2I, "div-by-power-of-2-i")
661 DECLARE_HYDROGEN_ACCESSOR(Div)
668 class LDivByConstI final : public LTemplateInstruction<1, 1, 0> {
670 LDivByConstI(LOperand* dividend, int32_t divisor) {
671 inputs_[0] = dividend;
675 LOperand* dividend() { return inputs_[0]; }
676 int32_t divisor() const { return divisor_; }
678 DECLARE_CONCRETE_INSTRUCTION(DivByConstI, "div-by-const-i")
679 DECLARE_HYDROGEN_ACCESSOR(Div)
686 class LDivI final : public LTemplateInstruction<1, 2, 1> {
688 LDivI(LOperand* dividend, LOperand* divisor, LOperand* temp) {
689 inputs_[0] = dividend;
690 inputs_[1] = divisor;
694 LOperand* dividend() { return inputs_[0]; }
695 LOperand* divisor() { return inputs_[1]; }
696 LOperand* temp() { return temps_[0]; }
698 DECLARE_CONCRETE_INSTRUCTION(DivI, "div-i")
699 DECLARE_HYDROGEN_ACCESSOR(BinaryOperation)
703 class LFlooringDivByPowerOf2I final : public LTemplateInstruction<1, 1, 0> {
705 LFlooringDivByPowerOf2I(LOperand* dividend, int32_t divisor) {
706 inputs_[0] = dividend;
710 LOperand* dividend() { return inputs_[0]; }
711 int32_t divisor() { return divisor_; }
713 DECLARE_CONCRETE_INSTRUCTION(FlooringDivByPowerOf2I,
714 "flooring-div-by-power-of-2-i")
715 DECLARE_HYDROGEN_ACCESSOR(MathFloorOfDiv)
722 class LFlooringDivByConstI final : public LTemplateInstruction<1, 1, 2> {
724 LFlooringDivByConstI(LOperand* dividend, int32_t divisor, LOperand* temp) {
725 inputs_[0] = dividend;
730 LOperand* dividend() { return inputs_[0]; }
731 int32_t divisor() const { return divisor_; }
732 LOperand* temp() { return temps_[0]; }
734 DECLARE_CONCRETE_INSTRUCTION(FlooringDivByConstI, "flooring-div-by-const-i")
735 DECLARE_HYDROGEN_ACCESSOR(MathFloorOfDiv)
742 class LFlooringDivI final : public LTemplateInstruction<1, 2, 0> {
744 LFlooringDivI(LOperand* dividend, LOperand* divisor) {
745 inputs_[0] = dividend;
746 inputs_[1] = divisor;
749 LOperand* dividend() { return inputs_[0]; }
750 LOperand* divisor() { return inputs_[1]; }
752 DECLARE_CONCRETE_INSTRUCTION(FlooringDivI, "flooring-div-i")
753 DECLARE_HYDROGEN_ACCESSOR(MathFloorOfDiv)
757 class LMulI final : public LTemplateInstruction<1, 2, 0> {
759 LMulI(LOperand* left, LOperand* right) {
764 LOperand* left() { return inputs_[0]; }
765 LOperand* right() { return inputs_[1]; }
767 DECLARE_CONCRETE_INSTRUCTION(MulI, "mul-i")
768 DECLARE_HYDROGEN_ACCESSOR(Mul)
772 // Instruction for computing multiplier * multiplicand + addend.
773 class LMultiplyAddD final : public LTemplateInstruction<1, 3, 0> {
775 LMultiplyAddD(LOperand* addend, LOperand* multiplier,
776 LOperand* multiplicand) {
778 inputs_[1] = multiplier;
779 inputs_[2] = multiplicand;
782 LOperand* addend() { return inputs_[0]; }
783 LOperand* multiplier() { return inputs_[1]; }
784 LOperand* multiplicand() { return inputs_[2]; }
786 DECLARE_CONCRETE_INSTRUCTION(MultiplyAddD, "multiply-add-d")
790 class LDebugBreak final : public LTemplateInstruction<0, 0, 0> {
792 DECLARE_CONCRETE_INSTRUCTION(DebugBreak, "break")
796 class LCompareNumericAndBranch final : public LControlInstruction<2, 0> {
798 LCompareNumericAndBranch(LOperand* left, LOperand* right) {
803 LOperand* left() { return inputs_[0]; }
804 LOperand* right() { return inputs_[1]; }
806 DECLARE_CONCRETE_INSTRUCTION(CompareNumericAndBranch,
807 "compare-numeric-and-branch")
808 DECLARE_HYDROGEN_ACCESSOR(CompareNumericAndBranch)
810 Token::Value op() const { return hydrogen()->token(); }
811 bool is_double() const {
812 return hydrogen()->representation().IsDouble();
815 void PrintDataTo(StringStream* stream) override;
819 class LMathFloor final : public LTemplateInstruction<1, 1, 1> {
821 LMathFloor(LOperand* value, LOperand* temp) {
826 LOperand* value() { return inputs_[0]; }
827 LOperand* temp() { return temps_[0]; }
829 DECLARE_CONCRETE_INSTRUCTION(MathFloor, "math-floor")
830 DECLARE_HYDROGEN_ACCESSOR(UnaryMathOperation)
834 class LMathRound final : public LTemplateInstruction<1, 1, 1> {
836 LMathRound(LOperand* value, LOperand* temp) {
841 LOperand* value() { return inputs_[0]; }
842 LOperand* temp() { return temps_[0]; }
844 DECLARE_CONCRETE_INSTRUCTION(MathRound, "math-round")
845 DECLARE_HYDROGEN_ACCESSOR(UnaryMathOperation)
849 class LMathFround final : public LTemplateInstruction<1, 1, 0> {
851 explicit LMathFround(LOperand* value) { inputs_[0] = value; }
853 LOperand* value() { return inputs_[0]; }
855 DECLARE_CONCRETE_INSTRUCTION(MathFround, "math-fround")
859 class LMathAbs final : public LTemplateInstruction<1, 2, 0> {
861 LMathAbs(LOperand* context, LOperand* value) {
862 inputs_[1] = context;
866 LOperand* context() { return inputs_[1]; }
867 LOperand* value() { return inputs_[0]; }
869 DECLARE_CONCRETE_INSTRUCTION(MathAbs, "math-abs")
870 DECLARE_HYDROGEN_ACCESSOR(UnaryMathOperation)
874 class LMathLog final : public LTemplateInstruction<1, 1, 0> {
876 explicit LMathLog(LOperand* value) {
880 LOperand* value() { return inputs_[0]; }
882 DECLARE_CONCRETE_INSTRUCTION(MathLog, "math-log")
886 class LMathClz32 final : public LTemplateInstruction<1, 1, 0> {
888 explicit LMathClz32(LOperand* value) {
892 LOperand* value() { return inputs_[0]; }
894 DECLARE_CONCRETE_INSTRUCTION(MathClz32, "math-clz32")
898 class LMathExp final : public LTemplateInstruction<1, 1, 3> {
900 LMathExp(LOperand* value,
901 LOperand* double_temp,
907 temps_[2] = double_temp;
908 ExternalReference::InitializeMathExpData();
911 LOperand* value() { return inputs_[0]; }
912 LOperand* temp1() { return temps_[0]; }
913 LOperand* temp2() { return temps_[1]; }
914 LOperand* double_temp() { return temps_[2]; }
916 DECLARE_CONCRETE_INSTRUCTION(MathExp, "math-exp")
920 class LMathSqrt final : public LTemplateInstruction<1, 1, 0> {
922 explicit LMathSqrt(LOperand* value) {
926 LOperand* value() { return inputs_[0]; }
928 DECLARE_CONCRETE_INSTRUCTION(MathSqrt, "math-sqrt")
932 class LMathPowHalf final : public LTemplateInstruction<1, 1, 1> {
934 LMathPowHalf(LOperand* value, LOperand* temp) {
939 LOperand* value() { return inputs_[0]; }
940 LOperand* temp() { return temps_[0]; }
942 DECLARE_CONCRETE_INSTRUCTION(MathPowHalf, "math-pow-half")
946 class LCmpObjectEqAndBranch final : public LControlInstruction<2, 0> {
948 LCmpObjectEqAndBranch(LOperand* left, LOperand* right) {
953 LOperand* left() { return inputs_[0]; }
954 LOperand* right() { return inputs_[1]; }
956 DECLARE_CONCRETE_INSTRUCTION(CmpObjectEqAndBranch, "cmp-object-eq-and-branch")
957 DECLARE_HYDROGEN_ACCESSOR(CompareObjectEqAndBranch)
961 class LCmpHoleAndBranch final : public LControlInstruction<1, 0> {
963 explicit LCmpHoleAndBranch(LOperand* object) {
967 LOperand* object() { return inputs_[0]; }
969 DECLARE_CONCRETE_INSTRUCTION(CmpHoleAndBranch, "cmp-hole-and-branch")
970 DECLARE_HYDROGEN_ACCESSOR(CompareHoleAndBranch)
974 class LCompareMinusZeroAndBranch final : public LControlInstruction<1, 1> {
976 LCompareMinusZeroAndBranch(LOperand* value, LOperand* temp) {
981 LOperand* value() { return inputs_[0]; }
982 LOperand* temp() { return temps_[0]; }
984 DECLARE_CONCRETE_INSTRUCTION(CompareMinusZeroAndBranch,
985 "cmp-minus-zero-and-branch")
986 DECLARE_HYDROGEN_ACCESSOR(CompareMinusZeroAndBranch)
990 class LIsObjectAndBranch final : public LControlInstruction<1, 1> {
992 LIsObjectAndBranch(LOperand* value, LOperand* temp) {
997 LOperand* value() { return inputs_[0]; }
998 LOperand* temp() { return temps_[0]; }
1000 DECLARE_CONCRETE_INSTRUCTION(IsObjectAndBranch, "is-object-and-branch")
1001 DECLARE_HYDROGEN_ACCESSOR(IsObjectAndBranch)
1003 void PrintDataTo(StringStream* stream) override;
1007 class LIsStringAndBranch final : public LControlInstruction<1, 1> {
1009 LIsStringAndBranch(LOperand* value, LOperand* temp) {
1014 LOperand* value() { return inputs_[0]; }
1015 LOperand* temp() { return temps_[0]; }
1017 DECLARE_CONCRETE_INSTRUCTION(IsStringAndBranch, "is-string-and-branch")
1018 DECLARE_HYDROGEN_ACCESSOR(IsStringAndBranch)
1020 void PrintDataTo(StringStream* stream) override;
1024 class LIsSmiAndBranch final : public LControlInstruction<1, 0> {
1026 explicit LIsSmiAndBranch(LOperand* value) {
1030 LOperand* value() { return inputs_[0]; }
1032 DECLARE_CONCRETE_INSTRUCTION(IsSmiAndBranch, "is-smi-and-branch")
1033 DECLARE_HYDROGEN_ACCESSOR(IsSmiAndBranch)
1035 void PrintDataTo(StringStream* stream) override;
1039 class LIsUndetectableAndBranch final : public LControlInstruction<1, 1> {
1041 explicit LIsUndetectableAndBranch(LOperand* value, LOperand* temp) {
1046 LOperand* value() { return inputs_[0]; }
1047 LOperand* temp() { return temps_[0]; }
1049 DECLARE_CONCRETE_INSTRUCTION(IsUndetectableAndBranch,
1050 "is-undetectable-and-branch")
1051 DECLARE_HYDROGEN_ACCESSOR(IsUndetectableAndBranch)
1053 void PrintDataTo(StringStream* stream) override;
1057 class LStringCompareAndBranch final : public LControlInstruction<3, 0> {
1059 LStringCompareAndBranch(LOperand* context, LOperand* left, LOperand* right) {
1060 inputs_[0] = context;
1065 LOperand* context() { return inputs_[0]; }
1066 LOperand* left() { return inputs_[1]; }
1067 LOperand* right() { return inputs_[2]; }
1069 DECLARE_CONCRETE_INSTRUCTION(StringCompareAndBranch,
1070 "string-compare-and-branch")
1071 DECLARE_HYDROGEN_ACCESSOR(StringCompareAndBranch)
1073 Token::Value op() const { return hydrogen()->token(); }
1075 void PrintDataTo(StringStream* stream) override;
1079 class LHasInstanceTypeAndBranch final : public LControlInstruction<1, 0> {
1081 explicit LHasInstanceTypeAndBranch(LOperand* value) {
1085 LOperand* value() { return inputs_[0]; }
1087 DECLARE_CONCRETE_INSTRUCTION(HasInstanceTypeAndBranch,
1088 "has-instance-type-and-branch")
1089 DECLARE_HYDROGEN_ACCESSOR(HasInstanceTypeAndBranch)
1091 void PrintDataTo(StringStream* stream) override;
1095 class LGetCachedArrayIndex final : public LTemplateInstruction<1, 1, 0> {
1097 explicit LGetCachedArrayIndex(LOperand* value) {
1101 LOperand* value() { return inputs_[0]; }
1103 DECLARE_CONCRETE_INSTRUCTION(GetCachedArrayIndex, "get-cached-array-index")
1104 DECLARE_HYDROGEN_ACCESSOR(GetCachedArrayIndex)
1108 class LHasCachedArrayIndexAndBranch final : public LControlInstruction<1, 0> {
1110 explicit LHasCachedArrayIndexAndBranch(LOperand* value) {
1114 LOperand* value() { return inputs_[0]; }
1116 DECLARE_CONCRETE_INSTRUCTION(HasCachedArrayIndexAndBranch,
1117 "has-cached-array-index-and-branch")
1118 DECLARE_HYDROGEN_ACCESSOR(HasCachedArrayIndexAndBranch)
1120 void PrintDataTo(StringStream* stream) override;
1124 class LClassOfTestAndBranch final : public LControlInstruction<1, 1> {
1126 LClassOfTestAndBranch(LOperand* value, LOperand* temp) {
1131 LOperand* value() { return inputs_[0]; }
1132 LOperand* temp() { return temps_[0]; }
1134 DECLARE_CONCRETE_INSTRUCTION(ClassOfTestAndBranch,
1135 "class-of-test-and-branch")
1136 DECLARE_HYDROGEN_ACCESSOR(ClassOfTestAndBranch)
1138 void PrintDataTo(StringStream* stream) override;
1142 class LCmpT final : public LTemplateInstruction<1, 3, 0> {
1144 LCmpT(LOperand* context, LOperand* left, LOperand* right) {
1145 inputs_[0] = context;
1150 LOperand* context() { return inputs_[0]; }
1151 LOperand* left() { return inputs_[1]; }
1152 LOperand* right() { return inputs_[2]; }
1154 DECLARE_CONCRETE_INSTRUCTION(CmpT, "cmp-t")
1155 DECLARE_HYDROGEN_ACCESSOR(CompareGeneric)
1157 LanguageMode language_mode() { return hydrogen()->language_mode(); }
1159 Token::Value op() const { return hydrogen()->token(); }
1163 class LInstanceOf final : public LTemplateInstruction<1, 3, 0> {
1165 LInstanceOf(LOperand* context, LOperand* left, LOperand* right) {
1166 inputs_[0] = context;
1171 LOperand* context() { return inputs_[0]; }
1172 LOperand* left() { return inputs_[1]; }
1173 LOperand* right() { return inputs_[2]; }
1175 DECLARE_CONCRETE_INSTRUCTION(InstanceOf, "instance-of")
1179 class LInstanceOfKnownGlobal final : public LTemplateInstruction<1, 2, 1> {
1181 LInstanceOfKnownGlobal(LOperand* context, LOperand* value, LOperand* temp) {
1182 inputs_[0] = context;
1187 LOperand* context() { return inputs_[0]; }
1188 LOperand* value() { return inputs_[1]; }
1189 LOperand* temp() { return temps_[0]; }
1191 DECLARE_CONCRETE_INSTRUCTION(InstanceOfKnownGlobal,
1192 "instance-of-known-global")
1193 DECLARE_HYDROGEN_ACCESSOR(InstanceOfKnownGlobal)
1195 Handle<JSFunction> function() const { return hydrogen()->function(); }
1196 LEnvironment* GetDeferredLazyDeoptimizationEnvironment() {
1197 return lazy_deopt_env_;
1199 virtual void SetDeferredLazyDeoptimizationEnvironment(
1200 LEnvironment* env) override {
1201 lazy_deopt_env_ = env;
1205 LEnvironment* lazy_deopt_env_;
1209 class LBoundsCheck final : public LTemplateInstruction<0, 2, 0> {
1211 LBoundsCheck(LOperand* index, LOperand* length) {
1213 inputs_[1] = length;
1216 LOperand* index() { return inputs_[0]; }
1217 LOperand* length() { return inputs_[1]; }
1219 DECLARE_CONCRETE_INSTRUCTION(BoundsCheck, "bounds-check")
1220 DECLARE_HYDROGEN_ACCESSOR(BoundsCheck)
1224 class LBitI final : public LTemplateInstruction<1, 2, 0> {
1226 LBitI(LOperand* left, LOperand* right) {
1231 LOperand* left() { return inputs_[0]; }
1232 LOperand* right() { return inputs_[1]; }
1234 Token::Value op() const { return hydrogen()->op(); }
1236 DECLARE_CONCRETE_INSTRUCTION(BitI, "bit-i")
1237 DECLARE_HYDROGEN_ACCESSOR(Bitwise)
1241 class LShiftI final : public LTemplateInstruction<1, 2, 0> {
1243 LShiftI(Token::Value op, LOperand* left, LOperand* right, bool can_deopt)
1244 : op_(op), can_deopt_(can_deopt) {
1249 Token::Value op() const { return op_; }
1250 LOperand* left() { return inputs_[0]; }
1251 LOperand* right() { return inputs_[1]; }
1252 bool can_deopt() const { return can_deopt_; }
1254 DECLARE_CONCRETE_INSTRUCTION(ShiftI, "shift-i")
1262 class LSubI final : public LTemplateInstruction<1, 2, 0> {
1264 LSubI(LOperand* left, LOperand* right) {
1269 LOperand* left() { return inputs_[0]; }
1270 LOperand* right() { return inputs_[1]; }
1272 DECLARE_CONCRETE_INSTRUCTION(SubI, "sub-i")
1273 DECLARE_HYDROGEN_ACCESSOR(Sub)
1277 class LConstantI final : public LTemplateInstruction<1, 0, 0> {
1279 DECLARE_CONCRETE_INSTRUCTION(ConstantI, "constant-i")
1280 DECLARE_HYDROGEN_ACCESSOR(Constant)
1282 int32_t value() const { return hydrogen()->Integer32Value(); }
1286 class LConstantS final : public LTemplateInstruction<1, 0, 0> {
1288 DECLARE_CONCRETE_INSTRUCTION(ConstantS, "constant-s")
1289 DECLARE_HYDROGEN_ACCESSOR(Constant)
1291 Smi* value() const { return Smi::FromInt(hydrogen()->Integer32Value()); }
1295 class LConstantD final : public LTemplateInstruction<1, 0, 0> {
1297 DECLARE_CONCRETE_INSTRUCTION(ConstantD, "constant-d")
1298 DECLARE_HYDROGEN_ACCESSOR(Constant)
1300 double value() const { return hydrogen()->DoubleValue(); }
1301 uint64_t bits() const { return hydrogen()->DoubleValueAsBits(); }
1305 class LConstantE final : public LTemplateInstruction<1, 0, 0> {
1307 DECLARE_CONCRETE_INSTRUCTION(ConstantE, "constant-e")
1308 DECLARE_HYDROGEN_ACCESSOR(Constant)
1310 ExternalReference value() const {
1311 return hydrogen()->ExternalReferenceValue();
1316 class LConstantT final : public LTemplateInstruction<1, 0, 0> {
1318 DECLARE_CONCRETE_INSTRUCTION(ConstantT, "constant-t")
1319 DECLARE_HYDROGEN_ACCESSOR(Constant)
1321 Handle<Object> value(Isolate* isolate) const {
1322 return hydrogen()->handle(isolate);
1327 class LBranch final : public LControlInstruction<1, 0> {
1329 explicit LBranch(LOperand* value) {
1333 LOperand* value() { return inputs_[0]; }
1335 DECLARE_CONCRETE_INSTRUCTION(Branch, "branch")
1336 DECLARE_HYDROGEN_ACCESSOR(Branch)
1338 void PrintDataTo(StringStream* stream) override;
1342 class LCmpMapAndBranch final : public LControlInstruction<1, 1> {
1344 LCmpMapAndBranch(LOperand* value, LOperand* temp) {
1349 LOperand* value() { return inputs_[0]; }
1350 LOperand* temp() { return temps_[0]; }
1352 DECLARE_CONCRETE_INSTRUCTION(CmpMapAndBranch, "cmp-map-and-branch")
1353 DECLARE_HYDROGEN_ACCESSOR(CompareMap)
1355 Handle<Map> map() const { return hydrogen()->map().handle(); }
1359 class LMapEnumLength final : public LTemplateInstruction<1, 1, 0> {
1361 explicit LMapEnumLength(LOperand* value) {
1365 LOperand* value() { return inputs_[0]; }
1367 DECLARE_CONCRETE_INSTRUCTION(MapEnumLength, "map-enum-length")
1371 class LDateField final : public LTemplateInstruction<1, 1, 1> {
1373 LDateField(LOperand* date, LOperand* temp, Smi* index) : index_(index) {
1378 LOperand* date() { return inputs_[0]; }
1379 LOperand* temp() { return temps_[0]; }
1380 Smi* index() const { return index_; }
1382 DECLARE_CONCRETE_INSTRUCTION(DateField, "date-field")
1383 DECLARE_HYDROGEN_ACCESSOR(DateField)
1390 class LSeqStringGetChar final : public LTemplateInstruction<1, 2, 0> {
1392 LSeqStringGetChar(LOperand* string, LOperand* index) {
1393 inputs_[0] = string;
1397 LOperand* string() const { return inputs_[0]; }
1398 LOperand* index() const { return inputs_[1]; }
1400 DECLARE_CONCRETE_INSTRUCTION(SeqStringGetChar, "seq-string-get-char")
1401 DECLARE_HYDROGEN_ACCESSOR(SeqStringGetChar)
1405 class LSeqStringSetChar final : public LTemplateInstruction<1, 4, 0> {
1407 LSeqStringSetChar(LOperand* context,
1411 inputs_[0] = context;
1412 inputs_[1] = string;
1417 LOperand* string() { return inputs_[1]; }
1418 LOperand* index() { return inputs_[2]; }
1419 LOperand* value() { return inputs_[3]; }
1421 DECLARE_CONCRETE_INSTRUCTION(SeqStringSetChar, "seq-string-set-char")
1422 DECLARE_HYDROGEN_ACCESSOR(SeqStringSetChar)
1426 class LAddI final : public LTemplateInstruction<1, 2, 0> {
1428 LAddI(LOperand* left, LOperand* right) {
1433 LOperand* left() { return inputs_[0]; }
1434 LOperand* right() { return inputs_[1]; }
1436 DECLARE_CONCRETE_INSTRUCTION(AddI, "add-i")
1437 DECLARE_HYDROGEN_ACCESSOR(Add)
1441 class LMathMinMax final : public LTemplateInstruction<1, 2, 0> {
1443 LMathMinMax(LOperand* left, LOperand* right) {
1448 LOperand* left() { return inputs_[0]; }
1449 LOperand* right() { return inputs_[1]; }
1451 DECLARE_CONCRETE_INSTRUCTION(MathMinMax, "math-min-max")
1452 DECLARE_HYDROGEN_ACCESSOR(MathMinMax)
1456 class LPower final : public LTemplateInstruction<1, 2, 0> {
1458 LPower(LOperand* left, LOperand* right) {
1463 LOperand* left() { return inputs_[0]; }
1464 LOperand* right() { return inputs_[1]; }
1466 DECLARE_CONCRETE_INSTRUCTION(Power, "power")
1467 DECLARE_HYDROGEN_ACCESSOR(Power)
1471 class LArithmeticD final : public LTemplateInstruction<1, 2, 0> {
1473 LArithmeticD(Token::Value op, LOperand* left, LOperand* right)
1479 Token::Value op() const { return op_; }
1480 LOperand* left() { return inputs_[0]; }
1481 LOperand* right() { return inputs_[1]; }
1483 Opcode opcode() const override { return LInstruction::kArithmeticD; }
1484 void CompileToNative(LCodeGen* generator) override;
1485 const char* Mnemonic() const override;
1492 class LArithmeticT final : public LTemplateInstruction<1, 3, 0> {
1494 LArithmeticT(Token::Value op,
1499 inputs_[0] = context;
1504 LOperand* context() { return inputs_[0]; }
1505 LOperand* left() { return inputs_[1]; }
1506 LOperand* right() { return inputs_[2]; }
1507 Token::Value op() const { return op_; }
1509 Opcode opcode() const final { return LInstruction::kArithmeticT; }
1510 void CompileToNative(LCodeGen* generator) override;
1511 const char* Mnemonic() const override;
1513 DECLARE_HYDROGEN_ACCESSOR(BinaryOperation)
1515 LanguageMode language_mode() { return hydrogen()->language_mode(); }
1522 class LReturn final : public LTemplateInstruction<0, 3, 0> {
1524 LReturn(LOperand* value, LOperand* context, LOperand* parameter_count) {
1526 inputs_[1] = context;
1527 inputs_[2] = parameter_count;
1530 LOperand* value() { return inputs_[0]; }
1532 bool has_constant_parameter_count() {
1533 return parameter_count()->IsConstantOperand();
1535 LConstantOperand* constant_parameter_count() {
1536 DCHECK(has_constant_parameter_count());
1537 return LConstantOperand::cast(parameter_count());
1539 LOperand* parameter_count() { return inputs_[2]; }
1541 DECLARE_CONCRETE_INSTRUCTION(Return, "return")
1545 class LLoadNamedField final : public LTemplateInstruction<1, 1, 0> {
1547 explicit LLoadNamedField(LOperand* object) {
1548 inputs_[0] = object;
1551 LOperand* object() { return inputs_[0]; }
1553 DECLARE_CONCRETE_INSTRUCTION(LoadNamedField, "load-named-field")
1554 DECLARE_HYDROGEN_ACCESSOR(LoadNamedField)
1558 class LLoadNamedGeneric final : public LTemplateInstruction<1, 2, 1> {
1560 LLoadNamedGeneric(LOperand* context, LOperand* object, LOperand* vector) {
1561 inputs_[0] = context;
1562 inputs_[1] = object;
1566 LOperand* context() { return inputs_[0]; }
1567 LOperand* object() { return inputs_[1]; }
1568 LOperand* temp_vector() { return temps_[0]; }
1570 DECLARE_CONCRETE_INSTRUCTION(LoadNamedGeneric, "load-named-generic")
1571 DECLARE_HYDROGEN_ACCESSOR(LoadNamedGeneric)
1573 Handle<Object> name() const { return hydrogen()->name(); }
1577 class LLoadFunctionPrototype final : public LTemplateInstruction<1, 1, 0> {
1579 explicit LLoadFunctionPrototype(LOperand* function) {
1580 inputs_[0] = function;
1583 LOperand* function() { return inputs_[0]; }
1585 DECLARE_CONCRETE_INSTRUCTION(LoadFunctionPrototype, "load-function-prototype")
1586 DECLARE_HYDROGEN_ACCESSOR(LoadFunctionPrototype)
1590 class LLoadRoot final : public LTemplateInstruction<1, 0, 0> {
1592 DECLARE_CONCRETE_INSTRUCTION(LoadRoot, "load-root")
1593 DECLARE_HYDROGEN_ACCESSOR(LoadRoot)
1595 Heap::RootListIndex index() const { return hydrogen()->index(); }
1599 class LLoadKeyed final : public LTemplateInstruction<1, 2, 0> {
1601 LLoadKeyed(LOperand* elements, LOperand* key) {
1602 inputs_[0] = elements;
1606 LOperand* elements() { return inputs_[0]; }
1607 LOperand* key() { return inputs_[1]; }
1608 ElementsKind elements_kind() const {
1609 return hydrogen()->elements_kind();
1611 bool is_external() const {
1612 return hydrogen()->is_external();
1614 bool is_fixed_typed_array() const {
1615 return hydrogen()->is_fixed_typed_array();
1617 bool is_typed_elements() const {
1618 return is_external() || is_fixed_typed_array();
1621 DECLARE_CONCRETE_INSTRUCTION(LoadKeyed, "load-keyed")
1622 DECLARE_HYDROGEN_ACCESSOR(LoadKeyed)
1624 void PrintDataTo(StringStream* stream) override;
1625 uint32_t base_offset() const { return hydrogen()->base_offset(); }
1629 class LLoadKeyedGeneric final : public LTemplateInstruction<1, 3, 1> {
1631 LLoadKeyedGeneric(LOperand* context, LOperand* object, LOperand* key,
1633 inputs_[0] = context;
1634 inputs_[1] = object;
1639 LOperand* context() { return inputs_[0]; }
1640 LOperand* object() { return inputs_[1]; }
1641 LOperand* key() { return inputs_[2]; }
1642 LOperand* temp_vector() { return temps_[0]; }
1644 DECLARE_CONCRETE_INSTRUCTION(LoadKeyedGeneric, "load-keyed-generic")
1645 DECLARE_HYDROGEN_ACCESSOR(LoadKeyedGeneric)
1649 class LLoadGlobalGeneric final : public LTemplateInstruction<1, 2, 1> {
1651 LLoadGlobalGeneric(LOperand* context, LOperand* global_object,
1653 inputs_[0] = context;
1654 inputs_[1] = global_object;
1658 LOperand* context() { return inputs_[0]; }
1659 LOperand* global_object() { return inputs_[1]; }
1660 LOperand* temp_vector() { return temps_[0]; }
1662 DECLARE_CONCRETE_INSTRUCTION(LoadGlobalGeneric, "load-global-generic")
1663 DECLARE_HYDROGEN_ACCESSOR(LoadGlobalGeneric)
1665 Handle<Object> name() const { return hydrogen()->name(); }
1666 bool for_typeof() const { return hydrogen()->for_typeof(); }
1670 class LLoadContextSlot final : public LTemplateInstruction<1, 1, 0> {
1672 explicit LLoadContextSlot(LOperand* context) {
1673 inputs_[0] = context;
1676 LOperand* context() { return inputs_[0]; }
1678 DECLARE_CONCRETE_INSTRUCTION(LoadContextSlot, "load-context-slot")
1679 DECLARE_HYDROGEN_ACCESSOR(LoadContextSlot)
1681 int slot_index() { return hydrogen()->slot_index(); }
1683 void PrintDataTo(StringStream* stream) override;
1687 class LStoreContextSlot final : public LTemplateInstruction<0, 2, 0> {
1689 LStoreContextSlot(LOperand* context, LOperand* value) {
1690 inputs_[0] = context;
1694 LOperand* context() { return inputs_[0]; }
1695 LOperand* value() { return inputs_[1]; }
1697 DECLARE_CONCRETE_INSTRUCTION(StoreContextSlot, "store-context-slot")
1698 DECLARE_HYDROGEN_ACCESSOR(StoreContextSlot)
1700 int slot_index() { return hydrogen()->slot_index(); }
1702 void PrintDataTo(StringStream* stream) override;
1706 class LPushArgument final : public LTemplateInstruction<0, 1, 0> {
1708 explicit LPushArgument(LOperand* value) {
1712 LOperand* value() { return inputs_[0]; }
1714 DECLARE_CONCRETE_INSTRUCTION(PushArgument, "push-argument")
1718 class LDrop final : public LTemplateInstruction<0, 0, 0> {
1720 explicit LDrop(int count) : count_(count) { }
1722 int count() const { return count_; }
1724 DECLARE_CONCRETE_INSTRUCTION(Drop, "drop")
1731 class LStoreCodeEntry final : public LTemplateInstruction<0, 2, 0> {
1733 LStoreCodeEntry(LOperand* function, LOperand* code_object) {
1734 inputs_[0] = function;
1735 inputs_[1] = code_object;
1738 LOperand* function() { return inputs_[0]; }
1739 LOperand* code_object() { return inputs_[1]; }
1741 void PrintDataTo(StringStream* stream) override;
1743 DECLARE_CONCRETE_INSTRUCTION(StoreCodeEntry, "store-code-entry")
1744 DECLARE_HYDROGEN_ACCESSOR(StoreCodeEntry)
1748 class LInnerAllocatedObject final : public LTemplateInstruction<1, 2, 0> {
1750 LInnerAllocatedObject(LOperand* base_object, LOperand* offset) {
1751 inputs_[0] = base_object;
1752 inputs_[1] = offset;
1755 LOperand* base_object() const { return inputs_[0]; }
1756 LOperand* offset() const { return inputs_[1]; }
1758 void PrintDataTo(StringStream* stream) override;
1760 DECLARE_CONCRETE_INSTRUCTION(InnerAllocatedObject, "inner-allocated-object")
1764 class LThisFunction final : public LTemplateInstruction<1, 0, 0> {
1766 DECLARE_CONCRETE_INSTRUCTION(ThisFunction, "this-function")
1767 DECLARE_HYDROGEN_ACCESSOR(ThisFunction)
1771 class LContext final : public LTemplateInstruction<1, 0, 0> {
1773 DECLARE_CONCRETE_INSTRUCTION(Context, "context")
1774 DECLARE_HYDROGEN_ACCESSOR(Context)
1778 class LDeclareGlobals final : public LTemplateInstruction<0, 1, 0> {
1780 explicit LDeclareGlobals(LOperand* context) {
1781 inputs_[0] = context;
1784 LOperand* context() { return inputs_[0]; }
1786 DECLARE_CONCRETE_INSTRUCTION(DeclareGlobals, "declare-globals")
1787 DECLARE_HYDROGEN_ACCESSOR(DeclareGlobals)
1791 class LCallJSFunction final : public LTemplateInstruction<1, 1, 0> {
1793 explicit LCallJSFunction(LOperand* function) {
1794 inputs_[0] = function;
1797 LOperand* function() { return inputs_[0]; }
1799 DECLARE_CONCRETE_INSTRUCTION(CallJSFunction, "call-js-function")
1800 DECLARE_HYDROGEN_ACCESSOR(CallJSFunction)
1802 void PrintDataTo(StringStream* stream) override;
1804 int arity() const { return hydrogen()->argument_count() - 1; }
1808 class LCallWithDescriptor final : public LTemplateResultInstruction<1> {
1810 LCallWithDescriptor(CallInterfaceDescriptor descriptor,
1811 const ZoneList<LOperand*>& operands, Zone* zone)
1812 : descriptor_(descriptor),
1813 inputs_(descriptor.GetRegisterParameterCount() + 1, zone) {
1814 DCHECK(descriptor.GetRegisterParameterCount() + 1 == operands.length());
1815 inputs_.AddAll(operands, zone);
1818 LOperand* target() const { return inputs_[0]; }
1820 const CallInterfaceDescriptor descriptor() { return descriptor_; }
1822 DECLARE_HYDROGEN_ACCESSOR(CallWithDescriptor)
1825 DECLARE_CONCRETE_INSTRUCTION(CallWithDescriptor, "call-with-descriptor")
1827 void PrintDataTo(StringStream* stream) override;
1829 int arity() const { return hydrogen()->argument_count() - 1; }
1831 CallInterfaceDescriptor descriptor_;
1832 ZoneList<LOperand*> inputs_;
1834 // Iterator support.
1835 int InputCount() final { return inputs_.length(); }
1836 LOperand* InputAt(int i) final { return inputs_[i]; }
1838 int TempCount() final { return 0; }
1839 LOperand* TempAt(int i) final { return NULL; }
1843 class LInvokeFunction final : public LTemplateInstruction<1, 2, 0> {
1845 LInvokeFunction(LOperand* context, LOperand* function) {
1846 inputs_[0] = context;
1847 inputs_[1] = function;
1850 LOperand* context() { return inputs_[0]; }
1851 LOperand* function() { return inputs_[1]; }
1853 DECLARE_CONCRETE_INSTRUCTION(InvokeFunction, "invoke-function")
1854 DECLARE_HYDROGEN_ACCESSOR(InvokeFunction)
1856 void PrintDataTo(StringStream* stream) override;
1858 int arity() const { return hydrogen()->argument_count() - 1; }
1862 class LCallFunction final : public LTemplateInstruction<1, 2, 2> {
1864 LCallFunction(LOperand* context, LOperand* function, LOperand* slot,
1866 inputs_[0] = context;
1867 inputs_[1] = function;
1872 LOperand* context() { return inputs_[0]; }
1873 LOperand* function() { return inputs_[1]; }
1874 LOperand* temp_slot() { return temps_[0]; }
1875 LOperand* temp_vector() { return temps_[1]; }
1877 DECLARE_CONCRETE_INSTRUCTION(CallFunction, "call-function")
1878 DECLARE_HYDROGEN_ACCESSOR(CallFunction)
1880 int arity() const { return hydrogen()->argument_count() - 1; }
1881 void PrintDataTo(StringStream* stream) override;
1885 class LCallNew final : public LTemplateInstruction<1, 2, 0> {
1887 LCallNew(LOperand* context, LOperand* constructor) {
1888 inputs_[0] = context;
1889 inputs_[1] = constructor;
1892 LOperand* context() { return inputs_[0]; }
1893 LOperand* constructor() { return inputs_[1]; }
1895 DECLARE_CONCRETE_INSTRUCTION(CallNew, "call-new")
1896 DECLARE_HYDROGEN_ACCESSOR(CallNew)
1898 void PrintDataTo(StringStream* stream) override;
1900 int arity() const { return hydrogen()->argument_count() - 1; }
1904 class LCallNewArray final : public LTemplateInstruction<1, 2, 0> {
1906 LCallNewArray(LOperand* context, LOperand* constructor) {
1907 inputs_[0] = context;
1908 inputs_[1] = constructor;
1911 LOperand* context() { return inputs_[0]; }
1912 LOperand* constructor() { return inputs_[1]; }
1914 DECLARE_CONCRETE_INSTRUCTION(CallNewArray, "call-new-array")
1915 DECLARE_HYDROGEN_ACCESSOR(CallNewArray)
1917 void PrintDataTo(StringStream* stream) override;
1919 int arity() const { return hydrogen()->argument_count() - 1; }
1923 class LCallRuntime final : public LTemplateInstruction<1, 1, 0> {
1925 explicit LCallRuntime(LOperand* context) {
1926 inputs_[0] = context;
1929 LOperand* context() { return inputs_[0]; }
1931 DECLARE_CONCRETE_INSTRUCTION(CallRuntime, "call-runtime")
1932 DECLARE_HYDROGEN_ACCESSOR(CallRuntime)
1934 bool ClobbersDoubleRegisters(Isolate* isolate) const override {
1935 return save_doubles() == kDontSaveFPRegs;
1938 const Runtime::Function* function() const { return hydrogen()->function(); }
1939 int arity() const { return hydrogen()->argument_count(); }
1940 SaveFPRegsMode save_doubles() const { return hydrogen()->save_doubles(); }
1944 class LInteger32ToDouble final : public LTemplateInstruction<1, 1, 0> {
1946 explicit LInteger32ToDouble(LOperand* value) {
1950 LOperand* value() { return inputs_[0]; }
1952 DECLARE_CONCRETE_INSTRUCTION(Integer32ToDouble, "int32-to-double")
1956 class LUint32ToDouble final : public LTemplateInstruction<1, 1, 0> {
1958 explicit LUint32ToDouble(LOperand* value) {
1962 LOperand* value() { return inputs_[0]; }
1964 DECLARE_CONCRETE_INSTRUCTION(Uint32ToDouble, "uint32-to-double")
1968 class LNumberTagI final : public LTemplateInstruction<1, 1, 2> {
1970 LNumberTagI(LOperand* value, LOperand* temp1, LOperand* temp2) {
1976 LOperand* value() { return inputs_[0]; }
1977 LOperand* temp1() { return temps_[0]; }
1978 LOperand* temp2() { return temps_[1]; }
1980 DECLARE_CONCRETE_INSTRUCTION(NumberTagI, "number-tag-i")
1984 class LNumberTagU final : public LTemplateInstruction<1, 1, 2> {
1986 LNumberTagU(LOperand* value, LOperand* temp1, LOperand* temp2) {
1992 LOperand* value() { return inputs_[0]; }
1993 LOperand* temp1() { return temps_[0]; }
1994 LOperand* temp2() { return temps_[1]; }
1996 DECLARE_CONCRETE_INSTRUCTION(NumberTagU, "number-tag-u")
2000 class LNumberTagD final : public LTemplateInstruction<1, 1, 2> {
2002 LNumberTagD(LOperand* value, LOperand* temp, LOperand* temp2) {
2008 LOperand* value() { return inputs_[0]; }
2009 LOperand* temp() { return temps_[0]; }
2010 LOperand* temp2() { return temps_[1]; }
2012 DECLARE_CONCRETE_INSTRUCTION(NumberTagD, "number-tag-d")
2013 DECLARE_HYDROGEN_ACCESSOR(Change)
2017 class LDoubleToSmi final : public LTemplateInstruction<1, 1, 0> {
2019 explicit LDoubleToSmi(LOperand* value) {
2023 LOperand* value() { return inputs_[0]; }
2025 DECLARE_CONCRETE_INSTRUCTION(DoubleToSmi, "double-to-smi")
2026 DECLARE_HYDROGEN_ACCESSOR(UnaryOperation)
2028 bool truncating() { return hydrogen()->CanTruncateToInt32(); }
2032 // Sometimes truncating conversion from a tagged value to an int32.
2033 class LDoubleToI final : public LTemplateInstruction<1, 1, 0> {
2035 explicit LDoubleToI(LOperand* value) {
2039 LOperand* value() { return inputs_[0]; }
2041 DECLARE_CONCRETE_INSTRUCTION(DoubleToI, "double-to-i")
2042 DECLARE_HYDROGEN_ACCESSOR(UnaryOperation)
2044 bool truncating() { return hydrogen()->CanTruncateToInt32(); }
2048 // Truncating conversion from a tagged value to an int32.
2049 class LTaggedToI final : public LTemplateInstruction<1, 1, 2> {
2051 LTaggedToI(LOperand* value,
2059 LOperand* value() { return inputs_[0]; }
2060 LOperand* temp() { return temps_[0]; }
2061 LOperand* temp2() { return temps_[1]; }
2063 DECLARE_CONCRETE_INSTRUCTION(TaggedToI, "tagged-to-i")
2064 DECLARE_HYDROGEN_ACCESSOR(Change)
2066 bool truncating() { return hydrogen()->CanTruncateToInt32(); }
2070 class LSmiTag final : public LTemplateInstruction<1, 1, 0> {
2072 explicit LSmiTag(LOperand* value) {
2076 LOperand* value() { return inputs_[0]; }
2078 DECLARE_CONCRETE_INSTRUCTION(SmiTag, "smi-tag")
2079 DECLARE_HYDROGEN_ACCESSOR(Change)
2083 class LNumberUntagD final : public LTemplateInstruction<1, 1, 0> {
2085 explicit LNumberUntagD(LOperand* value) {
2089 LOperand* value() { return inputs_[0]; }
2091 DECLARE_CONCRETE_INSTRUCTION(NumberUntagD, "double-untag")
2092 DECLARE_HYDROGEN_ACCESSOR(Change)
2096 class LSmiUntag final : public LTemplateInstruction<1, 1, 0> {
2098 LSmiUntag(LOperand* value, bool needs_check)
2099 : needs_check_(needs_check) {
2103 LOperand* value() { return inputs_[0]; }
2104 bool needs_check() const { return needs_check_; }
2106 DECLARE_CONCRETE_INSTRUCTION(SmiUntag, "smi-untag")
2113 class LStoreNamedField final : public LTemplateInstruction<0, 2, 1> {
2115 LStoreNamedField(LOperand* object, LOperand* value, LOperand* temp) {
2116 inputs_[0] = object;
2121 LOperand* object() { return inputs_[0]; }
2122 LOperand* value() { return inputs_[1]; }
2123 LOperand* temp() { return temps_[0]; }
2125 DECLARE_CONCRETE_INSTRUCTION(StoreNamedField, "store-named-field")
2126 DECLARE_HYDROGEN_ACCESSOR(StoreNamedField)
2128 void PrintDataTo(StringStream* stream) override;
2130 Representation representation() const {
2131 return hydrogen()->field_representation();
2136 class LStoreNamedGeneric final : public LTemplateInstruction<0, 3, 0> {
2138 LStoreNamedGeneric(LOperand* context, LOperand* object, LOperand* value) {
2139 inputs_[0] = context;
2140 inputs_[1] = object;
2144 LOperand* context() { return inputs_[0]; }
2145 LOperand* object() { return inputs_[1]; }
2146 LOperand* value() { return inputs_[2]; }
2148 DECLARE_CONCRETE_INSTRUCTION(StoreNamedGeneric, "store-named-generic")
2149 DECLARE_HYDROGEN_ACCESSOR(StoreNamedGeneric)
2151 void PrintDataTo(StringStream* stream) override;
2153 Handle<Object> name() const { return hydrogen()->name(); }
2154 LanguageMode language_mode() { return hydrogen()->language_mode(); }
2158 class LStoreKeyed final : public LTemplateInstruction<0, 3, 0> {
2160 LStoreKeyed(LOperand* object, LOperand* key, LOperand* value) {
2161 inputs_[0] = object;
2166 bool is_external() const { return hydrogen()->is_external(); }
2167 bool is_fixed_typed_array() const {
2168 return hydrogen()->is_fixed_typed_array();
2170 bool is_typed_elements() const {
2171 return is_external() || is_fixed_typed_array();
2173 LOperand* elements() { return inputs_[0]; }
2174 LOperand* key() { return inputs_[1]; }
2175 LOperand* value() { return inputs_[2]; }
2176 ElementsKind elements_kind() const {
2177 return hydrogen()->elements_kind();
2180 DECLARE_CONCRETE_INSTRUCTION(StoreKeyed, "store-keyed")
2181 DECLARE_HYDROGEN_ACCESSOR(StoreKeyed)
2183 void PrintDataTo(StringStream* stream) override;
2184 bool NeedsCanonicalization() { return hydrogen()->NeedsCanonicalization(); }
2185 uint32_t base_offset() const { return hydrogen()->base_offset(); }
2189 class LStoreKeyedGeneric final : public LTemplateInstruction<0, 4, 0> {
2191 LStoreKeyedGeneric(LOperand* context,
2195 inputs_[0] = context;
2201 LOperand* context() { return inputs_[0]; }
2202 LOperand* object() { return inputs_[1]; }
2203 LOperand* key() { return inputs_[2]; }
2204 LOperand* value() { return inputs_[3]; }
2206 DECLARE_CONCRETE_INSTRUCTION(StoreKeyedGeneric, "store-keyed-generic")
2207 DECLARE_HYDROGEN_ACCESSOR(StoreKeyedGeneric)
2209 void PrintDataTo(StringStream* stream) override;
2211 LanguageMode language_mode() { return hydrogen()->language_mode(); }
2215 class LTransitionElementsKind final : public LTemplateInstruction<0, 2, 1> {
2217 LTransitionElementsKind(LOperand* object,
2219 LOperand* new_map_temp) {
2220 inputs_[0] = object;
2221 inputs_[1] = context;
2222 temps_[0] = new_map_temp;
2225 LOperand* context() { return inputs_[1]; }
2226 LOperand* object() { return inputs_[0]; }
2227 LOperand* new_map_temp() { return temps_[0]; }
2229 DECLARE_CONCRETE_INSTRUCTION(TransitionElementsKind,
2230 "transition-elements-kind")
2231 DECLARE_HYDROGEN_ACCESSOR(TransitionElementsKind)
2233 void PrintDataTo(StringStream* stream) override;
2235 Handle<Map> original_map() { return hydrogen()->original_map().handle(); }
2236 Handle<Map> transitioned_map() {
2237 return hydrogen()->transitioned_map().handle();
2239 ElementsKind from_kind() { return hydrogen()->from_kind(); }
2240 ElementsKind to_kind() { return hydrogen()->to_kind(); }
2244 class LTrapAllocationMemento final : public LTemplateInstruction<0, 1, 1> {
2246 LTrapAllocationMemento(LOperand* object,
2248 inputs_[0] = object;
2252 LOperand* object() { return inputs_[0]; }
2253 LOperand* temp() { return temps_[0]; }
2255 DECLARE_CONCRETE_INSTRUCTION(TrapAllocationMemento,
2256 "trap-allocation-memento")
2260 class LMaybeGrowElements final : public LTemplateInstruction<1, 5, 0> {
2262 LMaybeGrowElements(LOperand* context, LOperand* object, LOperand* elements,
2263 LOperand* key, LOperand* current_capacity) {
2264 inputs_[0] = context;
2265 inputs_[1] = object;
2266 inputs_[2] = elements;
2268 inputs_[4] = current_capacity;
2271 LOperand* context() { return inputs_[0]; }
2272 LOperand* object() { return inputs_[1]; }
2273 LOperand* elements() { return inputs_[2]; }
2274 LOperand* key() { return inputs_[3]; }
2275 LOperand* current_capacity() { return inputs_[4]; }
2277 DECLARE_HYDROGEN_ACCESSOR(MaybeGrowElements)
2278 DECLARE_CONCRETE_INSTRUCTION(MaybeGrowElements, "maybe-grow-elements")
2282 class LStringAdd final : public LTemplateInstruction<1, 3, 0> {
2284 LStringAdd(LOperand* context, LOperand* left, LOperand* right) {
2285 inputs_[0] = context;
2290 LOperand* context() { return inputs_[0]; }
2291 LOperand* left() { return inputs_[1]; }
2292 LOperand* right() { return inputs_[2]; }
2294 DECLARE_CONCRETE_INSTRUCTION(StringAdd, "string-add")
2295 DECLARE_HYDROGEN_ACCESSOR(StringAdd)
2299 class LStringCharCodeAt final : public LTemplateInstruction<1, 3, 0> {
2301 LStringCharCodeAt(LOperand* context, LOperand* string, LOperand* index) {
2302 inputs_[0] = context;
2303 inputs_[1] = string;
2307 LOperand* context() { return inputs_[0]; }
2308 LOperand* string() { return inputs_[1]; }
2309 LOperand* index() { return inputs_[2]; }
2311 DECLARE_CONCRETE_INSTRUCTION(StringCharCodeAt, "string-char-code-at")
2312 DECLARE_HYDROGEN_ACCESSOR(StringCharCodeAt)
2316 class LStringCharFromCode final : public LTemplateInstruction<1, 2, 0> {
2318 explicit LStringCharFromCode(LOperand* context, LOperand* char_code) {
2319 inputs_[0] = context;
2320 inputs_[1] = char_code;
2323 LOperand* context() { return inputs_[0]; }
2324 LOperand* char_code() { return inputs_[1]; }
2326 DECLARE_CONCRETE_INSTRUCTION(StringCharFromCode, "string-char-from-code")
2327 DECLARE_HYDROGEN_ACCESSOR(StringCharFromCode)
2331 class LCheckValue final : public LTemplateInstruction<0, 1, 0> {
2333 explicit LCheckValue(LOperand* value) {
2337 LOperand* value() { return inputs_[0]; }
2339 DECLARE_CONCRETE_INSTRUCTION(CheckValue, "check-value")
2340 DECLARE_HYDROGEN_ACCESSOR(CheckValue)
2344 class LCheckArrayBufferNotNeutered final
2345 : public LTemplateInstruction<0, 1, 0> {
2347 explicit LCheckArrayBufferNotNeutered(LOperand* view) { inputs_[0] = view; }
2349 LOperand* view() { return inputs_[0]; }
2351 DECLARE_CONCRETE_INSTRUCTION(CheckArrayBufferNotNeutered,
2352 "check-array-buffer-not-neutered")
2353 DECLARE_HYDROGEN_ACCESSOR(CheckArrayBufferNotNeutered)
2357 class LCheckInstanceType final : public LTemplateInstruction<0, 1, 0> {
2359 explicit LCheckInstanceType(LOperand* value) {
2363 LOperand* value() { return inputs_[0]; }
2365 DECLARE_CONCRETE_INSTRUCTION(CheckInstanceType, "check-instance-type")
2366 DECLARE_HYDROGEN_ACCESSOR(CheckInstanceType)
2370 class LCheckMaps final : public LTemplateInstruction<0, 1, 0> {
2372 explicit LCheckMaps(LOperand* value = NULL) {
2376 LOperand* value() { return inputs_[0]; }
2378 DECLARE_CONCRETE_INSTRUCTION(CheckMaps, "check-maps")
2379 DECLARE_HYDROGEN_ACCESSOR(CheckMaps)
2383 class LCheckSmi final : public LTemplateInstruction<1, 1, 0> {
2385 explicit LCheckSmi(LOperand* value) {
2389 LOperand* value() { return inputs_[0]; }
2391 DECLARE_CONCRETE_INSTRUCTION(CheckSmi, "check-smi")
2395 class LCheckNonSmi final : public LTemplateInstruction<0, 1, 0> {
2397 explicit LCheckNonSmi(LOperand* value) {
2401 LOperand* value() { return inputs_[0]; }
2403 DECLARE_CONCRETE_INSTRUCTION(CheckNonSmi, "check-non-smi")
2404 DECLARE_HYDROGEN_ACCESSOR(CheckHeapObject)
2408 class LClampDToUint8 final : public LTemplateInstruction<1, 1, 1> {
2410 LClampDToUint8(LOperand* unclamped, LOperand* temp) {
2411 inputs_[0] = unclamped;
2415 LOperand* unclamped() { return inputs_[0]; }
2416 LOperand* temp() { return temps_[0]; }
2418 DECLARE_CONCRETE_INSTRUCTION(ClampDToUint8, "clamp-d-to-uint8")
2422 class LClampIToUint8 final : public LTemplateInstruction<1, 1, 0> {
2424 explicit LClampIToUint8(LOperand* unclamped) {
2425 inputs_[0] = unclamped;
2428 LOperand* unclamped() { return inputs_[0]; }
2430 DECLARE_CONCRETE_INSTRUCTION(ClampIToUint8, "clamp-i-to-uint8")
2434 class LClampTToUint8 final : public LTemplateInstruction<1, 1, 1> {
2436 LClampTToUint8(LOperand* unclamped, LOperand* temp) {
2437 inputs_[0] = unclamped;
2441 LOperand* unclamped() { return inputs_[0]; }
2442 LOperand* temp() { return temps_[0]; }
2444 DECLARE_CONCRETE_INSTRUCTION(ClampTToUint8, "clamp-t-to-uint8")
2448 class LDoubleBits final : public LTemplateInstruction<1, 1, 0> {
2450 explicit LDoubleBits(LOperand* value) {
2454 LOperand* value() { return inputs_[0]; }
2456 DECLARE_CONCRETE_INSTRUCTION(DoubleBits, "double-bits")
2457 DECLARE_HYDROGEN_ACCESSOR(DoubleBits)
2461 class LConstructDouble final : public LTemplateInstruction<1, 2, 0> {
2463 LConstructDouble(LOperand* hi, LOperand* lo) {
2468 LOperand* hi() { return inputs_[0]; }
2469 LOperand* lo() { return inputs_[1]; }
2471 DECLARE_CONCRETE_INSTRUCTION(ConstructDouble, "construct-double")
2475 class LAllocate final : public LTemplateInstruction<1, 2, 2> {
2477 LAllocate(LOperand* context,
2481 inputs_[0] = context;
2487 LOperand* context() { return inputs_[0]; }
2488 LOperand* size() { return inputs_[1]; }
2489 LOperand* temp1() { return temps_[0]; }
2490 LOperand* temp2() { return temps_[1]; }
2492 DECLARE_CONCRETE_INSTRUCTION(Allocate, "allocate")
2493 DECLARE_HYDROGEN_ACCESSOR(Allocate)
2497 class LRegExpLiteral final : public LTemplateInstruction<1, 1, 0> {
2499 explicit LRegExpLiteral(LOperand* context) {
2500 inputs_[0] = context;
2503 LOperand* context() { return inputs_[0]; }
2505 DECLARE_CONCRETE_INSTRUCTION(RegExpLiteral, "regexp-literal")
2506 DECLARE_HYDROGEN_ACCESSOR(RegExpLiteral)
2510 class LFunctionLiteral final : public LTemplateInstruction<1, 1, 0> {
2512 explicit LFunctionLiteral(LOperand* context) {
2513 inputs_[0] = context;
2516 LOperand* context() { return inputs_[0]; }
2518 DECLARE_CONCRETE_INSTRUCTION(FunctionLiteral, "function-literal")
2519 DECLARE_HYDROGEN_ACCESSOR(FunctionLiteral)
2523 class LToFastProperties final : public LTemplateInstruction<1, 1, 0> {
2525 explicit LToFastProperties(LOperand* value) {
2529 LOperand* value() { return inputs_[0]; }
2531 DECLARE_CONCRETE_INSTRUCTION(ToFastProperties, "to-fast-properties")
2532 DECLARE_HYDROGEN_ACCESSOR(ToFastProperties)
2536 class LTypeof final : public LTemplateInstruction<1, 2, 0> {
2538 LTypeof(LOperand* context, LOperand* value) {
2539 inputs_[0] = context;
2543 LOperand* context() { return inputs_[0]; }
2544 LOperand* value() { return inputs_[1]; }
2546 DECLARE_CONCRETE_INSTRUCTION(Typeof, "typeof")
2550 class LTypeofIsAndBranch final : public LControlInstruction<1, 0> {
2552 explicit LTypeofIsAndBranch(LOperand* value) {
2556 LOperand* value() { return inputs_[0]; }
2558 DECLARE_CONCRETE_INSTRUCTION(TypeofIsAndBranch, "typeof-is-and-branch")
2559 DECLARE_HYDROGEN_ACCESSOR(TypeofIsAndBranch)
2561 Handle<String> type_literal() { return hydrogen()->type_literal(); }
2563 void PrintDataTo(StringStream* stream) override;
2567 class LIsConstructCallAndBranch final : public LControlInstruction<0, 1> {
2569 explicit LIsConstructCallAndBranch(LOperand* temp) {
2573 LOperand* temp() { return temps_[0]; }
2575 DECLARE_CONCRETE_INSTRUCTION(IsConstructCallAndBranch,
2576 "is-construct-call-and-branch")
2580 class LOsrEntry final : public LTemplateInstruction<0, 0, 0> {
2584 bool HasInterestingComment(LCodeGen* gen) const override { return false; }
2585 DECLARE_CONCRETE_INSTRUCTION(OsrEntry, "osr-entry")
2589 class LStackCheck final : public LTemplateInstruction<0, 1, 0> {
2591 explicit LStackCheck(LOperand* context) {
2592 inputs_[0] = context;
2595 LOperand* context() { return inputs_[0]; }
2597 DECLARE_CONCRETE_INSTRUCTION(StackCheck, "stack-check")
2598 DECLARE_HYDROGEN_ACCESSOR(StackCheck)
2600 Label* done_label() { return &done_label_; }
2607 class LForInPrepareMap final : public LTemplateInstruction<1, 2, 0> {
2609 LForInPrepareMap(LOperand* context, LOperand* object) {
2610 inputs_[0] = context;
2611 inputs_[1] = object;
2614 LOperand* context() { return inputs_[0]; }
2615 LOperand* object() { return inputs_[1]; }
2617 DECLARE_CONCRETE_INSTRUCTION(ForInPrepareMap, "for-in-prepare-map")
2621 class LForInCacheArray final : public LTemplateInstruction<1, 1, 0> {
2623 explicit LForInCacheArray(LOperand* map) {
2627 LOperand* map() { return inputs_[0]; }
2629 DECLARE_CONCRETE_INSTRUCTION(ForInCacheArray, "for-in-cache-array")
2632 return HForInCacheArray::cast(this->hydrogen_value())->idx();
2637 class LCheckMapValue final : public LTemplateInstruction<0, 2, 0> {
2639 LCheckMapValue(LOperand* value, LOperand* map) {
2644 LOperand* value() { return inputs_[0]; }
2645 LOperand* map() { return inputs_[1]; }
2647 DECLARE_CONCRETE_INSTRUCTION(CheckMapValue, "check-map-value")
2651 class LLoadFieldByIndex final : public LTemplateInstruction<1, 2, 0> {
2653 LLoadFieldByIndex(LOperand* object, LOperand* index) {
2654 inputs_[0] = object;
2658 LOperand* object() { return inputs_[0]; }
2659 LOperand* index() { return inputs_[1]; }
2661 DECLARE_CONCRETE_INSTRUCTION(LoadFieldByIndex, "load-field-by-index")
2665 class LStoreFrameContext: public LTemplateInstruction<0, 1, 0> {
2667 explicit LStoreFrameContext(LOperand* context) {
2668 inputs_[0] = context;
2671 LOperand* context() { return inputs_[0]; }
2673 DECLARE_CONCRETE_INSTRUCTION(StoreFrameContext, "store-frame-context")
2677 class LAllocateBlockContext: public LTemplateInstruction<1, 2, 0> {
2679 LAllocateBlockContext(LOperand* context, LOperand* function) {
2680 inputs_[0] = context;
2681 inputs_[1] = function;
2684 LOperand* context() { return inputs_[0]; }
2685 LOperand* function() { return inputs_[1]; }
2687 Handle<ScopeInfo> scope_info() { return hydrogen()->scope_info(); }
2689 DECLARE_CONCRETE_INSTRUCTION(AllocateBlockContext, "allocate-block-context")
2690 DECLARE_HYDROGEN_ACCESSOR(AllocateBlockContext)
2694 class LChunkBuilder;
2695 class LPlatformChunk final : public LChunk {
2697 LPlatformChunk(CompilationInfo* info, HGraph* graph)
2698 : LChunk(info, graph) { }
2700 int GetNextSpillIndex(RegisterKind kind);
2701 LOperand* GetNextSpillSlot(RegisterKind kind);
2705 class LChunkBuilder final : public LChunkBuilderBase {
2707 LChunkBuilder(CompilationInfo* info, HGraph* graph, LAllocator* allocator)
2708 : LChunkBuilderBase(info, graph),
2709 current_instruction_(NULL),
2710 current_block_(NULL),
2712 allocator_(allocator) {}
2714 // Build the sequence for the graph.
2715 LPlatformChunk* Build();
2717 // Declare methods that deal with the individual node types.
2718 #define DECLARE_DO(type) LInstruction* Do##type(H##type* node);
2719 HYDROGEN_CONCRETE_INSTRUCTION_LIST(DECLARE_DO)
2722 LInstruction* DoMultiplyAdd(HMul* mul, HValue* addend);
2724 static bool HasMagicNumberForDivisor(int32_t divisor);
2726 LInstruction* DoMathFloor(HUnaryMathOperation* instr);
2727 LInstruction* DoMathRound(HUnaryMathOperation* instr);
2728 LInstruction* DoMathFround(HUnaryMathOperation* instr);
2729 LInstruction* DoMathAbs(HUnaryMathOperation* instr);
2730 LInstruction* DoMathLog(HUnaryMathOperation* instr);
2731 LInstruction* DoMathExp(HUnaryMathOperation* instr);
2732 LInstruction* DoMathSqrt(HUnaryMathOperation* instr);
2733 LInstruction* DoMathPowHalf(HUnaryMathOperation* instr);
2734 LInstruction* DoMathClz32(HUnaryMathOperation* instr);
2735 LInstruction* DoDivByPowerOf2I(HDiv* instr);
2736 LInstruction* DoDivByConstI(HDiv* instr);
2737 LInstruction* DoDivI(HDiv* instr);
2738 LInstruction* DoModByPowerOf2I(HMod* instr);
2739 LInstruction* DoModByConstI(HMod* instr);
2740 LInstruction* DoModI(HMod* instr);
2741 LInstruction* DoFlooringDivByPowerOf2I(HMathFloorOfDiv* instr);
2742 LInstruction* DoFlooringDivByConstI(HMathFloorOfDiv* instr);
2743 LInstruction* DoFlooringDivI(HMathFloorOfDiv* instr);
2746 // Methods for getting operands for Use / Define / Temp.
2747 LUnallocated* ToUnallocated(Register reg);
2748 LUnallocated* ToUnallocated(DoubleRegister reg);
2750 // Methods for setting up define-use relationships.
2751 MUST_USE_RESULT LOperand* Use(HValue* value, LUnallocated* operand);
2752 MUST_USE_RESULT LOperand* UseFixed(HValue* value, Register fixed_register);
2753 MUST_USE_RESULT LOperand* UseFixedDouble(HValue* value,
2754 DoubleRegister fixed_register);
2756 // A value that is guaranteed to be allocated to a register.
2757 // Operand created by UseRegister is guaranteed to be live until the end of
2758 // instruction. This means that register allocator will not reuse it's
2759 // register for any other operand inside instruction.
2760 // Operand created by UseRegisterAtStart is guaranteed to be live only at
2761 // instruction start. Register allocator is free to assign the same register
2762 // to some other operand used inside instruction (i.e. temporary or
2764 MUST_USE_RESULT LOperand* UseRegister(HValue* value);
2765 MUST_USE_RESULT LOperand* UseRegisterAtStart(HValue* value);
2767 // An input operand in a register that may be trashed.
2768 MUST_USE_RESULT LOperand* UseTempRegister(HValue* value);
2770 // An input operand in a register or stack slot.
2771 MUST_USE_RESULT LOperand* Use(HValue* value);
2772 MUST_USE_RESULT LOperand* UseAtStart(HValue* value);
2774 // An input operand in a register, stack slot or a constant operand.
2775 MUST_USE_RESULT LOperand* UseOrConstant(HValue* value);
2776 MUST_USE_RESULT LOperand* UseOrConstantAtStart(HValue* value);
2778 // An input operand in a register or a constant operand.
2779 MUST_USE_RESULT LOperand* UseRegisterOrConstant(HValue* value);
2780 MUST_USE_RESULT LOperand* UseRegisterOrConstantAtStart(HValue* value);
2782 // An input operand in a constant operand.
2783 MUST_USE_RESULT LOperand* UseConstant(HValue* value);
2785 // An input operand in register, stack slot or a constant operand.
2786 // Will not be moved to a register even if one is freely available.
2787 MUST_USE_RESULT LOperand* UseAny(HValue* value) override;
2789 // Temporary operand that must be in a register.
2790 MUST_USE_RESULT LUnallocated* TempRegister();
2791 MUST_USE_RESULT LUnallocated* TempDoubleRegister();
2792 MUST_USE_RESULT LOperand* FixedTemp(Register reg);
2793 MUST_USE_RESULT LOperand* FixedTemp(DoubleRegister reg);
2795 // Methods for setting up define-use relationships.
2796 // Return the same instruction that they are passed.
2797 LInstruction* Define(LTemplateResultInstruction<1>* instr,
2798 LUnallocated* result);
2799 LInstruction* DefineAsRegister(LTemplateResultInstruction<1>* instr);
2800 LInstruction* DefineAsSpilled(LTemplateResultInstruction<1>* instr,
2802 LInstruction* DefineSameAsFirst(LTemplateResultInstruction<1>* instr);
2803 LInstruction* DefineFixed(LTemplateResultInstruction<1>* instr,
2805 LInstruction* DefineFixedDouble(LTemplateResultInstruction<1>* instr,
2806 DoubleRegister reg);
2807 LInstruction* AssignEnvironment(LInstruction* instr);
2808 LInstruction* AssignPointerMap(LInstruction* instr);
2810 enum CanDeoptimize { CAN_DEOPTIMIZE_EAGERLY, CANNOT_DEOPTIMIZE_EAGERLY };
2812 // By default we assume that instruction sequences generated for calls
2813 // cannot deoptimize eagerly and we do not attach environment to this
2815 LInstruction* MarkAsCall(
2816 LInstruction* instr,
2817 HInstruction* hinstr,
2818 CanDeoptimize can_deoptimize = CANNOT_DEOPTIMIZE_EAGERLY);
2820 void VisitInstruction(HInstruction* current);
2821 void AddInstruction(LInstruction* instr, HInstruction* current);
2823 void DoBasicBlock(HBasicBlock* block, HBasicBlock* next_block);
2824 LInstruction* DoBit(Token::Value op, HBitwiseBinaryOperation* instr);
2825 LInstruction* DoShift(Token::Value op, HBitwiseBinaryOperation* instr);
2826 LInstruction* DoArithmeticD(Token::Value op,
2827 HArithmeticBinaryOperation* instr);
2828 LInstruction* DoArithmeticT(Token::Value op,
2829 HBinaryOperation* instr);
2831 HInstruction* current_instruction_;
2832 HBasicBlock* current_block_;
2833 HBasicBlock* next_block_;
2834 LAllocator* allocator_;
2836 DISALLOW_COPY_AND_ASSIGN(LChunkBuilder);
2839 #undef DECLARE_HYDROGEN_ACCESSOR
2840 #undef DECLARE_CONCRETE_INSTRUCTION
2842 } } // namespace v8::internal
2844 #endif // V8_MIPS_LITHIUM_MIPS_H_