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) \
134 V(SeqStringGetChar) \
135 V(SeqStringSetChar) \
141 V(StoreContextSlot) \
142 V(StoreFrameContext) \
144 V(StoreKeyedGeneric) \
146 V(StoreNamedGeneric) \
148 V(StringCharCodeAt) \
149 V(StringCharFromCode) \
150 V(StringCompareAndBranch) \
153 V(TailCallThroughMegamorphicCache) \
155 V(ToFastProperties) \
156 V(TransitionElementsKind) \
157 V(TrapAllocationMemento) \
159 V(TypeofIsAndBranch) \
164 #define DECLARE_CONCRETE_INSTRUCTION(type, mnemonic) \
165 Opcode opcode() const FINAL { return LInstruction::k##type; } \
166 void CompileToNative(LCodeGen* generator) FINAL; \
167 const char* Mnemonic() const FINAL { return mnemonic; } \
168 static L##type* cast(LInstruction* instr) { \
169 DCHECK(instr->Is##type()); \
170 return reinterpret_cast<L##type*>(instr); \
174 #define DECLARE_HYDROGEN_ACCESSOR(type) \
175 H##type* hydrogen() const { \
176 return H##type::cast(hydrogen_value()); \
180 class LInstruction : public ZoneObject {
183 : environment_(NULL),
184 hydrogen_value_(NULL),
185 bit_field_(IsCallBits::encode(false)) {
188 virtual ~LInstruction() {}
190 virtual void CompileToNative(LCodeGen* generator) = 0;
191 virtual const char* Mnemonic() const = 0;
192 virtual void PrintTo(StringStream* stream);
193 virtual void PrintDataTo(StringStream* stream);
194 virtual void PrintOutputOperandTo(StringStream* stream);
197 // Declare a unique enum value for each instruction.
198 #define DECLARE_OPCODE(type) k##type,
199 LITHIUM_CONCRETE_INSTRUCTION_LIST(DECLARE_OPCODE)
200 kNumberOfInstructions
201 #undef DECLARE_OPCODE
204 virtual Opcode opcode() const = 0;
206 // Declare non-virtual type testers for all leaf IR classes.
207 #define DECLARE_PREDICATE(type) \
208 bool Is##type() const { return opcode() == k##type; }
209 LITHIUM_CONCRETE_INSTRUCTION_LIST(DECLARE_PREDICATE)
210 #undef DECLARE_PREDICATE
212 // Declare virtual predicates for instructions that don't have
214 virtual bool IsGap() const { return false; }
216 virtual bool IsControl() const { return false; }
218 // Try deleting this instruction if possible.
219 virtual bool TryDelete() { return false; }
221 void set_environment(LEnvironment* env) { environment_ = env; }
222 LEnvironment* environment() const { return environment_; }
223 bool HasEnvironment() const { return environment_ != NULL; }
225 void set_pointer_map(LPointerMap* p) { pointer_map_.set(p); }
226 LPointerMap* pointer_map() const { return pointer_map_.get(); }
227 bool HasPointerMap() const { return pointer_map_.is_set(); }
229 void set_hydrogen_value(HValue* value) { hydrogen_value_ = value; }
230 HValue* hydrogen_value() const { return hydrogen_value_; }
232 virtual void SetDeferredLazyDeoptimizationEnvironment(LEnvironment* env) { }
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 LLazyBailout FINAL : public LTemplateInstruction<0, 0, 0> {
391 LLazyBailout() : gap_instructions_size_(0) { }
393 DECLARE_CONCRETE_INSTRUCTION(LazyBailout, "lazy-bailout")
395 void set_gap_instructions_size(int gap_instructions_size) {
396 gap_instructions_size_ = gap_instructions_size;
398 int gap_instructions_size() { return gap_instructions_size_; }
401 int gap_instructions_size_;
405 class LDummy FINAL : public LTemplateInstruction<1, 0, 0> {
408 DECLARE_CONCRETE_INSTRUCTION(Dummy, "dummy")
412 class LDummyUse FINAL : public LTemplateInstruction<1, 1, 0> {
414 explicit LDummyUse(LOperand* value) {
417 DECLARE_CONCRETE_INSTRUCTION(DummyUse, "dummy-use")
421 class LDeoptimize FINAL : public LTemplateInstruction<0, 0, 0> {
423 bool IsControl() const OVERRIDE { return true; }
424 DECLARE_CONCRETE_INSTRUCTION(Deoptimize, "deoptimize")
425 DECLARE_HYDROGEN_ACCESSOR(Deoptimize)
429 class LLabel FINAL : public LGap {
431 explicit LLabel(HBasicBlock* block)
432 : LGap(block), replacement_(NULL) { }
434 bool HasInterestingComment(LCodeGen* gen) const OVERRIDE { return false; }
435 DECLARE_CONCRETE_INSTRUCTION(Label, "label")
437 void PrintDataTo(StringStream* stream) OVERRIDE;
439 int block_id() const { return block()->block_id(); }
440 bool is_loop_header() const { return block()->IsLoopHeader(); }
441 bool is_osr_entry() const { return block()->is_osr_entry(); }
442 Label* label() { return &label_; }
443 LLabel* replacement() const { return replacement_; }
444 void set_replacement(LLabel* label) { replacement_ = label; }
445 bool HasReplacement() const { return replacement_ != NULL; }
449 LLabel* replacement_;
453 class LParameter FINAL : public LTemplateInstruction<1, 0, 0> {
455 bool HasInterestingComment(LCodeGen* gen) const OVERRIDE { return false; }
456 DECLARE_CONCRETE_INSTRUCTION(Parameter, "parameter")
460 class LCallStub FINAL : public LTemplateInstruction<1, 1, 0> {
462 explicit LCallStub(LOperand* context) {
463 inputs_[0] = context;
466 LOperand* context() { return inputs_[0]; }
468 DECLARE_CONCRETE_INSTRUCTION(CallStub, "call-stub")
469 DECLARE_HYDROGEN_ACCESSOR(CallStub)
473 class LTailCallThroughMegamorphicCache FINAL
474 : public LTemplateInstruction<0, 5, 0> {
476 LTailCallThroughMegamorphicCache(LOperand* context, LOperand* receiver,
477 LOperand* name, LOperand* slot,
479 inputs_[0] = context;
480 inputs_[1] = receiver;
486 LOperand* context() { return inputs_[0]; }
487 LOperand* receiver() { return inputs_[1]; }
488 LOperand* name() { return inputs_[2]; }
489 LOperand* slot() { return inputs_[3]; }
490 LOperand* vector() { return inputs_[4]; }
492 DECLARE_CONCRETE_INSTRUCTION(TailCallThroughMegamorphicCache,
493 "tail-call-through-megamorphic-cache")
494 DECLARE_HYDROGEN_ACCESSOR(TailCallThroughMegamorphicCache)
498 class LUnknownOSRValue FINAL : public LTemplateInstruction<1, 0, 0> {
500 bool HasInterestingComment(LCodeGen* gen) const OVERRIDE { return false; }
501 DECLARE_CONCRETE_INSTRUCTION(UnknownOSRValue, "unknown-osr-value")
505 template<int I, int T>
506 class LControlInstruction : public LTemplateInstruction<0, I, T> {
508 LControlInstruction() : false_label_(NULL), true_label_(NULL) { }
510 bool IsControl() const FINAL { return true; }
512 int SuccessorCount() { return hydrogen()->SuccessorCount(); }
513 HBasicBlock* SuccessorAt(int i) { return hydrogen()->SuccessorAt(i); }
515 int TrueDestination(LChunk* chunk) {
516 return chunk->LookupDestination(true_block_id());
518 int FalseDestination(LChunk* chunk) {
519 return chunk->LookupDestination(false_block_id());
522 Label* TrueLabel(LChunk* chunk) {
523 if (true_label_ == NULL) {
524 true_label_ = chunk->GetAssemblyLabel(TrueDestination(chunk));
528 Label* FalseLabel(LChunk* chunk) {
529 if (false_label_ == NULL) {
530 false_label_ = chunk->GetAssemblyLabel(FalseDestination(chunk));
536 int true_block_id() { return SuccessorAt(0)->block_id(); }
537 int false_block_id() { return SuccessorAt(1)->block_id(); }
540 HControlInstruction* hydrogen() {
541 return HControlInstruction::cast(this->hydrogen_value());
549 class LWrapReceiver FINAL : public LTemplateInstruction<1, 2, 0> {
551 LWrapReceiver(LOperand* receiver, LOperand* function) {
552 inputs_[0] = receiver;
553 inputs_[1] = function;
556 DECLARE_CONCRETE_INSTRUCTION(WrapReceiver, "wrap-receiver")
557 DECLARE_HYDROGEN_ACCESSOR(WrapReceiver)
559 LOperand* receiver() { return inputs_[0]; }
560 LOperand* function() { return inputs_[1]; }
564 class LApplyArguments FINAL : public LTemplateInstruction<1, 4, 0> {
566 LApplyArguments(LOperand* function,
569 LOperand* elements) {
570 inputs_[0] = function;
571 inputs_[1] = receiver;
573 inputs_[3] = elements;
576 DECLARE_CONCRETE_INSTRUCTION(ApplyArguments, "apply-arguments")
578 LOperand* function() { return inputs_[0]; }
579 LOperand* receiver() { return inputs_[1]; }
580 LOperand* length() { return inputs_[2]; }
581 LOperand* elements() { return inputs_[3]; }
585 class LAccessArgumentsAt FINAL : public LTemplateInstruction<1, 3, 0> {
587 LAccessArgumentsAt(LOperand* arguments, LOperand* length, LOperand* index) {
588 inputs_[0] = arguments;
593 DECLARE_CONCRETE_INSTRUCTION(AccessArgumentsAt, "access-arguments-at")
595 LOperand* arguments() { return inputs_[0]; }
596 LOperand* length() { return inputs_[1]; }
597 LOperand* index() { return inputs_[2]; }
599 void PrintDataTo(StringStream* stream) OVERRIDE;
603 class LArgumentsLength FINAL : public LTemplateInstruction<1, 1, 0> {
605 explicit LArgumentsLength(LOperand* elements) {
606 inputs_[0] = elements;
609 LOperand* elements() { return inputs_[0]; }
611 DECLARE_CONCRETE_INSTRUCTION(ArgumentsLength, "arguments-length")
615 class LArgumentsElements FINAL : public LTemplateInstruction<1, 0, 0> {
617 DECLARE_CONCRETE_INSTRUCTION(ArgumentsElements, "arguments-elements")
618 DECLARE_HYDROGEN_ACCESSOR(ArgumentsElements)
622 class LModByPowerOf2I FINAL : public LTemplateInstruction<1, 1, 0> {
624 LModByPowerOf2I(LOperand* dividend, int32_t divisor) {
625 inputs_[0] = dividend;
629 LOperand* dividend() { return inputs_[0]; }
630 int32_t divisor() const { return divisor_; }
632 DECLARE_CONCRETE_INSTRUCTION(ModByPowerOf2I, "mod-by-power-of-2-i")
633 DECLARE_HYDROGEN_ACCESSOR(Mod)
640 class LModByConstI FINAL : public LTemplateInstruction<1, 1, 0> {
642 LModByConstI(LOperand* dividend, int32_t divisor) {
643 inputs_[0] = dividend;
647 LOperand* dividend() { return inputs_[0]; }
648 int32_t divisor() const { return divisor_; }
650 DECLARE_CONCRETE_INSTRUCTION(ModByConstI, "mod-by-const-i")
651 DECLARE_HYDROGEN_ACCESSOR(Mod)
658 class LModI FINAL : public LTemplateInstruction<1, 2, 3> {
660 LModI(LOperand* left,
666 LOperand* left() { return inputs_[0]; }
667 LOperand* right() { return inputs_[1]; }
669 DECLARE_CONCRETE_INSTRUCTION(ModI, "mod-i")
670 DECLARE_HYDROGEN_ACCESSOR(Mod)
674 class LDivByPowerOf2I FINAL : public LTemplateInstruction<1, 1, 0> {
676 LDivByPowerOf2I(LOperand* dividend, int32_t divisor) {
677 inputs_[0] = dividend;
681 LOperand* dividend() { return inputs_[0]; }
682 int32_t divisor() const { return divisor_; }
684 DECLARE_CONCRETE_INSTRUCTION(DivByPowerOf2I, "div-by-power-of-2-i")
685 DECLARE_HYDROGEN_ACCESSOR(Div)
692 class LDivByConstI FINAL : public LTemplateInstruction<1, 1, 0> {
694 LDivByConstI(LOperand* dividend, int32_t divisor) {
695 inputs_[0] = dividend;
699 LOperand* dividend() { return inputs_[0]; }
700 int32_t divisor() const { return divisor_; }
702 DECLARE_CONCRETE_INSTRUCTION(DivByConstI, "div-by-const-i")
703 DECLARE_HYDROGEN_ACCESSOR(Div)
710 class LDivI FINAL : public LTemplateInstruction<1, 2, 1> {
712 LDivI(LOperand* dividend, LOperand* divisor, LOperand* temp) {
713 inputs_[0] = dividend;
714 inputs_[1] = divisor;
718 LOperand* dividend() { return inputs_[0]; }
719 LOperand* divisor() { return inputs_[1]; }
720 LOperand* temp() { return temps_[0]; }
722 DECLARE_CONCRETE_INSTRUCTION(DivI, "div-i")
723 DECLARE_HYDROGEN_ACCESSOR(BinaryOperation)
727 class LFlooringDivByPowerOf2I FINAL : public LTemplateInstruction<1, 1, 0> {
729 LFlooringDivByPowerOf2I(LOperand* dividend, int32_t divisor) {
730 inputs_[0] = dividend;
734 LOperand* dividend() { return inputs_[0]; }
735 int32_t divisor() { return divisor_; }
737 DECLARE_CONCRETE_INSTRUCTION(FlooringDivByPowerOf2I,
738 "flooring-div-by-power-of-2-i")
739 DECLARE_HYDROGEN_ACCESSOR(MathFloorOfDiv)
746 class LFlooringDivByConstI FINAL : public LTemplateInstruction<1, 1, 2> {
748 LFlooringDivByConstI(LOperand* dividend, int32_t divisor, LOperand* temp) {
749 inputs_[0] = dividend;
754 LOperand* dividend() { return inputs_[0]; }
755 int32_t divisor() const { return divisor_; }
756 LOperand* temp() { return temps_[0]; }
758 DECLARE_CONCRETE_INSTRUCTION(FlooringDivByConstI, "flooring-div-by-const-i")
759 DECLARE_HYDROGEN_ACCESSOR(MathFloorOfDiv)
766 class LFlooringDivI FINAL : public LTemplateInstruction<1, 2, 0> {
768 LFlooringDivI(LOperand* dividend, LOperand* divisor) {
769 inputs_[0] = dividend;
770 inputs_[1] = divisor;
773 LOperand* dividend() { return inputs_[0]; }
774 LOperand* divisor() { return inputs_[1]; }
776 DECLARE_CONCRETE_INSTRUCTION(FlooringDivI, "flooring-div-i")
777 DECLARE_HYDROGEN_ACCESSOR(MathFloorOfDiv)
781 class LMulI FINAL : public LTemplateInstruction<1, 2, 0> {
783 LMulI(LOperand* left, LOperand* right) {
788 LOperand* left() { return inputs_[0]; }
789 LOperand* right() { return inputs_[1]; }
791 DECLARE_CONCRETE_INSTRUCTION(MulI, "mul-i")
792 DECLARE_HYDROGEN_ACCESSOR(Mul)
796 // Instruction for computing multiplier * multiplicand + addend.
797 class LMultiplyAddD FINAL : public LTemplateInstruction<1, 3, 0> {
799 LMultiplyAddD(LOperand* addend, LOperand* multiplier,
800 LOperand* multiplicand) {
802 inputs_[1] = multiplier;
803 inputs_[2] = multiplicand;
806 LOperand* addend() { return inputs_[0]; }
807 LOperand* multiplier() { return inputs_[1]; }
808 LOperand* multiplicand() { return inputs_[2]; }
810 DECLARE_CONCRETE_INSTRUCTION(MultiplyAddD, "multiply-add-d")
814 class LDebugBreak FINAL : public LTemplateInstruction<0, 0, 0> {
816 DECLARE_CONCRETE_INSTRUCTION(DebugBreak, "break")
820 class LCompareNumericAndBranch FINAL : public LControlInstruction<2, 0> {
822 LCompareNumericAndBranch(LOperand* left, LOperand* right) {
827 LOperand* left() { return inputs_[0]; }
828 LOperand* right() { return inputs_[1]; }
830 DECLARE_CONCRETE_INSTRUCTION(CompareNumericAndBranch,
831 "compare-numeric-and-branch")
832 DECLARE_HYDROGEN_ACCESSOR(CompareNumericAndBranch)
834 Token::Value op() const { return hydrogen()->token(); }
835 bool is_double() const {
836 return hydrogen()->representation().IsDouble();
839 void PrintDataTo(StringStream* stream) OVERRIDE;
843 class LMathFloor FINAL : public LTemplateInstruction<1, 1, 1> {
845 LMathFloor(LOperand* value, LOperand* temp) {
850 LOperand* value() { return inputs_[0]; }
851 LOperand* temp() { return temps_[0]; }
853 DECLARE_CONCRETE_INSTRUCTION(MathFloor, "math-floor")
854 DECLARE_HYDROGEN_ACCESSOR(UnaryMathOperation)
858 class LMathRound FINAL : public LTemplateInstruction<1, 1, 1> {
860 LMathRound(LOperand* value, LOperand* temp) {
865 LOperand* value() { return inputs_[0]; }
866 LOperand* temp() { return temps_[0]; }
868 DECLARE_CONCRETE_INSTRUCTION(MathRound, "math-round")
869 DECLARE_HYDROGEN_ACCESSOR(UnaryMathOperation)
873 class LMathFround FINAL : public LTemplateInstruction<1, 1, 0> {
875 explicit LMathFround(LOperand* value) { inputs_[0] = value; }
877 LOperand* value() { return inputs_[0]; }
879 DECLARE_CONCRETE_INSTRUCTION(MathFround, "math-fround")
883 class LMathAbs FINAL : public LTemplateInstruction<1, 2, 0> {
885 LMathAbs(LOperand* context, LOperand* value) {
886 inputs_[1] = context;
890 LOperand* context() { return inputs_[1]; }
891 LOperand* value() { return inputs_[0]; }
893 DECLARE_CONCRETE_INSTRUCTION(MathAbs, "math-abs")
894 DECLARE_HYDROGEN_ACCESSOR(UnaryMathOperation)
898 class LMathLog FINAL : public LTemplateInstruction<1, 1, 0> {
900 explicit LMathLog(LOperand* value) {
904 LOperand* value() { return inputs_[0]; }
906 DECLARE_CONCRETE_INSTRUCTION(MathLog, "math-log")
910 class LMathClz32 FINAL : public LTemplateInstruction<1, 1, 0> {
912 explicit LMathClz32(LOperand* value) {
916 LOperand* value() { return inputs_[0]; }
918 DECLARE_CONCRETE_INSTRUCTION(MathClz32, "math-clz32")
922 class LMathExp FINAL : public LTemplateInstruction<1, 1, 3> {
924 LMathExp(LOperand* value,
925 LOperand* double_temp,
931 temps_[2] = double_temp;
932 ExternalReference::InitializeMathExpData();
935 LOperand* value() { return inputs_[0]; }
936 LOperand* temp1() { return temps_[0]; }
937 LOperand* temp2() { return temps_[1]; }
938 LOperand* double_temp() { return temps_[2]; }
940 DECLARE_CONCRETE_INSTRUCTION(MathExp, "math-exp")
944 class LMathSqrt FINAL : public LTemplateInstruction<1, 1, 0> {
946 explicit LMathSqrt(LOperand* value) {
950 LOperand* value() { return inputs_[0]; }
952 DECLARE_CONCRETE_INSTRUCTION(MathSqrt, "math-sqrt")
956 class LMathPowHalf FINAL : public LTemplateInstruction<1, 1, 1> {
958 LMathPowHalf(LOperand* value, LOperand* temp) {
963 LOperand* value() { return inputs_[0]; }
964 LOperand* temp() { return temps_[0]; }
966 DECLARE_CONCRETE_INSTRUCTION(MathPowHalf, "math-pow-half")
970 class LCmpObjectEqAndBranch FINAL : public LControlInstruction<2, 0> {
972 LCmpObjectEqAndBranch(LOperand* left, LOperand* right) {
977 LOperand* left() { return inputs_[0]; }
978 LOperand* right() { return inputs_[1]; }
980 DECLARE_CONCRETE_INSTRUCTION(CmpObjectEqAndBranch, "cmp-object-eq-and-branch")
981 DECLARE_HYDROGEN_ACCESSOR(CompareObjectEqAndBranch)
985 class LCmpHoleAndBranch FINAL : public LControlInstruction<1, 0> {
987 explicit LCmpHoleAndBranch(LOperand* object) {
991 LOperand* object() { return inputs_[0]; }
993 DECLARE_CONCRETE_INSTRUCTION(CmpHoleAndBranch, "cmp-hole-and-branch")
994 DECLARE_HYDROGEN_ACCESSOR(CompareHoleAndBranch)
998 class LCompareMinusZeroAndBranch FINAL : public LControlInstruction<1, 1> {
1000 LCompareMinusZeroAndBranch(LOperand* value, LOperand* temp) {
1005 LOperand* value() { return inputs_[0]; }
1006 LOperand* temp() { return temps_[0]; }
1008 DECLARE_CONCRETE_INSTRUCTION(CompareMinusZeroAndBranch,
1009 "cmp-minus-zero-and-branch")
1010 DECLARE_HYDROGEN_ACCESSOR(CompareMinusZeroAndBranch)
1014 class LIsObjectAndBranch FINAL : public LControlInstruction<1, 1> {
1016 LIsObjectAndBranch(LOperand* value, LOperand* temp) {
1021 LOperand* value() { return inputs_[0]; }
1022 LOperand* temp() { return temps_[0]; }
1024 DECLARE_CONCRETE_INSTRUCTION(IsObjectAndBranch, "is-object-and-branch")
1025 DECLARE_HYDROGEN_ACCESSOR(IsObjectAndBranch)
1027 void PrintDataTo(StringStream* stream) OVERRIDE;
1031 class LIsStringAndBranch FINAL : public LControlInstruction<1, 1> {
1033 LIsStringAndBranch(LOperand* value, LOperand* temp) {
1038 LOperand* value() { return inputs_[0]; }
1039 LOperand* temp() { return temps_[0]; }
1041 DECLARE_CONCRETE_INSTRUCTION(IsStringAndBranch, "is-string-and-branch")
1042 DECLARE_HYDROGEN_ACCESSOR(IsStringAndBranch)
1044 void PrintDataTo(StringStream* stream) OVERRIDE;
1048 class LIsSmiAndBranch FINAL : public LControlInstruction<1, 0> {
1050 explicit LIsSmiAndBranch(LOperand* value) {
1054 LOperand* value() { return inputs_[0]; }
1056 DECLARE_CONCRETE_INSTRUCTION(IsSmiAndBranch, "is-smi-and-branch")
1057 DECLARE_HYDROGEN_ACCESSOR(IsSmiAndBranch)
1059 void PrintDataTo(StringStream* stream) OVERRIDE;
1063 class LIsUndetectableAndBranch FINAL : public LControlInstruction<1, 1> {
1065 explicit LIsUndetectableAndBranch(LOperand* value, LOperand* temp) {
1070 LOperand* value() { return inputs_[0]; }
1071 LOperand* temp() { return temps_[0]; }
1073 DECLARE_CONCRETE_INSTRUCTION(IsUndetectableAndBranch,
1074 "is-undetectable-and-branch")
1075 DECLARE_HYDROGEN_ACCESSOR(IsUndetectableAndBranch)
1077 void PrintDataTo(StringStream* stream) OVERRIDE;
1081 class LStringCompareAndBranch FINAL : public LControlInstruction<3, 0> {
1083 LStringCompareAndBranch(LOperand* context, LOperand* left, LOperand* right) {
1084 inputs_[0] = context;
1089 LOperand* context() { return inputs_[0]; }
1090 LOperand* left() { return inputs_[1]; }
1091 LOperand* right() { return inputs_[2]; }
1093 DECLARE_CONCRETE_INSTRUCTION(StringCompareAndBranch,
1094 "string-compare-and-branch")
1095 DECLARE_HYDROGEN_ACCESSOR(StringCompareAndBranch)
1097 Token::Value op() const { return hydrogen()->token(); }
1099 void PrintDataTo(StringStream* stream) OVERRIDE;
1103 class LHasInstanceTypeAndBranch FINAL : public LControlInstruction<1, 0> {
1105 explicit LHasInstanceTypeAndBranch(LOperand* value) {
1109 LOperand* value() { return inputs_[0]; }
1111 DECLARE_CONCRETE_INSTRUCTION(HasInstanceTypeAndBranch,
1112 "has-instance-type-and-branch")
1113 DECLARE_HYDROGEN_ACCESSOR(HasInstanceTypeAndBranch)
1115 void PrintDataTo(StringStream* stream) OVERRIDE;
1119 class LGetCachedArrayIndex FINAL : public LTemplateInstruction<1, 1, 0> {
1121 explicit LGetCachedArrayIndex(LOperand* value) {
1125 LOperand* value() { return inputs_[0]; }
1127 DECLARE_CONCRETE_INSTRUCTION(GetCachedArrayIndex, "get-cached-array-index")
1128 DECLARE_HYDROGEN_ACCESSOR(GetCachedArrayIndex)
1132 class LHasCachedArrayIndexAndBranch FINAL
1133 : public LControlInstruction<1, 0> {
1135 explicit LHasCachedArrayIndexAndBranch(LOperand* value) {
1139 LOperand* value() { return inputs_[0]; }
1141 DECLARE_CONCRETE_INSTRUCTION(HasCachedArrayIndexAndBranch,
1142 "has-cached-array-index-and-branch")
1143 DECLARE_HYDROGEN_ACCESSOR(HasCachedArrayIndexAndBranch)
1145 void PrintDataTo(StringStream* stream) OVERRIDE;
1149 class LClassOfTestAndBranch FINAL : public LControlInstruction<1, 1> {
1151 LClassOfTestAndBranch(LOperand* value, LOperand* temp) {
1156 LOperand* value() { return inputs_[0]; }
1157 LOperand* temp() { return temps_[0]; }
1159 DECLARE_CONCRETE_INSTRUCTION(ClassOfTestAndBranch,
1160 "class-of-test-and-branch")
1161 DECLARE_HYDROGEN_ACCESSOR(ClassOfTestAndBranch)
1163 void PrintDataTo(StringStream* stream) OVERRIDE;
1167 class LCmpT FINAL : public LTemplateInstruction<1, 3, 0> {
1169 LCmpT(LOperand* context, LOperand* left, LOperand* right) {
1170 inputs_[0] = context;
1175 LOperand* context() { return inputs_[0]; }
1176 LOperand* left() { return inputs_[1]; }
1177 LOperand* right() { return inputs_[2]; }
1179 DECLARE_CONCRETE_INSTRUCTION(CmpT, "cmp-t")
1180 DECLARE_HYDROGEN_ACCESSOR(CompareGeneric)
1182 Token::Value op() const { return hydrogen()->token(); }
1186 class LInstanceOf FINAL : public LTemplateInstruction<1, 3, 0> {
1188 LInstanceOf(LOperand* context, LOperand* left, LOperand* right) {
1189 inputs_[0] = context;
1194 LOperand* context() { return inputs_[0]; }
1195 LOperand* left() { return inputs_[1]; }
1196 LOperand* right() { return inputs_[2]; }
1198 DECLARE_CONCRETE_INSTRUCTION(InstanceOf, "instance-of")
1202 class LInstanceOfKnownGlobal FINAL : public LTemplateInstruction<1, 2, 1> {
1204 LInstanceOfKnownGlobal(LOperand* context, LOperand* value, LOperand* temp) {
1205 inputs_[0] = context;
1210 LOperand* context() { return inputs_[0]; }
1211 LOperand* value() { return inputs_[1]; }
1212 LOperand* temp() { return temps_[0]; }
1214 DECLARE_CONCRETE_INSTRUCTION(InstanceOfKnownGlobal,
1215 "instance-of-known-global")
1216 DECLARE_HYDROGEN_ACCESSOR(InstanceOfKnownGlobal)
1218 Handle<JSFunction> function() const { return hydrogen()->function(); }
1219 LEnvironment* GetDeferredLazyDeoptimizationEnvironment() {
1220 return lazy_deopt_env_;
1222 virtual void SetDeferredLazyDeoptimizationEnvironment(
1223 LEnvironment* env) OVERRIDE {
1224 lazy_deopt_env_ = env;
1228 LEnvironment* lazy_deopt_env_;
1232 class LBoundsCheck FINAL : public LTemplateInstruction<0, 2, 0> {
1234 LBoundsCheck(LOperand* index, LOperand* length) {
1236 inputs_[1] = length;
1239 LOperand* index() { return inputs_[0]; }
1240 LOperand* length() { return inputs_[1]; }
1242 DECLARE_CONCRETE_INSTRUCTION(BoundsCheck, "bounds-check")
1243 DECLARE_HYDROGEN_ACCESSOR(BoundsCheck)
1247 class LBitI FINAL : public LTemplateInstruction<1, 2, 0> {
1249 LBitI(LOperand* left, LOperand* right) {
1254 LOperand* left() { return inputs_[0]; }
1255 LOperand* right() { return inputs_[1]; }
1257 Token::Value op() const { return hydrogen()->op(); }
1259 DECLARE_CONCRETE_INSTRUCTION(BitI, "bit-i")
1260 DECLARE_HYDROGEN_ACCESSOR(Bitwise)
1264 class LShiftI FINAL : public LTemplateInstruction<1, 2, 0> {
1266 LShiftI(Token::Value op, LOperand* left, LOperand* right, bool can_deopt)
1267 : op_(op), can_deopt_(can_deopt) {
1272 Token::Value op() const { return op_; }
1273 LOperand* left() { return inputs_[0]; }
1274 LOperand* right() { return inputs_[1]; }
1275 bool can_deopt() const { return can_deopt_; }
1277 DECLARE_CONCRETE_INSTRUCTION(ShiftI, "shift-i")
1285 class LSubI FINAL : public LTemplateInstruction<1, 2, 0> {
1287 LSubI(LOperand* left, LOperand* right) {
1292 LOperand* left() { return inputs_[0]; }
1293 LOperand* right() { return inputs_[1]; }
1295 DECLARE_CONCRETE_INSTRUCTION(SubI, "sub-i")
1296 DECLARE_HYDROGEN_ACCESSOR(Sub)
1300 class LConstantI FINAL : public LTemplateInstruction<1, 0, 0> {
1302 DECLARE_CONCRETE_INSTRUCTION(ConstantI, "constant-i")
1303 DECLARE_HYDROGEN_ACCESSOR(Constant)
1305 int32_t value() const { return hydrogen()->Integer32Value(); }
1309 class LConstantS FINAL : public LTemplateInstruction<1, 0, 0> {
1311 DECLARE_CONCRETE_INSTRUCTION(ConstantS, "constant-s")
1312 DECLARE_HYDROGEN_ACCESSOR(Constant)
1314 Smi* value() const { return Smi::FromInt(hydrogen()->Integer32Value()); }
1318 class LConstantD FINAL : public LTemplateInstruction<1, 0, 0> {
1320 DECLARE_CONCRETE_INSTRUCTION(ConstantD, "constant-d")
1321 DECLARE_HYDROGEN_ACCESSOR(Constant)
1323 double value() const { return hydrogen()->DoubleValue(); }
1324 uint64_t bits() const { return hydrogen()->DoubleValueAsBits(); }
1328 class LConstantE FINAL : public LTemplateInstruction<1, 0, 0> {
1330 DECLARE_CONCRETE_INSTRUCTION(ConstantE, "constant-e")
1331 DECLARE_HYDROGEN_ACCESSOR(Constant)
1333 ExternalReference value() const {
1334 return hydrogen()->ExternalReferenceValue();
1339 class LConstantT FINAL : public LTemplateInstruction<1, 0, 0> {
1341 DECLARE_CONCRETE_INSTRUCTION(ConstantT, "constant-t")
1342 DECLARE_HYDROGEN_ACCESSOR(Constant)
1344 Handle<Object> value(Isolate* isolate) const {
1345 return hydrogen()->handle(isolate);
1350 class LBranch FINAL : public LControlInstruction<1, 0> {
1352 explicit LBranch(LOperand* value) {
1356 LOperand* value() { return inputs_[0]; }
1358 DECLARE_CONCRETE_INSTRUCTION(Branch, "branch")
1359 DECLARE_HYDROGEN_ACCESSOR(Branch)
1361 void PrintDataTo(StringStream* stream) OVERRIDE;
1365 class LCmpMapAndBranch FINAL : public LControlInstruction<1, 1> {
1367 LCmpMapAndBranch(LOperand* value, LOperand* temp) {
1372 LOperand* value() { return inputs_[0]; }
1373 LOperand* temp() { return temps_[0]; }
1375 DECLARE_CONCRETE_INSTRUCTION(CmpMapAndBranch, "cmp-map-and-branch")
1376 DECLARE_HYDROGEN_ACCESSOR(CompareMap)
1378 Handle<Map> map() const { return hydrogen()->map().handle(); }
1382 class LMapEnumLength FINAL : public LTemplateInstruction<1, 1, 0> {
1384 explicit LMapEnumLength(LOperand* value) {
1388 LOperand* value() { return inputs_[0]; }
1390 DECLARE_CONCRETE_INSTRUCTION(MapEnumLength, "map-enum-length")
1394 class LDateField FINAL : public LTemplateInstruction<1, 1, 1> {
1396 LDateField(LOperand* date, LOperand* temp, Smi* index) : index_(index) {
1401 LOperand* date() { return inputs_[0]; }
1402 LOperand* temp() { return temps_[0]; }
1403 Smi* index() const { return index_; }
1405 DECLARE_CONCRETE_INSTRUCTION(DateField, "date-field")
1406 DECLARE_HYDROGEN_ACCESSOR(DateField)
1413 class LSeqStringGetChar FINAL : public LTemplateInstruction<1, 2, 0> {
1415 LSeqStringGetChar(LOperand* string, LOperand* index) {
1416 inputs_[0] = string;
1420 LOperand* string() const { return inputs_[0]; }
1421 LOperand* index() const { return inputs_[1]; }
1423 DECLARE_CONCRETE_INSTRUCTION(SeqStringGetChar, "seq-string-get-char")
1424 DECLARE_HYDROGEN_ACCESSOR(SeqStringGetChar)
1428 class LSeqStringSetChar FINAL : public LTemplateInstruction<1, 4, 0> {
1430 LSeqStringSetChar(LOperand* context,
1434 inputs_[0] = context;
1435 inputs_[1] = string;
1440 LOperand* string() { return inputs_[1]; }
1441 LOperand* index() { return inputs_[2]; }
1442 LOperand* value() { return inputs_[3]; }
1444 DECLARE_CONCRETE_INSTRUCTION(SeqStringSetChar, "seq-string-set-char")
1445 DECLARE_HYDROGEN_ACCESSOR(SeqStringSetChar)
1449 class LAddI FINAL : public LTemplateInstruction<1, 2, 0> {
1451 LAddI(LOperand* left, LOperand* right) {
1456 LOperand* left() { return inputs_[0]; }
1457 LOperand* right() { return inputs_[1]; }
1459 DECLARE_CONCRETE_INSTRUCTION(AddI, "add-i")
1460 DECLARE_HYDROGEN_ACCESSOR(Add)
1464 class LMathMinMax FINAL : public LTemplateInstruction<1, 2, 0> {
1466 LMathMinMax(LOperand* left, LOperand* right) {
1471 LOperand* left() { return inputs_[0]; }
1472 LOperand* right() { return inputs_[1]; }
1474 DECLARE_CONCRETE_INSTRUCTION(MathMinMax, "math-min-max")
1475 DECLARE_HYDROGEN_ACCESSOR(MathMinMax)
1479 class LPower FINAL : public LTemplateInstruction<1, 2, 0> {
1481 LPower(LOperand* left, LOperand* right) {
1486 LOperand* left() { return inputs_[0]; }
1487 LOperand* right() { return inputs_[1]; }
1489 DECLARE_CONCRETE_INSTRUCTION(Power, "power")
1490 DECLARE_HYDROGEN_ACCESSOR(Power)
1494 class LArithmeticD FINAL : public LTemplateInstruction<1, 2, 0> {
1496 LArithmeticD(Token::Value op, LOperand* left, LOperand* right)
1502 Token::Value op() const { return op_; }
1503 LOperand* left() { return inputs_[0]; }
1504 LOperand* right() { return inputs_[1]; }
1506 Opcode opcode() const OVERRIDE { return LInstruction::kArithmeticD; }
1507 void CompileToNative(LCodeGen* generator) OVERRIDE;
1508 const char* Mnemonic() const OVERRIDE;
1515 class LArithmeticT FINAL : public LTemplateInstruction<1, 3, 0> {
1517 LArithmeticT(Token::Value op,
1522 inputs_[0] = context;
1527 LOperand* context() { return inputs_[0]; }
1528 LOperand* left() { return inputs_[1]; }
1529 LOperand* right() { return inputs_[2]; }
1530 Token::Value op() const { return op_; }
1532 Opcode opcode() const FINAL { return LInstruction::kArithmeticT; }
1533 void CompileToNative(LCodeGen* generator) OVERRIDE;
1534 const char* Mnemonic() const OVERRIDE;
1541 class LReturn FINAL : public LTemplateInstruction<0, 3, 0> {
1543 LReturn(LOperand* value, LOperand* context, LOperand* parameter_count) {
1545 inputs_[1] = context;
1546 inputs_[2] = parameter_count;
1549 LOperand* value() { return inputs_[0]; }
1551 bool has_constant_parameter_count() {
1552 return parameter_count()->IsConstantOperand();
1554 LConstantOperand* constant_parameter_count() {
1555 DCHECK(has_constant_parameter_count());
1556 return LConstantOperand::cast(parameter_count());
1558 LOperand* parameter_count() { return inputs_[2]; }
1560 DECLARE_CONCRETE_INSTRUCTION(Return, "return")
1564 class LLoadNamedField FINAL : public LTemplateInstruction<1, 1, 0> {
1566 explicit LLoadNamedField(LOperand* object) {
1567 inputs_[0] = object;
1570 LOperand* object() { return inputs_[0]; }
1572 DECLARE_CONCRETE_INSTRUCTION(LoadNamedField, "load-named-field")
1573 DECLARE_HYDROGEN_ACCESSOR(LoadNamedField)
1577 class LLoadNamedGeneric FINAL : public LTemplateInstruction<1, 2, 1> {
1579 LLoadNamedGeneric(LOperand* context, LOperand* object, LOperand* vector) {
1580 inputs_[0] = context;
1581 inputs_[1] = object;
1585 LOperand* context() { return inputs_[0]; }
1586 LOperand* object() { return inputs_[1]; }
1587 LOperand* temp_vector() { return temps_[0]; }
1589 DECLARE_CONCRETE_INSTRUCTION(LoadNamedGeneric, "load-named-generic")
1590 DECLARE_HYDROGEN_ACCESSOR(LoadNamedGeneric)
1592 Handle<Object> name() const { return hydrogen()->name(); }
1596 class LLoadFunctionPrototype FINAL : public LTemplateInstruction<1, 1, 0> {
1598 explicit LLoadFunctionPrototype(LOperand* function) {
1599 inputs_[0] = function;
1602 LOperand* function() { return inputs_[0]; }
1604 DECLARE_CONCRETE_INSTRUCTION(LoadFunctionPrototype, "load-function-prototype")
1605 DECLARE_HYDROGEN_ACCESSOR(LoadFunctionPrototype)
1609 class LLoadRoot FINAL : public LTemplateInstruction<1, 0, 0> {
1611 DECLARE_CONCRETE_INSTRUCTION(LoadRoot, "load-root")
1612 DECLARE_HYDROGEN_ACCESSOR(LoadRoot)
1614 Heap::RootListIndex index() const { return hydrogen()->index(); }
1618 class LLoadKeyed FINAL : public LTemplateInstruction<1, 2, 0> {
1620 LLoadKeyed(LOperand* elements, LOperand* key) {
1621 inputs_[0] = elements;
1625 LOperand* elements() { return inputs_[0]; }
1626 LOperand* key() { return inputs_[1]; }
1627 ElementsKind elements_kind() const {
1628 return hydrogen()->elements_kind();
1630 bool is_external() const {
1631 return hydrogen()->is_external();
1633 bool is_fixed_typed_array() const {
1634 return hydrogen()->is_fixed_typed_array();
1636 bool is_typed_elements() const {
1637 return is_external() || is_fixed_typed_array();
1640 DECLARE_CONCRETE_INSTRUCTION(LoadKeyed, "load-keyed")
1641 DECLARE_HYDROGEN_ACCESSOR(LoadKeyed)
1643 void PrintDataTo(StringStream* stream) OVERRIDE;
1644 uint32_t base_offset() const { return hydrogen()->base_offset(); }
1648 class LLoadKeyedGeneric FINAL : public LTemplateInstruction<1, 3, 1> {
1650 LLoadKeyedGeneric(LOperand* context, LOperand* object, LOperand* key,
1652 inputs_[0] = context;
1653 inputs_[1] = object;
1658 LOperand* context() { return inputs_[0]; }
1659 LOperand* object() { return inputs_[1]; }
1660 LOperand* key() { return inputs_[2]; }
1661 LOperand* temp_vector() { return temps_[0]; }
1663 DECLARE_CONCRETE_INSTRUCTION(LoadKeyedGeneric, "load-keyed-generic")
1664 DECLARE_HYDROGEN_ACCESSOR(LoadKeyedGeneric)
1668 class LLoadGlobalGeneric FINAL : public LTemplateInstruction<1, 2, 1> {
1670 LLoadGlobalGeneric(LOperand* context, LOperand* global_object,
1672 inputs_[0] = context;
1673 inputs_[1] = global_object;
1677 LOperand* context() { return inputs_[0]; }
1678 LOperand* global_object() { return inputs_[1]; }
1679 LOperand* temp_vector() { return temps_[0]; }
1681 DECLARE_CONCRETE_INSTRUCTION(LoadGlobalGeneric, "load-global-generic")
1682 DECLARE_HYDROGEN_ACCESSOR(LoadGlobalGeneric)
1684 Handle<Object> name() const { return hydrogen()->name(); }
1685 bool for_typeof() const { return hydrogen()->for_typeof(); }
1689 class LLoadContextSlot FINAL : public LTemplateInstruction<1, 1, 0> {
1691 explicit LLoadContextSlot(LOperand* context) {
1692 inputs_[0] = context;
1695 LOperand* context() { return inputs_[0]; }
1697 DECLARE_CONCRETE_INSTRUCTION(LoadContextSlot, "load-context-slot")
1698 DECLARE_HYDROGEN_ACCESSOR(LoadContextSlot)
1700 int slot_index() { return hydrogen()->slot_index(); }
1702 void PrintDataTo(StringStream* stream) OVERRIDE;
1706 class LStoreContextSlot FINAL : public LTemplateInstruction<0, 2, 0> {
1708 LStoreContextSlot(LOperand* context, LOperand* value) {
1709 inputs_[0] = context;
1713 LOperand* context() { return inputs_[0]; }
1714 LOperand* value() { return inputs_[1]; }
1716 DECLARE_CONCRETE_INSTRUCTION(StoreContextSlot, "store-context-slot")
1717 DECLARE_HYDROGEN_ACCESSOR(StoreContextSlot)
1719 int slot_index() { return hydrogen()->slot_index(); }
1721 void PrintDataTo(StringStream* stream) OVERRIDE;
1725 class LPushArgument FINAL : public LTemplateInstruction<0, 1, 0> {
1727 explicit LPushArgument(LOperand* value) {
1731 LOperand* value() { return inputs_[0]; }
1733 DECLARE_CONCRETE_INSTRUCTION(PushArgument, "push-argument")
1737 class LDrop FINAL : public LTemplateInstruction<0, 0, 0> {
1739 explicit LDrop(int count) : count_(count) { }
1741 int count() const { return count_; }
1743 DECLARE_CONCRETE_INSTRUCTION(Drop, "drop")
1750 class LStoreCodeEntry FINAL: public LTemplateInstruction<0, 2, 0> {
1752 LStoreCodeEntry(LOperand* function, LOperand* code_object) {
1753 inputs_[0] = function;
1754 inputs_[1] = code_object;
1757 LOperand* function() { return inputs_[0]; }
1758 LOperand* code_object() { return inputs_[1]; }
1760 void PrintDataTo(StringStream* stream) OVERRIDE;
1762 DECLARE_CONCRETE_INSTRUCTION(StoreCodeEntry, "store-code-entry")
1763 DECLARE_HYDROGEN_ACCESSOR(StoreCodeEntry)
1767 class LInnerAllocatedObject FINAL: public LTemplateInstruction<1, 2, 0> {
1769 LInnerAllocatedObject(LOperand* base_object, LOperand* offset) {
1770 inputs_[0] = base_object;
1771 inputs_[1] = offset;
1774 LOperand* base_object() const { return inputs_[0]; }
1775 LOperand* offset() const { return inputs_[1]; }
1777 void PrintDataTo(StringStream* stream) OVERRIDE;
1779 DECLARE_CONCRETE_INSTRUCTION(InnerAllocatedObject, "inner-allocated-object")
1783 class LThisFunction FINAL : public LTemplateInstruction<1, 0, 0> {
1785 DECLARE_CONCRETE_INSTRUCTION(ThisFunction, "this-function")
1786 DECLARE_HYDROGEN_ACCESSOR(ThisFunction)
1790 class LContext FINAL : public LTemplateInstruction<1, 0, 0> {
1792 DECLARE_CONCRETE_INSTRUCTION(Context, "context")
1793 DECLARE_HYDROGEN_ACCESSOR(Context)
1797 class LDeclareGlobals FINAL : public LTemplateInstruction<0, 1, 0> {
1799 explicit LDeclareGlobals(LOperand* context) {
1800 inputs_[0] = context;
1803 LOperand* context() { return inputs_[0]; }
1805 DECLARE_CONCRETE_INSTRUCTION(DeclareGlobals, "declare-globals")
1806 DECLARE_HYDROGEN_ACCESSOR(DeclareGlobals)
1810 class LCallJSFunction FINAL : public LTemplateInstruction<1, 1, 0> {
1812 explicit LCallJSFunction(LOperand* function) {
1813 inputs_[0] = function;
1816 LOperand* function() { return inputs_[0]; }
1818 DECLARE_CONCRETE_INSTRUCTION(CallJSFunction, "call-js-function")
1819 DECLARE_HYDROGEN_ACCESSOR(CallJSFunction)
1821 void PrintDataTo(StringStream* stream) OVERRIDE;
1823 int arity() const { return hydrogen()->argument_count() - 1; }
1827 class LCallWithDescriptor FINAL : public LTemplateResultInstruction<1> {
1829 LCallWithDescriptor(CallInterfaceDescriptor descriptor,
1830 const ZoneList<LOperand*>& operands, Zone* zone)
1831 : descriptor_(descriptor),
1832 inputs_(descriptor.GetRegisterParameterCount() + 1, zone) {
1833 DCHECK(descriptor.GetRegisterParameterCount() + 1 == operands.length());
1834 inputs_.AddAll(operands, zone);
1837 LOperand* target() const { return inputs_[0]; }
1839 const CallInterfaceDescriptor descriptor() { return descriptor_; }
1841 DECLARE_HYDROGEN_ACCESSOR(CallWithDescriptor)
1844 DECLARE_CONCRETE_INSTRUCTION(CallWithDescriptor, "call-with-descriptor")
1846 void PrintDataTo(StringStream* stream) OVERRIDE;
1848 int arity() const { return hydrogen()->argument_count() - 1; }
1850 CallInterfaceDescriptor descriptor_;
1851 ZoneList<LOperand*> inputs_;
1853 // Iterator support.
1854 int InputCount() FINAL { return inputs_.length(); }
1855 LOperand* InputAt(int i) FINAL { return inputs_[i]; }
1857 int TempCount() FINAL { return 0; }
1858 LOperand* TempAt(int i) FINAL { return NULL; }
1862 class LInvokeFunction FINAL : public LTemplateInstruction<1, 2, 0> {
1864 LInvokeFunction(LOperand* context, LOperand* function) {
1865 inputs_[0] = context;
1866 inputs_[1] = function;
1869 LOperand* context() { return inputs_[0]; }
1870 LOperand* function() { return inputs_[1]; }
1872 DECLARE_CONCRETE_INSTRUCTION(InvokeFunction, "invoke-function")
1873 DECLARE_HYDROGEN_ACCESSOR(InvokeFunction)
1875 void PrintDataTo(StringStream* stream) OVERRIDE;
1877 int arity() const { return hydrogen()->argument_count() - 1; }
1881 class LCallFunction FINAL : public LTemplateInstruction<1, 2, 2> {
1883 LCallFunction(LOperand* context, LOperand* function, LOperand* slot,
1885 inputs_[0] = context;
1886 inputs_[1] = function;
1891 LOperand* context() { return inputs_[0]; }
1892 LOperand* function() { return inputs_[1]; }
1893 LOperand* temp_slot() { return temps_[0]; }
1894 LOperand* temp_vector() { return temps_[1]; }
1896 DECLARE_CONCRETE_INSTRUCTION(CallFunction, "call-function")
1897 DECLARE_HYDROGEN_ACCESSOR(CallFunction)
1899 int arity() const { return hydrogen()->argument_count() - 1; }
1900 void PrintDataTo(StringStream* stream) OVERRIDE;
1904 class LCallNew FINAL : public LTemplateInstruction<1, 2, 0> {
1906 LCallNew(LOperand* context, LOperand* constructor) {
1907 inputs_[0] = context;
1908 inputs_[1] = constructor;
1911 LOperand* context() { return inputs_[0]; }
1912 LOperand* constructor() { return inputs_[1]; }
1914 DECLARE_CONCRETE_INSTRUCTION(CallNew, "call-new")
1915 DECLARE_HYDROGEN_ACCESSOR(CallNew)
1917 void PrintDataTo(StringStream* stream) OVERRIDE;
1919 int arity() const { return hydrogen()->argument_count() - 1; }
1923 class LCallNewArray FINAL : public LTemplateInstruction<1, 2, 0> {
1925 LCallNewArray(LOperand* context, LOperand* constructor) {
1926 inputs_[0] = context;
1927 inputs_[1] = constructor;
1930 LOperand* context() { return inputs_[0]; }
1931 LOperand* constructor() { return inputs_[1]; }
1933 DECLARE_CONCRETE_INSTRUCTION(CallNewArray, "call-new-array")
1934 DECLARE_HYDROGEN_ACCESSOR(CallNewArray)
1936 void PrintDataTo(StringStream* stream) OVERRIDE;
1938 int arity() const { return hydrogen()->argument_count() - 1; }
1942 class LCallRuntime FINAL : public LTemplateInstruction<1, 1, 0> {
1944 explicit LCallRuntime(LOperand* context) {
1945 inputs_[0] = context;
1948 LOperand* context() { return inputs_[0]; }
1950 DECLARE_CONCRETE_INSTRUCTION(CallRuntime, "call-runtime")
1951 DECLARE_HYDROGEN_ACCESSOR(CallRuntime)
1953 bool ClobbersDoubleRegisters(Isolate* isolate) const OVERRIDE {
1954 return save_doubles() == kDontSaveFPRegs;
1957 const Runtime::Function* function() const { return hydrogen()->function(); }
1958 int arity() const { return hydrogen()->argument_count(); }
1959 SaveFPRegsMode save_doubles() const { return hydrogen()->save_doubles(); }
1963 class LInteger32ToDouble FINAL : public LTemplateInstruction<1, 1, 0> {
1965 explicit LInteger32ToDouble(LOperand* value) {
1969 LOperand* value() { return inputs_[0]; }
1971 DECLARE_CONCRETE_INSTRUCTION(Integer32ToDouble, "int32-to-double")
1975 class LUint32ToDouble FINAL : public LTemplateInstruction<1, 1, 0> {
1977 explicit LUint32ToDouble(LOperand* value) {
1981 LOperand* value() { return inputs_[0]; }
1983 DECLARE_CONCRETE_INSTRUCTION(Uint32ToDouble, "uint32-to-double")
1987 class LNumberTagI FINAL : public LTemplateInstruction<1, 1, 2> {
1989 LNumberTagI(LOperand* value, LOperand* temp1, LOperand* temp2) {
1995 LOperand* value() { return inputs_[0]; }
1996 LOperand* temp1() { return temps_[0]; }
1997 LOperand* temp2() { return temps_[1]; }
1999 DECLARE_CONCRETE_INSTRUCTION(NumberTagI, "number-tag-i")
2003 class LNumberTagU FINAL : public LTemplateInstruction<1, 1, 2> {
2005 LNumberTagU(LOperand* value, LOperand* temp1, LOperand* temp2) {
2011 LOperand* value() { return inputs_[0]; }
2012 LOperand* temp1() { return temps_[0]; }
2013 LOperand* temp2() { return temps_[1]; }
2015 DECLARE_CONCRETE_INSTRUCTION(NumberTagU, "number-tag-u")
2019 class LNumberTagD FINAL : public LTemplateInstruction<1, 1, 2> {
2021 LNumberTagD(LOperand* value, LOperand* temp, LOperand* temp2) {
2027 LOperand* value() { return inputs_[0]; }
2028 LOperand* temp() { return temps_[0]; }
2029 LOperand* temp2() { return temps_[1]; }
2031 DECLARE_CONCRETE_INSTRUCTION(NumberTagD, "number-tag-d")
2032 DECLARE_HYDROGEN_ACCESSOR(Change)
2036 class LDoubleToSmi FINAL : public LTemplateInstruction<1, 1, 0> {
2038 explicit LDoubleToSmi(LOperand* value) {
2042 LOperand* value() { return inputs_[0]; }
2044 DECLARE_CONCRETE_INSTRUCTION(DoubleToSmi, "double-to-smi")
2045 DECLARE_HYDROGEN_ACCESSOR(UnaryOperation)
2047 bool truncating() { return hydrogen()->CanTruncateToInt32(); }
2051 // Sometimes truncating conversion from a tagged value to an int32.
2052 class LDoubleToI FINAL : public LTemplateInstruction<1, 1, 0> {
2054 explicit LDoubleToI(LOperand* value) {
2058 LOperand* value() { return inputs_[0]; }
2060 DECLARE_CONCRETE_INSTRUCTION(DoubleToI, "double-to-i")
2061 DECLARE_HYDROGEN_ACCESSOR(UnaryOperation)
2063 bool truncating() { return hydrogen()->CanTruncateToInt32(); }
2067 // Truncating conversion from a tagged value to an int32.
2068 class LTaggedToI FINAL : public LTemplateInstruction<1, 1, 2> {
2070 LTaggedToI(LOperand* value,
2078 LOperand* value() { return inputs_[0]; }
2079 LOperand* temp() { return temps_[0]; }
2080 LOperand* temp2() { return temps_[1]; }
2082 DECLARE_CONCRETE_INSTRUCTION(TaggedToI, "tagged-to-i")
2083 DECLARE_HYDROGEN_ACCESSOR(Change)
2085 bool truncating() { return hydrogen()->CanTruncateToInt32(); }
2089 class LSmiTag FINAL : public LTemplateInstruction<1, 1, 0> {
2091 explicit LSmiTag(LOperand* value) {
2095 LOperand* value() { return inputs_[0]; }
2097 DECLARE_CONCRETE_INSTRUCTION(SmiTag, "smi-tag")
2098 DECLARE_HYDROGEN_ACCESSOR(Change)
2102 class LNumberUntagD FINAL : public LTemplateInstruction<1, 1, 0> {
2104 explicit LNumberUntagD(LOperand* value) {
2108 LOperand* value() { return inputs_[0]; }
2110 DECLARE_CONCRETE_INSTRUCTION(NumberUntagD, "double-untag")
2111 DECLARE_HYDROGEN_ACCESSOR(Change)
2115 class LSmiUntag FINAL : public LTemplateInstruction<1, 1, 0> {
2117 LSmiUntag(LOperand* value, bool needs_check)
2118 : needs_check_(needs_check) {
2122 LOperand* value() { return inputs_[0]; }
2123 bool needs_check() const { return needs_check_; }
2125 DECLARE_CONCRETE_INSTRUCTION(SmiUntag, "smi-untag")
2132 class LStoreNamedField FINAL : public LTemplateInstruction<0, 2, 1> {
2134 LStoreNamedField(LOperand* object, LOperand* value, LOperand* temp) {
2135 inputs_[0] = object;
2140 LOperand* object() { return inputs_[0]; }
2141 LOperand* value() { return inputs_[1]; }
2142 LOperand* temp() { return temps_[0]; }
2144 DECLARE_CONCRETE_INSTRUCTION(StoreNamedField, "store-named-field")
2145 DECLARE_HYDROGEN_ACCESSOR(StoreNamedField)
2147 void PrintDataTo(StringStream* stream) OVERRIDE;
2149 Representation representation() const {
2150 return hydrogen()->field_representation();
2155 class LStoreNamedGeneric FINAL : public LTemplateInstruction<0, 3, 0> {
2157 LStoreNamedGeneric(LOperand* context, LOperand* object, LOperand* value) {
2158 inputs_[0] = context;
2159 inputs_[1] = object;
2163 LOperand* context() { return inputs_[0]; }
2164 LOperand* object() { return inputs_[1]; }
2165 LOperand* value() { return inputs_[2]; }
2167 DECLARE_CONCRETE_INSTRUCTION(StoreNamedGeneric, "store-named-generic")
2168 DECLARE_HYDROGEN_ACCESSOR(StoreNamedGeneric)
2170 void PrintDataTo(StringStream* stream) OVERRIDE;
2172 Handle<Object> name() const { return hydrogen()->name(); }
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_external() const { return hydrogen()->is_external(); }
2186 bool is_fixed_typed_array() const {
2187 return hydrogen()->is_fixed_typed_array();
2189 bool is_typed_elements() const {
2190 return is_external() || is_fixed_typed_array();
2192 LOperand* elements() { return inputs_[0]; }
2193 LOperand* key() { return inputs_[1]; }
2194 LOperand* value() { return inputs_[2]; }
2195 ElementsKind elements_kind() const {
2196 return hydrogen()->elements_kind();
2199 DECLARE_CONCRETE_INSTRUCTION(StoreKeyed, "store-keyed")
2200 DECLARE_HYDROGEN_ACCESSOR(StoreKeyed)
2202 void PrintDataTo(StringStream* stream) OVERRIDE;
2203 bool NeedsCanonicalization() { return hydrogen()->NeedsCanonicalization(); }
2204 uint32_t base_offset() const { return hydrogen()->base_offset(); }
2208 class LStoreKeyedGeneric FINAL : public LTemplateInstruction<0, 4, 0> {
2210 LStoreKeyedGeneric(LOperand* context,
2214 inputs_[0] = context;
2220 LOperand* context() { return inputs_[0]; }
2221 LOperand* object() { return inputs_[1]; }
2222 LOperand* key() { return inputs_[2]; }
2223 LOperand* value() { return inputs_[3]; }
2225 DECLARE_CONCRETE_INSTRUCTION(StoreKeyedGeneric, "store-keyed-generic")
2226 DECLARE_HYDROGEN_ACCESSOR(StoreKeyedGeneric)
2228 void PrintDataTo(StringStream* stream) OVERRIDE;
2230 LanguageMode language_mode() { return hydrogen()->language_mode(); }
2234 class LTransitionElementsKind FINAL : public LTemplateInstruction<0, 2, 1> {
2236 LTransitionElementsKind(LOperand* object,
2238 LOperand* new_map_temp) {
2239 inputs_[0] = object;
2240 inputs_[1] = context;
2241 temps_[0] = new_map_temp;
2244 LOperand* context() { return inputs_[1]; }
2245 LOperand* object() { return inputs_[0]; }
2246 LOperand* new_map_temp() { return temps_[0]; }
2248 DECLARE_CONCRETE_INSTRUCTION(TransitionElementsKind,
2249 "transition-elements-kind")
2250 DECLARE_HYDROGEN_ACCESSOR(TransitionElementsKind)
2252 void PrintDataTo(StringStream* stream) OVERRIDE;
2254 Handle<Map> original_map() { return hydrogen()->original_map().handle(); }
2255 Handle<Map> transitioned_map() {
2256 return hydrogen()->transitioned_map().handle();
2258 ElementsKind from_kind() { return hydrogen()->from_kind(); }
2259 ElementsKind to_kind() { return hydrogen()->to_kind(); }
2263 class LTrapAllocationMemento FINAL : public LTemplateInstruction<0, 1, 1> {
2265 LTrapAllocationMemento(LOperand* object,
2267 inputs_[0] = object;
2271 LOperand* object() { return inputs_[0]; }
2272 LOperand* temp() { return temps_[0]; }
2274 DECLARE_CONCRETE_INSTRUCTION(TrapAllocationMemento,
2275 "trap-allocation-memento")
2279 class LStringAdd FINAL : public LTemplateInstruction<1, 3, 0> {
2281 LStringAdd(LOperand* context, LOperand* left, LOperand* right) {
2282 inputs_[0] = context;
2287 LOperand* context() { return inputs_[0]; }
2288 LOperand* left() { return inputs_[1]; }
2289 LOperand* right() { return inputs_[2]; }
2291 DECLARE_CONCRETE_INSTRUCTION(StringAdd, "string-add")
2292 DECLARE_HYDROGEN_ACCESSOR(StringAdd)
2297 class LStringCharCodeAt FINAL : public LTemplateInstruction<1, 3, 0> {
2299 LStringCharCodeAt(LOperand* context, LOperand* string, LOperand* index) {
2300 inputs_[0] = context;
2301 inputs_[1] = string;
2305 LOperand* context() { return inputs_[0]; }
2306 LOperand* string() { return inputs_[1]; }
2307 LOperand* index() { return inputs_[2]; }
2309 DECLARE_CONCRETE_INSTRUCTION(StringCharCodeAt, "string-char-code-at")
2310 DECLARE_HYDROGEN_ACCESSOR(StringCharCodeAt)
2314 class LStringCharFromCode FINAL : public LTemplateInstruction<1, 2, 0> {
2316 explicit LStringCharFromCode(LOperand* context, LOperand* char_code) {
2317 inputs_[0] = context;
2318 inputs_[1] = char_code;
2321 LOperand* context() { return inputs_[0]; }
2322 LOperand* char_code() { return inputs_[1]; }
2324 DECLARE_CONCRETE_INSTRUCTION(StringCharFromCode, "string-char-from-code")
2325 DECLARE_HYDROGEN_ACCESSOR(StringCharFromCode)
2329 class LCheckValue FINAL : public LTemplateInstruction<0, 1, 0> {
2331 explicit LCheckValue(LOperand* value) {
2335 LOperand* value() { return inputs_[0]; }
2337 DECLARE_CONCRETE_INSTRUCTION(CheckValue, "check-value")
2338 DECLARE_HYDROGEN_ACCESSOR(CheckValue)
2342 class LCheckInstanceType FINAL : public LTemplateInstruction<0, 1, 0> {
2344 explicit LCheckInstanceType(LOperand* value) {
2348 LOperand* value() { return inputs_[0]; }
2350 DECLARE_CONCRETE_INSTRUCTION(CheckInstanceType, "check-instance-type")
2351 DECLARE_HYDROGEN_ACCESSOR(CheckInstanceType)
2355 class LCheckMaps FINAL : public LTemplateInstruction<0, 1, 0> {
2357 explicit LCheckMaps(LOperand* value = NULL) {
2361 LOperand* value() { return inputs_[0]; }
2363 DECLARE_CONCRETE_INSTRUCTION(CheckMaps, "check-maps")
2364 DECLARE_HYDROGEN_ACCESSOR(CheckMaps)
2368 class LCheckSmi FINAL : public LTemplateInstruction<1, 1, 0> {
2370 explicit LCheckSmi(LOperand* value) {
2374 LOperand* value() { return inputs_[0]; }
2376 DECLARE_CONCRETE_INSTRUCTION(CheckSmi, "check-smi")
2380 class LCheckNonSmi FINAL : public LTemplateInstruction<0, 1, 0> {
2382 explicit LCheckNonSmi(LOperand* value) {
2386 LOperand* value() { return inputs_[0]; }
2388 DECLARE_CONCRETE_INSTRUCTION(CheckNonSmi, "check-non-smi")
2389 DECLARE_HYDROGEN_ACCESSOR(CheckHeapObject)
2393 class LClampDToUint8 FINAL : public LTemplateInstruction<1, 1, 1> {
2395 LClampDToUint8(LOperand* unclamped, LOperand* temp) {
2396 inputs_[0] = unclamped;
2400 LOperand* unclamped() { return inputs_[0]; }
2401 LOperand* temp() { return temps_[0]; }
2403 DECLARE_CONCRETE_INSTRUCTION(ClampDToUint8, "clamp-d-to-uint8")
2407 class LClampIToUint8 FINAL : public LTemplateInstruction<1, 1, 0> {
2409 explicit LClampIToUint8(LOperand* unclamped) {
2410 inputs_[0] = unclamped;
2413 LOperand* unclamped() { return inputs_[0]; }
2415 DECLARE_CONCRETE_INSTRUCTION(ClampIToUint8, "clamp-i-to-uint8")
2419 class LClampTToUint8 FINAL : public LTemplateInstruction<1, 1, 1> {
2421 LClampTToUint8(LOperand* unclamped, LOperand* temp) {
2422 inputs_[0] = unclamped;
2426 LOperand* unclamped() { return inputs_[0]; }
2427 LOperand* temp() { return temps_[0]; }
2429 DECLARE_CONCRETE_INSTRUCTION(ClampTToUint8, "clamp-t-to-uint8")
2433 class LDoubleBits FINAL : public LTemplateInstruction<1, 1, 0> {
2435 explicit LDoubleBits(LOperand* value) {
2439 LOperand* value() { return inputs_[0]; }
2441 DECLARE_CONCRETE_INSTRUCTION(DoubleBits, "double-bits")
2442 DECLARE_HYDROGEN_ACCESSOR(DoubleBits)
2446 class LConstructDouble FINAL : public LTemplateInstruction<1, 2, 0> {
2448 LConstructDouble(LOperand* hi, LOperand* lo) {
2453 LOperand* hi() { return inputs_[0]; }
2454 LOperand* lo() { return inputs_[1]; }
2456 DECLARE_CONCRETE_INSTRUCTION(ConstructDouble, "construct-double")
2460 class LAllocate FINAL : public LTemplateInstruction<1, 2, 2> {
2462 LAllocate(LOperand* context,
2466 inputs_[0] = context;
2472 LOperand* context() { return inputs_[0]; }
2473 LOperand* size() { return inputs_[1]; }
2474 LOperand* temp1() { return temps_[0]; }
2475 LOperand* temp2() { return temps_[1]; }
2477 DECLARE_CONCRETE_INSTRUCTION(Allocate, "allocate")
2478 DECLARE_HYDROGEN_ACCESSOR(Allocate)
2482 class LRegExpLiteral FINAL : public LTemplateInstruction<1, 1, 0> {
2484 explicit LRegExpLiteral(LOperand* context) {
2485 inputs_[0] = context;
2488 LOperand* context() { return inputs_[0]; }
2490 DECLARE_CONCRETE_INSTRUCTION(RegExpLiteral, "regexp-literal")
2491 DECLARE_HYDROGEN_ACCESSOR(RegExpLiteral)
2495 class LFunctionLiteral FINAL : public LTemplateInstruction<1, 1, 0> {
2497 explicit LFunctionLiteral(LOperand* context) {
2498 inputs_[0] = context;
2501 LOperand* context() { return inputs_[0]; }
2503 DECLARE_CONCRETE_INSTRUCTION(FunctionLiteral, "function-literal")
2504 DECLARE_HYDROGEN_ACCESSOR(FunctionLiteral)
2508 class LToFastProperties FINAL : public LTemplateInstruction<1, 1, 0> {
2510 explicit LToFastProperties(LOperand* value) {
2514 LOperand* value() { return inputs_[0]; }
2516 DECLARE_CONCRETE_INSTRUCTION(ToFastProperties, "to-fast-properties")
2517 DECLARE_HYDROGEN_ACCESSOR(ToFastProperties)
2521 class LTypeof FINAL : public LTemplateInstruction<1, 2, 0> {
2523 LTypeof(LOperand* context, LOperand* value) {
2524 inputs_[0] = context;
2528 LOperand* context() { return inputs_[0]; }
2529 LOperand* value() { return inputs_[1]; }
2531 DECLARE_CONCRETE_INSTRUCTION(Typeof, "typeof")
2535 class LTypeofIsAndBranch FINAL : public LControlInstruction<1, 0> {
2537 explicit LTypeofIsAndBranch(LOperand* value) {
2541 LOperand* value() { return inputs_[0]; }
2543 DECLARE_CONCRETE_INSTRUCTION(TypeofIsAndBranch, "typeof-is-and-branch")
2544 DECLARE_HYDROGEN_ACCESSOR(TypeofIsAndBranch)
2546 Handle<String> type_literal() { return hydrogen()->type_literal(); }
2548 void PrintDataTo(StringStream* stream) OVERRIDE;
2552 class LIsConstructCallAndBranch FINAL : public LControlInstruction<0, 1> {
2554 explicit LIsConstructCallAndBranch(LOperand* temp) {
2558 LOperand* temp() { return temps_[0]; }
2560 DECLARE_CONCRETE_INSTRUCTION(IsConstructCallAndBranch,
2561 "is-construct-call-and-branch")
2565 class LOsrEntry FINAL : public LTemplateInstruction<0, 0, 0> {
2569 bool HasInterestingComment(LCodeGen* gen) const OVERRIDE { return false; }
2570 DECLARE_CONCRETE_INSTRUCTION(OsrEntry, "osr-entry")
2574 class LStackCheck FINAL : public LTemplateInstruction<0, 1, 0> {
2576 explicit LStackCheck(LOperand* context) {
2577 inputs_[0] = context;
2580 LOperand* context() { return inputs_[0]; }
2582 DECLARE_CONCRETE_INSTRUCTION(StackCheck, "stack-check")
2583 DECLARE_HYDROGEN_ACCESSOR(StackCheck)
2585 Label* done_label() { return &done_label_; }
2592 class LForInPrepareMap FINAL : public LTemplateInstruction<1, 2, 0> {
2594 LForInPrepareMap(LOperand* context, LOperand* object) {
2595 inputs_[0] = context;
2596 inputs_[1] = object;
2599 LOperand* context() { return inputs_[0]; }
2600 LOperand* object() { return inputs_[1]; }
2602 DECLARE_CONCRETE_INSTRUCTION(ForInPrepareMap, "for-in-prepare-map")
2606 class LForInCacheArray FINAL : public LTemplateInstruction<1, 1, 0> {
2608 explicit LForInCacheArray(LOperand* map) {
2612 LOperand* map() { return inputs_[0]; }
2614 DECLARE_CONCRETE_INSTRUCTION(ForInCacheArray, "for-in-cache-array")
2617 return HForInCacheArray::cast(this->hydrogen_value())->idx();
2622 class LCheckMapValue FINAL : public LTemplateInstruction<0, 2, 0> {
2624 LCheckMapValue(LOperand* value, LOperand* map) {
2629 LOperand* value() { return inputs_[0]; }
2630 LOperand* map() { return inputs_[1]; }
2632 DECLARE_CONCRETE_INSTRUCTION(CheckMapValue, "check-map-value")
2636 class LLoadFieldByIndex FINAL : public LTemplateInstruction<1, 2, 0> {
2638 LLoadFieldByIndex(LOperand* object, LOperand* index) {
2639 inputs_[0] = object;
2643 LOperand* object() { return inputs_[0]; }
2644 LOperand* index() { return inputs_[1]; }
2646 DECLARE_CONCRETE_INSTRUCTION(LoadFieldByIndex, "load-field-by-index")
2650 class LStoreFrameContext: public LTemplateInstruction<0, 1, 0> {
2652 explicit LStoreFrameContext(LOperand* context) {
2653 inputs_[0] = context;
2656 LOperand* context() { return inputs_[0]; }
2658 DECLARE_CONCRETE_INSTRUCTION(StoreFrameContext, "store-frame-context")
2662 class LAllocateBlockContext: public LTemplateInstruction<1, 2, 0> {
2664 LAllocateBlockContext(LOperand* context, LOperand* function) {
2665 inputs_[0] = context;
2666 inputs_[1] = function;
2669 LOperand* context() { return inputs_[0]; }
2670 LOperand* function() { return inputs_[1]; }
2672 Handle<ScopeInfo> scope_info() { return hydrogen()->scope_info(); }
2674 DECLARE_CONCRETE_INSTRUCTION(AllocateBlockContext, "allocate-block-context")
2675 DECLARE_HYDROGEN_ACCESSOR(AllocateBlockContext)
2679 class LChunkBuilder;
2680 class LPlatformChunk FINAL : public LChunk {
2682 LPlatformChunk(CompilationInfo* info, HGraph* graph)
2683 : LChunk(info, graph) { }
2685 int GetNextSpillIndex(RegisterKind kind);
2686 LOperand* GetNextSpillSlot(RegisterKind kind);
2690 class LChunkBuilder FINAL : public LChunkBuilderBase {
2692 LChunkBuilder(CompilationInfo* info, HGraph* graph, LAllocator* allocator)
2693 : LChunkBuilderBase(info, graph),
2694 current_instruction_(NULL),
2695 current_block_(NULL),
2697 allocator_(allocator) {}
2699 // Build the sequence for the graph.
2700 LPlatformChunk* Build();
2702 // Declare methods that deal with the individual node types.
2703 #define DECLARE_DO(type) LInstruction* Do##type(H##type* node);
2704 HYDROGEN_CONCRETE_INSTRUCTION_LIST(DECLARE_DO)
2707 LInstruction* DoMultiplyAdd(HMul* mul, HValue* addend);
2709 static bool HasMagicNumberForDivisor(int32_t divisor);
2711 LInstruction* DoMathFloor(HUnaryMathOperation* instr);
2712 LInstruction* DoMathRound(HUnaryMathOperation* instr);
2713 LInstruction* DoMathFround(HUnaryMathOperation* instr);
2714 LInstruction* DoMathAbs(HUnaryMathOperation* instr);
2715 LInstruction* DoMathLog(HUnaryMathOperation* instr);
2716 LInstruction* DoMathExp(HUnaryMathOperation* instr);
2717 LInstruction* DoMathSqrt(HUnaryMathOperation* instr);
2718 LInstruction* DoMathPowHalf(HUnaryMathOperation* instr);
2719 LInstruction* DoMathClz32(HUnaryMathOperation* instr);
2720 LInstruction* DoDivByPowerOf2I(HDiv* instr);
2721 LInstruction* DoDivByConstI(HDiv* instr);
2722 LInstruction* DoDivI(HDiv* instr);
2723 LInstruction* DoModByPowerOf2I(HMod* instr);
2724 LInstruction* DoModByConstI(HMod* instr);
2725 LInstruction* DoModI(HMod* instr);
2726 LInstruction* DoFlooringDivByPowerOf2I(HMathFloorOfDiv* instr);
2727 LInstruction* DoFlooringDivByConstI(HMathFloorOfDiv* instr);
2728 LInstruction* DoFlooringDivI(HMathFloorOfDiv* instr);
2731 // Methods for getting operands for Use / Define / Temp.
2732 LUnallocated* ToUnallocated(Register reg);
2733 LUnallocated* ToUnallocated(DoubleRegister reg);
2735 // Methods for setting up define-use relationships.
2736 MUST_USE_RESULT LOperand* Use(HValue* value, LUnallocated* operand);
2737 MUST_USE_RESULT LOperand* UseFixed(HValue* value, Register fixed_register);
2738 MUST_USE_RESULT LOperand* UseFixedDouble(HValue* value,
2739 DoubleRegister fixed_register);
2741 // A value that is guaranteed to be allocated to a register.
2742 // Operand created by UseRegister is guaranteed to be live until the end of
2743 // instruction. This means that register allocator will not reuse it's
2744 // register for any other operand inside instruction.
2745 // Operand created by UseRegisterAtStart is guaranteed to be live only at
2746 // instruction start. Register allocator is free to assign the same register
2747 // to some other operand used inside instruction (i.e. temporary or
2749 MUST_USE_RESULT LOperand* UseRegister(HValue* value);
2750 MUST_USE_RESULT LOperand* UseRegisterAtStart(HValue* value);
2752 // An input operand in a register that may be trashed.
2753 MUST_USE_RESULT LOperand* UseTempRegister(HValue* value);
2755 // An input operand in a register or stack slot.
2756 MUST_USE_RESULT LOperand* Use(HValue* value);
2757 MUST_USE_RESULT LOperand* UseAtStart(HValue* value);
2759 // An input operand in a register, stack slot or a constant operand.
2760 MUST_USE_RESULT LOperand* UseOrConstant(HValue* value);
2761 MUST_USE_RESULT LOperand* UseOrConstantAtStart(HValue* value);
2763 // An input operand in a register or a constant operand.
2764 MUST_USE_RESULT LOperand* UseRegisterOrConstant(HValue* value);
2765 MUST_USE_RESULT LOperand* UseRegisterOrConstantAtStart(HValue* value);
2767 // An input operand in a constant operand.
2768 MUST_USE_RESULT LOperand* UseConstant(HValue* value);
2770 // An input operand in register, stack slot or a constant operand.
2771 // Will not be moved to a register even if one is freely available.
2772 MUST_USE_RESULT LOperand* UseAny(HValue* value) OVERRIDE;
2774 // Temporary operand that must be in a register.
2775 MUST_USE_RESULT LUnallocated* TempRegister();
2776 MUST_USE_RESULT LUnallocated* TempDoubleRegister();
2777 MUST_USE_RESULT LOperand* FixedTemp(Register reg);
2778 MUST_USE_RESULT LOperand* FixedTemp(DoubleRegister reg);
2780 // Methods for setting up define-use relationships.
2781 // Return the same instruction that they are passed.
2782 LInstruction* Define(LTemplateResultInstruction<1>* instr,
2783 LUnallocated* result);
2784 LInstruction* DefineAsRegister(LTemplateResultInstruction<1>* instr);
2785 LInstruction* DefineAsSpilled(LTemplateResultInstruction<1>* instr,
2787 LInstruction* DefineSameAsFirst(LTemplateResultInstruction<1>* instr);
2788 LInstruction* DefineFixed(LTemplateResultInstruction<1>* instr,
2790 LInstruction* DefineFixedDouble(LTemplateResultInstruction<1>* instr,
2791 DoubleRegister reg);
2792 LInstruction* AssignEnvironment(LInstruction* instr);
2793 LInstruction* AssignPointerMap(LInstruction* instr);
2795 enum CanDeoptimize { CAN_DEOPTIMIZE_EAGERLY, CANNOT_DEOPTIMIZE_EAGERLY };
2797 // By default we assume that instruction sequences generated for calls
2798 // cannot deoptimize eagerly and we do not attach environment to this
2800 LInstruction* MarkAsCall(
2801 LInstruction* instr,
2802 HInstruction* hinstr,
2803 CanDeoptimize can_deoptimize = CANNOT_DEOPTIMIZE_EAGERLY);
2805 void VisitInstruction(HInstruction* current);
2806 void AddInstruction(LInstruction* instr, HInstruction* current);
2808 void DoBasicBlock(HBasicBlock* block, HBasicBlock* next_block);
2809 LInstruction* DoBit(Token::Value op, HBitwiseBinaryOperation* instr);
2810 LInstruction* DoShift(Token::Value op, HBitwiseBinaryOperation* instr);
2811 LInstruction* DoArithmeticD(Token::Value op,
2812 HArithmeticBinaryOperation* instr);
2813 LInstruction* DoArithmeticT(Token::Value op,
2814 HBinaryOperation* instr);
2816 HInstruction* current_instruction_;
2817 HBasicBlock* current_block_;
2818 HBasicBlock* next_block_;
2819 LAllocator* allocator_;
2821 DISALLOW_COPY_AND_ASSIGN(LChunkBuilder);
2824 #undef DECLARE_HYDROGEN_ACCESSOR
2825 #undef DECLARE_CONCRETE_INSTRUCTION
2827 } } // namespace v8::internal
2829 #endif // V8_MIPS_LITHIUM_MIPS_H_