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) \
104 V(LoadGlobalGeneric) \
106 V(LoadKeyedGeneric) \
108 V(LoadNamedGeneric) \
136 V(SeqStringGetChar) \
137 V(SeqStringSetChar) \
143 V(StoreContextSlot) \
144 V(StoreFrameContext) \
147 V(StoreKeyedGeneric) \
149 V(StoreNamedGeneric) \
151 V(StringCharCodeAt) \
152 V(StringCharFromCode) \
153 V(StringCompareAndBranch) \
157 V(TailCallThroughMegamorphicCache) \
159 V(ToFastProperties) \
160 V(TransitionElementsKind) \
161 V(TrapAllocationMemento) \
163 V(TypeofIsAndBranch) \
169 #define DECLARE_CONCRETE_INSTRUCTION(type, mnemonic) \
170 Opcode opcode() const FINAL { return LInstruction::k##type; } \
171 void CompileToNative(LCodeGen* generator) FINAL; \
172 const char* Mnemonic() const FINAL { return mnemonic; } \
173 static L##type* cast(LInstruction* instr) { \
174 DCHECK(instr->Is##type()); \
175 return reinterpret_cast<L##type*>(instr); \
179 #define DECLARE_HYDROGEN_ACCESSOR(type) \
180 H##type* hydrogen() const { \
181 return H##type::cast(hydrogen_value()); \
185 class LInstruction : public ZoneObject {
188 : environment_(NULL),
189 hydrogen_value_(NULL),
190 bit_field_(IsCallBits::encode(false)) {
193 virtual ~LInstruction() {}
195 virtual void CompileToNative(LCodeGen* generator) = 0;
196 virtual const char* Mnemonic() const = 0;
197 virtual void PrintTo(StringStream* stream);
198 virtual void PrintDataTo(StringStream* stream);
199 virtual void PrintOutputOperandTo(StringStream* stream);
202 // Declare a unique enum value for each instruction.
203 #define DECLARE_OPCODE(type) k##type,
204 LITHIUM_CONCRETE_INSTRUCTION_LIST(DECLARE_OPCODE)
205 kNumberOfInstructions
206 #undef DECLARE_OPCODE
209 virtual Opcode opcode() const = 0;
211 // Declare non-virtual type testers for all leaf IR classes.
212 #define DECLARE_PREDICATE(type) \
213 bool Is##type() const { return opcode() == k##type; }
214 LITHIUM_CONCRETE_INSTRUCTION_LIST(DECLARE_PREDICATE)
215 #undef DECLARE_PREDICATE
217 // Declare virtual predicates for instructions that don't have
219 virtual bool IsGap() const { return false; }
221 virtual bool IsControl() const { return false; }
223 // Try deleting this instruction if possible.
224 virtual bool TryDelete() { return false; }
226 void set_environment(LEnvironment* env) { environment_ = env; }
227 LEnvironment* environment() const { return environment_; }
228 bool HasEnvironment() const { return environment_ != NULL; }
230 void set_pointer_map(LPointerMap* p) { pointer_map_.set(p); }
231 LPointerMap* pointer_map() const { return pointer_map_.get(); }
232 bool HasPointerMap() const { return pointer_map_.is_set(); }
234 void set_hydrogen_value(HValue* value) { hydrogen_value_ = value; }
235 HValue* hydrogen_value() const { return hydrogen_value_; }
237 virtual void SetDeferredLazyDeoptimizationEnvironment(LEnvironment* env) { }
239 void MarkAsCall() { bit_field_ = IsCallBits::update(bit_field_, true); }
240 bool IsCall() const { return IsCallBits::decode(bit_field_); }
242 // Interface to the register allocator and iterators.
243 bool ClobbersTemps() const { return IsCall(); }
244 bool ClobbersRegisters() const { return IsCall(); }
245 virtual bool ClobbersDoubleRegisters(Isolate* isolate) const {
249 // Interface to the register allocator and iterators.
250 bool IsMarkedAsCall() const { return IsCall(); }
252 virtual bool HasResult() const = 0;
253 virtual LOperand* result() const = 0;
255 LOperand* FirstInput() { return InputAt(0); }
256 LOperand* Output() { return HasResult() ? result() : NULL; }
258 virtual bool HasInterestingComment(LCodeGen* gen) const { return true; }
264 virtual int InputCount() = 0;
265 virtual LOperand* InputAt(int i) = 0;
269 friend class InputIterator;
271 friend class TempIterator;
272 virtual int TempCount() = 0;
273 virtual LOperand* TempAt(int i) = 0;
275 class IsCallBits: public BitField<bool, 0, 1> {};
277 LEnvironment* environment_;
278 SetOncePointer<LPointerMap> pointer_map_;
279 HValue* hydrogen_value_;
284 // R = number of result operands (0 or 1).
286 class LTemplateResultInstruction : public LInstruction {
288 // Allow 0 or 1 output operands.
289 STATIC_ASSERT(R == 0 || R == 1);
290 bool HasResult() const FINAL { return R != 0 && result() != NULL; }
291 void set_result(LOperand* operand) { results_[0] = operand; }
292 LOperand* result() const OVERRIDE { return results_[0]; }
295 EmbeddedContainer<LOperand*, R> results_;
299 // R = number of result operands (0 or 1).
300 // I = number of input operands.
301 // T = number of temporary operands.
302 template<int R, int I, int T>
303 class LTemplateInstruction : public LTemplateResultInstruction<R> {
305 EmbeddedContainer<LOperand*, I> inputs_;
306 EmbeddedContainer<LOperand*, T> temps_;
310 int InputCount() FINAL { return I; }
311 LOperand* InputAt(int i) FINAL { return inputs_[i]; }
313 int TempCount() FINAL { return T; }
314 LOperand* TempAt(int i) FINAL { return temps_[i]; }
318 class LGap : public LTemplateInstruction<0, 0, 0> {
320 explicit LGap(HBasicBlock* block)
322 parallel_moves_[BEFORE] = NULL;
323 parallel_moves_[START] = NULL;
324 parallel_moves_[END] = NULL;
325 parallel_moves_[AFTER] = NULL;
328 // Can't use the DECLARE-macro here because of sub-classes.
329 bool IsGap() const OVERRIDE { return true; }
330 void PrintDataTo(StringStream* stream) OVERRIDE;
331 static LGap* cast(LInstruction* instr) {
332 DCHECK(instr->IsGap());
333 return reinterpret_cast<LGap*>(instr);
336 bool IsRedundant() const;
338 HBasicBlock* block() const { return block_; }
345 FIRST_INNER_POSITION = BEFORE,
346 LAST_INNER_POSITION = AFTER
349 LParallelMove* GetOrCreateParallelMove(InnerPosition pos, Zone* zone) {
350 if (parallel_moves_[pos] == NULL) {
351 parallel_moves_[pos] = new(zone) LParallelMove(zone);
353 return parallel_moves_[pos];
356 LParallelMove* GetParallelMove(InnerPosition pos) {
357 return parallel_moves_[pos];
361 LParallelMove* parallel_moves_[LAST_INNER_POSITION + 1];
366 class LInstructionGap FINAL : public LGap {
368 explicit LInstructionGap(HBasicBlock* block) : LGap(block) { }
370 bool HasInterestingComment(LCodeGen* gen) const OVERRIDE {
371 return !IsRedundant();
374 DECLARE_CONCRETE_INSTRUCTION(InstructionGap, "gap")
378 class LGoto FINAL : public LTemplateInstruction<0, 0, 0> {
380 explicit LGoto(HBasicBlock* block) : block_(block) { }
382 bool HasInterestingComment(LCodeGen* gen) const OVERRIDE;
383 DECLARE_CONCRETE_INSTRUCTION(Goto, "goto")
384 void PrintDataTo(StringStream* stream) OVERRIDE;
385 bool IsControl() const OVERRIDE { return true; }
387 int block_id() const { return block_->block_id(); }
394 class LLazyBailout FINAL : public LTemplateInstruction<0, 0, 0> {
396 LLazyBailout() : gap_instructions_size_(0) { }
398 DECLARE_CONCRETE_INSTRUCTION(LazyBailout, "lazy-bailout")
400 void set_gap_instructions_size(int gap_instructions_size) {
401 gap_instructions_size_ = gap_instructions_size;
403 int gap_instructions_size() { return gap_instructions_size_; }
406 int gap_instructions_size_;
410 class LDummy FINAL : public LTemplateInstruction<1, 0, 0> {
413 DECLARE_CONCRETE_INSTRUCTION(Dummy, "dummy")
417 class LDummyUse FINAL : public LTemplateInstruction<1, 1, 0> {
419 explicit LDummyUse(LOperand* value) {
422 DECLARE_CONCRETE_INSTRUCTION(DummyUse, "dummy-use")
426 class LDeoptimize FINAL : public LTemplateInstruction<0, 0, 0> {
428 bool IsControl() const OVERRIDE { return true; }
429 DECLARE_CONCRETE_INSTRUCTION(Deoptimize, "deoptimize")
430 DECLARE_HYDROGEN_ACCESSOR(Deoptimize)
434 class LLabel FINAL : public LGap {
436 explicit LLabel(HBasicBlock* block)
437 : LGap(block), replacement_(NULL) { }
439 bool HasInterestingComment(LCodeGen* gen) const OVERRIDE { return false; }
440 DECLARE_CONCRETE_INSTRUCTION(Label, "label")
442 void PrintDataTo(StringStream* stream) OVERRIDE;
444 int block_id() const { return block()->block_id(); }
445 bool is_loop_header() const { return block()->IsLoopHeader(); }
446 bool is_osr_entry() const { return block()->is_osr_entry(); }
447 Label* label() { return &label_; }
448 LLabel* replacement() const { return replacement_; }
449 void set_replacement(LLabel* label) { replacement_ = label; }
450 bool HasReplacement() const { return replacement_ != NULL; }
454 LLabel* replacement_;
458 class LParameter FINAL : public LTemplateInstruction<1, 0, 0> {
460 bool HasInterestingComment(LCodeGen* gen) const OVERRIDE { return false; }
461 DECLARE_CONCRETE_INSTRUCTION(Parameter, "parameter")
465 class LCallStub FINAL : public LTemplateInstruction<1, 1, 0> {
467 explicit LCallStub(LOperand* context) {
468 inputs_[0] = context;
471 LOperand* context() { return inputs_[0]; }
473 DECLARE_CONCRETE_INSTRUCTION(CallStub, "call-stub")
474 DECLARE_HYDROGEN_ACCESSOR(CallStub)
478 class LTailCallThroughMegamorphicCache FINAL
479 : public LTemplateInstruction<0, 5, 0> {
481 LTailCallThroughMegamorphicCache(LOperand* context, LOperand* receiver,
482 LOperand* name, LOperand* slot,
484 inputs_[0] = context;
485 inputs_[1] = receiver;
491 LOperand* context() { return inputs_[0]; }
492 LOperand* receiver() { return inputs_[1]; }
493 LOperand* name() { return inputs_[2]; }
494 LOperand* slot() { return inputs_[3]; }
495 LOperand* vector() { return inputs_[4]; }
497 DECLARE_CONCRETE_INSTRUCTION(TailCallThroughMegamorphicCache,
498 "tail-call-through-megamorphic-cache")
499 DECLARE_HYDROGEN_ACCESSOR(TailCallThroughMegamorphicCache)
503 class LUnknownOSRValue FINAL : public LTemplateInstruction<1, 0, 0> {
505 bool HasInterestingComment(LCodeGen* gen) const OVERRIDE { return false; }
506 DECLARE_CONCRETE_INSTRUCTION(UnknownOSRValue, "unknown-osr-value")
510 template<int I, int T>
511 class LControlInstruction : public LTemplateInstruction<0, I, T> {
513 LControlInstruction() : false_label_(NULL), true_label_(NULL) { }
515 bool IsControl() const FINAL { return true; }
517 int SuccessorCount() { return hydrogen()->SuccessorCount(); }
518 HBasicBlock* SuccessorAt(int i) { return hydrogen()->SuccessorAt(i); }
520 int TrueDestination(LChunk* chunk) {
521 return chunk->LookupDestination(true_block_id());
523 int FalseDestination(LChunk* chunk) {
524 return chunk->LookupDestination(false_block_id());
527 Label* TrueLabel(LChunk* chunk) {
528 if (true_label_ == NULL) {
529 true_label_ = chunk->GetAssemblyLabel(TrueDestination(chunk));
533 Label* FalseLabel(LChunk* chunk) {
534 if (false_label_ == NULL) {
535 false_label_ = chunk->GetAssemblyLabel(FalseDestination(chunk));
541 int true_block_id() { return SuccessorAt(0)->block_id(); }
542 int false_block_id() { return SuccessorAt(1)->block_id(); }
545 HControlInstruction* hydrogen() {
546 return HControlInstruction::cast(this->hydrogen_value());
554 class LWrapReceiver FINAL : public LTemplateInstruction<1, 2, 0> {
556 LWrapReceiver(LOperand* receiver, LOperand* function) {
557 inputs_[0] = receiver;
558 inputs_[1] = function;
561 DECLARE_CONCRETE_INSTRUCTION(WrapReceiver, "wrap-receiver")
562 DECLARE_HYDROGEN_ACCESSOR(WrapReceiver)
564 LOperand* receiver() { return inputs_[0]; }
565 LOperand* function() { return inputs_[1]; }
569 class LApplyArguments FINAL : public LTemplateInstruction<1, 4, 0> {
571 LApplyArguments(LOperand* function,
574 LOperand* elements) {
575 inputs_[0] = function;
576 inputs_[1] = receiver;
578 inputs_[3] = elements;
581 DECLARE_CONCRETE_INSTRUCTION(ApplyArguments, "apply-arguments")
583 LOperand* function() { return inputs_[0]; }
584 LOperand* receiver() { return inputs_[1]; }
585 LOperand* length() { return inputs_[2]; }
586 LOperand* elements() { return inputs_[3]; }
590 class LAccessArgumentsAt FINAL : public LTemplateInstruction<1, 3, 0> {
592 LAccessArgumentsAt(LOperand* arguments, LOperand* length, LOperand* index) {
593 inputs_[0] = arguments;
598 DECLARE_CONCRETE_INSTRUCTION(AccessArgumentsAt, "access-arguments-at")
600 LOperand* arguments() { return inputs_[0]; }
601 LOperand* length() { return inputs_[1]; }
602 LOperand* index() { return inputs_[2]; }
604 void PrintDataTo(StringStream* stream) OVERRIDE;
608 class LArgumentsLength FINAL : public LTemplateInstruction<1, 1, 0> {
610 explicit LArgumentsLength(LOperand* elements) {
611 inputs_[0] = elements;
614 LOperand* elements() { return inputs_[0]; }
616 DECLARE_CONCRETE_INSTRUCTION(ArgumentsLength, "arguments-length")
620 class LArgumentsElements FINAL : public LTemplateInstruction<1, 0, 0> {
622 DECLARE_CONCRETE_INSTRUCTION(ArgumentsElements, "arguments-elements")
623 DECLARE_HYDROGEN_ACCESSOR(ArgumentsElements)
627 class LModByPowerOf2I FINAL : public LTemplateInstruction<1, 1, 0> {
629 LModByPowerOf2I(LOperand* dividend, int32_t divisor) {
630 inputs_[0] = dividend;
634 LOperand* dividend() { return inputs_[0]; }
635 int32_t divisor() const { return divisor_; }
637 DECLARE_CONCRETE_INSTRUCTION(ModByPowerOf2I, "mod-by-power-of-2-i")
638 DECLARE_HYDROGEN_ACCESSOR(Mod)
645 class LModByConstI FINAL : public LTemplateInstruction<1, 1, 0> {
647 LModByConstI(LOperand* dividend, int32_t divisor) {
648 inputs_[0] = dividend;
652 LOperand* dividend() { return inputs_[0]; }
653 int32_t divisor() const { return divisor_; }
655 DECLARE_CONCRETE_INSTRUCTION(ModByConstI, "mod-by-const-i")
656 DECLARE_HYDROGEN_ACCESSOR(Mod)
663 class LModI FINAL : public LTemplateInstruction<1, 2, 2> {
665 LModI(LOperand* left, LOperand* right, LOperand* temp, LOperand* temp2) {
672 LOperand* left() { return inputs_[0]; }
673 LOperand* right() { return inputs_[1]; }
674 LOperand* temp() { return temps_[0]; }
675 LOperand* temp2() { return temps_[1]; }
677 DECLARE_CONCRETE_INSTRUCTION(ModI, "mod-i")
678 DECLARE_HYDROGEN_ACCESSOR(Mod)
682 class LDivByPowerOf2I FINAL : public LTemplateInstruction<1, 1, 0> {
684 LDivByPowerOf2I(LOperand* dividend, int32_t divisor) {
685 inputs_[0] = dividend;
689 LOperand* dividend() { return inputs_[0]; }
690 int32_t divisor() const { return divisor_; }
692 DECLARE_CONCRETE_INSTRUCTION(DivByPowerOf2I, "div-by-power-of-2-i")
693 DECLARE_HYDROGEN_ACCESSOR(Div)
700 class LDivByConstI FINAL : public LTemplateInstruction<1, 1, 0> {
702 LDivByConstI(LOperand* dividend, int32_t divisor) {
703 inputs_[0] = dividend;
707 LOperand* dividend() { return inputs_[0]; }
708 int32_t divisor() const { return divisor_; }
710 DECLARE_CONCRETE_INSTRUCTION(DivByConstI, "div-by-const-i")
711 DECLARE_HYDROGEN_ACCESSOR(Div)
718 class LDivI FINAL : public LTemplateInstruction<1, 2, 1> {
720 LDivI(LOperand* dividend, LOperand* divisor, LOperand* temp) {
721 inputs_[0] = dividend;
722 inputs_[1] = divisor;
726 LOperand* dividend() { return inputs_[0]; }
727 LOperand* divisor() { return inputs_[1]; }
728 LOperand* temp() { return temps_[0]; }
730 DECLARE_CONCRETE_INSTRUCTION(DivI, "div-i")
731 DECLARE_HYDROGEN_ACCESSOR(BinaryOperation)
735 class LFlooringDivByPowerOf2I FINAL : public LTemplateInstruction<1, 1, 0> {
737 LFlooringDivByPowerOf2I(LOperand* dividend, int32_t divisor) {
738 inputs_[0] = dividend;
742 LOperand* dividend() { return inputs_[0]; }
743 int32_t divisor() { return divisor_; }
745 DECLARE_CONCRETE_INSTRUCTION(FlooringDivByPowerOf2I,
746 "flooring-div-by-power-of-2-i")
747 DECLARE_HYDROGEN_ACCESSOR(MathFloorOfDiv)
754 class LFlooringDivByConstI FINAL : public LTemplateInstruction<1, 1, 2> {
756 LFlooringDivByConstI(LOperand* dividend, int32_t divisor, LOperand* temp) {
757 inputs_[0] = dividend;
762 LOperand* dividend() { return inputs_[0]; }
763 int32_t divisor() const { return divisor_; }
764 LOperand* temp() { return temps_[0]; }
766 DECLARE_CONCRETE_INSTRUCTION(FlooringDivByConstI, "flooring-div-by-const-i")
767 DECLARE_HYDROGEN_ACCESSOR(MathFloorOfDiv)
774 class LFlooringDivI FINAL : public LTemplateInstruction<1, 2, 1> {
776 LFlooringDivI(LOperand* dividend, LOperand* divisor, LOperand* temp) {
777 inputs_[0] = dividend;
778 inputs_[1] = divisor;
782 LOperand* dividend() { return inputs_[0]; }
783 LOperand* divisor() { return inputs_[1]; }
784 LOperand* temp() { return temps_[0]; }
786 DECLARE_CONCRETE_INSTRUCTION(FlooringDivI, "flooring-div-i")
787 DECLARE_HYDROGEN_ACCESSOR(MathFloorOfDiv)
791 class LMulI FINAL : public LTemplateInstruction<1, 2, 0> {
793 LMulI(LOperand* left, LOperand* right) {
798 LOperand* left() { return inputs_[0]; }
799 LOperand* right() { return inputs_[1]; }
801 DECLARE_CONCRETE_INSTRUCTION(MulI, "mul-i")
802 DECLARE_HYDROGEN_ACCESSOR(Mul)
806 // Instruction for computing multiplier * multiplicand + addend.
807 class LMultiplyAddD FINAL : public LTemplateInstruction<1, 3, 0> {
809 LMultiplyAddD(LOperand* addend, LOperand* multiplier,
810 LOperand* multiplicand) {
812 inputs_[1] = multiplier;
813 inputs_[2] = multiplicand;
816 LOperand* addend() { return inputs_[0]; }
817 LOperand* multiplier() { return inputs_[1]; }
818 LOperand* multiplicand() { return inputs_[2]; }
820 DECLARE_CONCRETE_INSTRUCTION(MultiplyAddD, "multiply-add-d")
824 // Instruction for computing minuend - multiplier * multiplicand.
825 class LMultiplySubD FINAL : public LTemplateInstruction<1, 3, 0> {
827 LMultiplySubD(LOperand* minuend, LOperand* multiplier,
828 LOperand* multiplicand) {
829 inputs_[0] = minuend;
830 inputs_[1] = multiplier;
831 inputs_[2] = multiplicand;
834 LOperand* minuend() { return inputs_[0]; }
835 LOperand* multiplier() { return inputs_[1]; }
836 LOperand* multiplicand() { return inputs_[2]; }
838 DECLARE_CONCRETE_INSTRUCTION(MultiplySubD, "multiply-sub-d")
842 class LDebugBreak FINAL : public LTemplateInstruction<0, 0, 0> {
844 DECLARE_CONCRETE_INSTRUCTION(DebugBreak, "break")
848 class LCompareNumericAndBranch FINAL : public LControlInstruction<2, 0> {
850 LCompareNumericAndBranch(LOperand* left, LOperand* right) {
855 LOperand* left() { return inputs_[0]; }
856 LOperand* right() { return inputs_[1]; }
858 DECLARE_CONCRETE_INSTRUCTION(CompareNumericAndBranch,
859 "compare-numeric-and-branch")
860 DECLARE_HYDROGEN_ACCESSOR(CompareNumericAndBranch)
862 Token::Value op() const { return hydrogen()->token(); }
863 bool is_double() const {
864 return hydrogen()->representation().IsDouble();
867 void PrintDataTo(StringStream* stream) OVERRIDE;
871 class LMathFloor FINAL : public LTemplateInstruction<1, 1, 0> {
873 explicit LMathFloor(LOperand* value) {
877 LOperand* value() { return inputs_[0]; }
879 DECLARE_CONCRETE_INSTRUCTION(MathFloor, "math-floor")
880 DECLARE_HYDROGEN_ACCESSOR(UnaryMathOperation)
884 class LMathRound FINAL : public LTemplateInstruction<1, 1, 1> {
886 LMathRound(LOperand* value, LOperand* temp) {
891 LOperand* value() { return inputs_[0]; }
892 LOperand* temp() { return temps_[0]; }
894 DECLARE_CONCRETE_INSTRUCTION(MathRound, "math-round")
895 DECLARE_HYDROGEN_ACCESSOR(UnaryMathOperation)
899 class LMathFround FINAL : public LTemplateInstruction<1, 1, 0> {
901 explicit LMathFround(LOperand* value) { inputs_[0] = value; }
903 LOperand* value() { return inputs_[0]; }
905 DECLARE_CONCRETE_INSTRUCTION(MathFround, "math-fround")
909 class LMathAbs FINAL : public LTemplateInstruction<1, 2, 0> {
911 LMathAbs(LOperand* context, LOperand* value) {
912 inputs_[1] = context;
916 LOperand* context() { return inputs_[1]; }
917 LOperand* value() { return inputs_[0]; }
919 DECLARE_CONCRETE_INSTRUCTION(MathAbs, "math-abs")
920 DECLARE_HYDROGEN_ACCESSOR(UnaryMathOperation)
924 class LMathLog FINAL : public LTemplateInstruction<1, 1, 0> {
926 explicit LMathLog(LOperand* value) {
930 LOperand* value() { return inputs_[0]; }
932 DECLARE_CONCRETE_INSTRUCTION(MathLog, "math-log")
936 class LMathClz32 FINAL : public LTemplateInstruction<1, 1, 0> {
938 explicit LMathClz32(LOperand* value) {
942 LOperand* value() { return inputs_[0]; }
944 DECLARE_CONCRETE_INSTRUCTION(MathClz32, "math-clz32")
948 class LMathExp FINAL : public LTemplateInstruction<1, 1, 3> {
950 LMathExp(LOperand* value,
951 LOperand* double_temp,
957 temps_[2] = double_temp;
958 ExternalReference::InitializeMathExpData();
961 LOperand* value() { return inputs_[0]; }
962 LOperand* temp1() { return temps_[0]; }
963 LOperand* temp2() { return temps_[1]; }
964 LOperand* double_temp() { return temps_[2]; }
966 DECLARE_CONCRETE_INSTRUCTION(MathExp, "math-exp")
970 class LMathSqrt FINAL : public LTemplateInstruction<1, 1, 0> {
972 explicit LMathSqrt(LOperand* value) {
976 LOperand* value() { return inputs_[0]; }
978 DECLARE_CONCRETE_INSTRUCTION(MathSqrt, "math-sqrt")
982 class LMathPowHalf FINAL : public LTemplateInstruction<1, 1, 0> {
984 explicit LMathPowHalf(LOperand* value) {
988 LOperand* value() { return inputs_[0]; }
990 DECLARE_CONCRETE_INSTRUCTION(MathPowHalf, "math-pow-half")
994 class LCmpObjectEqAndBranch FINAL : public LControlInstruction<2, 0> {
996 LCmpObjectEqAndBranch(LOperand* left, LOperand* right) {
1001 LOperand* left() { return inputs_[0]; }
1002 LOperand* right() { return inputs_[1]; }
1004 DECLARE_CONCRETE_INSTRUCTION(CmpObjectEqAndBranch, "cmp-object-eq-and-branch")
1005 DECLARE_HYDROGEN_ACCESSOR(CompareObjectEqAndBranch)
1009 class LCmpHoleAndBranch FINAL : public LControlInstruction<1, 0> {
1011 explicit LCmpHoleAndBranch(LOperand* object) {
1012 inputs_[0] = object;
1015 LOperand* object() { return inputs_[0]; }
1017 DECLARE_CONCRETE_INSTRUCTION(CmpHoleAndBranch, "cmp-hole-and-branch")
1018 DECLARE_HYDROGEN_ACCESSOR(CompareHoleAndBranch)
1022 class LCompareMinusZeroAndBranch FINAL : public LControlInstruction<1, 1> {
1024 LCompareMinusZeroAndBranch(LOperand* value, LOperand* temp) {
1029 LOperand* value() { return inputs_[0]; }
1030 LOperand* temp() { return temps_[0]; }
1032 DECLARE_CONCRETE_INSTRUCTION(CompareMinusZeroAndBranch,
1033 "cmp-minus-zero-and-branch")
1034 DECLARE_HYDROGEN_ACCESSOR(CompareMinusZeroAndBranch)
1038 class LIsObjectAndBranch FINAL : public LControlInstruction<1, 1> {
1040 LIsObjectAndBranch(LOperand* value, LOperand* temp) {
1045 LOperand* value() { return inputs_[0]; }
1046 LOperand* temp() { return temps_[0]; }
1048 DECLARE_CONCRETE_INSTRUCTION(IsObjectAndBranch, "is-object-and-branch")
1049 DECLARE_HYDROGEN_ACCESSOR(IsObjectAndBranch)
1051 void PrintDataTo(StringStream* stream) OVERRIDE;
1055 class LIsStringAndBranch FINAL : public LControlInstruction<1, 1> {
1057 LIsStringAndBranch(LOperand* value, LOperand* temp) {
1062 LOperand* value() { return inputs_[0]; }
1063 LOperand* temp() { return temps_[0]; }
1065 DECLARE_CONCRETE_INSTRUCTION(IsStringAndBranch, "is-string-and-branch")
1066 DECLARE_HYDROGEN_ACCESSOR(IsStringAndBranch)
1068 void PrintDataTo(StringStream* stream) OVERRIDE;
1072 class LIsSmiAndBranch FINAL : public LControlInstruction<1, 0> {
1074 explicit LIsSmiAndBranch(LOperand* value) {
1078 LOperand* value() { return inputs_[0]; }
1080 DECLARE_CONCRETE_INSTRUCTION(IsSmiAndBranch, "is-smi-and-branch")
1081 DECLARE_HYDROGEN_ACCESSOR(IsSmiAndBranch)
1083 void PrintDataTo(StringStream* stream) OVERRIDE;
1087 class LIsUndetectableAndBranch FINAL : public LControlInstruction<1, 1> {
1089 explicit LIsUndetectableAndBranch(LOperand* value, LOperand* temp) {
1094 LOperand* value() { return inputs_[0]; }
1095 LOperand* temp() { return temps_[0]; }
1097 DECLARE_CONCRETE_INSTRUCTION(IsUndetectableAndBranch,
1098 "is-undetectable-and-branch")
1099 DECLARE_HYDROGEN_ACCESSOR(IsUndetectableAndBranch)
1101 void PrintDataTo(StringStream* stream) OVERRIDE;
1105 class LStringCompareAndBranch FINAL : public LControlInstruction<3, 0> {
1107 LStringCompareAndBranch(LOperand* context, LOperand* left, LOperand* right) {
1108 inputs_[0] = context;
1113 LOperand* context() { return inputs_[0]; }
1114 LOperand* left() { return inputs_[1]; }
1115 LOperand* right() { return inputs_[2]; }
1117 DECLARE_CONCRETE_INSTRUCTION(StringCompareAndBranch,
1118 "string-compare-and-branch")
1119 DECLARE_HYDROGEN_ACCESSOR(StringCompareAndBranch)
1121 Token::Value op() const { return hydrogen()->token(); }
1123 void PrintDataTo(StringStream* stream) OVERRIDE;
1127 class LHasInstanceTypeAndBranch FINAL : public LControlInstruction<1, 0> {
1129 explicit LHasInstanceTypeAndBranch(LOperand* value) {
1133 LOperand* value() { return inputs_[0]; }
1135 DECLARE_CONCRETE_INSTRUCTION(HasInstanceTypeAndBranch,
1136 "has-instance-type-and-branch")
1137 DECLARE_HYDROGEN_ACCESSOR(HasInstanceTypeAndBranch)
1139 void PrintDataTo(StringStream* stream) OVERRIDE;
1143 class LGetCachedArrayIndex FINAL : public LTemplateInstruction<1, 1, 0> {
1145 explicit LGetCachedArrayIndex(LOperand* value) {
1149 LOperand* value() { return inputs_[0]; }
1151 DECLARE_CONCRETE_INSTRUCTION(GetCachedArrayIndex, "get-cached-array-index")
1152 DECLARE_HYDROGEN_ACCESSOR(GetCachedArrayIndex)
1156 class LHasCachedArrayIndexAndBranch FINAL
1157 : public LControlInstruction<1, 0> {
1159 explicit LHasCachedArrayIndexAndBranch(LOperand* value) {
1163 LOperand* value() { return inputs_[0]; }
1165 DECLARE_CONCRETE_INSTRUCTION(HasCachedArrayIndexAndBranch,
1166 "has-cached-array-index-and-branch")
1167 DECLARE_HYDROGEN_ACCESSOR(HasCachedArrayIndexAndBranch)
1169 void PrintDataTo(StringStream* stream) OVERRIDE;
1173 class LClassOfTestAndBranch FINAL : public LControlInstruction<1, 1> {
1175 LClassOfTestAndBranch(LOperand* value, LOperand* temp) {
1180 LOperand* value() { return inputs_[0]; }
1181 LOperand* temp() { return temps_[0]; }
1183 DECLARE_CONCRETE_INSTRUCTION(ClassOfTestAndBranch,
1184 "class-of-test-and-branch")
1185 DECLARE_HYDROGEN_ACCESSOR(ClassOfTestAndBranch)
1187 void PrintDataTo(StringStream* stream) OVERRIDE;
1191 class LCmpT FINAL : public LTemplateInstruction<1, 3, 0> {
1193 LCmpT(LOperand* context, LOperand* left, LOperand* right) {
1194 inputs_[0] = context;
1199 LOperand* context() { return inputs_[0]; }
1200 LOperand* left() { return inputs_[1]; }
1201 LOperand* right() { return inputs_[2]; }
1203 DECLARE_CONCRETE_INSTRUCTION(CmpT, "cmp-t")
1204 DECLARE_HYDROGEN_ACCESSOR(CompareGeneric)
1206 Token::Value op() const { return hydrogen()->token(); }
1210 class LInstanceOf FINAL : public LTemplateInstruction<1, 3, 0> {
1212 LInstanceOf(LOperand* context, LOperand* left, LOperand* right) {
1213 inputs_[0] = context;
1218 LOperand* context() { return inputs_[0]; }
1219 LOperand* left() { return inputs_[1]; }
1220 LOperand* right() { return inputs_[2]; }
1222 DECLARE_CONCRETE_INSTRUCTION(InstanceOf, "instance-of")
1226 class LInstanceOfKnownGlobal FINAL : public LTemplateInstruction<1, 2, 1> {
1228 LInstanceOfKnownGlobal(LOperand* context, LOperand* value, LOperand* temp) {
1229 inputs_[0] = context;
1234 LOperand* context() { return inputs_[0]; }
1235 LOperand* value() { return inputs_[1]; }
1236 LOperand* temp() { return temps_[0]; }
1238 DECLARE_CONCRETE_INSTRUCTION(InstanceOfKnownGlobal,
1239 "instance-of-known-global")
1240 DECLARE_HYDROGEN_ACCESSOR(InstanceOfKnownGlobal)
1242 Handle<JSFunction> function() const { return hydrogen()->function(); }
1243 LEnvironment* GetDeferredLazyDeoptimizationEnvironment() {
1244 return lazy_deopt_env_;
1246 virtual void SetDeferredLazyDeoptimizationEnvironment(
1247 LEnvironment* env) OVERRIDE {
1248 lazy_deopt_env_ = env;
1252 LEnvironment* lazy_deopt_env_;
1256 class LBoundsCheck FINAL : public LTemplateInstruction<0, 2, 0> {
1258 LBoundsCheck(LOperand* index, LOperand* length) {
1260 inputs_[1] = length;
1263 LOperand* index() { return inputs_[0]; }
1264 LOperand* length() { return inputs_[1]; }
1266 DECLARE_CONCRETE_INSTRUCTION(BoundsCheck, "bounds-check")
1267 DECLARE_HYDROGEN_ACCESSOR(BoundsCheck)
1271 class LBitI FINAL : public LTemplateInstruction<1, 2, 0> {
1273 LBitI(LOperand* left, LOperand* right) {
1278 LOperand* left() { return inputs_[0]; }
1279 LOperand* right() { return inputs_[1]; }
1281 Token::Value op() const { return hydrogen()->op(); }
1283 DECLARE_CONCRETE_INSTRUCTION(BitI, "bit-i")
1284 DECLARE_HYDROGEN_ACCESSOR(Bitwise)
1288 class LShiftI FINAL : public LTemplateInstruction<1, 2, 0> {
1290 LShiftI(Token::Value op, LOperand* left, LOperand* right, bool can_deopt)
1291 : op_(op), can_deopt_(can_deopt) {
1296 Token::Value op() const { return op_; }
1297 LOperand* left() { return inputs_[0]; }
1298 LOperand* right() { return inputs_[1]; }
1299 bool can_deopt() const { return can_deopt_; }
1301 DECLARE_CONCRETE_INSTRUCTION(ShiftI, "shift-i")
1309 class LSubI FINAL : public LTemplateInstruction<1, 2, 0> {
1311 LSubI(LOperand* left, LOperand* right) {
1316 LOperand* left() { return inputs_[0]; }
1317 LOperand* right() { return inputs_[1]; }
1319 DECLARE_CONCRETE_INSTRUCTION(SubI, "sub-i")
1320 DECLARE_HYDROGEN_ACCESSOR(Sub)
1324 class LRSubI FINAL : public LTemplateInstruction<1, 2, 0> {
1326 LRSubI(LOperand* left, LOperand* right) {
1331 LOperand* left() { return inputs_[0]; }
1332 LOperand* right() { return inputs_[1]; }
1334 DECLARE_CONCRETE_INSTRUCTION(RSubI, "rsub-i")
1335 DECLARE_HYDROGEN_ACCESSOR(Sub)
1339 class LConstantI FINAL : public LTemplateInstruction<1, 0, 0> {
1341 DECLARE_CONCRETE_INSTRUCTION(ConstantI, "constant-i")
1342 DECLARE_HYDROGEN_ACCESSOR(Constant)
1344 int32_t value() const { return hydrogen()->Integer32Value(); }
1348 class LConstantS FINAL : public LTemplateInstruction<1, 0, 0> {
1350 DECLARE_CONCRETE_INSTRUCTION(ConstantS, "constant-s")
1351 DECLARE_HYDROGEN_ACCESSOR(Constant)
1353 Smi* value() const { return Smi::FromInt(hydrogen()->Integer32Value()); }
1357 class LConstantD FINAL : public LTemplateInstruction<1, 0, 0> {
1359 DECLARE_CONCRETE_INSTRUCTION(ConstantD, "constant-d")
1360 DECLARE_HYDROGEN_ACCESSOR(Constant)
1362 double value() const { return hydrogen()->DoubleValue(); }
1363 uint64_t bits() const { return hydrogen()->DoubleValueAsBits(); }
1367 class LConstantE FINAL : public LTemplateInstruction<1, 0, 0> {
1369 DECLARE_CONCRETE_INSTRUCTION(ConstantE, "constant-e")
1370 DECLARE_HYDROGEN_ACCESSOR(Constant)
1372 ExternalReference value() const {
1373 return hydrogen()->ExternalReferenceValue();
1378 class LConstantT FINAL : public LTemplateInstruction<1, 0, 0> {
1380 DECLARE_CONCRETE_INSTRUCTION(ConstantT, "constant-t")
1381 DECLARE_HYDROGEN_ACCESSOR(Constant)
1383 Handle<Object> value(Isolate* isolate) const {
1384 return hydrogen()->handle(isolate);
1389 class LBranch FINAL : public LControlInstruction<1, 0> {
1391 explicit LBranch(LOperand* value) {
1395 LOperand* value() { return inputs_[0]; }
1397 DECLARE_CONCRETE_INSTRUCTION(Branch, "branch")
1398 DECLARE_HYDROGEN_ACCESSOR(Branch)
1400 void PrintDataTo(StringStream* stream) OVERRIDE;
1404 class LCmpMapAndBranch FINAL : public LControlInstruction<1, 1> {
1406 LCmpMapAndBranch(LOperand* value, LOperand* temp) {
1411 LOperand* value() { return inputs_[0]; }
1412 LOperand* temp() { return temps_[0]; }
1414 DECLARE_CONCRETE_INSTRUCTION(CmpMapAndBranch, "cmp-map-and-branch")
1415 DECLARE_HYDROGEN_ACCESSOR(CompareMap)
1417 Handle<Map> map() const { return hydrogen()->map().handle(); }
1421 class LMapEnumLength FINAL : public LTemplateInstruction<1, 1, 0> {
1423 explicit LMapEnumLength(LOperand* value) {
1427 LOperand* value() { return inputs_[0]; }
1429 DECLARE_CONCRETE_INSTRUCTION(MapEnumLength, "map-enum-length")
1433 class LDateField FINAL : public LTemplateInstruction<1, 1, 1> {
1435 LDateField(LOperand* date, LOperand* temp, Smi* index) : index_(index) {
1440 LOperand* date() { return inputs_[0]; }
1441 LOperand* temp() { return temps_[0]; }
1442 Smi* index() const { return index_; }
1444 DECLARE_CONCRETE_INSTRUCTION(DateField, "date-field")
1445 DECLARE_HYDROGEN_ACCESSOR(DateField)
1452 class LSeqStringGetChar FINAL : public LTemplateInstruction<1, 2, 0> {
1454 LSeqStringGetChar(LOperand* string, LOperand* index) {
1455 inputs_[0] = string;
1459 LOperand* string() const { return inputs_[0]; }
1460 LOperand* index() const { return inputs_[1]; }
1462 DECLARE_CONCRETE_INSTRUCTION(SeqStringGetChar, "seq-string-get-char")
1463 DECLARE_HYDROGEN_ACCESSOR(SeqStringGetChar)
1467 class LSeqStringSetChar FINAL : public LTemplateInstruction<1, 4, 0> {
1469 LSeqStringSetChar(LOperand* context,
1473 inputs_[0] = context;
1474 inputs_[1] = string;
1479 LOperand* string() { return inputs_[1]; }
1480 LOperand* index() { return inputs_[2]; }
1481 LOperand* value() { return inputs_[3]; }
1483 DECLARE_CONCRETE_INSTRUCTION(SeqStringSetChar, "seq-string-set-char")
1484 DECLARE_HYDROGEN_ACCESSOR(SeqStringSetChar)
1488 class LAddI FINAL : public LTemplateInstruction<1, 2, 0> {
1490 LAddI(LOperand* left, LOperand* right) {
1495 LOperand* left() { return inputs_[0]; }
1496 LOperand* right() { return inputs_[1]; }
1498 DECLARE_CONCRETE_INSTRUCTION(AddI, "add-i")
1499 DECLARE_HYDROGEN_ACCESSOR(Add)
1503 class LMathMinMax FINAL : public LTemplateInstruction<1, 2, 0> {
1505 LMathMinMax(LOperand* left, LOperand* right) {
1510 LOperand* left() { return inputs_[0]; }
1511 LOperand* right() { return inputs_[1]; }
1513 DECLARE_CONCRETE_INSTRUCTION(MathMinMax, "math-min-max")
1514 DECLARE_HYDROGEN_ACCESSOR(MathMinMax)
1518 class LPower FINAL : public LTemplateInstruction<1, 2, 0> {
1520 LPower(LOperand* left, LOperand* right) {
1525 LOperand* left() { return inputs_[0]; }
1526 LOperand* right() { return inputs_[1]; }
1528 DECLARE_CONCRETE_INSTRUCTION(Power, "power")
1529 DECLARE_HYDROGEN_ACCESSOR(Power)
1533 class LArithmeticD FINAL : public LTemplateInstruction<1, 2, 0> {
1535 LArithmeticD(Token::Value op, LOperand* left, LOperand* right)
1541 Token::Value op() const { return op_; }
1542 LOperand* left() { return inputs_[0]; }
1543 LOperand* right() { return inputs_[1]; }
1545 Opcode opcode() const OVERRIDE { return LInstruction::kArithmeticD; }
1546 void CompileToNative(LCodeGen* generator) OVERRIDE;
1547 const char* Mnemonic() const OVERRIDE;
1554 class LArithmeticT FINAL : public LTemplateInstruction<1, 3, 0> {
1556 LArithmeticT(Token::Value op,
1561 inputs_[0] = context;
1566 LOperand* context() { return inputs_[0]; }
1567 LOperand* left() { return inputs_[1]; }
1568 LOperand* right() { return inputs_[2]; }
1569 Token::Value op() const { return op_; }
1571 Opcode opcode() const OVERRIDE { return LInstruction::kArithmeticT; }
1572 void CompileToNative(LCodeGen* generator) OVERRIDE;
1573 const char* Mnemonic() const OVERRIDE;
1580 class LReturn FINAL : public LTemplateInstruction<0, 3, 0> {
1582 LReturn(LOperand* value, LOperand* context, LOperand* parameter_count) {
1584 inputs_[1] = context;
1585 inputs_[2] = parameter_count;
1588 LOperand* value() { return inputs_[0]; }
1590 bool has_constant_parameter_count() {
1591 return parameter_count()->IsConstantOperand();
1593 LConstantOperand* constant_parameter_count() {
1594 DCHECK(has_constant_parameter_count());
1595 return LConstantOperand::cast(parameter_count());
1597 LOperand* parameter_count() { return inputs_[2]; }
1599 DECLARE_CONCRETE_INSTRUCTION(Return, "return")
1603 class LLoadNamedField FINAL : public LTemplateInstruction<1, 1, 0> {
1605 explicit LLoadNamedField(LOperand* object) {
1606 inputs_[0] = object;
1609 LOperand* object() { return inputs_[0]; }
1611 DECLARE_CONCRETE_INSTRUCTION(LoadNamedField, "load-named-field")
1612 DECLARE_HYDROGEN_ACCESSOR(LoadNamedField)
1616 class LLoadNamedGeneric FINAL : public LTemplateInstruction<1, 2, 1> {
1618 LLoadNamedGeneric(LOperand* context, LOperand* object, LOperand* vector) {
1619 inputs_[0] = context;
1620 inputs_[1] = object;
1624 LOperand* context() { return inputs_[0]; }
1625 LOperand* object() { return inputs_[1]; }
1626 LOperand* temp_vector() { return temps_[0]; }
1628 DECLARE_CONCRETE_INSTRUCTION(LoadNamedGeneric, "load-named-generic")
1629 DECLARE_HYDROGEN_ACCESSOR(LoadNamedGeneric)
1631 Handle<Object> name() const { return hydrogen()->name(); }
1635 class LLoadFunctionPrototype FINAL : public LTemplateInstruction<1, 1, 0> {
1637 explicit LLoadFunctionPrototype(LOperand* function) {
1638 inputs_[0] = function;
1641 LOperand* function() { return inputs_[0]; }
1643 DECLARE_CONCRETE_INSTRUCTION(LoadFunctionPrototype, "load-function-prototype")
1644 DECLARE_HYDROGEN_ACCESSOR(LoadFunctionPrototype)
1648 class LLoadRoot FINAL : public LTemplateInstruction<1, 0, 0> {
1650 DECLARE_CONCRETE_INSTRUCTION(LoadRoot, "load-root")
1651 DECLARE_HYDROGEN_ACCESSOR(LoadRoot)
1653 Heap::RootListIndex index() const { return hydrogen()->index(); }
1657 class LLoadKeyed FINAL : public LTemplateInstruction<1, 2, 0> {
1659 LLoadKeyed(LOperand* elements, LOperand* key) {
1660 inputs_[0] = elements;
1664 LOperand* elements() { return inputs_[0]; }
1665 LOperand* key() { return inputs_[1]; }
1666 ElementsKind elements_kind() const {
1667 return hydrogen()->elements_kind();
1669 bool is_external() const {
1670 return hydrogen()->is_external();
1672 bool is_fixed_typed_array() const {
1673 return hydrogen()->is_fixed_typed_array();
1675 bool is_typed_elements() const {
1676 return is_external() || is_fixed_typed_array();
1679 DECLARE_CONCRETE_INSTRUCTION(LoadKeyed, "load-keyed")
1680 DECLARE_HYDROGEN_ACCESSOR(LoadKeyed)
1682 void PrintDataTo(StringStream* stream) OVERRIDE;
1683 uint32_t base_offset() const { return hydrogen()->base_offset(); }
1687 class LLoadKeyedGeneric FINAL : public LTemplateInstruction<1, 3, 1> {
1689 LLoadKeyedGeneric(LOperand* context, LOperand* object, LOperand* key,
1691 inputs_[0] = context;
1692 inputs_[1] = object;
1697 LOperand* context() { return inputs_[0]; }
1698 LOperand* object() { return inputs_[1]; }
1699 LOperand* key() { return inputs_[2]; }
1700 LOperand* temp_vector() { return temps_[0]; }
1702 DECLARE_CONCRETE_INSTRUCTION(LoadKeyedGeneric, "load-keyed-generic")
1703 DECLARE_HYDROGEN_ACCESSOR(LoadKeyedGeneric)
1707 class LLoadGlobalCell FINAL : public LTemplateInstruction<1, 0, 0> {
1709 DECLARE_CONCRETE_INSTRUCTION(LoadGlobalCell, "load-global-cell")
1710 DECLARE_HYDROGEN_ACCESSOR(LoadGlobalCell)
1714 class LLoadGlobalGeneric FINAL : public LTemplateInstruction<1, 2, 1> {
1716 LLoadGlobalGeneric(LOperand* context, LOperand* global_object,
1718 inputs_[0] = context;
1719 inputs_[1] = global_object;
1723 LOperand* context() { return inputs_[0]; }
1724 LOperand* global_object() { return inputs_[1]; }
1725 LOperand* temp_vector() { return temps_[0]; }
1727 DECLARE_CONCRETE_INSTRUCTION(LoadGlobalGeneric, "load-global-generic")
1728 DECLARE_HYDROGEN_ACCESSOR(LoadGlobalGeneric)
1730 Handle<Object> name() const { return hydrogen()->name(); }
1731 bool for_typeof() const { return hydrogen()->for_typeof(); }
1735 class LStoreGlobalCell FINAL : public LTemplateInstruction<0, 1, 1> {
1737 LStoreGlobalCell(LOperand* value, LOperand* temp) {
1742 LOperand* value() { return inputs_[0]; }
1743 LOperand* temp() { return temps_[0]; }
1745 DECLARE_CONCRETE_INSTRUCTION(StoreGlobalCell, "store-global-cell")
1746 DECLARE_HYDROGEN_ACCESSOR(StoreGlobalCell)
1750 class LLoadContextSlot FINAL : public LTemplateInstruction<1, 1, 0> {
1752 explicit LLoadContextSlot(LOperand* context) {
1753 inputs_[0] = context;
1756 LOperand* context() { return inputs_[0]; }
1758 DECLARE_CONCRETE_INSTRUCTION(LoadContextSlot, "load-context-slot")
1759 DECLARE_HYDROGEN_ACCESSOR(LoadContextSlot)
1761 int slot_index() { return hydrogen()->slot_index(); }
1763 void PrintDataTo(StringStream* stream) OVERRIDE;
1767 class LStoreContextSlot FINAL : public LTemplateInstruction<0, 2, 0> {
1769 LStoreContextSlot(LOperand* context, LOperand* value) {
1770 inputs_[0] = context;
1774 LOperand* context() { return inputs_[0]; }
1775 LOperand* value() { return inputs_[1]; }
1777 DECLARE_CONCRETE_INSTRUCTION(StoreContextSlot, "store-context-slot")
1778 DECLARE_HYDROGEN_ACCESSOR(StoreContextSlot)
1780 int slot_index() { return hydrogen()->slot_index(); }
1782 void PrintDataTo(StringStream* stream) OVERRIDE;
1786 class LPushArgument FINAL : public LTemplateInstruction<0, 1, 0> {
1788 explicit LPushArgument(LOperand* value) {
1792 LOperand* value() { return inputs_[0]; }
1794 DECLARE_CONCRETE_INSTRUCTION(PushArgument, "push-argument")
1798 class LDrop FINAL : public LTemplateInstruction<0, 0, 0> {
1800 explicit LDrop(int count) : count_(count) { }
1802 int count() const { return count_; }
1804 DECLARE_CONCRETE_INSTRUCTION(Drop, "drop")
1811 class LStoreCodeEntry FINAL: public LTemplateInstruction<0, 2, 0> {
1813 LStoreCodeEntry(LOperand* function, LOperand* code_object) {
1814 inputs_[0] = function;
1815 inputs_[1] = code_object;
1818 LOperand* function() { return inputs_[0]; }
1819 LOperand* code_object() { return inputs_[1]; }
1821 void PrintDataTo(StringStream* stream) OVERRIDE;
1823 DECLARE_CONCRETE_INSTRUCTION(StoreCodeEntry, "store-code-entry")
1824 DECLARE_HYDROGEN_ACCESSOR(StoreCodeEntry)
1828 class LInnerAllocatedObject FINAL: public LTemplateInstruction<1, 2, 0> {
1830 LInnerAllocatedObject(LOperand* base_object, LOperand* offset) {
1831 inputs_[0] = base_object;
1832 inputs_[1] = offset;
1835 LOperand* base_object() const { return inputs_[0]; }
1836 LOperand* offset() const { return inputs_[1]; }
1838 void PrintDataTo(StringStream* stream) OVERRIDE;
1840 DECLARE_CONCRETE_INSTRUCTION(InnerAllocatedObject, "inner-allocated-object")
1844 class LThisFunction FINAL : public LTemplateInstruction<1, 0, 0> {
1846 DECLARE_CONCRETE_INSTRUCTION(ThisFunction, "this-function")
1847 DECLARE_HYDROGEN_ACCESSOR(ThisFunction)
1851 class LContext FINAL : public LTemplateInstruction<1, 0, 0> {
1853 DECLARE_CONCRETE_INSTRUCTION(Context, "context")
1854 DECLARE_HYDROGEN_ACCESSOR(Context)
1858 class LDeclareGlobals FINAL : public LTemplateInstruction<0, 1, 0> {
1860 explicit LDeclareGlobals(LOperand* context) {
1861 inputs_[0] = context;
1864 LOperand* context() { return inputs_[0]; }
1866 DECLARE_CONCRETE_INSTRUCTION(DeclareGlobals, "declare-globals")
1867 DECLARE_HYDROGEN_ACCESSOR(DeclareGlobals)
1871 class LCallJSFunction FINAL : public LTemplateInstruction<1, 1, 0> {
1873 explicit LCallJSFunction(LOperand* function) {
1874 inputs_[0] = function;
1877 LOperand* function() { return inputs_[0]; }
1879 DECLARE_CONCRETE_INSTRUCTION(CallJSFunction, "call-js-function")
1880 DECLARE_HYDROGEN_ACCESSOR(CallJSFunction)
1882 void PrintDataTo(StringStream* stream) OVERRIDE;
1884 int arity() const { return hydrogen()->argument_count() - 1; }
1888 class LCallWithDescriptor FINAL : public LTemplateResultInstruction<1> {
1890 LCallWithDescriptor(CallInterfaceDescriptor descriptor,
1891 const ZoneList<LOperand*>& operands, Zone* zone)
1892 : descriptor_(descriptor),
1893 inputs_(descriptor.GetRegisterParameterCount() + 1, zone) {
1894 DCHECK(descriptor.GetRegisterParameterCount() + 1 == operands.length());
1895 inputs_.AddAll(operands, zone);
1898 LOperand* target() const { return inputs_[0]; }
1900 const CallInterfaceDescriptor descriptor() { return descriptor_; }
1902 DECLARE_HYDROGEN_ACCESSOR(CallWithDescriptor)
1905 DECLARE_CONCRETE_INSTRUCTION(CallWithDescriptor, "call-with-descriptor")
1907 void PrintDataTo(StringStream* stream) OVERRIDE;
1909 int arity() const { return hydrogen()->argument_count() - 1; }
1911 CallInterfaceDescriptor descriptor_;
1912 ZoneList<LOperand*> inputs_;
1914 // Iterator support.
1915 int InputCount() FINAL { return inputs_.length(); }
1916 LOperand* InputAt(int i) FINAL { return inputs_[i]; }
1918 int TempCount() FINAL { return 0; }
1919 LOperand* TempAt(int i) FINAL { return NULL; }
1923 class LInvokeFunction FINAL : public LTemplateInstruction<1, 2, 0> {
1925 LInvokeFunction(LOperand* context, LOperand* function) {
1926 inputs_[0] = context;
1927 inputs_[1] = function;
1930 LOperand* context() { return inputs_[0]; }
1931 LOperand* function() { return inputs_[1]; }
1933 DECLARE_CONCRETE_INSTRUCTION(InvokeFunction, "invoke-function")
1934 DECLARE_HYDROGEN_ACCESSOR(InvokeFunction)
1936 void PrintDataTo(StringStream* stream) OVERRIDE;
1938 int arity() const { return hydrogen()->argument_count() - 1; }
1942 class LCallFunction FINAL : public LTemplateInstruction<1, 2, 2> {
1944 LCallFunction(LOperand* context, LOperand* function, LOperand* slot,
1946 inputs_[0] = context;
1947 inputs_[1] = function;
1952 LOperand* context() { return inputs_[0]; }
1953 LOperand* function() { return inputs_[1]; }
1954 LOperand* temp_slot() { return temps_[0]; }
1955 LOperand* temp_vector() { return temps_[1]; }
1957 DECLARE_CONCRETE_INSTRUCTION(CallFunction, "call-function")
1958 DECLARE_HYDROGEN_ACCESSOR(CallFunction)
1960 int arity() const { return hydrogen()->argument_count() - 1; }
1961 void PrintDataTo(StringStream* stream) OVERRIDE;
1965 class LCallNew FINAL : public LTemplateInstruction<1, 2, 0> {
1967 LCallNew(LOperand* context, LOperand* constructor) {
1968 inputs_[0] = context;
1969 inputs_[1] = constructor;
1972 LOperand* context() { return inputs_[0]; }
1973 LOperand* constructor() { return inputs_[1]; }
1975 DECLARE_CONCRETE_INSTRUCTION(CallNew, "call-new")
1976 DECLARE_HYDROGEN_ACCESSOR(CallNew)
1978 void PrintDataTo(StringStream* stream) OVERRIDE;
1980 int arity() const { return hydrogen()->argument_count() - 1; }
1984 class LCallNewArray FINAL : public LTemplateInstruction<1, 2, 0> {
1986 LCallNewArray(LOperand* context, LOperand* constructor) {
1987 inputs_[0] = context;
1988 inputs_[1] = constructor;
1991 LOperand* context() { return inputs_[0]; }
1992 LOperand* constructor() { return inputs_[1]; }
1994 DECLARE_CONCRETE_INSTRUCTION(CallNewArray, "call-new-array")
1995 DECLARE_HYDROGEN_ACCESSOR(CallNewArray)
1997 void PrintDataTo(StringStream* stream) OVERRIDE;
1999 int arity() const { return hydrogen()->argument_count() - 1; }
2003 class LCallRuntime FINAL : public LTemplateInstruction<1, 1, 0> {
2005 explicit LCallRuntime(LOperand* context) {
2006 inputs_[0] = context;
2009 LOperand* context() { return inputs_[0]; }
2011 DECLARE_CONCRETE_INSTRUCTION(CallRuntime, "call-runtime")
2012 DECLARE_HYDROGEN_ACCESSOR(CallRuntime)
2014 bool ClobbersDoubleRegisters(Isolate* isolate) const OVERRIDE {
2015 return save_doubles() == kDontSaveFPRegs;
2018 const Runtime::Function* function() const { return hydrogen()->function(); }
2019 int arity() const { return hydrogen()->argument_count(); }
2020 SaveFPRegsMode save_doubles() const { return hydrogen()->save_doubles(); }
2024 class LInteger32ToDouble FINAL : public LTemplateInstruction<1, 1, 0> {
2026 explicit LInteger32ToDouble(LOperand* value) {
2030 LOperand* value() { return inputs_[0]; }
2032 DECLARE_CONCRETE_INSTRUCTION(Integer32ToDouble, "int32-to-double")
2036 class LUint32ToDouble FINAL : public LTemplateInstruction<1, 1, 0> {
2038 explicit LUint32ToDouble(LOperand* value) {
2042 LOperand* value() { return inputs_[0]; }
2044 DECLARE_CONCRETE_INSTRUCTION(Uint32ToDouble, "uint32-to-double")
2048 class LNumberTagI FINAL : public LTemplateInstruction<1, 1, 2> {
2050 LNumberTagI(LOperand* value, LOperand* temp1, LOperand* temp2) {
2056 LOperand* value() { return inputs_[0]; }
2057 LOperand* temp1() { return temps_[0]; }
2058 LOperand* temp2() { return temps_[1]; }
2060 DECLARE_CONCRETE_INSTRUCTION(NumberTagI, "number-tag-i")
2064 class LNumberTagU FINAL : public LTemplateInstruction<1, 1, 2> {
2066 LNumberTagU(LOperand* value, LOperand* temp1, LOperand* temp2) {
2072 LOperand* value() { return inputs_[0]; }
2073 LOperand* temp1() { return temps_[0]; }
2074 LOperand* temp2() { return temps_[1]; }
2076 DECLARE_CONCRETE_INSTRUCTION(NumberTagU, "number-tag-u")
2080 class LNumberTagD FINAL : public LTemplateInstruction<1, 1, 2> {
2082 LNumberTagD(LOperand* value, LOperand* temp, LOperand* temp2) {
2088 LOperand* value() { return inputs_[0]; }
2089 LOperand* temp() { return temps_[0]; }
2090 LOperand* temp2() { return temps_[1]; }
2092 DECLARE_CONCRETE_INSTRUCTION(NumberTagD, "number-tag-d")
2093 DECLARE_HYDROGEN_ACCESSOR(Change)
2097 class LDoubleToSmi FINAL : public LTemplateInstruction<1, 1, 0> {
2099 explicit LDoubleToSmi(LOperand* value) {
2103 LOperand* value() { return inputs_[0]; }
2105 DECLARE_CONCRETE_INSTRUCTION(DoubleToSmi, "double-to-smi")
2106 DECLARE_HYDROGEN_ACCESSOR(UnaryOperation)
2108 bool truncating() { return hydrogen()->CanTruncateToInt32(); }
2112 // Sometimes truncating conversion from a tagged value to an int32.
2113 class LDoubleToI FINAL : public LTemplateInstruction<1, 1, 0> {
2115 explicit LDoubleToI(LOperand* value) {
2119 LOperand* value() { return inputs_[0]; }
2121 DECLARE_CONCRETE_INSTRUCTION(DoubleToI, "double-to-i")
2122 DECLARE_HYDROGEN_ACCESSOR(UnaryOperation)
2124 bool truncating() { return hydrogen()->CanTruncateToInt32(); }
2128 // Truncating conversion from a tagged value to an int32.
2129 class LTaggedToI FINAL : public LTemplateInstruction<1, 1, 2> {
2131 LTaggedToI(LOperand* value,
2139 LOperand* value() { return inputs_[0]; }
2140 LOperand* temp() { return temps_[0]; }
2141 LOperand* temp2() { return temps_[1]; }
2143 DECLARE_CONCRETE_INSTRUCTION(TaggedToI, "tagged-to-i")
2144 DECLARE_HYDROGEN_ACCESSOR(Change)
2146 bool truncating() { return hydrogen()->CanTruncateToInt32(); }
2150 class LSmiTag FINAL : public LTemplateInstruction<1, 1, 0> {
2152 explicit LSmiTag(LOperand* value) {
2156 LOperand* value() { return inputs_[0]; }
2158 DECLARE_CONCRETE_INSTRUCTION(SmiTag, "smi-tag")
2159 DECLARE_HYDROGEN_ACCESSOR(Change)
2163 class LNumberUntagD FINAL : public LTemplateInstruction<1, 1, 0> {
2165 explicit LNumberUntagD(LOperand* value) {
2169 LOperand* value() { return inputs_[0]; }
2171 DECLARE_CONCRETE_INSTRUCTION(NumberUntagD, "double-untag")
2172 DECLARE_HYDROGEN_ACCESSOR(Change)
2176 class LSmiUntag FINAL : public LTemplateInstruction<1, 1, 0> {
2178 LSmiUntag(LOperand* value, bool needs_check)
2179 : needs_check_(needs_check) {
2183 LOperand* value() { return inputs_[0]; }
2184 bool needs_check() const { return needs_check_; }
2186 DECLARE_CONCRETE_INSTRUCTION(SmiUntag, "smi-untag")
2193 class LStoreNamedField FINAL : public LTemplateInstruction<0, 2, 1> {
2195 LStoreNamedField(LOperand* object, LOperand* value, LOperand* temp) {
2196 inputs_[0] = object;
2201 LOperand* object() { return inputs_[0]; }
2202 LOperand* value() { return inputs_[1]; }
2203 LOperand* temp() { return temps_[0]; }
2205 DECLARE_CONCRETE_INSTRUCTION(StoreNamedField, "store-named-field")
2206 DECLARE_HYDROGEN_ACCESSOR(StoreNamedField)
2208 void PrintDataTo(StringStream* stream) OVERRIDE;
2210 Representation representation() const {
2211 return hydrogen()->field_representation();
2216 class LStoreNamedGeneric FINAL : public LTemplateInstruction<0, 3, 0> {
2218 LStoreNamedGeneric(LOperand* context, LOperand* object, LOperand* value) {
2219 inputs_[0] = context;
2220 inputs_[1] = object;
2224 LOperand* context() { return inputs_[0]; }
2225 LOperand* object() { return inputs_[1]; }
2226 LOperand* value() { return inputs_[2]; }
2228 DECLARE_CONCRETE_INSTRUCTION(StoreNamedGeneric, "store-named-generic")
2229 DECLARE_HYDROGEN_ACCESSOR(StoreNamedGeneric)
2231 void PrintDataTo(StringStream* stream) OVERRIDE;
2233 Handle<Object> name() const { return hydrogen()->name(); }
2234 LanguageMode language_mode() { return hydrogen()->language_mode(); }
2238 class LStoreKeyed FINAL : public LTemplateInstruction<0, 3, 0> {
2240 LStoreKeyed(LOperand* object, LOperand* key, LOperand* value) {
2241 inputs_[0] = object;
2246 bool is_external() const { return hydrogen()->is_external(); }
2247 bool is_fixed_typed_array() const {
2248 return hydrogen()->is_fixed_typed_array();
2250 bool is_typed_elements() const {
2251 return is_external() || is_fixed_typed_array();
2253 LOperand* elements() { return inputs_[0]; }
2254 LOperand* key() { return inputs_[1]; }
2255 LOperand* value() { return inputs_[2]; }
2256 ElementsKind elements_kind() const {
2257 return hydrogen()->elements_kind();
2260 DECLARE_CONCRETE_INSTRUCTION(StoreKeyed, "store-keyed")
2261 DECLARE_HYDROGEN_ACCESSOR(StoreKeyed)
2263 void PrintDataTo(StringStream* stream) OVERRIDE;
2264 bool NeedsCanonicalization() {
2265 if (hydrogen()->value()->IsAdd() || hydrogen()->value()->IsSub() ||
2266 hydrogen()->value()->IsMul() || hydrogen()->value()->IsDiv()) {
2269 return hydrogen()->NeedsCanonicalization();
2271 uint32_t base_offset() const { return hydrogen()->base_offset(); }
2275 class LStoreKeyedGeneric FINAL : public LTemplateInstruction<0, 4, 0> {
2277 LStoreKeyedGeneric(LOperand* context,
2281 inputs_[0] = context;
2287 LOperand* context() { return inputs_[0]; }
2288 LOperand* object() { return inputs_[1]; }
2289 LOperand* key() { return inputs_[2]; }
2290 LOperand* value() { return inputs_[3]; }
2292 DECLARE_CONCRETE_INSTRUCTION(StoreKeyedGeneric, "store-keyed-generic")
2293 DECLARE_HYDROGEN_ACCESSOR(StoreKeyedGeneric)
2295 void PrintDataTo(StringStream* stream) OVERRIDE;
2297 LanguageMode language_mode() { return hydrogen()->language_mode(); }
2301 class LTransitionElementsKind FINAL : public LTemplateInstruction<0, 2, 1> {
2303 LTransitionElementsKind(LOperand* object,
2305 LOperand* new_map_temp) {
2306 inputs_[0] = object;
2307 inputs_[1] = context;
2308 temps_[0] = new_map_temp;
2311 LOperand* context() { return inputs_[1]; }
2312 LOperand* object() { return inputs_[0]; }
2313 LOperand* new_map_temp() { return temps_[0]; }
2315 DECLARE_CONCRETE_INSTRUCTION(TransitionElementsKind,
2316 "transition-elements-kind")
2317 DECLARE_HYDROGEN_ACCESSOR(TransitionElementsKind)
2319 void PrintDataTo(StringStream* stream) OVERRIDE;
2321 Handle<Map> original_map() { return hydrogen()->original_map().handle(); }
2322 Handle<Map> transitioned_map() {
2323 return hydrogen()->transitioned_map().handle();
2325 ElementsKind from_kind() { return hydrogen()->from_kind(); }
2326 ElementsKind to_kind() { return hydrogen()->to_kind(); }
2330 class LTrapAllocationMemento FINAL : public LTemplateInstruction<0, 1, 1> {
2332 LTrapAllocationMemento(LOperand* object,
2334 inputs_[0] = object;
2338 LOperand* object() { return inputs_[0]; }
2339 LOperand* temp() { return temps_[0]; }
2341 DECLARE_CONCRETE_INSTRUCTION(TrapAllocationMemento,
2342 "trap-allocation-memento")
2346 class LStringAdd FINAL : public LTemplateInstruction<1, 3, 0> {
2348 LStringAdd(LOperand* context, LOperand* left, LOperand* right) {
2349 inputs_[0] = context;
2354 LOperand* context() { return inputs_[0]; }
2355 LOperand* left() { return inputs_[1]; }
2356 LOperand* right() { return inputs_[2]; }
2358 DECLARE_CONCRETE_INSTRUCTION(StringAdd, "string-add")
2359 DECLARE_HYDROGEN_ACCESSOR(StringAdd)
2364 class LStringCharCodeAt FINAL : public LTemplateInstruction<1, 3, 0> {
2366 LStringCharCodeAt(LOperand* context, LOperand* string, LOperand* index) {
2367 inputs_[0] = context;
2368 inputs_[1] = string;
2372 LOperand* context() { return inputs_[0]; }
2373 LOperand* string() { return inputs_[1]; }
2374 LOperand* index() { return inputs_[2]; }
2376 DECLARE_CONCRETE_INSTRUCTION(StringCharCodeAt, "string-char-code-at")
2377 DECLARE_HYDROGEN_ACCESSOR(StringCharCodeAt)
2381 class LStringCharFromCode FINAL : public LTemplateInstruction<1, 2, 0> {
2383 explicit LStringCharFromCode(LOperand* context, LOperand* char_code) {
2384 inputs_[0] = context;
2385 inputs_[1] = char_code;
2388 LOperand* context() { return inputs_[0]; }
2389 LOperand* char_code() { return inputs_[1]; }
2391 DECLARE_CONCRETE_INSTRUCTION(StringCharFromCode, "string-char-from-code")
2392 DECLARE_HYDROGEN_ACCESSOR(StringCharFromCode)
2396 class LCheckValue FINAL : public LTemplateInstruction<0, 1, 0> {
2398 explicit LCheckValue(LOperand* value) {
2402 LOperand* value() { return inputs_[0]; }
2404 DECLARE_CONCRETE_INSTRUCTION(CheckValue, "check-value")
2405 DECLARE_HYDROGEN_ACCESSOR(CheckValue)
2409 class LCheckInstanceType FINAL : public LTemplateInstruction<0, 1, 0> {
2411 explicit LCheckInstanceType(LOperand* value) {
2415 LOperand* value() { return inputs_[0]; }
2417 DECLARE_CONCRETE_INSTRUCTION(CheckInstanceType, "check-instance-type")
2418 DECLARE_HYDROGEN_ACCESSOR(CheckInstanceType)
2422 class LCheckMaps FINAL : public LTemplateInstruction<0, 1, 0> {
2424 explicit LCheckMaps(LOperand* value = NULL) {
2428 LOperand* value() { return inputs_[0]; }
2430 DECLARE_CONCRETE_INSTRUCTION(CheckMaps, "check-maps")
2431 DECLARE_HYDROGEN_ACCESSOR(CheckMaps)
2435 class LCheckSmi FINAL : public LTemplateInstruction<1, 1, 0> {
2437 explicit LCheckSmi(LOperand* value) {
2441 LOperand* value() { return inputs_[0]; }
2443 DECLARE_CONCRETE_INSTRUCTION(CheckSmi, "check-smi")
2447 class LCheckNonSmi FINAL : public LTemplateInstruction<0, 1, 0> {
2449 explicit LCheckNonSmi(LOperand* value) {
2453 LOperand* value() { return inputs_[0]; }
2455 DECLARE_CONCRETE_INSTRUCTION(CheckNonSmi, "check-non-smi")
2456 DECLARE_HYDROGEN_ACCESSOR(CheckHeapObject)
2460 class LClampDToUint8 FINAL : public LTemplateInstruction<1, 1, 0> {
2462 explicit LClampDToUint8(LOperand* unclamped) {
2463 inputs_[0] = unclamped;
2466 LOperand* unclamped() { return inputs_[0]; }
2468 DECLARE_CONCRETE_INSTRUCTION(ClampDToUint8, "clamp-d-to-uint8")
2472 class LClampIToUint8 FINAL : public LTemplateInstruction<1, 1, 0> {
2474 explicit LClampIToUint8(LOperand* unclamped) {
2475 inputs_[0] = unclamped;
2478 LOperand* unclamped() { return inputs_[0]; }
2480 DECLARE_CONCRETE_INSTRUCTION(ClampIToUint8, "clamp-i-to-uint8")
2484 class LClampTToUint8 FINAL : public LTemplateInstruction<1, 1, 1> {
2486 LClampTToUint8(LOperand* unclamped, LOperand* temp) {
2487 inputs_[0] = unclamped;
2491 LOperand* unclamped() { return inputs_[0]; }
2492 LOperand* temp() { return temps_[0]; }
2494 DECLARE_CONCRETE_INSTRUCTION(ClampTToUint8, "clamp-t-to-uint8")
2498 class LDoubleBits FINAL : public LTemplateInstruction<1, 1, 0> {
2500 explicit LDoubleBits(LOperand* value) {
2504 LOperand* value() { return inputs_[0]; }
2506 DECLARE_CONCRETE_INSTRUCTION(DoubleBits, "double-bits")
2507 DECLARE_HYDROGEN_ACCESSOR(DoubleBits)
2511 class LConstructDouble FINAL : public LTemplateInstruction<1, 2, 0> {
2513 LConstructDouble(LOperand* hi, LOperand* lo) {
2518 LOperand* hi() { return inputs_[0]; }
2519 LOperand* lo() { return inputs_[1]; }
2521 DECLARE_CONCRETE_INSTRUCTION(ConstructDouble, "construct-double")
2525 class LAllocate FINAL : public LTemplateInstruction<1, 2, 2> {
2527 LAllocate(LOperand* context,
2531 inputs_[0] = context;
2537 LOperand* context() { return inputs_[0]; }
2538 LOperand* size() { return inputs_[1]; }
2539 LOperand* temp1() { return temps_[0]; }
2540 LOperand* temp2() { return temps_[1]; }
2542 DECLARE_CONCRETE_INSTRUCTION(Allocate, "allocate")
2543 DECLARE_HYDROGEN_ACCESSOR(Allocate)
2547 class LRegExpLiteral FINAL : public LTemplateInstruction<1, 1, 0> {
2549 explicit LRegExpLiteral(LOperand* context) {
2550 inputs_[0] = context;
2553 LOperand* context() { return inputs_[0]; }
2555 DECLARE_CONCRETE_INSTRUCTION(RegExpLiteral, "regexp-literal")
2556 DECLARE_HYDROGEN_ACCESSOR(RegExpLiteral)
2560 class LFunctionLiteral FINAL : public LTemplateInstruction<1, 1, 0> {
2562 explicit LFunctionLiteral(LOperand* context) {
2563 inputs_[0] = context;
2566 LOperand* context() { return inputs_[0]; }
2568 DECLARE_CONCRETE_INSTRUCTION(FunctionLiteral, "function-literal")
2569 DECLARE_HYDROGEN_ACCESSOR(FunctionLiteral)
2573 class LToFastProperties FINAL : public LTemplateInstruction<1, 1, 0> {
2575 explicit LToFastProperties(LOperand* value) {
2579 LOperand* value() { return inputs_[0]; }
2581 DECLARE_CONCRETE_INSTRUCTION(ToFastProperties, "to-fast-properties")
2582 DECLARE_HYDROGEN_ACCESSOR(ToFastProperties)
2586 class LTypeof FINAL : public LTemplateInstruction<1, 2, 0> {
2588 LTypeof(LOperand* context, LOperand* value) {
2589 inputs_[0] = context;
2593 LOperand* context() { return inputs_[0]; }
2594 LOperand* value() { return inputs_[1]; }
2596 DECLARE_CONCRETE_INSTRUCTION(Typeof, "typeof")
2600 class LTypeofIsAndBranch FINAL : public LControlInstruction<1, 0> {
2602 explicit LTypeofIsAndBranch(LOperand* value) {
2606 LOperand* value() { return inputs_[0]; }
2608 DECLARE_CONCRETE_INSTRUCTION(TypeofIsAndBranch, "typeof-is-and-branch")
2609 DECLARE_HYDROGEN_ACCESSOR(TypeofIsAndBranch)
2611 Handle<String> type_literal() { return hydrogen()->type_literal(); }
2613 void PrintDataTo(StringStream* stream) OVERRIDE;
2617 class LIsConstructCallAndBranch FINAL : public LControlInstruction<0, 1> {
2619 explicit LIsConstructCallAndBranch(LOperand* temp) {
2623 LOperand* temp() { return temps_[0]; }
2625 DECLARE_CONCRETE_INSTRUCTION(IsConstructCallAndBranch,
2626 "is-construct-call-and-branch")
2630 class LOsrEntry FINAL : public LTemplateInstruction<0, 0, 0> {
2634 bool HasInterestingComment(LCodeGen* gen) const OVERRIDE { return false; }
2635 DECLARE_CONCRETE_INSTRUCTION(OsrEntry, "osr-entry")
2639 class LStackCheck FINAL : public LTemplateInstruction<0, 1, 0> {
2641 explicit LStackCheck(LOperand* context) {
2642 inputs_[0] = context;
2645 LOperand* context() { return inputs_[0]; }
2647 DECLARE_CONCRETE_INSTRUCTION(StackCheck, "stack-check")
2648 DECLARE_HYDROGEN_ACCESSOR(StackCheck)
2650 Label* done_label() { return &done_label_; }
2657 class LForInPrepareMap FINAL : public LTemplateInstruction<1, 2, 0> {
2659 LForInPrepareMap(LOperand* context, LOperand* object) {
2660 inputs_[0] = context;
2661 inputs_[1] = object;
2664 LOperand* context() { return inputs_[0]; }
2665 LOperand* object() { return inputs_[1]; }
2667 DECLARE_CONCRETE_INSTRUCTION(ForInPrepareMap, "for-in-prepare-map")
2671 class LForInCacheArray FINAL : public LTemplateInstruction<1, 1, 0> {
2673 explicit LForInCacheArray(LOperand* map) {
2677 LOperand* map() { return inputs_[0]; }
2679 DECLARE_CONCRETE_INSTRUCTION(ForInCacheArray, "for-in-cache-array")
2682 return HForInCacheArray::cast(this->hydrogen_value())->idx();
2687 class LCheckMapValue FINAL : public LTemplateInstruction<0, 2, 0> {
2689 LCheckMapValue(LOperand* value, LOperand* map) {
2694 LOperand* value() { return inputs_[0]; }
2695 LOperand* map() { return inputs_[1]; }
2697 DECLARE_CONCRETE_INSTRUCTION(CheckMapValue, "check-map-value")
2701 class LLoadFieldByIndex FINAL : public LTemplateInstruction<1, 2, 0> {
2703 LLoadFieldByIndex(LOperand* object, LOperand* index) {
2704 inputs_[0] = object;
2708 LOperand* object() { return inputs_[0]; }
2709 LOperand* index() { return inputs_[1]; }
2711 DECLARE_CONCRETE_INSTRUCTION(LoadFieldByIndex, "load-field-by-index")
2715 class LStoreFrameContext: public LTemplateInstruction<0, 1, 0> {
2717 explicit LStoreFrameContext(LOperand* context) {
2718 inputs_[0] = context;
2721 LOperand* context() { return inputs_[0]; }
2723 DECLARE_CONCRETE_INSTRUCTION(StoreFrameContext, "store-frame-context")
2727 class LAllocateBlockContext: public LTemplateInstruction<1, 2, 0> {
2729 LAllocateBlockContext(LOperand* context, LOperand* function) {
2730 inputs_[0] = context;
2731 inputs_[1] = function;
2734 LOperand* context() { return inputs_[0]; }
2735 LOperand* function() { return inputs_[1]; }
2737 Handle<ScopeInfo> scope_info() { return hydrogen()->scope_info(); }
2739 DECLARE_CONCRETE_INSTRUCTION(AllocateBlockContext, "allocate-block-context")
2740 DECLARE_HYDROGEN_ACCESSOR(AllocateBlockContext)
2744 class LChunkBuilder;
2745 class LPlatformChunk FINAL : public LChunk {
2747 LPlatformChunk(CompilationInfo* info, HGraph* graph)
2748 : LChunk(info, graph) { }
2750 int GetNextSpillIndex(RegisterKind kind);
2751 LOperand* GetNextSpillSlot(RegisterKind kind);
2755 class LChunkBuilder FINAL : public LChunkBuilderBase {
2757 LChunkBuilder(CompilationInfo* info, HGraph* graph, LAllocator* allocator)
2758 : LChunkBuilderBase(info, graph),
2759 current_instruction_(NULL),
2760 current_block_(NULL),
2762 allocator_(allocator) {}
2764 // Build the sequence for the graph.
2765 LPlatformChunk* Build();
2767 // Declare methods that deal with the individual node types.
2768 #define DECLARE_DO(type) LInstruction* Do##type(H##type* node);
2769 HYDROGEN_CONCRETE_INSTRUCTION_LIST(DECLARE_DO)
2772 LInstruction* DoMultiplyAdd(HMul* mul, HValue* addend);
2773 LInstruction* DoMultiplySub(HValue* minuend, HMul* mul);
2774 LInstruction* DoRSub(HSub* instr);
2776 static bool HasMagicNumberForDivisor(int32_t divisor);
2778 LInstruction* DoMathFloor(HUnaryMathOperation* instr);
2779 LInstruction* DoMathRound(HUnaryMathOperation* instr);
2780 LInstruction* DoMathFround(HUnaryMathOperation* instr);
2781 LInstruction* DoMathAbs(HUnaryMathOperation* instr);
2782 LInstruction* DoMathLog(HUnaryMathOperation* instr);
2783 LInstruction* DoMathExp(HUnaryMathOperation* instr);
2784 LInstruction* DoMathSqrt(HUnaryMathOperation* instr);
2785 LInstruction* DoMathPowHalf(HUnaryMathOperation* instr);
2786 LInstruction* DoMathClz32(HUnaryMathOperation* instr);
2787 LInstruction* DoDivByPowerOf2I(HDiv* instr);
2788 LInstruction* DoDivByConstI(HDiv* instr);
2789 LInstruction* DoDivI(HDiv* instr);
2790 LInstruction* DoModByPowerOf2I(HMod* instr);
2791 LInstruction* DoModByConstI(HMod* instr);
2792 LInstruction* DoModI(HMod* instr);
2793 LInstruction* DoFlooringDivByPowerOf2I(HMathFloorOfDiv* instr);
2794 LInstruction* DoFlooringDivByConstI(HMathFloorOfDiv* instr);
2795 LInstruction* DoFlooringDivI(HMathFloorOfDiv* instr);
2798 // Methods for getting operands for Use / Define / Temp.
2799 LUnallocated* ToUnallocated(Register reg);
2800 LUnallocated* ToUnallocated(DoubleRegister reg);
2802 // Methods for setting up define-use relationships.
2803 MUST_USE_RESULT LOperand* Use(HValue* value, LUnallocated* operand);
2804 MUST_USE_RESULT LOperand* UseFixed(HValue* value, Register fixed_register);
2805 MUST_USE_RESULT LOperand* UseFixedDouble(HValue* value,
2806 DoubleRegister fixed_register);
2808 // A value that is guaranteed to be allocated to a register.
2809 // Operand created by UseRegister is guaranteed to be live until the end of
2810 // instruction. This means that register allocator will not reuse it's
2811 // register for any other operand inside instruction.
2812 // Operand created by UseRegisterAtStart is guaranteed to be live only at
2813 // instruction start. Register allocator is free to assign the same register
2814 // to some other operand used inside instruction (i.e. temporary or
2816 MUST_USE_RESULT LOperand* UseRegister(HValue* value);
2817 MUST_USE_RESULT LOperand* UseRegisterAtStart(HValue* value);
2819 // An input operand in a register that may be trashed.
2820 MUST_USE_RESULT LOperand* UseTempRegister(HValue* value);
2822 // An input operand in a register or stack slot.
2823 MUST_USE_RESULT LOperand* Use(HValue* value);
2824 MUST_USE_RESULT LOperand* UseAtStart(HValue* value);
2826 // An input operand in a register, stack slot or a constant operand.
2827 MUST_USE_RESULT LOperand* UseOrConstant(HValue* value);
2828 MUST_USE_RESULT LOperand* UseOrConstantAtStart(HValue* value);
2830 // An input operand in a register or a constant operand.
2831 MUST_USE_RESULT LOperand* UseRegisterOrConstant(HValue* value);
2832 MUST_USE_RESULT LOperand* UseRegisterOrConstantAtStart(HValue* value);
2834 // An input operand in a constant operand.
2835 MUST_USE_RESULT LOperand* UseConstant(HValue* value);
2837 // An input operand in register, stack slot or a constant operand.
2838 // Will not be moved to a register even if one is freely available.
2839 MUST_USE_RESULT LOperand* UseAny(HValue* value) OVERRIDE;
2841 // Temporary operand that must be in a register.
2842 MUST_USE_RESULT LUnallocated* TempRegister();
2843 MUST_USE_RESULT LUnallocated* TempDoubleRegister();
2844 MUST_USE_RESULT LOperand* FixedTemp(Register reg);
2845 MUST_USE_RESULT LOperand* FixedTemp(DoubleRegister reg);
2847 // Methods for setting up define-use relationships.
2848 // Return the same instruction that they are passed.
2849 LInstruction* Define(LTemplateResultInstruction<1>* instr,
2850 LUnallocated* result);
2851 LInstruction* DefineAsRegister(LTemplateResultInstruction<1>* instr);
2852 LInstruction* DefineAsSpilled(LTemplateResultInstruction<1>* instr,
2854 LInstruction* DefineSameAsFirst(LTemplateResultInstruction<1>* instr);
2855 LInstruction* DefineFixed(LTemplateResultInstruction<1>* instr,
2857 LInstruction* DefineFixedDouble(LTemplateResultInstruction<1>* instr,
2858 DoubleRegister reg);
2859 LInstruction* AssignEnvironment(LInstruction* instr);
2860 LInstruction* AssignPointerMap(LInstruction* instr);
2862 enum CanDeoptimize { CAN_DEOPTIMIZE_EAGERLY, CANNOT_DEOPTIMIZE_EAGERLY };
2864 // By default we assume that instruction sequences generated for calls
2865 // cannot deoptimize eagerly and we do not attach environment to this
2867 LInstruction* MarkAsCall(
2868 LInstruction* instr,
2869 HInstruction* hinstr,
2870 CanDeoptimize can_deoptimize = CANNOT_DEOPTIMIZE_EAGERLY);
2872 void VisitInstruction(HInstruction* current);
2873 void AddInstruction(LInstruction* instr, HInstruction* current);
2875 void DoBasicBlock(HBasicBlock* block, HBasicBlock* next_block);
2876 LInstruction* DoShift(Token::Value op, HBitwiseBinaryOperation* instr);
2877 LInstruction* DoArithmeticD(Token::Value op,
2878 HArithmeticBinaryOperation* instr);
2879 LInstruction* DoArithmeticT(Token::Value op,
2880 HBinaryOperation* instr);
2882 HInstruction* current_instruction_;
2883 HBasicBlock* current_block_;
2884 HBasicBlock* next_block_;
2885 LAllocator* allocator_;
2887 DISALLOW_COPY_AND_ASSIGN(LChunkBuilder);
2890 #undef DECLARE_HYDROGEN_ACCESSOR
2891 #undef DECLARE_CONCRETE_INSTRUCTION
2893 } } // namespace v8::internal
2895 #endif // V8_ARM_LITHIUM_ARM_H_