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(CheckArrayBufferNotNeutered) \
41 V(CheckInstanceType) \
50 V(ClassOfTestAndBranch) \
51 V(CompareMinusZeroAndBranch) \
52 V(CompareNumericAndBranch) \
53 V(CmpObjectEqAndBranch) \
77 V(FlooringDivByConstI) \
78 V(FlooringDivByPowerOf2I) \
83 V(GetCachedArrayIndex) \
85 V(HasCachedArrayIndexAndBranch) \
86 V(HasInPrototypeChainAndBranch) \
87 V(HasInstanceTypeAndBranch) \
88 V(InnerAllocatedObject) \
91 V(Integer32ToDouble) \
93 V(IsConstructCallAndBranch) \
94 V(IsStringAndBranch) \
96 V(IsUndetectableAndBranch) \
101 V(LoadFieldByIndex) \
102 V(LoadFunctionPrototype) \
103 V(LoadGlobalGeneric) \
104 V(LoadGlobalViaContext) \
106 V(LoadKeyedGeneric) \
108 V(LoadNamedGeneric) \
120 V(MaybeGrowElements) \
136 V(SeqStringGetChar) \
137 V(SeqStringSetChar) \
143 V(StoreContextSlot) \
144 V(StoreFrameContext) \
145 V(StoreGlobalViaContext) \
147 V(StoreKeyedGeneric) \
149 V(StoreNamedGeneric) \
151 V(StringCharCodeAt) \
152 V(StringCharFromCode) \
153 V(StringCompareAndBranch) \
157 V(ToFastProperties) \
158 V(TransitionElementsKind) \
159 V(TrapAllocationMemento) \
161 V(TypeofIsAndBranch) \
167 #define DECLARE_CONCRETE_INSTRUCTION(type, mnemonic) \
168 Opcode opcode() const final { return LInstruction::k##type; } \
169 void CompileToNative(LCodeGen* generator) final; \
170 const char* Mnemonic() const final { return mnemonic; } \
171 static L##type* cast(LInstruction* instr) { \
172 DCHECK(instr->Is##type()); \
173 return reinterpret_cast<L##type*>(instr); \
177 #define DECLARE_HYDROGEN_ACCESSOR(type) \
178 H##type* hydrogen() const { \
179 return H##type::cast(hydrogen_value()); \
183 class LInstruction : public ZoneObject {
186 : environment_(NULL),
187 hydrogen_value_(NULL),
188 bit_field_(IsCallBits::encode(false)) {
191 virtual ~LInstruction() {}
193 virtual void CompileToNative(LCodeGen* generator) = 0;
194 virtual const char* Mnemonic() const = 0;
195 virtual void PrintTo(StringStream* stream);
196 virtual void PrintDataTo(StringStream* stream);
197 virtual void PrintOutputOperandTo(StringStream* stream);
200 // Declare a unique enum value for each instruction.
201 #define DECLARE_OPCODE(type) k##type,
202 LITHIUM_CONCRETE_INSTRUCTION_LIST(DECLARE_OPCODE)
203 kNumberOfInstructions
204 #undef DECLARE_OPCODE
207 virtual Opcode opcode() const = 0;
209 // Declare non-virtual type testers for all leaf IR classes.
210 #define DECLARE_PREDICATE(type) \
211 bool Is##type() const { return opcode() == k##type; }
212 LITHIUM_CONCRETE_INSTRUCTION_LIST(DECLARE_PREDICATE)
213 #undef DECLARE_PREDICATE
215 // Declare virtual predicates for instructions that don't have
217 virtual bool IsGap() const { return false; }
219 virtual bool IsControl() const { return false; }
221 // Try deleting this instruction if possible.
222 virtual bool TryDelete() { return false; }
224 void set_environment(LEnvironment* env) { environment_ = env; }
225 LEnvironment* environment() const { return environment_; }
226 bool HasEnvironment() const { return environment_ != NULL; }
228 void set_pointer_map(LPointerMap* p) { pointer_map_.set(p); }
229 LPointerMap* pointer_map() const { return pointer_map_.get(); }
230 bool HasPointerMap() const { return pointer_map_.is_set(); }
232 void set_hydrogen_value(HValue* value) { hydrogen_value_ = value; }
233 HValue* hydrogen_value() const { return hydrogen_value_; }
235 void MarkAsCall() { bit_field_ = IsCallBits::update(bit_field_, true); }
236 bool IsCall() const { return IsCallBits::decode(bit_field_); }
238 // Interface to the register allocator and iterators.
239 bool ClobbersTemps() const { return IsCall(); }
240 bool ClobbersRegisters() const { return IsCall(); }
241 virtual bool ClobbersDoubleRegisters(Isolate* isolate) const {
245 // Interface to the register allocator and iterators.
246 bool IsMarkedAsCall() const { return IsCall(); }
248 virtual bool HasResult() const = 0;
249 virtual LOperand* result() const = 0;
251 LOperand* FirstInput() { return InputAt(0); }
252 LOperand* Output() { return HasResult() ? result() : NULL; }
254 virtual bool HasInterestingComment(LCodeGen* gen) const { return true; }
256 virtual bool MustSignExtendResult(LPlatformChunk* chunk) const {
264 virtual int InputCount() = 0;
265 virtual LOperand* InputAt(int i) = 0;
269 friend class InputIterator;
271 friend class TempIterator;
272 virtual int TempCount() = 0;
273 virtual LOperand* TempAt(int i) = 0;
275 class IsCallBits: public BitField<bool, 0, 1> {};
277 LEnvironment* environment_;
278 SetOncePointer<LPointerMap> pointer_map_;
279 HValue* hydrogen_value_;
284 // R = number of result operands (0 or 1).
286 class LTemplateResultInstruction : public LInstruction {
288 // Allow 0 or 1 output operands.
289 STATIC_ASSERT(R == 0 || R == 1);
290 bool HasResult() const final { return R != 0 && result() != NULL; }
291 void set_result(LOperand* operand) { results_[0] = operand; }
292 LOperand* result() const override { return results_[0]; }
294 bool MustSignExtendResult(LPlatformChunk* chunk) const final;
297 EmbeddedContainer<LOperand*, R> results_;
301 // R = number of result operands (0 or 1).
302 // I = number of input operands.
303 // T = number of temporary operands.
304 template<int R, int I, int T>
305 class LTemplateInstruction : public LTemplateResultInstruction<R> {
307 EmbeddedContainer<LOperand*, I> inputs_;
308 EmbeddedContainer<LOperand*, T> temps_;
312 int InputCount() final { return I; }
313 LOperand* InputAt(int i) final { return inputs_[i]; }
315 int TempCount() final { return T; }
316 LOperand* TempAt(int i) final { return temps_[i]; }
320 class LGap : public LTemplateInstruction<0, 0, 0> {
322 explicit LGap(HBasicBlock* block)
324 parallel_moves_[BEFORE] = NULL;
325 parallel_moves_[START] = NULL;
326 parallel_moves_[END] = NULL;
327 parallel_moves_[AFTER] = NULL;
330 // Can't use the DECLARE-macro here because of sub-classes.
331 bool IsGap() const final { return true; }
332 void PrintDataTo(StringStream* stream) override;
333 static LGap* cast(LInstruction* instr) {
334 DCHECK(instr->IsGap());
335 return reinterpret_cast<LGap*>(instr);
338 bool IsRedundant() const;
340 HBasicBlock* block() const { return block_; }
347 FIRST_INNER_POSITION = BEFORE,
348 LAST_INNER_POSITION = AFTER
351 LParallelMove* GetOrCreateParallelMove(InnerPosition pos,
353 if (parallel_moves_[pos] == NULL) {
354 parallel_moves_[pos] = new(zone) LParallelMove(zone);
356 return parallel_moves_[pos];
359 LParallelMove* GetParallelMove(InnerPosition pos) {
360 return parallel_moves_[pos];
364 LParallelMove* parallel_moves_[LAST_INNER_POSITION + 1];
369 class LInstructionGap final : public LGap {
371 explicit LInstructionGap(HBasicBlock* block) : LGap(block) { }
373 bool HasInterestingComment(LCodeGen* gen) const override {
374 return !IsRedundant();
377 DECLARE_CONCRETE_INSTRUCTION(InstructionGap, "gap")
381 class LGoto final : public LTemplateInstruction<0, 0, 0> {
383 explicit LGoto(HBasicBlock* block) : block_(block) { }
385 bool HasInterestingComment(LCodeGen* gen) const override;
386 DECLARE_CONCRETE_INSTRUCTION(Goto, "goto")
387 void PrintDataTo(StringStream* stream) override;
388 bool IsControl() const override { return true; }
390 int block_id() const { return block_->block_id(); }
397 class LPrologue final : public LTemplateInstruction<0, 0, 0> {
399 DECLARE_CONCRETE_INSTRUCTION(Prologue, "prologue")
403 class LLazyBailout final : public LTemplateInstruction<0, 0, 0> {
405 LLazyBailout() : gap_instructions_size_(0) { }
407 DECLARE_CONCRETE_INSTRUCTION(LazyBailout, "lazy-bailout")
409 void set_gap_instructions_size(int gap_instructions_size) {
410 gap_instructions_size_ = gap_instructions_size;
412 int gap_instructions_size() { return gap_instructions_size_; }
415 int gap_instructions_size_;
419 class LDummy final : public LTemplateInstruction<1, 0, 0> {
422 DECLARE_CONCRETE_INSTRUCTION(Dummy, "dummy")
426 class LDummyUse final : public LTemplateInstruction<1, 1, 0> {
428 explicit LDummyUse(LOperand* value) {
431 DECLARE_CONCRETE_INSTRUCTION(DummyUse, "dummy-use")
435 class LDeoptimize final : public LTemplateInstruction<0, 0, 0> {
437 bool IsControl() const override { return true; }
438 DECLARE_CONCRETE_INSTRUCTION(Deoptimize, "deoptimize")
439 DECLARE_HYDROGEN_ACCESSOR(Deoptimize)
443 class LLabel final : public LGap {
445 explicit LLabel(HBasicBlock* block)
446 : LGap(block), replacement_(NULL) { }
448 bool HasInterestingComment(LCodeGen* gen) const override { return false; }
449 DECLARE_CONCRETE_INSTRUCTION(Label, "label")
451 void PrintDataTo(StringStream* stream) override;
453 int block_id() const { return block()->block_id(); }
454 bool is_loop_header() const { return block()->IsLoopHeader(); }
455 bool is_osr_entry() const { return block()->is_osr_entry(); }
456 Label* label() { return &label_; }
457 LLabel* replacement() const { return replacement_; }
458 void set_replacement(LLabel* label) { replacement_ = label; }
459 bool HasReplacement() const { return replacement_ != NULL; }
463 LLabel* replacement_;
467 class LParameter final : public LTemplateInstruction<1, 0, 0> {
469 bool HasInterestingComment(LCodeGen* gen) const override { return false; }
470 DECLARE_CONCRETE_INSTRUCTION(Parameter, "parameter")
474 class LCallStub final : public LTemplateInstruction<1, 1, 0> {
476 explicit LCallStub(LOperand* context) {
477 inputs_[0] = context;
480 LOperand* context() { return inputs_[0]; }
482 DECLARE_CONCRETE_INSTRUCTION(CallStub, "call-stub")
483 DECLARE_HYDROGEN_ACCESSOR(CallStub)
487 class LUnknownOSRValue final : public LTemplateInstruction<1, 0, 0> {
489 bool HasInterestingComment(LCodeGen* gen) const override { return false; }
490 DECLARE_CONCRETE_INSTRUCTION(UnknownOSRValue, "unknown-osr-value")
494 template<int I, int T>
495 class LControlInstruction : public LTemplateInstruction<0, I, T> {
497 LControlInstruction() : false_label_(NULL), true_label_(NULL) { }
499 bool IsControl() const final { return true; }
501 int SuccessorCount() { return hydrogen()->SuccessorCount(); }
502 HBasicBlock* SuccessorAt(int i) { return hydrogen()->SuccessorAt(i); }
504 int TrueDestination(LChunk* chunk) {
505 return chunk->LookupDestination(true_block_id());
507 int FalseDestination(LChunk* chunk) {
508 return chunk->LookupDestination(false_block_id());
511 Label* TrueLabel(LChunk* chunk) {
512 if (true_label_ == NULL) {
513 true_label_ = chunk->GetAssemblyLabel(TrueDestination(chunk));
517 Label* FalseLabel(LChunk* chunk) {
518 if (false_label_ == NULL) {
519 false_label_ = chunk->GetAssemblyLabel(FalseDestination(chunk));
525 int true_block_id() { return SuccessorAt(0)->block_id(); }
526 int false_block_id() { return SuccessorAt(1)->block_id(); }
529 HControlInstruction* hydrogen() {
530 return HControlInstruction::cast(this->hydrogen_value());
538 class LWrapReceiver final : public LTemplateInstruction<1, 2, 0> {
540 LWrapReceiver(LOperand* receiver, LOperand* function) {
541 inputs_[0] = receiver;
542 inputs_[1] = function;
545 LOperand* receiver() { return inputs_[0]; }
546 LOperand* function() { return inputs_[1]; }
548 DECLARE_CONCRETE_INSTRUCTION(WrapReceiver, "wrap-receiver")
549 DECLARE_HYDROGEN_ACCESSOR(WrapReceiver)
553 class LApplyArguments final : public LTemplateInstruction<1, 4, 0> {
555 LApplyArguments(LOperand* function,
558 LOperand* elements) {
559 inputs_[0] = function;
560 inputs_[1] = receiver;
562 inputs_[3] = elements;
565 LOperand* function() { return inputs_[0]; }
566 LOperand* receiver() { return inputs_[1]; }
567 LOperand* length() { return inputs_[2]; }
568 LOperand* elements() { return inputs_[3]; }
570 DECLARE_CONCRETE_INSTRUCTION(ApplyArguments, "apply-arguments")
574 class LAccessArgumentsAt final : public LTemplateInstruction<1, 3, 0> {
576 LAccessArgumentsAt(LOperand* arguments, LOperand* length, LOperand* index) {
577 inputs_[0] = arguments;
582 LOperand* arguments() { return inputs_[0]; }
583 LOperand* length() { return inputs_[1]; }
584 LOperand* index() { return inputs_[2]; }
586 DECLARE_CONCRETE_INSTRUCTION(AccessArgumentsAt, "access-arguments-at")
588 void PrintDataTo(StringStream* stream) override;
592 class LArgumentsLength final : public LTemplateInstruction<1, 1, 0> {
594 explicit LArgumentsLength(LOperand* elements) {
595 inputs_[0] = elements;
598 LOperand* elements() { return inputs_[0]; }
600 DECLARE_CONCRETE_INSTRUCTION(ArgumentsLength, "arguments-length")
604 class LArgumentsElements final : public LTemplateInstruction<1, 0, 0> {
606 DECLARE_CONCRETE_INSTRUCTION(ArgumentsElements, "arguments-elements")
607 DECLARE_HYDROGEN_ACCESSOR(ArgumentsElements)
611 class LModByPowerOf2I final : public LTemplateInstruction<1, 1, 0> {
613 LModByPowerOf2I(LOperand* dividend, int32_t divisor) {
614 inputs_[0] = dividend;
618 LOperand* dividend() { return inputs_[0]; }
619 int32_t divisor() const { return divisor_; }
621 DECLARE_CONCRETE_INSTRUCTION(ModByPowerOf2I, "mod-by-power-of-2-i")
622 DECLARE_HYDROGEN_ACCESSOR(Mod)
629 class LModByConstI final : public LTemplateInstruction<1, 1, 2> {
631 LModByConstI(LOperand* dividend,
635 inputs_[0] = dividend;
641 LOperand* dividend() { return inputs_[0]; }
642 int32_t divisor() const { return divisor_; }
643 LOperand* temp1() { return temps_[0]; }
644 LOperand* temp2() { return temps_[1]; }
646 DECLARE_CONCRETE_INSTRUCTION(ModByConstI, "mod-by-const-i")
647 DECLARE_HYDROGEN_ACCESSOR(Mod)
654 class LModI final : public LTemplateInstruction<1, 2, 1> {
656 LModI(LOperand* left, LOperand* right, LOperand* temp) {
662 LOperand* left() { return inputs_[0]; }
663 LOperand* right() { return inputs_[1]; }
664 LOperand* temp() { return temps_[0]; }
666 DECLARE_CONCRETE_INSTRUCTION(ModI, "mod-i")
667 DECLARE_HYDROGEN_ACCESSOR(Mod)
671 class LDivByPowerOf2I final : public LTemplateInstruction<1, 1, 0> {
673 LDivByPowerOf2I(LOperand* dividend, int32_t divisor) {
674 inputs_[0] = dividend;
678 LOperand* dividend() { return inputs_[0]; }
679 int32_t divisor() const { return divisor_; }
681 DECLARE_CONCRETE_INSTRUCTION(DivByPowerOf2I, "div-by-power-of-2-i")
682 DECLARE_HYDROGEN_ACCESSOR(Div)
689 class LDivByConstI final : public LTemplateInstruction<1, 1, 2> {
691 LDivByConstI(LOperand* dividend,
695 inputs_[0] = dividend;
701 LOperand* dividend() { return inputs_[0]; }
702 int32_t divisor() const { return divisor_; }
703 LOperand* temp1() { return temps_[0]; }
704 LOperand* temp2() { return temps_[1]; }
706 DECLARE_CONCRETE_INSTRUCTION(DivByConstI, "div-by-const-i")
707 DECLARE_HYDROGEN_ACCESSOR(Div)
714 class LDivI final : public LTemplateInstruction<1, 2, 1> {
716 LDivI(LOperand* dividend, LOperand* divisor, LOperand* temp) {
717 inputs_[0] = dividend;
718 inputs_[1] = divisor;
722 LOperand* dividend() { return inputs_[0]; }
723 LOperand* divisor() { return inputs_[1]; }
724 LOperand* temp() { return temps_[0]; }
726 DECLARE_CONCRETE_INSTRUCTION(DivI, "div-i")
727 DECLARE_HYDROGEN_ACCESSOR(BinaryOperation)
731 class LFlooringDivByPowerOf2I final : public LTemplateInstruction<1, 1, 0> {
733 LFlooringDivByPowerOf2I(LOperand* dividend, int32_t divisor) {
734 inputs_[0] = dividend;
738 LOperand* dividend() { return inputs_[0]; }
739 int32_t divisor() const { return divisor_; }
741 DECLARE_CONCRETE_INSTRUCTION(FlooringDivByPowerOf2I,
742 "flooring-div-by-power-of-2-i")
743 DECLARE_HYDROGEN_ACCESSOR(MathFloorOfDiv)
750 class LFlooringDivByConstI final : public LTemplateInstruction<1, 1, 3> {
752 LFlooringDivByConstI(LOperand* dividend,
757 inputs_[0] = dividend;
764 LOperand* dividend() { return inputs_[0]; }
765 int32_t divisor() const { return divisor_; }
766 LOperand* temp1() { return temps_[0]; }
767 LOperand* temp2() { return temps_[1]; }
768 LOperand* temp3() { return temps_[2]; }
770 DECLARE_CONCRETE_INSTRUCTION(FlooringDivByConstI, "flooring-div-by-const-i")
771 DECLARE_HYDROGEN_ACCESSOR(MathFloorOfDiv)
778 class LFlooringDivI final : public LTemplateInstruction<1, 2, 1> {
780 LFlooringDivI(LOperand* dividend, LOperand* divisor, LOperand* temp) {
781 inputs_[0] = dividend;
782 inputs_[1] = divisor;
786 LOperand* dividend() { return inputs_[0]; }
787 LOperand* divisor() { return inputs_[1]; }
788 LOperand* temp() { return temps_[0]; }
790 DECLARE_CONCRETE_INSTRUCTION(FlooringDivI, "flooring-div-i")
791 DECLARE_HYDROGEN_ACCESSOR(MathFloorOfDiv)
795 class LMulI final : public LTemplateInstruction<1, 2, 0> {
797 LMulI(LOperand* left, LOperand* right) {
802 LOperand* left() { return inputs_[0]; }
803 LOperand* right() { return inputs_[1]; }
805 DECLARE_CONCRETE_INSTRUCTION(MulI, "mul-i")
806 DECLARE_HYDROGEN_ACCESSOR(Mul)
810 class LCompareNumericAndBranch final : public LControlInstruction<2, 0> {
812 LCompareNumericAndBranch(LOperand* left, LOperand* right) {
817 LOperand* left() { return inputs_[0]; }
818 LOperand* right() { return inputs_[1]; }
820 DECLARE_CONCRETE_INSTRUCTION(CompareNumericAndBranch,
821 "compare-numeric-and-branch")
822 DECLARE_HYDROGEN_ACCESSOR(CompareNumericAndBranch)
824 Token::Value op() const { return hydrogen()->token(); }
825 bool is_double() const {
826 return hydrogen()->representation().IsDouble();
829 void PrintDataTo(StringStream* stream) override;
833 class LMathFloor final : public LTemplateInstruction<1, 1, 0> {
835 explicit LMathFloor(LOperand* value) {
839 LOperand* value() { return inputs_[0]; }
841 DECLARE_CONCRETE_INSTRUCTION(MathFloor, "math-floor")
842 DECLARE_HYDROGEN_ACCESSOR(UnaryMathOperation)
846 class LMathRound final : public LTemplateInstruction<1, 1, 1> {
848 LMathRound(LOperand* value, LOperand* temp) {
853 LOperand* value() { return inputs_[0]; }
854 LOperand* temp() { return temps_[0]; }
856 DECLARE_CONCRETE_INSTRUCTION(MathRound, "math-round")
857 DECLARE_HYDROGEN_ACCESSOR(UnaryMathOperation)
861 class LMathFround final : public LTemplateInstruction<1, 1, 0> {
863 explicit LMathFround(LOperand* value) { inputs_[0] = value; }
865 LOperand* value() { return inputs_[0]; }
867 DECLARE_CONCRETE_INSTRUCTION(MathFround, "math-fround")
871 class LMathAbs final : public LTemplateInstruction<1, 2, 0> {
873 explicit LMathAbs(LOperand* context, LOperand* value) {
874 inputs_[1] = context;
878 LOperand* context() { return inputs_[1]; }
879 LOperand* value() { return inputs_[0]; }
881 DECLARE_CONCRETE_INSTRUCTION(MathAbs, "math-abs")
882 DECLARE_HYDROGEN_ACCESSOR(UnaryMathOperation)
886 class LMathLog final : public LTemplateInstruction<1, 1, 0> {
888 explicit LMathLog(LOperand* value) {
892 LOperand* value() { return inputs_[0]; }
894 DECLARE_CONCRETE_INSTRUCTION(MathLog, "math-log")
898 class LMathClz32 final : public LTemplateInstruction<1, 1, 0> {
900 explicit LMathClz32(LOperand* value) {
904 LOperand* value() { return inputs_[0]; }
906 DECLARE_CONCRETE_INSTRUCTION(MathClz32, "math-clz32")
910 class LMathExp final : public LTemplateInstruction<1, 1, 2> {
912 LMathExp(LOperand* value, LOperand* temp1, LOperand* temp2) {
916 ExternalReference::InitializeMathExpData();
919 LOperand* value() { return inputs_[0]; }
920 LOperand* temp1() { return temps_[0]; }
921 LOperand* temp2() { return temps_[1]; }
923 DECLARE_CONCRETE_INSTRUCTION(MathExp, "math-exp")
927 class LMathSqrt final : public LTemplateInstruction<1, 1, 0> {
929 explicit LMathSqrt(LOperand* value) {
933 LOperand* value() { return inputs_[0]; }
935 DECLARE_CONCRETE_INSTRUCTION(MathSqrt, "math-sqrt")
939 class LMathPowHalf final : public LTemplateInstruction<1, 1, 0> {
941 explicit LMathPowHalf(LOperand* value) {
945 LOperand* value() { return inputs_[0]; }
947 DECLARE_CONCRETE_INSTRUCTION(MathPowHalf, "math-pow-half")
951 class LCmpObjectEqAndBranch final : public LControlInstruction<2, 0> {
953 LCmpObjectEqAndBranch(LOperand* left, LOperand* right) {
958 LOperand* left() { return inputs_[0]; }
959 LOperand* right() { return inputs_[1]; }
961 DECLARE_CONCRETE_INSTRUCTION(CmpObjectEqAndBranch, "cmp-object-eq-and-branch")
965 class LCmpHoleAndBranch final : public LControlInstruction<1, 0> {
967 explicit LCmpHoleAndBranch(LOperand* object) {
971 LOperand* object() { return inputs_[0]; }
973 DECLARE_CONCRETE_INSTRUCTION(CmpHoleAndBranch, "cmp-hole-and-branch")
974 DECLARE_HYDROGEN_ACCESSOR(CompareHoleAndBranch)
978 class LCompareMinusZeroAndBranch final : public LControlInstruction<1, 0> {
980 explicit LCompareMinusZeroAndBranch(LOperand* value) {
984 LOperand* value() { return inputs_[0]; }
986 DECLARE_CONCRETE_INSTRUCTION(CompareMinusZeroAndBranch,
987 "cmp-minus-zero-and-branch")
988 DECLARE_HYDROGEN_ACCESSOR(CompareMinusZeroAndBranch)
992 class LIsStringAndBranch final : public LControlInstruction<1, 1> {
994 explicit LIsStringAndBranch(LOperand* value, LOperand* temp) {
999 LOperand* value() { return inputs_[0]; }
1000 LOperand* temp() { return temps_[0]; }
1002 DECLARE_CONCRETE_INSTRUCTION(IsStringAndBranch, "is-string-and-branch")
1003 DECLARE_HYDROGEN_ACCESSOR(IsStringAndBranch)
1005 void PrintDataTo(StringStream* stream) override;
1009 class LIsSmiAndBranch final : public LControlInstruction<1, 0> {
1011 explicit LIsSmiAndBranch(LOperand* value) {
1015 LOperand* value() { return inputs_[0]; }
1017 DECLARE_CONCRETE_INSTRUCTION(IsSmiAndBranch, "is-smi-and-branch")
1018 DECLARE_HYDROGEN_ACCESSOR(IsSmiAndBranch)
1020 void PrintDataTo(StringStream* stream) override;
1024 class LIsUndetectableAndBranch final : public LControlInstruction<1, 1> {
1026 explicit LIsUndetectableAndBranch(LOperand* value, LOperand* temp) {
1031 LOperand* value() { return inputs_[0]; }
1032 LOperand* temp() { return temps_[0]; }
1034 DECLARE_CONCRETE_INSTRUCTION(IsUndetectableAndBranch,
1035 "is-undetectable-and-branch")
1036 DECLARE_HYDROGEN_ACCESSOR(IsUndetectableAndBranch)
1038 void PrintDataTo(StringStream* stream) override;
1042 class LStringCompareAndBranch final : public LControlInstruction<3, 0> {
1044 explicit LStringCompareAndBranch(LOperand* context,
1047 inputs_[0] = context;
1052 LOperand* context() { return inputs_[0]; }
1053 LOperand* left() { return inputs_[1]; }
1054 LOperand* right() { return inputs_[2]; }
1056 DECLARE_CONCRETE_INSTRUCTION(StringCompareAndBranch,
1057 "string-compare-and-branch")
1058 DECLARE_HYDROGEN_ACCESSOR(StringCompareAndBranch)
1060 void PrintDataTo(StringStream* stream) override;
1062 Token::Value op() const { return hydrogen()->token(); }
1066 class LHasInstanceTypeAndBranch final : public LControlInstruction<1, 0> {
1068 explicit LHasInstanceTypeAndBranch(LOperand* value) {
1072 LOperand* value() { return inputs_[0]; }
1074 DECLARE_CONCRETE_INSTRUCTION(HasInstanceTypeAndBranch,
1075 "has-instance-type-and-branch")
1076 DECLARE_HYDROGEN_ACCESSOR(HasInstanceTypeAndBranch)
1078 void PrintDataTo(StringStream* stream) override;
1082 class LGetCachedArrayIndex final : public LTemplateInstruction<1, 1, 0> {
1084 explicit LGetCachedArrayIndex(LOperand* value) {
1088 LOperand* value() { return inputs_[0]; }
1090 DECLARE_CONCRETE_INSTRUCTION(GetCachedArrayIndex, "get-cached-array-index")
1091 DECLARE_HYDROGEN_ACCESSOR(GetCachedArrayIndex)
1095 class LHasCachedArrayIndexAndBranch final : public LControlInstruction<1, 0> {
1097 explicit LHasCachedArrayIndexAndBranch(LOperand* value) {
1101 LOperand* value() { return inputs_[0]; }
1103 DECLARE_CONCRETE_INSTRUCTION(HasCachedArrayIndexAndBranch,
1104 "has-cached-array-index-and-branch")
1105 DECLARE_HYDROGEN_ACCESSOR(HasCachedArrayIndexAndBranch)
1107 void PrintDataTo(StringStream* stream) override;
1111 class LClassOfTestAndBranch final : public LControlInstruction<1, 2> {
1113 LClassOfTestAndBranch(LOperand* value, LOperand* temp, LOperand* temp2) {
1119 LOperand* value() { return inputs_[0]; }
1120 LOperand* temp() { return temps_[0]; }
1121 LOperand* temp2() { return temps_[1]; }
1123 DECLARE_CONCRETE_INSTRUCTION(ClassOfTestAndBranch,
1124 "class-of-test-and-branch")
1125 DECLARE_HYDROGEN_ACCESSOR(ClassOfTestAndBranch)
1127 void PrintDataTo(StringStream* stream) override;
1131 class LCmpT final : public LTemplateInstruction<1, 3, 0> {
1133 LCmpT(LOperand* context, LOperand* left, LOperand* right) {
1134 inputs_[0] = context;
1139 LOperand* context() { return inputs_[0]; }
1140 LOperand* left() { return inputs_[1]; }
1141 LOperand* right() { return inputs_[2]; }
1143 DECLARE_CONCRETE_INSTRUCTION(CmpT, "cmp-t")
1144 DECLARE_HYDROGEN_ACCESSOR(CompareGeneric)
1146 Strength strength() { return hydrogen()->strength(); }
1148 Token::Value op() const { return hydrogen()->token(); }
1152 class LInstanceOf final : public LTemplateInstruction<1, 3, 0> {
1154 LInstanceOf(LOperand* context, LOperand* left, LOperand* right) {
1155 inputs_[0] = context;
1160 LOperand* context() { return inputs_[0]; }
1161 LOperand* left() { return inputs_[1]; }
1162 LOperand* right() { return inputs_[2]; }
1164 DECLARE_CONCRETE_INSTRUCTION(InstanceOf, "instance-of")
1168 class LHasInPrototypeChainAndBranch final : public LControlInstruction<2, 0> {
1170 LHasInPrototypeChainAndBranch(LOperand* object, LOperand* prototype) {
1171 inputs_[0] = object;
1172 inputs_[1] = prototype;
1175 LOperand* object() const { return inputs_[0]; }
1176 LOperand* prototype() const { return inputs_[1]; }
1178 DECLARE_CONCRETE_INSTRUCTION(HasInPrototypeChainAndBranch,
1179 "has-in-prototype-chain-and-branch")
1180 DECLARE_HYDROGEN_ACCESSOR(HasInPrototypeChainAndBranch)
1184 class LBoundsCheck final : public LTemplateInstruction<0, 2, 0> {
1186 LBoundsCheck(LOperand* index, LOperand* length) {
1188 inputs_[1] = length;
1191 LOperand* index() { return inputs_[0]; }
1192 LOperand* length() { return inputs_[1]; }
1194 DECLARE_CONCRETE_INSTRUCTION(BoundsCheck, "bounds-check")
1195 DECLARE_HYDROGEN_ACCESSOR(BoundsCheck)
1199 class LBitI final : public LTemplateInstruction<1, 2, 0> {
1201 LBitI(LOperand* left, LOperand* right) {
1206 LOperand* left() { return inputs_[0]; }
1207 LOperand* right() { return inputs_[1]; }
1209 Token::Value op() const { return hydrogen()->op(); }
1210 bool IsInteger32() const {
1211 return hydrogen()->representation().IsInteger32();
1214 DECLARE_CONCRETE_INSTRUCTION(BitI, "bit-i")
1215 DECLARE_HYDROGEN_ACCESSOR(Bitwise)
1219 class LShiftI final : public LTemplateInstruction<1, 2, 0> {
1221 LShiftI(Token::Value op, LOperand* left, LOperand* right, bool can_deopt)
1222 : op_(op), can_deopt_(can_deopt) {
1227 Token::Value op() const { return op_; }
1228 LOperand* left() { return inputs_[0]; }
1229 LOperand* right() { return inputs_[1]; }
1230 bool can_deopt() const { return can_deopt_; }
1232 DECLARE_CONCRETE_INSTRUCTION(ShiftI, "shift-i")
1240 class LSubI final : public LTemplateInstruction<1, 2, 0> {
1242 LSubI(LOperand* left, LOperand* right) {
1247 LOperand* left() { return inputs_[0]; }
1248 LOperand* right() { return inputs_[1]; }
1250 DECLARE_CONCRETE_INSTRUCTION(SubI, "sub-i")
1251 DECLARE_HYDROGEN_ACCESSOR(Sub)
1255 class LConstantI final : public LTemplateInstruction<1, 0, 0> {
1257 DECLARE_CONCRETE_INSTRUCTION(ConstantI, "constant-i")
1258 DECLARE_HYDROGEN_ACCESSOR(Constant)
1260 int32_t value() const { return hydrogen()->Integer32Value(); }
1264 class LConstantS final : public LTemplateInstruction<1, 0, 0> {
1266 DECLARE_CONCRETE_INSTRUCTION(ConstantS, "constant-s")
1267 DECLARE_HYDROGEN_ACCESSOR(Constant)
1269 Smi* value() const { return Smi::FromInt(hydrogen()->Integer32Value()); }
1273 class LConstantD final : public LTemplateInstruction<1, 0, 0> {
1275 DECLARE_CONCRETE_INSTRUCTION(ConstantD, "constant-d")
1276 DECLARE_HYDROGEN_ACCESSOR(Constant)
1278 uint64_t bits() const { return hydrogen()->DoubleValueAsBits(); }
1282 class LConstantE final : public LTemplateInstruction<1, 0, 0> {
1284 DECLARE_CONCRETE_INSTRUCTION(ConstantE, "constant-e")
1285 DECLARE_HYDROGEN_ACCESSOR(Constant)
1287 ExternalReference value() const {
1288 return hydrogen()->ExternalReferenceValue();
1293 class LConstantT final : public LTemplateInstruction<1, 0, 0> {
1295 DECLARE_CONCRETE_INSTRUCTION(ConstantT, "constant-t")
1296 DECLARE_HYDROGEN_ACCESSOR(Constant)
1298 Handle<Object> value(Isolate* isolate) const {
1299 return hydrogen()->handle(isolate);
1304 class LBranch final : public LControlInstruction<1, 0> {
1306 explicit LBranch(LOperand* value) {
1310 LOperand* value() { return inputs_[0]; }
1312 DECLARE_CONCRETE_INSTRUCTION(Branch, "branch")
1313 DECLARE_HYDROGEN_ACCESSOR(Branch)
1315 void PrintDataTo(StringStream* stream) override;
1319 class LDebugBreak final : public LTemplateInstruction<0, 0, 0> {
1321 DECLARE_CONCRETE_INSTRUCTION(DebugBreak, "break")
1325 class LCmpMapAndBranch final : public LControlInstruction<1, 0> {
1327 explicit LCmpMapAndBranch(LOperand* value) {
1331 LOperand* value() { return inputs_[0]; }
1333 DECLARE_CONCRETE_INSTRUCTION(CmpMapAndBranch, "cmp-map-and-branch")
1334 DECLARE_HYDROGEN_ACCESSOR(CompareMap)
1336 Handle<Map> map() const { return hydrogen()->map().handle(); }
1340 class LMapEnumLength final : public LTemplateInstruction<1, 1, 0> {
1342 explicit LMapEnumLength(LOperand* value) {
1346 LOperand* value() { return inputs_[0]; }
1348 DECLARE_CONCRETE_INSTRUCTION(MapEnumLength, "map-enum-length")
1352 class LDateField final : public LTemplateInstruction<1, 1, 0> {
1354 LDateField(LOperand* date, Smi* index) : index_(index) {
1358 LOperand* date() { return inputs_[0]; }
1359 Smi* index() const { return index_; }
1361 DECLARE_CONCRETE_INSTRUCTION(DateField, "date-field")
1362 DECLARE_HYDROGEN_ACCESSOR(DateField)
1369 class LSeqStringGetChar final : public LTemplateInstruction<1, 2, 0> {
1371 LSeqStringGetChar(LOperand* string, LOperand* index) {
1372 inputs_[0] = string;
1376 LOperand* string() const { return inputs_[0]; }
1377 LOperand* index() const { return inputs_[1]; }
1379 DECLARE_CONCRETE_INSTRUCTION(SeqStringGetChar, "seq-string-get-char")
1380 DECLARE_HYDROGEN_ACCESSOR(SeqStringGetChar)
1384 class LSeqStringSetChar final : public LTemplateInstruction<1, 4, 0> {
1386 LSeqStringSetChar(LOperand* context,
1390 inputs_[0] = context;
1391 inputs_[1] = string;
1396 LOperand* string() { return inputs_[1]; }
1397 LOperand* index() { return inputs_[2]; }
1398 LOperand* value() { return inputs_[3]; }
1400 DECLARE_CONCRETE_INSTRUCTION(SeqStringSetChar, "seq-string-set-char")
1401 DECLARE_HYDROGEN_ACCESSOR(SeqStringSetChar)
1405 class LAddI final : public LTemplateInstruction<1, 2, 0> {
1407 LAddI(LOperand* left, LOperand* right) {
1412 LOperand* left() { return inputs_[0]; }
1413 LOperand* right() { return inputs_[1]; }
1415 static bool UseLea(HAdd* add) {
1416 return !add->CheckFlag(HValue::kCanOverflow) &&
1417 add->BetterLeftOperand()->UseCount() > 1;
1420 DECLARE_CONCRETE_INSTRUCTION(AddI, "add-i")
1421 DECLARE_HYDROGEN_ACCESSOR(Add)
1425 class LMathMinMax final : public LTemplateInstruction<1, 2, 0> {
1427 LMathMinMax(LOperand* left, LOperand* right) {
1432 LOperand* left() { return inputs_[0]; }
1433 LOperand* right() { return inputs_[1]; }
1435 DECLARE_CONCRETE_INSTRUCTION(MathMinMax, "math-min-max")
1436 DECLARE_HYDROGEN_ACCESSOR(MathMinMax)
1440 class LPower final : public LTemplateInstruction<1, 2, 0> {
1442 LPower(LOperand* left, LOperand* right) {
1447 LOperand* left() { return inputs_[0]; }
1448 LOperand* right() { return inputs_[1]; }
1450 DECLARE_CONCRETE_INSTRUCTION(Power, "power")
1451 DECLARE_HYDROGEN_ACCESSOR(Power)
1455 class LArithmeticD final : public LTemplateInstruction<1, 2, 0> {
1457 LArithmeticD(Token::Value op, LOperand* left, LOperand* right)
1463 Token::Value op() const { return op_; }
1464 LOperand* left() { return inputs_[0]; }
1465 LOperand* right() { return inputs_[1]; }
1467 Opcode opcode() const override { return LInstruction::kArithmeticD; }
1468 void CompileToNative(LCodeGen* generator) override;
1469 const char* Mnemonic() const override;
1476 class LArithmeticT final : public LTemplateInstruction<1, 3, 0> {
1478 LArithmeticT(Token::Value op,
1483 inputs_[0] = context;
1488 Token::Value op() const { return op_; }
1489 LOperand* context() { return inputs_[0]; }
1490 LOperand* left() { return inputs_[1]; }
1491 LOperand* right() { return inputs_[2]; }
1493 Opcode opcode() const override { return LInstruction::kArithmeticT; }
1494 void CompileToNative(LCodeGen* generator) override;
1495 const char* Mnemonic() const override;
1497 DECLARE_HYDROGEN_ACCESSOR(BinaryOperation)
1499 Strength strength() { return hydrogen()->strength(); }
1506 class LReturn final : public LTemplateInstruction<0, 3, 0> {
1508 explicit LReturn(LOperand* value,
1510 LOperand* parameter_count) {
1512 inputs_[1] = context;
1513 inputs_[2] = parameter_count;
1516 LOperand* value() { return inputs_[0]; }
1517 LOperand* context() { return inputs_[1]; }
1519 bool has_constant_parameter_count() {
1520 return parameter_count()->IsConstantOperand();
1522 LConstantOperand* constant_parameter_count() {
1523 DCHECK(has_constant_parameter_count());
1524 return LConstantOperand::cast(parameter_count());
1526 LOperand* parameter_count() { return inputs_[2]; }
1528 DECLARE_CONCRETE_INSTRUCTION(Return, "return")
1529 DECLARE_HYDROGEN_ACCESSOR(Return)
1533 class LLoadNamedField final : public LTemplateInstruction<1, 1, 0> {
1535 explicit LLoadNamedField(LOperand* object) {
1536 inputs_[0] = object;
1539 LOperand* object() { return inputs_[0]; }
1541 DECLARE_CONCRETE_INSTRUCTION(LoadNamedField, "load-named-field")
1542 DECLARE_HYDROGEN_ACCESSOR(LoadNamedField)
1546 class LLoadNamedGeneric final : public LTemplateInstruction<1, 2, 1> {
1548 explicit LLoadNamedGeneric(LOperand* context, LOperand* object,
1550 inputs_[0] = context;
1551 inputs_[1] = object;
1555 DECLARE_CONCRETE_INSTRUCTION(LoadNamedGeneric, "load-named-generic")
1556 DECLARE_HYDROGEN_ACCESSOR(LoadNamedGeneric)
1558 LOperand* context() { return inputs_[0]; }
1559 LOperand* object() { return inputs_[1]; }
1560 LOperand* temp_vector() { return temps_[0]; }
1562 Handle<Object> name() const { return hydrogen()->name(); }
1566 class LLoadFunctionPrototype final : public LTemplateInstruction<1, 1, 0> {
1568 explicit LLoadFunctionPrototype(LOperand* function) {
1569 inputs_[0] = function;
1572 DECLARE_CONCRETE_INSTRUCTION(LoadFunctionPrototype, "load-function-prototype")
1573 DECLARE_HYDROGEN_ACCESSOR(LoadFunctionPrototype)
1575 LOperand* function() { return inputs_[0]; }
1579 class LLoadRoot final : public LTemplateInstruction<1, 0, 0> {
1581 DECLARE_CONCRETE_INSTRUCTION(LoadRoot, "load-root")
1582 DECLARE_HYDROGEN_ACCESSOR(LoadRoot)
1584 Heap::RootListIndex index() const { return hydrogen()->index(); }
1588 inline static bool ExternalArrayOpRequiresTemp(
1589 Representation key_representation,
1590 ElementsKind elements_kind) {
1591 // Operations that require the key to be divided by two to be converted into
1592 // an index cannot fold the scale operation into a load and need an extra
1593 // temp register to do the work.
1594 return SmiValuesAre31Bits() && key_representation.IsSmi() &&
1595 (elements_kind == UINT8_ELEMENTS || elements_kind == INT8_ELEMENTS ||
1596 elements_kind == UINT8_CLAMPED_ELEMENTS);
1600 class LLoadKeyed final : public LTemplateInstruction<1, 2, 0> {
1602 LLoadKeyed(LOperand* elements, LOperand* key) {
1603 inputs_[0] = elements;
1607 DECLARE_CONCRETE_INSTRUCTION(LoadKeyed, "load-keyed")
1608 DECLARE_HYDROGEN_ACCESSOR(LoadKeyed)
1610 bool is_fixed_typed_array() const {
1611 return hydrogen()->is_fixed_typed_array();
1613 LOperand* elements() { return inputs_[0]; }
1614 LOperand* key() { return inputs_[1]; }
1615 void PrintDataTo(StringStream* stream) override;
1616 uint32_t base_offset() const { return hydrogen()->base_offset(); }
1617 ElementsKind elements_kind() const {
1618 return hydrogen()->elements_kind();
1623 class LLoadKeyedGeneric final : public LTemplateInstruction<1, 3, 1> {
1625 LLoadKeyedGeneric(LOperand* context, LOperand* obj, LOperand* key,
1627 inputs_[0] = context;
1633 DECLARE_CONCRETE_INSTRUCTION(LoadKeyedGeneric, "load-keyed-generic")
1634 DECLARE_HYDROGEN_ACCESSOR(LoadKeyedGeneric)
1636 LOperand* context() { return inputs_[0]; }
1637 LOperand* object() { return inputs_[1]; }
1638 LOperand* key() { return inputs_[2]; }
1639 LOperand* temp_vector() { return temps_[0]; }
1643 class LLoadGlobalGeneric final : public LTemplateInstruction<1, 2, 1> {
1645 explicit LLoadGlobalGeneric(LOperand* context, LOperand* global_object,
1647 inputs_[0] = context;
1648 inputs_[1] = global_object;
1652 DECLARE_CONCRETE_INSTRUCTION(LoadGlobalGeneric, "load-global-generic")
1653 DECLARE_HYDROGEN_ACCESSOR(LoadGlobalGeneric)
1655 LOperand* context() { return inputs_[0]; }
1656 LOperand* global_object() { return inputs_[1]; }
1657 LOperand* temp_vector() { return temps_[0]; }
1659 Handle<Object> name() const { return hydrogen()->name(); }
1660 TypeofMode typeof_mode() const { return hydrogen()->typeof_mode(); }
1664 class LLoadGlobalViaContext final : public LTemplateInstruction<1, 1, 1> {
1666 explicit LLoadGlobalViaContext(LOperand* context) { inputs_[0] = context; }
1668 DECLARE_CONCRETE_INSTRUCTION(LoadGlobalViaContext, "load-global-via-context")
1669 DECLARE_HYDROGEN_ACCESSOR(LoadGlobalViaContext)
1671 void PrintDataTo(StringStream* stream) override;
1673 LOperand* context() { return inputs_[0]; }
1675 int depth() const { return hydrogen()->depth(); }
1676 int slot_index() const { return hydrogen()->slot_index(); }
1680 class LLoadContextSlot final : public LTemplateInstruction<1, 1, 0> {
1682 explicit LLoadContextSlot(LOperand* context) {
1683 inputs_[0] = context;
1686 LOperand* context() { return inputs_[0]; }
1688 DECLARE_CONCRETE_INSTRUCTION(LoadContextSlot, "load-context-slot")
1689 DECLARE_HYDROGEN_ACCESSOR(LoadContextSlot)
1691 int slot_index() { return hydrogen()->slot_index(); }
1693 void PrintDataTo(StringStream* stream) override;
1697 class LStoreContextSlot final : public LTemplateInstruction<0, 2, 1> {
1699 LStoreContextSlot(LOperand* context, LOperand* value, LOperand* temp) {
1700 inputs_[0] = context;
1705 LOperand* context() { return inputs_[0]; }
1706 LOperand* value() { return inputs_[1]; }
1707 LOperand* temp() { return temps_[0]; }
1709 DECLARE_CONCRETE_INSTRUCTION(StoreContextSlot, "store-context-slot")
1710 DECLARE_HYDROGEN_ACCESSOR(StoreContextSlot)
1712 int slot_index() { return hydrogen()->slot_index(); }
1714 void PrintDataTo(StringStream* stream) override;
1718 class LPushArgument final : public LTemplateInstruction<0, 1, 0> {
1720 explicit LPushArgument(LOperand* value) {
1724 LOperand* value() { return inputs_[0]; }
1726 DECLARE_CONCRETE_INSTRUCTION(PushArgument, "push-argument")
1730 class LDrop final : public LTemplateInstruction<0, 0, 0> {
1732 explicit LDrop(int count) : count_(count) { }
1734 int count() const { return count_; }
1736 DECLARE_CONCRETE_INSTRUCTION(Drop, "drop")
1743 class LStoreCodeEntry final : public LTemplateInstruction<0, 2, 0> {
1745 LStoreCodeEntry(LOperand* function, LOperand* code_object) {
1746 inputs_[0] = function;
1747 inputs_[1] = code_object;
1750 LOperand* function() { return inputs_[0]; }
1751 LOperand* code_object() { return inputs_[1]; }
1753 void PrintDataTo(StringStream* stream) override;
1755 DECLARE_CONCRETE_INSTRUCTION(StoreCodeEntry, "store-code-entry")
1756 DECLARE_HYDROGEN_ACCESSOR(StoreCodeEntry)
1760 class LInnerAllocatedObject final : public LTemplateInstruction<1, 2, 0> {
1762 LInnerAllocatedObject(LOperand* base_object, LOperand* offset) {
1763 inputs_[0] = base_object;
1764 inputs_[1] = offset;
1767 LOperand* base_object() const { return inputs_[0]; }
1768 LOperand* offset() const { return inputs_[1]; }
1770 void PrintDataTo(StringStream* stream) override;
1772 DECLARE_CONCRETE_INSTRUCTION(InnerAllocatedObject, "inner-allocated-object")
1776 class LThisFunction final : public LTemplateInstruction<1, 0, 0> {
1778 DECLARE_CONCRETE_INSTRUCTION(ThisFunction, "this-function")
1779 DECLARE_HYDROGEN_ACCESSOR(ThisFunction)
1783 class LContext final : public LTemplateInstruction<1, 0, 0> {
1785 DECLARE_CONCRETE_INSTRUCTION(Context, "context")
1786 DECLARE_HYDROGEN_ACCESSOR(Context)
1790 class LDeclareGlobals final : public LTemplateInstruction<0, 1, 0> {
1792 explicit LDeclareGlobals(LOperand* context) {
1793 inputs_[0] = context;
1796 LOperand* context() { return inputs_[0]; }
1798 DECLARE_CONCRETE_INSTRUCTION(DeclareGlobals, "declare-globals")
1799 DECLARE_HYDROGEN_ACCESSOR(DeclareGlobals)
1803 class LCallJSFunction final : public LTemplateInstruction<1, 1, 0> {
1805 explicit LCallJSFunction(LOperand* function) {
1806 inputs_[0] = function;
1809 LOperand* function() { return inputs_[0]; }
1811 DECLARE_CONCRETE_INSTRUCTION(CallJSFunction, "call-js-function")
1812 DECLARE_HYDROGEN_ACCESSOR(CallJSFunction)
1814 void PrintDataTo(StringStream* stream) override;
1816 int arity() const { return hydrogen()->argument_count() - 1; }
1820 class LCallWithDescriptor final : public LTemplateResultInstruction<1> {
1822 LCallWithDescriptor(CallInterfaceDescriptor descriptor,
1823 const ZoneList<LOperand*>& operands, Zone* zone)
1824 : inputs_(descriptor.GetRegisterParameterCount() +
1825 kImplicitRegisterParameterCount,
1827 DCHECK(descriptor.GetRegisterParameterCount() +
1828 kImplicitRegisterParameterCount ==
1830 inputs_.AddAll(operands, zone);
1833 LOperand* target() const { return inputs_[0]; }
1835 DECLARE_HYDROGEN_ACCESSOR(CallWithDescriptor)
1837 // The target and context are passed as implicit parameters that are not
1838 // explicitly listed in the descriptor.
1839 static const int kImplicitRegisterParameterCount = 2;
1842 DECLARE_CONCRETE_INSTRUCTION(CallWithDescriptor, "call-with-descriptor")
1844 void PrintDataTo(StringStream* stream) override;
1846 int arity() const { return hydrogen()->argument_count() - 1; }
1848 ZoneList<LOperand*> inputs_;
1850 // Iterator support.
1851 int InputCount() final { return inputs_.length(); }
1852 LOperand* InputAt(int i) final { return inputs_[i]; }
1854 int TempCount() final { return 0; }
1855 LOperand* TempAt(int i) final { return NULL; }
1859 class LInvokeFunction final : public LTemplateInstruction<1, 2, 0> {
1861 LInvokeFunction(LOperand* context, LOperand* function) {
1862 inputs_[0] = context;
1863 inputs_[1] = function;
1866 LOperand* context() { return inputs_[0]; }
1867 LOperand* function() { return inputs_[1]; }
1869 DECLARE_CONCRETE_INSTRUCTION(InvokeFunction, "invoke-function")
1870 DECLARE_HYDROGEN_ACCESSOR(InvokeFunction)
1872 void PrintDataTo(StringStream* stream) override;
1874 int arity() const { return hydrogen()->argument_count() - 1; }
1878 class LCallFunction final : public LTemplateInstruction<1, 2, 2> {
1880 LCallFunction(LOperand* context, LOperand* function, LOperand* slot,
1882 inputs_[0] = context;
1883 inputs_[1] = function;
1888 DECLARE_CONCRETE_INSTRUCTION(CallFunction, "call-function")
1889 DECLARE_HYDROGEN_ACCESSOR(CallFunction)
1891 LOperand* context() { return inputs_[0]; }
1892 LOperand* function() { return inputs_[1]; }
1893 LOperand* temp_slot() { return temps_[0]; }
1894 LOperand* temp_vector() { return temps_[1]; }
1895 int arity() const { return hydrogen()->argument_count() - 1; }
1897 void PrintDataTo(StringStream* stream) override;
1901 class LCallNew final : public LTemplateInstruction<1, 2, 0> {
1903 LCallNew(LOperand* context, LOperand* constructor) {
1904 inputs_[0] = context;
1905 inputs_[1] = constructor;
1908 LOperand* context() { return inputs_[0]; }
1909 LOperand* constructor() { return inputs_[1]; }
1911 DECLARE_CONCRETE_INSTRUCTION(CallNew, "call-new")
1912 DECLARE_HYDROGEN_ACCESSOR(CallNew)
1914 void PrintDataTo(StringStream* stream) override;
1916 int arity() const { return hydrogen()->argument_count() - 1; }
1920 class LCallNewArray final : public LTemplateInstruction<1, 2, 0> {
1922 LCallNewArray(LOperand* context, LOperand* constructor) {
1923 inputs_[0] = context;
1924 inputs_[1] = constructor;
1927 LOperand* context() { return inputs_[0]; }
1928 LOperand* constructor() { return inputs_[1]; }
1930 DECLARE_CONCRETE_INSTRUCTION(CallNewArray, "call-new-array")
1931 DECLARE_HYDROGEN_ACCESSOR(CallNewArray)
1933 void PrintDataTo(StringStream* stream) override;
1935 int arity() const { return hydrogen()->argument_count() - 1; }
1939 class LCallRuntime final : public LTemplateInstruction<1, 1, 0> {
1941 explicit LCallRuntime(LOperand* context) {
1942 inputs_[0] = context;
1945 LOperand* context() { return inputs_[0]; }
1947 DECLARE_CONCRETE_INSTRUCTION(CallRuntime, "call-runtime")
1948 DECLARE_HYDROGEN_ACCESSOR(CallRuntime)
1950 bool ClobbersDoubleRegisters(Isolate* isolate) const override {
1951 return save_doubles() == kDontSaveFPRegs;
1954 const Runtime::Function* function() const { return hydrogen()->function(); }
1955 int arity() const { return hydrogen()->argument_count(); }
1956 SaveFPRegsMode save_doubles() const { return hydrogen()->save_doubles(); }
1960 class LInteger32ToDouble final : public LTemplateInstruction<1, 1, 0> {
1962 explicit LInteger32ToDouble(LOperand* value) {
1966 LOperand* value() { return inputs_[0]; }
1968 DECLARE_CONCRETE_INSTRUCTION(Integer32ToDouble, "int32-to-double")
1972 class LUint32ToDouble final : public LTemplateInstruction<1, 1, 0> {
1974 explicit LUint32ToDouble(LOperand* value) {
1978 LOperand* value() { return inputs_[0]; }
1980 DECLARE_CONCRETE_INSTRUCTION(Uint32ToDouble, "uint32-to-double")
1984 class LNumberTagI final : public LTemplateInstruction<1, 1, 2> {
1986 LNumberTagI(LOperand* value, LOperand* temp1, LOperand* temp2) {
1992 LOperand* value() { return inputs_[0]; }
1993 LOperand* temp1() { return temps_[0]; }
1994 LOperand* temp2() { return temps_[1]; }
1996 DECLARE_CONCRETE_INSTRUCTION(NumberTagI, "number-tag-i")
2000 class LNumberTagU final : public LTemplateInstruction<1, 1, 2> {
2002 LNumberTagU(LOperand* value, LOperand* temp1, LOperand* temp2) {
2008 LOperand* value() { return inputs_[0]; }
2009 LOperand* temp1() { return temps_[0]; }
2010 LOperand* temp2() { return temps_[1]; }
2012 DECLARE_CONCRETE_INSTRUCTION(NumberTagU, "number-tag-u")
2016 class LNumberTagD final : public LTemplateInstruction<1, 1, 1> {
2018 explicit LNumberTagD(LOperand* value, LOperand* temp) {
2023 LOperand* value() { return inputs_[0]; }
2024 LOperand* temp() { return temps_[0]; }
2026 DECLARE_CONCRETE_INSTRUCTION(NumberTagD, "number-tag-d")
2027 DECLARE_HYDROGEN_ACCESSOR(Change)
2031 // Sometimes truncating conversion from a tagged value to an int32.
2032 class LDoubleToI final : public LTemplateInstruction<1, 1, 0> {
2034 explicit LDoubleToI(LOperand* value) {
2038 LOperand* value() { return inputs_[0]; }
2040 DECLARE_CONCRETE_INSTRUCTION(DoubleToI, "double-to-i")
2041 DECLARE_HYDROGEN_ACCESSOR(UnaryOperation)
2043 bool truncating() { return hydrogen()->CanTruncateToInt32(); }
2047 class LDoubleToSmi final : public LTemplateInstruction<1, 1, 0> {
2049 explicit LDoubleToSmi(LOperand* value) {
2053 LOperand* value() { return inputs_[0]; }
2055 DECLARE_CONCRETE_INSTRUCTION(DoubleToSmi, "double-to-smi")
2056 DECLARE_HYDROGEN_ACCESSOR(UnaryOperation)
2060 // Truncating conversion from a tagged value to an int32.
2061 class LTaggedToI final : public LTemplateInstruction<1, 1, 1> {
2063 LTaggedToI(LOperand* value, LOperand* temp) {
2068 LOperand* value() { return inputs_[0]; }
2069 LOperand* temp() { return temps_[0]; }
2071 DECLARE_CONCRETE_INSTRUCTION(TaggedToI, "tagged-to-i")
2072 DECLARE_HYDROGEN_ACCESSOR(Change)
2074 bool truncating() { return hydrogen()->CanTruncateToInt32(); }
2078 class LSmiTag final : public LTemplateInstruction<1, 1, 0> {
2080 explicit LSmiTag(LOperand* value) {
2084 LOperand* value() { return inputs_[0]; }
2086 DECLARE_CONCRETE_INSTRUCTION(SmiTag, "smi-tag")
2087 DECLARE_HYDROGEN_ACCESSOR(Change)
2091 class LNumberUntagD final : public LTemplateInstruction<1, 1, 0> {
2093 explicit LNumberUntagD(LOperand* value) {
2097 LOperand* value() { return inputs_[0]; }
2099 DECLARE_CONCRETE_INSTRUCTION(NumberUntagD, "double-untag")
2100 DECLARE_HYDROGEN_ACCESSOR(Change);
2104 class LSmiUntag final : public LTemplateInstruction<1, 1, 0> {
2106 LSmiUntag(LOperand* value, bool needs_check)
2107 : needs_check_(needs_check) {
2111 LOperand* value() { return inputs_[0]; }
2112 bool needs_check() const { return needs_check_; }
2114 DECLARE_CONCRETE_INSTRUCTION(SmiUntag, "smi-untag")
2121 class LStoreNamedField final : public LTemplateInstruction<0, 2, 1> {
2123 LStoreNamedField(LOperand* object, LOperand* value, LOperand* temp) {
2124 inputs_[0] = object;
2129 LOperand* object() { return inputs_[0]; }
2130 LOperand* value() { return inputs_[1]; }
2131 LOperand* temp() { return temps_[0]; }
2133 DECLARE_CONCRETE_INSTRUCTION(StoreNamedField, "store-named-field")
2134 DECLARE_HYDROGEN_ACCESSOR(StoreNamedField)
2136 void PrintDataTo(StringStream* stream) override;
2138 Representation representation() const {
2139 return hydrogen()->field_representation();
2144 class LStoreNamedGeneric final : public LTemplateInstruction<0, 3, 2> {
2146 LStoreNamedGeneric(LOperand* context, LOperand* object, LOperand* value,
2147 LOperand* slot, LOperand* vector) {
2148 inputs_[0] = context;
2149 inputs_[1] = object;
2155 LOperand* context() { return inputs_[0]; }
2156 LOperand* object() { return inputs_[1]; }
2157 LOperand* value() { return inputs_[2]; }
2158 LOperand* temp_slot() { return temps_[0]; }
2159 LOperand* temp_vector() { return temps_[1]; }
2161 DECLARE_CONCRETE_INSTRUCTION(StoreNamedGeneric, "store-named-generic")
2162 DECLARE_HYDROGEN_ACCESSOR(StoreNamedGeneric)
2164 void PrintDataTo(StringStream* stream) override;
2166 Handle<Object> name() const { return hydrogen()->name(); }
2167 LanguageMode language_mode() { return hydrogen()->language_mode(); }
2171 class LStoreGlobalViaContext final : public LTemplateInstruction<0, 2, 0> {
2173 LStoreGlobalViaContext(LOperand* context, LOperand* value) {
2174 inputs_[0] = context;
2178 LOperand* context() { return inputs_[0]; }
2179 LOperand* value() { return inputs_[1]; }
2181 DECLARE_CONCRETE_INSTRUCTION(StoreGlobalViaContext,
2182 "store-global-via-context")
2183 DECLARE_HYDROGEN_ACCESSOR(StoreGlobalViaContext)
2185 void PrintDataTo(StringStream* stream) override;
2187 int depth() { return hydrogen()->depth(); }
2188 int slot_index() { return hydrogen()->slot_index(); }
2189 LanguageMode language_mode() { return hydrogen()->language_mode(); }
2193 class LStoreKeyed final : public LTemplateInstruction<0, 3, 0> {
2195 LStoreKeyed(LOperand* object, LOperand* key, LOperand* value) {
2196 inputs_[0] = object;
2201 bool is_fixed_typed_array() const {
2202 return hydrogen()->is_fixed_typed_array();
2204 LOperand* elements() { return inputs_[0]; }
2205 LOperand* key() { return inputs_[1]; }
2206 LOperand* value() { return inputs_[2]; }
2207 ElementsKind elements_kind() const { return hydrogen()->elements_kind(); }
2209 DECLARE_CONCRETE_INSTRUCTION(StoreKeyed, "store-keyed")
2210 DECLARE_HYDROGEN_ACCESSOR(StoreKeyed)
2212 void PrintDataTo(StringStream* stream) override;
2213 bool NeedsCanonicalization() { return hydrogen()->NeedsCanonicalization(); }
2214 uint32_t base_offset() const { return hydrogen()->base_offset(); }
2218 class LStoreKeyedGeneric final : public LTemplateInstruction<0, 4, 2> {
2220 LStoreKeyedGeneric(LOperand* context, LOperand* object, LOperand* key,
2221 LOperand* value, LOperand* slot, LOperand* vector) {
2222 inputs_[0] = context;
2223 inputs_[1] = object;
2230 LOperand* context() { return inputs_[0]; }
2231 LOperand* object() { return inputs_[1]; }
2232 LOperand* key() { return inputs_[2]; }
2233 LOperand* value() { return inputs_[3]; }
2234 LOperand* temp_slot() { return temps_[0]; }
2235 LOperand* temp_vector() { return temps_[1]; }
2237 DECLARE_CONCRETE_INSTRUCTION(StoreKeyedGeneric, "store-keyed-generic")
2238 DECLARE_HYDROGEN_ACCESSOR(StoreKeyedGeneric)
2240 void PrintDataTo(StringStream* stream) override;
2242 LanguageMode language_mode() { return hydrogen()->language_mode(); }
2246 class LTransitionElementsKind final : public LTemplateInstruction<0, 2, 2> {
2248 LTransitionElementsKind(LOperand* object,
2250 LOperand* new_map_temp,
2252 inputs_[0] = object;
2253 inputs_[1] = context;
2254 temps_[0] = new_map_temp;
2258 LOperand* object() { return inputs_[0]; }
2259 LOperand* context() { return inputs_[1]; }
2260 LOperand* new_map_temp() { return temps_[0]; }
2261 LOperand* temp() { return temps_[1]; }
2263 DECLARE_CONCRETE_INSTRUCTION(TransitionElementsKind,
2264 "transition-elements-kind")
2265 DECLARE_HYDROGEN_ACCESSOR(TransitionElementsKind)
2267 void PrintDataTo(StringStream* stream) override;
2269 Handle<Map> original_map() { return hydrogen()->original_map().handle(); }
2270 Handle<Map> transitioned_map() {
2271 return hydrogen()->transitioned_map().handle();
2273 ElementsKind from_kind() { return hydrogen()->from_kind(); }
2274 ElementsKind to_kind() { return hydrogen()->to_kind(); }
2278 class LTrapAllocationMemento final : public LTemplateInstruction<0, 1, 1> {
2280 LTrapAllocationMemento(LOperand* object,
2282 inputs_[0] = object;
2286 LOperand* object() { return inputs_[0]; }
2287 LOperand* temp() { return temps_[0]; }
2289 DECLARE_CONCRETE_INSTRUCTION(TrapAllocationMemento,
2290 "trap-allocation-memento")
2294 class LMaybeGrowElements final : public LTemplateInstruction<1, 5, 0> {
2296 LMaybeGrowElements(LOperand* context, LOperand* object, LOperand* elements,
2297 LOperand* key, LOperand* current_capacity) {
2298 inputs_[0] = context;
2299 inputs_[1] = object;
2300 inputs_[2] = elements;
2302 inputs_[4] = current_capacity;
2305 LOperand* context() { return inputs_[0]; }
2306 LOperand* object() { return inputs_[1]; }
2307 LOperand* elements() { return inputs_[2]; }
2308 LOperand* key() { return inputs_[3]; }
2309 LOperand* current_capacity() { return inputs_[4]; }
2311 DECLARE_HYDROGEN_ACCESSOR(MaybeGrowElements)
2312 DECLARE_CONCRETE_INSTRUCTION(MaybeGrowElements, "maybe-grow-elements")
2316 class LStringAdd final : public LTemplateInstruction<1, 3, 0> {
2318 LStringAdd(LOperand* context, LOperand* left, LOperand* right) {
2319 inputs_[0] = context;
2324 LOperand* context() { return inputs_[0]; }
2325 LOperand* left() { return inputs_[1]; }
2326 LOperand* right() { return inputs_[2]; }
2328 DECLARE_CONCRETE_INSTRUCTION(StringAdd, "string-add")
2329 DECLARE_HYDROGEN_ACCESSOR(StringAdd)
2333 class LStringCharCodeAt final : public LTemplateInstruction<1, 3, 0> {
2335 LStringCharCodeAt(LOperand* context, LOperand* string, LOperand* index) {
2336 inputs_[0] = context;
2337 inputs_[1] = string;
2341 LOperand* context() { return inputs_[0]; }
2342 LOperand* string() { return inputs_[1]; }
2343 LOperand* index() { return inputs_[2]; }
2345 DECLARE_CONCRETE_INSTRUCTION(StringCharCodeAt, "string-char-code-at")
2346 DECLARE_HYDROGEN_ACCESSOR(StringCharCodeAt)
2350 class LStringCharFromCode final : public LTemplateInstruction<1, 2, 0> {
2352 explicit LStringCharFromCode(LOperand* context, LOperand* char_code) {
2353 inputs_[0] = context;
2354 inputs_[1] = char_code;
2357 LOperand* context() { return inputs_[0]; }
2358 LOperand* char_code() { return inputs_[1]; }
2360 DECLARE_CONCRETE_INSTRUCTION(StringCharFromCode, "string-char-from-code")
2361 DECLARE_HYDROGEN_ACCESSOR(StringCharFromCode)
2365 class LCheckValue final : public LTemplateInstruction<0, 1, 0> {
2367 explicit LCheckValue(LOperand* value) {
2371 LOperand* value() { return inputs_[0]; }
2373 DECLARE_CONCRETE_INSTRUCTION(CheckValue, "check-value")
2374 DECLARE_HYDROGEN_ACCESSOR(CheckValue)
2378 class LCheckArrayBufferNotNeutered final
2379 : public LTemplateInstruction<0, 1, 0> {
2381 explicit LCheckArrayBufferNotNeutered(LOperand* view) { inputs_[0] = view; }
2383 LOperand* view() { return inputs_[0]; }
2385 DECLARE_CONCRETE_INSTRUCTION(CheckArrayBufferNotNeutered,
2386 "check-array-buffer-not-neutered")
2387 DECLARE_HYDROGEN_ACCESSOR(CheckArrayBufferNotNeutered)
2391 class LCheckInstanceType final : public LTemplateInstruction<0, 1, 0> {
2393 explicit LCheckInstanceType(LOperand* value) {
2397 LOperand* value() { return inputs_[0]; }
2399 DECLARE_CONCRETE_INSTRUCTION(CheckInstanceType, "check-instance-type")
2400 DECLARE_HYDROGEN_ACCESSOR(CheckInstanceType)
2404 class LCheckMaps final : public LTemplateInstruction<0, 1, 0> {
2406 explicit LCheckMaps(LOperand* value = NULL) {
2410 LOperand* value() { return inputs_[0]; }
2412 DECLARE_CONCRETE_INSTRUCTION(CheckMaps, "check-maps")
2413 DECLARE_HYDROGEN_ACCESSOR(CheckMaps)
2417 class LCheckSmi final : public LTemplateInstruction<1, 1, 0> {
2419 explicit LCheckSmi(LOperand* value) {
2423 LOperand* value() { return inputs_[0]; }
2425 DECLARE_CONCRETE_INSTRUCTION(CheckSmi, "check-smi")
2429 class LClampDToUint8 final : public LTemplateInstruction<1, 1, 0> {
2431 explicit LClampDToUint8(LOperand* unclamped) {
2432 inputs_[0] = unclamped;
2435 LOperand* unclamped() { return inputs_[0]; }
2437 DECLARE_CONCRETE_INSTRUCTION(ClampDToUint8, "clamp-d-to-uint8")
2441 class LClampIToUint8 final : public LTemplateInstruction<1, 1, 0> {
2443 explicit LClampIToUint8(LOperand* unclamped) {
2444 inputs_[0] = unclamped;
2447 LOperand* unclamped() { return inputs_[0]; }
2449 DECLARE_CONCRETE_INSTRUCTION(ClampIToUint8, "clamp-i-to-uint8")
2453 class LClampTToUint8 final : public LTemplateInstruction<1, 1, 1> {
2455 LClampTToUint8(LOperand* unclamped,
2456 LOperand* temp_xmm) {
2457 inputs_[0] = unclamped;
2458 temps_[0] = temp_xmm;
2461 LOperand* unclamped() { return inputs_[0]; }
2462 LOperand* temp_xmm() { return temps_[0]; }
2464 DECLARE_CONCRETE_INSTRUCTION(ClampTToUint8, "clamp-t-to-uint8")
2468 class LCheckNonSmi final : public LTemplateInstruction<0, 1, 0> {
2470 explicit LCheckNonSmi(LOperand* value) {
2474 LOperand* value() { return inputs_[0]; }
2476 DECLARE_CONCRETE_INSTRUCTION(CheckNonSmi, "check-non-smi")
2477 DECLARE_HYDROGEN_ACCESSOR(CheckHeapObject)
2481 class LDoubleBits final : public LTemplateInstruction<1, 1, 0> {
2483 explicit LDoubleBits(LOperand* value) {
2487 LOperand* value() { return inputs_[0]; }
2489 DECLARE_CONCRETE_INSTRUCTION(DoubleBits, "double-bits")
2490 DECLARE_HYDROGEN_ACCESSOR(DoubleBits)
2494 class LConstructDouble final : public LTemplateInstruction<1, 2, 0> {
2496 LConstructDouble(LOperand* hi, LOperand* lo) {
2501 LOperand* hi() { return inputs_[0]; }
2502 LOperand* lo() { return inputs_[1]; }
2504 DECLARE_CONCRETE_INSTRUCTION(ConstructDouble, "construct-double")
2508 class LAllocate final : public LTemplateInstruction<1, 2, 1> {
2510 LAllocate(LOperand* context, LOperand* size, LOperand* temp) {
2511 inputs_[0] = context;
2516 LOperand* context() { return inputs_[0]; }
2517 LOperand* size() { return inputs_[1]; }
2518 LOperand* temp() { return temps_[0]; }
2520 DECLARE_CONCRETE_INSTRUCTION(Allocate, "allocate")
2521 DECLARE_HYDROGEN_ACCESSOR(Allocate)
2525 class LRegExpLiteral final : public LTemplateInstruction<1, 1, 0> {
2527 explicit LRegExpLiteral(LOperand* context) {
2528 inputs_[0] = context;
2531 LOperand* context() { return inputs_[0]; }
2533 DECLARE_CONCRETE_INSTRUCTION(RegExpLiteral, "regexp-literal")
2534 DECLARE_HYDROGEN_ACCESSOR(RegExpLiteral)
2538 class LFunctionLiteral final : public LTemplateInstruction<1, 1, 0> {
2540 explicit LFunctionLiteral(LOperand* context) {
2541 inputs_[0] = context;
2544 LOperand* context() { return inputs_[0]; }
2546 DECLARE_CONCRETE_INSTRUCTION(FunctionLiteral, "function-literal")
2547 DECLARE_HYDROGEN_ACCESSOR(FunctionLiteral)
2551 class LToFastProperties final : public LTemplateInstruction<1, 1, 0> {
2553 explicit LToFastProperties(LOperand* value) {
2557 LOperand* value() { return inputs_[0]; }
2559 DECLARE_CONCRETE_INSTRUCTION(ToFastProperties, "to-fast-properties")
2560 DECLARE_HYDROGEN_ACCESSOR(ToFastProperties)
2564 class LTypeof final : public LTemplateInstruction<1, 2, 0> {
2566 LTypeof(LOperand* context, LOperand* value) {
2567 inputs_[0] = context;
2571 LOperand* context() { return inputs_[0]; }
2572 LOperand* value() { return inputs_[1]; }
2574 DECLARE_CONCRETE_INSTRUCTION(Typeof, "typeof")
2578 class LTypeofIsAndBranch final : public LControlInstruction<1, 0> {
2580 explicit LTypeofIsAndBranch(LOperand* value) {
2584 LOperand* value() { return inputs_[0]; }
2586 DECLARE_CONCRETE_INSTRUCTION(TypeofIsAndBranch, "typeof-is-and-branch")
2587 DECLARE_HYDROGEN_ACCESSOR(TypeofIsAndBranch)
2589 Handle<String> type_literal() { return hydrogen()->type_literal(); }
2591 void PrintDataTo(StringStream* stream) override;
2595 class LIsConstructCallAndBranch final : public LControlInstruction<0, 1> {
2597 explicit LIsConstructCallAndBranch(LOperand* temp) {
2601 LOperand* temp() { return temps_[0]; }
2603 DECLARE_CONCRETE_INSTRUCTION(IsConstructCallAndBranch,
2604 "is-construct-call-and-branch")
2605 DECLARE_HYDROGEN_ACCESSOR(IsConstructCallAndBranch)
2609 class LOsrEntry final : public LTemplateInstruction<0, 0, 0> {
2613 bool HasInterestingComment(LCodeGen* gen) const override { return false; }
2614 DECLARE_CONCRETE_INSTRUCTION(OsrEntry, "osr-entry")
2618 class LStackCheck final : public LTemplateInstruction<0, 1, 0> {
2620 explicit LStackCheck(LOperand* context) {
2621 inputs_[0] = context;
2624 LOperand* context() { return inputs_[0]; }
2626 DECLARE_CONCRETE_INSTRUCTION(StackCheck, "stack-check")
2627 DECLARE_HYDROGEN_ACCESSOR(StackCheck)
2629 Label* done_label() { return &done_label_; }
2636 class LForInPrepareMap final : public LTemplateInstruction<1, 2, 0> {
2638 LForInPrepareMap(LOperand* context, LOperand* object) {
2639 inputs_[0] = context;
2640 inputs_[1] = object;
2643 LOperand* context() { return inputs_[0]; }
2644 LOperand* object() { return inputs_[1]; }
2646 DECLARE_CONCRETE_INSTRUCTION(ForInPrepareMap, "for-in-prepare-map")
2650 class LForInCacheArray final : public LTemplateInstruction<1, 1, 0> {
2652 explicit LForInCacheArray(LOperand* map) {
2656 LOperand* map() { return inputs_[0]; }
2658 DECLARE_CONCRETE_INSTRUCTION(ForInCacheArray, "for-in-cache-array")
2661 return HForInCacheArray::cast(this->hydrogen_value())->idx();
2666 class LCheckMapValue final : public LTemplateInstruction<0, 2, 0> {
2668 LCheckMapValue(LOperand* value, LOperand* map) {
2673 LOperand* value() { return inputs_[0]; }
2674 LOperand* map() { return inputs_[1]; }
2676 DECLARE_CONCRETE_INSTRUCTION(CheckMapValue, "check-map-value")
2680 class LLoadFieldByIndex final : public LTemplateInstruction<1, 2, 0> {
2682 LLoadFieldByIndex(LOperand* object, LOperand* index) {
2683 inputs_[0] = object;
2687 LOperand* object() { return inputs_[0]; }
2688 LOperand* index() { return inputs_[1]; }
2690 DECLARE_CONCRETE_INSTRUCTION(LoadFieldByIndex, "load-field-by-index")
2694 class LStoreFrameContext: public LTemplateInstruction<0, 1, 0> {
2696 explicit LStoreFrameContext(LOperand* context) {
2697 inputs_[0] = context;
2700 LOperand* context() { return inputs_[0]; }
2702 DECLARE_CONCRETE_INSTRUCTION(StoreFrameContext, "store-frame-context")
2706 class LAllocateBlockContext: public LTemplateInstruction<1, 2, 0> {
2708 LAllocateBlockContext(LOperand* context, LOperand* function) {
2709 inputs_[0] = context;
2710 inputs_[1] = function;
2713 LOperand* context() { return inputs_[0]; }
2714 LOperand* function() { return inputs_[1]; }
2716 Handle<ScopeInfo> scope_info() { return hydrogen()->scope_info(); }
2718 DECLARE_CONCRETE_INSTRUCTION(AllocateBlockContext, "allocate-block-context")
2719 DECLARE_HYDROGEN_ACCESSOR(AllocateBlockContext)
2723 class LChunkBuilder;
2724 class LPlatformChunk final : public LChunk {
2726 LPlatformChunk(CompilationInfo* info, HGraph* graph)
2727 : LChunk(info, graph),
2728 dehoisted_key_ids_(graph->GetMaximumValueID(), graph->zone()) { }
2730 int GetNextSpillIndex(RegisterKind kind);
2731 LOperand* GetNextSpillSlot(RegisterKind kind);
2732 BitVector* GetDehoistedKeyIds() { return &dehoisted_key_ids_; }
2733 bool IsDehoistedKey(HValue* value) {
2734 return dehoisted_key_ids_.Contains(value->id());
2738 BitVector dehoisted_key_ids_;
2742 class LChunkBuilder final : public LChunkBuilderBase {
2744 LChunkBuilder(CompilationInfo* info, HGraph* graph, LAllocator* allocator)
2745 : LChunkBuilderBase(info, graph),
2746 current_instruction_(NULL),
2747 current_block_(NULL),
2749 allocator_(allocator) {}
2751 // Build the sequence for the graph.
2752 LPlatformChunk* Build();
2754 // Declare methods that deal with the individual node types.
2755 #define DECLARE_DO(type) LInstruction* Do##type(H##type* node);
2756 HYDROGEN_CONCRETE_INSTRUCTION_LIST(DECLARE_DO)
2759 LInstruction* DoMathFloor(HUnaryMathOperation* instr);
2760 LInstruction* DoMathRound(HUnaryMathOperation* instr);
2761 LInstruction* DoMathFround(HUnaryMathOperation* instr);
2762 LInstruction* DoMathAbs(HUnaryMathOperation* instr);
2763 LInstruction* DoMathLog(HUnaryMathOperation* instr);
2764 LInstruction* DoMathExp(HUnaryMathOperation* instr);
2765 LInstruction* DoMathSqrt(HUnaryMathOperation* instr);
2766 LInstruction* DoMathPowHalf(HUnaryMathOperation* instr);
2767 LInstruction* DoMathClz32(HUnaryMathOperation* instr);
2768 LInstruction* DoDivByPowerOf2I(HDiv* instr);
2769 LInstruction* DoDivByConstI(HDiv* instr);
2770 LInstruction* DoDivI(HDiv* instr);
2771 LInstruction* DoModByPowerOf2I(HMod* instr);
2772 LInstruction* DoModByConstI(HMod* instr);
2773 LInstruction* DoModI(HMod* instr);
2774 LInstruction* DoFlooringDivByPowerOf2I(HMathFloorOfDiv* instr);
2775 LInstruction* DoFlooringDivByConstI(HMathFloorOfDiv* instr);
2776 LInstruction* DoFlooringDivI(HMathFloorOfDiv* instr);
2779 // Methods for getting operands for Use / Define / Temp.
2780 LUnallocated* ToUnallocated(Register reg);
2781 LUnallocated* ToUnallocated(XMMRegister reg);
2783 // Methods for setting up define-use relationships.
2784 MUST_USE_RESULT LOperand* Use(HValue* value, LUnallocated* operand);
2785 MUST_USE_RESULT LOperand* UseFixed(HValue* value, Register fixed_register);
2786 MUST_USE_RESULT LOperand* UseFixedDouble(HValue* value,
2787 XMMRegister fixed_register);
2789 // A value that is guaranteed to be allocated to a register.
2790 // Operand created by UseRegister is guaranteed to be live until the end of
2791 // instruction. This means that register allocator will not reuse it's
2792 // register for any other operand inside instruction.
2793 // Operand created by UseRegisterAtStart is guaranteed to be live only at
2794 // instruction start. Register allocator is free to assign the same register
2795 // to some other operand used inside instruction (i.e. temporary or
2797 MUST_USE_RESULT LOperand* UseRegister(HValue* value);
2798 MUST_USE_RESULT LOperand* UseRegisterAtStart(HValue* value);
2800 // An input operand in a register that may be trashed.
2801 MUST_USE_RESULT LOperand* UseTempRegister(HValue* value);
2803 // An input operand in a register that may be trashed or a constant operand.
2804 MUST_USE_RESULT LOperand* UseTempRegisterOrConstant(HValue* value);
2806 // An input operand in a register or stack slot.
2807 MUST_USE_RESULT LOperand* Use(HValue* value);
2808 MUST_USE_RESULT LOperand* UseAtStart(HValue* value);
2810 // An input operand in a register, stack slot or a constant operand.
2811 MUST_USE_RESULT LOperand* UseOrConstant(HValue* value);
2812 MUST_USE_RESULT LOperand* UseOrConstantAtStart(HValue* value);
2814 // An input operand in a register or a constant operand.
2815 MUST_USE_RESULT LOperand* UseRegisterOrConstant(HValue* value);
2816 MUST_USE_RESULT LOperand* UseRegisterOrConstantAtStart(HValue* value);
2818 // An input operand in a constant operand.
2819 MUST_USE_RESULT LOperand* UseConstant(HValue* value);
2821 // An input operand in register, stack slot or a constant operand.
2822 // Will not be moved to a register even if one is freely available.
2823 MUST_USE_RESULT LOperand* UseAny(HValue* value) override;
2825 // Temporary operand that must be in a register.
2826 MUST_USE_RESULT LUnallocated* TempRegister();
2827 MUST_USE_RESULT LOperand* FixedTemp(Register reg);
2828 MUST_USE_RESULT LOperand* FixedTemp(XMMRegister reg);
2830 // Methods for setting up define-use relationships.
2831 // Return the same instruction that they are passed.
2832 LInstruction* Define(LTemplateResultInstruction<1>* instr,
2833 LUnallocated* result);
2834 LInstruction* DefineAsRegister(LTemplateResultInstruction<1>* instr);
2835 LInstruction* DefineAsSpilled(LTemplateResultInstruction<1>* instr,
2837 LInstruction* DefineSameAsFirst(LTemplateResultInstruction<1>* instr);
2838 LInstruction* DefineFixed(LTemplateResultInstruction<1>* instr,
2840 LInstruction* DefineFixedDouble(LTemplateResultInstruction<1>* instr,
2842 // Assigns an environment to an instruction. An instruction which can
2843 // deoptimize must have an environment.
2844 LInstruction* AssignEnvironment(LInstruction* instr);
2845 // Assigns a pointer map to an instruction. An instruction which can
2846 // trigger a GC or a lazy deoptimization must have a pointer map.
2847 LInstruction* AssignPointerMap(LInstruction* instr);
2849 enum CanDeoptimize { CAN_DEOPTIMIZE_EAGERLY, CANNOT_DEOPTIMIZE_EAGERLY };
2851 // Marks a call for the register allocator. Assigns a pointer map to
2852 // support GC and lazy deoptimization. Assigns an environment to support
2853 // eager deoptimization if CAN_DEOPTIMIZE_EAGERLY.
2854 LInstruction* MarkAsCall(
2855 LInstruction* instr,
2856 HInstruction* hinstr,
2857 CanDeoptimize can_deoptimize = CANNOT_DEOPTIMIZE_EAGERLY);
2859 void VisitInstruction(HInstruction* current);
2860 void AddInstruction(LInstruction* instr, HInstruction* current);
2862 void DoBasicBlock(HBasicBlock* block, HBasicBlock* next_block);
2863 LInstruction* DoShift(Token::Value op, HBitwiseBinaryOperation* instr);
2864 LInstruction* DoArithmeticD(Token::Value op,
2865 HArithmeticBinaryOperation* instr);
2866 LInstruction* DoArithmeticT(Token::Value op,
2867 HBinaryOperation* instr);
2868 void FindDehoistedKeyDefinitions(HValue* candidate);
2870 HInstruction* current_instruction_;
2871 HBasicBlock* current_block_;
2872 HBasicBlock* next_block_;
2873 LAllocator* allocator_;
2875 DISALLOW_COPY_AND_ASSIGN(LChunkBuilder);
2878 #undef DECLARE_HYDROGEN_ACCESSOR
2879 #undef DECLARE_CONCRETE_INSTRUCTION
2881 } } // namespace v8::int
2883 #endif // V8_X64_LITHIUM_X64_H_