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-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) \
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) \
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 void MarkAsCall() { bit_field_ = IsCallBits::update(bit_field_, true); }
241 bool IsCall() const { return IsCallBits::decode(bit_field_); }
243 // Interface to the register allocator and iterators.
244 bool ClobbersTemps() const { return IsCall(); }
245 bool ClobbersRegisters() const { return IsCall(); }
246 virtual bool ClobbersDoubleRegisters(Isolate* isolate) const {
250 virtual void SetDeferredLazyDeoptimizationEnvironment(LEnvironment* env) { }
252 // Interface to the register allocator and iterators.
253 bool IsMarkedAsCall() const { return IsCall(); }
255 virtual bool HasResult() const = 0;
256 virtual LOperand* result() const = 0;
258 LOperand* FirstInput() { return InputAt(0); }
259 LOperand* Output() { return HasResult() ? result() : NULL; }
261 virtual bool HasInterestingComment(LCodeGen* gen) const { return true; }
263 virtual bool MustSignExtendResult(LPlatformChunk* chunk) const {
273 friend class InputIterator;
274 virtual int InputCount() = 0;
275 virtual LOperand* InputAt(int i) = 0;
277 friend class TempIterator;
278 virtual int TempCount() = 0;
279 virtual LOperand* TempAt(int i) = 0;
281 class IsCallBits: public BitField<bool, 0, 1> {};
283 LEnvironment* environment_;
284 SetOncePointer<LPointerMap> pointer_map_;
285 HValue* hydrogen_value_;
290 // R = number of result operands (0 or 1).
292 class LTemplateResultInstruction : public LInstruction {
294 // Allow 0 or 1 output operands.
295 STATIC_ASSERT(R == 0 || R == 1);
296 virtual bool HasResult() const V8_FINAL V8_OVERRIDE {
297 return R != 0 && result() != NULL;
299 void set_result(LOperand* operand) { results_[0] = operand; }
300 LOperand* result() const { return results_[0]; }
302 virtual bool MustSignExtendResult(
303 LPlatformChunk* chunk) const V8_FINAL V8_OVERRIDE;
306 EmbeddedContainer<LOperand*, R> results_;
310 // R = number of result operands (0 or 1).
311 // I = number of input operands.
312 // T = number of temporary operands.
313 template<int R, int I, int T>
314 class LTemplateInstruction : public LTemplateResultInstruction<R> {
316 EmbeddedContainer<LOperand*, I> inputs_;
317 EmbeddedContainer<LOperand*, T> temps_;
321 virtual int InputCount() V8_FINAL V8_OVERRIDE { return I; }
322 virtual LOperand* InputAt(int i) V8_FINAL V8_OVERRIDE { return inputs_[i]; }
324 virtual int TempCount() V8_FINAL V8_OVERRIDE { return T; }
325 virtual LOperand* TempAt(int i) V8_FINAL V8_OVERRIDE { return temps_[i]; }
329 class LGap : public LTemplateInstruction<0, 0, 0> {
331 explicit LGap(HBasicBlock* block)
333 parallel_moves_[BEFORE] = NULL;
334 parallel_moves_[START] = NULL;
335 parallel_moves_[END] = NULL;
336 parallel_moves_[AFTER] = NULL;
339 // Can't use the DECLARE-macro here because of sub-classes.
340 virtual bool IsGap() const V8_FINAL V8_OVERRIDE { return true; }
341 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
342 static LGap* cast(LInstruction* instr) {
343 ASSERT(instr->IsGap());
344 return reinterpret_cast<LGap*>(instr);
347 bool IsRedundant() const;
349 HBasicBlock* block() const { return block_; }
356 FIRST_INNER_POSITION = BEFORE,
357 LAST_INNER_POSITION = AFTER
360 LParallelMove* GetOrCreateParallelMove(InnerPosition pos,
362 if (parallel_moves_[pos] == NULL) {
363 parallel_moves_[pos] = new(zone) LParallelMove(zone);
365 return parallel_moves_[pos];
368 LParallelMove* GetParallelMove(InnerPosition pos) {
369 return parallel_moves_[pos];
373 LParallelMove* parallel_moves_[LAST_INNER_POSITION + 1];
378 class LInstructionGap V8_FINAL : public LGap {
380 explicit LInstructionGap(HBasicBlock* block) : LGap(block) { }
382 virtual bool HasInterestingComment(LCodeGen* gen) const V8_OVERRIDE {
383 return !IsRedundant();
386 DECLARE_CONCRETE_INSTRUCTION(InstructionGap, "gap")
390 class LGoto V8_FINAL : public LTemplateInstruction<0, 0, 0> {
392 explicit LGoto(HBasicBlock* block) : block_(block) { }
394 virtual bool HasInterestingComment(LCodeGen* gen) const V8_OVERRIDE;
395 DECLARE_CONCRETE_INSTRUCTION(Goto, "goto")
396 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
397 virtual bool IsControl() const V8_OVERRIDE { return true; }
399 int block_id() const { return block_->block_id(); }
406 class LLazyBailout V8_FINAL : public LTemplateInstruction<0, 0, 0> {
408 LLazyBailout() : gap_instructions_size_(0) { }
410 DECLARE_CONCRETE_INSTRUCTION(LazyBailout, "lazy-bailout")
412 void set_gap_instructions_size(int gap_instructions_size) {
413 gap_instructions_size_ = gap_instructions_size;
415 int gap_instructions_size() { return gap_instructions_size_; }
418 int gap_instructions_size_;
422 class LDummy V8_FINAL : public LTemplateInstruction<1, 0, 0> {
424 explicit LDummy() { }
425 DECLARE_CONCRETE_INSTRUCTION(Dummy, "dummy")
429 class LDummyUse V8_FINAL : public LTemplateInstruction<1, 1, 0> {
431 explicit LDummyUse(LOperand* value) {
434 DECLARE_CONCRETE_INSTRUCTION(DummyUse, "dummy-use")
438 class LDeoptimize V8_FINAL : public LTemplateInstruction<0, 0, 0> {
440 virtual bool IsControl() const V8_OVERRIDE { return true; }
441 DECLARE_CONCRETE_INSTRUCTION(Deoptimize, "deoptimize")
442 DECLARE_HYDROGEN_ACCESSOR(Deoptimize)
446 class LLabel V8_FINAL : public LGap {
448 explicit LLabel(HBasicBlock* block)
449 : LGap(block), replacement_(NULL) { }
451 virtual bool HasInterestingComment(LCodeGen* gen) const V8_OVERRIDE {
454 DECLARE_CONCRETE_INSTRUCTION(Label, "label")
456 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
458 int block_id() const { return block()->block_id(); }
459 bool is_loop_header() const { return block()->IsLoopHeader(); }
460 bool is_osr_entry() const { return block()->is_osr_entry(); }
461 Label* label() { return &label_; }
462 LLabel* replacement() const { return replacement_; }
463 void set_replacement(LLabel* label) { replacement_ = label; }
464 bool HasReplacement() const { return replacement_ != NULL; }
468 LLabel* replacement_;
472 class LParameter V8_FINAL : public LTemplateInstruction<1, 0, 0> {
474 virtual bool HasInterestingComment(LCodeGen* gen) const V8_OVERRIDE {
477 DECLARE_CONCRETE_INSTRUCTION(Parameter, "parameter")
481 class LCallStub V8_FINAL : public LTemplateInstruction<1, 1, 0> {
483 explicit LCallStub(LOperand* context) {
484 inputs_[0] = context;
487 LOperand* context() { return inputs_[0]; }
489 DECLARE_CONCRETE_INSTRUCTION(CallStub, "call-stub")
490 DECLARE_HYDROGEN_ACCESSOR(CallStub)
494 class LUnknownOSRValue V8_FINAL : public LTemplateInstruction<1, 0, 0> {
496 virtual bool HasInterestingComment(LCodeGen* gen) const V8_OVERRIDE {
499 DECLARE_CONCRETE_INSTRUCTION(UnknownOSRValue, "unknown-osr-value")
503 template<int I, int T>
504 class LControlInstruction : public LTemplateInstruction<0, I, T> {
506 LControlInstruction() : false_label_(NULL), true_label_(NULL) { }
508 virtual bool IsControl() const V8_FINAL V8_OVERRIDE { return true; }
510 int SuccessorCount() { return hydrogen()->SuccessorCount(); }
511 HBasicBlock* SuccessorAt(int i) { return hydrogen()->SuccessorAt(i); }
513 int TrueDestination(LChunk* chunk) {
514 return chunk->LookupDestination(true_block_id());
516 int FalseDestination(LChunk* chunk) {
517 return chunk->LookupDestination(false_block_id());
520 Label* TrueLabel(LChunk* chunk) {
521 if (true_label_ == NULL) {
522 true_label_ = chunk->GetAssemblyLabel(TrueDestination(chunk));
526 Label* FalseLabel(LChunk* chunk) {
527 if (false_label_ == NULL) {
528 false_label_ = chunk->GetAssemblyLabel(FalseDestination(chunk));
534 int true_block_id() { return SuccessorAt(0)->block_id(); }
535 int false_block_id() { return SuccessorAt(1)->block_id(); }
538 HControlInstruction* hydrogen() {
539 return HControlInstruction::cast(this->hydrogen_value());
547 class LWrapReceiver V8_FINAL : public LTemplateInstruction<1, 2, 0> {
549 LWrapReceiver(LOperand* receiver, LOperand* function) {
550 inputs_[0] = receiver;
551 inputs_[1] = function;
554 LOperand* receiver() { return inputs_[0]; }
555 LOperand* function() { return inputs_[1]; }
557 DECLARE_CONCRETE_INSTRUCTION(WrapReceiver, "wrap-receiver")
558 DECLARE_HYDROGEN_ACCESSOR(WrapReceiver)
562 class LApplyArguments V8_FINAL : public LTemplateInstruction<1, 4, 0> {
564 LApplyArguments(LOperand* function,
567 LOperand* elements) {
568 inputs_[0] = function;
569 inputs_[1] = receiver;
571 inputs_[3] = elements;
574 LOperand* function() { return inputs_[0]; }
575 LOperand* receiver() { return inputs_[1]; }
576 LOperand* length() { return inputs_[2]; }
577 LOperand* elements() { return inputs_[3]; }
579 DECLARE_CONCRETE_INSTRUCTION(ApplyArguments, "apply-arguments")
583 class LAccessArgumentsAt V8_FINAL : public LTemplateInstruction<1, 3, 0> {
585 LAccessArgumentsAt(LOperand* arguments, LOperand* length, LOperand* index) {
586 inputs_[0] = arguments;
591 LOperand* arguments() { return inputs_[0]; }
592 LOperand* length() { return inputs_[1]; }
593 LOperand* index() { return inputs_[2]; }
595 DECLARE_CONCRETE_INSTRUCTION(AccessArgumentsAt, "access-arguments-at")
597 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
601 class LArgumentsLength V8_FINAL : public LTemplateInstruction<1, 1, 0> {
603 explicit LArgumentsLength(LOperand* elements) {
604 inputs_[0] = elements;
607 LOperand* elements() { return inputs_[0]; }
609 DECLARE_CONCRETE_INSTRUCTION(ArgumentsLength, "arguments-length")
613 class LArgumentsElements V8_FINAL : public LTemplateInstruction<1, 0, 0> {
615 DECLARE_CONCRETE_INSTRUCTION(ArgumentsElements, "arguments-elements")
616 DECLARE_HYDROGEN_ACCESSOR(ArgumentsElements)
620 class LModByPowerOf2I V8_FINAL : public LTemplateInstruction<1, 1, 0> {
622 LModByPowerOf2I(LOperand* dividend, int32_t divisor) {
623 inputs_[0] = dividend;
627 LOperand* dividend() { return inputs_[0]; }
628 int32_t divisor() const { return divisor_; }
630 DECLARE_CONCRETE_INSTRUCTION(ModByPowerOf2I, "mod-by-power-of-2-i")
631 DECLARE_HYDROGEN_ACCESSOR(Mod)
638 class LModByConstI V8_FINAL : public LTemplateInstruction<1, 1, 2> {
640 LModByConstI(LOperand* dividend,
644 inputs_[0] = dividend;
650 LOperand* dividend() { return inputs_[0]; }
651 int32_t divisor() const { return divisor_; }
652 LOperand* temp1() { return temps_[0]; }
653 LOperand* temp2() { return temps_[1]; }
655 DECLARE_CONCRETE_INSTRUCTION(ModByConstI, "mod-by-const-i")
656 DECLARE_HYDROGEN_ACCESSOR(Mod)
663 class LModI V8_FINAL : public LTemplateInstruction<1, 2, 1> {
665 LModI(LOperand* left, LOperand* right, LOperand* temp) {
671 LOperand* left() { return inputs_[0]; }
672 LOperand* right() { return inputs_[1]; }
673 LOperand* temp() { return temps_[0]; }
675 DECLARE_CONCRETE_INSTRUCTION(ModI, "mod-i")
676 DECLARE_HYDROGEN_ACCESSOR(Mod)
680 class LDivByPowerOf2I V8_FINAL : public LTemplateInstruction<1, 1, 0> {
682 LDivByPowerOf2I(LOperand* dividend, int32_t divisor) {
683 inputs_[0] = dividend;
687 LOperand* dividend() { return inputs_[0]; }
688 int32_t divisor() const { return divisor_; }
690 DECLARE_CONCRETE_INSTRUCTION(DivByPowerOf2I, "div-by-power-of-2-i")
691 DECLARE_HYDROGEN_ACCESSOR(Div)
698 class LDivByConstI V8_FINAL : public LTemplateInstruction<1, 1, 2> {
700 LDivByConstI(LOperand* dividend,
704 inputs_[0] = dividend;
710 LOperand* dividend() { return inputs_[0]; }
711 int32_t divisor() const { return divisor_; }
712 LOperand* temp1() { return temps_[0]; }
713 LOperand* temp2() { return temps_[1]; }
715 DECLARE_CONCRETE_INSTRUCTION(DivByConstI, "div-by-const-i")
716 DECLARE_HYDROGEN_ACCESSOR(Div)
723 class LDivI V8_FINAL : public LTemplateInstruction<1, 2, 1> {
725 LDivI(LOperand* dividend, LOperand* divisor, LOperand* temp) {
726 inputs_[0] = dividend;
727 inputs_[1] = divisor;
731 LOperand* dividend() { return inputs_[0]; }
732 LOperand* divisor() { return inputs_[1]; }
733 LOperand* temp() { return temps_[0]; }
735 DECLARE_CONCRETE_INSTRUCTION(DivI, "div-i")
736 DECLARE_HYDROGEN_ACCESSOR(BinaryOperation)
740 class LFlooringDivByPowerOf2I V8_FINAL : public LTemplateInstruction<1, 1, 0> {
742 LFlooringDivByPowerOf2I(LOperand* dividend, int32_t divisor) {
743 inputs_[0] = dividend;
747 LOperand* dividend() { return inputs_[0]; }
748 int32_t divisor() const { return divisor_; }
750 DECLARE_CONCRETE_INSTRUCTION(FlooringDivByPowerOf2I,
751 "flooring-div-by-power-of-2-i")
752 DECLARE_HYDROGEN_ACCESSOR(MathFloorOfDiv)
759 class LFlooringDivByConstI V8_FINAL : public LTemplateInstruction<1, 1, 3> {
761 LFlooringDivByConstI(LOperand* dividend,
766 inputs_[0] = dividend;
773 LOperand* dividend() { return inputs_[0]; }
774 int32_t divisor() const { return divisor_; }
775 LOperand* temp1() { return temps_[0]; }
776 LOperand* temp2() { return temps_[1]; }
777 LOperand* temp3() { return temps_[2]; }
779 DECLARE_CONCRETE_INSTRUCTION(FlooringDivByConstI, "flooring-div-by-const-i")
780 DECLARE_HYDROGEN_ACCESSOR(MathFloorOfDiv)
787 class LFlooringDivI V8_FINAL : public LTemplateInstruction<1, 2, 1> {
789 LFlooringDivI(LOperand* dividend, LOperand* divisor, LOperand* temp) {
790 inputs_[0] = dividend;
791 inputs_[1] = divisor;
795 LOperand* dividend() { return inputs_[0]; }
796 LOperand* divisor() { return inputs_[1]; }
797 LOperand* temp() { return temps_[0]; }
799 DECLARE_CONCRETE_INSTRUCTION(FlooringDivI, "flooring-div-i")
800 DECLARE_HYDROGEN_ACCESSOR(MathFloorOfDiv)
804 class LMulI V8_FINAL : public LTemplateInstruction<1, 2, 0> {
806 LMulI(LOperand* left, LOperand* right) {
811 LOperand* left() { return inputs_[0]; }
812 LOperand* right() { return inputs_[1]; }
814 DECLARE_CONCRETE_INSTRUCTION(MulI, "mul-i")
815 DECLARE_HYDROGEN_ACCESSOR(Mul)
819 class LCompareNumericAndBranch V8_FINAL : public LControlInstruction<2, 0> {
821 LCompareNumericAndBranch(LOperand* left, LOperand* right) {
826 LOperand* left() { return inputs_[0]; }
827 LOperand* right() { return inputs_[1]; }
829 DECLARE_CONCRETE_INSTRUCTION(CompareNumericAndBranch,
830 "compare-numeric-and-branch")
831 DECLARE_HYDROGEN_ACCESSOR(CompareNumericAndBranch)
833 Token::Value op() const { return hydrogen()->token(); }
834 bool is_double() const {
835 return hydrogen()->representation().IsDouble();
838 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
842 class LMathFloor V8_FINAL : public LTemplateInstruction<1, 1, 0> {
844 explicit LMathFloor(LOperand* value) {
848 LOperand* value() { return inputs_[0]; }
850 DECLARE_CONCRETE_INSTRUCTION(MathFloor, "math-floor")
851 DECLARE_HYDROGEN_ACCESSOR(UnaryMathOperation)
855 class LMathRound V8_FINAL : public LTemplateInstruction<1, 1, 1> {
857 explicit LMathRound(LOperand* value, LOperand* temp) {
862 LOperand* value() { return inputs_[0]; }
863 LOperand* temp() { return temps_[0]; }
865 DECLARE_CONCRETE_INSTRUCTION(MathRound, "math-round")
866 DECLARE_HYDROGEN_ACCESSOR(UnaryMathOperation)
870 class LMathAbs V8_FINAL : public LTemplateInstruction<1, 2, 0> {
872 explicit LMathAbs(LOperand* context, LOperand* value) {
873 inputs_[1] = context;
877 LOperand* context() { return inputs_[1]; }
878 LOperand* value() { return inputs_[0]; }
880 DECLARE_CONCRETE_INSTRUCTION(MathAbs, "math-abs")
881 DECLARE_HYDROGEN_ACCESSOR(UnaryMathOperation)
885 class LMathLog V8_FINAL : public LTemplateInstruction<1, 1, 0> {
887 explicit LMathLog(LOperand* value) {
891 LOperand* value() { return inputs_[0]; }
893 DECLARE_CONCRETE_INSTRUCTION(MathLog, "math-log")
897 class LMathClz32 V8_FINAL : public LTemplateInstruction<1, 1, 0> {
899 explicit LMathClz32(LOperand* value) {
903 LOperand* value() { return inputs_[0]; }
905 DECLARE_CONCRETE_INSTRUCTION(MathClz32, "math-clz32")
909 class LMathExp V8_FINAL : public LTemplateInstruction<1, 1, 2> {
911 LMathExp(LOperand* value, LOperand* temp1, LOperand* temp2) {
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, 0> {
940 explicit LMathPowHalf(LOperand* value) {
944 LOperand* value() { return inputs_[0]; }
946 DECLARE_CONCRETE_INSTRUCTION(MathPowHalf, "math-pow-half")
950 class LNullarySIMDOperation V8_FINAL : public LTemplateInstruction<1, 0, 0> {
952 explicit LNullarySIMDOperation(BuiltinFunctionId op)
956 BuiltinFunctionId op() const { return op_; }
958 virtual Opcode opcode() const V8_OVERRIDE {
959 return LInstruction::kNullarySIMDOperation;
961 virtual void CompileToNative(LCodeGen* generator) V8_OVERRIDE;
962 virtual const char* Mnemonic() const V8_OVERRIDE;
963 static LNullarySIMDOperation* cast(LInstruction* instr) {
964 ASSERT(instr->IsNullarySIMDOperation());
965 return reinterpret_cast<LNullarySIMDOperation*>(instr);
968 DECLARE_HYDROGEN_ACCESSOR(NullarySIMDOperation)
971 BuiltinFunctionId op_;
975 class LUnarySIMDOperation V8_FINAL : public LTemplateInstruction<1, 1, 0> {
977 LUnarySIMDOperation(LOperand* value, BuiltinFunctionId op)
982 LOperand* value() { return inputs_[0]; }
983 BuiltinFunctionId op() const { return op_; }
985 virtual Opcode opcode() const V8_OVERRIDE {
986 return LInstruction::kUnarySIMDOperation;
988 virtual void CompileToNative(LCodeGen* generator) V8_OVERRIDE;
989 virtual const char* Mnemonic() const V8_OVERRIDE;
990 static LUnarySIMDOperation* cast(LInstruction* instr) {
991 ASSERT(instr->IsUnarySIMDOperation());
992 return reinterpret_cast<LUnarySIMDOperation*>(instr);
995 DECLARE_HYDROGEN_ACCESSOR(UnarySIMDOperation)
998 BuiltinFunctionId op_;
1002 class LBinarySIMDOperation V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1004 LBinarySIMDOperation(LOperand* left, LOperand* right, BuiltinFunctionId op)
1010 LOperand* left() { return inputs_[0]; }
1011 LOperand* right() { return inputs_[1]; }
1012 BuiltinFunctionId op() const { return op_; }
1014 virtual Opcode opcode() const V8_OVERRIDE {
1015 return LInstruction::kBinarySIMDOperation;
1017 virtual void CompileToNative(LCodeGen* generator) V8_OVERRIDE;
1018 virtual const char* Mnemonic() const V8_OVERRIDE;
1019 static LBinarySIMDOperation* cast(LInstruction* instr) {
1020 ASSERT(instr->IsBinarySIMDOperation());
1021 return reinterpret_cast<LBinarySIMDOperation*>(instr);
1024 DECLARE_HYDROGEN_ACCESSOR(BinarySIMDOperation)
1027 BuiltinFunctionId op_;
1031 class LTernarySIMDOperation V8_FINAL : public LTemplateInstruction<1, 3, 0> {
1033 LTernarySIMDOperation(LOperand* first, LOperand* second, LOperand* third,
1034 BuiltinFunctionId op)
1037 inputs_[1] = second;
1041 LOperand* first() { return inputs_[0]; }
1042 LOperand* second() { return inputs_[1]; }
1043 LOperand* third() { return inputs_[2]; }
1044 BuiltinFunctionId op() const { return op_; }
1046 virtual Opcode opcode() const V8_OVERRIDE {
1047 return LInstruction::kTernarySIMDOperation;
1049 virtual void CompileToNative(LCodeGen* generator) V8_OVERRIDE;
1050 virtual const char* Mnemonic() const V8_OVERRIDE;
1051 static LTernarySIMDOperation* cast(LInstruction* instr) {
1052 ASSERT(instr->IsTernarySIMDOperation());
1053 return reinterpret_cast<LTernarySIMDOperation*>(instr);
1056 DECLARE_HYDROGEN_ACCESSOR(TernarySIMDOperation)
1059 BuiltinFunctionId op_;
1063 class LQuarternarySIMDOperation V8_FINAL
1064 : public LTemplateInstruction<1, 4, 0> {
1066 LQuarternarySIMDOperation(LOperand* x, LOperand* y, LOperand* z,
1067 LOperand* w, BuiltinFunctionId op)
1075 LOperand* x() { return inputs_[0]; }
1076 LOperand* y() { return inputs_[1]; }
1077 LOperand* z() { return inputs_[2]; }
1078 LOperand* w() { return inputs_[3]; }
1079 BuiltinFunctionId op() const { return op_; }
1081 virtual Opcode opcode() const V8_OVERRIDE {
1082 return LInstruction::kQuarternarySIMDOperation;
1084 virtual void CompileToNative(LCodeGen* generator) V8_OVERRIDE;
1085 virtual const char* Mnemonic() const V8_OVERRIDE;
1086 static LQuarternarySIMDOperation* cast(LInstruction* instr) {
1087 ASSERT(instr->IsQuarternarySIMDOperation());
1088 return reinterpret_cast<LQuarternarySIMDOperation*>(instr);
1091 DECLARE_HYDROGEN_ACCESSOR(QuarternarySIMDOperation)
1094 BuiltinFunctionId op_;
1098 class LCmpObjectEqAndBranch V8_FINAL : public LControlInstruction<2, 0> {
1100 LCmpObjectEqAndBranch(LOperand* left, LOperand* right) {
1105 LOperand* left() { return inputs_[0]; }
1106 LOperand* right() { return inputs_[1]; }
1108 DECLARE_CONCRETE_INSTRUCTION(CmpObjectEqAndBranch, "cmp-object-eq-and-branch")
1112 class LCmpHoleAndBranch V8_FINAL : public LControlInstruction<1, 0> {
1114 explicit LCmpHoleAndBranch(LOperand* object) {
1115 inputs_[0] = object;
1118 LOperand* object() { return inputs_[0]; }
1120 DECLARE_CONCRETE_INSTRUCTION(CmpHoleAndBranch, "cmp-hole-and-branch")
1121 DECLARE_HYDROGEN_ACCESSOR(CompareHoleAndBranch)
1125 class LCompareMinusZeroAndBranch V8_FINAL : public LControlInstruction<1, 0> {
1127 explicit LCompareMinusZeroAndBranch(LOperand* value) {
1131 LOperand* value() { return inputs_[0]; }
1133 DECLARE_CONCRETE_INSTRUCTION(CompareMinusZeroAndBranch,
1134 "cmp-minus-zero-and-branch")
1135 DECLARE_HYDROGEN_ACCESSOR(CompareMinusZeroAndBranch)
1140 class LIsObjectAndBranch V8_FINAL : public LControlInstruction<1, 0> {
1142 explicit LIsObjectAndBranch(LOperand* value) {
1146 LOperand* value() { return inputs_[0]; }
1148 DECLARE_CONCRETE_INSTRUCTION(IsObjectAndBranch, "is-object-and-branch")
1149 DECLARE_HYDROGEN_ACCESSOR(IsObjectAndBranch)
1151 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1155 class LIsStringAndBranch V8_FINAL : public LControlInstruction<1, 1> {
1157 explicit LIsStringAndBranch(LOperand* value, LOperand* temp) {
1162 LOperand* value() { return inputs_[0]; }
1163 LOperand* temp() { return temps_[0]; }
1165 DECLARE_CONCRETE_INSTRUCTION(IsStringAndBranch, "is-string-and-branch")
1166 DECLARE_HYDROGEN_ACCESSOR(IsStringAndBranch)
1168 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1172 class LIsSmiAndBranch V8_FINAL : public LControlInstruction<1, 0> {
1174 explicit LIsSmiAndBranch(LOperand* value) {
1178 LOperand* value() { return inputs_[0]; }
1180 DECLARE_CONCRETE_INSTRUCTION(IsSmiAndBranch, "is-smi-and-branch")
1181 DECLARE_HYDROGEN_ACCESSOR(IsSmiAndBranch)
1183 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1187 class LIsUndetectableAndBranch V8_FINAL : public LControlInstruction<1, 1> {
1189 explicit LIsUndetectableAndBranch(LOperand* value, LOperand* temp) {
1194 LOperand* value() { return inputs_[0]; }
1195 LOperand* temp() { return temps_[0]; }
1197 DECLARE_CONCRETE_INSTRUCTION(IsUndetectableAndBranch,
1198 "is-undetectable-and-branch")
1199 DECLARE_HYDROGEN_ACCESSOR(IsUndetectableAndBranch)
1201 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1205 class LStringCompareAndBranch V8_FINAL : public LControlInstruction<3, 0> {
1207 explicit LStringCompareAndBranch(LOperand* context,
1210 inputs_[0] = context;
1215 LOperand* context() { return inputs_[0]; }
1216 LOperand* left() { return inputs_[1]; }
1217 LOperand* right() { return inputs_[2]; }
1219 DECLARE_CONCRETE_INSTRUCTION(StringCompareAndBranch,
1220 "string-compare-and-branch")
1221 DECLARE_HYDROGEN_ACCESSOR(StringCompareAndBranch)
1223 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1225 Token::Value op() const { return hydrogen()->token(); }
1229 class LHasInstanceTypeAndBranch V8_FINAL : public LControlInstruction<1, 0> {
1231 explicit LHasInstanceTypeAndBranch(LOperand* value) {
1235 LOperand* value() { return inputs_[0]; }
1237 DECLARE_CONCRETE_INSTRUCTION(HasInstanceTypeAndBranch,
1238 "has-instance-type-and-branch")
1239 DECLARE_HYDROGEN_ACCESSOR(HasInstanceTypeAndBranch)
1241 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1245 class LGetCachedArrayIndex V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1247 explicit LGetCachedArrayIndex(LOperand* value) {
1251 LOperand* value() { return inputs_[0]; }
1253 DECLARE_CONCRETE_INSTRUCTION(GetCachedArrayIndex, "get-cached-array-index")
1254 DECLARE_HYDROGEN_ACCESSOR(GetCachedArrayIndex)
1258 class LHasCachedArrayIndexAndBranch V8_FINAL
1259 : public LControlInstruction<1, 0> {
1261 explicit LHasCachedArrayIndexAndBranch(LOperand* value) {
1265 LOperand* value() { return inputs_[0]; }
1267 DECLARE_CONCRETE_INSTRUCTION(HasCachedArrayIndexAndBranch,
1268 "has-cached-array-index-and-branch")
1269 DECLARE_HYDROGEN_ACCESSOR(HasCachedArrayIndexAndBranch)
1271 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1275 class LClassOfTestAndBranch V8_FINAL : public LControlInstruction<1, 2> {
1277 LClassOfTestAndBranch(LOperand* value, LOperand* temp, LOperand* temp2) {
1283 LOperand* value() { return inputs_[0]; }
1284 LOperand* temp() { return temps_[0]; }
1285 LOperand* temp2() { return temps_[1]; }
1287 DECLARE_CONCRETE_INSTRUCTION(ClassOfTestAndBranch,
1288 "class-of-test-and-branch")
1289 DECLARE_HYDROGEN_ACCESSOR(ClassOfTestAndBranch)
1291 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1295 class LCmpT V8_FINAL : public LTemplateInstruction<1, 3, 0> {
1297 LCmpT(LOperand* context, LOperand* left, LOperand* right) {
1298 inputs_[0] = context;
1303 LOperand* context() { return inputs_[0]; }
1304 LOperand* left() { return inputs_[1]; }
1305 LOperand* right() { return inputs_[2]; }
1307 DECLARE_CONCRETE_INSTRUCTION(CmpT, "cmp-t")
1308 DECLARE_HYDROGEN_ACCESSOR(CompareGeneric)
1310 Token::Value op() const { return hydrogen()->token(); }
1314 class LInstanceOf V8_FINAL : public LTemplateInstruction<1, 3, 0> {
1316 LInstanceOf(LOperand* context, LOperand* left, LOperand* right) {
1317 inputs_[0] = context;
1322 LOperand* context() { return inputs_[0]; }
1323 LOperand* left() { return inputs_[1]; }
1324 LOperand* right() { return inputs_[2]; }
1326 DECLARE_CONCRETE_INSTRUCTION(InstanceOf, "instance-of")
1330 class LInstanceOfKnownGlobal V8_FINAL : public LTemplateInstruction<1, 2, 1> {
1332 LInstanceOfKnownGlobal(LOperand* context, LOperand* value, LOperand* temp) {
1333 inputs_[0] = context;
1338 LOperand* context() { return inputs_[0]; }
1339 LOperand* value() { return inputs_[1]; }
1340 LOperand* temp() { return temps_[0]; }
1342 DECLARE_CONCRETE_INSTRUCTION(InstanceOfKnownGlobal,
1343 "instance-of-known-global")
1344 DECLARE_HYDROGEN_ACCESSOR(InstanceOfKnownGlobal)
1346 Handle<JSFunction> function() const { return hydrogen()->function(); }
1347 LEnvironment* GetDeferredLazyDeoptimizationEnvironment() {
1348 return lazy_deopt_env_;
1350 virtual void SetDeferredLazyDeoptimizationEnvironment(
1351 LEnvironment* env) V8_OVERRIDE {
1352 lazy_deopt_env_ = env;
1356 LEnvironment* lazy_deopt_env_;
1360 class LBoundsCheck V8_FINAL : public LTemplateInstruction<0, 2, 0> {
1362 LBoundsCheck(LOperand* index, LOperand* length) {
1364 inputs_[1] = length;
1367 LOperand* index() { return inputs_[0]; }
1368 LOperand* length() { return inputs_[1]; }
1370 DECLARE_CONCRETE_INSTRUCTION(BoundsCheck, "bounds-check")
1371 DECLARE_HYDROGEN_ACCESSOR(BoundsCheck)
1375 class LBitI V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1377 LBitI(LOperand* left, LOperand* right) {
1382 LOperand* left() { return inputs_[0]; }
1383 LOperand* right() { return inputs_[1]; }
1385 Token::Value op() const { return hydrogen()->op(); }
1386 bool IsInteger32() const {
1387 return hydrogen()->representation().IsInteger32();
1390 DECLARE_CONCRETE_INSTRUCTION(BitI, "bit-i")
1391 DECLARE_HYDROGEN_ACCESSOR(Bitwise)
1395 class LShiftI V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1397 LShiftI(Token::Value op, LOperand* left, LOperand* right, bool can_deopt)
1398 : op_(op), can_deopt_(can_deopt) {
1403 Token::Value op() const { return op_; }
1404 LOperand* left() { return inputs_[0]; }
1405 LOperand* right() { return inputs_[1]; }
1406 bool can_deopt() const { return can_deopt_; }
1408 DECLARE_CONCRETE_INSTRUCTION(ShiftI, "shift-i")
1416 class LSubI V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1418 LSubI(LOperand* left, LOperand* right) {
1423 LOperand* left() { return inputs_[0]; }
1424 LOperand* right() { return inputs_[1]; }
1426 DECLARE_CONCRETE_INSTRUCTION(SubI, "sub-i")
1427 DECLARE_HYDROGEN_ACCESSOR(Sub)
1431 class LConstantI V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1433 DECLARE_CONCRETE_INSTRUCTION(ConstantI, "constant-i")
1434 DECLARE_HYDROGEN_ACCESSOR(Constant)
1436 int32_t value() const { return hydrogen()->Integer32Value(); }
1440 class LConstantS V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1442 DECLARE_CONCRETE_INSTRUCTION(ConstantS, "constant-s")
1443 DECLARE_HYDROGEN_ACCESSOR(Constant)
1445 Smi* value() const { return Smi::FromInt(hydrogen()->Integer32Value()); }
1449 class LConstantD V8_FINAL : public LTemplateInstruction<1, 0, 1> {
1451 explicit LConstantD(LOperand* temp) {
1455 LOperand* temp() { return temps_[0]; }
1457 DECLARE_CONCRETE_INSTRUCTION(ConstantD, "constant-d")
1458 DECLARE_HYDROGEN_ACCESSOR(Constant)
1460 double value() const { return hydrogen()->DoubleValue(); }
1464 class LConstantE V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1466 DECLARE_CONCRETE_INSTRUCTION(ConstantE, "constant-e")
1467 DECLARE_HYDROGEN_ACCESSOR(Constant)
1469 ExternalReference value() const {
1470 return hydrogen()->ExternalReferenceValue();
1475 class LConstantT V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1477 DECLARE_CONCRETE_INSTRUCTION(ConstantT, "constant-t")
1478 DECLARE_HYDROGEN_ACCESSOR(Constant)
1480 Handle<Object> value(Isolate* isolate) const {
1481 return hydrogen()->handle(isolate);
1486 class LBranch V8_FINAL : public LControlInstruction<1, 0> {
1488 explicit LBranch(LOperand* value) {
1492 LOperand* value() { return inputs_[0]; }
1494 DECLARE_CONCRETE_INSTRUCTION(Branch, "branch")
1495 DECLARE_HYDROGEN_ACCESSOR(Branch)
1497 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1501 class LDebugBreak V8_FINAL : public LTemplateInstruction<0, 0, 0> {
1503 DECLARE_CONCRETE_INSTRUCTION(DebugBreak, "break")
1507 class LCmpMapAndBranch V8_FINAL : public LControlInstruction<1, 0> {
1509 explicit LCmpMapAndBranch(LOperand* value) {
1513 LOperand* value() { return inputs_[0]; }
1515 DECLARE_CONCRETE_INSTRUCTION(CmpMapAndBranch, "cmp-map-and-branch")
1516 DECLARE_HYDROGEN_ACCESSOR(CompareMap)
1518 Handle<Map> map() const { return hydrogen()->map().handle(); }
1522 class LMapEnumLength V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1524 explicit LMapEnumLength(LOperand* value) {
1528 LOperand* value() { return inputs_[0]; }
1530 DECLARE_CONCRETE_INSTRUCTION(MapEnumLength, "map-enum-length")
1534 class LDateField V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1536 LDateField(LOperand* date, Smi* index) : index_(index) {
1540 LOperand* date() { return inputs_[0]; }
1541 Smi* index() const { return index_; }
1543 DECLARE_CONCRETE_INSTRUCTION(DateField, "date-field")
1544 DECLARE_HYDROGEN_ACCESSOR(DateField)
1551 class LSeqStringGetChar V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1553 LSeqStringGetChar(LOperand* string, LOperand* index) {
1554 inputs_[0] = string;
1558 LOperand* string() const { return inputs_[0]; }
1559 LOperand* index() const { return inputs_[1]; }
1561 DECLARE_CONCRETE_INSTRUCTION(SeqStringGetChar, "seq-string-get-char")
1562 DECLARE_HYDROGEN_ACCESSOR(SeqStringGetChar)
1566 class LSeqStringSetChar V8_FINAL : public LTemplateInstruction<1, 4, 0> {
1568 LSeqStringSetChar(LOperand* context,
1572 inputs_[0] = context;
1573 inputs_[1] = string;
1578 LOperand* string() { return inputs_[1]; }
1579 LOperand* index() { return inputs_[2]; }
1580 LOperand* value() { return inputs_[3]; }
1582 DECLARE_CONCRETE_INSTRUCTION(SeqStringSetChar, "seq-string-set-char")
1583 DECLARE_HYDROGEN_ACCESSOR(SeqStringSetChar)
1587 class LAddI V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1589 LAddI(LOperand* left, LOperand* right) {
1594 LOperand* left() { return inputs_[0]; }
1595 LOperand* right() { return inputs_[1]; }
1597 static bool UseLea(HAdd* add) {
1598 return !add->CheckFlag(HValue::kCanOverflow) &&
1599 add->BetterLeftOperand()->UseCount() > 1;
1602 DECLARE_CONCRETE_INSTRUCTION(AddI, "add-i")
1603 DECLARE_HYDROGEN_ACCESSOR(Add)
1607 class LMathMinMax V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1609 LMathMinMax(LOperand* left, LOperand* right) {
1614 LOperand* left() { return inputs_[0]; }
1615 LOperand* right() { return inputs_[1]; }
1617 DECLARE_CONCRETE_INSTRUCTION(MathMinMax, "math-min-max")
1618 DECLARE_HYDROGEN_ACCESSOR(MathMinMax)
1622 class LPower V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1624 LPower(LOperand* left, LOperand* right) {
1629 LOperand* left() { return inputs_[0]; }
1630 LOperand* right() { return inputs_[1]; }
1632 DECLARE_CONCRETE_INSTRUCTION(Power, "power")
1633 DECLARE_HYDROGEN_ACCESSOR(Power)
1637 class LArithmeticD V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1639 LArithmeticD(Token::Value op, LOperand* left, LOperand* right)
1645 Token::Value op() const { return op_; }
1646 LOperand* left() { return inputs_[0]; }
1647 LOperand* right() { return inputs_[1]; }
1649 virtual Opcode opcode() const V8_OVERRIDE {
1650 return LInstruction::kArithmeticD;
1652 virtual void CompileToNative(LCodeGen* generator) V8_OVERRIDE;
1653 virtual const char* Mnemonic() const V8_OVERRIDE;
1660 class LArithmeticT V8_FINAL : public LTemplateInstruction<1, 3, 0> {
1662 LArithmeticT(Token::Value op,
1667 inputs_[0] = context;
1672 Token::Value op() const { return op_; }
1673 LOperand* context() { return inputs_[0]; }
1674 LOperand* left() { return inputs_[1]; }
1675 LOperand* right() { return inputs_[2]; }
1677 virtual Opcode opcode() const V8_OVERRIDE {
1678 return LInstruction::kArithmeticT;
1680 virtual void CompileToNative(LCodeGen* generator) V8_OVERRIDE;
1681 virtual const char* Mnemonic() const V8_OVERRIDE;
1688 class LReturn V8_FINAL : public LTemplateInstruction<0, 3, 0> {
1690 explicit LReturn(LOperand* value,
1692 LOperand* parameter_count) {
1694 inputs_[1] = context;
1695 inputs_[2] = parameter_count;
1698 LOperand* value() { return inputs_[0]; }
1699 LOperand* context() { return inputs_[1]; }
1701 bool has_constant_parameter_count() {
1702 return parameter_count()->IsConstantOperand();
1704 LConstantOperand* constant_parameter_count() {
1705 ASSERT(has_constant_parameter_count());
1706 return LConstantOperand::cast(parameter_count());
1708 LOperand* parameter_count() { return inputs_[2]; }
1710 DECLARE_CONCRETE_INSTRUCTION(Return, "return")
1711 DECLARE_HYDROGEN_ACCESSOR(Return)
1715 class LLoadNamedField V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1717 explicit LLoadNamedField(LOperand* object) {
1718 inputs_[0] = object;
1721 LOperand* object() { return inputs_[0]; }
1723 DECLARE_CONCRETE_INSTRUCTION(LoadNamedField, "load-named-field")
1724 DECLARE_HYDROGEN_ACCESSOR(LoadNamedField)
1728 class LLoadNamedGeneric V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1730 explicit LLoadNamedGeneric(LOperand* context, LOperand* object) {
1731 inputs_[0] = context;
1732 inputs_[1] = object;
1735 DECLARE_CONCRETE_INSTRUCTION(LoadNamedGeneric, "load-named-generic")
1736 DECLARE_HYDROGEN_ACCESSOR(LoadNamedGeneric)
1738 LOperand* context() { return inputs_[0]; }
1739 LOperand* object() { return inputs_[1]; }
1740 Handle<Object> name() const { return hydrogen()->name(); }
1744 class LLoadFunctionPrototype V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1746 explicit LLoadFunctionPrototype(LOperand* function) {
1747 inputs_[0] = function;
1750 DECLARE_CONCRETE_INSTRUCTION(LoadFunctionPrototype, "load-function-prototype")
1751 DECLARE_HYDROGEN_ACCESSOR(LoadFunctionPrototype)
1753 LOperand* function() { return inputs_[0]; }
1757 class LLoadRoot V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1759 DECLARE_CONCRETE_INSTRUCTION(LoadRoot, "load-root")
1760 DECLARE_HYDROGEN_ACCESSOR(LoadRoot)
1762 Heap::RootListIndex index() const { return hydrogen()->index(); }
1766 inline static bool ExternalArrayOpRequiresPreScale(
1767 Representation key_representation,
1768 ElementsKind kind) {
1769 int shift_size = ElementsKindToShiftSize(kind);
1770 return SmiValuesAre31Bits() && key_representation.IsSmi()
1771 ? shift_size > static_cast<int>(maximal_scale_factor) + kSmiTagSize
1772 : shift_size > static_cast<int>(maximal_scale_factor);
1776 inline static bool ExternalArrayOpRequiresTemp(
1777 Representation key_representation,
1778 ElementsKind elements_kind) {
1779 // Operations that require the key to be divided by two to be converted into
1780 // an index cannot fold the scale operation into a load and need an extra
1781 // temp register to do the work.
1782 return ExternalArrayOpRequiresPreScale(key_representation, elements_kind) ||
1783 (SmiValuesAre31Bits() && key_representation.IsSmi() &&
1784 (elements_kind == EXTERNAL_INT8_ELEMENTS ||
1785 elements_kind == EXTERNAL_UINT8_ELEMENTS ||
1786 elements_kind == EXTERNAL_UINT8_CLAMPED_ELEMENTS ||
1787 elements_kind == UINT8_ELEMENTS ||
1788 elements_kind == INT8_ELEMENTS ||
1789 elements_kind == UINT8_CLAMPED_ELEMENTS));
1793 class LLoadKeyed V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1795 LLoadKeyed(LOperand* elements, LOperand* key) {
1796 inputs_[0] = elements;
1800 DECLARE_CONCRETE_INSTRUCTION(LoadKeyed, "load-keyed")
1801 DECLARE_HYDROGEN_ACCESSOR(LoadKeyed)
1803 bool is_external() const {
1804 return hydrogen()->is_external();
1806 bool is_fixed_typed_array() const {
1807 return hydrogen()->is_fixed_typed_array();
1809 bool is_typed_elements() const {
1810 return is_external() || is_fixed_typed_array();
1812 LOperand* elements() { return inputs_[0]; }
1813 LOperand* key() { return inputs_[1]; }
1814 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1815 uint32_t base_offset() const { return hydrogen()->base_offset(); }
1816 ElementsKind elements_kind() const {
1817 return hydrogen()->elements_kind();
1822 class LLoadKeyedGeneric V8_FINAL : public LTemplateInstruction<1, 3, 0> {
1824 LLoadKeyedGeneric(LOperand* context, LOperand* obj, LOperand* key) {
1825 inputs_[0] = context;
1830 DECLARE_CONCRETE_INSTRUCTION(LoadKeyedGeneric, "load-keyed-generic")
1832 LOperand* context() { return inputs_[0]; }
1833 LOperand* object() { return inputs_[1]; }
1834 LOperand* key() { return inputs_[2]; }
1838 class LLoadGlobalCell V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1840 DECLARE_CONCRETE_INSTRUCTION(LoadGlobalCell, "load-global-cell")
1841 DECLARE_HYDROGEN_ACCESSOR(LoadGlobalCell)
1845 class LLoadGlobalGeneric V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1847 explicit LLoadGlobalGeneric(LOperand* context, LOperand* global_object) {
1848 inputs_[0] = context;
1849 inputs_[1] = global_object;
1852 DECLARE_CONCRETE_INSTRUCTION(LoadGlobalGeneric, "load-global-generic")
1853 DECLARE_HYDROGEN_ACCESSOR(LoadGlobalGeneric)
1855 LOperand* context() { return inputs_[0]; }
1856 LOperand* global_object() { return inputs_[1]; }
1857 Handle<Object> name() const { return hydrogen()->name(); }
1858 bool for_typeof() const { return hydrogen()->for_typeof(); }
1862 class LStoreGlobalCell V8_FINAL : public LTemplateInstruction<0, 1, 1> {
1864 explicit LStoreGlobalCell(LOperand* value, LOperand* temp) {
1869 LOperand* value() { return inputs_[0]; }
1870 LOperand* temp() { return temps_[0]; }
1872 DECLARE_CONCRETE_INSTRUCTION(StoreGlobalCell, "store-global-cell")
1873 DECLARE_HYDROGEN_ACCESSOR(StoreGlobalCell)
1877 class LLoadContextSlot V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1879 explicit LLoadContextSlot(LOperand* context) {
1880 inputs_[0] = context;
1883 LOperand* context() { return inputs_[0]; }
1885 DECLARE_CONCRETE_INSTRUCTION(LoadContextSlot, "load-context-slot")
1886 DECLARE_HYDROGEN_ACCESSOR(LoadContextSlot)
1888 int slot_index() { return hydrogen()->slot_index(); }
1890 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1894 class LStoreContextSlot V8_FINAL : public LTemplateInstruction<0, 2, 1> {
1896 LStoreContextSlot(LOperand* context, LOperand* value, LOperand* temp) {
1897 inputs_[0] = context;
1902 LOperand* context() { return inputs_[0]; }
1903 LOperand* value() { return inputs_[1]; }
1904 LOperand* temp() { return temps_[0]; }
1906 DECLARE_CONCRETE_INSTRUCTION(StoreContextSlot, "store-context-slot")
1907 DECLARE_HYDROGEN_ACCESSOR(StoreContextSlot)
1909 int slot_index() { return hydrogen()->slot_index(); }
1911 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1915 class LPushArgument V8_FINAL : public LTemplateInstruction<0, 1, 0> {
1917 explicit LPushArgument(LOperand* value) {
1921 LOperand* value() { return inputs_[0]; }
1923 DECLARE_CONCRETE_INSTRUCTION(PushArgument, "push-argument")
1927 class LDrop V8_FINAL : public LTemplateInstruction<0, 0, 0> {
1929 explicit LDrop(int count) : count_(count) { }
1931 int count() const { return count_; }
1933 DECLARE_CONCRETE_INSTRUCTION(Drop, "drop")
1940 class LStoreCodeEntry V8_FINAL: public LTemplateInstruction<0, 2, 0> {
1942 LStoreCodeEntry(LOperand* function, LOperand* code_object) {
1943 inputs_[0] = function;
1944 inputs_[1] = code_object;
1947 LOperand* function() { return inputs_[0]; }
1948 LOperand* code_object() { return inputs_[1]; }
1950 virtual void PrintDataTo(StringStream* stream);
1952 DECLARE_CONCRETE_INSTRUCTION(StoreCodeEntry, "store-code-entry")
1953 DECLARE_HYDROGEN_ACCESSOR(StoreCodeEntry)
1957 class LInnerAllocatedObject V8_FINAL: public LTemplateInstruction<1, 2, 0> {
1959 LInnerAllocatedObject(LOperand* base_object, LOperand* offset) {
1960 inputs_[0] = base_object;
1961 inputs_[1] = offset;
1964 LOperand* base_object() const { return inputs_[0]; }
1965 LOperand* offset() const { return inputs_[1]; }
1967 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1969 DECLARE_CONCRETE_INSTRUCTION(InnerAllocatedObject, "inner-allocated-object")
1973 class LThisFunction V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1975 DECLARE_CONCRETE_INSTRUCTION(ThisFunction, "this-function")
1976 DECLARE_HYDROGEN_ACCESSOR(ThisFunction)
1980 class LContext V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1982 DECLARE_CONCRETE_INSTRUCTION(Context, "context")
1983 DECLARE_HYDROGEN_ACCESSOR(Context)
1987 class LDeclareGlobals V8_FINAL : public LTemplateInstruction<0, 1, 0> {
1989 explicit LDeclareGlobals(LOperand* context) {
1990 inputs_[0] = context;
1993 LOperand* context() { return inputs_[0]; }
1995 DECLARE_CONCRETE_INSTRUCTION(DeclareGlobals, "declare-globals")
1996 DECLARE_HYDROGEN_ACCESSOR(DeclareGlobals)
2000 class LCallJSFunction V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2002 explicit LCallJSFunction(LOperand* function) {
2003 inputs_[0] = function;
2006 LOperand* function() { return inputs_[0]; }
2008 DECLARE_CONCRETE_INSTRUCTION(CallJSFunction, "call-js-function")
2009 DECLARE_HYDROGEN_ACCESSOR(CallJSFunction)
2011 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
2013 int arity() const { return hydrogen()->argument_count() - 1; }
2017 class LCallWithDescriptor V8_FINAL : public LTemplateResultInstruction<1> {
2019 LCallWithDescriptor(const CallInterfaceDescriptor* descriptor,
2020 const ZoneList<LOperand*>& operands,
2022 : inputs_(descriptor->environment_length() + 1, zone) {
2023 ASSERT(descriptor->environment_length() + 1 == operands.length());
2024 inputs_.AddAll(operands, zone);
2027 LOperand* target() const { return inputs_[0]; }
2030 DECLARE_CONCRETE_INSTRUCTION(CallWithDescriptor, "call-with-descriptor")
2031 DECLARE_HYDROGEN_ACCESSOR(CallWithDescriptor)
2033 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
2035 int arity() const { return hydrogen()->argument_count() - 1; }
2037 ZoneList<LOperand*> inputs_;
2039 // Iterator support.
2040 virtual int InputCount() V8_FINAL V8_OVERRIDE { return inputs_.length(); }
2041 virtual LOperand* InputAt(int i) V8_FINAL V8_OVERRIDE { return inputs_[i]; }
2043 virtual int TempCount() V8_FINAL V8_OVERRIDE { return 0; }
2044 virtual LOperand* TempAt(int i) V8_FINAL V8_OVERRIDE { return NULL; }
2048 class LInvokeFunction V8_FINAL : public LTemplateInstruction<1, 2, 0> {
2050 LInvokeFunction(LOperand* context, LOperand* function) {
2051 inputs_[0] = context;
2052 inputs_[1] = function;
2055 LOperand* context() { return inputs_[0]; }
2056 LOperand* function() { return inputs_[1]; }
2058 DECLARE_CONCRETE_INSTRUCTION(InvokeFunction, "invoke-function")
2059 DECLARE_HYDROGEN_ACCESSOR(InvokeFunction)
2061 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
2063 int arity() const { return hydrogen()->argument_count() - 1; }
2067 class LCallFunction V8_FINAL : public LTemplateInstruction<1, 2, 0> {
2069 LCallFunction(LOperand* context, LOperand* function) {
2070 inputs_[0] = context;
2071 inputs_[1] = function;
2074 DECLARE_CONCRETE_INSTRUCTION(CallFunction, "call-function")
2075 DECLARE_HYDROGEN_ACCESSOR(CallFunction)
2077 LOperand* context() { return inputs_[0]; }
2078 LOperand* function() { return inputs_[1]; }
2079 int arity() const { return hydrogen()->argument_count() - 1; }
2083 class LCallNew V8_FINAL : public LTemplateInstruction<1, 2, 0> {
2085 LCallNew(LOperand* context, LOperand* constructor) {
2086 inputs_[0] = context;
2087 inputs_[1] = constructor;
2090 LOperand* context() { return inputs_[0]; }
2091 LOperand* constructor() { return inputs_[1]; }
2093 DECLARE_CONCRETE_INSTRUCTION(CallNew, "call-new")
2094 DECLARE_HYDROGEN_ACCESSOR(CallNew)
2096 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
2098 int arity() const { return hydrogen()->argument_count() - 1; }
2102 class LCallNewArray V8_FINAL : public LTemplateInstruction<1, 2, 0> {
2104 LCallNewArray(LOperand* context, LOperand* constructor) {
2105 inputs_[0] = context;
2106 inputs_[1] = constructor;
2109 LOperand* context() { return inputs_[0]; }
2110 LOperand* constructor() { return inputs_[1]; }
2112 DECLARE_CONCRETE_INSTRUCTION(CallNewArray, "call-new-array")
2113 DECLARE_HYDROGEN_ACCESSOR(CallNewArray)
2115 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
2117 int arity() const { return hydrogen()->argument_count() - 1; }
2121 class LCallRuntime V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2123 explicit LCallRuntime(LOperand* context) {
2124 inputs_[0] = context;
2127 LOperand* context() { return inputs_[0]; }
2129 DECLARE_CONCRETE_INSTRUCTION(CallRuntime, "call-runtime")
2130 DECLARE_HYDROGEN_ACCESSOR(CallRuntime)
2132 virtual bool ClobbersDoubleRegisters(Isolate* isolate) const V8_OVERRIDE {
2133 return save_doubles() == kDontSaveFPRegs;
2136 const Runtime::Function* function() const { return hydrogen()->function(); }
2137 int arity() const { return hydrogen()->argument_count(); }
2138 SaveFPRegsMode save_doubles() const { return hydrogen()->save_doubles(); }
2142 class LInteger32ToDouble V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2144 explicit LInteger32ToDouble(LOperand* value) {
2148 LOperand* value() { return inputs_[0]; }
2150 DECLARE_CONCRETE_INSTRUCTION(Integer32ToDouble, "int32-to-double")
2154 class LUint32ToDouble V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2156 explicit LUint32ToDouble(LOperand* value) {
2160 LOperand* value() { return inputs_[0]; }
2162 DECLARE_CONCRETE_INSTRUCTION(Uint32ToDouble, "uint32-to-double")
2166 class LNumberTagI V8_FINAL : public LTemplateInstruction<1, 1, 2> {
2168 LNumberTagI(LOperand* value, LOperand* temp1, LOperand* temp2) {
2174 LOperand* value() { return inputs_[0]; }
2175 LOperand* temp1() { return temps_[0]; }
2176 LOperand* temp2() { return temps_[1]; }
2178 DECLARE_CONCRETE_INSTRUCTION(NumberTagI, "number-tag-i")
2182 class LNumberTagU V8_FINAL : public LTemplateInstruction<1, 1, 2> {
2184 LNumberTagU(LOperand* value, LOperand* temp1, LOperand* temp2) {
2190 LOperand* value() { return inputs_[0]; }
2191 LOperand* temp1() { return temps_[0]; }
2192 LOperand* temp2() { return temps_[1]; }
2194 DECLARE_CONCRETE_INSTRUCTION(NumberTagU, "number-tag-u")
2198 class LNumberTagD V8_FINAL : public LTemplateInstruction<1, 1, 1> {
2200 explicit LNumberTagD(LOperand* value, LOperand* temp) {
2205 LOperand* value() { return inputs_[0]; }
2206 LOperand* temp() { return temps_[0]; }
2208 DECLARE_CONCRETE_INSTRUCTION(NumberTagD, "number-tag-d")
2209 DECLARE_HYDROGEN_ACCESSOR(Change)
2213 class LSIMD128ToTagged V8_FINAL : public LTemplateInstruction<1, 1, 3> {
2215 explicit LSIMD128ToTagged(LOperand* value, LOperand* temp,
2216 LOperand* temp2, LOperand* temp3) {
2223 LOperand* value() { return inputs_[0]; }
2224 LOperand* temp() { return temps_[0]; }
2225 LOperand* temp2() { return temps_[1]; }
2226 LOperand* temp3() { return temps_[2]; }
2228 DECLARE_CONCRETE_INSTRUCTION(SIMD128ToTagged, "simd128-tag")
2229 DECLARE_HYDROGEN_ACCESSOR(Change)
2233 // Sometimes truncating conversion from a tagged value to an int32.
2234 class LDoubleToI V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2236 explicit LDoubleToI(LOperand* value) {
2240 LOperand* value() { return inputs_[0]; }
2242 DECLARE_CONCRETE_INSTRUCTION(DoubleToI, "double-to-i")
2243 DECLARE_HYDROGEN_ACCESSOR(UnaryOperation)
2245 bool truncating() { return hydrogen()->CanTruncateToInt32(); }
2249 class LDoubleToSmi V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2251 explicit LDoubleToSmi(LOperand* value) {
2255 LOperand* value() { return inputs_[0]; }
2257 DECLARE_CONCRETE_INSTRUCTION(DoubleToSmi, "double-to-smi")
2258 DECLARE_HYDROGEN_ACCESSOR(UnaryOperation)
2262 // Truncating conversion from a tagged value to an int32.
2263 class LTaggedToI V8_FINAL : public LTemplateInstruction<1, 1, 1> {
2265 LTaggedToI(LOperand* value, LOperand* temp) {
2270 LOperand* value() { return inputs_[0]; }
2271 LOperand* temp() { return temps_[0]; }
2273 DECLARE_CONCRETE_INSTRUCTION(TaggedToI, "tagged-to-i")
2274 DECLARE_HYDROGEN_ACCESSOR(Change)
2276 bool truncating() { return hydrogen()->CanTruncateToInt32(); }
2280 class LSmiTag V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2282 explicit LSmiTag(LOperand* value) {
2286 LOperand* value() { return inputs_[0]; }
2288 DECLARE_CONCRETE_INSTRUCTION(SmiTag, "smi-tag")
2289 DECLARE_HYDROGEN_ACCESSOR(Change)
2293 class LNumberUntagD V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2295 explicit LNumberUntagD(LOperand* value) {
2299 LOperand* value() { return inputs_[0]; }
2301 DECLARE_CONCRETE_INSTRUCTION(NumberUntagD, "double-untag")
2302 DECLARE_HYDROGEN_ACCESSOR(Change);
2306 class LTaggedToSIMD128 V8_FINAL : public LTemplateInstruction<1, 1, 1> {
2308 explicit LTaggedToSIMD128(LOperand* value, LOperand* temp,
2309 Representation representation)
2310 : representation_(representation) {
2315 LOperand* value() { return inputs_[0]; }
2316 LOperand* temp() { return temps_[0]; }
2317 Representation representation() const { return representation_; }
2319 DECLARE_CONCRETE_INSTRUCTION(TaggedToSIMD128, "simd128-untag")
2320 DECLARE_HYDROGEN_ACCESSOR(Change);
2322 Representation representation_;
2326 class LSmiUntag V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2328 LSmiUntag(LOperand* value, bool needs_check)
2329 : needs_check_(needs_check) {
2333 LOperand* value() { return inputs_[0]; }
2334 bool needs_check() const { return needs_check_; }
2336 DECLARE_CONCRETE_INSTRUCTION(SmiUntag, "smi-untag")
2343 class LStoreNamedField V8_FINAL : public LTemplateInstruction<0, 2, 1> {
2345 LStoreNamedField(LOperand* object, LOperand* value, LOperand* temp) {
2346 inputs_[0] = object;
2351 LOperand* object() { return inputs_[0]; }
2352 LOperand* value() { return inputs_[1]; }
2353 LOperand* temp() { return temps_[0]; }
2355 DECLARE_CONCRETE_INSTRUCTION(StoreNamedField, "store-named-field")
2356 DECLARE_HYDROGEN_ACCESSOR(StoreNamedField)
2358 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
2360 Representation representation() const {
2361 return hydrogen()->field_representation();
2366 class LStoreNamedGeneric V8_FINAL : public LTemplateInstruction<0, 3, 0> {
2368 LStoreNamedGeneric(LOperand* context, LOperand* object, LOperand* value) {
2369 inputs_[0] = context;
2370 inputs_[1] = object;
2374 LOperand* context() { return inputs_[0]; }
2375 LOperand* object() { return inputs_[1]; }
2376 LOperand* value() { return inputs_[2]; }
2378 DECLARE_CONCRETE_INSTRUCTION(StoreNamedGeneric, "store-named-generic")
2379 DECLARE_HYDROGEN_ACCESSOR(StoreNamedGeneric)
2381 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
2383 Handle<Object> name() const { return hydrogen()->name(); }
2384 StrictMode strict_mode() { return hydrogen()->strict_mode(); }
2388 class LStoreKeyed V8_FINAL : public LTemplateInstruction<0, 3, 0> {
2390 LStoreKeyed(LOperand* object, LOperand* key, LOperand* value) {
2391 inputs_[0] = object;
2396 bool is_external() const { return hydrogen()->is_external(); }
2397 bool is_fixed_typed_array() const {
2398 return hydrogen()->is_fixed_typed_array();
2400 bool is_typed_elements() const {
2401 return is_external() || is_fixed_typed_array();
2403 LOperand* elements() { return inputs_[0]; }
2404 LOperand* key() { return inputs_[1]; }
2405 LOperand* value() { return inputs_[2]; }
2406 ElementsKind elements_kind() const { return hydrogen()->elements_kind(); }
2408 DECLARE_CONCRETE_INSTRUCTION(StoreKeyed, "store-keyed")
2409 DECLARE_HYDROGEN_ACCESSOR(StoreKeyed)
2411 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
2412 bool NeedsCanonicalization() { return hydrogen()->NeedsCanonicalization(); }
2413 uint32_t base_offset() const { return hydrogen()->base_offset(); }
2417 class LStoreKeyedGeneric V8_FINAL : public LTemplateInstruction<0, 4, 0> {
2419 LStoreKeyedGeneric(LOperand* context,
2423 inputs_[0] = context;
2424 inputs_[1] = object;
2429 LOperand* context() { return inputs_[0]; }
2430 LOperand* object() { return inputs_[1]; }
2431 LOperand* key() { return inputs_[2]; }
2432 LOperand* value() { return inputs_[3]; }
2434 DECLARE_CONCRETE_INSTRUCTION(StoreKeyedGeneric, "store-keyed-generic")
2435 DECLARE_HYDROGEN_ACCESSOR(StoreKeyedGeneric)
2437 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
2439 StrictMode strict_mode() { return hydrogen()->strict_mode(); }
2443 class LTransitionElementsKind V8_FINAL : public LTemplateInstruction<0, 2, 2> {
2445 LTransitionElementsKind(LOperand* object,
2447 LOperand* new_map_temp,
2449 inputs_[0] = object;
2450 inputs_[1] = context;
2451 temps_[0] = new_map_temp;
2455 LOperand* object() { return inputs_[0]; }
2456 LOperand* context() { return inputs_[1]; }
2457 LOperand* new_map_temp() { return temps_[0]; }
2458 LOperand* temp() { return temps_[1]; }
2460 DECLARE_CONCRETE_INSTRUCTION(TransitionElementsKind,
2461 "transition-elements-kind")
2462 DECLARE_HYDROGEN_ACCESSOR(TransitionElementsKind)
2464 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
2466 Handle<Map> original_map() { return hydrogen()->original_map().handle(); }
2467 Handle<Map> transitioned_map() {
2468 return hydrogen()->transitioned_map().handle();
2470 ElementsKind from_kind() { return hydrogen()->from_kind(); }
2471 ElementsKind to_kind() { return hydrogen()->to_kind(); }
2475 class LTrapAllocationMemento V8_FINAL : public LTemplateInstruction<0, 1, 1> {
2477 LTrapAllocationMemento(LOperand* object,
2479 inputs_[0] = object;
2483 LOperand* object() { return inputs_[0]; }
2484 LOperand* temp() { return temps_[0]; }
2486 DECLARE_CONCRETE_INSTRUCTION(TrapAllocationMemento,
2487 "trap-allocation-memento")
2491 class LStringAdd V8_FINAL : public LTemplateInstruction<1, 3, 0> {
2493 LStringAdd(LOperand* context, LOperand* left, LOperand* right) {
2494 inputs_[0] = context;
2499 LOperand* context() { return inputs_[0]; }
2500 LOperand* left() { return inputs_[1]; }
2501 LOperand* right() { return inputs_[2]; }
2503 DECLARE_CONCRETE_INSTRUCTION(StringAdd, "string-add")
2504 DECLARE_HYDROGEN_ACCESSOR(StringAdd)
2508 class LStringCharCodeAt V8_FINAL : public LTemplateInstruction<1, 3, 0> {
2510 LStringCharCodeAt(LOperand* context, LOperand* string, LOperand* index) {
2511 inputs_[0] = context;
2512 inputs_[1] = string;
2516 LOperand* context() { return inputs_[0]; }
2517 LOperand* string() { return inputs_[1]; }
2518 LOperand* index() { return inputs_[2]; }
2520 DECLARE_CONCRETE_INSTRUCTION(StringCharCodeAt, "string-char-code-at")
2521 DECLARE_HYDROGEN_ACCESSOR(StringCharCodeAt)
2525 class LStringCharFromCode V8_FINAL : public LTemplateInstruction<1, 2, 0> {
2527 explicit LStringCharFromCode(LOperand* context, LOperand* char_code) {
2528 inputs_[0] = context;
2529 inputs_[1] = char_code;
2532 LOperand* context() { return inputs_[0]; }
2533 LOperand* char_code() { return inputs_[1]; }
2535 DECLARE_CONCRETE_INSTRUCTION(StringCharFromCode, "string-char-from-code")
2536 DECLARE_HYDROGEN_ACCESSOR(StringCharFromCode)
2540 class LCheckValue V8_FINAL : public LTemplateInstruction<0, 1, 0> {
2542 explicit LCheckValue(LOperand* value) {
2546 LOperand* value() { return inputs_[0]; }
2548 DECLARE_CONCRETE_INSTRUCTION(CheckValue, "check-value")
2549 DECLARE_HYDROGEN_ACCESSOR(CheckValue)
2553 class LCheckInstanceType V8_FINAL : public LTemplateInstruction<0, 1, 0> {
2555 explicit LCheckInstanceType(LOperand* value) {
2559 LOperand* value() { return inputs_[0]; }
2561 DECLARE_CONCRETE_INSTRUCTION(CheckInstanceType, "check-instance-type")
2562 DECLARE_HYDROGEN_ACCESSOR(CheckInstanceType)
2566 class LCheckMaps V8_FINAL : public LTemplateInstruction<0, 1, 0> {
2568 explicit LCheckMaps(LOperand* value = NULL) {
2572 LOperand* value() { return inputs_[0]; }
2574 DECLARE_CONCRETE_INSTRUCTION(CheckMaps, "check-maps")
2575 DECLARE_HYDROGEN_ACCESSOR(CheckMaps)
2579 class LCheckSmi V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2581 explicit LCheckSmi(LOperand* value) {
2585 LOperand* value() { return inputs_[0]; }
2587 DECLARE_CONCRETE_INSTRUCTION(CheckSmi, "check-smi")
2591 class LClampDToUint8 V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2593 explicit LClampDToUint8(LOperand* unclamped) {
2594 inputs_[0] = unclamped;
2597 LOperand* unclamped() { return inputs_[0]; }
2599 DECLARE_CONCRETE_INSTRUCTION(ClampDToUint8, "clamp-d-to-uint8")
2603 class LClampIToUint8 V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2605 explicit LClampIToUint8(LOperand* unclamped) {
2606 inputs_[0] = unclamped;
2609 LOperand* unclamped() { return inputs_[0]; }
2611 DECLARE_CONCRETE_INSTRUCTION(ClampIToUint8, "clamp-i-to-uint8")
2615 class LClampTToUint8 V8_FINAL : public LTemplateInstruction<1, 1, 1> {
2617 LClampTToUint8(LOperand* unclamped,
2618 LOperand* temp_xmm) {
2619 inputs_[0] = unclamped;
2620 temps_[0] = temp_xmm;
2623 LOperand* unclamped() { return inputs_[0]; }
2624 LOperand* temp_xmm() { return temps_[0]; }
2626 DECLARE_CONCRETE_INSTRUCTION(ClampTToUint8, "clamp-t-to-uint8")
2630 class LCheckNonSmi V8_FINAL : public LTemplateInstruction<0, 1, 0> {
2632 explicit LCheckNonSmi(LOperand* value) {
2636 LOperand* value() { return inputs_[0]; }
2638 DECLARE_CONCRETE_INSTRUCTION(CheckNonSmi, "check-non-smi")
2639 DECLARE_HYDROGEN_ACCESSOR(CheckHeapObject)
2643 class LDoubleBits V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2645 explicit LDoubleBits(LOperand* value) {
2649 LOperand* value() { return inputs_[0]; }
2651 DECLARE_CONCRETE_INSTRUCTION(DoubleBits, "double-bits")
2652 DECLARE_HYDROGEN_ACCESSOR(DoubleBits)
2656 class LConstructDouble V8_FINAL : public LTemplateInstruction<1, 2, 0> {
2658 LConstructDouble(LOperand* hi, LOperand* lo) {
2663 LOperand* hi() { return inputs_[0]; }
2664 LOperand* lo() { return inputs_[1]; }
2666 DECLARE_CONCRETE_INSTRUCTION(ConstructDouble, "construct-double")
2670 class LAllocate V8_FINAL : public LTemplateInstruction<1, 2, 1> {
2672 LAllocate(LOperand* context, LOperand* size, LOperand* temp) {
2673 inputs_[0] = context;
2678 LOperand* context() { return inputs_[0]; }
2679 LOperand* size() { return inputs_[1]; }
2680 LOperand* temp() { return temps_[0]; }
2682 DECLARE_CONCRETE_INSTRUCTION(Allocate, "allocate")
2683 DECLARE_HYDROGEN_ACCESSOR(Allocate)
2687 class LRegExpLiteral V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2689 explicit LRegExpLiteral(LOperand* context) {
2690 inputs_[0] = context;
2693 LOperand* context() { return inputs_[0]; }
2695 DECLARE_CONCRETE_INSTRUCTION(RegExpLiteral, "regexp-literal")
2696 DECLARE_HYDROGEN_ACCESSOR(RegExpLiteral)
2700 class LFunctionLiteral V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2702 explicit LFunctionLiteral(LOperand* context) {
2703 inputs_[0] = context;
2706 LOperand* context() { return inputs_[0]; }
2708 DECLARE_CONCRETE_INSTRUCTION(FunctionLiteral, "function-literal")
2709 DECLARE_HYDROGEN_ACCESSOR(FunctionLiteral)
2713 class LToFastProperties V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2715 explicit LToFastProperties(LOperand* value) {
2719 LOperand* value() { return inputs_[0]; }
2721 DECLARE_CONCRETE_INSTRUCTION(ToFastProperties, "to-fast-properties")
2722 DECLARE_HYDROGEN_ACCESSOR(ToFastProperties)
2726 class LTypeof V8_FINAL : public LTemplateInstruction<1, 2, 0> {
2728 LTypeof(LOperand* context, LOperand* value) {
2729 inputs_[0] = context;
2733 LOperand* context() { return inputs_[0]; }
2734 LOperand* value() { return inputs_[1]; }
2736 DECLARE_CONCRETE_INSTRUCTION(Typeof, "typeof")
2740 class LTypeofIsAndBranch V8_FINAL : public LControlInstruction<1, 0> {
2742 explicit LTypeofIsAndBranch(LOperand* value) {
2746 LOperand* value() { return inputs_[0]; }
2748 DECLARE_CONCRETE_INSTRUCTION(TypeofIsAndBranch, "typeof-is-and-branch")
2749 DECLARE_HYDROGEN_ACCESSOR(TypeofIsAndBranch)
2751 Handle<String> type_literal() { return hydrogen()->type_literal(); }
2753 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
2757 class LIsConstructCallAndBranch V8_FINAL : public LControlInstruction<0, 1> {
2759 explicit LIsConstructCallAndBranch(LOperand* temp) {
2763 LOperand* temp() { return temps_[0]; }
2765 DECLARE_CONCRETE_INSTRUCTION(IsConstructCallAndBranch,
2766 "is-construct-call-and-branch")
2767 DECLARE_HYDROGEN_ACCESSOR(IsConstructCallAndBranch)
2771 class LOsrEntry V8_FINAL : public LTemplateInstruction<0, 0, 0> {
2775 virtual bool HasInterestingComment(LCodeGen* gen) const V8_OVERRIDE {
2778 DECLARE_CONCRETE_INSTRUCTION(OsrEntry, "osr-entry")
2782 class LStackCheck V8_FINAL : public LTemplateInstruction<0, 1, 0> {
2784 explicit LStackCheck(LOperand* context) {
2785 inputs_[0] = context;
2788 LOperand* context() { return inputs_[0]; }
2790 DECLARE_CONCRETE_INSTRUCTION(StackCheck, "stack-check")
2791 DECLARE_HYDROGEN_ACCESSOR(StackCheck)
2793 Label* done_label() { return &done_label_; }
2800 class LForInPrepareMap V8_FINAL : public LTemplateInstruction<1, 2, 0> {
2802 LForInPrepareMap(LOperand* context, LOperand* object) {
2803 inputs_[0] = context;
2804 inputs_[1] = object;
2807 LOperand* context() { return inputs_[0]; }
2808 LOperand* object() { return inputs_[1]; }
2810 DECLARE_CONCRETE_INSTRUCTION(ForInPrepareMap, "for-in-prepare-map")
2814 class LForInCacheArray V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2816 explicit LForInCacheArray(LOperand* map) {
2820 LOperand* map() { return inputs_[0]; }
2822 DECLARE_CONCRETE_INSTRUCTION(ForInCacheArray, "for-in-cache-array")
2825 return HForInCacheArray::cast(this->hydrogen_value())->idx();
2830 class LCheckMapValue V8_FINAL : public LTemplateInstruction<0, 2, 0> {
2832 LCheckMapValue(LOperand* value, LOperand* map) {
2837 LOperand* value() { return inputs_[0]; }
2838 LOperand* map() { return inputs_[1]; }
2840 DECLARE_CONCRETE_INSTRUCTION(CheckMapValue, "check-map-value")
2844 class LLoadFieldByIndex V8_FINAL : public LTemplateInstruction<1, 2, 0> {
2846 LLoadFieldByIndex(LOperand* object, LOperand* index) {
2847 inputs_[0] = object;
2851 LOperand* object() { return inputs_[0]; }
2852 LOperand* index() { return inputs_[1]; }
2854 DECLARE_CONCRETE_INSTRUCTION(LoadFieldByIndex, "load-field-by-index")
2858 class LStoreFrameContext: public LTemplateInstruction<0, 1, 0> {
2860 explicit LStoreFrameContext(LOperand* context) {
2861 inputs_[0] = context;
2864 LOperand* context() { return inputs_[0]; }
2866 DECLARE_CONCRETE_INSTRUCTION(StoreFrameContext, "store-frame-context")
2870 class LAllocateBlockContext: public LTemplateInstruction<1, 2, 0> {
2872 LAllocateBlockContext(LOperand* context, LOperand* function) {
2873 inputs_[0] = context;
2874 inputs_[1] = function;
2877 LOperand* context() { return inputs_[0]; }
2878 LOperand* function() { return inputs_[1]; }
2880 Handle<ScopeInfo> scope_info() { return hydrogen()->scope_info(); }
2882 DECLARE_CONCRETE_INSTRUCTION(AllocateBlockContext, "allocate-block-context")
2883 DECLARE_HYDROGEN_ACCESSOR(AllocateBlockContext)
2887 class LChunkBuilder;
2888 class LPlatformChunk V8_FINAL : public LChunk {
2890 LPlatformChunk(CompilationInfo* info, HGraph* graph)
2891 : LChunk(info, graph),
2892 dehoisted_key_ids_(graph->GetMaximumValueID(), graph->zone()) { }
2894 int GetNextSpillIndex(RegisterKind kind);
2895 LOperand* GetNextSpillSlot(RegisterKind kind);
2896 BitVector* GetDehoistedKeyIds() { return &dehoisted_key_ids_; }
2897 bool IsDehoistedKey(HValue* value) {
2898 return dehoisted_key_ids_.Contains(value->id());
2902 BitVector dehoisted_key_ids_;
2906 class LChunkBuilder V8_FINAL : public LChunkBuilderBase {
2908 LChunkBuilder(CompilationInfo* info, HGraph* graph, LAllocator* allocator)
2909 : LChunkBuilderBase(graph->zone()),
2914 current_instruction_(NULL),
2915 current_block_(NULL),
2917 allocator_(allocator) { }
2919 Isolate* isolate() const { return graph_->isolate(); }
2921 // Build the sequence for the graph.
2922 LPlatformChunk* Build();
2924 // Declare methods that deal with the individual node types.
2925 #define DECLARE_DO(type) LInstruction* Do##type(H##type* node);
2926 HYDROGEN_CONCRETE_INSTRUCTION_LIST(DECLARE_DO)
2929 LInstruction* DoMathFloor(HUnaryMathOperation* instr);
2930 LInstruction* DoMathRound(HUnaryMathOperation* instr);
2931 LInstruction* DoMathAbs(HUnaryMathOperation* instr);
2932 LInstruction* DoMathLog(HUnaryMathOperation* instr);
2933 LInstruction* DoMathExp(HUnaryMathOperation* instr);
2934 LInstruction* DoMathSqrt(HUnaryMathOperation* instr);
2935 LInstruction* DoMathPowHalf(HUnaryMathOperation* instr);
2936 LInstruction* DoMathClz32(HUnaryMathOperation* instr);
2937 LInstruction* DoDivByPowerOf2I(HDiv* instr);
2938 LInstruction* DoDivByConstI(HDiv* instr);
2939 LInstruction* DoDivI(HDiv* instr);
2940 LInstruction* DoModByPowerOf2I(HMod* instr);
2941 LInstruction* DoModByConstI(HMod* instr);
2942 LInstruction* DoModI(HMod* instr);
2943 LInstruction* DoFlooringDivByPowerOf2I(HMathFloorOfDiv* instr);
2944 LInstruction* DoFlooringDivByConstI(HMathFloorOfDiv* instr);
2945 LInstruction* DoFlooringDivI(HMathFloorOfDiv* instr);
2955 LPlatformChunk* chunk() const { return chunk_; }
2956 CompilationInfo* info() const { return info_; }
2957 HGraph* graph() const { return graph_; }
2959 bool is_unused() const { return status_ == UNUSED; }
2960 bool is_building() const { return status_ == BUILDING; }
2961 bool is_done() const { return status_ == DONE; }
2962 bool is_aborted() const { return status_ == ABORTED; }
2964 void Abort(BailoutReason reason);
2966 // Methods for getting operands for Use / Define / Temp.
2967 LUnallocated* ToUnallocated(Register reg);
2968 LUnallocated* ToUnallocated(XMMRegister reg);
2970 // Methods for setting up define-use relationships.
2971 MUST_USE_RESULT LOperand* Use(HValue* value, LUnallocated* operand);
2972 MUST_USE_RESULT LOperand* UseFixed(HValue* value, Register fixed_register);
2973 MUST_USE_RESULT LOperand* UseFixedDouble(HValue* value,
2974 XMMRegister fixed_register);
2976 // A value that is guaranteed to be allocated to a register.
2977 // Operand created by UseRegister is guaranteed to be live until the end of
2978 // instruction. This means that register allocator will not reuse it's
2979 // register for any other operand inside instruction.
2980 // Operand created by UseRegisterAtStart is guaranteed to be live only at
2981 // instruction start. Register allocator is free to assign the same register
2982 // to some other operand used inside instruction (i.e. temporary or
2984 MUST_USE_RESULT LOperand* UseRegister(HValue* value);
2985 MUST_USE_RESULT LOperand* UseRegisterAtStart(HValue* value);
2987 // An input operand in a register that may be trashed.
2988 MUST_USE_RESULT LOperand* UseTempRegister(HValue* value);
2990 // An input operand in a register that may be trashed or a constant operand.
2991 MUST_USE_RESULT LOperand* UseTempRegisterOrConstant(HValue* value);
2993 // An input operand in a register or stack slot.
2994 MUST_USE_RESULT LOperand* Use(HValue* value);
2995 MUST_USE_RESULT LOperand* UseAtStart(HValue* value);
2997 // An input operand in a register, stack slot or a constant operand.
2998 MUST_USE_RESULT LOperand* UseOrConstant(HValue* value);
2999 MUST_USE_RESULT LOperand* UseOrConstantAtStart(HValue* value);
3001 // An input operand in a register or a constant operand.
3002 MUST_USE_RESULT LOperand* UseRegisterOrConstant(HValue* value);
3003 MUST_USE_RESULT LOperand* UseRegisterOrConstantAtStart(HValue* value);
3005 // An input operand in a constant operand.
3006 MUST_USE_RESULT LOperand* UseConstant(HValue* value);
3008 // An input operand in register, stack slot or a constant operand.
3009 // Will not be moved to a register even if one is freely available.
3010 virtual MUST_USE_RESULT LOperand* UseAny(HValue* value) V8_OVERRIDE;
3012 // Temporary operand that must be in a register.
3013 MUST_USE_RESULT LUnallocated* TempRegister();
3014 MUST_USE_RESULT LOperand* FixedTemp(Register reg);
3015 MUST_USE_RESULT LOperand* FixedTemp(XMMRegister reg);
3017 // Methods for setting up define-use relationships.
3018 // Return the same instruction that they are passed.
3019 LInstruction* Define(LTemplateResultInstruction<1>* instr,
3020 LUnallocated* result);
3021 LInstruction* DefineAsRegister(LTemplateResultInstruction<1>* instr);
3022 LInstruction* DefineAsSpilled(LTemplateResultInstruction<1>* instr,
3024 LInstruction* DefineSameAsFirst(LTemplateResultInstruction<1>* instr);
3025 LInstruction* DefineFixed(LTemplateResultInstruction<1>* instr,
3027 LInstruction* DefineFixedDouble(LTemplateResultInstruction<1>* instr,
3029 // Assigns an environment to an instruction. An instruction which can
3030 // deoptimize must have an environment.
3031 LInstruction* AssignEnvironment(LInstruction* instr);
3032 // Assigns a pointer map to an instruction. An instruction which can
3033 // trigger a GC or a lazy deoptimization must have a pointer map.
3034 LInstruction* AssignPointerMap(LInstruction* instr);
3036 enum CanDeoptimize { CAN_DEOPTIMIZE_EAGERLY, CANNOT_DEOPTIMIZE_EAGERLY };
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);
3055 void FindDehoistedKeyDefinitions(HValue* candidate);
3057 LPlatformChunk* chunk_;
3058 CompilationInfo* info_;
3059 HGraph* const graph_;
3061 HInstruction* current_instruction_;
3062 HBasicBlock* current_block_;
3063 HBasicBlock* next_block_;
3064 LAllocator* allocator_;
3066 DISALLOW_COPY_AND_ASSIGN(LChunkBuilder);
3069 #undef DECLARE_HYDROGEN_ACCESSOR
3070 #undef DECLARE_CONCRETE_INSTRUCTION
3072 } } // namespace v8::int
3074 #endif // V8_X64_LITHIUM_X64_H_