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(HasInPrototypeChainAndBranch) \
87 V(HasInstanceTypeAndBranch) \
88 V(InnerAllocatedObject) \
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 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 Strength strength() { return hydrogen()->strength(); }
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() const { return inputs_[0]; }
1172 LOperand* left() const { return inputs_[1]; }
1173 LOperand* right() const { return inputs_[2]; }
1175 DECLARE_CONCRETE_INSTRUCTION(InstanceOf, "instance-of")
1179 class LHasInPrototypeChainAndBranch final : public LControlInstruction<2, 0> {
1181 LHasInPrototypeChainAndBranch(LOperand* object, LOperand* prototype) {
1182 inputs_[0] = object;
1183 inputs_[1] = prototype;
1186 LOperand* object() const { return inputs_[0]; }
1187 LOperand* prototype() const { return inputs_[1]; }
1189 DECLARE_CONCRETE_INSTRUCTION(HasInPrototypeChainAndBranch,
1190 "has-in-prototype-chain-and-branch")
1191 DECLARE_HYDROGEN_ACCESSOR(HasInPrototypeChainAndBranch)
1195 class LBoundsCheck final : public LTemplateInstruction<0, 2, 0> {
1197 LBoundsCheck(LOperand* index, LOperand* length) {
1199 inputs_[1] = length;
1202 LOperand* index() { return inputs_[0]; }
1203 LOperand* length() { return inputs_[1]; }
1205 DECLARE_CONCRETE_INSTRUCTION(BoundsCheck, "bounds-check")
1206 DECLARE_HYDROGEN_ACCESSOR(BoundsCheck)
1210 class LBitI final : public LTemplateInstruction<1, 2, 0> {
1212 LBitI(LOperand* left, LOperand* right) {
1217 LOperand* left() { return inputs_[0]; }
1218 LOperand* right() { return inputs_[1]; }
1220 Token::Value op() const { return hydrogen()->op(); }
1222 DECLARE_CONCRETE_INSTRUCTION(BitI, "bit-i")
1223 DECLARE_HYDROGEN_ACCESSOR(Bitwise)
1227 class LShiftI final : public LTemplateInstruction<1, 2, 0> {
1229 LShiftI(Token::Value op, LOperand* left, LOperand* right, bool can_deopt)
1230 : op_(op), can_deopt_(can_deopt) {
1235 Token::Value op() const { return op_; }
1236 LOperand* left() { return inputs_[0]; }
1237 LOperand* right() { return inputs_[1]; }
1238 bool can_deopt() const { return can_deopt_; }
1240 DECLARE_CONCRETE_INSTRUCTION(ShiftI, "shift-i")
1248 class LSubI final : public LTemplateInstruction<1, 2, 0> {
1250 LSubI(LOperand* left, LOperand* right) {
1255 LOperand* left() { return inputs_[0]; }
1256 LOperand* right() { return inputs_[1]; }
1258 DECLARE_CONCRETE_INSTRUCTION(SubI, "sub-i")
1259 DECLARE_HYDROGEN_ACCESSOR(Sub)
1263 class LConstantI final : public LTemplateInstruction<1, 0, 0> {
1265 DECLARE_CONCRETE_INSTRUCTION(ConstantI, "constant-i")
1266 DECLARE_HYDROGEN_ACCESSOR(Constant)
1268 int32_t value() const { return hydrogen()->Integer32Value(); }
1272 class LConstantS final : public LTemplateInstruction<1, 0, 0> {
1274 DECLARE_CONCRETE_INSTRUCTION(ConstantS, "constant-s")
1275 DECLARE_HYDROGEN_ACCESSOR(Constant)
1277 Smi* value() const { return Smi::FromInt(hydrogen()->Integer32Value()); }
1281 class LConstantD final : public LTemplateInstruction<1, 0, 0> {
1283 DECLARE_CONCRETE_INSTRUCTION(ConstantD, "constant-d")
1284 DECLARE_HYDROGEN_ACCESSOR(Constant)
1286 double value() const { return hydrogen()->DoubleValue(); }
1287 uint64_t bits() const { return hydrogen()->DoubleValueAsBits(); }
1291 class LConstantE final : public LTemplateInstruction<1, 0, 0> {
1293 DECLARE_CONCRETE_INSTRUCTION(ConstantE, "constant-e")
1294 DECLARE_HYDROGEN_ACCESSOR(Constant)
1296 ExternalReference value() const {
1297 return hydrogen()->ExternalReferenceValue();
1302 class LConstantT final : public LTemplateInstruction<1, 0, 0> {
1304 DECLARE_CONCRETE_INSTRUCTION(ConstantT, "constant-t")
1305 DECLARE_HYDROGEN_ACCESSOR(Constant)
1307 Handle<Object> value(Isolate* isolate) const {
1308 return hydrogen()->handle(isolate);
1313 class LBranch final : public LControlInstruction<1, 0> {
1315 explicit LBranch(LOperand* value) {
1319 LOperand* value() { return inputs_[0]; }
1321 DECLARE_CONCRETE_INSTRUCTION(Branch, "branch")
1322 DECLARE_HYDROGEN_ACCESSOR(Branch)
1324 void PrintDataTo(StringStream* stream) override;
1328 class LCmpMapAndBranch final : public LControlInstruction<1, 1> {
1330 LCmpMapAndBranch(LOperand* value, LOperand* temp) {
1335 LOperand* value() { return inputs_[0]; }
1336 LOperand* temp() { return temps_[0]; }
1338 DECLARE_CONCRETE_INSTRUCTION(CmpMapAndBranch, "cmp-map-and-branch")
1339 DECLARE_HYDROGEN_ACCESSOR(CompareMap)
1341 Handle<Map> map() const { return hydrogen()->map().handle(); }
1345 class LMapEnumLength final : public LTemplateInstruction<1, 1, 0> {
1347 explicit LMapEnumLength(LOperand* value) {
1351 LOperand* value() { return inputs_[0]; }
1353 DECLARE_CONCRETE_INSTRUCTION(MapEnumLength, "map-enum-length")
1357 class LDateField final : public LTemplateInstruction<1, 1, 1> {
1359 LDateField(LOperand* date, LOperand* temp, Smi* index) : index_(index) {
1364 LOperand* date() { return inputs_[0]; }
1365 LOperand* temp() { return temps_[0]; }
1366 Smi* index() const { return index_; }
1368 DECLARE_CONCRETE_INSTRUCTION(DateField, "date-field")
1369 DECLARE_HYDROGEN_ACCESSOR(DateField)
1376 class LSeqStringGetChar final : public LTemplateInstruction<1, 2, 0> {
1378 LSeqStringGetChar(LOperand* string, LOperand* index) {
1379 inputs_[0] = string;
1383 LOperand* string() const { return inputs_[0]; }
1384 LOperand* index() const { return inputs_[1]; }
1386 DECLARE_CONCRETE_INSTRUCTION(SeqStringGetChar, "seq-string-get-char")
1387 DECLARE_HYDROGEN_ACCESSOR(SeqStringGetChar)
1391 class LSeqStringSetChar final : public LTemplateInstruction<1, 4, 0> {
1393 LSeqStringSetChar(LOperand* context,
1397 inputs_[0] = context;
1398 inputs_[1] = string;
1403 LOperand* string() { return inputs_[1]; }
1404 LOperand* index() { return inputs_[2]; }
1405 LOperand* value() { return inputs_[3]; }
1407 DECLARE_CONCRETE_INSTRUCTION(SeqStringSetChar, "seq-string-set-char")
1408 DECLARE_HYDROGEN_ACCESSOR(SeqStringSetChar)
1412 class LAddI final : public LTemplateInstruction<1, 2, 0> {
1414 LAddI(LOperand* left, LOperand* right) {
1419 LOperand* left() { return inputs_[0]; }
1420 LOperand* right() { return inputs_[1]; }
1422 DECLARE_CONCRETE_INSTRUCTION(AddI, "add-i")
1423 DECLARE_HYDROGEN_ACCESSOR(Add)
1427 class LMathMinMax final : public LTemplateInstruction<1, 2, 0> {
1429 LMathMinMax(LOperand* left, LOperand* right) {
1434 LOperand* left() { return inputs_[0]; }
1435 LOperand* right() { return inputs_[1]; }
1437 DECLARE_CONCRETE_INSTRUCTION(MathMinMax, "math-min-max")
1438 DECLARE_HYDROGEN_ACCESSOR(MathMinMax)
1442 class LPower final : public LTemplateInstruction<1, 2, 0> {
1444 LPower(LOperand* left, LOperand* right) {
1449 LOperand* left() { return inputs_[0]; }
1450 LOperand* right() { return inputs_[1]; }
1452 DECLARE_CONCRETE_INSTRUCTION(Power, "power")
1453 DECLARE_HYDROGEN_ACCESSOR(Power)
1457 class LArithmeticD final : public LTemplateInstruction<1, 2, 0> {
1459 LArithmeticD(Token::Value op, LOperand* left, LOperand* right)
1465 Token::Value op() const { return op_; }
1466 LOperand* left() { return inputs_[0]; }
1467 LOperand* right() { return inputs_[1]; }
1469 Opcode opcode() const override { return LInstruction::kArithmeticD; }
1470 void CompileToNative(LCodeGen* generator) override;
1471 const char* Mnemonic() const override;
1478 class LArithmeticT final : public LTemplateInstruction<1, 3, 0> {
1480 LArithmeticT(Token::Value op,
1485 inputs_[0] = context;
1490 LOperand* context() { return inputs_[0]; }
1491 LOperand* left() { return inputs_[1]; }
1492 LOperand* right() { return inputs_[2]; }
1493 Token::Value op() const { return op_; }
1495 Opcode opcode() const final { return LInstruction::kArithmeticT; }
1496 void CompileToNative(LCodeGen* generator) override;
1497 const char* Mnemonic() const override;
1499 DECLARE_HYDROGEN_ACCESSOR(BinaryOperation)
1501 Strength strength() { return hydrogen()->strength(); }
1508 class LReturn final : public LTemplateInstruction<0, 3, 0> {
1510 LReturn(LOperand* value, LOperand* context, LOperand* parameter_count) {
1512 inputs_[1] = context;
1513 inputs_[2] = parameter_count;
1516 LOperand* value() { return inputs_[0]; }
1518 bool has_constant_parameter_count() {
1519 return parameter_count()->IsConstantOperand();
1521 LConstantOperand* constant_parameter_count() {
1522 DCHECK(has_constant_parameter_count());
1523 return LConstantOperand::cast(parameter_count());
1525 LOperand* parameter_count() { return inputs_[2]; }
1527 DECLARE_CONCRETE_INSTRUCTION(Return, "return")
1531 class LLoadNamedField final : public LTemplateInstruction<1, 1, 0> {
1533 explicit LLoadNamedField(LOperand* object) {
1534 inputs_[0] = object;
1537 LOperand* object() { return inputs_[0]; }
1539 DECLARE_CONCRETE_INSTRUCTION(LoadNamedField, "load-named-field")
1540 DECLARE_HYDROGEN_ACCESSOR(LoadNamedField)
1544 class LLoadNamedGeneric final : public LTemplateInstruction<1, 2, 1> {
1546 LLoadNamedGeneric(LOperand* context, LOperand* object, LOperand* vector) {
1547 inputs_[0] = context;
1548 inputs_[1] = object;
1552 LOperand* context() { return inputs_[0]; }
1553 LOperand* object() { return inputs_[1]; }
1554 LOperand* temp_vector() { return temps_[0]; }
1556 DECLARE_CONCRETE_INSTRUCTION(LoadNamedGeneric, "load-named-generic")
1557 DECLARE_HYDROGEN_ACCESSOR(LoadNamedGeneric)
1559 Handle<Object> name() const { return hydrogen()->name(); }
1563 class LLoadFunctionPrototype final : public LTemplateInstruction<1, 1, 0> {
1565 explicit LLoadFunctionPrototype(LOperand* function) {
1566 inputs_[0] = function;
1569 LOperand* function() { return inputs_[0]; }
1571 DECLARE_CONCRETE_INSTRUCTION(LoadFunctionPrototype, "load-function-prototype")
1572 DECLARE_HYDROGEN_ACCESSOR(LoadFunctionPrototype)
1576 class LLoadRoot final : public LTemplateInstruction<1, 0, 0> {
1578 DECLARE_CONCRETE_INSTRUCTION(LoadRoot, "load-root")
1579 DECLARE_HYDROGEN_ACCESSOR(LoadRoot)
1581 Heap::RootListIndex index() const { return hydrogen()->index(); }
1585 class LLoadKeyed final : public LTemplateInstruction<1, 2, 0> {
1587 LLoadKeyed(LOperand* elements, LOperand* key) {
1588 inputs_[0] = elements;
1592 LOperand* elements() { return inputs_[0]; }
1593 LOperand* key() { return inputs_[1]; }
1594 ElementsKind elements_kind() const {
1595 return hydrogen()->elements_kind();
1597 bool is_fixed_typed_array() const {
1598 return hydrogen()->is_fixed_typed_array();
1601 DECLARE_CONCRETE_INSTRUCTION(LoadKeyed, "load-keyed")
1602 DECLARE_HYDROGEN_ACCESSOR(LoadKeyed)
1604 void PrintDataTo(StringStream* stream) override;
1605 uint32_t base_offset() const { return hydrogen()->base_offset(); }
1609 class LLoadKeyedGeneric final : public LTemplateInstruction<1, 3, 1> {
1611 LLoadKeyedGeneric(LOperand* context, LOperand* object, LOperand* key,
1613 inputs_[0] = context;
1614 inputs_[1] = object;
1619 LOperand* context() { return inputs_[0]; }
1620 LOperand* object() { return inputs_[1]; }
1621 LOperand* key() { return inputs_[2]; }
1622 LOperand* temp_vector() { return temps_[0]; }
1624 DECLARE_CONCRETE_INSTRUCTION(LoadKeyedGeneric, "load-keyed-generic")
1625 DECLARE_HYDROGEN_ACCESSOR(LoadKeyedGeneric)
1629 class LLoadGlobalGeneric final : public LTemplateInstruction<1, 2, 1> {
1631 LLoadGlobalGeneric(LOperand* context, LOperand* global_object,
1633 inputs_[0] = context;
1634 inputs_[1] = global_object;
1638 LOperand* context() { return inputs_[0]; }
1639 LOperand* global_object() { return inputs_[1]; }
1640 LOperand* temp_vector() { return temps_[0]; }
1642 DECLARE_CONCRETE_INSTRUCTION(LoadGlobalGeneric, "load-global-generic")
1643 DECLARE_HYDROGEN_ACCESSOR(LoadGlobalGeneric)
1645 Handle<Object> name() const { return hydrogen()->name(); }
1646 TypeofMode typeof_mode() const { return hydrogen()->typeof_mode(); }
1650 class LLoadGlobalViaContext final : public LTemplateInstruction<1, 1, 1> {
1652 explicit LLoadGlobalViaContext(LOperand* context) { inputs_[0] = context; }
1654 DECLARE_CONCRETE_INSTRUCTION(LoadGlobalViaContext, "load-global-via-context")
1655 DECLARE_HYDROGEN_ACCESSOR(LoadGlobalViaContext)
1657 void PrintDataTo(StringStream* stream) override;
1659 LOperand* context() { return inputs_[0]; }
1661 int depth() const { return hydrogen()->depth(); }
1662 int slot_index() const { return hydrogen()->slot_index(); }
1666 class LLoadContextSlot final : public LTemplateInstruction<1, 1, 0> {
1668 explicit LLoadContextSlot(LOperand* context) {
1669 inputs_[0] = context;
1672 LOperand* context() { return inputs_[0]; }
1674 DECLARE_CONCRETE_INSTRUCTION(LoadContextSlot, "load-context-slot")
1675 DECLARE_HYDROGEN_ACCESSOR(LoadContextSlot)
1677 int slot_index() { return hydrogen()->slot_index(); }
1679 void PrintDataTo(StringStream* stream) override;
1683 class LStoreContextSlot final : public LTemplateInstruction<0, 2, 0> {
1685 LStoreContextSlot(LOperand* context, LOperand* value) {
1686 inputs_[0] = context;
1690 LOperand* context() { return inputs_[0]; }
1691 LOperand* value() { return inputs_[1]; }
1693 DECLARE_CONCRETE_INSTRUCTION(StoreContextSlot, "store-context-slot")
1694 DECLARE_HYDROGEN_ACCESSOR(StoreContextSlot)
1696 int slot_index() { return hydrogen()->slot_index(); }
1698 void PrintDataTo(StringStream* stream) override;
1702 class LPushArgument final : public LTemplateInstruction<0, 1, 0> {
1704 explicit LPushArgument(LOperand* value) {
1708 LOperand* value() { return inputs_[0]; }
1710 DECLARE_CONCRETE_INSTRUCTION(PushArgument, "push-argument")
1714 class LDrop final : public LTemplateInstruction<0, 0, 0> {
1716 explicit LDrop(int count) : count_(count) { }
1718 int count() const { return count_; }
1720 DECLARE_CONCRETE_INSTRUCTION(Drop, "drop")
1727 class LStoreCodeEntry final : public LTemplateInstruction<0, 2, 0> {
1729 LStoreCodeEntry(LOperand* function, LOperand* code_object) {
1730 inputs_[0] = function;
1731 inputs_[1] = code_object;
1734 LOperand* function() { return inputs_[0]; }
1735 LOperand* code_object() { return inputs_[1]; }
1737 void PrintDataTo(StringStream* stream) override;
1739 DECLARE_CONCRETE_INSTRUCTION(StoreCodeEntry, "store-code-entry")
1740 DECLARE_HYDROGEN_ACCESSOR(StoreCodeEntry)
1744 class LInnerAllocatedObject final : public LTemplateInstruction<1, 2, 0> {
1746 LInnerAllocatedObject(LOperand* base_object, LOperand* offset) {
1747 inputs_[0] = base_object;
1748 inputs_[1] = offset;
1751 LOperand* base_object() const { return inputs_[0]; }
1752 LOperand* offset() const { return inputs_[1]; }
1754 void PrintDataTo(StringStream* stream) override;
1756 DECLARE_CONCRETE_INSTRUCTION(InnerAllocatedObject, "inner-allocated-object")
1760 class LThisFunction final : public LTemplateInstruction<1, 0, 0> {
1762 DECLARE_CONCRETE_INSTRUCTION(ThisFunction, "this-function")
1763 DECLARE_HYDROGEN_ACCESSOR(ThisFunction)
1767 class LContext final : public LTemplateInstruction<1, 0, 0> {
1769 DECLARE_CONCRETE_INSTRUCTION(Context, "context")
1770 DECLARE_HYDROGEN_ACCESSOR(Context)
1774 class LDeclareGlobals final : public LTemplateInstruction<0, 1, 0> {
1776 explicit LDeclareGlobals(LOperand* context) {
1777 inputs_[0] = context;
1780 LOperand* context() { return inputs_[0]; }
1782 DECLARE_CONCRETE_INSTRUCTION(DeclareGlobals, "declare-globals")
1783 DECLARE_HYDROGEN_ACCESSOR(DeclareGlobals)
1787 class LCallJSFunction final : public LTemplateInstruction<1, 1, 0> {
1789 explicit LCallJSFunction(LOperand* function) {
1790 inputs_[0] = function;
1793 LOperand* function() { return inputs_[0]; }
1795 DECLARE_CONCRETE_INSTRUCTION(CallJSFunction, "call-js-function")
1796 DECLARE_HYDROGEN_ACCESSOR(CallJSFunction)
1798 void PrintDataTo(StringStream* stream) override;
1800 int arity() const { return hydrogen()->argument_count() - 1; }
1804 class LCallWithDescriptor final : public LTemplateResultInstruction<1> {
1806 LCallWithDescriptor(CallInterfaceDescriptor descriptor,
1807 const ZoneList<LOperand*>& operands, Zone* zone)
1808 : descriptor_(descriptor),
1809 inputs_(descriptor.GetRegisterParameterCount() +
1810 kImplicitRegisterParameterCount,
1812 DCHECK(descriptor.GetRegisterParameterCount() +
1813 kImplicitRegisterParameterCount ==
1815 inputs_.AddAll(operands, zone);
1818 LOperand* target() const { return inputs_[0]; }
1820 const CallInterfaceDescriptor descriptor() { return descriptor_; }
1822 DECLARE_HYDROGEN_ACCESSOR(CallWithDescriptor)
1824 // The target and context are passed as implicit parameters that are not
1825 // explicitly listed in the descriptor.
1826 static const int kImplicitRegisterParameterCount = 2;
1829 DECLARE_CONCRETE_INSTRUCTION(CallWithDescriptor, "call-with-descriptor")
1831 void PrintDataTo(StringStream* stream) override;
1833 int arity() const { return hydrogen()->argument_count() - 1; }
1835 CallInterfaceDescriptor descriptor_;
1836 ZoneList<LOperand*> inputs_;
1838 // Iterator support.
1839 int InputCount() final { return inputs_.length(); }
1840 LOperand* InputAt(int i) final { return inputs_[i]; }
1842 int TempCount() final { return 0; }
1843 LOperand* TempAt(int i) final { return NULL; }
1847 class LInvokeFunction final : public LTemplateInstruction<1, 2, 0> {
1849 LInvokeFunction(LOperand* context, LOperand* function) {
1850 inputs_[0] = context;
1851 inputs_[1] = function;
1854 LOperand* context() { return inputs_[0]; }
1855 LOperand* function() { return inputs_[1]; }
1857 DECLARE_CONCRETE_INSTRUCTION(InvokeFunction, "invoke-function")
1858 DECLARE_HYDROGEN_ACCESSOR(InvokeFunction)
1860 void PrintDataTo(StringStream* stream) override;
1862 int arity() const { return hydrogen()->argument_count() - 1; }
1866 class LCallFunction final : public LTemplateInstruction<1, 2, 2> {
1868 LCallFunction(LOperand* context, LOperand* function, LOperand* slot,
1870 inputs_[0] = context;
1871 inputs_[1] = function;
1876 LOperand* context() { return inputs_[0]; }
1877 LOperand* function() { return inputs_[1]; }
1878 LOperand* temp_slot() { return temps_[0]; }
1879 LOperand* temp_vector() { return temps_[1]; }
1881 DECLARE_CONCRETE_INSTRUCTION(CallFunction, "call-function")
1882 DECLARE_HYDROGEN_ACCESSOR(CallFunction)
1884 int arity() const { return hydrogen()->argument_count() - 1; }
1885 void PrintDataTo(StringStream* stream) override;
1889 class LCallNew final : public LTemplateInstruction<1, 2, 0> {
1891 LCallNew(LOperand* context, LOperand* constructor) {
1892 inputs_[0] = context;
1893 inputs_[1] = constructor;
1896 LOperand* context() { return inputs_[0]; }
1897 LOperand* constructor() { return inputs_[1]; }
1899 DECLARE_CONCRETE_INSTRUCTION(CallNew, "call-new")
1900 DECLARE_HYDROGEN_ACCESSOR(CallNew)
1902 void PrintDataTo(StringStream* stream) override;
1904 int arity() const { return hydrogen()->argument_count() - 1; }
1908 class LCallNewArray final : public LTemplateInstruction<1, 2, 0> {
1910 LCallNewArray(LOperand* context, LOperand* constructor) {
1911 inputs_[0] = context;
1912 inputs_[1] = constructor;
1915 LOperand* context() { return inputs_[0]; }
1916 LOperand* constructor() { return inputs_[1]; }
1918 DECLARE_CONCRETE_INSTRUCTION(CallNewArray, "call-new-array")
1919 DECLARE_HYDROGEN_ACCESSOR(CallNewArray)
1921 void PrintDataTo(StringStream* stream) override;
1923 int arity() const { return hydrogen()->argument_count() - 1; }
1927 class LCallRuntime final : public LTemplateInstruction<1, 1, 0> {
1929 explicit LCallRuntime(LOperand* context) {
1930 inputs_[0] = context;
1933 LOperand* context() { return inputs_[0]; }
1935 DECLARE_CONCRETE_INSTRUCTION(CallRuntime, "call-runtime")
1936 DECLARE_HYDROGEN_ACCESSOR(CallRuntime)
1938 bool ClobbersDoubleRegisters(Isolate* isolate) const override {
1939 return save_doubles() == kDontSaveFPRegs;
1942 const Runtime::Function* function() const { return hydrogen()->function(); }
1943 int arity() const { return hydrogen()->argument_count(); }
1944 SaveFPRegsMode save_doubles() const { return hydrogen()->save_doubles(); }
1948 class LInteger32ToDouble final : public LTemplateInstruction<1, 1, 0> {
1950 explicit LInteger32ToDouble(LOperand* value) {
1954 LOperand* value() { return inputs_[0]; }
1956 DECLARE_CONCRETE_INSTRUCTION(Integer32ToDouble, "int32-to-double")
1960 class LUint32ToDouble final : public LTemplateInstruction<1, 1, 0> {
1962 explicit LUint32ToDouble(LOperand* value) {
1966 LOperand* value() { return inputs_[0]; }
1968 DECLARE_CONCRETE_INSTRUCTION(Uint32ToDouble, "uint32-to-double")
1972 class LNumberTagI final : public LTemplateInstruction<1, 1, 2> {
1974 LNumberTagI(LOperand* value, LOperand* temp1, LOperand* temp2) {
1980 LOperand* value() { return inputs_[0]; }
1981 LOperand* temp1() { return temps_[0]; }
1982 LOperand* temp2() { return temps_[1]; }
1984 DECLARE_CONCRETE_INSTRUCTION(NumberTagI, "number-tag-i")
1988 class LNumberTagU final : public LTemplateInstruction<1, 1, 2> {
1990 LNumberTagU(LOperand* value, LOperand* temp1, LOperand* temp2) {
1996 LOperand* value() { return inputs_[0]; }
1997 LOperand* temp1() { return temps_[0]; }
1998 LOperand* temp2() { return temps_[1]; }
2000 DECLARE_CONCRETE_INSTRUCTION(NumberTagU, "number-tag-u")
2004 class LNumberTagD final : public LTemplateInstruction<1, 1, 2> {
2006 LNumberTagD(LOperand* value, LOperand* temp, LOperand* temp2) {
2012 LOperand* value() { return inputs_[0]; }
2013 LOperand* temp() { return temps_[0]; }
2014 LOperand* temp2() { return temps_[1]; }
2016 DECLARE_CONCRETE_INSTRUCTION(NumberTagD, "number-tag-d")
2017 DECLARE_HYDROGEN_ACCESSOR(Change)
2021 class LDoubleToSmi final : public LTemplateInstruction<1, 1, 0> {
2023 explicit LDoubleToSmi(LOperand* value) {
2027 LOperand* value() { return inputs_[0]; }
2029 DECLARE_CONCRETE_INSTRUCTION(DoubleToSmi, "double-to-smi")
2030 DECLARE_HYDROGEN_ACCESSOR(UnaryOperation)
2032 bool truncating() { return hydrogen()->CanTruncateToInt32(); }
2036 // Sometimes truncating conversion from a tagged value to an int32.
2037 class LDoubleToI final : public LTemplateInstruction<1, 1, 0> {
2039 explicit LDoubleToI(LOperand* value) {
2043 LOperand* value() { return inputs_[0]; }
2045 DECLARE_CONCRETE_INSTRUCTION(DoubleToI, "double-to-i")
2046 DECLARE_HYDROGEN_ACCESSOR(UnaryOperation)
2048 bool truncating() { return hydrogen()->CanTruncateToInt32(); }
2052 // Truncating conversion from a tagged value to an int32.
2053 class LTaggedToI final : public LTemplateInstruction<1, 1, 2> {
2055 LTaggedToI(LOperand* value,
2063 LOperand* value() { return inputs_[0]; }
2064 LOperand* temp() { return temps_[0]; }
2065 LOperand* temp2() { return temps_[1]; }
2067 DECLARE_CONCRETE_INSTRUCTION(TaggedToI, "tagged-to-i")
2068 DECLARE_HYDROGEN_ACCESSOR(Change)
2070 bool truncating() { return hydrogen()->CanTruncateToInt32(); }
2074 class LSmiTag final : public LTemplateInstruction<1, 1, 0> {
2076 explicit LSmiTag(LOperand* value) {
2080 LOperand* value() { return inputs_[0]; }
2082 DECLARE_CONCRETE_INSTRUCTION(SmiTag, "smi-tag")
2083 DECLARE_HYDROGEN_ACCESSOR(Change)
2087 class LNumberUntagD final : public LTemplateInstruction<1, 1, 0> {
2089 explicit LNumberUntagD(LOperand* value) {
2093 LOperand* value() { return inputs_[0]; }
2095 DECLARE_CONCRETE_INSTRUCTION(NumberUntagD, "double-untag")
2096 DECLARE_HYDROGEN_ACCESSOR(Change)
2100 class LSmiUntag final : public LTemplateInstruction<1, 1, 0> {
2102 LSmiUntag(LOperand* value, bool needs_check)
2103 : needs_check_(needs_check) {
2107 LOperand* value() { return inputs_[0]; }
2108 bool needs_check() const { return needs_check_; }
2110 DECLARE_CONCRETE_INSTRUCTION(SmiUntag, "smi-untag")
2117 class LStoreNamedField final : public LTemplateInstruction<0, 2, 1> {
2119 LStoreNamedField(LOperand* object, LOperand* value, LOperand* temp) {
2120 inputs_[0] = object;
2125 LOperand* object() { return inputs_[0]; }
2126 LOperand* value() { return inputs_[1]; }
2127 LOperand* temp() { return temps_[0]; }
2129 DECLARE_CONCRETE_INSTRUCTION(StoreNamedField, "store-named-field")
2130 DECLARE_HYDROGEN_ACCESSOR(StoreNamedField)
2132 void PrintDataTo(StringStream* stream) override;
2134 Representation representation() const {
2135 return hydrogen()->field_representation();
2140 class LStoreNamedGeneric final : public LTemplateInstruction<0, 3, 2> {
2142 LStoreNamedGeneric(LOperand* context, LOperand* object, LOperand* value,
2143 LOperand* slot, LOperand* vector) {
2144 inputs_[0] = context;
2145 inputs_[1] = object;
2151 LOperand* context() { return inputs_[0]; }
2152 LOperand* object() { return inputs_[1]; }
2153 LOperand* value() { return inputs_[2]; }
2154 LOperand* temp_slot() { return temps_[0]; }
2155 LOperand* temp_vector() { return temps_[1]; }
2157 DECLARE_CONCRETE_INSTRUCTION(StoreNamedGeneric, "store-named-generic")
2158 DECLARE_HYDROGEN_ACCESSOR(StoreNamedGeneric)
2160 void PrintDataTo(StringStream* stream) override;
2162 Handle<Object> name() const { return hydrogen()->name(); }
2163 LanguageMode language_mode() { return hydrogen()->language_mode(); }
2167 class LStoreGlobalViaContext final : public LTemplateInstruction<0, 2, 0> {
2169 LStoreGlobalViaContext(LOperand* context, LOperand* value) {
2170 inputs_[0] = context;
2174 LOperand* context() { return inputs_[0]; }
2175 LOperand* value() { return inputs_[1]; }
2177 DECLARE_CONCRETE_INSTRUCTION(StoreGlobalViaContext,
2178 "store-global-via-context")
2179 DECLARE_HYDROGEN_ACCESSOR(StoreGlobalViaContext)
2181 void PrintDataTo(StringStream* stream) override;
2183 int depth() { return hydrogen()->depth(); }
2184 int slot_index() { return hydrogen()->slot_index(); }
2185 LanguageMode language_mode() { return hydrogen()->language_mode(); }
2189 class LStoreKeyed final : public LTemplateInstruction<0, 3, 0> {
2191 LStoreKeyed(LOperand* object, LOperand* key, LOperand* value) {
2192 inputs_[0] = object;
2197 bool is_fixed_typed_array() const {
2198 return hydrogen()->is_fixed_typed_array();
2200 LOperand* elements() { return inputs_[0]; }
2201 LOperand* key() { return inputs_[1]; }
2202 LOperand* value() { return inputs_[2]; }
2203 ElementsKind elements_kind() const {
2204 return hydrogen()->elements_kind();
2207 DECLARE_CONCRETE_INSTRUCTION(StoreKeyed, "store-keyed")
2208 DECLARE_HYDROGEN_ACCESSOR(StoreKeyed)
2210 void PrintDataTo(StringStream* stream) override;
2211 bool NeedsCanonicalization() { return hydrogen()->NeedsCanonicalization(); }
2212 uint32_t base_offset() const { return hydrogen()->base_offset(); }
2216 class LStoreKeyedGeneric final : public LTemplateInstruction<0, 4, 2> {
2218 LStoreKeyedGeneric(LOperand* context, LOperand* object, LOperand* key,
2219 LOperand* value, LOperand* slot, LOperand* vector) {
2220 inputs_[0] = context;
2221 inputs_[1] = object;
2228 LOperand* context() { return inputs_[0]; }
2229 LOperand* object() { return inputs_[1]; }
2230 LOperand* key() { return inputs_[2]; }
2231 LOperand* value() { return inputs_[3]; }
2232 LOperand* temp_slot() { return temps_[0]; }
2233 LOperand* temp_vector() { return temps_[1]; }
2235 DECLARE_CONCRETE_INSTRUCTION(StoreKeyedGeneric, "store-keyed-generic")
2236 DECLARE_HYDROGEN_ACCESSOR(StoreKeyedGeneric)
2238 void PrintDataTo(StringStream* stream) override;
2240 LanguageMode language_mode() { return hydrogen()->language_mode(); }
2244 class LTransitionElementsKind final : public LTemplateInstruction<0, 2, 1> {
2246 LTransitionElementsKind(LOperand* object,
2248 LOperand* new_map_temp) {
2249 inputs_[0] = object;
2250 inputs_[1] = context;
2251 temps_[0] = new_map_temp;
2254 LOperand* context() { return inputs_[1]; }
2255 LOperand* object() { return inputs_[0]; }
2256 LOperand* new_map_temp() { return temps_[0]; }
2258 DECLARE_CONCRETE_INSTRUCTION(TransitionElementsKind,
2259 "transition-elements-kind")
2260 DECLARE_HYDROGEN_ACCESSOR(TransitionElementsKind)
2262 void PrintDataTo(StringStream* stream) override;
2264 Handle<Map> original_map() { return hydrogen()->original_map().handle(); }
2265 Handle<Map> transitioned_map() {
2266 return hydrogen()->transitioned_map().handle();
2268 ElementsKind from_kind() { return hydrogen()->from_kind(); }
2269 ElementsKind to_kind() { return hydrogen()->to_kind(); }
2273 class LTrapAllocationMemento final : public LTemplateInstruction<0, 1, 1> {
2275 LTrapAllocationMemento(LOperand* object,
2277 inputs_[0] = object;
2281 LOperand* object() { return inputs_[0]; }
2282 LOperand* temp() { return temps_[0]; }
2284 DECLARE_CONCRETE_INSTRUCTION(TrapAllocationMemento,
2285 "trap-allocation-memento")
2289 class LMaybeGrowElements final : public LTemplateInstruction<1, 5, 0> {
2291 LMaybeGrowElements(LOperand* context, LOperand* object, LOperand* elements,
2292 LOperand* key, LOperand* current_capacity) {
2293 inputs_[0] = context;
2294 inputs_[1] = object;
2295 inputs_[2] = elements;
2297 inputs_[4] = current_capacity;
2300 LOperand* context() { return inputs_[0]; }
2301 LOperand* object() { return inputs_[1]; }
2302 LOperand* elements() { return inputs_[2]; }
2303 LOperand* key() { return inputs_[3]; }
2304 LOperand* current_capacity() { return inputs_[4]; }
2306 DECLARE_HYDROGEN_ACCESSOR(MaybeGrowElements)
2307 DECLARE_CONCRETE_INSTRUCTION(MaybeGrowElements, "maybe-grow-elements")
2311 class LStringAdd final : public LTemplateInstruction<1, 3, 0> {
2313 LStringAdd(LOperand* context, LOperand* left, LOperand* right) {
2314 inputs_[0] = context;
2319 LOperand* context() { return inputs_[0]; }
2320 LOperand* left() { return inputs_[1]; }
2321 LOperand* right() { return inputs_[2]; }
2323 DECLARE_CONCRETE_INSTRUCTION(StringAdd, "string-add")
2324 DECLARE_HYDROGEN_ACCESSOR(StringAdd)
2328 class LStringCharCodeAt final : public LTemplateInstruction<1, 3, 0> {
2330 LStringCharCodeAt(LOperand* context, LOperand* string, LOperand* index) {
2331 inputs_[0] = context;
2332 inputs_[1] = string;
2336 LOperand* context() { return inputs_[0]; }
2337 LOperand* string() { return inputs_[1]; }
2338 LOperand* index() { return inputs_[2]; }
2340 DECLARE_CONCRETE_INSTRUCTION(StringCharCodeAt, "string-char-code-at")
2341 DECLARE_HYDROGEN_ACCESSOR(StringCharCodeAt)
2345 class LStringCharFromCode final : public LTemplateInstruction<1, 2, 0> {
2347 explicit LStringCharFromCode(LOperand* context, LOperand* char_code) {
2348 inputs_[0] = context;
2349 inputs_[1] = char_code;
2352 LOperand* context() { return inputs_[0]; }
2353 LOperand* char_code() { return inputs_[1]; }
2355 DECLARE_CONCRETE_INSTRUCTION(StringCharFromCode, "string-char-from-code")
2356 DECLARE_HYDROGEN_ACCESSOR(StringCharFromCode)
2360 class LCheckValue final : public LTemplateInstruction<0, 1, 0> {
2362 explicit LCheckValue(LOperand* value) {
2366 LOperand* value() { return inputs_[0]; }
2368 DECLARE_CONCRETE_INSTRUCTION(CheckValue, "check-value")
2369 DECLARE_HYDROGEN_ACCESSOR(CheckValue)
2373 class LCheckArrayBufferNotNeutered final
2374 : public LTemplateInstruction<0, 1, 0> {
2376 explicit LCheckArrayBufferNotNeutered(LOperand* view) { inputs_[0] = view; }
2378 LOperand* view() { return inputs_[0]; }
2380 DECLARE_CONCRETE_INSTRUCTION(CheckArrayBufferNotNeutered,
2381 "check-array-buffer-not-neutered")
2382 DECLARE_HYDROGEN_ACCESSOR(CheckArrayBufferNotNeutered)
2386 class LCheckInstanceType final : public LTemplateInstruction<0, 1, 0> {
2388 explicit LCheckInstanceType(LOperand* value) {
2392 LOperand* value() { return inputs_[0]; }
2394 DECLARE_CONCRETE_INSTRUCTION(CheckInstanceType, "check-instance-type")
2395 DECLARE_HYDROGEN_ACCESSOR(CheckInstanceType)
2399 class LCheckMaps final : public LTemplateInstruction<0, 1, 0> {
2401 explicit LCheckMaps(LOperand* value = NULL) {
2405 LOperand* value() { return inputs_[0]; }
2407 DECLARE_CONCRETE_INSTRUCTION(CheckMaps, "check-maps")
2408 DECLARE_HYDROGEN_ACCESSOR(CheckMaps)
2412 class LCheckSmi final : public LTemplateInstruction<1, 1, 0> {
2414 explicit LCheckSmi(LOperand* value) {
2418 LOperand* value() { return inputs_[0]; }
2420 DECLARE_CONCRETE_INSTRUCTION(CheckSmi, "check-smi")
2424 class LCheckNonSmi final : public LTemplateInstruction<0, 1, 0> {
2426 explicit LCheckNonSmi(LOperand* value) {
2430 LOperand* value() { return inputs_[0]; }
2432 DECLARE_CONCRETE_INSTRUCTION(CheckNonSmi, "check-non-smi")
2433 DECLARE_HYDROGEN_ACCESSOR(CheckHeapObject)
2437 class LClampDToUint8 final : public LTemplateInstruction<1, 1, 1> {
2439 LClampDToUint8(LOperand* unclamped, LOperand* temp) {
2440 inputs_[0] = unclamped;
2444 LOperand* unclamped() { return inputs_[0]; }
2445 LOperand* temp() { return temps_[0]; }
2447 DECLARE_CONCRETE_INSTRUCTION(ClampDToUint8, "clamp-d-to-uint8")
2451 class LClampIToUint8 final : public LTemplateInstruction<1, 1, 0> {
2453 explicit LClampIToUint8(LOperand* unclamped) {
2454 inputs_[0] = unclamped;
2457 LOperand* unclamped() { return inputs_[0]; }
2459 DECLARE_CONCRETE_INSTRUCTION(ClampIToUint8, "clamp-i-to-uint8")
2463 class LClampTToUint8 final : public LTemplateInstruction<1, 1, 1> {
2465 LClampTToUint8(LOperand* unclamped, LOperand* temp) {
2466 inputs_[0] = unclamped;
2470 LOperand* unclamped() { return inputs_[0]; }
2471 LOperand* temp() { return temps_[0]; }
2473 DECLARE_CONCRETE_INSTRUCTION(ClampTToUint8, "clamp-t-to-uint8")
2477 class LDoubleBits final : public LTemplateInstruction<1, 1, 0> {
2479 explicit LDoubleBits(LOperand* value) {
2483 LOperand* value() { return inputs_[0]; }
2485 DECLARE_CONCRETE_INSTRUCTION(DoubleBits, "double-bits")
2486 DECLARE_HYDROGEN_ACCESSOR(DoubleBits)
2490 class LConstructDouble final : public LTemplateInstruction<1, 2, 0> {
2492 LConstructDouble(LOperand* hi, LOperand* lo) {
2497 LOperand* hi() { return inputs_[0]; }
2498 LOperand* lo() { return inputs_[1]; }
2500 DECLARE_CONCRETE_INSTRUCTION(ConstructDouble, "construct-double")
2504 class LAllocate final : public LTemplateInstruction<1, 2, 2> {
2506 LAllocate(LOperand* context,
2510 inputs_[0] = context;
2516 LOperand* context() { return inputs_[0]; }
2517 LOperand* size() { return inputs_[1]; }
2518 LOperand* temp1() { return temps_[0]; }
2519 LOperand* temp2() { return temps_[1]; }
2521 DECLARE_CONCRETE_INSTRUCTION(Allocate, "allocate")
2522 DECLARE_HYDROGEN_ACCESSOR(Allocate)
2526 class LRegExpLiteral final : public LTemplateInstruction<1, 1, 0> {
2528 explicit LRegExpLiteral(LOperand* context) {
2529 inputs_[0] = context;
2532 LOperand* context() { return inputs_[0]; }
2534 DECLARE_CONCRETE_INSTRUCTION(RegExpLiteral, "regexp-literal")
2535 DECLARE_HYDROGEN_ACCESSOR(RegExpLiteral)
2539 class LFunctionLiteral final : public LTemplateInstruction<1, 1, 0> {
2541 explicit LFunctionLiteral(LOperand* context) {
2542 inputs_[0] = context;
2545 LOperand* context() { return inputs_[0]; }
2547 DECLARE_CONCRETE_INSTRUCTION(FunctionLiteral, "function-literal")
2548 DECLARE_HYDROGEN_ACCESSOR(FunctionLiteral)
2552 class LToFastProperties final : public LTemplateInstruction<1, 1, 0> {
2554 explicit LToFastProperties(LOperand* value) {
2558 LOperand* value() { return inputs_[0]; }
2560 DECLARE_CONCRETE_INSTRUCTION(ToFastProperties, "to-fast-properties")
2561 DECLARE_HYDROGEN_ACCESSOR(ToFastProperties)
2565 class LTypeof final : public LTemplateInstruction<1, 2, 0> {
2567 LTypeof(LOperand* context, LOperand* value) {
2568 inputs_[0] = context;
2572 LOperand* context() { return inputs_[0]; }
2573 LOperand* value() { return inputs_[1]; }
2575 DECLARE_CONCRETE_INSTRUCTION(Typeof, "typeof")
2579 class LTypeofIsAndBranch final : public LControlInstruction<1, 0> {
2581 explicit LTypeofIsAndBranch(LOperand* value) {
2585 LOperand* value() { return inputs_[0]; }
2587 DECLARE_CONCRETE_INSTRUCTION(TypeofIsAndBranch, "typeof-is-and-branch")
2588 DECLARE_HYDROGEN_ACCESSOR(TypeofIsAndBranch)
2590 Handle<String> type_literal() { return hydrogen()->type_literal(); }
2592 void PrintDataTo(StringStream* stream) override;
2596 class LIsConstructCallAndBranch final : public LControlInstruction<0, 1> {
2598 explicit LIsConstructCallAndBranch(LOperand* temp) {
2602 LOperand* temp() { return temps_[0]; }
2604 DECLARE_CONCRETE_INSTRUCTION(IsConstructCallAndBranch,
2605 "is-construct-call-and-branch")
2609 class LOsrEntry final : public LTemplateInstruction<0, 0, 0> {
2613 bool HasInterestingComment(LCodeGen* gen) const override { return false; }
2614 DECLARE_CONCRETE_INSTRUCTION(OsrEntry, "osr-entry")
2618 class LStackCheck final : public LTemplateInstruction<0, 1, 0> {
2620 explicit LStackCheck(LOperand* context) {
2621 inputs_[0] = context;
2624 LOperand* context() { return inputs_[0]; }
2626 DECLARE_CONCRETE_INSTRUCTION(StackCheck, "stack-check")
2627 DECLARE_HYDROGEN_ACCESSOR(StackCheck)
2629 Label* done_label() { return &done_label_; }
2636 class LForInPrepareMap final : public LTemplateInstruction<1, 2, 0> {
2638 LForInPrepareMap(LOperand* context, LOperand* object) {
2639 inputs_[0] = context;
2640 inputs_[1] = object;
2643 LOperand* context() { return inputs_[0]; }
2644 LOperand* object() { return inputs_[1]; }
2646 DECLARE_CONCRETE_INSTRUCTION(ForInPrepareMap, "for-in-prepare-map")
2650 class LForInCacheArray final : public LTemplateInstruction<1, 1, 0> {
2652 explicit LForInCacheArray(LOperand* map) {
2656 LOperand* map() { return inputs_[0]; }
2658 DECLARE_CONCRETE_INSTRUCTION(ForInCacheArray, "for-in-cache-array")
2661 return HForInCacheArray::cast(this->hydrogen_value())->idx();
2666 class LCheckMapValue final : public LTemplateInstruction<0, 2, 0> {
2668 LCheckMapValue(LOperand* value, LOperand* map) {
2673 LOperand* value() { return inputs_[0]; }
2674 LOperand* map() { return inputs_[1]; }
2676 DECLARE_CONCRETE_INSTRUCTION(CheckMapValue, "check-map-value")
2680 class LLoadFieldByIndex final : public LTemplateInstruction<1, 2, 0> {
2682 LLoadFieldByIndex(LOperand* object, LOperand* index) {
2683 inputs_[0] = object;
2687 LOperand* object() { return inputs_[0]; }
2688 LOperand* index() { return inputs_[1]; }
2690 DECLARE_CONCRETE_INSTRUCTION(LoadFieldByIndex, "load-field-by-index")
2694 class LStoreFrameContext: public LTemplateInstruction<0, 1, 0> {
2696 explicit LStoreFrameContext(LOperand* context) {
2697 inputs_[0] = context;
2700 LOperand* context() { return inputs_[0]; }
2702 DECLARE_CONCRETE_INSTRUCTION(StoreFrameContext, "store-frame-context")
2706 class LAllocateBlockContext: public LTemplateInstruction<1, 2, 0> {
2708 LAllocateBlockContext(LOperand* context, LOperand* function) {
2709 inputs_[0] = context;
2710 inputs_[1] = function;
2713 LOperand* context() { return inputs_[0]; }
2714 LOperand* function() { return inputs_[1]; }
2716 Handle<ScopeInfo> scope_info() { return hydrogen()->scope_info(); }
2718 DECLARE_CONCRETE_INSTRUCTION(AllocateBlockContext, "allocate-block-context")
2719 DECLARE_HYDROGEN_ACCESSOR(AllocateBlockContext)
2723 class LChunkBuilder;
2724 class LPlatformChunk final : public LChunk {
2726 LPlatformChunk(CompilationInfo* info, HGraph* graph)
2727 : LChunk(info, graph) { }
2729 int GetNextSpillIndex(RegisterKind kind);
2730 LOperand* GetNextSpillSlot(RegisterKind kind);
2734 class LChunkBuilder final : public LChunkBuilderBase {
2736 LChunkBuilder(CompilationInfo* info, HGraph* graph, LAllocator* allocator)
2737 : LChunkBuilderBase(info, graph),
2738 current_instruction_(NULL),
2739 current_block_(NULL),
2741 allocator_(allocator) {}
2743 // Build the sequence for the graph.
2744 LPlatformChunk* Build();
2746 // Declare methods that deal with the individual node types.
2747 #define DECLARE_DO(type) LInstruction* Do##type(H##type* node);
2748 HYDROGEN_CONCRETE_INSTRUCTION_LIST(DECLARE_DO)
2751 LInstruction* DoMultiplyAdd(HMul* mul, HValue* addend);
2753 static bool HasMagicNumberForDivisor(int32_t divisor);
2755 LInstruction* DoMathFloor(HUnaryMathOperation* instr);
2756 LInstruction* DoMathRound(HUnaryMathOperation* instr);
2757 LInstruction* DoMathFround(HUnaryMathOperation* instr);
2758 LInstruction* DoMathAbs(HUnaryMathOperation* instr);
2759 LInstruction* DoMathLog(HUnaryMathOperation* instr);
2760 LInstruction* DoMathExp(HUnaryMathOperation* instr);
2761 LInstruction* DoMathSqrt(HUnaryMathOperation* instr);
2762 LInstruction* DoMathPowHalf(HUnaryMathOperation* instr);
2763 LInstruction* DoMathClz32(HUnaryMathOperation* instr);
2764 LInstruction* DoDivByPowerOf2I(HDiv* instr);
2765 LInstruction* DoDivByConstI(HDiv* instr);
2766 LInstruction* DoDivI(HDiv* instr);
2767 LInstruction* DoModByPowerOf2I(HMod* instr);
2768 LInstruction* DoModByConstI(HMod* instr);
2769 LInstruction* DoModI(HMod* instr);
2770 LInstruction* DoFlooringDivByPowerOf2I(HMathFloorOfDiv* instr);
2771 LInstruction* DoFlooringDivByConstI(HMathFloorOfDiv* instr);
2772 LInstruction* DoFlooringDivI(HMathFloorOfDiv* instr);
2775 // Methods for getting operands for Use / Define / Temp.
2776 LUnallocated* ToUnallocated(Register reg);
2777 LUnallocated* ToUnallocated(DoubleRegister reg);
2779 // Methods for setting up define-use relationships.
2780 MUST_USE_RESULT LOperand* Use(HValue* value, LUnallocated* operand);
2781 MUST_USE_RESULT LOperand* UseFixed(HValue* value, Register fixed_register);
2782 MUST_USE_RESULT LOperand* UseFixedDouble(HValue* value,
2783 DoubleRegister fixed_register);
2785 // A value that is guaranteed to be allocated to a register.
2786 // Operand created by UseRegister is guaranteed to be live until the end of
2787 // instruction. This means that register allocator will not reuse it's
2788 // register for any other operand inside instruction.
2789 // Operand created by UseRegisterAtStart is guaranteed to be live only at
2790 // instruction start. Register allocator is free to assign the same register
2791 // to some other operand used inside instruction (i.e. temporary or
2793 MUST_USE_RESULT LOperand* UseRegister(HValue* value);
2794 MUST_USE_RESULT LOperand* UseRegisterAtStart(HValue* value);
2796 // An input operand in a register that may be trashed.
2797 MUST_USE_RESULT LOperand* UseTempRegister(HValue* value);
2799 // An input operand in a register or stack slot.
2800 MUST_USE_RESULT LOperand* Use(HValue* value);
2801 MUST_USE_RESULT LOperand* UseAtStart(HValue* value);
2803 // An input operand in a register, stack slot or a constant operand.
2804 MUST_USE_RESULT LOperand* UseOrConstant(HValue* value);
2805 MUST_USE_RESULT LOperand* UseOrConstantAtStart(HValue* value);
2807 // An input operand in a register or a constant operand.
2808 MUST_USE_RESULT LOperand* UseRegisterOrConstant(HValue* value);
2809 MUST_USE_RESULT LOperand* UseRegisterOrConstantAtStart(HValue* value);
2811 // An input operand in a constant operand.
2812 MUST_USE_RESULT LOperand* UseConstant(HValue* value);
2814 // An input operand in register, stack slot or a constant operand.
2815 // Will not be moved to a register even if one is freely available.
2816 MUST_USE_RESULT LOperand* UseAny(HValue* value) override;
2818 // Temporary operand that must be in a register.
2819 MUST_USE_RESULT LUnallocated* TempRegister();
2820 MUST_USE_RESULT LUnallocated* TempDoubleRegister();
2821 MUST_USE_RESULT LOperand* FixedTemp(Register reg);
2822 MUST_USE_RESULT LOperand* FixedTemp(DoubleRegister reg);
2824 // Methods for setting up define-use relationships.
2825 // Return the same instruction that they are passed.
2826 LInstruction* Define(LTemplateResultInstruction<1>* instr,
2827 LUnallocated* result);
2828 LInstruction* DefineAsRegister(LTemplateResultInstruction<1>* instr);
2829 LInstruction* DefineAsSpilled(LTemplateResultInstruction<1>* instr,
2831 LInstruction* DefineSameAsFirst(LTemplateResultInstruction<1>* instr);
2832 LInstruction* DefineFixed(LTemplateResultInstruction<1>* instr,
2834 LInstruction* DefineFixedDouble(LTemplateResultInstruction<1>* instr,
2835 DoubleRegister reg);
2836 LInstruction* AssignEnvironment(LInstruction* instr);
2837 LInstruction* AssignPointerMap(LInstruction* instr);
2839 enum CanDeoptimize { CAN_DEOPTIMIZE_EAGERLY, CANNOT_DEOPTIMIZE_EAGERLY };
2841 // By default we assume that instruction sequences generated for calls
2842 // cannot deoptimize eagerly and we do not attach environment to this
2844 LInstruction* MarkAsCall(
2845 LInstruction* instr,
2846 HInstruction* hinstr,
2847 CanDeoptimize can_deoptimize = CANNOT_DEOPTIMIZE_EAGERLY);
2849 void VisitInstruction(HInstruction* current);
2850 void AddInstruction(LInstruction* instr, HInstruction* current);
2852 void DoBasicBlock(HBasicBlock* block, HBasicBlock* next_block);
2853 LInstruction* DoBit(Token::Value op, HBitwiseBinaryOperation* instr);
2854 LInstruction* DoShift(Token::Value op, HBitwiseBinaryOperation* instr);
2855 LInstruction* DoArithmeticD(Token::Value op,
2856 HArithmeticBinaryOperation* instr);
2857 LInstruction* DoArithmeticT(Token::Value op,
2858 HBinaryOperation* instr);
2860 HInstruction* current_instruction_;
2861 HBasicBlock* current_block_;
2862 HBasicBlock* next_block_;
2863 LAllocator* allocator_;
2865 DISALLOW_COPY_AND_ASSIGN(LChunkBuilder);
2868 #undef DECLARE_HYDROGEN_ACCESSOR
2869 #undef DECLARE_CONCRETE_INSTRUCTION
2871 } } // namespace v8::internal
2873 #endif // V8_MIPS_LITHIUM_MIPS_H_