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_ARM_LITHIUM_ARM_H_
6 #define V8_ARM_LITHIUM_ARM_H_
8 #include "src/hydrogen.h"
9 #include "src/lithium.h"
10 #include "src/lithium-allocator.h"
11 #include "src/safepoint-table.h"
12 #include "src/utils.h"
17 // Forward declarations.
20 #define LITHIUM_CONCRETE_INSTRUCTION_LIST(V) \
21 V(AccessArgumentsAt) \
24 V(AllocateBlockContext) \
26 V(ArgumentsElements) \
34 V(CallWithDescriptor) \
40 V(CheckInstanceType) \
49 V(ClassOfTestAndBranch) \
50 V(CompareMinusZeroAndBranch) \
51 V(CompareNumericAndBranch) \
52 V(CmpObjectEqAndBranch) \
76 V(FlooringDivByConstI) \
77 V(FlooringDivByPowerOf2I) \
82 V(GetCachedArrayIndex) \
84 V(HasCachedArrayIndexAndBranch) \
85 V(HasInstanceTypeAndBranch) \
86 V(InnerAllocatedObject) \
88 V(InstanceOfKnownGlobal) \
90 V(Integer32ToDouble) \
92 V(IsConstructCallAndBranch) \
93 V(IsObjectAndBranch) \
94 V(IsStringAndBranch) \
96 V(IsUndetectableAndBranch) \
101 V(LoadFieldByIndex) \
102 V(LoadFunctionPrototype) \
103 V(LoadGlobalGeneric) \
105 V(LoadKeyedGeneric) \
107 V(LoadNamedGeneric) \
135 V(SeqStringGetChar) \
136 V(SeqStringSetChar) \
142 V(StoreContextSlot) \
143 V(StoreFrameContext) \
145 V(StoreKeyedGeneric) \
147 V(StoreNamedGeneric) \
149 V(StringCharCodeAt) \
150 V(StringCharFromCode) \
151 V(StringCompareAndBranch) \
155 V(TailCallThroughMegamorphicCache) \
157 V(ToFastProperties) \
158 V(TransitionElementsKind) \
159 V(TrapAllocationMemento) \
161 V(TypeofIsAndBranch) \
167 #define DECLARE_CONCRETE_INSTRUCTION(type, mnemonic) \
168 Opcode opcode() const FINAL { return LInstruction::k##type; } \
169 void CompileToNative(LCodeGen* generator) FINAL; \
170 const char* Mnemonic() const FINAL { return mnemonic; } \
171 static L##type* cast(LInstruction* instr) { \
172 DCHECK(instr->Is##type()); \
173 return reinterpret_cast<L##type*>(instr); \
177 #define DECLARE_HYDROGEN_ACCESSOR(type) \
178 H##type* hydrogen() const { \
179 return H##type::cast(hydrogen_value()); \
183 class LInstruction : public ZoneObject {
186 : environment_(NULL),
187 hydrogen_value_(NULL),
188 bit_field_(IsCallBits::encode(false)) {
191 virtual ~LInstruction() {}
193 virtual void CompileToNative(LCodeGen* generator) = 0;
194 virtual const char* Mnemonic() const = 0;
195 virtual void PrintTo(StringStream* stream);
196 virtual void PrintDataTo(StringStream* stream);
197 virtual void PrintOutputOperandTo(StringStream* stream);
200 // Declare a unique enum value for each instruction.
201 #define DECLARE_OPCODE(type) k##type,
202 LITHIUM_CONCRETE_INSTRUCTION_LIST(DECLARE_OPCODE)
203 kNumberOfInstructions
204 #undef DECLARE_OPCODE
207 virtual Opcode opcode() const = 0;
209 // Declare non-virtual type testers for all leaf IR classes.
210 #define DECLARE_PREDICATE(type) \
211 bool Is##type() const { return opcode() == k##type; }
212 LITHIUM_CONCRETE_INSTRUCTION_LIST(DECLARE_PREDICATE)
213 #undef DECLARE_PREDICATE
215 // Declare virtual predicates for instructions that don't have
217 virtual bool IsGap() const { return false; }
219 virtual bool IsControl() const { return false; }
221 // Try deleting this instruction if possible.
222 virtual bool TryDelete() { return false; }
224 void set_environment(LEnvironment* env) { environment_ = env; }
225 LEnvironment* environment() const { return environment_; }
226 bool HasEnvironment() const { return environment_ != NULL; }
228 void set_pointer_map(LPointerMap* p) { pointer_map_.set(p); }
229 LPointerMap* pointer_map() const { return pointer_map_.get(); }
230 bool HasPointerMap() const { return pointer_map_.is_set(); }
232 void set_hydrogen_value(HValue* value) { hydrogen_value_ = value; }
233 HValue* hydrogen_value() const { return hydrogen_value_; }
235 virtual void SetDeferredLazyDeoptimizationEnvironment(LEnvironment* env) { }
237 void MarkAsCall() { bit_field_ = IsCallBits::update(bit_field_, true); }
238 bool IsCall() const { return IsCallBits::decode(bit_field_); }
240 // Interface to the register allocator and iterators.
241 bool ClobbersTemps() const { return IsCall(); }
242 bool ClobbersRegisters() const { return IsCall(); }
243 virtual bool ClobbersDoubleRegisters(Isolate* isolate) const {
247 // Interface to the register allocator and iterators.
248 bool IsMarkedAsCall() const { return IsCall(); }
250 virtual bool HasResult() const = 0;
251 virtual LOperand* result() const = 0;
253 LOperand* FirstInput() { return InputAt(0); }
254 LOperand* Output() { return HasResult() ? result() : NULL; }
256 virtual bool HasInterestingComment(LCodeGen* gen) const { return true; }
262 virtual int InputCount() = 0;
263 virtual LOperand* InputAt(int i) = 0;
267 friend class InputIterator;
269 friend class TempIterator;
270 virtual int TempCount() = 0;
271 virtual LOperand* TempAt(int i) = 0;
273 class IsCallBits: public BitField<bool, 0, 1> {};
275 LEnvironment* environment_;
276 SetOncePointer<LPointerMap> pointer_map_;
277 HValue* hydrogen_value_;
282 // R = number of result operands (0 or 1).
284 class LTemplateResultInstruction : public LInstruction {
286 // Allow 0 or 1 output operands.
287 STATIC_ASSERT(R == 0 || R == 1);
288 bool HasResult() const FINAL { return R != 0 && result() != NULL; }
289 void set_result(LOperand* operand) { results_[0] = operand; }
290 LOperand* result() const OVERRIDE { return results_[0]; }
293 EmbeddedContainer<LOperand*, R> results_;
297 // R = number of result operands (0 or 1).
298 // I = number of input operands.
299 // T = number of temporary operands.
300 template<int R, int I, int T>
301 class LTemplateInstruction : public LTemplateResultInstruction<R> {
303 EmbeddedContainer<LOperand*, I> inputs_;
304 EmbeddedContainer<LOperand*, T> temps_;
308 int InputCount() FINAL { return I; }
309 LOperand* InputAt(int i) FINAL { return inputs_[i]; }
311 int TempCount() FINAL { return T; }
312 LOperand* TempAt(int i) FINAL { return temps_[i]; }
316 class LGap : public LTemplateInstruction<0, 0, 0> {
318 explicit LGap(HBasicBlock* block)
320 parallel_moves_[BEFORE] = NULL;
321 parallel_moves_[START] = NULL;
322 parallel_moves_[END] = NULL;
323 parallel_moves_[AFTER] = NULL;
326 // Can't use the DECLARE-macro here because of sub-classes.
327 bool IsGap() const OVERRIDE { return true; }
328 void PrintDataTo(StringStream* stream) OVERRIDE;
329 static LGap* cast(LInstruction* instr) {
330 DCHECK(instr->IsGap());
331 return reinterpret_cast<LGap*>(instr);
334 bool IsRedundant() const;
336 HBasicBlock* block() const { return block_; }
343 FIRST_INNER_POSITION = BEFORE,
344 LAST_INNER_POSITION = AFTER
347 LParallelMove* GetOrCreateParallelMove(InnerPosition pos, Zone* zone) {
348 if (parallel_moves_[pos] == NULL) {
349 parallel_moves_[pos] = new(zone) LParallelMove(zone);
351 return parallel_moves_[pos];
354 LParallelMove* GetParallelMove(InnerPosition pos) {
355 return parallel_moves_[pos];
359 LParallelMove* parallel_moves_[LAST_INNER_POSITION + 1];
364 class LInstructionGap FINAL : public LGap {
366 explicit LInstructionGap(HBasicBlock* block) : LGap(block) { }
368 bool HasInterestingComment(LCodeGen* gen) const OVERRIDE {
369 return !IsRedundant();
372 DECLARE_CONCRETE_INSTRUCTION(InstructionGap, "gap")
376 class LGoto FINAL : public LTemplateInstruction<0, 0, 0> {
378 explicit LGoto(HBasicBlock* block) : block_(block) { }
380 bool HasInterestingComment(LCodeGen* gen) const OVERRIDE;
381 DECLARE_CONCRETE_INSTRUCTION(Goto, "goto")
382 void PrintDataTo(StringStream* stream) OVERRIDE;
383 bool IsControl() const OVERRIDE { return true; }
385 int block_id() const { return block_->block_id(); }
392 class LLazyBailout FINAL : public LTemplateInstruction<0, 0, 0> {
394 LLazyBailout() : gap_instructions_size_(0) { }
396 DECLARE_CONCRETE_INSTRUCTION(LazyBailout, "lazy-bailout")
398 void set_gap_instructions_size(int gap_instructions_size) {
399 gap_instructions_size_ = gap_instructions_size;
401 int gap_instructions_size() { return gap_instructions_size_; }
404 int gap_instructions_size_;
408 class LDummy FINAL : public LTemplateInstruction<1, 0, 0> {
411 DECLARE_CONCRETE_INSTRUCTION(Dummy, "dummy")
415 class LDummyUse FINAL : public LTemplateInstruction<1, 1, 0> {
417 explicit LDummyUse(LOperand* value) {
420 DECLARE_CONCRETE_INSTRUCTION(DummyUse, "dummy-use")
424 class LDeoptimize FINAL : public LTemplateInstruction<0, 0, 0> {
426 bool IsControl() const OVERRIDE { return true; }
427 DECLARE_CONCRETE_INSTRUCTION(Deoptimize, "deoptimize")
428 DECLARE_HYDROGEN_ACCESSOR(Deoptimize)
432 class LLabel FINAL : public LGap {
434 explicit LLabel(HBasicBlock* block)
435 : LGap(block), replacement_(NULL) { }
437 bool HasInterestingComment(LCodeGen* gen) const OVERRIDE { return false; }
438 DECLARE_CONCRETE_INSTRUCTION(Label, "label")
440 void PrintDataTo(StringStream* stream) OVERRIDE;
442 int block_id() const { return block()->block_id(); }
443 bool is_loop_header() const { return block()->IsLoopHeader(); }
444 bool is_osr_entry() const { return block()->is_osr_entry(); }
445 Label* label() { return &label_; }
446 LLabel* replacement() const { return replacement_; }
447 void set_replacement(LLabel* label) { replacement_ = label; }
448 bool HasReplacement() const { return replacement_ != NULL; }
452 LLabel* replacement_;
456 class LParameter FINAL : public LTemplateInstruction<1, 0, 0> {
458 bool HasInterestingComment(LCodeGen* gen) const OVERRIDE { return false; }
459 DECLARE_CONCRETE_INSTRUCTION(Parameter, "parameter")
463 class LCallStub FINAL : public LTemplateInstruction<1, 1, 0> {
465 explicit LCallStub(LOperand* context) {
466 inputs_[0] = context;
469 LOperand* context() { return inputs_[0]; }
471 DECLARE_CONCRETE_INSTRUCTION(CallStub, "call-stub")
472 DECLARE_HYDROGEN_ACCESSOR(CallStub)
476 class LTailCallThroughMegamorphicCache FINAL
477 : public LTemplateInstruction<0, 5, 0> {
479 LTailCallThroughMegamorphicCache(LOperand* context, LOperand* receiver,
480 LOperand* name, LOperand* slot,
482 inputs_[0] = context;
483 inputs_[1] = receiver;
489 LOperand* context() { return inputs_[0]; }
490 LOperand* receiver() { return inputs_[1]; }
491 LOperand* name() { return inputs_[2]; }
492 LOperand* slot() { return inputs_[3]; }
493 LOperand* vector() { return inputs_[4]; }
495 DECLARE_CONCRETE_INSTRUCTION(TailCallThroughMegamorphicCache,
496 "tail-call-through-megamorphic-cache")
497 DECLARE_HYDROGEN_ACCESSOR(TailCallThroughMegamorphicCache)
501 class LUnknownOSRValue FINAL : public LTemplateInstruction<1, 0, 0> {
503 bool HasInterestingComment(LCodeGen* gen) const OVERRIDE { return false; }
504 DECLARE_CONCRETE_INSTRUCTION(UnknownOSRValue, "unknown-osr-value")
508 template<int I, int T>
509 class LControlInstruction : public LTemplateInstruction<0, I, T> {
511 LControlInstruction() : false_label_(NULL), true_label_(NULL) { }
513 bool IsControl() const FINAL { return true; }
515 int SuccessorCount() { return hydrogen()->SuccessorCount(); }
516 HBasicBlock* SuccessorAt(int i) { return hydrogen()->SuccessorAt(i); }
518 int TrueDestination(LChunk* chunk) {
519 return chunk->LookupDestination(true_block_id());
521 int FalseDestination(LChunk* chunk) {
522 return chunk->LookupDestination(false_block_id());
525 Label* TrueLabel(LChunk* chunk) {
526 if (true_label_ == NULL) {
527 true_label_ = chunk->GetAssemblyLabel(TrueDestination(chunk));
531 Label* FalseLabel(LChunk* chunk) {
532 if (false_label_ == NULL) {
533 false_label_ = chunk->GetAssemblyLabel(FalseDestination(chunk));
539 int true_block_id() { return SuccessorAt(0)->block_id(); }
540 int false_block_id() { return SuccessorAt(1)->block_id(); }
543 HControlInstruction* hydrogen() {
544 return HControlInstruction::cast(this->hydrogen_value());
552 class LWrapReceiver FINAL : public LTemplateInstruction<1, 2, 0> {
554 LWrapReceiver(LOperand* receiver, LOperand* function) {
555 inputs_[0] = receiver;
556 inputs_[1] = function;
559 DECLARE_CONCRETE_INSTRUCTION(WrapReceiver, "wrap-receiver")
560 DECLARE_HYDROGEN_ACCESSOR(WrapReceiver)
562 LOperand* receiver() { return inputs_[0]; }
563 LOperand* function() { return inputs_[1]; }
567 class LApplyArguments FINAL : public LTemplateInstruction<1, 4, 0> {
569 LApplyArguments(LOperand* function,
572 LOperand* elements) {
573 inputs_[0] = function;
574 inputs_[1] = receiver;
576 inputs_[3] = elements;
579 DECLARE_CONCRETE_INSTRUCTION(ApplyArguments, "apply-arguments")
581 LOperand* function() { return inputs_[0]; }
582 LOperand* receiver() { return inputs_[1]; }
583 LOperand* length() { return inputs_[2]; }
584 LOperand* elements() { return inputs_[3]; }
588 class LAccessArgumentsAt FINAL : public LTemplateInstruction<1, 3, 0> {
590 LAccessArgumentsAt(LOperand* arguments, LOperand* length, LOperand* index) {
591 inputs_[0] = arguments;
596 DECLARE_CONCRETE_INSTRUCTION(AccessArgumentsAt, "access-arguments-at")
598 LOperand* arguments() { return inputs_[0]; }
599 LOperand* length() { return inputs_[1]; }
600 LOperand* index() { return inputs_[2]; }
602 void PrintDataTo(StringStream* stream) OVERRIDE;
606 class LArgumentsLength FINAL : public LTemplateInstruction<1, 1, 0> {
608 explicit LArgumentsLength(LOperand* elements) {
609 inputs_[0] = elements;
612 LOperand* elements() { return inputs_[0]; }
614 DECLARE_CONCRETE_INSTRUCTION(ArgumentsLength, "arguments-length")
618 class LArgumentsElements FINAL : public LTemplateInstruction<1, 0, 0> {
620 DECLARE_CONCRETE_INSTRUCTION(ArgumentsElements, "arguments-elements")
621 DECLARE_HYDROGEN_ACCESSOR(ArgumentsElements)
625 class LModByPowerOf2I FINAL : public LTemplateInstruction<1, 1, 0> {
627 LModByPowerOf2I(LOperand* dividend, int32_t divisor) {
628 inputs_[0] = dividend;
632 LOperand* dividend() { return inputs_[0]; }
633 int32_t divisor() const { return divisor_; }
635 DECLARE_CONCRETE_INSTRUCTION(ModByPowerOf2I, "mod-by-power-of-2-i")
636 DECLARE_HYDROGEN_ACCESSOR(Mod)
643 class LModByConstI FINAL : public LTemplateInstruction<1, 1, 0> {
645 LModByConstI(LOperand* dividend, int32_t divisor) {
646 inputs_[0] = dividend;
650 LOperand* dividend() { return inputs_[0]; }
651 int32_t divisor() const { return divisor_; }
653 DECLARE_CONCRETE_INSTRUCTION(ModByConstI, "mod-by-const-i")
654 DECLARE_HYDROGEN_ACCESSOR(Mod)
661 class LModI FINAL : public LTemplateInstruction<1, 2, 2> {
663 LModI(LOperand* left, LOperand* right, LOperand* temp, LOperand* temp2) {
670 LOperand* left() { return inputs_[0]; }
671 LOperand* right() { return inputs_[1]; }
672 LOperand* temp() { return temps_[0]; }
673 LOperand* temp2() { return temps_[1]; }
675 DECLARE_CONCRETE_INSTRUCTION(ModI, "mod-i")
676 DECLARE_HYDROGEN_ACCESSOR(Mod)
680 class LDivByPowerOf2I FINAL : public LTemplateInstruction<1, 1, 0> {
682 LDivByPowerOf2I(LOperand* dividend, int32_t divisor) {
683 inputs_[0] = dividend;
687 LOperand* dividend() { return inputs_[0]; }
688 int32_t divisor() const { return divisor_; }
690 DECLARE_CONCRETE_INSTRUCTION(DivByPowerOf2I, "div-by-power-of-2-i")
691 DECLARE_HYDROGEN_ACCESSOR(Div)
698 class LDivByConstI FINAL : public LTemplateInstruction<1, 1, 0> {
700 LDivByConstI(LOperand* dividend, int32_t divisor) {
701 inputs_[0] = dividend;
705 LOperand* dividend() { return inputs_[0]; }
706 int32_t divisor() const { return divisor_; }
708 DECLARE_CONCRETE_INSTRUCTION(DivByConstI, "div-by-const-i")
709 DECLARE_HYDROGEN_ACCESSOR(Div)
716 class LDivI FINAL : public LTemplateInstruction<1, 2, 1> {
718 LDivI(LOperand* dividend, LOperand* divisor, LOperand* temp) {
719 inputs_[0] = dividend;
720 inputs_[1] = divisor;
724 LOperand* dividend() { return inputs_[0]; }
725 LOperand* divisor() { return inputs_[1]; }
726 LOperand* temp() { return temps_[0]; }
728 DECLARE_CONCRETE_INSTRUCTION(DivI, "div-i")
729 DECLARE_HYDROGEN_ACCESSOR(BinaryOperation)
733 class LFlooringDivByPowerOf2I FINAL : public LTemplateInstruction<1, 1, 0> {
735 LFlooringDivByPowerOf2I(LOperand* dividend, int32_t divisor) {
736 inputs_[0] = dividend;
740 LOperand* dividend() { return inputs_[0]; }
741 int32_t divisor() { return divisor_; }
743 DECLARE_CONCRETE_INSTRUCTION(FlooringDivByPowerOf2I,
744 "flooring-div-by-power-of-2-i")
745 DECLARE_HYDROGEN_ACCESSOR(MathFloorOfDiv)
752 class LFlooringDivByConstI FINAL : public LTemplateInstruction<1, 1, 2> {
754 LFlooringDivByConstI(LOperand* dividend, int32_t divisor, LOperand* temp) {
755 inputs_[0] = dividend;
760 LOperand* dividend() { return inputs_[0]; }
761 int32_t divisor() const { return divisor_; }
762 LOperand* temp() { return temps_[0]; }
764 DECLARE_CONCRETE_INSTRUCTION(FlooringDivByConstI, "flooring-div-by-const-i")
765 DECLARE_HYDROGEN_ACCESSOR(MathFloorOfDiv)
772 class LFlooringDivI FINAL : public LTemplateInstruction<1, 2, 1> {
774 LFlooringDivI(LOperand* dividend, LOperand* divisor, LOperand* temp) {
775 inputs_[0] = dividend;
776 inputs_[1] = divisor;
780 LOperand* dividend() { return inputs_[0]; }
781 LOperand* divisor() { return inputs_[1]; }
782 LOperand* temp() { return temps_[0]; }
784 DECLARE_CONCRETE_INSTRUCTION(FlooringDivI, "flooring-div-i")
785 DECLARE_HYDROGEN_ACCESSOR(MathFloorOfDiv)
789 class LMulI FINAL : public LTemplateInstruction<1, 2, 0> {
791 LMulI(LOperand* left, LOperand* right) {
796 LOperand* left() { return inputs_[0]; }
797 LOperand* right() { return inputs_[1]; }
799 DECLARE_CONCRETE_INSTRUCTION(MulI, "mul-i")
800 DECLARE_HYDROGEN_ACCESSOR(Mul)
804 // Instruction for computing multiplier * multiplicand + addend.
805 class LMultiplyAddD FINAL : public LTemplateInstruction<1, 3, 0> {
807 LMultiplyAddD(LOperand* addend, LOperand* multiplier,
808 LOperand* multiplicand) {
810 inputs_[1] = multiplier;
811 inputs_[2] = multiplicand;
814 LOperand* addend() { return inputs_[0]; }
815 LOperand* multiplier() { return inputs_[1]; }
816 LOperand* multiplicand() { return inputs_[2]; }
818 DECLARE_CONCRETE_INSTRUCTION(MultiplyAddD, "multiply-add-d")
822 // Instruction for computing minuend - multiplier * multiplicand.
823 class LMultiplySubD FINAL : public LTemplateInstruction<1, 3, 0> {
825 LMultiplySubD(LOperand* minuend, LOperand* multiplier,
826 LOperand* multiplicand) {
827 inputs_[0] = minuend;
828 inputs_[1] = multiplier;
829 inputs_[2] = multiplicand;
832 LOperand* minuend() { return inputs_[0]; }
833 LOperand* multiplier() { return inputs_[1]; }
834 LOperand* multiplicand() { return inputs_[2]; }
836 DECLARE_CONCRETE_INSTRUCTION(MultiplySubD, "multiply-sub-d")
840 class LDebugBreak FINAL : public LTemplateInstruction<0, 0, 0> {
842 DECLARE_CONCRETE_INSTRUCTION(DebugBreak, "break")
846 class LCompareNumericAndBranch FINAL : public LControlInstruction<2, 0> {
848 LCompareNumericAndBranch(LOperand* left, LOperand* right) {
853 LOperand* left() { return inputs_[0]; }
854 LOperand* right() { return inputs_[1]; }
856 DECLARE_CONCRETE_INSTRUCTION(CompareNumericAndBranch,
857 "compare-numeric-and-branch")
858 DECLARE_HYDROGEN_ACCESSOR(CompareNumericAndBranch)
860 Token::Value op() const { return hydrogen()->token(); }
861 bool is_double() const {
862 return hydrogen()->representation().IsDouble();
865 void PrintDataTo(StringStream* stream) OVERRIDE;
869 class LMathFloor FINAL : public LTemplateInstruction<1, 1, 0> {
871 explicit LMathFloor(LOperand* value) {
875 LOperand* value() { return inputs_[0]; }
877 DECLARE_CONCRETE_INSTRUCTION(MathFloor, "math-floor")
878 DECLARE_HYDROGEN_ACCESSOR(UnaryMathOperation)
882 class LMathRound FINAL : public LTemplateInstruction<1, 1, 1> {
884 LMathRound(LOperand* value, LOperand* temp) {
889 LOperand* value() { return inputs_[0]; }
890 LOperand* temp() { return temps_[0]; }
892 DECLARE_CONCRETE_INSTRUCTION(MathRound, "math-round")
893 DECLARE_HYDROGEN_ACCESSOR(UnaryMathOperation)
897 class LMathFround FINAL : public LTemplateInstruction<1, 1, 0> {
899 explicit LMathFround(LOperand* value) { inputs_[0] = value; }
901 LOperand* value() { return inputs_[0]; }
903 DECLARE_CONCRETE_INSTRUCTION(MathFround, "math-fround")
907 class LMathAbs FINAL : public LTemplateInstruction<1, 2, 0> {
909 LMathAbs(LOperand* context, LOperand* value) {
910 inputs_[1] = context;
914 LOperand* context() { return inputs_[1]; }
915 LOperand* value() { return inputs_[0]; }
917 DECLARE_CONCRETE_INSTRUCTION(MathAbs, "math-abs")
918 DECLARE_HYDROGEN_ACCESSOR(UnaryMathOperation)
922 class LMathLog FINAL : public LTemplateInstruction<1, 1, 0> {
924 explicit LMathLog(LOperand* value) {
928 LOperand* value() { return inputs_[0]; }
930 DECLARE_CONCRETE_INSTRUCTION(MathLog, "math-log")
934 class LMathClz32 FINAL : public LTemplateInstruction<1, 1, 0> {
936 explicit LMathClz32(LOperand* value) {
940 LOperand* value() { return inputs_[0]; }
942 DECLARE_CONCRETE_INSTRUCTION(MathClz32, "math-clz32")
946 class LMathExp FINAL : public LTemplateInstruction<1, 1, 3> {
948 LMathExp(LOperand* value,
949 LOperand* double_temp,
955 temps_[2] = double_temp;
956 ExternalReference::InitializeMathExpData();
959 LOperand* value() { return inputs_[0]; }
960 LOperand* temp1() { return temps_[0]; }
961 LOperand* temp2() { return temps_[1]; }
962 LOperand* double_temp() { return temps_[2]; }
964 DECLARE_CONCRETE_INSTRUCTION(MathExp, "math-exp")
968 class LMathSqrt FINAL : public LTemplateInstruction<1, 1, 0> {
970 explicit LMathSqrt(LOperand* value) {
974 LOperand* value() { return inputs_[0]; }
976 DECLARE_CONCRETE_INSTRUCTION(MathSqrt, "math-sqrt")
980 class LMathPowHalf FINAL : public LTemplateInstruction<1, 1, 0> {
982 explicit LMathPowHalf(LOperand* value) {
986 LOperand* value() { return inputs_[0]; }
988 DECLARE_CONCRETE_INSTRUCTION(MathPowHalf, "math-pow-half")
992 class LCmpObjectEqAndBranch FINAL : public LControlInstruction<2, 0> {
994 LCmpObjectEqAndBranch(LOperand* left, LOperand* right) {
999 LOperand* left() { return inputs_[0]; }
1000 LOperand* right() { return inputs_[1]; }
1002 DECLARE_CONCRETE_INSTRUCTION(CmpObjectEqAndBranch, "cmp-object-eq-and-branch")
1003 DECLARE_HYDROGEN_ACCESSOR(CompareObjectEqAndBranch)
1007 class LCmpHoleAndBranch FINAL : public LControlInstruction<1, 0> {
1009 explicit LCmpHoleAndBranch(LOperand* object) {
1010 inputs_[0] = object;
1013 LOperand* object() { return inputs_[0]; }
1015 DECLARE_CONCRETE_INSTRUCTION(CmpHoleAndBranch, "cmp-hole-and-branch")
1016 DECLARE_HYDROGEN_ACCESSOR(CompareHoleAndBranch)
1020 class LCompareMinusZeroAndBranch FINAL : public LControlInstruction<1, 1> {
1022 LCompareMinusZeroAndBranch(LOperand* value, LOperand* temp) {
1027 LOperand* value() { return inputs_[0]; }
1028 LOperand* temp() { return temps_[0]; }
1030 DECLARE_CONCRETE_INSTRUCTION(CompareMinusZeroAndBranch,
1031 "cmp-minus-zero-and-branch")
1032 DECLARE_HYDROGEN_ACCESSOR(CompareMinusZeroAndBranch)
1036 class LIsObjectAndBranch FINAL : public LControlInstruction<1, 1> {
1038 LIsObjectAndBranch(LOperand* value, LOperand* temp) {
1043 LOperand* value() { return inputs_[0]; }
1044 LOperand* temp() { return temps_[0]; }
1046 DECLARE_CONCRETE_INSTRUCTION(IsObjectAndBranch, "is-object-and-branch")
1047 DECLARE_HYDROGEN_ACCESSOR(IsObjectAndBranch)
1049 void PrintDataTo(StringStream* stream) OVERRIDE;
1053 class LIsStringAndBranch FINAL : public LControlInstruction<1, 1> {
1055 LIsStringAndBranch(LOperand* value, LOperand* temp) {
1060 LOperand* value() { return inputs_[0]; }
1061 LOperand* temp() { return temps_[0]; }
1063 DECLARE_CONCRETE_INSTRUCTION(IsStringAndBranch, "is-string-and-branch")
1064 DECLARE_HYDROGEN_ACCESSOR(IsStringAndBranch)
1066 void PrintDataTo(StringStream* stream) OVERRIDE;
1070 class LIsSmiAndBranch FINAL : public LControlInstruction<1, 0> {
1072 explicit LIsSmiAndBranch(LOperand* value) {
1076 LOperand* value() { return inputs_[0]; }
1078 DECLARE_CONCRETE_INSTRUCTION(IsSmiAndBranch, "is-smi-and-branch")
1079 DECLARE_HYDROGEN_ACCESSOR(IsSmiAndBranch)
1081 void PrintDataTo(StringStream* stream) OVERRIDE;
1085 class LIsUndetectableAndBranch FINAL : public LControlInstruction<1, 1> {
1087 explicit LIsUndetectableAndBranch(LOperand* value, LOperand* temp) {
1092 LOperand* value() { return inputs_[0]; }
1093 LOperand* temp() { return temps_[0]; }
1095 DECLARE_CONCRETE_INSTRUCTION(IsUndetectableAndBranch,
1096 "is-undetectable-and-branch")
1097 DECLARE_HYDROGEN_ACCESSOR(IsUndetectableAndBranch)
1099 void PrintDataTo(StringStream* stream) OVERRIDE;
1103 class LStringCompareAndBranch FINAL : public LControlInstruction<3, 0> {
1105 LStringCompareAndBranch(LOperand* context, LOperand* left, LOperand* right) {
1106 inputs_[0] = context;
1111 LOperand* context() { return inputs_[0]; }
1112 LOperand* left() { return inputs_[1]; }
1113 LOperand* right() { return inputs_[2]; }
1115 DECLARE_CONCRETE_INSTRUCTION(StringCompareAndBranch,
1116 "string-compare-and-branch")
1117 DECLARE_HYDROGEN_ACCESSOR(StringCompareAndBranch)
1119 Token::Value op() const { return hydrogen()->token(); }
1121 void PrintDataTo(StringStream* stream) OVERRIDE;
1125 class LHasInstanceTypeAndBranch FINAL : public LControlInstruction<1, 0> {
1127 explicit LHasInstanceTypeAndBranch(LOperand* value) {
1131 LOperand* value() { return inputs_[0]; }
1133 DECLARE_CONCRETE_INSTRUCTION(HasInstanceTypeAndBranch,
1134 "has-instance-type-and-branch")
1135 DECLARE_HYDROGEN_ACCESSOR(HasInstanceTypeAndBranch)
1137 void PrintDataTo(StringStream* stream) OVERRIDE;
1141 class LGetCachedArrayIndex FINAL : public LTemplateInstruction<1, 1, 0> {
1143 explicit LGetCachedArrayIndex(LOperand* value) {
1147 LOperand* value() { return inputs_[0]; }
1149 DECLARE_CONCRETE_INSTRUCTION(GetCachedArrayIndex, "get-cached-array-index")
1150 DECLARE_HYDROGEN_ACCESSOR(GetCachedArrayIndex)
1154 class LHasCachedArrayIndexAndBranch FINAL
1155 : public LControlInstruction<1, 0> {
1157 explicit LHasCachedArrayIndexAndBranch(LOperand* value) {
1161 LOperand* value() { return inputs_[0]; }
1163 DECLARE_CONCRETE_INSTRUCTION(HasCachedArrayIndexAndBranch,
1164 "has-cached-array-index-and-branch")
1165 DECLARE_HYDROGEN_ACCESSOR(HasCachedArrayIndexAndBranch)
1167 void PrintDataTo(StringStream* stream) OVERRIDE;
1171 class LClassOfTestAndBranch FINAL : public LControlInstruction<1, 1> {
1173 LClassOfTestAndBranch(LOperand* value, LOperand* temp) {
1178 LOperand* value() { return inputs_[0]; }
1179 LOperand* temp() { return temps_[0]; }
1181 DECLARE_CONCRETE_INSTRUCTION(ClassOfTestAndBranch,
1182 "class-of-test-and-branch")
1183 DECLARE_HYDROGEN_ACCESSOR(ClassOfTestAndBranch)
1185 void PrintDataTo(StringStream* stream) OVERRIDE;
1189 class LCmpT FINAL : public LTemplateInstruction<1, 3, 0> {
1191 LCmpT(LOperand* context, LOperand* left, LOperand* right) {
1192 inputs_[0] = context;
1197 LOperand* context() { return inputs_[0]; }
1198 LOperand* left() { return inputs_[1]; }
1199 LOperand* right() { return inputs_[2]; }
1201 DECLARE_CONCRETE_INSTRUCTION(CmpT, "cmp-t")
1202 DECLARE_HYDROGEN_ACCESSOR(CompareGeneric)
1204 Token::Value op() const { return hydrogen()->token(); }
1208 class LInstanceOf FINAL : public LTemplateInstruction<1, 3, 0> {
1210 LInstanceOf(LOperand* context, LOperand* left, LOperand* right) {
1211 inputs_[0] = context;
1216 LOperand* context() { return inputs_[0]; }
1217 LOperand* left() { return inputs_[1]; }
1218 LOperand* right() { return inputs_[2]; }
1220 DECLARE_CONCRETE_INSTRUCTION(InstanceOf, "instance-of")
1224 class LInstanceOfKnownGlobal FINAL : public LTemplateInstruction<1, 2, 1> {
1226 LInstanceOfKnownGlobal(LOperand* context, LOperand* value, LOperand* temp) {
1227 inputs_[0] = context;
1232 LOperand* context() { return inputs_[0]; }
1233 LOperand* value() { return inputs_[1]; }
1234 LOperand* temp() { return temps_[0]; }
1236 DECLARE_CONCRETE_INSTRUCTION(InstanceOfKnownGlobal,
1237 "instance-of-known-global")
1238 DECLARE_HYDROGEN_ACCESSOR(InstanceOfKnownGlobal)
1240 Handle<JSFunction> function() const { return hydrogen()->function(); }
1241 LEnvironment* GetDeferredLazyDeoptimizationEnvironment() {
1242 return lazy_deopt_env_;
1244 virtual void SetDeferredLazyDeoptimizationEnvironment(
1245 LEnvironment* env) OVERRIDE {
1246 lazy_deopt_env_ = env;
1250 LEnvironment* lazy_deopt_env_;
1254 class LBoundsCheck FINAL : public LTemplateInstruction<0, 2, 0> {
1256 LBoundsCheck(LOperand* index, LOperand* length) {
1258 inputs_[1] = length;
1261 LOperand* index() { return inputs_[0]; }
1262 LOperand* length() { return inputs_[1]; }
1264 DECLARE_CONCRETE_INSTRUCTION(BoundsCheck, "bounds-check")
1265 DECLARE_HYDROGEN_ACCESSOR(BoundsCheck)
1269 class LBitI FINAL : public LTemplateInstruction<1, 2, 0> {
1271 LBitI(LOperand* left, LOperand* right) {
1276 LOperand* left() { return inputs_[0]; }
1277 LOperand* right() { return inputs_[1]; }
1279 Token::Value op() const { return hydrogen()->op(); }
1281 DECLARE_CONCRETE_INSTRUCTION(BitI, "bit-i")
1282 DECLARE_HYDROGEN_ACCESSOR(Bitwise)
1286 class LShiftI FINAL : public LTemplateInstruction<1, 2, 0> {
1288 LShiftI(Token::Value op, LOperand* left, LOperand* right, bool can_deopt)
1289 : op_(op), can_deopt_(can_deopt) {
1294 Token::Value op() const { return op_; }
1295 LOperand* left() { return inputs_[0]; }
1296 LOperand* right() { return inputs_[1]; }
1297 bool can_deopt() const { return can_deopt_; }
1299 DECLARE_CONCRETE_INSTRUCTION(ShiftI, "shift-i")
1307 class LSubI FINAL : public LTemplateInstruction<1, 2, 0> {
1309 LSubI(LOperand* left, LOperand* right) {
1314 LOperand* left() { return inputs_[0]; }
1315 LOperand* right() { return inputs_[1]; }
1317 DECLARE_CONCRETE_INSTRUCTION(SubI, "sub-i")
1318 DECLARE_HYDROGEN_ACCESSOR(Sub)
1322 class LRSubI FINAL : public LTemplateInstruction<1, 2, 0> {
1324 LRSubI(LOperand* left, LOperand* right) {
1329 LOperand* left() { return inputs_[0]; }
1330 LOperand* right() { return inputs_[1]; }
1332 DECLARE_CONCRETE_INSTRUCTION(RSubI, "rsub-i")
1333 DECLARE_HYDROGEN_ACCESSOR(Sub)
1337 class LConstantI FINAL : public LTemplateInstruction<1, 0, 0> {
1339 DECLARE_CONCRETE_INSTRUCTION(ConstantI, "constant-i")
1340 DECLARE_HYDROGEN_ACCESSOR(Constant)
1342 int32_t value() const { return hydrogen()->Integer32Value(); }
1346 class LConstantS FINAL : public LTemplateInstruction<1, 0, 0> {
1348 DECLARE_CONCRETE_INSTRUCTION(ConstantS, "constant-s")
1349 DECLARE_HYDROGEN_ACCESSOR(Constant)
1351 Smi* value() const { return Smi::FromInt(hydrogen()->Integer32Value()); }
1355 class LConstantD FINAL : public LTemplateInstruction<1, 0, 0> {
1357 DECLARE_CONCRETE_INSTRUCTION(ConstantD, "constant-d")
1358 DECLARE_HYDROGEN_ACCESSOR(Constant)
1360 double value() const { return hydrogen()->DoubleValue(); }
1361 uint64_t bits() const { return hydrogen()->DoubleValueAsBits(); }
1365 class LConstantE FINAL : public LTemplateInstruction<1, 0, 0> {
1367 DECLARE_CONCRETE_INSTRUCTION(ConstantE, "constant-e")
1368 DECLARE_HYDROGEN_ACCESSOR(Constant)
1370 ExternalReference value() const {
1371 return hydrogen()->ExternalReferenceValue();
1376 class LConstantT FINAL : public LTemplateInstruction<1, 0, 0> {
1378 DECLARE_CONCRETE_INSTRUCTION(ConstantT, "constant-t")
1379 DECLARE_HYDROGEN_ACCESSOR(Constant)
1381 Handle<Object> value(Isolate* isolate) const {
1382 return hydrogen()->handle(isolate);
1387 class LBranch FINAL : public LControlInstruction<1, 0> {
1389 explicit LBranch(LOperand* value) {
1393 LOperand* value() { return inputs_[0]; }
1395 DECLARE_CONCRETE_INSTRUCTION(Branch, "branch")
1396 DECLARE_HYDROGEN_ACCESSOR(Branch)
1398 void PrintDataTo(StringStream* stream) OVERRIDE;
1402 class LCmpMapAndBranch FINAL : public LControlInstruction<1, 1> {
1404 LCmpMapAndBranch(LOperand* value, LOperand* temp) {
1409 LOperand* value() { return inputs_[0]; }
1410 LOperand* temp() { return temps_[0]; }
1412 DECLARE_CONCRETE_INSTRUCTION(CmpMapAndBranch, "cmp-map-and-branch")
1413 DECLARE_HYDROGEN_ACCESSOR(CompareMap)
1415 Handle<Map> map() const { return hydrogen()->map().handle(); }
1419 class LMapEnumLength FINAL : public LTemplateInstruction<1, 1, 0> {
1421 explicit LMapEnumLength(LOperand* value) {
1425 LOperand* value() { return inputs_[0]; }
1427 DECLARE_CONCRETE_INSTRUCTION(MapEnumLength, "map-enum-length")
1431 class LDateField FINAL : public LTemplateInstruction<1, 1, 1> {
1433 LDateField(LOperand* date, LOperand* temp, Smi* index) : index_(index) {
1438 LOperand* date() { return inputs_[0]; }
1439 LOperand* temp() { return temps_[0]; }
1440 Smi* index() const { return index_; }
1442 DECLARE_CONCRETE_INSTRUCTION(DateField, "date-field")
1443 DECLARE_HYDROGEN_ACCESSOR(DateField)
1450 class LSeqStringGetChar FINAL : public LTemplateInstruction<1, 2, 0> {
1452 LSeqStringGetChar(LOperand* string, LOperand* index) {
1453 inputs_[0] = string;
1457 LOperand* string() const { return inputs_[0]; }
1458 LOperand* index() const { return inputs_[1]; }
1460 DECLARE_CONCRETE_INSTRUCTION(SeqStringGetChar, "seq-string-get-char")
1461 DECLARE_HYDROGEN_ACCESSOR(SeqStringGetChar)
1465 class LSeqStringSetChar FINAL : public LTemplateInstruction<1, 4, 0> {
1467 LSeqStringSetChar(LOperand* context,
1471 inputs_[0] = context;
1472 inputs_[1] = string;
1477 LOperand* string() { return inputs_[1]; }
1478 LOperand* index() { return inputs_[2]; }
1479 LOperand* value() { return inputs_[3]; }
1481 DECLARE_CONCRETE_INSTRUCTION(SeqStringSetChar, "seq-string-set-char")
1482 DECLARE_HYDROGEN_ACCESSOR(SeqStringSetChar)
1486 class LAddI FINAL : public LTemplateInstruction<1, 2, 0> {
1488 LAddI(LOperand* left, LOperand* right) {
1493 LOperand* left() { return inputs_[0]; }
1494 LOperand* right() { return inputs_[1]; }
1496 DECLARE_CONCRETE_INSTRUCTION(AddI, "add-i")
1497 DECLARE_HYDROGEN_ACCESSOR(Add)
1501 class LMathMinMax FINAL : public LTemplateInstruction<1, 2, 0> {
1503 LMathMinMax(LOperand* left, LOperand* right) {
1508 LOperand* left() { return inputs_[0]; }
1509 LOperand* right() { return inputs_[1]; }
1511 DECLARE_CONCRETE_INSTRUCTION(MathMinMax, "math-min-max")
1512 DECLARE_HYDROGEN_ACCESSOR(MathMinMax)
1516 class LPower FINAL : public LTemplateInstruction<1, 2, 0> {
1518 LPower(LOperand* left, LOperand* right) {
1523 LOperand* left() { return inputs_[0]; }
1524 LOperand* right() { return inputs_[1]; }
1526 DECLARE_CONCRETE_INSTRUCTION(Power, "power")
1527 DECLARE_HYDROGEN_ACCESSOR(Power)
1531 class LArithmeticD FINAL : public LTemplateInstruction<1, 2, 0> {
1533 LArithmeticD(Token::Value op, LOperand* left, LOperand* right)
1539 Token::Value op() const { return op_; }
1540 LOperand* left() { return inputs_[0]; }
1541 LOperand* right() { return inputs_[1]; }
1543 Opcode opcode() const OVERRIDE { return LInstruction::kArithmeticD; }
1544 void CompileToNative(LCodeGen* generator) OVERRIDE;
1545 const char* Mnemonic() const OVERRIDE;
1552 class LArithmeticT FINAL : public LTemplateInstruction<1, 3, 0> {
1554 LArithmeticT(Token::Value op,
1559 inputs_[0] = context;
1564 LOperand* context() { return inputs_[0]; }
1565 LOperand* left() { return inputs_[1]; }
1566 LOperand* right() { return inputs_[2]; }
1567 Token::Value op() const { return op_; }
1569 Opcode opcode() const OVERRIDE { return LInstruction::kArithmeticT; }
1570 void CompileToNative(LCodeGen* generator) OVERRIDE;
1571 const char* Mnemonic() const OVERRIDE;
1578 class LReturn FINAL : public LTemplateInstruction<0, 3, 0> {
1580 LReturn(LOperand* value, LOperand* context, LOperand* parameter_count) {
1582 inputs_[1] = context;
1583 inputs_[2] = parameter_count;
1586 LOperand* value() { return inputs_[0]; }
1588 bool has_constant_parameter_count() {
1589 return parameter_count()->IsConstantOperand();
1591 LConstantOperand* constant_parameter_count() {
1592 DCHECK(has_constant_parameter_count());
1593 return LConstantOperand::cast(parameter_count());
1595 LOperand* parameter_count() { return inputs_[2]; }
1597 DECLARE_CONCRETE_INSTRUCTION(Return, "return")
1601 class LLoadNamedField FINAL : public LTemplateInstruction<1, 1, 0> {
1603 explicit LLoadNamedField(LOperand* object) {
1604 inputs_[0] = object;
1607 LOperand* object() { return inputs_[0]; }
1609 DECLARE_CONCRETE_INSTRUCTION(LoadNamedField, "load-named-field")
1610 DECLARE_HYDROGEN_ACCESSOR(LoadNamedField)
1614 class LLoadNamedGeneric FINAL : public LTemplateInstruction<1, 2, 1> {
1616 LLoadNamedGeneric(LOperand* context, LOperand* object, LOperand* vector) {
1617 inputs_[0] = context;
1618 inputs_[1] = object;
1622 LOperand* context() { return inputs_[0]; }
1623 LOperand* object() { return inputs_[1]; }
1624 LOperand* temp_vector() { return temps_[0]; }
1626 DECLARE_CONCRETE_INSTRUCTION(LoadNamedGeneric, "load-named-generic")
1627 DECLARE_HYDROGEN_ACCESSOR(LoadNamedGeneric)
1629 Handle<Object> name() const { return hydrogen()->name(); }
1633 class LLoadFunctionPrototype FINAL : public LTemplateInstruction<1, 1, 0> {
1635 explicit LLoadFunctionPrototype(LOperand* function) {
1636 inputs_[0] = function;
1639 LOperand* function() { return inputs_[0]; }
1641 DECLARE_CONCRETE_INSTRUCTION(LoadFunctionPrototype, "load-function-prototype")
1642 DECLARE_HYDROGEN_ACCESSOR(LoadFunctionPrototype)
1646 class LLoadRoot FINAL : public LTemplateInstruction<1, 0, 0> {
1648 DECLARE_CONCRETE_INSTRUCTION(LoadRoot, "load-root")
1649 DECLARE_HYDROGEN_ACCESSOR(LoadRoot)
1651 Heap::RootListIndex index() const { return hydrogen()->index(); }
1655 class LLoadKeyed FINAL : public LTemplateInstruction<1, 2, 0> {
1657 LLoadKeyed(LOperand* elements, LOperand* key) {
1658 inputs_[0] = elements;
1662 LOperand* elements() { return inputs_[0]; }
1663 LOperand* key() { return inputs_[1]; }
1664 ElementsKind elements_kind() const {
1665 return hydrogen()->elements_kind();
1667 bool is_external() const {
1668 return hydrogen()->is_external();
1670 bool is_fixed_typed_array() const {
1671 return hydrogen()->is_fixed_typed_array();
1673 bool is_typed_elements() const {
1674 return is_external() || is_fixed_typed_array();
1677 DECLARE_CONCRETE_INSTRUCTION(LoadKeyed, "load-keyed")
1678 DECLARE_HYDROGEN_ACCESSOR(LoadKeyed)
1680 void PrintDataTo(StringStream* stream) OVERRIDE;
1681 uint32_t base_offset() const { return hydrogen()->base_offset(); }
1685 class LLoadKeyedGeneric FINAL : public LTemplateInstruction<1, 3, 1> {
1687 LLoadKeyedGeneric(LOperand* context, LOperand* object, LOperand* key,
1689 inputs_[0] = context;
1690 inputs_[1] = object;
1695 LOperand* context() { return inputs_[0]; }
1696 LOperand* object() { return inputs_[1]; }
1697 LOperand* key() { return inputs_[2]; }
1698 LOperand* temp_vector() { return temps_[0]; }
1700 DECLARE_CONCRETE_INSTRUCTION(LoadKeyedGeneric, "load-keyed-generic")
1701 DECLARE_HYDROGEN_ACCESSOR(LoadKeyedGeneric)
1705 class LLoadGlobalGeneric FINAL : public LTemplateInstruction<1, 2, 1> {
1707 LLoadGlobalGeneric(LOperand* context, LOperand* global_object,
1709 inputs_[0] = context;
1710 inputs_[1] = global_object;
1714 LOperand* context() { return inputs_[0]; }
1715 LOperand* global_object() { return inputs_[1]; }
1716 LOperand* temp_vector() { return temps_[0]; }
1718 DECLARE_CONCRETE_INSTRUCTION(LoadGlobalGeneric, "load-global-generic")
1719 DECLARE_HYDROGEN_ACCESSOR(LoadGlobalGeneric)
1721 Handle<Object> name() const { return hydrogen()->name(); }
1722 bool for_typeof() const { return hydrogen()->for_typeof(); }
1726 class LLoadContextSlot FINAL : public LTemplateInstruction<1, 1, 0> {
1728 explicit LLoadContextSlot(LOperand* context) {
1729 inputs_[0] = context;
1732 LOperand* context() { return inputs_[0]; }
1734 DECLARE_CONCRETE_INSTRUCTION(LoadContextSlot, "load-context-slot")
1735 DECLARE_HYDROGEN_ACCESSOR(LoadContextSlot)
1737 int slot_index() { return hydrogen()->slot_index(); }
1739 void PrintDataTo(StringStream* stream) OVERRIDE;
1743 class LStoreContextSlot FINAL : public LTemplateInstruction<0, 2, 0> {
1745 LStoreContextSlot(LOperand* context, LOperand* value) {
1746 inputs_[0] = context;
1750 LOperand* context() { return inputs_[0]; }
1751 LOperand* value() { return inputs_[1]; }
1753 DECLARE_CONCRETE_INSTRUCTION(StoreContextSlot, "store-context-slot")
1754 DECLARE_HYDROGEN_ACCESSOR(StoreContextSlot)
1756 int slot_index() { return hydrogen()->slot_index(); }
1758 void PrintDataTo(StringStream* stream) OVERRIDE;
1762 class LPushArgument FINAL : public LTemplateInstruction<0, 1, 0> {
1764 explicit LPushArgument(LOperand* value) {
1768 LOperand* value() { return inputs_[0]; }
1770 DECLARE_CONCRETE_INSTRUCTION(PushArgument, "push-argument")
1774 class LDrop FINAL : public LTemplateInstruction<0, 0, 0> {
1776 explicit LDrop(int count) : count_(count) { }
1778 int count() const { return count_; }
1780 DECLARE_CONCRETE_INSTRUCTION(Drop, "drop")
1787 class LStoreCodeEntry FINAL: public LTemplateInstruction<0, 2, 0> {
1789 LStoreCodeEntry(LOperand* function, LOperand* code_object) {
1790 inputs_[0] = function;
1791 inputs_[1] = code_object;
1794 LOperand* function() { return inputs_[0]; }
1795 LOperand* code_object() { return inputs_[1]; }
1797 void PrintDataTo(StringStream* stream) OVERRIDE;
1799 DECLARE_CONCRETE_INSTRUCTION(StoreCodeEntry, "store-code-entry")
1800 DECLARE_HYDROGEN_ACCESSOR(StoreCodeEntry)
1804 class LInnerAllocatedObject FINAL: public LTemplateInstruction<1, 2, 0> {
1806 LInnerAllocatedObject(LOperand* base_object, LOperand* offset) {
1807 inputs_[0] = base_object;
1808 inputs_[1] = offset;
1811 LOperand* base_object() const { return inputs_[0]; }
1812 LOperand* offset() const { return inputs_[1]; }
1814 void PrintDataTo(StringStream* stream) OVERRIDE;
1816 DECLARE_CONCRETE_INSTRUCTION(InnerAllocatedObject, "inner-allocated-object")
1820 class LThisFunction FINAL : public LTemplateInstruction<1, 0, 0> {
1822 DECLARE_CONCRETE_INSTRUCTION(ThisFunction, "this-function")
1823 DECLARE_HYDROGEN_ACCESSOR(ThisFunction)
1827 class LContext FINAL : public LTemplateInstruction<1, 0, 0> {
1829 DECLARE_CONCRETE_INSTRUCTION(Context, "context")
1830 DECLARE_HYDROGEN_ACCESSOR(Context)
1834 class LDeclareGlobals FINAL : public LTemplateInstruction<0, 1, 0> {
1836 explicit LDeclareGlobals(LOperand* context) {
1837 inputs_[0] = context;
1840 LOperand* context() { return inputs_[0]; }
1842 DECLARE_CONCRETE_INSTRUCTION(DeclareGlobals, "declare-globals")
1843 DECLARE_HYDROGEN_ACCESSOR(DeclareGlobals)
1847 class LCallJSFunction FINAL : public LTemplateInstruction<1, 1, 0> {
1849 explicit LCallJSFunction(LOperand* function) {
1850 inputs_[0] = function;
1853 LOperand* function() { return inputs_[0]; }
1855 DECLARE_CONCRETE_INSTRUCTION(CallJSFunction, "call-js-function")
1856 DECLARE_HYDROGEN_ACCESSOR(CallJSFunction)
1858 void PrintDataTo(StringStream* stream) OVERRIDE;
1860 int arity() const { return hydrogen()->argument_count() - 1; }
1864 class LCallWithDescriptor FINAL : public LTemplateResultInstruction<1> {
1866 LCallWithDescriptor(CallInterfaceDescriptor descriptor,
1867 const ZoneList<LOperand*>& operands, Zone* zone)
1868 : descriptor_(descriptor),
1869 inputs_(descriptor.GetRegisterParameterCount() + 1, zone) {
1870 DCHECK(descriptor.GetRegisterParameterCount() + 1 == operands.length());
1871 inputs_.AddAll(operands, zone);
1874 LOperand* target() const { return inputs_[0]; }
1876 const CallInterfaceDescriptor descriptor() { return descriptor_; }
1878 DECLARE_HYDROGEN_ACCESSOR(CallWithDescriptor)
1881 DECLARE_CONCRETE_INSTRUCTION(CallWithDescriptor, "call-with-descriptor")
1883 void PrintDataTo(StringStream* stream) OVERRIDE;
1885 int arity() const { return hydrogen()->argument_count() - 1; }
1887 CallInterfaceDescriptor descriptor_;
1888 ZoneList<LOperand*> inputs_;
1890 // Iterator support.
1891 int InputCount() FINAL { return inputs_.length(); }
1892 LOperand* InputAt(int i) FINAL { return inputs_[i]; }
1894 int TempCount() FINAL { return 0; }
1895 LOperand* TempAt(int i) FINAL { return NULL; }
1899 class LInvokeFunction FINAL : public LTemplateInstruction<1, 2, 0> {
1901 LInvokeFunction(LOperand* context, LOperand* function) {
1902 inputs_[0] = context;
1903 inputs_[1] = function;
1906 LOperand* context() { return inputs_[0]; }
1907 LOperand* function() { return inputs_[1]; }
1909 DECLARE_CONCRETE_INSTRUCTION(InvokeFunction, "invoke-function")
1910 DECLARE_HYDROGEN_ACCESSOR(InvokeFunction)
1912 void PrintDataTo(StringStream* stream) OVERRIDE;
1914 int arity() const { return hydrogen()->argument_count() - 1; }
1918 class LCallFunction FINAL : public LTemplateInstruction<1, 2, 2> {
1920 LCallFunction(LOperand* context, LOperand* function, LOperand* slot,
1922 inputs_[0] = context;
1923 inputs_[1] = function;
1928 LOperand* context() { return inputs_[0]; }
1929 LOperand* function() { return inputs_[1]; }
1930 LOperand* temp_slot() { return temps_[0]; }
1931 LOperand* temp_vector() { return temps_[1]; }
1933 DECLARE_CONCRETE_INSTRUCTION(CallFunction, "call-function")
1934 DECLARE_HYDROGEN_ACCESSOR(CallFunction)
1936 int arity() const { return hydrogen()->argument_count() - 1; }
1937 void PrintDataTo(StringStream* stream) OVERRIDE;
1941 class LCallNew FINAL : public LTemplateInstruction<1, 2, 0> {
1943 LCallNew(LOperand* context, LOperand* constructor) {
1944 inputs_[0] = context;
1945 inputs_[1] = constructor;
1948 LOperand* context() { return inputs_[0]; }
1949 LOperand* constructor() { return inputs_[1]; }
1951 DECLARE_CONCRETE_INSTRUCTION(CallNew, "call-new")
1952 DECLARE_HYDROGEN_ACCESSOR(CallNew)
1954 void PrintDataTo(StringStream* stream) OVERRIDE;
1956 int arity() const { return hydrogen()->argument_count() - 1; }
1960 class LCallNewArray FINAL : public LTemplateInstruction<1, 2, 0> {
1962 LCallNewArray(LOperand* context, LOperand* constructor) {
1963 inputs_[0] = context;
1964 inputs_[1] = constructor;
1967 LOperand* context() { return inputs_[0]; }
1968 LOperand* constructor() { return inputs_[1]; }
1970 DECLARE_CONCRETE_INSTRUCTION(CallNewArray, "call-new-array")
1971 DECLARE_HYDROGEN_ACCESSOR(CallNewArray)
1973 void PrintDataTo(StringStream* stream) OVERRIDE;
1975 int arity() const { return hydrogen()->argument_count() - 1; }
1979 class LCallRuntime FINAL : public LTemplateInstruction<1, 1, 0> {
1981 explicit LCallRuntime(LOperand* context) {
1982 inputs_[0] = context;
1985 LOperand* context() { return inputs_[0]; }
1987 DECLARE_CONCRETE_INSTRUCTION(CallRuntime, "call-runtime")
1988 DECLARE_HYDROGEN_ACCESSOR(CallRuntime)
1990 bool ClobbersDoubleRegisters(Isolate* isolate) const OVERRIDE {
1991 return save_doubles() == kDontSaveFPRegs;
1994 const Runtime::Function* function() const { return hydrogen()->function(); }
1995 int arity() const { return hydrogen()->argument_count(); }
1996 SaveFPRegsMode save_doubles() const { return hydrogen()->save_doubles(); }
2000 class LInteger32ToDouble FINAL : public LTemplateInstruction<1, 1, 0> {
2002 explicit LInteger32ToDouble(LOperand* value) {
2006 LOperand* value() { return inputs_[0]; }
2008 DECLARE_CONCRETE_INSTRUCTION(Integer32ToDouble, "int32-to-double")
2012 class LUint32ToDouble FINAL : public LTemplateInstruction<1, 1, 0> {
2014 explicit LUint32ToDouble(LOperand* value) {
2018 LOperand* value() { return inputs_[0]; }
2020 DECLARE_CONCRETE_INSTRUCTION(Uint32ToDouble, "uint32-to-double")
2024 class LNumberTagI FINAL : public LTemplateInstruction<1, 1, 2> {
2026 LNumberTagI(LOperand* value, LOperand* temp1, LOperand* temp2) {
2032 LOperand* value() { return inputs_[0]; }
2033 LOperand* temp1() { return temps_[0]; }
2034 LOperand* temp2() { return temps_[1]; }
2036 DECLARE_CONCRETE_INSTRUCTION(NumberTagI, "number-tag-i")
2040 class LNumberTagU FINAL : public LTemplateInstruction<1, 1, 2> {
2042 LNumberTagU(LOperand* value, LOperand* temp1, LOperand* temp2) {
2048 LOperand* value() { return inputs_[0]; }
2049 LOperand* temp1() { return temps_[0]; }
2050 LOperand* temp2() { return temps_[1]; }
2052 DECLARE_CONCRETE_INSTRUCTION(NumberTagU, "number-tag-u")
2056 class LNumberTagD FINAL : public LTemplateInstruction<1, 1, 2> {
2058 LNumberTagD(LOperand* value, LOperand* temp, LOperand* temp2) {
2064 LOperand* value() { return inputs_[0]; }
2065 LOperand* temp() { return temps_[0]; }
2066 LOperand* temp2() { return temps_[1]; }
2068 DECLARE_CONCRETE_INSTRUCTION(NumberTagD, "number-tag-d")
2069 DECLARE_HYDROGEN_ACCESSOR(Change)
2073 class LDoubleToSmi FINAL : public LTemplateInstruction<1, 1, 0> {
2075 explicit LDoubleToSmi(LOperand* value) {
2079 LOperand* value() { return inputs_[0]; }
2081 DECLARE_CONCRETE_INSTRUCTION(DoubleToSmi, "double-to-smi")
2082 DECLARE_HYDROGEN_ACCESSOR(UnaryOperation)
2084 bool truncating() { return hydrogen()->CanTruncateToInt32(); }
2088 // Sometimes truncating conversion from a tagged value to an int32.
2089 class LDoubleToI FINAL : public LTemplateInstruction<1, 1, 0> {
2091 explicit LDoubleToI(LOperand* value) {
2095 LOperand* value() { return inputs_[0]; }
2097 DECLARE_CONCRETE_INSTRUCTION(DoubleToI, "double-to-i")
2098 DECLARE_HYDROGEN_ACCESSOR(UnaryOperation)
2100 bool truncating() { return hydrogen()->CanTruncateToInt32(); }
2104 // Truncating conversion from a tagged value to an int32.
2105 class LTaggedToI FINAL : public LTemplateInstruction<1, 1, 2> {
2107 LTaggedToI(LOperand* value,
2115 LOperand* value() { return inputs_[0]; }
2116 LOperand* temp() { return temps_[0]; }
2117 LOperand* temp2() { return temps_[1]; }
2119 DECLARE_CONCRETE_INSTRUCTION(TaggedToI, "tagged-to-i")
2120 DECLARE_HYDROGEN_ACCESSOR(Change)
2122 bool truncating() { return hydrogen()->CanTruncateToInt32(); }
2126 class LSmiTag FINAL : public LTemplateInstruction<1, 1, 0> {
2128 explicit LSmiTag(LOperand* value) {
2132 LOperand* value() { return inputs_[0]; }
2134 DECLARE_CONCRETE_INSTRUCTION(SmiTag, "smi-tag")
2135 DECLARE_HYDROGEN_ACCESSOR(Change)
2139 class LNumberUntagD FINAL : public LTemplateInstruction<1, 1, 0> {
2141 explicit LNumberUntagD(LOperand* value) {
2145 LOperand* value() { return inputs_[0]; }
2147 DECLARE_CONCRETE_INSTRUCTION(NumberUntagD, "double-untag")
2148 DECLARE_HYDROGEN_ACCESSOR(Change)
2152 class LSmiUntag FINAL : public LTemplateInstruction<1, 1, 0> {
2154 LSmiUntag(LOperand* value, bool needs_check)
2155 : needs_check_(needs_check) {
2159 LOperand* value() { return inputs_[0]; }
2160 bool needs_check() const { return needs_check_; }
2162 DECLARE_CONCRETE_INSTRUCTION(SmiUntag, "smi-untag")
2169 class LStoreNamedField FINAL : public LTemplateInstruction<0, 2, 1> {
2171 LStoreNamedField(LOperand* object, LOperand* value, LOperand* temp) {
2172 inputs_[0] = object;
2177 LOperand* object() { return inputs_[0]; }
2178 LOperand* value() { return inputs_[1]; }
2179 LOperand* temp() { return temps_[0]; }
2181 DECLARE_CONCRETE_INSTRUCTION(StoreNamedField, "store-named-field")
2182 DECLARE_HYDROGEN_ACCESSOR(StoreNamedField)
2184 void PrintDataTo(StringStream* stream) OVERRIDE;
2186 Representation representation() const {
2187 return hydrogen()->field_representation();
2192 class LStoreNamedGeneric FINAL : public LTemplateInstruction<0, 3, 0> {
2194 LStoreNamedGeneric(LOperand* context, LOperand* object, LOperand* value) {
2195 inputs_[0] = context;
2196 inputs_[1] = object;
2200 LOperand* context() { return inputs_[0]; }
2201 LOperand* object() { return inputs_[1]; }
2202 LOperand* value() { return inputs_[2]; }
2204 DECLARE_CONCRETE_INSTRUCTION(StoreNamedGeneric, "store-named-generic")
2205 DECLARE_HYDROGEN_ACCESSOR(StoreNamedGeneric)
2207 void PrintDataTo(StringStream* stream) OVERRIDE;
2209 Handle<Object> name() const { return hydrogen()->name(); }
2210 LanguageMode language_mode() { return hydrogen()->language_mode(); }
2214 class LStoreKeyed FINAL : public LTemplateInstruction<0, 3, 0> {
2216 LStoreKeyed(LOperand* object, LOperand* key, LOperand* value) {
2217 inputs_[0] = object;
2222 bool is_external() const { return hydrogen()->is_external(); }
2223 bool is_fixed_typed_array() const {
2224 return hydrogen()->is_fixed_typed_array();
2226 bool is_typed_elements() const {
2227 return is_external() || is_fixed_typed_array();
2229 LOperand* elements() { return inputs_[0]; }
2230 LOperand* key() { return inputs_[1]; }
2231 LOperand* value() { return inputs_[2]; }
2232 ElementsKind elements_kind() const {
2233 return hydrogen()->elements_kind();
2236 DECLARE_CONCRETE_INSTRUCTION(StoreKeyed, "store-keyed")
2237 DECLARE_HYDROGEN_ACCESSOR(StoreKeyed)
2239 void PrintDataTo(StringStream* stream) OVERRIDE;
2240 bool NeedsCanonicalization() {
2241 if (hydrogen()->value()->IsAdd() || hydrogen()->value()->IsSub() ||
2242 hydrogen()->value()->IsMul() || hydrogen()->value()->IsDiv()) {
2245 return hydrogen()->NeedsCanonicalization();
2247 uint32_t base_offset() const { return hydrogen()->base_offset(); }
2251 class LStoreKeyedGeneric FINAL : public LTemplateInstruction<0, 4, 0> {
2253 LStoreKeyedGeneric(LOperand* context,
2257 inputs_[0] = context;
2263 LOperand* context() { return inputs_[0]; }
2264 LOperand* object() { return inputs_[1]; }
2265 LOperand* key() { return inputs_[2]; }
2266 LOperand* value() { return inputs_[3]; }
2268 DECLARE_CONCRETE_INSTRUCTION(StoreKeyedGeneric, "store-keyed-generic")
2269 DECLARE_HYDROGEN_ACCESSOR(StoreKeyedGeneric)
2271 void PrintDataTo(StringStream* stream) OVERRIDE;
2273 LanguageMode language_mode() { return hydrogen()->language_mode(); }
2277 class LTransitionElementsKind FINAL : public LTemplateInstruction<0, 2, 1> {
2279 LTransitionElementsKind(LOperand* object,
2281 LOperand* new_map_temp) {
2282 inputs_[0] = object;
2283 inputs_[1] = context;
2284 temps_[0] = new_map_temp;
2287 LOperand* context() { return inputs_[1]; }
2288 LOperand* object() { return inputs_[0]; }
2289 LOperand* new_map_temp() { return temps_[0]; }
2291 DECLARE_CONCRETE_INSTRUCTION(TransitionElementsKind,
2292 "transition-elements-kind")
2293 DECLARE_HYDROGEN_ACCESSOR(TransitionElementsKind)
2295 void PrintDataTo(StringStream* stream) OVERRIDE;
2297 Handle<Map> original_map() { return hydrogen()->original_map().handle(); }
2298 Handle<Map> transitioned_map() {
2299 return hydrogen()->transitioned_map().handle();
2301 ElementsKind from_kind() { return hydrogen()->from_kind(); }
2302 ElementsKind to_kind() { return hydrogen()->to_kind(); }
2306 class LTrapAllocationMemento FINAL : public LTemplateInstruction<0, 1, 1> {
2308 LTrapAllocationMemento(LOperand* object,
2310 inputs_[0] = object;
2314 LOperand* object() { return inputs_[0]; }
2315 LOperand* temp() { return temps_[0]; }
2317 DECLARE_CONCRETE_INSTRUCTION(TrapAllocationMemento,
2318 "trap-allocation-memento")
2322 class LStringAdd FINAL : public LTemplateInstruction<1, 3, 0> {
2324 LStringAdd(LOperand* context, LOperand* left, LOperand* right) {
2325 inputs_[0] = context;
2330 LOperand* context() { return inputs_[0]; }
2331 LOperand* left() { return inputs_[1]; }
2332 LOperand* right() { return inputs_[2]; }
2334 DECLARE_CONCRETE_INSTRUCTION(StringAdd, "string-add")
2335 DECLARE_HYDROGEN_ACCESSOR(StringAdd)
2340 class LStringCharCodeAt FINAL : public LTemplateInstruction<1, 3, 0> {
2342 LStringCharCodeAt(LOperand* context, LOperand* string, LOperand* index) {
2343 inputs_[0] = context;
2344 inputs_[1] = string;
2348 LOperand* context() { return inputs_[0]; }
2349 LOperand* string() { return inputs_[1]; }
2350 LOperand* index() { return inputs_[2]; }
2352 DECLARE_CONCRETE_INSTRUCTION(StringCharCodeAt, "string-char-code-at")
2353 DECLARE_HYDROGEN_ACCESSOR(StringCharCodeAt)
2357 class LStringCharFromCode FINAL : public LTemplateInstruction<1, 2, 0> {
2359 explicit LStringCharFromCode(LOperand* context, LOperand* char_code) {
2360 inputs_[0] = context;
2361 inputs_[1] = char_code;
2364 LOperand* context() { return inputs_[0]; }
2365 LOperand* char_code() { return inputs_[1]; }
2367 DECLARE_CONCRETE_INSTRUCTION(StringCharFromCode, "string-char-from-code")
2368 DECLARE_HYDROGEN_ACCESSOR(StringCharFromCode)
2372 class LCheckValue FINAL : public LTemplateInstruction<0, 1, 0> {
2374 explicit LCheckValue(LOperand* value) {
2378 LOperand* value() { return inputs_[0]; }
2380 DECLARE_CONCRETE_INSTRUCTION(CheckValue, "check-value")
2381 DECLARE_HYDROGEN_ACCESSOR(CheckValue)
2385 class LCheckInstanceType FINAL : public LTemplateInstruction<0, 1, 0> {
2387 explicit LCheckInstanceType(LOperand* value) {
2391 LOperand* value() { return inputs_[0]; }
2393 DECLARE_CONCRETE_INSTRUCTION(CheckInstanceType, "check-instance-type")
2394 DECLARE_HYDROGEN_ACCESSOR(CheckInstanceType)
2398 class LCheckMaps FINAL : public LTemplateInstruction<0, 1, 0> {
2400 explicit LCheckMaps(LOperand* value = NULL) {
2404 LOperand* value() { return inputs_[0]; }
2406 DECLARE_CONCRETE_INSTRUCTION(CheckMaps, "check-maps")
2407 DECLARE_HYDROGEN_ACCESSOR(CheckMaps)
2411 class LCheckSmi FINAL : public LTemplateInstruction<1, 1, 0> {
2413 explicit LCheckSmi(LOperand* value) {
2417 LOperand* value() { return inputs_[0]; }
2419 DECLARE_CONCRETE_INSTRUCTION(CheckSmi, "check-smi")
2423 class LCheckNonSmi FINAL : public LTemplateInstruction<0, 1, 0> {
2425 explicit LCheckNonSmi(LOperand* value) {
2429 LOperand* value() { return inputs_[0]; }
2431 DECLARE_CONCRETE_INSTRUCTION(CheckNonSmi, "check-non-smi")
2432 DECLARE_HYDROGEN_ACCESSOR(CheckHeapObject)
2436 class LClampDToUint8 FINAL : public LTemplateInstruction<1, 1, 0> {
2438 explicit LClampDToUint8(LOperand* unclamped) {
2439 inputs_[0] = unclamped;
2442 LOperand* unclamped() { return inputs_[0]; }
2444 DECLARE_CONCRETE_INSTRUCTION(ClampDToUint8, "clamp-d-to-uint8")
2448 class LClampIToUint8 FINAL : public LTemplateInstruction<1, 1, 0> {
2450 explicit LClampIToUint8(LOperand* unclamped) {
2451 inputs_[0] = unclamped;
2454 LOperand* unclamped() { return inputs_[0]; }
2456 DECLARE_CONCRETE_INSTRUCTION(ClampIToUint8, "clamp-i-to-uint8")
2460 class LClampTToUint8 FINAL : public LTemplateInstruction<1, 1, 1> {
2462 LClampTToUint8(LOperand* unclamped, LOperand* temp) {
2463 inputs_[0] = unclamped;
2467 LOperand* unclamped() { return inputs_[0]; }
2468 LOperand* temp() { return temps_[0]; }
2470 DECLARE_CONCRETE_INSTRUCTION(ClampTToUint8, "clamp-t-to-uint8")
2474 class LDoubleBits FINAL : public LTemplateInstruction<1, 1, 0> {
2476 explicit LDoubleBits(LOperand* value) {
2480 LOperand* value() { return inputs_[0]; }
2482 DECLARE_CONCRETE_INSTRUCTION(DoubleBits, "double-bits")
2483 DECLARE_HYDROGEN_ACCESSOR(DoubleBits)
2487 class LConstructDouble FINAL : public LTemplateInstruction<1, 2, 0> {
2489 LConstructDouble(LOperand* hi, LOperand* lo) {
2494 LOperand* hi() { return inputs_[0]; }
2495 LOperand* lo() { return inputs_[1]; }
2497 DECLARE_CONCRETE_INSTRUCTION(ConstructDouble, "construct-double")
2501 class LAllocate FINAL : public LTemplateInstruction<1, 2, 2> {
2503 LAllocate(LOperand* context,
2507 inputs_[0] = context;
2513 LOperand* context() { return inputs_[0]; }
2514 LOperand* size() { return inputs_[1]; }
2515 LOperand* temp1() { return temps_[0]; }
2516 LOperand* temp2() { return temps_[1]; }
2518 DECLARE_CONCRETE_INSTRUCTION(Allocate, "allocate")
2519 DECLARE_HYDROGEN_ACCESSOR(Allocate)
2523 class LRegExpLiteral FINAL : public LTemplateInstruction<1, 1, 0> {
2525 explicit LRegExpLiteral(LOperand* context) {
2526 inputs_[0] = context;
2529 LOperand* context() { return inputs_[0]; }
2531 DECLARE_CONCRETE_INSTRUCTION(RegExpLiteral, "regexp-literal")
2532 DECLARE_HYDROGEN_ACCESSOR(RegExpLiteral)
2536 class LFunctionLiteral FINAL : public LTemplateInstruction<1, 1, 0> {
2538 explicit LFunctionLiteral(LOperand* context) {
2539 inputs_[0] = context;
2542 LOperand* context() { return inputs_[0]; }
2544 DECLARE_CONCRETE_INSTRUCTION(FunctionLiteral, "function-literal")
2545 DECLARE_HYDROGEN_ACCESSOR(FunctionLiteral)
2549 class LToFastProperties FINAL : public LTemplateInstruction<1, 1, 0> {
2551 explicit LToFastProperties(LOperand* value) {
2555 LOperand* value() { return inputs_[0]; }
2557 DECLARE_CONCRETE_INSTRUCTION(ToFastProperties, "to-fast-properties")
2558 DECLARE_HYDROGEN_ACCESSOR(ToFastProperties)
2562 class LTypeof FINAL : public LTemplateInstruction<1, 2, 0> {
2564 LTypeof(LOperand* context, LOperand* value) {
2565 inputs_[0] = context;
2569 LOperand* context() { return inputs_[0]; }
2570 LOperand* value() { return inputs_[1]; }
2572 DECLARE_CONCRETE_INSTRUCTION(Typeof, "typeof")
2576 class LTypeofIsAndBranch FINAL : public LControlInstruction<1, 0> {
2578 explicit LTypeofIsAndBranch(LOperand* value) {
2582 LOperand* value() { return inputs_[0]; }
2584 DECLARE_CONCRETE_INSTRUCTION(TypeofIsAndBranch, "typeof-is-and-branch")
2585 DECLARE_HYDROGEN_ACCESSOR(TypeofIsAndBranch)
2587 Handle<String> type_literal() { return hydrogen()->type_literal(); }
2589 void PrintDataTo(StringStream* stream) OVERRIDE;
2593 class LIsConstructCallAndBranch FINAL : public LControlInstruction<0, 1> {
2595 explicit LIsConstructCallAndBranch(LOperand* temp) {
2599 LOperand* temp() { return temps_[0]; }
2601 DECLARE_CONCRETE_INSTRUCTION(IsConstructCallAndBranch,
2602 "is-construct-call-and-branch")
2606 class LOsrEntry FINAL : public LTemplateInstruction<0, 0, 0> {
2610 bool HasInterestingComment(LCodeGen* gen) const OVERRIDE { return false; }
2611 DECLARE_CONCRETE_INSTRUCTION(OsrEntry, "osr-entry")
2615 class LStackCheck FINAL : public LTemplateInstruction<0, 1, 0> {
2617 explicit LStackCheck(LOperand* context) {
2618 inputs_[0] = context;
2621 LOperand* context() { return inputs_[0]; }
2623 DECLARE_CONCRETE_INSTRUCTION(StackCheck, "stack-check")
2624 DECLARE_HYDROGEN_ACCESSOR(StackCheck)
2626 Label* done_label() { return &done_label_; }
2633 class LForInPrepareMap FINAL : public LTemplateInstruction<1, 2, 0> {
2635 LForInPrepareMap(LOperand* context, LOperand* object) {
2636 inputs_[0] = context;
2637 inputs_[1] = object;
2640 LOperand* context() { return inputs_[0]; }
2641 LOperand* object() { return inputs_[1]; }
2643 DECLARE_CONCRETE_INSTRUCTION(ForInPrepareMap, "for-in-prepare-map")
2647 class LForInCacheArray FINAL : public LTemplateInstruction<1, 1, 0> {
2649 explicit LForInCacheArray(LOperand* map) {
2653 LOperand* map() { return inputs_[0]; }
2655 DECLARE_CONCRETE_INSTRUCTION(ForInCacheArray, "for-in-cache-array")
2658 return HForInCacheArray::cast(this->hydrogen_value())->idx();
2663 class LCheckMapValue FINAL : public LTemplateInstruction<0, 2, 0> {
2665 LCheckMapValue(LOperand* value, LOperand* map) {
2670 LOperand* value() { return inputs_[0]; }
2671 LOperand* map() { return inputs_[1]; }
2673 DECLARE_CONCRETE_INSTRUCTION(CheckMapValue, "check-map-value")
2677 class LLoadFieldByIndex FINAL : public LTemplateInstruction<1, 2, 0> {
2679 LLoadFieldByIndex(LOperand* object, LOperand* index) {
2680 inputs_[0] = object;
2684 LOperand* object() { return inputs_[0]; }
2685 LOperand* index() { return inputs_[1]; }
2687 DECLARE_CONCRETE_INSTRUCTION(LoadFieldByIndex, "load-field-by-index")
2691 class LStoreFrameContext: public LTemplateInstruction<0, 1, 0> {
2693 explicit LStoreFrameContext(LOperand* context) {
2694 inputs_[0] = context;
2697 LOperand* context() { return inputs_[0]; }
2699 DECLARE_CONCRETE_INSTRUCTION(StoreFrameContext, "store-frame-context")
2703 class LAllocateBlockContext: public LTemplateInstruction<1, 2, 0> {
2705 LAllocateBlockContext(LOperand* context, LOperand* function) {
2706 inputs_[0] = context;
2707 inputs_[1] = function;
2710 LOperand* context() { return inputs_[0]; }
2711 LOperand* function() { return inputs_[1]; }
2713 Handle<ScopeInfo> scope_info() { return hydrogen()->scope_info(); }
2715 DECLARE_CONCRETE_INSTRUCTION(AllocateBlockContext, "allocate-block-context")
2716 DECLARE_HYDROGEN_ACCESSOR(AllocateBlockContext)
2720 class LChunkBuilder;
2721 class LPlatformChunk FINAL : public LChunk {
2723 LPlatformChunk(CompilationInfo* info, HGraph* graph)
2724 : LChunk(info, graph) { }
2726 int GetNextSpillIndex(RegisterKind kind);
2727 LOperand* GetNextSpillSlot(RegisterKind kind);
2731 class LChunkBuilder FINAL : public LChunkBuilderBase {
2733 LChunkBuilder(CompilationInfo* info, HGraph* graph, LAllocator* allocator)
2734 : LChunkBuilderBase(info, graph),
2735 current_instruction_(NULL),
2736 current_block_(NULL),
2738 allocator_(allocator) {}
2740 // Build the sequence for the graph.
2741 LPlatformChunk* Build();
2743 // Declare methods that deal with the individual node types.
2744 #define DECLARE_DO(type) LInstruction* Do##type(H##type* node);
2745 HYDROGEN_CONCRETE_INSTRUCTION_LIST(DECLARE_DO)
2748 LInstruction* DoMultiplyAdd(HMul* mul, HValue* addend);
2749 LInstruction* DoMultiplySub(HValue* minuend, HMul* mul);
2750 LInstruction* DoRSub(HSub* instr);
2752 static bool HasMagicNumberForDivisor(int32_t divisor);
2754 LInstruction* DoMathFloor(HUnaryMathOperation* instr);
2755 LInstruction* DoMathRound(HUnaryMathOperation* instr);
2756 LInstruction* DoMathFround(HUnaryMathOperation* instr);
2757 LInstruction* DoMathAbs(HUnaryMathOperation* instr);
2758 LInstruction* DoMathLog(HUnaryMathOperation* instr);
2759 LInstruction* DoMathExp(HUnaryMathOperation* instr);
2760 LInstruction* DoMathSqrt(HUnaryMathOperation* instr);
2761 LInstruction* DoMathPowHalf(HUnaryMathOperation* instr);
2762 LInstruction* DoMathClz32(HUnaryMathOperation* instr);
2763 LInstruction* DoDivByPowerOf2I(HDiv* instr);
2764 LInstruction* DoDivByConstI(HDiv* instr);
2765 LInstruction* DoDivI(HDiv* instr);
2766 LInstruction* DoModByPowerOf2I(HMod* instr);
2767 LInstruction* DoModByConstI(HMod* instr);
2768 LInstruction* DoModI(HMod* instr);
2769 LInstruction* DoFlooringDivByPowerOf2I(HMathFloorOfDiv* instr);
2770 LInstruction* DoFlooringDivByConstI(HMathFloorOfDiv* instr);
2771 LInstruction* DoFlooringDivI(HMathFloorOfDiv* instr);
2774 // Methods for getting operands for Use / Define / Temp.
2775 LUnallocated* ToUnallocated(Register reg);
2776 LUnallocated* ToUnallocated(DoubleRegister reg);
2778 // Methods for setting up define-use relationships.
2779 MUST_USE_RESULT LOperand* Use(HValue* value, LUnallocated* operand);
2780 MUST_USE_RESULT LOperand* UseFixed(HValue* value, Register fixed_register);
2781 MUST_USE_RESULT LOperand* UseFixedDouble(HValue* value,
2782 DoubleRegister fixed_register);
2784 // A value that is guaranteed to be allocated to a register.
2785 // Operand created by UseRegister is guaranteed to be live until the end of
2786 // instruction. This means that register allocator will not reuse it's
2787 // register for any other operand inside instruction.
2788 // Operand created by UseRegisterAtStart is guaranteed to be live only at
2789 // instruction start. Register allocator is free to assign the same register
2790 // to some other operand used inside instruction (i.e. temporary or
2792 MUST_USE_RESULT LOperand* UseRegister(HValue* value);
2793 MUST_USE_RESULT LOperand* UseRegisterAtStart(HValue* value);
2795 // An input operand in a register that may be trashed.
2796 MUST_USE_RESULT LOperand* UseTempRegister(HValue* value);
2798 // An input operand in a register or stack slot.
2799 MUST_USE_RESULT LOperand* Use(HValue* value);
2800 MUST_USE_RESULT LOperand* UseAtStart(HValue* value);
2802 // An input operand in a register, stack slot or a constant operand.
2803 MUST_USE_RESULT LOperand* UseOrConstant(HValue* value);
2804 MUST_USE_RESULT LOperand* UseOrConstantAtStart(HValue* value);
2806 // An input operand in a register or a constant operand.
2807 MUST_USE_RESULT LOperand* UseRegisterOrConstant(HValue* value);
2808 MUST_USE_RESULT LOperand* UseRegisterOrConstantAtStart(HValue* value);
2810 // An input operand in a constant operand.
2811 MUST_USE_RESULT LOperand* UseConstant(HValue* value);
2813 // An input operand in register, stack slot or a constant operand.
2814 // Will not be moved to a register even if one is freely available.
2815 MUST_USE_RESULT LOperand* UseAny(HValue* value) OVERRIDE;
2817 // Temporary operand that must be in a register.
2818 MUST_USE_RESULT LUnallocated* TempRegister();
2819 MUST_USE_RESULT LUnallocated* TempDoubleRegister();
2820 MUST_USE_RESULT LOperand* FixedTemp(Register reg);
2821 MUST_USE_RESULT LOperand* FixedTemp(DoubleRegister reg);
2823 // Methods for setting up define-use relationships.
2824 // Return the same instruction that they are passed.
2825 LInstruction* Define(LTemplateResultInstruction<1>* instr,
2826 LUnallocated* result);
2827 LInstruction* DefineAsRegister(LTemplateResultInstruction<1>* instr);
2828 LInstruction* DefineAsSpilled(LTemplateResultInstruction<1>* instr,
2830 LInstruction* DefineSameAsFirst(LTemplateResultInstruction<1>* instr);
2831 LInstruction* DefineFixed(LTemplateResultInstruction<1>* instr,
2833 LInstruction* DefineFixedDouble(LTemplateResultInstruction<1>* instr,
2834 DoubleRegister reg);
2835 LInstruction* AssignEnvironment(LInstruction* instr);
2836 LInstruction* AssignPointerMap(LInstruction* instr);
2838 enum CanDeoptimize { CAN_DEOPTIMIZE_EAGERLY, CANNOT_DEOPTIMIZE_EAGERLY };
2840 // By default we assume that instruction sequences generated for calls
2841 // cannot deoptimize eagerly and we do not attach environment to this
2843 LInstruction* MarkAsCall(
2844 LInstruction* instr,
2845 HInstruction* hinstr,
2846 CanDeoptimize can_deoptimize = CANNOT_DEOPTIMIZE_EAGERLY);
2848 void VisitInstruction(HInstruction* current);
2849 void AddInstruction(LInstruction* instr, HInstruction* current);
2851 void DoBasicBlock(HBasicBlock* block, HBasicBlock* next_block);
2852 LInstruction* DoShift(Token::Value op, HBitwiseBinaryOperation* instr);
2853 LInstruction* DoArithmeticD(Token::Value op,
2854 HArithmeticBinaryOperation* instr);
2855 LInstruction* DoArithmeticT(Token::Value op,
2856 HBinaryOperation* instr);
2858 HInstruction* current_instruction_;
2859 HBasicBlock* current_block_;
2860 HBasicBlock* next_block_;
2861 LAllocator* allocator_;
2863 DISALLOW_COPY_AND_ASSIGN(LChunkBuilder);
2866 #undef DECLARE_HYDROGEN_ACCESSOR
2867 #undef DECLARE_CONCRETE_INSTRUCTION
2869 } } // namespace v8::internal
2871 #endif // V8_ARM_LITHIUM_ARM_H_