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_
9 #include "lithium-allocator.h"
11 #include "safepoint-table.h"
17 // Forward declarations.
20 #define LITHIUM_CONCRETE_INSTRUCTION_LIST(V) \
21 V(AccessArgumentsAt) \
25 V(ArgumentsElements) \
33 V(CallWithDescriptor) \
39 V(CheckInstanceType) \
48 V(ClampTToUint8NoSSE2) \
49 V(ClassOfTestAndBranch) \
51 V(CompareMinusZeroAndBranch) \
52 V(CompareNumericAndBranch) \
53 V(CmpObjectEqAndBranch) \
77 V(FlooringDivByConstI) \
78 V(FlooringDivByPowerOf2I) \
83 V(GetCachedArrayIndex) \
85 V(HasCachedArrayIndexAndBranch) \
86 V(HasInstanceTypeAndBranch) \
87 V(InnerAllocatedObject) \
89 V(InstanceOfKnownGlobal) \
91 V(Integer32ToDouble) \
93 V(IsConstructCallAndBranch) \
94 V(IsObjectAndBranch) \
95 V(IsStringAndBranch) \
97 V(IsUndetectableAndBranch) \
101 V(LoadFieldByIndex) \
102 V(LoadFunctionPrototype) \
104 V(LoadGlobalGeneric) \
106 V(LoadKeyedGeneric) \
108 V(LoadNamedGeneric) \
122 V(NullarySIMDOperation) \
123 V(UnarySIMDOperation) \
124 V(BinarySIMDOperation) \
125 V(TernarySIMDOperation) \
126 V(QuarternarySIMDOperation) \
141 V(SeqStringGetChar) \
142 V(SeqStringSetChar) \
148 V(StoreContextSlot) \
151 V(StoreKeyedGeneric) \
153 V(StoreNamedGeneric) \
155 V(StringCharCodeAt) \
156 V(StringCharFromCode) \
157 V(StringCompareAndBranch) \
161 V(ToFastProperties) \
162 V(TransitionElementsKind) \
163 V(TrapAllocationMemento) \
165 V(TypeofIsAndBranch) \
171 #define DECLARE_CONCRETE_INSTRUCTION(type, mnemonic) \
172 virtual Opcode opcode() const V8_FINAL V8_OVERRIDE { \
173 return LInstruction::k##type; \
175 virtual void CompileToNative(LCodeGen* generator) V8_FINAL V8_OVERRIDE; \
176 virtual const char* Mnemonic() const V8_FINAL V8_OVERRIDE { \
179 static L##type* cast(LInstruction* instr) { \
180 ASSERT(instr->Is##type()); \
181 return reinterpret_cast<L##type*>(instr); \
185 #define DECLARE_HYDROGEN_ACCESSOR(type) \
186 H##type* hydrogen() const { \
187 return H##type::cast(hydrogen_value()); \
191 class LInstruction : public ZoneObject {
194 : environment_(NULL),
195 hydrogen_value_(NULL),
196 bit_field_(IsCallBits::encode(false)) {
199 virtual ~LInstruction() {}
201 virtual void CompileToNative(LCodeGen* generator) = 0;
202 virtual const char* Mnemonic() const = 0;
203 virtual void PrintTo(StringStream* stream);
204 virtual void PrintDataTo(StringStream* stream);
205 virtual void PrintOutputOperandTo(StringStream* stream);
208 // Declare a unique enum value for each instruction.
209 #define DECLARE_OPCODE(type) k##type,
210 LITHIUM_CONCRETE_INSTRUCTION_LIST(DECLARE_OPCODE)
211 kNumberOfInstructions
212 #undef DECLARE_OPCODE
215 virtual Opcode opcode() const = 0;
217 // Declare non-virtual type testers for all leaf IR classes.
218 #define DECLARE_PREDICATE(type) \
219 bool Is##type() const { return opcode() == k##type; }
220 LITHIUM_CONCRETE_INSTRUCTION_LIST(DECLARE_PREDICATE)
221 #undef DECLARE_PREDICATE
223 // Declare virtual predicates for instructions that don't have
225 virtual bool IsGap() const { return false; }
227 virtual bool IsControl() const { return false; }
229 void set_environment(LEnvironment* env) { environment_ = env; }
230 LEnvironment* environment() const { return environment_; }
231 bool HasEnvironment() const { return environment_ != NULL; }
233 void set_pointer_map(LPointerMap* p) { pointer_map_.set(p); }
234 LPointerMap* pointer_map() const { return pointer_map_.get(); }
235 bool HasPointerMap() const { return pointer_map_.is_set(); }
237 void set_hydrogen_value(HValue* value) { hydrogen_value_ = value; }
238 HValue* hydrogen_value() const { return hydrogen_value_; }
240 virtual void SetDeferredLazyDeoptimizationEnvironment(LEnvironment* env) { }
242 void MarkAsCall() { bit_field_ = IsCallBits::update(bit_field_, true); }
243 bool IsCall() const { return IsCallBits::decode(bit_field_); }
245 // Interface to the register allocator and iterators.
246 bool ClobbersTemps() const { return IsCall(); }
247 bool ClobbersRegisters() const { return IsCall(); }
248 virtual bool ClobbersDoubleRegisters(Isolate* isolate) const {
250 // We only have rudimentary X87Stack tracking, thus in general
251 // cannot handle phi-nodes.
252 (!CpuFeatures::IsSafeForSnapshot(isolate, SSE2) && IsControl());
255 virtual bool HasResult() const = 0;
256 virtual LOperand* result() const = 0;
258 bool HasDoubleRegisterResult();
259 bool HasDoubleRegisterInput();
260 bool IsDoubleInput(X87Register reg, LCodeGen* cgen);
262 LOperand* FirstInput() { return InputAt(0); }
263 LOperand* Output() { return HasResult() ? result() : NULL; }
265 virtual bool HasInterestingComment(LCodeGen* gen) const { return true; }
273 friend class InputIterator;
274 virtual int InputCount() = 0;
275 virtual LOperand* InputAt(int i) = 0;
277 friend class TempIterator;
278 virtual int TempCount() = 0;
279 virtual LOperand* TempAt(int i) = 0;
281 class IsCallBits: public BitField<bool, 0, 1> {};
283 LEnvironment* environment_;
284 SetOncePointer<LPointerMap> pointer_map_;
285 HValue* hydrogen_value_;
290 // R = number of result operands (0 or 1).
292 class LTemplateResultInstruction : public LInstruction {
294 // Allow 0 or 1 output operands.
295 STATIC_ASSERT(R == 0 || R == 1);
296 virtual bool HasResult() const V8_FINAL V8_OVERRIDE {
297 return R != 0 && result() != NULL;
299 void set_result(LOperand* operand) { results_[0] = operand; }
300 LOperand* result() const { return results_[0]; }
303 EmbeddedContainer<LOperand*, R> results_;
307 // R = number of result operands (0 or 1).
308 // I = number of input operands.
309 // T = number of temporary operands.
310 template<int R, int I, int T>
311 class LTemplateInstruction : public LTemplateResultInstruction<R> {
313 EmbeddedContainer<LOperand*, I> inputs_;
314 EmbeddedContainer<LOperand*, T> temps_;
318 virtual int InputCount() V8_FINAL V8_OVERRIDE { return I; }
319 virtual LOperand* InputAt(int i) V8_FINAL V8_OVERRIDE { return inputs_[i]; }
321 virtual int TempCount() V8_FINAL V8_OVERRIDE { return T; }
322 virtual LOperand* TempAt(int i) V8_FINAL V8_OVERRIDE { return temps_[i]; }
326 class LGap : public LTemplateInstruction<0, 0, 0> {
328 explicit LGap(HBasicBlock* block) : block_(block) {
329 parallel_moves_[BEFORE] = NULL;
330 parallel_moves_[START] = NULL;
331 parallel_moves_[END] = NULL;
332 parallel_moves_[AFTER] = NULL;
335 // Can't use the DECLARE-macro here because of sub-classes.
336 virtual bool IsGap() const V8_FINAL V8_OVERRIDE { return true; }
337 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
338 static LGap* cast(LInstruction* instr) {
339 ASSERT(instr->IsGap());
340 return reinterpret_cast<LGap*>(instr);
343 bool IsRedundant() const;
345 HBasicBlock* block() const { return block_; }
352 FIRST_INNER_POSITION = BEFORE,
353 LAST_INNER_POSITION = AFTER
356 LParallelMove* GetOrCreateParallelMove(InnerPosition pos, Zone* zone) {
357 if (parallel_moves_[pos] == NULL) {
358 parallel_moves_[pos] = new(zone) LParallelMove(zone);
360 return parallel_moves_[pos];
363 LParallelMove* GetParallelMove(InnerPosition pos) {
364 return parallel_moves_[pos];
368 LParallelMove* parallel_moves_[LAST_INNER_POSITION + 1];
373 class LInstructionGap V8_FINAL : public LGap {
375 explicit LInstructionGap(HBasicBlock* block) : LGap(block) { }
377 virtual bool HasInterestingComment(LCodeGen* gen) const V8_OVERRIDE {
378 return !IsRedundant();
381 DECLARE_CONCRETE_INSTRUCTION(InstructionGap, "gap")
385 class LClobberDoubles V8_FINAL : public LTemplateInstruction<0, 0, 0> {
387 explicit LClobberDoubles(Isolate* isolate) {
388 ASSERT(!CpuFeatures::IsSafeForSnapshot(isolate, SSE2));
391 virtual bool ClobbersDoubleRegisters(Isolate* isolate) const V8_OVERRIDE {
395 DECLARE_CONCRETE_INSTRUCTION(ClobberDoubles, "clobber-d")
399 class LGoto V8_FINAL : public LTemplateInstruction<0, 0, 0> {
401 explicit LGoto(HBasicBlock* block) : block_(block) { }
403 virtual bool HasInterestingComment(LCodeGen* gen) const V8_OVERRIDE;
404 DECLARE_CONCRETE_INSTRUCTION(Goto, "goto")
405 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
406 virtual bool IsControl() const V8_OVERRIDE { return true; }
408 int block_id() const { return block_->block_id(); }
409 virtual bool ClobbersDoubleRegisters(Isolate* isolate) const V8_OVERRIDE {
413 bool jumps_to_join() const { return block_->predecessors()->length() > 1; }
420 class LLazyBailout V8_FINAL : public LTemplateInstruction<0, 0, 0> {
422 DECLARE_CONCRETE_INSTRUCTION(LazyBailout, "lazy-bailout")
426 class LDummy V8_FINAL : public LTemplateInstruction<1, 0, 0> {
428 explicit LDummy() { }
429 DECLARE_CONCRETE_INSTRUCTION(Dummy, "dummy")
433 class LDummyUse V8_FINAL : public LTemplateInstruction<1, 1, 0> {
435 explicit LDummyUse(LOperand* value) {
438 DECLARE_CONCRETE_INSTRUCTION(DummyUse, "dummy-use")
442 class LDeoptimize V8_FINAL : public LTemplateInstruction<0, 0, 0> {
444 DECLARE_CONCRETE_INSTRUCTION(Deoptimize, "deoptimize")
445 DECLARE_HYDROGEN_ACCESSOR(Deoptimize)
449 class LLabel V8_FINAL : public LGap {
451 explicit LLabel(HBasicBlock* block)
452 : LGap(block), replacement_(NULL) { }
454 virtual bool HasInterestingComment(LCodeGen* gen) const V8_OVERRIDE {
457 DECLARE_CONCRETE_INSTRUCTION(Label, "label")
459 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
461 int block_id() const { return block()->block_id(); }
462 bool is_loop_header() const { return block()->IsLoopHeader(); }
463 bool is_osr_entry() const { return block()->is_osr_entry(); }
464 Label* label() { return &label_; }
465 LLabel* replacement() const { return replacement_; }
466 void set_replacement(LLabel* label) { replacement_ = label; }
467 bool HasReplacement() const { return replacement_ != NULL; }
471 LLabel* replacement_;
475 class LParameter V8_FINAL : public LTemplateInstruction<1, 0, 0> {
477 virtual bool HasInterestingComment(LCodeGen* gen) const V8_OVERRIDE {
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, 1> {
552 LWrapReceiver(LOperand* receiver,
555 inputs_[0] = receiver;
556 inputs_[1] = function;
560 LOperand* receiver() { return inputs_[0]; }
561 LOperand* function() { return inputs_[1]; }
562 LOperand* temp() { return temps_[0]; }
564 DECLARE_CONCRETE_INSTRUCTION(WrapReceiver, "wrap-receiver")
565 DECLARE_HYDROGEN_ACCESSOR(WrapReceiver)
569 class LApplyArguments V8_FINAL : public LTemplateInstruction<1, 4, 0> {
571 LApplyArguments(LOperand* function,
574 LOperand* elements) {
575 inputs_[0] = function;
576 inputs_[1] = receiver;
578 inputs_[3] = elements;
581 LOperand* function() { return inputs_[0]; }
582 LOperand* receiver() { return inputs_[1]; }
583 LOperand* length() { return inputs_[2]; }
584 LOperand* elements() { return inputs_[3]; }
586 DECLARE_CONCRETE_INSTRUCTION(ApplyArguments, "apply-arguments")
590 class LAccessArgumentsAt V8_FINAL : public LTemplateInstruction<1, 3, 0> {
592 LAccessArgumentsAt(LOperand* arguments, LOperand* length, LOperand* index) {
593 inputs_[0] = arguments;
598 LOperand* arguments() { return inputs_[0]; }
599 LOperand* length() { return inputs_[1]; }
600 LOperand* index() { return inputs_[2]; }
602 DECLARE_CONCRETE_INSTRUCTION(AccessArgumentsAt, "access-arguments-at")
604 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
608 class LArgumentsLength V8_FINAL : public LTemplateInstruction<1, 1, 0> {
610 explicit LArgumentsLength(LOperand* elements) {
611 inputs_[0] = elements;
614 LOperand* elements() { return inputs_[0]; }
616 DECLARE_CONCRETE_INSTRUCTION(ArgumentsLength, "arguments-length")
620 class LArgumentsElements V8_FINAL : public LTemplateInstruction<1, 0, 0> {
622 DECLARE_CONCRETE_INSTRUCTION(ArgumentsElements, "arguments-elements")
623 DECLARE_HYDROGEN_ACCESSOR(ArgumentsElements)
627 class LDebugBreak V8_FINAL : public LTemplateInstruction<0, 0, 0> {
629 DECLARE_CONCRETE_INSTRUCTION(DebugBreak, "break")
633 class LModByPowerOf2I V8_FINAL : public LTemplateInstruction<1, 1, 0> {
635 LModByPowerOf2I(LOperand* dividend, int32_t divisor) {
636 inputs_[0] = dividend;
640 LOperand* dividend() { return inputs_[0]; }
641 int32_t divisor() const { return divisor_; }
643 DECLARE_CONCRETE_INSTRUCTION(ModByPowerOf2I, "mod-by-power-of-2-i")
644 DECLARE_HYDROGEN_ACCESSOR(Mod)
651 class LModByConstI V8_FINAL : public LTemplateInstruction<1, 1, 2> {
653 LModByConstI(LOperand* dividend,
657 inputs_[0] = dividend;
663 LOperand* dividend() { return inputs_[0]; }
664 int32_t divisor() const { return divisor_; }
665 LOperand* temp1() { return temps_[0]; }
666 LOperand* temp2() { return temps_[1]; }
668 DECLARE_CONCRETE_INSTRUCTION(ModByConstI, "mod-by-const-i")
669 DECLARE_HYDROGEN_ACCESSOR(Mod)
676 class LModI V8_FINAL : public LTemplateInstruction<1, 2, 1> {
678 LModI(LOperand* left, LOperand* right, LOperand* temp) {
684 LOperand* left() { return inputs_[0]; }
685 LOperand* right() { return inputs_[1]; }
686 LOperand* temp() { return temps_[0]; }
688 DECLARE_CONCRETE_INSTRUCTION(ModI, "mod-i")
689 DECLARE_HYDROGEN_ACCESSOR(Mod)
693 class LDivByPowerOf2I V8_FINAL : public LTemplateInstruction<1, 1, 0> {
695 LDivByPowerOf2I(LOperand* dividend, int32_t divisor) {
696 inputs_[0] = dividend;
700 LOperand* dividend() { return inputs_[0]; }
701 int32_t divisor() const { return divisor_; }
703 DECLARE_CONCRETE_INSTRUCTION(DivByPowerOf2I, "div-by-power-of-2-i")
704 DECLARE_HYDROGEN_ACCESSOR(Div)
711 class LDivByConstI V8_FINAL : public LTemplateInstruction<1, 1, 2> {
713 LDivByConstI(LOperand* dividend,
717 inputs_[0] = dividend;
723 LOperand* dividend() { return inputs_[0]; }
724 int32_t divisor() const { return divisor_; }
725 LOperand* temp1() { return temps_[0]; }
726 LOperand* temp2() { return temps_[1]; }
728 DECLARE_CONCRETE_INSTRUCTION(DivByConstI, "div-by-const-i")
729 DECLARE_HYDROGEN_ACCESSOR(Div)
736 class LDivI V8_FINAL : public LTemplateInstruction<1, 2, 1> {
738 LDivI(LOperand* dividend, LOperand* divisor, LOperand* temp) {
739 inputs_[0] = dividend;
740 inputs_[1] = divisor;
744 LOperand* dividend() { return inputs_[0]; }
745 LOperand* divisor() { return inputs_[1]; }
746 LOperand* temp() { return temps_[0]; }
748 DECLARE_CONCRETE_INSTRUCTION(DivI, "div-i")
749 DECLARE_HYDROGEN_ACCESSOR(BinaryOperation)
753 class LFlooringDivByPowerOf2I V8_FINAL : public LTemplateInstruction<1, 1, 0> {
755 LFlooringDivByPowerOf2I(LOperand* dividend, int32_t divisor) {
756 inputs_[0] = dividend;
760 LOperand* dividend() { return inputs_[0]; }
761 int32_t divisor() const { return divisor_; }
763 DECLARE_CONCRETE_INSTRUCTION(FlooringDivByPowerOf2I,
764 "flooring-div-by-power-of-2-i")
765 DECLARE_HYDROGEN_ACCESSOR(MathFloorOfDiv)
772 class LFlooringDivByConstI V8_FINAL : public LTemplateInstruction<1, 1, 3> {
774 LFlooringDivByConstI(LOperand* dividend,
779 inputs_[0] = dividend;
786 LOperand* dividend() { return inputs_[0]; }
787 int32_t divisor() const { return divisor_; }
788 LOperand* temp1() { return temps_[0]; }
789 LOperand* temp2() { return temps_[1]; }
790 LOperand* temp3() { return temps_[2]; }
792 DECLARE_CONCRETE_INSTRUCTION(FlooringDivByConstI, "flooring-div-by-const-i")
793 DECLARE_HYDROGEN_ACCESSOR(MathFloorOfDiv)
800 class LFlooringDivI V8_FINAL : public LTemplateInstruction<1, 2, 1> {
802 LFlooringDivI(LOperand* dividend, LOperand* divisor, LOperand* temp) {
803 inputs_[0] = dividend;
804 inputs_[1] = divisor;
808 LOperand* dividend() { return inputs_[0]; }
809 LOperand* divisor() { return inputs_[1]; }
810 LOperand* temp() { return temps_[0]; }
812 DECLARE_CONCRETE_INSTRUCTION(FlooringDivI, "flooring-div-i")
813 DECLARE_HYDROGEN_ACCESSOR(MathFloorOfDiv)
817 class LMulI V8_FINAL : public LTemplateInstruction<1, 2, 1> {
819 LMulI(LOperand* left, LOperand* right, LOperand* temp) {
825 LOperand* left() { return inputs_[0]; }
826 LOperand* right() { return inputs_[1]; }
827 LOperand* temp() { return temps_[0]; }
829 DECLARE_CONCRETE_INSTRUCTION(MulI, "mul-i")
830 DECLARE_HYDROGEN_ACCESSOR(Mul)
834 class LCompareNumericAndBranch V8_FINAL : public LControlInstruction<2, 0> {
836 LCompareNumericAndBranch(LOperand* left, LOperand* right) {
841 LOperand* left() { return inputs_[0]; }
842 LOperand* right() { return inputs_[1]; }
844 DECLARE_CONCRETE_INSTRUCTION(CompareNumericAndBranch,
845 "compare-numeric-and-branch")
846 DECLARE_HYDROGEN_ACCESSOR(CompareNumericAndBranch)
848 Token::Value op() const { return hydrogen()->token(); }
849 bool is_double() const {
850 return hydrogen()->representation().IsDouble();
853 virtual void PrintDataTo(StringStream* stream);
857 class LMathFloor V8_FINAL : public LTemplateInstruction<1, 1, 0> {
859 explicit LMathFloor(LOperand* value) {
863 LOperand* value() { return inputs_[0]; }
865 DECLARE_CONCRETE_INSTRUCTION(MathFloor, "math-floor")
866 DECLARE_HYDROGEN_ACCESSOR(UnaryMathOperation)
870 class LMathRound V8_FINAL : public LTemplateInstruction<1, 1, 1> {
872 LMathRound(LOperand* value, LOperand* temp) {
877 LOperand* value() { return inputs_[0]; }
878 LOperand* temp() { return temps_[0]; }
880 DECLARE_CONCRETE_INSTRUCTION(MathRound, "math-round")
881 DECLARE_HYDROGEN_ACCESSOR(UnaryMathOperation)
885 class LMathAbs V8_FINAL : public LTemplateInstruction<1, 2, 0> {
887 LMathAbs(LOperand* context, LOperand* value) {
888 inputs_[1] = context;
892 LOperand* context() { return inputs_[1]; }
893 LOperand* value() { return inputs_[0]; }
895 DECLARE_CONCRETE_INSTRUCTION(MathAbs, "math-abs")
896 DECLARE_HYDROGEN_ACCESSOR(UnaryMathOperation)
900 class LMathLog V8_FINAL : public LTemplateInstruction<1, 1, 0> {
902 explicit LMathLog(LOperand* value) {
906 LOperand* value() { return inputs_[0]; }
908 DECLARE_CONCRETE_INSTRUCTION(MathLog, "math-log")
912 class LMathClz32 V8_FINAL : public LTemplateInstruction<1, 1, 0> {
914 explicit LMathClz32(LOperand* value) {
918 LOperand* value() { return inputs_[0]; }
920 DECLARE_CONCRETE_INSTRUCTION(MathClz32, "math-clz32")
924 class LMathExp V8_FINAL : public LTemplateInstruction<1, 1, 2> {
926 LMathExp(LOperand* value,
932 ExternalReference::InitializeMathExpData();
935 LOperand* value() { return inputs_[0]; }
936 LOperand* temp1() { return temps_[0]; }
937 LOperand* temp2() { return temps_[1]; }
939 DECLARE_CONCRETE_INSTRUCTION(MathExp, "math-exp")
943 class LMathSqrt V8_FINAL : public LTemplateInstruction<1, 1, 0> {
945 explicit LMathSqrt(LOperand* value) {
949 LOperand* value() { return inputs_[0]; }
951 DECLARE_CONCRETE_INSTRUCTION(MathSqrt, "math-sqrt")
955 class LMathPowHalf V8_FINAL : public LTemplateInstruction<1, 1, 1> {
957 LMathPowHalf(LOperand* value, LOperand* temp) {
962 LOperand* value() { return inputs_[0]; }
963 LOperand* temp() { return temps_[0]; }
965 DECLARE_CONCRETE_INSTRUCTION(MathPowHalf, "math-pow-half")
969 class LNullarySIMDOperation V8_FINAL : public LTemplateInstruction<1, 0, 0> {
971 explicit LNullarySIMDOperation(BuiltinFunctionId op)
975 BuiltinFunctionId op() const { return op_; }
977 virtual Opcode opcode() const V8_OVERRIDE {
978 return LInstruction::kNullarySIMDOperation;
980 virtual void CompileToNative(LCodeGen* generator) V8_OVERRIDE;
981 virtual const char* Mnemonic() const V8_OVERRIDE;
982 static LNullarySIMDOperation* cast(LInstruction* instr) {
983 ASSERT(instr->IsNullarySIMDOperation());
984 return reinterpret_cast<LNullarySIMDOperation*>(instr);
987 DECLARE_HYDROGEN_ACCESSOR(NullarySIMDOperation)
990 BuiltinFunctionId op_;
994 class LUnarySIMDOperation V8_FINAL : public LTemplateInstruction<1, 1, 0> {
996 LUnarySIMDOperation(LOperand* value, BuiltinFunctionId op)
1001 LOperand* value() { return inputs_[0]; }
1002 BuiltinFunctionId op() const { return op_; }
1004 virtual Opcode opcode() const V8_OVERRIDE {
1005 return LInstruction::kUnarySIMDOperation;
1007 virtual void CompileToNative(LCodeGen* generator) V8_OVERRIDE;
1008 virtual const char* Mnemonic() const V8_OVERRIDE;
1009 static LUnarySIMDOperation* cast(LInstruction* instr) {
1010 ASSERT(instr->IsUnarySIMDOperation());
1011 return reinterpret_cast<LUnarySIMDOperation*>(instr);
1014 DECLARE_HYDROGEN_ACCESSOR(UnarySIMDOperation)
1017 BuiltinFunctionId op_;
1021 class LBinarySIMDOperation V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1023 LBinarySIMDOperation(LOperand* left, LOperand* right, BuiltinFunctionId op)
1029 LOperand* left() { return inputs_[0]; }
1030 LOperand* right() { return inputs_[1]; }
1031 BuiltinFunctionId op() const { return op_; }
1033 virtual Opcode opcode() const V8_OVERRIDE {
1034 return LInstruction::kBinarySIMDOperation;
1036 virtual void CompileToNative(LCodeGen* generator) V8_OVERRIDE;
1037 virtual const char* Mnemonic() const V8_OVERRIDE;
1038 static LBinarySIMDOperation* cast(LInstruction* instr) {
1039 ASSERT(instr->IsBinarySIMDOperation());
1040 return reinterpret_cast<LBinarySIMDOperation*>(instr);
1043 DECLARE_HYDROGEN_ACCESSOR(BinarySIMDOperation)
1046 BuiltinFunctionId op_;
1050 class LTernarySIMDOperation V8_FINAL : public LTemplateInstruction<1, 3, 0> {
1052 LTernarySIMDOperation(LOperand* first, LOperand* second, LOperand* third,
1053 BuiltinFunctionId op)
1056 inputs_[1] = second;
1060 LOperand* first() { return inputs_[0]; }
1061 LOperand* second() { return inputs_[1]; }
1062 LOperand* third() { return inputs_[2]; }
1063 BuiltinFunctionId op() const { return op_; }
1065 virtual Opcode opcode() const V8_OVERRIDE {
1066 return LInstruction::kTernarySIMDOperation;
1068 virtual void CompileToNative(LCodeGen* generator) V8_OVERRIDE;
1069 virtual const char* Mnemonic() const V8_OVERRIDE;
1070 static LTernarySIMDOperation* cast(LInstruction* instr) {
1071 ASSERT(instr->IsTernarySIMDOperation());
1072 return reinterpret_cast<LTernarySIMDOperation*>(instr);
1075 DECLARE_HYDROGEN_ACCESSOR(TernarySIMDOperation)
1078 BuiltinFunctionId op_;
1082 class LQuarternarySIMDOperation V8_FINAL
1083 : public LTemplateInstruction<1, 4, 0> {
1085 LQuarternarySIMDOperation(LOperand* x, LOperand* y, LOperand* z,
1086 LOperand* w, BuiltinFunctionId op)
1094 LOperand* x() { return inputs_[0]; }
1095 LOperand* y() { return inputs_[1]; }
1096 LOperand* z() { return inputs_[2]; }
1097 LOperand* w() { return inputs_[3]; }
1098 BuiltinFunctionId op() const { return op_; }
1100 virtual Opcode opcode() const V8_OVERRIDE {
1101 return LInstruction::kQuarternarySIMDOperation;
1103 virtual void CompileToNative(LCodeGen* generator) V8_OVERRIDE;
1104 virtual const char* Mnemonic() const V8_OVERRIDE;
1105 static LQuarternarySIMDOperation* cast(LInstruction* instr) {
1106 ASSERT(instr->IsQuarternarySIMDOperation());
1107 return reinterpret_cast<LQuarternarySIMDOperation*>(instr);
1110 DECLARE_HYDROGEN_ACCESSOR(QuarternarySIMDOperation)
1113 BuiltinFunctionId op_;
1117 class LCmpObjectEqAndBranch V8_FINAL : public LControlInstruction<2, 0> {
1119 LCmpObjectEqAndBranch(LOperand* left, LOperand* right) {
1124 LOperand* left() { return inputs_[0]; }
1125 LOperand* right() { return inputs_[1]; }
1127 DECLARE_CONCRETE_INSTRUCTION(CmpObjectEqAndBranch, "cmp-object-eq-and-branch")
1131 class LCmpHoleAndBranch V8_FINAL : public LControlInstruction<1, 0> {
1133 explicit LCmpHoleAndBranch(LOperand* object) {
1134 inputs_[0] = object;
1137 LOperand* object() { return inputs_[0]; }
1139 DECLARE_CONCRETE_INSTRUCTION(CmpHoleAndBranch, "cmp-hole-and-branch")
1140 DECLARE_HYDROGEN_ACCESSOR(CompareHoleAndBranch)
1144 class LCompareMinusZeroAndBranch V8_FINAL : public LControlInstruction<1, 1> {
1146 LCompareMinusZeroAndBranch(LOperand* value, LOperand* temp) {
1151 LOperand* value() { return inputs_[0]; }
1152 LOperand* temp() { return temps_[0]; }
1154 DECLARE_CONCRETE_INSTRUCTION(CompareMinusZeroAndBranch,
1155 "cmp-minus-zero-and-branch")
1156 DECLARE_HYDROGEN_ACCESSOR(CompareMinusZeroAndBranch)
1160 class LIsObjectAndBranch V8_FINAL : public LControlInstruction<1, 1> {
1162 LIsObjectAndBranch(LOperand* value, LOperand* temp) {
1167 LOperand* value() { return inputs_[0]; }
1168 LOperand* temp() { return temps_[0]; }
1170 DECLARE_CONCRETE_INSTRUCTION(IsObjectAndBranch, "is-object-and-branch")
1172 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1176 class LIsStringAndBranch V8_FINAL : public LControlInstruction<1, 1> {
1178 LIsStringAndBranch(LOperand* value, LOperand* temp) {
1183 LOperand* value() { return inputs_[0]; }
1184 LOperand* temp() { return temps_[0]; }
1186 DECLARE_CONCRETE_INSTRUCTION(IsStringAndBranch, "is-string-and-branch")
1187 DECLARE_HYDROGEN_ACCESSOR(IsStringAndBranch)
1189 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1193 class LIsSmiAndBranch V8_FINAL : public LControlInstruction<1, 0> {
1195 explicit LIsSmiAndBranch(LOperand* value) {
1199 LOperand* value() { return inputs_[0]; }
1201 DECLARE_CONCRETE_INSTRUCTION(IsSmiAndBranch, "is-smi-and-branch")
1202 DECLARE_HYDROGEN_ACCESSOR(IsSmiAndBranch)
1204 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1208 class LIsUndetectableAndBranch V8_FINAL : public LControlInstruction<1, 1> {
1210 LIsUndetectableAndBranch(LOperand* value, LOperand* temp) {
1215 LOperand* value() { return inputs_[0]; }
1216 LOperand* temp() { return temps_[0]; }
1218 DECLARE_CONCRETE_INSTRUCTION(IsUndetectableAndBranch,
1219 "is-undetectable-and-branch")
1220 DECLARE_HYDROGEN_ACCESSOR(IsUndetectableAndBranch)
1222 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1226 class LStringCompareAndBranch V8_FINAL : public LControlInstruction<3, 0> {
1228 LStringCompareAndBranch(LOperand* context, LOperand* left, LOperand* right) {
1229 inputs_[0] = context;
1234 LOperand* context() { return inputs_[1]; }
1235 LOperand* left() { return inputs_[1]; }
1236 LOperand* right() { return inputs_[2]; }
1238 DECLARE_CONCRETE_INSTRUCTION(StringCompareAndBranch,
1239 "string-compare-and-branch")
1240 DECLARE_HYDROGEN_ACCESSOR(StringCompareAndBranch)
1242 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1244 Token::Value op() const { return hydrogen()->token(); }
1248 class LHasInstanceTypeAndBranch V8_FINAL : public LControlInstruction<1, 1> {
1250 LHasInstanceTypeAndBranch(LOperand* value, LOperand* temp) {
1255 LOperand* value() { return inputs_[0]; }
1256 LOperand* temp() { return temps_[0]; }
1258 DECLARE_CONCRETE_INSTRUCTION(HasInstanceTypeAndBranch,
1259 "has-instance-type-and-branch")
1260 DECLARE_HYDROGEN_ACCESSOR(HasInstanceTypeAndBranch)
1262 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1266 class LGetCachedArrayIndex V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1268 explicit LGetCachedArrayIndex(LOperand* value) {
1272 LOperand* value() { return inputs_[0]; }
1274 DECLARE_CONCRETE_INSTRUCTION(GetCachedArrayIndex, "get-cached-array-index")
1275 DECLARE_HYDROGEN_ACCESSOR(GetCachedArrayIndex)
1279 class LHasCachedArrayIndexAndBranch V8_FINAL
1280 : public LControlInstruction<1, 0> {
1282 explicit LHasCachedArrayIndexAndBranch(LOperand* value) {
1286 LOperand* value() { return inputs_[0]; }
1288 DECLARE_CONCRETE_INSTRUCTION(HasCachedArrayIndexAndBranch,
1289 "has-cached-array-index-and-branch")
1291 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1295 class LIsConstructCallAndBranch V8_FINAL : public LControlInstruction<0, 1> {
1297 explicit LIsConstructCallAndBranch(LOperand* temp) {
1301 LOperand* temp() { return temps_[0]; }
1303 DECLARE_CONCRETE_INSTRUCTION(IsConstructCallAndBranch,
1304 "is-construct-call-and-branch")
1308 class LClassOfTestAndBranch V8_FINAL : public LControlInstruction<1, 2> {
1310 LClassOfTestAndBranch(LOperand* value, LOperand* temp, LOperand* temp2) {
1316 LOperand* value() { return inputs_[0]; }
1317 LOperand* temp() { return temps_[0]; }
1318 LOperand* temp2() { return temps_[1]; }
1320 DECLARE_CONCRETE_INSTRUCTION(ClassOfTestAndBranch,
1321 "class-of-test-and-branch")
1322 DECLARE_HYDROGEN_ACCESSOR(ClassOfTestAndBranch)
1324 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1328 class LCmpT V8_FINAL : public LTemplateInstruction<1, 3, 0> {
1330 LCmpT(LOperand* context, LOperand* left, LOperand* right) {
1331 inputs_[0] = context;
1336 DECLARE_CONCRETE_INSTRUCTION(CmpT, "cmp-t")
1337 DECLARE_HYDROGEN_ACCESSOR(CompareGeneric)
1339 LOperand* context() { return inputs_[0]; }
1340 Token::Value op() const { return hydrogen()->token(); }
1344 class LInstanceOf V8_FINAL : public LTemplateInstruction<1, 3, 0> {
1346 LInstanceOf(LOperand* context, LOperand* left, LOperand* right) {
1347 inputs_[0] = context;
1352 LOperand* context() { return inputs_[0]; }
1354 DECLARE_CONCRETE_INSTRUCTION(InstanceOf, "instance-of")
1358 class LInstanceOfKnownGlobal V8_FINAL : public LTemplateInstruction<1, 2, 1> {
1360 LInstanceOfKnownGlobal(LOperand* context, LOperand* value, LOperand* temp) {
1361 inputs_[0] = context;
1366 LOperand* context() { return inputs_[0]; }
1367 LOperand* value() { return inputs_[1]; }
1368 LOperand* temp() { return temps_[0]; }
1370 DECLARE_CONCRETE_INSTRUCTION(InstanceOfKnownGlobal,
1371 "instance-of-known-global")
1372 DECLARE_HYDROGEN_ACCESSOR(InstanceOfKnownGlobal)
1374 Handle<JSFunction> function() const { return hydrogen()->function(); }
1375 LEnvironment* GetDeferredLazyDeoptimizationEnvironment() {
1376 return lazy_deopt_env_;
1378 virtual void SetDeferredLazyDeoptimizationEnvironment(
1379 LEnvironment* env) V8_OVERRIDE {
1380 lazy_deopt_env_ = env;
1384 LEnvironment* lazy_deopt_env_;
1388 class LBoundsCheck V8_FINAL : public LTemplateInstruction<0, 2, 0> {
1390 LBoundsCheck(LOperand* index, LOperand* length) {
1392 inputs_[1] = length;
1395 LOperand* index() { return inputs_[0]; }
1396 LOperand* length() { return inputs_[1]; }
1398 DECLARE_CONCRETE_INSTRUCTION(BoundsCheck, "bounds-check")
1399 DECLARE_HYDROGEN_ACCESSOR(BoundsCheck)
1403 class LBitI V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1405 LBitI(LOperand* left, LOperand* right) {
1410 LOperand* left() { return inputs_[0]; }
1411 LOperand* right() { return inputs_[1]; }
1413 DECLARE_CONCRETE_INSTRUCTION(BitI, "bit-i")
1414 DECLARE_HYDROGEN_ACCESSOR(Bitwise)
1416 Token::Value op() const { return hydrogen()->op(); }
1420 class LShiftI V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1422 LShiftI(Token::Value op, LOperand* left, LOperand* right, bool can_deopt)
1423 : op_(op), can_deopt_(can_deopt) {
1428 LOperand* left() { return inputs_[0]; }
1429 LOperand* right() { return inputs_[1]; }
1431 DECLARE_CONCRETE_INSTRUCTION(ShiftI, "shift-i")
1433 Token::Value op() const { return op_; }
1434 bool can_deopt() const { return can_deopt_; }
1442 class LSubI V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1444 LSubI(LOperand* left, LOperand* right) {
1449 LOperand* left() { return inputs_[0]; }
1450 LOperand* right() { return inputs_[1]; }
1452 DECLARE_CONCRETE_INSTRUCTION(SubI, "sub-i")
1453 DECLARE_HYDROGEN_ACCESSOR(Sub)
1457 class LConstantI V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1459 DECLARE_CONCRETE_INSTRUCTION(ConstantI, "constant-i")
1460 DECLARE_HYDROGEN_ACCESSOR(Constant)
1462 int32_t value() const { return hydrogen()->Integer32Value(); }
1466 class LConstantS V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1468 DECLARE_CONCRETE_INSTRUCTION(ConstantS, "constant-s")
1469 DECLARE_HYDROGEN_ACCESSOR(Constant)
1471 Smi* value() const { return Smi::FromInt(hydrogen()->Integer32Value()); }
1475 class LConstantD V8_FINAL : public LTemplateInstruction<1, 0, 1> {
1477 explicit LConstantD(LOperand* temp) {
1481 LOperand* temp() { return temps_[0]; }
1483 DECLARE_CONCRETE_INSTRUCTION(ConstantD, "constant-d")
1484 DECLARE_HYDROGEN_ACCESSOR(Constant)
1486 double value() const { return hydrogen()->DoubleValue(); }
1490 class LConstantE V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1492 DECLARE_CONCRETE_INSTRUCTION(ConstantE, "constant-e")
1493 DECLARE_HYDROGEN_ACCESSOR(Constant)
1495 ExternalReference value() const {
1496 return hydrogen()->ExternalReferenceValue();
1501 class LConstantT V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1503 DECLARE_CONCRETE_INSTRUCTION(ConstantT, "constant-t")
1504 DECLARE_HYDROGEN_ACCESSOR(Constant)
1506 Handle<Object> value(Isolate* isolate) const {
1507 return hydrogen()->handle(isolate);
1512 class LBranch V8_FINAL : public LControlInstruction<1, 1> {
1514 LBranch(LOperand* value, LOperand* temp) {
1519 LOperand* value() { return inputs_[0]; }
1520 LOperand* temp() { return temps_[0]; }
1522 DECLARE_CONCRETE_INSTRUCTION(Branch, "branch")
1523 DECLARE_HYDROGEN_ACCESSOR(Branch)
1525 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1529 class LCmpMapAndBranch V8_FINAL : public LControlInstruction<1, 0> {
1531 explicit LCmpMapAndBranch(LOperand* value) {
1535 LOperand* value() { return inputs_[0]; }
1537 DECLARE_CONCRETE_INSTRUCTION(CmpMapAndBranch, "cmp-map-and-branch")
1538 DECLARE_HYDROGEN_ACCESSOR(CompareMap)
1540 Handle<Map> map() const { return hydrogen()->map().handle(); }
1544 class LMapEnumLength V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1546 explicit LMapEnumLength(LOperand* value) {
1550 LOperand* value() { return inputs_[0]; }
1552 DECLARE_CONCRETE_INSTRUCTION(MapEnumLength, "map-enum-length")
1556 class LDateField V8_FINAL : public LTemplateInstruction<1, 1, 1> {
1558 LDateField(LOperand* date, LOperand* temp, Smi* index)
1564 LOperand* date() { return inputs_[0]; }
1565 LOperand* temp() { return temps_[0]; }
1567 DECLARE_CONCRETE_INSTRUCTION(DateField, "date-field")
1568 DECLARE_HYDROGEN_ACCESSOR(DateField)
1570 Smi* index() const { return index_; }
1577 class LSeqStringGetChar V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1579 LSeqStringGetChar(LOperand* string, LOperand* index) {
1580 inputs_[0] = string;
1584 LOperand* string() const { return inputs_[0]; }
1585 LOperand* index() const { return inputs_[1]; }
1587 DECLARE_CONCRETE_INSTRUCTION(SeqStringGetChar, "seq-string-get-char")
1588 DECLARE_HYDROGEN_ACCESSOR(SeqStringGetChar)
1592 class LSeqStringSetChar V8_FINAL : public LTemplateInstruction<1, 4, 0> {
1594 LSeqStringSetChar(LOperand* context,
1598 inputs_[0] = context;
1599 inputs_[1] = string;
1604 LOperand* string() { return inputs_[1]; }
1605 LOperand* index() { return inputs_[2]; }
1606 LOperand* value() { return inputs_[3]; }
1608 DECLARE_CONCRETE_INSTRUCTION(SeqStringSetChar, "seq-string-set-char")
1609 DECLARE_HYDROGEN_ACCESSOR(SeqStringSetChar)
1613 class LAddI V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1615 LAddI(LOperand* left, LOperand* right) {
1620 LOperand* left() { return inputs_[0]; }
1621 LOperand* right() { return inputs_[1]; }
1623 static bool UseLea(HAdd* add) {
1624 return !add->CheckFlag(HValue::kCanOverflow) &&
1625 add->BetterLeftOperand()->UseCount() > 1;
1628 DECLARE_CONCRETE_INSTRUCTION(AddI, "add-i")
1629 DECLARE_HYDROGEN_ACCESSOR(Add)
1633 class LMathMinMax V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1635 LMathMinMax(LOperand* left, LOperand* right) {
1640 LOperand* left() { return inputs_[0]; }
1641 LOperand* right() { return inputs_[1]; }
1643 DECLARE_CONCRETE_INSTRUCTION(MathMinMax, "math-min-max")
1644 DECLARE_HYDROGEN_ACCESSOR(MathMinMax)
1648 class LPower V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1650 LPower(LOperand* left, LOperand* right) {
1655 LOperand* left() { return inputs_[0]; }
1656 LOperand* right() { return inputs_[1]; }
1658 DECLARE_CONCRETE_INSTRUCTION(Power, "power")
1659 DECLARE_HYDROGEN_ACCESSOR(Power)
1663 class LArithmeticD V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1665 LArithmeticD(Token::Value op, LOperand* left, LOperand* right)
1671 LOperand* left() { return inputs_[0]; }
1672 LOperand* right() { return inputs_[1]; }
1674 Token::Value op() const { return op_; }
1676 virtual Opcode opcode() const V8_OVERRIDE {
1677 return LInstruction::kArithmeticD;
1679 virtual void CompileToNative(LCodeGen* generator) V8_OVERRIDE;
1680 virtual const char* Mnemonic() const V8_OVERRIDE;
1687 class LArithmeticT V8_FINAL : public LTemplateInstruction<1, 3, 0> {
1689 LArithmeticT(Token::Value op,
1694 inputs_[0] = context;
1699 LOperand* context() { return inputs_[0]; }
1700 LOperand* left() { return inputs_[1]; }
1701 LOperand* right() { return inputs_[2]; }
1703 virtual Opcode opcode() const V8_OVERRIDE {
1704 return LInstruction::kArithmeticT;
1706 virtual void CompileToNative(LCodeGen* generator) V8_OVERRIDE;
1707 virtual const char* Mnemonic() const V8_OVERRIDE;
1709 Token::Value op() const { return op_; }
1716 class LReturn V8_FINAL : public LTemplateInstruction<0, 3, 0> {
1718 explicit LReturn(LOperand* value,
1720 LOperand* parameter_count) {
1722 inputs_[1] = context;
1723 inputs_[2] = parameter_count;
1726 bool has_constant_parameter_count() {
1727 return parameter_count()->IsConstantOperand();
1729 LConstantOperand* constant_parameter_count() {
1730 ASSERT(has_constant_parameter_count());
1731 return LConstantOperand::cast(parameter_count());
1733 LOperand* parameter_count() { return inputs_[2]; }
1735 DECLARE_CONCRETE_INSTRUCTION(Return, "return")
1736 DECLARE_HYDROGEN_ACCESSOR(Return)
1740 class LLoadNamedField V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1742 explicit LLoadNamedField(LOperand* object) {
1743 inputs_[0] = object;
1746 LOperand* object() { return inputs_[0]; }
1748 DECLARE_CONCRETE_INSTRUCTION(LoadNamedField, "load-named-field")
1749 DECLARE_HYDROGEN_ACCESSOR(LoadNamedField)
1753 class LLoadNamedGeneric V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1755 LLoadNamedGeneric(LOperand* context, LOperand* object) {
1756 inputs_[0] = context;
1757 inputs_[1] = object;
1760 LOperand* context() { return inputs_[0]; }
1761 LOperand* object() { return inputs_[1]; }
1763 DECLARE_CONCRETE_INSTRUCTION(LoadNamedGeneric, "load-named-generic")
1764 DECLARE_HYDROGEN_ACCESSOR(LoadNamedGeneric)
1766 Handle<Object> name() const { return hydrogen()->name(); }
1770 class LLoadFunctionPrototype V8_FINAL : public LTemplateInstruction<1, 1, 1> {
1772 LLoadFunctionPrototype(LOperand* function, LOperand* temp) {
1773 inputs_[0] = function;
1777 LOperand* function() { return inputs_[0]; }
1778 LOperand* temp() { return temps_[0]; }
1780 DECLARE_CONCRETE_INSTRUCTION(LoadFunctionPrototype, "load-function-prototype")
1781 DECLARE_HYDROGEN_ACCESSOR(LoadFunctionPrototype)
1785 class LLoadRoot V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1787 DECLARE_CONCRETE_INSTRUCTION(LoadRoot, "load-root")
1788 DECLARE_HYDROGEN_ACCESSOR(LoadRoot)
1790 Heap::RootListIndex index() const { return hydrogen()->index(); }
1794 class LLoadKeyed V8_FINAL : public LTemplateInstruction<1, 2, 1> {
1796 LLoadKeyed(LOperand* elements, LOperand* key, LOperand* temp) {
1797 inputs_[0] = elements;
1801 LOperand* elements() { return inputs_[0]; }
1802 LOperand* key() { return inputs_[1]; }
1803 LOperand* temp() { return temps_[0]; }
1804 ElementsKind elements_kind() const {
1805 return hydrogen()->elements_kind();
1807 bool is_external() const {
1808 return hydrogen()->is_external();
1810 bool is_fixed_typed_array() const {
1811 return hydrogen()->is_fixed_typed_array();
1813 bool is_typed_elements() const {
1814 return is_external() || is_fixed_typed_array();
1817 DECLARE_CONCRETE_INSTRUCTION(LoadKeyed, "load-keyed")
1818 DECLARE_HYDROGEN_ACCESSOR(LoadKeyed)
1820 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1821 uint32_t additional_index() const { return hydrogen()->index_offset(); }
1823 return hydrogen()->key()->representation().IsTagged();
1828 inline static bool ExternalArrayOpRequiresPreScale(
1829 Representation key_representation,
1830 ElementsKind kind) {
1831 int shift_size = ElementsKindToShiftSize(kind);
1832 return key_representation.IsSmi()
1833 ? shift_size > static_cast<int>(maximal_scale_factor) + kSmiTagSize
1834 : shift_size > static_cast<int>(maximal_scale_factor);
1838 inline static bool ExternalArrayOpRequiresTemp(
1839 Representation key_representation,
1840 ElementsKind elements_kind) {
1841 // Operations that require the key to be scaled by a factor or divided by two
1842 // to be converted into an index cannot fold the scale operation into a load
1843 // and need an extra temp register to do the work.
1844 return ExternalArrayOpRequiresPreScale(key_representation, elements_kind) ||
1845 (key_representation.IsSmi() &&
1846 (elements_kind == EXTERNAL_INT8_ELEMENTS ||
1847 elements_kind == EXTERNAL_UINT8_ELEMENTS ||
1848 elements_kind == EXTERNAL_UINT8_CLAMPED_ELEMENTS ||
1849 elements_kind == UINT8_ELEMENTS ||
1850 elements_kind == INT8_ELEMENTS ||
1851 elements_kind == UINT8_CLAMPED_ELEMENTS));
1855 class LLoadKeyedGeneric V8_FINAL : public LTemplateInstruction<1, 3, 0> {
1857 LLoadKeyedGeneric(LOperand* context, LOperand* obj, LOperand* key) {
1858 inputs_[0] = context;
1863 LOperand* context() { return inputs_[0]; }
1864 LOperand* object() { return inputs_[1]; }
1865 LOperand* key() { return inputs_[2]; }
1867 DECLARE_CONCRETE_INSTRUCTION(LoadKeyedGeneric, "load-keyed-generic")
1871 class LLoadGlobalCell V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1873 DECLARE_CONCRETE_INSTRUCTION(LoadGlobalCell, "load-global-cell")
1874 DECLARE_HYDROGEN_ACCESSOR(LoadGlobalCell)
1878 class LLoadGlobalGeneric V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1880 LLoadGlobalGeneric(LOperand* context, LOperand* global_object) {
1881 inputs_[0] = context;
1882 inputs_[1] = global_object;
1885 LOperand* context() { return inputs_[0]; }
1886 LOperand* global_object() { return inputs_[1]; }
1888 DECLARE_CONCRETE_INSTRUCTION(LoadGlobalGeneric, "load-global-generic")
1889 DECLARE_HYDROGEN_ACCESSOR(LoadGlobalGeneric)
1891 Handle<Object> name() const { return hydrogen()->name(); }
1892 bool for_typeof() const { return hydrogen()->for_typeof(); }
1896 class LStoreGlobalCell V8_FINAL : public LTemplateInstruction<0, 1, 0> {
1898 explicit LStoreGlobalCell(LOperand* value) {
1902 LOperand* value() { return inputs_[0]; }
1904 DECLARE_CONCRETE_INSTRUCTION(StoreGlobalCell, "store-global-cell")
1905 DECLARE_HYDROGEN_ACCESSOR(StoreGlobalCell)
1909 class LLoadContextSlot V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1911 explicit LLoadContextSlot(LOperand* context) {
1912 inputs_[0] = context;
1915 LOperand* context() { return inputs_[0]; }
1917 DECLARE_CONCRETE_INSTRUCTION(LoadContextSlot, "load-context-slot")
1918 DECLARE_HYDROGEN_ACCESSOR(LoadContextSlot)
1920 int slot_index() { return hydrogen()->slot_index(); }
1922 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1926 class LStoreContextSlot V8_FINAL : public LTemplateInstruction<0, 2, 1> {
1928 LStoreContextSlot(LOperand* context, LOperand* value, LOperand* temp) {
1929 inputs_[0] = context;
1934 LOperand* context() { return inputs_[0]; }
1935 LOperand* value() { return inputs_[1]; }
1936 LOperand* temp() { return temps_[0]; }
1938 DECLARE_CONCRETE_INSTRUCTION(StoreContextSlot, "store-context-slot")
1939 DECLARE_HYDROGEN_ACCESSOR(StoreContextSlot)
1941 int slot_index() { return hydrogen()->slot_index(); }
1943 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1947 class LPushArgument V8_FINAL : public LTemplateInstruction<0, 1, 0> {
1949 explicit LPushArgument(LOperand* value) {
1953 LOperand* value() { return inputs_[0]; }
1955 DECLARE_CONCRETE_INSTRUCTION(PushArgument, "push-argument")
1959 class LDrop V8_FINAL : public LTemplateInstruction<0, 0, 0> {
1961 explicit LDrop(int count) : count_(count) { }
1963 int count() const { return count_; }
1965 DECLARE_CONCRETE_INSTRUCTION(Drop, "drop")
1972 class LStoreCodeEntry V8_FINAL: public LTemplateInstruction<0, 1, 1> {
1974 LStoreCodeEntry(LOperand* function, LOperand* code_object) {
1975 inputs_[0] = function;
1976 temps_[0] = code_object;
1979 LOperand* function() { return inputs_[0]; }
1980 LOperand* code_object() { return temps_[0]; }
1982 virtual void PrintDataTo(StringStream* stream);
1984 DECLARE_CONCRETE_INSTRUCTION(StoreCodeEntry, "store-code-entry")
1985 DECLARE_HYDROGEN_ACCESSOR(StoreCodeEntry)
1989 class LInnerAllocatedObject V8_FINAL: public LTemplateInstruction<1, 2, 0> {
1991 LInnerAllocatedObject(LOperand* base_object, LOperand* offset) {
1992 inputs_[0] = base_object;
1993 inputs_[1] = offset;
1996 LOperand* base_object() const { return inputs_[0]; }
1997 LOperand* offset() const { return inputs_[1]; }
1999 virtual void PrintDataTo(StringStream* stream);
2001 DECLARE_CONCRETE_INSTRUCTION(InnerAllocatedObject, "inner-allocated-object")
2005 class LThisFunction V8_FINAL : public LTemplateInstruction<1, 0, 0> {
2007 DECLARE_CONCRETE_INSTRUCTION(ThisFunction, "this-function")
2008 DECLARE_HYDROGEN_ACCESSOR(ThisFunction)
2012 class LContext V8_FINAL : public LTemplateInstruction<1, 0, 0> {
2014 DECLARE_CONCRETE_INSTRUCTION(Context, "context")
2015 DECLARE_HYDROGEN_ACCESSOR(Context)
2019 class LDeclareGlobals V8_FINAL : public LTemplateInstruction<0, 1, 0> {
2021 explicit LDeclareGlobals(LOperand* context) {
2022 inputs_[0] = context;
2025 LOperand* context() { return inputs_[0]; }
2027 DECLARE_CONCRETE_INSTRUCTION(DeclareGlobals, "declare-globals")
2028 DECLARE_HYDROGEN_ACCESSOR(DeclareGlobals)
2032 class LCallJSFunction V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2034 explicit LCallJSFunction(LOperand* function) {
2035 inputs_[0] = function;
2038 LOperand* function() { return inputs_[0]; }
2040 DECLARE_CONCRETE_INSTRUCTION(CallJSFunction, "call-js-function")
2041 DECLARE_HYDROGEN_ACCESSOR(CallJSFunction)
2043 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
2045 int arity() const { return hydrogen()->argument_count() - 1; }
2049 class LCallWithDescriptor V8_FINAL : public LTemplateResultInstruction<1> {
2051 LCallWithDescriptor(const CallInterfaceDescriptor* descriptor,
2052 ZoneList<LOperand*>& operands,
2054 : inputs_(descriptor->environment_length() + 1, zone) {
2055 ASSERT(descriptor->environment_length() + 1 == operands.length());
2056 inputs_.AddAll(operands, zone);
2059 LOperand* target() const { return inputs_[0]; }
2062 DECLARE_CONCRETE_INSTRUCTION(CallWithDescriptor, "call-with-descriptor")
2063 DECLARE_HYDROGEN_ACCESSOR(CallWithDescriptor)
2065 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
2067 int arity() const { return hydrogen()->argument_count() - 1; }
2069 ZoneList<LOperand*> inputs_;
2071 // Iterator support.
2072 virtual int InputCount() V8_FINAL V8_OVERRIDE { return inputs_.length(); }
2073 virtual LOperand* InputAt(int i) V8_FINAL V8_OVERRIDE { return inputs_[i]; }
2075 virtual int TempCount() V8_FINAL V8_OVERRIDE { return 0; }
2076 virtual LOperand* TempAt(int i) V8_FINAL V8_OVERRIDE { return NULL; }
2080 class LInvokeFunction V8_FINAL : public LTemplateInstruction<1, 2, 0> {
2082 LInvokeFunction(LOperand* context, LOperand* function) {
2083 inputs_[0] = context;
2084 inputs_[1] = function;
2087 LOperand* context() { return inputs_[0]; }
2088 LOperand* function() { return inputs_[1]; }
2090 DECLARE_CONCRETE_INSTRUCTION(InvokeFunction, "invoke-function")
2091 DECLARE_HYDROGEN_ACCESSOR(InvokeFunction)
2093 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
2095 int arity() const { return hydrogen()->argument_count() - 1; }
2099 class LCallFunction V8_FINAL : public LTemplateInstruction<1, 2, 0> {
2101 explicit LCallFunction(LOperand* context, LOperand* function) {
2102 inputs_[0] = context;
2103 inputs_[1] = function;
2106 LOperand* context() { return inputs_[0]; }
2107 LOperand* function() { return inputs_[1]; }
2109 DECLARE_CONCRETE_INSTRUCTION(CallFunction, "call-function")
2110 DECLARE_HYDROGEN_ACCESSOR(CallFunction)
2112 int arity() const { return hydrogen()->argument_count() - 1; }
2116 class LCallNew V8_FINAL : public LTemplateInstruction<1, 2, 0> {
2118 LCallNew(LOperand* context, LOperand* constructor) {
2119 inputs_[0] = context;
2120 inputs_[1] = constructor;
2123 LOperand* context() { return inputs_[0]; }
2124 LOperand* constructor() { return inputs_[1]; }
2126 DECLARE_CONCRETE_INSTRUCTION(CallNew, "call-new")
2127 DECLARE_HYDROGEN_ACCESSOR(CallNew)
2129 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
2131 int arity() const { return hydrogen()->argument_count() - 1; }
2135 class LCallNewArray V8_FINAL : public LTemplateInstruction<1, 2, 0> {
2137 LCallNewArray(LOperand* context, LOperand* constructor) {
2138 inputs_[0] = context;
2139 inputs_[1] = constructor;
2142 LOperand* context() { return inputs_[0]; }
2143 LOperand* constructor() { return inputs_[1]; }
2145 DECLARE_CONCRETE_INSTRUCTION(CallNewArray, "call-new-array")
2146 DECLARE_HYDROGEN_ACCESSOR(CallNewArray)
2148 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
2150 int arity() const { return hydrogen()->argument_count() - 1; }
2154 class LCallRuntime V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2156 explicit LCallRuntime(LOperand* context) {
2157 inputs_[0] = context;
2160 LOperand* context() { return inputs_[0]; }
2162 DECLARE_CONCRETE_INSTRUCTION(CallRuntime, "call-runtime")
2163 DECLARE_HYDROGEN_ACCESSOR(CallRuntime)
2165 virtual bool ClobbersDoubleRegisters(Isolate* isolate) const V8_OVERRIDE {
2166 return save_doubles() == kDontSaveFPRegs;
2169 const Runtime::Function* function() const { return hydrogen()->function(); }
2170 int arity() const { return hydrogen()->argument_count(); }
2171 SaveFPRegsMode save_doubles() const { return hydrogen()->save_doubles(); }
2175 class LInteger32ToDouble V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2177 explicit LInteger32ToDouble(LOperand* value) {
2181 LOperand* value() { return inputs_[0]; }
2183 DECLARE_CONCRETE_INSTRUCTION(Integer32ToDouble, "int32-to-double")
2187 class LUint32ToDouble V8_FINAL : public LTemplateInstruction<1, 1, 1> {
2189 explicit LUint32ToDouble(LOperand* value, LOperand* temp) {
2194 LOperand* value() { return inputs_[0]; }
2195 LOperand* temp() { return temps_[0]; }
2197 DECLARE_CONCRETE_INSTRUCTION(Uint32ToDouble, "uint32-to-double")
2201 class LNumberTagI V8_FINAL : public LTemplateInstruction<1, 1, 1> {
2203 LNumberTagI(LOperand* value, LOperand* temp) {
2208 LOperand* value() { return inputs_[0]; }
2209 LOperand* temp() { return temps_[0]; }
2211 DECLARE_CONCRETE_INSTRUCTION(NumberTagI, "number-tag-i")
2215 class LNumberTagU V8_FINAL : public LTemplateInstruction<1, 1, 2> {
2217 LNumberTagU(LOperand* value, LOperand* temp1, LOperand* temp2) {
2223 LOperand* value() { return inputs_[0]; }
2224 LOperand* temp1() { return temps_[0]; }
2225 LOperand* temp2() { return temps_[1]; }
2227 DECLARE_CONCRETE_INSTRUCTION(NumberTagU, "number-tag-u")
2231 class LNumberTagD V8_FINAL : public LTemplateInstruction<1, 1, 1> {
2233 LNumberTagD(LOperand* value, LOperand* temp) {
2238 LOperand* value() { return inputs_[0]; }
2239 LOperand* temp() { return temps_[0]; }
2241 DECLARE_CONCRETE_INSTRUCTION(NumberTagD, "number-tag-d")
2242 DECLARE_HYDROGEN_ACCESSOR(Change)
2246 class LSIMD128ToTagged V8_FINAL : public LTemplateInstruction<1, 1, 1> {
2248 explicit LSIMD128ToTagged(LOperand* value, LOperand* temp) {
2253 LOperand* value() { return inputs_[0]; }
2254 LOperand* temp() { return temps_[0]; }
2256 DECLARE_CONCRETE_INSTRUCTION(SIMD128ToTagged, "simd128-tag")
2257 DECLARE_HYDROGEN_ACCESSOR(Change)
2261 // Sometimes truncating conversion from a tagged value to an int32.
2262 class LDoubleToI V8_FINAL : public LTemplateInstruction<1, 1, 1> {
2264 LDoubleToI(LOperand* value, LOperand* temp) {
2269 LOperand* value() { return inputs_[0]; }
2270 LOperand* temp() { return temps_[0]; }
2272 DECLARE_CONCRETE_INSTRUCTION(DoubleToI, "double-to-i")
2273 DECLARE_HYDROGEN_ACCESSOR(UnaryOperation)
2275 bool truncating() { return hydrogen()->CanTruncateToInt32(); }
2279 class LDoubleToSmi V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2281 explicit LDoubleToSmi(LOperand* value) {
2285 LOperand* value() { return inputs_[0]; }
2287 DECLARE_CONCRETE_INSTRUCTION(DoubleToSmi, "double-to-smi")
2288 DECLARE_HYDROGEN_ACCESSOR(UnaryOperation)
2292 // Truncating conversion from a tagged value to an int32.
2293 class LTaggedToI V8_FINAL : public LTemplateInstruction<1, 1, 1> {
2295 LTaggedToI(LOperand* value, LOperand* temp) {
2300 LOperand* value() { return inputs_[0]; }
2301 LOperand* temp() { return temps_[0]; }
2303 DECLARE_CONCRETE_INSTRUCTION(TaggedToI, "tagged-to-i")
2304 DECLARE_HYDROGEN_ACCESSOR(Change)
2306 bool truncating() { return hydrogen()->CanTruncateToInt32(); }
2310 class LSmiTag V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2312 explicit LSmiTag(LOperand* value) {
2316 LOperand* value() { return inputs_[0]; }
2318 DECLARE_CONCRETE_INSTRUCTION(SmiTag, "smi-tag")
2319 DECLARE_HYDROGEN_ACCESSOR(Change)
2323 class LNumberUntagD V8_FINAL : public LTemplateInstruction<1, 1, 1> {
2325 explicit LNumberUntagD(LOperand* value, LOperand* temp) {
2330 LOperand* value() { return inputs_[0]; }
2331 LOperand* temp() { return temps_[0]; }
2333 DECLARE_CONCRETE_INSTRUCTION(NumberUntagD, "double-untag")
2334 DECLARE_HYDROGEN_ACCESSOR(Change);
2338 class LTaggedToSIMD128 V8_FINAL : public LTemplateInstruction<1, 1, 1> {
2340 explicit LTaggedToSIMD128(LOperand* value, LOperand* temp,
2341 Representation representation) : representation_(representation) {
2346 LOperand* value() { return inputs_[0]; }
2347 LOperand* temp() { return temps_[0]; }
2348 Representation representation() const { return representation_; }
2350 DECLARE_CONCRETE_INSTRUCTION(TaggedToSIMD128, "simd128-untag")
2351 DECLARE_HYDROGEN_ACCESSOR(Change);
2353 Representation representation_;
2357 class LSmiUntag V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2359 LSmiUntag(LOperand* value, bool needs_check)
2360 : needs_check_(needs_check) {
2364 LOperand* value() { return inputs_[0]; }
2366 DECLARE_CONCRETE_INSTRUCTION(SmiUntag, "smi-untag")
2368 bool needs_check() const { return needs_check_; }
2375 class LStoreNamedField V8_FINAL : public LTemplateInstruction<0, 2, 2> {
2377 LStoreNamedField(LOperand* obj,
2380 LOperand* temp_map) {
2384 temps_[1] = temp_map;
2387 LOperand* object() { return inputs_[0]; }
2388 LOperand* value() { return inputs_[1]; }
2389 LOperand* temp() { return temps_[0]; }
2390 LOperand* temp_map() { return temps_[1]; }
2392 DECLARE_CONCRETE_INSTRUCTION(StoreNamedField, "store-named-field")
2393 DECLARE_HYDROGEN_ACCESSOR(StoreNamedField)
2395 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
2399 class LStoreNamedGeneric V8_FINAL : public LTemplateInstruction<0, 3, 0> {
2401 LStoreNamedGeneric(LOperand* context, LOperand* object, LOperand* value) {
2402 inputs_[0] = context;
2403 inputs_[1] = object;
2407 LOperand* context() { return inputs_[0]; }
2408 LOperand* object() { return inputs_[1]; }
2409 LOperand* value() { return inputs_[2]; }
2411 DECLARE_CONCRETE_INSTRUCTION(StoreNamedGeneric, "store-named-generic")
2412 DECLARE_HYDROGEN_ACCESSOR(StoreNamedGeneric)
2414 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
2415 Handle<Object> name() const { return hydrogen()->name(); }
2416 StrictMode strict_mode() { return hydrogen()->strict_mode(); }
2420 class LStoreKeyed V8_FINAL : public LTemplateInstruction<0, 3, 1> {
2422 LStoreKeyed(LOperand* obj, LOperand* key, LOperand* val, LOperand* temp) {
2429 bool is_external() const { return hydrogen()->is_external(); }
2430 bool is_fixed_typed_array() const {
2431 return hydrogen()->is_fixed_typed_array();
2433 bool is_typed_elements() const {
2434 return is_external() || is_fixed_typed_array();
2436 LOperand* elements() { return inputs_[0]; }
2437 LOperand* key() { return inputs_[1]; }
2438 LOperand* value() { return inputs_[2]; }
2439 LOperand* temp() { return temps_[0]; }
2440 ElementsKind elements_kind() const {
2441 return hydrogen()->elements_kind();
2444 DECLARE_CONCRETE_INSTRUCTION(StoreKeyed, "store-keyed")
2445 DECLARE_HYDROGEN_ACCESSOR(StoreKeyed)
2447 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
2448 uint32_t additional_index() const { return hydrogen()->index_offset(); }
2449 bool NeedsCanonicalization() { return hydrogen()->NeedsCanonicalization(); }
2453 class LStoreKeyedGeneric V8_FINAL : public LTemplateInstruction<0, 4, 0> {
2455 LStoreKeyedGeneric(LOperand* context,
2459 inputs_[0] = context;
2460 inputs_[1] = object;
2465 LOperand* context() { return inputs_[0]; }
2466 LOperand* object() { return inputs_[1]; }
2467 LOperand* key() { return inputs_[2]; }
2468 LOperand* value() { return inputs_[3]; }
2470 DECLARE_CONCRETE_INSTRUCTION(StoreKeyedGeneric, "store-keyed-generic")
2471 DECLARE_HYDROGEN_ACCESSOR(StoreKeyedGeneric)
2473 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
2475 StrictMode strict_mode() { return hydrogen()->strict_mode(); }
2479 class LTransitionElementsKind V8_FINAL : public LTemplateInstruction<0, 2, 2> {
2481 LTransitionElementsKind(LOperand* object,
2483 LOperand* new_map_temp,
2485 inputs_[0] = object;
2486 inputs_[1] = context;
2487 temps_[0] = new_map_temp;
2491 LOperand* context() { return inputs_[1]; }
2492 LOperand* object() { return inputs_[0]; }
2493 LOperand* new_map_temp() { return temps_[0]; }
2494 LOperand* temp() { return temps_[1]; }
2496 DECLARE_CONCRETE_INSTRUCTION(TransitionElementsKind,
2497 "transition-elements-kind")
2498 DECLARE_HYDROGEN_ACCESSOR(TransitionElementsKind)
2500 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
2502 Handle<Map> original_map() { return hydrogen()->original_map().handle(); }
2503 Handle<Map> transitioned_map() {
2504 return hydrogen()->transitioned_map().handle();
2506 ElementsKind from_kind() { return hydrogen()->from_kind(); }
2507 ElementsKind to_kind() { return hydrogen()->to_kind(); }
2511 class LTrapAllocationMemento V8_FINAL : public LTemplateInstruction<0, 1, 1> {
2513 LTrapAllocationMemento(LOperand* object,
2515 inputs_[0] = object;
2519 LOperand* object() { return inputs_[0]; }
2520 LOperand* temp() { return temps_[0]; }
2522 DECLARE_CONCRETE_INSTRUCTION(TrapAllocationMemento,
2523 "trap-allocation-memento")
2527 class LStringAdd V8_FINAL : public LTemplateInstruction<1, 3, 0> {
2529 LStringAdd(LOperand* context, LOperand* left, LOperand* right) {
2530 inputs_[0] = context;
2535 LOperand* context() { return inputs_[0]; }
2536 LOperand* left() { return inputs_[1]; }
2537 LOperand* right() { return inputs_[2]; }
2539 DECLARE_CONCRETE_INSTRUCTION(StringAdd, "string-add")
2540 DECLARE_HYDROGEN_ACCESSOR(StringAdd)
2544 class LStringCharCodeAt V8_FINAL : public LTemplateInstruction<1, 3, 0> {
2546 LStringCharCodeAt(LOperand* context, LOperand* string, LOperand* index) {
2547 inputs_[0] = context;
2548 inputs_[1] = string;
2552 LOperand* context() { return inputs_[0]; }
2553 LOperand* string() { return inputs_[1]; }
2554 LOperand* index() { return inputs_[2]; }
2556 DECLARE_CONCRETE_INSTRUCTION(StringCharCodeAt, "string-char-code-at")
2557 DECLARE_HYDROGEN_ACCESSOR(StringCharCodeAt)
2561 class LStringCharFromCode V8_FINAL : public LTemplateInstruction<1, 2, 0> {
2563 LStringCharFromCode(LOperand* context, LOperand* char_code) {
2564 inputs_[0] = context;
2565 inputs_[1] = char_code;
2568 LOperand* context() { return inputs_[0]; }
2569 LOperand* char_code() { return inputs_[1]; }
2571 DECLARE_CONCRETE_INSTRUCTION(StringCharFromCode, "string-char-from-code")
2572 DECLARE_HYDROGEN_ACCESSOR(StringCharFromCode)
2576 class LCheckValue V8_FINAL : public LTemplateInstruction<0, 1, 0> {
2578 explicit LCheckValue(LOperand* value) {
2582 LOperand* value() { return inputs_[0]; }
2584 DECLARE_CONCRETE_INSTRUCTION(CheckValue, "check-value")
2585 DECLARE_HYDROGEN_ACCESSOR(CheckValue)
2589 class LCheckInstanceType V8_FINAL : public LTemplateInstruction<0, 1, 1> {
2591 LCheckInstanceType(LOperand* value, LOperand* temp) {
2596 LOperand* value() { return inputs_[0]; }
2597 LOperand* temp() { return temps_[0]; }
2599 DECLARE_CONCRETE_INSTRUCTION(CheckInstanceType, "check-instance-type")
2600 DECLARE_HYDROGEN_ACCESSOR(CheckInstanceType)
2604 class LCheckMaps V8_FINAL : public LTemplateInstruction<0, 1, 0> {
2606 explicit LCheckMaps(LOperand* value = NULL) {
2610 LOperand* value() { return inputs_[0]; }
2612 DECLARE_CONCRETE_INSTRUCTION(CheckMaps, "check-maps")
2613 DECLARE_HYDROGEN_ACCESSOR(CheckMaps)
2617 class LCheckSmi V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2619 explicit LCheckSmi(LOperand* value) {
2623 LOperand* value() { return inputs_[0]; }
2625 DECLARE_CONCRETE_INSTRUCTION(CheckSmi, "check-smi")
2629 class LClampDToUint8 V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2631 explicit LClampDToUint8(LOperand* value) {
2635 LOperand* unclamped() { return inputs_[0]; }
2637 DECLARE_CONCRETE_INSTRUCTION(ClampDToUint8, "clamp-d-to-uint8")
2641 class LClampIToUint8 V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2643 explicit LClampIToUint8(LOperand* value) {
2647 LOperand* unclamped() { return inputs_[0]; }
2649 DECLARE_CONCRETE_INSTRUCTION(ClampIToUint8, "clamp-i-to-uint8")
2653 class LClampTToUint8 V8_FINAL : public LTemplateInstruction<1, 1, 1> {
2655 LClampTToUint8(LOperand* value, LOperand* temp_xmm) {
2657 temps_[0] = temp_xmm;
2660 LOperand* unclamped() { return inputs_[0]; }
2661 LOperand* temp_xmm() { return temps_[0]; }
2663 DECLARE_CONCRETE_INSTRUCTION(ClampTToUint8, "clamp-t-to-uint8")
2667 // Truncating conversion from a tagged value to an int32.
2668 class LClampTToUint8NoSSE2 V8_FINAL : public LTemplateInstruction<1, 1, 3> {
2670 LClampTToUint8NoSSE2(LOperand* unclamped,
2674 inputs_[0] = unclamped;
2680 LOperand* unclamped() { return inputs_[0]; }
2681 LOperand* scratch() { return temps_[0]; }
2682 LOperand* scratch2() { return temps_[1]; }
2683 LOperand* scratch3() { return temps_[2]; }
2685 DECLARE_CONCRETE_INSTRUCTION(ClampTToUint8NoSSE2,
2686 "clamp-t-to-uint8-nosse2")
2687 DECLARE_HYDROGEN_ACCESSOR(UnaryOperation)
2691 class LCheckNonSmi V8_FINAL : public LTemplateInstruction<0, 1, 0> {
2693 explicit LCheckNonSmi(LOperand* value) {
2697 LOperand* value() { return inputs_[0]; }
2699 DECLARE_CONCRETE_INSTRUCTION(CheckNonSmi, "check-non-smi")
2700 DECLARE_HYDROGEN_ACCESSOR(CheckHeapObject)
2704 class LDoubleBits V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2706 explicit LDoubleBits(LOperand* value) {
2710 LOperand* value() { return inputs_[0]; }
2712 DECLARE_CONCRETE_INSTRUCTION(DoubleBits, "double-bits")
2713 DECLARE_HYDROGEN_ACCESSOR(DoubleBits)
2717 class LConstructDouble V8_FINAL : public LTemplateInstruction<1, 2, 0> {
2719 LConstructDouble(LOperand* hi, LOperand* lo) {
2724 LOperand* hi() { return inputs_[0]; }
2725 LOperand* lo() { return inputs_[1]; }
2727 DECLARE_CONCRETE_INSTRUCTION(ConstructDouble, "construct-double")
2731 class LAllocate V8_FINAL : public LTemplateInstruction<1, 2, 1> {
2733 LAllocate(LOperand* context, LOperand* size, LOperand* temp) {
2734 inputs_[0] = context;
2739 LOperand* context() { return inputs_[0]; }
2740 LOperand* size() { return inputs_[1]; }
2741 LOperand* temp() { return temps_[0]; }
2743 DECLARE_CONCRETE_INSTRUCTION(Allocate, "allocate")
2744 DECLARE_HYDROGEN_ACCESSOR(Allocate)
2748 class LRegExpLiteral V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2750 explicit LRegExpLiteral(LOperand* context) {
2751 inputs_[0] = context;
2754 LOperand* context() { return inputs_[0]; }
2756 DECLARE_CONCRETE_INSTRUCTION(RegExpLiteral, "regexp-literal")
2757 DECLARE_HYDROGEN_ACCESSOR(RegExpLiteral)
2761 class LFunctionLiteral V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2763 explicit LFunctionLiteral(LOperand* context) {
2764 inputs_[0] = context;
2767 LOperand* context() { return inputs_[0]; }
2769 DECLARE_CONCRETE_INSTRUCTION(FunctionLiteral, "function-literal")
2770 DECLARE_HYDROGEN_ACCESSOR(FunctionLiteral)
2774 class LToFastProperties V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2776 explicit LToFastProperties(LOperand* value) {
2780 LOperand* value() { return inputs_[0]; }
2782 DECLARE_CONCRETE_INSTRUCTION(ToFastProperties, "to-fast-properties")
2783 DECLARE_HYDROGEN_ACCESSOR(ToFastProperties)
2787 class LTypeof V8_FINAL : public LTemplateInstruction<1, 2, 0> {
2789 LTypeof(LOperand* context, LOperand* value) {
2790 inputs_[0] = context;
2794 LOperand* context() { return inputs_[0]; }
2795 LOperand* value() { return inputs_[1]; }
2797 DECLARE_CONCRETE_INSTRUCTION(Typeof, "typeof")
2801 class LTypeofIsAndBranch V8_FINAL : public LControlInstruction<1, 0> {
2803 explicit LTypeofIsAndBranch(LOperand* value) {
2807 LOperand* value() { return inputs_[0]; }
2809 DECLARE_CONCRETE_INSTRUCTION(TypeofIsAndBranch, "typeof-is-and-branch")
2810 DECLARE_HYDROGEN_ACCESSOR(TypeofIsAndBranch)
2812 Handle<String> type_literal() { return hydrogen()->type_literal(); }
2814 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
2818 class LOsrEntry V8_FINAL : public LTemplateInstruction<0, 0, 0> {
2820 virtual bool HasInterestingComment(LCodeGen* gen) const V8_OVERRIDE {
2823 DECLARE_CONCRETE_INSTRUCTION(OsrEntry, "osr-entry")
2827 class LStackCheck V8_FINAL : public LTemplateInstruction<0, 1, 0> {
2829 explicit LStackCheck(LOperand* context) {
2830 inputs_[0] = context;
2833 LOperand* context() { return inputs_[0]; }
2835 DECLARE_CONCRETE_INSTRUCTION(StackCheck, "stack-check")
2836 DECLARE_HYDROGEN_ACCESSOR(StackCheck)
2838 Label* done_label() { return &done_label_; }
2845 class LForInPrepareMap V8_FINAL : public LTemplateInstruction<1, 2, 0> {
2847 LForInPrepareMap(LOperand* context, LOperand* object) {
2848 inputs_[0] = context;
2849 inputs_[1] = object;
2852 LOperand* context() { return inputs_[0]; }
2853 LOperand* object() { return inputs_[1]; }
2855 DECLARE_CONCRETE_INSTRUCTION(ForInPrepareMap, "for-in-prepare-map")
2859 class LForInCacheArray V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2861 explicit LForInCacheArray(LOperand* map) {
2865 LOperand* map() { return inputs_[0]; }
2867 DECLARE_CONCRETE_INSTRUCTION(ForInCacheArray, "for-in-cache-array")
2870 return HForInCacheArray::cast(this->hydrogen_value())->idx();
2875 class LCheckMapValue V8_FINAL : public LTemplateInstruction<0, 2, 0> {
2877 LCheckMapValue(LOperand* value, LOperand* map) {
2882 LOperand* value() { return inputs_[0]; }
2883 LOperand* map() { return inputs_[1]; }
2885 DECLARE_CONCRETE_INSTRUCTION(CheckMapValue, "check-map-value")
2889 class LLoadFieldByIndex V8_FINAL : public LTemplateInstruction<1, 2, 0> {
2891 LLoadFieldByIndex(LOperand* object, LOperand* index) {
2892 inputs_[0] = object;
2896 LOperand* object() { return inputs_[0]; }
2897 LOperand* index() { return inputs_[1]; }
2899 DECLARE_CONCRETE_INSTRUCTION(LoadFieldByIndex, "load-field-by-index")
2903 class LChunkBuilder;
2904 class LPlatformChunk V8_FINAL : public LChunk {
2906 LPlatformChunk(CompilationInfo* info, HGraph* graph)
2907 : LChunk(info, graph),
2908 num_double_slots_(0) { }
2910 int GetNextSpillIndex(RegisterKind kind);
2911 LOperand* GetNextSpillSlot(RegisterKind kind);
2913 int num_double_slots() const { return num_double_slots_; }
2916 int num_double_slots_;
2920 class LChunkBuilder V8_FINAL : public LChunkBuilderBase {
2922 LChunkBuilder(CompilationInfo* info, HGraph* graph, LAllocator* allocator)
2923 : LChunkBuilderBase(graph->zone()),
2928 current_instruction_(NULL),
2929 current_block_(NULL),
2931 allocator_(allocator) { }
2933 Isolate* isolate() const { return graph_->isolate(); }
2935 // Build the sequence for the graph.
2936 LPlatformChunk* Build();
2938 LInstruction* CheckElideControlInstruction(HControlInstruction* instr);
2940 // Declare methods that deal with the individual node types.
2941 #define DECLARE_DO(type) LInstruction* Do##type(H##type* node);
2942 HYDROGEN_CONCRETE_INSTRUCTION_LIST(DECLARE_DO)
2945 LInstruction* DoMathFloor(HUnaryMathOperation* instr);
2946 LInstruction* DoMathRound(HUnaryMathOperation* instr);
2947 LInstruction* DoMathAbs(HUnaryMathOperation* instr);
2948 LInstruction* DoMathLog(HUnaryMathOperation* instr);
2949 LInstruction* DoMathExp(HUnaryMathOperation* instr);
2950 LInstruction* DoMathSqrt(HUnaryMathOperation* instr);
2951 LInstruction* DoMathPowHalf(HUnaryMathOperation* instr);
2952 LInstruction* DoMathClz32(HUnaryMathOperation* instr);
2953 LInstruction* DoDivByPowerOf2I(HDiv* instr);
2954 LInstruction* DoDivByConstI(HDiv* instr);
2955 LInstruction* DoDivI(HDiv* instr);
2956 LInstruction* DoModByPowerOf2I(HMod* instr);
2957 LInstruction* DoModByConstI(HMod* instr);
2958 LInstruction* DoModI(HMod* instr);
2959 LInstruction* DoFlooringDivByPowerOf2I(HMathFloorOfDiv* instr);
2960 LInstruction* DoFlooringDivByConstI(HMathFloorOfDiv* instr);
2961 LInstruction* DoFlooringDivI(HMathFloorOfDiv* instr);
2971 LPlatformChunk* chunk() const { return chunk_; }
2972 CompilationInfo* info() const { return info_; }
2973 HGraph* graph() const { return graph_; }
2975 bool is_unused() const { return status_ == UNUSED; }
2976 bool is_building() const { return status_ == BUILDING; }
2977 bool is_done() const { return status_ == DONE; }
2978 bool is_aborted() const { return status_ == ABORTED; }
2980 void Abort(BailoutReason reason);
2982 // Methods for getting operands for Use / Define / Temp.
2983 LUnallocated* ToUnallocated(Register reg);
2984 LUnallocated* ToUnallocated(XMMRegister reg);
2985 LUnallocated* ToUnallocated(X87Register reg);
2987 // Methods for setting up define-use relationships.
2988 MUST_USE_RESULT LOperand* Use(HValue* value, LUnallocated* operand);
2989 MUST_USE_RESULT LOperand* UseFixed(HValue* value, Register fixed_register);
2990 MUST_USE_RESULT LOperand* UseFixedDouble(HValue* value,
2991 XMMRegister fixed_register);
2993 // A value that is guaranteed to be allocated to a register.
2994 // Operand created by UseRegister is guaranteed to be live until the end of
2995 // instruction. This means that register allocator will not reuse it's
2996 // register for any other operand inside instruction.
2997 // Operand created by UseRegisterAtStart is guaranteed to be live only at
2998 // instruction start. Register allocator is free to assign the same register
2999 // to some other operand used inside instruction (i.e. temporary or
3001 MUST_USE_RESULT LOperand* UseRegister(HValue* value);
3002 MUST_USE_RESULT LOperand* UseRegisterAtStart(HValue* value);
3004 // An input operand in a register that may be trashed.
3005 MUST_USE_RESULT LOperand* UseTempRegister(HValue* value);
3007 // An input operand in a register or stack slot.
3008 MUST_USE_RESULT LOperand* Use(HValue* value);
3009 MUST_USE_RESULT LOperand* UseAtStart(HValue* value);
3011 // An input operand in a register, stack slot or a constant operand.
3012 MUST_USE_RESULT LOperand* UseOrConstant(HValue* value);
3013 MUST_USE_RESULT LOperand* UseOrConstantAtStart(HValue* value);
3015 // An input operand in a fixed register or a constant operand.
3016 MUST_USE_RESULT LOperand* UseFixedOrConstant(HValue* value,
3017 Register fixed_register);
3019 // An input operand in a register or a constant operand.
3020 MUST_USE_RESULT LOperand* UseRegisterOrConstant(HValue* value);
3021 MUST_USE_RESULT LOperand* UseRegisterOrConstantAtStart(HValue* value);
3023 // An input operand in a constant operand.
3024 MUST_USE_RESULT LOperand* UseConstant(HValue* value);
3026 // An input operand in register, stack slot or a constant operand.
3027 // Will not be moved to a register even if one is freely available.
3028 virtual MUST_USE_RESULT LOperand* UseAny(HValue* value) V8_OVERRIDE;
3030 // Temporary operand that must be in a register.
3031 MUST_USE_RESULT LUnallocated* TempRegister();
3032 MUST_USE_RESULT LOperand* FixedTemp(Register reg);
3033 MUST_USE_RESULT LOperand* FixedTemp(XMMRegister reg);
3035 // Methods for setting up define-use relationships.
3036 // Return the same instruction that they are passed.
3037 LInstruction* Define(LTemplateResultInstruction<1>* instr,
3038 LUnallocated* result);
3039 LInstruction* DefineAsRegister(LTemplateResultInstruction<1>* instr);
3040 LInstruction* DefineAsSpilled(LTemplateResultInstruction<1>* instr,
3042 LInstruction* DefineSameAsFirst(LTemplateResultInstruction<1>* instr);
3043 LInstruction* DefineFixed(LTemplateResultInstruction<1>* instr,
3045 LInstruction* DefineFixedDouble(LTemplateResultInstruction<1>* instr,
3047 LInstruction* DefineX87TOS(LTemplateResultInstruction<1>* instr);
3048 // Assigns an environment to an instruction. An instruction which can
3049 // deoptimize must have an environment.
3050 LInstruction* AssignEnvironment(LInstruction* instr);
3051 // Assigns a pointer map to an instruction. An instruction which can
3052 // trigger a GC or a lazy deoptimization must have a pointer map.
3053 LInstruction* AssignPointerMap(LInstruction* instr);
3055 enum CanDeoptimize { CAN_DEOPTIMIZE_EAGERLY, CANNOT_DEOPTIMIZE_EAGERLY };
3057 LOperand* GetSeqStringSetCharOperand(HSeqStringSetChar* instr);
3059 // Marks a call for the register allocator. Assigns a pointer map to
3060 // support GC and lazy deoptimization. Assigns an environment to support
3061 // eager deoptimization if CAN_DEOPTIMIZE_EAGERLY.
3062 LInstruction* MarkAsCall(
3063 LInstruction* instr,
3064 HInstruction* hinstr,
3065 CanDeoptimize can_deoptimize = CANNOT_DEOPTIMIZE_EAGERLY);
3067 void VisitInstruction(HInstruction* current);
3069 void DoBasicBlock(HBasicBlock* block, HBasicBlock* next_block);
3070 LInstruction* DoShift(Token::Value op, HBitwiseBinaryOperation* instr);
3071 LInstruction* DoArithmeticD(Token::Value op,
3072 HArithmeticBinaryOperation* instr);
3073 LInstruction* DoArithmeticT(Token::Value op,
3074 HBinaryOperation* instr);
3076 LOperand* GetStoreKeyedValueOperand(HStoreKeyed* instr);
3078 LPlatformChunk* chunk_;
3079 CompilationInfo* info_;
3080 HGraph* const graph_;
3082 HInstruction* current_instruction_;
3083 HBasicBlock* current_block_;
3084 HBasicBlock* next_block_;
3085 LAllocator* allocator_;
3087 DISALLOW_COPY_AND_ASSIGN(LChunkBuilder);
3090 #undef DECLARE_HYDROGEN_ACCESSOR
3091 #undef DECLARE_CONCRETE_INSTRUCTION
3093 } } // namespace v8::internal
3095 #endif // V8_IA32_LITHIUM_IA32_H_