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 virtual Opcode opcode() const FINAL OVERRIDE { \
171 return LInstruction::k##type; \
173 virtual void CompileToNative(LCodeGen* generator) FINAL OVERRIDE; \
174 virtual const char* Mnemonic() const FINAL OVERRIDE { \
177 static L##type* cast(LInstruction* instr) { \
178 DCHECK(instr->Is##type()); \
179 return reinterpret_cast<L##type*>(instr); \
183 #define DECLARE_HYDROGEN_ACCESSOR(type) \
184 H##type* hydrogen() const { \
185 return H##type::cast(hydrogen_value()); \
189 class LInstruction : public ZoneObject {
192 : environment_(NULL),
193 hydrogen_value_(NULL),
194 bit_field_(IsCallBits::encode(false)) {
197 virtual ~LInstruction() {}
199 virtual void CompileToNative(LCodeGen* generator) = 0;
200 virtual const char* Mnemonic() const = 0;
201 virtual void PrintTo(StringStream* stream);
202 virtual void PrintDataTo(StringStream* stream);
203 virtual void PrintOutputOperandTo(StringStream* stream);
206 // Declare a unique enum value for each instruction.
207 #define DECLARE_OPCODE(type) k##type,
208 LITHIUM_CONCRETE_INSTRUCTION_LIST(DECLARE_OPCODE)
209 kNumberOfInstructions
210 #undef DECLARE_OPCODE
213 virtual Opcode opcode() const = 0;
215 // Declare non-virtual type testers for all leaf IR classes.
216 #define DECLARE_PREDICATE(type) \
217 bool Is##type() const { return opcode() == k##type; }
218 LITHIUM_CONCRETE_INSTRUCTION_LIST(DECLARE_PREDICATE)
219 #undef DECLARE_PREDICATE
221 // Declare virtual predicates for instructions that don't have
223 virtual bool IsGap() const { return false; }
225 virtual bool IsControl() const { return false; }
227 // Try deleting this instruction if possible.
228 virtual bool TryDelete() { return false; }
230 void set_environment(LEnvironment* env) { environment_ = env; }
231 LEnvironment* environment() const { return environment_; }
232 bool HasEnvironment() const { return environment_ != NULL; }
234 void set_pointer_map(LPointerMap* p) { pointer_map_.set(p); }
235 LPointerMap* pointer_map() const { return pointer_map_.get(); }
236 bool HasPointerMap() const { return pointer_map_.is_set(); }
238 void set_hydrogen_value(HValue* value) { hydrogen_value_ = value; }
239 HValue* hydrogen_value() const { return hydrogen_value_; }
241 virtual void SetDeferredLazyDeoptimizationEnvironment(LEnvironment* env) { }
243 void MarkAsCall() { bit_field_ = IsCallBits::update(bit_field_, true); }
244 bool IsCall() const { return IsCallBits::decode(bit_field_); }
246 // Interface to the register allocator and iterators.
247 bool ClobbersTemps() const { return IsCall(); }
248 bool ClobbersRegisters() const { return IsCall(); }
249 virtual bool ClobbersDoubleRegisters(Isolate* isolate) const {
253 // Interface to the register allocator and iterators.
254 bool IsMarkedAsCall() const { return IsCall(); }
256 virtual bool HasResult() const = 0;
257 virtual LOperand* result() const = 0;
259 LOperand* FirstInput() { return InputAt(0); }
260 LOperand* Output() { return HasResult() ? result() : NULL; }
262 virtual bool HasInterestingComment(LCodeGen* gen) const { return true; }
268 virtual int InputCount() = 0;
269 virtual LOperand* InputAt(int i) = 0;
273 friend class InputIterator;
275 friend class TempIterator;
276 virtual int TempCount() = 0;
277 virtual LOperand* TempAt(int i) = 0;
279 class IsCallBits: public BitField<bool, 0, 1> {};
281 LEnvironment* environment_;
282 SetOncePointer<LPointerMap> pointer_map_;
283 HValue* hydrogen_value_;
288 // R = number of result operands (0 or 1).
290 class LTemplateResultInstruction : public LInstruction {
292 // Allow 0 or 1 output operands.
293 STATIC_ASSERT(R == 0 || R == 1);
294 virtual bool HasResult() const FINAL OVERRIDE {
295 return R != 0 && result() != NULL;
297 void set_result(LOperand* operand) { results_[0] = operand; }
298 LOperand* result() const { return results_[0]; }
301 EmbeddedContainer<LOperand*, R> results_;
305 // R = number of result operands (0 or 1).
306 // I = number of input operands.
307 // T = number of temporary operands.
308 template<int R, int I, int T>
309 class LTemplateInstruction : public LTemplateResultInstruction<R> {
311 EmbeddedContainer<LOperand*, I> inputs_;
312 EmbeddedContainer<LOperand*, T> temps_;
316 virtual int InputCount() FINAL OVERRIDE { return I; }
317 virtual LOperand* InputAt(int i) FINAL OVERRIDE { return inputs_[i]; }
319 virtual int TempCount() FINAL OVERRIDE { return T; }
320 virtual LOperand* TempAt(int i) FINAL OVERRIDE { return temps_[i]; }
324 class LGap : public LTemplateInstruction<0, 0, 0> {
326 explicit LGap(HBasicBlock* block)
328 parallel_moves_[BEFORE] = NULL;
329 parallel_moves_[START] = NULL;
330 parallel_moves_[END] = NULL;
331 parallel_moves_[AFTER] = NULL;
334 // Can't use the DECLARE-macro here because of sub-classes.
335 virtual bool IsGap() const OVERRIDE { return true; }
336 virtual void PrintDataTo(StringStream* stream) OVERRIDE;
337 static LGap* cast(LInstruction* instr) {
338 DCHECK(instr->IsGap());
339 return reinterpret_cast<LGap*>(instr);
342 bool IsRedundant() const;
344 HBasicBlock* block() const { return block_; }
351 FIRST_INNER_POSITION = BEFORE,
352 LAST_INNER_POSITION = AFTER
355 LParallelMove* GetOrCreateParallelMove(InnerPosition pos, Zone* zone) {
356 if (parallel_moves_[pos] == NULL) {
357 parallel_moves_[pos] = new(zone) LParallelMove(zone);
359 return parallel_moves_[pos];
362 LParallelMove* GetParallelMove(InnerPosition pos) {
363 return parallel_moves_[pos];
367 LParallelMove* parallel_moves_[LAST_INNER_POSITION + 1];
372 class LInstructionGap FINAL : public LGap {
374 explicit LInstructionGap(HBasicBlock* block) : LGap(block) { }
376 virtual bool HasInterestingComment(LCodeGen* gen) const OVERRIDE {
377 return !IsRedundant();
380 DECLARE_CONCRETE_INSTRUCTION(InstructionGap, "gap")
384 class LGoto FINAL : public LTemplateInstruction<0, 0, 0> {
386 explicit LGoto(HBasicBlock* block) : block_(block) { }
388 virtual bool HasInterestingComment(LCodeGen* gen) const OVERRIDE;
389 DECLARE_CONCRETE_INSTRUCTION(Goto, "goto")
390 virtual void PrintDataTo(StringStream* stream) OVERRIDE;
391 virtual bool IsControl() const OVERRIDE { return true; }
393 int block_id() const { return block_->block_id(); }
400 class LLazyBailout FINAL : public LTemplateInstruction<0, 0, 0> {
402 LLazyBailout() : gap_instructions_size_(0) { }
404 DECLARE_CONCRETE_INSTRUCTION(LazyBailout, "lazy-bailout")
406 void set_gap_instructions_size(int gap_instructions_size) {
407 gap_instructions_size_ = gap_instructions_size;
409 int gap_instructions_size() { return gap_instructions_size_; }
412 int gap_instructions_size_;
416 class LDummy FINAL : public LTemplateInstruction<1, 0, 0> {
419 DECLARE_CONCRETE_INSTRUCTION(Dummy, "dummy")
423 class LDummyUse FINAL : public LTemplateInstruction<1, 1, 0> {
425 explicit LDummyUse(LOperand* value) {
428 DECLARE_CONCRETE_INSTRUCTION(DummyUse, "dummy-use")
432 class LDeoptimize FINAL : public LTemplateInstruction<0, 0, 0> {
434 virtual bool IsControl() const OVERRIDE { return true; }
435 DECLARE_CONCRETE_INSTRUCTION(Deoptimize, "deoptimize")
436 DECLARE_HYDROGEN_ACCESSOR(Deoptimize)
440 class LLabel FINAL : public LGap {
442 explicit LLabel(HBasicBlock* block)
443 : LGap(block), replacement_(NULL) { }
445 virtual bool HasInterestingComment(LCodeGen* gen) const OVERRIDE {
448 DECLARE_CONCRETE_INSTRUCTION(Label, "label")
450 virtual void PrintDataTo(StringStream* stream) OVERRIDE;
452 int block_id() const { return block()->block_id(); }
453 bool is_loop_header() const { return block()->IsLoopHeader(); }
454 bool is_osr_entry() const { return block()->is_osr_entry(); }
455 Label* label() { return &label_; }
456 LLabel* replacement() const { return replacement_; }
457 void set_replacement(LLabel* label) { replacement_ = label; }
458 bool HasReplacement() const { return replacement_ != NULL; }
462 LLabel* replacement_;
466 class LParameter FINAL : public LTemplateInstruction<1, 0, 0> {
468 virtual bool HasInterestingComment(LCodeGen* gen) const { return false; }
469 DECLARE_CONCRETE_INSTRUCTION(Parameter, "parameter")
473 class LCallStub FINAL : public LTemplateInstruction<1, 1, 0> {
475 explicit LCallStub(LOperand* context) {
476 inputs_[0] = context;
479 LOperand* context() { return inputs_[0]; }
481 DECLARE_CONCRETE_INSTRUCTION(CallStub, "call-stub")
482 DECLARE_HYDROGEN_ACCESSOR(CallStub)
486 class LTailCallThroughMegamorphicCache FINAL
487 : public LTemplateInstruction<0, 3, 0> {
489 explicit LTailCallThroughMegamorphicCache(LOperand* context,
492 inputs_[0] = context;
493 inputs_[1] = receiver;
497 LOperand* context() { return inputs_[0]; }
498 LOperand* receiver() { return inputs_[1]; }
499 LOperand* name() { return inputs_[2]; }
501 DECLARE_CONCRETE_INSTRUCTION(TailCallThroughMegamorphicCache,
502 "tail-call-through-megamorphic-cache")
503 DECLARE_HYDROGEN_ACCESSOR(TailCallThroughMegamorphicCache)
506 class LUnknownOSRValue FINAL : public LTemplateInstruction<1, 0, 0> {
508 virtual bool HasInterestingComment(LCodeGen* gen) const OVERRIDE {
511 DECLARE_CONCRETE_INSTRUCTION(UnknownOSRValue, "unknown-osr-value")
515 template<int I, int T>
516 class LControlInstruction : public LTemplateInstruction<0, I, T> {
518 LControlInstruction() : false_label_(NULL), true_label_(NULL) { }
520 virtual bool IsControl() const FINAL OVERRIDE { return true; }
522 int SuccessorCount() { return hydrogen()->SuccessorCount(); }
523 HBasicBlock* SuccessorAt(int i) { return hydrogen()->SuccessorAt(i); }
525 int TrueDestination(LChunk* chunk) {
526 return chunk->LookupDestination(true_block_id());
528 int FalseDestination(LChunk* chunk) {
529 return chunk->LookupDestination(false_block_id());
532 Label* TrueLabel(LChunk* chunk) {
533 if (true_label_ == NULL) {
534 true_label_ = chunk->GetAssemblyLabel(TrueDestination(chunk));
538 Label* FalseLabel(LChunk* chunk) {
539 if (false_label_ == NULL) {
540 false_label_ = chunk->GetAssemblyLabel(FalseDestination(chunk));
546 int true_block_id() { return SuccessorAt(0)->block_id(); }
547 int false_block_id() { return SuccessorAt(1)->block_id(); }
550 HControlInstruction* hydrogen() {
551 return HControlInstruction::cast(this->hydrogen_value());
559 class LWrapReceiver FINAL : public LTemplateInstruction<1, 2, 0> {
561 LWrapReceiver(LOperand* receiver, LOperand* function) {
562 inputs_[0] = receiver;
563 inputs_[1] = function;
566 DECLARE_CONCRETE_INSTRUCTION(WrapReceiver, "wrap-receiver")
567 DECLARE_HYDROGEN_ACCESSOR(WrapReceiver)
569 LOperand* receiver() { return inputs_[0]; }
570 LOperand* function() { return inputs_[1]; }
574 class LApplyArguments FINAL : public LTemplateInstruction<1, 4, 0> {
576 LApplyArguments(LOperand* function,
579 LOperand* elements) {
580 inputs_[0] = function;
581 inputs_[1] = receiver;
583 inputs_[3] = elements;
586 DECLARE_CONCRETE_INSTRUCTION(ApplyArguments, "apply-arguments")
588 LOperand* function() { return inputs_[0]; }
589 LOperand* receiver() { return inputs_[1]; }
590 LOperand* length() { return inputs_[2]; }
591 LOperand* elements() { return inputs_[3]; }
595 class LAccessArgumentsAt FINAL : public LTemplateInstruction<1, 3, 0> {
597 LAccessArgumentsAt(LOperand* arguments, LOperand* length, LOperand* index) {
598 inputs_[0] = arguments;
603 DECLARE_CONCRETE_INSTRUCTION(AccessArgumentsAt, "access-arguments-at")
605 LOperand* arguments() { return inputs_[0]; }
606 LOperand* length() { return inputs_[1]; }
607 LOperand* index() { return inputs_[2]; }
609 virtual void PrintDataTo(StringStream* stream) OVERRIDE;
613 class LArgumentsLength FINAL : public LTemplateInstruction<1, 1, 0> {
615 explicit LArgumentsLength(LOperand* elements) {
616 inputs_[0] = elements;
619 LOperand* elements() { return inputs_[0]; }
621 DECLARE_CONCRETE_INSTRUCTION(ArgumentsLength, "arguments-length")
625 class LArgumentsElements FINAL : public LTemplateInstruction<1, 0, 0> {
627 DECLARE_CONCRETE_INSTRUCTION(ArgumentsElements, "arguments-elements")
628 DECLARE_HYDROGEN_ACCESSOR(ArgumentsElements)
632 class LModByPowerOf2I FINAL : public LTemplateInstruction<1, 1, 0> {
634 LModByPowerOf2I(LOperand* dividend, int32_t divisor) {
635 inputs_[0] = dividend;
639 LOperand* dividend() { return inputs_[0]; }
640 int32_t divisor() const { return divisor_; }
642 DECLARE_CONCRETE_INSTRUCTION(ModByPowerOf2I, "mod-by-power-of-2-i")
643 DECLARE_HYDROGEN_ACCESSOR(Mod)
650 class LModByConstI FINAL : public LTemplateInstruction<1, 1, 0> {
652 LModByConstI(LOperand* dividend, int32_t divisor) {
653 inputs_[0] = dividend;
657 LOperand* dividend() { return inputs_[0]; }
658 int32_t divisor() const { return divisor_; }
660 DECLARE_CONCRETE_INSTRUCTION(ModByConstI, "mod-by-const-i")
661 DECLARE_HYDROGEN_ACCESSOR(Mod)
668 class LModI FINAL : public LTemplateInstruction<1, 2, 2> {
670 LModI(LOperand* left, LOperand* right, LOperand* temp, LOperand* temp2) {
677 LOperand* left() { return inputs_[0]; }
678 LOperand* right() { return inputs_[1]; }
679 LOperand* temp() { return temps_[0]; }
680 LOperand* temp2() { return temps_[1]; }
682 DECLARE_CONCRETE_INSTRUCTION(ModI, "mod-i")
683 DECLARE_HYDROGEN_ACCESSOR(Mod)
687 class LDivByPowerOf2I FINAL : public LTemplateInstruction<1, 1, 0> {
689 LDivByPowerOf2I(LOperand* dividend, int32_t divisor) {
690 inputs_[0] = dividend;
694 LOperand* dividend() { return inputs_[0]; }
695 int32_t divisor() const { return divisor_; }
697 DECLARE_CONCRETE_INSTRUCTION(DivByPowerOf2I, "div-by-power-of-2-i")
698 DECLARE_HYDROGEN_ACCESSOR(Div)
705 class LDivByConstI FINAL : public LTemplateInstruction<1, 1, 0> {
707 LDivByConstI(LOperand* dividend, int32_t divisor) {
708 inputs_[0] = dividend;
712 LOperand* dividend() { return inputs_[0]; }
713 int32_t divisor() const { return divisor_; }
715 DECLARE_CONCRETE_INSTRUCTION(DivByConstI, "div-by-const-i")
716 DECLARE_HYDROGEN_ACCESSOR(Div)
723 class LDivI FINAL : public LTemplateInstruction<1, 2, 1> {
725 LDivI(LOperand* dividend, LOperand* divisor, LOperand* temp) {
726 inputs_[0] = dividend;
727 inputs_[1] = divisor;
731 LOperand* dividend() { return inputs_[0]; }
732 LOperand* divisor() { return inputs_[1]; }
733 LOperand* temp() { return temps_[0]; }
735 DECLARE_CONCRETE_INSTRUCTION(DivI, "div-i")
736 DECLARE_HYDROGEN_ACCESSOR(BinaryOperation)
740 class LFlooringDivByPowerOf2I FINAL : public LTemplateInstruction<1, 1, 0> {
742 LFlooringDivByPowerOf2I(LOperand* dividend, int32_t divisor) {
743 inputs_[0] = dividend;
747 LOperand* dividend() { return inputs_[0]; }
748 int32_t divisor() { return divisor_; }
750 DECLARE_CONCRETE_INSTRUCTION(FlooringDivByPowerOf2I,
751 "flooring-div-by-power-of-2-i")
752 DECLARE_HYDROGEN_ACCESSOR(MathFloorOfDiv)
759 class LFlooringDivByConstI FINAL : public LTemplateInstruction<1, 1, 2> {
761 LFlooringDivByConstI(LOperand* dividend, int32_t divisor, LOperand* temp) {
762 inputs_[0] = dividend;
767 LOperand* dividend() { return inputs_[0]; }
768 int32_t divisor() const { return divisor_; }
769 LOperand* temp() { return temps_[0]; }
771 DECLARE_CONCRETE_INSTRUCTION(FlooringDivByConstI, "flooring-div-by-const-i")
772 DECLARE_HYDROGEN_ACCESSOR(MathFloorOfDiv)
779 class LFlooringDivI FINAL : public LTemplateInstruction<1, 2, 1> {
781 LFlooringDivI(LOperand* dividend, LOperand* divisor, LOperand* temp) {
782 inputs_[0] = dividend;
783 inputs_[1] = divisor;
787 LOperand* dividend() { return inputs_[0]; }
788 LOperand* divisor() { return inputs_[1]; }
789 LOperand* temp() { return temps_[0]; }
791 DECLARE_CONCRETE_INSTRUCTION(FlooringDivI, "flooring-div-i")
792 DECLARE_HYDROGEN_ACCESSOR(MathFloorOfDiv)
796 class LMulI FINAL : public LTemplateInstruction<1, 2, 0> {
798 LMulI(LOperand* left, LOperand* right) {
803 LOperand* left() { return inputs_[0]; }
804 LOperand* right() { return inputs_[1]; }
806 DECLARE_CONCRETE_INSTRUCTION(MulI, "mul-i")
807 DECLARE_HYDROGEN_ACCESSOR(Mul)
811 // Instruction for computing multiplier * multiplicand + addend.
812 class LMultiplyAddD FINAL : public LTemplateInstruction<1, 3, 0> {
814 LMultiplyAddD(LOperand* addend, LOperand* multiplier,
815 LOperand* multiplicand) {
817 inputs_[1] = multiplier;
818 inputs_[2] = multiplicand;
821 LOperand* addend() { return inputs_[0]; }
822 LOperand* multiplier() { return inputs_[1]; }
823 LOperand* multiplicand() { return inputs_[2]; }
825 DECLARE_CONCRETE_INSTRUCTION(MultiplyAddD, "multiply-add-d")
829 // Instruction for computing minuend - multiplier * multiplicand.
830 class LMultiplySubD FINAL : public LTemplateInstruction<1, 3, 0> {
832 LMultiplySubD(LOperand* minuend, LOperand* multiplier,
833 LOperand* multiplicand) {
834 inputs_[0] = minuend;
835 inputs_[1] = multiplier;
836 inputs_[2] = multiplicand;
839 LOperand* minuend() { return inputs_[0]; }
840 LOperand* multiplier() { return inputs_[1]; }
841 LOperand* multiplicand() { return inputs_[2]; }
843 DECLARE_CONCRETE_INSTRUCTION(MultiplySubD, "multiply-sub-d")
847 class LDebugBreak FINAL : public LTemplateInstruction<0, 0, 0> {
849 DECLARE_CONCRETE_INSTRUCTION(DebugBreak, "break")
853 class LCompareNumericAndBranch FINAL : public LControlInstruction<2, 0> {
855 LCompareNumericAndBranch(LOperand* left, LOperand* right) {
860 LOperand* left() { return inputs_[0]; }
861 LOperand* right() { return inputs_[1]; }
863 DECLARE_CONCRETE_INSTRUCTION(CompareNumericAndBranch,
864 "compare-numeric-and-branch")
865 DECLARE_HYDROGEN_ACCESSOR(CompareNumericAndBranch)
867 Token::Value op() const { return hydrogen()->token(); }
868 bool is_double() const {
869 return hydrogen()->representation().IsDouble();
872 virtual void PrintDataTo(StringStream* stream) OVERRIDE;
876 class LMathFloor FINAL : public LTemplateInstruction<1, 1, 0> {
878 explicit LMathFloor(LOperand* value) {
882 LOperand* value() { return inputs_[0]; }
884 DECLARE_CONCRETE_INSTRUCTION(MathFloor, "math-floor")
885 DECLARE_HYDROGEN_ACCESSOR(UnaryMathOperation)
889 class LMathRound FINAL : public LTemplateInstruction<1, 1, 1> {
891 LMathRound(LOperand* value, LOperand* temp) {
896 LOperand* value() { return inputs_[0]; }
897 LOperand* temp() { return temps_[0]; }
899 DECLARE_CONCRETE_INSTRUCTION(MathRound, "math-round")
900 DECLARE_HYDROGEN_ACCESSOR(UnaryMathOperation)
904 class LMathFround FINAL : public LTemplateInstruction<1, 1, 0> {
906 explicit LMathFround(LOperand* value) { inputs_[0] = value; }
908 LOperand* value() { return inputs_[0]; }
910 DECLARE_CONCRETE_INSTRUCTION(MathFround, "math-fround")
914 class LMathAbs FINAL : public LTemplateInstruction<1, 2, 0> {
916 LMathAbs(LOperand* context, LOperand* value) {
917 inputs_[1] = context;
921 LOperand* context() { return inputs_[1]; }
922 LOperand* value() { return inputs_[0]; }
924 DECLARE_CONCRETE_INSTRUCTION(MathAbs, "math-abs")
925 DECLARE_HYDROGEN_ACCESSOR(UnaryMathOperation)
929 class LMathLog FINAL : public LTemplateInstruction<1, 1, 0> {
931 explicit LMathLog(LOperand* value) {
935 LOperand* value() { return inputs_[0]; }
937 DECLARE_CONCRETE_INSTRUCTION(MathLog, "math-log")
941 class LMathClz32 FINAL : public LTemplateInstruction<1, 1, 0> {
943 explicit LMathClz32(LOperand* value) {
947 LOperand* value() { return inputs_[0]; }
949 DECLARE_CONCRETE_INSTRUCTION(MathClz32, "math-clz32")
953 class LMathExp FINAL : public LTemplateInstruction<1, 1, 3> {
955 LMathExp(LOperand* value,
956 LOperand* double_temp,
962 temps_[2] = double_temp;
963 ExternalReference::InitializeMathExpData();
966 LOperand* value() { return inputs_[0]; }
967 LOperand* temp1() { return temps_[0]; }
968 LOperand* temp2() { return temps_[1]; }
969 LOperand* double_temp() { return temps_[2]; }
971 DECLARE_CONCRETE_INSTRUCTION(MathExp, "math-exp")
975 class LMathSqrt FINAL : public LTemplateInstruction<1, 1, 0> {
977 explicit LMathSqrt(LOperand* value) {
981 LOperand* value() { return inputs_[0]; }
983 DECLARE_CONCRETE_INSTRUCTION(MathSqrt, "math-sqrt")
987 class LMathPowHalf FINAL : public LTemplateInstruction<1, 1, 0> {
989 explicit LMathPowHalf(LOperand* value) {
993 LOperand* value() { return inputs_[0]; }
995 DECLARE_CONCRETE_INSTRUCTION(MathPowHalf, "math-pow-half")
999 class LCmpObjectEqAndBranch FINAL : public LControlInstruction<2, 0> {
1001 LCmpObjectEqAndBranch(LOperand* left, LOperand* right) {
1006 LOperand* left() { return inputs_[0]; }
1007 LOperand* right() { return inputs_[1]; }
1009 DECLARE_CONCRETE_INSTRUCTION(CmpObjectEqAndBranch, "cmp-object-eq-and-branch")
1010 DECLARE_HYDROGEN_ACCESSOR(CompareObjectEqAndBranch)
1014 class LCmpHoleAndBranch FINAL : public LControlInstruction<1, 0> {
1016 explicit LCmpHoleAndBranch(LOperand* object) {
1017 inputs_[0] = object;
1020 LOperand* object() { return inputs_[0]; }
1022 DECLARE_CONCRETE_INSTRUCTION(CmpHoleAndBranch, "cmp-hole-and-branch")
1023 DECLARE_HYDROGEN_ACCESSOR(CompareHoleAndBranch)
1027 class LCompareMinusZeroAndBranch FINAL : public LControlInstruction<1, 1> {
1029 LCompareMinusZeroAndBranch(LOperand* value, LOperand* temp) {
1034 LOperand* value() { return inputs_[0]; }
1035 LOperand* temp() { return temps_[0]; }
1037 DECLARE_CONCRETE_INSTRUCTION(CompareMinusZeroAndBranch,
1038 "cmp-minus-zero-and-branch")
1039 DECLARE_HYDROGEN_ACCESSOR(CompareMinusZeroAndBranch)
1043 class LIsObjectAndBranch FINAL : public LControlInstruction<1, 1> {
1045 LIsObjectAndBranch(LOperand* value, LOperand* temp) {
1050 LOperand* value() { return inputs_[0]; }
1051 LOperand* temp() { return temps_[0]; }
1053 DECLARE_CONCRETE_INSTRUCTION(IsObjectAndBranch, "is-object-and-branch")
1054 DECLARE_HYDROGEN_ACCESSOR(IsObjectAndBranch)
1056 virtual void PrintDataTo(StringStream* stream) OVERRIDE;
1060 class LIsStringAndBranch FINAL : public LControlInstruction<1, 1> {
1062 LIsStringAndBranch(LOperand* value, LOperand* temp) {
1067 LOperand* value() { return inputs_[0]; }
1068 LOperand* temp() { return temps_[0]; }
1070 DECLARE_CONCRETE_INSTRUCTION(IsStringAndBranch, "is-string-and-branch")
1071 DECLARE_HYDROGEN_ACCESSOR(IsStringAndBranch)
1073 virtual void PrintDataTo(StringStream* stream) OVERRIDE;
1077 class LIsSmiAndBranch FINAL : public LControlInstruction<1, 0> {
1079 explicit LIsSmiAndBranch(LOperand* value) {
1083 LOperand* value() { return inputs_[0]; }
1085 DECLARE_CONCRETE_INSTRUCTION(IsSmiAndBranch, "is-smi-and-branch")
1086 DECLARE_HYDROGEN_ACCESSOR(IsSmiAndBranch)
1088 virtual void PrintDataTo(StringStream* stream) OVERRIDE;
1092 class LIsUndetectableAndBranch FINAL : public LControlInstruction<1, 1> {
1094 explicit LIsUndetectableAndBranch(LOperand* value, LOperand* temp) {
1099 LOperand* value() { return inputs_[0]; }
1100 LOperand* temp() { return temps_[0]; }
1102 DECLARE_CONCRETE_INSTRUCTION(IsUndetectableAndBranch,
1103 "is-undetectable-and-branch")
1104 DECLARE_HYDROGEN_ACCESSOR(IsUndetectableAndBranch)
1106 virtual void PrintDataTo(StringStream* stream) OVERRIDE;
1110 class LStringCompareAndBranch FINAL : public LControlInstruction<3, 0> {
1112 LStringCompareAndBranch(LOperand* context, LOperand* left, LOperand* right) {
1113 inputs_[0] = context;
1118 LOperand* context() { return inputs_[0]; }
1119 LOperand* left() { return inputs_[1]; }
1120 LOperand* right() { return inputs_[2]; }
1122 DECLARE_CONCRETE_INSTRUCTION(StringCompareAndBranch,
1123 "string-compare-and-branch")
1124 DECLARE_HYDROGEN_ACCESSOR(StringCompareAndBranch)
1126 Token::Value op() const { return hydrogen()->token(); }
1128 virtual void PrintDataTo(StringStream* stream) OVERRIDE;
1132 class LHasInstanceTypeAndBranch FINAL : public LControlInstruction<1, 0> {
1134 explicit LHasInstanceTypeAndBranch(LOperand* value) {
1138 LOperand* value() { return inputs_[0]; }
1140 DECLARE_CONCRETE_INSTRUCTION(HasInstanceTypeAndBranch,
1141 "has-instance-type-and-branch")
1142 DECLARE_HYDROGEN_ACCESSOR(HasInstanceTypeAndBranch)
1144 virtual void PrintDataTo(StringStream* stream) OVERRIDE;
1148 class LGetCachedArrayIndex FINAL : public LTemplateInstruction<1, 1, 0> {
1150 explicit LGetCachedArrayIndex(LOperand* value) {
1154 LOperand* value() { return inputs_[0]; }
1156 DECLARE_CONCRETE_INSTRUCTION(GetCachedArrayIndex, "get-cached-array-index")
1157 DECLARE_HYDROGEN_ACCESSOR(GetCachedArrayIndex)
1161 class LHasCachedArrayIndexAndBranch FINAL
1162 : public LControlInstruction<1, 0> {
1164 explicit LHasCachedArrayIndexAndBranch(LOperand* value) {
1168 LOperand* value() { return inputs_[0]; }
1170 DECLARE_CONCRETE_INSTRUCTION(HasCachedArrayIndexAndBranch,
1171 "has-cached-array-index-and-branch")
1172 DECLARE_HYDROGEN_ACCESSOR(HasCachedArrayIndexAndBranch)
1174 virtual void PrintDataTo(StringStream* stream) OVERRIDE;
1178 class LClassOfTestAndBranch FINAL : public LControlInstruction<1, 1> {
1180 LClassOfTestAndBranch(LOperand* value, LOperand* temp) {
1185 LOperand* value() { return inputs_[0]; }
1186 LOperand* temp() { return temps_[0]; }
1188 DECLARE_CONCRETE_INSTRUCTION(ClassOfTestAndBranch,
1189 "class-of-test-and-branch")
1190 DECLARE_HYDROGEN_ACCESSOR(ClassOfTestAndBranch)
1192 virtual void PrintDataTo(StringStream* stream) OVERRIDE;
1196 class LCmpT FINAL : public LTemplateInstruction<1, 3, 0> {
1198 LCmpT(LOperand* context, LOperand* left, LOperand* right) {
1199 inputs_[0] = context;
1204 LOperand* context() { return inputs_[0]; }
1205 LOperand* left() { return inputs_[1]; }
1206 LOperand* right() { return inputs_[2]; }
1208 DECLARE_CONCRETE_INSTRUCTION(CmpT, "cmp-t")
1209 DECLARE_HYDROGEN_ACCESSOR(CompareGeneric)
1211 Token::Value op() const { return hydrogen()->token(); }
1215 class LInstanceOf FINAL : public LTemplateInstruction<1, 3, 0> {
1217 LInstanceOf(LOperand* context, LOperand* left, LOperand* right) {
1218 inputs_[0] = context;
1223 LOperand* context() { return inputs_[0]; }
1224 LOperand* left() { return inputs_[1]; }
1225 LOperand* right() { return inputs_[2]; }
1227 DECLARE_CONCRETE_INSTRUCTION(InstanceOf, "instance-of")
1231 class LInstanceOfKnownGlobal FINAL : public LTemplateInstruction<1, 2, 1> {
1233 LInstanceOfKnownGlobal(LOperand* context, LOperand* value, LOperand* temp) {
1234 inputs_[0] = context;
1239 LOperand* context() { return inputs_[0]; }
1240 LOperand* value() { return inputs_[1]; }
1241 LOperand* temp() { return temps_[0]; }
1243 DECLARE_CONCRETE_INSTRUCTION(InstanceOfKnownGlobal,
1244 "instance-of-known-global")
1245 DECLARE_HYDROGEN_ACCESSOR(InstanceOfKnownGlobal)
1247 Handle<JSFunction> function() const { return hydrogen()->function(); }
1248 LEnvironment* GetDeferredLazyDeoptimizationEnvironment() {
1249 return lazy_deopt_env_;
1251 virtual void SetDeferredLazyDeoptimizationEnvironment(
1252 LEnvironment* env) OVERRIDE {
1253 lazy_deopt_env_ = env;
1257 LEnvironment* lazy_deopt_env_;
1261 class LBoundsCheck FINAL : public LTemplateInstruction<0, 2, 0> {
1263 LBoundsCheck(LOperand* index, LOperand* length) {
1265 inputs_[1] = length;
1268 LOperand* index() { return inputs_[0]; }
1269 LOperand* length() { return inputs_[1]; }
1271 DECLARE_CONCRETE_INSTRUCTION(BoundsCheck, "bounds-check")
1272 DECLARE_HYDROGEN_ACCESSOR(BoundsCheck)
1276 class LBitI FINAL : public LTemplateInstruction<1, 2, 0> {
1278 LBitI(LOperand* left, LOperand* right) {
1283 LOperand* left() { return inputs_[0]; }
1284 LOperand* right() { return inputs_[1]; }
1286 Token::Value op() const { return hydrogen()->op(); }
1288 DECLARE_CONCRETE_INSTRUCTION(BitI, "bit-i")
1289 DECLARE_HYDROGEN_ACCESSOR(Bitwise)
1293 class LShiftI FINAL : public LTemplateInstruction<1, 2, 0> {
1295 LShiftI(Token::Value op, LOperand* left, LOperand* right, bool can_deopt)
1296 : op_(op), can_deopt_(can_deopt) {
1301 Token::Value op() const { return op_; }
1302 LOperand* left() { return inputs_[0]; }
1303 LOperand* right() { return inputs_[1]; }
1304 bool can_deopt() const { return can_deopt_; }
1306 DECLARE_CONCRETE_INSTRUCTION(ShiftI, "shift-i")
1314 class LSubI FINAL : public LTemplateInstruction<1, 2, 0> {
1316 LSubI(LOperand* left, LOperand* right) {
1321 LOperand* left() { return inputs_[0]; }
1322 LOperand* right() { return inputs_[1]; }
1324 DECLARE_CONCRETE_INSTRUCTION(SubI, "sub-i")
1325 DECLARE_HYDROGEN_ACCESSOR(Sub)
1329 class LRSubI FINAL : public LTemplateInstruction<1, 2, 0> {
1331 LRSubI(LOperand* left, LOperand* right) {
1336 LOperand* left() { return inputs_[0]; }
1337 LOperand* right() { return inputs_[1]; }
1339 DECLARE_CONCRETE_INSTRUCTION(RSubI, "rsub-i")
1340 DECLARE_HYDROGEN_ACCESSOR(Sub)
1344 class LConstantI FINAL : public LTemplateInstruction<1, 0, 0> {
1346 DECLARE_CONCRETE_INSTRUCTION(ConstantI, "constant-i")
1347 DECLARE_HYDROGEN_ACCESSOR(Constant)
1349 int32_t value() const { return hydrogen()->Integer32Value(); }
1353 class LConstantS FINAL : public LTemplateInstruction<1, 0, 0> {
1355 DECLARE_CONCRETE_INSTRUCTION(ConstantS, "constant-s")
1356 DECLARE_HYDROGEN_ACCESSOR(Constant)
1358 Smi* value() const { return Smi::FromInt(hydrogen()->Integer32Value()); }
1362 class LConstantD FINAL : public LTemplateInstruction<1, 0, 0> {
1364 DECLARE_CONCRETE_INSTRUCTION(ConstantD, "constant-d")
1365 DECLARE_HYDROGEN_ACCESSOR(Constant)
1367 double value() const { return hydrogen()->DoubleValue(); }
1371 class LConstantE FINAL : public LTemplateInstruction<1, 0, 0> {
1373 DECLARE_CONCRETE_INSTRUCTION(ConstantE, "constant-e")
1374 DECLARE_HYDROGEN_ACCESSOR(Constant)
1376 ExternalReference value() const {
1377 return hydrogen()->ExternalReferenceValue();
1382 class LConstantT FINAL : public LTemplateInstruction<1, 0, 0> {
1384 DECLARE_CONCRETE_INSTRUCTION(ConstantT, "constant-t")
1385 DECLARE_HYDROGEN_ACCESSOR(Constant)
1387 Handle<Object> value(Isolate* isolate) const {
1388 return hydrogen()->handle(isolate);
1393 class LBranch FINAL : public LControlInstruction<1, 0> {
1395 explicit LBranch(LOperand* value) {
1399 LOperand* value() { return inputs_[0]; }
1401 DECLARE_CONCRETE_INSTRUCTION(Branch, "branch")
1402 DECLARE_HYDROGEN_ACCESSOR(Branch)
1404 virtual void PrintDataTo(StringStream* stream) OVERRIDE;
1408 class LCmpMapAndBranch FINAL : public LControlInstruction<1, 1> {
1410 LCmpMapAndBranch(LOperand* value, LOperand* temp) {
1415 LOperand* value() { return inputs_[0]; }
1416 LOperand* temp() { return temps_[0]; }
1418 DECLARE_CONCRETE_INSTRUCTION(CmpMapAndBranch, "cmp-map-and-branch")
1419 DECLARE_HYDROGEN_ACCESSOR(CompareMap)
1421 Handle<Map> map() const { return hydrogen()->map().handle(); }
1425 class LMapEnumLength FINAL : public LTemplateInstruction<1, 1, 0> {
1427 explicit LMapEnumLength(LOperand* value) {
1431 LOperand* value() { return inputs_[0]; }
1433 DECLARE_CONCRETE_INSTRUCTION(MapEnumLength, "map-enum-length")
1437 class LDateField FINAL : public LTemplateInstruction<1, 1, 1> {
1439 LDateField(LOperand* date, LOperand* temp, Smi* index) : index_(index) {
1444 LOperand* date() { return inputs_[0]; }
1445 LOperand* temp() { return temps_[0]; }
1446 Smi* index() const { return index_; }
1448 DECLARE_CONCRETE_INSTRUCTION(DateField, "date-field")
1449 DECLARE_HYDROGEN_ACCESSOR(DateField)
1456 class LSeqStringGetChar FINAL : public LTemplateInstruction<1, 2, 0> {
1458 LSeqStringGetChar(LOperand* string, LOperand* index) {
1459 inputs_[0] = string;
1463 LOperand* string() const { return inputs_[0]; }
1464 LOperand* index() const { return inputs_[1]; }
1466 DECLARE_CONCRETE_INSTRUCTION(SeqStringGetChar, "seq-string-get-char")
1467 DECLARE_HYDROGEN_ACCESSOR(SeqStringGetChar)
1471 class LSeqStringSetChar FINAL : public LTemplateInstruction<1, 4, 0> {
1473 LSeqStringSetChar(LOperand* context,
1477 inputs_[0] = context;
1478 inputs_[1] = string;
1483 LOperand* string() { return inputs_[1]; }
1484 LOperand* index() { return inputs_[2]; }
1485 LOperand* value() { return inputs_[3]; }
1487 DECLARE_CONCRETE_INSTRUCTION(SeqStringSetChar, "seq-string-set-char")
1488 DECLARE_HYDROGEN_ACCESSOR(SeqStringSetChar)
1492 class LAddI FINAL : public LTemplateInstruction<1, 2, 0> {
1494 LAddI(LOperand* left, LOperand* right) {
1499 LOperand* left() { return inputs_[0]; }
1500 LOperand* right() { return inputs_[1]; }
1502 DECLARE_CONCRETE_INSTRUCTION(AddI, "add-i")
1503 DECLARE_HYDROGEN_ACCESSOR(Add)
1507 class LMathMinMax FINAL : public LTemplateInstruction<1, 2, 0> {
1509 LMathMinMax(LOperand* left, LOperand* right) {
1514 LOperand* left() { return inputs_[0]; }
1515 LOperand* right() { return inputs_[1]; }
1517 DECLARE_CONCRETE_INSTRUCTION(MathMinMax, "math-min-max")
1518 DECLARE_HYDROGEN_ACCESSOR(MathMinMax)
1522 class LPower FINAL : public LTemplateInstruction<1, 2, 0> {
1524 LPower(LOperand* left, LOperand* right) {
1529 LOperand* left() { return inputs_[0]; }
1530 LOperand* right() { return inputs_[1]; }
1532 DECLARE_CONCRETE_INSTRUCTION(Power, "power")
1533 DECLARE_HYDROGEN_ACCESSOR(Power)
1537 class LArithmeticD FINAL : public LTemplateInstruction<1, 2, 0> {
1539 LArithmeticD(Token::Value op, LOperand* left, LOperand* right)
1545 Token::Value op() const { return op_; }
1546 LOperand* left() { return inputs_[0]; }
1547 LOperand* right() { return inputs_[1]; }
1549 virtual Opcode opcode() const OVERRIDE {
1550 return LInstruction::kArithmeticD;
1552 virtual void CompileToNative(LCodeGen* generator) OVERRIDE;
1553 virtual const char* Mnemonic() const OVERRIDE;
1560 class LArithmeticT FINAL : public LTemplateInstruction<1, 3, 0> {
1562 LArithmeticT(Token::Value op,
1567 inputs_[0] = context;
1572 LOperand* context() { return inputs_[0]; }
1573 LOperand* left() { return inputs_[1]; }
1574 LOperand* right() { return inputs_[2]; }
1575 Token::Value op() const { return op_; }
1577 virtual Opcode opcode() const OVERRIDE {
1578 return LInstruction::kArithmeticT;
1580 virtual void CompileToNative(LCodeGen* generator) OVERRIDE;
1581 virtual const char* Mnemonic() const OVERRIDE;
1588 class LReturn FINAL : public LTemplateInstruction<0, 3, 0> {
1590 LReturn(LOperand* value, LOperand* context, LOperand* parameter_count) {
1592 inputs_[1] = context;
1593 inputs_[2] = parameter_count;
1596 LOperand* value() { return inputs_[0]; }
1598 bool has_constant_parameter_count() {
1599 return parameter_count()->IsConstantOperand();
1601 LConstantOperand* constant_parameter_count() {
1602 DCHECK(has_constant_parameter_count());
1603 return LConstantOperand::cast(parameter_count());
1605 LOperand* parameter_count() { return inputs_[2]; }
1607 DECLARE_CONCRETE_INSTRUCTION(Return, "return")
1611 class LLoadNamedField FINAL : public LTemplateInstruction<1, 1, 0> {
1613 explicit LLoadNamedField(LOperand* object) {
1614 inputs_[0] = object;
1617 LOperand* object() { return inputs_[0]; }
1619 DECLARE_CONCRETE_INSTRUCTION(LoadNamedField, "load-named-field")
1620 DECLARE_HYDROGEN_ACCESSOR(LoadNamedField)
1624 class LLoadNamedGeneric FINAL : public LTemplateInstruction<1, 2, 1> {
1626 LLoadNamedGeneric(LOperand* context, LOperand* object, LOperand* vector) {
1627 inputs_[0] = context;
1628 inputs_[1] = object;
1632 LOperand* context() { return inputs_[0]; }
1633 LOperand* object() { return inputs_[1]; }
1634 LOperand* temp_vector() { return temps_[0]; }
1636 DECLARE_CONCRETE_INSTRUCTION(LoadNamedGeneric, "load-named-generic")
1637 DECLARE_HYDROGEN_ACCESSOR(LoadNamedGeneric)
1639 Handle<Object> name() const { return hydrogen()->name(); }
1643 class LLoadFunctionPrototype FINAL : public LTemplateInstruction<1, 1, 0> {
1645 explicit LLoadFunctionPrototype(LOperand* function) {
1646 inputs_[0] = function;
1649 LOperand* function() { return inputs_[0]; }
1651 DECLARE_CONCRETE_INSTRUCTION(LoadFunctionPrototype, "load-function-prototype")
1652 DECLARE_HYDROGEN_ACCESSOR(LoadFunctionPrototype)
1656 class LLoadRoot FINAL : public LTemplateInstruction<1, 0, 0> {
1658 DECLARE_CONCRETE_INSTRUCTION(LoadRoot, "load-root")
1659 DECLARE_HYDROGEN_ACCESSOR(LoadRoot)
1661 Heap::RootListIndex index() const { return hydrogen()->index(); }
1665 class LLoadKeyed FINAL : public LTemplateInstruction<1, 2, 0> {
1667 LLoadKeyed(LOperand* elements, LOperand* key) {
1668 inputs_[0] = elements;
1672 LOperand* elements() { return inputs_[0]; }
1673 LOperand* key() { return inputs_[1]; }
1674 ElementsKind elements_kind() const {
1675 return hydrogen()->elements_kind();
1677 bool is_external() const {
1678 return hydrogen()->is_external();
1680 bool is_fixed_typed_array() const {
1681 return hydrogen()->is_fixed_typed_array();
1683 bool is_typed_elements() const {
1684 return is_external() || is_fixed_typed_array();
1687 DECLARE_CONCRETE_INSTRUCTION(LoadKeyed, "load-keyed")
1688 DECLARE_HYDROGEN_ACCESSOR(LoadKeyed)
1690 virtual void PrintDataTo(StringStream* stream) OVERRIDE;
1691 uint32_t base_offset() const { return hydrogen()->base_offset(); }
1695 class LLoadKeyedGeneric FINAL : public LTemplateInstruction<1, 3, 1> {
1697 LLoadKeyedGeneric(LOperand* context, LOperand* object, LOperand* key,
1699 inputs_[0] = context;
1700 inputs_[1] = object;
1705 LOperand* context() { return inputs_[0]; }
1706 LOperand* object() { return inputs_[1]; }
1707 LOperand* key() { return inputs_[2]; }
1708 LOperand* temp_vector() { return temps_[0]; }
1710 DECLARE_CONCRETE_INSTRUCTION(LoadKeyedGeneric, "load-keyed-generic")
1711 DECLARE_HYDROGEN_ACCESSOR(LoadKeyedGeneric)
1715 class LLoadGlobalCell FINAL : public LTemplateInstruction<1, 0, 0> {
1717 DECLARE_CONCRETE_INSTRUCTION(LoadGlobalCell, "load-global-cell")
1718 DECLARE_HYDROGEN_ACCESSOR(LoadGlobalCell)
1722 class LLoadGlobalGeneric FINAL : public LTemplateInstruction<1, 2, 1> {
1724 LLoadGlobalGeneric(LOperand* context, LOperand* global_object,
1726 inputs_[0] = context;
1727 inputs_[1] = global_object;
1731 LOperand* context() { return inputs_[0]; }
1732 LOperand* global_object() { return inputs_[1]; }
1733 LOperand* temp_vector() { return temps_[0]; }
1735 DECLARE_CONCRETE_INSTRUCTION(LoadGlobalGeneric, "load-global-generic")
1736 DECLARE_HYDROGEN_ACCESSOR(LoadGlobalGeneric)
1738 Handle<Object> name() const { return hydrogen()->name(); }
1739 bool for_typeof() const { return hydrogen()->for_typeof(); }
1743 class LStoreGlobalCell FINAL : public LTemplateInstruction<0, 1, 1> {
1745 LStoreGlobalCell(LOperand* value, LOperand* temp) {
1750 LOperand* value() { return inputs_[0]; }
1751 LOperand* temp() { return temps_[0]; }
1753 DECLARE_CONCRETE_INSTRUCTION(StoreGlobalCell, "store-global-cell")
1754 DECLARE_HYDROGEN_ACCESSOR(StoreGlobalCell)
1758 class LLoadContextSlot FINAL : public LTemplateInstruction<1, 1, 0> {
1760 explicit LLoadContextSlot(LOperand* context) {
1761 inputs_[0] = context;
1764 LOperand* context() { return inputs_[0]; }
1766 DECLARE_CONCRETE_INSTRUCTION(LoadContextSlot, "load-context-slot")
1767 DECLARE_HYDROGEN_ACCESSOR(LoadContextSlot)
1769 int slot_index() { return hydrogen()->slot_index(); }
1771 virtual void PrintDataTo(StringStream* stream) OVERRIDE;
1775 class LStoreContextSlot FINAL : public LTemplateInstruction<0, 2, 0> {
1777 LStoreContextSlot(LOperand* context, LOperand* value) {
1778 inputs_[0] = context;
1782 LOperand* context() { return inputs_[0]; }
1783 LOperand* value() { return inputs_[1]; }
1785 DECLARE_CONCRETE_INSTRUCTION(StoreContextSlot, "store-context-slot")
1786 DECLARE_HYDROGEN_ACCESSOR(StoreContextSlot)
1788 int slot_index() { return hydrogen()->slot_index(); }
1790 virtual void PrintDataTo(StringStream* stream) OVERRIDE;
1794 class LPushArgument FINAL : public LTemplateInstruction<0, 1, 0> {
1796 explicit LPushArgument(LOperand* value) {
1800 LOperand* value() { return inputs_[0]; }
1802 DECLARE_CONCRETE_INSTRUCTION(PushArgument, "push-argument")
1806 class LDrop FINAL : public LTemplateInstruction<0, 0, 0> {
1808 explicit LDrop(int count) : count_(count) { }
1810 int count() const { return count_; }
1812 DECLARE_CONCRETE_INSTRUCTION(Drop, "drop")
1819 class LStoreCodeEntry FINAL: public LTemplateInstruction<0, 2, 0> {
1821 LStoreCodeEntry(LOperand* function, LOperand* code_object) {
1822 inputs_[0] = function;
1823 inputs_[1] = code_object;
1826 LOperand* function() { return inputs_[0]; }
1827 LOperand* code_object() { return inputs_[1]; }
1829 virtual void PrintDataTo(StringStream* stream);
1831 DECLARE_CONCRETE_INSTRUCTION(StoreCodeEntry, "store-code-entry")
1832 DECLARE_HYDROGEN_ACCESSOR(StoreCodeEntry)
1836 class LInnerAllocatedObject FINAL: public LTemplateInstruction<1, 2, 0> {
1838 LInnerAllocatedObject(LOperand* base_object, LOperand* offset) {
1839 inputs_[0] = base_object;
1840 inputs_[1] = offset;
1843 LOperand* base_object() const { return inputs_[0]; }
1844 LOperand* offset() const { return inputs_[1]; }
1846 virtual void PrintDataTo(StringStream* stream) OVERRIDE;
1848 DECLARE_CONCRETE_INSTRUCTION(InnerAllocatedObject, "inner-allocated-object")
1852 class LThisFunction FINAL : public LTemplateInstruction<1, 0, 0> {
1854 DECLARE_CONCRETE_INSTRUCTION(ThisFunction, "this-function")
1855 DECLARE_HYDROGEN_ACCESSOR(ThisFunction)
1859 class LContext FINAL : public LTemplateInstruction<1, 0, 0> {
1861 DECLARE_CONCRETE_INSTRUCTION(Context, "context")
1862 DECLARE_HYDROGEN_ACCESSOR(Context)
1866 class LDeclareGlobals FINAL : public LTemplateInstruction<0, 1, 0> {
1868 explicit LDeclareGlobals(LOperand* context) {
1869 inputs_[0] = context;
1872 LOperand* context() { return inputs_[0]; }
1874 DECLARE_CONCRETE_INSTRUCTION(DeclareGlobals, "declare-globals")
1875 DECLARE_HYDROGEN_ACCESSOR(DeclareGlobals)
1879 class LCallJSFunction FINAL : public LTemplateInstruction<1, 1, 0> {
1881 explicit LCallJSFunction(LOperand* function) {
1882 inputs_[0] = function;
1885 LOperand* function() { return inputs_[0]; }
1887 DECLARE_CONCRETE_INSTRUCTION(CallJSFunction, "call-js-function")
1888 DECLARE_HYDROGEN_ACCESSOR(CallJSFunction)
1890 virtual void PrintDataTo(StringStream* stream) OVERRIDE;
1892 int arity() const { return hydrogen()->argument_count() - 1; }
1896 class LCallWithDescriptor FINAL : public LTemplateResultInstruction<1> {
1898 LCallWithDescriptor(CallInterfaceDescriptor descriptor,
1899 const ZoneList<LOperand*>& operands, Zone* zone)
1900 : descriptor_(descriptor),
1901 inputs_(descriptor.GetRegisterParameterCount() + 1, zone) {
1902 DCHECK(descriptor.GetRegisterParameterCount() + 1 == operands.length());
1903 inputs_.AddAll(operands, zone);
1906 LOperand* target() const { return inputs_[0]; }
1908 const CallInterfaceDescriptor descriptor() { return descriptor_; }
1911 DECLARE_CONCRETE_INSTRUCTION(CallWithDescriptor, "call-with-descriptor")
1912 DECLARE_HYDROGEN_ACCESSOR(CallWithDescriptor)
1914 virtual void PrintDataTo(StringStream* stream) OVERRIDE;
1916 int arity() const { return hydrogen()->argument_count() - 1; }
1918 CallInterfaceDescriptor descriptor_;
1919 ZoneList<LOperand*> inputs_;
1921 // Iterator support.
1922 virtual int InputCount() FINAL OVERRIDE { return inputs_.length(); }
1923 virtual LOperand* InputAt(int i) FINAL OVERRIDE { return inputs_[i]; }
1925 virtual int TempCount() FINAL OVERRIDE { return 0; }
1926 virtual LOperand* TempAt(int i) FINAL OVERRIDE { return NULL; }
1930 class LInvokeFunction FINAL : public LTemplateInstruction<1, 2, 0> {
1932 LInvokeFunction(LOperand* context, LOperand* function) {
1933 inputs_[0] = context;
1934 inputs_[1] = function;
1937 LOperand* context() { return inputs_[0]; }
1938 LOperand* function() { return inputs_[1]; }
1940 DECLARE_CONCRETE_INSTRUCTION(InvokeFunction, "invoke-function")
1941 DECLARE_HYDROGEN_ACCESSOR(InvokeFunction)
1943 virtual void PrintDataTo(StringStream* stream) OVERRIDE;
1945 int arity() const { return hydrogen()->argument_count() - 1; }
1949 class LCallFunction FINAL : public LTemplateInstruction<1, 2, 0> {
1951 LCallFunction(LOperand* context, LOperand* function) {
1952 inputs_[0] = context;
1953 inputs_[1] = function;
1956 LOperand* context() { return inputs_[0]; }
1957 LOperand* function() { return inputs_[1]; }
1959 DECLARE_CONCRETE_INSTRUCTION(CallFunction, "call-function")
1960 DECLARE_HYDROGEN_ACCESSOR(CallFunction)
1962 int arity() const { return hydrogen()->argument_count() - 1; }
1966 class LCallNew FINAL : public LTemplateInstruction<1, 2, 0> {
1968 LCallNew(LOperand* context, LOperand* constructor) {
1969 inputs_[0] = context;
1970 inputs_[1] = constructor;
1973 LOperand* context() { return inputs_[0]; }
1974 LOperand* constructor() { return inputs_[1]; }
1976 DECLARE_CONCRETE_INSTRUCTION(CallNew, "call-new")
1977 DECLARE_HYDROGEN_ACCESSOR(CallNew)
1979 virtual void PrintDataTo(StringStream* stream) OVERRIDE;
1981 int arity() const { return hydrogen()->argument_count() - 1; }
1985 class LCallNewArray FINAL : public LTemplateInstruction<1, 2, 0> {
1987 LCallNewArray(LOperand* context, LOperand* constructor) {
1988 inputs_[0] = context;
1989 inputs_[1] = constructor;
1992 LOperand* context() { return inputs_[0]; }
1993 LOperand* constructor() { return inputs_[1]; }
1995 DECLARE_CONCRETE_INSTRUCTION(CallNewArray, "call-new-array")
1996 DECLARE_HYDROGEN_ACCESSOR(CallNewArray)
1998 virtual void PrintDataTo(StringStream* stream) OVERRIDE;
2000 int arity() const { return hydrogen()->argument_count() - 1; }
2004 class LCallRuntime FINAL : public LTemplateInstruction<1, 1, 0> {
2006 explicit LCallRuntime(LOperand* context) {
2007 inputs_[0] = context;
2010 LOperand* context() { return inputs_[0]; }
2012 DECLARE_CONCRETE_INSTRUCTION(CallRuntime, "call-runtime")
2013 DECLARE_HYDROGEN_ACCESSOR(CallRuntime)
2015 virtual bool ClobbersDoubleRegisters(Isolate* isolate) const OVERRIDE {
2016 return save_doubles() == kDontSaveFPRegs;
2019 const Runtime::Function* function() const { return hydrogen()->function(); }
2020 int arity() const { return hydrogen()->argument_count(); }
2021 SaveFPRegsMode save_doubles() const { return hydrogen()->save_doubles(); }
2025 class LInteger32ToDouble FINAL : public LTemplateInstruction<1, 1, 0> {
2027 explicit LInteger32ToDouble(LOperand* value) {
2031 LOperand* value() { return inputs_[0]; }
2033 DECLARE_CONCRETE_INSTRUCTION(Integer32ToDouble, "int32-to-double")
2037 class LUint32ToDouble FINAL : public LTemplateInstruction<1, 1, 0> {
2039 explicit LUint32ToDouble(LOperand* value) {
2043 LOperand* value() { return inputs_[0]; }
2045 DECLARE_CONCRETE_INSTRUCTION(Uint32ToDouble, "uint32-to-double")
2049 class LNumberTagI FINAL : public LTemplateInstruction<1, 1, 2> {
2051 LNumberTagI(LOperand* value, LOperand* temp1, LOperand* temp2) {
2057 LOperand* value() { return inputs_[0]; }
2058 LOperand* temp1() { return temps_[0]; }
2059 LOperand* temp2() { return temps_[1]; }
2061 DECLARE_CONCRETE_INSTRUCTION(NumberTagI, "number-tag-i")
2065 class LNumberTagU FINAL : public LTemplateInstruction<1, 1, 2> {
2067 LNumberTagU(LOperand* value, LOperand* temp1, LOperand* temp2) {
2073 LOperand* value() { return inputs_[0]; }
2074 LOperand* temp1() { return temps_[0]; }
2075 LOperand* temp2() { return temps_[1]; }
2077 DECLARE_CONCRETE_INSTRUCTION(NumberTagU, "number-tag-u")
2081 class LNumberTagD FINAL : public LTemplateInstruction<1, 1, 2> {
2083 LNumberTagD(LOperand* value, LOperand* temp, LOperand* temp2) {
2089 LOperand* value() { return inputs_[0]; }
2090 LOperand* temp() { return temps_[0]; }
2091 LOperand* temp2() { return temps_[1]; }
2093 DECLARE_CONCRETE_INSTRUCTION(NumberTagD, "number-tag-d")
2094 DECLARE_HYDROGEN_ACCESSOR(Change)
2098 class LDoubleToSmi FINAL : public LTemplateInstruction<1, 1, 0> {
2100 explicit LDoubleToSmi(LOperand* value) {
2104 LOperand* value() { return inputs_[0]; }
2106 DECLARE_CONCRETE_INSTRUCTION(DoubleToSmi, "double-to-smi")
2107 DECLARE_HYDROGEN_ACCESSOR(UnaryOperation)
2109 bool truncating() { return hydrogen()->CanTruncateToInt32(); }
2113 // Sometimes truncating conversion from a tagged value to an int32.
2114 class LDoubleToI FINAL : public LTemplateInstruction<1, 1, 0> {
2116 explicit LDoubleToI(LOperand* value) {
2120 LOperand* value() { return inputs_[0]; }
2122 DECLARE_CONCRETE_INSTRUCTION(DoubleToI, "double-to-i")
2123 DECLARE_HYDROGEN_ACCESSOR(UnaryOperation)
2125 bool truncating() { return hydrogen()->CanTruncateToInt32(); }
2129 // Truncating conversion from a tagged value to an int32.
2130 class LTaggedToI FINAL : public LTemplateInstruction<1, 1, 2> {
2132 LTaggedToI(LOperand* value,
2140 LOperand* value() { return inputs_[0]; }
2141 LOperand* temp() { return temps_[0]; }
2142 LOperand* temp2() { return temps_[1]; }
2144 DECLARE_CONCRETE_INSTRUCTION(TaggedToI, "tagged-to-i")
2145 DECLARE_HYDROGEN_ACCESSOR(Change)
2147 bool truncating() { return hydrogen()->CanTruncateToInt32(); }
2151 class LSmiTag FINAL : public LTemplateInstruction<1, 1, 0> {
2153 explicit LSmiTag(LOperand* value) {
2157 LOperand* value() { return inputs_[0]; }
2159 DECLARE_CONCRETE_INSTRUCTION(SmiTag, "smi-tag")
2160 DECLARE_HYDROGEN_ACCESSOR(Change)
2164 class LNumberUntagD FINAL : public LTemplateInstruction<1, 1, 0> {
2166 explicit LNumberUntagD(LOperand* value) {
2170 LOperand* value() { return inputs_[0]; }
2172 DECLARE_CONCRETE_INSTRUCTION(NumberUntagD, "double-untag")
2173 DECLARE_HYDROGEN_ACCESSOR(Change)
2177 class LSmiUntag FINAL : public LTemplateInstruction<1, 1, 0> {
2179 LSmiUntag(LOperand* value, bool needs_check)
2180 : needs_check_(needs_check) {
2184 LOperand* value() { return inputs_[0]; }
2185 bool needs_check() const { return needs_check_; }
2187 DECLARE_CONCRETE_INSTRUCTION(SmiUntag, "smi-untag")
2194 class LStoreNamedField FINAL : public LTemplateInstruction<0, 2, 1> {
2196 LStoreNamedField(LOperand* object, LOperand* value, LOperand* temp) {
2197 inputs_[0] = object;
2202 LOperand* object() { return inputs_[0]; }
2203 LOperand* value() { return inputs_[1]; }
2204 LOperand* temp() { return temps_[0]; }
2206 DECLARE_CONCRETE_INSTRUCTION(StoreNamedField, "store-named-field")
2207 DECLARE_HYDROGEN_ACCESSOR(StoreNamedField)
2209 virtual void PrintDataTo(StringStream* stream) OVERRIDE;
2211 Representation representation() const {
2212 return hydrogen()->field_representation();
2217 class LStoreNamedGeneric FINAL : public LTemplateInstruction<0, 3, 0> {
2219 LStoreNamedGeneric(LOperand* context, LOperand* object, LOperand* value) {
2220 inputs_[0] = context;
2221 inputs_[1] = object;
2225 LOperand* context() { return inputs_[0]; }
2226 LOperand* object() { return inputs_[1]; }
2227 LOperand* value() { return inputs_[2]; }
2229 DECLARE_CONCRETE_INSTRUCTION(StoreNamedGeneric, "store-named-generic")
2230 DECLARE_HYDROGEN_ACCESSOR(StoreNamedGeneric)
2232 virtual void PrintDataTo(StringStream* stream) OVERRIDE;
2234 Handle<Object> name() const { return hydrogen()->name(); }
2235 StrictMode strict_mode() { return hydrogen()->strict_mode(); }
2239 class LStoreKeyed FINAL : public LTemplateInstruction<0, 3, 0> {
2241 LStoreKeyed(LOperand* object, LOperand* key, LOperand* value) {
2242 inputs_[0] = object;
2247 bool is_external() const { return hydrogen()->is_external(); }
2248 bool is_fixed_typed_array() const {
2249 return hydrogen()->is_fixed_typed_array();
2251 bool is_typed_elements() const {
2252 return is_external() || is_fixed_typed_array();
2254 LOperand* elements() { return inputs_[0]; }
2255 LOperand* key() { return inputs_[1]; }
2256 LOperand* value() { return inputs_[2]; }
2257 ElementsKind elements_kind() const {
2258 return hydrogen()->elements_kind();
2261 DECLARE_CONCRETE_INSTRUCTION(StoreKeyed, "store-keyed")
2262 DECLARE_HYDROGEN_ACCESSOR(StoreKeyed)
2264 virtual void PrintDataTo(StringStream* stream) OVERRIDE;
2265 bool NeedsCanonicalization() {
2266 if (hydrogen()->value()->IsAdd() || hydrogen()->value()->IsSub() ||
2267 hydrogen()->value()->IsMul() || hydrogen()->value()->IsDiv()) {
2270 return hydrogen()->NeedsCanonicalization();
2272 uint32_t base_offset() const { return hydrogen()->base_offset(); }
2276 class LStoreKeyedGeneric FINAL : public LTemplateInstruction<0, 4, 0> {
2278 LStoreKeyedGeneric(LOperand* context,
2282 inputs_[0] = context;
2288 LOperand* context() { return inputs_[0]; }
2289 LOperand* object() { return inputs_[1]; }
2290 LOperand* key() { return inputs_[2]; }
2291 LOperand* value() { return inputs_[3]; }
2293 DECLARE_CONCRETE_INSTRUCTION(StoreKeyedGeneric, "store-keyed-generic")
2294 DECLARE_HYDROGEN_ACCESSOR(StoreKeyedGeneric)
2296 virtual void PrintDataTo(StringStream* stream) OVERRIDE;
2298 StrictMode strict_mode() { return hydrogen()->strict_mode(); }
2302 class LTransitionElementsKind FINAL : public LTemplateInstruction<0, 2, 1> {
2304 LTransitionElementsKind(LOperand* object,
2306 LOperand* new_map_temp) {
2307 inputs_[0] = object;
2308 inputs_[1] = context;
2309 temps_[0] = new_map_temp;
2312 LOperand* context() { return inputs_[1]; }
2313 LOperand* object() { return inputs_[0]; }
2314 LOperand* new_map_temp() { return temps_[0]; }
2316 DECLARE_CONCRETE_INSTRUCTION(TransitionElementsKind,
2317 "transition-elements-kind")
2318 DECLARE_HYDROGEN_ACCESSOR(TransitionElementsKind)
2320 virtual void PrintDataTo(StringStream* stream) OVERRIDE;
2322 Handle<Map> original_map() { return hydrogen()->original_map().handle(); }
2323 Handle<Map> transitioned_map() {
2324 return hydrogen()->transitioned_map().handle();
2326 ElementsKind from_kind() { return hydrogen()->from_kind(); }
2327 ElementsKind to_kind() { return hydrogen()->to_kind(); }
2331 class LTrapAllocationMemento FINAL : public LTemplateInstruction<0, 1, 1> {
2333 LTrapAllocationMemento(LOperand* object,
2335 inputs_[0] = object;
2339 LOperand* object() { return inputs_[0]; }
2340 LOperand* temp() { return temps_[0]; }
2342 DECLARE_CONCRETE_INSTRUCTION(TrapAllocationMemento,
2343 "trap-allocation-memento")
2347 class LStringAdd FINAL : public LTemplateInstruction<1, 3, 0> {
2349 LStringAdd(LOperand* context, LOperand* left, LOperand* right) {
2350 inputs_[0] = context;
2355 LOperand* context() { return inputs_[0]; }
2356 LOperand* left() { return inputs_[1]; }
2357 LOperand* right() { return inputs_[2]; }
2359 DECLARE_CONCRETE_INSTRUCTION(StringAdd, "string-add")
2360 DECLARE_HYDROGEN_ACCESSOR(StringAdd)
2365 class LStringCharCodeAt FINAL : public LTemplateInstruction<1, 3, 0> {
2367 LStringCharCodeAt(LOperand* context, LOperand* string, LOperand* index) {
2368 inputs_[0] = context;
2369 inputs_[1] = string;
2373 LOperand* context() { return inputs_[0]; }
2374 LOperand* string() { return inputs_[1]; }
2375 LOperand* index() { return inputs_[2]; }
2377 DECLARE_CONCRETE_INSTRUCTION(StringCharCodeAt, "string-char-code-at")
2378 DECLARE_HYDROGEN_ACCESSOR(StringCharCodeAt)
2382 class LStringCharFromCode FINAL : public LTemplateInstruction<1, 2, 0> {
2384 explicit LStringCharFromCode(LOperand* context, LOperand* char_code) {
2385 inputs_[0] = context;
2386 inputs_[1] = char_code;
2389 LOperand* context() { return inputs_[0]; }
2390 LOperand* char_code() { return inputs_[1]; }
2392 DECLARE_CONCRETE_INSTRUCTION(StringCharFromCode, "string-char-from-code")
2393 DECLARE_HYDROGEN_ACCESSOR(StringCharFromCode)
2397 class LCheckValue FINAL : public LTemplateInstruction<0, 1, 0> {
2399 explicit LCheckValue(LOperand* value) {
2403 LOperand* value() { return inputs_[0]; }
2405 DECLARE_CONCRETE_INSTRUCTION(CheckValue, "check-value")
2406 DECLARE_HYDROGEN_ACCESSOR(CheckValue)
2410 class LCheckInstanceType FINAL : public LTemplateInstruction<0, 1, 0> {
2412 explicit LCheckInstanceType(LOperand* value) {
2416 LOperand* value() { return inputs_[0]; }
2418 DECLARE_CONCRETE_INSTRUCTION(CheckInstanceType, "check-instance-type")
2419 DECLARE_HYDROGEN_ACCESSOR(CheckInstanceType)
2423 class LCheckMaps FINAL : public LTemplateInstruction<0, 1, 0> {
2425 explicit LCheckMaps(LOperand* value = NULL) {
2429 LOperand* value() { return inputs_[0]; }
2431 DECLARE_CONCRETE_INSTRUCTION(CheckMaps, "check-maps")
2432 DECLARE_HYDROGEN_ACCESSOR(CheckMaps)
2436 class LCheckSmi FINAL : public LTemplateInstruction<1, 1, 0> {
2438 explicit LCheckSmi(LOperand* value) {
2442 LOperand* value() { return inputs_[0]; }
2444 DECLARE_CONCRETE_INSTRUCTION(CheckSmi, "check-smi")
2448 class LCheckNonSmi FINAL : public LTemplateInstruction<0, 1, 0> {
2450 explicit LCheckNonSmi(LOperand* value) {
2454 LOperand* value() { return inputs_[0]; }
2456 DECLARE_CONCRETE_INSTRUCTION(CheckNonSmi, "check-non-smi")
2457 DECLARE_HYDROGEN_ACCESSOR(CheckHeapObject)
2461 class LClampDToUint8 FINAL : public LTemplateInstruction<1, 1, 0> {
2463 explicit LClampDToUint8(LOperand* unclamped) {
2464 inputs_[0] = unclamped;
2467 LOperand* unclamped() { return inputs_[0]; }
2469 DECLARE_CONCRETE_INSTRUCTION(ClampDToUint8, "clamp-d-to-uint8")
2473 class LClampIToUint8 FINAL : public LTemplateInstruction<1, 1, 0> {
2475 explicit LClampIToUint8(LOperand* unclamped) {
2476 inputs_[0] = unclamped;
2479 LOperand* unclamped() { return inputs_[0]; }
2481 DECLARE_CONCRETE_INSTRUCTION(ClampIToUint8, "clamp-i-to-uint8")
2485 class LClampTToUint8 FINAL : public LTemplateInstruction<1, 1, 1> {
2487 LClampTToUint8(LOperand* unclamped, LOperand* temp) {
2488 inputs_[0] = unclamped;
2492 LOperand* unclamped() { return inputs_[0]; }
2493 LOperand* temp() { return temps_[0]; }
2495 DECLARE_CONCRETE_INSTRUCTION(ClampTToUint8, "clamp-t-to-uint8")
2499 class LDoubleBits FINAL : public LTemplateInstruction<1, 1, 0> {
2501 explicit LDoubleBits(LOperand* value) {
2505 LOperand* value() { return inputs_[0]; }
2507 DECLARE_CONCRETE_INSTRUCTION(DoubleBits, "double-bits")
2508 DECLARE_HYDROGEN_ACCESSOR(DoubleBits)
2512 class LConstructDouble FINAL : public LTemplateInstruction<1, 2, 0> {
2514 LConstructDouble(LOperand* hi, LOperand* lo) {
2519 LOperand* hi() { return inputs_[0]; }
2520 LOperand* lo() { return inputs_[1]; }
2522 DECLARE_CONCRETE_INSTRUCTION(ConstructDouble, "construct-double")
2526 class LAllocate FINAL : public LTemplateInstruction<1, 2, 2> {
2528 LAllocate(LOperand* context,
2532 inputs_[0] = context;
2538 LOperand* context() { return inputs_[0]; }
2539 LOperand* size() { return inputs_[1]; }
2540 LOperand* temp1() { return temps_[0]; }
2541 LOperand* temp2() { return temps_[1]; }
2543 DECLARE_CONCRETE_INSTRUCTION(Allocate, "allocate")
2544 DECLARE_HYDROGEN_ACCESSOR(Allocate)
2548 class LRegExpLiteral FINAL : public LTemplateInstruction<1, 1, 0> {
2550 explicit LRegExpLiteral(LOperand* context) {
2551 inputs_[0] = context;
2554 LOperand* context() { return inputs_[0]; }
2556 DECLARE_CONCRETE_INSTRUCTION(RegExpLiteral, "regexp-literal")
2557 DECLARE_HYDROGEN_ACCESSOR(RegExpLiteral)
2561 class LFunctionLiteral FINAL : public LTemplateInstruction<1, 1, 0> {
2563 explicit LFunctionLiteral(LOperand* context) {
2564 inputs_[0] = context;
2567 LOperand* context() { return inputs_[0]; }
2569 DECLARE_CONCRETE_INSTRUCTION(FunctionLiteral, "function-literal")
2570 DECLARE_HYDROGEN_ACCESSOR(FunctionLiteral)
2574 class LToFastProperties FINAL : public LTemplateInstruction<1, 1, 0> {
2576 explicit LToFastProperties(LOperand* value) {
2580 LOperand* value() { return inputs_[0]; }
2582 DECLARE_CONCRETE_INSTRUCTION(ToFastProperties, "to-fast-properties")
2583 DECLARE_HYDROGEN_ACCESSOR(ToFastProperties)
2587 class LTypeof FINAL : public LTemplateInstruction<1, 2, 0> {
2589 LTypeof(LOperand* context, LOperand* value) {
2590 inputs_[0] = context;
2594 LOperand* context() { return inputs_[0]; }
2595 LOperand* value() { return inputs_[1]; }
2597 DECLARE_CONCRETE_INSTRUCTION(Typeof, "typeof")
2601 class LTypeofIsAndBranch FINAL : public LControlInstruction<1, 0> {
2603 explicit LTypeofIsAndBranch(LOperand* value) {
2607 LOperand* value() { return inputs_[0]; }
2609 DECLARE_CONCRETE_INSTRUCTION(TypeofIsAndBranch, "typeof-is-and-branch")
2610 DECLARE_HYDROGEN_ACCESSOR(TypeofIsAndBranch)
2612 Handle<String> type_literal() { return hydrogen()->type_literal(); }
2614 virtual void PrintDataTo(StringStream* stream) OVERRIDE;
2618 class LIsConstructCallAndBranch FINAL : public LControlInstruction<0, 1> {
2620 explicit LIsConstructCallAndBranch(LOperand* temp) {
2624 LOperand* temp() { return temps_[0]; }
2626 DECLARE_CONCRETE_INSTRUCTION(IsConstructCallAndBranch,
2627 "is-construct-call-and-branch")
2631 class LOsrEntry FINAL : public LTemplateInstruction<0, 0, 0> {
2635 virtual bool HasInterestingComment(LCodeGen* gen) const OVERRIDE {
2638 DECLARE_CONCRETE_INSTRUCTION(OsrEntry, "osr-entry")
2642 class LStackCheck FINAL : public LTemplateInstruction<0, 1, 0> {
2644 explicit LStackCheck(LOperand* context) {
2645 inputs_[0] = context;
2648 LOperand* context() { return inputs_[0]; }
2650 DECLARE_CONCRETE_INSTRUCTION(StackCheck, "stack-check")
2651 DECLARE_HYDROGEN_ACCESSOR(StackCheck)
2653 Label* done_label() { return &done_label_; }
2660 class LForInPrepareMap FINAL : public LTemplateInstruction<1, 2, 0> {
2662 LForInPrepareMap(LOperand* context, LOperand* object) {
2663 inputs_[0] = context;
2664 inputs_[1] = object;
2667 LOperand* context() { return inputs_[0]; }
2668 LOperand* object() { return inputs_[1]; }
2670 DECLARE_CONCRETE_INSTRUCTION(ForInPrepareMap, "for-in-prepare-map")
2674 class LForInCacheArray FINAL : public LTemplateInstruction<1, 1, 0> {
2676 explicit LForInCacheArray(LOperand* map) {
2680 LOperand* map() { return inputs_[0]; }
2682 DECLARE_CONCRETE_INSTRUCTION(ForInCacheArray, "for-in-cache-array")
2685 return HForInCacheArray::cast(this->hydrogen_value())->idx();
2690 class LCheckMapValue FINAL : public LTemplateInstruction<0, 2, 0> {
2692 LCheckMapValue(LOperand* value, LOperand* map) {
2697 LOperand* value() { return inputs_[0]; }
2698 LOperand* map() { return inputs_[1]; }
2700 DECLARE_CONCRETE_INSTRUCTION(CheckMapValue, "check-map-value")
2704 class LLoadFieldByIndex FINAL : public LTemplateInstruction<1, 2, 0> {
2706 LLoadFieldByIndex(LOperand* object, LOperand* index) {
2707 inputs_[0] = object;
2711 LOperand* object() { return inputs_[0]; }
2712 LOperand* index() { return inputs_[1]; }
2714 DECLARE_CONCRETE_INSTRUCTION(LoadFieldByIndex, "load-field-by-index")
2718 class LStoreFrameContext: public LTemplateInstruction<0, 1, 0> {
2720 explicit LStoreFrameContext(LOperand* context) {
2721 inputs_[0] = context;
2724 LOperand* context() { return inputs_[0]; }
2726 DECLARE_CONCRETE_INSTRUCTION(StoreFrameContext, "store-frame-context")
2730 class LAllocateBlockContext: public LTemplateInstruction<1, 2, 0> {
2732 LAllocateBlockContext(LOperand* context, LOperand* function) {
2733 inputs_[0] = context;
2734 inputs_[1] = function;
2737 LOperand* context() { return inputs_[0]; }
2738 LOperand* function() { return inputs_[1]; }
2740 Handle<ScopeInfo> scope_info() { return hydrogen()->scope_info(); }
2742 DECLARE_CONCRETE_INSTRUCTION(AllocateBlockContext, "allocate-block-context")
2743 DECLARE_HYDROGEN_ACCESSOR(AllocateBlockContext)
2747 class LChunkBuilder;
2748 class LPlatformChunk FINAL : public LChunk {
2750 LPlatformChunk(CompilationInfo* info, HGraph* graph)
2751 : LChunk(info, graph) { }
2753 int GetNextSpillIndex(RegisterKind kind);
2754 LOperand* GetNextSpillSlot(RegisterKind kind);
2758 class LChunkBuilder FINAL : public LChunkBuilderBase {
2760 LChunkBuilder(CompilationInfo* info, HGraph* graph, LAllocator* allocator)
2761 : LChunkBuilderBase(info, graph),
2762 current_instruction_(NULL),
2763 current_block_(NULL),
2765 allocator_(allocator) {}
2767 // Build the sequence for the graph.
2768 LPlatformChunk* Build();
2770 // Declare methods that deal with the individual node types.
2771 #define DECLARE_DO(type) LInstruction* Do##type(H##type* node);
2772 HYDROGEN_CONCRETE_INSTRUCTION_LIST(DECLARE_DO)
2775 LInstruction* DoMultiplyAdd(HMul* mul, HValue* addend);
2776 LInstruction* DoMultiplySub(HValue* minuend, HMul* mul);
2777 LInstruction* DoRSub(HSub* instr);
2779 static bool HasMagicNumberForDivisor(int32_t divisor);
2781 LInstruction* DoMathFloor(HUnaryMathOperation* instr);
2782 LInstruction* DoMathRound(HUnaryMathOperation* instr);
2783 LInstruction* DoMathFround(HUnaryMathOperation* instr);
2784 LInstruction* DoMathAbs(HUnaryMathOperation* instr);
2785 LInstruction* DoMathLog(HUnaryMathOperation* instr);
2786 LInstruction* DoMathExp(HUnaryMathOperation* instr);
2787 LInstruction* DoMathSqrt(HUnaryMathOperation* instr);
2788 LInstruction* DoMathPowHalf(HUnaryMathOperation* instr);
2789 LInstruction* DoMathClz32(HUnaryMathOperation* instr);
2790 LInstruction* DoDivByPowerOf2I(HDiv* instr);
2791 LInstruction* DoDivByConstI(HDiv* instr);
2792 LInstruction* DoDivI(HDiv* instr);
2793 LInstruction* DoModByPowerOf2I(HMod* instr);
2794 LInstruction* DoModByConstI(HMod* instr);
2795 LInstruction* DoModI(HMod* instr);
2796 LInstruction* DoFlooringDivByPowerOf2I(HMathFloorOfDiv* instr);
2797 LInstruction* DoFlooringDivByConstI(HMathFloorOfDiv* instr);
2798 LInstruction* DoFlooringDivI(HMathFloorOfDiv* instr);
2801 // Methods for getting operands for Use / Define / Temp.
2802 LUnallocated* ToUnallocated(Register reg);
2803 LUnallocated* ToUnallocated(DoubleRegister reg);
2805 // Methods for setting up define-use relationships.
2806 MUST_USE_RESULT LOperand* Use(HValue* value, LUnallocated* operand);
2807 MUST_USE_RESULT LOperand* UseFixed(HValue* value, Register fixed_register);
2808 MUST_USE_RESULT LOperand* UseFixedDouble(HValue* value,
2809 DoubleRegister fixed_register);
2811 // A value that is guaranteed to be allocated to a register.
2812 // Operand created by UseRegister is guaranteed to be live until the end of
2813 // instruction. This means that register allocator will not reuse it's
2814 // register for any other operand inside instruction.
2815 // Operand created by UseRegisterAtStart is guaranteed to be live only at
2816 // instruction start. Register allocator is free to assign the same register
2817 // to some other operand used inside instruction (i.e. temporary or
2819 MUST_USE_RESULT LOperand* UseRegister(HValue* value);
2820 MUST_USE_RESULT LOperand* UseRegisterAtStart(HValue* value);
2822 // An input operand in a register that may be trashed.
2823 MUST_USE_RESULT LOperand* UseTempRegister(HValue* value);
2825 // An input operand in a register or stack slot.
2826 MUST_USE_RESULT LOperand* Use(HValue* value);
2827 MUST_USE_RESULT LOperand* UseAtStart(HValue* value);
2829 // An input operand in a register, stack slot or a constant operand.
2830 MUST_USE_RESULT LOperand* UseOrConstant(HValue* value);
2831 MUST_USE_RESULT LOperand* UseOrConstantAtStart(HValue* value);
2833 // An input operand in a register or a constant operand.
2834 MUST_USE_RESULT LOperand* UseRegisterOrConstant(HValue* value);
2835 MUST_USE_RESULT LOperand* UseRegisterOrConstantAtStart(HValue* value);
2837 // An input operand in a constant operand.
2838 MUST_USE_RESULT LOperand* UseConstant(HValue* value);
2840 // An input operand in register, stack slot or a constant operand.
2841 // Will not be moved to a register even if one is freely available.
2842 virtual MUST_USE_RESULT LOperand* UseAny(HValue* value) OVERRIDE;
2844 // Temporary operand that must be in a register.
2845 MUST_USE_RESULT LUnallocated* TempRegister();
2846 MUST_USE_RESULT LUnallocated* TempDoubleRegister();
2847 MUST_USE_RESULT LOperand* FixedTemp(Register reg);
2848 MUST_USE_RESULT LOperand* FixedTemp(DoubleRegister reg);
2850 // Methods for setting up define-use relationships.
2851 // Return the same instruction that they are passed.
2852 LInstruction* Define(LTemplateResultInstruction<1>* instr,
2853 LUnallocated* result);
2854 LInstruction* DefineAsRegister(LTemplateResultInstruction<1>* instr);
2855 LInstruction* DefineAsSpilled(LTemplateResultInstruction<1>* instr,
2857 LInstruction* DefineSameAsFirst(LTemplateResultInstruction<1>* instr);
2858 LInstruction* DefineFixed(LTemplateResultInstruction<1>* instr,
2860 LInstruction* DefineFixedDouble(LTemplateResultInstruction<1>* instr,
2861 DoubleRegister reg);
2862 LInstruction* AssignEnvironment(LInstruction* instr);
2863 LInstruction* AssignPointerMap(LInstruction* instr);
2865 enum CanDeoptimize { CAN_DEOPTIMIZE_EAGERLY, CANNOT_DEOPTIMIZE_EAGERLY };
2867 // By default we assume that instruction sequences generated for calls
2868 // cannot deoptimize eagerly and we do not attach environment to this
2870 LInstruction* MarkAsCall(
2871 LInstruction* instr,
2872 HInstruction* hinstr,
2873 CanDeoptimize can_deoptimize = CANNOT_DEOPTIMIZE_EAGERLY);
2875 void VisitInstruction(HInstruction* current);
2876 void AddInstruction(LInstruction* instr, HInstruction* current);
2878 void DoBasicBlock(HBasicBlock* block, HBasicBlock* next_block);
2879 LInstruction* DoShift(Token::Value op, HBitwiseBinaryOperation* instr);
2880 LInstruction* DoArithmeticD(Token::Value op,
2881 HArithmeticBinaryOperation* instr);
2882 LInstruction* DoArithmeticT(Token::Value op,
2883 HBinaryOperation* instr);
2885 HInstruction* current_instruction_;
2886 HBasicBlock* current_block_;
2887 HBasicBlock* next_block_;
2888 LAllocator* allocator_;
2890 DISALLOW_COPY_AND_ASSIGN(LChunkBuilder);
2893 #undef DECLARE_HYDROGEN_ACCESSOR
2894 #undef DECLARE_CONCRETE_INSTRUCTION
2896 } } // namespace v8::internal
2898 #endif // V8_ARM_LITHIUM_ARM_H_