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) \
104 V(LoadGlobalGeneric) \
106 V(LoadKeyedGeneric) \
108 V(LoadNamedGeneric) \
134 V(SeqStringGetChar) \
135 V(SeqStringSetChar) \
141 V(StoreContextSlot) \
142 V(StoreFrameContext) \
145 V(StoreKeyedGeneric) \
147 V(StoreNamedGeneric) \
149 V(StringCharCodeAt) \
150 V(StringCharFromCode) \
151 V(StringCompareAndBranch) \
154 V(TailCallThroughMegamorphicCache) \
156 V(ToFastProperties) \
157 V(TransitionElementsKind) \
158 V(TrapAllocationMemento) \
160 V(TypeofIsAndBranch) \
165 #define DECLARE_CONCRETE_INSTRUCTION(type, mnemonic) \
166 virtual Opcode opcode() const FINAL OVERRIDE { \
167 return LInstruction::k##type; \
169 virtual void CompileToNative(LCodeGen* generator) FINAL OVERRIDE; \
170 virtual const char* Mnemonic() const FINAL OVERRIDE { \
173 static L##type* cast(LInstruction* instr) { \
174 DCHECK(instr->Is##type()); \
175 return reinterpret_cast<L##type*>(instr); \
179 #define DECLARE_HYDROGEN_ACCESSOR(type) \
180 H##type* hydrogen() const { \
181 return H##type::cast(hydrogen_value()); \
185 class LInstruction : public ZoneObject {
188 : environment_(NULL),
189 hydrogen_value_(NULL),
190 bit_field_(IsCallBits::encode(false)) {
193 virtual ~LInstruction() {}
195 virtual void CompileToNative(LCodeGen* generator) = 0;
196 virtual const char* Mnemonic() const = 0;
197 virtual void PrintTo(StringStream* stream);
198 virtual void PrintDataTo(StringStream* stream);
199 virtual void PrintOutputOperandTo(StringStream* stream);
202 // Declare a unique enum value for each instruction.
203 #define DECLARE_OPCODE(type) k##type,
204 LITHIUM_CONCRETE_INSTRUCTION_LIST(DECLARE_OPCODE)
205 kNumberOfInstructions
206 #undef DECLARE_OPCODE
209 virtual Opcode opcode() const = 0;
211 // Declare non-virtual type testers for all leaf IR classes.
212 #define DECLARE_PREDICATE(type) \
213 bool Is##type() const { return opcode() == k##type; }
214 LITHIUM_CONCRETE_INSTRUCTION_LIST(DECLARE_PREDICATE)
215 #undef DECLARE_PREDICATE
217 // Declare virtual predicates for instructions that don't have
219 virtual bool IsGap() const { return false; }
221 virtual bool IsControl() const { return false; }
223 // Try deleting this instruction if possible.
224 virtual bool TryDelete() { return false; }
226 void set_environment(LEnvironment* env) { environment_ = env; }
227 LEnvironment* environment() const { return environment_; }
228 bool HasEnvironment() const { return environment_ != NULL; }
230 void set_pointer_map(LPointerMap* p) { pointer_map_.set(p); }
231 LPointerMap* pointer_map() const { return pointer_map_.get(); }
232 bool HasPointerMap() const { return pointer_map_.is_set(); }
234 void set_hydrogen_value(HValue* value) { hydrogen_value_ = value; }
235 HValue* hydrogen_value() const { return hydrogen_value_; }
237 virtual void SetDeferredLazyDeoptimizationEnvironment(LEnvironment* env) { }
239 void MarkAsCall() { bit_field_ = IsCallBits::update(bit_field_, true); }
240 bool IsCall() const { return IsCallBits::decode(bit_field_); }
242 // Interface to the register allocator and iterators.
243 bool ClobbersTemps() const { return IsCall(); }
244 bool ClobbersRegisters() const { return IsCall(); }
245 virtual bool ClobbersDoubleRegisters(Isolate* isolate) const {
249 // Interface to the register allocator and iterators.
250 bool IsMarkedAsCall() const { return IsCall(); }
252 virtual bool HasResult() const = 0;
253 virtual LOperand* result() const = 0;
255 LOperand* FirstInput() { return InputAt(0); }
256 LOperand* Output() { return HasResult() ? result() : NULL; }
258 virtual bool HasInterestingComment(LCodeGen* gen) const { return true; }
264 virtual int InputCount() = 0;
265 virtual LOperand* InputAt(int i) = 0;
268 // Iterator interface.
269 friend class InputIterator;
271 friend class TempIterator;
272 virtual int TempCount() = 0;
273 virtual LOperand* TempAt(int i) = 0;
275 class IsCallBits: public BitField<bool, 0, 1> {};
277 LEnvironment* environment_;
278 SetOncePointer<LPointerMap> pointer_map_;
279 HValue* hydrogen_value_;
284 // R = number of result operands (0 or 1).
286 class LTemplateResultInstruction : public LInstruction {
288 // Allow 0 or 1 output operands.
289 STATIC_ASSERT(R == 0 || R == 1);
290 virtual bool HasResult() const FINAL OVERRIDE {
291 return R != 0 && result() != NULL;
293 void set_result(LOperand* operand) { results_[0] = operand; }
294 LOperand* result() const { return results_[0]; }
297 EmbeddedContainer<LOperand*, R> results_;
301 // R = number of result operands (0 or 1).
302 // I = number of input operands.
303 // T = number of temporary operands.
304 template<int R, int I, int T>
305 class LTemplateInstruction : public LTemplateResultInstruction<R> {
307 EmbeddedContainer<LOperand*, I> inputs_;
308 EmbeddedContainer<LOperand*, T> temps_;
312 virtual int InputCount() FINAL OVERRIDE { return I; }
313 virtual LOperand* InputAt(int i) FINAL OVERRIDE { return inputs_[i]; }
315 virtual int TempCount() FINAL OVERRIDE { return T; }
316 virtual LOperand* TempAt(int i) FINAL OVERRIDE { return temps_[i]; }
320 class LGap : public LTemplateInstruction<0, 0, 0> {
322 explicit LGap(HBasicBlock* block)
324 parallel_moves_[BEFORE] = NULL;
325 parallel_moves_[START] = NULL;
326 parallel_moves_[END] = NULL;
327 parallel_moves_[AFTER] = NULL;
330 // Can't use the DECLARE-macro here because of sub-classes.
331 virtual bool IsGap() const FINAL OVERRIDE { return true; }
332 virtual void PrintDataTo(StringStream* stream) OVERRIDE;
333 static LGap* cast(LInstruction* instr) {
334 DCHECK(instr->IsGap());
335 return reinterpret_cast<LGap*>(instr);
338 bool IsRedundant() const;
340 HBasicBlock* block() const { return block_; }
347 FIRST_INNER_POSITION = BEFORE,
348 LAST_INNER_POSITION = AFTER
351 LParallelMove* GetOrCreateParallelMove(InnerPosition pos, Zone* zone) {
352 if (parallel_moves_[pos] == NULL) {
353 parallel_moves_[pos] = new(zone) LParallelMove(zone);
355 return parallel_moves_[pos];
358 LParallelMove* GetParallelMove(InnerPosition pos) {
359 return parallel_moves_[pos];
363 LParallelMove* parallel_moves_[LAST_INNER_POSITION + 1];
368 class LInstructionGap FINAL : public LGap {
370 explicit LInstructionGap(HBasicBlock* block) : LGap(block) { }
372 virtual bool HasInterestingComment(LCodeGen* gen) const OVERRIDE {
373 return !IsRedundant();
376 DECLARE_CONCRETE_INSTRUCTION(InstructionGap, "gap")
380 class LGoto FINAL : public LTemplateInstruction<0, 0, 0> {
382 explicit LGoto(HBasicBlock* block) : block_(block) { }
384 virtual bool HasInterestingComment(LCodeGen* gen) const OVERRIDE;
385 DECLARE_CONCRETE_INSTRUCTION(Goto, "goto")
386 virtual void PrintDataTo(StringStream* stream) OVERRIDE;
387 virtual bool IsControl() const OVERRIDE { return true; }
389 int block_id() const { return block_->block_id(); }
396 class LLazyBailout FINAL : public LTemplateInstruction<0, 0, 0> {
398 LLazyBailout() : gap_instructions_size_(0) { }
400 DECLARE_CONCRETE_INSTRUCTION(LazyBailout, "lazy-bailout")
402 void set_gap_instructions_size(int gap_instructions_size) {
403 gap_instructions_size_ = gap_instructions_size;
405 int gap_instructions_size() { return gap_instructions_size_; }
408 int gap_instructions_size_;
412 class LDummy FINAL : public LTemplateInstruction<1, 0, 0> {
415 DECLARE_CONCRETE_INSTRUCTION(Dummy, "dummy")
419 class LDummyUse FINAL : public LTemplateInstruction<1, 1, 0> {
421 explicit LDummyUse(LOperand* value) {
424 DECLARE_CONCRETE_INSTRUCTION(DummyUse, "dummy-use")
428 class LDeoptimize FINAL : public LTemplateInstruction<0, 0, 0> {
430 virtual bool IsControl() const OVERRIDE { return true; }
431 DECLARE_CONCRETE_INSTRUCTION(Deoptimize, "deoptimize")
432 DECLARE_HYDROGEN_ACCESSOR(Deoptimize)
436 class LLabel FINAL : public LGap {
438 explicit LLabel(HBasicBlock* block)
439 : LGap(block), replacement_(NULL) { }
441 virtual bool HasInterestingComment(LCodeGen* gen) const OVERRIDE {
444 DECLARE_CONCRETE_INSTRUCTION(Label, "label")
446 virtual void PrintDataTo(StringStream* stream) OVERRIDE;
448 int block_id() const { return block()->block_id(); }
449 bool is_loop_header() const { return block()->IsLoopHeader(); }
450 bool is_osr_entry() const { return block()->is_osr_entry(); }
451 Label* label() { return &label_; }
452 LLabel* replacement() const { return replacement_; }
453 void set_replacement(LLabel* label) { replacement_ = label; }
454 bool HasReplacement() const { return replacement_ != NULL; }
458 LLabel* replacement_;
462 class LParameter FINAL : public LTemplateInstruction<1, 0, 0> {
464 virtual bool HasInterestingComment(LCodeGen* gen) const OVERRIDE {
467 DECLARE_CONCRETE_INSTRUCTION(Parameter, "parameter")
471 class LCallStub FINAL : public LTemplateInstruction<1, 1, 0> {
473 explicit LCallStub(LOperand* context) {
474 inputs_[0] = context;
477 LOperand* context() { return inputs_[0]; }
479 DECLARE_CONCRETE_INSTRUCTION(CallStub, "call-stub")
480 DECLARE_HYDROGEN_ACCESSOR(CallStub)
484 class LTailCallThroughMegamorphicCache FINAL
485 : public LTemplateInstruction<0, 3, 0> {
487 explicit LTailCallThroughMegamorphicCache(LOperand* context,
490 inputs_[0] = context;
491 inputs_[1] = receiver;
495 LOperand* context() { return inputs_[0]; }
496 LOperand* receiver() { return inputs_[1]; }
497 LOperand* name() { return inputs_[2]; }
499 DECLARE_CONCRETE_INSTRUCTION(TailCallThroughMegamorphicCache,
500 "tail-call-through-megamorphic-cache")
501 DECLARE_HYDROGEN_ACCESSOR(TailCallThroughMegamorphicCache)
505 class LUnknownOSRValue FINAL : public LTemplateInstruction<1, 0, 0> {
507 virtual bool HasInterestingComment(LCodeGen* gen) const OVERRIDE {
510 DECLARE_CONCRETE_INSTRUCTION(UnknownOSRValue, "unknown-osr-value")
514 template<int I, int T>
515 class LControlInstruction : public LTemplateInstruction<0, I, T> {
517 LControlInstruction() : false_label_(NULL), true_label_(NULL) { }
519 virtual bool IsControl() const FINAL OVERRIDE { return true; }
521 int SuccessorCount() { return hydrogen()->SuccessorCount(); }
522 HBasicBlock* SuccessorAt(int i) { return hydrogen()->SuccessorAt(i); }
524 int TrueDestination(LChunk* chunk) {
525 return chunk->LookupDestination(true_block_id());
527 int FalseDestination(LChunk* chunk) {
528 return chunk->LookupDestination(false_block_id());
531 Label* TrueLabel(LChunk* chunk) {
532 if (true_label_ == NULL) {
533 true_label_ = chunk->GetAssemblyLabel(TrueDestination(chunk));
537 Label* FalseLabel(LChunk* chunk) {
538 if (false_label_ == NULL) {
539 false_label_ = chunk->GetAssemblyLabel(FalseDestination(chunk));
545 int true_block_id() { return SuccessorAt(0)->block_id(); }
546 int false_block_id() { return SuccessorAt(1)->block_id(); }
549 HControlInstruction* hydrogen() {
550 return HControlInstruction::cast(this->hydrogen_value());
558 class LWrapReceiver FINAL : public LTemplateInstruction<1, 2, 0> {
560 LWrapReceiver(LOperand* receiver, LOperand* function) {
561 inputs_[0] = receiver;
562 inputs_[1] = function;
565 DECLARE_CONCRETE_INSTRUCTION(WrapReceiver, "wrap-receiver")
566 DECLARE_HYDROGEN_ACCESSOR(WrapReceiver)
568 LOperand* receiver() { return inputs_[0]; }
569 LOperand* function() { return inputs_[1]; }
573 class LApplyArguments FINAL : public LTemplateInstruction<1, 4, 0> {
575 LApplyArguments(LOperand* function,
578 LOperand* elements) {
579 inputs_[0] = function;
580 inputs_[1] = receiver;
582 inputs_[3] = elements;
585 DECLARE_CONCRETE_INSTRUCTION(ApplyArguments, "apply-arguments")
587 LOperand* function() { return inputs_[0]; }
588 LOperand* receiver() { return inputs_[1]; }
589 LOperand* length() { return inputs_[2]; }
590 LOperand* elements() { return inputs_[3]; }
594 class LAccessArgumentsAt FINAL : public LTemplateInstruction<1, 3, 0> {
596 LAccessArgumentsAt(LOperand* arguments, LOperand* length, LOperand* index) {
597 inputs_[0] = arguments;
602 DECLARE_CONCRETE_INSTRUCTION(AccessArgumentsAt, "access-arguments-at")
604 LOperand* arguments() { return inputs_[0]; }
605 LOperand* length() { return inputs_[1]; }
606 LOperand* index() { return inputs_[2]; }
608 virtual void PrintDataTo(StringStream* stream) OVERRIDE;
612 class LArgumentsLength FINAL : public LTemplateInstruction<1, 1, 0> {
614 explicit LArgumentsLength(LOperand* elements) {
615 inputs_[0] = elements;
618 LOperand* elements() { return inputs_[0]; }
620 DECLARE_CONCRETE_INSTRUCTION(ArgumentsLength, "arguments-length")
624 class LArgumentsElements FINAL : public LTemplateInstruction<1, 0, 0> {
626 DECLARE_CONCRETE_INSTRUCTION(ArgumentsElements, "arguments-elements")
627 DECLARE_HYDROGEN_ACCESSOR(ArgumentsElements)
631 class LModByPowerOf2I FINAL : public LTemplateInstruction<1, 1, 0> {
633 LModByPowerOf2I(LOperand* dividend, int32_t divisor) {
634 inputs_[0] = dividend;
638 LOperand* dividend() { return inputs_[0]; }
639 int32_t divisor() const { return divisor_; }
641 DECLARE_CONCRETE_INSTRUCTION(ModByPowerOf2I, "mod-by-power-of-2-i")
642 DECLARE_HYDROGEN_ACCESSOR(Mod)
649 class LModByConstI FINAL : public LTemplateInstruction<1, 1, 0> {
651 LModByConstI(LOperand* dividend, int32_t divisor) {
652 inputs_[0] = dividend;
656 LOperand* dividend() { return inputs_[0]; }
657 int32_t divisor() const { return divisor_; }
659 DECLARE_CONCRETE_INSTRUCTION(ModByConstI, "mod-by-const-i")
660 DECLARE_HYDROGEN_ACCESSOR(Mod)
667 class LModI FINAL : public LTemplateInstruction<1, 2, 3> {
669 LModI(LOperand* left,
675 LOperand* left() { return inputs_[0]; }
676 LOperand* right() { return inputs_[1]; }
678 DECLARE_CONCRETE_INSTRUCTION(ModI, "mod-i")
679 DECLARE_HYDROGEN_ACCESSOR(Mod)
683 class LDivByPowerOf2I FINAL : public LTemplateInstruction<1, 1, 0> {
685 LDivByPowerOf2I(LOperand* dividend, int32_t divisor) {
686 inputs_[0] = dividend;
690 LOperand* dividend() { return inputs_[0]; }
691 int32_t divisor() const { return divisor_; }
693 DECLARE_CONCRETE_INSTRUCTION(DivByPowerOf2I, "div-by-power-of-2-i")
694 DECLARE_HYDROGEN_ACCESSOR(Div)
701 class LDivByConstI FINAL : public LTemplateInstruction<1, 1, 0> {
703 LDivByConstI(LOperand* dividend, int32_t divisor) {
704 inputs_[0] = dividend;
708 LOperand* dividend() { return inputs_[0]; }
709 int32_t divisor() const { return divisor_; }
711 DECLARE_CONCRETE_INSTRUCTION(DivByConstI, "div-by-const-i")
712 DECLARE_HYDROGEN_ACCESSOR(Div)
719 class LDivI FINAL : public LTemplateInstruction<1, 2, 1> {
721 LDivI(LOperand* dividend, LOperand* divisor, LOperand* temp) {
722 inputs_[0] = dividend;
723 inputs_[1] = divisor;
727 LOperand* dividend() { return inputs_[0]; }
728 LOperand* divisor() { return inputs_[1]; }
729 LOperand* temp() { return temps_[0]; }
731 DECLARE_CONCRETE_INSTRUCTION(DivI, "div-i")
732 DECLARE_HYDROGEN_ACCESSOR(BinaryOperation)
736 class LFlooringDivByPowerOf2I FINAL : public LTemplateInstruction<1, 1, 0> {
738 LFlooringDivByPowerOf2I(LOperand* dividend, int32_t divisor) {
739 inputs_[0] = dividend;
743 LOperand* dividend() { return inputs_[0]; }
744 int32_t divisor() { return divisor_; }
746 DECLARE_CONCRETE_INSTRUCTION(FlooringDivByPowerOf2I,
747 "flooring-div-by-power-of-2-i")
748 DECLARE_HYDROGEN_ACCESSOR(MathFloorOfDiv)
755 class LFlooringDivByConstI FINAL : public LTemplateInstruction<1, 1, 2> {
757 LFlooringDivByConstI(LOperand* dividend, int32_t divisor, LOperand* temp) {
758 inputs_[0] = dividend;
763 LOperand* dividend() { return inputs_[0]; }
764 int32_t divisor() const { return divisor_; }
765 LOperand* temp() { return temps_[0]; }
767 DECLARE_CONCRETE_INSTRUCTION(FlooringDivByConstI, "flooring-div-by-const-i")
768 DECLARE_HYDROGEN_ACCESSOR(MathFloorOfDiv)
775 class LFlooringDivI FINAL : public LTemplateInstruction<1, 2, 0> {
777 LFlooringDivI(LOperand* dividend, LOperand* divisor) {
778 inputs_[0] = dividend;
779 inputs_[1] = divisor;
782 LOperand* dividend() { return inputs_[0]; }
783 LOperand* divisor() { return inputs_[1]; }
785 DECLARE_CONCRETE_INSTRUCTION(FlooringDivI, "flooring-div-i")
786 DECLARE_HYDROGEN_ACCESSOR(MathFloorOfDiv)
790 class LMulI FINAL : public LTemplateInstruction<1, 2, 0> {
792 LMulI(LOperand* left, LOperand* right) {
797 LOperand* left() { return inputs_[0]; }
798 LOperand* right() { return inputs_[1]; }
800 DECLARE_CONCRETE_INSTRUCTION(MulI, "mul-i")
801 DECLARE_HYDROGEN_ACCESSOR(Mul)
805 // Instruction for computing multiplier * multiplicand + addend.
806 class LMultiplyAddD FINAL : public LTemplateInstruction<1, 3, 0> {
808 LMultiplyAddD(LOperand* addend, LOperand* multiplier,
809 LOperand* multiplicand) {
811 inputs_[1] = multiplier;
812 inputs_[2] = multiplicand;
815 LOperand* addend() { return inputs_[0]; }
816 LOperand* multiplier() { return inputs_[1]; }
817 LOperand* multiplicand() { return inputs_[2]; }
819 DECLARE_CONCRETE_INSTRUCTION(MultiplyAddD, "multiply-add-d")
823 class LDebugBreak FINAL : public LTemplateInstruction<0, 0, 0> {
825 DECLARE_CONCRETE_INSTRUCTION(DebugBreak, "break")
829 class LCompareNumericAndBranch FINAL : public LControlInstruction<2, 0> {
831 LCompareNumericAndBranch(LOperand* left, LOperand* right) {
836 LOperand* left() { return inputs_[0]; }
837 LOperand* right() { return inputs_[1]; }
839 DECLARE_CONCRETE_INSTRUCTION(CompareNumericAndBranch,
840 "compare-numeric-and-branch")
841 DECLARE_HYDROGEN_ACCESSOR(CompareNumericAndBranch)
843 Token::Value op() const { return hydrogen()->token(); }
844 bool is_double() const {
845 return hydrogen()->representation().IsDouble();
848 virtual void PrintDataTo(StringStream* stream) OVERRIDE;
852 class LMathFloor FINAL : public LTemplateInstruction<1, 1, 1> {
854 LMathFloor(LOperand* value, LOperand* temp) {
859 LOperand* value() { return inputs_[0]; }
860 LOperand* temp() { return temps_[0]; }
862 DECLARE_CONCRETE_INSTRUCTION(MathFloor, "math-floor")
863 DECLARE_HYDROGEN_ACCESSOR(UnaryMathOperation)
867 class LMathRound FINAL : public LTemplateInstruction<1, 1, 1> {
869 LMathRound(LOperand* value, LOperand* temp) {
874 LOperand* value() { return inputs_[0]; }
875 LOperand* temp() { return temps_[0]; }
877 DECLARE_CONCRETE_INSTRUCTION(MathRound, "math-round")
878 DECLARE_HYDROGEN_ACCESSOR(UnaryMathOperation)
882 class LMathFround FINAL : public LTemplateInstruction<1, 1, 0> {
884 explicit LMathFround(LOperand* value) { inputs_[0] = value; }
886 LOperand* value() { return inputs_[0]; }
888 DECLARE_CONCRETE_INSTRUCTION(MathFround, "math-fround")
892 class LMathAbs FINAL : public LTemplateInstruction<1, 2, 0> {
894 LMathAbs(LOperand* context, LOperand* value) {
895 inputs_[1] = context;
899 LOperand* context() { return inputs_[1]; }
900 LOperand* value() { return inputs_[0]; }
902 DECLARE_CONCRETE_INSTRUCTION(MathAbs, "math-abs")
903 DECLARE_HYDROGEN_ACCESSOR(UnaryMathOperation)
907 class LMathLog FINAL : public LTemplateInstruction<1, 1, 0> {
909 explicit LMathLog(LOperand* value) {
913 LOperand* value() { return inputs_[0]; }
915 DECLARE_CONCRETE_INSTRUCTION(MathLog, "math-log")
919 class LMathClz32 FINAL : public LTemplateInstruction<1, 1, 0> {
921 explicit LMathClz32(LOperand* value) {
925 LOperand* value() { return inputs_[0]; }
927 DECLARE_CONCRETE_INSTRUCTION(MathClz32, "math-clz32")
931 class LMathExp FINAL : public LTemplateInstruction<1, 1, 3> {
933 LMathExp(LOperand* value,
934 LOperand* double_temp,
940 temps_[2] = double_temp;
941 ExternalReference::InitializeMathExpData();
944 LOperand* value() { return inputs_[0]; }
945 LOperand* temp1() { return temps_[0]; }
946 LOperand* temp2() { return temps_[1]; }
947 LOperand* double_temp() { return temps_[2]; }
949 DECLARE_CONCRETE_INSTRUCTION(MathExp, "math-exp")
953 class LMathSqrt FINAL : public LTemplateInstruction<1, 1, 0> {
955 explicit LMathSqrt(LOperand* value) {
959 LOperand* value() { return inputs_[0]; }
961 DECLARE_CONCRETE_INSTRUCTION(MathSqrt, "math-sqrt")
965 class LMathPowHalf FINAL : public LTemplateInstruction<1, 1, 1> {
967 LMathPowHalf(LOperand* value, LOperand* temp) {
972 LOperand* value() { return inputs_[0]; }
973 LOperand* temp() { return temps_[0]; }
975 DECLARE_CONCRETE_INSTRUCTION(MathPowHalf, "math-pow-half")
979 class LCmpObjectEqAndBranch FINAL : public LControlInstruction<2, 0> {
981 LCmpObjectEqAndBranch(LOperand* left, LOperand* right) {
986 LOperand* left() { return inputs_[0]; }
987 LOperand* right() { return inputs_[1]; }
989 DECLARE_CONCRETE_INSTRUCTION(CmpObjectEqAndBranch, "cmp-object-eq-and-branch")
990 DECLARE_HYDROGEN_ACCESSOR(CompareObjectEqAndBranch)
994 class LCmpHoleAndBranch FINAL : public LControlInstruction<1, 0> {
996 explicit LCmpHoleAndBranch(LOperand* object) {
1000 LOperand* object() { return inputs_[0]; }
1002 DECLARE_CONCRETE_INSTRUCTION(CmpHoleAndBranch, "cmp-hole-and-branch")
1003 DECLARE_HYDROGEN_ACCESSOR(CompareHoleAndBranch)
1007 class LCompareMinusZeroAndBranch FINAL : public LControlInstruction<1, 1> {
1009 LCompareMinusZeroAndBranch(LOperand* value, LOperand* temp) {
1014 LOperand* value() { return inputs_[0]; }
1015 LOperand* temp() { return temps_[0]; }
1017 DECLARE_CONCRETE_INSTRUCTION(CompareMinusZeroAndBranch,
1018 "cmp-minus-zero-and-branch")
1019 DECLARE_HYDROGEN_ACCESSOR(CompareMinusZeroAndBranch)
1023 class LIsObjectAndBranch FINAL : public LControlInstruction<1, 1> {
1025 LIsObjectAndBranch(LOperand* value, LOperand* temp) {
1030 LOperand* value() { return inputs_[0]; }
1031 LOperand* temp() { return temps_[0]; }
1033 DECLARE_CONCRETE_INSTRUCTION(IsObjectAndBranch, "is-object-and-branch")
1034 DECLARE_HYDROGEN_ACCESSOR(IsObjectAndBranch)
1036 virtual void PrintDataTo(StringStream* stream);
1040 class LIsStringAndBranch FINAL : public LControlInstruction<1, 1> {
1042 LIsStringAndBranch(LOperand* value, LOperand* temp) {
1047 LOperand* value() { return inputs_[0]; }
1048 LOperand* temp() { return temps_[0]; }
1050 DECLARE_CONCRETE_INSTRUCTION(IsStringAndBranch, "is-string-and-branch")
1051 DECLARE_HYDROGEN_ACCESSOR(IsStringAndBranch)
1053 virtual void PrintDataTo(StringStream* stream) OVERRIDE;
1057 class LIsSmiAndBranch FINAL : public LControlInstruction<1, 0> {
1059 explicit LIsSmiAndBranch(LOperand* value) {
1063 LOperand* value() { return inputs_[0]; }
1065 DECLARE_CONCRETE_INSTRUCTION(IsSmiAndBranch, "is-smi-and-branch")
1066 DECLARE_HYDROGEN_ACCESSOR(IsSmiAndBranch)
1068 virtual void PrintDataTo(StringStream* stream) OVERRIDE;
1072 class LIsUndetectableAndBranch FINAL : public LControlInstruction<1, 1> {
1074 explicit LIsUndetectableAndBranch(LOperand* value, LOperand* temp) {
1079 LOperand* value() { return inputs_[0]; }
1080 LOperand* temp() { return temps_[0]; }
1082 DECLARE_CONCRETE_INSTRUCTION(IsUndetectableAndBranch,
1083 "is-undetectable-and-branch")
1084 DECLARE_HYDROGEN_ACCESSOR(IsUndetectableAndBranch)
1086 virtual void PrintDataTo(StringStream* stream) OVERRIDE;
1090 class LStringCompareAndBranch FINAL : public LControlInstruction<3, 0> {
1092 LStringCompareAndBranch(LOperand* context, LOperand* left, LOperand* right) {
1093 inputs_[0] = context;
1098 LOperand* context() { return inputs_[0]; }
1099 LOperand* left() { return inputs_[1]; }
1100 LOperand* right() { return inputs_[2]; }
1102 DECLARE_CONCRETE_INSTRUCTION(StringCompareAndBranch,
1103 "string-compare-and-branch")
1104 DECLARE_HYDROGEN_ACCESSOR(StringCompareAndBranch)
1106 Token::Value op() const { return hydrogen()->token(); }
1108 virtual void PrintDataTo(StringStream* stream) OVERRIDE;
1112 class LHasInstanceTypeAndBranch FINAL : public LControlInstruction<1, 0> {
1114 explicit LHasInstanceTypeAndBranch(LOperand* value) {
1118 LOperand* value() { return inputs_[0]; }
1120 DECLARE_CONCRETE_INSTRUCTION(HasInstanceTypeAndBranch,
1121 "has-instance-type-and-branch")
1122 DECLARE_HYDROGEN_ACCESSOR(HasInstanceTypeAndBranch)
1124 virtual void PrintDataTo(StringStream* stream) OVERRIDE;
1128 class LGetCachedArrayIndex FINAL : public LTemplateInstruction<1, 1, 0> {
1130 explicit LGetCachedArrayIndex(LOperand* value) {
1134 LOperand* value() { return inputs_[0]; }
1136 DECLARE_CONCRETE_INSTRUCTION(GetCachedArrayIndex, "get-cached-array-index")
1137 DECLARE_HYDROGEN_ACCESSOR(GetCachedArrayIndex)
1141 class LHasCachedArrayIndexAndBranch FINAL
1142 : public LControlInstruction<1, 0> {
1144 explicit LHasCachedArrayIndexAndBranch(LOperand* value) {
1148 LOperand* value() { return inputs_[0]; }
1150 DECLARE_CONCRETE_INSTRUCTION(HasCachedArrayIndexAndBranch,
1151 "has-cached-array-index-and-branch")
1152 DECLARE_HYDROGEN_ACCESSOR(HasCachedArrayIndexAndBranch)
1154 virtual void PrintDataTo(StringStream* stream) OVERRIDE;
1158 class LClassOfTestAndBranch FINAL : public LControlInstruction<1, 1> {
1160 LClassOfTestAndBranch(LOperand* value, LOperand* temp) {
1165 LOperand* value() { return inputs_[0]; }
1166 LOperand* temp() { return temps_[0]; }
1168 DECLARE_CONCRETE_INSTRUCTION(ClassOfTestAndBranch,
1169 "class-of-test-and-branch")
1170 DECLARE_HYDROGEN_ACCESSOR(ClassOfTestAndBranch)
1172 virtual void PrintDataTo(StringStream* stream) OVERRIDE;
1176 class LCmpT FINAL : public LTemplateInstruction<1, 3, 0> {
1178 LCmpT(LOperand* context, LOperand* left, LOperand* right) {
1179 inputs_[0] = context;
1184 LOperand* context() { return inputs_[0]; }
1185 LOperand* left() { return inputs_[1]; }
1186 LOperand* right() { return inputs_[2]; }
1188 DECLARE_CONCRETE_INSTRUCTION(CmpT, "cmp-t")
1189 DECLARE_HYDROGEN_ACCESSOR(CompareGeneric)
1191 Token::Value op() const { return hydrogen()->token(); }
1195 class LInstanceOf FINAL : public LTemplateInstruction<1, 3, 0> {
1197 LInstanceOf(LOperand* context, LOperand* left, LOperand* right) {
1198 inputs_[0] = context;
1203 LOperand* context() { return inputs_[0]; }
1204 LOperand* left() { return inputs_[1]; }
1205 LOperand* right() { return inputs_[2]; }
1207 DECLARE_CONCRETE_INSTRUCTION(InstanceOf, "instance-of")
1211 class LInstanceOfKnownGlobal FINAL : public LTemplateInstruction<1, 2, 1> {
1213 LInstanceOfKnownGlobal(LOperand* context, LOperand* value, LOperand* temp) {
1214 inputs_[0] = context;
1219 LOperand* context() { return inputs_[0]; }
1220 LOperand* value() { return inputs_[1]; }
1221 LOperand* temp() { return temps_[0]; }
1223 DECLARE_CONCRETE_INSTRUCTION(InstanceOfKnownGlobal,
1224 "instance-of-known-global")
1225 DECLARE_HYDROGEN_ACCESSOR(InstanceOfKnownGlobal)
1227 Handle<JSFunction> function() const { return hydrogen()->function(); }
1228 LEnvironment* GetDeferredLazyDeoptimizationEnvironment() {
1229 return lazy_deopt_env_;
1231 virtual void SetDeferredLazyDeoptimizationEnvironment(
1232 LEnvironment* env) OVERRIDE {
1233 lazy_deopt_env_ = env;
1237 LEnvironment* lazy_deopt_env_;
1241 class LBoundsCheck FINAL : public LTemplateInstruction<0, 2, 0> {
1243 LBoundsCheck(LOperand* index, LOperand* length) {
1245 inputs_[1] = length;
1248 LOperand* index() { return inputs_[0]; }
1249 LOperand* length() { return inputs_[1]; }
1251 DECLARE_CONCRETE_INSTRUCTION(BoundsCheck, "bounds-check")
1252 DECLARE_HYDROGEN_ACCESSOR(BoundsCheck)
1256 class LBitI FINAL : public LTemplateInstruction<1, 2, 0> {
1258 LBitI(LOperand* left, LOperand* right) {
1263 LOperand* left() { return inputs_[0]; }
1264 LOperand* right() { return inputs_[1]; }
1266 Token::Value op() const { return hydrogen()->op(); }
1268 DECLARE_CONCRETE_INSTRUCTION(BitI, "bit-i")
1269 DECLARE_HYDROGEN_ACCESSOR(Bitwise)
1273 class LShiftI FINAL : public LTemplateInstruction<1, 2, 0> {
1275 LShiftI(Token::Value op, LOperand* left, LOperand* right, bool can_deopt)
1276 : op_(op), can_deopt_(can_deopt) {
1281 Token::Value op() const { return op_; }
1282 LOperand* left() { return inputs_[0]; }
1283 LOperand* right() { return inputs_[1]; }
1284 bool can_deopt() const { return can_deopt_; }
1286 DECLARE_CONCRETE_INSTRUCTION(ShiftI, "shift-i")
1294 class LSubI FINAL : public LTemplateInstruction<1, 2, 0> {
1296 LSubI(LOperand* left, LOperand* right) {
1301 LOperand* left() { return inputs_[0]; }
1302 LOperand* right() { return inputs_[1]; }
1304 DECLARE_CONCRETE_INSTRUCTION(SubI, "sub-i")
1305 DECLARE_HYDROGEN_ACCESSOR(Sub)
1309 class LConstantI FINAL : public LTemplateInstruction<1, 0, 0> {
1311 DECLARE_CONCRETE_INSTRUCTION(ConstantI, "constant-i")
1312 DECLARE_HYDROGEN_ACCESSOR(Constant)
1314 int32_t value() const { return hydrogen()->Integer32Value(); }
1318 class LConstantS FINAL : public LTemplateInstruction<1, 0, 0> {
1320 DECLARE_CONCRETE_INSTRUCTION(ConstantS, "constant-s")
1321 DECLARE_HYDROGEN_ACCESSOR(Constant)
1323 Smi* value() const { return Smi::FromInt(hydrogen()->Integer32Value()); }
1327 class LConstantD FINAL : public LTemplateInstruction<1, 0, 0> {
1329 DECLARE_CONCRETE_INSTRUCTION(ConstantD, "constant-d")
1330 DECLARE_HYDROGEN_ACCESSOR(Constant)
1332 double value() const { return hydrogen()->DoubleValue(); }
1336 class LConstantE FINAL : public LTemplateInstruction<1, 0, 0> {
1338 DECLARE_CONCRETE_INSTRUCTION(ConstantE, "constant-e")
1339 DECLARE_HYDROGEN_ACCESSOR(Constant)
1341 ExternalReference value() const {
1342 return hydrogen()->ExternalReferenceValue();
1347 class LConstantT FINAL : public LTemplateInstruction<1, 0, 0> {
1349 DECLARE_CONCRETE_INSTRUCTION(ConstantT, "constant-t")
1350 DECLARE_HYDROGEN_ACCESSOR(Constant)
1352 Handle<Object> value(Isolate* isolate) const {
1353 return hydrogen()->handle(isolate);
1358 class LBranch FINAL : public LControlInstruction<1, 0> {
1360 explicit LBranch(LOperand* value) {
1364 LOperand* value() { return inputs_[0]; }
1366 DECLARE_CONCRETE_INSTRUCTION(Branch, "branch")
1367 DECLARE_HYDROGEN_ACCESSOR(Branch)
1369 virtual void PrintDataTo(StringStream* stream) OVERRIDE;
1373 class LCmpMapAndBranch FINAL : public LControlInstruction<1, 1> {
1375 LCmpMapAndBranch(LOperand* value, LOperand* temp) {
1380 LOperand* value() { return inputs_[0]; }
1381 LOperand* temp() { return temps_[0]; }
1383 DECLARE_CONCRETE_INSTRUCTION(CmpMapAndBranch, "cmp-map-and-branch")
1384 DECLARE_HYDROGEN_ACCESSOR(CompareMap)
1386 Handle<Map> map() const { return hydrogen()->map().handle(); }
1390 class LMapEnumLength FINAL : public LTemplateInstruction<1, 1, 0> {
1392 explicit LMapEnumLength(LOperand* value) {
1396 LOperand* value() { return inputs_[0]; }
1398 DECLARE_CONCRETE_INSTRUCTION(MapEnumLength, "map-enum-length")
1402 class LDateField FINAL : public LTemplateInstruction<1, 1, 1> {
1404 LDateField(LOperand* date, LOperand* temp, Smi* index) : index_(index) {
1409 LOperand* date() { return inputs_[0]; }
1410 LOperand* temp() { return temps_[0]; }
1411 Smi* index() const { return index_; }
1413 DECLARE_CONCRETE_INSTRUCTION(DateField, "date-field")
1414 DECLARE_HYDROGEN_ACCESSOR(DateField)
1421 class LSeqStringGetChar FINAL : public LTemplateInstruction<1, 2, 0> {
1423 LSeqStringGetChar(LOperand* string, LOperand* index) {
1424 inputs_[0] = string;
1428 LOperand* string() const { return inputs_[0]; }
1429 LOperand* index() const { return inputs_[1]; }
1431 DECLARE_CONCRETE_INSTRUCTION(SeqStringGetChar, "seq-string-get-char")
1432 DECLARE_HYDROGEN_ACCESSOR(SeqStringGetChar)
1436 class LSeqStringSetChar FINAL : public LTemplateInstruction<1, 4, 0> {
1438 LSeqStringSetChar(LOperand* context,
1442 inputs_[0] = context;
1443 inputs_[1] = string;
1448 LOperand* string() { return inputs_[1]; }
1449 LOperand* index() { return inputs_[2]; }
1450 LOperand* value() { return inputs_[3]; }
1452 DECLARE_CONCRETE_INSTRUCTION(SeqStringSetChar, "seq-string-set-char")
1453 DECLARE_HYDROGEN_ACCESSOR(SeqStringSetChar)
1457 class LAddI FINAL : public LTemplateInstruction<1, 2, 0> {
1459 LAddI(LOperand* left, LOperand* right) {
1464 LOperand* left() { return inputs_[0]; }
1465 LOperand* right() { return inputs_[1]; }
1467 DECLARE_CONCRETE_INSTRUCTION(AddI, "add-i")
1468 DECLARE_HYDROGEN_ACCESSOR(Add)
1472 class LMathMinMax FINAL : public LTemplateInstruction<1, 2, 0> {
1474 LMathMinMax(LOperand* left, LOperand* right) {
1479 LOperand* left() { return inputs_[0]; }
1480 LOperand* right() { return inputs_[1]; }
1482 DECLARE_CONCRETE_INSTRUCTION(MathMinMax, "math-min-max")
1483 DECLARE_HYDROGEN_ACCESSOR(MathMinMax)
1487 class LPower FINAL : public LTemplateInstruction<1, 2, 0> {
1489 LPower(LOperand* left, LOperand* right) {
1494 LOperand* left() { return inputs_[0]; }
1495 LOperand* right() { return inputs_[1]; }
1497 DECLARE_CONCRETE_INSTRUCTION(Power, "power")
1498 DECLARE_HYDROGEN_ACCESSOR(Power)
1502 class LArithmeticD FINAL : public LTemplateInstruction<1, 2, 0> {
1504 LArithmeticD(Token::Value op, LOperand* left, LOperand* right)
1510 Token::Value op() const { return op_; }
1511 LOperand* left() { return inputs_[0]; }
1512 LOperand* right() { return inputs_[1]; }
1514 virtual Opcode opcode() const OVERRIDE {
1515 return LInstruction::kArithmeticD;
1517 virtual void CompileToNative(LCodeGen* generator) OVERRIDE;
1518 virtual const char* Mnemonic() const OVERRIDE;
1525 class LArithmeticT FINAL : public LTemplateInstruction<1, 3, 0> {
1527 LArithmeticT(Token::Value op,
1532 inputs_[0] = context;
1537 LOperand* context() { return inputs_[0]; }
1538 LOperand* left() { return inputs_[1]; }
1539 LOperand* right() { return inputs_[2]; }
1540 Token::Value op() const { return op_; }
1542 virtual Opcode opcode() const FINAL { return LInstruction::kArithmeticT; }
1543 virtual void CompileToNative(LCodeGen* generator) OVERRIDE;
1544 virtual const char* Mnemonic() const OVERRIDE;
1551 class LReturn FINAL : public LTemplateInstruction<0, 3, 0> {
1553 LReturn(LOperand* value, LOperand* context, LOperand* parameter_count) {
1555 inputs_[1] = context;
1556 inputs_[2] = parameter_count;
1559 LOperand* value() { return inputs_[0]; }
1561 bool has_constant_parameter_count() {
1562 return parameter_count()->IsConstantOperand();
1564 LConstantOperand* constant_parameter_count() {
1565 DCHECK(has_constant_parameter_count());
1566 return LConstantOperand::cast(parameter_count());
1568 LOperand* parameter_count() { return inputs_[2]; }
1570 DECLARE_CONCRETE_INSTRUCTION(Return, "return")
1574 class LLoadNamedField FINAL : public LTemplateInstruction<1, 1, 0> {
1576 explicit LLoadNamedField(LOperand* object) {
1577 inputs_[0] = object;
1580 LOperand* object() { return inputs_[0]; }
1582 DECLARE_CONCRETE_INSTRUCTION(LoadNamedField, "load-named-field")
1583 DECLARE_HYDROGEN_ACCESSOR(LoadNamedField)
1587 class LLoadNamedGeneric FINAL : public LTemplateInstruction<1, 2, 1> {
1589 LLoadNamedGeneric(LOperand* context, LOperand* object, LOperand* vector) {
1590 inputs_[0] = context;
1591 inputs_[1] = object;
1595 LOperand* context() { return inputs_[0]; }
1596 LOperand* object() { return inputs_[1]; }
1597 LOperand* temp_vector() { return temps_[0]; }
1599 DECLARE_CONCRETE_INSTRUCTION(LoadNamedGeneric, "load-named-generic")
1600 DECLARE_HYDROGEN_ACCESSOR(LoadNamedGeneric)
1602 Handle<Object> name() const { return hydrogen()->name(); }
1606 class LLoadFunctionPrototype FINAL : public LTemplateInstruction<1, 1, 0> {
1608 explicit LLoadFunctionPrototype(LOperand* function) {
1609 inputs_[0] = function;
1612 LOperand* function() { return inputs_[0]; }
1614 DECLARE_CONCRETE_INSTRUCTION(LoadFunctionPrototype, "load-function-prototype")
1615 DECLARE_HYDROGEN_ACCESSOR(LoadFunctionPrototype)
1619 class LLoadRoot FINAL : public LTemplateInstruction<1, 0, 0> {
1621 DECLARE_CONCRETE_INSTRUCTION(LoadRoot, "load-root")
1622 DECLARE_HYDROGEN_ACCESSOR(LoadRoot)
1624 Heap::RootListIndex index() const { return hydrogen()->index(); }
1628 class LLoadKeyed FINAL : public LTemplateInstruction<1, 2, 0> {
1630 LLoadKeyed(LOperand* elements, LOperand* key) {
1631 inputs_[0] = elements;
1635 LOperand* elements() { return inputs_[0]; }
1636 LOperand* key() { return inputs_[1]; }
1637 ElementsKind elements_kind() const {
1638 return hydrogen()->elements_kind();
1640 bool is_external() const {
1641 return hydrogen()->is_external();
1643 bool is_fixed_typed_array() const {
1644 return hydrogen()->is_fixed_typed_array();
1646 bool is_typed_elements() const {
1647 return is_external() || is_fixed_typed_array();
1650 DECLARE_CONCRETE_INSTRUCTION(LoadKeyed, "load-keyed")
1651 DECLARE_HYDROGEN_ACCESSOR(LoadKeyed)
1653 virtual void PrintDataTo(StringStream* stream);
1654 uint32_t base_offset() const { return hydrogen()->base_offset(); }
1658 class LLoadKeyedGeneric FINAL : public LTemplateInstruction<1, 3, 1> {
1660 LLoadKeyedGeneric(LOperand* context, LOperand* object, LOperand* key,
1662 inputs_[0] = context;
1663 inputs_[1] = object;
1668 LOperand* context() { return inputs_[0]; }
1669 LOperand* object() { return inputs_[1]; }
1670 LOperand* key() { return inputs_[2]; }
1671 LOperand* temp_vector() { return temps_[0]; }
1673 DECLARE_CONCRETE_INSTRUCTION(LoadKeyedGeneric, "load-keyed-generic")
1674 DECLARE_HYDROGEN_ACCESSOR(LoadKeyedGeneric)
1678 class LLoadGlobalCell FINAL : public LTemplateInstruction<1, 0, 0> {
1680 DECLARE_CONCRETE_INSTRUCTION(LoadGlobalCell, "load-global-cell")
1681 DECLARE_HYDROGEN_ACCESSOR(LoadGlobalCell)
1685 class LLoadGlobalGeneric FINAL : public LTemplateInstruction<1, 2, 1> {
1687 LLoadGlobalGeneric(LOperand* context, LOperand* global_object,
1689 inputs_[0] = context;
1690 inputs_[1] = global_object;
1694 LOperand* context() { return inputs_[0]; }
1695 LOperand* global_object() { return inputs_[1]; }
1696 LOperand* temp_vector() { return temps_[0]; }
1698 DECLARE_CONCRETE_INSTRUCTION(LoadGlobalGeneric, "load-global-generic")
1699 DECLARE_HYDROGEN_ACCESSOR(LoadGlobalGeneric)
1701 Handle<Object> name() const { return hydrogen()->name(); }
1702 bool for_typeof() const { return hydrogen()->for_typeof(); }
1706 class LStoreGlobalCell FINAL : public LTemplateInstruction<0, 1, 1> {
1708 LStoreGlobalCell(LOperand* value, LOperand* temp) {
1713 LOperand* value() { return inputs_[0]; }
1714 LOperand* temp() { return temps_[0]; }
1716 DECLARE_CONCRETE_INSTRUCTION(StoreGlobalCell, "store-global-cell")
1717 DECLARE_HYDROGEN_ACCESSOR(StoreGlobalCell)
1721 class LLoadContextSlot FINAL : public LTemplateInstruction<1, 1, 0> {
1723 explicit LLoadContextSlot(LOperand* context) {
1724 inputs_[0] = context;
1727 LOperand* context() { return inputs_[0]; }
1729 DECLARE_CONCRETE_INSTRUCTION(LoadContextSlot, "load-context-slot")
1730 DECLARE_HYDROGEN_ACCESSOR(LoadContextSlot)
1732 int slot_index() { return hydrogen()->slot_index(); }
1734 virtual void PrintDataTo(StringStream* stream);
1738 class LStoreContextSlot FINAL : public LTemplateInstruction<0, 2, 0> {
1740 LStoreContextSlot(LOperand* context, LOperand* value) {
1741 inputs_[0] = context;
1745 LOperand* context() { return inputs_[0]; }
1746 LOperand* value() { return inputs_[1]; }
1748 DECLARE_CONCRETE_INSTRUCTION(StoreContextSlot, "store-context-slot")
1749 DECLARE_HYDROGEN_ACCESSOR(StoreContextSlot)
1751 int slot_index() { return hydrogen()->slot_index(); }
1753 virtual void PrintDataTo(StringStream* stream) OVERRIDE;
1757 class LPushArgument FINAL : public LTemplateInstruction<0, 1, 0> {
1759 explicit LPushArgument(LOperand* value) {
1763 LOperand* value() { return inputs_[0]; }
1765 DECLARE_CONCRETE_INSTRUCTION(PushArgument, "push-argument")
1769 class LDrop FINAL : public LTemplateInstruction<0, 0, 0> {
1771 explicit LDrop(int count) : count_(count) { }
1773 int count() const { return count_; }
1775 DECLARE_CONCRETE_INSTRUCTION(Drop, "drop")
1782 class LStoreCodeEntry FINAL: public LTemplateInstruction<0, 2, 0> {
1784 LStoreCodeEntry(LOperand* function, LOperand* code_object) {
1785 inputs_[0] = function;
1786 inputs_[1] = code_object;
1789 LOperand* function() { return inputs_[0]; }
1790 LOperand* code_object() { return inputs_[1]; }
1792 virtual void PrintDataTo(StringStream* stream);
1794 DECLARE_CONCRETE_INSTRUCTION(StoreCodeEntry, "store-code-entry")
1795 DECLARE_HYDROGEN_ACCESSOR(StoreCodeEntry)
1799 class LInnerAllocatedObject FINAL: public LTemplateInstruction<1, 2, 0> {
1801 LInnerAllocatedObject(LOperand* base_object, LOperand* offset) {
1802 inputs_[0] = base_object;
1803 inputs_[1] = offset;
1806 LOperand* base_object() const { return inputs_[0]; }
1807 LOperand* offset() const { return inputs_[1]; }
1809 virtual void PrintDataTo(StringStream* stream) OVERRIDE;
1811 DECLARE_CONCRETE_INSTRUCTION(InnerAllocatedObject, "inner-allocated-object")
1815 class LThisFunction FINAL : public LTemplateInstruction<1, 0, 0> {
1817 DECLARE_CONCRETE_INSTRUCTION(ThisFunction, "this-function")
1818 DECLARE_HYDROGEN_ACCESSOR(ThisFunction)
1822 class LContext FINAL : public LTemplateInstruction<1, 0, 0> {
1824 DECLARE_CONCRETE_INSTRUCTION(Context, "context")
1825 DECLARE_HYDROGEN_ACCESSOR(Context)
1829 class LDeclareGlobals FINAL : public LTemplateInstruction<0, 1, 0> {
1831 explicit LDeclareGlobals(LOperand* context) {
1832 inputs_[0] = context;
1835 LOperand* context() { return inputs_[0]; }
1837 DECLARE_CONCRETE_INSTRUCTION(DeclareGlobals, "declare-globals")
1838 DECLARE_HYDROGEN_ACCESSOR(DeclareGlobals)
1842 class LCallJSFunction FINAL : public LTemplateInstruction<1, 1, 0> {
1844 explicit LCallJSFunction(LOperand* function) {
1845 inputs_[0] = function;
1848 LOperand* function() { return inputs_[0]; }
1850 DECLARE_CONCRETE_INSTRUCTION(CallJSFunction, "call-js-function")
1851 DECLARE_HYDROGEN_ACCESSOR(CallJSFunction)
1853 virtual void PrintDataTo(StringStream* stream) OVERRIDE;
1855 int arity() const { return hydrogen()->argument_count() - 1; }
1859 class LCallWithDescriptor FINAL : public LTemplateResultInstruction<1> {
1861 LCallWithDescriptor(CallInterfaceDescriptor descriptor,
1862 const ZoneList<LOperand*>& operands, Zone* zone)
1863 : descriptor_(descriptor),
1864 inputs_(descriptor.GetRegisterParameterCount() + 1, zone) {
1865 DCHECK(descriptor.GetRegisterParameterCount() + 1 == operands.length());
1866 inputs_.AddAll(operands, zone);
1869 LOperand* target() const { return inputs_[0]; }
1871 const CallInterfaceDescriptor descriptor() { return descriptor_; }
1874 DECLARE_CONCRETE_INSTRUCTION(CallWithDescriptor, "call-with-descriptor")
1875 DECLARE_HYDROGEN_ACCESSOR(CallWithDescriptor)
1877 virtual void PrintDataTo(StringStream* stream) OVERRIDE;
1879 int arity() const { return hydrogen()->argument_count() - 1; }
1881 CallInterfaceDescriptor descriptor_;
1882 ZoneList<LOperand*> inputs_;
1884 // Iterator support.
1885 virtual int InputCount() FINAL OVERRIDE { return inputs_.length(); }
1886 virtual LOperand* InputAt(int i) FINAL OVERRIDE { return inputs_[i]; }
1888 virtual int TempCount() FINAL OVERRIDE { return 0; }
1889 virtual LOperand* TempAt(int i) FINAL OVERRIDE { return NULL; }
1894 class LInvokeFunction FINAL : public LTemplateInstruction<1, 2, 0> {
1896 LInvokeFunction(LOperand* context, LOperand* function) {
1897 inputs_[0] = context;
1898 inputs_[1] = function;
1901 LOperand* context() { return inputs_[0]; }
1902 LOperand* function() { return inputs_[1]; }
1904 DECLARE_CONCRETE_INSTRUCTION(InvokeFunction, "invoke-function")
1905 DECLARE_HYDROGEN_ACCESSOR(InvokeFunction)
1907 virtual void PrintDataTo(StringStream* stream) OVERRIDE;
1909 int arity() const { return hydrogen()->argument_count() - 1; }
1913 class LCallFunction FINAL : public LTemplateInstruction<1, 2, 0> {
1915 LCallFunction(LOperand* context, LOperand* function) {
1916 inputs_[0] = context;
1917 inputs_[1] = function;
1920 LOperand* context() { return inputs_[0]; }
1921 LOperand* function() { return inputs_[1]; }
1923 DECLARE_CONCRETE_INSTRUCTION(CallFunction, "call-function")
1924 DECLARE_HYDROGEN_ACCESSOR(CallFunction)
1926 int arity() const { return hydrogen()->argument_count() - 1; }
1930 class LCallNew FINAL : public LTemplateInstruction<1, 2, 0> {
1932 LCallNew(LOperand* context, LOperand* constructor) {
1933 inputs_[0] = context;
1934 inputs_[1] = constructor;
1937 LOperand* context() { return inputs_[0]; }
1938 LOperand* constructor() { return inputs_[1]; }
1940 DECLARE_CONCRETE_INSTRUCTION(CallNew, "call-new")
1941 DECLARE_HYDROGEN_ACCESSOR(CallNew)
1943 virtual void PrintDataTo(StringStream* stream) OVERRIDE;
1945 int arity() const { return hydrogen()->argument_count() - 1; }
1949 class LCallNewArray FINAL : public LTemplateInstruction<1, 2, 0> {
1951 LCallNewArray(LOperand* context, LOperand* constructor) {
1952 inputs_[0] = context;
1953 inputs_[1] = constructor;
1956 LOperand* context() { return inputs_[0]; }
1957 LOperand* constructor() { return inputs_[1]; }
1959 DECLARE_CONCRETE_INSTRUCTION(CallNewArray, "call-new-array")
1960 DECLARE_HYDROGEN_ACCESSOR(CallNewArray)
1962 virtual void PrintDataTo(StringStream* stream) OVERRIDE;
1964 int arity() const { return hydrogen()->argument_count() - 1; }
1968 class LCallRuntime FINAL : public LTemplateInstruction<1, 1, 0> {
1970 explicit LCallRuntime(LOperand* context) {
1971 inputs_[0] = context;
1974 LOperand* context() { return inputs_[0]; }
1976 DECLARE_CONCRETE_INSTRUCTION(CallRuntime, "call-runtime")
1977 DECLARE_HYDROGEN_ACCESSOR(CallRuntime)
1979 virtual bool ClobbersDoubleRegisters(Isolate* isolate) const OVERRIDE {
1980 return save_doubles() == kDontSaveFPRegs;
1983 const Runtime::Function* function() const { return hydrogen()->function(); }
1984 int arity() const { return hydrogen()->argument_count(); }
1985 SaveFPRegsMode save_doubles() const { return hydrogen()->save_doubles(); }
1989 class LInteger32ToDouble FINAL : public LTemplateInstruction<1, 1, 0> {
1991 explicit LInteger32ToDouble(LOperand* value) {
1995 LOperand* value() { return inputs_[0]; }
1997 DECLARE_CONCRETE_INSTRUCTION(Integer32ToDouble, "int32-to-double")
2001 class LUint32ToDouble FINAL : public LTemplateInstruction<1, 1, 0> {
2003 explicit LUint32ToDouble(LOperand* value) {
2007 LOperand* value() { return inputs_[0]; }
2009 DECLARE_CONCRETE_INSTRUCTION(Uint32ToDouble, "uint32-to-double")
2013 class LNumberTagU FINAL : public LTemplateInstruction<1, 1, 2> {
2015 LNumberTagU(LOperand* value, LOperand* temp1, LOperand* temp2) {
2021 LOperand* value() { return inputs_[0]; }
2022 LOperand* temp1() { return temps_[0]; }
2023 LOperand* temp2() { return temps_[1]; }
2025 DECLARE_CONCRETE_INSTRUCTION(NumberTagU, "number-tag-u")
2029 class LNumberTagD FINAL : public LTemplateInstruction<1, 1, 2> {
2031 LNumberTagD(LOperand* value, LOperand* temp, LOperand* temp2) {
2037 LOperand* value() { return inputs_[0]; }
2038 LOperand* temp() { return temps_[0]; }
2039 LOperand* temp2() { return temps_[1]; }
2041 DECLARE_CONCRETE_INSTRUCTION(NumberTagD, "number-tag-d")
2042 DECLARE_HYDROGEN_ACCESSOR(Change)
2046 class LDoubleToSmi FINAL : public LTemplateInstruction<1, 1, 0> {
2048 explicit LDoubleToSmi(LOperand* value) {
2052 LOperand* value() { return inputs_[0]; }
2054 DECLARE_CONCRETE_INSTRUCTION(DoubleToSmi, "double-to-smi")
2055 DECLARE_HYDROGEN_ACCESSOR(UnaryOperation)
2057 bool truncating() { return hydrogen()->CanTruncateToInt32(); }
2061 // Sometimes truncating conversion from a tagged value to an int32.
2062 class LDoubleToI FINAL : public LTemplateInstruction<1, 1, 0> {
2064 explicit LDoubleToI(LOperand* value) {
2068 LOperand* value() { return inputs_[0]; }
2070 DECLARE_CONCRETE_INSTRUCTION(DoubleToI, "double-to-i")
2071 DECLARE_HYDROGEN_ACCESSOR(UnaryOperation)
2073 bool truncating() { return hydrogen()->CanTruncateToInt32(); }
2077 // Truncating conversion from a tagged value to an int32.
2078 class LTaggedToI FINAL : public LTemplateInstruction<1, 1, 2> {
2080 LTaggedToI(LOperand* value,
2088 LOperand* value() { return inputs_[0]; }
2089 LOperand* temp() { return temps_[0]; }
2090 LOperand* temp2() { return temps_[1]; }
2092 DECLARE_CONCRETE_INSTRUCTION(TaggedToI, "tagged-to-i")
2093 DECLARE_HYDROGEN_ACCESSOR(Change)
2095 bool truncating() { return hydrogen()->CanTruncateToInt32(); }
2099 class LSmiTag FINAL : public LTemplateInstruction<1, 1, 0> {
2101 explicit LSmiTag(LOperand* value) {
2105 LOperand* value() { return inputs_[0]; }
2107 DECLARE_CONCRETE_INSTRUCTION(SmiTag, "smi-tag")
2108 DECLARE_HYDROGEN_ACCESSOR(Change)
2112 class LNumberUntagD FINAL : public LTemplateInstruction<1, 1, 0> {
2114 explicit LNumberUntagD(LOperand* value) {
2118 LOperand* value() { return inputs_[0]; }
2120 DECLARE_CONCRETE_INSTRUCTION(NumberUntagD, "double-untag")
2121 DECLARE_HYDROGEN_ACCESSOR(Change)
2125 class LSmiUntag FINAL : public LTemplateInstruction<1, 1, 0> {
2127 LSmiUntag(LOperand* value, bool needs_check)
2128 : needs_check_(needs_check) {
2132 LOperand* value() { return inputs_[0]; }
2133 bool needs_check() const { return needs_check_; }
2135 DECLARE_CONCRETE_INSTRUCTION(SmiUntag, "smi-untag")
2142 class LStoreNamedField FINAL : public LTemplateInstruction<0, 2, 1> {
2144 LStoreNamedField(LOperand* object, LOperand* value, LOperand* temp) {
2145 inputs_[0] = object;
2150 LOperand* object() { return inputs_[0]; }
2151 LOperand* value() { return inputs_[1]; }
2152 LOperand* temp() { return temps_[0]; }
2154 DECLARE_CONCRETE_INSTRUCTION(StoreNamedField, "store-named-field")
2155 DECLARE_HYDROGEN_ACCESSOR(StoreNamedField)
2157 virtual void PrintDataTo(StringStream* stream) OVERRIDE;
2159 Representation representation() const {
2160 return hydrogen()->field_representation();
2165 class LStoreNamedGeneric FINAL : public LTemplateInstruction<0, 3, 0> {
2167 LStoreNamedGeneric(LOperand* context, LOperand* object, LOperand* value) {
2168 inputs_[0] = context;
2169 inputs_[1] = object;
2173 LOperand* context() { return inputs_[0]; }
2174 LOperand* object() { return inputs_[1]; }
2175 LOperand* value() { return inputs_[2]; }
2177 DECLARE_CONCRETE_INSTRUCTION(StoreNamedGeneric, "store-named-generic")
2178 DECLARE_HYDROGEN_ACCESSOR(StoreNamedGeneric)
2180 virtual void PrintDataTo(StringStream* stream) OVERRIDE;
2182 Handle<Object> name() const { return hydrogen()->name(); }
2183 StrictMode strict_mode() { return hydrogen()->strict_mode(); }
2187 class LStoreKeyed FINAL : public LTemplateInstruction<0, 3, 0> {
2189 LStoreKeyed(LOperand* object, LOperand* key, LOperand* value) {
2190 inputs_[0] = object;
2195 bool is_external() const { return hydrogen()->is_external(); }
2196 bool is_fixed_typed_array() const {
2197 return hydrogen()->is_fixed_typed_array();
2199 bool is_typed_elements() const {
2200 return is_external() || is_fixed_typed_array();
2202 LOperand* elements() { return inputs_[0]; }
2203 LOperand* key() { return inputs_[1]; }
2204 LOperand* value() { return inputs_[2]; }
2205 ElementsKind elements_kind() const {
2206 return hydrogen()->elements_kind();
2209 DECLARE_CONCRETE_INSTRUCTION(StoreKeyed, "store-keyed")
2210 DECLARE_HYDROGEN_ACCESSOR(StoreKeyed)
2212 virtual void PrintDataTo(StringStream* stream) OVERRIDE;
2213 bool NeedsCanonicalization() { return hydrogen()->NeedsCanonicalization(); }
2214 uint32_t base_offset() const { return hydrogen()->base_offset(); }
2218 class LStoreKeyedGeneric FINAL : public LTemplateInstruction<0, 4, 0> {
2220 LStoreKeyedGeneric(LOperand* context,
2224 inputs_[0] = context;
2230 LOperand* context() { return inputs_[0]; }
2231 LOperand* object() { return inputs_[1]; }
2232 LOperand* key() { return inputs_[2]; }
2233 LOperand* value() { return inputs_[3]; }
2235 DECLARE_CONCRETE_INSTRUCTION(StoreKeyedGeneric, "store-keyed-generic")
2236 DECLARE_HYDROGEN_ACCESSOR(StoreKeyedGeneric)
2238 virtual void PrintDataTo(StringStream* stream) OVERRIDE;
2240 StrictMode strict_mode() { return hydrogen()->strict_mode(); }
2244 class LTransitionElementsKind FINAL : public LTemplateInstruction<0, 2, 1> {
2246 LTransitionElementsKind(LOperand* object,
2248 LOperand* new_map_temp) {
2249 inputs_[0] = object;
2250 inputs_[1] = context;
2251 temps_[0] = new_map_temp;
2254 LOperand* context() { return inputs_[1]; }
2255 LOperand* object() { return inputs_[0]; }
2256 LOperand* new_map_temp() { return temps_[0]; }
2258 DECLARE_CONCRETE_INSTRUCTION(TransitionElementsKind,
2259 "transition-elements-kind")
2260 DECLARE_HYDROGEN_ACCESSOR(TransitionElementsKind)
2262 virtual void PrintDataTo(StringStream* stream) OVERRIDE;
2264 Handle<Map> original_map() { return hydrogen()->original_map().handle(); }
2265 Handle<Map> transitioned_map() {
2266 return hydrogen()->transitioned_map().handle();
2268 ElementsKind from_kind() { return hydrogen()->from_kind(); }
2269 ElementsKind to_kind() { return hydrogen()->to_kind(); }
2273 class LTrapAllocationMemento FINAL : public LTemplateInstruction<0, 1, 1> {
2275 LTrapAllocationMemento(LOperand* object,
2277 inputs_[0] = object;
2281 LOperand* object() { return inputs_[0]; }
2282 LOperand* temp() { return temps_[0]; }
2284 DECLARE_CONCRETE_INSTRUCTION(TrapAllocationMemento,
2285 "trap-allocation-memento")
2289 class LStringAdd FINAL : public LTemplateInstruction<1, 3, 0> {
2291 LStringAdd(LOperand* context, LOperand* left, LOperand* right) {
2292 inputs_[0] = context;
2297 LOperand* context() { return inputs_[0]; }
2298 LOperand* left() { return inputs_[1]; }
2299 LOperand* right() { return inputs_[2]; }
2301 DECLARE_CONCRETE_INSTRUCTION(StringAdd, "string-add")
2302 DECLARE_HYDROGEN_ACCESSOR(StringAdd)
2307 class LStringCharCodeAt FINAL : public LTemplateInstruction<1, 3, 0> {
2309 LStringCharCodeAt(LOperand* context, LOperand* string, LOperand* index) {
2310 inputs_[0] = context;
2311 inputs_[1] = string;
2315 LOperand* context() { return inputs_[0]; }
2316 LOperand* string() { return inputs_[1]; }
2317 LOperand* index() { return inputs_[2]; }
2319 DECLARE_CONCRETE_INSTRUCTION(StringCharCodeAt, "string-char-code-at")
2320 DECLARE_HYDROGEN_ACCESSOR(StringCharCodeAt)
2324 class LStringCharFromCode FINAL : public LTemplateInstruction<1, 2, 0> {
2326 explicit LStringCharFromCode(LOperand* context, LOperand* char_code) {
2327 inputs_[0] = context;
2328 inputs_[1] = char_code;
2331 LOperand* context() { return inputs_[0]; }
2332 LOperand* char_code() { return inputs_[1]; }
2334 DECLARE_CONCRETE_INSTRUCTION(StringCharFromCode, "string-char-from-code")
2335 DECLARE_HYDROGEN_ACCESSOR(StringCharFromCode)
2339 class LCheckValue FINAL : public LTemplateInstruction<0, 1, 0> {
2341 explicit LCheckValue(LOperand* value) {
2345 LOperand* value() { return inputs_[0]; }
2347 DECLARE_CONCRETE_INSTRUCTION(CheckValue, "check-value")
2348 DECLARE_HYDROGEN_ACCESSOR(CheckValue)
2352 class LCheckInstanceType FINAL : public LTemplateInstruction<0, 1, 0> {
2354 explicit LCheckInstanceType(LOperand* value) {
2358 LOperand* value() { return inputs_[0]; }
2360 DECLARE_CONCRETE_INSTRUCTION(CheckInstanceType, "check-instance-type")
2361 DECLARE_HYDROGEN_ACCESSOR(CheckInstanceType)
2365 class LCheckMaps FINAL : public LTemplateInstruction<0, 1, 0> {
2367 explicit LCheckMaps(LOperand* value = NULL) {
2371 LOperand* value() { return inputs_[0]; }
2373 DECLARE_CONCRETE_INSTRUCTION(CheckMaps, "check-maps")
2374 DECLARE_HYDROGEN_ACCESSOR(CheckMaps)
2378 class LCheckSmi FINAL : public LTemplateInstruction<1, 1, 0> {
2380 explicit LCheckSmi(LOperand* value) {
2384 LOperand* value() { return inputs_[0]; }
2386 DECLARE_CONCRETE_INSTRUCTION(CheckSmi, "check-smi")
2390 class LCheckNonSmi FINAL : public LTemplateInstruction<0, 1, 0> {
2392 explicit LCheckNonSmi(LOperand* value) {
2396 LOperand* value() { return inputs_[0]; }
2398 DECLARE_CONCRETE_INSTRUCTION(CheckNonSmi, "check-non-smi")
2399 DECLARE_HYDROGEN_ACCESSOR(CheckHeapObject)
2403 class LClampDToUint8 FINAL : public LTemplateInstruction<1, 1, 1> {
2405 LClampDToUint8(LOperand* unclamped, LOperand* temp) {
2406 inputs_[0] = unclamped;
2410 LOperand* unclamped() { return inputs_[0]; }
2411 LOperand* temp() { return temps_[0]; }
2413 DECLARE_CONCRETE_INSTRUCTION(ClampDToUint8, "clamp-d-to-uint8")
2417 class LClampIToUint8 FINAL : public LTemplateInstruction<1, 1, 0> {
2419 explicit LClampIToUint8(LOperand* unclamped) {
2420 inputs_[0] = unclamped;
2423 LOperand* unclamped() { return inputs_[0]; }
2425 DECLARE_CONCRETE_INSTRUCTION(ClampIToUint8, "clamp-i-to-uint8")
2429 class LClampTToUint8 FINAL : public LTemplateInstruction<1, 1, 1> {
2431 LClampTToUint8(LOperand* unclamped, LOperand* temp) {
2432 inputs_[0] = unclamped;
2436 LOperand* unclamped() { return inputs_[0]; }
2437 LOperand* temp() { return temps_[0]; }
2439 DECLARE_CONCRETE_INSTRUCTION(ClampTToUint8, "clamp-t-to-uint8")
2443 class LDoubleBits FINAL : public LTemplateInstruction<1, 1, 0> {
2445 explicit LDoubleBits(LOperand* value) {
2449 LOperand* value() { return inputs_[0]; }
2451 DECLARE_CONCRETE_INSTRUCTION(DoubleBits, "double-bits")
2452 DECLARE_HYDROGEN_ACCESSOR(DoubleBits)
2456 class LConstructDouble FINAL : public LTemplateInstruction<1, 2, 0> {
2458 LConstructDouble(LOperand* hi, LOperand* lo) {
2463 LOperand* hi() { return inputs_[0]; }
2464 LOperand* lo() { return inputs_[1]; }
2466 DECLARE_CONCRETE_INSTRUCTION(ConstructDouble, "construct-double")
2470 class LAllocate FINAL : public LTemplateInstruction<1, 2, 2> {
2472 LAllocate(LOperand* context,
2476 inputs_[0] = context;
2482 LOperand* context() { return inputs_[0]; }
2483 LOperand* size() { return inputs_[1]; }
2484 LOperand* temp1() { return temps_[0]; }
2485 LOperand* temp2() { return temps_[1]; }
2487 DECLARE_CONCRETE_INSTRUCTION(Allocate, "allocate")
2488 DECLARE_HYDROGEN_ACCESSOR(Allocate)
2492 class LRegExpLiteral FINAL : public LTemplateInstruction<1, 1, 0> {
2494 explicit LRegExpLiteral(LOperand* context) {
2495 inputs_[0] = context;
2498 LOperand* context() { return inputs_[0]; }
2500 DECLARE_CONCRETE_INSTRUCTION(RegExpLiteral, "regexp-literal")
2501 DECLARE_HYDROGEN_ACCESSOR(RegExpLiteral)
2505 class LFunctionLiteral FINAL : public LTemplateInstruction<1, 1, 0> {
2507 explicit LFunctionLiteral(LOperand* context) {
2508 inputs_[0] = context;
2511 LOperand* context() { return inputs_[0]; }
2513 DECLARE_CONCRETE_INSTRUCTION(FunctionLiteral, "function-literal")
2514 DECLARE_HYDROGEN_ACCESSOR(FunctionLiteral)
2518 class LToFastProperties FINAL : public LTemplateInstruction<1, 1, 0> {
2520 explicit LToFastProperties(LOperand* value) {
2524 LOperand* value() { return inputs_[0]; }
2526 DECLARE_CONCRETE_INSTRUCTION(ToFastProperties, "to-fast-properties")
2527 DECLARE_HYDROGEN_ACCESSOR(ToFastProperties)
2531 class LTypeof FINAL : public LTemplateInstruction<1, 2, 0> {
2533 LTypeof(LOperand* context, LOperand* value) {
2534 inputs_[0] = context;
2538 LOperand* context() { return inputs_[0]; }
2539 LOperand* value() { return inputs_[1]; }
2541 DECLARE_CONCRETE_INSTRUCTION(Typeof, "typeof")
2545 class LTypeofIsAndBranch FINAL : public LControlInstruction<1, 0> {
2547 explicit LTypeofIsAndBranch(LOperand* value) {
2551 LOperand* value() { return inputs_[0]; }
2553 DECLARE_CONCRETE_INSTRUCTION(TypeofIsAndBranch, "typeof-is-and-branch")
2554 DECLARE_HYDROGEN_ACCESSOR(TypeofIsAndBranch)
2556 Handle<String> type_literal() { return hydrogen()->type_literal(); }
2558 virtual void PrintDataTo(StringStream* stream) OVERRIDE;
2562 class LIsConstructCallAndBranch FINAL : public LControlInstruction<0, 1> {
2564 explicit LIsConstructCallAndBranch(LOperand* temp) {
2568 LOperand* temp() { return temps_[0]; }
2570 DECLARE_CONCRETE_INSTRUCTION(IsConstructCallAndBranch,
2571 "is-construct-call-and-branch")
2575 class LOsrEntry FINAL : public LTemplateInstruction<0, 0, 0> {
2579 virtual bool HasInterestingComment(LCodeGen* gen) const OVERRIDE {
2582 DECLARE_CONCRETE_INSTRUCTION(OsrEntry, "osr-entry")
2586 class LStackCheck FINAL : public LTemplateInstruction<0, 1, 0> {
2588 explicit LStackCheck(LOperand* context) {
2589 inputs_[0] = context;
2592 LOperand* context() { return inputs_[0]; }
2594 DECLARE_CONCRETE_INSTRUCTION(StackCheck, "stack-check")
2595 DECLARE_HYDROGEN_ACCESSOR(StackCheck)
2597 Label* done_label() { return &done_label_; }
2604 class LForInPrepareMap FINAL : public LTemplateInstruction<1, 2, 0> {
2606 LForInPrepareMap(LOperand* context, LOperand* object) {
2607 inputs_[0] = context;
2608 inputs_[1] = object;
2611 LOperand* context() { return inputs_[0]; }
2612 LOperand* object() { return inputs_[1]; }
2614 DECLARE_CONCRETE_INSTRUCTION(ForInPrepareMap, "for-in-prepare-map")
2618 class LForInCacheArray FINAL : public LTemplateInstruction<1, 1, 0> {
2620 explicit LForInCacheArray(LOperand* map) {
2624 LOperand* map() { return inputs_[0]; }
2626 DECLARE_CONCRETE_INSTRUCTION(ForInCacheArray, "for-in-cache-array")
2629 return HForInCacheArray::cast(this->hydrogen_value())->idx();
2634 class LCheckMapValue FINAL : public LTemplateInstruction<0, 2, 0> {
2636 LCheckMapValue(LOperand* value, LOperand* map) {
2641 LOperand* value() { return inputs_[0]; }
2642 LOperand* map() { return inputs_[1]; }
2644 DECLARE_CONCRETE_INSTRUCTION(CheckMapValue, "check-map-value")
2648 class LLoadFieldByIndex FINAL : public LTemplateInstruction<1, 2, 0> {
2650 LLoadFieldByIndex(LOperand* object, LOperand* index) {
2651 inputs_[0] = object;
2655 LOperand* object() { return inputs_[0]; }
2656 LOperand* index() { return inputs_[1]; }
2658 DECLARE_CONCRETE_INSTRUCTION(LoadFieldByIndex, "load-field-by-index")
2662 class LStoreFrameContext: public LTemplateInstruction<0, 1, 0> {
2664 explicit LStoreFrameContext(LOperand* context) {
2665 inputs_[0] = context;
2668 LOperand* context() { return inputs_[0]; }
2670 DECLARE_CONCRETE_INSTRUCTION(StoreFrameContext, "store-frame-context")
2674 class LAllocateBlockContext: public LTemplateInstruction<1, 2, 0> {
2676 LAllocateBlockContext(LOperand* context, LOperand* function) {
2677 inputs_[0] = context;
2678 inputs_[1] = function;
2681 LOperand* context() { return inputs_[0]; }
2682 LOperand* function() { return inputs_[1]; }
2684 Handle<ScopeInfo> scope_info() { return hydrogen()->scope_info(); }
2686 DECLARE_CONCRETE_INSTRUCTION(AllocateBlockContext, "allocate-block-context")
2687 DECLARE_HYDROGEN_ACCESSOR(AllocateBlockContext)
2691 class LChunkBuilder;
2692 class LPlatformChunk FINAL : public LChunk {
2694 LPlatformChunk(CompilationInfo* info, HGraph* graph)
2695 : LChunk(info, graph) { }
2697 int GetNextSpillIndex(RegisterKind kind);
2698 LOperand* GetNextSpillSlot(RegisterKind kind);
2702 class LChunkBuilder FINAL : public LChunkBuilderBase {
2704 LChunkBuilder(CompilationInfo* info, HGraph* graph, LAllocator* allocator)
2705 : LChunkBuilderBase(info, graph),
2706 current_instruction_(NULL),
2707 current_block_(NULL),
2709 allocator_(allocator) {}
2711 // Build the sequence for the graph.
2712 LPlatformChunk* Build();
2714 // Declare methods that deal with the individual node types.
2715 #define DECLARE_DO(type) LInstruction* Do##type(H##type* node);
2716 HYDROGEN_CONCRETE_INSTRUCTION_LIST(DECLARE_DO)
2719 LInstruction* DoMultiplyAdd(HMul* mul, HValue* addend);
2721 static bool HasMagicNumberForDivisor(int32_t divisor);
2723 LInstruction* DoMathFloor(HUnaryMathOperation* instr);
2724 LInstruction* DoMathRound(HUnaryMathOperation* instr);
2725 LInstruction* DoMathFround(HUnaryMathOperation* instr);
2726 LInstruction* DoMathAbs(HUnaryMathOperation* instr);
2727 LInstruction* DoMathLog(HUnaryMathOperation* instr);
2728 LInstruction* DoMathExp(HUnaryMathOperation* instr);
2729 LInstruction* DoMathSqrt(HUnaryMathOperation* instr);
2730 LInstruction* DoMathPowHalf(HUnaryMathOperation* instr);
2731 LInstruction* DoMathClz32(HUnaryMathOperation* instr);
2732 LInstruction* DoDivByPowerOf2I(HDiv* instr);
2733 LInstruction* DoDivByConstI(HDiv* instr);
2734 LInstruction* DoDivI(HDiv* instr);
2735 LInstruction* DoModByPowerOf2I(HMod* instr);
2736 LInstruction* DoModByConstI(HMod* instr);
2737 LInstruction* DoModI(HMod* instr);
2738 LInstruction* DoFlooringDivByPowerOf2I(HMathFloorOfDiv* instr);
2739 LInstruction* DoFlooringDivByConstI(HMathFloorOfDiv* instr);
2740 LInstruction* DoFlooringDivI(HMathFloorOfDiv* instr);
2743 // Methods for getting operands for Use / Define / Temp.
2744 LUnallocated* ToUnallocated(Register reg);
2745 LUnallocated* ToUnallocated(DoubleRegister reg);
2747 // Methods for setting up define-use relationships.
2748 MUST_USE_RESULT LOperand* Use(HValue* value, LUnallocated* operand);
2749 MUST_USE_RESULT LOperand* UseFixed(HValue* value, Register fixed_register);
2750 MUST_USE_RESULT LOperand* UseFixedDouble(HValue* value,
2751 DoubleRegister fixed_register);
2753 // A value that is guaranteed to be allocated to a register.
2754 // Operand created by UseRegister is guaranteed to be live until the end of
2755 // instruction. This means that register allocator will not reuse it's
2756 // register for any other operand inside instruction.
2757 // Operand created by UseRegisterAtStart is guaranteed to be live only at
2758 // instruction start. Register allocator is free to assign the same register
2759 // to some other operand used inside instruction (i.e. temporary or
2761 MUST_USE_RESULT LOperand* UseRegister(HValue* value);
2762 MUST_USE_RESULT LOperand* UseRegisterAtStart(HValue* value);
2764 // An input operand in a register that may be trashed.
2765 MUST_USE_RESULT LOperand* UseTempRegister(HValue* value);
2767 // An input operand in a register or stack slot.
2768 MUST_USE_RESULT LOperand* Use(HValue* value);
2769 MUST_USE_RESULT LOperand* UseAtStart(HValue* value);
2771 // An input operand in a register, stack slot or a constant operand.
2772 MUST_USE_RESULT LOperand* UseOrConstant(HValue* value);
2773 MUST_USE_RESULT LOperand* UseOrConstantAtStart(HValue* value);
2775 // An input operand in a register or a constant operand.
2776 MUST_USE_RESULT LOperand* UseRegisterOrConstant(HValue* value);
2777 MUST_USE_RESULT LOperand* UseRegisterOrConstantAtStart(HValue* value);
2779 // An input operand in a constant operand.
2780 MUST_USE_RESULT LOperand* UseConstant(HValue* value);
2782 // An input operand in register, stack slot or a constant operand.
2783 // Will not be moved to a register even if one is freely available.
2784 virtual MUST_USE_RESULT LOperand* UseAny(HValue* value) OVERRIDE;
2786 // Temporary operand that must be in a register.
2787 MUST_USE_RESULT LUnallocated* TempRegister();
2788 MUST_USE_RESULT LUnallocated* TempDoubleRegister();
2789 MUST_USE_RESULT LOperand* FixedTemp(Register reg);
2790 MUST_USE_RESULT LOperand* FixedTemp(DoubleRegister reg);
2792 // Methods for setting up define-use relationships.
2793 // Return the same instruction that they are passed.
2794 LInstruction* Define(LTemplateResultInstruction<1>* instr,
2795 LUnallocated* result);
2796 LInstruction* DefineAsRegister(LTemplateResultInstruction<1>* instr);
2797 LInstruction* DefineAsSpilled(LTemplateResultInstruction<1>* instr,
2799 LInstruction* DefineSameAsFirst(LTemplateResultInstruction<1>* instr);
2800 LInstruction* DefineFixed(LTemplateResultInstruction<1>* instr,
2802 LInstruction* DefineFixedDouble(LTemplateResultInstruction<1>* instr,
2803 DoubleRegister reg);
2804 LInstruction* AssignEnvironment(LInstruction* instr);
2805 LInstruction* AssignPointerMap(LInstruction* instr);
2807 enum CanDeoptimize { CAN_DEOPTIMIZE_EAGERLY, CANNOT_DEOPTIMIZE_EAGERLY };
2809 // By default we assume that instruction sequences generated for calls
2810 // cannot deoptimize eagerly and we do not attach environment to this
2812 LInstruction* MarkAsCall(
2813 LInstruction* instr,
2814 HInstruction* hinstr,
2815 CanDeoptimize can_deoptimize = CANNOT_DEOPTIMIZE_EAGERLY);
2817 void VisitInstruction(HInstruction* current);
2818 void AddInstruction(LInstruction* instr, HInstruction* current);
2820 void DoBasicBlock(HBasicBlock* block, HBasicBlock* next_block);
2821 LInstruction* DoBit(Token::Value op, HBitwiseBinaryOperation* instr);
2822 LInstruction* DoShift(Token::Value op, HBitwiseBinaryOperation* instr);
2823 LInstruction* DoArithmeticD(Token::Value op,
2824 HArithmeticBinaryOperation* instr);
2825 LInstruction* DoArithmeticT(Token::Value op,
2826 HBinaryOperation* instr);
2828 HInstruction* current_instruction_;
2829 HBasicBlock* current_block_;
2830 HBasicBlock* next_block_;
2831 LAllocator* allocator_;
2833 DISALLOW_COPY_AND_ASSIGN(LChunkBuilder);
2836 #undef DECLARE_HYDROGEN_ACCESSOR
2837 #undef DECLARE_CONCRETE_INSTRUCTION
2839 } } // namespace v8::internal
2841 #endif // V8_MIPS_LITHIUM_MIPS_H_