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_X64_LITHIUM_X64_H_
6 #define V8_X64_LITHIUM_X64_H_
8 #include "src/hydrogen.h"
9 #include "src/lithium.h"
10 #include "src/lithium-allocator.h"
11 #include "src/safepoint-table.h"
12 #include "src/utils.h"
17 // Forward declarations.
20 #define LITHIUM_CONCRETE_INSTRUCTION_LIST(V) \
21 V(AccessArgumentsAt) \
24 V(AllocateBlockContext) \
26 V(ArgumentsElements) \
34 V(CallWithDescriptor) \
40 V(CheckInstanceType) \
49 V(ClassOfTestAndBranch) \
50 V(CompareMinusZeroAndBranch) \
51 V(CompareNumericAndBranch) \
52 V(CmpObjectEqAndBranch) \
76 V(FlooringDivByConstI) \
77 V(FlooringDivByPowerOf2I) \
82 V(GetCachedArrayIndex) \
84 V(HasCachedArrayIndexAndBranch) \
85 V(HasInstanceTypeAndBranch) \
86 V(InnerAllocatedObject) \
88 V(InstanceOfKnownGlobal) \
90 V(Integer32ToDouble) \
92 V(IsConstructCallAndBranch) \
93 V(IsObjectAndBranch) \
94 V(IsStringAndBranch) \
96 V(IsUndetectableAndBranch) \
101 V(LoadFieldByIndex) \
102 V(LoadFunctionPrototype) \
104 V(LoadGlobalGeneric) \
106 V(LoadKeyedGeneric) \
108 V(LoadNamedGeneric) \
122 V(NullarySIMDOperation) \
123 V(UnarySIMDOperation) \
124 V(BinarySIMDOperation) \
125 V(TernarySIMDOperation) \
126 V(QuarternarySIMDOperation) \
141 V(SeqStringGetChar) \
142 V(SeqStringSetChar) \
148 V(StoreContextSlot) \
149 V(StoreFrameContext) \
152 V(StoreKeyedGeneric) \
154 V(StoreNamedGeneric) \
156 V(StringCharCodeAt) \
157 V(StringCharFromCode) \
158 V(StringCompareAndBranch) \
162 V(ToFastProperties) \
163 V(TransitionElementsKind) \
164 V(TrapAllocationMemento) \
166 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 DCHECK(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 // Try deleting this instruction if possible.
230 virtual bool TryDelete() { return false; }
232 void set_environment(LEnvironment* env) { environment_ = env; }
233 LEnvironment* environment() const { return environment_; }
234 bool HasEnvironment() const { return environment_ != NULL; }
236 void set_pointer_map(LPointerMap* p) { pointer_map_.set(p); }
237 LPointerMap* pointer_map() const { return pointer_map_.get(); }
238 bool HasPointerMap() const { return pointer_map_.is_set(); }
240 void set_hydrogen_value(HValue* value) { hydrogen_value_ = value; }
241 HValue* hydrogen_value() const { return hydrogen_value_; }
243 void MarkAsCall() { bit_field_ = IsCallBits::update(bit_field_, true); }
244 bool IsCall() const { return IsCallBits::decode(bit_field_); }
246 // Interface to the register allocator and iterators.
247 bool ClobbersTemps() const { return IsCall(); }
248 bool ClobbersRegisters() const { return IsCall(); }
249 virtual bool ClobbersDoubleRegisters(Isolate* isolate) const {
253 virtual void SetDeferredLazyDeoptimizationEnvironment(LEnvironment* env) { }
255 // Interface to the register allocator and iterators.
256 bool IsMarkedAsCall() const { return IsCall(); }
258 virtual bool HasResult() const = 0;
259 virtual LOperand* result() const = 0;
261 LOperand* FirstInput() { return InputAt(0); }
262 LOperand* Output() { return HasResult() ? result() : NULL; }
264 virtual bool HasInterestingComment(LCodeGen* gen) const { return true; }
266 virtual bool MustSignExtendResult(LPlatformChunk* chunk) const {
274 virtual int InputCount() = 0;
275 virtual LOperand* InputAt(int i) = 0;
279 friend class InputIterator;
281 friend class TempIterator;
282 virtual int TempCount() = 0;
283 virtual LOperand* TempAt(int i) = 0;
285 class IsCallBits: public BitField<bool, 0, 1> {};
287 LEnvironment* environment_;
288 SetOncePointer<LPointerMap> pointer_map_;
289 HValue* hydrogen_value_;
294 // R = number of result operands (0 or 1).
296 class LTemplateResultInstruction : public LInstruction {
298 // Allow 0 or 1 output operands.
299 STATIC_ASSERT(R == 0 || R == 1);
300 virtual bool HasResult() const V8_FINAL V8_OVERRIDE {
301 return R != 0 && result() != NULL;
303 void set_result(LOperand* operand) { results_[0] = operand; }
304 LOperand* result() const { return results_[0]; }
306 virtual bool MustSignExtendResult(
307 LPlatformChunk* chunk) const V8_FINAL V8_OVERRIDE;
310 EmbeddedContainer<LOperand*, R> results_;
314 // R = number of result operands (0 or 1).
315 // I = number of input operands.
316 // T = number of temporary operands.
317 template<int R, int I, int T>
318 class LTemplateInstruction : public LTemplateResultInstruction<R> {
320 EmbeddedContainer<LOperand*, I> inputs_;
321 EmbeddedContainer<LOperand*, T> temps_;
325 virtual int InputCount() V8_FINAL V8_OVERRIDE { return I; }
326 virtual LOperand* InputAt(int i) V8_FINAL V8_OVERRIDE { return inputs_[i]; }
328 virtual int TempCount() V8_FINAL V8_OVERRIDE { return T; }
329 virtual LOperand* TempAt(int i) V8_FINAL V8_OVERRIDE { return temps_[i]; }
333 class LGap : public LTemplateInstruction<0, 0, 0> {
335 explicit LGap(HBasicBlock* block)
337 parallel_moves_[BEFORE] = NULL;
338 parallel_moves_[START] = NULL;
339 parallel_moves_[END] = NULL;
340 parallel_moves_[AFTER] = NULL;
343 // Can't use the DECLARE-macro here because of sub-classes.
344 virtual bool IsGap() const V8_FINAL V8_OVERRIDE { return true; }
345 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
346 static LGap* cast(LInstruction* instr) {
347 DCHECK(instr->IsGap());
348 return reinterpret_cast<LGap*>(instr);
351 bool IsRedundant() const;
353 HBasicBlock* block() const { return block_; }
360 FIRST_INNER_POSITION = BEFORE,
361 LAST_INNER_POSITION = AFTER
364 LParallelMove* GetOrCreateParallelMove(InnerPosition pos,
366 if (parallel_moves_[pos] == NULL) {
367 parallel_moves_[pos] = new(zone) LParallelMove(zone);
369 return parallel_moves_[pos];
372 LParallelMove* GetParallelMove(InnerPosition pos) {
373 return parallel_moves_[pos];
377 LParallelMove* parallel_moves_[LAST_INNER_POSITION + 1];
382 class LInstructionGap V8_FINAL : public LGap {
384 explicit LInstructionGap(HBasicBlock* block) : LGap(block) { }
386 virtual bool HasInterestingComment(LCodeGen* gen) const V8_OVERRIDE {
387 return !IsRedundant();
390 DECLARE_CONCRETE_INSTRUCTION(InstructionGap, "gap")
394 class LGoto V8_FINAL : public LTemplateInstruction<0, 0, 0> {
396 explicit LGoto(HBasicBlock* block) : block_(block) { }
398 virtual bool HasInterestingComment(LCodeGen* gen) const V8_OVERRIDE;
399 DECLARE_CONCRETE_INSTRUCTION(Goto, "goto")
400 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
401 virtual bool IsControl() const V8_OVERRIDE { return true; }
403 int block_id() const { return block_->block_id(); }
410 class LLazyBailout V8_FINAL : public LTemplateInstruction<0, 0, 0> {
412 LLazyBailout() : gap_instructions_size_(0) { }
414 DECLARE_CONCRETE_INSTRUCTION(LazyBailout, "lazy-bailout")
416 void set_gap_instructions_size(int gap_instructions_size) {
417 gap_instructions_size_ = gap_instructions_size;
419 int gap_instructions_size() { return gap_instructions_size_; }
422 int gap_instructions_size_;
426 class LDummy V8_FINAL : public LTemplateInstruction<1, 0, 0> {
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 virtual bool IsControl() const V8_OVERRIDE { return true; }
445 DECLARE_CONCRETE_INSTRUCTION(Deoptimize, "deoptimize")
446 DECLARE_HYDROGEN_ACCESSOR(Deoptimize)
450 class LLabel V8_FINAL : public LGap {
452 explicit LLabel(HBasicBlock* block)
453 : LGap(block), replacement_(NULL) { }
455 virtual bool HasInterestingComment(LCodeGen* gen) const V8_OVERRIDE {
458 DECLARE_CONCRETE_INSTRUCTION(Label, "label")
460 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
462 int block_id() const { return block()->block_id(); }
463 bool is_loop_header() const { return block()->IsLoopHeader(); }
464 bool is_osr_entry() const { return block()->is_osr_entry(); }
465 Label* label() { return &label_; }
466 LLabel* replacement() const { return replacement_; }
467 void set_replacement(LLabel* label) { replacement_ = label; }
468 bool HasReplacement() const { return replacement_ != NULL; }
472 LLabel* replacement_;
476 class LParameter V8_FINAL : public LTemplateInstruction<1, 0, 0> {
478 virtual bool HasInterestingComment(LCodeGen* gen) const V8_OVERRIDE {
481 DECLARE_CONCRETE_INSTRUCTION(Parameter, "parameter")
485 class LCallStub V8_FINAL : public LTemplateInstruction<1, 1, 0> {
487 explicit LCallStub(LOperand* context) {
488 inputs_[0] = context;
491 LOperand* context() { return inputs_[0]; }
493 DECLARE_CONCRETE_INSTRUCTION(CallStub, "call-stub")
494 DECLARE_HYDROGEN_ACCESSOR(CallStub)
498 class LUnknownOSRValue V8_FINAL : public LTemplateInstruction<1, 0, 0> {
500 virtual bool HasInterestingComment(LCodeGen* gen) const V8_OVERRIDE {
503 DECLARE_CONCRETE_INSTRUCTION(UnknownOSRValue, "unknown-osr-value")
507 template<int I, int T>
508 class LControlInstruction : public LTemplateInstruction<0, I, T> {
510 LControlInstruction() : false_label_(NULL), true_label_(NULL) { }
512 virtual bool IsControl() const V8_FINAL V8_OVERRIDE { return true; }
514 int SuccessorCount() { return hydrogen()->SuccessorCount(); }
515 HBasicBlock* SuccessorAt(int i) { return hydrogen()->SuccessorAt(i); }
517 int TrueDestination(LChunk* chunk) {
518 return chunk->LookupDestination(true_block_id());
520 int FalseDestination(LChunk* chunk) {
521 return chunk->LookupDestination(false_block_id());
524 Label* TrueLabel(LChunk* chunk) {
525 if (true_label_ == NULL) {
526 true_label_ = chunk->GetAssemblyLabel(TrueDestination(chunk));
530 Label* FalseLabel(LChunk* chunk) {
531 if (false_label_ == NULL) {
532 false_label_ = chunk->GetAssemblyLabel(FalseDestination(chunk));
538 int true_block_id() { return SuccessorAt(0)->block_id(); }
539 int false_block_id() { return SuccessorAt(1)->block_id(); }
542 HControlInstruction* hydrogen() {
543 return HControlInstruction::cast(this->hydrogen_value());
551 class LWrapReceiver V8_FINAL : public LTemplateInstruction<1, 2, 0> {
553 LWrapReceiver(LOperand* receiver, LOperand* function) {
554 inputs_[0] = receiver;
555 inputs_[1] = function;
558 LOperand* receiver() { return inputs_[0]; }
559 LOperand* function() { return inputs_[1]; }
561 DECLARE_CONCRETE_INSTRUCTION(WrapReceiver, "wrap-receiver")
562 DECLARE_HYDROGEN_ACCESSOR(WrapReceiver)
566 class LApplyArguments V8_FINAL : public LTemplateInstruction<1, 4, 0> {
568 LApplyArguments(LOperand* function,
571 LOperand* elements) {
572 inputs_[0] = function;
573 inputs_[1] = receiver;
575 inputs_[3] = elements;
578 LOperand* function() { return inputs_[0]; }
579 LOperand* receiver() { return inputs_[1]; }
580 LOperand* length() { return inputs_[2]; }
581 LOperand* elements() { return inputs_[3]; }
583 DECLARE_CONCRETE_INSTRUCTION(ApplyArguments, "apply-arguments")
587 class LAccessArgumentsAt V8_FINAL : public LTemplateInstruction<1, 3, 0> {
589 LAccessArgumentsAt(LOperand* arguments, LOperand* length, LOperand* index) {
590 inputs_[0] = arguments;
595 LOperand* arguments() { return inputs_[0]; }
596 LOperand* length() { return inputs_[1]; }
597 LOperand* index() { return inputs_[2]; }
599 DECLARE_CONCRETE_INSTRUCTION(AccessArgumentsAt, "access-arguments-at")
601 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
605 class LArgumentsLength V8_FINAL : public LTemplateInstruction<1, 1, 0> {
607 explicit LArgumentsLength(LOperand* elements) {
608 inputs_[0] = elements;
611 LOperand* elements() { return inputs_[0]; }
613 DECLARE_CONCRETE_INSTRUCTION(ArgumentsLength, "arguments-length")
617 class LArgumentsElements V8_FINAL : public LTemplateInstruction<1, 0, 0> {
619 DECLARE_CONCRETE_INSTRUCTION(ArgumentsElements, "arguments-elements")
620 DECLARE_HYDROGEN_ACCESSOR(ArgumentsElements)
624 class LModByPowerOf2I V8_FINAL : public LTemplateInstruction<1, 1, 0> {
626 LModByPowerOf2I(LOperand* dividend, int32_t divisor) {
627 inputs_[0] = dividend;
631 LOperand* dividend() { return inputs_[0]; }
632 int32_t divisor() const { return divisor_; }
634 DECLARE_CONCRETE_INSTRUCTION(ModByPowerOf2I, "mod-by-power-of-2-i")
635 DECLARE_HYDROGEN_ACCESSOR(Mod)
642 class LModByConstI V8_FINAL : public LTemplateInstruction<1, 1, 2> {
644 LModByConstI(LOperand* dividend,
648 inputs_[0] = dividend;
654 LOperand* dividend() { return inputs_[0]; }
655 int32_t divisor() const { return divisor_; }
656 LOperand* temp1() { return temps_[0]; }
657 LOperand* temp2() { return temps_[1]; }
659 DECLARE_CONCRETE_INSTRUCTION(ModByConstI, "mod-by-const-i")
660 DECLARE_HYDROGEN_ACCESSOR(Mod)
667 class LModI V8_FINAL : public LTemplateInstruction<1, 2, 1> {
669 LModI(LOperand* left, LOperand* right, LOperand* temp) {
675 LOperand* left() { return inputs_[0]; }
676 LOperand* right() { return inputs_[1]; }
677 LOperand* temp() { return temps_[0]; }
679 DECLARE_CONCRETE_INSTRUCTION(ModI, "mod-i")
680 DECLARE_HYDROGEN_ACCESSOR(Mod)
684 class LDivByPowerOf2I V8_FINAL : public LTemplateInstruction<1, 1, 0> {
686 LDivByPowerOf2I(LOperand* dividend, int32_t divisor) {
687 inputs_[0] = dividend;
691 LOperand* dividend() { return inputs_[0]; }
692 int32_t divisor() const { return divisor_; }
694 DECLARE_CONCRETE_INSTRUCTION(DivByPowerOf2I, "div-by-power-of-2-i")
695 DECLARE_HYDROGEN_ACCESSOR(Div)
702 class LDivByConstI V8_FINAL : public LTemplateInstruction<1, 1, 2> {
704 LDivByConstI(LOperand* dividend,
708 inputs_[0] = dividend;
714 LOperand* dividend() { return inputs_[0]; }
715 int32_t divisor() const { return divisor_; }
716 LOperand* temp1() { return temps_[0]; }
717 LOperand* temp2() { return temps_[1]; }
719 DECLARE_CONCRETE_INSTRUCTION(DivByConstI, "div-by-const-i")
720 DECLARE_HYDROGEN_ACCESSOR(Div)
727 class LDivI V8_FINAL : public LTemplateInstruction<1, 2, 1> {
729 LDivI(LOperand* dividend, LOperand* divisor, LOperand* temp) {
730 inputs_[0] = dividend;
731 inputs_[1] = divisor;
735 LOperand* dividend() { return inputs_[0]; }
736 LOperand* divisor() { return inputs_[1]; }
737 LOperand* temp() { return temps_[0]; }
739 DECLARE_CONCRETE_INSTRUCTION(DivI, "div-i")
740 DECLARE_HYDROGEN_ACCESSOR(BinaryOperation)
744 class LFlooringDivByPowerOf2I V8_FINAL : public LTemplateInstruction<1, 1, 0> {
746 LFlooringDivByPowerOf2I(LOperand* dividend, int32_t divisor) {
747 inputs_[0] = dividend;
751 LOperand* dividend() { return inputs_[0]; }
752 int32_t divisor() const { return divisor_; }
754 DECLARE_CONCRETE_INSTRUCTION(FlooringDivByPowerOf2I,
755 "flooring-div-by-power-of-2-i")
756 DECLARE_HYDROGEN_ACCESSOR(MathFloorOfDiv)
763 class LFlooringDivByConstI V8_FINAL : public LTemplateInstruction<1, 1, 3> {
765 LFlooringDivByConstI(LOperand* dividend,
770 inputs_[0] = dividend;
777 LOperand* dividend() { return inputs_[0]; }
778 int32_t divisor() const { return divisor_; }
779 LOperand* temp1() { return temps_[0]; }
780 LOperand* temp2() { return temps_[1]; }
781 LOperand* temp3() { return temps_[2]; }
783 DECLARE_CONCRETE_INSTRUCTION(FlooringDivByConstI, "flooring-div-by-const-i")
784 DECLARE_HYDROGEN_ACCESSOR(MathFloorOfDiv)
791 class LFlooringDivI V8_FINAL : public LTemplateInstruction<1, 2, 1> {
793 LFlooringDivI(LOperand* dividend, LOperand* divisor, LOperand* temp) {
794 inputs_[0] = dividend;
795 inputs_[1] = divisor;
799 LOperand* dividend() { return inputs_[0]; }
800 LOperand* divisor() { return inputs_[1]; }
801 LOperand* temp() { return temps_[0]; }
803 DECLARE_CONCRETE_INSTRUCTION(FlooringDivI, "flooring-div-i")
804 DECLARE_HYDROGEN_ACCESSOR(MathFloorOfDiv)
808 class LMulI V8_FINAL : public LTemplateInstruction<1, 2, 0> {
810 LMulI(LOperand* left, LOperand* right) {
815 LOperand* left() { return inputs_[0]; }
816 LOperand* right() { return inputs_[1]; }
818 DECLARE_CONCRETE_INSTRUCTION(MulI, "mul-i")
819 DECLARE_HYDROGEN_ACCESSOR(Mul)
823 class LCompareNumericAndBranch V8_FINAL : public LControlInstruction<2, 0> {
825 LCompareNumericAndBranch(LOperand* left, LOperand* right) {
830 LOperand* left() { return inputs_[0]; }
831 LOperand* right() { return inputs_[1]; }
833 DECLARE_CONCRETE_INSTRUCTION(CompareNumericAndBranch,
834 "compare-numeric-and-branch")
835 DECLARE_HYDROGEN_ACCESSOR(CompareNumericAndBranch)
837 Token::Value op() const { return hydrogen()->token(); }
838 bool is_double() const {
839 return hydrogen()->representation().IsDouble();
842 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
846 class LMathFloor V8_FINAL : public LTemplateInstruction<1, 1, 0> {
848 explicit LMathFloor(LOperand* value) {
852 LOperand* value() { return inputs_[0]; }
854 DECLARE_CONCRETE_INSTRUCTION(MathFloor, "math-floor")
855 DECLARE_HYDROGEN_ACCESSOR(UnaryMathOperation)
859 class LMathRound V8_FINAL : public LTemplateInstruction<1, 1, 1> {
861 LMathRound(LOperand* value, LOperand* temp) {
866 LOperand* value() { return inputs_[0]; }
867 LOperand* temp() { return temps_[0]; }
869 DECLARE_CONCRETE_INSTRUCTION(MathRound, "math-round")
870 DECLARE_HYDROGEN_ACCESSOR(UnaryMathOperation)
874 class LMathFround V8_FINAL : public LTemplateInstruction<1, 1, 0> {
876 explicit LMathFround(LOperand* value) { inputs_[0] = value; }
878 LOperand* value() { return inputs_[0]; }
880 DECLARE_CONCRETE_INSTRUCTION(MathFround, "math-fround")
884 class LMathAbs V8_FINAL : public LTemplateInstruction<1, 2, 0> {
886 explicit LMathAbs(LOperand* context, LOperand* value) {
887 inputs_[1] = context;
891 LOperand* context() { return inputs_[1]; }
892 LOperand* value() { return inputs_[0]; }
894 DECLARE_CONCRETE_INSTRUCTION(MathAbs, "math-abs")
895 DECLARE_HYDROGEN_ACCESSOR(UnaryMathOperation)
899 class LMathLog V8_FINAL : public LTemplateInstruction<1, 1, 0> {
901 explicit LMathLog(LOperand* value) {
905 LOperand* value() { return inputs_[0]; }
907 DECLARE_CONCRETE_INSTRUCTION(MathLog, "math-log")
911 class LMathClz32 V8_FINAL : public LTemplateInstruction<1, 1, 0> {
913 explicit LMathClz32(LOperand* value) {
917 LOperand* value() { return inputs_[0]; }
919 DECLARE_CONCRETE_INSTRUCTION(MathClz32, "math-clz32")
923 class LMathExp V8_FINAL : public LTemplateInstruction<1, 1, 2> {
925 LMathExp(LOperand* value, LOperand* temp1, LOperand* temp2) {
929 ExternalReference::InitializeMathExpData();
932 LOperand* value() { return inputs_[0]; }
933 LOperand* temp1() { return temps_[0]; }
934 LOperand* temp2() { return temps_[1]; }
936 DECLARE_CONCRETE_INSTRUCTION(MathExp, "math-exp")
940 class LMathSqrt V8_FINAL : public LTemplateInstruction<1, 1, 0> {
942 explicit LMathSqrt(LOperand* value) {
946 LOperand* value() { return inputs_[0]; }
948 DECLARE_CONCRETE_INSTRUCTION(MathSqrt, "math-sqrt")
952 class LMathPowHalf V8_FINAL : public LTemplateInstruction<1, 1, 0> {
954 explicit LMathPowHalf(LOperand* value) {
958 LOperand* value() { return inputs_[0]; }
960 DECLARE_CONCRETE_INSTRUCTION(MathPowHalf, "math-pow-half")
964 class LNullarySIMDOperation V8_FINAL : public LTemplateInstruction<1, 0, 0> {
966 explicit LNullarySIMDOperation(BuiltinFunctionId op)
970 BuiltinFunctionId op() const { return op_; }
972 virtual Opcode opcode() const V8_OVERRIDE {
973 return LInstruction::kNullarySIMDOperation;
975 virtual void CompileToNative(LCodeGen* generator) V8_OVERRIDE;
976 virtual const char* Mnemonic() const V8_OVERRIDE;
977 static LNullarySIMDOperation* cast(LInstruction* instr) {
978 DCHECK(instr->IsNullarySIMDOperation());
979 return reinterpret_cast<LNullarySIMDOperation*>(instr);
982 DECLARE_HYDROGEN_ACCESSOR(NullarySIMDOperation)
985 BuiltinFunctionId op_;
989 class LUnarySIMDOperation V8_FINAL : public LTemplateInstruction<1, 1, 0> {
991 LUnarySIMDOperation(LOperand* value, BuiltinFunctionId op)
996 LOperand* value() { return inputs_[0]; }
997 BuiltinFunctionId op() const { return op_; }
999 virtual Opcode opcode() const V8_OVERRIDE {
1000 return LInstruction::kUnarySIMDOperation;
1002 virtual void CompileToNative(LCodeGen* generator) V8_OVERRIDE;
1003 virtual const char* Mnemonic() const V8_OVERRIDE;
1004 static LUnarySIMDOperation* cast(LInstruction* instr) {
1005 DCHECK(instr->IsUnarySIMDOperation());
1006 return reinterpret_cast<LUnarySIMDOperation*>(instr);
1009 DECLARE_HYDROGEN_ACCESSOR(UnarySIMDOperation)
1012 BuiltinFunctionId op_;
1016 class LBinarySIMDOperation V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1018 LBinarySIMDOperation(LOperand* left, LOperand* right, BuiltinFunctionId op)
1024 LOperand* left() { return inputs_[0]; }
1025 LOperand* right() { return inputs_[1]; }
1026 BuiltinFunctionId op() const { return op_; }
1028 virtual Opcode opcode() const V8_OVERRIDE {
1029 return LInstruction::kBinarySIMDOperation;
1031 virtual void CompileToNative(LCodeGen* generator) V8_OVERRIDE;
1032 virtual const char* Mnemonic() const V8_OVERRIDE;
1033 static LBinarySIMDOperation* cast(LInstruction* instr) {
1034 DCHECK(instr->IsBinarySIMDOperation());
1035 return reinterpret_cast<LBinarySIMDOperation*>(instr);
1038 DECLARE_HYDROGEN_ACCESSOR(BinarySIMDOperation)
1041 BuiltinFunctionId op_;
1045 class LTernarySIMDOperation V8_FINAL : public LTemplateInstruction<1, 3, 0> {
1047 LTernarySIMDOperation(LOperand* first, LOperand* second, LOperand* third,
1048 BuiltinFunctionId op)
1051 inputs_[1] = second;
1055 LOperand* first() { return inputs_[0]; }
1056 LOperand* second() { return inputs_[1]; }
1057 LOperand* third() { return inputs_[2]; }
1058 BuiltinFunctionId op() const { return op_; }
1060 virtual Opcode opcode() const V8_OVERRIDE {
1061 return LInstruction::kTernarySIMDOperation;
1063 virtual void CompileToNative(LCodeGen* generator) V8_OVERRIDE;
1064 virtual const char* Mnemonic() const V8_OVERRIDE;
1065 static LTernarySIMDOperation* cast(LInstruction* instr) {
1066 DCHECK(instr->IsTernarySIMDOperation());
1067 return reinterpret_cast<LTernarySIMDOperation*>(instr);
1070 DECLARE_HYDROGEN_ACCESSOR(TernarySIMDOperation)
1073 BuiltinFunctionId op_;
1077 class LQuarternarySIMDOperation V8_FINAL
1078 : public LTemplateInstruction<1, 4, 0> {
1080 LQuarternarySIMDOperation(LOperand* x, LOperand* y, LOperand* z,
1081 LOperand* w, BuiltinFunctionId op)
1089 LOperand* x() { return inputs_[0]; }
1090 LOperand* y() { return inputs_[1]; }
1091 LOperand* z() { return inputs_[2]; }
1092 LOperand* w() { return inputs_[3]; }
1093 BuiltinFunctionId op() const { return op_; }
1095 virtual Opcode opcode() const V8_OVERRIDE {
1096 return LInstruction::kQuarternarySIMDOperation;
1098 virtual void CompileToNative(LCodeGen* generator) V8_OVERRIDE;
1099 virtual const char* Mnemonic() const V8_OVERRIDE;
1100 static LQuarternarySIMDOperation* cast(LInstruction* instr) {
1101 DCHECK(instr->IsQuarternarySIMDOperation());
1102 return reinterpret_cast<LQuarternarySIMDOperation*>(instr);
1105 DECLARE_HYDROGEN_ACCESSOR(QuarternarySIMDOperation)
1108 BuiltinFunctionId op_;
1112 class LCmpObjectEqAndBranch V8_FINAL : public LControlInstruction<2, 0> {
1114 LCmpObjectEqAndBranch(LOperand* left, LOperand* right) {
1119 LOperand* left() { return inputs_[0]; }
1120 LOperand* right() { return inputs_[1]; }
1122 DECLARE_CONCRETE_INSTRUCTION(CmpObjectEqAndBranch, "cmp-object-eq-and-branch")
1126 class LCmpHoleAndBranch V8_FINAL : public LControlInstruction<1, 0> {
1128 explicit LCmpHoleAndBranch(LOperand* object) {
1129 inputs_[0] = object;
1132 LOperand* object() { return inputs_[0]; }
1134 DECLARE_CONCRETE_INSTRUCTION(CmpHoleAndBranch, "cmp-hole-and-branch")
1135 DECLARE_HYDROGEN_ACCESSOR(CompareHoleAndBranch)
1139 class LCompareMinusZeroAndBranch V8_FINAL : public LControlInstruction<1, 0> {
1141 explicit LCompareMinusZeroAndBranch(LOperand* value) {
1145 LOperand* value() { return inputs_[0]; }
1147 DECLARE_CONCRETE_INSTRUCTION(CompareMinusZeroAndBranch,
1148 "cmp-minus-zero-and-branch")
1149 DECLARE_HYDROGEN_ACCESSOR(CompareMinusZeroAndBranch)
1154 class LIsObjectAndBranch V8_FINAL : public LControlInstruction<1, 0> {
1156 explicit LIsObjectAndBranch(LOperand* value) {
1160 LOperand* value() { return inputs_[0]; }
1162 DECLARE_CONCRETE_INSTRUCTION(IsObjectAndBranch, "is-object-and-branch")
1163 DECLARE_HYDROGEN_ACCESSOR(IsObjectAndBranch)
1165 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1169 class LIsStringAndBranch V8_FINAL : public LControlInstruction<1, 1> {
1171 explicit LIsStringAndBranch(LOperand* value, LOperand* temp) {
1176 LOperand* value() { return inputs_[0]; }
1177 LOperand* temp() { return temps_[0]; }
1179 DECLARE_CONCRETE_INSTRUCTION(IsStringAndBranch, "is-string-and-branch")
1180 DECLARE_HYDROGEN_ACCESSOR(IsStringAndBranch)
1182 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1186 class LIsSmiAndBranch V8_FINAL : public LControlInstruction<1, 0> {
1188 explicit LIsSmiAndBranch(LOperand* value) {
1192 LOperand* value() { return inputs_[0]; }
1194 DECLARE_CONCRETE_INSTRUCTION(IsSmiAndBranch, "is-smi-and-branch")
1195 DECLARE_HYDROGEN_ACCESSOR(IsSmiAndBranch)
1197 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1201 class LIsUndetectableAndBranch V8_FINAL : public LControlInstruction<1, 1> {
1203 explicit LIsUndetectableAndBranch(LOperand* value, LOperand* temp) {
1208 LOperand* value() { return inputs_[0]; }
1209 LOperand* temp() { return temps_[0]; }
1211 DECLARE_CONCRETE_INSTRUCTION(IsUndetectableAndBranch,
1212 "is-undetectable-and-branch")
1213 DECLARE_HYDROGEN_ACCESSOR(IsUndetectableAndBranch)
1215 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1219 class LStringCompareAndBranch V8_FINAL : public LControlInstruction<3, 0> {
1221 explicit LStringCompareAndBranch(LOperand* context,
1224 inputs_[0] = context;
1229 LOperand* context() { return inputs_[0]; }
1230 LOperand* left() { return inputs_[1]; }
1231 LOperand* right() { return inputs_[2]; }
1233 DECLARE_CONCRETE_INSTRUCTION(StringCompareAndBranch,
1234 "string-compare-and-branch")
1235 DECLARE_HYDROGEN_ACCESSOR(StringCompareAndBranch)
1237 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1239 Token::Value op() const { return hydrogen()->token(); }
1243 class LHasInstanceTypeAndBranch V8_FINAL : public LControlInstruction<1, 0> {
1245 explicit LHasInstanceTypeAndBranch(LOperand* value) {
1249 LOperand* value() { return inputs_[0]; }
1251 DECLARE_CONCRETE_INSTRUCTION(HasInstanceTypeAndBranch,
1252 "has-instance-type-and-branch")
1253 DECLARE_HYDROGEN_ACCESSOR(HasInstanceTypeAndBranch)
1255 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1259 class LGetCachedArrayIndex V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1261 explicit LGetCachedArrayIndex(LOperand* value) {
1265 LOperand* value() { return inputs_[0]; }
1267 DECLARE_CONCRETE_INSTRUCTION(GetCachedArrayIndex, "get-cached-array-index")
1268 DECLARE_HYDROGEN_ACCESSOR(GetCachedArrayIndex)
1272 class LHasCachedArrayIndexAndBranch V8_FINAL
1273 : public LControlInstruction<1, 0> {
1275 explicit LHasCachedArrayIndexAndBranch(LOperand* value) {
1279 LOperand* value() { return inputs_[0]; }
1281 DECLARE_CONCRETE_INSTRUCTION(HasCachedArrayIndexAndBranch,
1282 "has-cached-array-index-and-branch")
1283 DECLARE_HYDROGEN_ACCESSOR(HasCachedArrayIndexAndBranch)
1285 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1289 class LClassOfTestAndBranch V8_FINAL : public LControlInstruction<1, 2> {
1291 LClassOfTestAndBranch(LOperand* value, LOperand* temp, LOperand* temp2) {
1297 LOperand* value() { return inputs_[0]; }
1298 LOperand* temp() { return temps_[0]; }
1299 LOperand* temp2() { return temps_[1]; }
1301 DECLARE_CONCRETE_INSTRUCTION(ClassOfTestAndBranch,
1302 "class-of-test-and-branch")
1303 DECLARE_HYDROGEN_ACCESSOR(ClassOfTestAndBranch)
1305 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1309 class LCmpT V8_FINAL : public LTemplateInstruction<1, 3, 0> {
1311 LCmpT(LOperand* context, LOperand* left, LOperand* right) {
1312 inputs_[0] = context;
1317 LOperand* context() { return inputs_[0]; }
1318 LOperand* left() { return inputs_[1]; }
1319 LOperand* right() { return inputs_[2]; }
1321 DECLARE_CONCRETE_INSTRUCTION(CmpT, "cmp-t")
1322 DECLARE_HYDROGEN_ACCESSOR(CompareGeneric)
1324 Token::Value op() const { return hydrogen()->token(); }
1328 class LInstanceOf V8_FINAL : public LTemplateInstruction<1, 3, 0> {
1330 LInstanceOf(LOperand* context, LOperand* left, LOperand* right) {
1331 inputs_[0] = context;
1336 LOperand* context() { return inputs_[0]; }
1337 LOperand* left() { return inputs_[1]; }
1338 LOperand* right() { return inputs_[2]; }
1340 DECLARE_CONCRETE_INSTRUCTION(InstanceOf, "instance-of")
1344 class LInstanceOfKnownGlobal V8_FINAL : public LTemplateInstruction<1, 2, 1> {
1346 LInstanceOfKnownGlobal(LOperand* context, LOperand* value, LOperand* temp) {
1347 inputs_[0] = context;
1352 LOperand* context() { return inputs_[0]; }
1353 LOperand* value() { return inputs_[1]; }
1354 LOperand* temp() { return temps_[0]; }
1356 DECLARE_CONCRETE_INSTRUCTION(InstanceOfKnownGlobal,
1357 "instance-of-known-global")
1358 DECLARE_HYDROGEN_ACCESSOR(InstanceOfKnownGlobal)
1360 Handle<JSFunction> function() const { return hydrogen()->function(); }
1361 LEnvironment* GetDeferredLazyDeoptimizationEnvironment() {
1362 return lazy_deopt_env_;
1364 virtual void SetDeferredLazyDeoptimizationEnvironment(
1365 LEnvironment* env) V8_OVERRIDE {
1366 lazy_deopt_env_ = env;
1370 LEnvironment* lazy_deopt_env_;
1374 class LBoundsCheck V8_FINAL : public LTemplateInstruction<0, 2, 0> {
1376 LBoundsCheck(LOperand* index, LOperand* length) {
1378 inputs_[1] = length;
1381 LOperand* index() { return inputs_[0]; }
1382 LOperand* length() { return inputs_[1]; }
1384 DECLARE_CONCRETE_INSTRUCTION(BoundsCheck, "bounds-check")
1385 DECLARE_HYDROGEN_ACCESSOR(BoundsCheck)
1389 class LBitI V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1391 LBitI(LOperand* left, LOperand* right) {
1396 LOperand* left() { return inputs_[0]; }
1397 LOperand* right() { return inputs_[1]; }
1399 Token::Value op() const { return hydrogen()->op(); }
1400 bool IsInteger32() const {
1401 return hydrogen()->representation().IsInteger32();
1404 DECLARE_CONCRETE_INSTRUCTION(BitI, "bit-i")
1405 DECLARE_HYDROGEN_ACCESSOR(Bitwise)
1409 class LShiftI V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1411 LShiftI(Token::Value op, LOperand* left, LOperand* right, bool can_deopt)
1412 : op_(op), can_deopt_(can_deopt) {
1417 Token::Value op() const { return op_; }
1418 LOperand* left() { return inputs_[0]; }
1419 LOperand* right() { return inputs_[1]; }
1420 bool can_deopt() const { return can_deopt_; }
1422 DECLARE_CONCRETE_INSTRUCTION(ShiftI, "shift-i")
1430 class LSubI V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1432 LSubI(LOperand* left, LOperand* right) {
1437 LOperand* left() { return inputs_[0]; }
1438 LOperand* right() { return inputs_[1]; }
1440 DECLARE_CONCRETE_INSTRUCTION(SubI, "sub-i")
1441 DECLARE_HYDROGEN_ACCESSOR(Sub)
1445 class LConstantI V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1447 DECLARE_CONCRETE_INSTRUCTION(ConstantI, "constant-i")
1448 DECLARE_HYDROGEN_ACCESSOR(Constant)
1450 int32_t value() const { return hydrogen()->Integer32Value(); }
1454 class LConstantS V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1456 DECLARE_CONCRETE_INSTRUCTION(ConstantS, "constant-s")
1457 DECLARE_HYDROGEN_ACCESSOR(Constant)
1459 Smi* value() const { return Smi::FromInt(hydrogen()->Integer32Value()); }
1463 class LConstantD V8_FINAL : public LTemplateInstruction<1, 0, 1> {
1465 explicit LConstantD(LOperand* temp) {
1469 LOperand* temp() { return temps_[0]; }
1471 DECLARE_CONCRETE_INSTRUCTION(ConstantD, "constant-d")
1472 DECLARE_HYDROGEN_ACCESSOR(Constant)
1474 double value() const { return hydrogen()->DoubleValue(); }
1478 class LConstantE V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1480 DECLARE_CONCRETE_INSTRUCTION(ConstantE, "constant-e")
1481 DECLARE_HYDROGEN_ACCESSOR(Constant)
1483 ExternalReference value() const {
1484 return hydrogen()->ExternalReferenceValue();
1489 class LConstantT V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1491 DECLARE_CONCRETE_INSTRUCTION(ConstantT, "constant-t")
1492 DECLARE_HYDROGEN_ACCESSOR(Constant)
1494 Handle<Object> value(Isolate* isolate) const {
1495 return hydrogen()->handle(isolate);
1500 class LBranch V8_FINAL : public LControlInstruction<1, 0> {
1502 explicit LBranch(LOperand* value) {
1506 LOperand* value() { return inputs_[0]; }
1508 DECLARE_CONCRETE_INSTRUCTION(Branch, "branch")
1509 DECLARE_HYDROGEN_ACCESSOR(Branch)
1511 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1515 class LDebugBreak V8_FINAL : public LTemplateInstruction<0, 0, 0> {
1517 DECLARE_CONCRETE_INSTRUCTION(DebugBreak, "break")
1521 class LCmpMapAndBranch V8_FINAL : public LControlInstruction<1, 0> {
1523 explicit LCmpMapAndBranch(LOperand* value) {
1527 LOperand* value() { return inputs_[0]; }
1529 DECLARE_CONCRETE_INSTRUCTION(CmpMapAndBranch, "cmp-map-and-branch")
1530 DECLARE_HYDROGEN_ACCESSOR(CompareMap)
1532 Handle<Map> map() const { return hydrogen()->map().handle(); }
1536 class LMapEnumLength V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1538 explicit LMapEnumLength(LOperand* value) {
1542 LOperand* value() { return inputs_[0]; }
1544 DECLARE_CONCRETE_INSTRUCTION(MapEnumLength, "map-enum-length")
1548 class LDateField V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1550 LDateField(LOperand* date, Smi* index) : index_(index) {
1554 LOperand* date() { return inputs_[0]; }
1555 Smi* index() const { return index_; }
1557 DECLARE_CONCRETE_INSTRUCTION(DateField, "date-field")
1558 DECLARE_HYDROGEN_ACCESSOR(DateField)
1565 class LSeqStringGetChar V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1567 LSeqStringGetChar(LOperand* string, LOperand* index) {
1568 inputs_[0] = string;
1572 LOperand* string() const { return inputs_[0]; }
1573 LOperand* index() const { return inputs_[1]; }
1575 DECLARE_CONCRETE_INSTRUCTION(SeqStringGetChar, "seq-string-get-char")
1576 DECLARE_HYDROGEN_ACCESSOR(SeqStringGetChar)
1580 class LSeqStringSetChar V8_FINAL : public LTemplateInstruction<1, 4, 0> {
1582 LSeqStringSetChar(LOperand* context,
1586 inputs_[0] = context;
1587 inputs_[1] = string;
1592 LOperand* string() { return inputs_[1]; }
1593 LOperand* index() { return inputs_[2]; }
1594 LOperand* value() { return inputs_[3]; }
1596 DECLARE_CONCRETE_INSTRUCTION(SeqStringSetChar, "seq-string-set-char")
1597 DECLARE_HYDROGEN_ACCESSOR(SeqStringSetChar)
1601 class LAddI V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1603 LAddI(LOperand* left, LOperand* right) {
1608 LOperand* left() { return inputs_[0]; }
1609 LOperand* right() { return inputs_[1]; }
1611 static bool UseLea(HAdd* add) {
1612 return !add->CheckFlag(HValue::kCanOverflow) &&
1613 add->BetterLeftOperand()->UseCount() > 1;
1616 DECLARE_CONCRETE_INSTRUCTION(AddI, "add-i")
1617 DECLARE_HYDROGEN_ACCESSOR(Add)
1621 class LMathMinMax V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1623 LMathMinMax(LOperand* left, LOperand* right) {
1628 LOperand* left() { return inputs_[0]; }
1629 LOperand* right() { return inputs_[1]; }
1631 DECLARE_CONCRETE_INSTRUCTION(MathMinMax, "math-min-max")
1632 DECLARE_HYDROGEN_ACCESSOR(MathMinMax)
1636 class LPower V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1638 LPower(LOperand* left, LOperand* right) {
1643 LOperand* left() { return inputs_[0]; }
1644 LOperand* right() { return inputs_[1]; }
1646 DECLARE_CONCRETE_INSTRUCTION(Power, "power")
1647 DECLARE_HYDROGEN_ACCESSOR(Power)
1651 class LArithmeticD V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1653 LArithmeticD(Token::Value op, LOperand* left, LOperand* right)
1659 Token::Value op() const { return op_; }
1660 LOperand* left() { return inputs_[0]; }
1661 LOperand* right() { return inputs_[1]; }
1663 virtual Opcode opcode() const V8_OVERRIDE {
1664 return LInstruction::kArithmeticD;
1666 virtual void CompileToNative(LCodeGen* generator) V8_OVERRIDE;
1667 virtual const char* Mnemonic() const V8_OVERRIDE;
1674 class LArithmeticT V8_FINAL : public LTemplateInstruction<1, 3, 0> {
1676 LArithmeticT(Token::Value op,
1681 inputs_[0] = context;
1686 Token::Value op() const { return op_; }
1687 LOperand* context() { return inputs_[0]; }
1688 LOperand* left() { return inputs_[1]; }
1689 LOperand* right() { return inputs_[2]; }
1691 virtual Opcode opcode() const V8_OVERRIDE {
1692 return LInstruction::kArithmeticT;
1694 virtual void CompileToNative(LCodeGen* generator) V8_OVERRIDE;
1695 virtual const char* Mnemonic() const V8_OVERRIDE;
1702 class LReturn V8_FINAL : public LTemplateInstruction<0, 3, 0> {
1704 explicit LReturn(LOperand* value,
1706 LOperand* parameter_count) {
1708 inputs_[1] = context;
1709 inputs_[2] = parameter_count;
1712 LOperand* value() { return inputs_[0]; }
1713 LOperand* context() { return inputs_[1]; }
1715 bool has_constant_parameter_count() {
1716 return parameter_count()->IsConstantOperand();
1718 LConstantOperand* constant_parameter_count() {
1719 DCHECK(has_constant_parameter_count());
1720 return LConstantOperand::cast(parameter_count());
1722 LOperand* parameter_count() { return inputs_[2]; }
1724 DECLARE_CONCRETE_INSTRUCTION(Return, "return")
1725 DECLARE_HYDROGEN_ACCESSOR(Return)
1729 class LLoadNamedField V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1731 explicit LLoadNamedField(LOperand* object) {
1732 inputs_[0] = object;
1735 LOperand* object() { return inputs_[0]; }
1737 DECLARE_CONCRETE_INSTRUCTION(LoadNamedField, "load-named-field")
1738 DECLARE_HYDROGEN_ACCESSOR(LoadNamedField)
1742 class LLoadNamedGeneric V8_FINAL : public LTemplateInstruction<1, 2, 1> {
1744 explicit LLoadNamedGeneric(LOperand* context, LOperand* object,
1746 inputs_[0] = context;
1747 inputs_[1] = object;
1751 DECLARE_CONCRETE_INSTRUCTION(LoadNamedGeneric, "load-named-generic")
1752 DECLARE_HYDROGEN_ACCESSOR(LoadNamedGeneric)
1754 LOperand* context() { return inputs_[0]; }
1755 LOperand* object() { return inputs_[1]; }
1756 LOperand* temp_vector() { return temps_[0]; }
1758 Handle<Object> name() const { return hydrogen()->name(); }
1762 class LLoadFunctionPrototype V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1764 explicit LLoadFunctionPrototype(LOperand* function) {
1765 inputs_[0] = function;
1768 DECLARE_CONCRETE_INSTRUCTION(LoadFunctionPrototype, "load-function-prototype")
1769 DECLARE_HYDROGEN_ACCESSOR(LoadFunctionPrototype)
1771 LOperand* function() { return inputs_[0]; }
1775 class LLoadRoot V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1777 DECLARE_CONCRETE_INSTRUCTION(LoadRoot, "load-root")
1778 DECLARE_HYDROGEN_ACCESSOR(LoadRoot)
1780 Heap::RootListIndex index() const { return hydrogen()->index(); }
1784 inline static bool ExternalArrayOpRequiresPreScale(
1785 Representation key_representation,
1786 ElementsKind kind) {
1787 int shift_size = ElementsKindToShiftSize(kind);
1788 return SmiValuesAre31Bits() && key_representation.IsSmi()
1789 ? shift_size > static_cast<int>(maximal_scale_factor) + kSmiTagSize
1790 : shift_size > static_cast<int>(maximal_scale_factor);
1794 inline static bool ExternalArrayOpRequiresTemp(
1795 Representation key_representation,
1796 ElementsKind elements_kind) {
1797 // Operations that require the key to be divided by two to be converted into
1798 // an index cannot fold the scale operation into a load and need an extra
1799 // temp register to do the work.
1800 return ExternalArrayOpRequiresPreScale(key_representation, elements_kind) ||
1801 (SmiValuesAre31Bits() && key_representation.IsSmi() &&
1802 (elements_kind == EXTERNAL_INT8_ELEMENTS ||
1803 elements_kind == EXTERNAL_UINT8_ELEMENTS ||
1804 elements_kind == EXTERNAL_UINT8_CLAMPED_ELEMENTS ||
1805 elements_kind == UINT8_ELEMENTS ||
1806 elements_kind == INT8_ELEMENTS ||
1807 elements_kind == UINT8_CLAMPED_ELEMENTS));
1811 class LLoadKeyed V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1813 LLoadKeyed(LOperand* elements, LOperand* key) {
1814 inputs_[0] = elements;
1818 DECLARE_CONCRETE_INSTRUCTION(LoadKeyed, "load-keyed")
1819 DECLARE_HYDROGEN_ACCESSOR(LoadKeyed)
1821 bool is_external() const {
1822 return hydrogen()->is_external();
1824 bool is_fixed_typed_array() const {
1825 return hydrogen()->is_fixed_typed_array();
1827 bool is_typed_elements() const {
1828 return is_external() || is_fixed_typed_array();
1830 LOperand* elements() { return inputs_[0]; }
1831 LOperand* key() { return inputs_[1]; }
1832 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1833 uint32_t base_offset() const { return hydrogen()->base_offset(); }
1834 ElementsKind elements_kind() const {
1835 return hydrogen()->elements_kind();
1840 class LLoadKeyedGeneric V8_FINAL : public LTemplateInstruction<1, 3, 1> {
1842 LLoadKeyedGeneric(LOperand* context, LOperand* obj, LOperand* key,
1844 inputs_[0] = context;
1850 DECLARE_CONCRETE_INSTRUCTION(LoadKeyedGeneric, "load-keyed-generic")
1851 DECLARE_HYDROGEN_ACCESSOR(LoadKeyedGeneric)
1853 LOperand* context() { return inputs_[0]; }
1854 LOperand* object() { return inputs_[1]; }
1855 LOperand* key() { return inputs_[2]; }
1856 LOperand* temp_vector() { return temps_[0]; }
1860 class LLoadGlobalCell V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1862 DECLARE_CONCRETE_INSTRUCTION(LoadGlobalCell, "load-global-cell")
1863 DECLARE_HYDROGEN_ACCESSOR(LoadGlobalCell)
1867 class LLoadGlobalGeneric V8_FINAL : public LTemplateInstruction<1, 2, 1> {
1869 explicit LLoadGlobalGeneric(LOperand* context, LOperand* global_object,
1871 inputs_[0] = context;
1872 inputs_[1] = global_object;
1876 DECLARE_CONCRETE_INSTRUCTION(LoadGlobalGeneric, "load-global-generic")
1877 DECLARE_HYDROGEN_ACCESSOR(LoadGlobalGeneric)
1879 LOperand* context() { return inputs_[0]; }
1880 LOperand* global_object() { return inputs_[1]; }
1881 LOperand* temp_vector() { return temps_[0]; }
1883 Handle<Object> name() const { return hydrogen()->name(); }
1884 bool for_typeof() const { return hydrogen()->for_typeof(); }
1888 class LStoreGlobalCell V8_FINAL : public LTemplateInstruction<0, 1, 1> {
1890 explicit LStoreGlobalCell(LOperand* value, LOperand* temp) {
1895 LOperand* value() { return inputs_[0]; }
1896 LOperand* temp() { return temps_[0]; }
1898 DECLARE_CONCRETE_INSTRUCTION(StoreGlobalCell, "store-global-cell")
1899 DECLARE_HYDROGEN_ACCESSOR(StoreGlobalCell)
1903 class LLoadContextSlot V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1905 explicit LLoadContextSlot(LOperand* context) {
1906 inputs_[0] = context;
1909 LOperand* context() { return inputs_[0]; }
1911 DECLARE_CONCRETE_INSTRUCTION(LoadContextSlot, "load-context-slot")
1912 DECLARE_HYDROGEN_ACCESSOR(LoadContextSlot)
1914 int slot_index() { return hydrogen()->slot_index(); }
1916 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1920 class LStoreContextSlot V8_FINAL : public LTemplateInstruction<0, 2, 1> {
1922 LStoreContextSlot(LOperand* context, LOperand* value, LOperand* temp) {
1923 inputs_[0] = context;
1928 LOperand* context() { return inputs_[0]; }
1929 LOperand* value() { return inputs_[1]; }
1930 LOperand* temp() { return temps_[0]; }
1932 DECLARE_CONCRETE_INSTRUCTION(StoreContextSlot, "store-context-slot")
1933 DECLARE_HYDROGEN_ACCESSOR(StoreContextSlot)
1935 int slot_index() { return hydrogen()->slot_index(); }
1937 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1941 class LPushArgument V8_FINAL : public LTemplateInstruction<0, 1, 0> {
1943 explicit LPushArgument(LOperand* value) {
1947 LOperand* value() { return inputs_[0]; }
1949 DECLARE_CONCRETE_INSTRUCTION(PushArgument, "push-argument")
1953 class LDrop V8_FINAL : public LTemplateInstruction<0, 0, 0> {
1955 explicit LDrop(int count) : count_(count) { }
1957 int count() const { return count_; }
1959 DECLARE_CONCRETE_INSTRUCTION(Drop, "drop")
1966 class LStoreCodeEntry V8_FINAL: public LTemplateInstruction<0, 2, 0> {
1968 LStoreCodeEntry(LOperand* function, LOperand* code_object) {
1969 inputs_[0] = function;
1970 inputs_[1] = code_object;
1973 LOperand* function() { return inputs_[0]; }
1974 LOperand* code_object() { return inputs_[1]; }
1976 virtual void PrintDataTo(StringStream* stream);
1978 DECLARE_CONCRETE_INSTRUCTION(StoreCodeEntry, "store-code-entry")
1979 DECLARE_HYDROGEN_ACCESSOR(StoreCodeEntry)
1983 class LInnerAllocatedObject V8_FINAL: public LTemplateInstruction<1, 2, 0> {
1985 LInnerAllocatedObject(LOperand* base_object, LOperand* offset) {
1986 inputs_[0] = base_object;
1987 inputs_[1] = offset;
1990 LOperand* base_object() const { return inputs_[0]; }
1991 LOperand* offset() const { return inputs_[1]; }
1993 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1995 DECLARE_CONCRETE_INSTRUCTION(InnerAllocatedObject, "inner-allocated-object")
1999 class LThisFunction V8_FINAL : public LTemplateInstruction<1, 0, 0> {
2001 DECLARE_CONCRETE_INSTRUCTION(ThisFunction, "this-function")
2002 DECLARE_HYDROGEN_ACCESSOR(ThisFunction)
2006 class LContext V8_FINAL : public LTemplateInstruction<1, 0, 0> {
2008 DECLARE_CONCRETE_INSTRUCTION(Context, "context")
2009 DECLARE_HYDROGEN_ACCESSOR(Context)
2013 class LDeclareGlobals V8_FINAL : public LTemplateInstruction<0, 1, 0> {
2015 explicit LDeclareGlobals(LOperand* context) {
2016 inputs_[0] = context;
2019 LOperand* context() { return inputs_[0]; }
2021 DECLARE_CONCRETE_INSTRUCTION(DeclareGlobals, "declare-globals")
2022 DECLARE_HYDROGEN_ACCESSOR(DeclareGlobals)
2026 class LCallJSFunction V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2028 explicit LCallJSFunction(LOperand* function) {
2029 inputs_[0] = function;
2032 LOperand* function() { return inputs_[0]; }
2034 DECLARE_CONCRETE_INSTRUCTION(CallJSFunction, "call-js-function")
2035 DECLARE_HYDROGEN_ACCESSOR(CallJSFunction)
2037 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
2039 int arity() const { return hydrogen()->argument_count() - 1; }
2043 class LCallWithDescriptor V8_FINAL : public LTemplateResultInstruction<1> {
2045 LCallWithDescriptor(const InterfaceDescriptor* descriptor,
2046 const ZoneList<LOperand*>& operands,
2048 : inputs_(descriptor->GetRegisterParameterCount() + 1, zone) {
2049 DCHECK(descriptor->GetRegisterParameterCount() + 1 == operands.length());
2050 inputs_.AddAll(operands, zone);
2053 LOperand* target() const { return inputs_[0]; }
2056 DECLARE_CONCRETE_INSTRUCTION(CallWithDescriptor, "call-with-descriptor")
2057 DECLARE_HYDROGEN_ACCESSOR(CallWithDescriptor)
2059 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
2061 int arity() const { return hydrogen()->argument_count() - 1; }
2063 ZoneList<LOperand*> inputs_;
2065 // Iterator support.
2066 virtual int InputCount() V8_FINAL V8_OVERRIDE { return inputs_.length(); }
2067 virtual LOperand* InputAt(int i) V8_FINAL V8_OVERRIDE { return inputs_[i]; }
2069 virtual int TempCount() V8_FINAL V8_OVERRIDE { return 0; }
2070 virtual LOperand* TempAt(int i) V8_FINAL V8_OVERRIDE { return NULL; }
2074 class LInvokeFunction V8_FINAL : public LTemplateInstruction<1, 2, 0> {
2076 LInvokeFunction(LOperand* context, LOperand* function) {
2077 inputs_[0] = context;
2078 inputs_[1] = function;
2081 LOperand* context() { return inputs_[0]; }
2082 LOperand* function() { return inputs_[1]; }
2084 DECLARE_CONCRETE_INSTRUCTION(InvokeFunction, "invoke-function")
2085 DECLARE_HYDROGEN_ACCESSOR(InvokeFunction)
2087 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
2089 int arity() const { return hydrogen()->argument_count() - 1; }
2093 class LCallFunction V8_FINAL : public LTemplateInstruction<1, 2, 0> {
2095 LCallFunction(LOperand* context, LOperand* function) {
2096 inputs_[0] = context;
2097 inputs_[1] = function;
2100 DECLARE_CONCRETE_INSTRUCTION(CallFunction, "call-function")
2101 DECLARE_HYDROGEN_ACCESSOR(CallFunction)
2103 LOperand* context() { return inputs_[0]; }
2104 LOperand* function() { return inputs_[1]; }
2105 int arity() const { return hydrogen()->argument_count() - 1; }
2109 class LCallNew V8_FINAL : public LTemplateInstruction<1, 2, 0> {
2111 LCallNew(LOperand* context, LOperand* constructor) {
2112 inputs_[0] = context;
2113 inputs_[1] = constructor;
2116 LOperand* context() { return inputs_[0]; }
2117 LOperand* constructor() { return inputs_[1]; }
2119 DECLARE_CONCRETE_INSTRUCTION(CallNew, "call-new")
2120 DECLARE_HYDROGEN_ACCESSOR(CallNew)
2122 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
2124 int arity() const { return hydrogen()->argument_count() - 1; }
2128 class LCallNewArray V8_FINAL : public LTemplateInstruction<1, 2, 0> {
2130 LCallNewArray(LOperand* context, LOperand* constructor) {
2131 inputs_[0] = context;
2132 inputs_[1] = constructor;
2135 LOperand* context() { return inputs_[0]; }
2136 LOperand* constructor() { return inputs_[1]; }
2138 DECLARE_CONCRETE_INSTRUCTION(CallNewArray, "call-new-array")
2139 DECLARE_HYDROGEN_ACCESSOR(CallNewArray)
2141 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
2143 int arity() const { return hydrogen()->argument_count() - 1; }
2147 class LCallRuntime V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2149 explicit LCallRuntime(LOperand* context) {
2150 inputs_[0] = context;
2153 LOperand* context() { return inputs_[0]; }
2155 DECLARE_CONCRETE_INSTRUCTION(CallRuntime, "call-runtime")
2156 DECLARE_HYDROGEN_ACCESSOR(CallRuntime)
2158 virtual bool ClobbersDoubleRegisters(Isolate* isolate) const V8_OVERRIDE {
2159 return save_doubles() == kDontSaveFPRegs;
2162 const Runtime::Function* function() const { return hydrogen()->function(); }
2163 int arity() const { return hydrogen()->argument_count(); }
2164 SaveFPRegsMode save_doubles() const { return hydrogen()->save_doubles(); }
2168 class LInteger32ToDouble V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2170 explicit LInteger32ToDouble(LOperand* value) {
2174 LOperand* value() { return inputs_[0]; }
2176 DECLARE_CONCRETE_INSTRUCTION(Integer32ToDouble, "int32-to-double")
2180 class LUint32ToDouble V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2182 explicit LUint32ToDouble(LOperand* value) {
2186 LOperand* value() { return inputs_[0]; }
2188 DECLARE_CONCRETE_INSTRUCTION(Uint32ToDouble, "uint32-to-double")
2192 class LNumberTagI V8_FINAL : public LTemplateInstruction<1, 1, 2> {
2194 LNumberTagI(LOperand* value, LOperand* temp1, LOperand* temp2) {
2200 LOperand* value() { return inputs_[0]; }
2201 LOperand* temp1() { return temps_[0]; }
2202 LOperand* temp2() { return temps_[1]; }
2204 DECLARE_CONCRETE_INSTRUCTION(NumberTagI, "number-tag-i")
2208 class LNumberTagU V8_FINAL : public LTemplateInstruction<1, 1, 2> {
2210 LNumberTagU(LOperand* value, LOperand* temp1, LOperand* temp2) {
2216 LOperand* value() { return inputs_[0]; }
2217 LOperand* temp1() { return temps_[0]; }
2218 LOperand* temp2() { return temps_[1]; }
2220 DECLARE_CONCRETE_INSTRUCTION(NumberTagU, "number-tag-u")
2224 class LNumberTagD V8_FINAL : public LTemplateInstruction<1, 1, 1> {
2226 explicit LNumberTagD(LOperand* value, LOperand* temp) {
2231 LOperand* value() { return inputs_[0]; }
2232 LOperand* temp() { return temps_[0]; }
2234 DECLARE_CONCRETE_INSTRUCTION(NumberTagD, "number-tag-d")
2235 DECLARE_HYDROGEN_ACCESSOR(Change)
2239 class LSIMD128ToTagged V8_FINAL : public LTemplateInstruction<1, 1, 3> {
2241 explicit LSIMD128ToTagged(LOperand* value, LOperand* temp,
2242 LOperand* temp2, LOperand* temp3) {
2249 LOperand* value() { return inputs_[0]; }
2250 LOperand* temp() { return temps_[0]; }
2251 LOperand* temp2() { return temps_[1]; }
2252 LOperand* temp3() { return temps_[2]; }
2254 DECLARE_CONCRETE_INSTRUCTION(SIMD128ToTagged, "simd128-tag")
2255 DECLARE_HYDROGEN_ACCESSOR(Change)
2259 // Sometimes truncating conversion from a tagged value to an int32.
2260 class LDoubleToI V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2262 explicit LDoubleToI(LOperand* value) {
2266 LOperand* value() { return inputs_[0]; }
2268 DECLARE_CONCRETE_INSTRUCTION(DoubleToI, "double-to-i")
2269 DECLARE_HYDROGEN_ACCESSOR(UnaryOperation)
2271 bool truncating() { return hydrogen()->CanTruncateToInt32(); }
2275 class LDoubleToSmi V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2277 explicit LDoubleToSmi(LOperand* value) {
2281 LOperand* value() { return inputs_[0]; }
2283 DECLARE_CONCRETE_INSTRUCTION(DoubleToSmi, "double-to-smi")
2284 DECLARE_HYDROGEN_ACCESSOR(UnaryOperation)
2288 // Truncating conversion from a tagged value to an int32.
2289 class LTaggedToI V8_FINAL : public LTemplateInstruction<1, 1, 1> {
2291 LTaggedToI(LOperand* value, LOperand* temp) {
2296 LOperand* value() { return inputs_[0]; }
2297 LOperand* temp() { return temps_[0]; }
2299 DECLARE_CONCRETE_INSTRUCTION(TaggedToI, "tagged-to-i")
2300 DECLARE_HYDROGEN_ACCESSOR(Change)
2302 bool truncating() { return hydrogen()->CanTruncateToInt32(); }
2306 class LSmiTag V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2308 explicit LSmiTag(LOperand* value) {
2312 LOperand* value() { return inputs_[0]; }
2314 DECLARE_CONCRETE_INSTRUCTION(SmiTag, "smi-tag")
2315 DECLARE_HYDROGEN_ACCESSOR(Change)
2319 class LNumberUntagD V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2321 explicit LNumberUntagD(LOperand* value) {
2325 LOperand* value() { return inputs_[0]; }
2327 DECLARE_CONCRETE_INSTRUCTION(NumberUntagD, "double-untag")
2328 DECLARE_HYDROGEN_ACCESSOR(Change);
2332 class LTaggedToSIMD128 V8_FINAL : public LTemplateInstruction<1, 1, 1> {
2334 explicit LTaggedToSIMD128(LOperand* value, LOperand* temp,
2335 Representation representation)
2336 : representation_(representation) {
2341 LOperand* value() { return inputs_[0]; }
2342 LOperand* temp() { return temps_[0]; }
2343 Representation representation() const { return representation_; }
2345 DECLARE_CONCRETE_INSTRUCTION(TaggedToSIMD128, "simd128-untag")
2346 DECLARE_HYDROGEN_ACCESSOR(Change);
2348 Representation representation_;
2352 class LSmiUntag V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2354 LSmiUntag(LOperand* value, bool needs_check)
2355 : needs_check_(needs_check) {
2359 LOperand* value() { return inputs_[0]; }
2360 bool needs_check() const { return needs_check_; }
2362 DECLARE_CONCRETE_INSTRUCTION(SmiUntag, "smi-untag")
2369 class LStoreNamedField V8_FINAL : public LTemplateInstruction<0, 2, 1> {
2371 LStoreNamedField(LOperand* object, LOperand* value, LOperand* temp) {
2372 inputs_[0] = object;
2377 LOperand* object() { return inputs_[0]; }
2378 LOperand* value() { return inputs_[1]; }
2379 LOperand* temp() { return temps_[0]; }
2381 DECLARE_CONCRETE_INSTRUCTION(StoreNamedField, "store-named-field")
2382 DECLARE_HYDROGEN_ACCESSOR(StoreNamedField)
2384 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
2386 Representation representation() const {
2387 return hydrogen()->field_representation();
2392 class LStoreNamedGeneric V8_FINAL : public LTemplateInstruction<0, 3, 0> {
2394 LStoreNamedGeneric(LOperand* context, LOperand* object, LOperand* value) {
2395 inputs_[0] = context;
2396 inputs_[1] = object;
2400 LOperand* context() { return inputs_[0]; }
2401 LOperand* object() { return inputs_[1]; }
2402 LOperand* value() { return inputs_[2]; }
2404 DECLARE_CONCRETE_INSTRUCTION(StoreNamedGeneric, "store-named-generic")
2405 DECLARE_HYDROGEN_ACCESSOR(StoreNamedGeneric)
2407 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
2409 Handle<Object> name() const { return hydrogen()->name(); }
2410 StrictMode strict_mode() { return hydrogen()->strict_mode(); }
2414 class LStoreKeyed V8_FINAL : public LTemplateInstruction<0, 3, 0> {
2416 LStoreKeyed(LOperand* object, LOperand* key, LOperand* value) {
2417 inputs_[0] = object;
2422 bool is_external() const { return hydrogen()->is_external(); }
2423 bool is_fixed_typed_array() const {
2424 return hydrogen()->is_fixed_typed_array();
2426 bool is_typed_elements() const {
2427 return is_external() || is_fixed_typed_array();
2429 LOperand* elements() { return inputs_[0]; }
2430 LOperand* key() { return inputs_[1]; }
2431 LOperand* value() { return inputs_[2]; }
2432 ElementsKind elements_kind() const { return hydrogen()->elements_kind(); }
2434 DECLARE_CONCRETE_INSTRUCTION(StoreKeyed, "store-keyed")
2435 DECLARE_HYDROGEN_ACCESSOR(StoreKeyed)
2437 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
2438 bool NeedsCanonicalization() { return hydrogen()->NeedsCanonicalization(); }
2439 uint32_t base_offset() const { return hydrogen()->base_offset(); }
2443 class LStoreKeyedGeneric V8_FINAL : public LTemplateInstruction<0, 4, 0> {
2445 LStoreKeyedGeneric(LOperand* context,
2449 inputs_[0] = context;
2450 inputs_[1] = object;
2455 LOperand* context() { return inputs_[0]; }
2456 LOperand* object() { return inputs_[1]; }
2457 LOperand* key() { return inputs_[2]; }
2458 LOperand* value() { return inputs_[3]; }
2460 DECLARE_CONCRETE_INSTRUCTION(StoreKeyedGeneric, "store-keyed-generic")
2461 DECLARE_HYDROGEN_ACCESSOR(StoreKeyedGeneric)
2463 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
2465 StrictMode strict_mode() { return hydrogen()->strict_mode(); }
2469 class LTransitionElementsKind V8_FINAL : public LTemplateInstruction<0, 2, 2> {
2471 LTransitionElementsKind(LOperand* object,
2473 LOperand* new_map_temp,
2475 inputs_[0] = object;
2476 inputs_[1] = context;
2477 temps_[0] = new_map_temp;
2481 LOperand* object() { return inputs_[0]; }
2482 LOperand* context() { return inputs_[1]; }
2483 LOperand* new_map_temp() { return temps_[0]; }
2484 LOperand* temp() { return temps_[1]; }
2486 DECLARE_CONCRETE_INSTRUCTION(TransitionElementsKind,
2487 "transition-elements-kind")
2488 DECLARE_HYDROGEN_ACCESSOR(TransitionElementsKind)
2490 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
2492 Handle<Map> original_map() { return hydrogen()->original_map().handle(); }
2493 Handle<Map> transitioned_map() {
2494 return hydrogen()->transitioned_map().handle();
2496 ElementsKind from_kind() { return hydrogen()->from_kind(); }
2497 ElementsKind to_kind() { return hydrogen()->to_kind(); }
2501 class LTrapAllocationMemento V8_FINAL : public LTemplateInstruction<0, 1, 1> {
2503 LTrapAllocationMemento(LOperand* object,
2505 inputs_[0] = object;
2509 LOperand* object() { return inputs_[0]; }
2510 LOperand* temp() { return temps_[0]; }
2512 DECLARE_CONCRETE_INSTRUCTION(TrapAllocationMemento,
2513 "trap-allocation-memento")
2517 class LStringAdd V8_FINAL : public LTemplateInstruction<1, 3, 0> {
2519 LStringAdd(LOperand* context, LOperand* left, LOperand* right) {
2520 inputs_[0] = context;
2525 LOperand* context() { return inputs_[0]; }
2526 LOperand* left() { return inputs_[1]; }
2527 LOperand* right() { return inputs_[2]; }
2529 DECLARE_CONCRETE_INSTRUCTION(StringAdd, "string-add")
2530 DECLARE_HYDROGEN_ACCESSOR(StringAdd)
2534 class LStringCharCodeAt V8_FINAL : public LTemplateInstruction<1, 3, 0> {
2536 LStringCharCodeAt(LOperand* context, LOperand* string, LOperand* index) {
2537 inputs_[0] = context;
2538 inputs_[1] = string;
2542 LOperand* context() { return inputs_[0]; }
2543 LOperand* string() { return inputs_[1]; }
2544 LOperand* index() { return inputs_[2]; }
2546 DECLARE_CONCRETE_INSTRUCTION(StringCharCodeAt, "string-char-code-at")
2547 DECLARE_HYDROGEN_ACCESSOR(StringCharCodeAt)
2551 class LStringCharFromCode V8_FINAL : public LTemplateInstruction<1, 2, 0> {
2553 explicit LStringCharFromCode(LOperand* context, LOperand* char_code) {
2554 inputs_[0] = context;
2555 inputs_[1] = char_code;
2558 LOperand* context() { return inputs_[0]; }
2559 LOperand* char_code() { return inputs_[1]; }
2561 DECLARE_CONCRETE_INSTRUCTION(StringCharFromCode, "string-char-from-code")
2562 DECLARE_HYDROGEN_ACCESSOR(StringCharFromCode)
2566 class LCheckValue V8_FINAL : public LTemplateInstruction<0, 1, 0> {
2568 explicit LCheckValue(LOperand* value) {
2572 LOperand* value() { return inputs_[0]; }
2574 DECLARE_CONCRETE_INSTRUCTION(CheckValue, "check-value")
2575 DECLARE_HYDROGEN_ACCESSOR(CheckValue)
2579 class LCheckInstanceType V8_FINAL : public LTemplateInstruction<0, 1, 0> {
2581 explicit LCheckInstanceType(LOperand* value) {
2585 LOperand* value() { return inputs_[0]; }
2587 DECLARE_CONCRETE_INSTRUCTION(CheckInstanceType, "check-instance-type")
2588 DECLARE_HYDROGEN_ACCESSOR(CheckInstanceType)
2592 class LCheckMaps V8_FINAL : public LTemplateInstruction<0, 1, 0> {
2594 explicit LCheckMaps(LOperand* value = NULL) {
2598 LOperand* value() { return inputs_[0]; }
2600 DECLARE_CONCRETE_INSTRUCTION(CheckMaps, "check-maps")
2601 DECLARE_HYDROGEN_ACCESSOR(CheckMaps)
2605 class LCheckSmi V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2607 explicit LCheckSmi(LOperand* value) {
2611 LOperand* value() { return inputs_[0]; }
2613 DECLARE_CONCRETE_INSTRUCTION(CheckSmi, "check-smi")
2617 class LClampDToUint8 V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2619 explicit LClampDToUint8(LOperand* unclamped) {
2620 inputs_[0] = unclamped;
2623 LOperand* unclamped() { return inputs_[0]; }
2625 DECLARE_CONCRETE_INSTRUCTION(ClampDToUint8, "clamp-d-to-uint8")
2629 class LClampIToUint8 V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2631 explicit LClampIToUint8(LOperand* unclamped) {
2632 inputs_[0] = unclamped;
2635 LOperand* unclamped() { return inputs_[0]; }
2637 DECLARE_CONCRETE_INSTRUCTION(ClampIToUint8, "clamp-i-to-uint8")
2641 class LClampTToUint8 V8_FINAL : public LTemplateInstruction<1, 1, 1> {
2643 LClampTToUint8(LOperand* unclamped,
2644 LOperand* temp_xmm) {
2645 inputs_[0] = unclamped;
2646 temps_[0] = temp_xmm;
2649 LOperand* unclamped() { return inputs_[0]; }
2650 LOperand* temp_xmm() { return temps_[0]; }
2652 DECLARE_CONCRETE_INSTRUCTION(ClampTToUint8, "clamp-t-to-uint8")
2656 class LCheckNonSmi V8_FINAL : public LTemplateInstruction<0, 1, 0> {
2658 explicit LCheckNonSmi(LOperand* value) {
2662 LOperand* value() { return inputs_[0]; }
2664 DECLARE_CONCRETE_INSTRUCTION(CheckNonSmi, "check-non-smi")
2665 DECLARE_HYDROGEN_ACCESSOR(CheckHeapObject)
2669 class LDoubleBits V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2671 explicit LDoubleBits(LOperand* value) {
2675 LOperand* value() { return inputs_[0]; }
2677 DECLARE_CONCRETE_INSTRUCTION(DoubleBits, "double-bits")
2678 DECLARE_HYDROGEN_ACCESSOR(DoubleBits)
2682 class LConstructDouble V8_FINAL : public LTemplateInstruction<1, 2, 0> {
2684 LConstructDouble(LOperand* hi, LOperand* lo) {
2689 LOperand* hi() { return inputs_[0]; }
2690 LOperand* lo() { return inputs_[1]; }
2692 DECLARE_CONCRETE_INSTRUCTION(ConstructDouble, "construct-double")
2696 class LAllocate V8_FINAL : public LTemplateInstruction<1, 2, 1> {
2698 LAllocate(LOperand* context, LOperand* size, LOperand* temp) {
2699 inputs_[0] = context;
2704 LOperand* context() { return inputs_[0]; }
2705 LOperand* size() { return inputs_[1]; }
2706 LOperand* temp() { return temps_[0]; }
2708 DECLARE_CONCRETE_INSTRUCTION(Allocate, "allocate")
2709 DECLARE_HYDROGEN_ACCESSOR(Allocate)
2713 class LRegExpLiteral V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2715 explicit LRegExpLiteral(LOperand* context) {
2716 inputs_[0] = context;
2719 LOperand* context() { return inputs_[0]; }
2721 DECLARE_CONCRETE_INSTRUCTION(RegExpLiteral, "regexp-literal")
2722 DECLARE_HYDROGEN_ACCESSOR(RegExpLiteral)
2726 class LFunctionLiteral V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2728 explicit LFunctionLiteral(LOperand* context) {
2729 inputs_[0] = context;
2732 LOperand* context() { return inputs_[0]; }
2734 DECLARE_CONCRETE_INSTRUCTION(FunctionLiteral, "function-literal")
2735 DECLARE_HYDROGEN_ACCESSOR(FunctionLiteral)
2739 class LToFastProperties V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2741 explicit LToFastProperties(LOperand* value) {
2745 LOperand* value() { return inputs_[0]; }
2747 DECLARE_CONCRETE_INSTRUCTION(ToFastProperties, "to-fast-properties")
2748 DECLARE_HYDROGEN_ACCESSOR(ToFastProperties)
2752 class LTypeof V8_FINAL : public LTemplateInstruction<1, 2, 0> {
2754 LTypeof(LOperand* context, LOperand* value) {
2755 inputs_[0] = context;
2759 LOperand* context() { return inputs_[0]; }
2760 LOperand* value() { return inputs_[1]; }
2762 DECLARE_CONCRETE_INSTRUCTION(Typeof, "typeof")
2766 class LTypeofIsAndBranch V8_FINAL : public LControlInstruction<1, 0> {
2768 explicit LTypeofIsAndBranch(LOperand* value) {
2772 LOperand* value() { return inputs_[0]; }
2774 DECLARE_CONCRETE_INSTRUCTION(TypeofIsAndBranch, "typeof-is-and-branch")
2775 DECLARE_HYDROGEN_ACCESSOR(TypeofIsAndBranch)
2777 Handle<String> type_literal() { return hydrogen()->type_literal(); }
2779 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
2783 class LIsConstructCallAndBranch V8_FINAL : public LControlInstruction<0, 1> {
2785 explicit LIsConstructCallAndBranch(LOperand* temp) {
2789 LOperand* temp() { return temps_[0]; }
2791 DECLARE_CONCRETE_INSTRUCTION(IsConstructCallAndBranch,
2792 "is-construct-call-and-branch")
2793 DECLARE_HYDROGEN_ACCESSOR(IsConstructCallAndBranch)
2797 class LOsrEntry V8_FINAL : public LTemplateInstruction<0, 0, 0> {
2801 virtual bool HasInterestingComment(LCodeGen* gen) const V8_OVERRIDE {
2804 DECLARE_CONCRETE_INSTRUCTION(OsrEntry, "osr-entry")
2808 class LStackCheck V8_FINAL : public LTemplateInstruction<0, 1, 0> {
2810 explicit LStackCheck(LOperand* context) {
2811 inputs_[0] = context;
2814 LOperand* context() { return inputs_[0]; }
2816 DECLARE_CONCRETE_INSTRUCTION(StackCheck, "stack-check")
2817 DECLARE_HYDROGEN_ACCESSOR(StackCheck)
2819 Label* done_label() { return &done_label_; }
2826 class LForInPrepareMap V8_FINAL : public LTemplateInstruction<1, 2, 0> {
2828 LForInPrepareMap(LOperand* context, LOperand* object) {
2829 inputs_[0] = context;
2830 inputs_[1] = object;
2833 LOperand* context() { return inputs_[0]; }
2834 LOperand* object() { return inputs_[1]; }
2836 DECLARE_CONCRETE_INSTRUCTION(ForInPrepareMap, "for-in-prepare-map")
2840 class LForInCacheArray V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2842 explicit LForInCacheArray(LOperand* map) {
2846 LOperand* map() { return inputs_[0]; }
2848 DECLARE_CONCRETE_INSTRUCTION(ForInCacheArray, "for-in-cache-array")
2851 return HForInCacheArray::cast(this->hydrogen_value())->idx();
2856 class LCheckMapValue V8_FINAL : public LTemplateInstruction<0, 2, 0> {
2858 LCheckMapValue(LOperand* value, LOperand* map) {
2863 LOperand* value() { return inputs_[0]; }
2864 LOperand* map() { return inputs_[1]; }
2866 DECLARE_CONCRETE_INSTRUCTION(CheckMapValue, "check-map-value")
2870 class LLoadFieldByIndex V8_FINAL : public LTemplateInstruction<1, 2, 0> {
2872 LLoadFieldByIndex(LOperand* object, LOperand* index) {
2873 inputs_[0] = object;
2877 LOperand* object() { return inputs_[0]; }
2878 LOperand* index() { return inputs_[1]; }
2880 DECLARE_CONCRETE_INSTRUCTION(LoadFieldByIndex, "load-field-by-index")
2884 class LStoreFrameContext: public LTemplateInstruction<0, 1, 0> {
2886 explicit LStoreFrameContext(LOperand* context) {
2887 inputs_[0] = context;
2890 LOperand* context() { return inputs_[0]; }
2892 DECLARE_CONCRETE_INSTRUCTION(StoreFrameContext, "store-frame-context")
2896 class LAllocateBlockContext: public LTemplateInstruction<1, 2, 0> {
2898 LAllocateBlockContext(LOperand* context, LOperand* function) {
2899 inputs_[0] = context;
2900 inputs_[1] = function;
2903 LOperand* context() { return inputs_[0]; }
2904 LOperand* function() { return inputs_[1]; }
2906 Handle<ScopeInfo> scope_info() { return hydrogen()->scope_info(); }
2908 DECLARE_CONCRETE_INSTRUCTION(AllocateBlockContext, "allocate-block-context")
2909 DECLARE_HYDROGEN_ACCESSOR(AllocateBlockContext)
2913 class LChunkBuilder;
2914 class LPlatformChunk V8_FINAL : public LChunk {
2916 LPlatformChunk(CompilationInfo* info, HGraph* graph)
2917 : LChunk(info, graph),
2918 dehoisted_key_ids_(graph->GetMaximumValueID(), graph->zone()) { }
2920 int GetNextSpillIndex(RegisterKind kind);
2921 LOperand* GetNextSpillSlot(RegisterKind kind);
2922 BitVector* GetDehoistedKeyIds() { return &dehoisted_key_ids_; }
2923 bool IsDehoistedKey(HValue* value) {
2924 return dehoisted_key_ids_.Contains(value->id());
2928 BitVector dehoisted_key_ids_;
2932 class LChunkBuilder V8_FINAL : public LChunkBuilderBase {
2934 LChunkBuilder(CompilationInfo* info, HGraph* graph, LAllocator* allocator)
2935 : LChunkBuilderBase(graph->zone()),
2940 current_instruction_(NULL),
2941 current_block_(NULL),
2943 allocator_(allocator) { }
2945 Isolate* isolate() const { return graph_->isolate(); }
2947 // Build the sequence for the graph.
2948 LPlatformChunk* Build();
2950 // Declare methods that deal with the individual node types.
2951 #define DECLARE_DO(type) LInstruction* Do##type(H##type* node);
2952 HYDROGEN_CONCRETE_INSTRUCTION_LIST(DECLARE_DO)
2955 LInstruction* DoMathFloor(HUnaryMathOperation* instr);
2956 LInstruction* DoMathRound(HUnaryMathOperation* instr);
2957 LInstruction* DoMathFround(HUnaryMathOperation* instr);
2958 LInstruction* DoMathAbs(HUnaryMathOperation* instr);
2959 LInstruction* DoMathLog(HUnaryMathOperation* instr);
2960 LInstruction* DoMathExp(HUnaryMathOperation* instr);
2961 LInstruction* DoMathSqrt(HUnaryMathOperation* instr);
2962 LInstruction* DoMathPowHalf(HUnaryMathOperation* instr);
2963 LInstruction* DoMathClz32(HUnaryMathOperation* instr);
2964 LInstruction* DoDivByPowerOf2I(HDiv* instr);
2965 LInstruction* DoDivByConstI(HDiv* instr);
2966 LInstruction* DoDivI(HDiv* instr);
2967 LInstruction* DoModByPowerOf2I(HMod* instr);
2968 LInstruction* DoModByConstI(HMod* instr);
2969 LInstruction* DoModI(HMod* instr);
2970 LInstruction* DoFlooringDivByPowerOf2I(HMathFloorOfDiv* instr);
2971 LInstruction* DoFlooringDivByConstI(HMathFloorOfDiv* instr);
2972 LInstruction* DoFlooringDivI(HMathFloorOfDiv* instr);
2982 LPlatformChunk* chunk() const { return chunk_; }
2983 CompilationInfo* info() const { return info_; }
2984 HGraph* graph() const { return graph_; }
2986 bool is_unused() const { return status_ == UNUSED; }
2987 bool is_building() const { return status_ == BUILDING; }
2988 bool is_done() const { return status_ == DONE; }
2989 bool is_aborted() const { return status_ == ABORTED; }
2991 void Abort(BailoutReason reason);
2993 // Methods for getting operands for Use / Define / Temp.
2994 LUnallocated* ToUnallocated(Register reg);
2995 LUnallocated* ToUnallocated(XMMRegister reg);
2997 // Methods for setting up define-use relationships.
2998 MUST_USE_RESULT LOperand* Use(HValue* value, LUnallocated* operand);
2999 MUST_USE_RESULT LOperand* UseFixed(HValue* value, Register fixed_register);
3000 MUST_USE_RESULT LOperand* UseFixedDouble(HValue* value,
3001 XMMRegister fixed_register);
3003 // A value that is guaranteed to be allocated to a register.
3004 // Operand created by UseRegister is guaranteed to be live until the end of
3005 // instruction. This means that register allocator will not reuse it's
3006 // register for any other operand inside instruction.
3007 // Operand created by UseRegisterAtStart is guaranteed to be live only at
3008 // instruction start. Register allocator is free to assign the same register
3009 // to some other operand used inside instruction (i.e. temporary or
3011 MUST_USE_RESULT LOperand* UseRegister(HValue* value);
3012 MUST_USE_RESULT LOperand* UseRegisterAtStart(HValue* value);
3014 // An input operand in a register that may be trashed.
3015 MUST_USE_RESULT LOperand* UseTempRegister(HValue* value);
3017 // An input operand in a register that may be trashed or a constant operand.
3018 MUST_USE_RESULT LOperand* UseTempRegisterOrConstant(HValue* value);
3020 // An input operand in a register or stack slot.
3021 MUST_USE_RESULT LOperand* Use(HValue* value);
3022 MUST_USE_RESULT LOperand* UseAtStart(HValue* value);
3024 // An input operand in a register, stack slot or a constant operand.
3025 MUST_USE_RESULT LOperand* UseOrConstant(HValue* value);
3026 MUST_USE_RESULT LOperand* UseOrConstantAtStart(HValue* value);
3028 // An input operand in a register or a constant operand.
3029 MUST_USE_RESULT LOperand* UseRegisterOrConstant(HValue* value);
3030 MUST_USE_RESULT LOperand* UseRegisterOrConstantAtStart(HValue* value);
3032 // An input operand in a constant operand.
3033 MUST_USE_RESULT LOperand* UseConstant(HValue* value);
3035 // An input operand in register, stack slot or a constant operand.
3036 // Will not be moved to a register even if one is freely available.
3037 virtual MUST_USE_RESULT LOperand* UseAny(HValue* value) V8_OVERRIDE;
3039 // Temporary operand that must be in a register.
3040 MUST_USE_RESULT LUnallocated* TempRegister();
3041 MUST_USE_RESULT LOperand* FixedTemp(Register reg);
3042 MUST_USE_RESULT LOperand* FixedTemp(XMMRegister reg);
3044 // Methods for setting up define-use relationships.
3045 // Return the same instruction that they are passed.
3046 LInstruction* Define(LTemplateResultInstruction<1>* instr,
3047 LUnallocated* result);
3048 LInstruction* DefineAsRegister(LTemplateResultInstruction<1>* instr);
3049 LInstruction* DefineAsSpilled(LTemplateResultInstruction<1>* instr,
3051 LInstruction* DefineSameAsFirst(LTemplateResultInstruction<1>* instr);
3052 LInstruction* DefineFixed(LTemplateResultInstruction<1>* instr,
3054 LInstruction* DefineFixedDouble(LTemplateResultInstruction<1>* instr,
3056 // Assigns an environment to an instruction. An instruction which can
3057 // deoptimize must have an environment.
3058 LInstruction* AssignEnvironment(LInstruction* instr);
3059 // Assigns a pointer map to an instruction. An instruction which can
3060 // trigger a GC or a lazy deoptimization must have a pointer map.
3061 LInstruction* AssignPointerMap(LInstruction* instr);
3063 enum CanDeoptimize { CAN_DEOPTIMIZE_EAGERLY, CANNOT_DEOPTIMIZE_EAGERLY };
3065 // Marks a call for the register allocator. Assigns a pointer map to
3066 // support GC and lazy deoptimization. Assigns an environment to support
3067 // eager deoptimization if CAN_DEOPTIMIZE_EAGERLY.
3068 LInstruction* MarkAsCall(
3069 LInstruction* instr,
3070 HInstruction* hinstr,
3071 CanDeoptimize can_deoptimize = CANNOT_DEOPTIMIZE_EAGERLY);
3073 void VisitInstruction(HInstruction* current);
3074 void AddInstruction(LInstruction* instr, HInstruction* current);
3076 void DoBasicBlock(HBasicBlock* block, HBasicBlock* next_block);
3077 LInstruction* DoShift(Token::Value op, HBitwiseBinaryOperation* instr);
3078 LInstruction* DoArithmeticD(Token::Value op,
3079 HArithmeticBinaryOperation* instr);
3080 LInstruction* DoArithmeticT(Token::Value op,
3081 HBinaryOperation* instr);
3082 void FindDehoistedKeyDefinitions(HValue* candidate);
3084 LPlatformChunk* chunk_;
3085 CompilationInfo* info_;
3086 HGraph* const graph_;
3088 HInstruction* current_instruction_;
3089 HBasicBlock* current_block_;
3090 HBasicBlock* next_block_;
3091 LAllocator* allocator_;
3093 DISALLOW_COPY_AND_ASSIGN(LChunkBuilder);
3096 #undef DECLARE_HYDROGEN_ACCESSOR
3097 #undef DECLARE_CONCRETE_INSTRUCTION
3099 } } // namespace v8::int
3101 #endif // V8_X64_LITHIUM_X64_H_