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) \
158 V(ToFastProperties) \
159 V(TransitionElementsKind) \
160 V(TrapAllocationMemento) \
162 V(TypeofIsAndBranch) \
168 #define DECLARE_CONCRETE_INSTRUCTION(type, mnemonic) \
169 virtual Opcode opcode() const V8_FINAL V8_OVERRIDE { \
170 return LInstruction::k##type; \
172 virtual void CompileToNative(LCodeGen* generator) V8_FINAL V8_OVERRIDE; \
173 virtual const char* Mnemonic() const V8_FINAL V8_OVERRIDE { \
176 static L##type* cast(LInstruction* instr) { \
177 DCHECK(instr->Is##type()); \
178 return reinterpret_cast<L##type*>(instr); \
182 #define DECLARE_HYDROGEN_ACCESSOR(type) \
183 H##type* hydrogen() const { \
184 return H##type::cast(hydrogen_value()); \
188 class LInstruction : public ZoneObject {
191 : environment_(NULL),
192 hydrogen_value_(NULL),
193 bit_field_(IsCallBits::encode(false)) {
196 virtual ~LInstruction() {}
198 virtual void CompileToNative(LCodeGen* generator) = 0;
199 virtual const char* Mnemonic() const = 0;
200 virtual void PrintTo(StringStream* stream);
201 virtual void PrintDataTo(StringStream* stream);
202 virtual void PrintOutputOperandTo(StringStream* stream);
205 // Declare a unique enum value for each instruction.
206 #define DECLARE_OPCODE(type) k##type,
207 LITHIUM_CONCRETE_INSTRUCTION_LIST(DECLARE_OPCODE)
208 kNumberOfInstructions
209 #undef DECLARE_OPCODE
212 virtual Opcode opcode() const = 0;
214 // Declare non-virtual type testers for all leaf IR classes.
215 #define DECLARE_PREDICATE(type) \
216 bool Is##type() const { return opcode() == k##type; }
217 LITHIUM_CONCRETE_INSTRUCTION_LIST(DECLARE_PREDICATE)
218 #undef DECLARE_PREDICATE
220 // Declare virtual predicates for instructions that don't have
222 virtual bool IsGap() const { return false; }
224 virtual bool IsControl() const { return false; }
226 // Try deleting this instruction if possible.
227 virtual bool TryDelete() { return false; }
229 void set_environment(LEnvironment* env) { environment_ = env; }
230 LEnvironment* environment() const { return environment_; }
231 bool HasEnvironment() const { return environment_ != NULL; }
233 void set_pointer_map(LPointerMap* p) { pointer_map_.set(p); }
234 LPointerMap* pointer_map() const { return pointer_map_.get(); }
235 bool HasPointerMap() const { return pointer_map_.is_set(); }
237 void set_hydrogen_value(HValue* value) { hydrogen_value_ = value; }
238 HValue* hydrogen_value() const { return hydrogen_value_; }
240 virtual void SetDeferredLazyDeoptimizationEnvironment(LEnvironment* env) { }
242 void MarkAsCall() { bit_field_ = IsCallBits::update(bit_field_, true); }
243 bool IsCall() const { return IsCallBits::decode(bit_field_); }
245 // Interface to the register allocator and iterators.
246 bool ClobbersTemps() const { return IsCall(); }
247 bool ClobbersRegisters() const { return IsCall(); }
248 virtual bool ClobbersDoubleRegisters(Isolate* isolate) const {
252 // Interface to the register allocator and iterators.
253 bool IsMarkedAsCall() const { return IsCall(); }
255 virtual bool HasResult() const = 0;
256 virtual LOperand* result() const = 0;
258 LOperand* FirstInput() { return InputAt(0); }
259 LOperand* Output() { return HasResult() ? result() : NULL; }
261 virtual bool HasInterestingComment(LCodeGen* gen) const { return true; }
267 virtual int InputCount() = 0;
268 virtual LOperand* InputAt(int i) = 0;
272 friend class InputIterator;
274 friend class TempIterator;
275 virtual int TempCount() = 0;
276 virtual LOperand* TempAt(int i) = 0;
278 class IsCallBits: public BitField<bool, 0, 1> {};
280 LEnvironment* environment_;
281 SetOncePointer<LPointerMap> pointer_map_;
282 HValue* hydrogen_value_;
287 // R = number of result operands (0 or 1).
289 class LTemplateResultInstruction : public LInstruction {
291 // Allow 0 or 1 output operands.
292 STATIC_ASSERT(R == 0 || R == 1);
293 virtual bool HasResult() const V8_FINAL V8_OVERRIDE {
294 return R != 0 && result() != NULL;
296 void set_result(LOperand* operand) { results_[0] = operand; }
297 LOperand* result() const { return results_[0]; }
300 EmbeddedContainer<LOperand*, R> results_;
304 // R = number of result operands (0 or 1).
305 // I = number of input operands.
306 // T = number of temporary operands.
307 template<int R, int I, int T>
308 class LTemplateInstruction : public LTemplateResultInstruction<R> {
310 EmbeddedContainer<LOperand*, I> inputs_;
311 EmbeddedContainer<LOperand*, T> temps_;
315 virtual int InputCount() V8_FINAL V8_OVERRIDE { return I; }
316 virtual LOperand* InputAt(int i) V8_FINAL V8_OVERRIDE { return inputs_[i]; }
318 virtual int TempCount() V8_FINAL V8_OVERRIDE { return T; }
319 virtual LOperand* TempAt(int i) V8_FINAL V8_OVERRIDE { return temps_[i]; }
323 class LGap : public LTemplateInstruction<0, 0, 0> {
325 explicit LGap(HBasicBlock* block)
327 parallel_moves_[BEFORE] = NULL;
328 parallel_moves_[START] = NULL;
329 parallel_moves_[END] = NULL;
330 parallel_moves_[AFTER] = NULL;
333 // Can't use the DECLARE-macro here because of sub-classes.
334 virtual bool IsGap() const V8_OVERRIDE { return true; }
335 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
336 static LGap* cast(LInstruction* instr) {
337 DCHECK(instr->IsGap());
338 return reinterpret_cast<LGap*>(instr);
341 bool IsRedundant() const;
343 HBasicBlock* block() const { return block_; }
350 FIRST_INNER_POSITION = BEFORE,
351 LAST_INNER_POSITION = AFTER
354 LParallelMove* GetOrCreateParallelMove(InnerPosition pos, Zone* zone) {
355 if (parallel_moves_[pos] == NULL) {
356 parallel_moves_[pos] = new(zone) LParallelMove(zone);
358 return parallel_moves_[pos];
361 LParallelMove* GetParallelMove(InnerPosition pos) {
362 return parallel_moves_[pos];
366 LParallelMove* parallel_moves_[LAST_INNER_POSITION + 1];
371 class LInstructionGap V8_FINAL : public LGap {
373 explicit LInstructionGap(HBasicBlock* block) : LGap(block) { }
375 virtual bool HasInterestingComment(LCodeGen* gen) const V8_OVERRIDE {
376 return !IsRedundant();
379 DECLARE_CONCRETE_INSTRUCTION(InstructionGap, "gap")
383 class LGoto V8_FINAL : public LTemplateInstruction<0, 0, 0> {
385 explicit LGoto(HBasicBlock* block) : block_(block) { }
387 virtual bool HasInterestingComment(LCodeGen* gen) const V8_OVERRIDE;
388 DECLARE_CONCRETE_INSTRUCTION(Goto, "goto")
389 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
390 virtual bool IsControl() const V8_OVERRIDE { return true; }
392 int block_id() const { return block_->block_id(); }
399 class LLazyBailout V8_FINAL : public LTemplateInstruction<0, 0, 0> {
401 LLazyBailout() : gap_instructions_size_(0) { }
403 DECLARE_CONCRETE_INSTRUCTION(LazyBailout, "lazy-bailout")
405 void set_gap_instructions_size(int gap_instructions_size) {
406 gap_instructions_size_ = gap_instructions_size;
408 int gap_instructions_size() { return gap_instructions_size_; }
411 int gap_instructions_size_;
415 class LDummy V8_FINAL : public LTemplateInstruction<1, 0, 0> {
418 DECLARE_CONCRETE_INSTRUCTION(Dummy, "dummy")
422 class LDummyUse V8_FINAL : public LTemplateInstruction<1, 1, 0> {
424 explicit LDummyUse(LOperand* value) {
427 DECLARE_CONCRETE_INSTRUCTION(DummyUse, "dummy-use")
431 class LDeoptimize V8_FINAL : public LTemplateInstruction<0, 0, 0> {
433 virtual bool IsControl() const V8_OVERRIDE { return true; }
434 DECLARE_CONCRETE_INSTRUCTION(Deoptimize, "deoptimize")
435 DECLARE_HYDROGEN_ACCESSOR(Deoptimize)
439 class LLabel V8_FINAL : public LGap {
441 explicit LLabel(HBasicBlock* block)
442 : LGap(block), replacement_(NULL) { }
444 virtual bool HasInterestingComment(LCodeGen* gen) const V8_OVERRIDE {
447 DECLARE_CONCRETE_INSTRUCTION(Label, "label")
449 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
451 int block_id() const { return block()->block_id(); }
452 bool is_loop_header() const { return block()->IsLoopHeader(); }
453 bool is_osr_entry() const { return block()->is_osr_entry(); }
454 Label* label() { return &label_; }
455 LLabel* replacement() const { return replacement_; }
456 void set_replacement(LLabel* label) { replacement_ = label; }
457 bool HasReplacement() const { return replacement_ != NULL; }
461 LLabel* replacement_;
465 class LParameter V8_FINAL : public LTemplateInstruction<1, 0, 0> {
467 virtual bool HasInterestingComment(LCodeGen* gen) const { return false; }
468 DECLARE_CONCRETE_INSTRUCTION(Parameter, "parameter")
472 class LCallStub V8_FINAL : public LTemplateInstruction<1, 1, 0> {
474 explicit LCallStub(LOperand* context) {
475 inputs_[0] = context;
478 LOperand* context() { return inputs_[0]; }
480 DECLARE_CONCRETE_INSTRUCTION(CallStub, "call-stub")
481 DECLARE_HYDROGEN_ACCESSOR(CallStub)
485 class LUnknownOSRValue V8_FINAL : public LTemplateInstruction<1, 0, 0> {
487 virtual bool HasInterestingComment(LCodeGen* gen) const V8_OVERRIDE {
490 DECLARE_CONCRETE_INSTRUCTION(UnknownOSRValue, "unknown-osr-value")
494 template<int I, int T>
495 class LControlInstruction : public LTemplateInstruction<0, I, T> {
497 LControlInstruction() : false_label_(NULL), true_label_(NULL) { }
499 virtual bool IsControl() const V8_FINAL V8_OVERRIDE { return true; }
501 int SuccessorCount() { return hydrogen()->SuccessorCount(); }
502 HBasicBlock* SuccessorAt(int i) { return hydrogen()->SuccessorAt(i); }
504 int TrueDestination(LChunk* chunk) {
505 return chunk->LookupDestination(true_block_id());
507 int FalseDestination(LChunk* chunk) {
508 return chunk->LookupDestination(false_block_id());
511 Label* TrueLabel(LChunk* chunk) {
512 if (true_label_ == NULL) {
513 true_label_ = chunk->GetAssemblyLabel(TrueDestination(chunk));
517 Label* FalseLabel(LChunk* chunk) {
518 if (false_label_ == NULL) {
519 false_label_ = chunk->GetAssemblyLabel(FalseDestination(chunk));
525 int true_block_id() { return SuccessorAt(0)->block_id(); }
526 int false_block_id() { return SuccessorAt(1)->block_id(); }
529 HControlInstruction* hydrogen() {
530 return HControlInstruction::cast(this->hydrogen_value());
538 class LWrapReceiver V8_FINAL : public LTemplateInstruction<1, 2, 0> {
540 LWrapReceiver(LOperand* receiver, LOperand* function) {
541 inputs_[0] = receiver;
542 inputs_[1] = function;
545 DECLARE_CONCRETE_INSTRUCTION(WrapReceiver, "wrap-receiver")
546 DECLARE_HYDROGEN_ACCESSOR(WrapReceiver)
548 LOperand* receiver() { return inputs_[0]; }
549 LOperand* function() { return inputs_[1]; }
553 class LApplyArguments V8_FINAL : public LTemplateInstruction<1, 4, 0> {
555 LApplyArguments(LOperand* function,
558 LOperand* elements) {
559 inputs_[0] = function;
560 inputs_[1] = receiver;
562 inputs_[3] = elements;
565 DECLARE_CONCRETE_INSTRUCTION(ApplyArguments, "apply-arguments")
567 LOperand* function() { return inputs_[0]; }
568 LOperand* receiver() { return inputs_[1]; }
569 LOperand* length() { return inputs_[2]; }
570 LOperand* elements() { return inputs_[3]; }
574 class LAccessArgumentsAt V8_FINAL : public LTemplateInstruction<1, 3, 0> {
576 LAccessArgumentsAt(LOperand* arguments, LOperand* length, LOperand* index) {
577 inputs_[0] = arguments;
582 DECLARE_CONCRETE_INSTRUCTION(AccessArgumentsAt, "access-arguments-at")
584 LOperand* arguments() { return inputs_[0]; }
585 LOperand* length() { return inputs_[1]; }
586 LOperand* index() { return inputs_[2]; }
588 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
592 class LArgumentsLength V8_FINAL : public LTemplateInstruction<1, 1, 0> {
594 explicit LArgumentsLength(LOperand* elements) {
595 inputs_[0] = elements;
598 LOperand* elements() { return inputs_[0]; }
600 DECLARE_CONCRETE_INSTRUCTION(ArgumentsLength, "arguments-length")
604 class LArgumentsElements V8_FINAL : public LTemplateInstruction<1, 0, 0> {
606 DECLARE_CONCRETE_INSTRUCTION(ArgumentsElements, "arguments-elements")
607 DECLARE_HYDROGEN_ACCESSOR(ArgumentsElements)
611 class LModByPowerOf2I V8_FINAL : public LTemplateInstruction<1, 1, 0> {
613 LModByPowerOf2I(LOperand* dividend, int32_t divisor) {
614 inputs_[0] = dividend;
618 LOperand* dividend() { return inputs_[0]; }
619 int32_t divisor() const { return divisor_; }
621 DECLARE_CONCRETE_INSTRUCTION(ModByPowerOf2I, "mod-by-power-of-2-i")
622 DECLARE_HYDROGEN_ACCESSOR(Mod)
629 class LModByConstI V8_FINAL : public LTemplateInstruction<1, 1, 0> {
631 LModByConstI(LOperand* dividend, int32_t divisor) {
632 inputs_[0] = dividend;
636 LOperand* dividend() { return inputs_[0]; }
637 int32_t divisor() const { return divisor_; }
639 DECLARE_CONCRETE_INSTRUCTION(ModByConstI, "mod-by-const-i")
640 DECLARE_HYDROGEN_ACCESSOR(Mod)
647 class LModI V8_FINAL : public LTemplateInstruction<1, 2, 2> {
649 LModI(LOperand* left, LOperand* right, LOperand* temp, LOperand* temp2) {
656 LOperand* left() { return inputs_[0]; }
657 LOperand* right() { return inputs_[1]; }
658 LOperand* temp() { return temps_[0]; }
659 LOperand* temp2() { return temps_[1]; }
661 DECLARE_CONCRETE_INSTRUCTION(ModI, "mod-i")
662 DECLARE_HYDROGEN_ACCESSOR(Mod)
666 class LDivByPowerOf2I V8_FINAL : public LTemplateInstruction<1, 1, 0> {
668 LDivByPowerOf2I(LOperand* dividend, int32_t divisor) {
669 inputs_[0] = dividend;
673 LOperand* dividend() { return inputs_[0]; }
674 int32_t divisor() const { return divisor_; }
676 DECLARE_CONCRETE_INSTRUCTION(DivByPowerOf2I, "div-by-power-of-2-i")
677 DECLARE_HYDROGEN_ACCESSOR(Div)
684 class LDivByConstI V8_FINAL : public LTemplateInstruction<1, 1, 0> {
686 LDivByConstI(LOperand* dividend, int32_t divisor) {
687 inputs_[0] = dividend;
691 LOperand* dividend() { return inputs_[0]; }
692 int32_t divisor() const { return divisor_; }
694 DECLARE_CONCRETE_INSTRUCTION(DivByConstI, "div-by-const-i")
695 DECLARE_HYDROGEN_ACCESSOR(Div)
702 class LDivI V8_FINAL : public LTemplateInstruction<1, 2, 1> {
704 LDivI(LOperand* dividend, LOperand* divisor, LOperand* temp) {
705 inputs_[0] = dividend;
706 inputs_[1] = divisor;
710 LOperand* dividend() { return inputs_[0]; }
711 LOperand* divisor() { return inputs_[1]; }
712 LOperand* temp() { return temps_[0]; }
714 DECLARE_CONCRETE_INSTRUCTION(DivI, "div-i")
715 DECLARE_HYDROGEN_ACCESSOR(BinaryOperation)
719 class LFlooringDivByPowerOf2I V8_FINAL : public LTemplateInstruction<1, 1, 0> {
721 LFlooringDivByPowerOf2I(LOperand* dividend, int32_t divisor) {
722 inputs_[0] = dividend;
726 LOperand* dividend() { return inputs_[0]; }
727 int32_t divisor() { return divisor_; }
729 DECLARE_CONCRETE_INSTRUCTION(FlooringDivByPowerOf2I,
730 "flooring-div-by-power-of-2-i")
731 DECLARE_HYDROGEN_ACCESSOR(MathFloorOfDiv)
738 class LFlooringDivByConstI V8_FINAL : public LTemplateInstruction<1, 1, 2> {
740 LFlooringDivByConstI(LOperand* dividend, int32_t divisor, LOperand* temp) {
741 inputs_[0] = dividend;
746 LOperand* dividend() { return inputs_[0]; }
747 int32_t divisor() const { return divisor_; }
748 LOperand* temp() { return temps_[0]; }
750 DECLARE_CONCRETE_INSTRUCTION(FlooringDivByConstI, "flooring-div-by-const-i")
751 DECLARE_HYDROGEN_ACCESSOR(MathFloorOfDiv)
758 class LFlooringDivI V8_FINAL : public LTemplateInstruction<1, 2, 1> {
760 LFlooringDivI(LOperand* dividend, LOperand* divisor, LOperand* temp) {
761 inputs_[0] = dividend;
762 inputs_[1] = divisor;
766 LOperand* dividend() { return inputs_[0]; }
767 LOperand* divisor() { return inputs_[1]; }
768 LOperand* temp() { return temps_[0]; }
770 DECLARE_CONCRETE_INSTRUCTION(FlooringDivI, "flooring-div-i")
771 DECLARE_HYDROGEN_ACCESSOR(MathFloorOfDiv)
775 class LMulI V8_FINAL : public LTemplateInstruction<1, 2, 0> {
777 LMulI(LOperand* left, LOperand* right) {
782 LOperand* left() { return inputs_[0]; }
783 LOperand* right() { return inputs_[1]; }
785 DECLARE_CONCRETE_INSTRUCTION(MulI, "mul-i")
786 DECLARE_HYDROGEN_ACCESSOR(Mul)
790 // Instruction for computing multiplier * multiplicand + addend.
791 class LMultiplyAddD V8_FINAL : public LTemplateInstruction<1, 3, 0> {
793 LMultiplyAddD(LOperand* addend, LOperand* multiplier,
794 LOperand* multiplicand) {
796 inputs_[1] = multiplier;
797 inputs_[2] = multiplicand;
800 LOperand* addend() { return inputs_[0]; }
801 LOperand* multiplier() { return inputs_[1]; }
802 LOperand* multiplicand() { return inputs_[2]; }
804 DECLARE_CONCRETE_INSTRUCTION(MultiplyAddD, "multiply-add-d")
808 // Instruction for computing minuend - multiplier * multiplicand.
809 class LMultiplySubD V8_FINAL : public LTemplateInstruction<1, 3, 0> {
811 LMultiplySubD(LOperand* minuend, LOperand* multiplier,
812 LOperand* multiplicand) {
813 inputs_[0] = minuend;
814 inputs_[1] = multiplier;
815 inputs_[2] = multiplicand;
818 LOperand* minuend() { return inputs_[0]; }
819 LOperand* multiplier() { return inputs_[1]; }
820 LOperand* multiplicand() { return inputs_[2]; }
822 DECLARE_CONCRETE_INSTRUCTION(MultiplySubD, "multiply-sub-d")
826 class LDebugBreak V8_FINAL : public LTemplateInstruction<0, 0, 0> {
828 DECLARE_CONCRETE_INSTRUCTION(DebugBreak, "break")
832 class LCompareNumericAndBranch V8_FINAL : public LControlInstruction<2, 0> {
834 LCompareNumericAndBranch(LOperand* left, LOperand* right) {
839 LOperand* left() { return inputs_[0]; }
840 LOperand* right() { return inputs_[1]; }
842 DECLARE_CONCRETE_INSTRUCTION(CompareNumericAndBranch,
843 "compare-numeric-and-branch")
844 DECLARE_HYDROGEN_ACCESSOR(CompareNumericAndBranch)
846 Token::Value op() const { return hydrogen()->token(); }
847 bool is_double() const {
848 return hydrogen()->representation().IsDouble();
851 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
855 class LMathFloor V8_FINAL : public LTemplateInstruction<1, 1, 0> {
857 explicit LMathFloor(LOperand* value) {
861 LOperand* value() { return inputs_[0]; }
863 DECLARE_CONCRETE_INSTRUCTION(MathFloor, "math-floor")
864 DECLARE_HYDROGEN_ACCESSOR(UnaryMathOperation)
868 class LMathRound V8_FINAL : public LTemplateInstruction<1, 1, 1> {
870 LMathRound(LOperand* value, LOperand* temp) {
875 LOperand* value() { return inputs_[0]; }
876 LOperand* temp() { return temps_[0]; }
878 DECLARE_CONCRETE_INSTRUCTION(MathRound, "math-round")
879 DECLARE_HYDROGEN_ACCESSOR(UnaryMathOperation)
883 class LMathFround V8_FINAL : public LTemplateInstruction<1, 1, 0> {
885 explicit LMathFround(LOperand* value) { inputs_[0] = value; }
887 LOperand* value() { return inputs_[0]; }
889 DECLARE_CONCRETE_INSTRUCTION(MathFround, "math-fround")
893 class LMathAbs V8_FINAL : public LTemplateInstruction<1, 2, 0> {
895 LMathAbs(LOperand* context, LOperand* value) {
896 inputs_[1] = context;
900 LOperand* context() { return inputs_[1]; }
901 LOperand* value() { return inputs_[0]; }
903 DECLARE_CONCRETE_INSTRUCTION(MathAbs, "math-abs")
904 DECLARE_HYDROGEN_ACCESSOR(UnaryMathOperation)
908 class LMathLog V8_FINAL : public LTemplateInstruction<1, 1, 0> {
910 explicit LMathLog(LOperand* value) {
914 LOperand* value() { return inputs_[0]; }
916 DECLARE_CONCRETE_INSTRUCTION(MathLog, "math-log")
920 class LMathClz32 V8_FINAL : public LTemplateInstruction<1, 1, 0> {
922 explicit LMathClz32(LOperand* value) {
926 LOperand* value() { return inputs_[0]; }
928 DECLARE_CONCRETE_INSTRUCTION(MathClz32, "math-clz32")
932 class LMathExp V8_FINAL : public LTemplateInstruction<1, 1, 3> {
934 LMathExp(LOperand* value,
935 LOperand* double_temp,
941 temps_[2] = double_temp;
942 ExternalReference::InitializeMathExpData();
945 LOperand* value() { return inputs_[0]; }
946 LOperand* temp1() { return temps_[0]; }
947 LOperand* temp2() { return temps_[1]; }
948 LOperand* double_temp() { return temps_[2]; }
950 DECLARE_CONCRETE_INSTRUCTION(MathExp, "math-exp")
954 class LMathSqrt V8_FINAL : public LTemplateInstruction<1, 1, 0> {
956 explicit LMathSqrt(LOperand* value) {
960 LOperand* value() { return inputs_[0]; }
962 DECLARE_CONCRETE_INSTRUCTION(MathSqrt, "math-sqrt")
966 class LMathPowHalf V8_FINAL : public LTemplateInstruction<1, 1, 0> {
968 explicit LMathPowHalf(LOperand* value) {
972 LOperand* value() { return inputs_[0]; }
974 DECLARE_CONCRETE_INSTRUCTION(MathPowHalf, "math-pow-half")
978 class LCmpObjectEqAndBranch V8_FINAL : public LControlInstruction<2, 0> {
980 LCmpObjectEqAndBranch(LOperand* left, LOperand* right) {
985 LOperand* left() { return inputs_[0]; }
986 LOperand* right() { return inputs_[1]; }
988 DECLARE_CONCRETE_INSTRUCTION(CmpObjectEqAndBranch, "cmp-object-eq-and-branch")
989 DECLARE_HYDROGEN_ACCESSOR(CompareObjectEqAndBranch)
993 class LCmpHoleAndBranch V8_FINAL : public LControlInstruction<1, 0> {
995 explicit LCmpHoleAndBranch(LOperand* object) {
999 LOperand* object() { return inputs_[0]; }
1001 DECLARE_CONCRETE_INSTRUCTION(CmpHoleAndBranch, "cmp-hole-and-branch")
1002 DECLARE_HYDROGEN_ACCESSOR(CompareHoleAndBranch)
1006 class LCompareMinusZeroAndBranch V8_FINAL : public LControlInstruction<1, 1> {
1008 LCompareMinusZeroAndBranch(LOperand* value, LOperand* temp) {
1013 LOperand* value() { return inputs_[0]; }
1014 LOperand* temp() { return temps_[0]; }
1016 DECLARE_CONCRETE_INSTRUCTION(CompareMinusZeroAndBranch,
1017 "cmp-minus-zero-and-branch")
1018 DECLARE_HYDROGEN_ACCESSOR(CompareMinusZeroAndBranch)
1022 class LIsObjectAndBranch V8_FINAL : public LControlInstruction<1, 1> {
1024 LIsObjectAndBranch(LOperand* value, LOperand* temp) {
1029 LOperand* value() { return inputs_[0]; }
1030 LOperand* temp() { return temps_[0]; }
1032 DECLARE_CONCRETE_INSTRUCTION(IsObjectAndBranch, "is-object-and-branch")
1033 DECLARE_HYDROGEN_ACCESSOR(IsObjectAndBranch)
1035 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1039 class LIsStringAndBranch V8_FINAL : public LControlInstruction<1, 1> {
1041 LIsStringAndBranch(LOperand* value, LOperand* temp) {
1046 LOperand* value() { return inputs_[0]; }
1047 LOperand* temp() { return temps_[0]; }
1049 DECLARE_CONCRETE_INSTRUCTION(IsStringAndBranch, "is-string-and-branch")
1050 DECLARE_HYDROGEN_ACCESSOR(IsStringAndBranch)
1052 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1056 class LIsSmiAndBranch V8_FINAL : public LControlInstruction<1, 0> {
1058 explicit LIsSmiAndBranch(LOperand* value) {
1062 LOperand* value() { return inputs_[0]; }
1064 DECLARE_CONCRETE_INSTRUCTION(IsSmiAndBranch, "is-smi-and-branch")
1065 DECLARE_HYDROGEN_ACCESSOR(IsSmiAndBranch)
1067 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1071 class LIsUndetectableAndBranch V8_FINAL : public LControlInstruction<1, 1> {
1073 explicit LIsUndetectableAndBranch(LOperand* value, LOperand* temp) {
1078 LOperand* value() { return inputs_[0]; }
1079 LOperand* temp() { return temps_[0]; }
1081 DECLARE_CONCRETE_INSTRUCTION(IsUndetectableAndBranch,
1082 "is-undetectable-and-branch")
1083 DECLARE_HYDROGEN_ACCESSOR(IsUndetectableAndBranch)
1085 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1089 class LStringCompareAndBranch V8_FINAL : public LControlInstruction<3, 0> {
1091 LStringCompareAndBranch(LOperand* context, LOperand* left, LOperand* right) {
1092 inputs_[0] = context;
1097 LOperand* context() { return inputs_[0]; }
1098 LOperand* left() { return inputs_[1]; }
1099 LOperand* right() { return inputs_[2]; }
1101 DECLARE_CONCRETE_INSTRUCTION(StringCompareAndBranch,
1102 "string-compare-and-branch")
1103 DECLARE_HYDROGEN_ACCESSOR(StringCompareAndBranch)
1105 Token::Value op() const { return hydrogen()->token(); }
1107 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1111 class LHasInstanceTypeAndBranch V8_FINAL : public LControlInstruction<1, 0> {
1113 explicit LHasInstanceTypeAndBranch(LOperand* value) {
1117 LOperand* value() { return inputs_[0]; }
1119 DECLARE_CONCRETE_INSTRUCTION(HasInstanceTypeAndBranch,
1120 "has-instance-type-and-branch")
1121 DECLARE_HYDROGEN_ACCESSOR(HasInstanceTypeAndBranch)
1123 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1127 class LGetCachedArrayIndex V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1129 explicit LGetCachedArrayIndex(LOperand* value) {
1133 LOperand* value() { return inputs_[0]; }
1135 DECLARE_CONCRETE_INSTRUCTION(GetCachedArrayIndex, "get-cached-array-index")
1136 DECLARE_HYDROGEN_ACCESSOR(GetCachedArrayIndex)
1140 class LHasCachedArrayIndexAndBranch V8_FINAL
1141 : public LControlInstruction<1, 0> {
1143 explicit LHasCachedArrayIndexAndBranch(LOperand* value) {
1147 LOperand* value() { return inputs_[0]; }
1149 DECLARE_CONCRETE_INSTRUCTION(HasCachedArrayIndexAndBranch,
1150 "has-cached-array-index-and-branch")
1151 DECLARE_HYDROGEN_ACCESSOR(HasCachedArrayIndexAndBranch)
1153 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1157 class LClassOfTestAndBranch V8_FINAL : public LControlInstruction<1, 1> {
1159 LClassOfTestAndBranch(LOperand* value, LOperand* temp) {
1164 LOperand* value() { return inputs_[0]; }
1165 LOperand* temp() { return temps_[0]; }
1167 DECLARE_CONCRETE_INSTRUCTION(ClassOfTestAndBranch,
1168 "class-of-test-and-branch")
1169 DECLARE_HYDROGEN_ACCESSOR(ClassOfTestAndBranch)
1171 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1175 class LCmpT V8_FINAL : public LTemplateInstruction<1, 3, 0> {
1177 LCmpT(LOperand* context, LOperand* left, LOperand* right) {
1178 inputs_[0] = context;
1183 LOperand* context() { return inputs_[0]; }
1184 LOperand* left() { return inputs_[1]; }
1185 LOperand* right() { return inputs_[2]; }
1187 DECLARE_CONCRETE_INSTRUCTION(CmpT, "cmp-t")
1188 DECLARE_HYDROGEN_ACCESSOR(CompareGeneric)
1190 Token::Value op() const { return hydrogen()->token(); }
1194 class LInstanceOf V8_FINAL : public LTemplateInstruction<1, 3, 0> {
1196 LInstanceOf(LOperand* context, LOperand* left, LOperand* right) {
1197 inputs_[0] = context;
1202 LOperand* context() { return inputs_[0]; }
1203 LOperand* left() { return inputs_[1]; }
1204 LOperand* right() { return inputs_[2]; }
1206 DECLARE_CONCRETE_INSTRUCTION(InstanceOf, "instance-of")
1210 class LInstanceOfKnownGlobal V8_FINAL : public LTemplateInstruction<1, 2, 1> {
1212 LInstanceOfKnownGlobal(LOperand* context, LOperand* value, LOperand* temp) {
1213 inputs_[0] = context;
1218 LOperand* context() { return inputs_[0]; }
1219 LOperand* value() { return inputs_[1]; }
1220 LOperand* temp() { return temps_[0]; }
1222 DECLARE_CONCRETE_INSTRUCTION(InstanceOfKnownGlobal,
1223 "instance-of-known-global")
1224 DECLARE_HYDROGEN_ACCESSOR(InstanceOfKnownGlobal)
1226 Handle<JSFunction> function() const { return hydrogen()->function(); }
1227 LEnvironment* GetDeferredLazyDeoptimizationEnvironment() {
1228 return lazy_deopt_env_;
1230 virtual void SetDeferredLazyDeoptimizationEnvironment(
1231 LEnvironment* env) V8_OVERRIDE {
1232 lazy_deopt_env_ = env;
1236 LEnvironment* lazy_deopt_env_;
1240 class LBoundsCheck V8_FINAL : public LTemplateInstruction<0, 2, 0> {
1242 LBoundsCheck(LOperand* index, LOperand* length) {
1244 inputs_[1] = length;
1247 LOperand* index() { return inputs_[0]; }
1248 LOperand* length() { return inputs_[1]; }
1250 DECLARE_CONCRETE_INSTRUCTION(BoundsCheck, "bounds-check")
1251 DECLARE_HYDROGEN_ACCESSOR(BoundsCheck)
1255 class LBitI V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1257 LBitI(LOperand* left, LOperand* right) {
1262 LOperand* left() { return inputs_[0]; }
1263 LOperand* right() { return inputs_[1]; }
1265 Token::Value op() const { return hydrogen()->op(); }
1267 DECLARE_CONCRETE_INSTRUCTION(BitI, "bit-i")
1268 DECLARE_HYDROGEN_ACCESSOR(Bitwise)
1272 class LShiftI V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1274 LShiftI(Token::Value op, LOperand* left, LOperand* right, bool can_deopt)
1275 : op_(op), can_deopt_(can_deopt) {
1280 Token::Value op() const { return op_; }
1281 LOperand* left() { return inputs_[0]; }
1282 LOperand* right() { return inputs_[1]; }
1283 bool can_deopt() const { return can_deopt_; }
1285 DECLARE_CONCRETE_INSTRUCTION(ShiftI, "shift-i")
1293 class LSubI V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1295 LSubI(LOperand* left, LOperand* right) {
1300 LOperand* left() { return inputs_[0]; }
1301 LOperand* right() { return inputs_[1]; }
1303 DECLARE_CONCRETE_INSTRUCTION(SubI, "sub-i")
1304 DECLARE_HYDROGEN_ACCESSOR(Sub)
1308 class LRSubI V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1310 LRSubI(LOperand* left, LOperand* right) {
1315 LOperand* left() { return inputs_[0]; }
1316 LOperand* right() { return inputs_[1]; }
1318 DECLARE_CONCRETE_INSTRUCTION(RSubI, "rsub-i")
1319 DECLARE_HYDROGEN_ACCESSOR(Sub)
1323 class LConstantI V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1325 DECLARE_CONCRETE_INSTRUCTION(ConstantI, "constant-i")
1326 DECLARE_HYDROGEN_ACCESSOR(Constant)
1328 int32_t value() const { return hydrogen()->Integer32Value(); }
1332 class LConstantS V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1334 DECLARE_CONCRETE_INSTRUCTION(ConstantS, "constant-s")
1335 DECLARE_HYDROGEN_ACCESSOR(Constant)
1337 Smi* value() const { return Smi::FromInt(hydrogen()->Integer32Value()); }
1341 class LConstantD V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1343 DECLARE_CONCRETE_INSTRUCTION(ConstantD, "constant-d")
1344 DECLARE_HYDROGEN_ACCESSOR(Constant)
1346 double value() const { return hydrogen()->DoubleValue(); }
1350 class LConstantE V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1352 DECLARE_CONCRETE_INSTRUCTION(ConstantE, "constant-e")
1353 DECLARE_HYDROGEN_ACCESSOR(Constant)
1355 ExternalReference value() const {
1356 return hydrogen()->ExternalReferenceValue();
1361 class LConstantT V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1363 DECLARE_CONCRETE_INSTRUCTION(ConstantT, "constant-t")
1364 DECLARE_HYDROGEN_ACCESSOR(Constant)
1366 Handle<Object> value(Isolate* isolate) const {
1367 return hydrogen()->handle(isolate);
1372 class LBranch V8_FINAL : public LControlInstruction<1, 0> {
1374 explicit LBranch(LOperand* value) {
1378 LOperand* value() { return inputs_[0]; }
1380 DECLARE_CONCRETE_INSTRUCTION(Branch, "branch")
1381 DECLARE_HYDROGEN_ACCESSOR(Branch)
1383 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1387 class LCmpMapAndBranch V8_FINAL : public LControlInstruction<1, 1> {
1389 LCmpMapAndBranch(LOperand* value, LOperand* temp) {
1394 LOperand* value() { return inputs_[0]; }
1395 LOperand* temp() { return temps_[0]; }
1397 DECLARE_CONCRETE_INSTRUCTION(CmpMapAndBranch, "cmp-map-and-branch")
1398 DECLARE_HYDROGEN_ACCESSOR(CompareMap)
1400 Handle<Map> map() const { return hydrogen()->map().handle(); }
1404 class LMapEnumLength V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1406 explicit LMapEnumLength(LOperand* value) {
1410 LOperand* value() { return inputs_[0]; }
1412 DECLARE_CONCRETE_INSTRUCTION(MapEnumLength, "map-enum-length")
1416 class LDateField V8_FINAL : public LTemplateInstruction<1, 1, 1> {
1418 LDateField(LOperand* date, LOperand* temp, Smi* index) : index_(index) {
1423 LOperand* date() { return inputs_[0]; }
1424 LOperand* temp() { return temps_[0]; }
1425 Smi* index() const { return index_; }
1427 DECLARE_CONCRETE_INSTRUCTION(DateField, "date-field")
1428 DECLARE_HYDROGEN_ACCESSOR(DateField)
1435 class LSeqStringGetChar V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1437 LSeqStringGetChar(LOperand* string, LOperand* index) {
1438 inputs_[0] = string;
1442 LOperand* string() const { return inputs_[0]; }
1443 LOperand* index() const { return inputs_[1]; }
1445 DECLARE_CONCRETE_INSTRUCTION(SeqStringGetChar, "seq-string-get-char")
1446 DECLARE_HYDROGEN_ACCESSOR(SeqStringGetChar)
1450 class LSeqStringSetChar V8_FINAL : public LTemplateInstruction<1, 4, 0> {
1452 LSeqStringSetChar(LOperand* context,
1456 inputs_[0] = context;
1457 inputs_[1] = string;
1462 LOperand* string() { return inputs_[1]; }
1463 LOperand* index() { return inputs_[2]; }
1464 LOperand* value() { return inputs_[3]; }
1466 DECLARE_CONCRETE_INSTRUCTION(SeqStringSetChar, "seq-string-set-char")
1467 DECLARE_HYDROGEN_ACCESSOR(SeqStringSetChar)
1471 class LAddI V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1473 LAddI(LOperand* left, LOperand* right) {
1478 LOperand* left() { return inputs_[0]; }
1479 LOperand* right() { return inputs_[1]; }
1481 DECLARE_CONCRETE_INSTRUCTION(AddI, "add-i")
1482 DECLARE_HYDROGEN_ACCESSOR(Add)
1486 class LMathMinMax V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1488 LMathMinMax(LOperand* left, LOperand* right) {
1493 LOperand* left() { return inputs_[0]; }
1494 LOperand* right() { return inputs_[1]; }
1496 DECLARE_CONCRETE_INSTRUCTION(MathMinMax, "math-min-max")
1497 DECLARE_HYDROGEN_ACCESSOR(MathMinMax)
1501 class LPower V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1503 LPower(LOperand* left, LOperand* right) {
1508 LOperand* left() { return inputs_[0]; }
1509 LOperand* right() { return inputs_[1]; }
1511 DECLARE_CONCRETE_INSTRUCTION(Power, "power")
1512 DECLARE_HYDROGEN_ACCESSOR(Power)
1516 class LArithmeticD V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1518 LArithmeticD(Token::Value op, LOperand* left, LOperand* right)
1524 Token::Value op() const { return op_; }
1525 LOperand* left() { return inputs_[0]; }
1526 LOperand* right() { return inputs_[1]; }
1528 virtual Opcode opcode() const V8_OVERRIDE {
1529 return LInstruction::kArithmeticD;
1531 virtual void CompileToNative(LCodeGen* generator) V8_OVERRIDE;
1532 virtual const char* Mnemonic() const V8_OVERRIDE;
1539 class LArithmeticT V8_FINAL : public LTemplateInstruction<1, 3, 0> {
1541 LArithmeticT(Token::Value op,
1546 inputs_[0] = context;
1551 LOperand* context() { return inputs_[0]; }
1552 LOperand* left() { return inputs_[1]; }
1553 LOperand* right() { return inputs_[2]; }
1554 Token::Value op() const { return op_; }
1556 virtual Opcode opcode() const V8_OVERRIDE {
1557 return LInstruction::kArithmeticT;
1559 virtual void CompileToNative(LCodeGen* generator) V8_OVERRIDE;
1560 virtual const char* Mnemonic() const V8_OVERRIDE;
1567 class LReturn V8_FINAL : public LTemplateInstruction<0, 3, 0> {
1569 LReturn(LOperand* value, LOperand* context, LOperand* parameter_count) {
1571 inputs_[1] = context;
1572 inputs_[2] = parameter_count;
1575 LOperand* value() { return inputs_[0]; }
1577 bool has_constant_parameter_count() {
1578 return parameter_count()->IsConstantOperand();
1580 LConstantOperand* constant_parameter_count() {
1581 DCHECK(has_constant_parameter_count());
1582 return LConstantOperand::cast(parameter_count());
1584 LOperand* parameter_count() { return inputs_[2]; }
1586 DECLARE_CONCRETE_INSTRUCTION(Return, "return")
1590 class LLoadNamedField V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1592 explicit LLoadNamedField(LOperand* object) {
1593 inputs_[0] = object;
1596 LOperand* object() { return inputs_[0]; }
1598 DECLARE_CONCRETE_INSTRUCTION(LoadNamedField, "load-named-field")
1599 DECLARE_HYDROGEN_ACCESSOR(LoadNamedField)
1603 class LLoadNamedGeneric V8_FINAL : public LTemplateInstruction<1, 2, 1> {
1605 LLoadNamedGeneric(LOperand* context, LOperand* object, LOperand* vector) {
1606 inputs_[0] = context;
1607 inputs_[1] = object;
1611 LOperand* context() { return inputs_[0]; }
1612 LOperand* object() { return inputs_[1]; }
1613 LOperand* temp_vector() { return temps_[0]; }
1615 DECLARE_CONCRETE_INSTRUCTION(LoadNamedGeneric, "load-named-generic")
1616 DECLARE_HYDROGEN_ACCESSOR(LoadNamedGeneric)
1618 Handle<Object> name() const { return hydrogen()->name(); }
1622 class LLoadFunctionPrototype V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1624 explicit LLoadFunctionPrototype(LOperand* function) {
1625 inputs_[0] = function;
1628 LOperand* function() { return inputs_[0]; }
1630 DECLARE_CONCRETE_INSTRUCTION(LoadFunctionPrototype, "load-function-prototype")
1631 DECLARE_HYDROGEN_ACCESSOR(LoadFunctionPrototype)
1635 class LLoadRoot V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1637 DECLARE_CONCRETE_INSTRUCTION(LoadRoot, "load-root")
1638 DECLARE_HYDROGEN_ACCESSOR(LoadRoot)
1640 Heap::RootListIndex index() const { return hydrogen()->index(); }
1644 class LLoadKeyed V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1646 LLoadKeyed(LOperand* elements, LOperand* key) {
1647 inputs_[0] = elements;
1651 LOperand* elements() { return inputs_[0]; }
1652 LOperand* key() { return inputs_[1]; }
1653 ElementsKind elements_kind() const {
1654 return hydrogen()->elements_kind();
1656 bool is_external() const {
1657 return hydrogen()->is_external();
1659 bool is_fixed_typed_array() const {
1660 return hydrogen()->is_fixed_typed_array();
1662 bool is_typed_elements() const {
1663 return is_external() || is_fixed_typed_array();
1666 DECLARE_CONCRETE_INSTRUCTION(LoadKeyed, "load-keyed")
1667 DECLARE_HYDROGEN_ACCESSOR(LoadKeyed)
1669 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1670 uint32_t base_offset() const { return hydrogen()->base_offset(); }
1674 class LLoadKeyedGeneric V8_FINAL : public LTemplateInstruction<1, 3, 1> {
1676 LLoadKeyedGeneric(LOperand* context, LOperand* object, LOperand* key,
1678 inputs_[0] = context;
1679 inputs_[1] = object;
1684 LOperand* context() { return inputs_[0]; }
1685 LOperand* object() { return inputs_[1]; }
1686 LOperand* key() { return inputs_[2]; }
1687 LOperand* temp_vector() { return temps_[0]; }
1689 DECLARE_CONCRETE_INSTRUCTION(LoadKeyedGeneric, "load-keyed-generic")
1690 DECLARE_HYDROGEN_ACCESSOR(LoadKeyedGeneric)
1694 class LLoadGlobalCell V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1696 DECLARE_CONCRETE_INSTRUCTION(LoadGlobalCell, "load-global-cell")
1697 DECLARE_HYDROGEN_ACCESSOR(LoadGlobalCell)
1701 class LLoadGlobalGeneric V8_FINAL : public LTemplateInstruction<1, 2, 1> {
1703 LLoadGlobalGeneric(LOperand* context, LOperand* global_object,
1705 inputs_[0] = context;
1706 inputs_[1] = global_object;
1710 LOperand* context() { return inputs_[0]; }
1711 LOperand* global_object() { return inputs_[1]; }
1712 LOperand* temp_vector() { return temps_[0]; }
1714 DECLARE_CONCRETE_INSTRUCTION(LoadGlobalGeneric, "load-global-generic")
1715 DECLARE_HYDROGEN_ACCESSOR(LoadGlobalGeneric)
1717 Handle<Object> name() const { return hydrogen()->name(); }
1718 bool for_typeof() const { return hydrogen()->for_typeof(); }
1722 class LStoreGlobalCell V8_FINAL : public LTemplateInstruction<0, 1, 1> {
1724 LStoreGlobalCell(LOperand* value, LOperand* temp) {
1729 LOperand* value() { return inputs_[0]; }
1730 LOperand* temp() { return temps_[0]; }
1732 DECLARE_CONCRETE_INSTRUCTION(StoreGlobalCell, "store-global-cell")
1733 DECLARE_HYDROGEN_ACCESSOR(StoreGlobalCell)
1737 class LLoadContextSlot V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1739 explicit LLoadContextSlot(LOperand* context) {
1740 inputs_[0] = context;
1743 LOperand* context() { return inputs_[0]; }
1745 DECLARE_CONCRETE_INSTRUCTION(LoadContextSlot, "load-context-slot")
1746 DECLARE_HYDROGEN_ACCESSOR(LoadContextSlot)
1748 int slot_index() { return hydrogen()->slot_index(); }
1750 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1754 class LStoreContextSlot V8_FINAL : public LTemplateInstruction<0, 2, 0> {
1756 LStoreContextSlot(LOperand* context, LOperand* value) {
1757 inputs_[0] = context;
1761 LOperand* context() { return inputs_[0]; }
1762 LOperand* value() { return inputs_[1]; }
1764 DECLARE_CONCRETE_INSTRUCTION(StoreContextSlot, "store-context-slot")
1765 DECLARE_HYDROGEN_ACCESSOR(StoreContextSlot)
1767 int slot_index() { return hydrogen()->slot_index(); }
1769 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1773 class LPushArgument V8_FINAL : public LTemplateInstruction<0, 1, 0> {
1775 explicit LPushArgument(LOperand* value) {
1779 LOperand* value() { return inputs_[0]; }
1781 DECLARE_CONCRETE_INSTRUCTION(PushArgument, "push-argument")
1785 class LDrop V8_FINAL : public LTemplateInstruction<0, 0, 0> {
1787 explicit LDrop(int count) : count_(count) { }
1789 int count() const { return count_; }
1791 DECLARE_CONCRETE_INSTRUCTION(Drop, "drop")
1798 class LStoreCodeEntry V8_FINAL: public LTemplateInstruction<0, 2, 0> {
1800 LStoreCodeEntry(LOperand* function, LOperand* code_object) {
1801 inputs_[0] = function;
1802 inputs_[1] = code_object;
1805 LOperand* function() { return inputs_[0]; }
1806 LOperand* code_object() { return inputs_[1]; }
1808 virtual void PrintDataTo(StringStream* stream);
1810 DECLARE_CONCRETE_INSTRUCTION(StoreCodeEntry, "store-code-entry")
1811 DECLARE_HYDROGEN_ACCESSOR(StoreCodeEntry)
1815 class LInnerAllocatedObject V8_FINAL: public LTemplateInstruction<1, 2, 0> {
1817 LInnerAllocatedObject(LOperand* base_object, LOperand* offset) {
1818 inputs_[0] = base_object;
1819 inputs_[1] = offset;
1822 LOperand* base_object() const { return inputs_[0]; }
1823 LOperand* offset() const { return inputs_[1]; }
1825 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1827 DECLARE_CONCRETE_INSTRUCTION(InnerAllocatedObject, "inner-allocated-object")
1831 class LThisFunction V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1833 DECLARE_CONCRETE_INSTRUCTION(ThisFunction, "this-function")
1834 DECLARE_HYDROGEN_ACCESSOR(ThisFunction)
1838 class LContext V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1840 DECLARE_CONCRETE_INSTRUCTION(Context, "context")
1841 DECLARE_HYDROGEN_ACCESSOR(Context)
1845 class LDeclareGlobals V8_FINAL : public LTemplateInstruction<0, 1, 0> {
1847 explicit LDeclareGlobals(LOperand* context) {
1848 inputs_[0] = context;
1851 LOperand* context() { return inputs_[0]; }
1853 DECLARE_CONCRETE_INSTRUCTION(DeclareGlobals, "declare-globals")
1854 DECLARE_HYDROGEN_ACCESSOR(DeclareGlobals)
1858 class LCallJSFunction V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1860 explicit LCallJSFunction(LOperand* function) {
1861 inputs_[0] = function;
1864 LOperand* function() { return inputs_[0]; }
1866 DECLARE_CONCRETE_INSTRUCTION(CallJSFunction, "call-js-function")
1867 DECLARE_HYDROGEN_ACCESSOR(CallJSFunction)
1869 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1871 int arity() const { return hydrogen()->argument_count() - 1; }
1875 class LCallWithDescriptor V8_FINAL : public LTemplateResultInstruction<1> {
1877 LCallWithDescriptor(const InterfaceDescriptor* descriptor,
1878 const ZoneList<LOperand*>& operands,
1880 : descriptor_(descriptor),
1881 inputs_(descriptor->GetRegisterParameterCount() + 1, zone) {
1882 DCHECK(descriptor->GetRegisterParameterCount() + 1 == operands.length());
1883 inputs_.AddAll(operands, zone);
1886 LOperand* target() const { return inputs_[0]; }
1888 const InterfaceDescriptor* descriptor() { return descriptor_; }
1891 DECLARE_CONCRETE_INSTRUCTION(CallWithDescriptor, "call-with-descriptor")
1892 DECLARE_HYDROGEN_ACCESSOR(CallWithDescriptor)
1894 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1896 int arity() const { return hydrogen()->argument_count() - 1; }
1898 const InterfaceDescriptor* descriptor_;
1899 ZoneList<LOperand*> inputs_;
1901 // Iterator support.
1902 virtual int InputCount() V8_FINAL V8_OVERRIDE { return inputs_.length(); }
1903 virtual LOperand* InputAt(int i) V8_FINAL V8_OVERRIDE { return inputs_[i]; }
1905 virtual int TempCount() V8_FINAL V8_OVERRIDE { return 0; }
1906 virtual LOperand* TempAt(int i) V8_FINAL V8_OVERRIDE { return NULL; }
1910 class LInvokeFunction V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1912 LInvokeFunction(LOperand* context, LOperand* function) {
1913 inputs_[0] = context;
1914 inputs_[1] = function;
1917 LOperand* context() { return inputs_[0]; }
1918 LOperand* function() { return inputs_[1]; }
1920 DECLARE_CONCRETE_INSTRUCTION(InvokeFunction, "invoke-function")
1921 DECLARE_HYDROGEN_ACCESSOR(InvokeFunction)
1923 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1925 int arity() const { return hydrogen()->argument_count() - 1; }
1929 class LCallFunction V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1931 LCallFunction(LOperand* context, LOperand* function) {
1932 inputs_[0] = context;
1933 inputs_[1] = function;
1936 LOperand* context() { return inputs_[0]; }
1937 LOperand* function() { return inputs_[1]; }
1939 DECLARE_CONCRETE_INSTRUCTION(CallFunction, "call-function")
1940 DECLARE_HYDROGEN_ACCESSOR(CallFunction)
1942 int arity() const { return hydrogen()->argument_count() - 1; }
1946 class LCallNew V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1948 LCallNew(LOperand* context, LOperand* constructor) {
1949 inputs_[0] = context;
1950 inputs_[1] = constructor;
1953 LOperand* context() { return inputs_[0]; }
1954 LOperand* constructor() { return inputs_[1]; }
1956 DECLARE_CONCRETE_INSTRUCTION(CallNew, "call-new")
1957 DECLARE_HYDROGEN_ACCESSOR(CallNew)
1959 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1961 int arity() const { return hydrogen()->argument_count() - 1; }
1965 class LCallNewArray V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1967 LCallNewArray(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(CallNewArray, "call-new-array")
1976 DECLARE_HYDROGEN_ACCESSOR(CallNewArray)
1978 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1980 int arity() const { return hydrogen()->argument_count() - 1; }
1984 class LCallRuntime V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1986 explicit LCallRuntime(LOperand* context) {
1987 inputs_[0] = context;
1990 LOperand* context() { return inputs_[0]; }
1992 DECLARE_CONCRETE_INSTRUCTION(CallRuntime, "call-runtime")
1993 DECLARE_HYDROGEN_ACCESSOR(CallRuntime)
1995 virtual bool ClobbersDoubleRegisters(Isolate* isolate) const V8_OVERRIDE {
1996 return save_doubles() == kDontSaveFPRegs;
1999 const Runtime::Function* function() const { return hydrogen()->function(); }
2000 int arity() const { return hydrogen()->argument_count(); }
2001 SaveFPRegsMode save_doubles() const { return hydrogen()->save_doubles(); }
2005 class LInteger32ToDouble V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2007 explicit LInteger32ToDouble(LOperand* value) {
2011 LOperand* value() { return inputs_[0]; }
2013 DECLARE_CONCRETE_INSTRUCTION(Integer32ToDouble, "int32-to-double")
2017 class LUint32ToDouble V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2019 explicit LUint32ToDouble(LOperand* value) {
2023 LOperand* value() { return inputs_[0]; }
2025 DECLARE_CONCRETE_INSTRUCTION(Uint32ToDouble, "uint32-to-double")
2029 class LNumberTagI V8_FINAL : public LTemplateInstruction<1, 1, 2> {
2031 LNumberTagI(LOperand* value, LOperand* temp1, LOperand* temp2) {
2037 LOperand* value() { return inputs_[0]; }
2038 LOperand* temp1() { return temps_[0]; }
2039 LOperand* temp2() { return temps_[1]; }
2041 DECLARE_CONCRETE_INSTRUCTION(NumberTagI, "number-tag-i")
2045 class LNumberTagU V8_FINAL : public LTemplateInstruction<1, 1, 2> {
2047 LNumberTagU(LOperand* value, LOperand* temp1, LOperand* temp2) {
2053 LOperand* value() { return inputs_[0]; }
2054 LOperand* temp1() { return temps_[0]; }
2055 LOperand* temp2() { return temps_[1]; }
2057 DECLARE_CONCRETE_INSTRUCTION(NumberTagU, "number-tag-u")
2061 class LNumberTagD V8_FINAL : public LTemplateInstruction<1, 1, 2> {
2063 LNumberTagD(LOperand* value, LOperand* temp, LOperand* temp2) {
2069 LOperand* value() { return inputs_[0]; }
2070 LOperand* temp() { return temps_[0]; }
2071 LOperand* temp2() { return temps_[1]; }
2073 DECLARE_CONCRETE_INSTRUCTION(NumberTagD, "number-tag-d")
2074 DECLARE_HYDROGEN_ACCESSOR(Change)
2078 class LDoubleToSmi V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2080 explicit LDoubleToSmi(LOperand* value) {
2084 LOperand* value() { return inputs_[0]; }
2086 DECLARE_CONCRETE_INSTRUCTION(DoubleToSmi, "double-to-smi")
2087 DECLARE_HYDROGEN_ACCESSOR(UnaryOperation)
2089 bool truncating() { return hydrogen()->CanTruncateToInt32(); }
2093 // Sometimes truncating conversion from a tagged value to an int32.
2094 class LDoubleToI V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2096 explicit LDoubleToI(LOperand* value) {
2100 LOperand* value() { return inputs_[0]; }
2102 DECLARE_CONCRETE_INSTRUCTION(DoubleToI, "double-to-i")
2103 DECLARE_HYDROGEN_ACCESSOR(UnaryOperation)
2105 bool truncating() { return hydrogen()->CanTruncateToInt32(); }
2109 // Truncating conversion from a tagged value to an int32.
2110 class LTaggedToI V8_FINAL : public LTemplateInstruction<1, 1, 2> {
2112 LTaggedToI(LOperand* value,
2120 LOperand* value() { return inputs_[0]; }
2121 LOperand* temp() { return temps_[0]; }
2122 LOperand* temp2() { return temps_[1]; }
2124 DECLARE_CONCRETE_INSTRUCTION(TaggedToI, "tagged-to-i")
2125 DECLARE_HYDROGEN_ACCESSOR(Change)
2127 bool truncating() { return hydrogen()->CanTruncateToInt32(); }
2131 class LSmiTag V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2133 explicit LSmiTag(LOperand* value) {
2137 LOperand* value() { return inputs_[0]; }
2139 DECLARE_CONCRETE_INSTRUCTION(SmiTag, "smi-tag")
2140 DECLARE_HYDROGEN_ACCESSOR(Change)
2144 class LNumberUntagD V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2146 explicit LNumberUntagD(LOperand* value) {
2150 LOperand* value() { return inputs_[0]; }
2152 DECLARE_CONCRETE_INSTRUCTION(NumberUntagD, "double-untag")
2153 DECLARE_HYDROGEN_ACCESSOR(Change)
2157 class LSmiUntag V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2159 LSmiUntag(LOperand* value, bool needs_check)
2160 : needs_check_(needs_check) {
2164 LOperand* value() { return inputs_[0]; }
2165 bool needs_check() const { return needs_check_; }
2167 DECLARE_CONCRETE_INSTRUCTION(SmiUntag, "smi-untag")
2174 class LStoreNamedField V8_FINAL : public LTemplateInstruction<0, 2, 1> {
2176 LStoreNamedField(LOperand* object, LOperand* value, LOperand* temp) {
2177 inputs_[0] = object;
2182 LOperand* object() { return inputs_[0]; }
2183 LOperand* value() { return inputs_[1]; }
2184 LOperand* temp() { return temps_[0]; }
2186 DECLARE_CONCRETE_INSTRUCTION(StoreNamedField, "store-named-field")
2187 DECLARE_HYDROGEN_ACCESSOR(StoreNamedField)
2189 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
2191 Representation representation() const {
2192 return hydrogen()->field_representation();
2197 class LStoreNamedGeneric V8_FINAL : public LTemplateInstruction<0, 3, 0> {
2199 LStoreNamedGeneric(LOperand* context, LOperand* object, LOperand* value) {
2200 inputs_[0] = context;
2201 inputs_[1] = object;
2205 LOperand* context() { return inputs_[0]; }
2206 LOperand* object() { return inputs_[1]; }
2207 LOperand* value() { return inputs_[2]; }
2209 DECLARE_CONCRETE_INSTRUCTION(StoreNamedGeneric, "store-named-generic")
2210 DECLARE_HYDROGEN_ACCESSOR(StoreNamedGeneric)
2212 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
2214 Handle<Object> name() const { return hydrogen()->name(); }
2215 StrictMode strict_mode() { return hydrogen()->strict_mode(); }
2219 class LStoreKeyed V8_FINAL : public LTemplateInstruction<0, 3, 0> {
2221 LStoreKeyed(LOperand* object, LOperand* key, LOperand* value) {
2222 inputs_[0] = object;
2227 bool is_external() const { return hydrogen()->is_external(); }
2228 bool is_fixed_typed_array() const {
2229 return hydrogen()->is_fixed_typed_array();
2231 bool is_typed_elements() const {
2232 return is_external() || is_fixed_typed_array();
2234 LOperand* elements() { return inputs_[0]; }
2235 LOperand* key() { return inputs_[1]; }
2236 LOperand* value() { return inputs_[2]; }
2237 ElementsKind elements_kind() const {
2238 return hydrogen()->elements_kind();
2241 DECLARE_CONCRETE_INSTRUCTION(StoreKeyed, "store-keyed")
2242 DECLARE_HYDROGEN_ACCESSOR(StoreKeyed)
2244 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
2245 bool NeedsCanonicalization() {
2246 if (hydrogen()->value()->IsAdd() || hydrogen()->value()->IsSub() ||
2247 hydrogen()->value()->IsMul() || hydrogen()->value()->IsDiv()) {
2250 return hydrogen()->NeedsCanonicalization();
2252 uint32_t base_offset() const { return hydrogen()->base_offset(); }
2256 class LStoreKeyedGeneric V8_FINAL : public LTemplateInstruction<0, 4, 0> {
2258 LStoreKeyedGeneric(LOperand* context,
2262 inputs_[0] = context;
2268 LOperand* context() { return inputs_[0]; }
2269 LOperand* object() { return inputs_[1]; }
2270 LOperand* key() { return inputs_[2]; }
2271 LOperand* value() { return inputs_[3]; }
2273 DECLARE_CONCRETE_INSTRUCTION(StoreKeyedGeneric, "store-keyed-generic")
2274 DECLARE_HYDROGEN_ACCESSOR(StoreKeyedGeneric)
2276 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
2278 StrictMode strict_mode() { return hydrogen()->strict_mode(); }
2282 class LTransitionElementsKind V8_FINAL : public LTemplateInstruction<0, 2, 1> {
2284 LTransitionElementsKind(LOperand* object,
2286 LOperand* new_map_temp) {
2287 inputs_[0] = object;
2288 inputs_[1] = context;
2289 temps_[0] = new_map_temp;
2292 LOperand* context() { return inputs_[1]; }
2293 LOperand* object() { return inputs_[0]; }
2294 LOperand* new_map_temp() { return temps_[0]; }
2296 DECLARE_CONCRETE_INSTRUCTION(TransitionElementsKind,
2297 "transition-elements-kind")
2298 DECLARE_HYDROGEN_ACCESSOR(TransitionElementsKind)
2300 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
2302 Handle<Map> original_map() { return hydrogen()->original_map().handle(); }
2303 Handle<Map> transitioned_map() {
2304 return hydrogen()->transitioned_map().handle();
2306 ElementsKind from_kind() { return hydrogen()->from_kind(); }
2307 ElementsKind to_kind() { return hydrogen()->to_kind(); }
2311 class LTrapAllocationMemento V8_FINAL : public LTemplateInstruction<0, 1, 1> {
2313 LTrapAllocationMemento(LOperand* object,
2315 inputs_[0] = object;
2319 LOperand* object() { return inputs_[0]; }
2320 LOperand* temp() { return temps_[0]; }
2322 DECLARE_CONCRETE_INSTRUCTION(TrapAllocationMemento,
2323 "trap-allocation-memento")
2327 class LStringAdd V8_FINAL : public LTemplateInstruction<1, 3, 0> {
2329 LStringAdd(LOperand* context, LOperand* left, LOperand* right) {
2330 inputs_[0] = context;
2335 LOperand* context() { return inputs_[0]; }
2336 LOperand* left() { return inputs_[1]; }
2337 LOperand* right() { return inputs_[2]; }
2339 DECLARE_CONCRETE_INSTRUCTION(StringAdd, "string-add")
2340 DECLARE_HYDROGEN_ACCESSOR(StringAdd)
2345 class LStringCharCodeAt V8_FINAL : public LTemplateInstruction<1, 3, 0> {
2347 LStringCharCodeAt(LOperand* context, LOperand* string, LOperand* index) {
2348 inputs_[0] = context;
2349 inputs_[1] = string;
2353 LOperand* context() { return inputs_[0]; }
2354 LOperand* string() { return inputs_[1]; }
2355 LOperand* index() { return inputs_[2]; }
2357 DECLARE_CONCRETE_INSTRUCTION(StringCharCodeAt, "string-char-code-at")
2358 DECLARE_HYDROGEN_ACCESSOR(StringCharCodeAt)
2362 class LStringCharFromCode V8_FINAL : public LTemplateInstruction<1, 2, 0> {
2364 explicit LStringCharFromCode(LOperand* context, LOperand* char_code) {
2365 inputs_[0] = context;
2366 inputs_[1] = char_code;
2369 LOperand* context() { return inputs_[0]; }
2370 LOperand* char_code() { return inputs_[1]; }
2372 DECLARE_CONCRETE_INSTRUCTION(StringCharFromCode, "string-char-from-code")
2373 DECLARE_HYDROGEN_ACCESSOR(StringCharFromCode)
2377 class LCheckValue V8_FINAL : public LTemplateInstruction<0, 1, 0> {
2379 explicit LCheckValue(LOperand* value) {
2383 LOperand* value() { return inputs_[0]; }
2385 DECLARE_CONCRETE_INSTRUCTION(CheckValue, "check-value")
2386 DECLARE_HYDROGEN_ACCESSOR(CheckValue)
2390 class LCheckInstanceType V8_FINAL : public LTemplateInstruction<0, 1, 0> {
2392 explicit LCheckInstanceType(LOperand* value) {
2396 LOperand* value() { return inputs_[0]; }
2398 DECLARE_CONCRETE_INSTRUCTION(CheckInstanceType, "check-instance-type")
2399 DECLARE_HYDROGEN_ACCESSOR(CheckInstanceType)
2403 class LCheckMaps V8_FINAL : public LTemplateInstruction<0, 1, 0> {
2405 explicit LCheckMaps(LOperand* value = NULL) {
2409 LOperand* value() { return inputs_[0]; }
2411 DECLARE_CONCRETE_INSTRUCTION(CheckMaps, "check-maps")
2412 DECLARE_HYDROGEN_ACCESSOR(CheckMaps)
2416 class LCheckSmi V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2418 explicit LCheckSmi(LOperand* value) {
2422 LOperand* value() { return inputs_[0]; }
2424 DECLARE_CONCRETE_INSTRUCTION(CheckSmi, "check-smi")
2428 class LCheckNonSmi V8_FINAL : public LTemplateInstruction<0, 1, 0> {
2430 explicit LCheckNonSmi(LOperand* value) {
2434 LOperand* value() { return inputs_[0]; }
2436 DECLARE_CONCRETE_INSTRUCTION(CheckNonSmi, "check-non-smi")
2437 DECLARE_HYDROGEN_ACCESSOR(CheckHeapObject)
2441 class LClampDToUint8 V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2443 explicit LClampDToUint8(LOperand* unclamped) {
2444 inputs_[0] = unclamped;
2447 LOperand* unclamped() { return inputs_[0]; }
2449 DECLARE_CONCRETE_INSTRUCTION(ClampDToUint8, "clamp-d-to-uint8")
2453 class LClampIToUint8 V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2455 explicit LClampIToUint8(LOperand* unclamped) {
2456 inputs_[0] = unclamped;
2459 LOperand* unclamped() { return inputs_[0]; }
2461 DECLARE_CONCRETE_INSTRUCTION(ClampIToUint8, "clamp-i-to-uint8")
2465 class LClampTToUint8 V8_FINAL : public LTemplateInstruction<1, 1, 1> {
2467 LClampTToUint8(LOperand* unclamped, LOperand* temp) {
2468 inputs_[0] = unclamped;
2472 LOperand* unclamped() { return inputs_[0]; }
2473 LOperand* temp() { return temps_[0]; }
2475 DECLARE_CONCRETE_INSTRUCTION(ClampTToUint8, "clamp-t-to-uint8")
2479 class LDoubleBits V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2481 explicit LDoubleBits(LOperand* value) {
2485 LOperand* value() { return inputs_[0]; }
2487 DECLARE_CONCRETE_INSTRUCTION(DoubleBits, "double-bits")
2488 DECLARE_HYDROGEN_ACCESSOR(DoubleBits)
2492 class LConstructDouble V8_FINAL : public LTemplateInstruction<1, 2, 0> {
2494 LConstructDouble(LOperand* hi, LOperand* lo) {
2499 LOperand* hi() { return inputs_[0]; }
2500 LOperand* lo() { return inputs_[1]; }
2502 DECLARE_CONCRETE_INSTRUCTION(ConstructDouble, "construct-double")
2506 class LAllocate V8_FINAL : public LTemplateInstruction<1, 2, 2> {
2508 LAllocate(LOperand* context,
2512 inputs_[0] = context;
2518 LOperand* context() { return inputs_[0]; }
2519 LOperand* size() { return inputs_[1]; }
2520 LOperand* temp1() { return temps_[0]; }
2521 LOperand* temp2() { return temps_[1]; }
2523 DECLARE_CONCRETE_INSTRUCTION(Allocate, "allocate")
2524 DECLARE_HYDROGEN_ACCESSOR(Allocate)
2528 class LRegExpLiteral V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2530 explicit LRegExpLiteral(LOperand* context) {
2531 inputs_[0] = context;
2534 LOperand* context() { return inputs_[0]; }
2536 DECLARE_CONCRETE_INSTRUCTION(RegExpLiteral, "regexp-literal")
2537 DECLARE_HYDROGEN_ACCESSOR(RegExpLiteral)
2541 class LFunctionLiteral V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2543 explicit LFunctionLiteral(LOperand* context) {
2544 inputs_[0] = context;
2547 LOperand* context() { return inputs_[0]; }
2549 DECLARE_CONCRETE_INSTRUCTION(FunctionLiteral, "function-literal")
2550 DECLARE_HYDROGEN_ACCESSOR(FunctionLiteral)
2554 class LToFastProperties V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2556 explicit LToFastProperties(LOperand* value) {
2560 LOperand* value() { return inputs_[0]; }
2562 DECLARE_CONCRETE_INSTRUCTION(ToFastProperties, "to-fast-properties")
2563 DECLARE_HYDROGEN_ACCESSOR(ToFastProperties)
2567 class LTypeof V8_FINAL : public LTemplateInstruction<1, 2, 0> {
2569 LTypeof(LOperand* context, LOperand* value) {
2570 inputs_[0] = context;
2574 LOperand* context() { return inputs_[0]; }
2575 LOperand* value() { return inputs_[1]; }
2577 DECLARE_CONCRETE_INSTRUCTION(Typeof, "typeof")
2581 class LTypeofIsAndBranch V8_FINAL : public LControlInstruction<1, 0> {
2583 explicit LTypeofIsAndBranch(LOperand* value) {
2587 LOperand* value() { return inputs_[0]; }
2589 DECLARE_CONCRETE_INSTRUCTION(TypeofIsAndBranch, "typeof-is-and-branch")
2590 DECLARE_HYDROGEN_ACCESSOR(TypeofIsAndBranch)
2592 Handle<String> type_literal() { return hydrogen()->type_literal(); }
2594 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
2598 class LIsConstructCallAndBranch V8_FINAL : public LControlInstruction<0, 1> {
2600 explicit LIsConstructCallAndBranch(LOperand* temp) {
2604 LOperand* temp() { return temps_[0]; }
2606 DECLARE_CONCRETE_INSTRUCTION(IsConstructCallAndBranch,
2607 "is-construct-call-and-branch")
2611 class LOsrEntry V8_FINAL : public LTemplateInstruction<0, 0, 0> {
2615 virtual bool HasInterestingComment(LCodeGen* gen) const V8_OVERRIDE {
2618 DECLARE_CONCRETE_INSTRUCTION(OsrEntry, "osr-entry")
2622 class LStackCheck V8_FINAL : public LTemplateInstruction<0, 1, 0> {
2624 explicit LStackCheck(LOperand* context) {
2625 inputs_[0] = context;
2628 LOperand* context() { return inputs_[0]; }
2630 DECLARE_CONCRETE_INSTRUCTION(StackCheck, "stack-check")
2631 DECLARE_HYDROGEN_ACCESSOR(StackCheck)
2633 Label* done_label() { return &done_label_; }
2640 class LForInPrepareMap V8_FINAL : public LTemplateInstruction<1, 2, 0> {
2642 LForInPrepareMap(LOperand* context, LOperand* object) {
2643 inputs_[0] = context;
2644 inputs_[1] = object;
2647 LOperand* context() { return inputs_[0]; }
2648 LOperand* object() { return inputs_[1]; }
2650 DECLARE_CONCRETE_INSTRUCTION(ForInPrepareMap, "for-in-prepare-map")
2654 class LForInCacheArray V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2656 explicit LForInCacheArray(LOperand* map) {
2660 LOperand* map() { return inputs_[0]; }
2662 DECLARE_CONCRETE_INSTRUCTION(ForInCacheArray, "for-in-cache-array")
2665 return HForInCacheArray::cast(this->hydrogen_value())->idx();
2670 class LCheckMapValue V8_FINAL : public LTemplateInstruction<0, 2, 0> {
2672 LCheckMapValue(LOperand* value, LOperand* map) {
2677 LOperand* value() { return inputs_[0]; }
2678 LOperand* map() { return inputs_[1]; }
2680 DECLARE_CONCRETE_INSTRUCTION(CheckMapValue, "check-map-value")
2684 class LLoadFieldByIndex V8_FINAL : public LTemplateInstruction<1, 2, 0> {
2686 LLoadFieldByIndex(LOperand* object, LOperand* index) {
2687 inputs_[0] = object;
2691 LOperand* object() { return inputs_[0]; }
2692 LOperand* index() { return inputs_[1]; }
2694 DECLARE_CONCRETE_INSTRUCTION(LoadFieldByIndex, "load-field-by-index")
2698 class LStoreFrameContext: public LTemplateInstruction<0, 1, 0> {
2700 explicit LStoreFrameContext(LOperand* context) {
2701 inputs_[0] = context;
2704 LOperand* context() { return inputs_[0]; }
2706 DECLARE_CONCRETE_INSTRUCTION(StoreFrameContext, "store-frame-context")
2710 class LAllocateBlockContext: public LTemplateInstruction<1, 2, 0> {
2712 LAllocateBlockContext(LOperand* context, LOperand* function) {
2713 inputs_[0] = context;
2714 inputs_[1] = function;
2717 LOperand* context() { return inputs_[0]; }
2718 LOperand* function() { return inputs_[1]; }
2720 Handle<ScopeInfo> scope_info() { return hydrogen()->scope_info(); }
2722 DECLARE_CONCRETE_INSTRUCTION(AllocateBlockContext, "allocate-block-context")
2723 DECLARE_HYDROGEN_ACCESSOR(AllocateBlockContext)
2727 class LChunkBuilder;
2728 class LPlatformChunk V8_FINAL : public LChunk {
2730 LPlatformChunk(CompilationInfo* info, HGraph* graph)
2731 : LChunk(info, graph) { }
2733 int GetNextSpillIndex(RegisterKind kind);
2734 LOperand* GetNextSpillSlot(RegisterKind kind);
2738 class LChunkBuilder V8_FINAL : public LChunkBuilderBase {
2740 LChunkBuilder(CompilationInfo* info, HGraph* graph, LAllocator* allocator)
2741 : LChunkBuilderBase(graph->zone()),
2746 current_instruction_(NULL),
2747 current_block_(NULL),
2749 allocator_(allocator) { }
2751 Isolate* isolate() const { return graph_->isolate(); }
2753 // Build the sequence for the graph.
2754 LPlatformChunk* Build();
2756 // Declare methods that deal with the individual node types.
2757 #define DECLARE_DO(type) LInstruction* Do##type(H##type* node);
2758 HYDROGEN_CONCRETE_INSTRUCTION_LIST(DECLARE_DO)
2761 LInstruction* DoMultiplyAdd(HMul* mul, HValue* addend);
2762 LInstruction* DoMultiplySub(HValue* minuend, HMul* mul);
2763 LInstruction* DoRSub(HSub* instr);
2765 static bool HasMagicNumberForDivisor(int32_t divisor);
2767 LInstruction* DoMathFloor(HUnaryMathOperation* instr);
2768 LInstruction* DoMathRound(HUnaryMathOperation* instr);
2769 LInstruction* DoMathFround(HUnaryMathOperation* instr);
2770 LInstruction* DoMathAbs(HUnaryMathOperation* instr);
2771 LInstruction* DoMathLog(HUnaryMathOperation* instr);
2772 LInstruction* DoMathExp(HUnaryMathOperation* instr);
2773 LInstruction* DoMathSqrt(HUnaryMathOperation* instr);
2774 LInstruction* DoMathPowHalf(HUnaryMathOperation* instr);
2775 LInstruction* DoMathClz32(HUnaryMathOperation* instr);
2776 LInstruction* DoDivByPowerOf2I(HDiv* instr);
2777 LInstruction* DoDivByConstI(HDiv* instr);
2778 LInstruction* DoDivI(HDiv* instr);
2779 LInstruction* DoModByPowerOf2I(HMod* instr);
2780 LInstruction* DoModByConstI(HMod* instr);
2781 LInstruction* DoModI(HMod* instr);
2782 LInstruction* DoFlooringDivByPowerOf2I(HMathFloorOfDiv* instr);
2783 LInstruction* DoFlooringDivByConstI(HMathFloorOfDiv* instr);
2784 LInstruction* DoFlooringDivI(HMathFloorOfDiv* instr);
2794 LPlatformChunk* chunk() const { return chunk_; }
2795 CompilationInfo* info() const { return info_; }
2796 HGraph* graph() const { return graph_; }
2798 bool is_unused() const { return status_ == UNUSED; }
2799 bool is_building() const { return status_ == BUILDING; }
2800 bool is_done() const { return status_ == DONE; }
2801 bool is_aborted() const { return status_ == ABORTED; }
2803 void Abort(BailoutReason reason);
2805 // Methods for getting operands for Use / Define / Temp.
2806 LUnallocated* ToUnallocated(Register reg);
2807 LUnallocated* ToUnallocated(DoubleRegister reg);
2809 // Methods for setting up define-use relationships.
2810 MUST_USE_RESULT LOperand* Use(HValue* value, LUnallocated* operand);
2811 MUST_USE_RESULT LOperand* UseFixed(HValue* value, Register fixed_register);
2812 MUST_USE_RESULT LOperand* UseFixedDouble(HValue* value,
2813 DoubleRegister fixed_register);
2815 // A value that is guaranteed to be allocated to a register.
2816 // Operand created by UseRegister is guaranteed to be live until the end of
2817 // instruction. This means that register allocator will not reuse it's
2818 // register for any other operand inside instruction.
2819 // Operand created by UseRegisterAtStart is guaranteed to be live only at
2820 // instruction start. Register allocator is free to assign the same register
2821 // to some other operand used inside instruction (i.e. temporary or
2823 MUST_USE_RESULT LOperand* UseRegister(HValue* value);
2824 MUST_USE_RESULT LOperand* UseRegisterAtStart(HValue* value);
2826 // An input operand in a register that may be trashed.
2827 MUST_USE_RESULT LOperand* UseTempRegister(HValue* value);
2829 // An input operand in a register or stack slot.
2830 MUST_USE_RESULT LOperand* Use(HValue* value);
2831 MUST_USE_RESULT LOperand* UseAtStart(HValue* value);
2833 // An input operand in a register, stack slot or a constant operand.
2834 MUST_USE_RESULT LOperand* UseOrConstant(HValue* value);
2835 MUST_USE_RESULT LOperand* UseOrConstantAtStart(HValue* value);
2837 // An input operand in a register or a constant operand.
2838 MUST_USE_RESULT LOperand* UseRegisterOrConstant(HValue* value);
2839 MUST_USE_RESULT LOperand* UseRegisterOrConstantAtStart(HValue* value);
2841 // An input operand in a constant operand.
2842 MUST_USE_RESULT LOperand* UseConstant(HValue* value);
2844 // An input operand in register, stack slot or a constant operand.
2845 // Will not be moved to a register even if one is freely available.
2846 virtual MUST_USE_RESULT LOperand* UseAny(HValue* value) V8_OVERRIDE;
2848 // Temporary operand that must be in a register.
2849 MUST_USE_RESULT LUnallocated* TempRegister();
2850 MUST_USE_RESULT LUnallocated* TempDoubleRegister();
2851 MUST_USE_RESULT LOperand* FixedTemp(Register reg);
2852 MUST_USE_RESULT LOperand* FixedTemp(DoubleRegister reg);
2854 // Methods for setting up define-use relationships.
2855 // Return the same instruction that they are passed.
2856 LInstruction* Define(LTemplateResultInstruction<1>* instr,
2857 LUnallocated* result);
2858 LInstruction* DefineAsRegister(LTemplateResultInstruction<1>* instr);
2859 LInstruction* DefineAsSpilled(LTemplateResultInstruction<1>* instr,
2861 LInstruction* DefineSameAsFirst(LTemplateResultInstruction<1>* instr);
2862 LInstruction* DefineFixed(LTemplateResultInstruction<1>* instr,
2864 LInstruction* DefineFixedDouble(LTemplateResultInstruction<1>* instr,
2865 DoubleRegister reg);
2866 LInstruction* AssignEnvironment(LInstruction* instr);
2867 LInstruction* AssignPointerMap(LInstruction* instr);
2869 enum CanDeoptimize { CAN_DEOPTIMIZE_EAGERLY, CANNOT_DEOPTIMIZE_EAGERLY };
2871 // By default we assume that instruction sequences generated for calls
2872 // cannot deoptimize eagerly and we do not attach environment to this
2874 LInstruction* MarkAsCall(
2875 LInstruction* instr,
2876 HInstruction* hinstr,
2877 CanDeoptimize can_deoptimize = CANNOT_DEOPTIMIZE_EAGERLY);
2879 void VisitInstruction(HInstruction* current);
2880 void AddInstruction(LInstruction* instr, HInstruction* current);
2882 void DoBasicBlock(HBasicBlock* block, HBasicBlock* next_block);
2883 LInstruction* DoShift(Token::Value op, HBitwiseBinaryOperation* instr);
2884 LInstruction* DoArithmeticD(Token::Value op,
2885 HArithmeticBinaryOperation* instr);
2886 LInstruction* DoArithmeticT(Token::Value op,
2887 HBinaryOperation* instr);
2889 LPlatformChunk* chunk_;
2890 CompilationInfo* info_;
2891 HGraph* const graph_;
2893 HInstruction* current_instruction_;
2894 HBasicBlock* current_block_;
2895 HBasicBlock* next_block_;
2896 LAllocator* allocator_;
2898 DISALLOW_COPY_AND_ASSIGN(LChunkBuilder);
2901 #undef DECLARE_HYDROGEN_ACCESSOR
2902 #undef DECLARE_CONCRETE_INSTRUCTION
2904 } } // namespace v8::internal
2906 #endif // V8_ARM_LITHIUM_ARM_H_