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) \
82 V(GetCachedArrayIndex) \
84 V(HasCachedArrayIndexAndBranch) \
85 V(HasInPrototypeChainAndBranch) \
86 V(HasInstanceTypeAndBranch) \
87 V(InnerAllocatedObject) \
90 V(Integer32ToDouble) \
92 V(IsConstructCallAndBranch) \
93 V(IsStringAndBranch) \
95 V(IsUndetectableAndBranch) \
100 V(LoadFieldByIndex) \
101 V(LoadFunctionPrototype) \
102 V(LoadGlobalGeneric) \
103 V(LoadGlobalViaContext) \
105 V(LoadKeyedGeneric) \
107 V(LoadNamedGeneric) \
119 V(MaybeGrowElements) \
136 V(SeqStringGetChar) \
137 V(SeqStringSetChar) \
143 V(StoreContextSlot) \
144 V(StoreFrameContext) \
145 V(StoreGlobalViaContext) \
147 V(StoreKeyedGeneric) \
149 V(StoreNamedGeneric) \
151 V(StringCharCodeAt) \
152 V(StringCharFromCode) \
153 V(StringCompareAndBranch) \
157 V(ToFastProperties) \
158 V(TransitionElementsKind) \
159 V(TrapAllocationMemento) \
161 V(TypeofIsAndBranch) \
166 #define DECLARE_CONCRETE_INSTRUCTION(type, mnemonic) \
167 Opcode opcode() const final { return LInstruction::k##type; } \
168 void CompileToNative(LCodeGen* generator) final; \
169 const char* Mnemonic() const final { return mnemonic; } \
170 static L##type* cast(LInstruction* instr) { \
171 DCHECK(instr->Is##type()); \
172 return reinterpret_cast<L##type*>(instr); \
176 #define DECLARE_HYDROGEN_ACCESSOR(type) \
177 H##type* hydrogen() const { \
178 return H##type::cast(hydrogen_value()); \
182 class LInstruction : public ZoneObject {
185 : environment_(NULL),
186 hydrogen_value_(NULL),
187 bit_field_(IsCallBits::encode(false)) {
190 virtual ~LInstruction() {}
192 virtual void CompileToNative(LCodeGen* generator) = 0;
193 virtual const char* Mnemonic() const = 0;
194 virtual void PrintTo(StringStream* stream);
195 virtual void PrintDataTo(StringStream* stream);
196 virtual void PrintOutputOperandTo(StringStream* stream);
199 // Declare a unique enum value for each instruction.
200 #define DECLARE_OPCODE(type) k##type,
201 LITHIUM_CONCRETE_INSTRUCTION_LIST(DECLARE_OPCODE)
202 kNumberOfInstructions
203 #undef DECLARE_OPCODE
206 virtual Opcode opcode() const = 0;
208 // Declare non-virtual type testers for all leaf IR classes.
209 #define DECLARE_PREDICATE(type) \
210 bool Is##type() const { return opcode() == k##type; }
211 LITHIUM_CONCRETE_INSTRUCTION_LIST(DECLARE_PREDICATE)
212 #undef DECLARE_PREDICATE
214 // Declare virtual predicates for instructions that don't have
216 virtual bool IsGap() const { return false; }
218 virtual bool IsControl() const { return false; }
220 // Try deleting this instruction if possible.
221 virtual bool TryDelete() { return false; }
223 void set_environment(LEnvironment* env) { environment_ = env; }
224 LEnvironment* environment() const { return environment_; }
225 bool HasEnvironment() const { return environment_ != NULL; }
227 void set_pointer_map(LPointerMap* p) { pointer_map_.set(p); }
228 LPointerMap* pointer_map() const { return pointer_map_.get(); }
229 bool HasPointerMap() const { return pointer_map_.is_set(); }
231 void set_hydrogen_value(HValue* value) { hydrogen_value_ = value; }
232 HValue* hydrogen_value() const { return hydrogen_value_; }
234 void MarkAsCall() { bit_field_ = IsCallBits::update(bit_field_, true); }
235 bool IsCall() const { return IsCallBits::decode(bit_field_); }
237 // Interface to the register allocator and iterators.
238 bool ClobbersTemps() const { return IsCall(); }
239 bool ClobbersRegisters() const { return IsCall(); }
240 virtual bool ClobbersDoubleRegisters(Isolate* isolate) const {
244 // Interface to the register allocator and iterators.
245 bool IsMarkedAsCall() const { return IsCall(); }
247 virtual bool HasResult() const = 0;
248 virtual LOperand* result() const = 0;
250 LOperand* FirstInput() { return InputAt(0); }
251 LOperand* Output() { return HasResult() ? result() : NULL; }
253 virtual bool HasInterestingComment(LCodeGen* gen) const { return true; }
259 virtual int InputCount() = 0;
260 virtual LOperand* InputAt(int i) = 0;
263 // Iterator interface.
264 friend class InputIterator;
266 friend class TempIterator;
267 virtual int TempCount() = 0;
268 virtual LOperand* TempAt(int i) = 0;
270 class IsCallBits: public BitField<bool, 0, 1> {};
272 LEnvironment* environment_;
273 SetOncePointer<LPointerMap> pointer_map_;
274 HValue* hydrogen_value_;
279 // R = number of result operands (0 or 1).
281 class LTemplateResultInstruction : public LInstruction {
283 // Allow 0 or 1 output operands.
284 STATIC_ASSERT(R == 0 || R == 1);
285 bool HasResult() const final { return R != 0 && result() != NULL; }
286 void set_result(LOperand* operand) { results_[0] = operand; }
287 LOperand* result() const override { return results_[0]; }
290 EmbeddedContainer<LOperand*, R> results_;
294 // R = number of result operands (0 or 1).
295 // I = number of input operands.
296 // T = number of temporary operands.
297 template<int R, int I, int T>
298 class LTemplateInstruction : public LTemplateResultInstruction<R> {
300 EmbeddedContainer<LOperand*, I> inputs_;
301 EmbeddedContainer<LOperand*, T> temps_;
305 int InputCount() final { return I; }
306 LOperand* InputAt(int i) final { return inputs_[i]; }
308 int TempCount() final { return T; }
309 LOperand* TempAt(int i) final { return temps_[i]; }
313 class LGap : public LTemplateInstruction<0, 0, 0> {
315 explicit LGap(HBasicBlock* block)
317 parallel_moves_[BEFORE] = NULL;
318 parallel_moves_[START] = NULL;
319 parallel_moves_[END] = NULL;
320 parallel_moves_[AFTER] = NULL;
323 // Can't use the DECLARE-macro here because of sub-classes.
324 bool IsGap() const final { return true; }
325 void PrintDataTo(StringStream* stream) override;
326 static LGap* cast(LInstruction* instr) {
327 DCHECK(instr->IsGap());
328 return reinterpret_cast<LGap*>(instr);
331 bool IsRedundant() const;
333 HBasicBlock* block() const { return block_; }
340 FIRST_INNER_POSITION = BEFORE,
341 LAST_INNER_POSITION = AFTER
344 LParallelMove* GetOrCreateParallelMove(InnerPosition pos, Zone* zone) {
345 if (parallel_moves_[pos] == NULL) {
346 parallel_moves_[pos] = new(zone) LParallelMove(zone);
348 return parallel_moves_[pos];
351 LParallelMove* GetParallelMove(InnerPosition pos) {
352 return parallel_moves_[pos];
356 LParallelMove* parallel_moves_[LAST_INNER_POSITION + 1];
361 class LInstructionGap final : public LGap {
363 explicit LInstructionGap(HBasicBlock* block) : LGap(block) { }
365 bool HasInterestingComment(LCodeGen* gen) const override {
366 return !IsRedundant();
369 DECLARE_CONCRETE_INSTRUCTION(InstructionGap, "gap")
373 class LGoto final : public LTemplateInstruction<0, 0, 0> {
375 explicit LGoto(HBasicBlock* block) : block_(block) { }
377 bool HasInterestingComment(LCodeGen* gen) const override;
378 DECLARE_CONCRETE_INSTRUCTION(Goto, "goto")
379 void PrintDataTo(StringStream* stream) override;
380 bool IsControl() const override { return true; }
382 int block_id() const { return block_->block_id(); }
389 class LPrologue final : public LTemplateInstruction<0, 0, 0> {
391 DECLARE_CONCRETE_INSTRUCTION(Prologue, "prologue")
395 class LLazyBailout final : public LTemplateInstruction<0, 0, 0> {
397 LLazyBailout() : gap_instructions_size_(0) { }
399 DECLARE_CONCRETE_INSTRUCTION(LazyBailout, "lazy-bailout")
401 void set_gap_instructions_size(int gap_instructions_size) {
402 gap_instructions_size_ = gap_instructions_size;
404 int gap_instructions_size() { return gap_instructions_size_; }
407 int gap_instructions_size_;
411 class LDummy final : public LTemplateInstruction<1, 0, 0> {
414 DECLARE_CONCRETE_INSTRUCTION(Dummy, "dummy")
418 class LDummyUse final : public LTemplateInstruction<1, 1, 0> {
420 explicit LDummyUse(LOperand* value) {
423 DECLARE_CONCRETE_INSTRUCTION(DummyUse, "dummy-use")
427 class LDeoptimize final : public LTemplateInstruction<0, 0, 0> {
429 bool IsControl() const override { return true; }
430 DECLARE_CONCRETE_INSTRUCTION(Deoptimize, "deoptimize")
431 DECLARE_HYDROGEN_ACCESSOR(Deoptimize)
435 class LLabel final : public LGap {
437 explicit LLabel(HBasicBlock* block)
438 : LGap(block), replacement_(NULL) { }
440 bool HasInterestingComment(LCodeGen* gen) const override { return false; }
441 DECLARE_CONCRETE_INSTRUCTION(Label, "label")
443 void PrintDataTo(StringStream* stream) override;
445 int block_id() const { return block()->block_id(); }
446 bool is_loop_header() const { return block()->IsLoopHeader(); }
447 bool is_osr_entry() const { return block()->is_osr_entry(); }
448 Label* label() { return &label_; }
449 LLabel* replacement() const { return replacement_; }
450 void set_replacement(LLabel* label) { replacement_ = label; }
451 bool HasReplacement() const { return replacement_ != NULL; }
455 LLabel* replacement_;
459 class LParameter final : public LTemplateInstruction<1, 0, 0> {
461 bool HasInterestingComment(LCodeGen* gen) const override { return false; }
462 DECLARE_CONCRETE_INSTRUCTION(Parameter, "parameter")
466 class LCallStub final : public LTemplateInstruction<1, 1, 0> {
468 explicit LCallStub(LOperand* context) {
469 inputs_[0] = context;
472 LOperand* context() { return inputs_[0]; }
474 DECLARE_CONCRETE_INSTRUCTION(CallStub, "call-stub")
475 DECLARE_HYDROGEN_ACCESSOR(CallStub)
479 class LUnknownOSRValue final : public LTemplateInstruction<1, 0, 0> {
481 bool HasInterestingComment(LCodeGen* gen) const override { return false; }
482 DECLARE_CONCRETE_INSTRUCTION(UnknownOSRValue, "unknown-osr-value")
486 template<int I, int T>
487 class LControlInstruction : public LTemplateInstruction<0, I, T> {
489 LControlInstruction() : false_label_(NULL), true_label_(NULL) { }
491 bool IsControl() const final { return true; }
493 int SuccessorCount() { return hydrogen()->SuccessorCount(); }
494 HBasicBlock* SuccessorAt(int i) { return hydrogen()->SuccessorAt(i); }
496 int TrueDestination(LChunk* chunk) {
497 return chunk->LookupDestination(true_block_id());
499 int FalseDestination(LChunk* chunk) {
500 return chunk->LookupDestination(false_block_id());
503 Label* TrueLabel(LChunk* chunk) {
504 if (true_label_ == NULL) {
505 true_label_ = chunk->GetAssemblyLabel(TrueDestination(chunk));
509 Label* FalseLabel(LChunk* chunk) {
510 if (false_label_ == NULL) {
511 false_label_ = chunk->GetAssemblyLabel(FalseDestination(chunk));
517 int true_block_id() { return SuccessorAt(0)->block_id(); }
518 int false_block_id() { return SuccessorAt(1)->block_id(); }
521 HControlInstruction* hydrogen() {
522 return HControlInstruction::cast(this->hydrogen_value());
530 class LWrapReceiver final : public LTemplateInstruction<1, 2, 0> {
532 LWrapReceiver(LOperand* receiver, LOperand* function) {
533 inputs_[0] = receiver;
534 inputs_[1] = function;
537 DECLARE_CONCRETE_INSTRUCTION(WrapReceiver, "wrap-receiver")
538 DECLARE_HYDROGEN_ACCESSOR(WrapReceiver)
540 LOperand* receiver() { return inputs_[0]; }
541 LOperand* function() { return inputs_[1]; }
545 class LApplyArguments final : public LTemplateInstruction<1, 4, 0> {
547 LApplyArguments(LOperand* function,
550 LOperand* elements) {
551 inputs_[0] = function;
552 inputs_[1] = receiver;
554 inputs_[3] = elements;
557 DECLARE_CONCRETE_INSTRUCTION(ApplyArguments, "apply-arguments")
559 LOperand* function() { return inputs_[0]; }
560 LOperand* receiver() { return inputs_[1]; }
561 LOperand* length() { return inputs_[2]; }
562 LOperand* elements() { return inputs_[3]; }
566 class LAccessArgumentsAt final : public LTemplateInstruction<1, 3, 0> {
568 LAccessArgumentsAt(LOperand* arguments, LOperand* length, LOperand* index) {
569 inputs_[0] = arguments;
574 DECLARE_CONCRETE_INSTRUCTION(AccessArgumentsAt, "access-arguments-at")
576 LOperand* arguments() { return inputs_[0]; }
577 LOperand* length() { return inputs_[1]; }
578 LOperand* index() { return inputs_[2]; }
580 void PrintDataTo(StringStream* stream) override;
584 class LArgumentsLength final : public LTemplateInstruction<1, 1, 0> {
586 explicit LArgumentsLength(LOperand* elements) {
587 inputs_[0] = elements;
590 LOperand* elements() { return inputs_[0]; }
592 DECLARE_CONCRETE_INSTRUCTION(ArgumentsLength, "arguments-length")
596 class LArgumentsElements final : public LTemplateInstruction<1, 0, 0> {
598 DECLARE_CONCRETE_INSTRUCTION(ArgumentsElements, "arguments-elements")
599 DECLARE_HYDROGEN_ACCESSOR(ArgumentsElements)
603 class LModByPowerOf2I final : public LTemplateInstruction<1, 1, 0> {
605 LModByPowerOf2I(LOperand* dividend, int32_t divisor) {
606 inputs_[0] = dividend;
610 LOperand* dividend() { return inputs_[0]; }
611 int32_t divisor() const { return divisor_; }
613 DECLARE_CONCRETE_INSTRUCTION(ModByPowerOf2I, "mod-by-power-of-2-i")
614 DECLARE_HYDROGEN_ACCESSOR(Mod)
621 class LModByConstI final : public LTemplateInstruction<1, 1, 0> {
623 LModByConstI(LOperand* dividend, int32_t divisor) {
624 inputs_[0] = dividend;
628 LOperand* dividend() { return inputs_[0]; }
629 int32_t divisor() const { return divisor_; }
631 DECLARE_CONCRETE_INSTRUCTION(ModByConstI, "mod-by-const-i")
632 DECLARE_HYDROGEN_ACCESSOR(Mod)
639 class LModI final : public LTemplateInstruction<1, 2, 3> {
641 LModI(LOperand* left,
647 LOperand* left() { return inputs_[0]; }
648 LOperand* right() { return inputs_[1]; }
650 DECLARE_CONCRETE_INSTRUCTION(ModI, "mod-i")
651 DECLARE_HYDROGEN_ACCESSOR(Mod)
655 class LDivByPowerOf2I final : public LTemplateInstruction<1, 1, 0> {
657 LDivByPowerOf2I(LOperand* dividend, int32_t divisor) {
658 inputs_[0] = dividend;
662 LOperand* dividend() { return inputs_[0]; }
663 int32_t divisor() const { return divisor_; }
665 DECLARE_CONCRETE_INSTRUCTION(DivByPowerOf2I, "div-by-power-of-2-i")
666 DECLARE_HYDROGEN_ACCESSOR(Div)
673 class LDivByConstI final : public LTemplateInstruction<1, 1, 0> {
675 LDivByConstI(LOperand* dividend, int32_t divisor) {
676 inputs_[0] = dividend;
680 LOperand* dividend() { return inputs_[0]; }
681 int32_t divisor() const { return divisor_; }
683 DECLARE_CONCRETE_INSTRUCTION(DivByConstI, "div-by-const-i")
684 DECLARE_HYDROGEN_ACCESSOR(Div)
691 class LDivI final : public LTemplateInstruction<1, 2, 1> {
693 LDivI(LOperand* dividend, LOperand* divisor, LOperand* temp) {
694 inputs_[0] = dividend;
695 inputs_[1] = divisor;
699 LOperand* dividend() { return inputs_[0]; }
700 LOperand* divisor() { return inputs_[1]; }
701 LOperand* temp() { return temps_[0]; }
703 DECLARE_CONCRETE_INSTRUCTION(DivI, "div-i")
704 DECLARE_HYDROGEN_ACCESSOR(BinaryOperation)
708 class LFlooringDivByPowerOf2I final : public LTemplateInstruction<1, 1, 0> {
710 LFlooringDivByPowerOf2I(LOperand* dividend, int32_t divisor) {
711 inputs_[0] = dividend;
715 LOperand* dividend() { return inputs_[0]; }
716 int32_t divisor() { return divisor_; }
718 DECLARE_CONCRETE_INSTRUCTION(FlooringDivByPowerOf2I,
719 "flooring-div-by-power-of-2-i")
720 DECLARE_HYDROGEN_ACCESSOR(MathFloorOfDiv)
727 class LFlooringDivByConstI final : public LTemplateInstruction<1, 1, 2> {
729 LFlooringDivByConstI(LOperand* dividend, int32_t divisor, LOperand* temp) {
730 inputs_[0] = dividend;
735 LOperand* dividend() { return inputs_[0]; }
736 int32_t divisor() const { return divisor_; }
737 LOperand* temp() { return temps_[0]; }
739 DECLARE_CONCRETE_INSTRUCTION(FlooringDivByConstI, "flooring-div-by-const-i")
740 DECLARE_HYDROGEN_ACCESSOR(MathFloorOfDiv)
747 class LFlooringDivI final : public LTemplateInstruction<1, 2, 0> {
749 LFlooringDivI(LOperand* dividend, LOperand* divisor) {
750 inputs_[0] = dividend;
751 inputs_[1] = divisor;
754 LOperand* dividend() { return inputs_[0]; }
755 LOperand* divisor() { return inputs_[1]; }
757 DECLARE_CONCRETE_INSTRUCTION(FlooringDivI, "flooring-div-i")
758 DECLARE_HYDROGEN_ACCESSOR(MathFloorOfDiv)
762 class LMulI final : public LTemplateInstruction<1, 2, 0> {
764 LMulI(LOperand* left, LOperand* right) {
769 LOperand* left() { return inputs_[0]; }
770 LOperand* right() { return inputs_[1]; }
772 DECLARE_CONCRETE_INSTRUCTION(MulI, "mul-i")
773 DECLARE_HYDROGEN_ACCESSOR(Mul)
777 // Instruction for computing multiplier * multiplicand + addend.
778 class LMultiplyAddD final : public LTemplateInstruction<1, 3, 0> {
780 LMultiplyAddD(LOperand* addend, LOperand* multiplier,
781 LOperand* multiplicand) {
783 inputs_[1] = multiplier;
784 inputs_[2] = multiplicand;
787 LOperand* addend() { return inputs_[0]; }
788 LOperand* multiplier() { return inputs_[1]; }
789 LOperand* multiplicand() { return inputs_[2]; }
791 DECLARE_CONCRETE_INSTRUCTION(MultiplyAddD, "multiply-add-d")
795 class LDebugBreak final : public LTemplateInstruction<0, 0, 0> {
797 DECLARE_CONCRETE_INSTRUCTION(DebugBreak, "break")
801 class LCompareNumericAndBranch final : public LControlInstruction<2, 0> {
803 LCompareNumericAndBranch(LOperand* left, LOperand* right) {
808 LOperand* left() { return inputs_[0]; }
809 LOperand* right() { return inputs_[1]; }
811 DECLARE_CONCRETE_INSTRUCTION(CompareNumericAndBranch,
812 "compare-numeric-and-branch")
813 DECLARE_HYDROGEN_ACCESSOR(CompareNumericAndBranch)
815 Token::Value op() const { return hydrogen()->token(); }
816 bool is_double() const {
817 return hydrogen()->representation().IsDouble();
820 void PrintDataTo(StringStream* stream) override;
824 class LMathFloor final : public LTemplateInstruction<1, 1, 1> {
826 LMathFloor(LOperand* value, LOperand* temp) {
831 LOperand* value() { return inputs_[0]; }
832 LOperand* temp() { return temps_[0]; }
834 DECLARE_CONCRETE_INSTRUCTION(MathFloor, "math-floor")
835 DECLARE_HYDROGEN_ACCESSOR(UnaryMathOperation)
839 class LMathRound final : public LTemplateInstruction<1, 1, 1> {
841 LMathRound(LOperand* value, LOperand* temp) {
846 LOperand* value() { return inputs_[0]; }
847 LOperand* temp() { return temps_[0]; }
849 DECLARE_CONCRETE_INSTRUCTION(MathRound, "math-round")
850 DECLARE_HYDROGEN_ACCESSOR(UnaryMathOperation)
854 class LMathFround final : public LTemplateInstruction<1, 1, 0> {
856 explicit LMathFround(LOperand* value) { inputs_[0] = value; }
858 LOperand* value() { return inputs_[0]; }
860 DECLARE_CONCRETE_INSTRUCTION(MathFround, "math-fround")
864 class LMathAbs final : public LTemplateInstruction<1, 2, 0> {
866 LMathAbs(LOperand* context, LOperand* value) {
867 inputs_[1] = context;
871 LOperand* context() { return inputs_[1]; }
872 LOperand* value() { return inputs_[0]; }
874 DECLARE_CONCRETE_INSTRUCTION(MathAbs, "math-abs")
875 DECLARE_HYDROGEN_ACCESSOR(UnaryMathOperation)
879 class LMathLog final : public LTemplateInstruction<1, 1, 0> {
881 explicit LMathLog(LOperand* value) {
885 LOperand* value() { return inputs_[0]; }
887 DECLARE_CONCRETE_INSTRUCTION(MathLog, "math-log")
891 class LMathClz32 final : public LTemplateInstruction<1, 1, 0> {
893 explicit LMathClz32(LOperand* value) {
897 LOperand* value() { return inputs_[0]; }
899 DECLARE_CONCRETE_INSTRUCTION(MathClz32, "math-clz32")
903 class LMathExp final : public LTemplateInstruction<1, 1, 3> {
905 LMathExp(LOperand* value,
906 LOperand* double_temp,
912 temps_[2] = double_temp;
913 ExternalReference::InitializeMathExpData();
916 LOperand* value() { return inputs_[0]; }
917 LOperand* temp1() { return temps_[0]; }
918 LOperand* temp2() { return temps_[1]; }
919 LOperand* double_temp() { return temps_[2]; }
921 DECLARE_CONCRETE_INSTRUCTION(MathExp, "math-exp")
925 class LMathSqrt final : public LTemplateInstruction<1, 1, 0> {
927 explicit LMathSqrt(LOperand* value) {
931 LOperand* value() { return inputs_[0]; }
933 DECLARE_CONCRETE_INSTRUCTION(MathSqrt, "math-sqrt")
937 class LMathPowHalf final : public LTemplateInstruction<1, 1, 1> {
939 LMathPowHalf(LOperand* value, LOperand* temp) {
944 LOperand* value() { return inputs_[0]; }
945 LOperand* temp() { return temps_[0]; }
947 DECLARE_CONCRETE_INSTRUCTION(MathPowHalf, "math-pow-half")
951 class LCmpObjectEqAndBranch final : public LControlInstruction<2, 0> {
953 LCmpObjectEqAndBranch(LOperand* left, LOperand* right) {
958 LOperand* left() { return inputs_[0]; }
959 LOperand* right() { return inputs_[1]; }
961 DECLARE_CONCRETE_INSTRUCTION(CmpObjectEqAndBranch, "cmp-object-eq-and-branch")
962 DECLARE_HYDROGEN_ACCESSOR(CompareObjectEqAndBranch)
966 class LCmpHoleAndBranch final : public LControlInstruction<1, 0> {
968 explicit LCmpHoleAndBranch(LOperand* object) {
972 LOperand* object() { return inputs_[0]; }
974 DECLARE_CONCRETE_INSTRUCTION(CmpHoleAndBranch, "cmp-hole-and-branch")
975 DECLARE_HYDROGEN_ACCESSOR(CompareHoleAndBranch)
979 class LCompareMinusZeroAndBranch final : public LControlInstruction<1, 1> {
981 LCompareMinusZeroAndBranch(LOperand* value, LOperand* temp) {
986 LOperand* value() { return inputs_[0]; }
987 LOperand* temp() { return temps_[0]; }
989 DECLARE_CONCRETE_INSTRUCTION(CompareMinusZeroAndBranch,
990 "cmp-minus-zero-and-branch")
991 DECLARE_HYDROGEN_ACCESSOR(CompareMinusZeroAndBranch)
995 class LIsStringAndBranch final : public LControlInstruction<1, 1> {
997 LIsStringAndBranch(LOperand* value, LOperand* temp) {
1002 LOperand* value() { return inputs_[0]; }
1003 LOperand* temp() { return temps_[0]; }
1005 DECLARE_CONCRETE_INSTRUCTION(IsStringAndBranch, "is-string-and-branch")
1006 DECLARE_HYDROGEN_ACCESSOR(IsStringAndBranch)
1008 void PrintDataTo(StringStream* stream) override;
1012 class LIsSmiAndBranch final : public LControlInstruction<1, 0> {
1014 explicit LIsSmiAndBranch(LOperand* value) {
1018 LOperand* value() { return inputs_[0]; }
1020 DECLARE_CONCRETE_INSTRUCTION(IsSmiAndBranch, "is-smi-and-branch")
1021 DECLARE_HYDROGEN_ACCESSOR(IsSmiAndBranch)
1023 void PrintDataTo(StringStream* stream) override;
1027 class LIsUndetectableAndBranch final : public LControlInstruction<1, 1> {
1029 explicit LIsUndetectableAndBranch(LOperand* value, LOperand* temp) {
1034 LOperand* value() { return inputs_[0]; }
1035 LOperand* temp() { return temps_[0]; }
1037 DECLARE_CONCRETE_INSTRUCTION(IsUndetectableAndBranch,
1038 "is-undetectable-and-branch")
1039 DECLARE_HYDROGEN_ACCESSOR(IsUndetectableAndBranch)
1041 void PrintDataTo(StringStream* stream) override;
1045 class LStringCompareAndBranch final : public LControlInstruction<3, 0> {
1047 LStringCompareAndBranch(LOperand* context, LOperand* left, LOperand* right) {
1048 inputs_[0] = context;
1053 LOperand* context() { return inputs_[0]; }
1054 LOperand* left() { return inputs_[1]; }
1055 LOperand* right() { return inputs_[2]; }
1057 DECLARE_CONCRETE_INSTRUCTION(StringCompareAndBranch,
1058 "string-compare-and-branch")
1059 DECLARE_HYDROGEN_ACCESSOR(StringCompareAndBranch)
1061 Token::Value op() const { return hydrogen()->token(); }
1063 void PrintDataTo(StringStream* stream) override;
1067 class LHasInstanceTypeAndBranch final : public LControlInstruction<1, 0> {
1069 explicit LHasInstanceTypeAndBranch(LOperand* value) {
1073 LOperand* value() { return inputs_[0]; }
1075 DECLARE_CONCRETE_INSTRUCTION(HasInstanceTypeAndBranch,
1076 "has-instance-type-and-branch")
1077 DECLARE_HYDROGEN_ACCESSOR(HasInstanceTypeAndBranch)
1079 void PrintDataTo(StringStream* stream) override;
1083 class LGetCachedArrayIndex final : public LTemplateInstruction<1, 1, 0> {
1085 explicit LGetCachedArrayIndex(LOperand* value) {
1089 LOperand* value() { return inputs_[0]; }
1091 DECLARE_CONCRETE_INSTRUCTION(GetCachedArrayIndex, "get-cached-array-index")
1092 DECLARE_HYDROGEN_ACCESSOR(GetCachedArrayIndex)
1096 class LHasCachedArrayIndexAndBranch final : public LControlInstruction<1, 0> {
1098 explicit LHasCachedArrayIndexAndBranch(LOperand* value) {
1102 LOperand* value() { return inputs_[0]; }
1104 DECLARE_CONCRETE_INSTRUCTION(HasCachedArrayIndexAndBranch,
1105 "has-cached-array-index-and-branch")
1106 DECLARE_HYDROGEN_ACCESSOR(HasCachedArrayIndexAndBranch)
1108 void PrintDataTo(StringStream* stream) override;
1112 class LClassOfTestAndBranch final : public LControlInstruction<1, 1> {
1114 LClassOfTestAndBranch(LOperand* value, LOperand* temp) {
1119 LOperand* value() { return inputs_[0]; }
1120 LOperand* temp() { return temps_[0]; }
1122 DECLARE_CONCRETE_INSTRUCTION(ClassOfTestAndBranch,
1123 "class-of-test-and-branch")
1124 DECLARE_HYDROGEN_ACCESSOR(ClassOfTestAndBranch)
1126 void PrintDataTo(StringStream* stream) override;
1130 class LCmpT final : public LTemplateInstruction<1, 3, 0> {
1132 LCmpT(LOperand* context, LOperand* left, LOperand* right) {
1133 inputs_[0] = context;
1138 LOperand* context() { return inputs_[0]; }
1139 LOperand* left() { return inputs_[1]; }
1140 LOperand* right() { return inputs_[2]; }
1142 DECLARE_CONCRETE_INSTRUCTION(CmpT, "cmp-t")
1143 DECLARE_HYDROGEN_ACCESSOR(CompareGeneric)
1145 Strength strength() { return hydrogen()->strength(); }
1147 Token::Value op() const { return hydrogen()->token(); }
1151 class LInstanceOf final : public LTemplateInstruction<1, 3, 0> {
1153 LInstanceOf(LOperand* context, LOperand* left, LOperand* right) {
1154 inputs_[0] = context;
1159 LOperand* context() const { return inputs_[0]; }
1160 LOperand* left() const { return inputs_[1]; }
1161 LOperand* right() const { return inputs_[2]; }
1163 DECLARE_CONCRETE_INSTRUCTION(InstanceOf, "instance-of")
1167 class LHasInPrototypeChainAndBranch final : public LControlInstruction<2, 0> {
1169 LHasInPrototypeChainAndBranch(LOperand* object, LOperand* prototype) {
1170 inputs_[0] = object;
1171 inputs_[1] = prototype;
1174 LOperand* object() const { return inputs_[0]; }
1175 LOperand* prototype() const { return inputs_[1]; }
1177 DECLARE_CONCRETE_INSTRUCTION(HasInPrototypeChainAndBranch,
1178 "has-in-prototype-chain-and-branch")
1179 DECLARE_HYDROGEN_ACCESSOR(HasInPrototypeChainAndBranch)
1183 class LBoundsCheck final : public LTemplateInstruction<0, 2, 0> {
1185 LBoundsCheck(LOperand* index, LOperand* length) {
1187 inputs_[1] = length;
1190 LOperand* index() { return inputs_[0]; }
1191 LOperand* length() { return inputs_[1]; }
1193 DECLARE_CONCRETE_INSTRUCTION(BoundsCheck, "bounds-check")
1194 DECLARE_HYDROGEN_ACCESSOR(BoundsCheck)
1198 class LBitI final : public LTemplateInstruction<1, 2, 0> {
1200 LBitI(LOperand* left, LOperand* right) {
1205 LOperand* left() { return inputs_[0]; }
1206 LOperand* right() { return inputs_[1]; }
1208 Token::Value op() const { return hydrogen()->op(); }
1210 DECLARE_CONCRETE_INSTRUCTION(BitI, "bit-i")
1211 DECLARE_HYDROGEN_ACCESSOR(Bitwise)
1215 class LShiftI final : public LTemplateInstruction<1, 2, 0> {
1217 LShiftI(Token::Value op, LOperand* left, LOperand* right, bool can_deopt)
1218 : op_(op), can_deopt_(can_deopt) {
1223 Token::Value op() const { return op_; }
1224 LOperand* left() { return inputs_[0]; }
1225 LOperand* right() { return inputs_[1]; }
1226 bool can_deopt() const { return can_deopt_; }
1228 DECLARE_CONCRETE_INSTRUCTION(ShiftI, "shift-i")
1236 class LSubI final : public LTemplateInstruction<1, 2, 0> {
1238 LSubI(LOperand* left, LOperand* right) {
1243 LOperand* left() { return inputs_[0]; }
1244 LOperand* right() { return inputs_[1]; }
1246 DECLARE_CONCRETE_INSTRUCTION(SubI, "sub-i")
1247 DECLARE_HYDROGEN_ACCESSOR(Sub)
1251 class LConstantI final : public LTemplateInstruction<1, 0, 0> {
1253 DECLARE_CONCRETE_INSTRUCTION(ConstantI, "constant-i")
1254 DECLARE_HYDROGEN_ACCESSOR(Constant)
1256 int32_t value() const { return hydrogen()->Integer32Value(); }
1260 class LConstantS final : public LTemplateInstruction<1, 0, 0> {
1262 DECLARE_CONCRETE_INSTRUCTION(ConstantS, "constant-s")
1263 DECLARE_HYDROGEN_ACCESSOR(Constant)
1265 Smi* value() const { return Smi::FromInt(hydrogen()->Integer32Value()); }
1269 class LConstantD final : public LTemplateInstruction<1, 0, 0> {
1271 DECLARE_CONCRETE_INSTRUCTION(ConstantD, "constant-d")
1272 DECLARE_HYDROGEN_ACCESSOR(Constant)
1274 double value() const { return hydrogen()->DoubleValue(); }
1275 uint64_t bits() const { return hydrogen()->DoubleValueAsBits(); }
1279 class LConstantE final : public LTemplateInstruction<1, 0, 0> {
1281 DECLARE_CONCRETE_INSTRUCTION(ConstantE, "constant-e")
1282 DECLARE_HYDROGEN_ACCESSOR(Constant)
1284 ExternalReference value() const {
1285 return hydrogen()->ExternalReferenceValue();
1290 class LConstantT final : public LTemplateInstruction<1, 0, 0> {
1292 DECLARE_CONCRETE_INSTRUCTION(ConstantT, "constant-t")
1293 DECLARE_HYDROGEN_ACCESSOR(Constant)
1295 Handle<Object> value(Isolate* isolate) const {
1296 return hydrogen()->handle(isolate);
1301 class LBranch final : public LControlInstruction<1, 0> {
1303 explicit LBranch(LOperand* value) {
1307 LOperand* value() { return inputs_[0]; }
1309 DECLARE_CONCRETE_INSTRUCTION(Branch, "branch")
1310 DECLARE_HYDROGEN_ACCESSOR(Branch)
1312 void PrintDataTo(StringStream* stream) override;
1316 class LCmpMapAndBranch final : public LControlInstruction<1, 1> {
1318 LCmpMapAndBranch(LOperand* value, LOperand* temp) {
1323 LOperand* value() { return inputs_[0]; }
1324 LOperand* temp() { return temps_[0]; }
1326 DECLARE_CONCRETE_INSTRUCTION(CmpMapAndBranch, "cmp-map-and-branch")
1327 DECLARE_HYDROGEN_ACCESSOR(CompareMap)
1329 Handle<Map> map() const { return hydrogen()->map().handle(); }
1333 class LMapEnumLength final : public LTemplateInstruction<1, 1, 0> {
1335 explicit LMapEnumLength(LOperand* value) {
1339 LOperand* value() { return inputs_[0]; }
1341 DECLARE_CONCRETE_INSTRUCTION(MapEnumLength, "map-enum-length")
1345 class LDateField final : public LTemplateInstruction<1, 1, 1> {
1347 LDateField(LOperand* date, LOperand* temp, Smi* index) : index_(index) {
1352 LOperand* date() { return inputs_[0]; }
1353 LOperand* temp() { return temps_[0]; }
1354 Smi* index() const { return index_; }
1356 DECLARE_CONCRETE_INSTRUCTION(DateField, "date-field")
1357 DECLARE_HYDROGEN_ACCESSOR(DateField)
1364 class LSeqStringGetChar final : public LTemplateInstruction<1, 2, 0> {
1366 LSeqStringGetChar(LOperand* string, LOperand* index) {
1367 inputs_[0] = string;
1371 LOperand* string() const { return inputs_[0]; }
1372 LOperand* index() const { return inputs_[1]; }
1374 DECLARE_CONCRETE_INSTRUCTION(SeqStringGetChar, "seq-string-get-char")
1375 DECLARE_HYDROGEN_ACCESSOR(SeqStringGetChar)
1379 class LSeqStringSetChar final : public LTemplateInstruction<1, 4, 0> {
1381 LSeqStringSetChar(LOperand* context,
1385 inputs_[0] = context;
1386 inputs_[1] = string;
1391 LOperand* string() { return inputs_[1]; }
1392 LOperand* index() { return inputs_[2]; }
1393 LOperand* value() { return inputs_[3]; }
1395 DECLARE_CONCRETE_INSTRUCTION(SeqStringSetChar, "seq-string-set-char")
1396 DECLARE_HYDROGEN_ACCESSOR(SeqStringSetChar)
1400 class LAddI final : public LTemplateInstruction<1, 2, 0> {
1402 LAddI(LOperand* left, LOperand* right) {
1407 LOperand* left() { return inputs_[0]; }
1408 LOperand* right() { return inputs_[1]; }
1410 DECLARE_CONCRETE_INSTRUCTION(AddI, "add-i")
1411 DECLARE_HYDROGEN_ACCESSOR(Add)
1415 class LMathMinMax final : public LTemplateInstruction<1, 2, 0> {
1417 LMathMinMax(LOperand* left, LOperand* right) {
1422 LOperand* left() { return inputs_[0]; }
1423 LOperand* right() { return inputs_[1]; }
1425 DECLARE_CONCRETE_INSTRUCTION(MathMinMax, "math-min-max")
1426 DECLARE_HYDROGEN_ACCESSOR(MathMinMax)
1430 class LPower final : public LTemplateInstruction<1, 2, 0> {
1432 LPower(LOperand* left, LOperand* right) {
1437 LOperand* left() { return inputs_[0]; }
1438 LOperand* right() { return inputs_[1]; }
1440 DECLARE_CONCRETE_INSTRUCTION(Power, "power")
1441 DECLARE_HYDROGEN_ACCESSOR(Power)
1445 class LArithmeticD final : public LTemplateInstruction<1, 2, 0> {
1447 LArithmeticD(Token::Value op, LOperand* left, LOperand* right)
1453 Token::Value op() const { return op_; }
1454 LOperand* left() { return inputs_[0]; }
1455 LOperand* right() { return inputs_[1]; }
1457 Opcode opcode() const override { return LInstruction::kArithmeticD; }
1458 void CompileToNative(LCodeGen* generator) override;
1459 const char* Mnemonic() const override;
1466 class LArithmeticT final : public LTemplateInstruction<1, 3, 0> {
1468 LArithmeticT(Token::Value op,
1473 inputs_[0] = context;
1478 LOperand* context() { return inputs_[0]; }
1479 LOperand* left() { return inputs_[1]; }
1480 LOperand* right() { return inputs_[2]; }
1481 Token::Value op() const { return op_; }
1483 Opcode opcode() const final { return LInstruction::kArithmeticT; }
1484 void CompileToNative(LCodeGen* generator) override;
1485 const char* Mnemonic() const override;
1487 DECLARE_HYDROGEN_ACCESSOR(BinaryOperation)
1489 Strength strength() { return hydrogen()->strength(); }
1496 class LReturn final : public LTemplateInstruction<0, 3, 0> {
1498 LReturn(LOperand* value, LOperand* context, LOperand* parameter_count) {
1500 inputs_[1] = context;
1501 inputs_[2] = parameter_count;
1504 LOperand* value() { return inputs_[0]; }
1506 bool has_constant_parameter_count() {
1507 return parameter_count()->IsConstantOperand();
1509 LConstantOperand* constant_parameter_count() {
1510 DCHECK(has_constant_parameter_count());
1511 return LConstantOperand::cast(parameter_count());
1513 LOperand* parameter_count() { return inputs_[2]; }
1515 DECLARE_CONCRETE_INSTRUCTION(Return, "return")
1519 class LLoadNamedField final : public LTemplateInstruction<1, 1, 0> {
1521 explicit LLoadNamedField(LOperand* object) {
1522 inputs_[0] = object;
1525 LOperand* object() { return inputs_[0]; }
1527 DECLARE_CONCRETE_INSTRUCTION(LoadNamedField, "load-named-field")
1528 DECLARE_HYDROGEN_ACCESSOR(LoadNamedField)
1532 class LLoadNamedGeneric final : public LTemplateInstruction<1, 2, 1> {
1534 LLoadNamedGeneric(LOperand* context, LOperand* object, LOperand* vector) {
1535 inputs_[0] = context;
1536 inputs_[1] = object;
1540 LOperand* context() { return inputs_[0]; }
1541 LOperand* object() { return inputs_[1]; }
1542 LOperand* temp_vector() { return temps_[0]; }
1544 DECLARE_CONCRETE_INSTRUCTION(LoadNamedGeneric, "load-named-generic")
1545 DECLARE_HYDROGEN_ACCESSOR(LoadNamedGeneric)
1547 Handle<Object> name() const { return hydrogen()->name(); }
1551 class LLoadFunctionPrototype final : public LTemplateInstruction<1, 1, 0> {
1553 explicit LLoadFunctionPrototype(LOperand* function) {
1554 inputs_[0] = function;
1557 LOperand* function() { return inputs_[0]; }
1559 DECLARE_CONCRETE_INSTRUCTION(LoadFunctionPrototype, "load-function-prototype")
1560 DECLARE_HYDROGEN_ACCESSOR(LoadFunctionPrototype)
1564 class LLoadRoot final : public LTemplateInstruction<1, 0, 0> {
1566 DECLARE_CONCRETE_INSTRUCTION(LoadRoot, "load-root")
1567 DECLARE_HYDROGEN_ACCESSOR(LoadRoot)
1569 Heap::RootListIndex index() const { return hydrogen()->index(); }
1573 class LLoadKeyed final : public LTemplateInstruction<1, 2, 0> {
1575 LLoadKeyed(LOperand* elements, LOperand* key) {
1576 inputs_[0] = elements;
1580 LOperand* elements() { return inputs_[0]; }
1581 LOperand* key() { return inputs_[1]; }
1582 ElementsKind elements_kind() const {
1583 return hydrogen()->elements_kind();
1585 bool is_fixed_typed_array() const {
1586 return hydrogen()->is_fixed_typed_array();
1589 DECLARE_CONCRETE_INSTRUCTION(LoadKeyed, "load-keyed")
1590 DECLARE_HYDROGEN_ACCESSOR(LoadKeyed)
1592 void PrintDataTo(StringStream* stream) override;
1593 uint32_t base_offset() const { return hydrogen()->base_offset(); }
1597 class LLoadKeyedGeneric final : public LTemplateInstruction<1, 3, 1> {
1599 LLoadKeyedGeneric(LOperand* context, LOperand* object, LOperand* key,
1601 inputs_[0] = context;
1602 inputs_[1] = object;
1607 LOperand* context() { return inputs_[0]; }
1608 LOperand* object() { return inputs_[1]; }
1609 LOperand* key() { return inputs_[2]; }
1610 LOperand* temp_vector() { return temps_[0]; }
1612 DECLARE_CONCRETE_INSTRUCTION(LoadKeyedGeneric, "load-keyed-generic")
1613 DECLARE_HYDROGEN_ACCESSOR(LoadKeyedGeneric)
1617 class LLoadGlobalGeneric final : public LTemplateInstruction<1, 2, 1> {
1619 LLoadGlobalGeneric(LOperand* context, LOperand* global_object,
1621 inputs_[0] = context;
1622 inputs_[1] = global_object;
1626 LOperand* context() { return inputs_[0]; }
1627 LOperand* global_object() { return inputs_[1]; }
1628 LOperand* temp_vector() { return temps_[0]; }
1630 DECLARE_CONCRETE_INSTRUCTION(LoadGlobalGeneric, "load-global-generic")
1631 DECLARE_HYDROGEN_ACCESSOR(LoadGlobalGeneric)
1633 Handle<Object> name() const { return hydrogen()->name(); }
1634 TypeofMode typeof_mode() const { return hydrogen()->typeof_mode(); }
1638 class LLoadGlobalViaContext final : public LTemplateInstruction<1, 1, 1> {
1640 explicit LLoadGlobalViaContext(LOperand* context) { inputs_[0] = context; }
1642 DECLARE_CONCRETE_INSTRUCTION(LoadGlobalViaContext, "load-global-via-context")
1643 DECLARE_HYDROGEN_ACCESSOR(LoadGlobalViaContext)
1645 void PrintDataTo(StringStream* stream) override;
1647 LOperand* context() { return inputs_[0]; }
1649 int depth() const { return hydrogen()->depth(); }
1650 int slot_index() const { return hydrogen()->slot_index(); }
1654 class LLoadContextSlot final : public LTemplateInstruction<1, 1, 0> {
1656 explicit LLoadContextSlot(LOperand* context) {
1657 inputs_[0] = context;
1660 LOperand* context() { return inputs_[0]; }
1662 DECLARE_CONCRETE_INSTRUCTION(LoadContextSlot, "load-context-slot")
1663 DECLARE_HYDROGEN_ACCESSOR(LoadContextSlot)
1665 int slot_index() { return hydrogen()->slot_index(); }
1667 void PrintDataTo(StringStream* stream) override;
1671 class LStoreContextSlot final : public LTemplateInstruction<0, 2, 0> {
1673 LStoreContextSlot(LOperand* context, LOperand* value) {
1674 inputs_[0] = context;
1678 LOperand* context() { return inputs_[0]; }
1679 LOperand* value() { return inputs_[1]; }
1681 DECLARE_CONCRETE_INSTRUCTION(StoreContextSlot, "store-context-slot")
1682 DECLARE_HYDROGEN_ACCESSOR(StoreContextSlot)
1684 int slot_index() { return hydrogen()->slot_index(); }
1686 void PrintDataTo(StringStream* stream) override;
1690 class LPushArgument final : public LTemplateInstruction<0, 1, 0> {
1692 explicit LPushArgument(LOperand* value) {
1696 LOperand* value() { return inputs_[0]; }
1698 DECLARE_CONCRETE_INSTRUCTION(PushArgument, "push-argument")
1702 class LDrop final : public LTemplateInstruction<0, 0, 0> {
1704 explicit LDrop(int count) : count_(count) { }
1706 int count() const { return count_; }
1708 DECLARE_CONCRETE_INSTRUCTION(Drop, "drop")
1715 class LStoreCodeEntry final : public LTemplateInstruction<0, 2, 0> {
1717 LStoreCodeEntry(LOperand* function, LOperand* code_object) {
1718 inputs_[0] = function;
1719 inputs_[1] = code_object;
1722 LOperand* function() { return inputs_[0]; }
1723 LOperand* code_object() { return inputs_[1]; }
1725 void PrintDataTo(StringStream* stream) override;
1727 DECLARE_CONCRETE_INSTRUCTION(StoreCodeEntry, "store-code-entry")
1728 DECLARE_HYDROGEN_ACCESSOR(StoreCodeEntry)
1732 class LInnerAllocatedObject final : public LTemplateInstruction<1, 2, 0> {
1734 LInnerAllocatedObject(LOperand* base_object, LOperand* offset) {
1735 inputs_[0] = base_object;
1736 inputs_[1] = offset;
1739 LOperand* base_object() const { return inputs_[0]; }
1740 LOperand* offset() const { return inputs_[1]; }
1742 void PrintDataTo(StringStream* stream) override;
1744 DECLARE_CONCRETE_INSTRUCTION(InnerAllocatedObject, "inner-allocated-object")
1748 class LThisFunction final : public LTemplateInstruction<1, 0, 0> {
1750 DECLARE_CONCRETE_INSTRUCTION(ThisFunction, "this-function")
1751 DECLARE_HYDROGEN_ACCESSOR(ThisFunction)
1755 class LContext final : public LTemplateInstruction<1, 0, 0> {
1757 DECLARE_CONCRETE_INSTRUCTION(Context, "context")
1758 DECLARE_HYDROGEN_ACCESSOR(Context)
1762 class LDeclareGlobals final : public LTemplateInstruction<0, 1, 0> {
1764 explicit LDeclareGlobals(LOperand* context) {
1765 inputs_[0] = context;
1768 LOperand* context() { return inputs_[0]; }
1770 DECLARE_CONCRETE_INSTRUCTION(DeclareGlobals, "declare-globals")
1771 DECLARE_HYDROGEN_ACCESSOR(DeclareGlobals)
1775 class LCallJSFunction final : public LTemplateInstruction<1, 1, 0> {
1777 explicit LCallJSFunction(LOperand* function) {
1778 inputs_[0] = function;
1781 LOperand* function() { return inputs_[0]; }
1783 DECLARE_CONCRETE_INSTRUCTION(CallJSFunction, "call-js-function")
1784 DECLARE_HYDROGEN_ACCESSOR(CallJSFunction)
1786 void PrintDataTo(StringStream* stream) override;
1788 int arity() const { return hydrogen()->argument_count() - 1; }
1792 class LCallWithDescriptor final : public LTemplateResultInstruction<1> {
1794 LCallWithDescriptor(CallInterfaceDescriptor descriptor,
1795 const ZoneList<LOperand*>& operands, Zone* zone)
1796 : descriptor_(descriptor),
1797 inputs_(descriptor.GetRegisterParameterCount() +
1798 kImplicitRegisterParameterCount,
1800 DCHECK(descriptor.GetRegisterParameterCount() +
1801 kImplicitRegisterParameterCount ==
1803 inputs_.AddAll(operands, zone);
1806 LOperand* target() const { return inputs_[0]; }
1808 const CallInterfaceDescriptor descriptor() { return descriptor_; }
1810 DECLARE_HYDROGEN_ACCESSOR(CallWithDescriptor)
1812 // The target and context are passed as implicit parameters that are not
1813 // explicitly listed in the descriptor.
1814 static const int kImplicitRegisterParameterCount = 2;
1817 DECLARE_CONCRETE_INSTRUCTION(CallWithDescriptor, "call-with-descriptor")
1819 void PrintDataTo(StringStream* stream) override;
1821 int arity() const { return hydrogen()->argument_count() - 1; }
1823 CallInterfaceDescriptor descriptor_;
1824 ZoneList<LOperand*> inputs_;
1826 // Iterator support.
1827 int InputCount() final { return inputs_.length(); }
1828 LOperand* InputAt(int i) final { return inputs_[i]; }
1830 int TempCount() final { return 0; }
1831 LOperand* TempAt(int i) final { return NULL; }
1835 class LInvokeFunction final : public LTemplateInstruction<1, 2, 0> {
1837 LInvokeFunction(LOperand* context, LOperand* function) {
1838 inputs_[0] = context;
1839 inputs_[1] = function;
1842 LOperand* context() { return inputs_[0]; }
1843 LOperand* function() { return inputs_[1]; }
1845 DECLARE_CONCRETE_INSTRUCTION(InvokeFunction, "invoke-function")
1846 DECLARE_HYDROGEN_ACCESSOR(InvokeFunction)
1848 void PrintDataTo(StringStream* stream) override;
1850 int arity() const { return hydrogen()->argument_count() - 1; }
1854 class LCallFunction final : public LTemplateInstruction<1, 2, 2> {
1856 LCallFunction(LOperand* context, LOperand* function, LOperand* slot,
1858 inputs_[0] = context;
1859 inputs_[1] = function;
1864 LOperand* context() { return inputs_[0]; }
1865 LOperand* function() { return inputs_[1]; }
1866 LOperand* temp_slot() { return temps_[0]; }
1867 LOperand* temp_vector() { return temps_[1]; }
1869 DECLARE_CONCRETE_INSTRUCTION(CallFunction, "call-function")
1870 DECLARE_HYDROGEN_ACCESSOR(CallFunction)
1872 int arity() const { return hydrogen()->argument_count() - 1; }
1873 void PrintDataTo(StringStream* stream) override;
1877 class LCallNew final : public LTemplateInstruction<1, 2, 0> {
1879 LCallNew(LOperand* context, LOperand* constructor) {
1880 inputs_[0] = context;
1881 inputs_[1] = constructor;
1884 LOperand* context() { return inputs_[0]; }
1885 LOperand* constructor() { return inputs_[1]; }
1887 DECLARE_CONCRETE_INSTRUCTION(CallNew, "call-new")
1888 DECLARE_HYDROGEN_ACCESSOR(CallNew)
1890 void PrintDataTo(StringStream* stream) override;
1892 int arity() const { return hydrogen()->argument_count() - 1; }
1896 class LCallNewArray final : public LTemplateInstruction<1, 2, 0> {
1898 LCallNewArray(LOperand* context, LOperand* constructor) {
1899 inputs_[0] = context;
1900 inputs_[1] = constructor;
1903 LOperand* context() { return inputs_[0]; }
1904 LOperand* constructor() { return inputs_[1]; }
1906 DECLARE_CONCRETE_INSTRUCTION(CallNewArray, "call-new-array")
1907 DECLARE_HYDROGEN_ACCESSOR(CallNewArray)
1909 void PrintDataTo(StringStream* stream) override;
1911 int arity() const { return hydrogen()->argument_count() - 1; }
1915 class LCallRuntime final : public LTemplateInstruction<1, 1, 0> {
1917 explicit LCallRuntime(LOperand* context) {
1918 inputs_[0] = context;
1921 LOperand* context() { return inputs_[0]; }
1923 DECLARE_CONCRETE_INSTRUCTION(CallRuntime, "call-runtime")
1924 DECLARE_HYDROGEN_ACCESSOR(CallRuntime)
1926 bool ClobbersDoubleRegisters(Isolate* isolate) const override {
1927 return save_doubles() == kDontSaveFPRegs;
1930 const Runtime::Function* function() const { return hydrogen()->function(); }
1931 int arity() const { return hydrogen()->argument_count(); }
1932 SaveFPRegsMode save_doubles() const { return hydrogen()->save_doubles(); }
1936 class LInteger32ToDouble final : public LTemplateInstruction<1, 1, 0> {
1938 explicit LInteger32ToDouble(LOperand* value) {
1942 LOperand* value() { return inputs_[0]; }
1944 DECLARE_CONCRETE_INSTRUCTION(Integer32ToDouble, "int32-to-double")
1948 class LUint32ToDouble final : public LTemplateInstruction<1, 1, 0> {
1950 explicit LUint32ToDouble(LOperand* value) {
1954 LOperand* value() { return inputs_[0]; }
1956 DECLARE_CONCRETE_INSTRUCTION(Uint32ToDouble, "uint32-to-double")
1960 class LNumberTagI final : public LTemplateInstruction<1, 1, 2> {
1962 LNumberTagI(LOperand* value, LOperand* temp1, LOperand* temp2) {
1968 LOperand* value() { return inputs_[0]; }
1969 LOperand* temp1() { return temps_[0]; }
1970 LOperand* temp2() { return temps_[1]; }
1972 DECLARE_CONCRETE_INSTRUCTION(NumberTagI, "number-tag-i")
1976 class LNumberTagU final : public LTemplateInstruction<1, 1, 2> {
1978 LNumberTagU(LOperand* value, LOperand* temp1, LOperand* temp2) {
1984 LOperand* value() { return inputs_[0]; }
1985 LOperand* temp1() { return temps_[0]; }
1986 LOperand* temp2() { return temps_[1]; }
1988 DECLARE_CONCRETE_INSTRUCTION(NumberTagU, "number-tag-u")
1992 class LNumberTagD final : public LTemplateInstruction<1, 1, 2> {
1994 LNumberTagD(LOperand* value, LOperand* temp, LOperand* temp2) {
2000 LOperand* value() { return inputs_[0]; }
2001 LOperand* temp() { return temps_[0]; }
2002 LOperand* temp2() { return temps_[1]; }
2004 DECLARE_CONCRETE_INSTRUCTION(NumberTagD, "number-tag-d")
2005 DECLARE_HYDROGEN_ACCESSOR(Change)
2009 class LDoubleToSmi final : public LTemplateInstruction<1, 1, 0> {
2011 explicit LDoubleToSmi(LOperand* value) {
2015 LOperand* value() { return inputs_[0]; }
2017 DECLARE_CONCRETE_INSTRUCTION(DoubleToSmi, "double-to-smi")
2018 DECLARE_HYDROGEN_ACCESSOR(UnaryOperation)
2020 bool truncating() { return hydrogen()->CanTruncateToInt32(); }
2024 // Sometimes truncating conversion from a tagged value to an int32.
2025 class LDoubleToI final : public LTemplateInstruction<1, 1, 0> {
2027 explicit LDoubleToI(LOperand* value) {
2031 LOperand* value() { return inputs_[0]; }
2033 DECLARE_CONCRETE_INSTRUCTION(DoubleToI, "double-to-i")
2034 DECLARE_HYDROGEN_ACCESSOR(UnaryOperation)
2036 bool truncating() { return hydrogen()->CanTruncateToInt32(); }
2040 // Truncating conversion from a tagged value to an int32.
2041 class LTaggedToI final : public LTemplateInstruction<1, 1, 2> {
2043 LTaggedToI(LOperand* value,
2051 LOperand* value() { return inputs_[0]; }
2052 LOperand* temp() { return temps_[0]; }
2053 LOperand* temp2() { return temps_[1]; }
2055 DECLARE_CONCRETE_INSTRUCTION(TaggedToI, "tagged-to-i")
2056 DECLARE_HYDROGEN_ACCESSOR(Change)
2058 bool truncating() { return hydrogen()->CanTruncateToInt32(); }
2062 class LSmiTag final : public LTemplateInstruction<1, 1, 0> {
2064 explicit LSmiTag(LOperand* value) {
2068 LOperand* value() { return inputs_[0]; }
2070 DECLARE_CONCRETE_INSTRUCTION(SmiTag, "smi-tag")
2071 DECLARE_HYDROGEN_ACCESSOR(Change)
2075 class LNumberUntagD final : public LTemplateInstruction<1, 1, 0> {
2077 explicit LNumberUntagD(LOperand* value) {
2081 LOperand* value() { return inputs_[0]; }
2083 DECLARE_CONCRETE_INSTRUCTION(NumberUntagD, "double-untag")
2084 DECLARE_HYDROGEN_ACCESSOR(Change)
2088 class LSmiUntag final : public LTemplateInstruction<1, 1, 0> {
2090 LSmiUntag(LOperand* value, bool needs_check)
2091 : needs_check_(needs_check) {
2095 LOperand* value() { return inputs_[0]; }
2096 bool needs_check() const { return needs_check_; }
2098 DECLARE_CONCRETE_INSTRUCTION(SmiUntag, "smi-untag")
2105 class LStoreNamedField final : public LTemplateInstruction<0, 2, 1> {
2107 LStoreNamedField(LOperand* object, LOperand* value, LOperand* temp) {
2108 inputs_[0] = object;
2113 LOperand* object() { return inputs_[0]; }
2114 LOperand* value() { return inputs_[1]; }
2115 LOperand* temp() { return temps_[0]; }
2117 DECLARE_CONCRETE_INSTRUCTION(StoreNamedField, "store-named-field")
2118 DECLARE_HYDROGEN_ACCESSOR(StoreNamedField)
2120 void PrintDataTo(StringStream* stream) override;
2122 Representation representation() const {
2123 return hydrogen()->field_representation();
2128 class LStoreNamedGeneric final : public LTemplateInstruction<0, 3, 2> {
2130 LStoreNamedGeneric(LOperand* context, LOperand* object, LOperand* value,
2131 LOperand* slot, LOperand* vector) {
2132 inputs_[0] = context;
2133 inputs_[1] = object;
2139 LOperand* context() { return inputs_[0]; }
2140 LOperand* object() { return inputs_[1]; }
2141 LOperand* value() { return inputs_[2]; }
2142 LOperand* temp_slot() { return temps_[0]; }
2143 LOperand* temp_vector() { return temps_[1]; }
2145 DECLARE_CONCRETE_INSTRUCTION(StoreNamedGeneric, "store-named-generic")
2146 DECLARE_HYDROGEN_ACCESSOR(StoreNamedGeneric)
2148 void PrintDataTo(StringStream* stream) override;
2150 Handle<Object> name() const { return hydrogen()->name(); }
2151 LanguageMode language_mode() { return hydrogen()->language_mode(); }
2155 class LStoreGlobalViaContext final : public LTemplateInstruction<0, 2, 0> {
2157 LStoreGlobalViaContext(LOperand* context, LOperand* value) {
2158 inputs_[0] = context;
2162 LOperand* context() { return inputs_[0]; }
2163 LOperand* value() { return inputs_[1]; }
2165 DECLARE_CONCRETE_INSTRUCTION(StoreGlobalViaContext,
2166 "store-global-via-context")
2167 DECLARE_HYDROGEN_ACCESSOR(StoreGlobalViaContext)
2169 void PrintDataTo(StringStream* stream) override;
2171 int depth() { return hydrogen()->depth(); }
2172 int slot_index() { return hydrogen()->slot_index(); }
2173 LanguageMode language_mode() { return hydrogen()->language_mode(); }
2177 class LStoreKeyed final : public LTemplateInstruction<0, 3, 0> {
2179 LStoreKeyed(LOperand* object, LOperand* key, LOperand* value) {
2180 inputs_[0] = object;
2185 bool is_fixed_typed_array() const {
2186 return hydrogen()->is_fixed_typed_array();
2188 LOperand* elements() { return inputs_[0]; }
2189 LOperand* key() { return inputs_[1]; }
2190 LOperand* value() { return inputs_[2]; }
2191 ElementsKind elements_kind() const {
2192 return hydrogen()->elements_kind();
2195 DECLARE_CONCRETE_INSTRUCTION(StoreKeyed, "store-keyed")
2196 DECLARE_HYDROGEN_ACCESSOR(StoreKeyed)
2198 void PrintDataTo(StringStream* stream) override;
2199 bool NeedsCanonicalization() { return hydrogen()->NeedsCanonicalization(); }
2200 uint32_t base_offset() const { return hydrogen()->base_offset(); }
2204 class LStoreKeyedGeneric final : public LTemplateInstruction<0, 4, 2> {
2206 LStoreKeyedGeneric(LOperand* context, LOperand* object, LOperand* key,
2207 LOperand* value, LOperand* slot, LOperand* vector) {
2208 inputs_[0] = context;
2209 inputs_[1] = object;
2216 LOperand* context() { return inputs_[0]; }
2217 LOperand* object() { return inputs_[1]; }
2218 LOperand* key() { return inputs_[2]; }
2219 LOperand* value() { return inputs_[3]; }
2220 LOperand* temp_slot() { return temps_[0]; }
2221 LOperand* temp_vector() { return temps_[1]; }
2223 DECLARE_CONCRETE_INSTRUCTION(StoreKeyedGeneric, "store-keyed-generic")
2224 DECLARE_HYDROGEN_ACCESSOR(StoreKeyedGeneric)
2226 void PrintDataTo(StringStream* stream) override;
2228 LanguageMode language_mode() { return hydrogen()->language_mode(); }
2232 class LTransitionElementsKind final : public LTemplateInstruction<0, 2, 1> {
2234 LTransitionElementsKind(LOperand* object,
2236 LOperand* new_map_temp) {
2237 inputs_[0] = object;
2238 inputs_[1] = context;
2239 temps_[0] = new_map_temp;
2242 LOperand* context() { return inputs_[1]; }
2243 LOperand* object() { return inputs_[0]; }
2244 LOperand* new_map_temp() { return temps_[0]; }
2246 DECLARE_CONCRETE_INSTRUCTION(TransitionElementsKind,
2247 "transition-elements-kind")
2248 DECLARE_HYDROGEN_ACCESSOR(TransitionElementsKind)
2250 void PrintDataTo(StringStream* stream) override;
2252 Handle<Map> original_map() { return hydrogen()->original_map().handle(); }
2253 Handle<Map> transitioned_map() {
2254 return hydrogen()->transitioned_map().handle();
2256 ElementsKind from_kind() { return hydrogen()->from_kind(); }
2257 ElementsKind to_kind() { return hydrogen()->to_kind(); }
2261 class LTrapAllocationMemento final : public LTemplateInstruction<0, 1, 1> {
2263 LTrapAllocationMemento(LOperand* object,
2265 inputs_[0] = object;
2269 LOperand* object() { return inputs_[0]; }
2270 LOperand* temp() { return temps_[0]; }
2272 DECLARE_CONCRETE_INSTRUCTION(TrapAllocationMemento,
2273 "trap-allocation-memento")
2277 class LMaybeGrowElements final : public LTemplateInstruction<1, 5, 0> {
2279 LMaybeGrowElements(LOperand* context, LOperand* object, LOperand* elements,
2280 LOperand* key, LOperand* current_capacity) {
2281 inputs_[0] = context;
2282 inputs_[1] = object;
2283 inputs_[2] = elements;
2285 inputs_[4] = current_capacity;
2288 LOperand* context() { return inputs_[0]; }
2289 LOperand* object() { return inputs_[1]; }
2290 LOperand* elements() { return inputs_[2]; }
2291 LOperand* key() { return inputs_[3]; }
2292 LOperand* current_capacity() { return inputs_[4]; }
2294 DECLARE_HYDROGEN_ACCESSOR(MaybeGrowElements)
2295 DECLARE_CONCRETE_INSTRUCTION(MaybeGrowElements, "maybe-grow-elements")
2299 class LStringAdd final : public LTemplateInstruction<1, 3, 0> {
2301 LStringAdd(LOperand* context, LOperand* left, LOperand* right) {
2302 inputs_[0] = context;
2307 LOperand* context() { return inputs_[0]; }
2308 LOperand* left() { return inputs_[1]; }
2309 LOperand* right() { return inputs_[2]; }
2311 DECLARE_CONCRETE_INSTRUCTION(StringAdd, "string-add")
2312 DECLARE_HYDROGEN_ACCESSOR(StringAdd)
2316 class LStringCharCodeAt final : public LTemplateInstruction<1, 3, 0> {
2318 LStringCharCodeAt(LOperand* context, LOperand* string, LOperand* index) {
2319 inputs_[0] = context;
2320 inputs_[1] = string;
2324 LOperand* context() { return inputs_[0]; }
2325 LOperand* string() { return inputs_[1]; }
2326 LOperand* index() { return inputs_[2]; }
2328 DECLARE_CONCRETE_INSTRUCTION(StringCharCodeAt, "string-char-code-at")
2329 DECLARE_HYDROGEN_ACCESSOR(StringCharCodeAt)
2333 class LStringCharFromCode final : public LTemplateInstruction<1, 2, 0> {
2335 explicit LStringCharFromCode(LOperand* context, LOperand* char_code) {
2336 inputs_[0] = context;
2337 inputs_[1] = char_code;
2340 LOperand* context() { return inputs_[0]; }
2341 LOperand* char_code() { return inputs_[1]; }
2343 DECLARE_CONCRETE_INSTRUCTION(StringCharFromCode, "string-char-from-code")
2344 DECLARE_HYDROGEN_ACCESSOR(StringCharFromCode)
2348 class LCheckValue final : public LTemplateInstruction<0, 1, 0> {
2350 explicit LCheckValue(LOperand* value) {
2354 LOperand* value() { return inputs_[0]; }
2356 DECLARE_CONCRETE_INSTRUCTION(CheckValue, "check-value")
2357 DECLARE_HYDROGEN_ACCESSOR(CheckValue)
2361 class LCheckArrayBufferNotNeutered final
2362 : public LTemplateInstruction<0, 1, 0> {
2364 explicit LCheckArrayBufferNotNeutered(LOperand* view) { inputs_[0] = view; }
2366 LOperand* view() { return inputs_[0]; }
2368 DECLARE_CONCRETE_INSTRUCTION(CheckArrayBufferNotNeutered,
2369 "check-array-buffer-not-neutered")
2370 DECLARE_HYDROGEN_ACCESSOR(CheckArrayBufferNotNeutered)
2374 class LCheckInstanceType final : public LTemplateInstruction<0, 1, 0> {
2376 explicit LCheckInstanceType(LOperand* value) {
2380 LOperand* value() { return inputs_[0]; }
2382 DECLARE_CONCRETE_INSTRUCTION(CheckInstanceType, "check-instance-type")
2383 DECLARE_HYDROGEN_ACCESSOR(CheckInstanceType)
2387 class LCheckMaps final : public LTemplateInstruction<0, 1, 0> {
2389 explicit LCheckMaps(LOperand* value = NULL) {
2393 LOperand* value() { return inputs_[0]; }
2395 DECLARE_CONCRETE_INSTRUCTION(CheckMaps, "check-maps")
2396 DECLARE_HYDROGEN_ACCESSOR(CheckMaps)
2400 class LCheckSmi final : public LTemplateInstruction<1, 1, 0> {
2402 explicit LCheckSmi(LOperand* value) {
2406 LOperand* value() { return inputs_[0]; }
2408 DECLARE_CONCRETE_INSTRUCTION(CheckSmi, "check-smi")
2412 class LCheckNonSmi final : public LTemplateInstruction<0, 1, 0> {
2414 explicit LCheckNonSmi(LOperand* value) {
2418 LOperand* value() { return inputs_[0]; }
2420 DECLARE_CONCRETE_INSTRUCTION(CheckNonSmi, "check-non-smi")
2421 DECLARE_HYDROGEN_ACCESSOR(CheckHeapObject)
2425 class LClampDToUint8 final : public LTemplateInstruction<1, 1, 1> {
2427 LClampDToUint8(LOperand* unclamped, LOperand* temp) {
2428 inputs_[0] = unclamped;
2432 LOperand* unclamped() { return inputs_[0]; }
2433 LOperand* temp() { return temps_[0]; }
2435 DECLARE_CONCRETE_INSTRUCTION(ClampDToUint8, "clamp-d-to-uint8")
2439 class LClampIToUint8 final : public LTemplateInstruction<1, 1, 0> {
2441 explicit LClampIToUint8(LOperand* unclamped) {
2442 inputs_[0] = unclamped;
2445 LOperand* unclamped() { return inputs_[0]; }
2447 DECLARE_CONCRETE_INSTRUCTION(ClampIToUint8, "clamp-i-to-uint8")
2451 class LClampTToUint8 final : public LTemplateInstruction<1, 1, 1> {
2453 LClampTToUint8(LOperand* unclamped, LOperand* temp) {
2454 inputs_[0] = unclamped;
2458 LOperand* unclamped() { return inputs_[0]; }
2459 LOperand* temp() { return temps_[0]; }
2461 DECLARE_CONCRETE_INSTRUCTION(ClampTToUint8, "clamp-t-to-uint8")
2465 class LDoubleBits final : public LTemplateInstruction<1, 1, 0> {
2467 explicit LDoubleBits(LOperand* value) {
2471 LOperand* value() { return inputs_[0]; }
2473 DECLARE_CONCRETE_INSTRUCTION(DoubleBits, "double-bits")
2474 DECLARE_HYDROGEN_ACCESSOR(DoubleBits)
2478 class LConstructDouble final : public LTemplateInstruction<1, 2, 0> {
2480 LConstructDouble(LOperand* hi, LOperand* lo) {
2485 LOperand* hi() { return inputs_[0]; }
2486 LOperand* lo() { return inputs_[1]; }
2488 DECLARE_CONCRETE_INSTRUCTION(ConstructDouble, "construct-double")
2492 class LAllocate final : public LTemplateInstruction<1, 2, 2> {
2494 LAllocate(LOperand* context,
2498 inputs_[0] = context;
2504 LOperand* context() { return inputs_[0]; }
2505 LOperand* size() { return inputs_[1]; }
2506 LOperand* temp1() { return temps_[0]; }
2507 LOperand* temp2() { return temps_[1]; }
2509 DECLARE_CONCRETE_INSTRUCTION(Allocate, "allocate")
2510 DECLARE_HYDROGEN_ACCESSOR(Allocate)
2514 class LRegExpLiteral final : public LTemplateInstruction<1, 1, 0> {
2516 explicit LRegExpLiteral(LOperand* context) {
2517 inputs_[0] = context;
2520 LOperand* context() { return inputs_[0]; }
2522 DECLARE_CONCRETE_INSTRUCTION(RegExpLiteral, "regexp-literal")
2523 DECLARE_HYDROGEN_ACCESSOR(RegExpLiteral)
2527 class LToFastProperties final : public LTemplateInstruction<1, 1, 0> {
2529 explicit LToFastProperties(LOperand* value) {
2533 LOperand* value() { return inputs_[0]; }
2535 DECLARE_CONCRETE_INSTRUCTION(ToFastProperties, "to-fast-properties")
2536 DECLARE_HYDROGEN_ACCESSOR(ToFastProperties)
2540 class LTypeof final : public LTemplateInstruction<1, 2, 0> {
2542 LTypeof(LOperand* context, LOperand* value) {
2543 inputs_[0] = context;
2547 LOperand* context() { return inputs_[0]; }
2548 LOperand* value() { return inputs_[1]; }
2550 DECLARE_CONCRETE_INSTRUCTION(Typeof, "typeof")
2554 class LTypeofIsAndBranch final : public LControlInstruction<1, 0> {
2556 explicit LTypeofIsAndBranch(LOperand* value) {
2560 LOperand* value() { return inputs_[0]; }
2562 DECLARE_CONCRETE_INSTRUCTION(TypeofIsAndBranch, "typeof-is-and-branch")
2563 DECLARE_HYDROGEN_ACCESSOR(TypeofIsAndBranch)
2565 Handle<String> type_literal() { return hydrogen()->type_literal(); }
2567 void PrintDataTo(StringStream* stream) override;
2571 class LIsConstructCallAndBranch final : public LControlInstruction<0, 1> {
2573 explicit LIsConstructCallAndBranch(LOperand* temp) {
2577 LOperand* temp() { return temps_[0]; }
2579 DECLARE_CONCRETE_INSTRUCTION(IsConstructCallAndBranch,
2580 "is-construct-call-and-branch")
2584 class LOsrEntry final : public LTemplateInstruction<0, 0, 0> {
2588 bool HasInterestingComment(LCodeGen* gen) const override { return false; }
2589 DECLARE_CONCRETE_INSTRUCTION(OsrEntry, "osr-entry")
2593 class LStackCheck final : public LTemplateInstruction<0, 1, 0> {
2595 explicit LStackCheck(LOperand* context) {
2596 inputs_[0] = context;
2599 LOperand* context() { return inputs_[0]; }
2601 DECLARE_CONCRETE_INSTRUCTION(StackCheck, "stack-check")
2602 DECLARE_HYDROGEN_ACCESSOR(StackCheck)
2604 Label* done_label() { return &done_label_; }
2611 class LForInPrepareMap final : public LTemplateInstruction<1, 2, 0> {
2613 LForInPrepareMap(LOperand* context, LOperand* object) {
2614 inputs_[0] = context;
2615 inputs_[1] = object;
2618 LOperand* context() { return inputs_[0]; }
2619 LOperand* object() { return inputs_[1]; }
2621 DECLARE_CONCRETE_INSTRUCTION(ForInPrepareMap, "for-in-prepare-map")
2625 class LForInCacheArray final : public LTemplateInstruction<1, 1, 0> {
2627 explicit LForInCacheArray(LOperand* map) {
2631 LOperand* map() { return inputs_[0]; }
2633 DECLARE_CONCRETE_INSTRUCTION(ForInCacheArray, "for-in-cache-array")
2636 return HForInCacheArray::cast(this->hydrogen_value())->idx();
2641 class LCheckMapValue final : public LTemplateInstruction<0, 2, 0> {
2643 LCheckMapValue(LOperand* value, LOperand* map) {
2648 LOperand* value() { return inputs_[0]; }
2649 LOperand* map() { return inputs_[1]; }
2651 DECLARE_CONCRETE_INSTRUCTION(CheckMapValue, "check-map-value")
2655 class LLoadFieldByIndex final : public LTemplateInstruction<1, 2, 0> {
2657 LLoadFieldByIndex(LOperand* object, LOperand* index) {
2658 inputs_[0] = object;
2662 LOperand* object() { return inputs_[0]; }
2663 LOperand* index() { return inputs_[1]; }
2665 DECLARE_CONCRETE_INSTRUCTION(LoadFieldByIndex, "load-field-by-index")
2669 class LStoreFrameContext: public LTemplateInstruction<0, 1, 0> {
2671 explicit LStoreFrameContext(LOperand* context) {
2672 inputs_[0] = context;
2675 LOperand* context() { return inputs_[0]; }
2677 DECLARE_CONCRETE_INSTRUCTION(StoreFrameContext, "store-frame-context")
2681 class LAllocateBlockContext: public LTemplateInstruction<1, 2, 0> {
2683 LAllocateBlockContext(LOperand* context, LOperand* function) {
2684 inputs_[0] = context;
2685 inputs_[1] = function;
2688 LOperand* context() { return inputs_[0]; }
2689 LOperand* function() { return inputs_[1]; }
2691 Handle<ScopeInfo> scope_info() { return hydrogen()->scope_info(); }
2693 DECLARE_CONCRETE_INSTRUCTION(AllocateBlockContext, "allocate-block-context")
2694 DECLARE_HYDROGEN_ACCESSOR(AllocateBlockContext)
2698 class LChunkBuilder;
2699 class LPlatformChunk final : public LChunk {
2701 LPlatformChunk(CompilationInfo* info, HGraph* graph)
2702 : LChunk(info, graph) { }
2704 int GetNextSpillIndex(RegisterKind kind);
2705 LOperand* GetNextSpillSlot(RegisterKind kind);
2709 class LChunkBuilder final : public LChunkBuilderBase {
2711 LChunkBuilder(CompilationInfo* info, HGraph* graph, LAllocator* allocator)
2712 : LChunkBuilderBase(info, graph),
2713 current_instruction_(NULL),
2714 current_block_(NULL),
2716 allocator_(allocator) {}
2718 // Build the sequence for the graph.
2719 LPlatformChunk* Build();
2721 // Declare methods that deal with the individual node types.
2722 #define DECLARE_DO(type) LInstruction* Do##type(H##type* node);
2723 HYDROGEN_CONCRETE_INSTRUCTION_LIST(DECLARE_DO)
2726 LInstruction* DoMultiplyAdd(HMul* mul, HValue* addend);
2728 static bool HasMagicNumberForDivisor(int32_t divisor);
2730 LInstruction* DoMathFloor(HUnaryMathOperation* instr);
2731 LInstruction* DoMathRound(HUnaryMathOperation* instr);
2732 LInstruction* DoMathFround(HUnaryMathOperation* instr);
2733 LInstruction* DoMathAbs(HUnaryMathOperation* instr);
2734 LInstruction* DoMathLog(HUnaryMathOperation* instr);
2735 LInstruction* DoMathExp(HUnaryMathOperation* instr);
2736 LInstruction* DoMathSqrt(HUnaryMathOperation* instr);
2737 LInstruction* DoMathPowHalf(HUnaryMathOperation* instr);
2738 LInstruction* DoMathClz32(HUnaryMathOperation* instr);
2739 LInstruction* DoDivByPowerOf2I(HDiv* instr);
2740 LInstruction* DoDivByConstI(HDiv* instr);
2741 LInstruction* DoDivI(HDiv* instr);
2742 LInstruction* DoModByPowerOf2I(HMod* instr);
2743 LInstruction* DoModByConstI(HMod* instr);
2744 LInstruction* DoModI(HMod* instr);
2745 LInstruction* DoFlooringDivByPowerOf2I(HMathFloorOfDiv* instr);
2746 LInstruction* DoFlooringDivByConstI(HMathFloorOfDiv* instr);
2747 LInstruction* DoFlooringDivI(HMathFloorOfDiv* instr);
2750 // Methods for getting operands for Use / Define / Temp.
2751 LUnallocated* ToUnallocated(Register reg);
2752 LUnallocated* ToUnallocated(DoubleRegister reg);
2754 // Methods for setting up define-use relationships.
2755 MUST_USE_RESULT LOperand* Use(HValue* value, LUnallocated* operand);
2756 MUST_USE_RESULT LOperand* UseFixed(HValue* value, Register fixed_register);
2757 MUST_USE_RESULT LOperand* UseFixedDouble(HValue* value,
2758 DoubleRegister fixed_register);
2760 // A value that is guaranteed to be allocated to a register.
2761 // Operand created by UseRegister is guaranteed to be live until the end of
2762 // instruction. This means that register allocator will not reuse it's
2763 // register for any other operand inside instruction.
2764 // Operand created by UseRegisterAtStart is guaranteed to be live only at
2765 // instruction start. Register allocator is free to assign the same register
2766 // to some other operand used inside instruction (i.e. temporary or
2768 MUST_USE_RESULT LOperand* UseRegister(HValue* value);
2769 MUST_USE_RESULT LOperand* UseRegisterAtStart(HValue* value);
2771 // An input operand in a register that may be trashed.
2772 MUST_USE_RESULT LOperand* UseTempRegister(HValue* value);
2774 // An input operand in a register or stack slot.
2775 MUST_USE_RESULT LOperand* Use(HValue* value);
2776 MUST_USE_RESULT LOperand* UseAtStart(HValue* value);
2778 // An input operand in a register, stack slot or a constant operand.
2779 MUST_USE_RESULT LOperand* UseOrConstant(HValue* value);
2780 MUST_USE_RESULT LOperand* UseOrConstantAtStart(HValue* value);
2782 // An input operand in a register or a constant operand.
2783 MUST_USE_RESULT LOperand* UseRegisterOrConstant(HValue* value);
2784 MUST_USE_RESULT LOperand* UseRegisterOrConstantAtStart(HValue* value);
2786 // An input operand in a constant operand.
2787 MUST_USE_RESULT LOperand* UseConstant(HValue* value);
2789 // An input operand in register, stack slot or a constant operand.
2790 // Will not be moved to a register even if one is freely available.
2791 MUST_USE_RESULT LOperand* UseAny(HValue* value) override;
2793 // Temporary operand that must be in a register.
2794 MUST_USE_RESULT LUnallocated* TempRegister();
2795 MUST_USE_RESULT LUnallocated* TempDoubleRegister();
2796 MUST_USE_RESULT LOperand* FixedTemp(Register reg);
2797 MUST_USE_RESULT LOperand* FixedTemp(DoubleRegister reg);
2799 // Methods for setting up define-use relationships.
2800 // Return the same instruction that they are passed.
2801 LInstruction* Define(LTemplateResultInstruction<1>* instr,
2802 LUnallocated* result);
2803 LInstruction* DefineAsRegister(LTemplateResultInstruction<1>* instr);
2804 LInstruction* DefineAsSpilled(LTemplateResultInstruction<1>* instr,
2806 LInstruction* DefineSameAsFirst(LTemplateResultInstruction<1>* instr);
2807 LInstruction* DefineFixed(LTemplateResultInstruction<1>* instr,
2809 LInstruction* DefineFixedDouble(LTemplateResultInstruction<1>* instr,
2810 DoubleRegister reg);
2811 LInstruction* AssignEnvironment(LInstruction* instr);
2812 LInstruction* AssignPointerMap(LInstruction* instr);
2814 enum CanDeoptimize { CAN_DEOPTIMIZE_EAGERLY, CANNOT_DEOPTIMIZE_EAGERLY };
2816 // By default we assume that instruction sequences generated for calls
2817 // cannot deoptimize eagerly and we do not attach environment to this
2819 LInstruction* MarkAsCall(
2820 LInstruction* instr,
2821 HInstruction* hinstr,
2822 CanDeoptimize can_deoptimize = CANNOT_DEOPTIMIZE_EAGERLY);
2824 void VisitInstruction(HInstruction* current);
2825 void AddInstruction(LInstruction* instr, HInstruction* current);
2827 void DoBasicBlock(HBasicBlock* block, HBasicBlock* next_block);
2828 LInstruction* DoBit(Token::Value op, HBitwiseBinaryOperation* instr);
2829 LInstruction* DoShift(Token::Value op, HBitwiseBinaryOperation* instr);
2830 LInstruction* DoArithmeticD(Token::Value op,
2831 HArithmeticBinaryOperation* instr);
2832 LInstruction* DoArithmeticT(Token::Value op,
2833 HBinaryOperation* instr);
2835 HInstruction* current_instruction_;
2836 HBasicBlock* current_block_;
2837 HBasicBlock* next_block_;
2838 LAllocator* allocator_;
2840 DISALLOW_COPY_AND_ASSIGN(LChunkBuilder);
2843 #undef DECLARE_HYDROGEN_ACCESSOR
2844 #undef DECLARE_CONCRETE_INSTRUCTION
2846 } // namespace internal
2849 #endif // V8_MIPS_LITHIUM_MIPS_H_