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) \
135 V(SeqStringGetChar) \
136 V(SeqStringSetChar) \
142 V(StoreContextSlot) \
143 V(StoreFrameContext) \
146 V(StoreKeyedGeneric) \
148 V(StoreNamedGeneric) \
150 V(StringCharCodeAt) \
151 V(StringCharFromCode) \
152 V(StringCompareAndBranch) \
155 V(TailCallThroughMegamorphicCache) \
157 V(ToFastProperties) \
158 V(TransitionElementsKind) \
159 V(TrapAllocationMemento) \
161 V(TypeofIsAndBranch) \
166 #define DECLARE_CONCRETE_INSTRUCTION(type, mnemonic) \
167 Opcode opcode() const FINAL { return LInstruction::k##type; } \
168 void CompileToNative(LCodeGen* generator) FINAL; \
169 const char* Mnemonic() const FINAL { return mnemonic; } \
170 static L##type* cast(LInstruction* instr) { \
171 DCHECK(instr->Is##type()); \
172 return reinterpret_cast<L##type*>(instr); \
176 #define DECLARE_HYDROGEN_ACCESSOR(type) \
177 H##type* hydrogen() const { \
178 return H##type::cast(hydrogen_value()); \
182 class LInstruction : public ZoneObject {
185 : environment_(NULL),
186 hydrogen_value_(NULL),
187 bit_field_(IsCallBits::encode(false)) {
190 virtual ~LInstruction() {}
192 virtual void CompileToNative(LCodeGen* generator) = 0;
193 virtual const char* Mnemonic() const = 0;
194 virtual void PrintTo(StringStream* stream);
195 virtual void PrintDataTo(StringStream* stream);
196 virtual void PrintOutputOperandTo(StringStream* stream);
199 // Declare a unique enum value for each instruction.
200 #define DECLARE_OPCODE(type) k##type,
201 LITHIUM_CONCRETE_INSTRUCTION_LIST(DECLARE_OPCODE)
202 kNumberOfInstructions
203 #undef DECLARE_OPCODE
206 virtual Opcode opcode() const = 0;
208 // Declare non-virtual type testers for all leaf IR classes.
209 #define DECLARE_PREDICATE(type) \
210 bool Is##type() const { return opcode() == k##type; }
211 LITHIUM_CONCRETE_INSTRUCTION_LIST(DECLARE_PREDICATE)
212 #undef DECLARE_PREDICATE
214 // Declare virtual predicates for instructions that don't have
216 virtual bool IsGap() const { return false; }
218 virtual bool IsControl() const { return false; }
220 // Try deleting this instruction if possible.
221 virtual bool TryDelete() { return false; }
223 void set_environment(LEnvironment* env) { environment_ = env; }
224 LEnvironment* environment() const { return environment_; }
225 bool HasEnvironment() const { return environment_ != NULL; }
227 void set_pointer_map(LPointerMap* p) { pointer_map_.set(p); }
228 LPointerMap* pointer_map() const { return pointer_map_.get(); }
229 bool HasPointerMap() const { return pointer_map_.is_set(); }
231 void set_hydrogen_value(HValue* value) { hydrogen_value_ = value; }
232 HValue* hydrogen_value() const { return hydrogen_value_; }
234 virtual void SetDeferredLazyDeoptimizationEnvironment(LEnvironment* env) { }
236 void MarkAsCall() { bit_field_ = IsCallBits::update(bit_field_, true); }
237 bool IsCall() const { return IsCallBits::decode(bit_field_); }
239 // Interface to the register allocator and iterators.
240 bool ClobbersTemps() const { return IsCall(); }
241 bool ClobbersRegisters() const { return IsCall(); }
242 virtual bool ClobbersDoubleRegisters(Isolate* isolate) const {
246 // Interface to the register allocator and iterators.
247 bool IsMarkedAsCall() const { return IsCall(); }
249 virtual bool HasResult() const = 0;
250 virtual LOperand* result() const = 0;
252 LOperand* FirstInput() { return InputAt(0); }
253 LOperand* Output() { return HasResult() ? result() : NULL; }
255 virtual bool HasInterestingComment(LCodeGen* gen) const { return true; }
261 virtual int InputCount() = 0;
262 virtual LOperand* InputAt(int i) = 0;
265 // Iterator interface.
266 friend class InputIterator;
268 friend class TempIterator;
269 virtual int TempCount() = 0;
270 virtual LOperand* TempAt(int i) = 0;
272 class IsCallBits: public BitField<bool, 0, 1> {};
274 LEnvironment* environment_;
275 SetOncePointer<LPointerMap> pointer_map_;
276 HValue* hydrogen_value_;
281 // R = number of result operands (0 or 1).
283 class LTemplateResultInstruction : public LInstruction {
285 // Allow 0 or 1 output operands.
286 STATIC_ASSERT(R == 0 || R == 1);
287 bool HasResult() const FINAL { return R != 0 && result() != NULL; }
288 void set_result(LOperand* operand) { results_[0] = operand; }
289 LOperand* result() const OVERRIDE { return results_[0]; }
292 EmbeddedContainer<LOperand*, R> results_;
296 // R = number of result operands (0 or 1).
297 // I = number of input operands.
298 // T = number of temporary operands.
299 template<int R, int I, int T>
300 class LTemplateInstruction : public LTemplateResultInstruction<R> {
302 EmbeddedContainer<LOperand*, I> inputs_;
303 EmbeddedContainer<LOperand*, T> temps_;
307 int InputCount() FINAL { return I; }
308 LOperand* InputAt(int i) FINAL { return inputs_[i]; }
310 int TempCount() FINAL { return T; }
311 LOperand* TempAt(int i) FINAL { return temps_[i]; }
315 class LGap : public LTemplateInstruction<0, 0, 0> {
317 explicit LGap(HBasicBlock* block)
319 parallel_moves_[BEFORE] = NULL;
320 parallel_moves_[START] = NULL;
321 parallel_moves_[END] = NULL;
322 parallel_moves_[AFTER] = NULL;
325 // Can't use the DECLARE-macro here because of sub-classes.
326 bool IsGap() const FINAL { return true; }
327 void PrintDataTo(StringStream* stream) OVERRIDE;
328 static LGap* cast(LInstruction* instr) {
329 DCHECK(instr->IsGap());
330 return reinterpret_cast<LGap*>(instr);
333 bool IsRedundant() const;
335 HBasicBlock* block() const { return block_; }
342 FIRST_INNER_POSITION = BEFORE,
343 LAST_INNER_POSITION = AFTER
346 LParallelMove* GetOrCreateParallelMove(InnerPosition pos, Zone* zone) {
347 if (parallel_moves_[pos] == NULL) {
348 parallel_moves_[pos] = new(zone) LParallelMove(zone);
350 return parallel_moves_[pos];
353 LParallelMove* GetParallelMove(InnerPosition pos) {
354 return parallel_moves_[pos];
358 LParallelMove* parallel_moves_[LAST_INNER_POSITION + 1];
363 class LInstructionGap FINAL : public LGap {
365 explicit LInstructionGap(HBasicBlock* block) : LGap(block) { }
367 bool HasInterestingComment(LCodeGen* gen) const OVERRIDE {
368 return !IsRedundant();
371 DECLARE_CONCRETE_INSTRUCTION(InstructionGap, "gap")
375 class LGoto FINAL : public LTemplateInstruction<0, 0, 0> {
377 explicit LGoto(HBasicBlock* block) : block_(block) { }
379 bool HasInterestingComment(LCodeGen* gen) const OVERRIDE;
380 DECLARE_CONCRETE_INSTRUCTION(Goto, "goto")
381 void PrintDataTo(StringStream* stream) OVERRIDE;
382 bool IsControl() const OVERRIDE { return true; }
384 int block_id() const { return block_->block_id(); }
391 class LLazyBailout FINAL : public LTemplateInstruction<0, 0, 0> {
393 LLazyBailout() : gap_instructions_size_(0) { }
395 DECLARE_CONCRETE_INSTRUCTION(LazyBailout, "lazy-bailout")
397 void set_gap_instructions_size(int gap_instructions_size) {
398 gap_instructions_size_ = gap_instructions_size;
400 int gap_instructions_size() { return gap_instructions_size_; }
403 int gap_instructions_size_;
407 class LDummy FINAL : public LTemplateInstruction<1, 0, 0> {
410 DECLARE_CONCRETE_INSTRUCTION(Dummy, "dummy")
414 class LDummyUse FINAL : public LTemplateInstruction<1, 1, 0> {
416 explicit LDummyUse(LOperand* value) {
419 DECLARE_CONCRETE_INSTRUCTION(DummyUse, "dummy-use")
423 class LDeoptimize FINAL : public LTemplateInstruction<0, 0, 0> {
425 bool IsControl() const OVERRIDE { return true; }
426 DECLARE_CONCRETE_INSTRUCTION(Deoptimize, "deoptimize")
427 DECLARE_HYDROGEN_ACCESSOR(Deoptimize)
431 class LLabel FINAL : public LGap {
433 explicit LLabel(HBasicBlock* block)
434 : LGap(block), replacement_(NULL) { }
436 bool HasInterestingComment(LCodeGen* gen) const OVERRIDE { return false; }
437 DECLARE_CONCRETE_INSTRUCTION(Label, "label")
439 void PrintDataTo(StringStream* stream) OVERRIDE;
441 int block_id() const { return block()->block_id(); }
442 bool is_loop_header() const { return block()->IsLoopHeader(); }
443 bool is_osr_entry() const { return block()->is_osr_entry(); }
444 Label* label() { return &label_; }
445 LLabel* replacement() const { return replacement_; }
446 void set_replacement(LLabel* label) { replacement_ = label; }
447 bool HasReplacement() const { return replacement_ != NULL; }
451 LLabel* replacement_;
455 class LParameter FINAL : public LTemplateInstruction<1, 0, 0> {
457 bool HasInterestingComment(LCodeGen* gen) const OVERRIDE { return false; }
458 DECLARE_CONCRETE_INSTRUCTION(Parameter, "parameter")
462 class LCallStub FINAL : public LTemplateInstruction<1, 1, 0> {
464 explicit LCallStub(LOperand* context) {
465 inputs_[0] = context;
468 LOperand* context() { return inputs_[0]; }
470 DECLARE_CONCRETE_INSTRUCTION(CallStub, "call-stub")
471 DECLARE_HYDROGEN_ACCESSOR(CallStub)
475 class LTailCallThroughMegamorphicCache FINAL
476 : public LTemplateInstruction<0, 5, 0> {
478 LTailCallThroughMegamorphicCache(LOperand* context, LOperand* receiver,
479 LOperand* name, LOperand* slot,
481 inputs_[0] = context;
482 inputs_[1] = receiver;
488 LOperand* context() { return inputs_[0]; }
489 LOperand* receiver() { return inputs_[1]; }
490 LOperand* name() { return inputs_[2]; }
491 LOperand* slot() { return inputs_[3]; }
492 LOperand* vector() { return inputs_[4]; }
494 DECLARE_CONCRETE_INSTRUCTION(TailCallThroughMegamorphicCache,
495 "tail-call-through-megamorphic-cache")
496 DECLARE_HYDROGEN_ACCESSOR(TailCallThroughMegamorphicCache)
500 class LUnknownOSRValue FINAL : public LTemplateInstruction<1, 0, 0> {
502 bool HasInterestingComment(LCodeGen* gen) const OVERRIDE { return false; }
503 DECLARE_CONCRETE_INSTRUCTION(UnknownOSRValue, "unknown-osr-value")
507 template<int I, int T>
508 class LControlInstruction : public LTemplateInstruction<0, I, T> {
510 LControlInstruction() : false_label_(NULL), true_label_(NULL) { }
512 bool IsControl() const FINAL { return true; }
514 int SuccessorCount() { return hydrogen()->SuccessorCount(); }
515 HBasicBlock* SuccessorAt(int i) { return hydrogen()->SuccessorAt(i); }
517 int TrueDestination(LChunk* chunk) {
518 return chunk->LookupDestination(true_block_id());
520 int FalseDestination(LChunk* chunk) {
521 return chunk->LookupDestination(false_block_id());
524 Label* TrueLabel(LChunk* chunk) {
525 if (true_label_ == NULL) {
526 true_label_ = chunk->GetAssemblyLabel(TrueDestination(chunk));
530 Label* FalseLabel(LChunk* chunk) {
531 if (false_label_ == NULL) {
532 false_label_ = chunk->GetAssemblyLabel(FalseDestination(chunk));
538 int true_block_id() { return SuccessorAt(0)->block_id(); }
539 int false_block_id() { return SuccessorAt(1)->block_id(); }
542 HControlInstruction* hydrogen() {
543 return HControlInstruction::cast(this->hydrogen_value());
551 class LWrapReceiver FINAL : public LTemplateInstruction<1, 2, 0> {
553 LWrapReceiver(LOperand* receiver, LOperand* function) {
554 inputs_[0] = receiver;
555 inputs_[1] = function;
558 DECLARE_CONCRETE_INSTRUCTION(WrapReceiver, "wrap-receiver")
559 DECLARE_HYDROGEN_ACCESSOR(WrapReceiver)
561 LOperand* receiver() { return inputs_[0]; }
562 LOperand* function() { return inputs_[1]; }
566 class LApplyArguments FINAL : public LTemplateInstruction<1, 4, 0> {
568 LApplyArguments(LOperand* function,
571 LOperand* elements) {
572 inputs_[0] = function;
573 inputs_[1] = receiver;
575 inputs_[3] = elements;
578 DECLARE_CONCRETE_INSTRUCTION(ApplyArguments, "apply-arguments")
580 LOperand* function() { return inputs_[0]; }
581 LOperand* receiver() { return inputs_[1]; }
582 LOperand* length() { return inputs_[2]; }
583 LOperand* elements() { return inputs_[3]; }
587 class LAccessArgumentsAt FINAL : public LTemplateInstruction<1, 3, 0> {
589 LAccessArgumentsAt(LOperand* arguments, LOperand* length, LOperand* index) {
590 inputs_[0] = arguments;
595 DECLARE_CONCRETE_INSTRUCTION(AccessArgumentsAt, "access-arguments-at")
597 LOperand* arguments() { return inputs_[0]; }
598 LOperand* length() { return inputs_[1]; }
599 LOperand* index() { return inputs_[2]; }
601 void PrintDataTo(StringStream* stream) OVERRIDE;
605 class LArgumentsLength FINAL : public LTemplateInstruction<1, 1, 0> {
607 explicit LArgumentsLength(LOperand* elements) {
608 inputs_[0] = elements;
611 LOperand* elements() { return inputs_[0]; }
613 DECLARE_CONCRETE_INSTRUCTION(ArgumentsLength, "arguments-length")
617 class LArgumentsElements FINAL : public LTemplateInstruction<1, 0, 0> {
619 DECLARE_CONCRETE_INSTRUCTION(ArgumentsElements, "arguments-elements")
620 DECLARE_HYDROGEN_ACCESSOR(ArgumentsElements)
624 class LModByPowerOf2I FINAL : public LTemplateInstruction<1, 1, 0> {
626 LModByPowerOf2I(LOperand* dividend, int32_t divisor) {
627 inputs_[0] = dividend;
631 LOperand* dividend() { return inputs_[0]; }
632 int32_t divisor() const { return divisor_; }
634 DECLARE_CONCRETE_INSTRUCTION(ModByPowerOf2I, "mod-by-power-of-2-i")
635 DECLARE_HYDROGEN_ACCESSOR(Mod)
642 class LModByConstI FINAL : public LTemplateInstruction<1, 1, 0> {
644 LModByConstI(LOperand* dividend, int32_t divisor) {
645 inputs_[0] = dividend;
649 LOperand* dividend() { return inputs_[0]; }
650 int32_t divisor() const { return divisor_; }
652 DECLARE_CONCRETE_INSTRUCTION(ModByConstI, "mod-by-const-i")
653 DECLARE_HYDROGEN_ACCESSOR(Mod)
660 class LModI FINAL : public LTemplateInstruction<1, 2, 3> {
662 LModI(LOperand* left,
668 LOperand* left() { return inputs_[0]; }
669 LOperand* right() { return inputs_[1]; }
671 DECLARE_CONCRETE_INSTRUCTION(ModI, "mod-i")
672 DECLARE_HYDROGEN_ACCESSOR(Mod)
676 class LDivByPowerOf2I FINAL : public LTemplateInstruction<1, 1, 0> {
678 LDivByPowerOf2I(LOperand* dividend, int32_t divisor) {
679 inputs_[0] = dividend;
683 LOperand* dividend() { return inputs_[0]; }
684 int32_t divisor() const { return divisor_; }
686 DECLARE_CONCRETE_INSTRUCTION(DivByPowerOf2I, "div-by-power-of-2-i")
687 DECLARE_HYDROGEN_ACCESSOR(Div)
694 class LDivByConstI FINAL : public LTemplateInstruction<1, 1, 0> {
696 LDivByConstI(LOperand* dividend, int32_t divisor) {
697 inputs_[0] = dividend;
701 LOperand* dividend() { return inputs_[0]; }
702 int32_t divisor() const { return divisor_; }
704 DECLARE_CONCRETE_INSTRUCTION(DivByConstI, "div-by-const-i")
705 DECLARE_HYDROGEN_ACCESSOR(Div)
712 class LDivI FINAL : public LTemplateInstruction<1, 2, 1> {
714 LDivI(LOperand* dividend, LOperand* divisor, LOperand* temp) {
715 inputs_[0] = dividend;
716 inputs_[1] = divisor;
720 LOperand* dividend() { return inputs_[0]; }
721 LOperand* divisor() { return inputs_[1]; }
722 LOperand* temp() { return temps_[0]; }
724 DECLARE_CONCRETE_INSTRUCTION(DivI, "div-i")
725 DECLARE_HYDROGEN_ACCESSOR(BinaryOperation)
729 class LFlooringDivByPowerOf2I FINAL : public LTemplateInstruction<1, 1, 0> {
731 LFlooringDivByPowerOf2I(LOperand* dividend, int32_t divisor) {
732 inputs_[0] = dividend;
736 LOperand* dividend() { return inputs_[0]; }
737 int32_t divisor() { return divisor_; }
739 DECLARE_CONCRETE_INSTRUCTION(FlooringDivByPowerOf2I,
740 "flooring-div-by-power-of-2-i")
741 DECLARE_HYDROGEN_ACCESSOR(MathFloorOfDiv)
748 class LFlooringDivByConstI FINAL : public LTemplateInstruction<1, 1, 2> {
750 LFlooringDivByConstI(LOperand* dividend, int32_t divisor, LOperand* temp) {
751 inputs_[0] = dividend;
756 LOperand* dividend() { return inputs_[0]; }
757 int32_t divisor() const { return divisor_; }
758 LOperand* temp() { return temps_[0]; }
760 DECLARE_CONCRETE_INSTRUCTION(FlooringDivByConstI, "flooring-div-by-const-i")
761 DECLARE_HYDROGEN_ACCESSOR(MathFloorOfDiv)
768 class LFlooringDivI FINAL : public LTemplateInstruction<1, 2, 0> {
770 LFlooringDivI(LOperand* dividend, LOperand* divisor) {
771 inputs_[0] = dividend;
772 inputs_[1] = divisor;
775 LOperand* dividend() { return inputs_[0]; }
776 LOperand* divisor() { return inputs_[1]; }
778 DECLARE_CONCRETE_INSTRUCTION(FlooringDivI, "flooring-div-i")
779 DECLARE_HYDROGEN_ACCESSOR(MathFloorOfDiv)
783 class LMulI FINAL : public LTemplateInstruction<1, 2, 0> {
785 LMulI(LOperand* left, LOperand* right) {
790 LOperand* left() { return inputs_[0]; }
791 LOperand* right() { return inputs_[1]; }
793 DECLARE_CONCRETE_INSTRUCTION(MulI, "mul-i")
794 DECLARE_HYDROGEN_ACCESSOR(Mul)
798 // Instruction for computing multiplier * multiplicand + addend.
799 class LMultiplyAddD FINAL : public LTemplateInstruction<1, 3, 0> {
801 LMultiplyAddD(LOperand* addend, LOperand* multiplier,
802 LOperand* multiplicand) {
804 inputs_[1] = multiplier;
805 inputs_[2] = multiplicand;
808 LOperand* addend() { return inputs_[0]; }
809 LOperand* multiplier() { return inputs_[1]; }
810 LOperand* multiplicand() { return inputs_[2]; }
812 DECLARE_CONCRETE_INSTRUCTION(MultiplyAddD, "multiply-add-d")
816 class LDebugBreak FINAL : public LTemplateInstruction<0, 0, 0> {
818 DECLARE_CONCRETE_INSTRUCTION(DebugBreak, "break")
822 class LCompareNumericAndBranch FINAL : public LControlInstruction<2, 0> {
824 LCompareNumericAndBranch(LOperand* left, LOperand* right) {
829 LOperand* left() { return inputs_[0]; }
830 LOperand* right() { return inputs_[1]; }
832 DECLARE_CONCRETE_INSTRUCTION(CompareNumericAndBranch,
833 "compare-numeric-and-branch")
834 DECLARE_HYDROGEN_ACCESSOR(CompareNumericAndBranch)
836 Token::Value op() const { return hydrogen()->token(); }
837 bool is_double() const {
838 return hydrogen()->representation().IsDouble();
841 void PrintDataTo(StringStream* stream) OVERRIDE;
845 class LMathFloor FINAL : public LTemplateInstruction<1, 1, 1> {
847 LMathFloor(LOperand* value, LOperand* temp) {
852 LOperand* value() { return inputs_[0]; }
853 LOperand* temp() { return temps_[0]; }
855 DECLARE_CONCRETE_INSTRUCTION(MathFloor, "math-floor")
856 DECLARE_HYDROGEN_ACCESSOR(UnaryMathOperation)
860 class LMathRound FINAL : public LTemplateInstruction<1, 1, 1> {
862 LMathRound(LOperand* value, LOperand* temp) {
867 LOperand* value() { return inputs_[0]; }
868 LOperand* temp() { return temps_[0]; }
870 DECLARE_CONCRETE_INSTRUCTION(MathRound, "math-round")
871 DECLARE_HYDROGEN_ACCESSOR(UnaryMathOperation)
875 class LMathFround FINAL : public LTemplateInstruction<1, 1, 0> {
877 explicit LMathFround(LOperand* value) { inputs_[0] = value; }
879 LOperand* value() { return inputs_[0]; }
881 DECLARE_CONCRETE_INSTRUCTION(MathFround, "math-fround")
885 class LMathAbs FINAL : public LTemplateInstruction<1, 2, 0> {
887 LMathAbs(LOperand* context, LOperand* value) {
888 inputs_[1] = context;
892 LOperand* context() { return inputs_[1]; }
893 LOperand* value() { return inputs_[0]; }
895 DECLARE_CONCRETE_INSTRUCTION(MathAbs, "math-abs")
896 DECLARE_HYDROGEN_ACCESSOR(UnaryMathOperation)
900 class LMathLog FINAL : public LTemplateInstruction<1, 1, 0> {
902 explicit LMathLog(LOperand* value) {
906 LOperand* value() { return inputs_[0]; }
908 DECLARE_CONCRETE_INSTRUCTION(MathLog, "math-log")
912 class LMathClz32 FINAL : public LTemplateInstruction<1, 1, 0> {
914 explicit LMathClz32(LOperand* value) {
918 LOperand* value() { return inputs_[0]; }
920 DECLARE_CONCRETE_INSTRUCTION(MathClz32, "math-clz32")
924 class LMathExp FINAL : public LTemplateInstruction<1, 1, 3> {
926 LMathExp(LOperand* value,
927 LOperand* double_temp,
933 temps_[2] = double_temp;
934 ExternalReference::InitializeMathExpData();
937 LOperand* value() { return inputs_[0]; }
938 LOperand* temp1() { return temps_[0]; }
939 LOperand* temp2() { return temps_[1]; }
940 LOperand* double_temp() { return temps_[2]; }
942 DECLARE_CONCRETE_INSTRUCTION(MathExp, "math-exp")
946 class LMathSqrt FINAL : public LTemplateInstruction<1, 1, 0> {
948 explicit LMathSqrt(LOperand* value) {
952 LOperand* value() { return inputs_[0]; }
954 DECLARE_CONCRETE_INSTRUCTION(MathSqrt, "math-sqrt")
958 class LMathPowHalf FINAL : public LTemplateInstruction<1, 1, 1> {
960 LMathPowHalf(LOperand* value, LOperand* temp) {
965 LOperand* value() { return inputs_[0]; }
966 LOperand* temp() { return temps_[0]; }
968 DECLARE_CONCRETE_INSTRUCTION(MathPowHalf, "math-pow-half")
972 class LCmpObjectEqAndBranch FINAL : public LControlInstruction<2, 0> {
974 LCmpObjectEqAndBranch(LOperand* left, LOperand* right) {
979 LOperand* left() { return inputs_[0]; }
980 LOperand* right() { return inputs_[1]; }
982 DECLARE_CONCRETE_INSTRUCTION(CmpObjectEqAndBranch, "cmp-object-eq-and-branch")
983 DECLARE_HYDROGEN_ACCESSOR(CompareObjectEqAndBranch)
987 class LCmpHoleAndBranch FINAL : public LControlInstruction<1, 0> {
989 explicit LCmpHoleAndBranch(LOperand* object) {
993 LOperand* object() { return inputs_[0]; }
995 DECLARE_CONCRETE_INSTRUCTION(CmpHoleAndBranch, "cmp-hole-and-branch")
996 DECLARE_HYDROGEN_ACCESSOR(CompareHoleAndBranch)
1000 class LCompareMinusZeroAndBranch FINAL : public LControlInstruction<1, 1> {
1002 LCompareMinusZeroAndBranch(LOperand* value, LOperand* temp) {
1007 LOperand* value() { return inputs_[0]; }
1008 LOperand* temp() { return temps_[0]; }
1010 DECLARE_CONCRETE_INSTRUCTION(CompareMinusZeroAndBranch,
1011 "cmp-minus-zero-and-branch")
1012 DECLARE_HYDROGEN_ACCESSOR(CompareMinusZeroAndBranch)
1016 class LIsObjectAndBranch FINAL : public LControlInstruction<1, 1> {
1018 LIsObjectAndBranch(LOperand* value, LOperand* temp) {
1023 LOperand* value() { return inputs_[0]; }
1024 LOperand* temp() { return temps_[0]; }
1026 DECLARE_CONCRETE_INSTRUCTION(IsObjectAndBranch, "is-object-and-branch")
1027 DECLARE_HYDROGEN_ACCESSOR(IsObjectAndBranch)
1029 void PrintDataTo(StringStream* stream) OVERRIDE;
1033 class LIsStringAndBranch FINAL : public LControlInstruction<1, 1> {
1035 LIsStringAndBranch(LOperand* value, LOperand* temp) {
1040 LOperand* value() { return inputs_[0]; }
1041 LOperand* temp() { return temps_[0]; }
1043 DECLARE_CONCRETE_INSTRUCTION(IsStringAndBranch, "is-string-and-branch")
1044 DECLARE_HYDROGEN_ACCESSOR(IsStringAndBranch)
1046 void PrintDataTo(StringStream* stream) OVERRIDE;
1050 class LIsSmiAndBranch FINAL : public LControlInstruction<1, 0> {
1052 explicit LIsSmiAndBranch(LOperand* value) {
1056 LOperand* value() { return inputs_[0]; }
1058 DECLARE_CONCRETE_INSTRUCTION(IsSmiAndBranch, "is-smi-and-branch")
1059 DECLARE_HYDROGEN_ACCESSOR(IsSmiAndBranch)
1061 void PrintDataTo(StringStream* stream) OVERRIDE;
1065 class LIsUndetectableAndBranch FINAL : public LControlInstruction<1, 1> {
1067 explicit LIsUndetectableAndBranch(LOperand* value, LOperand* temp) {
1072 LOperand* value() { return inputs_[0]; }
1073 LOperand* temp() { return temps_[0]; }
1075 DECLARE_CONCRETE_INSTRUCTION(IsUndetectableAndBranch,
1076 "is-undetectable-and-branch")
1077 DECLARE_HYDROGEN_ACCESSOR(IsUndetectableAndBranch)
1079 void PrintDataTo(StringStream* stream) OVERRIDE;
1083 class LStringCompareAndBranch FINAL : public LControlInstruction<3, 0> {
1085 LStringCompareAndBranch(LOperand* context, LOperand* left, LOperand* right) {
1086 inputs_[0] = context;
1091 LOperand* context() { return inputs_[0]; }
1092 LOperand* left() { return inputs_[1]; }
1093 LOperand* right() { return inputs_[2]; }
1095 DECLARE_CONCRETE_INSTRUCTION(StringCompareAndBranch,
1096 "string-compare-and-branch")
1097 DECLARE_HYDROGEN_ACCESSOR(StringCompareAndBranch)
1099 Token::Value op() const { return hydrogen()->token(); }
1101 void PrintDataTo(StringStream* stream) OVERRIDE;
1105 class LHasInstanceTypeAndBranch FINAL : public LControlInstruction<1, 0> {
1107 explicit LHasInstanceTypeAndBranch(LOperand* value) {
1111 LOperand* value() { return inputs_[0]; }
1113 DECLARE_CONCRETE_INSTRUCTION(HasInstanceTypeAndBranch,
1114 "has-instance-type-and-branch")
1115 DECLARE_HYDROGEN_ACCESSOR(HasInstanceTypeAndBranch)
1117 void PrintDataTo(StringStream* stream) OVERRIDE;
1121 class LGetCachedArrayIndex FINAL : public LTemplateInstruction<1, 1, 0> {
1123 explicit LGetCachedArrayIndex(LOperand* value) {
1127 LOperand* value() { return inputs_[0]; }
1129 DECLARE_CONCRETE_INSTRUCTION(GetCachedArrayIndex, "get-cached-array-index")
1130 DECLARE_HYDROGEN_ACCESSOR(GetCachedArrayIndex)
1134 class LHasCachedArrayIndexAndBranch FINAL
1135 : public LControlInstruction<1, 0> {
1137 explicit LHasCachedArrayIndexAndBranch(LOperand* value) {
1141 LOperand* value() { return inputs_[0]; }
1143 DECLARE_CONCRETE_INSTRUCTION(HasCachedArrayIndexAndBranch,
1144 "has-cached-array-index-and-branch")
1145 DECLARE_HYDROGEN_ACCESSOR(HasCachedArrayIndexAndBranch)
1147 void PrintDataTo(StringStream* stream) OVERRIDE;
1151 class LClassOfTestAndBranch FINAL : public LControlInstruction<1, 1> {
1153 LClassOfTestAndBranch(LOperand* value, LOperand* temp) {
1158 LOperand* value() { return inputs_[0]; }
1159 LOperand* temp() { return temps_[0]; }
1161 DECLARE_CONCRETE_INSTRUCTION(ClassOfTestAndBranch,
1162 "class-of-test-and-branch")
1163 DECLARE_HYDROGEN_ACCESSOR(ClassOfTestAndBranch)
1165 void PrintDataTo(StringStream* stream) OVERRIDE;
1169 class LCmpT FINAL : public LTemplateInstruction<1, 3, 0> {
1171 LCmpT(LOperand* context, LOperand* left, LOperand* right) {
1172 inputs_[0] = context;
1177 LOperand* context() { return inputs_[0]; }
1178 LOperand* left() { return inputs_[1]; }
1179 LOperand* right() { return inputs_[2]; }
1181 DECLARE_CONCRETE_INSTRUCTION(CmpT, "cmp-t")
1182 DECLARE_HYDROGEN_ACCESSOR(CompareGeneric)
1184 Token::Value op() const { return hydrogen()->token(); }
1188 class LInstanceOf FINAL : public LTemplateInstruction<1, 3, 0> {
1190 LInstanceOf(LOperand* context, LOperand* left, LOperand* right) {
1191 inputs_[0] = context;
1196 LOperand* context() { return inputs_[0]; }
1197 LOperand* left() { return inputs_[1]; }
1198 LOperand* right() { return inputs_[2]; }
1200 DECLARE_CONCRETE_INSTRUCTION(InstanceOf, "instance-of")
1204 class LInstanceOfKnownGlobal FINAL : public LTemplateInstruction<1, 2, 1> {
1206 LInstanceOfKnownGlobal(LOperand* context, LOperand* value, LOperand* temp) {
1207 inputs_[0] = context;
1212 LOperand* context() { return inputs_[0]; }
1213 LOperand* value() { return inputs_[1]; }
1214 LOperand* temp() { return temps_[0]; }
1216 DECLARE_CONCRETE_INSTRUCTION(InstanceOfKnownGlobal,
1217 "instance-of-known-global")
1218 DECLARE_HYDROGEN_ACCESSOR(InstanceOfKnownGlobal)
1220 Handle<JSFunction> function() const { return hydrogen()->function(); }
1221 LEnvironment* GetDeferredLazyDeoptimizationEnvironment() {
1222 return lazy_deopt_env_;
1224 virtual void SetDeferredLazyDeoptimizationEnvironment(
1225 LEnvironment* env) OVERRIDE {
1226 lazy_deopt_env_ = env;
1230 LEnvironment* lazy_deopt_env_;
1234 class LBoundsCheck FINAL : public LTemplateInstruction<0, 2, 0> {
1236 LBoundsCheck(LOperand* index, LOperand* length) {
1238 inputs_[1] = length;
1241 LOperand* index() { return inputs_[0]; }
1242 LOperand* length() { return inputs_[1]; }
1244 DECLARE_CONCRETE_INSTRUCTION(BoundsCheck, "bounds-check")
1245 DECLARE_HYDROGEN_ACCESSOR(BoundsCheck)
1249 class LBitI FINAL : public LTemplateInstruction<1, 2, 0> {
1251 LBitI(LOperand* left, LOperand* right) {
1256 LOperand* left() { return inputs_[0]; }
1257 LOperand* right() { return inputs_[1]; }
1259 Token::Value op() const { return hydrogen()->op(); }
1261 DECLARE_CONCRETE_INSTRUCTION(BitI, "bit-i")
1262 DECLARE_HYDROGEN_ACCESSOR(Bitwise)
1266 class LShiftI FINAL : public LTemplateInstruction<1, 2, 0> {
1268 LShiftI(Token::Value op, LOperand* left, LOperand* right, bool can_deopt)
1269 : op_(op), can_deopt_(can_deopt) {
1274 Token::Value op() const { return op_; }
1275 LOperand* left() { return inputs_[0]; }
1276 LOperand* right() { return inputs_[1]; }
1277 bool can_deopt() const { return can_deopt_; }
1279 DECLARE_CONCRETE_INSTRUCTION(ShiftI, "shift-i")
1287 class LSubI FINAL : public LTemplateInstruction<1, 2, 0> {
1289 LSubI(LOperand* left, LOperand* right) {
1294 LOperand* left() { return inputs_[0]; }
1295 LOperand* right() { return inputs_[1]; }
1297 DECLARE_CONCRETE_INSTRUCTION(SubI, "sub-i")
1298 DECLARE_HYDROGEN_ACCESSOR(Sub)
1302 class LConstantI FINAL : public LTemplateInstruction<1, 0, 0> {
1304 DECLARE_CONCRETE_INSTRUCTION(ConstantI, "constant-i")
1305 DECLARE_HYDROGEN_ACCESSOR(Constant)
1307 int32_t value() const { return hydrogen()->Integer32Value(); }
1311 class LConstantS FINAL : public LTemplateInstruction<1, 0, 0> {
1313 DECLARE_CONCRETE_INSTRUCTION(ConstantS, "constant-s")
1314 DECLARE_HYDROGEN_ACCESSOR(Constant)
1316 Smi* value() const { return Smi::FromInt(hydrogen()->Integer32Value()); }
1320 class LConstantD FINAL : public LTemplateInstruction<1, 0, 0> {
1322 DECLARE_CONCRETE_INSTRUCTION(ConstantD, "constant-d")
1323 DECLARE_HYDROGEN_ACCESSOR(Constant)
1325 double value() const { return hydrogen()->DoubleValue(); }
1326 uint64_t bits() const { return hydrogen()->DoubleValueAsBits(); }
1330 class LConstantE FINAL : public LTemplateInstruction<1, 0, 0> {
1332 DECLARE_CONCRETE_INSTRUCTION(ConstantE, "constant-e")
1333 DECLARE_HYDROGEN_ACCESSOR(Constant)
1335 ExternalReference value() const {
1336 return hydrogen()->ExternalReferenceValue();
1341 class LConstantT FINAL : public LTemplateInstruction<1, 0, 0> {
1343 DECLARE_CONCRETE_INSTRUCTION(ConstantT, "constant-t")
1344 DECLARE_HYDROGEN_ACCESSOR(Constant)
1346 Handle<Object> value(Isolate* isolate) const {
1347 return hydrogen()->handle(isolate);
1352 class LBranch FINAL : public LControlInstruction<1, 0> {
1354 explicit LBranch(LOperand* value) {
1358 LOperand* value() { return inputs_[0]; }
1360 DECLARE_CONCRETE_INSTRUCTION(Branch, "branch")
1361 DECLARE_HYDROGEN_ACCESSOR(Branch)
1363 void PrintDataTo(StringStream* stream) OVERRIDE;
1367 class LCmpMapAndBranch FINAL : public LControlInstruction<1, 1> {
1369 LCmpMapAndBranch(LOperand* value, LOperand* temp) {
1374 LOperand* value() { return inputs_[0]; }
1375 LOperand* temp() { return temps_[0]; }
1377 DECLARE_CONCRETE_INSTRUCTION(CmpMapAndBranch, "cmp-map-and-branch")
1378 DECLARE_HYDROGEN_ACCESSOR(CompareMap)
1380 Handle<Map> map() const { return hydrogen()->map().handle(); }
1384 class LMapEnumLength FINAL : public LTemplateInstruction<1, 1, 0> {
1386 explicit LMapEnumLength(LOperand* value) {
1390 LOperand* value() { return inputs_[0]; }
1392 DECLARE_CONCRETE_INSTRUCTION(MapEnumLength, "map-enum-length")
1396 class LDateField FINAL : public LTemplateInstruction<1, 1, 1> {
1398 LDateField(LOperand* date, LOperand* temp, Smi* index) : index_(index) {
1403 LOperand* date() { return inputs_[0]; }
1404 LOperand* temp() { return temps_[0]; }
1405 Smi* index() const { return index_; }
1407 DECLARE_CONCRETE_INSTRUCTION(DateField, "date-field")
1408 DECLARE_HYDROGEN_ACCESSOR(DateField)
1415 class LSeqStringGetChar FINAL : public LTemplateInstruction<1, 2, 0> {
1417 LSeqStringGetChar(LOperand* string, LOperand* index) {
1418 inputs_[0] = string;
1422 LOperand* string() const { return inputs_[0]; }
1423 LOperand* index() const { return inputs_[1]; }
1425 DECLARE_CONCRETE_INSTRUCTION(SeqStringGetChar, "seq-string-get-char")
1426 DECLARE_HYDROGEN_ACCESSOR(SeqStringGetChar)
1430 class LSeqStringSetChar FINAL : public LTemplateInstruction<1, 4, 0> {
1432 LSeqStringSetChar(LOperand* context,
1436 inputs_[0] = context;
1437 inputs_[1] = string;
1442 LOperand* string() { return inputs_[1]; }
1443 LOperand* index() { return inputs_[2]; }
1444 LOperand* value() { return inputs_[3]; }
1446 DECLARE_CONCRETE_INSTRUCTION(SeqStringSetChar, "seq-string-set-char")
1447 DECLARE_HYDROGEN_ACCESSOR(SeqStringSetChar)
1451 class LAddI FINAL : public LTemplateInstruction<1, 2, 0> {
1453 LAddI(LOperand* left, LOperand* right) {
1458 LOperand* left() { return inputs_[0]; }
1459 LOperand* right() { return inputs_[1]; }
1461 DECLARE_CONCRETE_INSTRUCTION(AddI, "add-i")
1462 DECLARE_HYDROGEN_ACCESSOR(Add)
1466 class LMathMinMax FINAL : public LTemplateInstruction<1, 2, 0> {
1468 LMathMinMax(LOperand* left, LOperand* right) {
1473 LOperand* left() { return inputs_[0]; }
1474 LOperand* right() { return inputs_[1]; }
1476 DECLARE_CONCRETE_INSTRUCTION(MathMinMax, "math-min-max")
1477 DECLARE_HYDROGEN_ACCESSOR(MathMinMax)
1481 class LPower FINAL : public LTemplateInstruction<1, 2, 0> {
1483 LPower(LOperand* left, LOperand* right) {
1488 LOperand* left() { return inputs_[0]; }
1489 LOperand* right() { return inputs_[1]; }
1491 DECLARE_CONCRETE_INSTRUCTION(Power, "power")
1492 DECLARE_HYDROGEN_ACCESSOR(Power)
1496 class LArithmeticD FINAL : public LTemplateInstruction<1, 2, 0> {
1498 LArithmeticD(Token::Value op, LOperand* left, LOperand* right)
1504 Token::Value op() const { return op_; }
1505 LOperand* left() { return inputs_[0]; }
1506 LOperand* right() { return inputs_[1]; }
1508 Opcode opcode() const OVERRIDE { return LInstruction::kArithmeticD; }
1509 void CompileToNative(LCodeGen* generator) OVERRIDE;
1510 const char* Mnemonic() const OVERRIDE;
1517 class LArithmeticT FINAL : public LTemplateInstruction<1, 3, 0> {
1519 LArithmeticT(Token::Value op,
1524 inputs_[0] = context;
1529 LOperand* context() { return inputs_[0]; }
1530 LOperand* left() { return inputs_[1]; }
1531 LOperand* right() { return inputs_[2]; }
1532 Token::Value op() const { return op_; }
1534 Opcode opcode() const FINAL { return LInstruction::kArithmeticT; }
1535 void CompileToNative(LCodeGen* generator) OVERRIDE;
1536 const char* Mnemonic() const OVERRIDE;
1543 class LReturn FINAL : public LTemplateInstruction<0, 3, 0> {
1545 LReturn(LOperand* value, LOperand* context, LOperand* parameter_count) {
1547 inputs_[1] = context;
1548 inputs_[2] = parameter_count;
1551 LOperand* value() { return inputs_[0]; }
1553 bool has_constant_parameter_count() {
1554 return parameter_count()->IsConstantOperand();
1556 LConstantOperand* constant_parameter_count() {
1557 DCHECK(has_constant_parameter_count());
1558 return LConstantOperand::cast(parameter_count());
1560 LOperand* parameter_count() { return inputs_[2]; }
1562 DECLARE_CONCRETE_INSTRUCTION(Return, "return")
1566 class LLoadNamedField FINAL : public LTemplateInstruction<1, 1, 0> {
1568 explicit LLoadNamedField(LOperand* object) {
1569 inputs_[0] = object;
1572 LOperand* object() { return inputs_[0]; }
1574 DECLARE_CONCRETE_INSTRUCTION(LoadNamedField, "load-named-field")
1575 DECLARE_HYDROGEN_ACCESSOR(LoadNamedField)
1579 class LLoadNamedGeneric FINAL : public LTemplateInstruction<1, 2, 1> {
1581 LLoadNamedGeneric(LOperand* context, LOperand* object, LOperand* vector) {
1582 inputs_[0] = context;
1583 inputs_[1] = object;
1587 LOperand* context() { return inputs_[0]; }
1588 LOperand* object() { return inputs_[1]; }
1589 LOperand* temp_vector() { return temps_[0]; }
1591 DECLARE_CONCRETE_INSTRUCTION(LoadNamedGeneric, "load-named-generic")
1592 DECLARE_HYDROGEN_ACCESSOR(LoadNamedGeneric)
1594 Handle<Object> name() const { return hydrogen()->name(); }
1598 class LLoadFunctionPrototype FINAL : public LTemplateInstruction<1, 1, 0> {
1600 explicit LLoadFunctionPrototype(LOperand* function) {
1601 inputs_[0] = function;
1604 LOperand* function() { return inputs_[0]; }
1606 DECLARE_CONCRETE_INSTRUCTION(LoadFunctionPrototype, "load-function-prototype")
1607 DECLARE_HYDROGEN_ACCESSOR(LoadFunctionPrototype)
1611 class LLoadRoot FINAL : public LTemplateInstruction<1, 0, 0> {
1613 DECLARE_CONCRETE_INSTRUCTION(LoadRoot, "load-root")
1614 DECLARE_HYDROGEN_ACCESSOR(LoadRoot)
1616 Heap::RootListIndex index() const { return hydrogen()->index(); }
1620 class LLoadKeyed FINAL : public LTemplateInstruction<1, 2, 0> {
1622 LLoadKeyed(LOperand* elements, LOperand* key) {
1623 inputs_[0] = elements;
1627 LOperand* elements() { return inputs_[0]; }
1628 LOperand* key() { return inputs_[1]; }
1629 ElementsKind elements_kind() const {
1630 return hydrogen()->elements_kind();
1632 bool is_external() const {
1633 return hydrogen()->is_external();
1635 bool is_fixed_typed_array() const {
1636 return hydrogen()->is_fixed_typed_array();
1638 bool is_typed_elements() const {
1639 return is_external() || is_fixed_typed_array();
1642 DECLARE_CONCRETE_INSTRUCTION(LoadKeyed, "load-keyed")
1643 DECLARE_HYDROGEN_ACCESSOR(LoadKeyed)
1645 void PrintDataTo(StringStream* stream) OVERRIDE;
1646 uint32_t base_offset() const { return hydrogen()->base_offset(); }
1650 class LLoadKeyedGeneric FINAL : public LTemplateInstruction<1, 3, 1> {
1652 LLoadKeyedGeneric(LOperand* context, LOperand* object, LOperand* key,
1654 inputs_[0] = context;
1655 inputs_[1] = object;
1660 LOperand* context() { return inputs_[0]; }
1661 LOperand* object() { return inputs_[1]; }
1662 LOperand* key() { return inputs_[2]; }
1663 LOperand* temp_vector() { return temps_[0]; }
1665 DECLARE_CONCRETE_INSTRUCTION(LoadKeyedGeneric, "load-keyed-generic")
1666 DECLARE_HYDROGEN_ACCESSOR(LoadKeyedGeneric)
1670 class LLoadGlobalCell FINAL : public LTemplateInstruction<1, 0, 0> {
1672 DECLARE_CONCRETE_INSTRUCTION(LoadGlobalCell, "load-global-cell")
1673 DECLARE_HYDROGEN_ACCESSOR(LoadGlobalCell)
1677 class LLoadGlobalGeneric FINAL : public LTemplateInstruction<1, 2, 1> {
1679 LLoadGlobalGeneric(LOperand* context, LOperand* global_object,
1681 inputs_[0] = context;
1682 inputs_[1] = global_object;
1686 LOperand* context() { return inputs_[0]; }
1687 LOperand* global_object() { return inputs_[1]; }
1688 LOperand* temp_vector() { return temps_[0]; }
1690 DECLARE_CONCRETE_INSTRUCTION(LoadGlobalGeneric, "load-global-generic")
1691 DECLARE_HYDROGEN_ACCESSOR(LoadGlobalGeneric)
1693 Handle<Object> name() const { return hydrogen()->name(); }
1694 bool for_typeof() const { return hydrogen()->for_typeof(); }
1698 class LStoreGlobalCell FINAL : public LTemplateInstruction<0, 1, 1> {
1700 LStoreGlobalCell(LOperand* value, LOperand* temp) {
1705 LOperand* value() { return inputs_[0]; }
1706 LOperand* temp() { return temps_[0]; }
1708 DECLARE_CONCRETE_INSTRUCTION(StoreGlobalCell, "store-global-cell")
1709 DECLARE_HYDROGEN_ACCESSOR(StoreGlobalCell)
1713 class LLoadContextSlot FINAL : public LTemplateInstruction<1, 1, 0> {
1715 explicit LLoadContextSlot(LOperand* context) {
1716 inputs_[0] = context;
1719 LOperand* context() { return inputs_[0]; }
1721 DECLARE_CONCRETE_INSTRUCTION(LoadContextSlot, "load-context-slot")
1722 DECLARE_HYDROGEN_ACCESSOR(LoadContextSlot)
1724 int slot_index() { return hydrogen()->slot_index(); }
1726 void PrintDataTo(StringStream* stream) OVERRIDE;
1730 class LStoreContextSlot FINAL : public LTemplateInstruction<0, 2, 0> {
1732 LStoreContextSlot(LOperand* context, LOperand* value) {
1733 inputs_[0] = context;
1737 LOperand* context() { return inputs_[0]; }
1738 LOperand* value() { return inputs_[1]; }
1740 DECLARE_CONCRETE_INSTRUCTION(StoreContextSlot, "store-context-slot")
1741 DECLARE_HYDROGEN_ACCESSOR(StoreContextSlot)
1743 int slot_index() { return hydrogen()->slot_index(); }
1745 void PrintDataTo(StringStream* stream) OVERRIDE;
1749 class LPushArgument FINAL : public LTemplateInstruction<0, 1, 0> {
1751 explicit LPushArgument(LOperand* value) {
1755 LOperand* value() { return inputs_[0]; }
1757 DECLARE_CONCRETE_INSTRUCTION(PushArgument, "push-argument")
1761 class LDrop FINAL : public LTemplateInstruction<0, 0, 0> {
1763 explicit LDrop(int count) : count_(count) { }
1765 int count() const { return count_; }
1767 DECLARE_CONCRETE_INSTRUCTION(Drop, "drop")
1774 class LStoreCodeEntry FINAL: public LTemplateInstruction<0, 2, 0> {
1776 LStoreCodeEntry(LOperand* function, LOperand* code_object) {
1777 inputs_[0] = function;
1778 inputs_[1] = code_object;
1781 LOperand* function() { return inputs_[0]; }
1782 LOperand* code_object() { return inputs_[1]; }
1784 void PrintDataTo(StringStream* stream) OVERRIDE;
1786 DECLARE_CONCRETE_INSTRUCTION(StoreCodeEntry, "store-code-entry")
1787 DECLARE_HYDROGEN_ACCESSOR(StoreCodeEntry)
1791 class LInnerAllocatedObject FINAL: public LTemplateInstruction<1, 2, 0> {
1793 LInnerAllocatedObject(LOperand* base_object, LOperand* offset) {
1794 inputs_[0] = base_object;
1795 inputs_[1] = offset;
1798 LOperand* base_object() const { return inputs_[0]; }
1799 LOperand* offset() const { return inputs_[1]; }
1801 void PrintDataTo(StringStream* stream) OVERRIDE;
1803 DECLARE_CONCRETE_INSTRUCTION(InnerAllocatedObject, "inner-allocated-object")
1807 class LThisFunction FINAL : public LTemplateInstruction<1, 0, 0> {
1809 DECLARE_CONCRETE_INSTRUCTION(ThisFunction, "this-function")
1810 DECLARE_HYDROGEN_ACCESSOR(ThisFunction)
1814 class LContext FINAL : public LTemplateInstruction<1, 0, 0> {
1816 DECLARE_CONCRETE_INSTRUCTION(Context, "context")
1817 DECLARE_HYDROGEN_ACCESSOR(Context)
1821 class LDeclareGlobals FINAL : public LTemplateInstruction<0, 1, 0> {
1823 explicit LDeclareGlobals(LOperand* context) {
1824 inputs_[0] = context;
1827 LOperand* context() { return inputs_[0]; }
1829 DECLARE_CONCRETE_INSTRUCTION(DeclareGlobals, "declare-globals")
1830 DECLARE_HYDROGEN_ACCESSOR(DeclareGlobals)
1834 class LCallJSFunction FINAL : public LTemplateInstruction<1, 1, 0> {
1836 explicit LCallJSFunction(LOperand* function) {
1837 inputs_[0] = function;
1840 LOperand* function() { return inputs_[0]; }
1842 DECLARE_CONCRETE_INSTRUCTION(CallJSFunction, "call-js-function")
1843 DECLARE_HYDROGEN_ACCESSOR(CallJSFunction)
1845 void PrintDataTo(StringStream* stream) OVERRIDE;
1847 int arity() const { return hydrogen()->argument_count() - 1; }
1851 class LCallWithDescriptor FINAL : public LTemplateResultInstruction<1> {
1853 LCallWithDescriptor(CallInterfaceDescriptor descriptor,
1854 const ZoneList<LOperand*>& operands, Zone* zone)
1855 : descriptor_(descriptor),
1856 inputs_(descriptor.GetRegisterParameterCount() + 1, zone) {
1857 DCHECK(descriptor.GetRegisterParameterCount() + 1 == operands.length());
1858 inputs_.AddAll(operands, zone);
1861 LOperand* target() const { return inputs_[0]; }
1863 const CallInterfaceDescriptor descriptor() { return descriptor_; }
1865 DECLARE_HYDROGEN_ACCESSOR(CallWithDescriptor)
1868 DECLARE_CONCRETE_INSTRUCTION(CallWithDescriptor, "call-with-descriptor")
1870 void PrintDataTo(StringStream* stream) OVERRIDE;
1872 int arity() const { return hydrogen()->argument_count() - 1; }
1874 CallInterfaceDescriptor descriptor_;
1875 ZoneList<LOperand*> inputs_;
1877 // Iterator support.
1878 int InputCount() FINAL { return inputs_.length(); }
1879 LOperand* InputAt(int i) FINAL { return inputs_[i]; }
1881 int TempCount() FINAL { return 0; }
1882 LOperand* TempAt(int i) FINAL { return NULL; }
1886 class LInvokeFunction FINAL : public LTemplateInstruction<1, 2, 0> {
1888 LInvokeFunction(LOperand* context, LOperand* function) {
1889 inputs_[0] = context;
1890 inputs_[1] = function;
1893 LOperand* context() { return inputs_[0]; }
1894 LOperand* function() { return inputs_[1]; }
1896 DECLARE_CONCRETE_INSTRUCTION(InvokeFunction, "invoke-function")
1897 DECLARE_HYDROGEN_ACCESSOR(InvokeFunction)
1899 void PrintDataTo(StringStream* stream) OVERRIDE;
1901 int arity() const { return hydrogen()->argument_count() - 1; }
1905 class LCallFunction FINAL : public LTemplateInstruction<1, 2, 2> {
1907 LCallFunction(LOperand* context, LOperand* function, LOperand* slot,
1909 inputs_[0] = context;
1910 inputs_[1] = function;
1915 LOperand* context() { return inputs_[0]; }
1916 LOperand* function() { return inputs_[1]; }
1917 LOperand* temp_slot() { return temps_[0]; }
1918 LOperand* temp_vector() { return temps_[1]; }
1920 DECLARE_CONCRETE_INSTRUCTION(CallFunction, "call-function")
1921 DECLARE_HYDROGEN_ACCESSOR(CallFunction)
1923 int arity() const { return hydrogen()->argument_count() - 1; }
1924 void PrintDataTo(StringStream* stream) OVERRIDE;
1928 class LCallNew FINAL : public LTemplateInstruction<1, 2, 0> {
1930 LCallNew(LOperand* context, LOperand* constructor) {
1931 inputs_[0] = context;
1932 inputs_[1] = constructor;
1935 LOperand* context() { return inputs_[0]; }
1936 LOperand* constructor() { return inputs_[1]; }
1938 DECLARE_CONCRETE_INSTRUCTION(CallNew, "call-new")
1939 DECLARE_HYDROGEN_ACCESSOR(CallNew)
1941 void PrintDataTo(StringStream* stream) OVERRIDE;
1943 int arity() const { return hydrogen()->argument_count() - 1; }
1947 class LCallNewArray FINAL : public LTemplateInstruction<1, 2, 0> {
1949 LCallNewArray(LOperand* context, LOperand* constructor) {
1950 inputs_[0] = context;
1951 inputs_[1] = constructor;
1954 LOperand* context() { return inputs_[0]; }
1955 LOperand* constructor() { return inputs_[1]; }
1957 DECLARE_CONCRETE_INSTRUCTION(CallNewArray, "call-new-array")
1958 DECLARE_HYDROGEN_ACCESSOR(CallNewArray)
1960 void PrintDataTo(StringStream* stream) OVERRIDE;
1962 int arity() const { return hydrogen()->argument_count() - 1; }
1966 class LCallRuntime FINAL : public LTemplateInstruction<1, 1, 0> {
1968 explicit LCallRuntime(LOperand* context) {
1969 inputs_[0] = context;
1972 LOperand* context() { return inputs_[0]; }
1974 DECLARE_CONCRETE_INSTRUCTION(CallRuntime, "call-runtime")
1975 DECLARE_HYDROGEN_ACCESSOR(CallRuntime)
1977 bool ClobbersDoubleRegisters(Isolate* isolate) const OVERRIDE {
1978 return save_doubles() == kDontSaveFPRegs;
1981 const Runtime::Function* function() const { return hydrogen()->function(); }
1982 int arity() const { return hydrogen()->argument_count(); }
1983 SaveFPRegsMode save_doubles() const { return hydrogen()->save_doubles(); }
1987 class LInteger32ToDouble FINAL : public LTemplateInstruction<1, 1, 0> {
1989 explicit LInteger32ToDouble(LOperand* value) {
1993 LOperand* value() { return inputs_[0]; }
1995 DECLARE_CONCRETE_INSTRUCTION(Integer32ToDouble, "int32-to-double")
1999 class LUint32ToDouble FINAL : public LTemplateInstruction<1, 1, 0> {
2001 explicit LUint32ToDouble(LOperand* value) {
2005 LOperand* value() { return inputs_[0]; }
2007 DECLARE_CONCRETE_INSTRUCTION(Uint32ToDouble, "uint32-to-double")
2011 class LNumberTagI FINAL : public LTemplateInstruction<1, 1, 2> {
2013 LNumberTagI(LOperand* value, LOperand* temp1, LOperand* temp2) {
2019 LOperand* value() { return inputs_[0]; }
2020 LOperand* temp1() { return temps_[0]; }
2021 LOperand* temp2() { return temps_[1]; }
2023 DECLARE_CONCRETE_INSTRUCTION(NumberTagI, "number-tag-i")
2027 class LNumberTagU FINAL : public LTemplateInstruction<1, 1, 2> {
2029 LNumberTagU(LOperand* value, LOperand* temp1, LOperand* temp2) {
2035 LOperand* value() { return inputs_[0]; }
2036 LOperand* temp1() { return temps_[0]; }
2037 LOperand* temp2() { return temps_[1]; }
2039 DECLARE_CONCRETE_INSTRUCTION(NumberTagU, "number-tag-u")
2043 class LNumberTagD FINAL : public LTemplateInstruction<1, 1, 2> {
2045 LNumberTagD(LOperand* value, LOperand* temp, LOperand* temp2) {
2051 LOperand* value() { return inputs_[0]; }
2052 LOperand* temp() { return temps_[0]; }
2053 LOperand* temp2() { return temps_[1]; }
2055 DECLARE_CONCRETE_INSTRUCTION(NumberTagD, "number-tag-d")
2056 DECLARE_HYDROGEN_ACCESSOR(Change)
2060 class LDoubleToSmi FINAL : public LTemplateInstruction<1, 1, 0> {
2062 explicit LDoubleToSmi(LOperand* value) {
2066 LOperand* value() { return inputs_[0]; }
2068 DECLARE_CONCRETE_INSTRUCTION(DoubleToSmi, "double-to-smi")
2069 DECLARE_HYDROGEN_ACCESSOR(UnaryOperation)
2071 bool truncating() { return hydrogen()->CanTruncateToInt32(); }
2075 // Sometimes truncating conversion from a tagged value to an int32.
2076 class LDoubleToI FINAL : public LTemplateInstruction<1, 1, 0> {
2078 explicit LDoubleToI(LOperand* value) {
2082 LOperand* value() { return inputs_[0]; }
2084 DECLARE_CONCRETE_INSTRUCTION(DoubleToI, "double-to-i")
2085 DECLARE_HYDROGEN_ACCESSOR(UnaryOperation)
2087 bool truncating() { return hydrogen()->CanTruncateToInt32(); }
2091 // Truncating conversion from a tagged value to an int32.
2092 class LTaggedToI FINAL : public LTemplateInstruction<1, 1, 2> {
2094 LTaggedToI(LOperand* value,
2102 LOperand* value() { return inputs_[0]; }
2103 LOperand* temp() { return temps_[0]; }
2104 LOperand* temp2() { return temps_[1]; }
2106 DECLARE_CONCRETE_INSTRUCTION(TaggedToI, "tagged-to-i")
2107 DECLARE_HYDROGEN_ACCESSOR(Change)
2109 bool truncating() { return hydrogen()->CanTruncateToInt32(); }
2113 class LSmiTag FINAL : public LTemplateInstruction<1, 1, 0> {
2115 explicit LSmiTag(LOperand* value) {
2119 LOperand* value() { return inputs_[0]; }
2121 DECLARE_CONCRETE_INSTRUCTION(SmiTag, "smi-tag")
2122 DECLARE_HYDROGEN_ACCESSOR(Change)
2126 class LNumberUntagD FINAL : public LTemplateInstruction<1, 1, 0> {
2128 explicit LNumberUntagD(LOperand* value) {
2132 LOperand* value() { return inputs_[0]; }
2134 DECLARE_CONCRETE_INSTRUCTION(NumberUntagD, "double-untag")
2135 DECLARE_HYDROGEN_ACCESSOR(Change)
2139 class LSmiUntag FINAL : public LTemplateInstruction<1, 1, 0> {
2141 LSmiUntag(LOperand* value, bool needs_check)
2142 : needs_check_(needs_check) {
2146 LOperand* value() { return inputs_[0]; }
2147 bool needs_check() const { return needs_check_; }
2149 DECLARE_CONCRETE_INSTRUCTION(SmiUntag, "smi-untag")
2156 class LStoreNamedField FINAL : public LTemplateInstruction<0, 2, 1> {
2158 LStoreNamedField(LOperand* object, LOperand* value, LOperand* temp) {
2159 inputs_[0] = object;
2164 LOperand* object() { return inputs_[0]; }
2165 LOperand* value() { return inputs_[1]; }
2166 LOperand* temp() { return temps_[0]; }
2168 DECLARE_CONCRETE_INSTRUCTION(StoreNamedField, "store-named-field")
2169 DECLARE_HYDROGEN_ACCESSOR(StoreNamedField)
2171 void PrintDataTo(StringStream* stream) OVERRIDE;
2173 Representation representation() const {
2174 return hydrogen()->field_representation();
2179 class LStoreNamedGeneric FINAL : public LTemplateInstruction<0, 3, 0> {
2181 LStoreNamedGeneric(LOperand* context, LOperand* object, LOperand* value) {
2182 inputs_[0] = context;
2183 inputs_[1] = object;
2187 LOperand* context() { return inputs_[0]; }
2188 LOperand* object() { return inputs_[1]; }
2189 LOperand* value() { return inputs_[2]; }
2191 DECLARE_CONCRETE_INSTRUCTION(StoreNamedGeneric, "store-named-generic")
2192 DECLARE_HYDROGEN_ACCESSOR(StoreNamedGeneric)
2194 void PrintDataTo(StringStream* stream) OVERRIDE;
2196 Handle<Object> name() const { return hydrogen()->name(); }
2197 LanguageMode language_mode() { return hydrogen()->language_mode(); }
2201 class LStoreKeyed FINAL : public LTemplateInstruction<0, 3, 0> {
2203 LStoreKeyed(LOperand* object, LOperand* key, LOperand* value) {
2204 inputs_[0] = object;
2209 bool is_external() const { return hydrogen()->is_external(); }
2210 bool is_fixed_typed_array() const {
2211 return hydrogen()->is_fixed_typed_array();
2213 bool is_typed_elements() const {
2214 return is_external() || is_fixed_typed_array();
2216 LOperand* elements() { return inputs_[0]; }
2217 LOperand* key() { return inputs_[1]; }
2218 LOperand* value() { return inputs_[2]; }
2219 ElementsKind elements_kind() const {
2220 return hydrogen()->elements_kind();
2223 DECLARE_CONCRETE_INSTRUCTION(StoreKeyed, "store-keyed")
2224 DECLARE_HYDROGEN_ACCESSOR(StoreKeyed)
2226 void PrintDataTo(StringStream* stream) OVERRIDE;
2227 bool NeedsCanonicalization() { return hydrogen()->NeedsCanonicalization(); }
2228 uint32_t base_offset() const { return hydrogen()->base_offset(); }
2232 class LStoreKeyedGeneric FINAL : public LTemplateInstruction<0, 4, 0> {
2234 LStoreKeyedGeneric(LOperand* context,
2238 inputs_[0] = context;
2244 LOperand* context() { return inputs_[0]; }
2245 LOperand* object() { return inputs_[1]; }
2246 LOperand* key() { return inputs_[2]; }
2247 LOperand* value() { return inputs_[3]; }
2249 DECLARE_CONCRETE_INSTRUCTION(StoreKeyedGeneric, "store-keyed-generic")
2250 DECLARE_HYDROGEN_ACCESSOR(StoreKeyedGeneric)
2252 void PrintDataTo(StringStream* stream) OVERRIDE;
2254 LanguageMode language_mode() { return hydrogen()->language_mode(); }
2258 class LTransitionElementsKind FINAL : public LTemplateInstruction<0, 2, 1> {
2260 LTransitionElementsKind(LOperand* object,
2262 LOperand* new_map_temp) {
2263 inputs_[0] = object;
2264 inputs_[1] = context;
2265 temps_[0] = new_map_temp;
2268 LOperand* context() { return inputs_[1]; }
2269 LOperand* object() { return inputs_[0]; }
2270 LOperand* new_map_temp() { return temps_[0]; }
2272 DECLARE_CONCRETE_INSTRUCTION(TransitionElementsKind,
2273 "transition-elements-kind")
2274 DECLARE_HYDROGEN_ACCESSOR(TransitionElementsKind)
2276 void PrintDataTo(StringStream* stream) OVERRIDE;
2278 Handle<Map> original_map() { return hydrogen()->original_map().handle(); }
2279 Handle<Map> transitioned_map() {
2280 return hydrogen()->transitioned_map().handle();
2282 ElementsKind from_kind() { return hydrogen()->from_kind(); }
2283 ElementsKind to_kind() { return hydrogen()->to_kind(); }
2287 class LTrapAllocationMemento FINAL : public LTemplateInstruction<0, 1, 1> {
2289 LTrapAllocationMemento(LOperand* object,
2291 inputs_[0] = object;
2295 LOperand* object() { return inputs_[0]; }
2296 LOperand* temp() { return temps_[0]; }
2298 DECLARE_CONCRETE_INSTRUCTION(TrapAllocationMemento,
2299 "trap-allocation-memento")
2303 class LStringAdd FINAL : public LTemplateInstruction<1, 3, 0> {
2305 LStringAdd(LOperand* context, LOperand* left, LOperand* right) {
2306 inputs_[0] = context;
2311 LOperand* context() { return inputs_[0]; }
2312 LOperand* left() { return inputs_[1]; }
2313 LOperand* right() { return inputs_[2]; }
2315 DECLARE_CONCRETE_INSTRUCTION(StringAdd, "string-add")
2316 DECLARE_HYDROGEN_ACCESSOR(StringAdd)
2321 class LStringCharCodeAt FINAL : public LTemplateInstruction<1, 3, 0> {
2323 LStringCharCodeAt(LOperand* context, LOperand* string, LOperand* index) {
2324 inputs_[0] = context;
2325 inputs_[1] = string;
2329 LOperand* context() { return inputs_[0]; }
2330 LOperand* string() { return inputs_[1]; }
2331 LOperand* index() { return inputs_[2]; }
2333 DECLARE_CONCRETE_INSTRUCTION(StringCharCodeAt, "string-char-code-at")
2334 DECLARE_HYDROGEN_ACCESSOR(StringCharCodeAt)
2338 class LStringCharFromCode FINAL : public LTemplateInstruction<1, 2, 0> {
2340 explicit LStringCharFromCode(LOperand* context, LOperand* char_code) {
2341 inputs_[0] = context;
2342 inputs_[1] = char_code;
2345 LOperand* context() { return inputs_[0]; }
2346 LOperand* char_code() { return inputs_[1]; }
2348 DECLARE_CONCRETE_INSTRUCTION(StringCharFromCode, "string-char-from-code")
2349 DECLARE_HYDROGEN_ACCESSOR(StringCharFromCode)
2353 class LCheckValue FINAL : public LTemplateInstruction<0, 1, 0> {
2355 explicit LCheckValue(LOperand* value) {
2359 LOperand* value() { return inputs_[0]; }
2361 DECLARE_CONCRETE_INSTRUCTION(CheckValue, "check-value")
2362 DECLARE_HYDROGEN_ACCESSOR(CheckValue)
2366 class LCheckInstanceType FINAL : public LTemplateInstruction<0, 1, 0> {
2368 explicit LCheckInstanceType(LOperand* value) {
2372 LOperand* value() { return inputs_[0]; }
2374 DECLARE_CONCRETE_INSTRUCTION(CheckInstanceType, "check-instance-type")
2375 DECLARE_HYDROGEN_ACCESSOR(CheckInstanceType)
2379 class LCheckMaps FINAL : public LTemplateInstruction<0, 1, 0> {
2381 explicit LCheckMaps(LOperand* value = NULL) {
2385 LOperand* value() { return inputs_[0]; }
2387 DECLARE_CONCRETE_INSTRUCTION(CheckMaps, "check-maps")
2388 DECLARE_HYDROGEN_ACCESSOR(CheckMaps)
2392 class LCheckSmi FINAL : public LTemplateInstruction<1, 1, 0> {
2394 explicit LCheckSmi(LOperand* value) {
2398 LOperand* value() { return inputs_[0]; }
2400 DECLARE_CONCRETE_INSTRUCTION(CheckSmi, "check-smi")
2404 class LCheckNonSmi FINAL : public LTemplateInstruction<0, 1, 0> {
2406 explicit LCheckNonSmi(LOperand* value) {
2410 LOperand* value() { return inputs_[0]; }
2412 DECLARE_CONCRETE_INSTRUCTION(CheckNonSmi, "check-non-smi")
2413 DECLARE_HYDROGEN_ACCESSOR(CheckHeapObject)
2417 class LClampDToUint8 FINAL : public LTemplateInstruction<1, 1, 1> {
2419 LClampDToUint8(LOperand* unclamped, LOperand* temp) {
2420 inputs_[0] = unclamped;
2424 LOperand* unclamped() { return inputs_[0]; }
2425 LOperand* temp() { return temps_[0]; }
2427 DECLARE_CONCRETE_INSTRUCTION(ClampDToUint8, "clamp-d-to-uint8")
2431 class LClampIToUint8 FINAL : public LTemplateInstruction<1, 1, 0> {
2433 explicit LClampIToUint8(LOperand* unclamped) {
2434 inputs_[0] = unclamped;
2437 LOperand* unclamped() { return inputs_[0]; }
2439 DECLARE_CONCRETE_INSTRUCTION(ClampIToUint8, "clamp-i-to-uint8")
2443 class LClampTToUint8 FINAL : public LTemplateInstruction<1, 1, 1> {
2445 LClampTToUint8(LOperand* unclamped, LOperand* temp) {
2446 inputs_[0] = unclamped;
2450 LOperand* unclamped() { return inputs_[0]; }
2451 LOperand* temp() { return temps_[0]; }
2453 DECLARE_CONCRETE_INSTRUCTION(ClampTToUint8, "clamp-t-to-uint8")
2457 class LDoubleBits FINAL : public LTemplateInstruction<1, 1, 0> {
2459 explicit LDoubleBits(LOperand* value) {
2463 LOperand* value() { return inputs_[0]; }
2465 DECLARE_CONCRETE_INSTRUCTION(DoubleBits, "double-bits")
2466 DECLARE_HYDROGEN_ACCESSOR(DoubleBits)
2470 class LConstructDouble FINAL : public LTemplateInstruction<1, 2, 0> {
2472 LConstructDouble(LOperand* hi, LOperand* lo) {
2477 LOperand* hi() { return inputs_[0]; }
2478 LOperand* lo() { return inputs_[1]; }
2480 DECLARE_CONCRETE_INSTRUCTION(ConstructDouble, "construct-double")
2484 class LAllocate FINAL : public LTemplateInstruction<1, 2, 2> {
2486 LAllocate(LOperand* context,
2490 inputs_[0] = context;
2496 LOperand* context() { return inputs_[0]; }
2497 LOperand* size() { return inputs_[1]; }
2498 LOperand* temp1() { return temps_[0]; }
2499 LOperand* temp2() { return temps_[1]; }
2501 DECLARE_CONCRETE_INSTRUCTION(Allocate, "allocate")
2502 DECLARE_HYDROGEN_ACCESSOR(Allocate)
2506 class LRegExpLiteral FINAL : public LTemplateInstruction<1, 1, 0> {
2508 explicit LRegExpLiteral(LOperand* context) {
2509 inputs_[0] = context;
2512 LOperand* context() { return inputs_[0]; }
2514 DECLARE_CONCRETE_INSTRUCTION(RegExpLiteral, "regexp-literal")
2515 DECLARE_HYDROGEN_ACCESSOR(RegExpLiteral)
2519 class LFunctionLiteral FINAL : public LTemplateInstruction<1, 1, 0> {
2521 explicit LFunctionLiteral(LOperand* context) {
2522 inputs_[0] = context;
2525 LOperand* context() { return inputs_[0]; }
2527 DECLARE_CONCRETE_INSTRUCTION(FunctionLiteral, "function-literal")
2528 DECLARE_HYDROGEN_ACCESSOR(FunctionLiteral)
2532 class LToFastProperties FINAL : public LTemplateInstruction<1, 1, 0> {
2534 explicit LToFastProperties(LOperand* value) {
2538 LOperand* value() { return inputs_[0]; }
2540 DECLARE_CONCRETE_INSTRUCTION(ToFastProperties, "to-fast-properties")
2541 DECLARE_HYDROGEN_ACCESSOR(ToFastProperties)
2545 class LTypeof FINAL : public LTemplateInstruction<1, 2, 0> {
2547 LTypeof(LOperand* context, LOperand* value) {
2548 inputs_[0] = context;
2552 LOperand* context() { return inputs_[0]; }
2553 LOperand* value() { return inputs_[1]; }
2555 DECLARE_CONCRETE_INSTRUCTION(Typeof, "typeof")
2559 class LTypeofIsAndBranch FINAL : public LControlInstruction<1, 0> {
2561 explicit LTypeofIsAndBranch(LOperand* value) {
2565 LOperand* value() { return inputs_[0]; }
2567 DECLARE_CONCRETE_INSTRUCTION(TypeofIsAndBranch, "typeof-is-and-branch")
2568 DECLARE_HYDROGEN_ACCESSOR(TypeofIsAndBranch)
2570 Handle<String> type_literal() { return hydrogen()->type_literal(); }
2572 void PrintDataTo(StringStream* stream) OVERRIDE;
2576 class LIsConstructCallAndBranch FINAL : public LControlInstruction<0, 1> {
2578 explicit LIsConstructCallAndBranch(LOperand* temp) {
2582 LOperand* temp() { return temps_[0]; }
2584 DECLARE_CONCRETE_INSTRUCTION(IsConstructCallAndBranch,
2585 "is-construct-call-and-branch")
2589 class LOsrEntry FINAL : public LTemplateInstruction<0, 0, 0> {
2593 bool HasInterestingComment(LCodeGen* gen) const OVERRIDE { return false; }
2594 DECLARE_CONCRETE_INSTRUCTION(OsrEntry, "osr-entry")
2598 class LStackCheck FINAL : public LTemplateInstruction<0, 1, 0> {
2600 explicit LStackCheck(LOperand* context) {
2601 inputs_[0] = context;
2604 LOperand* context() { return inputs_[0]; }
2606 DECLARE_CONCRETE_INSTRUCTION(StackCheck, "stack-check")
2607 DECLARE_HYDROGEN_ACCESSOR(StackCheck)
2609 Label* done_label() { return &done_label_; }
2616 class LForInPrepareMap FINAL : public LTemplateInstruction<1, 2, 0> {
2618 LForInPrepareMap(LOperand* context, LOperand* object) {
2619 inputs_[0] = context;
2620 inputs_[1] = object;
2623 LOperand* context() { return inputs_[0]; }
2624 LOperand* object() { return inputs_[1]; }
2626 DECLARE_CONCRETE_INSTRUCTION(ForInPrepareMap, "for-in-prepare-map")
2630 class LForInCacheArray FINAL : public LTemplateInstruction<1, 1, 0> {
2632 explicit LForInCacheArray(LOperand* map) {
2636 LOperand* map() { return inputs_[0]; }
2638 DECLARE_CONCRETE_INSTRUCTION(ForInCacheArray, "for-in-cache-array")
2641 return HForInCacheArray::cast(this->hydrogen_value())->idx();
2646 class LCheckMapValue FINAL : public LTemplateInstruction<0, 2, 0> {
2648 LCheckMapValue(LOperand* value, LOperand* map) {
2653 LOperand* value() { return inputs_[0]; }
2654 LOperand* map() { return inputs_[1]; }
2656 DECLARE_CONCRETE_INSTRUCTION(CheckMapValue, "check-map-value")
2660 class LLoadFieldByIndex FINAL : public LTemplateInstruction<1, 2, 0> {
2662 LLoadFieldByIndex(LOperand* object, LOperand* index) {
2663 inputs_[0] = object;
2667 LOperand* object() { return inputs_[0]; }
2668 LOperand* index() { return inputs_[1]; }
2670 DECLARE_CONCRETE_INSTRUCTION(LoadFieldByIndex, "load-field-by-index")
2674 class LStoreFrameContext: public LTemplateInstruction<0, 1, 0> {
2676 explicit LStoreFrameContext(LOperand* context) {
2677 inputs_[0] = context;
2680 LOperand* context() { return inputs_[0]; }
2682 DECLARE_CONCRETE_INSTRUCTION(StoreFrameContext, "store-frame-context")
2686 class LAllocateBlockContext: public LTemplateInstruction<1, 2, 0> {
2688 LAllocateBlockContext(LOperand* context, LOperand* function) {
2689 inputs_[0] = context;
2690 inputs_[1] = function;
2693 LOperand* context() { return inputs_[0]; }
2694 LOperand* function() { return inputs_[1]; }
2696 Handle<ScopeInfo> scope_info() { return hydrogen()->scope_info(); }
2698 DECLARE_CONCRETE_INSTRUCTION(AllocateBlockContext, "allocate-block-context")
2699 DECLARE_HYDROGEN_ACCESSOR(AllocateBlockContext)
2703 class LChunkBuilder;
2704 class LPlatformChunk FINAL : public LChunk {
2706 LPlatformChunk(CompilationInfo* info, HGraph* graph)
2707 : LChunk(info, graph) { }
2709 int GetNextSpillIndex(RegisterKind kind);
2710 LOperand* GetNextSpillSlot(RegisterKind kind);
2714 class LChunkBuilder FINAL : public LChunkBuilderBase {
2716 LChunkBuilder(CompilationInfo* info, HGraph* graph, LAllocator* allocator)
2717 : LChunkBuilderBase(info, graph),
2718 current_instruction_(NULL),
2719 current_block_(NULL),
2721 allocator_(allocator) {}
2723 // Build the sequence for the graph.
2724 LPlatformChunk* Build();
2726 // Declare methods that deal with the individual node types.
2727 #define DECLARE_DO(type) LInstruction* Do##type(H##type* node);
2728 HYDROGEN_CONCRETE_INSTRUCTION_LIST(DECLARE_DO)
2731 LInstruction* DoMultiplyAdd(HMul* mul, HValue* addend);
2733 static bool HasMagicNumberForDivisor(int32_t divisor);
2735 LInstruction* DoMathFloor(HUnaryMathOperation* instr);
2736 LInstruction* DoMathRound(HUnaryMathOperation* instr);
2737 LInstruction* DoMathFround(HUnaryMathOperation* instr);
2738 LInstruction* DoMathAbs(HUnaryMathOperation* instr);
2739 LInstruction* DoMathLog(HUnaryMathOperation* instr);
2740 LInstruction* DoMathExp(HUnaryMathOperation* instr);
2741 LInstruction* DoMathSqrt(HUnaryMathOperation* instr);
2742 LInstruction* DoMathPowHalf(HUnaryMathOperation* instr);
2743 LInstruction* DoMathClz32(HUnaryMathOperation* instr);
2744 LInstruction* DoDivByPowerOf2I(HDiv* instr);
2745 LInstruction* DoDivByConstI(HDiv* instr);
2746 LInstruction* DoDivI(HDiv* instr);
2747 LInstruction* DoModByPowerOf2I(HMod* instr);
2748 LInstruction* DoModByConstI(HMod* instr);
2749 LInstruction* DoModI(HMod* instr);
2750 LInstruction* DoFlooringDivByPowerOf2I(HMathFloorOfDiv* instr);
2751 LInstruction* DoFlooringDivByConstI(HMathFloorOfDiv* instr);
2752 LInstruction* DoFlooringDivI(HMathFloorOfDiv* instr);
2755 // Methods for getting operands for Use / Define / Temp.
2756 LUnallocated* ToUnallocated(Register reg);
2757 LUnallocated* ToUnallocated(DoubleRegister reg);
2759 // Methods for setting up define-use relationships.
2760 MUST_USE_RESULT LOperand* Use(HValue* value, LUnallocated* operand);
2761 MUST_USE_RESULT LOperand* UseFixed(HValue* value, Register fixed_register);
2762 MUST_USE_RESULT LOperand* UseFixedDouble(HValue* value,
2763 DoubleRegister fixed_register);
2765 // A value that is guaranteed to be allocated to a register.
2766 // Operand created by UseRegister is guaranteed to be live until the end of
2767 // instruction. This means that register allocator will not reuse it's
2768 // register for any other operand inside instruction.
2769 // Operand created by UseRegisterAtStart is guaranteed to be live only at
2770 // instruction start. Register allocator is free to assign the same register
2771 // to some other operand used inside instruction (i.e. temporary or
2773 MUST_USE_RESULT LOperand* UseRegister(HValue* value);
2774 MUST_USE_RESULT LOperand* UseRegisterAtStart(HValue* value);
2776 // An input operand in a register that may be trashed.
2777 MUST_USE_RESULT LOperand* UseTempRegister(HValue* value);
2779 // An input operand in a register or stack slot.
2780 MUST_USE_RESULT LOperand* Use(HValue* value);
2781 MUST_USE_RESULT LOperand* UseAtStart(HValue* value);
2783 // An input operand in a register, stack slot or a constant operand.
2784 MUST_USE_RESULT LOperand* UseOrConstant(HValue* value);
2785 MUST_USE_RESULT LOperand* UseOrConstantAtStart(HValue* value);
2787 // An input operand in a register or a constant operand.
2788 MUST_USE_RESULT LOperand* UseRegisterOrConstant(HValue* value);
2789 MUST_USE_RESULT LOperand* UseRegisterOrConstantAtStart(HValue* value);
2791 // An input operand in a constant operand.
2792 MUST_USE_RESULT LOperand* UseConstant(HValue* value);
2794 // An input operand in register, stack slot or a constant operand.
2795 // Will not be moved to a register even if one is freely available.
2796 MUST_USE_RESULT LOperand* UseAny(HValue* value) OVERRIDE;
2798 // Temporary operand that must be in a register.
2799 MUST_USE_RESULT LUnallocated* TempRegister();
2800 MUST_USE_RESULT LUnallocated* TempDoubleRegister();
2801 MUST_USE_RESULT LOperand* FixedTemp(Register reg);
2802 MUST_USE_RESULT LOperand* FixedTemp(DoubleRegister reg);
2804 // Methods for setting up define-use relationships.
2805 // Return the same instruction that they are passed.
2806 LInstruction* Define(LTemplateResultInstruction<1>* instr,
2807 LUnallocated* result);
2808 LInstruction* DefineAsRegister(LTemplateResultInstruction<1>* instr);
2809 LInstruction* DefineAsSpilled(LTemplateResultInstruction<1>* instr,
2811 LInstruction* DefineSameAsFirst(LTemplateResultInstruction<1>* instr);
2812 LInstruction* DefineFixed(LTemplateResultInstruction<1>* instr,
2814 LInstruction* DefineFixedDouble(LTemplateResultInstruction<1>* instr,
2815 DoubleRegister reg);
2816 LInstruction* AssignEnvironment(LInstruction* instr);
2817 LInstruction* AssignPointerMap(LInstruction* instr);
2819 enum CanDeoptimize { CAN_DEOPTIMIZE_EAGERLY, CANNOT_DEOPTIMIZE_EAGERLY };
2821 // By default we assume that instruction sequences generated for calls
2822 // cannot deoptimize eagerly and we do not attach environment to this
2824 LInstruction* MarkAsCall(
2825 LInstruction* instr,
2826 HInstruction* hinstr,
2827 CanDeoptimize can_deoptimize = CANNOT_DEOPTIMIZE_EAGERLY);
2829 void VisitInstruction(HInstruction* current);
2830 void AddInstruction(LInstruction* instr, HInstruction* current);
2832 void DoBasicBlock(HBasicBlock* block, HBasicBlock* next_block);
2833 LInstruction* DoBit(Token::Value op, HBitwiseBinaryOperation* instr);
2834 LInstruction* DoShift(Token::Value op, HBitwiseBinaryOperation* instr);
2835 LInstruction* DoArithmeticD(Token::Value op,
2836 HArithmeticBinaryOperation* instr);
2837 LInstruction* DoArithmeticT(Token::Value op,
2838 HBinaryOperation* instr);
2840 HInstruction* current_instruction_;
2841 HBasicBlock* current_block_;
2842 HBasicBlock* next_block_;
2843 LAllocator* allocator_;
2845 DISALLOW_COPY_AND_ASSIGN(LChunkBuilder);
2848 #undef DECLARE_HYDROGEN_ACCESSOR
2849 #undef DECLARE_CONCRETE_INSTRUCTION
2851 } } // namespace v8::internal
2853 #endif // V8_MIPS_LITHIUM_MIPS_H_