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-allocator.h"
10 #include "src/lithium.h"
11 #include "src/safepoint-table.h"
12 #include "src/utils.h"
17 // Forward declarations.
20 #define LITHIUM_CONCRETE_INSTRUCTION_LIST(V) \
21 V(AccessArgumentsAt) \
23 V(AllocateBlockContext) \
26 V(ArgumentsElements) \
34 V(CallWithDescriptor) \
40 V(CheckInstanceType) \
49 V(ClassOfTestAndBranch) \
50 V(CompareMinusZeroAndBranch) \
51 V(CompareNumericAndBranch) \
52 V(CmpObjectEqAndBranch) \
76 V(FlooringDivByConstI) \
77 V(FlooringDivByPowerOf2I) \
82 V(GetCachedArrayIndex) \
84 V(HasCachedArrayIndexAndBranch) \
85 V(HasInstanceTypeAndBranch) \
86 V(InnerAllocatedObject) \
88 V(InstanceOfKnownGlobal) \
90 V(Integer32ToDouble) \
92 V(IsConstructCallAndBranch) \
93 V(IsObjectAndBranch) \
94 V(IsStringAndBranch) \
96 V(IsUndetectableAndBranch) \
100 V(LoadFieldByIndex) \
101 V(LoadFunctionPrototype) \
103 V(LoadGlobalGeneric) \
105 V(LoadKeyedGeneric) \
107 V(LoadNamedGeneric) \
121 V(NullarySIMDOperation) \
122 V(UnarySIMDOperation) \
123 V(BinarySIMDOperation) \
124 V(TernarySIMDOperation) \
125 V(QuarternarySIMDOperation) \
140 V(SeqStringGetChar) \
141 V(SeqStringSetChar) \
147 V(StoreContextSlot) \
148 V(StoreFrameContext) \
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 {
252 virtual bool HasResult() const = 0;
253 virtual LOperand* result() const = 0;
255 bool HasDoubleRegisterResult();
256 bool HasDoubleRegisterInput();
258 LOperand* FirstInput() { return InputAt(0); }
259 LOperand* Output() { return HasResult() ? result() : NULL; }
261 virtual bool HasInterestingComment(LCodeGen* gen) const { return true; }
269 friend class InputIterator;
270 virtual int InputCount() = 0;
271 virtual LOperand* InputAt(int i) = 0;
273 friend class TempIterator;
274 virtual int TempCount() = 0;
275 virtual LOperand* TempAt(int i) = 0;
277 class IsCallBits: public BitField<bool, 0, 1> {};
279 LEnvironment* environment_;
280 SetOncePointer<LPointerMap> pointer_map_;
281 HValue* hydrogen_value_;
286 // R = number of result operands (0 or 1).
288 class LTemplateResultInstruction : public LInstruction {
290 // Allow 0 or 1 output operands.
291 STATIC_ASSERT(R == 0 || R == 1);
292 virtual bool HasResult() const V8_FINAL V8_OVERRIDE {
293 return R != 0 && result() != NULL;
295 void set_result(LOperand* operand) { results_[0] = operand; }
296 LOperand* result() const { return results_[0]; }
299 EmbeddedContainer<LOperand*, R> results_;
303 // R = number of result operands (0 or 1).
304 // I = number of input operands.
305 // T = number of temporary operands.
306 template<int R, int I, int T>
307 class LTemplateInstruction : public LTemplateResultInstruction<R> {
309 EmbeddedContainer<LOperand*, I> inputs_;
310 EmbeddedContainer<LOperand*, T> temps_;
314 virtual int InputCount() V8_FINAL V8_OVERRIDE { return I; }
315 virtual LOperand* InputAt(int i) V8_FINAL V8_OVERRIDE { return inputs_[i]; }
317 virtual int TempCount() V8_FINAL V8_OVERRIDE { return T; }
318 virtual LOperand* TempAt(int i) V8_FINAL V8_OVERRIDE { return temps_[i]; }
322 class LGap : public LTemplateInstruction<0, 0, 0> {
324 explicit LGap(HBasicBlock* block) : block_(block) {
325 parallel_moves_[BEFORE] = NULL;
326 parallel_moves_[START] = NULL;
327 parallel_moves_[END] = NULL;
328 parallel_moves_[AFTER] = NULL;
331 // Can't use the DECLARE-macro here because of sub-classes.
332 virtual bool IsGap() const V8_FINAL V8_OVERRIDE { return true; }
333 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
334 static LGap* cast(LInstruction* instr) {
335 ASSERT(instr->IsGap());
336 return reinterpret_cast<LGap*>(instr);
339 bool IsRedundant() const;
341 HBasicBlock* block() const { return block_; }
348 FIRST_INNER_POSITION = BEFORE,
349 LAST_INNER_POSITION = AFTER
352 LParallelMove* GetOrCreateParallelMove(InnerPosition pos, Zone* zone) {
353 if (parallel_moves_[pos] == NULL) {
354 parallel_moves_[pos] = new(zone) LParallelMove(zone);
356 return parallel_moves_[pos];
359 LParallelMove* GetParallelMove(InnerPosition pos) {
360 return parallel_moves_[pos];
364 LParallelMove* parallel_moves_[LAST_INNER_POSITION + 1];
369 class LInstructionGap V8_FINAL : public LGap {
371 explicit LInstructionGap(HBasicBlock* block) : LGap(block) { }
373 virtual bool HasInterestingComment(LCodeGen* gen) const V8_OVERRIDE {
374 return !IsRedundant();
377 DECLARE_CONCRETE_INSTRUCTION(InstructionGap, "gap")
381 class LGoto V8_FINAL : public LTemplateInstruction<0, 0, 0> {
383 explicit LGoto(HBasicBlock* block) : block_(block) { }
385 virtual bool HasInterestingComment(LCodeGen* gen) const V8_OVERRIDE;
386 DECLARE_CONCRETE_INSTRUCTION(Goto, "goto")
387 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
388 virtual bool IsControl() const V8_OVERRIDE { return true; }
390 int block_id() const { return block_->block_id(); }
391 virtual bool ClobbersDoubleRegisters(Isolate* isolate) const V8_OVERRIDE {
395 bool jumps_to_join() const { return block_->predecessors()->length() > 1; }
402 class LLazyBailout V8_FINAL : public LTemplateInstruction<0, 0, 0> {
404 DECLARE_CONCRETE_INSTRUCTION(LazyBailout, "lazy-bailout")
408 class LDummy V8_FINAL : public LTemplateInstruction<1, 0, 0> {
410 explicit LDummy() { }
411 DECLARE_CONCRETE_INSTRUCTION(Dummy, "dummy")
415 class LDummyUse V8_FINAL : public LTemplateInstruction<1, 1, 0> {
417 explicit LDummyUse(LOperand* value) {
420 DECLARE_CONCRETE_INSTRUCTION(DummyUse, "dummy-use")
424 class LDeoptimize V8_FINAL : public LTemplateInstruction<0, 0, 0> {
426 virtual bool IsControl() const V8_OVERRIDE { return true; }
427 DECLARE_CONCRETE_INSTRUCTION(Deoptimize, "deoptimize")
428 DECLARE_HYDROGEN_ACCESSOR(Deoptimize)
432 class LLabel V8_FINAL : public LGap {
434 explicit LLabel(HBasicBlock* block)
435 : LGap(block), replacement_(NULL) { }
437 virtual bool HasInterestingComment(LCodeGen* gen) const V8_OVERRIDE {
440 DECLARE_CONCRETE_INSTRUCTION(Label, "label")
442 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
444 int block_id() const { return block()->block_id(); }
445 bool is_loop_header() const { return block()->IsLoopHeader(); }
446 bool is_osr_entry() const { return block()->is_osr_entry(); }
447 Label* label() { return &label_; }
448 LLabel* replacement() const { return replacement_; }
449 void set_replacement(LLabel* label) { replacement_ = label; }
450 bool HasReplacement() const { return replacement_ != NULL; }
454 LLabel* replacement_;
458 class LParameter V8_FINAL : public LTemplateInstruction<1, 0, 0> {
460 virtual bool HasInterestingComment(LCodeGen* gen) const V8_OVERRIDE {
463 DECLARE_CONCRETE_INSTRUCTION(Parameter, "parameter")
467 class LCallStub V8_FINAL : public LTemplateInstruction<1, 1, 0> {
469 explicit LCallStub(LOperand* context) {
470 inputs_[0] = context;
473 LOperand* context() { return inputs_[0]; }
475 DECLARE_CONCRETE_INSTRUCTION(CallStub, "call-stub")
476 DECLARE_HYDROGEN_ACCESSOR(CallStub)
480 class LUnknownOSRValue V8_FINAL : public LTemplateInstruction<1, 0, 0> {
482 virtual bool HasInterestingComment(LCodeGen* gen) const V8_OVERRIDE {
485 DECLARE_CONCRETE_INSTRUCTION(UnknownOSRValue, "unknown-osr-value")
489 template<int I, int T>
490 class LControlInstruction: public LTemplateInstruction<0, I, T> {
492 LControlInstruction() : false_label_(NULL), true_label_(NULL) { }
494 virtual bool IsControl() const V8_FINAL V8_OVERRIDE { return true; }
496 int SuccessorCount() { return hydrogen()->SuccessorCount(); }
497 HBasicBlock* SuccessorAt(int i) { return hydrogen()->SuccessorAt(i); }
499 int TrueDestination(LChunk* chunk) {
500 return chunk->LookupDestination(true_block_id());
502 int FalseDestination(LChunk* chunk) {
503 return chunk->LookupDestination(false_block_id());
506 Label* TrueLabel(LChunk* chunk) {
507 if (true_label_ == NULL) {
508 true_label_ = chunk->GetAssemblyLabel(TrueDestination(chunk));
512 Label* FalseLabel(LChunk* chunk) {
513 if (false_label_ == NULL) {
514 false_label_ = chunk->GetAssemblyLabel(FalseDestination(chunk));
520 int true_block_id() { return SuccessorAt(0)->block_id(); }
521 int false_block_id() { return SuccessorAt(1)->block_id(); }
524 HControlInstruction* hydrogen() {
525 return HControlInstruction::cast(this->hydrogen_value());
533 class LWrapReceiver V8_FINAL : public LTemplateInstruction<1, 2, 1> {
535 LWrapReceiver(LOperand* receiver,
538 inputs_[0] = receiver;
539 inputs_[1] = function;
543 LOperand* receiver() { return inputs_[0]; }
544 LOperand* function() { return inputs_[1]; }
545 LOperand* temp() { return temps_[0]; }
547 DECLARE_CONCRETE_INSTRUCTION(WrapReceiver, "wrap-receiver")
548 DECLARE_HYDROGEN_ACCESSOR(WrapReceiver)
552 class LApplyArguments V8_FINAL : public LTemplateInstruction<1, 4, 0> {
554 LApplyArguments(LOperand* function,
557 LOperand* elements) {
558 inputs_[0] = function;
559 inputs_[1] = receiver;
561 inputs_[3] = elements;
564 LOperand* function() { return inputs_[0]; }
565 LOperand* receiver() { return inputs_[1]; }
566 LOperand* length() { return inputs_[2]; }
567 LOperand* elements() { return inputs_[3]; }
569 DECLARE_CONCRETE_INSTRUCTION(ApplyArguments, "apply-arguments")
573 class LAccessArgumentsAt V8_FINAL : public LTemplateInstruction<1, 3, 0> {
575 LAccessArgumentsAt(LOperand* arguments, LOperand* length, LOperand* index) {
576 inputs_[0] = arguments;
581 LOperand* arguments() { return inputs_[0]; }
582 LOperand* length() { return inputs_[1]; }
583 LOperand* index() { return inputs_[2]; }
585 DECLARE_CONCRETE_INSTRUCTION(AccessArgumentsAt, "access-arguments-at")
587 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
591 class LArgumentsLength V8_FINAL : public LTemplateInstruction<1, 1, 0> {
593 explicit LArgumentsLength(LOperand* elements) {
594 inputs_[0] = elements;
597 LOperand* elements() { return inputs_[0]; }
599 DECLARE_CONCRETE_INSTRUCTION(ArgumentsLength, "arguments-length")
603 class LArgumentsElements V8_FINAL : public LTemplateInstruction<1, 0, 0> {
605 DECLARE_CONCRETE_INSTRUCTION(ArgumentsElements, "arguments-elements")
606 DECLARE_HYDROGEN_ACCESSOR(ArgumentsElements)
610 class LDebugBreak V8_FINAL : public LTemplateInstruction<0, 0, 0> {
612 DECLARE_CONCRETE_INSTRUCTION(DebugBreak, "break")
616 class LModByPowerOf2I V8_FINAL : public LTemplateInstruction<1, 1, 0> {
618 LModByPowerOf2I(LOperand* dividend, int32_t divisor) {
619 inputs_[0] = dividend;
623 LOperand* dividend() { return inputs_[0]; }
624 int32_t divisor() const { return divisor_; }
626 DECLARE_CONCRETE_INSTRUCTION(ModByPowerOf2I, "mod-by-power-of-2-i")
627 DECLARE_HYDROGEN_ACCESSOR(Mod)
634 class LModByConstI V8_FINAL : public LTemplateInstruction<1, 1, 2> {
636 LModByConstI(LOperand* dividend,
640 inputs_[0] = dividend;
646 LOperand* dividend() { return inputs_[0]; }
647 int32_t divisor() const { return divisor_; }
648 LOperand* temp1() { return temps_[0]; }
649 LOperand* temp2() { return temps_[1]; }
651 DECLARE_CONCRETE_INSTRUCTION(ModByConstI, "mod-by-const-i")
652 DECLARE_HYDROGEN_ACCESSOR(Mod)
659 class LModI V8_FINAL : public LTemplateInstruction<1, 2, 1> {
661 LModI(LOperand* left, LOperand* right, LOperand* temp) {
667 LOperand* left() { return inputs_[0]; }
668 LOperand* right() { return inputs_[1]; }
669 LOperand* temp() { return temps_[0]; }
671 DECLARE_CONCRETE_INSTRUCTION(ModI, "mod-i")
672 DECLARE_HYDROGEN_ACCESSOR(Mod)
676 class LDivByPowerOf2I V8_FINAL : public LTemplateInstruction<1, 1, 0> {
678 LDivByPowerOf2I(LOperand* dividend, int32_t divisor) {
679 inputs_[0] = dividend;
683 LOperand* dividend() { return inputs_[0]; }
684 int32_t divisor() const { return divisor_; }
686 DECLARE_CONCRETE_INSTRUCTION(DivByPowerOf2I, "div-by-power-of-2-i")
687 DECLARE_HYDROGEN_ACCESSOR(Div)
694 class LDivByConstI V8_FINAL : public LTemplateInstruction<1, 1, 2> {
696 LDivByConstI(LOperand* dividend,
700 inputs_[0] = dividend;
706 LOperand* dividend() { return inputs_[0]; }
707 int32_t divisor() const { return divisor_; }
708 LOperand* temp1() { return temps_[0]; }
709 LOperand* temp2() { return temps_[1]; }
711 DECLARE_CONCRETE_INSTRUCTION(DivByConstI, "div-by-const-i")
712 DECLARE_HYDROGEN_ACCESSOR(Div)
719 class LDivI V8_FINAL : public LTemplateInstruction<1, 2, 1> {
721 LDivI(LOperand* dividend, LOperand* divisor, LOperand* temp) {
722 inputs_[0] = dividend;
723 inputs_[1] = divisor;
727 LOperand* dividend() { return inputs_[0]; }
728 LOperand* divisor() { return inputs_[1]; }
729 LOperand* temp() { return temps_[0]; }
731 DECLARE_CONCRETE_INSTRUCTION(DivI, "div-i")
732 DECLARE_HYDROGEN_ACCESSOR(BinaryOperation)
736 class LFlooringDivByPowerOf2I V8_FINAL : public LTemplateInstruction<1, 1, 0> {
738 LFlooringDivByPowerOf2I(LOperand* dividend, int32_t divisor) {
739 inputs_[0] = dividend;
743 LOperand* dividend() { return inputs_[0]; }
744 int32_t divisor() const { return divisor_; }
746 DECLARE_CONCRETE_INSTRUCTION(FlooringDivByPowerOf2I,
747 "flooring-div-by-power-of-2-i")
748 DECLARE_HYDROGEN_ACCESSOR(MathFloorOfDiv)
755 class LFlooringDivByConstI V8_FINAL : public LTemplateInstruction<1, 1, 3> {
757 LFlooringDivByConstI(LOperand* dividend,
762 inputs_[0] = dividend;
769 LOperand* dividend() { return inputs_[0]; }
770 int32_t divisor() const { return divisor_; }
771 LOperand* temp1() { return temps_[0]; }
772 LOperand* temp2() { return temps_[1]; }
773 LOperand* temp3() { return temps_[2]; }
775 DECLARE_CONCRETE_INSTRUCTION(FlooringDivByConstI, "flooring-div-by-const-i")
776 DECLARE_HYDROGEN_ACCESSOR(MathFloorOfDiv)
783 class LFlooringDivI V8_FINAL : public LTemplateInstruction<1, 2, 1> {
785 LFlooringDivI(LOperand* dividend, LOperand* divisor, LOperand* temp) {
786 inputs_[0] = dividend;
787 inputs_[1] = divisor;
791 LOperand* dividend() { return inputs_[0]; }
792 LOperand* divisor() { return inputs_[1]; }
793 LOperand* temp() { return temps_[0]; }
795 DECLARE_CONCRETE_INSTRUCTION(FlooringDivI, "flooring-div-i")
796 DECLARE_HYDROGEN_ACCESSOR(MathFloorOfDiv)
800 class LMulI V8_FINAL : public LTemplateInstruction<1, 2, 1> {
802 LMulI(LOperand* left, LOperand* right, LOperand* temp) {
808 LOperand* left() { return inputs_[0]; }
809 LOperand* right() { return inputs_[1]; }
810 LOperand* temp() { return temps_[0]; }
812 DECLARE_CONCRETE_INSTRUCTION(MulI, "mul-i")
813 DECLARE_HYDROGEN_ACCESSOR(Mul)
817 class LCompareNumericAndBranch V8_FINAL : public LControlInstruction<2, 0> {
819 LCompareNumericAndBranch(LOperand* left, LOperand* right) {
824 LOperand* left() { return inputs_[0]; }
825 LOperand* right() { return inputs_[1]; }
827 DECLARE_CONCRETE_INSTRUCTION(CompareNumericAndBranch,
828 "compare-numeric-and-branch")
829 DECLARE_HYDROGEN_ACCESSOR(CompareNumericAndBranch)
831 Token::Value op() const { return hydrogen()->token(); }
832 bool is_double() const {
833 return hydrogen()->representation().IsDouble();
836 virtual void PrintDataTo(StringStream* stream);
840 class LMathFloor V8_FINAL : public LTemplateInstruction<1, 1, 0> {
842 explicit LMathFloor(LOperand* value) {
846 LOperand* value() { return inputs_[0]; }
848 DECLARE_CONCRETE_INSTRUCTION(MathFloor, "math-floor")
849 DECLARE_HYDROGEN_ACCESSOR(UnaryMathOperation)
853 class LMathRound V8_FINAL : public LTemplateInstruction<1, 1, 1> {
855 LMathRound(LOperand* value, LOperand* temp) {
860 LOperand* value() { return inputs_[0]; }
861 LOperand* temp() { return temps_[0]; }
863 DECLARE_CONCRETE_INSTRUCTION(MathRound, "math-round")
864 DECLARE_HYDROGEN_ACCESSOR(UnaryMathOperation)
868 class LMathAbs V8_FINAL : public LTemplateInstruction<1, 2, 0> {
870 LMathAbs(LOperand* context, LOperand* value) {
871 inputs_[1] = context;
875 LOperand* context() { return inputs_[1]; }
876 LOperand* value() { return inputs_[0]; }
878 DECLARE_CONCRETE_INSTRUCTION(MathAbs, "math-abs")
879 DECLARE_HYDROGEN_ACCESSOR(UnaryMathOperation)
883 class LMathLog V8_FINAL : public LTemplateInstruction<1, 1, 0> {
885 explicit LMathLog(LOperand* value) {
889 LOperand* value() { return inputs_[0]; }
891 DECLARE_CONCRETE_INSTRUCTION(MathLog, "math-log")
895 class LMathClz32 V8_FINAL : public LTemplateInstruction<1, 1, 0> {
897 explicit LMathClz32(LOperand* value) {
901 LOperand* value() { return inputs_[0]; }
903 DECLARE_CONCRETE_INSTRUCTION(MathClz32, "math-clz32")
907 class LMathExp V8_FINAL : public LTemplateInstruction<1, 1, 2> {
909 LMathExp(LOperand* value,
915 ExternalReference::InitializeMathExpData();
918 LOperand* value() { return inputs_[0]; }
919 LOperand* temp1() { return temps_[0]; }
920 LOperand* temp2() { return temps_[1]; }
922 DECLARE_CONCRETE_INSTRUCTION(MathExp, "math-exp")
926 class LMathSqrt V8_FINAL : public LTemplateInstruction<1, 1, 0> {
928 explicit LMathSqrt(LOperand* value) {
932 LOperand* value() { return inputs_[0]; }
934 DECLARE_CONCRETE_INSTRUCTION(MathSqrt, "math-sqrt")
938 class LMathPowHalf V8_FINAL : public LTemplateInstruction<1, 1, 1> {
940 LMathPowHalf(LOperand* value, LOperand* temp) {
945 LOperand* value() { return inputs_[0]; }
946 LOperand* temp() { return temps_[0]; }
948 DECLARE_CONCRETE_INSTRUCTION(MathPowHalf, "math-pow-half")
952 class LNullarySIMDOperation V8_FINAL : public LTemplateInstruction<1, 0, 0> {
954 explicit LNullarySIMDOperation(BuiltinFunctionId op)
958 BuiltinFunctionId op() const { return op_; }
960 virtual Opcode opcode() const V8_OVERRIDE {
961 return LInstruction::kNullarySIMDOperation;
963 virtual void CompileToNative(LCodeGen* generator) V8_OVERRIDE;
964 virtual const char* Mnemonic() const V8_OVERRIDE;
965 static LNullarySIMDOperation* cast(LInstruction* instr) {
966 ASSERT(instr->IsNullarySIMDOperation());
967 return reinterpret_cast<LNullarySIMDOperation*>(instr);
970 DECLARE_HYDROGEN_ACCESSOR(NullarySIMDOperation)
973 BuiltinFunctionId op_;
977 class LUnarySIMDOperation V8_FINAL : public LTemplateInstruction<1, 1, 0> {
979 LUnarySIMDOperation(LOperand* value, BuiltinFunctionId op)
984 LOperand* value() { return inputs_[0]; }
985 BuiltinFunctionId op() const { return op_; }
987 virtual Opcode opcode() const V8_OVERRIDE {
988 return LInstruction::kUnarySIMDOperation;
990 virtual void CompileToNative(LCodeGen* generator) V8_OVERRIDE;
991 virtual const char* Mnemonic() const V8_OVERRIDE;
992 static LUnarySIMDOperation* cast(LInstruction* instr) {
993 ASSERT(instr->IsUnarySIMDOperation());
994 return reinterpret_cast<LUnarySIMDOperation*>(instr);
997 DECLARE_HYDROGEN_ACCESSOR(UnarySIMDOperation)
1000 BuiltinFunctionId op_;
1004 class LBinarySIMDOperation V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1006 LBinarySIMDOperation(LOperand* left, LOperand* right, BuiltinFunctionId op)
1012 LOperand* left() { return inputs_[0]; }
1013 LOperand* right() { return inputs_[1]; }
1014 BuiltinFunctionId op() const { return op_; }
1016 virtual Opcode opcode() const V8_OVERRIDE {
1017 return LInstruction::kBinarySIMDOperation;
1019 virtual void CompileToNative(LCodeGen* generator) V8_OVERRIDE;
1020 virtual const char* Mnemonic() const V8_OVERRIDE;
1021 static LBinarySIMDOperation* cast(LInstruction* instr) {
1022 ASSERT(instr->IsBinarySIMDOperation());
1023 return reinterpret_cast<LBinarySIMDOperation*>(instr);
1026 DECLARE_HYDROGEN_ACCESSOR(BinarySIMDOperation)
1029 BuiltinFunctionId op_;
1033 class LTernarySIMDOperation V8_FINAL : public LTemplateInstruction<1, 3, 0> {
1035 LTernarySIMDOperation(LOperand* first, LOperand* second, LOperand* third,
1036 BuiltinFunctionId op)
1039 inputs_[1] = second;
1043 LOperand* first() { return inputs_[0]; }
1044 LOperand* second() { return inputs_[1]; }
1045 LOperand* third() { return inputs_[2]; }
1046 BuiltinFunctionId op() const { return op_; }
1048 virtual Opcode opcode() const V8_OVERRIDE {
1049 return LInstruction::kTernarySIMDOperation;
1051 virtual void CompileToNative(LCodeGen* generator) V8_OVERRIDE;
1052 virtual const char* Mnemonic() const V8_OVERRIDE;
1053 static LTernarySIMDOperation* cast(LInstruction* instr) {
1054 ASSERT(instr->IsTernarySIMDOperation());
1055 return reinterpret_cast<LTernarySIMDOperation*>(instr);
1058 DECLARE_HYDROGEN_ACCESSOR(TernarySIMDOperation)
1061 BuiltinFunctionId op_;
1065 class LQuarternarySIMDOperation V8_FINAL
1066 : public LTemplateInstruction<1, 4, 0> {
1068 LQuarternarySIMDOperation(LOperand* x, LOperand* y, LOperand* z,
1069 LOperand* w, BuiltinFunctionId op)
1077 LOperand* x() { return inputs_[0]; }
1078 LOperand* y() { return inputs_[1]; }
1079 LOperand* z() { return inputs_[2]; }
1080 LOperand* w() { return inputs_[3]; }
1081 BuiltinFunctionId op() const { return op_; }
1083 virtual Opcode opcode() const V8_OVERRIDE {
1084 return LInstruction::kQuarternarySIMDOperation;
1086 virtual void CompileToNative(LCodeGen* generator) V8_OVERRIDE;
1087 virtual const char* Mnemonic() const V8_OVERRIDE;
1088 static LQuarternarySIMDOperation* cast(LInstruction* instr) {
1089 ASSERT(instr->IsQuarternarySIMDOperation());
1090 return reinterpret_cast<LQuarternarySIMDOperation*>(instr);
1093 DECLARE_HYDROGEN_ACCESSOR(QuarternarySIMDOperation)
1096 BuiltinFunctionId op_;
1100 class LCmpObjectEqAndBranch V8_FINAL : public LControlInstruction<2, 0> {
1102 LCmpObjectEqAndBranch(LOperand* left, LOperand* right) {
1107 LOperand* left() { return inputs_[0]; }
1108 LOperand* right() { return inputs_[1]; }
1110 DECLARE_CONCRETE_INSTRUCTION(CmpObjectEqAndBranch, "cmp-object-eq-and-branch")
1114 class LCmpHoleAndBranch V8_FINAL : public LControlInstruction<1, 0> {
1116 explicit LCmpHoleAndBranch(LOperand* object) {
1117 inputs_[0] = object;
1120 LOperand* object() { return inputs_[0]; }
1122 DECLARE_CONCRETE_INSTRUCTION(CmpHoleAndBranch, "cmp-hole-and-branch")
1123 DECLARE_HYDROGEN_ACCESSOR(CompareHoleAndBranch)
1127 class LCompareMinusZeroAndBranch V8_FINAL : public LControlInstruction<1, 1> {
1129 LCompareMinusZeroAndBranch(LOperand* value, LOperand* temp) {
1134 LOperand* value() { return inputs_[0]; }
1135 LOperand* temp() { return temps_[0]; }
1137 DECLARE_CONCRETE_INSTRUCTION(CompareMinusZeroAndBranch,
1138 "cmp-minus-zero-and-branch")
1139 DECLARE_HYDROGEN_ACCESSOR(CompareMinusZeroAndBranch)
1143 class LIsObjectAndBranch V8_FINAL : public LControlInstruction<1, 1> {
1145 LIsObjectAndBranch(LOperand* value, LOperand* temp) {
1150 LOperand* value() { return inputs_[0]; }
1151 LOperand* temp() { return temps_[0]; }
1153 DECLARE_CONCRETE_INSTRUCTION(IsObjectAndBranch, "is-object-and-branch")
1155 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1159 class LIsStringAndBranch V8_FINAL : public LControlInstruction<1, 1> {
1161 LIsStringAndBranch(LOperand* value, LOperand* temp) {
1166 LOperand* value() { return inputs_[0]; }
1167 LOperand* temp() { return temps_[0]; }
1169 DECLARE_CONCRETE_INSTRUCTION(IsStringAndBranch, "is-string-and-branch")
1170 DECLARE_HYDROGEN_ACCESSOR(IsStringAndBranch)
1172 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1176 class LIsSmiAndBranch V8_FINAL : public LControlInstruction<1, 0> {
1178 explicit LIsSmiAndBranch(LOperand* value) {
1182 LOperand* value() { return inputs_[0]; }
1184 DECLARE_CONCRETE_INSTRUCTION(IsSmiAndBranch, "is-smi-and-branch")
1185 DECLARE_HYDROGEN_ACCESSOR(IsSmiAndBranch)
1187 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1191 class LIsUndetectableAndBranch V8_FINAL : public LControlInstruction<1, 1> {
1193 LIsUndetectableAndBranch(LOperand* value, LOperand* temp) {
1198 LOperand* value() { return inputs_[0]; }
1199 LOperand* temp() { return temps_[0]; }
1201 DECLARE_CONCRETE_INSTRUCTION(IsUndetectableAndBranch,
1202 "is-undetectable-and-branch")
1203 DECLARE_HYDROGEN_ACCESSOR(IsUndetectableAndBranch)
1205 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1209 class LStringCompareAndBranch V8_FINAL : public LControlInstruction<3, 0> {
1211 LStringCompareAndBranch(LOperand* context, LOperand* left, LOperand* right) {
1212 inputs_[0] = context;
1217 LOperand* context() { return inputs_[1]; }
1218 LOperand* left() { return inputs_[1]; }
1219 LOperand* right() { return inputs_[2]; }
1221 DECLARE_CONCRETE_INSTRUCTION(StringCompareAndBranch,
1222 "string-compare-and-branch")
1223 DECLARE_HYDROGEN_ACCESSOR(StringCompareAndBranch)
1225 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1227 Token::Value op() const { return hydrogen()->token(); }
1231 class LHasInstanceTypeAndBranch V8_FINAL : public LControlInstruction<1, 1> {
1233 LHasInstanceTypeAndBranch(LOperand* value, LOperand* temp) {
1238 LOperand* value() { return inputs_[0]; }
1239 LOperand* temp() { return temps_[0]; }
1241 DECLARE_CONCRETE_INSTRUCTION(HasInstanceTypeAndBranch,
1242 "has-instance-type-and-branch")
1243 DECLARE_HYDROGEN_ACCESSOR(HasInstanceTypeAndBranch)
1245 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1249 class LGetCachedArrayIndex V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1251 explicit LGetCachedArrayIndex(LOperand* value) {
1255 LOperand* value() { return inputs_[0]; }
1257 DECLARE_CONCRETE_INSTRUCTION(GetCachedArrayIndex, "get-cached-array-index")
1258 DECLARE_HYDROGEN_ACCESSOR(GetCachedArrayIndex)
1262 class LHasCachedArrayIndexAndBranch V8_FINAL
1263 : public LControlInstruction<1, 0> {
1265 explicit LHasCachedArrayIndexAndBranch(LOperand* value) {
1269 LOperand* value() { return inputs_[0]; }
1271 DECLARE_CONCRETE_INSTRUCTION(HasCachedArrayIndexAndBranch,
1272 "has-cached-array-index-and-branch")
1274 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1278 class LIsConstructCallAndBranch V8_FINAL : public LControlInstruction<0, 1> {
1280 explicit LIsConstructCallAndBranch(LOperand* temp) {
1284 LOperand* temp() { return temps_[0]; }
1286 DECLARE_CONCRETE_INSTRUCTION(IsConstructCallAndBranch,
1287 "is-construct-call-and-branch")
1291 class LClassOfTestAndBranch V8_FINAL : public LControlInstruction<1, 2> {
1293 LClassOfTestAndBranch(LOperand* value, LOperand* temp, LOperand* temp2) {
1299 LOperand* value() { return inputs_[0]; }
1300 LOperand* temp() { return temps_[0]; }
1301 LOperand* temp2() { return temps_[1]; }
1303 DECLARE_CONCRETE_INSTRUCTION(ClassOfTestAndBranch,
1304 "class-of-test-and-branch")
1305 DECLARE_HYDROGEN_ACCESSOR(ClassOfTestAndBranch)
1307 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1311 class LCmpT V8_FINAL : public LTemplateInstruction<1, 3, 0> {
1313 LCmpT(LOperand* context, LOperand* left, LOperand* right) {
1314 inputs_[0] = context;
1319 DECLARE_CONCRETE_INSTRUCTION(CmpT, "cmp-t")
1320 DECLARE_HYDROGEN_ACCESSOR(CompareGeneric)
1322 LOperand* context() { return inputs_[0]; }
1323 Token::Value op() const { return hydrogen()->token(); }
1327 class LInstanceOf V8_FINAL : public LTemplateInstruction<1, 3, 0> {
1329 LInstanceOf(LOperand* context, LOperand* left, LOperand* right) {
1330 inputs_[0] = context;
1335 LOperand* context() { return inputs_[0]; }
1337 DECLARE_CONCRETE_INSTRUCTION(InstanceOf, "instance-of")
1341 class LInstanceOfKnownGlobal V8_FINAL : public LTemplateInstruction<1, 2, 1> {
1343 LInstanceOfKnownGlobal(LOperand* context, LOperand* value, LOperand* temp) {
1344 inputs_[0] = context;
1349 LOperand* context() { return inputs_[0]; }
1350 LOperand* value() { return inputs_[1]; }
1351 LOperand* temp() { return temps_[0]; }
1353 DECLARE_CONCRETE_INSTRUCTION(InstanceOfKnownGlobal,
1354 "instance-of-known-global")
1355 DECLARE_HYDROGEN_ACCESSOR(InstanceOfKnownGlobal)
1357 Handle<JSFunction> function() const { return hydrogen()->function(); }
1358 LEnvironment* GetDeferredLazyDeoptimizationEnvironment() {
1359 return lazy_deopt_env_;
1361 virtual void SetDeferredLazyDeoptimizationEnvironment(
1362 LEnvironment* env) V8_OVERRIDE {
1363 lazy_deopt_env_ = env;
1367 LEnvironment* lazy_deopt_env_;
1371 class LBoundsCheck V8_FINAL : public LTemplateInstruction<0, 2, 0> {
1373 LBoundsCheck(LOperand* index, LOperand* length) {
1375 inputs_[1] = length;
1378 LOperand* index() { return inputs_[0]; }
1379 LOperand* length() { return inputs_[1]; }
1381 DECLARE_CONCRETE_INSTRUCTION(BoundsCheck, "bounds-check")
1382 DECLARE_HYDROGEN_ACCESSOR(BoundsCheck)
1386 class LBitI V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1388 LBitI(LOperand* left, LOperand* right) {
1393 LOperand* left() { return inputs_[0]; }
1394 LOperand* right() { return inputs_[1]; }
1396 DECLARE_CONCRETE_INSTRUCTION(BitI, "bit-i")
1397 DECLARE_HYDROGEN_ACCESSOR(Bitwise)
1399 Token::Value op() const { return hydrogen()->op(); }
1403 class LShiftI V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1405 LShiftI(Token::Value op, LOperand* left, LOperand* right, bool can_deopt)
1406 : op_(op), can_deopt_(can_deopt) {
1411 LOperand* left() { return inputs_[0]; }
1412 LOperand* right() { return inputs_[1]; }
1414 DECLARE_CONCRETE_INSTRUCTION(ShiftI, "shift-i")
1416 Token::Value op() const { return op_; }
1417 bool can_deopt() const { return can_deopt_; }
1425 class LSubI V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1427 LSubI(LOperand* left, LOperand* right) {
1432 LOperand* left() { return inputs_[0]; }
1433 LOperand* right() { return inputs_[1]; }
1435 DECLARE_CONCRETE_INSTRUCTION(SubI, "sub-i")
1436 DECLARE_HYDROGEN_ACCESSOR(Sub)
1440 class LConstantI V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1442 DECLARE_CONCRETE_INSTRUCTION(ConstantI, "constant-i")
1443 DECLARE_HYDROGEN_ACCESSOR(Constant)
1445 int32_t value() const { return hydrogen()->Integer32Value(); }
1449 class LConstantS V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1451 DECLARE_CONCRETE_INSTRUCTION(ConstantS, "constant-s")
1452 DECLARE_HYDROGEN_ACCESSOR(Constant)
1454 Smi* value() const { return Smi::FromInt(hydrogen()->Integer32Value()); }
1458 class LConstantD V8_FINAL : public LTemplateInstruction<1, 0, 1> {
1460 explicit LConstantD(LOperand* temp) {
1464 LOperand* temp() { return temps_[0]; }
1466 DECLARE_CONCRETE_INSTRUCTION(ConstantD, "constant-d")
1467 DECLARE_HYDROGEN_ACCESSOR(Constant)
1469 double value() const { return hydrogen()->DoubleValue(); }
1473 class LConstantE V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1475 DECLARE_CONCRETE_INSTRUCTION(ConstantE, "constant-e")
1476 DECLARE_HYDROGEN_ACCESSOR(Constant)
1478 ExternalReference value() const {
1479 return hydrogen()->ExternalReferenceValue();
1484 class LConstantT V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1486 DECLARE_CONCRETE_INSTRUCTION(ConstantT, "constant-t")
1487 DECLARE_HYDROGEN_ACCESSOR(Constant)
1489 Handle<Object> value(Isolate* isolate) const {
1490 return hydrogen()->handle(isolate);
1495 class LBranch V8_FINAL : public LControlInstruction<1, 1> {
1497 LBranch(LOperand* value, LOperand* temp) {
1502 LOperand* value() { return inputs_[0]; }
1503 LOperand* temp() { return temps_[0]; }
1505 DECLARE_CONCRETE_INSTRUCTION(Branch, "branch")
1506 DECLARE_HYDROGEN_ACCESSOR(Branch)
1508 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1512 class LCmpMapAndBranch V8_FINAL : public LControlInstruction<1, 0> {
1514 explicit LCmpMapAndBranch(LOperand* value) {
1518 LOperand* value() { return inputs_[0]; }
1520 DECLARE_CONCRETE_INSTRUCTION(CmpMapAndBranch, "cmp-map-and-branch")
1521 DECLARE_HYDROGEN_ACCESSOR(CompareMap)
1523 Handle<Map> map() const { return hydrogen()->map().handle(); }
1527 class LMapEnumLength V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1529 explicit LMapEnumLength(LOperand* value) {
1533 LOperand* value() { return inputs_[0]; }
1535 DECLARE_CONCRETE_INSTRUCTION(MapEnumLength, "map-enum-length")
1539 class LDateField V8_FINAL : public LTemplateInstruction<1, 1, 1> {
1541 LDateField(LOperand* date, LOperand* temp, Smi* index)
1547 LOperand* date() { return inputs_[0]; }
1548 LOperand* temp() { return temps_[0]; }
1550 DECLARE_CONCRETE_INSTRUCTION(DateField, "date-field")
1551 DECLARE_HYDROGEN_ACCESSOR(DateField)
1553 Smi* index() const { return index_; }
1560 class LSeqStringGetChar V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1562 LSeqStringGetChar(LOperand* string, LOperand* index) {
1563 inputs_[0] = string;
1567 LOperand* string() const { return inputs_[0]; }
1568 LOperand* index() const { return inputs_[1]; }
1570 DECLARE_CONCRETE_INSTRUCTION(SeqStringGetChar, "seq-string-get-char")
1571 DECLARE_HYDROGEN_ACCESSOR(SeqStringGetChar)
1575 class LSeqStringSetChar V8_FINAL : public LTemplateInstruction<1, 4, 0> {
1577 LSeqStringSetChar(LOperand* context,
1581 inputs_[0] = context;
1582 inputs_[1] = string;
1587 LOperand* string() { return inputs_[1]; }
1588 LOperand* index() { return inputs_[2]; }
1589 LOperand* value() { return inputs_[3]; }
1591 DECLARE_CONCRETE_INSTRUCTION(SeqStringSetChar, "seq-string-set-char")
1592 DECLARE_HYDROGEN_ACCESSOR(SeqStringSetChar)
1596 class LAddI V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1598 LAddI(LOperand* left, LOperand* right) {
1603 LOperand* left() { return inputs_[0]; }
1604 LOperand* right() { return inputs_[1]; }
1606 static bool UseLea(HAdd* add) {
1607 return !add->CheckFlag(HValue::kCanOverflow) &&
1608 add->BetterLeftOperand()->UseCount() > 1;
1611 DECLARE_CONCRETE_INSTRUCTION(AddI, "add-i")
1612 DECLARE_HYDROGEN_ACCESSOR(Add)
1616 class LMathMinMax V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1618 LMathMinMax(LOperand* left, LOperand* right) {
1623 LOperand* left() { return inputs_[0]; }
1624 LOperand* right() { return inputs_[1]; }
1626 DECLARE_CONCRETE_INSTRUCTION(MathMinMax, "math-min-max")
1627 DECLARE_HYDROGEN_ACCESSOR(MathMinMax)
1631 class LPower V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1633 LPower(LOperand* left, LOperand* right) {
1638 LOperand* left() { return inputs_[0]; }
1639 LOperand* right() { return inputs_[1]; }
1641 DECLARE_CONCRETE_INSTRUCTION(Power, "power")
1642 DECLARE_HYDROGEN_ACCESSOR(Power)
1646 class LArithmeticD V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1648 LArithmeticD(Token::Value op, LOperand* left, LOperand* right)
1654 LOperand* left() { return inputs_[0]; }
1655 LOperand* right() { return inputs_[1]; }
1657 Token::Value op() const { return op_; }
1659 virtual Opcode opcode() const V8_OVERRIDE {
1660 return LInstruction::kArithmeticD;
1662 virtual void CompileToNative(LCodeGen* generator) V8_OVERRIDE;
1663 virtual const char* Mnemonic() const V8_OVERRIDE;
1670 class LArithmeticT V8_FINAL : public LTemplateInstruction<1, 3, 0> {
1672 LArithmeticT(Token::Value op,
1677 inputs_[0] = context;
1682 LOperand* context() { return inputs_[0]; }
1683 LOperand* left() { return inputs_[1]; }
1684 LOperand* right() { return inputs_[2]; }
1686 virtual Opcode opcode() const V8_OVERRIDE {
1687 return LInstruction::kArithmeticT;
1689 virtual void CompileToNative(LCodeGen* generator) V8_OVERRIDE;
1690 virtual const char* Mnemonic() const V8_OVERRIDE;
1692 Token::Value op() const { return op_; }
1699 class LReturn V8_FINAL : public LTemplateInstruction<0, 3, 0> {
1701 explicit LReturn(LOperand* value,
1703 LOperand* parameter_count) {
1705 inputs_[1] = context;
1706 inputs_[2] = parameter_count;
1709 bool has_constant_parameter_count() {
1710 return parameter_count()->IsConstantOperand();
1712 LConstantOperand* constant_parameter_count() {
1713 ASSERT(has_constant_parameter_count());
1714 return LConstantOperand::cast(parameter_count());
1716 LOperand* parameter_count() { return inputs_[2]; }
1718 DECLARE_CONCRETE_INSTRUCTION(Return, "return")
1719 DECLARE_HYDROGEN_ACCESSOR(Return)
1723 class LLoadNamedField V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1725 explicit LLoadNamedField(LOperand* object) {
1726 inputs_[0] = object;
1729 LOperand* object() { return inputs_[0]; }
1731 DECLARE_CONCRETE_INSTRUCTION(LoadNamedField, "load-named-field")
1732 DECLARE_HYDROGEN_ACCESSOR(LoadNamedField)
1736 class LLoadNamedGeneric V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1738 LLoadNamedGeneric(LOperand* context, LOperand* object) {
1739 inputs_[0] = context;
1740 inputs_[1] = object;
1743 LOperand* context() { return inputs_[0]; }
1744 LOperand* object() { return inputs_[1]; }
1746 DECLARE_CONCRETE_INSTRUCTION(LoadNamedGeneric, "load-named-generic")
1747 DECLARE_HYDROGEN_ACCESSOR(LoadNamedGeneric)
1749 Handle<Object> name() const { return hydrogen()->name(); }
1753 class LLoadFunctionPrototype V8_FINAL : public LTemplateInstruction<1, 1, 1> {
1755 LLoadFunctionPrototype(LOperand* function, LOperand* temp) {
1756 inputs_[0] = function;
1760 LOperand* function() { return inputs_[0]; }
1761 LOperand* temp() { return temps_[0]; }
1763 DECLARE_CONCRETE_INSTRUCTION(LoadFunctionPrototype, "load-function-prototype")
1764 DECLARE_HYDROGEN_ACCESSOR(LoadFunctionPrototype)
1768 class LLoadRoot V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1770 DECLARE_CONCRETE_INSTRUCTION(LoadRoot, "load-root")
1771 DECLARE_HYDROGEN_ACCESSOR(LoadRoot)
1773 Heap::RootListIndex index() const { return hydrogen()->index(); }
1777 class LLoadKeyed V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1779 LLoadKeyed(LOperand* elements, LOperand* key) {
1780 inputs_[0] = elements;
1783 LOperand* elements() { return inputs_[0]; }
1784 LOperand* key() { return inputs_[1]; }
1785 ElementsKind elements_kind() const {
1786 return hydrogen()->elements_kind();
1788 bool is_external() const {
1789 return hydrogen()->is_external();
1791 bool is_fixed_typed_array() const {
1792 return hydrogen()->is_fixed_typed_array();
1794 bool is_typed_elements() const {
1795 return is_external() || is_fixed_typed_array();
1798 DECLARE_CONCRETE_INSTRUCTION(LoadKeyed, "load-keyed")
1799 DECLARE_HYDROGEN_ACCESSOR(LoadKeyed)
1801 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1802 uint32_t base_offset() const { return hydrogen()->base_offset(); }
1804 return hydrogen()->key()->representation().IsTagged();
1809 inline static bool ExternalArrayOpRequiresPreScale(
1810 Representation key_representation,
1811 ElementsKind kind) {
1812 int shift_size = ElementsKindToShiftSize(kind);
1813 return key_representation.IsSmi()
1814 ? shift_size > static_cast<int>(maximal_scale_factor) + kSmiTagSize
1815 : shift_size > static_cast<int>(maximal_scale_factor);
1819 inline static bool ExternalArrayOpRequiresTemp(
1820 Representation key_representation,
1821 ElementsKind elements_kind) {
1822 // Operations that require the key to be scaled by a factor or divided by two
1823 // to be converted into an index cannot fold the scale operation into a load
1824 // and need an extra temp register to do the work.
1825 return ExternalArrayOpRequiresPreScale(key_representation, elements_kind) ||
1826 (key_representation.IsSmi() &&
1827 (elements_kind == EXTERNAL_INT8_ELEMENTS ||
1828 elements_kind == EXTERNAL_UINT8_ELEMENTS ||
1829 elements_kind == EXTERNAL_UINT8_CLAMPED_ELEMENTS ||
1830 elements_kind == UINT8_ELEMENTS ||
1831 elements_kind == INT8_ELEMENTS ||
1832 elements_kind == UINT8_CLAMPED_ELEMENTS));
1836 class LLoadKeyedGeneric V8_FINAL : public LTemplateInstruction<1, 3, 0> {
1838 LLoadKeyedGeneric(LOperand* context, LOperand* obj, LOperand* key) {
1839 inputs_[0] = context;
1844 LOperand* context() { return inputs_[0]; }
1845 LOperand* object() { return inputs_[1]; }
1846 LOperand* key() { return inputs_[2]; }
1848 DECLARE_CONCRETE_INSTRUCTION(LoadKeyedGeneric, "load-keyed-generic")
1852 class LLoadGlobalCell V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1854 DECLARE_CONCRETE_INSTRUCTION(LoadGlobalCell, "load-global-cell")
1855 DECLARE_HYDROGEN_ACCESSOR(LoadGlobalCell)
1859 class LLoadGlobalGeneric V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1861 LLoadGlobalGeneric(LOperand* context, LOperand* global_object) {
1862 inputs_[0] = context;
1863 inputs_[1] = global_object;
1866 LOperand* context() { return inputs_[0]; }
1867 LOperand* global_object() { return inputs_[1]; }
1869 DECLARE_CONCRETE_INSTRUCTION(LoadGlobalGeneric, "load-global-generic")
1870 DECLARE_HYDROGEN_ACCESSOR(LoadGlobalGeneric)
1872 Handle<Object> name() const { return hydrogen()->name(); }
1873 bool for_typeof() const { return hydrogen()->for_typeof(); }
1877 class LStoreGlobalCell V8_FINAL : public LTemplateInstruction<0, 1, 0> {
1879 explicit LStoreGlobalCell(LOperand* value) {
1883 LOperand* value() { return inputs_[0]; }
1885 DECLARE_CONCRETE_INSTRUCTION(StoreGlobalCell, "store-global-cell")
1886 DECLARE_HYDROGEN_ACCESSOR(StoreGlobalCell)
1890 class LLoadContextSlot V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1892 explicit LLoadContextSlot(LOperand* context) {
1893 inputs_[0] = context;
1896 LOperand* context() { return inputs_[0]; }
1898 DECLARE_CONCRETE_INSTRUCTION(LoadContextSlot, "load-context-slot")
1899 DECLARE_HYDROGEN_ACCESSOR(LoadContextSlot)
1901 int slot_index() { return hydrogen()->slot_index(); }
1903 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1907 class LStoreContextSlot V8_FINAL : public LTemplateInstruction<0, 2, 1> {
1909 LStoreContextSlot(LOperand* context, LOperand* value, LOperand* temp) {
1910 inputs_[0] = context;
1915 LOperand* context() { return inputs_[0]; }
1916 LOperand* value() { return inputs_[1]; }
1917 LOperand* temp() { return temps_[0]; }
1919 DECLARE_CONCRETE_INSTRUCTION(StoreContextSlot, "store-context-slot")
1920 DECLARE_HYDROGEN_ACCESSOR(StoreContextSlot)
1922 int slot_index() { return hydrogen()->slot_index(); }
1924 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1928 class LPushArgument V8_FINAL : public LTemplateInstruction<0, 1, 0> {
1930 explicit LPushArgument(LOperand* value) {
1934 LOperand* value() { return inputs_[0]; }
1936 DECLARE_CONCRETE_INSTRUCTION(PushArgument, "push-argument")
1940 class LDrop V8_FINAL : public LTemplateInstruction<0, 0, 0> {
1942 explicit LDrop(int count) : count_(count) { }
1944 int count() const { return count_; }
1946 DECLARE_CONCRETE_INSTRUCTION(Drop, "drop")
1953 class LStoreCodeEntry V8_FINAL: public LTemplateInstruction<0, 2, 0> {
1955 LStoreCodeEntry(LOperand* function, LOperand* code_object) {
1956 inputs_[0] = function;
1957 inputs_[1] = code_object;
1960 LOperand* function() { return inputs_[0]; }
1961 LOperand* code_object() { return inputs_[1]; }
1963 virtual void PrintDataTo(StringStream* stream);
1965 DECLARE_CONCRETE_INSTRUCTION(StoreCodeEntry, "store-code-entry")
1966 DECLARE_HYDROGEN_ACCESSOR(StoreCodeEntry)
1970 class LInnerAllocatedObject V8_FINAL: public LTemplateInstruction<1, 2, 0> {
1972 LInnerAllocatedObject(LOperand* base_object, LOperand* offset) {
1973 inputs_[0] = base_object;
1974 inputs_[1] = offset;
1977 LOperand* base_object() const { return inputs_[0]; }
1978 LOperand* offset() const { return inputs_[1]; }
1980 virtual void PrintDataTo(StringStream* stream);
1982 DECLARE_CONCRETE_INSTRUCTION(InnerAllocatedObject, "inner-allocated-object")
1986 class LThisFunction V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1988 DECLARE_CONCRETE_INSTRUCTION(ThisFunction, "this-function")
1989 DECLARE_HYDROGEN_ACCESSOR(ThisFunction)
1993 class LContext V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1995 DECLARE_CONCRETE_INSTRUCTION(Context, "context")
1996 DECLARE_HYDROGEN_ACCESSOR(Context)
2000 class LDeclareGlobals V8_FINAL : public LTemplateInstruction<0, 1, 0> {
2002 explicit LDeclareGlobals(LOperand* context) {
2003 inputs_[0] = context;
2006 LOperand* context() { return inputs_[0]; }
2008 DECLARE_CONCRETE_INSTRUCTION(DeclareGlobals, "declare-globals")
2009 DECLARE_HYDROGEN_ACCESSOR(DeclareGlobals)
2013 class LCallJSFunction V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2015 explicit LCallJSFunction(LOperand* function) {
2016 inputs_[0] = function;
2019 LOperand* function() { return inputs_[0]; }
2021 DECLARE_CONCRETE_INSTRUCTION(CallJSFunction, "call-js-function")
2022 DECLARE_HYDROGEN_ACCESSOR(CallJSFunction)
2024 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
2026 int arity() const { return hydrogen()->argument_count() - 1; }
2030 class LCallWithDescriptor V8_FINAL : public LTemplateResultInstruction<1> {
2032 LCallWithDescriptor(const CallInterfaceDescriptor* descriptor,
2033 const ZoneList<LOperand*>& operands,
2035 : inputs_(descriptor->environment_length() + 1, zone) {
2036 ASSERT(descriptor->environment_length() + 1 == operands.length());
2037 inputs_.AddAll(operands, zone);
2040 LOperand* target() const { return inputs_[0]; }
2043 DECLARE_CONCRETE_INSTRUCTION(CallWithDescriptor, "call-with-descriptor")
2044 DECLARE_HYDROGEN_ACCESSOR(CallWithDescriptor)
2046 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
2048 int arity() const { return hydrogen()->argument_count() - 1; }
2050 ZoneList<LOperand*> inputs_;
2052 // Iterator support.
2053 virtual int InputCount() V8_FINAL V8_OVERRIDE { return inputs_.length(); }
2054 virtual LOperand* InputAt(int i) V8_FINAL V8_OVERRIDE { return inputs_[i]; }
2056 virtual int TempCount() V8_FINAL V8_OVERRIDE { return 0; }
2057 virtual LOperand* TempAt(int i) V8_FINAL V8_OVERRIDE { return NULL; }
2061 class LInvokeFunction V8_FINAL : public LTemplateInstruction<1, 2, 0> {
2063 LInvokeFunction(LOperand* context, LOperand* function) {
2064 inputs_[0] = context;
2065 inputs_[1] = function;
2068 LOperand* context() { return inputs_[0]; }
2069 LOperand* function() { return inputs_[1]; }
2071 DECLARE_CONCRETE_INSTRUCTION(InvokeFunction, "invoke-function")
2072 DECLARE_HYDROGEN_ACCESSOR(InvokeFunction)
2074 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
2076 int arity() const { return hydrogen()->argument_count() - 1; }
2080 class LCallFunction V8_FINAL : public LTemplateInstruction<1, 2, 0> {
2082 explicit LCallFunction(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(CallFunction, "call-function")
2091 DECLARE_HYDROGEN_ACCESSOR(CallFunction)
2093 int arity() const { return hydrogen()->argument_count() - 1; }
2097 class LCallNew V8_FINAL : public LTemplateInstruction<1, 2, 0> {
2099 LCallNew(LOperand* context, LOperand* constructor) {
2100 inputs_[0] = context;
2101 inputs_[1] = constructor;
2104 LOperand* context() { return inputs_[0]; }
2105 LOperand* constructor() { return inputs_[1]; }
2107 DECLARE_CONCRETE_INSTRUCTION(CallNew, "call-new")
2108 DECLARE_HYDROGEN_ACCESSOR(CallNew)
2110 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
2112 int arity() const { return hydrogen()->argument_count() - 1; }
2116 class LCallNewArray V8_FINAL : public LTemplateInstruction<1, 2, 0> {
2118 LCallNewArray(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(CallNewArray, "call-new-array")
2127 DECLARE_HYDROGEN_ACCESSOR(CallNewArray)
2129 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
2131 int arity() const { return hydrogen()->argument_count() - 1; }
2135 class LCallRuntime V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2137 explicit LCallRuntime(LOperand* context) {
2138 inputs_[0] = context;
2141 LOperand* context() { return inputs_[0]; }
2143 DECLARE_CONCRETE_INSTRUCTION(CallRuntime, "call-runtime")
2144 DECLARE_HYDROGEN_ACCESSOR(CallRuntime)
2146 virtual bool ClobbersDoubleRegisters(Isolate* isolate) const V8_OVERRIDE {
2147 return save_doubles() == kDontSaveFPRegs;
2150 const Runtime::Function* function() const { return hydrogen()->function(); }
2151 int arity() const { return hydrogen()->argument_count(); }
2152 SaveFPRegsMode save_doubles() const { return hydrogen()->save_doubles(); }
2156 class LInteger32ToDouble V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2158 explicit LInteger32ToDouble(LOperand* value) {
2162 LOperand* value() { return inputs_[0]; }
2164 DECLARE_CONCRETE_INSTRUCTION(Integer32ToDouble, "int32-to-double")
2168 class LUint32ToDouble V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2170 explicit LUint32ToDouble(LOperand* value) {
2174 LOperand* value() { return inputs_[0]; }
2176 DECLARE_CONCRETE_INSTRUCTION(Uint32ToDouble, "uint32-to-double")
2180 class LNumberTagI V8_FINAL : public LTemplateInstruction<1, 1, 1> {
2182 LNumberTagI(LOperand* value, LOperand* temp) {
2187 LOperand* value() { return inputs_[0]; }
2188 LOperand* temp() { return temps_[0]; }
2190 DECLARE_CONCRETE_INSTRUCTION(NumberTagI, "number-tag-i")
2194 class LNumberTagU V8_FINAL : public LTemplateInstruction<1, 1, 1> {
2196 LNumberTagU(LOperand* value, LOperand* temp) {
2201 LOperand* value() { return inputs_[0]; }
2202 LOperand* temp() { return temps_[0]; }
2204 DECLARE_CONCRETE_INSTRUCTION(NumberTagU, "number-tag-u")
2208 class LNumberTagD V8_FINAL : public LTemplateInstruction<1, 1, 1> {
2210 LNumberTagD(LOperand* value, LOperand* temp) {
2215 LOperand* value() { return inputs_[0]; }
2216 LOperand* temp() { return temps_[0]; }
2218 DECLARE_CONCRETE_INSTRUCTION(NumberTagD, "number-tag-d")
2219 DECLARE_HYDROGEN_ACCESSOR(Change)
2223 class LSIMD128ToTagged V8_FINAL : public LTemplateInstruction<1, 1, 2> {
2225 explicit LSIMD128ToTagged(LOperand* value, LOperand* temp, LOperand* temp2) {
2231 LOperand* value() { return inputs_[0]; }
2232 LOperand* temp() { return temps_[0]; }
2233 LOperand* temp2() { return temps_[1]; }
2235 DECLARE_CONCRETE_INSTRUCTION(SIMD128ToTagged, "simd128-tag")
2236 DECLARE_HYDROGEN_ACCESSOR(Change)
2240 // Sometimes truncating conversion from a tagged value to an int32.
2241 class LDoubleToI V8_FINAL : public LTemplateInstruction<1, 1, 1> {
2243 LDoubleToI(LOperand* value, LOperand* temp) {
2248 LOperand* value() { return inputs_[0]; }
2249 LOperand* temp() { return temps_[0]; }
2251 DECLARE_CONCRETE_INSTRUCTION(DoubleToI, "double-to-i")
2252 DECLARE_HYDROGEN_ACCESSOR(UnaryOperation)
2254 bool truncating() { return hydrogen()->CanTruncateToInt32(); }
2258 class LDoubleToSmi V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2260 explicit LDoubleToSmi(LOperand* value) {
2264 LOperand* value() { return inputs_[0]; }
2266 DECLARE_CONCRETE_INSTRUCTION(DoubleToSmi, "double-to-smi")
2267 DECLARE_HYDROGEN_ACCESSOR(UnaryOperation)
2271 // Truncating conversion from a tagged value to an int32.
2272 class LTaggedToI V8_FINAL : public LTemplateInstruction<1, 1, 1> {
2274 LTaggedToI(LOperand* value, LOperand* temp) {
2279 LOperand* value() { return inputs_[0]; }
2280 LOperand* temp() { return temps_[0]; }
2282 DECLARE_CONCRETE_INSTRUCTION(TaggedToI, "tagged-to-i")
2283 DECLARE_HYDROGEN_ACCESSOR(Change)
2285 bool truncating() { return hydrogen()->CanTruncateToInt32(); }
2289 class LSmiTag V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2291 explicit LSmiTag(LOperand* value) {
2295 LOperand* value() { return inputs_[0]; }
2297 DECLARE_CONCRETE_INSTRUCTION(SmiTag, "smi-tag")
2298 DECLARE_HYDROGEN_ACCESSOR(Change)
2302 class LNumberUntagD V8_FINAL : public LTemplateInstruction<1, 1, 1> {
2304 explicit LNumberUntagD(LOperand* value, LOperand* temp) {
2309 LOperand* value() { return inputs_[0]; }
2310 LOperand* temp() { return temps_[0]; }
2312 DECLARE_CONCRETE_INSTRUCTION(NumberUntagD, "double-untag")
2313 DECLARE_HYDROGEN_ACCESSOR(Change);
2317 class LTaggedToSIMD128 V8_FINAL : public LTemplateInstruction<1, 1, 1> {
2319 explicit LTaggedToSIMD128(LOperand* value, LOperand* temp,
2320 Representation representation)
2321 : representation_(representation) {
2326 LOperand* value() { return inputs_[0]; }
2327 LOperand* temp() { return temps_[0]; }
2328 Representation representation() const { return representation_; }
2330 DECLARE_CONCRETE_INSTRUCTION(TaggedToSIMD128, "simd128-untag")
2331 DECLARE_HYDROGEN_ACCESSOR(Change);
2333 Representation representation_;
2337 class LSmiUntag V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2339 LSmiUntag(LOperand* value, bool needs_check)
2340 : needs_check_(needs_check) {
2344 LOperand* value() { return inputs_[0]; }
2346 DECLARE_CONCRETE_INSTRUCTION(SmiUntag, "smi-untag")
2348 bool needs_check() const { return needs_check_; }
2355 class LStoreNamedField V8_FINAL : public LTemplateInstruction<0, 2, 2> {
2357 LStoreNamedField(LOperand* obj,
2360 LOperand* temp_map) {
2364 temps_[1] = temp_map;
2367 LOperand* object() { return inputs_[0]; }
2368 LOperand* value() { return inputs_[1]; }
2369 LOperand* temp() { return temps_[0]; }
2370 LOperand* temp_map() { return temps_[1]; }
2372 DECLARE_CONCRETE_INSTRUCTION(StoreNamedField, "store-named-field")
2373 DECLARE_HYDROGEN_ACCESSOR(StoreNamedField)
2375 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
2379 class LStoreNamedGeneric V8_FINAL : public LTemplateInstruction<0, 3, 0> {
2381 LStoreNamedGeneric(LOperand* context, LOperand* object, LOperand* value) {
2382 inputs_[0] = context;
2383 inputs_[1] = object;
2387 LOperand* context() { return inputs_[0]; }
2388 LOperand* object() { return inputs_[1]; }
2389 LOperand* value() { return inputs_[2]; }
2391 DECLARE_CONCRETE_INSTRUCTION(StoreNamedGeneric, "store-named-generic")
2392 DECLARE_HYDROGEN_ACCESSOR(StoreNamedGeneric)
2394 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
2395 Handle<Object> name() const { return hydrogen()->name(); }
2396 StrictMode strict_mode() { return hydrogen()->strict_mode(); }
2400 class LStoreKeyed V8_FINAL : public LTemplateInstruction<0, 3, 0> {
2402 LStoreKeyed(LOperand* obj, LOperand* key, LOperand* val) {
2408 bool is_external() const { return hydrogen()->is_external(); }
2409 bool is_fixed_typed_array() const {
2410 return hydrogen()->is_fixed_typed_array();
2412 bool is_typed_elements() const {
2413 return is_external() || is_fixed_typed_array();
2415 LOperand* elements() { return inputs_[0]; }
2416 LOperand* key() { return inputs_[1]; }
2417 LOperand* value() { return inputs_[2]; }
2418 ElementsKind elements_kind() const {
2419 return hydrogen()->elements_kind();
2422 DECLARE_CONCRETE_INSTRUCTION(StoreKeyed, "store-keyed")
2423 DECLARE_HYDROGEN_ACCESSOR(StoreKeyed)
2425 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
2426 uint32_t base_offset() const { return hydrogen()->base_offset(); }
2427 bool NeedsCanonicalization() { return hydrogen()->NeedsCanonicalization(); }
2431 class LStoreKeyedGeneric V8_FINAL : public LTemplateInstruction<0, 4, 0> {
2433 LStoreKeyedGeneric(LOperand* context,
2437 inputs_[0] = context;
2438 inputs_[1] = object;
2443 LOperand* context() { return inputs_[0]; }
2444 LOperand* object() { return inputs_[1]; }
2445 LOperand* key() { return inputs_[2]; }
2446 LOperand* value() { return inputs_[3]; }
2448 DECLARE_CONCRETE_INSTRUCTION(StoreKeyedGeneric, "store-keyed-generic")
2449 DECLARE_HYDROGEN_ACCESSOR(StoreKeyedGeneric)
2451 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
2453 StrictMode strict_mode() { return hydrogen()->strict_mode(); }
2457 class LTransitionElementsKind V8_FINAL : public LTemplateInstruction<0, 2, 2> {
2459 LTransitionElementsKind(LOperand* object,
2461 LOperand* new_map_temp,
2463 inputs_[0] = object;
2464 inputs_[1] = context;
2465 temps_[0] = new_map_temp;
2469 LOperand* context() { return inputs_[1]; }
2470 LOperand* object() { return inputs_[0]; }
2471 LOperand* new_map_temp() { return temps_[0]; }
2472 LOperand* temp() { return temps_[1]; }
2474 DECLARE_CONCRETE_INSTRUCTION(TransitionElementsKind,
2475 "transition-elements-kind")
2476 DECLARE_HYDROGEN_ACCESSOR(TransitionElementsKind)
2478 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
2480 Handle<Map> original_map() { return hydrogen()->original_map().handle(); }
2481 Handle<Map> transitioned_map() {
2482 return hydrogen()->transitioned_map().handle();
2484 ElementsKind from_kind() { return hydrogen()->from_kind(); }
2485 ElementsKind to_kind() { return hydrogen()->to_kind(); }
2489 class LTrapAllocationMemento V8_FINAL : public LTemplateInstruction<0, 1, 1> {
2491 LTrapAllocationMemento(LOperand* object,
2493 inputs_[0] = object;
2497 LOperand* object() { return inputs_[0]; }
2498 LOperand* temp() { return temps_[0]; }
2500 DECLARE_CONCRETE_INSTRUCTION(TrapAllocationMemento,
2501 "trap-allocation-memento")
2505 class LStringAdd V8_FINAL : public LTemplateInstruction<1, 3, 0> {
2507 LStringAdd(LOperand* context, LOperand* left, LOperand* right) {
2508 inputs_[0] = context;
2513 LOperand* context() { return inputs_[0]; }
2514 LOperand* left() { return inputs_[1]; }
2515 LOperand* right() { return inputs_[2]; }
2517 DECLARE_CONCRETE_INSTRUCTION(StringAdd, "string-add")
2518 DECLARE_HYDROGEN_ACCESSOR(StringAdd)
2522 class LStringCharCodeAt V8_FINAL : public LTemplateInstruction<1, 3, 0> {
2524 LStringCharCodeAt(LOperand* context, LOperand* string, LOperand* index) {
2525 inputs_[0] = context;
2526 inputs_[1] = string;
2530 LOperand* context() { return inputs_[0]; }
2531 LOperand* string() { return inputs_[1]; }
2532 LOperand* index() { return inputs_[2]; }
2534 DECLARE_CONCRETE_INSTRUCTION(StringCharCodeAt, "string-char-code-at")
2535 DECLARE_HYDROGEN_ACCESSOR(StringCharCodeAt)
2539 class LStringCharFromCode V8_FINAL : public LTemplateInstruction<1, 2, 0> {
2541 LStringCharFromCode(LOperand* context, LOperand* char_code) {
2542 inputs_[0] = context;
2543 inputs_[1] = char_code;
2546 LOperand* context() { return inputs_[0]; }
2547 LOperand* char_code() { return inputs_[1]; }
2549 DECLARE_CONCRETE_INSTRUCTION(StringCharFromCode, "string-char-from-code")
2550 DECLARE_HYDROGEN_ACCESSOR(StringCharFromCode)
2554 class LCheckValue V8_FINAL : public LTemplateInstruction<0, 1, 0> {
2556 explicit LCheckValue(LOperand* value) {
2560 LOperand* value() { return inputs_[0]; }
2562 DECLARE_CONCRETE_INSTRUCTION(CheckValue, "check-value")
2563 DECLARE_HYDROGEN_ACCESSOR(CheckValue)
2567 class LCheckInstanceType V8_FINAL : public LTemplateInstruction<0, 1, 1> {
2569 LCheckInstanceType(LOperand* value, LOperand* temp) {
2574 LOperand* value() { return inputs_[0]; }
2575 LOperand* temp() { return temps_[0]; }
2577 DECLARE_CONCRETE_INSTRUCTION(CheckInstanceType, "check-instance-type")
2578 DECLARE_HYDROGEN_ACCESSOR(CheckInstanceType)
2582 class LCheckMaps V8_FINAL : public LTemplateInstruction<0, 1, 0> {
2584 explicit LCheckMaps(LOperand* value = NULL) {
2588 LOperand* value() { return inputs_[0]; }
2590 DECLARE_CONCRETE_INSTRUCTION(CheckMaps, "check-maps")
2591 DECLARE_HYDROGEN_ACCESSOR(CheckMaps)
2595 class LCheckSmi V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2597 explicit LCheckSmi(LOperand* value) {
2601 LOperand* value() { return inputs_[0]; }
2603 DECLARE_CONCRETE_INSTRUCTION(CheckSmi, "check-smi")
2607 class LClampDToUint8 V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2609 explicit LClampDToUint8(LOperand* value) {
2613 LOperand* unclamped() { return inputs_[0]; }
2615 DECLARE_CONCRETE_INSTRUCTION(ClampDToUint8, "clamp-d-to-uint8")
2619 class LClampIToUint8 V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2621 explicit LClampIToUint8(LOperand* value) {
2625 LOperand* unclamped() { return inputs_[0]; }
2627 DECLARE_CONCRETE_INSTRUCTION(ClampIToUint8, "clamp-i-to-uint8")
2631 class LClampTToUint8 V8_FINAL : public LTemplateInstruction<1, 1, 1> {
2633 LClampTToUint8(LOperand* value, LOperand* temp_xmm) {
2635 temps_[0] = temp_xmm;
2638 LOperand* unclamped() { return inputs_[0]; }
2639 LOperand* temp_xmm() { return temps_[0]; }
2641 DECLARE_CONCRETE_INSTRUCTION(ClampTToUint8, "clamp-t-to-uint8")
2645 class LCheckNonSmi V8_FINAL : public LTemplateInstruction<0, 1, 0> {
2647 explicit LCheckNonSmi(LOperand* value) {
2651 LOperand* value() { return inputs_[0]; }
2653 DECLARE_CONCRETE_INSTRUCTION(CheckNonSmi, "check-non-smi")
2654 DECLARE_HYDROGEN_ACCESSOR(CheckHeapObject)
2658 class LDoubleBits V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2660 explicit LDoubleBits(LOperand* value) {
2664 LOperand* value() { return inputs_[0]; }
2666 DECLARE_CONCRETE_INSTRUCTION(DoubleBits, "double-bits")
2667 DECLARE_HYDROGEN_ACCESSOR(DoubleBits)
2671 class LConstructDouble V8_FINAL : public LTemplateInstruction<1, 2, 0> {
2673 LConstructDouble(LOperand* hi, LOperand* lo) {
2678 LOperand* hi() { return inputs_[0]; }
2679 LOperand* lo() { return inputs_[1]; }
2681 DECLARE_CONCRETE_INSTRUCTION(ConstructDouble, "construct-double")
2685 class LAllocate V8_FINAL : public LTemplateInstruction<1, 2, 1> {
2687 LAllocate(LOperand* context, LOperand* size, LOperand* temp) {
2688 inputs_[0] = context;
2693 LOperand* context() { return inputs_[0]; }
2694 LOperand* size() { return inputs_[1]; }
2695 LOperand* temp() { return temps_[0]; }
2697 DECLARE_CONCRETE_INSTRUCTION(Allocate, "allocate")
2698 DECLARE_HYDROGEN_ACCESSOR(Allocate)
2702 class LRegExpLiteral V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2704 explicit LRegExpLiteral(LOperand* context) {
2705 inputs_[0] = context;
2708 LOperand* context() { return inputs_[0]; }
2710 DECLARE_CONCRETE_INSTRUCTION(RegExpLiteral, "regexp-literal")
2711 DECLARE_HYDROGEN_ACCESSOR(RegExpLiteral)
2715 class LFunctionLiteral V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2717 explicit LFunctionLiteral(LOperand* context) {
2718 inputs_[0] = context;
2721 LOperand* context() { return inputs_[0]; }
2723 DECLARE_CONCRETE_INSTRUCTION(FunctionLiteral, "function-literal")
2724 DECLARE_HYDROGEN_ACCESSOR(FunctionLiteral)
2728 class LToFastProperties V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2730 explicit LToFastProperties(LOperand* value) {
2734 LOperand* value() { return inputs_[0]; }
2736 DECLARE_CONCRETE_INSTRUCTION(ToFastProperties, "to-fast-properties")
2737 DECLARE_HYDROGEN_ACCESSOR(ToFastProperties)
2741 class LTypeof V8_FINAL : public LTemplateInstruction<1, 2, 0> {
2743 LTypeof(LOperand* context, LOperand* value) {
2744 inputs_[0] = context;
2748 LOperand* context() { return inputs_[0]; }
2749 LOperand* value() { return inputs_[1]; }
2751 DECLARE_CONCRETE_INSTRUCTION(Typeof, "typeof")
2755 class LTypeofIsAndBranch V8_FINAL : public LControlInstruction<1, 0> {
2757 explicit LTypeofIsAndBranch(LOperand* value) {
2761 LOperand* value() { return inputs_[0]; }
2763 DECLARE_CONCRETE_INSTRUCTION(TypeofIsAndBranch, "typeof-is-and-branch")
2764 DECLARE_HYDROGEN_ACCESSOR(TypeofIsAndBranch)
2766 Handle<String> type_literal() { return hydrogen()->type_literal(); }
2768 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
2772 class LOsrEntry V8_FINAL : public LTemplateInstruction<0, 0, 0> {
2774 virtual bool HasInterestingComment(LCodeGen* gen) const V8_OVERRIDE {
2777 DECLARE_CONCRETE_INSTRUCTION(OsrEntry, "osr-entry")
2781 class LStackCheck V8_FINAL : public LTemplateInstruction<0, 1, 0> {
2783 explicit LStackCheck(LOperand* context) {
2784 inputs_[0] = context;
2787 LOperand* context() { return inputs_[0]; }
2789 DECLARE_CONCRETE_INSTRUCTION(StackCheck, "stack-check")
2790 DECLARE_HYDROGEN_ACCESSOR(StackCheck)
2792 Label* done_label() { return &done_label_; }
2799 class LForInPrepareMap V8_FINAL : public LTemplateInstruction<1, 2, 0> {
2801 LForInPrepareMap(LOperand* context, LOperand* object) {
2802 inputs_[0] = context;
2803 inputs_[1] = object;
2806 LOperand* context() { return inputs_[0]; }
2807 LOperand* object() { return inputs_[1]; }
2809 DECLARE_CONCRETE_INSTRUCTION(ForInPrepareMap, "for-in-prepare-map")
2813 class LForInCacheArray V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2815 explicit LForInCacheArray(LOperand* map) {
2819 LOperand* map() { return inputs_[0]; }
2821 DECLARE_CONCRETE_INSTRUCTION(ForInCacheArray, "for-in-cache-array")
2824 return HForInCacheArray::cast(this->hydrogen_value())->idx();
2829 class LCheckMapValue V8_FINAL : public LTemplateInstruction<0, 2, 0> {
2831 LCheckMapValue(LOperand* value, LOperand* map) {
2836 LOperand* value() { return inputs_[0]; }
2837 LOperand* map() { return inputs_[1]; }
2839 DECLARE_CONCRETE_INSTRUCTION(CheckMapValue, "check-map-value")
2843 class LLoadFieldByIndex V8_FINAL : public LTemplateInstruction<1, 2, 0> {
2845 LLoadFieldByIndex(LOperand* object, LOperand* index) {
2846 inputs_[0] = object;
2850 LOperand* object() { return inputs_[0]; }
2851 LOperand* index() { return inputs_[1]; }
2853 DECLARE_CONCRETE_INSTRUCTION(LoadFieldByIndex, "load-field-by-index")
2857 class LStoreFrameContext: public LTemplateInstruction<0, 1, 0> {
2859 explicit LStoreFrameContext(LOperand* context) {
2860 inputs_[0] = context;
2863 LOperand* context() { return inputs_[0]; }
2865 DECLARE_CONCRETE_INSTRUCTION(StoreFrameContext, "store-frame-context")
2869 class LAllocateBlockContext: public LTemplateInstruction<1, 2, 0> {
2871 LAllocateBlockContext(LOperand* context, LOperand* function) {
2872 inputs_[0] = context;
2873 inputs_[1] = function;
2876 LOperand* context() { return inputs_[0]; }
2877 LOperand* function() { return inputs_[1]; }
2879 Handle<ScopeInfo> scope_info() { return hydrogen()->scope_info(); }
2881 DECLARE_CONCRETE_INSTRUCTION(AllocateBlockContext, "allocate-block-context")
2882 DECLARE_HYDROGEN_ACCESSOR(AllocateBlockContext)
2886 class LChunkBuilder;
2887 class LPlatformChunk V8_FINAL : public LChunk {
2889 LPlatformChunk(CompilationInfo* info, HGraph* graph)
2890 : LChunk(info, graph),
2891 num_double_slots_(0) { }
2893 int GetNextSpillIndex(RegisterKind kind);
2894 LOperand* GetNextSpillSlot(RegisterKind kind);
2896 int num_double_slots() const { return num_double_slots_; }
2899 int num_double_slots_;
2903 class LChunkBuilder V8_FINAL : public LChunkBuilderBase {
2905 LChunkBuilder(CompilationInfo* info, HGraph* graph, LAllocator* allocator)
2906 : LChunkBuilderBase(graph->zone()),
2911 current_instruction_(NULL),
2912 current_block_(NULL),
2914 allocator_(allocator) { }
2916 Isolate* isolate() const { return graph_->isolate(); }
2918 // Build the sequence for the graph.
2919 LPlatformChunk* Build();
2921 // Declare methods that deal with the individual node types.
2922 #define DECLARE_DO(type) LInstruction* Do##type(H##type* node);
2923 HYDROGEN_CONCRETE_INSTRUCTION_LIST(DECLARE_DO)
2926 LInstruction* DoMathFloor(HUnaryMathOperation* instr);
2927 LInstruction* DoMathRound(HUnaryMathOperation* instr);
2928 LInstruction* DoMathAbs(HUnaryMathOperation* instr);
2929 LInstruction* DoMathLog(HUnaryMathOperation* instr);
2930 LInstruction* DoMathExp(HUnaryMathOperation* instr);
2931 LInstruction* DoMathSqrt(HUnaryMathOperation* instr);
2932 LInstruction* DoMathPowHalf(HUnaryMathOperation* instr);
2933 LInstruction* DoMathClz32(HUnaryMathOperation* instr);
2934 LInstruction* DoDivByPowerOf2I(HDiv* instr);
2935 LInstruction* DoDivByConstI(HDiv* instr);
2936 LInstruction* DoDivI(HDiv* instr);
2937 LInstruction* DoModByPowerOf2I(HMod* instr);
2938 LInstruction* DoModByConstI(HMod* instr);
2939 LInstruction* DoModI(HMod* instr);
2940 LInstruction* DoFlooringDivByPowerOf2I(HMathFloorOfDiv* instr);
2941 LInstruction* DoFlooringDivByConstI(HMathFloorOfDiv* instr);
2942 LInstruction* DoFlooringDivI(HMathFloorOfDiv* instr);
2952 LPlatformChunk* chunk() const { return chunk_; }
2953 CompilationInfo* info() const { return info_; }
2954 HGraph* graph() const { return graph_; }
2956 bool is_unused() const { return status_ == UNUSED; }
2957 bool is_building() const { return status_ == BUILDING; }
2958 bool is_done() const { return status_ == DONE; }
2959 bool is_aborted() const { return status_ == ABORTED; }
2961 void Abort(BailoutReason reason);
2963 // Methods for getting operands for Use / Define / Temp.
2964 LUnallocated* ToUnallocated(Register reg);
2965 LUnallocated* ToUnallocated(XMMRegister reg);
2967 // Methods for setting up define-use relationships.
2968 MUST_USE_RESULT LOperand* Use(HValue* value, LUnallocated* operand);
2969 MUST_USE_RESULT LOperand* UseFixed(HValue* value, Register fixed_register);
2970 MUST_USE_RESULT LOperand* UseFixedDouble(HValue* value,
2971 XMMRegister fixed_register);
2973 // A value that is guaranteed to be allocated to a register.
2974 // Operand created by UseRegister is guaranteed to be live until the end of
2975 // instruction. This means that register allocator will not reuse it's
2976 // register for any other operand inside instruction.
2977 // Operand created by UseRegisterAtStart is guaranteed to be live only at
2978 // instruction start. Register allocator is free to assign the same register
2979 // to some other operand used inside instruction (i.e. temporary or
2981 MUST_USE_RESULT LOperand* UseRegister(HValue* value);
2982 MUST_USE_RESULT LOperand* UseRegisterAtStart(HValue* value);
2984 // An input operand in a register that may be trashed.
2985 MUST_USE_RESULT LOperand* UseTempRegister(HValue* value);
2987 // An input operand in a register or stack slot.
2988 MUST_USE_RESULT LOperand* Use(HValue* value);
2989 MUST_USE_RESULT LOperand* UseAtStart(HValue* value);
2991 // An input operand in a register, stack slot or a constant operand.
2992 MUST_USE_RESULT LOperand* UseOrConstant(HValue* value);
2993 MUST_USE_RESULT LOperand* UseOrConstantAtStart(HValue* value);
2995 // An input operand in a fixed register or a constant operand.
2996 MUST_USE_RESULT LOperand* UseFixedOrConstant(HValue* value,
2997 Register fixed_register);
2999 // An input operand in a register or a constant operand.
3000 MUST_USE_RESULT LOperand* UseRegisterOrConstant(HValue* value);
3001 MUST_USE_RESULT LOperand* UseRegisterOrConstantAtStart(HValue* value);
3003 // An input operand in a constant operand.
3004 MUST_USE_RESULT LOperand* UseConstant(HValue* value);
3006 // An input operand in register, stack slot or a constant operand.
3007 // Will not be moved to a register even if one is freely available.
3008 virtual MUST_USE_RESULT LOperand* UseAny(HValue* value) V8_OVERRIDE;
3010 // Temporary operand that must be in a register.
3011 MUST_USE_RESULT LUnallocated* TempRegister();
3012 MUST_USE_RESULT LOperand* FixedTemp(Register reg);
3013 MUST_USE_RESULT LOperand* FixedTemp(XMMRegister reg);
3015 // Methods for setting up define-use relationships.
3016 // Return the same instruction that they are passed.
3017 LInstruction* Define(LTemplateResultInstruction<1>* instr,
3018 LUnallocated* result);
3019 LInstruction* DefineAsRegister(LTemplateResultInstruction<1>* instr);
3020 LInstruction* DefineAsSpilled(LTemplateResultInstruction<1>* instr,
3022 LInstruction* DefineSameAsFirst(LTemplateResultInstruction<1>* instr);
3023 LInstruction* DefineFixed(LTemplateResultInstruction<1>* instr,
3025 LInstruction* DefineFixedDouble(LTemplateResultInstruction<1>* instr,
3027 // Assigns an environment to an instruction. An instruction which can
3028 // deoptimize must have an environment.
3029 LInstruction* AssignEnvironment(LInstruction* instr);
3030 // Assigns a pointer map to an instruction. An instruction which can
3031 // trigger a GC or a lazy deoptimization must have a pointer map.
3032 LInstruction* AssignPointerMap(LInstruction* instr);
3034 enum CanDeoptimize { CAN_DEOPTIMIZE_EAGERLY, CANNOT_DEOPTIMIZE_EAGERLY };
3036 LOperand* GetSeqStringSetCharOperand(HSeqStringSetChar* instr);
3038 // Marks a call for the register allocator. Assigns a pointer map to
3039 // support GC and lazy deoptimization. Assigns an environment to support
3040 // eager deoptimization if CAN_DEOPTIMIZE_EAGERLY.
3041 LInstruction* MarkAsCall(
3042 LInstruction* instr,
3043 HInstruction* hinstr,
3044 CanDeoptimize can_deoptimize = CANNOT_DEOPTIMIZE_EAGERLY);
3046 void VisitInstruction(HInstruction* current);
3047 void AddInstruction(LInstruction* instr, HInstruction* current);
3049 void DoBasicBlock(HBasicBlock* block, HBasicBlock* next_block);
3050 LInstruction* DoShift(Token::Value op, HBitwiseBinaryOperation* instr);
3051 LInstruction* DoArithmeticD(Token::Value op,
3052 HArithmeticBinaryOperation* instr);
3053 LInstruction* DoArithmeticT(Token::Value op,
3054 HBinaryOperation* instr);
3056 LOperand* GetStoreKeyedValueOperand(HStoreKeyed* instr);
3058 LPlatformChunk* chunk_;
3059 CompilationInfo* info_;
3060 HGraph* const graph_;
3062 HInstruction* current_instruction_;
3063 HBasicBlock* current_block_;
3064 HBasicBlock* next_block_;
3065 LAllocator* allocator_;
3067 DISALLOW_COPY_AND_ASSIGN(LChunkBuilder);
3070 #undef DECLARE_HYDROGEN_ACCESSOR
3071 #undef DECLARE_CONCRETE_INSTRUCTION
3073 } } // namespace v8::internal
3075 #endif // V8_IA32_LITHIUM_IA32_H_