1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are
6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided
11 // with the distribution.
12 // * Neither the name of Google Inc. nor the names of its
13 // contributors may be used to endorse or promote products derived
14 // from this software without specific prior written permission.
16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 #ifndef V8_ARM_LITHIUM_ARM_H_
29 #define V8_ARM_LITHIUM_ARM_H_
32 #include "lithium-allocator.h"
34 #include "safepoint-table.h"
40 // Forward declarations.
43 #define LITHIUM_CONCRETE_INSTRUCTION_LIST(V) \
44 V(AccessArgumentsAt) \
48 V(ArgumentsElements) \
56 V(CallWithDescriptor) \
62 V(CheckInstanceType) \
71 V(ClassOfTestAndBranch) \
72 V(CompareMinusZeroAndBranch) \
73 V(CompareNumericAndBranch) \
74 V(CmpObjectEqAndBranch) \
98 V(FlooringDivByConstI) \
99 V(FlooringDivByPowerOf2I) \
103 V(GetCachedArrayIndex) \
105 V(HasCachedArrayIndexAndBranch) \
106 V(HasInstanceTypeAndBranch) \
107 V(InnerAllocatedObject) \
109 V(InstanceOfKnownGlobal) \
111 V(Integer32ToDouble) \
113 V(IsConstructCallAndBranch) \
114 V(IsObjectAndBranch) \
115 V(IsStringAndBranch) \
117 V(IsUndetectableAndBranch) \
122 V(LoadFieldByIndex) \
123 V(LoadFunctionPrototype) \
125 V(LoadGlobalGeneric) \
127 V(LoadKeyedGeneric) \
129 V(LoadNamedGeneric) \
156 V(SeqStringGetChar) \
157 V(SeqStringSetChar) \
163 V(StoreContextSlot) \
166 V(StoreKeyedGeneric) \
168 V(StoreNamedGeneric) \
170 V(StringCharCodeAt) \
171 V(StringCharFromCode) \
172 V(StringCompareAndBranch) \
177 V(ToFastProperties) \
178 V(TransitionElementsKind) \
179 V(TrapAllocationMemento) \
181 V(TypeofIsAndBranch) \
187 #define DECLARE_CONCRETE_INSTRUCTION(type, mnemonic) \
188 virtual Opcode opcode() const V8_FINAL V8_OVERRIDE { \
189 return LInstruction::k##type; \
191 virtual void CompileToNative(LCodeGen* generator) V8_FINAL V8_OVERRIDE; \
192 virtual const char* Mnemonic() const V8_FINAL V8_OVERRIDE { \
195 static L##type* cast(LInstruction* instr) { \
196 ASSERT(instr->Is##type()); \
197 return reinterpret_cast<L##type*>(instr); \
201 #define DECLARE_HYDROGEN_ACCESSOR(type) \
202 H##type* hydrogen() const { \
203 return H##type::cast(hydrogen_value()); \
207 class LInstruction : public ZoneObject {
210 : environment_(NULL),
211 hydrogen_value_(NULL),
212 bit_field_(IsCallBits::encode(false)) {
215 virtual ~LInstruction() {}
217 virtual void CompileToNative(LCodeGen* generator) = 0;
218 virtual const char* Mnemonic() const = 0;
219 virtual void PrintTo(StringStream* stream);
220 virtual void PrintDataTo(StringStream* stream);
221 virtual void PrintOutputOperandTo(StringStream* stream);
224 // Declare a unique enum value for each instruction.
225 #define DECLARE_OPCODE(type) k##type,
226 LITHIUM_CONCRETE_INSTRUCTION_LIST(DECLARE_OPCODE)
227 kNumberOfInstructions
228 #undef DECLARE_OPCODE
231 virtual Opcode opcode() const = 0;
233 // Declare non-virtual type testers for all leaf IR classes.
234 #define DECLARE_PREDICATE(type) \
235 bool Is##type() const { return opcode() == k##type; }
236 LITHIUM_CONCRETE_INSTRUCTION_LIST(DECLARE_PREDICATE)
237 #undef DECLARE_PREDICATE
239 // Declare virtual predicates for instructions that don't have
241 virtual bool IsGap() const { return false; }
243 virtual bool IsControl() const { return false; }
245 void set_environment(LEnvironment* env) { environment_ = env; }
246 LEnvironment* environment() const { return environment_; }
247 bool HasEnvironment() const { return environment_ != NULL; }
249 void set_pointer_map(LPointerMap* p) { pointer_map_.set(p); }
250 LPointerMap* pointer_map() const { return pointer_map_.get(); }
251 bool HasPointerMap() const { return pointer_map_.is_set(); }
253 void set_hydrogen_value(HValue* value) { hydrogen_value_ = value; }
254 HValue* hydrogen_value() const { return hydrogen_value_; }
256 virtual void SetDeferredLazyDeoptimizationEnvironment(LEnvironment* env) { }
258 void MarkAsCall() { bit_field_ = IsCallBits::update(bit_field_, true); }
259 bool IsCall() const { return IsCallBits::decode(bit_field_); }
261 // Interface to the register allocator and iterators.
262 bool ClobbersTemps() const { return IsCall(); }
263 bool ClobbersRegisters() const { return IsCall(); }
264 virtual bool ClobbersDoubleRegisters() const { return IsCall(); }
266 // Interface to the register allocator and iterators.
267 bool IsMarkedAsCall() const { return IsCall(); }
269 virtual bool HasResult() const = 0;
270 virtual LOperand* result() const = 0;
272 LOperand* FirstInput() { return InputAt(0); }
273 LOperand* Output() { return HasResult() ? result() : NULL; }
275 virtual bool HasInterestingComment(LCodeGen* gen) const { return true; }
283 friend class InputIterator;
284 virtual int InputCount() = 0;
285 virtual LOperand* InputAt(int i) = 0;
287 friend class TempIterator;
288 virtual int TempCount() = 0;
289 virtual LOperand* TempAt(int i) = 0;
291 class IsCallBits: public BitField<bool, 0, 1> {};
293 LEnvironment* environment_;
294 SetOncePointer<LPointerMap> pointer_map_;
295 HValue* hydrogen_value_;
300 // R = number of result operands (0 or 1).
302 class LTemplateResultInstruction : public LInstruction {
304 // Allow 0 or 1 output operands.
305 STATIC_ASSERT(R == 0 || R == 1);
306 virtual bool HasResult() const V8_FINAL V8_OVERRIDE {
307 return R != 0 && result() != NULL;
309 void set_result(LOperand* operand) { results_[0] = operand; }
310 LOperand* result() const { return results_[0]; }
313 EmbeddedContainer<LOperand*, R> results_;
317 // R = number of result operands (0 or 1).
318 // I = number of input operands.
319 // T = number of temporary operands.
320 template<int R, int I, int T>
321 class LTemplateInstruction : public LTemplateResultInstruction<R> {
323 EmbeddedContainer<LOperand*, I> inputs_;
324 EmbeddedContainer<LOperand*, T> temps_;
328 virtual int InputCount() V8_FINAL V8_OVERRIDE { return I; }
329 virtual LOperand* InputAt(int i) V8_FINAL V8_OVERRIDE { return inputs_[i]; }
331 virtual int TempCount() V8_FINAL V8_OVERRIDE { return T; }
332 virtual LOperand* TempAt(int i) V8_FINAL V8_OVERRIDE { return temps_[i]; }
336 class LGap : public LTemplateInstruction<0, 0, 0> {
338 explicit LGap(HBasicBlock* block)
340 parallel_moves_[BEFORE] = NULL;
341 parallel_moves_[START] = NULL;
342 parallel_moves_[END] = NULL;
343 parallel_moves_[AFTER] = NULL;
346 // Can't use the DECLARE-macro here because of sub-classes.
347 virtual bool IsGap() const V8_OVERRIDE { return true; }
348 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
349 static LGap* cast(LInstruction* instr) {
350 ASSERT(instr->IsGap());
351 return reinterpret_cast<LGap*>(instr);
354 bool IsRedundant() const;
356 HBasicBlock* block() const { return block_; }
363 FIRST_INNER_POSITION = BEFORE,
364 LAST_INNER_POSITION = AFTER
367 LParallelMove* GetOrCreateParallelMove(InnerPosition pos, Zone* zone) {
368 if (parallel_moves_[pos] == NULL) {
369 parallel_moves_[pos] = new(zone) LParallelMove(zone);
371 return parallel_moves_[pos];
374 LParallelMove* GetParallelMove(InnerPosition pos) {
375 return parallel_moves_[pos];
379 LParallelMove* parallel_moves_[LAST_INNER_POSITION + 1];
384 class LInstructionGap V8_FINAL : public LGap {
386 explicit LInstructionGap(HBasicBlock* block) : LGap(block) { }
388 virtual bool HasInterestingComment(LCodeGen* gen) const V8_OVERRIDE {
389 return !IsRedundant();
392 DECLARE_CONCRETE_INSTRUCTION(InstructionGap, "gap")
396 class LGoto V8_FINAL : public LTemplateInstruction<0, 0, 0> {
398 explicit LGoto(HBasicBlock* block) : block_(block) { }
400 virtual bool HasInterestingComment(LCodeGen* gen) const V8_OVERRIDE;
401 DECLARE_CONCRETE_INSTRUCTION(Goto, "goto")
402 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
403 virtual bool IsControl() const V8_OVERRIDE { return true; }
405 int block_id() const { return block_->block_id(); }
412 class LLazyBailout V8_FINAL : public LTemplateInstruction<0, 0, 0> {
414 LLazyBailout() : gap_instructions_size_(0) { }
416 DECLARE_CONCRETE_INSTRUCTION(LazyBailout, "lazy-bailout")
418 void set_gap_instructions_size(int gap_instructions_size) {
419 gap_instructions_size_ = gap_instructions_size;
421 int gap_instructions_size() { return gap_instructions_size_; }
424 int gap_instructions_size_;
428 class LDummy V8_FINAL : public LTemplateInstruction<1, 0, 0> {
430 explicit LDummy() { }
431 DECLARE_CONCRETE_INSTRUCTION(Dummy, "dummy")
435 class LDummyUse V8_FINAL : public LTemplateInstruction<1, 1, 0> {
437 explicit LDummyUse(LOperand* value) {
440 DECLARE_CONCRETE_INSTRUCTION(DummyUse, "dummy-use")
444 class LDeoptimize V8_FINAL : public LTemplateInstruction<0, 0, 0> {
446 DECLARE_CONCRETE_INSTRUCTION(Deoptimize, "deoptimize")
447 DECLARE_HYDROGEN_ACCESSOR(Deoptimize)
451 class LLabel V8_FINAL : public LGap {
453 explicit LLabel(HBasicBlock* block)
454 : LGap(block), replacement_(NULL) { }
456 virtual bool HasInterestingComment(LCodeGen* gen) const V8_OVERRIDE {
459 DECLARE_CONCRETE_INSTRUCTION(Label, "label")
461 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
463 int block_id() const { return block()->block_id(); }
464 bool is_loop_header() const { return block()->IsLoopHeader(); }
465 bool is_osr_entry() const { return block()->is_osr_entry(); }
466 Label* label() { return &label_; }
467 LLabel* replacement() const { return replacement_; }
468 void set_replacement(LLabel* label) { replacement_ = label; }
469 bool HasReplacement() const { return replacement_ != NULL; }
473 LLabel* replacement_;
477 class LParameter V8_FINAL : public LTemplateInstruction<1, 0, 0> {
479 virtual bool HasInterestingComment(LCodeGen* gen) const { return false; }
480 DECLARE_CONCRETE_INSTRUCTION(Parameter, "parameter")
484 class LCallStub V8_FINAL : public LTemplateInstruction<1, 1, 0> {
486 explicit LCallStub(LOperand* context) {
487 inputs_[0] = context;
490 LOperand* context() { return inputs_[0]; }
492 DECLARE_CONCRETE_INSTRUCTION(CallStub, "call-stub")
493 DECLARE_HYDROGEN_ACCESSOR(CallStub)
497 class LUnknownOSRValue V8_FINAL : public LTemplateInstruction<1, 0, 0> {
499 virtual bool HasInterestingComment(LCodeGen* gen) const V8_OVERRIDE {
502 DECLARE_CONCRETE_INSTRUCTION(UnknownOSRValue, "unknown-osr-value")
506 template<int I, int T>
507 class LControlInstruction : public LTemplateInstruction<0, I, T> {
509 LControlInstruction() : false_label_(NULL), true_label_(NULL) { }
511 virtual bool IsControl() const V8_FINAL V8_OVERRIDE { return true; }
513 int SuccessorCount() { return hydrogen()->SuccessorCount(); }
514 HBasicBlock* SuccessorAt(int i) { return hydrogen()->SuccessorAt(i); }
516 int TrueDestination(LChunk* chunk) {
517 return chunk->LookupDestination(true_block_id());
519 int FalseDestination(LChunk* chunk) {
520 return chunk->LookupDestination(false_block_id());
523 Label* TrueLabel(LChunk* chunk) {
524 if (true_label_ == NULL) {
525 true_label_ = chunk->GetAssemblyLabel(TrueDestination(chunk));
529 Label* FalseLabel(LChunk* chunk) {
530 if (false_label_ == NULL) {
531 false_label_ = chunk->GetAssemblyLabel(FalseDestination(chunk));
537 int true_block_id() { return SuccessorAt(0)->block_id(); }
538 int false_block_id() { return SuccessorAt(1)->block_id(); }
541 HControlInstruction* hydrogen() {
542 return HControlInstruction::cast(this->hydrogen_value());
550 class LWrapReceiver V8_FINAL : public LTemplateInstruction<1, 2, 0> {
552 LWrapReceiver(LOperand* receiver, LOperand* function) {
553 inputs_[0] = receiver;
554 inputs_[1] = function;
557 DECLARE_CONCRETE_INSTRUCTION(WrapReceiver, "wrap-receiver")
558 DECLARE_HYDROGEN_ACCESSOR(WrapReceiver)
560 LOperand* receiver() { return inputs_[0]; }
561 LOperand* function() { return inputs_[1]; }
565 class LApplyArguments V8_FINAL : public LTemplateInstruction<1, 4, 0> {
567 LApplyArguments(LOperand* function,
570 LOperand* elements) {
571 inputs_[0] = function;
572 inputs_[1] = receiver;
574 inputs_[3] = elements;
577 DECLARE_CONCRETE_INSTRUCTION(ApplyArguments, "apply-arguments")
579 LOperand* function() { return inputs_[0]; }
580 LOperand* receiver() { return inputs_[1]; }
581 LOperand* length() { return inputs_[2]; }
582 LOperand* elements() { return inputs_[3]; }
586 class LAccessArgumentsAt V8_FINAL : public LTemplateInstruction<1, 3, 0> {
588 LAccessArgumentsAt(LOperand* arguments, LOperand* length, LOperand* index) {
589 inputs_[0] = arguments;
594 DECLARE_CONCRETE_INSTRUCTION(AccessArgumentsAt, "access-arguments-at")
596 LOperand* arguments() { return inputs_[0]; }
597 LOperand* length() { return inputs_[1]; }
598 LOperand* index() { return inputs_[2]; }
600 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
604 class LArgumentsLength V8_FINAL : public LTemplateInstruction<1, 1, 0> {
606 explicit LArgumentsLength(LOperand* elements) {
607 inputs_[0] = elements;
610 LOperand* elements() { return inputs_[0]; }
612 DECLARE_CONCRETE_INSTRUCTION(ArgumentsLength, "arguments-length")
616 class LArgumentsElements V8_FINAL : public LTemplateInstruction<1, 0, 0> {
618 DECLARE_CONCRETE_INSTRUCTION(ArgumentsElements, "arguments-elements")
619 DECLARE_HYDROGEN_ACCESSOR(ArgumentsElements)
623 class LModByPowerOf2I V8_FINAL : public LTemplateInstruction<1, 1, 0> {
625 LModByPowerOf2I(LOperand* dividend, int32_t divisor) {
626 inputs_[0] = dividend;
630 LOperand* dividend() { return inputs_[0]; }
631 int32_t divisor() const { return divisor_; }
633 DECLARE_CONCRETE_INSTRUCTION(ModByPowerOf2I, "mod-by-power-of-2-i")
634 DECLARE_HYDROGEN_ACCESSOR(Mod)
641 class LModByConstI V8_FINAL : public LTemplateInstruction<1, 1, 0> {
643 LModByConstI(LOperand* dividend, int32_t divisor) {
644 inputs_[0] = dividend;
648 LOperand* dividend() { return inputs_[0]; }
649 int32_t divisor() const { return divisor_; }
651 DECLARE_CONCRETE_INSTRUCTION(ModByConstI, "mod-by-const-i")
652 DECLARE_HYDROGEN_ACCESSOR(Mod)
659 class LModI V8_FINAL : public LTemplateInstruction<1, 2, 2> {
661 LModI(LOperand* left, LOperand* right, LOperand* temp, LOperand* temp2) {
668 LOperand* left() { return inputs_[0]; }
669 LOperand* right() { return inputs_[1]; }
670 LOperand* temp() { return temps_[0]; }
671 LOperand* temp2() { return temps_[1]; }
673 DECLARE_CONCRETE_INSTRUCTION(ModI, "mod-i")
674 DECLARE_HYDROGEN_ACCESSOR(Mod)
678 class LDivByPowerOf2I V8_FINAL : public LTemplateInstruction<1, 1, 0> {
680 LDivByPowerOf2I(LOperand* dividend, int32_t divisor) {
681 inputs_[0] = dividend;
685 LOperand* dividend() { return inputs_[0]; }
686 int32_t divisor() const { return divisor_; }
688 DECLARE_CONCRETE_INSTRUCTION(DivByPowerOf2I, "div-by-power-of-2-i")
689 DECLARE_HYDROGEN_ACCESSOR(Div)
696 class LDivByConstI V8_FINAL : public LTemplateInstruction<1, 1, 0> {
698 LDivByConstI(LOperand* dividend, int32_t divisor) {
699 inputs_[0] = dividend;
703 LOperand* dividend() { return inputs_[0]; }
704 int32_t divisor() const { return divisor_; }
706 DECLARE_CONCRETE_INSTRUCTION(DivByConstI, "div-by-const-i")
707 DECLARE_HYDROGEN_ACCESSOR(Div)
714 class LDivI V8_FINAL : public LTemplateInstruction<1, 2, 1> {
716 LDivI(LOperand* left, LOperand* right, LOperand* temp) {
722 LOperand* left() { return inputs_[0]; }
723 LOperand* right() { return inputs_[1]; }
724 LOperand* temp() { return temps_[0]; }
726 DECLARE_CONCRETE_INSTRUCTION(DivI, "div-i")
727 DECLARE_HYDROGEN_ACCESSOR(BinaryOperation)
731 class LFlooringDivByPowerOf2I V8_FINAL : public LTemplateInstruction<1, 1, 0> {
733 LFlooringDivByPowerOf2I(LOperand* dividend, int32_t divisor) {
734 inputs_[0] = dividend;
738 LOperand* dividend() { return inputs_[0]; }
739 int32_t divisor() { return divisor_; }
741 DECLARE_CONCRETE_INSTRUCTION(FlooringDivByPowerOf2I,
742 "flooring-div-by-power-of-2-i")
743 DECLARE_HYDROGEN_ACCESSOR(MathFloorOfDiv)
750 class LFlooringDivByConstI V8_FINAL : public LTemplateInstruction<1, 1, 2> {
752 LFlooringDivByConstI(LOperand* dividend, int32_t divisor, LOperand* temp) {
753 inputs_[0] = dividend;
758 LOperand* dividend() { return inputs_[0]; }
759 int32_t divisor() const { return divisor_; }
760 LOperand* temp() { return temps_[0]; }
762 DECLARE_CONCRETE_INSTRUCTION(FlooringDivByConstI, "flooring-div-by-const-i")
763 DECLARE_HYDROGEN_ACCESSOR(MathFloorOfDiv)
770 class LMulI V8_FINAL : public LTemplateInstruction<1, 2, 0> {
772 LMulI(LOperand* left, LOperand* right) {
777 LOperand* left() { return inputs_[0]; }
778 LOperand* right() { return inputs_[1]; }
780 DECLARE_CONCRETE_INSTRUCTION(MulI, "mul-i")
781 DECLARE_HYDROGEN_ACCESSOR(Mul)
785 // Instruction for computing multiplier * multiplicand + addend.
786 class LMultiplyAddD V8_FINAL : public LTemplateInstruction<1, 3, 0> {
788 LMultiplyAddD(LOperand* addend, LOperand* multiplier,
789 LOperand* multiplicand) {
791 inputs_[1] = multiplier;
792 inputs_[2] = multiplicand;
795 LOperand* addend() { return inputs_[0]; }
796 LOperand* multiplier() { return inputs_[1]; }
797 LOperand* multiplicand() { return inputs_[2]; }
799 DECLARE_CONCRETE_INSTRUCTION(MultiplyAddD, "multiply-add-d")
803 // Instruction for computing minuend - multiplier * multiplicand.
804 class LMultiplySubD V8_FINAL : public LTemplateInstruction<1, 3, 0> {
806 LMultiplySubD(LOperand* minuend, LOperand* multiplier,
807 LOperand* multiplicand) {
808 inputs_[0] = minuend;
809 inputs_[1] = multiplier;
810 inputs_[2] = multiplicand;
813 LOperand* minuend() { return inputs_[0]; }
814 LOperand* multiplier() { return inputs_[1]; }
815 LOperand* multiplicand() { return inputs_[2]; }
817 DECLARE_CONCRETE_INSTRUCTION(MultiplySubD, "multiply-sub-d")
821 class LDebugBreak V8_FINAL : public LTemplateInstruction<0, 0, 0> {
823 DECLARE_CONCRETE_INSTRUCTION(DebugBreak, "break")
827 class LCompareNumericAndBranch V8_FINAL : public LControlInstruction<2, 0> {
829 LCompareNumericAndBranch(LOperand* left, LOperand* right) {
834 LOperand* left() { return inputs_[0]; }
835 LOperand* right() { return inputs_[1]; }
837 DECLARE_CONCRETE_INSTRUCTION(CompareNumericAndBranch,
838 "compare-numeric-and-branch")
839 DECLARE_HYDROGEN_ACCESSOR(CompareNumericAndBranch)
841 Token::Value op() const { return hydrogen()->token(); }
842 bool is_double() const {
843 return hydrogen()->representation().IsDouble();
846 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
850 class LMathFloor V8_FINAL : public LTemplateInstruction<1, 1, 0> {
852 explicit LMathFloor(LOperand* value) {
856 LOperand* value() { return inputs_[0]; }
858 DECLARE_CONCRETE_INSTRUCTION(MathFloor, "math-floor")
859 DECLARE_HYDROGEN_ACCESSOR(UnaryMathOperation)
863 class LMathRound V8_FINAL : public LTemplateInstruction<1, 1, 1> {
865 LMathRound(LOperand* value, LOperand* temp) {
870 LOperand* value() { return inputs_[0]; }
871 LOperand* temp() { return temps_[0]; }
873 DECLARE_CONCRETE_INSTRUCTION(MathRound, "math-round")
874 DECLARE_HYDROGEN_ACCESSOR(UnaryMathOperation)
878 class LMathAbs V8_FINAL : public LTemplateInstruction<1, 2, 0> {
880 LMathAbs(LOperand* context, LOperand* value) {
881 inputs_[1] = context;
885 LOperand* context() { return inputs_[1]; }
886 LOperand* value() { return inputs_[0]; }
888 DECLARE_CONCRETE_INSTRUCTION(MathAbs, "math-abs")
889 DECLARE_HYDROGEN_ACCESSOR(UnaryMathOperation)
893 class LMathLog V8_FINAL : public LTemplateInstruction<1, 1, 0> {
895 explicit LMathLog(LOperand* value) {
899 LOperand* value() { return inputs_[0]; }
901 DECLARE_CONCRETE_INSTRUCTION(MathLog, "math-log")
905 class LMathClz32 V8_FINAL : public LTemplateInstruction<1, 1, 0> {
907 explicit LMathClz32(LOperand* value) {
911 LOperand* value() { return inputs_[0]; }
913 DECLARE_CONCRETE_INSTRUCTION(MathClz32, "math-clz32")
917 class LMathExp V8_FINAL : public LTemplateInstruction<1, 1, 3> {
919 LMathExp(LOperand* value,
920 LOperand* double_temp,
926 temps_[2] = double_temp;
927 ExternalReference::InitializeMathExpData();
930 LOperand* value() { return inputs_[0]; }
931 LOperand* temp1() { return temps_[0]; }
932 LOperand* temp2() { return temps_[1]; }
933 LOperand* double_temp() { return temps_[2]; }
935 DECLARE_CONCRETE_INSTRUCTION(MathExp, "math-exp")
939 class LMathSqrt V8_FINAL : public LTemplateInstruction<1, 1, 0> {
941 explicit LMathSqrt(LOperand* value) {
945 LOperand* value() { return inputs_[0]; }
947 DECLARE_CONCRETE_INSTRUCTION(MathSqrt, "math-sqrt")
951 class LMathPowHalf V8_FINAL : public LTemplateInstruction<1, 1, 0> {
953 explicit LMathPowHalf(LOperand* value) {
957 LOperand* value() { return inputs_[0]; }
959 DECLARE_CONCRETE_INSTRUCTION(MathPowHalf, "math-pow-half")
963 class LCmpObjectEqAndBranch V8_FINAL : public LControlInstruction<2, 0> {
965 LCmpObjectEqAndBranch(LOperand* left, LOperand* right) {
970 LOperand* left() { return inputs_[0]; }
971 LOperand* right() { return inputs_[1]; }
973 DECLARE_CONCRETE_INSTRUCTION(CmpObjectEqAndBranch, "cmp-object-eq-and-branch")
974 DECLARE_HYDROGEN_ACCESSOR(CompareObjectEqAndBranch)
978 class LCmpHoleAndBranch V8_FINAL : public LControlInstruction<1, 0> {
980 explicit LCmpHoleAndBranch(LOperand* object) {
984 LOperand* object() { return inputs_[0]; }
986 DECLARE_CONCRETE_INSTRUCTION(CmpHoleAndBranch, "cmp-hole-and-branch")
987 DECLARE_HYDROGEN_ACCESSOR(CompareHoleAndBranch)
991 class LCompareMinusZeroAndBranch V8_FINAL : public LControlInstruction<1, 1> {
993 LCompareMinusZeroAndBranch(LOperand* value, LOperand* temp) {
998 LOperand* value() { return inputs_[0]; }
999 LOperand* temp() { return temps_[0]; }
1001 DECLARE_CONCRETE_INSTRUCTION(CompareMinusZeroAndBranch,
1002 "cmp-minus-zero-and-branch")
1003 DECLARE_HYDROGEN_ACCESSOR(CompareMinusZeroAndBranch)
1007 class LIsObjectAndBranch V8_FINAL : public LControlInstruction<1, 1> {
1009 LIsObjectAndBranch(LOperand* value, LOperand* temp) {
1014 LOperand* value() { return inputs_[0]; }
1015 LOperand* temp() { return temps_[0]; }
1017 DECLARE_CONCRETE_INSTRUCTION(IsObjectAndBranch, "is-object-and-branch")
1018 DECLARE_HYDROGEN_ACCESSOR(IsObjectAndBranch)
1020 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1024 class LIsStringAndBranch V8_FINAL : public LControlInstruction<1, 1> {
1026 LIsStringAndBranch(LOperand* value, LOperand* temp) {
1031 LOperand* value() { return inputs_[0]; }
1032 LOperand* temp() { return temps_[0]; }
1034 DECLARE_CONCRETE_INSTRUCTION(IsStringAndBranch, "is-string-and-branch")
1035 DECLARE_HYDROGEN_ACCESSOR(IsStringAndBranch)
1037 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1041 class LIsSmiAndBranch V8_FINAL : public LControlInstruction<1, 0> {
1043 explicit LIsSmiAndBranch(LOperand* value) {
1047 LOperand* value() { return inputs_[0]; }
1049 DECLARE_CONCRETE_INSTRUCTION(IsSmiAndBranch, "is-smi-and-branch")
1050 DECLARE_HYDROGEN_ACCESSOR(IsSmiAndBranch)
1052 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1056 class LIsUndetectableAndBranch V8_FINAL : public LControlInstruction<1, 1> {
1058 explicit LIsUndetectableAndBranch(LOperand* value, LOperand* temp) {
1063 LOperand* value() { return inputs_[0]; }
1064 LOperand* temp() { return temps_[0]; }
1066 DECLARE_CONCRETE_INSTRUCTION(IsUndetectableAndBranch,
1067 "is-undetectable-and-branch")
1068 DECLARE_HYDROGEN_ACCESSOR(IsUndetectableAndBranch)
1070 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1074 class LStringCompareAndBranch V8_FINAL : public LControlInstruction<3, 0> {
1076 LStringCompareAndBranch(LOperand* context, LOperand* left, LOperand* right) {
1077 inputs_[0] = context;
1082 LOperand* context() { return inputs_[0]; }
1083 LOperand* left() { return inputs_[1]; }
1084 LOperand* right() { return inputs_[2]; }
1086 DECLARE_CONCRETE_INSTRUCTION(StringCompareAndBranch,
1087 "string-compare-and-branch")
1088 DECLARE_HYDROGEN_ACCESSOR(StringCompareAndBranch)
1090 Token::Value op() const { return hydrogen()->token(); }
1092 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1096 class LHasInstanceTypeAndBranch V8_FINAL : public LControlInstruction<1, 0> {
1098 explicit LHasInstanceTypeAndBranch(LOperand* value) {
1102 LOperand* value() { return inputs_[0]; }
1104 DECLARE_CONCRETE_INSTRUCTION(HasInstanceTypeAndBranch,
1105 "has-instance-type-and-branch")
1106 DECLARE_HYDROGEN_ACCESSOR(HasInstanceTypeAndBranch)
1108 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1112 class LGetCachedArrayIndex V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1114 explicit LGetCachedArrayIndex(LOperand* value) {
1118 LOperand* value() { return inputs_[0]; }
1120 DECLARE_CONCRETE_INSTRUCTION(GetCachedArrayIndex, "get-cached-array-index")
1121 DECLARE_HYDROGEN_ACCESSOR(GetCachedArrayIndex)
1125 class LHasCachedArrayIndexAndBranch V8_FINAL
1126 : public LControlInstruction<1, 0> {
1128 explicit LHasCachedArrayIndexAndBranch(LOperand* value) {
1132 LOperand* value() { return inputs_[0]; }
1134 DECLARE_CONCRETE_INSTRUCTION(HasCachedArrayIndexAndBranch,
1135 "has-cached-array-index-and-branch")
1136 DECLARE_HYDROGEN_ACCESSOR(HasCachedArrayIndexAndBranch)
1138 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1142 class LClassOfTestAndBranch V8_FINAL : public LControlInstruction<1, 1> {
1144 LClassOfTestAndBranch(LOperand* value, LOperand* temp) {
1149 LOperand* value() { return inputs_[0]; }
1150 LOperand* temp() { return temps_[0]; }
1152 DECLARE_CONCRETE_INSTRUCTION(ClassOfTestAndBranch,
1153 "class-of-test-and-branch")
1154 DECLARE_HYDROGEN_ACCESSOR(ClassOfTestAndBranch)
1156 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1160 class LCmpT V8_FINAL : public LTemplateInstruction<1, 3, 0> {
1162 LCmpT(LOperand* context, LOperand* left, LOperand* right) {
1163 inputs_[0] = context;
1168 LOperand* context() { return inputs_[0]; }
1169 LOperand* left() { return inputs_[1]; }
1170 LOperand* right() { return inputs_[2]; }
1172 DECLARE_CONCRETE_INSTRUCTION(CmpT, "cmp-t")
1173 DECLARE_HYDROGEN_ACCESSOR(CompareGeneric)
1175 Token::Value op() const { return hydrogen()->token(); }
1179 class LInstanceOf V8_FINAL : public LTemplateInstruction<1, 3, 0> {
1181 LInstanceOf(LOperand* context, LOperand* left, LOperand* right) {
1182 inputs_[0] = context;
1187 LOperand* context() { return inputs_[0]; }
1188 LOperand* left() { return inputs_[1]; }
1189 LOperand* right() { return inputs_[2]; }
1191 DECLARE_CONCRETE_INSTRUCTION(InstanceOf, "instance-of")
1195 class LInstanceOfKnownGlobal V8_FINAL : public LTemplateInstruction<1, 2, 1> {
1197 LInstanceOfKnownGlobal(LOperand* context, LOperand* value, LOperand* temp) {
1198 inputs_[0] = context;
1203 LOperand* context() { return inputs_[0]; }
1204 LOperand* value() { return inputs_[1]; }
1205 LOperand* temp() { return temps_[0]; }
1207 DECLARE_CONCRETE_INSTRUCTION(InstanceOfKnownGlobal,
1208 "instance-of-known-global")
1209 DECLARE_HYDROGEN_ACCESSOR(InstanceOfKnownGlobal)
1211 Handle<JSFunction> function() const { return hydrogen()->function(); }
1212 LEnvironment* GetDeferredLazyDeoptimizationEnvironment() {
1213 return lazy_deopt_env_;
1215 virtual void SetDeferredLazyDeoptimizationEnvironment(
1216 LEnvironment* env) V8_OVERRIDE {
1217 lazy_deopt_env_ = env;
1221 LEnvironment* lazy_deopt_env_;
1225 class LBoundsCheck V8_FINAL : public LTemplateInstruction<0, 2, 0> {
1227 LBoundsCheck(LOperand* index, LOperand* length) {
1229 inputs_[1] = length;
1232 LOperand* index() { return inputs_[0]; }
1233 LOperand* length() { return inputs_[1]; }
1235 DECLARE_CONCRETE_INSTRUCTION(BoundsCheck, "bounds-check")
1236 DECLARE_HYDROGEN_ACCESSOR(BoundsCheck)
1240 class LBitI V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1242 LBitI(LOperand* left, LOperand* right) {
1247 LOperand* left() { return inputs_[0]; }
1248 LOperand* right() { return inputs_[1]; }
1250 Token::Value op() const { return hydrogen()->op(); }
1252 DECLARE_CONCRETE_INSTRUCTION(BitI, "bit-i")
1253 DECLARE_HYDROGEN_ACCESSOR(Bitwise)
1257 class LShiftI V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1259 LShiftI(Token::Value op, LOperand* left, LOperand* right, bool can_deopt)
1260 : op_(op), can_deopt_(can_deopt) {
1265 Token::Value op() const { return op_; }
1266 LOperand* left() { return inputs_[0]; }
1267 LOperand* right() { return inputs_[1]; }
1268 bool can_deopt() const { return can_deopt_; }
1270 DECLARE_CONCRETE_INSTRUCTION(ShiftI, "shift-i")
1278 class LSubI V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1280 LSubI(LOperand* left, LOperand* right) {
1285 LOperand* left() { return inputs_[0]; }
1286 LOperand* right() { return inputs_[1]; }
1288 DECLARE_CONCRETE_INSTRUCTION(SubI, "sub-i")
1289 DECLARE_HYDROGEN_ACCESSOR(Sub)
1293 class LRSubI V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1295 LRSubI(LOperand* left, LOperand* right) {
1300 LOperand* left() { return inputs_[0]; }
1301 LOperand* right() { return inputs_[1]; }
1303 DECLARE_CONCRETE_INSTRUCTION(RSubI, "rsub-i")
1304 DECLARE_HYDROGEN_ACCESSOR(Sub)
1308 class LConstantI V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1310 DECLARE_CONCRETE_INSTRUCTION(ConstantI, "constant-i")
1311 DECLARE_HYDROGEN_ACCESSOR(Constant)
1313 int32_t value() const { return hydrogen()->Integer32Value(); }
1317 class LConstantS V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1319 DECLARE_CONCRETE_INSTRUCTION(ConstantS, "constant-s")
1320 DECLARE_HYDROGEN_ACCESSOR(Constant)
1322 Smi* value() const { return Smi::FromInt(hydrogen()->Integer32Value()); }
1326 class LConstantD V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1328 DECLARE_CONCRETE_INSTRUCTION(ConstantD, "constant-d")
1329 DECLARE_HYDROGEN_ACCESSOR(Constant)
1331 double value() const { return hydrogen()->DoubleValue(); }
1335 class LConstantE V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1337 DECLARE_CONCRETE_INSTRUCTION(ConstantE, "constant-e")
1338 DECLARE_HYDROGEN_ACCESSOR(Constant)
1340 ExternalReference value() const {
1341 return hydrogen()->ExternalReferenceValue();
1346 class LConstantT V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1348 DECLARE_CONCRETE_INSTRUCTION(ConstantT, "constant-t")
1349 DECLARE_HYDROGEN_ACCESSOR(Constant)
1351 Handle<Object> value(Isolate* isolate) const {
1352 return hydrogen()->handle(isolate);
1357 class LBranch V8_FINAL : public LControlInstruction<1, 0> {
1359 explicit LBranch(LOperand* value) {
1363 LOperand* value() { return inputs_[0]; }
1365 DECLARE_CONCRETE_INSTRUCTION(Branch, "branch")
1366 DECLARE_HYDROGEN_ACCESSOR(Branch)
1368 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1372 class LCmpMapAndBranch V8_FINAL : public LControlInstruction<1, 1> {
1374 LCmpMapAndBranch(LOperand* value, LOperand* temp) {
1379 LOperand* value() { return inputs_[0]; }
1380 LOperand* temp() { return temps_[0]; }
1382 DECLARE_CONCRETE_INSTRUCTION(CmpMapAndBranch, "cmp-map-and-branch")
1383 DECLARE_HYDROGEN_ACCESSOR(CompareMap)
1385 Handle<Map> map() const { return hydrogen()->map().handle(); }
1389 class LMapEnumLength V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1391 explicit LMapEnumLength(LOperand* value) {
1395 LOperand* value() { return inputs_[0]; }
1397 DECLARE_CONCRETE_INSTRUCTION(MapEnumLength, "map-enum-length")
1401 class LDateField V8_FINAL : public LTemplateInstruction<1, 1, 1> {
1403 LDateField(LOperand* date, LOperand* temp, Smi* index) : index_(index) {
1408 LOperand* date() { return inputs_[0]; }
1409 LOperand* temp() { return temps_[0]; }
1410 Smi* index() const { return index_; }
1412 DECLARE_CONCRETE_INSTRUCTION(DateField, "date-field")
1413 DECLARE_HYDROGEN_ACCESSOR(DateField)
1420 class LSeqStringGetChar V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1422 LSeqStringGetChar(LOperand* string, LOperand* index) {
1423 inputs_[0] = string;
1427 LOperand* string() const { return inputs_[0]; }
1428 LOperand* index() const { return inputs_[1]; }
1430 DECLARE_CONCRETE_INSTRUCTION(SeqStringGetChar, "seq-string-get-char")
1431 DECLARE_HYDROGEN_ACCESSOR(SeqStringGetChar)
1435 class LSeqStringSetChar V8_FINAL : public LTemplateInstruction<1, 4, 0> {
1437 LSeqStringSetChar(LOperand* context,
1441 inputs_[0] = context;
1442 inputs_[1] = string;
1447 LOperand* string() { return inputs_[1]; }
1448 LOperand* index() { return inputs_[2]; }
1449 LOperand* value() { return inputs_[3]; }
1451 DECLARE_CONCRETE_INSTRUCTION(SeqStringSetChar, "seq-string-set-char")
1452 DECLARE_HYDROGEN_ACCESSOR(SeqStringSetChar)
1456 class LAddI V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1458 LAddI(LOperand* left, LOperand* right) {
1463 LOperand* left() { return inputs_[0]; }
1464 LOperand* right() { return inputs_[1]; }
1466 DECLARE_CONCRETE_INSTRUCTION(AddI, "add-i")
1467 DECLARE_HYDROGEN_ACCESSOR(Add)
1471 class LMathMinMax V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1473 LMathMinMax(LOperand* left, LOperand* right) {
1478 LOperand* left() { return inputs_[0]; }
1479 LOperand* right() { return inputs_[1]; }
1481 DECLARE_CONCRETE_INSTRUCTION(MathMinMax, "math-min-max")
1482 DECLARE_HYDROGEN_ACCESSOR(MathMinMax)
1486 class LPower V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1488 LPower(LOperand* left, LOperand* right) {
1493 LOperand* left() { return inputs_[0]; }
1494 LOperand* right() { return inputs_[1]; }
1496 DECLARE_CONCRETE_INSTRUCTION(Power, "power")
1497 DECLARE_HYDROGEN_ACCESSOR(Power)
1501 class LArithmeticD V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1503 LArithmeticD(Token::Value op, LOperand* left, LOperand* right)
1509 Token::Value op() const { return op_; }
1510 LOperand* left() { return inputs_[0]; }
1511 LOperand* right() { return inputs_[1]; }
1513 virtual Opcode opcode() const V8_OVERRIDE {
1514 return LInstruction::kArithmeticD;
1516 virtual void CompileToNative(LCodeGen* generator) V8_OVERRIDE;
1517 virtual const char* Mnemonic() const V8_OVERRIDE;
1524 class LArithmeticT V8_FINAL : public LTemplateInstruction<1, 3, 0> {
1526 LArithmeticT(Token::Value op,
1531 inputs_[0] = context;
1536 LOperand* context() { return inputs_[0]; }
1537 LOperand* left() { return inputs_[1]; }
1538 LOperand* right() { return inputs_[2]; }
1539 Token::Value op() const { return op_; }
1541 virtual Opcode opcode() const V8_OVERRIDE {
1542 return LInstruction::kArithmeticT;
1544 virtual void CompileToNative(LCodeGen* generator) V8_OVERRIDE;
1545 virtual const char* Mnemonic() const V8_OVERRIDE;
1552 class LReturn V8_FINAL : public LTemplateInstruction<0, 3, 0> {
1554 LReturn(LOperand* value, LOperand* context, LOperand* parameter_count) {
1556 inputs_[1] = context;
1557 inputs_[2] = parameter_count;
1560 LOperand* value() { return inputs_[0]; }
1562 bool has_constant_parameter_count() {
1563 return parameter_count()->IsConstantOperand();
1565 LConstantOperand* constant_parameter_count() {
1566 ASSERT(has_constant_parameter_count());
1567 return LConstantOperand::cast(parameter_count());
1569 LOperand* parameter_count() { return inputs_[2]; }
1571 DECLARE_CONCRETE_INSTRUCTION(Return, "return")
1575 class LLoadNamedField V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1577 explicit LLoadNamedField(LOperand* object) {
1578 inputs_[0] = object;
1581 LOperand* object() { return inputs_[0]; }
1583 DECLARE_CONCRETE_INSTRUCTION(LoadNamedField, "load-named-field")
1584 DECLARE_HYDROGEN_ACCESSOR(LoadNamedField)
1588 class LLoadNamedGeneric V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1590 LLoadNamedGeneric(LOperand* context, LOperand* object) {
1591 inputs_[0] = context;
1592 inputs_[1] = object;
1595 LOperand* context() { return inputs_[0]; }
1596 LOperand* object() { return inputs_[1]; }
1598 DECLARE_CONCRETE_INSTRUCTION(LoadNamedGeneric, "load-named-generic")
1599 DECLARE_HYDROGEN_ACCESSOR(LoadNamedGeneric)
1601 Handle<Object> name() const { return hydrogen()->name(); }
1605 class LLoadFunctionPrototype V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1607 explicit LLoadFunctionPrototype(LOperand* function) {
1608 inputs_[0] = function;
1611 LOperand* function() { return inputs_[0]; }
1613 DECLARE_CONCRETE_INSTRUCTION(LoadFunctionPrototype, "load-function-prototype")
1614 DECLARE_HYDROGEN_ACCESSOR(LoadFunctionPrototype)
1618 class LLoadRoot V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1620 DECLARE_CONCRETE_INSTRUCTION(LoadRoot, "load-root")
1621 DECLARE_HYDROGEN_ACCESSOR(LoadRoot)
1623 Heap::RootListIndex index() const { return hydrogen()->index(); }
1627 class LLoadKeyed V8_FINAL : public LTemplateInstruction<1, 2, 2> {
1629 LLoadKeyed(LOperand* elements, LOperand* key,
1630 LOperand* temp, LOperand* temp2) {
1631 inputs_[0] = elements;
1637 LOperand* elements() { return inputs_[0]; }
1638 LOperand* key() { return inputs_[1]; }
1639 LOperand* temp() { return temps_[0]; }
1640 LOperand* temp2() { return temps_[1]; }
1641 ElementsKind elements_kind() const {
1642 return hydrogen()->elements_kind();
1644 bool is_external() const {
1645 return hydrogen()->is_external();
1647 bool is_fixed_typed_array() const {
1648 return hydrogen()->is_fixed_typed_array();
1650 bool is_typed_elements() const {
1651 return is_external() || is_fixed_typed_array();
1654 DECLARE_CONCRETE_INSTRUCTION(LoadKeyed, "load-keyed")
1655 DECLARE_HYDROGEN_ACCESSOR(LoadKeyed)
1657 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1658 uint32_t additional_index() const { return hydrogen()->index_offset(); }
1662 class LLoadKeyedGeneric V8_FINAL : public LTemplateInstruction<1, 3, 0> {
1664 LLoadKeyedGeneric(LOperand* context, LOperand* object, LOperand* key) {
1665 inputs_[0] = context;
1666 inputs_[1] = object;
1670 LOperand* context() { return inputs_[0]; }
1671 LOperand* object() { return inputs_[1]; }
1672 LOperand* key() { return inputs_[2]; }
1674 DECLARE_CONCRETE_INSTRUCTION(LoadKeyedGeneric, "load-keyed-generic")
1678 class LLoadGlobalCell V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1680 DECLARE_CONCRETE_INSTRUCTION(LoadGlobalCell, "load-global-cell")
1681 DECLARE_HYDROGEN_ACCESSOR(LoadGlobalCell)
1685 class LLoadGlobalGeneric V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1687 LLoadGlobalGeneric(LOperand* context, LOperand* global_object) {
1688 inputs_[0] = context;
1689 inputs_[1] = global_object;
1692 LOperand* context() { return inputs_[0]; }
1693 LOperand* global_object() { return inputs_[1]; }
1695 DECLARE_CONCRETE_INSTRUCTION(LoadGlobalGeneric, "load-global-generic")
1696 DECLARE_HYDROGEN_ACCESSOR(LoadGlobalGeneric)
1698 Handle<Object> name() const { return hydrogen()->name(); }
1699 bool for_typeof() const { return hydrogen()->for_typeof(); }
1703 class LStoreGlobalCell V8_FINAL : public LTemplateInstruction<0, 1, 1> {
1705 LStoreGlobalCell(LOperand* value, LOperand* temp) {
1710 LOperand* value() { return inputs_[0]; }
1711 LOperand* temp() { return temps_[0]; }
1713 DECLARE_CONCRETE_INSTRUCTION(StoreGlobalCell, "store-global-cell")
1714 DECLARE_HYDROGEN_ACCESSOR(StoreGlobalCell)
1718 class LLoadContextSlot V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1720 explicit LLoadContextSlot(LOperand* context) {
1721 inputs_[0] = context;
1724 LOperand* context() { return inputs_[0]; }
1726 DECLARE_CONCRETE_INSTRUCTION(LoadContextSlot, "load-context-slot")
1727 DECLARE_HYDROGEN_ACCESSOR(LoadContextSlot)
1729 int slot_index() { return hydrogen()->slot_index(); }
1731 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1735 class LStoreContextSlot V8_FINAL : public LTemplateInstruction<0, 2, 0> {
1737 LStoreContextSlot(LOperand* context, LOperand* value) {
1738 inputs_[0] = context;
1742 LOperand* context() { return inputs_[0]; }
1743 LOperand* value() { return inputs_[1]; }
1745 DECLARE_CONCRETE_INSTRUCTION(StoreContextSlot, "store-context-slot")
1746 DECLARE_HYDROGEN_ACCESSOR(StoreContextSlot)
1748 int slot_index() { return hydrogen()->slot_index(); }
1750 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1754 class LPushArgument V8_FINAL : public LTemplateInstruction<0, 1, 0> {
1756 explicit LPushArgument(LOperand* value) {
1760 LOperand* value() { return inputs_[0]; }
1762 DECLARE_CONCRETE_INSTRUCTION(PushArgument, "push-argument")
1766 class LDrop V8_FINAL : public LTemplateInstruction<0, 0, 0> {
1768 explicit LDrop(int count) : count_(count) { }
1770 int count() const { return count_; }
1772 DECLARE_CONCRETE_INSTRUCTION(Drop, "drop")
1779 class LStoreCodeEntry V8_FINAL: public LTemplateInstruction<0, 1, 1> {
1781 LStoreCodeEntry(LOperand* function, LOperand* code_object) {
1782 inputs_[0] = function;
1783 temps_[0] = code_object;
1786 LOperand* function() { return inputs_[0]; }
1787 LOperand* code_object() { return temps_[0]; }
1789 virtual void PrintDataTo(StringStream* stream);
1791 DECLARE_CONCRETE_INSTRUCTION(StoreCodeEntry, "store-code-entry")
1792 DECLARE_HYDROGEN_ACCESSOR(StoreCodeEntry)
1796 class LInnerAllocatedObject V8_FINAL: public LTemplateInstruction<1, 2, 0> {
1798 LInnerAllocatedObject(LOperand* base_object, LOperand* offset) {
1799 inputs_[0] = base_object;
1800 inputs_[1] = offset;
1803 LOperand* base_object() const { return inputs_[0]; }
1804 LOperand* offset() const { return inputs_[1]; }
1806 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1808 DECLARE_CONCRETE_INSTRUCTION(InnerAllocatedObject, "inner-allocated-object")
1812 class LThisFunction V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1814 DECLARE_CONCRETE_INSTRUCTION(ThisFunction, "this-function")
1815 DECLARE_HYDROGEN_ACCESSOR(ThisFunction)
1819 class LContext V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1821 DECLARE_CONCRETE_INSTRUCTION(Context, "context")
1822 DECLARE_HYDROGEN_ACCESSOR(Context)
1826 class LDeclareGlobals V8_FINAL : public LTemplateInstruction<0, 1, 0> {
1828 explicit LDeclareGlobals(LOperand* context) {
1829 inputs_[0] = context;
1832 LOperand* context() { return inputs_[0]; }
1834 DECLARE_CONCRETE_INSTRUCTION(DeclareGlobals, "declare-globals")
1835 DECLARE_HYDROGEN_ACCESSOR(DeclareGlobals)
1839 class LCallJSFunction V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1841 explicit LCallJSFunction(LOperand* function) {
1842 inputs_[0] = function;
1845 LOperand* function() { return inputs_[0]; }
1847 DECLARE_CONCRETE_INSTRUCTION(CallJSFunction, "call-js-function")
1848 DECLARE_HYDROGEN_ACCESSOR(CallJSFunction)
1850 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1852 int arity() const { return hydrogen()->argument_count() - 1; }
1856 class LCallWithDescriptor V8_FINAL : public LTemplateResultInstruction<1> {
1858 LCallWithDescriptor(const CallInterfaceDescriptor* descriptor,
1859 ZoneList<LOperand*>& operands,
1861 : descriptor_(descriptor),
1862 inputs_(descriptor->environment_length() + 1, zone) {
1863 ASSERT(descriptor->environment_length() + 1 == operands.length());
1864 inputs_.AddAll(operands, zone);
1867 LOperand* target() const { return inputs_[0]; }
1869 const CallInterfaceDescriptor* descriptor() { return descriptor_; }
1872 DECLARE_CONCRETE_INSTRUCTION(CallWithDescriptor, "call-with-descriptor")
1873 DECLARE_HYDROGEN_ACCESSOR(CallWithDescriptor)
1875 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1877 int arity() const { return hydrogen()->argument_count() - 1; }
1879 const CallInterfaceDescriptor* descriptor_;
1880 ZoneList<LOperand*> inputs_;
1882 // Iterator support.
1883 virtual int InputCount() V8_FINAL V8_OVERRIDE { return inputs_.length(); }
1884 virtual LOperand* InputAt(int i) V8_FINAL V8_OVERRIDE { return inputs_[i]; }
1886 virtual int TempCount() V8_FINAL V8_OVERRIDE { return 0; }
1887 virtual LOperand* TempAt(int i) V8_FINAL V8_OVERRIDE { return NULL; }
1891 class LInvokeFunction V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1893 LInvokeFunction(LOperand* context, LOperand* function) {
1894 inputs_[0] = context;
1895 inputs_[1] = function;
1898 LOperand* context() { return inputs_[0]; }
1899 LOperand* function() { return inputs_[1]; }
1901 DECLARE_CONCRETE_INSTRUCTION(InvokeFunction, "invoke-function")
1902 DECLARE_HYDROGEN_ACCESSOR(InvokeFunction)
1904 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1906 int arity() const { return hydrogen()->argument_count() - 1; }
1910 class LCallFunction V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1912 LCallFunction(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(CallFunction, "call-function")
1921 DECLARE_HYDROGEN_ACCESSOR(CallFunction)
1923 int arity() const { return hydrogen()->argument_count() - 1; }
1927 class LCallNew V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1929 LCallNew(LOperand* context, LOperand* constructor) {
1930 inputs_[0] = context;
1931 inputs_[1] = constructor;
1934 LOperand* context() { return inputs_[0]; }
1935 LOperand* constructor() { return inputs_[1]; }
1937 DECLARE_CONCRETE_INSTRUCTION(CallNew, "call-new")
1938 DECLARE_HYDROGEN_ACCESSOR(CallNew)
1940 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1942 int arity() const { return hydrogen()->argument_count() - 1; }
1946 class LCallNewArray V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1948 LCallNewArray(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(CallNewArray, "call-new-array")
1957 DECLARE_HYDROGEN_ACCESSOR(CallNewArray)
1959 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1961 int arity() const { return hydrogen()->argument_count() - 1; }
1965 class LCallRuntime V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1967 explicit LCallRuntime(LOperand* context) {
1968 inputs_[0] = context;
1971 LOperand* context() { return inputs_[0]; }
1973 DECLARE_CONCRETE_INSTRUCTION(CallRuntime, "call-runtime")
1974 DECLARE_HYDROGEN_ACCESSOR(CallRuntime)
1976 virtual bool ClobbersDoubleRegisters() const V8_OVERRIDE {
1977 return save_doubles() == kDontSaveFPRegs;
1980 const Runtime::Function* function() const { return hydrogen()->function(); }
1981 int arity() const { return hydrogen()->argument_count(); }
1982 SaveFPRegsMode save_doubles() const { return hydrogen()->save_doubles(); }
1986 class LInteger32ToDouble V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1988 explicit LInteger32ToDouble(LOperand* value) {
1992 LOperand* value() { return inputs_[0]; }
1994 DECLARE_CONCRETE_INSTRUCTION(Integer32ToDouble, "int32-to-double")
1998 class LUint32ToDouble V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2000 explicit LUint32ToDouble(LOperand* value) {
2004 LOperand* value() { return inputs_[0]; }
2006 DECLARE_CONCRETE_INSTRUCTION(Uint32ToDouble, "uint32-to-double")
2010 class LNumberTagI V8_FINAL : public LTemplateInstruction<1, 1, 2> {
2012 LNumberTagI(LOperand* value, LOperand* temp1, LOperand* temp2) {
2018 LOperand* value() { return inputs_[0]; }
2019 LOperand* temp1() { return temps_[0]; }
2020 LOperand* temp2() { return temps_[1]; }
2022 DECLARE_CONCRETE_INSTRUCTION(NumberTagI, "number-tag-i")
2026 class LNumberTagU V8_FINAL : public LTemplateInstruction<1, 1, 2> {
2028 LNumberTagU(LOperand* value, LOperand* temp1, LOperand* temp2) {
2034 LOperand* value() { return inputs_[0]; }
2035 LOperand* temp1() { return temps_[0]; }
2036 LOperand* temp2() { return temps_[1]; }
2038 DECLARE_CONCRETE_INSTRUCTION(NumberTagU, "number-tag-u")
2042 class LNumberTagD V8_FINAL : public LTemplateInstruction<1, 1, 2> {
2044 LNumberTagD(LOperand* value, LOperand* temp, LOperand* temp2) {
2050 LOperand* value() { return inputs_[0]; }
2051 LOperand* temp() { return temps_[0]; }
2052 LOperand* temp2() { return temps_[1]; }
2054 DECLARE_CONCRETE_INSTRUCTION(NumberTagD, "number-tag-d")
2055 DECLARE_HYDROGEN_ACCESSOR(Change)
2059 class LDoubleToSmi V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2061 explicit LDoubleToSmi(LOperand* value) {
2065 LOperand* value() { return inputs_[0]; }
2067 DECLARE_CONCRETE_INSTRUCTION(DoubleToSmi, "double-to-smi")
2068 DECLARE_HYDROGEN_ACCESSOR(UnaryOperation)
2070 bool truncating() { return hydrogen()->CanTruncateToInt32(); }
2074 // Sometimes truncating conversion from a tagged value to an int32.
2075 class LDoubleToI V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2077 explicit LDoubleToI(LOperand* value) {
2081 LOperand* value() { return inputs_[0]; }
2083 DECLARE_CONCRETE_INSTRUCTION(DoubleToI, "double-to-i")
2084 DECLARE_HYDROGEN_ACCESSOR(UnaryOperation)
2086 bool truncating() { return hydrogen()->CanTruncateToInt32(); }
2090 // Truncating conversion from a tagged value to an int32.
2091 class LTaggedToI V8_FINAL : public LTemplateInstruction<1, 1, 2> {
2093 LTaggedToI(LOperand* value,
2101 LOperand* value() { return inputs_[0]; }
2102 LOperand* temp() { return temps_[0]; }
2103 LOperand* temp2() { return temps_[1]; }
2105 DECLARE_CONCRETE_INSTRUCTION(TaggedToI, "tagged-to-i")
2106 DECLARE_HYDROGEN_ACCESSOR(Change)
2108 bool truncating() { return hydrogen()->CanTruncateToInt32(); }
2112 class LSmiTag V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2114 explicit LSmiTag(LOperand* value) {
2118 LOperand* value() { return inputs_[0]; }
2120 DECLARE_CONCRETE_INSTRUCTION(SmiTag, "smi-tag")
2121 DECLARE_HYDROGEN_ACCESSOR(Change)
2125 class LNumberUntagD V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2127 explicit LNumberUntagD(LOperand* value) {
2131 LOperand* value() { return inputs_[0]; }
2133 DECLARE_CONCRETE_INSTRUCTION(NumberUntagD, "double-untag")
2134 DECLARE_HYDROGEN_ACCESSOR(Change)
2138 class LSmiUntag V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2140 LSmiUntag(LOperand* value, bool needs_check)
2141 : needs_check_(needs_check) {
2145 LOperand* value() { return inputs_[0]; }
2146 bool needs_check() const { return needs_check_; }
2148 DECLARE_CONCRETE_INSTRUCTION(SmiUntag, "smi-untag")
2155 class LStoreNamedField V8_FINAL : public LTemplateInstruction<0, 2, 1> {
2157 LStoreNamedField(LOperand* object, LOperand* value, LOperand* temp) {
2158 inputs_[0] = object;
2163 LOperand* object() { return inputs_[0]; }
2164 LOperand* value() { return inputs_[1]; }
2165 LOperand* temp() { return temps_[0]; }
2167 DECLARE_CONCRETE_INSTRUCTION(StoreNamedField, "store-named-field")
2168 DECLARE_HYDROGEN_ACCESSOR(StoreNamedField)
2170 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
2172 Handle<Map> transition() const { return hydrogen()->transition_map(); }
2173 Representation representation() const {
2174 return hydrogen()->field_representation();
2179 class LStoreNamedGeneric V8_FINAL : public LTemplateInstruction<0, 3, 0> {
2181 LStoreNamedGeneric(LOperand* context, LOperand* object, LOperand* value) {
2182 inputs_[0] = context;
2183 inputs_[1] = object;
2187 LOperand* context() { return inputs_[0]; }
2188 LOperand* object() { return inputs_[1]; }
2189 LOperand* value() { return inputs_[2]; }
2191 DECLARE_CONCRETE_INSTRUCTION(StoreNamedGeneric, "store-named-generic")
2192 DECLARE_HYDROGEN_ACCESSOR(StoreNamedGeneric)
2194 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
2196 Handle<Object> name() const { return hydrogen()->name(); }
2197 StrictMode strict_mode() { return hydrogen()->strict_mode(); }
2201 class LStoreKeyed V8_FINAL : public LTemplateInstruction<0, 3, 1> {
2203 LStoreKeyed(LOperand* object, LOperand* key, LOperand* value,
2205 inputs_[0] = object;
2211 bool is_external() const { return hydrogen()->is_external(); }
2212 bool is_fixed_typed_array() const {
2213 return hydrogen()->is_fixed_typed_array();
2215 bool is_typed_elements() const {
2216 return is_external() || is_fixed_typed_array();
2218 LOperand* elements() { return inputs_[0]; }
2219 LOperand* key() { return inputs_[1]; }
2220 LOperand* value() { return inputs_[2]; }
2221 LOperand* temp() { return temps_[0]; }
2222 ElementsKind elements_kind() const {
2223 return hydrogen()->elements_kind();
2226 DECLARE_CONCRETE_INSTRUCTION(StoreKeyed, "store-keyed")
2227 DECLARE_HYDROGEN_ACCESSOR(StoreKeyed)
2229 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
2230 bool NeedsCanonicalization() {
2231 if (hydrogen()->value()->IsAdd() || hydrogen()->value()->IsSub() ||
2232 hydrogen()->value()->IsMul() || hydrogen()->value()->IsDiv()) {
2235 return hydrogen()->NeedsCanonicalization();
2237 uint32_t additional_index() const { return hydrogen()->index_offset(); }
2241 class LStoreKeyedGeneric V8_FINAL : public LTemplateInstruction<0, 4, 0> {
2243 LStoreKeyedGeneric(LOperand* context,
2247 inputs_[0] = context;
2253 LOperand* context() { return inputs_[0]; }
2254 LOperand* object() { return inputs_[1]; }
2255 LOperand* key() { return inputs_[2]; }
2256 LOperand* value() { return inputs_[3]; }
2258 DECLARE_CONCRETE_INSTRUCTION(StoreKeyedGeneric, "store-keyed-generic")
2259 DECLARE_HYDROGEN_ACCESSOR(StoreKeyedGeneric)
2261 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
2263 StrictMode strict_mode() { return hydrogen()->strict_mode(); }
2267 class LTransitionElementsKind V8_FINAL : public LTemplateInstruction<0, 2, 1> {
2269 LTransitionElementsKind(LOperand* object,
2271 LOperand* new_map_temp) {
2272 inputs_[0] = object;
2273 inputs_[1] = context;
2274 temps_[0] = new_map_temp;
2277 LOperand* context() { return inputs_[1]; }
2278 LOperand* object() { return inputs_[0]; }
2279 LOperand* new_map_temp() { return temps_[0]; }
2281 DECLARE_CONCRETE_INSTRUCTION(TransitionElementsKind,
2282 "transition-elements-kind")
2283 DECLARE_HYDROGEN_ACCESSOR(TransitionElementsKind)
2285 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
2287 Handle<Map> original_map() { return hydrogen()->original_map().handle(); }
2288 Handle<Map> transitioned_map() {
2289 return hydrogen()->transitioned_map().handle();
2291 ElementsKind from_kind() { return hydrogen()->from_kind(); }
2292 ElementsKind to_kind() { return hydrogen()->to_kind(); }
2296 class LTrapAllocationMemento V8_FINAL : public LTemplateInstruction<0, 1, 1> {
2298 LTrapAllocationMemento(LOperand* object,
2300 inputs_[0] = object;
2304 LOperand* object() { return inputs_[0]; }
2305 LOperand* temp() { return temps_[0]; }
2307 DECLARE_CONCRETE_INSTRUCTION(TrapAllocationMemento,
2308 "trap-allocation-memento")
2312 class LStringAdd V8_FINAL : public LTemplateInstruction<1, 3, 0> {
2314 LStringAdd(LOperand* context, LOperand* left, LOperand* right) {
2315 inputs_[0] = context;
2320 LOperand* context() { return inputs_[0]; }
2321 LOperand* left() { return inputs_[1]; }
2322 LOperand* right() { return inputs_[2]; }
2324 DECLARE_CONCRETE_INSTRUCTION(StringAdd, "string-add")
2325 DECLARE_HYDROGEN_ACCESSOR(StringAdd)
2330 class LStringCharCodeAt V8_FINAL : public LTemplateInstruction<1, 3, 0> {
2332 LStringCharCodeAt(LOperand* context, LOperand* string, LOperand* index) {
2333 inputs_[0] = context;
2334 inputs_[1] = string;
2338 LOperand* context() { return inputs_[0]; }
2339 LOperand* string() { return inputs_[1]; }
2340 LOperand* index() { return inputs_[2]; }
2342 DECLARE_CONCRETE_INSTRUCTION(StringCharCodeAt, "string-char-code-at")
2343 DECLARE_HYDROGEN_ACCESSOR(StringCharCodeAt)
2347 class LStringCharFromCode V8_FINAL : public LTemplateInstruction<1, 2, 0> {
2349 explicit LStringCharFromCode(LOperand* context, LOperand* char_code) {
2350 inputs_[0] = context;
2351 inputs_[1] = char_code;
2354 LOperand* context() { return inputs_[0]; }
2355 LOperand* char_code() { return inputs_[1]; }
2357 DECLARE_CONCRETE_INSTRUCTION(StringCharFromCode, "string-char-from-code")
2358 DECLARE_HYDROGEN_ACCESSOR(StringCharFromCode)
2362 class LCheckValue V8_FINAL : public LTemplateInstruction<0, 1, 0> {
2364 explicit LCheckValue(LOperand* value) {
2368 LOperand* value() { return inputs_[0]; }
2370 DECLARE_CONCRETE_INSTRUCTION(CheckValue, "check-value")
2371 DECLARE_HYDROGEN_ACCESSOR(CheckValue)
2375 class LCheckInstanceType V8_FINAL : public LTemplateInstruction<0, 1, 0> {
2377 explicit LCheckInstanceType(LOperand* value) {
2381 LOperand* value() { return inputs_[0]; }
2383 DECLARE_CONCRETE_INSTRUCTION(CheckInstanceType, "check-instance-type")
2384 DECLARE_HYDROGEN_ACCESSOR(CheckInstanceType)
2388 class LCheckMaps V8_FINAL : public LTemplateInstruction<0, 1, 0> {
2390 explicit LCheckMaps(LOperand* value) {
2394 LOperand* value() { return inputs_[0]; }
2396 DECLARE_CONCRETE_INSTRUCTION(CheckMaps, "check-maps")
2397 DECLARE_HYDROGEN_ACCESSOR(CheckMaps)
2401 class LCheckSmi V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2403 explicit LCheckSmi(LOperand* value) {
2407 LOperand* value() { return inputs_[0]; }
2409 DECLARE_CONCRETE_INSTRUCTION(CheckSmi, "check-smi")
2413 class LCheckNonSmi V8_FINAL : public LTemplateInstruction<0, 1, 0> {
2415 explicit LCheckNonSmi(LOperand* value) {
2419 LOperand* value() { return inputs_[0]; }
2421 DECLARE_CONCRETE_INSTRUCTION(CheckNonSmi, "check-non-smi")
2422 DECLARE_HYDROGEN_ACCESSOR(CheckHeapObject)
2426 class LClampDToUint8 V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2428 explicit LClampDToUint8(LOperand* unclamped) {
2429 inputs_[0] = unclamped;
2432 LOperand* unclamped() { return inputs_[0]; }
2434 DECLARE_CONCRETE_INSTRUCTION(ClampDToUint8, "clamp-d-to-uint8")
2438 class LClampIToUint8 V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2440 explicit LClampIToUint8(LOperand* unclamped) {
2441 inputs_[0] = unclamped;
2444 LOperand* unclamped() { return inputs_[0]; }
2446 DECLARE_CONCRETE_INSTRUCTION(ClampIToUint8, "clamp-i-to-uint8")
2450 class LClampTToUint8 V8_FINAL : public LTemplateInstruction<1, 1, 1> {
2452 LClampTToUint8(LOperand* unclamped, LOperand* temp) {
2453 inputs_[0] = unclamped;
2457 LOperand* unclamped() { return inputs_[0]; }
2458 LOperand* temp() { return temps_[0]; }
2460 DECLARE_CONCRETE_INSTRUCTION(ClampTToUint8, "clamp-t-to-uint8")
2464 class LDoubleBits V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2466 explicit LDoubleBits(LOperand* value) {
2470 LOperand* value() { return inputs_[0]; }
2472 DECLARE_CONCRETE_INSTRUCTION(DoubleBits, "double-bits")
2473 DECLARE_HYDROGEN_ACCESSOR(DoubleBits)
2477 class LConstructDouble V8_FINAL : public LTemplateInstruction<1, 2, 0> {
2479 LConstructDouble(LOperand* hi, LOperand* lo) {
2484 LOperand* hi() { return inputs_[0]; }
2485 LOperand* lo() { return inputs_[1]; }
2487 DECLARE_CONCRETE_INSTRUCTION(ConstructDouble, "construct-double")
2491 class LAllocate V8_FINAL : public LTemplateInstruction<1, 2, 2> {
2493 LAllocate(LOperand* context,
2497 inputs_[0] = context;
2503 LOperand* context() { return inputs_[0]; }
2504 LOperand* size() { return inputs_[1]; }
2505 LOperand* temp1() { return temps_[0]; }
2506 LOperand* temp2() { return temps_[1]; }
2508 DECLARE_CONCRETE_INSTRUCTION(Allocate, "allocate")
2509 DECLARE_HYDROGEN_ACCESSOR(Allocate)
2513 class LRegExpLiteral V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2515 explicit LRegExpLiteral(LOperand* context) {
2516 inputs_[0] = context;
2519 LOperand* context() { return inputs_[0]; }
2521 DECLARE_CONCRETE_INSTRUCTION(RegExpLiteral, "regexp-literal")
2522 DECLARE_HYDROGEN_ACCESSOR(RegExpLiteral)
2526 class LFunctionLiteral V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2528 explicit LFunctionLiteral(LOperand* context) {
2529 inputs_[0] = context;
2532 LOperand* context() { return inputs_[0]; }
2534 DECLARE_CONCRETE_INSTRUCTION(FunctionLiteral, "function-literal")
2535 DECLARE_HYDROGEN_ACCESSOR(FunctionLiteral)
2539 class LToFastProperties V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2541 explicit LToFastProperties(LOperand* value) {
2545 LOperand* value() { return inputs_[0]; }
2547 DECLARE_CONCRETE_INSTRUCTION(ToFastProperties, "to-fast-properties")
2548 DECLARE_HYDROGEN_ACCESSOR(ToFastProperties)
2552 class LTypeof V8_FINAL : public LTemplateInstruction<1, 2, 0> {
2554 LTypeof(LOperand* context, LOperand* value) {
2555 inputs_[0] = context;
2559 LOperand* context() { return inputs_[0]; }
2560 LOperand* value() { return inputs_[1]; }
2562 DECLARE_CONCRETE_INSTRUCTION(Typeof, "typeof")
2566 class LTypeofIsAndBranch V8_FINAL : public LControlInstruction<1, 0> {
2568 explicit LTypeofIsAndBranch(LOperand* value) {
2572 LOperand* value() { return inputs_[0]; }
2574 DECLARE_CONCRETE_INSTRUCTION(TypeofIsAndBranch, "typeof-is-and-branch")
2575 DECLARE_HYDROGEN_ACCESSOR(TypeofIsAndBranch)
2577 Handle<String> type_literal() { return hydrogen()->type_literal(); }
2579 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
2583 class LIsConstructCallAndBranch V8_FINAL : public LControlInstruction<0, 1> {
2585 explicit LIsConstructCallAndBranch(LOperand* temp) {
2589 LOperand* temp() { return temps_[0]; }
2591 DECLARE_CONCRETE_INSTRUCTION(IsConstructCallAndBranch,
2592 "is-construct-call-and-branch")
2596 class LOsrEntry V8_FINAL : public LTemplateInstruction<0, 0, 0> {
2600 virtual bool HasInterestingComment(LCodeGen* gen) const V8_OVERRIDE {
2603 DECLARE_CONCRETE_INSTRUCTION(OsrEntry, "osr-entry")
2607 class LStackCheck V8_FINAL : public LTemplateInstruction<0, 1, 0> {
2609 explicit LStackCheck(LOperand* context) {
2610 inputs_[0] = context;
2613 LOperand* context() { return inputs_[0]; }
2615 DECLARE_CONCRETE_INSTRUCTION(StackCheck, "stack-check")
2616 DECLARE_HYDROGEN_ACCESSOR(StackCheck)
2618 Label* done_label() { return &done_label_; }
2625 class LForInPrepareMap V8_FINAL : public LTemplateInstruction<1, 2, 0> {
2627 LForInPrepareMap(LOperand* context, LOperand* object) {
2628 inputs_[0] = context;
2629 inputs_[1] = object;
2632 LOperand* context() { return inputs_[0]; }
2633 LOperand* object() { return inputs_[1]; }
2635 DECLARE_CONCRETE_INSTRUCTION(ForInPrepareMap, "for-in-prepare-map")
2639 class LForInCacheArray V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2641 explicit LForInCacheArray(LOperand* map) {
2645 LOperand* map() { return inputs_[0]; }
2647 DECLARE_CONCRETE_INSTRUCTION(ForInCacheArray, "for-in-cache-array")
2650 return HForInCacheArray::cast(this->hydrogen_value())->idx();
2655 class LCheckMapValue V8_FINAL : public LTemplateInstruction<0, 2, 0> {
2657 LCheckMapValue(LOperand* value, LOperand* map) {
2662 LOperand* value() { return inputs_[0]; }
2663 LOperand* map() { return inputs_[1]; }
2665 DECLARE_CONCRETE_INSTRUCTION(CheckMapValue, "check-map-value")
2669 class LLoadFieldByIndex V8_FINAL : public LTemplateInstruction<1, 2, 0> {
2671 LLoadFieldByIndex(LOperand* object, LOperand* index) {
2672 inputs_[0] = object;
2676 LOperand* object() { return inputs_[0]; }
2677 LOperand* index() { return inputs_[1]; }
2679 DECLARE_CONCRETE_INSTRUCTION(LoadFieldByIndex, "load-field-by-index")
2683 class LChunkBuilder;
2684 class LPlatformChunk V8_FINAL : public LChunk {
2686 LPlatformChunk(CompilationInfo* info, HGraph* graph)
2687 : LChunk(info, graph) { }
2689 int GetNextSpillIndex(RegisterKind kind);
2690 LOperand* GetNextSpillSlot(RegisterKind kind);
2694 class LChunkBuilder V8_FINAL : public LChunkBuilderBase {
2696 LChunkBuilder(CompilationInfo* info, HGraph* graph, LAllocator* allocator)
2697 : LChunkBuilderBase(graph->zone()),
2702 current_instruction_(NULL),
2703 current_block_(NULL),
2705 allocator_(allocator) { }
2707 // Build the sequence for the graph.
2708 LPlatformChunk* Build();
2710 LInstruction* CheckElideControlInstruction(HControlInstruction* instr);
2712 // Declare methods that deal with the individual node types.
2713 #define DECLARE_DO(type) LInstruction* Do##type(H##type* node);
2714 HYDROGEN_CONCRETE_INSTRUCTION_LIST(DECLARE_DO)
2717 LInstruction* DoMultiplyAdd(HMul* mul, HValue* addend);
2718 LInstruction* DoMultiplySub(HValue* minuend, HMul* mul);
2719 LInstruction* DoRSub(HSub* instr);
2721 static bool HasMagicNumberForDivisor(int32_t divisor);
2723 LInstruction* DoMathFloor(HUnaryMathOperation* instr);
2724 LInstruction* DoMathRound(HUnaryMathOperation* instr);
2725 LInstruction* DoMathAbs(HUnaryMathOperation* instr);
2726 LInstruction* DoMathLog(HUnaryMathOperation* instr);
2727 LInstruction* DoMathExp(HUnaryMathOperation* instr);
2728 LInstruction* DoMathSqrt(HUnaryMathOperation* instr);
2729 LInstruction* DoMathPowHalf(HUnaryMathOperation* instr);
2730 LInstruction* DoMathClz32(HUnaryMathOperation* instr);
2731 LInstruction* DoDivByPowerOf2I(HDiv* instr);
2732 LInstruction* DoDivByConstI(HDiv* instr);
2733 LInstruction* DoDivI(HBinaryOperation* instr);
2734 LInstruction* DoModByPowerOf2I(HMod* instr);
2735 LInstruction* DoModByConstI(HMod* instr);
2736 LInstruction* DoModI(HMod* instr);
2737 LInstruction* DoFlooringDivByPowerOf2I(HMathFloorOfDiv* instr);
2738 LInstruction* DoFlooringDivByConstI(HMathFloorOfDiv* instr);
2748 LPlatformChunk* chunk() const { return chunk_; }
2749 CompilationInfo* info() const { return info_; }
2750 HGraph* graph() const { return graph_; }
2752 bool is_unused() const { return status_ == UNUSED; }
2753 bool is_building() const { return status_ == BUILDING; }
2754 bool is_done() const { return status_ == DONE; }
2755 bool is_aborted() const { return status_ == ABORTED; }
2757 void Abort(BailoutReason reason);
2759 // Methods for getting operands for Use / Define / Temp.
2760 LUnallocated* ToUnallocated(Register reg);
2761 LUnallocated* ToUnallocated(DoubleRegister reg);
2763 // Methods for setting up define-use relationships.
2764 MUST_USE_RESULT LOperand* Use(HValue* value, LUnallocated* operand);
2765 MUST_USE_RESULT LOperand* UseFixed(HValue* value, Register fixed_register);
2766 MUST_USE_RESULT LOperand* UseFixedDouble(HValue* value,
2767 DoubleRegister fixed_register);
2769 // A value that is guaranteed to be allocated to a register.
2770 // Operand created by UseRegister is guaranteed to be live until the end of
2771 // instruction. This means that register allocator will not reuse it's
2772 // register for any other operand inside instruction.
2773 // Operand created by UseRegisterAtStart is guaranteed to be live only at
2774 // instruction start. Register allocator is free to assign the same register
2775 // to some other operand used inside instruction (i.e. temporary or
2777 MUST_USE_RESULT LOperand* UseRegister(HValue* value);
2778 MUST_USE_RESULT LOperand* UseRegisterAtStart(HValue* value);
2780 // An input operand in a register that may be trashed.
2781 MUST_USE_RESULT LOperand* UseTempRegister(HValue* value);
2783 // An input operand in a register or stack slot.
2784 MUST_USE_RESULT LOperand* Use(HValue* value);
2785 MUST_USE_RESULT LOperand* UseAtStart(HValue* value);
2787 // An input operand in a register, stack slot or a constant operand.
2788 MUST_USE_RESULT LOperand* UseOrConstant(HValue* value);
2789 MUST_USE_RESULT LOperand* UseOrConstantAtStart(HValue* value);
2791 // An input operand in a register or a constant operand.
2792 MUST_USE_RESULT LOperand* UseRegisterOrConstant(HValue* value);
2793 MUST_USE_RESULT LOperand* UseRegisterOrConstantAtStart(HValue* value);
2795 // An input operand in a constant operand.
2796 MUST_USE_RESULT LOperand* UseConstant(HValue* value);
2798 // An input operand in register, stack slot or a constant operand.
2799 // Will not be moved to a register even if one is freely available.
2800 virtual MUST_USE_RESULT LOperand* UseAny(HValue* value) V8_OVERRIDE;
2802 // Temporary operand that must be in a register.
2803 MUST_USE_RESULT LUnallocated* TempRegister();
2804 MUST_USE_RESULT LOperand* FixedTemp(Register reg);
2805 MUST_USE_RESULT LOperand* FixedTemp(DoubleRegister reg);
2807 // Methods for setting up define-use relationships.
2808 // Return the same instruction that they are passed.
2809 LInstruction* Define(LTemplateResultInstruction<1>* instr,
2810 LUnallocated* result);
2811 LInstruction* DefineAsRegister(LTemplateResultInstruction<1>* instr);
2812 LInstruction* DefineAsSpilled(LTemplateResultInstruction<1>* instr,
2814 LInstruction* DefineSameAsFirst(LTemplateResultInstruction<1>* instr);
2815 LInstruction* DefineFixed(LTemplateResultInstruction<1>* instr,
2817 LInstruction* DefineFixedDouble(LTemplateResultInstruction<1>* instr,
2818 DoubleRegister reg);
2819 LInstruction* AssignEnvironment(LInstruction* instr);
2820 LInstruction* AssignPointerMap(LInstruction* instr);
2822 enum CanDeoptimize { CAN_DEOPTIMIZE_EAGERLY, CANNOT_DEOPTIMIZE_EAGERLY };
2824 // By default we assume that instruction sequences generated for calls
2825 // cannot deoptimize eagerly and we do not attach environment to this
2827 LInstruction* MarkAsCall(
2828 LInstruction* instr,
2829 HInstruction* hinstr,
2830 CanDeoptimize can_deoptimize = CANNOT_DEOPTIMIZE_EAGERLY);
2832 void VisitInstruction(HInstruction* current);
2834 void DoBasicBlock(HBasicBlock* block, HBasicBlock* next_block);
2835 LInstruction* DoShift(Token::Value op, HBitwiseBinaryOperation* instr);
2836 LInstruction* DoArithmeticD(Token::Value op,
2837 HArithmeticBinaryOperation* instr);
2838 LInstruction* DoArithmeticT(Token::Value op,
2839 HBinaryOperation* instr);
2841 LPlatformChunk* chunk_;
2842 CompilationInfo* info_;
2843 HGraph* const graph_;
2845 HInstruction* current_instruction_;
2846 HBasicBlock* current_block_;
2847 HBasicBlock* next_block_;
2848 LAllocator* allocator_;
2850 DISALLOW_COPY_AND_ASSIGN(LChunkBuilder);
2853 #undef DECLARE_HYDROGEN_ACCESSOR
2854 #undef DECLARE_CONCRETE_INSTRUCTION
2856 } } // namespace v8::internal
2858 #endif // V8_ARM_LITHIUM_ARM_H_