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(CheckInstanceType) \
49 V(ClassOfTestAndBranch) \
50 V(CompareMinusZeroAndBranch) \
51 V(CompareNumericAndBranch) \
52 V(CmpObjectEqAndBranch) \
76 V(FlooringDivByConstI) \
77 V(FlooringDivByPowerOf2I) \
82 V(GetCachedArrayIndex) \
84 V(HasCachedArrayIndexAndBranch) \
85 V(HasInstanceTypeAndBranch) \
86 V(InnerAllocatedObject) \
88 V(InstanceOfKnownGlobal) \
90 V(Integer32ToDouble) \
92 V(IsConstructCallAndBranch) \
93 V(IsObjectAndBranch) \
94 V(IsStringAndBranch) \
96 V(IsUndetectableAndBranch) \
101 V(LoadFieldByIndex) \
102 V(LoadFunctionPrototype) \
103 V(LoadGlobalGeneric) \
105 V(LoadKeyedGeneric) \
107 V(LoadNamedGeneric) \
133 V(SeqStringGetChar) \
134 V(SeqStringSetChar) \
140 V(StoreContextSlot) \
141 V(StoreFrameContext) \
143 V(StoreKeyedGeneric) \
145 V(StoreNamedGeneric) \
147 V(StringCharCodeAt) \
148 V(StringCharFromCode) \
149 V(StringCompareAndBranch) \
152 V(TailCallThroughMegamorphicCache) \
154 V(ToFastProperties) \
155 V(TransitionElementsKind) \
156 V(TrapAllocationMemento) \
158 V(TypeofIsAndBranch) \
163 #define DECLARE_CONCRETE_INSTRUCTION(type, mnemonic) \
164 Opcode opcode() const FINAL { return LInstruction::k##type; } \
165 void CompileToNative(LCodeGen* generator) FINAL; \
166 const char* Mnemonic() const FINAL { return mnemonic; } \
167 static L##type* cast(LInstruction* instr) { \
168 DCHECK(instr->Is##type()); \
169 return reinterpret_cast<L##type*>(instr); \
173 #define DECLARE_HYDROGEN_ACCESSOR(type) \
174 H##type* hydrogen() const { \
175 return H##type::cast(hydrogen_value()); \
179 class LInstruction : public ZoneObject {
182 : environment_(NULL),
183 hydrogen_value_(NULL),
184 bit_field_(IsCallBits::encode(false)) {
187 virtual ~LInstruction() {}
189 virtual void CompileToNative(LCodeGen* generator) = 0;
190 virtual const char* Mnemonic() const = 0;
191 virtual void PrintTo(StringStream* stream);
192 virtual void PrintDataTo(StringStream* stream);
193 virtual void PrintOutputOperandTo(StringStream* stream);
196 // Declare a unique enum value for each instruction.
197 #define DECLARE_OPCODE(type) k##type,
198 LITHIUM_CONCRETE_INSTRUCTION_LIST(DECLARE_OPCODE)
199 kNumberOfInstructions
200 #undef DECLARE_OPCODE
203 virtual Opcode opcode() const = 0;
205 // Declare non-virtual type testers for all leaf IR classes.
206 #define DECLARE_PREDICATE(type) \
207 bool Is##type() const { return opcode() == k##type; }
208 LITHIUM_CONCRETE_INSTRUCTION_LIST(DECLARE_PREDICATE)
209 #undef DECLARE_PREDICATE
211 // Declare virtual predicates for instructions that don't have
213 virtual bool IsGap() const { return false; }
215 virtual bool IsControl() const { return false; }
217 // Try deleting this instruction if possible.
218 virtual bool TryDelete() { return false; }
220 void set_environment(LEnvironment* env) { environment_ = env; }
221 LEnvironment* environment() const { return environment_; }
222 bool HasEnvironment() const { return environment_ != NULL; }
224 void set_pointer_map(LPointerMap* p) { pointer_map_.set(p); }
225 LPointerMap* pointer_map() const { return pointer_map_.get(); }
226 bool HasPointerMap() const { return pointer_map_.is_set(); }
228 void set_hydrogen_value(HValue* value) { hydrogen_value_ = value; }
229 HValue* hydrogen_value() const { return hydrogen_value_; }
231 virtual void SetDeferredLazyDeoptimizationEnvironment(LEnvironment* env) { }
233 void MarkAsCall() { bit_field_ = IsCallBits::update(bit_field_, true); }
234 bool IsCall() const { return IsCallBits::decode(bit_field_); }
236 // Interface to the register allocator and iterators.
237 bool ClobbersTemps() const { return IsCall(); }
238 bool ClobbersRegisters() const { return IsCall(); }
239 virtual bool ClobbersDoubleRegisters(Isolate* isolate) const {
243 // Interface to the register allocator and iterators.
244 bool IsMarkedAsCall() const { return IsCall(); }
246 virtual bool HasResult() const = 0;
247 virtual LOperand* result() const = 0;
249 LOperand* FirstInput() { return InputAt(0); }
250 LOperand* Output() { return HasResult() ? result() : NULL; }
252 virtual bool HasInterestingComment(LCodeGen* gen) const { return true; }
258 virtual int InputCount() = 0;
259 virtual LOperand* InputAt(int i) = 0;
262 // Iterator interface.
263 friend class InputIterator;
265 friend class TempIterator;
266 virtual int TempCount() = 0;
267 virtual LOperand* TempAt(int i) = 0;
269 class IsCallBits: public BitField<bool, 0, 1> {};
271 LEnvironment* environment_;
272 SetOncePointer<LPointerMap> pointer_map_;
273 HValue* hydrogen_value_;
278 // R = number of result operands (0 or 1).
280 class LTemplateResultInstruction : public LInstruction {
282 // Allow 0 or 1 output operands.
283 STATIC_ASSERT(R == 0 || R == 1);
284 bool HasResult() const FINAL { return R != 0 && result() != NULL; }
285 void set_result(LOperand* operand) { results_[0] = operand; }
286 LOperand* result() const OVERRIDE { return results_[0]; }
289 EmbeddedContainer<LOperand*, R> results_;
293 // R = number of result operands (0 or 1).
294 // I = number of input operands.
295 // T = number of temporary operands.
296 template<int R, int I, int T>
297 class LTemplateInstruction : public LTemplateResultInstruction<R> {
299 EmbeddedContainer<LOperand*, I> inputs_;
300 EmbeddedContainer<LOperand*, T> temps_;
304 int InputCount() FINAL { return I; }
305 LOperand* InputAt(int i) FINAL { return inputs_[i]; }
307 int TempCount() FINAL { return T; }
308 LOperand* TempAt(int i) FINAL { return temps_[i]; }
312 class LGap : public LTemplateInstruction<0, 0, 0> {
314 explicit LGap(HBasicBlock* block)
316 parallel_moves_[BEFORE] = NULL;
317 parallel_moves_[START] = NULL;
318 parallel_moves_[END] = NULL;
319 parallel_moves_[AFTER] = NULL;
322 // Can't use the DECLARE-macro here because of sub-classes.
323 bool IsGap() const FINAL { return true; }
324 void PrintDataTo(StringStream* stream) OVERRIDE;
325 static LGap* cast(LInstruction* instr) {
326 DCHECK(instr->IsGap());
327 return reinterpret_cast<LGap*>(instr);
330 bool IsRedundant() const;
332 HBasicBlock* block() const { return block_; }
339 FIRST_INNER_POSITION = BEFORE,
340 LAST_INNER_POSITION = AFTER
343 LParallelMove* GetOrCreateParallelMove(InnerPosition pos, Zone* zone) {
344 if (parallel_moves_[pos] == NULL) {
345 parallel_moves_[pos] = new(zone) LParallelMove(zone);
347 return parallel_moves_[pos];
350 LParallelMove* GetParallelMove(InnerPosition pos) {
351 return parallel_moves_[pos];
355 LParallelMove* parallel_moves_[LAST_INNER_POSITION + 1];
360 class LInstructionGap FINAL : public LGap {
362 explicit LInstructionGap(HBasicBlock* block) : LGap(block) { }
364 bool HasInterestingComment(LCodeGen* gen) const OVERRIDE {
365 return !IsRedundant();
368 DECLARE_CONCRETE_INSTRUCTION(InstructionGap, "gap")
372 class LGoto FINAL : public LTemplateInstruction<0, 0, 0> {
374 explicit LGoto(HBasicBlock* block) : block_(block) { }
376 bool HasInterestingComment(LCodeGen* gen) const OVERRIDE;
377 DECLARE_CONCRETE_INSTRUCTION(Goto, "goto")
378 void PrintDataTo(StringStream* stream) OVERRIDE;
379 bool IsControl() const OVERRIDE { return true; }
381 int block_id() const { return block_->block_id(); }
388 class LLazyBailout FINAL : public LTemplateInstruction<0, 0, 0> {
390 LLazyBailout() : gap_instructions_size_(0) { }
392 DECLARE_CONCRETE_INSTRUCTION(LazyBailout, "lazy-bailout")
394 void set_gap_instructions_size(int gap_instructions_size) {
395 gap_instructions_size_ = gap_instructions_size;
397 int gap_instructions_size() { return gap_instructions_size_; }
400 int gap_instructions_size_;
404 class LDummy FINAL : public LTemplateInstruction<1, 0, 0> {
407 DECLARE_CONCRETE_INSTRUCTION(Dummy, "dummy")
411 class LDummyUse FINAL : public LTemplateInstruction<1, 1, 0> {
413 explicit LDummyUse(LOperand* value) {
416 DECLARE_CONCRETE_INSTRUCTION(DummyUse, "dummy-use")
420 class LDeoptimize FINAL : public LTemplateInstruction<0, 0, 0> {
422 bool IsControl() const OVERRIDE { return true; }
423 DECLARE_CONCRETE_INSTRUCTION(Deoptimize, "deoptimize")
424 DECLARE_HYDROGEN_ACCESSOR(Deoptimize)
428 class LLabel FINAL : public LGap {
430 explicit LLabel(HBasicBlock* block)
431 : LGap(block), replacement_(NULL) { }
433 bool HasInterestingComment(LCodeGen* gen) const OVERRIDE { return false; }
434 DECLARE_CONCRETE_INSTRUCTION(Label, "label")
436 void PrintDataTo(StringStream* stream) OVERRIDE;
438 int block_id() const { return block()->block_id(); }
439 bool is_loop_header() const { return block()->IsLoopHeader(); }
440 bool is_osr_entry() const { return block()->is_osr_entry(); }
441 Label* label() { return &label_; }
442 LLabel* replacement() const { return replacement_; }
443 void set_replacement(LLabel* label) { replacement_ = label; }
444 bool HasReplacement() const { return replacement_ != NULL; }
448 LLabel* replacement_;
452 class LParameter FINAL : public LTemplateInstruction<1, 0, 0> {
454 bool HasInterestingComment(LCodeGen* gen) const OVERRIDE { return false; }
455 DECLARE_CONCRETE_INSTRUCTION(Parameter, "parameter")
459 class LCallStub FINAL : public LTemplateInstruction<1, 1, 0> {
461 explicit LCallStub(LOperand* context) {
462 inputs_[0] = context;
465 LOperand* context() { return inputs_[0]; }
467 DECLARE_CONCRETE_INSTRUCTION(CallStub, "call-stub")
468 DECLARE_HYDROGEN_ACCESSOR(CallStub)
472 class LTailCallThroughMegamorphicCache FINAL
473 : public LTemplateInstruction<0, 5, 0> {
475 LTailCallThroughMegamorphicCache(LOperand* context, LOperand* receiver,
476 LOperand* name, LOperand* slot,
478 inputs_[0] = context;
479 inputs_[1] = receiver;
485 LOperand* context() { return inputs_[0]; }
486 LOperand* receiver() { return inputs_[1]; }
487 LOperand* name() { return inputs_[2]; }
488 LOperand* slot() { return inputs_[3]; }
489 LOperand* vector() { return inputs_[4]; }
491 DECLARE_CONCRETE_INSTRUCTION(TailCallThroughMegamorphicCache,
492 "tail-call-through-megamorphic-cache")
493 DECLARE_HYDROGEN_ACCESSOR(TailCallThroughMegamorphicCache)
497 class LUnknownOSRValue FINAL : public LTemplateInstruction<1, 0, 0> {
499 bool HasInterestingComment(LCodeGen* gen) const OVERRIDE { return false; }
500 DECLARE_CONCRETE_INSTRUCTION(UnknownOSRValue, "unknown-osr-value")
504 template<int I, int T>
505 class LControlInstruction : public LTemplateInstruction<0, I, T> {
507 LControlInstruction() : false_label_(NULL), true_label_(NULL) { }
509 bool IsControl() const FINAL { return true; }
511 int SuccessorCount() { return hydrogen()->SuccessorCount(); }
512 HBasicBlock* SuccessorAt(int i) { return hydrogen()->SuccessorAt(i); }
514 int TrueDestination(LChunk* chunk) {
515 return chunk->LookupDestination(true_block_id());
517 int FalseDestination(LChunk* chunk) {
518 return chunk->LookupDestination(false_block_id());
521 Label* TrueLabel(LChunk* chunk) {
522 if (true_label_ == NULL) {
523 true_label_ = chunk->GetAssemblyLabel(TrueDestination(chunk));
527 Label* FalseLabel(LChunk* chunk) {
528 if (false_label_ == NULL) {
529 false_label_ = chunk->GetAssemblyLabel(FalseDestination(chunk));
535 int true_block_id() { return SuccessorAt(0)->block_id(); }
536 int false_block_id() { return SuccessorAt(1)->block_id(); }
539 HControlInstruction* hydrogen() {
540 return HControlInstruction::cast(this->hydrogen_value());
548 class LWrapReceiver FINAL : public LTemplateInstruction<1, 2, 0> {
550 LWrapReceiver(LOperand* receiver, LOperand* function) {
551 inputs_[0] = receiver;
552 inputs_[1] = function;
555 DECLARE_CONCRETE_INSTRUCTION(WrapReceiver, "wrap-receiver")
556 DECLARE_HYDROGEN_ACCESSOR(WrapReceiver)
558 LOperand* receiver() { return inputs_[0]; }
559 LOperand* function() { return inputs_[1]; }
563 class LApplyArguments FINAL : public LTemplateInstruction<1, 4, 0> {
565 LApplyArguments(LOperand* function,
568 LOperand* elements) {
569 inputs_[0] = function;
570 inputs_[1] = receiver;
572 inputs_[3] = elements;
575 DECLARE_CONCRETE_INSTRUCTION(ApplyArguments, "apply-arguments")
577 LOperand* function() { return inputs_[0]; }
578 LOperand* receiver() { return inputs_[1]; }
579 LOperand* length() { return inputs_[2]; }
580 LOperand* elements() { return inputs_[3]; }
584 class LAccessArgumentsAt FINAL : public LTemplateInstruction<1, 3, 0> {
586 LAccessArgumentsAt(LOperand* arguments, LOperand* length, LOperand* index) {
587 inputs_[0] = arguments;
592 DECLARE_CONCRETE_INSTRUCTION(AccessArgumentsAt, "access-arguments-at")
594 LOperand* arguments() { return inputs_[0]; }
595 LOperand* length() { return inputs_[1]; }
596 LOperand* index() { return inputs_[2]; }
598 void PrintDataTo(StringStream* stream) OVERRIDE;
602 class LArgumentsLength FINAL : public LTemplateInstruction<1, 1, 0> {
604 explicit LArgumentsLength(LOperand* elements) {
605 inputs_[0] = elements;
608 LOperand* elements() { return inputs_[0]; }
610 DECLARE_CONCRETE_INSTRUCTION(ArgumentsLength, "arguments-length")
614 class LArgumentsElements FINAL : public LTemplateInstruction<1, 0, 0> {
616 DECLARE_CONCRETE_INSTRUCTION(ArgumentsElements, "arguments-elements")
617 DECLARE_HYDROGEN_ACCESSOR(ArgumentsElements)
621 class LModByPowerOf2I FINAL : public LTemplateInstruction<1, 1, 0> {
623 LModByPowerOf2I(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(ModByPowerOf2I, "mod-by-power-of-2-i")
632 DECLARE_HYDROGEN_ACCESSOR(Mod)
639 class LModByConstI FINAL : public LTemplateInstruction<1, 1, 0> {
641 LModByConstI(LOperand* dividend, int32_t divisor) {
642 inputs_[0] = dividend;
646 LOperand* dividend() { return inputs_[0]; }
647 int32_t divisor() const { return divisor_; }
649 DECLARE_CONCRETE_INSTRUCTION(ModByConstI, "mod-by-const-i")
650 DECLARE_HYDROGEN_ACCESSOR(Mod)
657 class LModI FINAL : public LTemplateInstruction<1, 2, 3> {
659 LModI(LOperand* left,
665 LOperand* left() { return inputs_[0]; }
666 LOperand* right() { return inputs_[1]; }
668 DECLARE_CONCRETE_INSTRUCTION(ModI, "mod-i")
669 DECLARE_HYDROGEN_ACCESSOR(Mod)
673 class LDivByPowerOf2I FINAL : public LTemplateInstruction<1, 1, 0> {
675 LDivByPowerOf2I(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(DivByPowerOf2I, "div-by-power-of-2-i")
684 DECLARE_HYDROGEN_ACCESSOR(Div)
691 class LDivByConstI FINAL : public LTemplateInstruction<1, 1, 0> {
693 LDivByConstI(LOperand* dividend, int32_t divisor) {
694 inputs_[0] = dividend;
698 LOperand* dividend() { return inputs_[0]; }
699 int32_t divisor() const { return divisor_; }
701 DECLARE_CONCRETE_INSTRUCTION(DivByConstI, "div-by-const-i")
702 DECLARE_HYDROGEN_ACCESSOR(Div)
709 class LDivI FINAL : public LTemplateInstruction<1, 2, 1> {
711 LDivI(LOperand* dividend, LOperand* divisor, LOperand* temp) {
712 inputs_[0] = dividend;
713 inputs_[1] = divisor;
717 LOperand* dividend() { return inputs_[0]; }
718 LOperand* divisor() { return inputs_[1]; }
719 LOperand* temp() { return temps_[0]; }
721 DECLARE_CONCRETE_INSTRUCTION(DivI, "div-i")
722 DECLARE_HYDROGEN_ACCESSOR(BinaryOperation)
726 class LFlooringDivByPowerOf2I FINAL : public LTemplateInstruction<1, 1, 0> {
728 LFlooringDivByPowerOf2I(LOperand* dividend, int32_t divisor) {
729 inputs_[0] = dividend;
733 LOperand* dividend() { return inputs_[0]; }
734 int32_t divisor() { return divisor_; }
736 DECLARE_CONCRETE_INSTRUCTION(FlooringDivByPowerOf2I,
737 "flooring-div-by-power-of-2-i")
738 DECLARE_HYDROGEN_ACCESSOR(MathFloorOfDiv)
745 class LFlooringDivByConstI FINAL : public LTemplateInstruction<1, 1, 2> {
747 LFlooringDivByConstI(LOperand* dividend, int32_t divisor, LOperand* temp) {
748 inputs_[0] = dividend;
753 LOperand* dividend() { return inputs_[0]; }
754 int32_t divisor() const { return divisor_; }
755 LOperand* temp() { return temps_[0]; }
757 DECLARE_CONCRETE_INSTRUCTION(FlooringDivByConstI, "flooring-div-by-const-i")
758 DECLARE_HYDROGEN_ACCESSOR(MathFloorOfDiv)
765 class LFlooringDivI FINAL : public LTemplateInstruction<1, 2, 0> {
767 LFlooringDivI(LOperand* dividend, LOperand* divisor) {
768 inputs_[0] = dividend;
769 inputs_[1] = divisor;
772 LOperand* dividend() { return inputs_[0]; }
773 LOperand* divisor() { return inputs_[1]; }
775 DECLARE_CONCRETE_INSTRUCTION(FlooringDivI, "flooring-div-i")
776 DECLARE_HYDROGEN_ACCESSOR(MathFloorOfDiv)
780 class LMulI FINAL : public LTemplateInstruction<1, 2, 0> {
782 LMulI(LOperand* left, LOperand* right) {
787 LOperand* left() { return inputs_[0]; }
788 LOperand* right() { return inputs_[1]; }
790 DECLARE_CONCRETE_INSTRUCTION(MulI, "mul-i")
791 DECLARE_HYDROGEN_ACCESSOR(Mul)
795 // Instruction for computing multiplier * multiplicand + addend.
796 class LMultiplyAddD FINAL : public LTemplateInstruction<1, 3, 0> {
798 LMultiplyAddD(LOperand* addend, LOperand* multiplier,
799 LOperand* multiplicand) {
801 inputs_[1] = multiplier;
802 inputs_[2] = multiplicand;
805 LOperand* addend() { return inputs_[0]; }
806 LOperand* multiplier() { return inputs_[1]; }
807 LOperand* multiplicand() { return inputs_[2]; }
809 DECLARE_CONCRETE_INSTRUCTION(MultiplyAddD, "multiply-add-d")
813 class LDebugBreak FINAL : public LTemplateInstruction<0, 0, 0> {
815 DECLARE_CONCRETE_INSTRUCTION(DebugBreak, "break")
819 class LCompareNumericAndBranch FINAL : public LControlInstruction<2, 0> {
821 LCompareNumericAndBranch(LOperand* left, LOperand* right) {
826 LOperand* left() { return inputs_[0]; }
827 LOperand* right() { return inputs_[1]; }
829 DECLARE_CONCRETE_INSTRUCTION(CompareNumericAndBranch,
830 "compare-numeric-and-branch")
831 DECLARE_HYDROGEN_ACCESSOR(CompareNumericAndBranch)
833 Token::Value op() const { return hydrogen()->token(); }
834 bool is_double() const {
835 return hydrogen()->representation().IsDouble();
838 void PrintDataTo(StringStream* stream) OVERRIDE;
842 class LMathFloor FINAL : public LTemplateInstruction<1, 1, 1> {
844 LMathFloor(LOperand* value, LOperand* temp) {
849 LOperand* value() { return inputs_[0]; }
850 LOperand* temp() { return temps_[0]; }
852 DECLARE_CONCRETE_INSTRUCTION(MathFloor, "math-floor")
853 DECLARE_HYDROGEN_ACCESSOR(UnaryMathOperation)
857 class LMathRound FINAL : public LTemplateInstruction<1, 1, 1> {
859 LMathRound(LOperand* value, LOperand* temp) {
864 LOperand* value() { return inputs_[0]; }
865 LOperand* temp() { return temps_[0]; }
867 DECLARE_CONCRETE_INSTRUCTION(MathRound, "math-round")
868 DECLARE_HYDROGEN_ACCESSOR(UnaryMathOperation)
872 class LMathFround FINAL : public LTemplateInstruction<1, 1, 0> {
874 explicit LMathFround(LOperand* value) { inputs_[0] = value; }
876 LOperand* value() { return inputs_[0]; }
878 DECLARE_CONCRETE_INSTRUCTION(MathFround, "math-fround")
882 class LMathAbs FINAL : public LTemplateInstruction<1, 2, 0> {
884 LMathAbs(LOperand* context, LOperand* value) {
885 inputs_[1] = context;
889 LOperand* context() { return inputs_[1]; }
890 LOperand* value() { return inputs_[0]; }
892 DECLARE_CONCRETE_INSTRUCTION(MathAbs, "math-abs")
893 DECLARE_HYDROGEN_ACCESSOR(UnaryMathOperation)
897 class LMathLog FINAL : public LTemplateInstruction<1, 1, 0> {
899 explicit LMathLog(LOperand* value) {
903 LOperand* value() { return inputs_[0]; }
905 DECLARE_CONCRETE_INSTRUCTION(MathLog, "math-log")
909 class LMathClz32 FINAL : public LTemplateInstruction<1, 1, 0> {
911 explicit LMathClz32(LOperand* value) {
915 LOperand* value() { return inputs_[0]; }
917 DECLARE_CONCRETE_INSTRUCTION(MathClz32, "math-clz32")
921 class LMathExp FINAL : public LTemplateInstruction<1, 1, 3> {
923 LMathExp(LOperand* value,
924 LOperand* double_temp,
930 temps_[2] = double_temp;
931 ExternalReference::InitializeMathExpData();
934 LOperand* value() { return inputs_[0]; }
935 LOperand* temp1() { return temps_[0]; }
936 LOperand* temp2() { return temps_[1]; }
937 LOperand* double_temp() { return temps_[2]; }
939 DECLARE_CONCRETE_INSTRUCTION(MathExp, "math-exp")
943 class LMathSqrt FINAL : public LTemplateInstruction<1, 1, 0> {
945 explicit LMathSqrt(LOperand* value) {
949 LOperand* value() { return inputs_[0]; }
951 DECLARE_CONCRETE_INSTRUCTION(MathSqrt, "math-sqrt")
955 class LMathPowHalf FINAL : public LTemplateInstruction<1, 1, 1> {
957 LMathPowHalf(LOperand* value, LOperand* temp) {
962 LOperand* value() { return inputs_[0]; }
963 LOperand* temp() { return temps_[0]; }
965 DECLARE_CONCRETE_INSTRUCTION(MathPowHalf, "math-pow-half")
969 class LCmpObjectEqAndBranch FINAL : public LControlInstruction<2, 0> {
971 LCmpObjectEqAndBranch(LOperand* left, LOperand* right) {
976 LOperand* left() { return inputs_[0]; }
977 LOperand* right() { return inputs_[1]; }
979 DECLARE_CONCRETE_INSTRUCTION(CmpObjectEqAndBranch, "cmp-object-eq-and-branch")
980 DECLARE_HYDROGEN_ACCESSOR(CompareObjectEqAndBranch)
984 class LCmpHoleAndBranch FINAL : public LControlInstruction<1, 0> {
986 explicit LCmpHoleAndBranch(LOperand* object) {
990 LOperand* object() { return inputs_[0]; }
992 DECLARE_CONCRETE_INSTRUCTION(CmpHoleAndBranch, "cmp-hole-and-branch")
993 DECLARE_HYDROGEN_ACCESSOR(CompareHoleAndBranch)
997 class LCompareMinusZeroAndBranch FINAL : public LControlInstruction<1, 1> {
999 LCompareMinusZeroAndBranch(LOperand* value, LOperand* temp) {
1004 LOperand* value() { return inputs_[0]; }
1005 LOperand* temp() { return temps_[0]; }
1007 DECLARE_CONCRETE_INSTRUCTION(CompareMinusZeroAndBranch,
1008 "cmp-minus-zero-and-branch")
1009 DECLARE_HYDROGEN_ACCESSOR(CompareMinusZeroAndBranch)
1013 class LIsObjectAndBranch FINAL : public LControlInstruction<1, 1> {
1015 LIsObjectAndBranch(LOperand* value, LOperand* temp) {
1020 LOperand* value() { return inputs_[0]; }
1021 LOperand* temp() { return temps_[0]; }
1023 DECLARE_CONCRETE_INSTRUCTION(IsObjectAndBranch, "is-object-and-branch")
1024 DECLARE_HYDROGEN_ACCESSOR(IsObjectAndBranch)
1026 void PrintDataTo(StringStream* stream) OVERRIDE;
1030 class LIsStringAndBranch FINAL : public LControlInstruction<1, 1> {
1032 LIsStringAndBranch(LOperand* value, LOperand* temp) {
1037 LOperand* value() { return inputs_[0]; }
1038 LOperand* temp() { return temps_[0]; }
1040 DECLARE_CONCRETE_INSTRUCTION(IsStringAndBranch, "is-string-and-branch")
1041 DECLARE_HYDROGEN_ACCESSOR(IsStringAndBranch)
1043 void PrintDataTo(StringStream* stream) OVERRIDE;
1047 class LIsSmiAndBranch FINAL : public LControlInstruction<1, 0> {
1049 explicit LIsSmiAndBranch(LOperand* value) {
1053 LOperand* value() { return inputs_[0]; }
1055 DECLARE_CONCRETE_INSTRUCTION(IsSmiAndBranch, "is-smi-and-branch")
1056 DECLARE_HYDROGEN_ACCESSOR(IsSmiAndBranch)
1058 void PrintDataTo(StringStream* stream) OVERRIDE;
1062 class LIsUndetectableAndBranch FINAL : public LControlInstruction<1, 1> {
1064 explicit LIsUndetectableAndBranch(LOperand* value, LOperand* temp) {
1069 LOperand* value() { return inputs_[0]; }
1070 LOperand* temp() { return temps_[0]; }
1072 DECLARE_CONCRETE_INSTRUCTION(IsUndetectableAndBranch,
1073 "is-undetectable-and-branch")
1074 DECLARE_HYDROGEN_ACCESSOR(IsUndetectableAndBranch)
1076 void PrintDataTo(StringStream* stream) OVERRIDE;
1080 class LStringCompareAndBranch FINAL : public LControlInstruction<3, 0> {
1082 LStringCompareAndBranch(LOperand* context, LOperand* left, LOperand* right) {
1083 inputs_[0] = context;
1088 LOperand* context() { return inputs_[0]; }
1089 LOperand* left() { return inputs_[1]; }
1090 LOperand* right() { return inputs_[2]; }
1092 DECLARE_CONCRETE_INSTRUCTION(StringCompareAndBranch,
1093 "string-compare-and-branch")
1094 DECLARE_HYDROGEN_ACCESSOR(StringCompareAndBranch)
1096 Token::Value op() const { return hydrogen()->token(); }
1098 void PrintDataTo(StringStream* stream) OVERRIDE;
1102 class LHasInstanceTypeAndBranch FINAL : public LControlInstruction<1, 0> {
1104 explicit LHasInstanceTypeAndBranch(LOperand* value) {
1108 LOperand* value() { return inputs_[0]; }
1110 DECLARE_CONCRETE_INSTRUCTION(HasInstanceTypeAndBranch,
1111 "has-instance-type-and-branch")
1112 DECLARE_HYDROGEN_ACCESSOR(HasInstanceTypeAndBranch)
1114 void PrintDataTo(StringStream* stream) OVERRIDE;
1118 class LGetCachedArrayIndex FINAL : public LTemplateInstruction<1, 1, 0> {
1120 explicit LGetCachedArrayIndex(LOperand* value) {
1124 LOperand* value() { return inputs_[0]; }
1126 DECLARE_CONCRETE_INSTRUCTION(GetCachedArrayIndex, "get-cached-array-index")
1127 DECLARE_HYDROGEN_ACCESSOR(GetCachedArrayIndex)
1131 class LHasCachedArrayIndexAndBranch FINAL
1132 : public LControlInstruction<1, 0> {
1134 explicit LHasCachedArrayIndexAndBranch(LOperand* value) {
1138 LOperand* value() { return inputs_[0]; }
1140 DECLARE_CONCRETE_INSTRUCTION(HasCachedArrayIndexAndBranch,
1141 "has-cached-array-index-and-branch")
1142 DECLARE_HYDROGEN_ACCESSOR(HasCachedArrayIndexAndBranch)
1144 void PrintDataTo(StringStream* stream) OVERRIDE;
1148 class LClassOfTestAndBranch FINAL : public LControlInstruction<1, 1> {
1150 LClassOfTestAndBranch(LOperand* value, LOperand* temp) {
1155 LOperand* value() { return inputs_[0]; }
1156 LOperand* temp() { return temps_[0]; }
1158 DECLARE_CONCRETE_INSTRUCTION(ClassOfTestAndBranch,
1159 "class-of-test-and-branch")
1160 DECLARE_HYDROGEN_ACCESSOR(ClassOfTestAndBranch)
1162 void PrintDataTo(StringStream* stream) OVERRIDE;
1166 class LCmpT FINAL : public LTemplateInstruction<1, 3, 0> {
1168 LCmpT(LOperand* context, LOperand* left, LOperand* right) {
1169 inputs_[0] = context;
1174 LOperand* context() { return inputs_[0]; }
1175 LOperand* left() { return inputs_[1]; }
1176 LOperand* right() { return inputs_[2]; }
1178 DECLARE_CONCRETE_INSTRUCTION(CmpT, "cmp-t")
1179 DECLARE_HYDROGEN_ACCESSOR(CompareGeneric)
1181 Token::Value op() const { return hydrogen()->token(); }
1185 class LInstanceOf FINAL : public LTemplateInstruction<1, 3, 0> {
1187 LInstanceOf(LOperand* context, LOperand* left, LOperand* right) {
1188 inputs_[0] = context;
1193 LOperand* context() { return inputs_[0]; }
1194 LOperand* left() { return inputs_[1]; }
1195 LOperand* right() { return inputs_[2]; }
1197 DECLARE_CONCRETE_INSTRUCTION(InstanceOf, "instance-of")
1201 class LInstanceOfKnownGlobal FINAL : public LTemplateInstruction<1, 2, 1> {
1203 LInstanceOfKnownGlobal(LOperand* context, LOperand* value, LOperand* temp) {
1204 inputs_[0] = context;
1209 LOperand* context() { return inputs_[0]; }
1210 LOperand* value() { return inputs_[1]; }
1211 LOperand* temp() { return temps_[0]; }
1213 DECLARE_CONCRETE_INSTRUCTION(InstanceOfKnownGlobal,
1214 "instance-of-known-global")
1215 DECLARE_HYDROGEN_ACCESSOR(InstanceOfKnownGlobal)
1217 Handle<JSFunction> function() const { return hydrogen()->function(); }
1218 LEnvironment* GetDeferredLazyDeoptimizationEnvironment() {
1219 return lazy_deopt_env_;
1221 virtual void SetDeferredLazyDeoptimizationEnvironment(
1222 LEnvironment* env) OVERRIDE {
1223 lazy_deopt_env_ = env;
1227 LEnvironment* lazy_deopt_env_;
1231 class LBoundsCheck FINAL : public LTemplateInstruction<0, 2, 0> {
1233 LBoundsCheck(LOperand* index, LOperand* length) {
1235 inputs_[1] = length;
1238 LOperand* index() { return inputs_[0]; }
1239 LOperand* length() { return inputs_[1]; }
1241 DECLARE_CONCRETE_INSTRUCTION(BoundsCheck, "bounds-check")
1242 DECLARE_HYDROGEN_ACCESSOR(BoundsCheck)
1246 class LBitI FINAL : public LTemplateInstruction<1, 2, 0> {
1248 LBitI(LOperand* left, LOperand* right) {
1253 LOperand* left() { return inputs_[0]; }
1254 LOperand* right() { return inputs_[1]; }
1256 Token::Value op() const { return hydrogen()->op(); }
1258 DECLARE_CONCRETE_INSTRUCTION(BitI, "bit-i")
1259 DECLARE_HYDROGEN_ACCESSOR(Bitwise)
1263 class LShiftI FINAL : public LTemplateInstruction<1, 2, 0> {
1265 LShiftI(Token::Value op, LOperand* left, LOperand* right, bool can_deopt)
1266 : op_(op), can_deopt_(can_deopt) {
1271 Token::Value op() const { return op_; }
1272 LOperand* left() { return inputs_[0]; }
1273 LOperand* right() { return inputs_[1]; }
1274 bool can_deopt() const { return can_deopt_; }
1276 DECLARE_CONCRETE_INSTRUCTION(ShiftI, "shift-i")
1284 class LSubI FINAL : public LTemplateInstruction<1, 2, 0> {
1286 LSubI(LOperand* left, LOperand* right) {
1291 LOperand* left() { return inputs_[0]; }
1292 LOperand* right() { return inputs_[1]; }
1294 DECLARE_CONCRETE_INSTRUCTION(SubI, "sub-i")
1295 DECLARE_HYDROGEN_ACCESSOR(Sub)
1299 class LConstantI FINAL : public LTemplateInstruction<1, 0, 0> {
1301 DECLARE_CONCRETE_INSTRUCTION(ConstantI, "constant-i")
1302 DECLARE_HYDROGEN_ACCESSOR(Constant)
1304 int32_t value() const { return hydrogen()->Integer32Value(); }
1308 class LConstantS FINAL : public LTemplateInstruction<1, 0, 0> {
1310 DECLARE_CONCRETE_INSTRUCTION(ConstantS, "constant-s")
1311 DECLARE_HYDROGEN_ACCESSOR(Constant)
1313 Smi* value() const { return Smi::FromInt(hydrogen()->Integer32Value()); }
1317 class LConstantD FINAL : public LTemplateInstruction<1, 0, 0> {
1319 DECLARE_CONCRETE_INSTRUCTION(ConstantD, "constant-d")
1320 DECLARE_HYDROGEN_ACCESSOR(Constant)
1322 double value() const { return hydrogen()->DoubleValue(); }
1326 class LConstantE FINAL : public LTemplateInstruction<1, 0, 0> {
1328 DECLARE_CONCRETE_INSTRUCTION(ConstantE, "constant-e")
1329 DECLARE_HYDROGEN_ACCESSOR(Constant)
1331 ExternalReference value() const {
1332 return hydrogen()->ExternalReferenceValue();
1337 class LConstantT FINAL : public LTemplateInstruction<1, 0, 0> {
1339 DECLARE_CONCRETE_INSTRUCTION(ConstantT, "constant-t")
1340 DECLARE_HYDROGEN_ACCESSOR(Constant)
1342 Handle<Object> value(Isolate* isolate) const {
1343 return hydrogen()->handle(isolate);
1348 class LBranch FINAL : public LControlInstruction<1, 0> {
1350 explicit LBranch(LOperand* value) {
1354 LOperand* value() { return inputs_[0]; }
1356 DECLARE_CONCRETE_INSTRUCTION(Branch, "branch")
1357 DECLARE_HYDROGEN_ACCESSOR(Branch)
1359 void PrintDataTo(StringStream* stream) OVERRIDE;
1363 class LCmpMapAndBranch FINAL : public LControlInstruction<1, 1> {
1365 LCmpMapAndBranch(LOperand* value, LOperand* temp) {
1370 LOperand* value() { return inputs_[0]; }
1371 LOperand* temp() { return temps_[0]; }
1373 DECLARE_CONCRETE_INSTRUCTION(CmpMapAndBranch, "cmp-map-and-branch")
1374 DECLARE_HYDROGEN_ACCESSOR(CompareMap)
1376 Handle<Map> map() const { return hydrogen()->map().handle(); }
1380 class LMapEnumLength FINAL : public LTemplateInstruction<1, 1, 0> {
1382 explicit LMapEnumLength(LOperand* value) {
1386 LOperand* value() { return inputs_[0]; }
1388 DECLARE_CONCRETE_INSTRUCTION(MapEnumLength, "map-enum-length")
1392 class LDateField FINAL : public LTemplateInstruction<1, 1, 1> {
1394 LDateField(LOperand* date, LOperand* temp, Smi* index) : index_(index) {
1399 LOperand* date() { return inputs_[0]; }
1400 LOperand* temp() { return temps_[0]; }
1401 Smi* index() const { return index_; }
1403 DECLARE_CONCRETE_INSTRUCTION(DateField, "date-field")
1404 DECLARE_HYDROGEN_ACCESSOR(DateField)
1411 class LSeqStringGetChar FINAL : public LTemplateInstruction<1, 2, 0> {
1413 LSeqStringGetChar(LOperand* string, LOperand* index) {
1414 inputs_[0] = string;
1418 LOperand* string() const { return inputs_[0]; }
1419 LOperand* index() const { return inputs_[1]; }
1421 DECLARE_CONCRETE_INSTRUCTION(SeqStringGetChar, "seq-string-get-char")
1422 DECLARE_HYDROGEN_ACCESSOR(SeqStringGetChar)
1426 class LSeqStringSetChar FINAL : public LTemplateInstruction<1, 4, 0> {
1428 LSeqStringSetChar(LOperand* context,
1432 inputs_[0] = context;
1433 inputs_[1] = string;
1438 LOperand* string() { return inputs_[1]; }
1439 LOperand* index() { return inputs_[2]; }
1440 LOperand* value() { return inputs_[3]; }
1442 DECLARE_CONCRETE_INSTRUCTION(SeqStringSetChar, "seq-string-set-char")
1443 DECLARE_HYDROGEN_ACCESSOR(SeqStringSetChar)
1447 class LAddI FINAL : public LTemplateInstruction<1, 2, 0> {
1449 LAddI(LOperand* left, LOperand* right) {
1454 LOperand* left() { return inputs_[0]; }
1455 LOperand* right() { return inputs_[1]; }
1457 DECLARE_CONCRETE_INSTRUCTION(AddI, "add-i")
1458 DECLARE_HYDROGEN_ACCESSOR(Add)
1462 class LMathMinMax FINAL : public LTemplateInstruction<1, 2, 0> {
1464 LMathMinMax(LOperand* left, LOperand* right) {
1469 LOperand* left() { return inputs_[0]; }
1470 LOperand* right() { return inputs_[1]; }
1472 DECLARE_CONCRETE_INSTRUCTION(MathMinMax, "math-min-max")
1473 DECLARE_HYDROGEN_ACCESSOR(MathMinMax)
1477 class LPower FINAL : public LTemplateInstruction<1, 2, 0> {
1479 LPower(LOperand* left, LOperand* right) {
1484 LOperand* left() { return inputs_[0]; }
1485 LOperand* right() { return inputs_[1]; }
1487 DECLARE_CONCRETE_INSTRUCTION(Power, "power")
1488 DECLARE_HYDROGEN_ACCESSOR(Power)
1492 class LArithmeticD FINAL : public LTemplateInstruction<1, 2, 0> {
1494 LArithmeticD(Token::Value op, LOperand* left, LOperand* right)
1500 Token::Value op() const { return op_; }
1501 LOperand* left() { return inputs_[0]; }
1502 LOperand* right() { return inputs_[1]; }
1504 Opcode opcode() const OVERRIDE { return LInstruction::kArithmeticD; }
1505 void CompileToNative(LCodeGen* generator) OVERRIDE;
1506 const char* Mnemonic() const OVERRIDE;
1513 class LArithmeticT FINAL : public LTemplateInstruction<1, 3, 0> {
1515 LArithmeticT(Token::Value op,
1520 inputs_[0] = context;
1525 LOperand* context() { return inputs_[0]; }
1526 LOperand* left() { return inputs_[1]; }
1527 LOperand* right() { return inputs_[2]; }
1528 Token::Value op() const { return op_; }
1530 Opcode opcode() const FINAL { return LInstruction::kArithmeticT; }
1531 void CompileToNative(LCodeGen* generator) OVERRIDE;
1532 const char* Mnemonic() const OVERRIDE;
1539 class LReturn FINAL : public LTemplateInstruction<0, 3, 0> {
1541 LReturn(LOperand* value, LOperand* context, LOperand* parameter_count) {
1543 inputs_[1] = context;
1544 inputs_[2] = parameter_count;
1547 LOperand* value() { return inputs_[0]; }
1549 bool has_constant_parameter_count() {
1550 return parameter_count()->IsConstantOperand();
1552 LConstantOperand* constant_parameter_count() {
1553 DCHECK(has_constant_parameter_count());
1554 return LConstantOperand::cast(parameter_count());
1556 LOperand* parameter_count() { return inputs_[2]; }
1558 DECLARE_CONCRETE_INSTRUCTION(Return, "return")
1562 class LLoadNamedField FINAL : public LTemplateInstruction<1, 1, 0> {
1564 explicit LLoadNamedField(LOperand* object) {
1565 inputs_[0] = object;
1568 LOperand* object() { return inputs_[0]; }
1570 DECLARE_CONCRETE_INSTRUCTION(LoadNamedField, "load-named-field")
1571 DECLARE_HYDROGEN_ACCESSOR(LoadNamedField)
1575 class LLoadNamedGeneric FINAL : public LTemplateInstruction<1, 2, 1> {
1577 LLoadNamedGeneric(LOperand* context, LOperand* object, LOperand* vector) {
1578 inputs_[0] = context;
1579 inputs_[1] = object;
1583 LOperand* context() { return inputs_[0]; }
1584 LOperand* object() { return inputs_[1]; }
1585 LOperand* temp_vector() { return temps_[0]; }
1587 DECLARE_CONCRETE_INSTRUCTION(LoadNamedGeneric, "load-named-generic")
1588 DECLARE_HYDROGEN_ACCESSOR(LoadNamedGeneric)
1590 Handle<Object> name() const { return hydrogen()->name(); }
1594 class LLoadFunctionPrototype FINAL : public LTemplateInstruction<1, 1, 0> {
1596 explicit LLoadFunctionPrototype(LOperand* function) {
1597 inputs_[0] = function;
1600 LOperand* function() { return inputs_[0]; }
1602 DECLARE_CONCRETE_INSTRUCTION(LoadFunctionPrototype, "load-function-prototype")
1603 DECLARE_HYDROGEN_ACCESSOR(LoadFunctionPrototype)
1607 class LLoadRoot FINAL : public LTemplateInstruction<1, 0, 0> {
1609 DECLARE_CONCRETE_INSTRUCTION(LoadRoot, "load-root")
1610 DECLARE_HYDROGEN_ACCESSOR(LoadRoot)
1612 Heap::RootListIndex index() const { return hydrogen()->index(); }
1616 class LLoadKeyed FINAL : public LTemplateInstruction<1, 2, 0> {
1618 LLoadKeyed(LOperand* elements, LOperand* key) {
1619 inputs_[0] = elements;
1623 LOperand* elements() { return inputs_[0]; }
1624 LOperand* key() { return inputs_[1]; }
1625 ElementsKind elements_kind() const {
1626 return hydrogen()->elements_kind();
1628 bool is_external() const {
1629 return hydrogen()->is_external();
1631 bool is_fixed_typed_array() const {
1632 return hydrogen()->is_fixed_typed_array();
1634 bool is_typed_elements() const {
1635 return is_external() || is_fixed_typed_array();
1638 DECLARE_CONCRETE_INSTRUCTION(LoadKeyed, "load-keyed")
1639 DECLARE_HYDROGEN_ACCESSOR(LoadKeyed)
1641 void PrintDataTo(StringStream* stream) OVERRIDE;
1642 uint32_t base_offset() const { return hydrogen()->base_offset(); }
1646 class LLoadKeyedGeneric FINAL : public LTemplateInstruction<1, 3, 1> {
1648 LLoadKeyedGeneric(LOperand* context, LOperand* object, LOperand* key,
1650 inputs_[0] = context;
1651 inputs_[1] = object;
1656 LOperand* context() { return inputs_[0]; }
1657 LOperand* object() { return inputs_[1]; }
1658 LOperand* key() { return inputs_[2]; }
1659 LOperand* temp_vector() { return temps_[0]; }
1661 DECLARE_CONCRETE_INSTRUCTION(LoadKeyedGeneric, "load-keyed-generic")
1662 DECLARE_HYDROGEN_ACCESSOR(LoadKeyedGeneric)
1666 class LLoadGlobalGeneric FINAL : public LTemplateInstruction<1, 2, 1> {
1668 LLoadGlobalGeneric(LOperand* context, LOperand* global_object,
1670 inputs_[0] = context;
1671 inputs_[1] = global_object;
1675 LOperand* context() { return inputs_[0]; }
1676 LOperand* global_object() { return inputs_[1]; }
1677 LOperand* temp_vector() { return temps_[0]; }
1679 DECLARE_CONCRETE_INSTRUCTION(LoadGlobalGeneric, "load-global-generic")
1680 DECLARE_HYDROGEN_ACCESSOR(LoadGlobalGeneric)
1682 Handle<Object> name() const { return hydrogen()->name(); }
1683 bool for_typeof() const { return hydrogen()->for_typeof(); }
1687 class LLoadContextSlot FINAL : public LTemplateInstruction<1, 1, 0> {
1689 explicit LLoadContextSlot(LOperand* context) {
1690 inputs_[0] = context;
1693 LOperand* context() { return inputs_[0]; }
1695 DECLARE_CONCRETE_INSTRUCTION(LoadContextSlot, "load-context-slot")
1696 DECLARE_HYDROGEN_ACCESSOR(LoadContextSlot)
1698 int slot_index() { return hydrogen()->slot_index(); }
1700 void PrintDataTo(StringStream* stream) OVERRIDE;
1704 class LStoreContextSlot FINAL : public LTemplateInstruction<0, 2, 0> {
1706 LStoreContextSlot(LOperand* context, LOperand* value) {
1707 inputs_[0] = context;
1711 LOperand* context() { return inputs_[0]; }
1712 LOperand* value() { return inputs_[1]; }
1714 DECLARE_CONCRETE_INSTRUCTION(StoreContextSlot, "store-context-slot")
1715 DECLARE_HYDROGEN_ACCESSOR(StoreContextSlot)
1717 int slot_index() { return hydrogen()->slot_index(); }
1719 void PrintDataTo(StringStream* stream) OVERRIDE;
1723 class LPushArgument FINAL : public LTemplateInstruction<0, 1, 0> {
1725 explicit LPushArgument(LOperand* value) {
1729 LOperand* value() { return inputs_[0]; }
1731 DECLARE_CONCRETE_INSTRUCTION(PushArgument, "push-argument")
1735 class LDrop FINAL : public LTemplateInstruction<0, 0, 0> {
1737 explicit LDrop(int count) : count_(count) { }
1739 int count() const { return count_; }
1741 DECLARE_CONCRETE_INSTRUCTION(Drop, "drop")
1748 class LStoreCodeEntry FINAL: public LTemplateInstruction<0, 2, 0> {
1750 LStoreCodeEntry(LOperand* function, LOperand* code_object) {
1751 inputs_[0] = function;
1752 inputs_[1] = code_object;
1755 LOperand* function() { return inputs_[0]; }
1756 LOperand* code_object() { return inputs_[1]; }
1758 void PrintDataTo(StringStream* stream) OVERRIDE;
1760 DECLARE_CONCRETE_INSTRUCTION(StoreCodeEntry, "store-code-entry")
1761 DECLARE_HYDROGEN_ACCESSOR(StoreCodeEntry)
1765 class LInnerAllocatedObject FINAL: public LTemplateInstruction<1, 2, 0> {
1767 LInnerAllocatedObject(LOperand* base_object, LOperand* offset) {
1768 inputs_[0] = base_object;
1769 inputs_[1] = offset;
1772 LOperand* base_object() const { return inputs_[0]; }
1773 LOperand* offset() const { return inputs_[1]; }
1775 void PrintDataTo(StringStream* stream) OVERRIDE;
1777 DECLARE_CONCRETE_INSTRUCTION(InnerAllocatedObject, "inner-allocated-object")
1781 class LThisFunction FINAL : public LTemplateInstruction<1, 0, 0> {
1783 DECLARE_CONCRETE_INSTRUCTION(ThisFunction, "this-function")
1784 DECLARE_HYDROGEN_ACCESSOR(ThisFunction)
1788 class LContext FINAL : public LTemplateInstruction<1, 0, 0> {
1790 DECLARE_CONCRETE_INSTRUCTION(Context, "context")
1791 DECLARE_HYDROGEN_ACCESSOR(Context)
1795 class LDeclareGlobals FINAL : public LTemplateInstruction<0, 1, 0> {
1797 explicit LDeclareGlobals(LOperand* context) {
1798 inputs_[0] = context;
1801 LOperand* context() { return inputs_[0]; }
1803 DECLARE_CONCRETE_INSTRUCTION(DeclareGlobals, "declare-globals")
1804 DECLARE_HYDROGEN_ACCESSOR(DeclareGlobals)
1808 class LCallJSFunction FINAL : public LTemplateInstruction<1, 1, 0> {
1810 explicit LCallJSFunction(LOperand* function) {
1811 inputs_[0] = function;
1814 LOperand* function() { return inputs_[0]; }
1816 DECLARE_CONCRETE_INSTRUCTION(CallJSFunction, "call-js-function")
1817 DECLARE_HYDROGEN_ACCESSOR(CallJSFunction)
1819 void PrintDataTo(StringStream* stream) OVERRIDE;
1821 int arity() const { return hydrogen()->argument_count() - 1; }
1825 class LCallWithDescriptor FINAL : public LTemplateResultInstruction<1> {
1827 LCallWithDescriptor(CallInterfaceDescriptor descriptor,
1828 const ZoneList<LOperand*>& operands, Zone* zone)
1829 : descriptor_(descriptor),
1830 inputs_(descriptor.GetRegisterParameterCount() + 1, zone) {
1831 DCHECK(descriptor.GetRegisterParameterCount() + 1 == operands.length());
1832 inputs_.AddAll(operands, zone);
1835 LOperand* target() const { return inputs_[0]; }
1837 const CallInterfaceDescriptor descriptor() { return descriptor_; }
1839 DECLARE_HYDROGEN_ACCESSOR(CallWithDescriptor)
1842 DECLARE_CONCRETE_INSTRUCTION(CallWithDescriptor, "call-with-descriptor")
1844 void PrintDataTo(StringStream* stream) OVERRIDE;
1846 int arity() const { return hydrogen()->argument_count() - 1; }
1848 CallInterfaceDescriptor descriptor_;
1849 ZoneList<LOperand*> inputs_;
1851 // Iterator support.
1852 int InputCount() FINAL { return inputs_.length(); }
1853 LOperand* InputAt(int i) FINAL { return inputs_[i]; }
1855 int TempCount() FINAL { return 0; }
1856 LOperand* TempAt(int i) FINAL { return NULL; }
1861 class LInvokeFunction FINAL : public LTemplateInstruction<1, 2, 0> {
1863 LInvokeFunction(LOperand* context, LOperand* function) {
1864 inputs_[0] = context;
1865 inputs_[1] = function;
1868 LOperand* context() { return inputs_[0]; }
1869 LOperand* function() { return inputs_[1]; }
1871 DECLARE_CONCRETE_INSTRUCTION(InvokeFunction, "invoke-function")
1872 DECLARE_HYDROGEN_ACCESSOR(InvokeFunction)
1874 void PrintDataTo(StringStream* stream) OVERRIDE;
1876 int arity() const { return hydrogen()->argument_count() - 1; }
1880 class LCallFunction FINAL : public LTemplateInstruction<1, 2, 2> {
1882 LCallFunction(LOperand* context, LOperand* function, LOperand* slot,
1884 inputs_[0] = context;
1885 inputs_[1] = function;
1890 LOperand* context() { return inputs_[0]; }
1891 LOperand* function() { return inputs_[1]; }
1892 LOperand* temp_slot() { return temps_[0]; }
1893 LOperand* temp_vector() { return temps_[1]; }
1895 DECLARE_CONCRETE_INSTRUCTION(CallFunction, "call-function")
1896 DECLARE_HYDROGEN_ACCESSOR(CallFunction)
1898 int arity() const { return hydrogen()->argument_count() - 1; }
1899 void PrintDataTo(StringStream* stream) OVERRIDE;
1903 class LCallNew FINAL : public LTemplateInstruction<1, 2, 0> {
1905 LCallNew(LOperand* context, LOperand* constructor) {
1906 inputs_[0] = context;
1907 inputs_[1] = constructor;
1910 LOperand* context() { return inputs_[0]; }
1911 LOperand* constructor() { return inputs_[1]; }
1913 DECLARE_CONCRETE_INSTRUCTION(CallNew, "call-new")
1914 DECLARE_HYDROGEN_ACCESSOR(CallNew)
1916 void PrintDataTo(StringStream* stream) OVERRIDE;
1918 int arity() const { return hydrogen()->argument_count() - 1; }
1922 class LCallNewArray FINAL : public LTemplateInstruction<1, 2, 0> {
1924 LCallNewArray(LOperand* context, LOperand* constructor) {
1925 inputs_[0] = context;
1926 inputs_[1] = constructor;
1929 LOperand* context() { return inputs_[0]; }
1930 LOperand* constructor() { return inputs_[1]; }
1932 DECLARE_CONCRETE_INSTRUCTION(CallNewArray, "call-new-array")
1933 DECLARE_HYDROGEN_ACCESSOR(CallNewArray)
1935 void PrintDataTo(StringStream* stream) OVERRIDE;
1937 int arity() const { return hydrogen()->argument_count() - 1; }
1941 class LCallRuntime FINAL : public LTemplateInstruction<1, 1, 0> {
1943 explicit LCallRuntime(LOperand* context) {
1944 inputs_[0] = context;
1947 LOperand* context() { return inputs_[0]; }
1949 DECLARE_CONCRETE_INSTRUCTION(CallRuntime, "call-runtime")
1950 DECLARE_HYDROGEN_ACCESSOR(CallRuntime)
1952 bool ClobbersDoubleRegisters(Isolate* isolate) const OVERRIDE {
1953 return save_doubles() == kDontSaveFPRegs;
1956 const Runtime::Function* function() const { return hydrogen()->function(); }
1957 int arity() const { return hydrogen()->argument_count(); }
1958 SaveFPRegsMode save_doubles() const { return hydrogen()->save_doubles(); }
1962 class LInteger32ToDouble FINAL : public LTemplateInstruction<1, 1, 0> {
1964 explicit LInteger32ToDouble(LOperand* value) {
1968 LOperand* value() { return inputs_[0]; }
1970 DECLARE_CONCRETE_INSTRUCTION(Integer32ToDouble, "int32-to-double")
1974 class LUint32ToDouble FINAL : public LTemplateInstruction<1, 1, 0> {
1976 explicit LUint32ToDouble(LOperand* value) {
1980 LOperand* value() { return inputs_[0]; }
1982 DECLARE_CONCRETE_INSTRUCTION(Uint32ToDouble, "uint32-to-double")
1986 class LNumberTagU FINAL : public LTemplateInstruction<1, 1, 2> {
1988 LNumberTagU(LOperand* value, LOperand* temp1, LOperand* temp2) {
1994 LOperand* value() { return inputs_[0]; }
1995 LOperand* temp1() { return temps_[0]; }
1996 LOperand* temp2() { return temps_[1]; }
1998 DECLARE_CONCRETE_INSTRUCTION(NumberTagU, "number-tag-u")
2002 class LNumberTagD FINAL : public LTemplateInstruction<1, 1, 2> {
2004 LNumberTagD(LOperand* value, LOperand* temp, LOperand* temp2) {
2010 LOperand* value() { return inputs_[0]; }
2011 LOperand* temp() { return temps_[0]; }
2012 LOperand* temp2() { return temps_[1]; }
2014 DECLARE_CONCRETE_INSTRUCTION(NumberTagD, "number-tag-d")
2015 DECLARE_HYDROGEN_ACCESSOR(Change)
2019 class LDoubleToSmi FINAL : public LTemplateInstruction<1, 1, 0> {
2021 explicit LDoubleToSmi(LOperand* value) {
2025 LOperand* value() { return inputs_[0]; }
2027 DECLARE_CONCRETE_INSTRUCTION(DoubleToSmi, "double-to-smi")
2028 DECLARE_HYDROGEN_ACCESSOR(UnaryOperation)
2030 bool truncating() { return hydrogen()->CanTruncateToInt32(); }
2034 // Sometimes truncating conversion from a tagged value to an int32.
2035 class LDoubleToI FINAL : public LTemplateInstruction<1, 1, 0> {
2037 explicit LDoubleToI(LOperand* value) {
2041 LOperand* value() { return inputs_[0]; }
2043 DECLARE_CONCRETE_INSTRUCTION(DoubleToI, "double-to-i")
2044 DECLARE_HYDROGEN_ACCESSOR(UnaryOperation)
2046 bool truncating() { return hydrogen()->CanTruncateToInt32(); }
2050 // Truncating conversion from a tagged value to an int32.
2051 class LTaggedToI FINAL : public LTemplateInstruction<1, 1, 2> {
2053 LTaggedToI(LOperand* value,
2061 LOperand* value() { return inputs_[0]; }
2062 LOperand* temp() { return temps_[0]; }
2063 LOperand* temp2() { return temps_[1]; }
2065 DECLARE_CONCRETE_INSTRUCTION(TaggedToI, "tagged-to-i")
2066 DECLARE_HYDROGEN_ACCESSOR(Change)
2068 bool truncating() { return hydrogen()->CanTruncateToInt32(); }
2072 class LSmiTag FINAL : public LTemplateInstruction<1, 1, 0> {
2074 explicit LSmiTag(LOperand* value) {
2078 LOperand* value() { return inputs_[0]; }
2080 DECLARE_CONCRETE_INSTRUCTION(SmiTag, "smi-tag")
2081 DECLARE_HYDROGEN_ACCESSOR(Change)
2085 class LNumberUntagD FINAL : public LTemplateInstruction<1, 1, 0> {
2087 explicit LNumberUntagD(LOperand* value) {
2091 LOperand* value() { return inputs_[0]; }
2093 DECLARE_CONCRETE_INSTRUCTION(NumberUntagD, "double-untag")
2094 DECLARE_HYDROGEN_ACCESSOR(Change)
2098 class LSmiUntag FINAL : public LTemplateInstruction<1, 1, 0> {
2100 LSmiUntag(LOperand* value, bool needs_check)
2101 : needs_check_(needs_check) {
2105 LOperand* value() { return inputs_[0]; }
2106 bool needs_check() const { return needs_check_; }
2108 DECLARE_CONCRETE_INSTRUCTION(SmiUntag, "smi-untag")
2115 class LStoreNamedField FINAL : public LTemplateInstruction<0, 2, 1> {
2117 LStoreNamedField(LOperand* object, LOperand* value, LOperand* temp) {
2118 inputs_[0] = object;
2123 LOperand* object() { return inputs_[0]; }
2124 LOperand* value() { return inputs_[1]; }
2125 LOperand* temp() { return temps_[0]; }
2127 DECLARE_CONCRETE_INSTRUCTION(StoreNamedField, "store-named-field")
2128 DECLARE_HYDROGEN_ACCESSOR(StoreNamedField)
2130 void PrintDataTo(StringStream* stream) OVERRIDE;
2132 Representation representation() const {
2133 return hydrogen()->field_representation();
2138 class LStoreNamedGeneric FINAL : public LTemplateInstruction<0, 3, 0> {
2140 LStoreNamedGeneric(LOperand* context, LOperand* object, LOperand* value) {
2141 inputs_[0] = context;
2142 inputs_[1] = object;
2146 LOperand* context() { return inputs_[0]; }
2147 LOperand* object() { return inputs_[1]; }
2148 LOperand* value() { return inputs_[2]; }
2150 DECLARE_CONCRETE_INSTRUCTION(StoreNamedGeneric, "store-named-generic")
2151 DECLARE_HYDROGEN_ACCESSOR(StoreNamedGeneric)
2153 void PrintDataTo(StringStream* stream) OVERRIDE;
2155 Handle<Object> name() const { return hydrogen()->name(); }
2156 LanguageMode language_mode() { return hydrogen()->language_mode(); }
2160 class LStoreKeyed FINAL : public LTemplateInstruction<0, 3, 0> {
2162 LStoreKeyed(LOperand* object, LOperand* key, LOperand* value) {
2163 inputs_[0] = object;
2168 bool is_external() const { return hydrogen()->is_external(); }
2169 bool is_fixed_typed_array() const {
2170 return hydrogen()->is_fixed_typed_array();
2172 bool is_typed_elements() const {
2173 return is_external() || is_fixed_typed_array();
2175 LOperand* elements() { return inputs_[0]; }
2176 LOperand* key() { return inputs_[1]; }
2177 LOperand* value() { return inputs_[2]; }
2178 ElementsKind elements_kind() const {
2179 return hydrogen()->elements_kind();
2182 DECLARE_CONCRETE_INSTRUCTION(StoreKeyed, "store-keyed")
2183 DECLARE_HYDROGEN_ACCESSOR(StoreKeyed)
2185 void PrintDataTo(StringStream* stream) OVERRIDE;
2186 bool NeedsCanonicalization() { return hydrogen()->NeedsCanonicalization(); }
2187 uint32_t base_offset() const { return hydrogen()->base_offset(); }
2191 class LStoreKeyedGeneric FINAL : public LTemplateInstruction<0, 4, 0> {
2193 LStoreKeyedGeneric(LOperand* context,
2197 inputs_[0] = context;
2203 LOperand* context() { return inputs_[0]; }
2204 LOperand* object() { return inputs_[1]; }
2205 LOperand* key() { return inputs_[2]; }
2206 LOperand* value() { return inputs_[3]; }
2208 DECLARE_CONCRETE_INSTRUCTION(StoreKeyedGeneric, "store-keyed-generic")
2209 DECLARE_HYDROGEN_ACCESSOR(StoreKeyedGeneric)
2211 void PrintDataTo(StringStream* stream) OVERRIDE;
2213 LanguageMode language_mode() { return hydrogen()->language_mode(); }
2217 class LTransitionElementsKind FINAL : public LTemplateInstruction<0, 2, 1> {
2219 LTransitionElementsKind(LOperand* object,
2221 LOperand* new_map_temp) {
2222 inputs_[0] = object;
2223 inputs_[1] = context;
2224 temps_[0] = new_map_temp;
2227 LOperand* context() { return inputs_[1]; }
2228 LOperand* object() { return inputs_[0]; }
2229 LOperand* new_map_temp() { return temps_[0]; }
2231 DECLARE_CONCRETE_INSTRUCTION(TransitionElementsKind,
2232 "transition-elements-kind")
2233 DECLARE_HYDROGEN_ACCESSOR(TransitionElementsKind)
2235 void PrintDataTo(StringStream* stream) OVERRIDE;
2237 Handle<Map> original_map() { return hydrogen()->original_map().handle(); }
2238 Handle<Map> transitioned_map() {
2239 return hydrogen()->transitioned_map().handle();
2241 ElementsKind from_kind() { return hydrogen()->from_kind(); }
2242 ElementsKind to_kind() { return hydrogen()->to_kind(); }
2246 class LTrapAllocationMemento FINAL : public LTemplateInstruction<0, 1, 1> {
2248 LTrapAllocationMemento(LOperand* object,
2250 inputs_[0] = object;
2254 LOperand* object() { return inputs_[0]; }
2255 LOperand* temp() { return temps_[0]; }
2257 DECLARE_CONCRETE_INSTRUCTION(TrapAllocationMemento,
2258 "trap-allocation-memento")
2262 class LStringAdd FINAL : public LTemplateInstruction<1, 3, 0> {
2264 LStringAdd(LOperand* context, LOperand* left, LOperand* right) {
2265 inputs_[0] = context;
2270 LOperand* context() { return inputs_[0]; }
2271 LOperand* left() { return inputs_[1]; }
2272 LOperand* right() { return inputs_[2]; }
2274 DECLARE_CONCRETE_INSTRUCTION(StringAdd, "string-add")
2275 DECLARE_HYDROGEN_ACCESSOR(StringAdd)
2280 class LStringCharCodeAt FINAL : public LTemplateInstruction<1, 3, 0> {
2282 LStringCharCodeAt(LOperand* context, LOperand* string, LOperand* index) {
2283 inputs_[0] = context;
2284 inputs_[1] = string;
2288 LOperand* context() { return inputs_[0]; }
2289 LOperand* string() { return inputs_[1]; }
2290 LOperand* index() { return inputs_[2]; }
2292 DECLARE_CONCRETE_INSTRUCTION(StringCharCodeAt, "string-char-code-at")
2293 DECLARE_HYDROGEN_ACCESSOR(StringCharCodeAt)
2297 class LStringCharFromCode FINAL : public LTemplateInstruction<1, 2, 0> {
2299 explicit LStringCharFromCode(LOperand* context, LOperand* char_code) {
2300 inputs_[0] = context;
2301 inputs_[1] = char_code;
2304 LOperand* context() { return inputs_[0]; }
2305 LOperand* char_code() { return inputs_[1]; }
2307 DECLARE_CONCRETE_INSTRUCTION(StringCharFromCode, "string-char-from-code")
2308 DECLARE_HYDROGEN_ACCESSOR(StringCharFromCode)
2312 class LCheckValue FINAL : public LTemplateInstruction<0, 1, 0> {
2314 explicit LCheckValue(LOperand* value) {
2318 LOperand* value() { return inputs_[0]; }
2320 DECLARE_CONCRETE_INSTRUCTION(CheckValue, "check-value")
2321 DECLARE_HYDROGEN_ACCESSOR(CheckValue)
2325 class LCheckInstanceType FINAL : public LTemplateInstruction<0, 1, 0> {
2327 explicit LCheckInstanceType(LOperand* value) {
2331 LOperand* value() { return inputs_[0]; }
2333 DECLARE_CONCRETE_INSTRUCTION(CheckInstanceType, "check-instance-type")
2334 DECLARE_HYDROGEN_ACCESSOR(CheckInstanceType)
2338 class LCheckMaps FINAL : public LTemplateInstruction<0, 1, 0> {
2340 explicit LCheckMaps(LOperand* value = NULL) {
2344 LOperand* value() { return inputs_[0]; }
2346 DECLARE_CONCRETE_INSTRUCTION(CheckMaps, "check-maps")
2347 DECLARE_HYDROGEN_ACCESSOR(CheckMaps)
2351 class LCheckSmi FINAL : public LTemplateInstruction<1, 1, 0> {
2353 explicit LCheckSmi(LOperand* value) {
2357 LOperand* value() { return inputs_[0]; }
2359 DECLARE_CONCRETE_INSTRUCTION(CheckSmi, "check-smi")
2363 class LCheckNonSmi FINAL : public LTemplateInstruction<0, 1, 0> {
2365 explicit LCheckNonSmi(LOperand* value) {
2369 LOperand* value() { return inputs_[0]; }
2371 DECLARE_CONCRETE_INSTRUCTION(CheckNonSmi, "check-non-smi")
2372 DECLARE_HYDROGEN_ACCESSOR(CheckHeapObject)
2376 class LClampDToUint8 FINAL : public LTemplateInstruction<1, 1, 1> {
2378 LClampDToUint8(LOperand* unclamped, LOperand* temp) {
2379 inputs_[0] = unclamped;
2383 LOperand* unclamped() { return inputs_[0]; }
2384 LOperand* temp() { return temps_[0]; }
2386 DECLARE_CONCRETE_INSTRUCTION(ClampDToUint8, "clamp-d-to-uint8")
2390 class LClampIToUint8 FINAL : public LTemplateInstruction<1, 1, 0> {
2392 explicit LClampIToUint8(LOperand* unclamped) {
2393 inputs_[0] = unclamped;
2396 LOperand* unclamped() { return inputs_[0]; }
2398 DECLARE_CONCRETE_INSTRUCTION(ClampIToUint8, "clamp-i-to-uint8")
2402 class LClampTToUint8 FINAL : public LTemplateInstruction<1, 1, 1> {
2404 LClampTToUint8(LOperand* unclamped, LOperand* temp) {
2405 inputs_[0] = unclamped;
2409 LOperand* unclamped() { return inputs_[0]; }
2410 LOperand* temp() { return temps_[0]; }
2412 DECLARE_CONCRETE_INSTRUCTION(ClampTToUint8, "clamp-t-to-uint8")
2416 class LDoubleBits FINAL : public LTemplateInstruction<1, 1, 0> {
2418 explicit LDoubleBits(LOperand* value) {
2422 LOperand* value() { return inputs_[0]; }
2424 DECLARE_CONCRETE_INSTRUCTION(DoubleBits, "double-bits")
2425 DECLARE_HYDROGEN_ACCESSOR(DoubleBits)
2429 class LConstructDouble FINAL : public LTemplateInstruction<1, 2, 0> {
2431 LConstructDouble(LOperand* hi, LOperand* lo) {
2436 LOperand* hi() { return inputs_[0]; }
2437 LOperand* lo() { return inputs_[1]; }
2439 DECLARE_CONCRETE_INSTRUCTION(ConstructDouble, "construct-double")
2443 class LAllocate FINAL : public LTemplateInstruction<1, 2, 2> {
2445 LAllocate(LOperand* context,
2449 inputs_[0] = context;
2455 LOperand* context() { return inputs_[0]; }
2456 LOperand* size() { return inputs_[1]; }
2457 LOperand* temp1() { return temps_[0]; }
2458 LOperand* temp2() { return temps_[1]; }
2460 DECLARE_CONCRETE_INSTRUCTION(Allocate, "allocate")
2461 DECLARE_HYDROGEN_ACCESSOR(Allocate)
2465 class LRegExpLiteral FINAL : public LTemplateInstruction<1, 1, 0> {
2467 explicit LRegExpLiteral(LOperand* context) {
2468 inputs_[0] = context;
2471 LOperand* context() { return inputs_[0]; }
2473 DECLARE_CONCRETE_INSTRUCTION(RegExpLiteral, "regexp-literal")
2474 DECLARE_HYDROGEN_ACCESSOR(RegExpLiteral)
2478 class LFunctionLiteral FINAL : public LTemplateInstruction<1, 1, 0> {
2480 explicit LFunctionLiteral(LOperand* context) {
2481 inputs_[0] = context;
2484 LOperand* context() { return inputs_[0]; }
2486 DECLARE_CONCRETE_INSTRUCTION(FunctionLiteral, "function-literal")
2487 DECLARE_HYDROGEN_ACCESSOR(FunctionLiteral)
2491 class LToFastProperties FINAL : public LTemplateInstruction<1, 1, 0> {
2493 explicit LToFastProperties(LOperand* value) {
2497 LOperand* value() { return inputs_[0]; }
2499 DECLARE_CONCRETE_INSTRUCTION(ToFastProperties, "to-fast-properties")
2500 DECLARE_HYDROGEN_ACCESSOR(ToFastProperties)
2504 class LTypeof FINAL : public LTemplateInstruction<1, 2, 0> {
2506 LTypeof(LOperand* context, LOperand* value) {
2507 inputs_[0] = context;
2511 LOperand* context() { return inputs_[0]; }
2512 LOperand* value() { return inputs_[1]; }
2514 DECLARE_CONCRETE_INSTRUCTION(Typeof, "typeof")
2518 class LTypeofIsAndBranch FINAL : public LControlInstruction<1, 0> {
2520 explicit LTypeofIsAndBranch(LOperand* value) {
2524 LOperand* value() { return inputs_[0]; }
2526 DECLARE_CONCRETE_INSTRUCTION(TypeofIsAndBranch, "typeof-is-and-branch")
2527 DECLARE_HYDROGEN_ACCESSOR(TypeofIsAndBranch)
2529 Handle<String> type_literal() { return hydrogen()->type_literal(); }
2531 void PrintDataTo(StringStream* stream) OVERRIDE;
2535 class LIsConstructCallAndBranch FINAL : public LControlInstruction<0, 1> {
2537 explicit LIsConstructCallAndBranch(LOperand* temp) {
2541 LOperand* temp() { return temps_[0]; }
2543 DECLARE_CONCRETE_INSTRUCTION(IsConstructCallAndBranch,
2544 "is-construct-call-and-branch")
2548 class LOsrEntry FINAL : public LTemplateInstruction<0, 0, 0> {
2552 bool HasInterestingComment(LCodeGen* gen) const OVERRIDE { return false; }
2553 DECLARE_CONCRETE_INSTRUCTION(OsrEntry, "osr-entry")
2557 class LStackCheck FINAL : public LTemplateInstruction<0, 1, 0> {
2559 explicit LStackCheck(LOperand* context) {
2560 inputs_[0] = context;
2563 LOperand* context() { return inputs_[0]; }
2565 DECLARE_CONCRETE_INSTRUCTION(StackCheck, "stack-check")
2566 DECLARE_HYDROGEN_ACCESSOR(StackCheck)
2568 Label* done_label() { return &done_label_; }
2575 class LForInPrepareMap FINAL : public LTemplateInstruction<1, 2, 0> {
2577 LForInPrepareMap(LOperand* context, LOperand* object) {
2578 inputs_[0] = context;
2579 inputs_[1] = object;
2582 LOperand* context() { return inputs_[0]; }
2583 LOperand* object() { return inputs_[1]; }
2585 DECLARE_CONCRETE_INSTRUCTION(ForInPrepareMap, "for-in-prepare-map")
2589 class LForInCacheArray FINAL : public LTemplateInstruction<1, 1, 0> {
2591 explicit LForInCacheArray(LOperand* map) {
2595 LOperand* map() { return inputs_[0]; }
2597 DECLARE_CONCRETE_INSTRUCTION(ForInCacheArray, "for-in-cache-array")
2600 return HForInCacheArray::cast(this->hydrogen_value())->idx();
2605 class LCheckMapValue FINAL : public LTemplateInstruction<0, 2, 0> {
2607 LCheckMapValue(LOperand* value, LOperand* map) {
2612 LOperand* value() { return inputs_[0]; }
2613 LOperand* map() { return inputs_[1]; }
2615 DECLARE_CONCRETE_INSTRUCTION(CheckMapValue, "check-map-value")
2619 class LLoadFieldByIndex FINAL : public LTemplateInstruction<1, 2, 0> {
2621 LLoadFieldByIndex(LOperand* object, LOperand* index) {
2622 inputs_[0] = object;
2626 LOperand* object() { return inputs_[0]; }
2627 LOperand* index() { return inputs_[1]; }
2629 DECLARE_CONCRETE_INSTRUCTION(LoadFieldByIndex, "load-field-by-index")
2633 class LStoreFrameContext: public LTemplateInstruction<0, 1, 0> {
2635 explicit LStoreFrameContext(LOperand* context) {
2636 inputs_[0] = context;
2639 LOperand* context() { return inputs_[0]; }
2641 DECLARE_CONCRETE_INSTRUCTION(StoreFrameContext, "store-frame-context")
2645 class LAllocateBlockContext: public LTemplateInstruction<1, 2, 0> {
2647 LAllocateBlockContext(LOperand* context, LOperand* function) {
2648 inputs_[0] = context;
2649 inputs_[1] = function;
2652 LOperand* context() { return inputs_[0]; }
2653 LOperand* function() { return inputs_[1]; }
2655 Handle<ScopeInfo> scope_info() { return hydrogen()->scope_info(); }
2657 DECLARE_CONCRETE_INSTRUCTION(AllocateBlockContext, "allocate-block-context")
2658 DECLARE_HYDROGEN_ACCESSOR(AllocateBlockContext)
2662 class LChunkBuilder;
2663 class LPlatformChunk FINAL : public LChunk {
2665 LPlatformChunk(CompilationInfo* info, HGraph* graph)
2666 : LChunk(info, graph) { }
2668 int GetNextSpillIndex(RegisterKind kind);
2669 LOperand* GetNextSpillSlot(RegisterKind kind);
2673 class LChunkBuilder FINAL : public LChunkBuilderBase {
2675 LChunkBuilder(CompilationInfo* info, HGraph* graph, LAllocator* allocator)
2676 : LChunkBuilderBase(info, graph),
2677 current_instruction_(NULL),
2678 current_block_(NULL),
2680 allocator_(allocator) {}
2682 // Build the sequence for the graph.
2683 LPlatformChunk* Build();
2685 // Declare methods that deal with the individual node types.
2686 #define DECLARE_DO(type) LInstruction* Do##type(H##type* node);
2687 HYDROGEN_CONCRETE_INSTRUCTION_LIST(DECLARE_DO)
2690 LInstruction* DoMultiplyAdd(HMul* mul, HValue* addend);
2692 static bool HasMagicNumberForDivisor(int32_t divisor);
2694 LInstruction* DoMathFloor(HUnaryMathOperation* instr);
2695 LInstruction* DoMathRound(HUnaryMathOperation* instr);
2696 LInstruction* DoMathFround(HUnaryMathOperation* instr);
2697 LInstruction* DoMathAbs(HUnaryMathOperation* instr);
2698 LInstruction* DoMathLog(HUnaryMathOperation* instr);
2699 LInstruction* DoMathExp(HUnaryMathOperation* instr);
2700 LInstruction* DoMathSqrt(HUnaryMathOperation* instr);
2701 LInstruction* DoMathPowHalf(HUnaryMathOperation* instr);
2702 LInstruction* DoMathClz32(HUnaryMathOperation* instr);
2703 LInstruction* DoDivByPowerOf2I(HDiv* instr);
2704 LInstruction* DoDivByConstI(HDiv* instr);
2705 LInstruction* DoDivI(HDiv* instr);
2706 LInstruction* DoModByPowerOf2I(HMod* instr);
2707 LInstruction* DoModByConstI(HMod* instr);
2708 LInstruction* DoModI(HMod* instr);
2709 LInstruction* DoFlooringDivByPowerOf2I(HMathFloorOfDiv* instr);
2710 LInstruction* DoFlooringDivByConstI(HMathFloorOfDiv* instr);
2711 LInstruction* DoFlooringDivI(HMathFloorOfDiv* instr);
2714 // Methods for getting operands for Use / Define / Temp.
2715 LUnallocated* ToUnallocated(Register reg);
2716 LUnallocated* ToUnallocated(DoubleRegister reg);
2718 // Methods for setting up define-use relationships.
2719 MUST_USE_RESULT LOperand* Use(HValue* value, LUnallocated* operand);
2720 MUST_USE_RESULT LOperand* UseFixed(HValue* value, Register fixed_register);
2721 MUST_USE_RESULT LOperand* UseFixedDouble(HValue* value,
2722 DoubleRegister fixed_register);
2724 // A value that is guaranteed to be allocated to a register.
2725 // Operand created by UseRegister is guaranteed to be live until the end of
2726 // instruction. This means that register allocator will not reuse it's
2727 // register for any other operand inside instruction.
2728 // Operand created by UseRegisterAtStart is guaranteed to be live only at
2729 // instruction start. Register allocator is free to assign the same register
2730 // to some other operand used inside instruction (i.e. temporary or
2732 MUST_USE_RESULT LOperand* UseRegister(HValue* value);
2733 MUST_USE_RESULT LOperand* UseRegisterAtStart(HValue* value);
2735 // An input operand in a register that may be trashed.
2736 MUST_USE_RESULT LOperand* UseTempRegister(HValue* value);
2738 // An input operand in a register or stack slot.
2739 MUST_USE_RESULT LOperand* Use(HValue* value);
2740 MUST_USE_RESULT LOperand* UseAtStart(HValue* value);
2742 // An input operand in a register, stack slot or a constant operand.
2743 MUST_USE_RESULT LOperand* UseOrConstant(HValue* value);
2744 MUST_USE_RESULT LOperand* UseOrConstantAtStart(HValue* value);
2746 // An input operand in a register or a constant operand.
2747 MUST_USE_RESULT LOperand* UseRegisterOrConstant(HValue* value);
2748 MUST_USE_RESULT LOperand* UseRegisterOrConstantAtStart(HValue* value);
2750 // An input operand in a constant operand.
2751 MUST_USE_RESULT LOperand* UseConstant(HValue* value);
2753 // An input operand in register, stack slot or a constant operand.
2754 // Will not be moved to a register even if one is freely available.
2755 MUST_USE_RESULT LOperand* UseAny(HValue* value) OVERRIDE;
2757 // Temporary operand that must be in a register.
2758 MUST_USE_RESULT LUnallocated* TempRegister();
2759 MUST_USE_RESULT LUnallocated* TempDoubleRegister();
2760 MUST_USE_RESULT LOperand* FixedTemp(Register reg);
2761 MUST_USE_RESULT LOperand* FixedTemp(DoubleRegister reg);
2763 // Methods for setting up define-use relationships.
2764 // Return the same instruction that they are passed.
2765 LInstruction* Define(LTemplateResultInstruction<1>* instr,
2766 LUnallocated* result);
2767 LInstruction* DefineAsRegister(LTemplateResultInstruction<1>* instr);
2768 LInstruction* DefineAsSpilled(LTemplateResultInstruction<1>* instr,
2770 LInstruction* DefineSameAsFirst(LTemplateResultInstruction<1>* instr);
2771 LInstruction* DefineFixed(LTemplateResultInstruction<1>* instr,
2773 LInstruction* DefineFixedDouble(LTemplateResultInstruction<1>* instr,
2774 DoubleRegister reg);
2775 LInstruction* AssignEnvironment(LInstruction* instr);
2776 LInstruction* AssignPointerMap(LInstruction* instr);
2778 enum CanDeoptimize { CAN_DEOPTIMIZE_EAGERLY, CANNOT_DEOPTIMIZE_EAGERLY };
2780 // By default we assume that instruction sequences generated for calls
2781 // cannot deoptimize eagerly and we do not attach environment to this
2783 LInstruction* MarkAsCall(
2784 LInstruction* instr,
2785 HInstruction* hinstr,
2786 CanDeoptimize can_deoptimize = CANNOT_DEOPTIMIZE_EAGERLY);
2788 void VisitInstruction(HInstruction* current);
2789 void AddInstruction(LInstruction* instr, HInstruction* current);
2791 void DoBasicBlock(HBasicBlock* block, HBasicBlock* next_block);
2792 LInstruction* DoBit(Token::Value op, HBitwiseBinaryOperation* instr);
2793 LInstruction* DoShift(Token::Value op, HBitwiseBinaryOperation* instr);
2794 LInstruction* DoArithmeticD(Token::Value op,
2795 HArithmeticBinaryOperation* instr);
2796 LInstruction* DoArithmeticT(Token::Value op,
2797 HBinaryOperation* instr);
2799 HInstruction* current_instruction_;
2800 HBasicBlock* current_block_;
2801 HBasicBlock* next_block_;
2802 LAllocator* allocator_;
2804 DISALLOW_COPY_AND_ASSIGN(LChunkBuilder);
2807 #undef DECLARE_HYDROGEN_ACCESSOR
2808 #undef DECLARE_CONCRETE_INSTRUCTION
2810 } } // namespace v8::internal
2812 #endif // V8_MIPS_LITHIUM_MIPS_H_