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_IA32_LITHIUM_IA32_H_
6 #define V8_IA32_LITHIUM_IA32_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"
18 class RCodeVisualizer;
21 // Forward declarations.
24 #define LITHIUM_CONCRETE_INSTRUCTION_LIST(V) \
25 V(AccessArgumentsAt) \
27 V(AllocateBlockContext) \
30 V(ArgumentsElements) \
38 V(CallWithDescriptor) \
44 V(CheckInstanceType) \
53 V(ClassOfTestAndBranch) \
54 V(CompareMinusZeroAndBranch) \
55 V(CompareNumericAndBranch) \
56 V(CmpObjectEqAndBranch) \
80 V(FlooringDivByConstI) \
81 V(FlooringDivByPowerOf2I) \
86 V(GetCachedArrayIndex) \
88 V(HasCachedArrayIndexAndBranch) \
89 V(HasInstanceTypeAndBranch) \
90 V(InnerAllocatedObject) \
92 V(InstanceOfKnownGlobal) \
94 V(Integer32ToDouble) \
96 V(IsConstructCallAndBranch) \
97 V(IsObjectAndBranch) \
98 V(IsStringAndBranch) \
100 V(IsUndetectableAndBranch) \
104 V(LoadFieldByIndex) \
105 V(LoadFunctionPrototype) \
107 V(LoadGlobalGeneric) \
109 V(LoadKeyedGeneric) \
111 V(LoadNamedGeneric) \
138 V(SeqStringGetChar) \
139 V(SeqStringSetChar) \
145 V(StoreContextSlot) \
146 V(StoreFrameContext) \
149 V(StoreKeyedGeneric) \
151 V(StoreNamedGeneric) \
153 V(StringCharCodeAt) \
154 V(StringCharFromCode) \
155 V(StringCompareAndBranch) \
159 V(ToFastProperties) \
160 V(TransitionElementsKind) \
161 V(TrapAllocationMemento) \
163 V(TypeofIsAndBranch) \
169 #define DECLARE_CONCRETE_INSTRUCTION(type, mnemonic) \
170 virtual Opcode opcode() const V8_FINAL V8_OVERRIDE { \
171 return LInstruction::k##type; \
173 virtual void CompileToNative(LCodeGen* generator) V8_FINAL V8_OVERRIDE; \
174 virtual const char* Mnemonic() const V8_FINAL V8_OVERRIDE { \
177 static L##type* cast(LInstruction* instr) { \
178 DCHECK(instr->Is##type()); \
179 return reinterpret_cast<L##type*>(instr); \
183 #define DECLARE_HYDROGEN_ACCESSOR(type) \
184 H##type* hydrogen() const { \
185 return H##type::cast(hydrogen_value()); \
189 class LInstruction : public ZoneObject {
192 : environment_(NULL),
193 hydrogen_value_(NULL),
194 bit_field_(IsCallBits::encode(false)) {
197 virtual ~LInstruction() {}
199 virtual void CompileToNative(LCodeGen* generator) = 0;
200 virtual const char* Mnemonic() const = 0;
201 virtual void PrintTo(StringStream* stream);
202 virtual void PrintDataTo(StringStream* stream);
203 virtual void PrintOutputOperandTo(StringStream* stream);
206 // Declare a unique enum value for each instruction.
207 #define DECLARE_OPCODE(type) k##type,
208 LITHIUM_CONCRETE_INSTRUCTION_LIST(DECLARE_OPCODE) kAdapter,
209 kNumberOfInstructions
210 #undef DECLARE_OPCODE
213 virtual Opcode opcode() const = 0;
215 // Declare non-virtual type testers for all leaf IR classes.
216 #define DECLARE_PREDICATE(type) \
217 bool Is##type() const { return opcode() == k##type; }
218 LITHIUM_CONCRETE_INSTRUCTION_LIST(DECLARE_PREDICATE)
219 #undef DECLARE_PREDICATE
221 // Declare virtual predicates for instructions that don't have
223 virtual bool IsGap() const { return false; }
225 virtual bool IsControl() const { return false; }
227 // Try deleting this instruction if possible.
228 virtual bool TryDelete() { return false; }
230 void set_environment(LEnvironment* env) { environment_ = env; }
231 LEnvironment* environment() const { return environment_; }
232 bool HasEnvironment() const { return environment_ != NULL; }
234 void set_pointer_map(LPointerMap* p) { pointer_map_.set(p); }
235 LPointerMap* pointer_map() const { return pointer_map_.get(); }
236 bool HasPointerMap() const { return pointer_map_.is_set(); }
238 void set_hydrogen_value(HValue* value) { hydrogen_value_ = value; }
239 HValue* hydrogen_value() const { return hydrogen_value_; }
241 virtual void SetDeferredLazyDeoptimizationEnvironment(LEnvironment* env) { }
243 void MarkAsCall() { bit_field_ = IsCallBits::update(bit_field_, true); }
244 bool IsCall() const { return IsCallBits::decode(bit_field_); }
246 // Interface to the register allocator and iterators.
247 bool ClobbersTemps() const { return IsCall(); }
248 bool ClobbersRegisters() const { return IsCall(); }
249 virtual bool ClobbersDoubleRegisters(Isolate* isolate) const {
253 virtual bool HasResult() const = 0;
254 virtual LOperand* result() const = 0;
256 bool HasDoubleRegisterResult();
257 bool HasDoubleRegisterInput();
259 LOperand* FirstInput() { return InputAt(0); }
260 LOperand* Output() { return HasResult() ? result() : NULL; }
262 virtual bool HasInterestingComment(LCodeGen* gen) const { return true; }
268 virtual int InputCount() = 0;
269 virtual LOperand* InputAt(int i) = 0;
273 friend class InputIterator;
275 friend class TempIterator;
276 virtual int TempCount() = 0;
277 virtual LOperand* TempAt(int i) = 0;
279 class IsCallBits: public BitField<bool, 0, 1> {};
281 LEnvironment* environment_;
282 SetOncePointer<LPointerMap> pointer_map_;
283 HValue* hydrogen_value_;
288 // R = number of result operands (0 or 1).
290 class LTemplateResultInstruction : public LInstruction {
292 // Allow 0 or 1 output operands.
293 STATIC_ASSERT(R == 0 || R == 1);
294 virtual bool HasResult() const V8_FINAL V8_OVERRIDE {
295 return R != 0 && result() != NULL;
297 void set_result(LOperand* operand) { results_[0] = operand; }
298 LOperand* result() const { return results_[0]; }
301 EmbeddedContainer<LOperand*, R> results_;
305 // R = number of result operands (0 or 1).
306 // I = number of input operands.
307 // T = number of temporary operands.
308 template<int R, int I, int T>
309 class LTemplateInstruction : public LTemplateResultInstruction<R> {
311 EmbeddedContainer<LOperand*, I> inputs_;
312 EmbeddedContainer<LOperand*, T> temps_;
316 virtual int InputCount() V8_FINAL V8_OVERRIDE { return I; }
317 virtual LOperand* InputAt(int i) V8_FINAL V8_OVERRIDE { return inputs_[i]; }
319 virtual int TempCount() V8_FINAL V8_OVERRIDE { return T; }
320 virtual LOperand* TempAt(int i) V8_FINAL V8_OVERRIDE { return temps_[i]; }
324 class LGap : public LTemplateInstruction<0, 0, 0> {
326 explicit LGap(HBasicBlock* block) : block_(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_FINAL 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(); }
393 virtual bool ClobbersDoubleRegisters(Isolate* isolate) const V8_OVERRIDE {
397 bool jumps_to_join() const { return block_->predecessors()->length() > 1; }
404 class LLazyBailout V8_FINAL : public LTemplateInstruction<0, 0, 0> {
406 DECLARE_CONCRETE_INSTRUCTION(LazyBailout, "lazy-bailout")
410 class LDummy V8_FINAL : public LTemplateInstruction<1, 0, 0> {
413 DECLARE_CONCRETE_INSTRUCTION(Dummy, "dummy")
417 class LDummyUse V8_FINAL : public LTemplateInstruction<1, 1, 0> {
419 explicit LDummyUse(LOperand* value) {
422 DECLARE_CONCRETE_INSTRUCTION(DummyUse, "dummy-use")
426 class LDeoptimize V8_FINAL : public LTemplateInstruction<0, 0, 0> {
428 virtual bool IsControl() const V8_OVERRIDE { return true; }
429 DECLARE_CONCRETE_INSTRUCTION(Deoptimize, "deoptimize")
430 DECLARE_HYDROGEN_ACCESSOR(Deoptimize)
434 class LLabel V8_FINAL : public LGap {
436 explicit LLabel(HBasicBlock* block)
437 : LGap(block), replacement_(NULL) { }
439 virtual bool HasInterestingComment(LCodeGen* gen) const V8_OVERRIDE {
442 DECLARE_CONCRETE_INSTRUCTION(Label, "label")
444 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
446 int block_id() const { return block()->block_id(); }
447 bool is_loop_header() const { return block()->IsLoopHeader(); }
448 bool is_osr_entry() const { return block()->is_osr_entry(); }
449 Label* label() { return &label_; }
450 LLabel* replacement() const { return replacement_; }
451 void set_replacement(LLabel* label) { replacement_ = label; }
452 bool HasReplacement() const { return replacement_ != NULL; }
456 LLabel* replacement_;
460 class LParameter V8_FINAL : public LTemplateInstruction<1, 0, 0> {
462 virtual bool HasInterestingComment(LCodeGen* gen) const V8_OVERRIDE {
465 DECLARE_CONCRETE_INSTRUCTION(Parameter, "parameter")
469 class LCallStub V8_FINAL : public LTemplateInstruction<1, 1, 0> {
471 explicit LCallStub(LOperand* context) {
472 inputs_[0] = context;
475 LOperand* context() { return inputs_[0]; }
477 DECLARE_CONCRETE_INSTRUCTION(CallStub, "call-stub")
478 DECLARE_HYDROGEN_ACCESSOR(CallStub)
482 class LUnknownOSRValue V8_FINAL : public LTemplateInstruction<1, 0, 0> {
484 virtual bool HasInterestingComment(LCodeGen* gen) const V8_OVERRIDE {
487 DECLARE_CONCRETE_INSTRUCTION(UnknownOSRValue, "unknown-osr-value")
491 template<int I, int T>
492 class LControlInstruction: public LTemplateInstruction<0, I, T> {
494 LControlInstruction() : false_label_(NULL), true_label_(NULL) { }
496 virtual bool IsControl() const V8_FINAL V8_OVERRIDE { return true; }
498 int SuccessorCount() { return hydrogen()->SuccessorCount(); }
499 HBasicBlock* SuccessorAt(int i) { return hydrogen()->SuccessorAt(i); }
501 int TrueDestination(LChunk* chunk) {
502 return chunk->LookupDestination(true_block_id());
504 int FalseDestination(LChunk* chunk) {
505 return chunk->LookupDestination(false_block_id());
508 Label* TrueLabel(LChunk* chunk) {
509 if (true_label_ == NULL) {
510 true_label_ = chunk->GetAssemblyLabel(TrueDestination(chunk));
514 Label* FalseLabel(LChunk* chunk) {
515 if (false_label_ == NULL) {
516 false_label_ = chunk->GetAssemblyLabel(FalseDestination(chunk));
522 int true_block_id() { return SuccessorAt(0)->block_id(); }
523 int false_block_id() { return SuccessorAt(1)->block_id(); }
526 HControlInstruction* hydrogen() {
527 return HControlInstruction::cast(this->hydrogen_value());
535 class LWrapReceiver V8_FINAL : public LTemplateInstruction<1, 2, 1> {
537 LWrapReceiver(LOperand* receiver,
540 inputs_[0] = receiver;
541 inputs_[1] = function;
545 LOperand* receiver() { return inputs_[0]; }
546 LOperand* function() { return inputs_[1]; }
547 LOperand* temp() { return temps_[0]; }
549 DECLARE_CONCRETE_INSTRUCTION(WrapReceiver, "wrap-receiver")
550 DECLARE_HYDROGEN_ACCESSOR(WrapReceiver)
554 class LApplyArguments V8_FINAL : public LTemplateInstruction<1, 4, 0> {
556 LApplyArguments(LOperand* function,
559 LOperand* elements) {
560 inputs_[0] = function;
561 inputs_[1] = receiver;
563 inputs_[3] = elements;
566 LOperand* function() { return inputs_[0]; }
567 LOperand* receiver() { return inputs_[1]; }
568 LOperand* length() { return inputs_[2]; }
569 LOperand* elements() { return inputs_[3]; }
571 DECLARE_CONCRETE_INSTRUCTION(ApplyArguments, "apply-arguments")
575 class LAccessArgumentsAt V8_FINAL : public LTemplateInstruction<1, 3, 0> {
577 LAccessArgumentsAt(LOperand* arguments, LOperand* length, LOperand* index) {
578 inputs_[0] = arguments;
583 LOperand* arguments() { return inputs_[0]; }
584 LOperand* length() { return inputs_[1]; }
585 LOperand* index() { return inputs_[2]; }
587 DECLARE_CONCRETE_INSTRUCTION(AccessArgumentsAt, "access-arguments-at")
589 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
593 class LArgumentsLength V8_FINAL : public LTemplateInstruction<1, 1, 0> {
595 explicit LArgumentsLength(LOperand* elements) {
596 inputs_[0] = elements;
599 LOperand* elements() { return inputs_[0]; }
601 DECLARE_CONCRETE_INSTRUCTION(ArgumentsLength, "arguments-length")
605 class LArgumentsElements V8_FINAL : public LTemplateInstruction<1, 0, 0> {
607 DECLARE_CONCRETE_INSTRUCTION(ArgumentsElements, "arguments-elements")
608 DECLARE_HYDROGEN_ACCESSOR(ArgumentsElements)
612 class LDebugBreak V8_FINAL : public LTemplateInstruction<0, 0, 0> {
614 DECLARE_CONCRETE_INSTRUCTION(DebugBreak, "break")
618 class LModByPowerOf2I V8_FINAL : public LTemplateInstruction<1, 1, 0> {
620 LModByPowerOf2I(LOperand* dividend, int32_t divisor) {
621 inputs_[0] = dividend;
625 LOperand* dividend() { return inputs_[0]; }
626 int32_t divisor() const { return divisor_; }
628 DECLARE_CONCRETE_INSTRUCTION(ModByPowerOf2I, "mod-by-power-of-2-i")
629 DECLARE_HYDROGEN_ACCESSOR(Mod)
636 class LModByConstI V8_FINAL : public LTemplateInstruction<1, 1, 2> {
638 LModByConstI(LOperand* dividend,
642 inputs_[0] = dividend;
648 LOperand* dividend() { return inputs_[0]; }
649 int32_t divisor() const { return divisor_; }
650 LOperand* temp1() { return temps_[0]; }
651 LOperand* temp2() { return temps_[1]; }
653 DECLARE_CONCRETE_INSTRUCTION(ModByConstI, "mod-by-const-i")
654 DECLARE_HYDROGEN_ACCESSOR(Mod)
661 class LModI V8_FINAL : public LTemplateInstruction<1, 2, 1> {
663 LModI(LOperand* left, LOperand* right, LOperand* temp) {
669 LOperand* left() { return inputs_[0]; }
670 LOperand* right() { return inputs_[1]; }
671 LOperand* temp() { return temps_[0]; }
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, 2> {
698 LDivByConstI(LOperand* dividend,
702 inputs_[0] = dividend;
708 LOperand* dividend() { return inputs_[0]; }
709 int32_t divisor() const { return divisor_; }
710 LOperand* temp1() { return temps_[0]; }
711 LOperand* temp2() { return temps_[1]; }
713 DECLARE_CONCRETE_INSTRUCTION(DivByConstI, "div-by-const-i")
714 DECLARE_HYDROGEN_ACCESSOR(Div)
721 class LDivI V8_FINAL : public LTemplateInstruction<1, 2, 1> {
723 LDivI(LOperand* dividend, LOperand* divisor, LOperand* temp) {
724 inputs_[0] = dividend;
725 inputs_[1] = divisor;
729 LOperand* dividend() { return inputs_[0]; }
730 LOperand* divisor() { return inputs_[1]; }
731 LOperand* temp() { return temps_[0]; }
733 DECLARE_CONCRETE_INSTRUCTION(DivI, "div-i")
734 DECLARE_HYDROGEN_ACCESSOR(BinaryOperation)
738 class LFlooringDivByPowerOf2I V8_FINAL : public LTemplateInstruction<1, 1, 0> {
740 LFlooringDivByPowerOf2I(LOperand* dividend, int32_t divisor) {
741 inputs_[0] = dividend;
745 LOperand* dividend() { return inputs_[0]; }
746 int32_t divisor() const { return divisor_; }
748 DECLARE_CONCRETE_INSTRUCTION(FlooringDivByPowerOf2I,
749 "flooring-div-by-power-of-2-i")
750 DECLARE_HYDROGEN_ACCESSOR(MathFloorOfDiv)
757 class LFlooringDivByConstI V8_FINAL : public LTemplateInstruction<1, 1, 3> {
759 LFlooringDivByConstI(LOperand* dividend,
764 inputs_[0] = dividend;
771 LOperand* dividend() { return inputs_[0]; }
772 int32_t divisor() const { return divisor_; }
773 LOperand* temp1() { return temps_[0]; }
774 LOperand* temp2() { return temps_[1]; }
775 LOperand* temp3() { return temps_[2]; }
777 DECLARE_CONCRETE_INSTRUCTION(FlooringDivByConstI, "flooring-div-by-const-i")
778 DECLARE_HYDROGEN_ACCESSOR(MathFloorOfDiv)
785 class LFlooringDivI V8_FINAL : public LTemplateInstruction<1, 2, 1> {
787 LFlooringDivI(LOperand* dividend, LOperand* divisor, LOperand* temp) {
788 inputs_[0] = dividend;
789 inputs_[1] = divisor;
793 LOperand* dividend() { return inputs_[0]; }
794 LOperand* divisor() { return inputs_[1]; }
795 LOperand* temp() { return temps_[0]; }
797 DECLARE_CONCRETE_INSTRUCTION(FlooringDivI, "flooring-div-i")
798 DECLARE_HYDROGEN_ACCESSOR(MathFloorOfDiv)
802 class LMulI V8_FINAL : public LTemplateInstruction<1, 2, 1> {
804 LMulI(LOperand* left, LOperand* right, LOperand* temp) {
810 LOperand* left() { return inputs_[0]; }
811 LOperand* right() { return inputs_[1]; }
812 LOperand* temp() { return temps_[0]; }
814 DECLARE_CONCRETE_INSTRUCTION(MulI, "mul-i")
815 DECLARE_HYDROGEN_ACCESSOR(Mul)
819 class LCompareNumericAndBranch V8_FINAL : public LControlInstruction<2, 0> {
821 LCompareNumericAndBranch(LOperand* left, LOperand* right) {
826 LOperand* left() { return inputs_[0]; }
827 LOperand* right() { return inputs_[1]; }
829 DECLARE_CONCRETE_INSTRUCTION(CompareNumericAndBranch,
830 "compare-numeric-and-branch")
831 DECLARE_HYDROGEN_ACCESSOR(CompareNumericAndBranch)
833 Token::Value op() const { return hydrogen()->token(); }
834 bool is_double() const {
835 return hydrogen()->representation().IsDouble();
838 virtual void PrintDataTo(StringStream* stream);
842 class LMathFloor V8_FINAL : public LTemplateInstruction<1, 1, 0> {
844 explicit LMathFloor(LOperand* value) {
848 LOperand* value() { return inputs_[0]; }
850 DECLARE_CONCRETE_INSTRUCTION(MathFloor, "math-floor")
851 DECLARE_HYDROGEN_ACCESSOR(UnaryMathOperation)
855 class LMathRound V8_FINAL : public LTemplateInstruction<1, 1, 1> {
857 LMathRound(LOperand* value, LOperand* temp) {
862 LOperand* temp() { return temps_[0]; }
863 LOperand* value() { return inputs_[0]; }
865 DECLARE_CONCRETE_INSTRUCTION(MathRound, "math-round")
866 DECLARE_HYDROGEN_ACCESSOR(UnaryMathOperation)
870 class LMathFround V8_FINAL : public LTemplateInstruction<1, 1, 0> {
872 explicit LMathFround(LOperand* value) { inputs_[0] = value; }
874 LOperand* value() { return inputs_[0]; }
876 DECLARE_CONCRETE_INSTRUCTION(MathFround, "math-fround")
880 class LMathAbs V8_FINAL : public LTemplateInstruction<1, 2, 0> {
882 LMathAbs(LOperand* context, LOperand* value) {
883 inputs_[1] = context;
887 LOperand* context() { return inputs_[1]; }
888 LOperand* value() { return inputs_[0]; }
890 DECLARE_CONCRETE_INSTRUCTION(MathAbs, "math-abs")
891 DECLARE_HYDROGEN_ACCESSOR(UnaryMathOperation)
895 class LMathLog V8_FINAL : public LTemplateInstruction<1, 1, 0> {
897 explicit LMathLog(LOperand* value) {
901 LOperand* value() { return inputs_[0]; }
903 DECLARE_CONCRETE_INSTRUCTION(MathLog, "math-log")
907 class LMathClz32 V8_FINAL : public LTemplateInstruction<1, 1, 0> {
909 explicit LMathClz32(LOperand* value) {
913 LOperand* value() { return inputs_[0]; }
915 DECLARE_CONCRETE_INSTRUCTION(MathClz32, "math-clz32")
919 class LMathExp V8_FINAL : public LTemplateInstruction<1, 1, 2> {
921 LMathExp(LOperand* value,
927 ExternalReference::InitializeMathExpData();
930 LOperand* value() { return inputs_[0]; }
931 LOperand* temp1() { return temps_[0]; }
932 LOperand* temp2() { return temps_[1]; }
934 DECLARE_CONCRETE_INSTRUCTION(MathExp, "math-exp")
938 class LMathSqrt V8_FINAL : public LTemplateInstruction<1, 1, 0> {
940 explicit LMathSqrt(LOperand* value) {
944 LOperand* value() { return inputs_[0]; }
946 DECLARE_CONCRETE_INSTRUCTION(MathSqrt, "math-sqrt")
950 class LMathPowHalf V8_FINAL : public LTemplateInstruction<1, 1, 1> {
952 LMathPowHalf(LOperand* value, LOperand* temp) {
957 LOperand* value() { return inputs_[0]; }
958 LOperand* temp() { return temps_[0]; }
960 DECLARE_CONCRETE_INSTRUCTION(MathPowHalf, "math-pow-half")
964 class LCmpObjectEqAndBranch V8_FINAL : public LControlInstruction<2, 0> {
966 LCmpObjectEqAndBranch(LOperand* left, LOperand* right) {
971 LOperand* left() { return inputs_[0]; }
972 LOperand* right() { return inputs_[1]; }
974 DECLARE_CONCRETE_INSTRUCTION(CmpObjectEqAndBranch, "cmp-object-eq-and-branch")
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")
1019 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1023 class LIsStringAndBranch V8_FINAL : public LControlInstruction<1, 1> {
1025 LIsStringAndBranch(LOperand* value, LOperand* temp) {
1030 LOperand* value() { return inputs_[0]; }
1031 LOperand* temp() { return temps_[0]; }
1033 DECLARE_CONCRETE_INSTRUCTION(IsStringAndBranch, "is-string-and-branch")
1034 DECLARE_HYDROGEN_ACCESSOR(IsStringAndBranch)
1036 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1040 class LIsSmiAndBranch V8_FINAL : public LControlInstruction<1, 0> {
1042 explicit LIsSmiAndBranch(LOperand* value) {
1046 LOperand* value() { return inputs_[0]; }
1048 DECLARE_CONCRETE_INSTRUCTION(IsSmiAndBranch, "is-smi-and-branch")
1049 DECLARE_HYDROGEN_ACCESSOR(IsSmiAndBranch)
1051 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1055 class LIsUndetectableAndBranch V8_FINAL : public LControlInstruction<1, 1> {
1057 LIsUndetectableAndBranch(LOperand* value, LOperand* temp) {
1062 LOperand* value() { return inputs_[0]; }
1063 LOperand* temp() { return temps_[0]; }
1065 DECLARE_CONCRETE_INSTRUCTION(IsUndetectableAndBranch,
1066 "is-undetectable-and-branch")
1067 DECLARE_HYDROGEN_ACCESSOR(IsUndetectableAndBranch)
1069 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1073 class LStringCompareAndBranch V8_FINAL : public LControlInstruction<3, 0> {
1075 LStringCompareAndBranch(LOperand* context, LOperand* left, LOperand* right) {
1076 inputs_[0] = context;
1081 LOperand* context() { return inputs_[1]; }
1082 LOperand* left() { return inputs_[1]; }
1083 LOperand* right() { return inputs_[2]; }
1085 DECLARE_CONCRETE_INSTRUCTION(StringCompareAndBranch,
1086 "string-compare-and-branch")
1087 DECLARE_HYDROGEN_ACCESSOR(StringCompareAndBranch)
1089 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1091 Token::Value op() const { return hydrogen()->token(); }
1095 class LHasInstanceTypeAndBranch V8_FINAL : public LControlInstruction<1, 1> {
1097 LHasInstanceTypeAndBranch(LOperand* value, LOperand* temp) {
1102 LOperand* value() { return inputs_[0]; }
1103 LOperand* temp() { return temps_[0]; }
1105 DECLARE_CONCRETE_INSTRUCTION(HasInstanceTypeAndBranch,
1106 "has-instance-type-and-branch")
1107 DECLARE_HYDROGEN_ACCESSOR(HasInstanceTypeAndBranch)
1109 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1113 class LGetCachedArrayIndex V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1115 explicit LGetCachedArrayIndex(LOperand* value) {
1119 LOperand* value() { return inputs_[0]; }
1121 DECLARE_CONCRETE_INSTRUCTION(GetCachedArrayIndex, "get-cached-array-index")
1122 DECLARE_HYDROGEN_ACCESSOR(GetCachedArrayIndex)
1126 class LHasCachedArrayIndexAndBranch V8_FINAL
1127 : public LControlInstruction<1, 0> {
1129 explicit LHasCachedArrayIndexAndBranch(LOperand* value) {
1133 LOperand* value() { return inputs_[0]; }
1135 DECLARE_CONCRETE_INSTRUCTION(HasCachedArrayIndexAndBranch,
1136 "has-cached-array-index-and-branch")
1138 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1142 class LIsConstructCallAndBranch V8_FINAL : public LControlInstruction<0, 1> {
1144 explicit LIsConstructCallAndBranch(LOperand* temp) {
1148 LOperand* temp() { return temps_[0]; }
1150 DECLARE_CONCRETE_INSTRUCTION(IsConstructCallAndBranch,
1151 "is-construct-call-and-branch")
1155 class LClassOfTestAndBranch V8_FINAL : public LControlInstruction<1, 2> {
1157 LClassOfTestAndBranch(LOperand* value, LOperand* temp, LOperand* temp2) {
1163 LOperand* value() { return inputs_[0]; }
1164 LOperand* temp() { return temps_[0]; }
1165 LOperand* temp2() { return temps_[1]; }
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 DECLARE_CONCRETE_INSTRUCTION(CmpT, "cmp-t")
1184 DECLARE_HYDROGEN_ACCESSOR(CompareGeneric)
1186 LOperand* context() { return inputs_[0]; }
1187 Token::Value op() const { return hydrogen()->token(); }
1191 class LInstanceOf V8_FINAL : public LTemplateInstruction<1, 3, 0> {
1193 LInstanceOf(LOperand* context, LOperand* left, LOperand* right) {
1194 inputs_[0] = context;
1199 LOperand* context() { return inputs_[0]; }
1201 DECLARE_CONCRETE_INSTRUCTION(InstanceOf, "instance-of")
1205 class LInstanceOfKnownGlobal V8_FINAL : public LTemplateInstruction<1, 2, 1> {
1207 LInstanceOfKnownGlobal(LOperand* context, LOperand* value, LOperand* temp) {
1208 inputs_[0] = context;
1213 LOperand* context() { return inputs_[0]; }
1214 LOperand* value() { return inputs_[1]; }
1215 LOperand* temp() { return temps_[0]; }
1217 DECLARE_CONCRETE_INSTRUCTION(InstanceOfKnownGlobal,
1218 "instance-of-known-global")
1219 DECLARE_HYDROGEN_ACCESSOR(InstanceOfKnownGlobal)
1221 Handle<JSFunction> function() const { return hydrogen()->function(); }
1222 LEnvironment* GetDeferredLazyDeoptimizationEnvironment() {
1223 return lazy_deopt_env_;
1225 virtual void SetDeferredLazyDeoptimizationEnvironment(
1226 LEnvironment* env) V8_OVERRIDE {
1227 lazy_deopt_env_ = env;
1231 LEnvironment* lazy_deopt_env_;
1235 class LBoundsCheck V8_FINAL : public LTemplateInstruction<0, 2, 0> {
1237 LBoundsCheck(LOperand* index, LOperand* length) {
1239 inputs_[1] = length;
1242 LOperand* index() { return inputs_[0]; }
1243 LOperand* length() { return inputs_[1]; }
1245 DECLARE_CONCRETE_INSTRUCTION(BoundsCheck, "bounds-check")
1246 DECLARE_HYDROGEN_ACCESSOR(BoundsCheck)
1250 class LBitI V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1252 LBitI(LOperand* left, LOperand* right) {
1257 LOperand* left() { return inputs_[0]; }
1258 LOperand* right() { return inputs_[1]; }
1260 DECLARE_CONCRETE_INSTRUCTION(BitI, "bit-i")
1261 DECLARE_HYDROGEN_ACCESSOR(Bitwise)
1263 Token::Value op() const { return hydrogen()->op(); }
1267 class LShiftI V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1269 LShiftI(Token::Value op, LOperand* left, LOperand* right, bool can_deopt)
1270 : op_(op), can_deopt_(can_deopt) {
1275 LOperand* left() { return inputs_[0]; }
1276 LOperand* right() { return inputs_[1]; }
1278 DECLARE_CONCRETE_INSTRUCTION(ShiftI, "shift-i")
1280 Token::Value op() const { return op_; }
1281 bool can_deopt() const { return can_deopt_; }
1289 class LSubI V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1291 LSubI(LOperand* left, LOperand* right) {
1296 LOperand* left() { return inputs_[0]; }
1297 LOperand* right() { return inputs_[1]; }
1299 DECLARE_CONCRETE_INSTRUCTION(SubI, "sub-i")
1300 DECLARE_HYDROGEN_ACCESSOR(Sub)
1304 class LConstantI V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1306 DECLARE_CONCRETE_INSTRUCTION(ConstantI, "constant-i")
1307 DECLARE_HYDROGEN_ACCESSOR(Constant)
1309 int32_t value() const { return hydrogen()->Integer32Value(); }
1313 class LConstantS V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1315 DECLARE_CONCRETE_INSTRUCTION(ConstantS, "constant-s")
1316 DECLARE_HYDROGEN_ACCESSOR(Constant)
1318 Smi* value() const { return Smi::FromInt(hydrogen()->Integer32Value()); }
1322 class LConstantD V8_FINAL : public LTemplateInstruction<1, 0, 1> {
1324 explicit LConstantD(LOperand* temp) {
1328 LOperand* temp() { return temps_[0]; }
1330 DECLARE_CONCRETE_INSTRUCTION(ConstantD, "constant-d")
1331 DECLARE_HYDROGEN_ACCESSOR(Constant)
1333 double value() const { return hydrogen()->DoubleValue(); }
1337 class LConstantE V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1339 DECLARE_CONCRETE_INSTRUCTION(ConstantE, "constant-e")
1340 DECLARE_HYDROGEN_ACCESSOR(Constant)
1342 ExternalReference value() const {
1343 return hydrogen()->ExternalReferenceValue();
1348 class LConstantT V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1350 DECLARE_CONCRETE_INSTRUCTION(ConstantT, "constant-t")
1351 DECLARE_HYDROGEN_ACCESSOR(Constant)
1353 Handle<Object> value(Isolate* isolate) const {
1354 return hydrogen()->handle(isolate);
1359 class LBranch V8_FINAL : public LControlInstruction<1, 1> {
1361 LBranch(LOperand* value, LOperand* temp) {
1366 LOperand* value() { return inputs_[0]; }
1367 LOperand* temp() { return temps_[0]; }
1369 DECLARE_CONCRETE_INSTRUCTION(Branch, "branch")
1370 DECLARE_HYDROGEN_ACCESSOR(Branch)
1372 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1376 class LCmpMapAndBranch V8_FINAL : public LControlInstruction<1, 0> {
1378 explicit LCmpMapAndBranch(LOperand* value) {
1382 LOperand* value() { return inputs_[0]; }
1384 DECLARE_CONCRETE_INSTRUCTION(CmpMapAndBranch, "cmp-map-and-branch")
1385 DECLARE_HYDROGEN_ACCESSOR(CompareMap)
1387 Handle<Map> map() const { return hydrogen()->map().handle(); }
1391 class LMapEnumLength V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1393 explicit LMapEnumLength(LOperand* value) {
1397 LOperand* value() { return inputs_[0]; }
1399 DECLARE_CONCRETE_INSTRUCTION(MapEnumLength, "map-enum-length")
1403 class LDateField V8_FINAL : public LTemplateInstruction<1, 1, 1> {
1405 LDateField(LOperand* date, LOperand* temp, Smi* index)
1411 LOperand* date() { return inputs_[0]; }
1412 LOperand* temp() { return temps_[0]; }
1414 DECLARE_CONCRETE_INSTRUCTION(DateField, "date-field")
1415 DECLARE_HYDROGEN_ACCESSOR(DateField)
1417 Smi* index() const { return index_; }
1424 class LSeqStringGetChar V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1426 LSeqStringGetChar(LOperand* string, LOperand* index) {
1427 inputs_[0] = string;
1431 LOperand* string() const { return inputs_[0]; }
1432 LOperand* index() const { return inputs_[1]; }
1434 DECLARE_CONCRETE_INSTRUCTION(SeqStringGetChar, "seq-string-get-char")
1435 DECLARE_HYDROGEN_ACCESSOR(SeqStringGetChar)
1439 class LSeqStringSetChar V8_FINAL : public LTemplateInstruction<1, 4, 0> {
1441 LSeqStringSetChar(LOperand* context,
1445 inputs_[0] = context;
1446 inputs_[1] = string;
1451 LOperand* string() { return inputs_[1]; }
1452 LOperand* index() { return inputs_[2]; }
1453 LOperand* value() { return inputs_[3]; }
1455 DECLARE_CONCRETE_INSTRUCTION(SeqStringSetChar, "seq-string-set-char")
1456 DECLARE_HYDROGEN_ACCESSOR(SeqStringSetChar)
1460 class LAddI V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1462 LAddI(LOperand* left, LOperand* right) {
1467 LOperand* left() { return inputs_[0]; }
1468 LOperand* right() { return inputs_[1]; }
1470 static bool UseLea(HAdd* add) {
1471 return !add->CheckFlag(HValue::kCanOverflow) &&
1472 add->BetterLeftOperand()->UseCount() > 1;
1475 DECLARE_CONCRETE_INSTRUCTION(AddI, "add-i")
1476 DECLARE_HYDROGEN_ACCESSOR(Add)
1480 class LMathMinMax V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1482 LMathMinMax(LOperand* left, LOperand* right) {
1487 LOperand* left() { return inputs_[0]; }
1488 LOperand* right() { return inputs_[1]; }
1490 DECLARE_CONCRETE_INSTRUCTION(MathMinMax, "math-min-max")
1491 DECLARE_HYDROGEN_ACCESSOR(MathMinMax)
1495 class LPower V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1497 LPower(LOperand* left, LOperand* right) {
1502 LOperand* left() { return inputs_[0]; }
1503 LOperand* right() { return inputs_[1]; }
1505 DECLARE_CONCRETE_INSTRUCTION(Power, "power")
1506 DECLARE_HYDROGEN_ACCESSOR(Power)
1510 class LArithmeticD V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1512 LArithmeticD(Token::Value op, LOperand* left, LOperand* right)
1518 LOperand* left() { return inputs_[0]; }
1519 LOperand* right() { return inputs_[1]; }
1521 Token::Value op() const { return op_; }
1523 virtual Opcode opcode() const V8_OVERRIDE {
1524 return LInstruction::kArithmeticD;
1526 virtual void CompileToNative(LCodeGen* generator) V8_OVERRIDE;
1527 virtual const char* Mnemonic() const V8_OVERRIDE;
1534 class LArithmeticT V8_FINAL : public LTemplateInstruction<1, 3, 0> {
1536 LArithmeticT(Token::Value op,
1541 inputs_[0] = context;
1546 LOperand* context() { return inputs_[0]; }
1547 LOperand* left() { return inputs_[1]; }
1548 LOperand* right() { return inputs_[2]; }
1550 virtual Opcode opcode() const V8_OVERRIDE {
1551 return LInstruction::kArithmeticT;
1553 virtual void CompileToNative(LCodeGen* generator) V8_OVERRIDE;
1554 virtual const char* Mnemonic() const V8_OVERRIDE;
1556 Token::Value op() const { return op_; }
1563 class LReturn V8_FINAL : public LTemplateInstruction<0, 3, 0> {
1565 explicit LReturn(LOperand* value,
1567 LOperand* parameter_count) {
1569 inputs_[1] = context;
1570 inputs_[2] = parameter_count;
1573 bool has_constant_parameter_count() {
1574 return parameter_count()->IsConstantOperand();
1576 LConstantOperand* constant_parameter_count() {
1577 DCHECK(has_constant_parameter_count());
1578 return LConstantOperand::cast(parameter_count());
1580 LOperand* parameter_count() { return inputs_[2]; }
1582 DECLARE_CONCRETE_INSTRUCTION(Return, "return")
1583 DECLARE_HYDROGEN_ACCESSOR(Return)
1587 class LLoadNamedField V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1589 explicit LLoadNamedField(LOperand* object) {
1590 inputs_[0] = object;
1593 LOperand* object() { return inputs_[0]; }
1595 DECLARE_CONCRETE_INSTRUCTION(LoadNamedField, "load-named-field")
1596 DECLARE_HYDROGEN_ACCESSOR(LoadNamedField)
1600 class LLoadNamedGeneric V8_FINAL : public LTemplateInstruction<1, 2, 1> {
1602 LLoadNamedGeneric(LOperand* context, LOperand* object, LOperand* vector) {
1603 inputs_[0] = context;
1604 inputs_[1] = object;
1608 LOperand* context() { return inputs_[0]; }
1609 LOperand* object() { return inputs_[1]; }
1610 LOperand* temp_vector() { return temps_[0]; }
1612 DECLARE_CONCRETE_INSTRUCTION(LoadNamedGeneric, "load-named-generic")
1613 DECLARE_HYDROGEN_ACCESSOR(LoadNamedGeneric)
1615 Handle<Object> name() const { return hydrogen()->name(); }
1619 class LLoadFunctionPrototype V8_FINAL : public LTemplateInstruction<1, 1, 1> {
1621 LLoadFunctionPrototype(LOperand* function, LOperand* temp) {
1622 inputs_[0] = function;
1626 LOperand* function() { return inputs_[0]; }
1627 LOperand* temp() { return temps_[0]; }
1629 DECLARE_CONCRETE_INSTRUCTION(LoadFunctionPrototype, "load-function-prototype")
1630 DECLARE_HYDROGEN_ACCESSOR(LoadFunctionPrototype)
1634 class LLoadRoot V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1636 DECLARE_CONCRETE_INSTRUCTION(LoadRoot, "load-root")
1637 DECLARE_HYDROGEN_ACCESSOR(LoadRoot)
1639 Heap::RootListIndex index() const { return hydrogen()->index(); }
1643 class LLoadKeyed V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1645 LLoadKeyed(LOperand* elements, LOperand* key) {
1646 inputs_[0] = elements;
1649 LOperand* elements() { return inputs_[0]; }
1650 LOperand* key() { return inputs_[1]; }
1651 ElementsKind elements_kind() const {
1652 return hydrogen()->elements_kind();
1654 bool is_external() const {
1655 return hydrogen()->is_external();
1657 bool is_fixed_typed_array() const {
1658 return hydrogen()->is_fixed_typed_array();
1660 bool is_typed_elements() const {
1661 return is_external() || is_fixed_typed_array();
1664 DECLARE_CONCRETE_INSTRUCTION(LoadKeyed, "load-keyed")
1665 DECLARE_HYDROGEN_ACCESSOR(LoadKeyed)
1667 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1668 uint32_t base_offset() const { return hydrogen()->base_offset(); }
1670 return hydrogen()->key()->representation().IsTagged();
1675 inline static bool ExternalArrayOpRequiresTemp(
1676 Representation key_representation,
1677 ElementsKind elements_kind) {
1678 // Operations that require the key to be divided by two to be converted into
1679 // an index cannot fold the scale operation into a load and need an extra
1680 // temp register to do the work.
1681 return key_representation.IsSmi() &&
1682 (elements_kind == EXTERNAL_INT8_ELEMENTS ||
1683 elements_kind == EXTERNAL_UINT8_ELEMENTS ||
1684 elements_kind == EXTERNAL_UINT8_CLAMPED_ELEMENTS ||
1685 elements_kind == UINT8_ELEMENTS ||
1686 elements_kind == INT8_ELEMENTS ||
1687 elements_kind == UINT8_CLAMPED_ELEMENTS);
1691 class LLoadKeyedGeneric V8_FINAL : public LTemplateInstruction<1, 3, 1> {
1693 LLoadKeyedGeneric(LOperand* context, LOperand* obj, LOperand* key,
1695 inputs_[0] = context;
1701 LOperand* context() { return inputs_[0]; }
1702 LOperand* object() { return inputs_[1]; }
1703 LOperand* key() { return inputs_[2]; }
1704 LOperand* temp_vector() { return temps_[0]; }
1706 DECLARE_CONCRETE_INSTRUCTION(LoadKeyedGeneric, "load-keyed-generic")
1707 DECLARE_HYDROGEN_ACCESSOR(LoadKeyedGeneric)
1711 class LLoadGlobalCell V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1713 DECLARE_CONCRETE_INSTRUCTION(LoadGlobalCell, "load-global-cell")
1714 DECLARE_HYDROGEN_ACCESSOR(LoadGlobalCell)
1718 class LLoadGlobalGeneric V8_FINAL : public LTemplateInstruction<1, 2, 1> {
1720 LLoadGlobalGeneric(LOperand* context, LOperand* global_object,
1722 inputs_[0] = context;
1723 inputs_[1] = global_object;
1727 LOperand* context() { return inputs_[0]; }
1728 LOperand* global_object() { return inputs_[1]; }
1729 LOperand* temp_vector() { return temps_[0]; }
1731 DECLARE_CONCRETE_INSTRUCTION(LoadGlobalGeneric, "load-global-generic")
1732 DECLARE_HYDROGEN_ACCESSOR(LoadGlobalGeneric)
1734 Handle<Object> name() const { return hydrogen()->name(); }
1735 bool for_typeof() const { return hydrogen()->for_typeof(); }
1739 class LStoreGlobalCell V8_FINAL : public LTemplateInstruction<0, 1, 0> {
1741 explicit LStoreGlobalCell(LOperand* value) {
1745 LOperand* value() { return inputs_[0]; }
1747 DECLARE_CONCRETE_INSTRUCTION(StoreGlobalCell, "store-global-cell")
1748 DECLARE_HYDROGEN_ACCESSOR(StoreGlobalCell)
1752 class LLoadContextSlot V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1754 explicit LLoadContextSlot(LOperand* context) {
1755 inputs_[0] = context;
1758 LOperand* context() { return inputs_[0]; }
1760 DECLARE_CONCRETE_INSTRUCTION(LoadContextSlot, "load-context-slot")
1761 DECLARE_HYDROGEN_ACCESSOR(LoadContextSlot)
1763 int slot_index() { return hydrogen()->slot_index(); }
1765 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1769 class LStoreContextSlot V8_FINAL : public LTemplateInstruction<0, 2, 1> {
1771 LStoreContextSlot(LOperand* context, LOperand* value, LOperand* temp) {
1772 inputs_[0] = context;
1777 LOperand* context() { return inputs_[0]; }
1778 LOperand* value() { return inputs_[1]; }
1779 LOperand* temp() { return temps_[0]; }
1781 DECLARE_CONCRETE_INSTRUCTION(StoreContextSlot, "store-context-slot")
1782 DECLARE_HYDROGEN_ACCESSOR(StoreContextSlot)
1784 int slot_index() { return hydrogen()->slot_index(); }
1786 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1790 class LPushArgument V8_FINAL : public LTemplateInstruction<0, 1, 0> {
1792 explicit LPushArgument(LOperand* value) {
1796 LOperand* value() { return inputs_[0]; }
1798 DECLARE_CONCRETE_INSTRUCTION(PushArgument, "push-argument")
1802 class LDrop V8_FINAL : public LTemplateInstruction<0, 0, 0> {
1804 explicit LDrop(int count) : count_(count) { }
1806 int count() const { return count_; }
1808 DECLARE_CONCRETE_INSTRUCTION(Drop, "drop")
1815 class LStoreCodeEntry V8_FINAL: public LTemplateInstruction<0, 2, 0> {
1817 LStoreCodeEntry(LOperand* function, LOperand* code_object) {
1818 inputs_[0] = function;
1819 inputs_[1] = code_object;
1822 LOperand* function() { return inputs_[0]; }
1823 LOperand* code_object() { return inputs_[1]; }
1825 virtual void PrintDataTo(StringStream* stream);
1827 DECLARE_CONCRETE_INSTRUCTION(StoreCodeEntry, "store-code-entry")
1828 DECLARE_HYDROGEN_ACCESSOR(StoreCodeEntry)
1832 class LInnerAllocatedObject V8_FINAL: public LTemplateInstruction<1, 2, 0> {
1834 LInnerAllocatedObject(LOperand* base_object, LOperand* offset) {
1835 inputs_[0] = base_object;
1836 inputs_[1] = offset;
1839 LOperand* base_object() const { return inputs_[0]; }
1840 LOperand* offset() const { return inputs_[1]; }
1842 virtual void PrintDataTo(StringStream* stream);
1844 DECLARE_CONCRETE_INSTRUCTION(InnerAllocatedObject, "inner-allocated-object")
1848 class LThisFunction V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1850 DECLARE_CONCRETE_INSTRUCTION(ThisFunction, "this-function")
1851 DECLARE_HYDROGEN_ACCESSOR(ThisFunction)
1855 class LContext V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1857 DECLARE_CONCRETE_INSTRUCTION(Context, "context")
1858 DECLARE_HYDROGEN_ACCESSOR(Context)
1862 class LDeclareGlobals V8_FINAL : public LTemplateInstruction<0, 1, 0> {
1864 explicit LDeclareGlobals(LOperand* context) {
1865 inputs_[0] = context;
1868 LOperand* context() { return inputs_[0]; }
1870 DECLARE_CONCRETE_INSTRUCTION(DeclareGlobals, "declare-globals")
1871 DECLARE_HYDROGEN_ACCESSOR(DeclareGlobals)
1875 class LCallJSFunction V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1877 explicit LCallJSFunction(LOperand* function) {
1878 inputs_[0] = function;
1881 LOperand* function() { return inputs_[0]; }
1883 DECLARE_CONCRETE_INSTRUCTION(CallJSFunction, "call-js-function")
1884 DECLARE_HYDROGEN_ACCESSOR(CallJSFunction)
1886 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1888 int arity() const { return hydrogen()->argument_count() - 1; }
1892 class LCallWithDescriptor V8_FINAL : public LTemplateResultInstruction<1> {
1894 LCallWithDescriptor(const InterfaceDescriptor* descriptor,
1895 const ZoneList<LOperand*>& operands,
1897 : inputs_(descriptor->GetRegisterParameterCount() + 1, zone) {
1898 DCHECK(descriptor->GetRegisterParameterCount() + 1 == operands.length());
1899 inputs_.AddAll(operands, zone);
1902 LOperand* target() const { return inputs_[0]; }
1905 DECLARE_CONCRETE_INSTRUCTION(CallWithDescriptor, "call-with-descriptor")
1906 DECLARE_HYDROGEN_ACCESSOR(CallWithDescriptor)
1908 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1910 int arity() const { return hydrogen()->argument_count() - 1; }
1912 ZoneList<LOperand*> inputs_;
1914 // Iterator support.
1915 virtual int InputCount() V8_FINAL V8_OVERRIDE { return inputs_.length(); }
1916 virtual LOperand* InputAt(int i) V8_FINAL V8_OVERRIDE { return inputs_[i]; }
1918 virtual int TempCount() V8_FINAL V8_OVERRIDE { return 0; }
1919 virtual LOperand* TempAt(int i) V8_FINAL V8_OVERRIDE { return NULL; }
1923 class LInvokeFunction V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1925 LInvokeFunction(LOperand* context, LOperand* function) {
1926 inputs_[0] = context;
1927 inputs_[1] = function;
1930 LOperand* context() { return inputs_[0]; }
1931 LOperand* function() { return inputs_[1]; }
1933 DECLARE_CONCRETE_INSTRUCTION(InvokeFunction, "invoke-function")
1934 DECLARE_HYDROGEN_ACCESSOR(InvokeFunction)
1936 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1938 int arity() const { return hydrogen()->argument_count() - 1; }
1942 class LCallFunction V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1944 explicit LCallFunction(LOperand* context, LOperand* function) {
1945 inputs_[0] = context;
1946 inputs_[1] = function;
1949 LOperand* context() { return inputs_[0]; }
1950 LOperand* function() { return inputs_[1]; }
1952 DECLARE_CONCRETE_INSTRUCTION(CallFunction, "call-function")
1953 DECLARE_HYDROGEN_ACCESSOR(CallFunction)
1955 int arity() const { return hydrogen()->argument_count() - 1; }
1959 class LCallNew V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1961 LCallNew(LOperand* context, LOperand* constructor) {
1962 inputs_[0] = context;
1963 inputs_[1] = constructor;
1966 LOperand* context() { return inputs_[0]; }
1967 LOperand* constructor() { return inputs_[1]; }
1969 DECLARE_CONCRETE_INSTRUCTION(CallNew, "call-new")
1970 DECLARE_HYDROGEN_ACCESSOR(CallNew)
1972 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1974 int arity() const { return hydrogen()->argument_count() - 1; }
1978 class LCallNewArray V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1980 LCallNewArray(LOperand* context, LOperand* constructor) {
1981 inputs_[0] = context;
1982 inputs_[1] = constructor;
1985 LOperand* context() { return inputs_[0]; }
1986 LOperand* constructor() { return inputs_[1]; }
1988 DECLARE_CONCRETE_INSTRUCTION(CallNewArray, "call-new-array")
1989 DECLARE_HYDROGEN_ACCESSOR(CallNewArray)
1991 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1993 int arity() const { return hydrogen()->argument_count() - 1; }
1997 class LCallRuntime V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1999 explicit LCallRuntime(LOperand* context) {
2000 inputs_[0] = context;
2003 LOperand* context() { return inputs_[0]; }
2005 DECLARE_CONCRETE_INSTRUCTION(CallRuntime, "call-runtime")
2006 DECLARE_HYDROGEN_ACCESSOR(CallRuntime)
2008 virtual bool ClobbersDoubleRegisters(Isolate* isolate) const V8_OVERRIDE {
2009 return save_doubles() == kDontSaveFPRegs;
2012 const Runtime::Function* function() const { return hydrogen()->function(); }
2013 int arity() const { return hydrogen()->argument_count(); }
2014 SaveFPRegsMode save_doubles() const { return hydrogen()->save_doubles(); }
2018 class LInteger32ToDouble V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2020 explicit LInteger32ToDouble(LOperand* value) {
2024 LOperand* value() { return inputs_[0]; }
2026 DECLARE_CONCRETE_INSTRUCTION(Integer32ToDouble, "int32-to-double")
2030 class LUint32ToDouble V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2032 explicit LUint32ToDouble(LOperand* value) {
2036 LOperand* value() { return inputs_[0]; }
2038 DECLARE_CONCRETE_INSTRUCTION(Uint32ToDouble, "uint32-to-double")
2042 class LNumberTagI V8_FINAL : public LTemplateInstruction<1, 1, 1> {
2044 LNumberTagI(LOperand* value, LOperand* temp) {
2049 LOperand* value() { return inputs_[0]; }
2050 LOperand* temp() { return temps_[0]; }
2052 DECLARE_CONCRETE_INSTRUCTION(NumberTagI, "number-tag-i")
2056 class LNumberTagU V8_FINAL : public LTemplateInstruction<1, 1, 1> {
2058 LNumberTagU(LOperand* value, LOperand* temp) {
2063 LOperand* value() { return inputs_[0]; }
2064 LOperand* temp() { return temps_[0]; }
2066 DECLARE_CONCRETE_INSTRUCTION(NumberTagU, "number-tag-u")
2070 class LNumberTagD V8_FINAL : public LTemplateInstruction<1, 1, 1> {
2072 LNumberTagD(LOperand* value, LOperand* temp) {
2077 LOperand* value() { return inputs_[0]; }
2078 LOperand* temp() { return temps_[0]; }
2080 DECLARE_CONCRETE_INSTRUCTION(NumberTagD, "number-tag-d")
2081 DECLARE_HYDROGEN_ACCESSOR(Change)
2085 // Sometimes truncating conversion from a tagged value to an int32.
2086 class LDoubleToI V8_FINAL : public LTemplateInstruction<1, 1, 1> {
2088 LDoubleToI(LOperand* value, LOperand* temp) {
2093 LOperand* value() { return inputs_[0]; }
2094 LOperand* temp() { return temps_[0]; }
2096 DECLARE_CONCRETE_INSTRUCTION(DoubleToI, "double-to-i")
2097 DECLARE_HYDROGEN_ACCESSOR(UnaryOperation)
2099 bool truncating() { return hydrogen()->CanTruncateToInt32(); }
2103 class LDoubleToSmi V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2105 explicit LDoubleToSmi(LOperand* value) {
2109 LOperand* value() { return inputs_[0]; }
2111 DECLARE_CONCRETE_INSTRUCTION(DoubleToSmi, "double-to-smi")
2112 DECLARE_HYDROGEN_ACCESSOR(UnaryOperation)
2116 // Truncating conversion from a tagged value to an int32.
2117 class LTaggedToI V8_FINAL : public LTemplateInstruction<1, 1, 1> {
2119 LTaggedToI(LOperand* value, LOperand* temp) {
2124 LOperand* value() { return inputs_[0]; }
2125 LOperand* temp() { return temps_[0]; }
2127 DECLARE_CONCRETE_INSTRUCTION(TaggedToI, "tagged-to-i")
2128 DECLARE_HYDROGEN_ACCESSOR(Change)
2130 bool truncating() { return hydrogen()->CanTruncateToInt32(); }
2134 class LSmiTag V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2136 explicit LSmiTag(LOperand* value) {
2140 LOperand* value() { return inputs_[0]; }
2142 DECLARE_CONCRETE_INSTRUCTION(SmiTag, "smi-tag")
2143 DECLARE_HYDROGEN_ACCESSOR(Change)
2147 class LNumberUntagD V8_FINAL : public LTemplateInstruction<1, 1, 1> {
2149 explicit LNumberUntagD(LOperand* value, LOperand* temp) {
2154 LOperand* value() { return inputs_[0]; }
2155 LOperand* temp() { return temps_[0]; }
2157 DECLARE_CONCRETE_INSTRUCTION(NumberUntagD, "double-untag")
2158 DECLARE_HYDROGEN_ACCESSOR(Change);
2162 class LSmiUntag V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2164 LSmiUntag(LOperand* value, bool needs_check)
2165 : needs_check_(needs_check) {
2169 LOperand* value() { return inputs_[0]; }
2171 DECLARE_CONCRETE_INSTRUCTION(SmiUntag, "smi-untag")
2173 bool needs_check() const { return needs_check_; }
2180 class LStoreNamedField V8_FINAL : public LTemplateInstruction<0, 2, 2> {
2182 LStoreNamedField(LOperand* obj,
2185 LOperand* temp_map) {
2189 temps_[1] = temp_map;
2192 LOperand* object() { return inputs_[0]; }
2193 LOperand* value() { return inputs_[1]; }
2194 LOperand* temp() { return temps_[0]; }
2195 LOperand* temp_map() { return temps_[1]; }
2197 DECLARE_CONCRETE_INSTRUCTION(StoreNamedField, "store-named-field")
2198 DECLARE_HYDROGEN_ACCESSOR(StoreNamedField)
2200 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
2204 class LStoreNamedGeneric V8_FINAL : public LTemplateInstruction<0, 3, 0> {
2206 LStoreNamedGeneric(LOperand* context, LOperand* object, LOperand* value) {
2207 inputs_[0] = context;
2208 inputs_[1] = object;
2212 LOperand* context() { return inputs_[0]; }
2213 LOperand* object() { return inputs_[1]; }
2214 LOperand* value() { return inputs_[2]; }
2216 DECLARE_CONCRETE_INSTRUCTION(StoreNamedGeneric, "store-named-generic")
2217 DECLARE_HYDROGEN_ACCESSOR(StoreNamedGeneric)
2219 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
2220 Handle<Object> name() const { return hydrogen()->name(); }
2221 StrictMode strict_mode() { return hydrogen()->strict_mode(); }
2225 class LStoreKeyed V8_FINAL : public LTemplateInstruction<0, 3, 0> {
2227 LStoreKeyed(LOperand* obj, LOperand* key, LOperand* val) {
2233 bool is_external() const { return hydrogen()->is_external(); }
2234 bool is_fixed_typed_array() const {
2235 return hydrogen()->is_fixed_typed_array();
2237 bool is_typed_elements() const {
2238 return is_external() || is_fixed_typed_array();
2240 LOperand* elements() { return inputs_[0]; }
2241 LOperand* key() { return inputs_[1]; }
2242 LOperand* value() { return inputs_[2]; }
2243 ElementsKind elements_kind() const {
2244 return hydrogen()->elements_kind();
2247 DECLARE_CONCRETE_INSTRUCTION(StoreKeyed, "store-keyed")
2248 DECLARE_HYDROGEN_ACCESSOR(StoreKeyed)
2250 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
2251 uint32_t base_offset() const { return hydrogen()->base_offset(); }
2252 bool NeedsCanonicalization() { return hydrogen()->NeedsCanonicalization(); }
2256 class LStoreKeyedGeneric V8_FINAL : public LTemplateInstruction<0, 4, 0> {
2258 LStoreKeyedGeneric(LOperand* context,
2262 inputs_[0] = context;
2263 inputs_[1] = object;
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, 2> {
2284 LTransitionElementsKind(LOperand* object,
2286 LOperand* new_map_temp,
2288 inputs_[0] = object;
2289 inputs_[1] = context;
2290 temps_[0] = new_map_temp;
2294 LOperand* context() { return inputs_[1]; }
2295 LOperand* object() { return inputs_[0]; }
2296 LOperand* new_map_temp() { return temps_[0]; }
2297 LOperand* temp() { return temps_[1]; }
2299 DECLARE_CONCRETE_INSTRUCTION(TransitionElementsKind,
2300 "transition-elements-kind")
2301 DECLARE_HYDROGEN_ACCESSOR(TransitionElementsKind)
2303 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
2305 Handle<Map> original_map() { return hydrogen()->original_map().handle(); }
2306 Handle<Map> transitioned_map() {
2307 return hydrogen()->transitioned_map().handle();
2309 ElementsKind from_kind() { return hydrogen()->from_kind(); }
2310 ElementsKind to_kind() { return hydrogen()->to_kind(); }
2314 class LTrapAllocationMemento V8_FINAL : public LTemplateInstruction<0, 1, 1> {
2316 LTrapAllocationMemento(LOperand* object,
2318 inputs_[0] = object;
2322 LOperand* object() { return inputs_[0]; }
2323 LOperand* temp() { return temps_[0]; }
2325 DECLARE_CONCRETE_INSTRUCTION(TrapAllocationMemento,
2326 "trap-allocation-memento")
2330 class LStringAdd V8_FINAL : public LTemplateInstruction<1, 3, 0> {
2332 LStringAdd(LOperand* context, LOperand* left, LOperand* right) {
2333 inputs_[0] = context;
2338 LOperand* context() { return inputs_[0]; }
2339 LOperand* left() { return inputs_[1]; }
2340 LOperand* right() { return inputs_[2]; }
2342 DECLARE_CONCRETE_INSTRUCTION(StringAdd, "string-add")
2343 DECLARE_HYDROGEN_ACCESSOR(StringAdd)
2347 class LStringCharCodeAt V8_FINAL : public LTemplateInstruction<1, 3, 0> {
2349 LStringCharCodeAt(LOperand* context, LOperand* string, LOperand* index) {
2350 inputs_[0] = context;
2351 inputs_[1] = string;
2355 LOperand* context() { return inputs_[0]; }
2356 LOperand* string() { return inputs_[1]; }
2357 LOperand* index() { return inputs_[2]; }
2359 DECLARE_CONCRETE_INSTRUCTION(StringCharCodeAt, "string-char-code-at")
2360 DECLARE_HYDROGEN_ACCESSOR(StringCharCodeAt)
2364 class LStringCharFromCode V8_FINAL : public LTemplateInstruction<1, 2, 0> {
2366 LStringCharFromCode(LOperand* context, LOperand* char_code) {
2367 inputs_[0] = context;
2368 inputs_[1] = char_code;
2371 LOperand* context() { return inputs_[0]; }
2372 LOperand* char_code() { return inputs_[1]; }
2374 DECLARE_CONCRETE_INSTRUCTION(StringCharFromCode, "string-char-from-code")
2375 DECLARE_HYDROGEN_ACCESSOR(StringCharFromCode)
2379 class LCheckValue V8_FINAL : public LTemplateInstruction<0, 1, 0> {
2381 explicit LCheckValue(LOperand* value) {
2385 LOperand* value() { return inputs_[0]; }
2387 DECLARE_CONCRETE_INSTRUCTION(CheckValue, "check-value")
2388 DECLARE_HYDROGEN_ACCESSOR(CheckValue)
2392 class LCheckInstanceType V8_FINAL : public LTemplateInstruction<0, 1, 1> {
2394 LCheckInstanceType(LOperand* value, LOperand* temp) {
2399 LOperand* value() { return inputs_[0]; }
2400 LOperand* temp() { return temps_[0]; }
2402 DECLARE_CONCRETE_INSTRUCTION(CheckInstanceType, "check-instance-type")
2403 DECLARE_HYDROGEN_ACCESSOR(CheckInstanceType)
2407 class LCheckMaps V8_FINAL : public LTemplateInstruction<0, 1, 0> {
2409 explicit LCheckMaps(LOperand* value = NULL) {
2413 LOperand* value() { return inputs_[0]; }
2415 DECLARE_CONCRETE_INSTRUCTION(CheckMaps, "check-maps")
2416 DECLARE_HYDROGEN_ACCESSOR(CheckMaps)
2420 class LCheckSmi V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2422 explicit LCheckSmi(LOperand* value) {
2426 LOperand* value() { return inputs_[0]; }
2428 DECLARE_CONCRETE_INSTRUCTION(CheckSmi, "check-smi")
2432 class LClampDToUint8 V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2434 explicit LClampDToUint8(LOperand* value) {
2438 LOperand* unclamped() { return inputs_[0]; }
2440 DECLARE_CONCRETE_INSTRUCTION(ClampDToUint8, "clamp-d-to-uint8")
2444 class LClampIToUint8 V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2446 explicit LClampIToUint8(LOperand* value) {
2450 LOperand* unclamped() { return inputs_[0]; }
2452 DECLARE_CONCRETE_INSTRUCTION(ClampIToUint8, "clamp-i-to-uint8")
2456 class LClampTToUint8 V8_FINAL : public LTemplateInstruction<1, 1, 1> {
2458 LClampTToUint8(LOperand* value, LOperand* temp_xmm) {
2460 temps_[0] = temp_xmm;
2463 LOperand* unclamped() { return inputs_[0]; }
2464 LOperand* temp_xmm() { return temps_[0]; }
2466 DECLARE_CONCRETE_INSTRUCTION(ClampTToUint8, "clamp-t-to-uint8")
2470 class LCheckNonSmi V8_FINAL : public LTemplateInstruction<0, 1, 0> {
2472 explicit LCheckNonSmi(LOperand* value) {
2476 LOperand* value() { return inputs_[0]; }
2478 DECLARE_CONCRETE_INSTRUCTION(CheckNonSmi, "check-non-smi")
2479 DECLARE_HYDROGEN_ACCESSOR(CheckHeapObject)
2483 class LDoubleBits V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2485 explicit LDoubleBits(LOperand* value) {
2489 LOperand* value() { return inputs_[0]; }
2491 DECLARE_CONCRETE_INSTRUCTION(DoubleBits, "double-bits")
2492 DECLARE_HYDROGEN_ACCESSOR(DoubleBits)
2496 class LConstructDouble V8_FINAL : public LTemplateInstruction<1, 2, 0> {
2498 LConstructDouble(LOperand* hi, LOperand* lo) {
2503 LOperand* hi() { return inputs_[0]; }
2504 LOperand* lo() { return inputs_[1]; }
2506 DECLARE_CONCRETE_INSTRUCTION(ConstructDouble, "construct-double")
2510 class LAllocate V8_FINAL : public LTemplateInstruction<1, 2, 1> {
2512 LAllocate(LOperand* context, LOperand* size, LOperand* temp) {
2513 inputs_[0] = context;
2518 LOperand* context() { return inputs_[0]; }
2519 LOperand* size() { return inputs_[1]; }
2520 LOperand* temp() { return temps_[0]; }
2522 DECLARE_CONCRETE_INSTRUCTION(Allocate, "allocate")
2523 DECLARE_HYDROGEN_ACCESSOR(Allocate)
2527 class LRegExpLiteral V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2529 explicit LRegExpLiteral(LOperand* context) {
2530 inputs_[0] = context;
2533 LOperand* context() { return inputs_[0]; }
2535 DECLARE_CONCRETE_INSTRUCTION(RegExpLiteral, "regexp-literal")
2536 DECLARE_HYDROGEN_ACCESSOR(RegExpLiteral)
2540 class LFunctionLiteral V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2542 explicit LFunctionLiteral(LOperand* context) {
2543 inputs_[0] = context;
2546 LOperand* context() { return inputs_[0]; }
2548 DECLARE_CONCRETE_INSTRUCTION(FunctionLiteral, "function-literal")
2549 DECLARE_HYDROGEN_ACCESSOR(FunctionLiteral)
2553 class LToFastProperties V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2555 explicit LToFastProperties(LOperand* value) {
2559 LOperand* value() { return inputs_[0]; }
2561 DECLARE_CONCRETE_INSTRUCTION(ToFastProperties, "to-fast-properties")
2562 DECLARE_HYDROGEN_ACCESSOR(ToFastProperties)
2566 class LTypeof V8_FINAL : public LTemplateInstruction<1, 2, 0> {
2568 LTypeof(LOperand* context, LOperand* value) {
2569 inputs_[0] = context;
2573 LOperand* context() { return inputs_[0]; }
2574 LOperand* value() { return inputs_[1]; }
2576 DECLARE_CONCRETE_INSTRUCTION(Typeof, "typeof")
2580 class LTypeofIsAndBranch V8_FINAL : public LControlInstruction<1, 0> {
2582 explicit LTypeofIsAndBranch(LOperand* value) {
2586 LOperand* value() { return inputs_[0]; }
2588 DECLARE_CONCRETE_INSTRUCTION(TypeofIsAndBranch, "typeof-is-and-branch")
2589 DECLARE_HYDROGEN_ACCESSOR(TypeofIsAndBranch)
2591 Handle<String> type_literal() { return hydrogen()->type_literal(); }
2593 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
2597 class LOsrEntry V8_FINAL : public LTemplateInstruction<0, 0, 0> {
2599 virtual bool HasInterestingComment(LCodeGen* gen) const V8_OVERRIDE {
2602 DECLARE_CONCRETE_INSTRUCTION(OsrEntry, "osr-entry")
2606 class LStackCheck V8_FINAL : public LTemplateInstruction<0, 1, 0> {
2608 explicit LStackCheck(LOperand* context) {
2609 inputs_[0] = context;
2612 LOperand* context() { return inputs_[0]; }
2614 DECLARE_CONCRETE_INSTRUCTION(StackCheck, "stack-check")
2615 DECLARE_HYDROGEN_ACCESSOR(StackCheck)
2617 Label* done_label() { return &done_label_; }
2624 class LForInPrepareMap V8_FINAL : public LTemplateInstruction<1, 2, 0> {
2626 LForInPrepareMap(LOperand* context, LOperand* object) {
2627 inputs_[0] = context;
2628 inputs_[1] = object;
2631 LOperand* context() { return inputs_[0]; }
2632 LOperand* object() { return inputs_[1]; }
2634 DECLARE_CONCRETE_INSTRUCTION(ForInPrepareMap, "for-in-prepare-map")
2638 class LForInCacheArray V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2640 explicit LForInCacheArray(LOperand* map) {
2644 LOperand* map() { return inputs_[0]; }
2646 DECLARE_CONCRETE_INSTRUCTION(ForInCacheArray, "for-in-cache-array")
2649 return HForInCacheArray::cast(this->hydrogen_value())->idx();
2654 class LCheckMapValue V8_FINAL : public LTemplateInstruction<0, 2, 0> {
2656 LCheckMapValue(LOperand* value, LOperand* map) {
2661 LOperand* value() { return inputs_[0]; }
2662 LOperand* map() { return inputs_[1]; }
2664 DECLARE_CONCRETE_INSTRUCTION(CheckMapValue, "check-map-value")
2668 class LLoadFieldByIndex V8_FINAL : public LTemplateInstruction<1, 2, 0> {
2670 LLoadFieldByIndex(LOperand* object, LOperand* index) {
2671 inputs_[0] = object;
2675 LOperand* object() { return inputs_[0]; }
2676 LOperand* index() { return inputs_[1]; }
2678 DECLARE_CONCRETE_INSTRUCTION(LoadFieldByIndex, "load-field-by-index")
2682 class LStoreFrameContext: public LTemplateInstruction<0, 1, 0> {
2684 explicit LStoreFrameContext(LOperand* context) {
2685 inputs_[0] = context;
2688 LOperand* context() { return inputs_[0]; }
2690 DECLARE_CONCRETE_INSTRUCTION(StoreFrameContext, "store-frame-context")
2694 class LAllocateBlockContext: public LTemplateInstruction<1, 2, 0> {
2696 LAllocateBlockContext(LOperand* context, LOperand* function) {
2697 inputs_[0] = context;
2698 inputs_[1] = function;
2701 LOperand* context() { return inputs_[0]; }
2702 LOperand* function() { return inputs_[1]; }
2704 Handle<ScopeInfo> scope_info() { return hydrogen()->scope_info(); }
2706 DECLARE_CONCRETE_INSTRUCTION(AllocateBlockContext, "allocate-block-context")
2707 DECLARE_HYDROGEN_ACCESSOR(AllocateBlockContext)
2711 class LChunkBuilder;
2712 class LPlatformChunk V8_FINAL : public LChunk {
2714 LPlatformChunk(CompilationInfo* info, HGraph* graph)
2715 : LChunk(info, graph),
2716 num_double_slots_(0) { }
2718 int GetNextSpillIndex(RegisterKind kind);
2719 LOperand* GetNextSpillSlot(RegisterKind kind);
2721 int num_double_slots() const { return num_double_slots_; }
2724 int num_double_slots_;
2728 class LChunkBuilder V8_FINAL : public LChunkBuilderBase {
2730 LChunkBuilder(CompilationInfo* info, HGraph* graph, LAllocator* allocator)
2731 : LChunkBuilderBase(graph->zone()),
2736 current_instruction_(NULL),
2737 current_block_(NULL),
2739 allocator_(allocator) { }
2741 Isolate* isolate() const { return graph_->isolate(); }
2743 // Build the sequence for the graph.
2744 LPlatformChunk* Build();
2746 // Declare methods that deal with the individual node types.
2747 #define DECLARE_DO(type) LInstruction* Do##type(H##type* node);
2748 HYDROGEN_CONCRETE_INSTRUCTION_LIST(DECLARE_DO)
2751 LInstruction* DoMathFloor(HUnaryMathOperation* instr);
2752 LInstruction* DoMathRound(HUnaryMathOperation* instr);
2753 LInstruction* DoMathFround(HUnaryMathOperation* instr);
2754 LInstruction* DoMathAbs(HUnaryMathOperation* instr);
2755 LInstruction* DoMathLog(HUnaryMathOperation* instr);
2756 LInstruction* DoMathExp(HUnaryMathOperation* instr);
2757 LInstruction* DoMathSqrt(HUnaryMathOperation* instr);
2758 LInstruction* DoMathPowHalf(HUnaryMathOperation* instr);
2759 LInstruction* DoMathClz32(HUnaryMathOperation* instr);
2760 LInstruction* DoDivByPowerOf2I(HDiv* instr);
2761 LInstruction* DoDivByConstI(HDiv* instr);
2762 LInstruction* DoDivI(HDiv* instr);
2763 LInstruction* DoModByPowerOf2I(HMod* instr);
2764 LInstruction* DoModByConstI(HMod* instr);
2765 LInstruction* DoModI(HMod* instr);
2766 LInstruction* DoFlooringDivByPowerOf2I(HMathFloorOfDiv* instr);
2767 LInstruction* DoFlooringDivByConstI(HMathFloorOfDiv* instr);
2768 LInstruction* DoFlooringDivI(HMathFloorOfDiv* instr);
2778 LPlatformChunk* chunk() const { return chunk_; }
2779 CompilationInfo* info() const { return info_; }
2780 HGraph* graph() const { return graph_; }
2782 bool is_unused() const { return status_ == UNUSED; }
2783 bool is_building() const { return status_ == BUILDING; }
2784 bool is_done() const { return status_ == DONE; }
2785 bool is_aborted() const { return status_ == ABORTED; }
2787 void Abort(BailoutReason reason);
2789 // Methods for getting operands for Use / Define / Temp.
2790 LUnallocated* ToUnallocated(Register reg);
2791 LUnallocated* ToUnallocated(XMMRegister reg);
2793 // Methods for setting up define-use relationships.
2794 MUST_USE_RESULT LOperand* Use(HValue* value, LUnallocated* operand);
2795 MUST_USE_RESULT LOperand* UseFixed(HValue* value, Register fixed_register);
2796 MUST_USE_RESULT LOperand* UseFixedDouble(HValue* value,
2797 XMMRegister fixed_register);
2799 // A value that is guaranteed to be allocated to a register.
2800 // Operand created by UseRegister is guaranteed to be live until the end of
2801 // instruction. This means that register allocator will not reuse it's
2802 // register for any other operand inside instruction.
2803 // Operand created by UseRegisterAtStart is guaranteed to be live only at
2804 // instruction start. Register allocator is free to assign the same register
2805 // to some other operand used inside instruction (i.e. temporary or
2807 MUST_USE_RESULT LOperand* UseRegister(HValue* value);
2808 MUST_USE_RESULT LOperand* UseRegisterAtStart(HValue* value);
2810 // An input operand in a register that may be trashed.
2811 MUST_USE_RESULT LOperand* UseTempRegister(HValue* value);
2813 // An input operand in a register or stack slot.
2814 MUST_USE_RESULT LOperand* Use(HValue* value);
2815 MUST_USE_RESULT LOperand* UseAtStart(HValue* value);
2817 // An input operand in a register, stack slot or a constant operand.
2818 MUST_USE_RESULT LOperand* UseOrConstant(HValue* value);
2819 MUST_USE_RESULT LOperand* UseOrConstantAtStart(HValue* value);
2821 // An input operand in a fixed register or a constant operand.
2822 MUST_USE_RESULT LOperand* UseFixedOrConstant(HValue* value,
2823 Register fixed_register);
2825 // An input operand in a register or a constant operand.
2826 MUST_USE_RESULT LOperand* UseRegisterOrConstant(HValue* value);
2827 MUST_USE_RESULT LOperand* UseRegisterOrConstantAtStart(HValue* value);
2829 // An input operand in a constant operand.
2830 MUST_USE_RESULT LOperand* UseConstant(HValue* value);
2832 // An input operand in register, stack slot or a constant operand.
2833 // Will not be moved to a register even if one is freely available.
2834 virtual MUST_USE_RESULT LOperand* UseAny(HValue* value) V8_OVERRIDE;
2836 // Temporary operand that must be in a register.
2837 MUST_USE_RESULT LUnallocated* TempRegister();
2838 MUST_USE_RESULT LOperand* FixedTemp(Register reg);
2839 MUST_USE_RESULT LOperand* FixedTemp(XMMRegister reg);
2841 // Methods for setting up define-use relationships.
2842 // Return the same instruction that they are passed.
2843 LInstruction* Define(LTemplateResultInstruction<1>* instr,
2844 LUnallocated* result);
2845 LInstruction* DefineAsRegister(LTemplateResultInstruction<1>* instr);
2846 LInstruction* DefineAsSpilled(LTemplateResultInstruction<1>* instr,
2848 LInstruction* DefineSameAsFirst(LTemplateResultInstruction<1>* instr);
2849 LInstruction* DefineFixed(LTemplateResultInstruction<1>* instr,
2851 LInstruction* DefineFixedDouble(LTemplateResultInstruction<1>* instr,
2853 // Assigns an environment to an instruction. An instruction which can
2854 // deoptimize must have an environment.
2855 LInstruction* AssignEnvironment(LInstruction* instr);
2856 // Assigns a pointer map to an instruction. An instruction which can
2857 // trigger a GC or a lazy deoptimization must have a pointer map.
2858 LInstruction* AssignPointerMap(LInstruction* instr);
2860 enum CanDeoptimize { CAN_DEOPTIMIZE_EAGERLY, CANNOT_DEOPTIMIZE_EAGERLY };
2862 LOperand* GetSeqStringSetCharOperand(HSeqStringSetChar* instr);
2864 // Marks a call for the register allocator. Assigns a pointer map to
2865 // support GC and lazy deoptimization. Assigns an environment to support
2866 // eager deoptimization if CAN_DEOPTIMIZE_EAGERLY.
2867 LInstruction* MarkAsCall(
2868 LInstruction* instr,
2869 HInstruction* hinstr,
2870 CanDeoptimize can_deoptimize = CANNOT_DEOPTIMIZE_EAGERLY);
2872 void VisitInstruction(HInstruction* current);
2873 void AddInstruction(LInstruction* instr, HInstruction* current);
2875 void DoBasicBlock(HBasicBlock* block, HBasicBlock* next_block);
2876 LInstruction* DoShift(Token::Value op, HBitwiseBinaryOperation* instr);
2877 LInstruction* DoArithmeticD(Token::Value op,
2878 HArithmeticBinaryOperation* instr);
2879 LInstruction* DoArithmeticT(Token::Value op,
2880 HBinaryOperation* instr);
2882 LOperand* GetStoreKeyedValueOperand(HStoreKeyed* instr);
2884 LPlatformChunk* chunk_;
2885 CompilationInfo* info_;
2886 HGraph* const graph_;
2888 HInstruction* current_instruction_;
2889 HBasicBlock* current_block_;
2890 HBasicBlock* next_block_;
2891 LAllocator* allocator_;
2893 DISALLOW_COPY_AND_ASSIGN(LChunkBuilder);
2896 #undef DECLARE_HYDROGEN_ACCESSOR
2897 #undef DECLARE_CONCRETE_INSTRUCTION
2899 } } // namespace v8::internal
2901 #endif // V8_IA32_LITHIUM_IA32_H_