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(HasInstanceTypeAndBranch) \
87 V(InnerAllocatedObject) \
89 V(InstanceOfKnownGlobal) \
91 V(Integer32ToDouble) \
93 V(IsConstructCallAndBranch) \
94 V(IsObjectAndBranch) \
95 V(IsStringAndBranch) \
97 V(IsUndetectableAndBranch) \
102 V(LoadFieldByIndex) \
103 V(LoadFunctionPrototype) \
104 V(LoadGlobalGeneric) \
105 V(LoadGlobalViaContext) \
107 V(LoadKeyedGeneric) \
109 V(LoadNamedGeneric) \
121 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 virtual void SetDeferredLazyDeoptimizationEnvironment(LEnvironment* env) { }
247 // Interface to the register allocator and iterators.
248 bool IsMarkedAsCall() const { return IsCall(); }
250 virtual bool HasResult() const = 0;
251 virtual LOperand* result() const = 0;
253 LOperand* FirstInput() { return InputAt(0); }
254 LOperand* Output() { return HasResult() ? result() : NULL; }
256 virtual bool HasInterestingComment(LCodeGen* gen) const { return true; }
258 virtual bool MustSignExtendResult(LPlatformChunk* chunk) const {
266 virtual int InputCount() = 0;
267 virtual LOperand* InputAt(int i) = 0;
271 friend class InputIterator;
273 friend class TempIterator;
274 virtual int TempCount() = 0;
275 virtual LOperand* TempAt(int i) = 0;
277 class IsCallBits: public BitField<bool, 0, 1> {};
279 LEnvironment* environment_;
280 SetOncePointer<LPointerMap> pointer_map_;
281 HValue* hydrogen_value_;
286 // R = number of result operands (0 or 1).
288 class LTemplateResultInstruction : public LInstruction {
290 // Allow 0 or 1 output operands.
291 STATIC_ASSERT(R == 0 || R == 1);
292 bool HasResult() const final { return R != 0 && result() != NULL; }
293 void set_result(LOperand* operand) { results_[0] = operand; }
294 LOperand* result() const override { return results_[0]; }
296 bool MustSignExtendResult(LPlatformChunk* chunk) const final;
299 EmbeddedContainer<LOperand*, R> results_;
303 // R = number of result operands (0 or 1).
304 // I = number of input operands.
305 // T = number of temporary operands.
306 template<int R, int I, int T>
307 class LTemplateInstruction : public LTemplateResultInstruction<R> {
309 EmbeddedContainer<LOperand*, I> inputs_;
310 EmbeddedContainer<LOperand*, T> temps_;
314 int InputCount() final { return I; }
315 LOperand* InputAt(int i) final { return inputs_[i]; }
317 int TempCount() final { return T; }
318 LOperand* TempAt(int i) final { return temps_[i]; }
322 class LGap : public LTemplateInstruction<0, 0, 0> {
324 explicit LGap(HBasicBlock* block)
326 parallel_moves_[BEFORE] = NULL;
327 parallel_moves_[START] = NULL;
328 parallel_moves_[END] = NULL;
329 parallel_moves_[AFTER] = NULL;
332 // Can't use the DECLARE-macro here because of sub-classes.
333 bool IsGap() const final { return true; }
334 void PrintDataTo(StringStream* stream) override;
335 static LGap* cast(LInstruction* instr) {
336 DCHECK(instr->IsGap());
337 return reinterpret_cast<LGap*>(instr);
340 bool IsRedundant() const;
342 HBasicBlock* block() const { return block_; }
349 FIRST_INNER_POSITION = BEFORE,
350 LAST_INNER_POSITION = AFTER
353 LParallelMove* GetOrCreateParallelMove(InnerPosition pos,
355 if (parallel_moves_[pos] == NULL) {
356 parallel_moves_[pos] = new(zone) LParallelMove(zone);
358 return parallel_moves_[pos];
361 LParallelMove* GetParallelMove(InnerPosition pos) {
362 return parallel_moves_[pos];
366 LParallelMove* parallel_moves_[LAST_INNER_POSITION + 1];
371 class LInstructionGap final : public LGap {
373 explicit LInstructionGap(HBasicBlock* block) : LGap(block) { }
375 bool HasInterestingComment(LCodeGen* gen) const override {
376 return !IsRedundant();
379 DECLARE_CONCRETE_INSTRUCTION(InstructionGap, "gap")
383 class LGoto final : public LTemplateInstruction<0, 0, 0> {
385 explicit LGoto(HBasicBlock* block) : block_(block) { }
387 bool HasInterestingComment(LCodeGen* gen) const override;
388 DECLARE_CONCRETE_INSTRUCTION(Goto, "goto")
389 void PrintDataTo(StringStream* stream) override;
390 bool IsControl() const override { return true; }
392 int block_id() const { return block_->block_id(); }
399 class LLazyBailout final : public LTemplateInstruction<0, 0, 0> {
401 LLazyBailout() : gap_instructions_size_(0) { }
403 DECLARE_CONCRETE_INSTRUCTION(LazyBailout, "lazy-bailout")
405 void set_gap_instructions_size(int gap_instructions_size) {
406 gap_instructions_size_ = gap_instructions_size;
408 int gap_instructions_size() { return gap_instructions_size_; }
411 int gap_instructions_size_;
415 class LDummy final : public LTemplateInstruction<1, 0, 0> {
418 DECLARE_CONCRETE_INSTRUCTION(Dummy, "dummy")
422 class LDummyUse final : public LTemplateInstruction<1, 1, 0> {
424 explicit LDummyUse(LOperand* value) {
427 DECLARE_CONCRETE_INSTRUCTION(DummyUse, "dummy-use")
431 class LDeoptimize final : public LTemplateInstruction<0, 0, 0> {
433 bool IsControl() const override { return true; }
434 DECLARE_CONCRETE_INSTRUCTION(Deoptimize, "deoptimize")
435 DECLARE_HYDROGEN_ACCESSOR(Deoptimize)
439 class LLabel final : public LGap {
441 explicit LLabel(HBasicBlock* block)
442 : LGap(block), replacement_(NULL) { }
444 bool HasInterestingComment(LCodeGen* gen) const override { return false; }
445 DECLARE_CONCRETE_INSTRUCTION(Label, "label")
447 void PrintDataTo(StringStream* stream) override;
449 int block_id() const { return block()->block_id(); }
450 bool is_loop_header() const { return block()->IsLoopHeader(); }
451 bool is_osr_entry() const { return block()->is_osr_entry(); }
452 Label* label() { return &label_; }
453 LLabel* replacement() const { return replacement_; }
454 void set_replacement(LLabel* label) { replacement_ = label; }
455 bool HasReplacement() const { return replacement_ != NULL; }
459 LLabel* replacement_;
463 class LParameter final : public LTemplateInstruction<1, 0, 0> {
465 bool HasInterestingComment(LCodeGen* gen) const override { return false; }
466 DECLARE_CONCRETE_INSTRUCTION(Parameter, "parameter")
470 class LCallStub final : public LTemplateInstruction<1, 1, 0> {
472 explicit LCallStub(LOperand* context) {
473 inputs_[0] = context;
476 LOperand* context() { return inputs_[0]; }
478 DECLARE_CONCRETE_INSTRUCTION(CallStub, "call-stub")
479 DECLARE_HYDROGEN_ACCESSOR(CallStub)
483 class LUnknownOSRValue final : public LTemplateInstruction<1, 0, 0> {
485 bool HasInterestingComment(LCodeGen* gen) const override { return false; }
486 DECLARE_CONCRETE_INSTRUCTION(UnknownOSRValue, "unknown-osr-value")
490 template<int I, int T>
491 class LControlInstruction : public LTemplateInstruction<0, I, T> {
493 LControlInstruction() : false_label_(NULL), true_label_(NULL) { }
495 bool IsControl() const final { return true; }
497 int SuccessorCount() { return hydrogen()->SuccessorCount(); }
498 HBasicBlock* SuccessorAt(int i) { return hydrogen()->SuccessorAt(i); }
500 int TrueDestination(LChunk* chunk) {
501 return chunk->LookupDestination(true_block_id());
503 int FalseDestination(LChunk* chunk) {
504 return chunk->LookupDestination(false_block_id());
507 Label* TrueLabel(LChunk* chunk) {
508 if (true_label_ == NULL) {
509 true_label_ = chunk->GetAssemblyLabel(TrueDestination(chunk));
513 Label* FalseLabel(LChunk* chunk) {
514 if (false_label_ == NULL) {
515 false_label_ = chunk->GetAssemblyLabel(FalseDestination(chunk));
521 int true_block_id() { return SuccessorAt(0)->block_id(); }
522 int false_block_id() { return SuccessorAt(1)->block_id(); }
525 HControlInstruction* hydrogen() {
526 return HControlInstruction::cast(this->hydrogen_value());
534 class LWrapReceiver final : public LTemplateInstruction<1, 2, 0> {
536 LWrapReceiver(LOperand* receiver, LOperand* function) {
537 inputs_[0] = receiver;
538 inputs_[1] = function;
541 LOperand* receiver() { return inputs_[0]; }
542 LOperand* function() { return inputs_[1]; }
544 DECLARE_CONCRETE_INSTRUCTION(WrapReceiver, "wrap-receiver")
545 DECLARE_HYDROGEN_ACCESSOR(WrapReceiver)
549 class LApplyArguments final : public LTemplateInstruction<1, 4, 0> {
551 LApplyArguments(LOperand* function,
554 LOperand* elements) {
555 inputs_[0] = function;
556 inputs_[1] = receiver;
558 inputs_[3] = elements;
561 LOperand* function() { return inputs_[0]; }
562 LOperand* receiver() { return inputs_[1]; }
563 LOperand* length() { return inputs_[2]; }
564 LOperand* elements() { return inputs_[3]; }
566 DECLARE_CONCRETE_INSTRUCTION(ApplyArguments, "apply-arguments")
570 class LAccessArgumentsAt final : public LTemplateInstruction<1, 3, 0> {
572 LAccessArgumentsAt(LOperand* arguments, LOperand* length, LOperand* index) {
573 inputs_[0] = arguments;
578 LOperand* arguments() { return inputs_[0]; }
579 LOperand* length() { return inputs_[1]; }
580 LOperand* index() { return inputs_[2]; }
582 DECLARE_CONCRETE_INSTRUCTION(AccessArgumentsAt, "access-arguments-at")
584 void PrintDataTo(StringStream* stream) override;
588 class LArgumentsLength final : public LTemplateInstruction<1, 1, 0> {
590 explicit LArgumentsLength(LOperand* elements) {
591 inputs_[0] = elements;
594 LOperand* elements() { return inputs_[0]; }
596 DECLARE_CONCRETE_INSTRUCTION(ArgumentsLength, "arguments-length")
600 class LArgumentsElements final : public LTemplateInstruction<1, 0, 0> {
602 DECLARE_CONCRETE_INSTRUCTION(ArgumentsElements, "arguments-elements")
603 DECLARE_HYDROGEN_ACCESSOR(ArgumentsElements)
607 class LModByPowerOf2I final : public LTemplateInstruction<1, 1, 0> {
609 LModByPowerOf2I(LOperand* dividend, int32_t divisor) {
610 inputs_[0] = dividend;
614 LOperand* dividend() { return inputs_[0]; }
615 int32_t divisor() const { return divisor_; }
617 DECLARE_CONCRETE_INSTRUCTION(ModByPowerOf2I, "mod-by-power-of-2-i")
618 DECLARE_HYDROGEN_ACCESSOR(Mod)
625 class LModByConstI final : public LTemplateInstruction<1, 1, 2> {
627 LModByConstI(LOperand* dividend,
631 inputs_[0] = dividend;
637 LOperand* dividend() { return inputs_[0]; }
638 int32_t divisor() const { return divisor_; }
639 LOperand* temp1() { return temps_[0]; }
640 LOperand* temp2() { return temps_[1]; }
642 DECLARE_CONCRETE_INSTRUCTION(ModByConstI, "mod-by-const-i")
643 DECLARE_HYDROGEN_ACCESSOR(Mod)
650 class LModI final : public LTemplateInstruction<1, 2, 1> {
652 LModI(LOperand* left, LOperand* right, LOperand* temp) {
658 LOperand* left() { return inputs_[0]; }
659 LOperand* right() { return inputs_[1]; }
660 LOperand* temp() { return temps_[0]; }
662 DECLARE_CONCRETE_INSTRUCTION(ModI, "mod-i")
663 DECLARE_HYDROGEN_ACCESSOR(Mod)
667 class LDivByPowerOf2I final : public LTemplateInstruction<1, 1, 0> {
669 LDivByPowerOf2I(LOperand* dividend, int32_t divisor) {
670 inputs_[0] = dividend;
674 LOperand* dividend() { return inputs_[0]; }
675 int32_t divisor() const { return divisor_; }
677 DECLARE_CONCRETE_INSTRUCTION(DivByPowerOf2I, "div-by-power-of-2-i")
678 DECLARE_HYDROGEN_ACCESSOR(Div)
685 class LDivByConstI final : public LTemplateInstruction<1, 1, 2> {
687 LDivByConstI(LOperand* dividend,
691 inputs_[0] = dividend;
697 LOperand* dividend() { return inputs_[0]; }
698 int32_t divisor() const { return divisor_; }
699 LOperand* temp1() { return temps_[0]; }
700 LOperand* temp2() { return temps_[1]; }
702 DECLARE_CONCRETE_INSTRUCTION(DivByConstI, "div-by-const-i")
703 DECLARE_HYDROGEN_ACCESSOR(Div)
710 class LDivI final : public LTemplateInstruction<1, 2, 1> {
712 LDivI(LOperand* dividend, LOperand* divisor, LOperand* temp) {
713 inputs_[0] = dividend;
714 inputs_[1] = divisor;
718 LOperand* dividend() { return inputs_[0]; }
719 LOperand* divisor() { return inputs_[1]; }
720 LOperand* temp() { return temps_[0]; }
722 DECLARE_CONCRETE_INSTRUCTION(DivI, "div-i")
723 DECLARE_HYDROGEN_ACCESSOR(BinaryOperation)
727 class LFlooringDivByPowerOf2I final : public LTemplateInstruction<1, 1, 0> {
729 LFlooringDivByPowerOf2I(LOperand* dividend, int32_t divisor) {
730 inputs_[0] = dividend;
734 LOperand* dividend() { return inputs_[0]; }
735 int32_t divisor() const { return divisor_; }
737 DECLARE_CONCRETE_INSTRUCTION(FlooringDivByPowerOf2I,
738 "flooring-div-by-power-of-2-i")
739 DECLARE_HYDROGEN_ACCESSOR(MathFloorOfDiv)
746 class LFlooringDivByConstI final : public LTemplateInstruction<1, 1, 3> {
748 LFlooringDivByConstI(LOperand* dividend,
753 inputs_[0] = dividend;
760 LOperand* dividend() { return inputs_[0]; }
761 int32_t divisor() const { return divisor_; }
762 LOperand* temp1() { return temps_[0]; }
763 LOperand* temp2() { return temps_[1]; }
764 LOperand* temp3() { return temps_[2]; }
766 DECLARE_CONCRETE_INSTRUCTION(FlooringDivByConstI, "flooring-div-by-const-i")
767 DECLARE_HYDROGEN_ACCESSOR(MathFloorOfDiv)
774 class LFlooringDivI final : public LTemplateInstruction<1, 2, 1> {
776 LFlooringDivI(LOperand* dividend, LOperand* divisor, LOperand* temp) {
777 inputs_[0] = dividend;
778 inputs_[1] = divisor;
782 LOperand* dividend() { return inputs_[0]; }
783 LOperand* divisor() { return inputs_[1]; }
784 LOperand* temp() { return temps_[0]; }
786 DECLARE_CONCRETE_INSTRUCTION(FlooringDivI, "flooring-div-i")
787 DECLARE_HYDROGEN_ACCESSOR(MathFloorOfDiv)
791 class LMulI final : public LTemplateInstruction<1, 2, 0> {
793 LMulI(LOperand* left, LOperand* right) {
798 LOperand* left() { return inputs_[0]; }
799 LOperand* right() { return inputs_[1]; }
801 DECLARE_CONCRETE_INSTRUCTION(MulI, "mul-i")
802 DECLARE_HYDROGEN_ACCESSOR(Mul)
806 class LCompareNumericAndBranch final : public LControlInstruction<2, 0> {
808 LCompareNumericAndBranch(LOperand* left, LOperand* right) {
813 LOperand* left() { return inputs_[0]; }
814 LOperand* right() { return inputs_[1]; }
816 DECLARE_CONCRETE_INSTRUCTION(CompareNumericAndBranch,
817 "compare-numeric-and-branch")
818 DECLARE_HYDROGEN_ACCESSOR(CompareNumericAndBranch)
820 Token::Value op() const { return hydrogen()->token(); }
821 bool is_double() const {
822 return hydrogen()->representation().IsDouble();
825 void PrintDataTo(StringStream* stream) override;
829 class LMathFloor final : public LTemplateInstruction<1, 1, 0> {
831 explicit LMathFloor(LOperand* value) {
835 LOperand* value() { return inputs_[0]; }
837 DECLARE_CONCRETE_INSTRUCTION(MathFloor, "math-floor")
838 DECLARE_HYDROGEN_ACCESSOR(UnaryMathOperation)
842 class LMathRound final : public LTemplateInstruction<1, 1, 1> {
844 LMathRound(LOperand* value, LOperand* temp) {
849 LOperand* value() { return inputs_[0]; }
850 LOperand* temp() { return temps_[0]; }
852 DECLARE_CONCRETE_INSTRUCTION(MathRound, "math-round")
853 DECLARE_HYDROGEN_ACCESSOR(UnaryMathOperation)
857 class LMathFround final : public LTemplateInstruction<1, 1, 0> {
859 explicit LMathFround(LOperand* value) { inputs_[0] = value; }
861 LOperand* value() { return inputs_[0]; }
863 DECLARE_CONCRETE_INSTRUCTION(MathFround, "math-fround")
867 class LMathAbs final : public LTemplateInstruction<1, 2, 0> {
869 explicit LMathAbs(LOperand* context, LOperand* value) {
870 inputs_[1] = context;
874 LOperand* context() { return inputs_[1]; }
875 LOperand* value() { return inputs_[0]; }
877 DECLARE_CONCRETE_INSTRUCTION(MathAbs, "math-abs")
878 DECLARE_HYDROGEN_ACCESSOR(UnaryMathOperation)
882 class LMathLog final : public LTemplateInstruction<1, 1, 0> {
884 explicit LMathLog(LOperand* value) {
888 LOperand* value() { return inputs_[0]; }
890 DECLARE_CONCRETE_INSTRUCTION(MathLog, "math-log")
894 class LMathClz32 final : public LTemplateInstruction<1, 1, 0> {
896 explicit LMathClz32(LOperand* value) {
900 LOperand* value() { return inputs_[0]; }
902 DECLARE_CONCRETE_INSTRUCTION(MathClz32, "math-clz32")
906 class LMathExp final : public LTemplateInstruction<1, 1, 2> {
908 LMathExp(LOperand* value, LOperand* temp1, LOperand* temp2) {
912 ExternalReference::InitializeMathExpData();
915 LOperand* value() { return inputs_[0]; }
916 LOperand* temp1() { return temps_[0]; }
917 LOperand* temp2() { return temps_[1]; }
919 DECLARE_CONCRETE_INSTRUCTION(MathExp, "math-exp")
923 class LMathSqrt final : public LTemplateInstruction<1, 1, 0> {
925 explicit LMathSqrt(LOperand* value) {
929 LOperand* value() { return inputs_[0]; }
931 DECLARE_CONCRETE_INSTRUCTION(MathSqrt, "math-sqrt")
935 class LMathPowHalf final : public LTemplateInstruction<1, 1, 0> {
937 explicit LMathPowHalf(LOperand* value) {
941 LOperand* value() { return inputs_[0]; }
943 DECLARE_CONCRETE_INSTRUCTION(MathPowHalf, "math-pow-half")
947 class LCmpObjectEqAndBranch final : public LControlInstruction<2, 0> {
949 LCmpObjectEqAndBranch(LOperand* left, LOperand* right) {
954 LOperand* left() { return inputs_[0]; }
955 LOperand* right() { return inputs_[1]; }
957 DECLARE_CONCRETE_INSTRUCTION(CmpObjectEqAndBranch, "cmp-object-eq-and-branch")
961 class LCmpHoleAndBranch final : public LControlInstruction<1, 0> {
963 explicit LCmpHoleAndBranch(LOperand* object) {
967 LOperand* object() { return inputs_[0]; }
969 DECLARE_CONCRETE_INSTRUCTION(CmpHoleAndBranch, "cmp-hole-and-branch")
970 DECLARE_HYDROGEN_ACCESSOR(CompareHoleAndBranch)
974 class LCompareMinusZeroAndBranch final : public LControlInstruction<1, 0> {
976 explicit LCompareMinusZeroAndBranch(LOperand* value) {
980 LOperand* value() { return inputs_[0]; }
982 DECLARE_CONCRETE_INSTRUCTION(CompareMinusZeroAndBranch,
983 "cmp-minus-zero-and-branch")
984 DECLARE_HYDROGEN_ACCESSOR(CompareMinusZeroAndBranch)
988 class LIsObjectAndBranch final : public LControlInstruction<1, 0> {
990 explicit LIsObjectAndBranch(LOperand* value) {
994 LOperand* value() { return inputs_[0]; }
996 DECLARE_CONCRETE_INSTRUCTION(IsObjectAndBranch, "is-object-and-branch")
997 DECLARE_HYDROGEN_ACCESSOR(IsObjectAndBranch)
999 void PrintDataTo(StringStream* stream) override;
1003 class LIsStringAndBranch final : public LControlInstruction<1, 1> {
1005 explicit LIsStringAndBranch(LOperand* value, LOperand* temp) {
1010 LOperand* value() { return inputs_[0]; }
1011 LOperand* temp() { return temps_[0]; }
1013 DECLARE_CONCRETE_INSTRUCTION(IsStringAndBranch, "is-string-and-branch")
1014 DECLARE_HYDROGEN_ACCESSOR(IsStringAndBranch)
1016 void PrintDataTo(StringStream* stream) override;
1020 class LIsSmiAndBranch final : public LControlInstruction<1, 0> {
1022 explicit LIsSmiAndBranch(LOperand* value) {
1026 LOperand* value() { return inputs_[0]; }
1028 DECLARE_CONCRETE_INSTRUCTION(IsSmiAndBranch, "is-smi-and-branch")
1029 DECLARE_HYDROGEN_ACCESSOR(IsSmiAndBranch)
1031 void PrintDataTo(StringStream* stream) override;
1035 class LIsUndetectableAndBranch final : public LControlInstruction<1, 1> {
1037 explicit LIsUndetectableAndBranch(LOperand* value, LOperand* temp) {
1042 LOperand* value() { return inputs_[0]; }
1043 LOperand* temp() { return temps_[0]; }
1045 DECLARE_CONCRETE_INSTRUCTION(IsUndetectableAndBranch,
1046 "is-undetectable-and-branch")
1047 DECLARE_HYDROGEN_ACCESSOR(IsUndetectableAndBranch)
1049 void PrintDataTo(StringStream* stream) override;
1053 class LStringCompareAndBranch final : public LControlInstruction<3, 0> {
1055 explicit LStringCompareAndBranch(LOperand* context,
1058 inputs_[0] = context;
1063 LOperand* context() { return inputs_[0]; }
1064 LOperand* left() { return inputs_[1]; }
1065 LOperand* right() { return inputs_[2]; }
1067 DECLARE_CONCRETE_INSTRUCTION(StringCompareAndBranch,
1068 "string-compare-and-branch")
1069 DECLARE_HYDROGEN_ACCESSOR(StringCompareAndBranch)
1071 void PrintDataTo(StringStream* stream) override;
1073 Token::Value op() const { return hydrogen()->token(); }
1077 class LHasInstanceTypeAndBranch final : public LControlInstruction<1, 0> {
1079 explicit LHasInstanceTypeAndBranch(LOperand* value) {
1083 LOperand* value() { return inputs_[0]; }
1085 DECLARE_CONCRETE_INSTRUCTION(HasInstanceTypeAndBranch,
1086 "has-instance-type-and-branch")
1087 DECLARE_HYDROGEN_ACCESSOR(HasInstanceTypeAndBranch)
1089 void PrintDataTo(StringStream* stream) override;
1093 class LGetCachedArrayIndex final : public LTemplateInstruction<1, 1, 0> {
1095 explicit LGetCachedArrayIndex(LOperand* value) {
1099 LOperand* value() { return inputs_[0]; }
1101 DECLARE_CONCRETE_INSTRUCTION(GetCachedArrayIndex, "get-cached-array-index")
1102 DECLARE_HYDROGEN_ACCESSOR(GetCachedArrayIndex)
1106 class LHasCachedArrayIndexAndBranch final : public LControlInstruction<1, 0> {
1108 explicit LHasCachedArrayIndexAndBranch(LOperand* value) {
1112 LOperand* value() { return inputs_[0]; }
1114 DECLARE_CONCRETE_INSTRUCTION(HasCachedArrayIndexAndBranch,
1115 "has-cached-array-index-and-branch")
1116 DECLARE_HYDROGEN_ACCESSOR(HasCachedArrayIndexAndBranch)
1118 void PrintDataTo(StringStream* stream) override;
1122 class LClassOfTestAndBranch final : public LControlInstruction<1, 2> {
1124 LClassOfTestAndBranch(LOperand* value, LOperand* temp, LOperand* temp2) {
1130 LOperand* value() { return inputs_[0]; }
1131 LOperand* temp() { return temps_[0]; }
1132 LOperand* temp2() { return temps_[1]; }
1134 DECLARE_CONCRETE_INSTRUCTION(ClassOfTestAndBranch,
1135 "class-of-test-and-branch")
1136 DECLARE_HYDROGEN_ACCESSOR(ClassOfTestAndBranch)
1138 void PrintDataTo(StringStream* stream) override;
1142 class LCmpT final : public LTemplateInstruction<1, 3, 0> {
1144 LCmpT(LOperand* context, LOperand* left, LOperand* right) {
1145 inputs_[0] = context;
1150 LOperand* context() { return inputs_[0]; }
1151 LOperand* left() { return inputs_[1]; }
1152 LOperand* right() { return inputs_[2]; }
1154 DECLARE_CONCRETE_INSTRUCTION(CmpT, "cmp-t")
1155 DECLARE_HYDROGEN_ACCESSOR(CompareGeneric)
1157 Strength strength() { return hydrogen()->strength(); }
1159 Token::Value op() const { return hydrogen()->token(); }
1163 class LInstanceOf final : public LTemplateInstruction<1, 3, 0> {
1165 LInstanceOf(LOperand* context, LOperand* left, LOperand* right) {
1166 inputs_[0] = context;
1171 LOperand* context() { return inputs_[0]; }
1172 LOperand* left() { return inputs_[1]; }
1173 LOperand* right() { return inputs_[2]; }
1175 DECLARE_CONCRETE_INSTRUCTION(InstanceOf, "instance-of")
1179 class LInstanceOfKnownGlobal final : public LTemplateInstruction<1, 2, 1> {
1181 LInstanceOfKnownGlobal(LOperand* context, LOperand* value, LOperand* temp) {
1182 inputs_[0] = context;
1187 LOperand* context() { return inputs_[0]; }
1188 LOperand* value() { return inputs_[1]; }
1189 LOperand* temp() { return temps_[0]; }
1191 DECLARE_CONCRETE_INSTRUCTION(InstanceOfKnownGlobal,
1192 "instance-of-known-global")
1193 DECLARE_HYDROGEN_ACCESSOR(InstanceOfKnownGlobal)
1195 Handle<JSFunction> function() const { return hydrogen()->function(); }
1196 LEnvironment* GetDeferredLazyDeoptimizationEnvironment() {
1197 return lazy_deopt_env_;
1199 virtual void SetDeferredLazyDeoptimizationEnvironment(
1200 LEnvironment* env) override {
1201 lazy_deopt_env_ = env;
1205 LEnvironment* lazy_deopt_env_;
1209 class LBoundsCheck final : public LTemplateInstruction<0, 2, 0> {
1211 LBoundsCheck(LOperand* index, LOperand* length) {
1213 inputs_[1] = length;
1216 LOperand* index() { return inputs_[0]; }
1217 LOperand* length() { return inputs_[1]; }
1219 DECLARE_CONCRETE_INSTRUCTION(BoundsCheck, "bounds-check")
1220 DECLARE_HYDROGEN_ACCESSOR(BoundsCheck)
1224 class LBitI final : public LTemplateInstruction<1, 2, 0> {
1226 LBitI(LOperand* left, LOperand* right) {
1231 LOperand* left() { return inputs_[0]; }
1232 LOperand* right() { return inputs_[1]; }
1234 Token::Value op() const { return hydrogen()->op(); }
1235 bool IsInteger32() const {
1236 return hydrogen()->representation().IsInteger32();
1239 DECLARE_CONCRETE_INSTRUCTION(BitI, "bit-i")
1240 DECLARE_HYDROGEN_ACCESSOR(Bitwise)
1244 class LShiftI final : public LTemplateInstruction<1, 2, 0> {
1246 LShiftI(Token::Value op, LOperand* left, LOperand* right, bool can_deopt)
1247 : op_(op), can_deopt_(can_deopt) {
1252 Token::Value op() const { return op_; }
1253 LOperand* left() { return inputs_[0]; }
1254 LOperand* right() { return inputs_[1]; }
1255 bool can_deopt() const { return can_deopt_; }
1257 DECLARE_CONCRETE_INSTRUCTION(ShiftI, "shift-i")
1265 class LSubI final : public LTemplateInstruction<1, 2, 0> {
1267 LSubI(LOperand* left, LOperand* right) {
1272 LOperand* left() { return inputs_[0]; }
1273 LOperand* right() { return inputs_[1]; }
1275 DECLARE_CONCRETE_INSTRUCTION(SubI, "sub-i")
1276 DECLARE_HYDROGEN_ACCESSOR(Sub)
1280 class LConstantI final : public LTemplateInstruction<1, 0, 0> {
1282 DECLARE_CONCRETE_INSTRUCTION(ConstantI, "constant-i")
1283 DECLARE_HYDROGEN_ACCESSOR(Constant)
1285 int32_t value() const { return hydrogen()->Integer32Value(); }
1289 class LConstantS final : public LTemplateInstruction<1, 0, 0> {
1291 DECLARE_CONCRETE_INSTRUCTION(ConstantS, "constant-s")
1292 DECLARE_HYDROGEN_ACCESSOR(Constant)
1294 Smi* value() const { return Smi::FromInt(hydrogen()->Integer32Value()); }
1298 class LConstantD final : public LTemplateInstruction<1, 0, 0> {
1300 DECLARE_CONCRETE_INSTRUCTION(ConstantD, "constant-d")
1301 DECLARE_HYDROGEN_ACCESSOR(Constant)
1303 uint64_t bits() const { return hydrogen()->DoubleValueAsBits(); }
1307 class LConstantE final : public LTemplateInstruction<1, 0, 0> {
1309 DECLARE_CONCRETE_INSTRUCTION(ConstantE, "constant-e")
1310 DECLARE_HYDROGEN_ACCESSOR(Constant)
1312 ExternalReference value() const {
1313 return hydrogen()->ExternalReferenceValue();
1318 class LConstantT final : public LTemplateInstruction<1, 0, 0> {
1320 DECLARE_CONCRETE_INSTRUCTION(ConstantT, "constant-t")
1321 DECLARE_HYDROGEN_ACCESSOR(Constant)
1323 Handle<Object> value(Isolate* isolate) const {
1324 return hydrogen()->handle(isolate);
1329 class LBranch final : public LControlInstruction<1, 0> {
1331 explicit LBranch(LOperand* value) {
1335 LOperand* value() { return inputs_[0]; }
1337 DECLARE_CONCRETE_INSTRUCTION(Branch, "branch")
1338 DECLARE_HYDROGEN_ACCESSOR(Branch)
1340 void PrintDataTo(StringStream* stream) override;
1344 class LDebugBreak final : public LTemplateInstruction<0, 0, 0> {
1346 DECLARE_CONCRETE_INSTRUCTION(DebugBreak, "break")
1350 class LCmpMapAndBranch final : public LControlInstruction<1, 0> {
1352 explicit LCmpMapAndBranch(LOperand* value) {
1356 LOperand* value() { return inputs_[0]; }
1358 DECLARE_CONCRETE_INSTRUCTION(CmpMapAndBranch, "cmp-map-and-branch")
1359 DECLARE_HYDROGEN_ACCESSOR(CompareMap)
1361 Handle<Map> map() const { return hydrogen()->map().handle(); }
1365 class LMapEnumLength final : public LTemplateInstruction<1, 1, 0> {
1367 explicit LMapEnumLength(LOperand* value) {
1371 LOperand* value() { return inputs_[0]; }
1373 DECLARE_CONCRETE_INSTRUCTION(MapEnumLength, "map-enum-length")
1377 class LDateField final : public LTemplateInstruction<1, 1, 0> {
1379 LDateField(LOperand* date, Smi* index) : index_(index) {
1383 LOperand* date() { return inputs_[0]; }
1384 Smi* index() const { return index_; }
1386 DECLARE_CONCRETE_INSTRUCTION(DateField, "date-field")
1387 DECLARE_HYDROGEN_ACCESSOR(DateField)
1394 class LSeqStringGetChar final : public LTemplateInstruction<1, 2, 0> {
1396 LSeqStringGetChar(LOperand* string, LOperand* index) {
1397 inputs_[0] = string;
1401 LOperand* string() const { return inputs_[0]; }
1402 LOperand* index() const { return inputs_[1]; }
1404 DECLARE_CONCRETE_INSTRUCTION(SeqStringGetChar, "seq-string-get-char")
1405 DECLARE_HYDROGEN_ACCESSOR(SeqStringGetChar)
1409 class LSeqStringSetChar final : public LTemplateInstruction<1, 4, 0> {
1411 LSeqStringSetChar(LOperand* context,
1415 inputs_[0] = context;
1416 inputs_[1] = string;
1421 LOperand* string() { return inputs_[1]; }
1422 LOperand* index() { return inputs_[2]; }
1423 LOperand* value() { return inputs_[3]; }
1425 DECLARE_CONCRETE_INSTRUCTION(SeqStringSetChar, "seq-string-set-char")
1426 DECLARE_HYDROGEN_ACCESSOR(SeqStringSetChar)
1430 class LAddI final : public LTemplateInstruction<1, 2, 0> {
1432 LAddI(LOperand* left, LOperand* right) {
1437 LOperand* left() { return inputs_[0]; }
1438 LOperand* right() { return inputs_[1]; }
1440 static bool UseLea(HAdd* add) {
1441 return !add->CheckFlag(HValue::kCanOverflow) &&
1442 add->BetterLeftOperand()->UseCount() > 1;
1445 DECLARE_CONCRETE_INSTRUCTION(AddI, "add-i")
1446 DECLARE_HYDROGEN_ACCESSOR(Add)
1450 class LMathMinMax final : public LTemplateInstruction<1, 2, 0> {
1452 LMathMinMax(LOperand* left, LOperand* right) {
1457 LOperand* left() { return inputs_[0]; }
1458 LOperand* right() { return inputs_[1]; }
1460 DECLARE_CONCRETE_INSTRUCTION(MathMinMax, "math-min-max")
1461 DECLARE_HYDROGEN_ACCESSOR(MathMinMax)
1465 class LPower final : public LTemplateInstruction<1, 2, 0> {
1467 LPower(LOperand* left, LOperand* right) {
1472 LOperand* left() { return inputs_[0]; }
1473 LOperand* right() { return inputs_[1]; }
1475 DECLARE_CONCRETE_INSTRUCTION(Power, "power")
1476 DECLARE_HYDROGEN_ACCESSOR(Power)
1480 class LArithmeticD final : public LTemplateInstruction<1, 2, 0> {
1482 LArithmeticD(Token::Value op, LOperand* left, LOperand* right)
1488 Token::Value op() const { return op_; }
1489 LOperand* left() { return inputs_[0]; }
1490 LOperand* right() { return inputs_[1]; }
1492 Opcode opcode() const override { return LInstruction::kArithmeticD; }
1493 void CompileToNative(LCodeGen* generator) override;
1494 const char* Mnemonic() const override;
1501 class LArithmeticT final : public LTemplateInstruction<1, 3, 0> {
1503 LArithmeticT(Token::Value op,
1508 inputs_[0] = context;
1513 Token::Value op() const { return op_; }
1514 LOperand* context() { return inputs_[0]; }
1515 LOperand* left() { return inputs_[1]; }
1516 LOperand* right() { return inputs_[2]; }
1518 Opcode opcode() const override { return LInstruction::kArithmeticT; }
1519 void CompileToNative(LCodeGen* generator) override;
1520 const char* Mnemonic() const override;
1522 DECLARE_HYDROGEN_ACCESSOR(BinaryOperation)
1524 Strength strength() { return hydrogen()->strength(); }
1531 class LReturn final : public LTemplateInstruction<0, 3, 0> {
1533 explicit LReturn(LOperand* value,
1535 LOperand* parameter_count) {
1537 inputs_[1] = context;
1538 inputs_[2] = parameter_count;
1541 LOperand* value() { return inputs_[0]; }
1542 LOperand* context() { return inputs_[1]; }
1544 bool has_constant_parameter_count() {
1545 return parameter_count()->IsConstantOperand();
1547 LConstantOperand* constant_parameter_count() {
1548 DCHECK(has_constant_parameter_count());
1549 return LConstantOperand::cast(parameter_count());
1551 LOperand* parameter_count() { return inputs_[2]; }
1553 DECLARE_CONCRETE_INSTRUCTION(Return, "return")
1554 DECLARE_HYDROGEN_ACCESSOR(Return)
1558 class LLoadNamedField final : public LTemplateInstruction<1, 1, 0> {
1560 explicit LLoadNamedField(LOperand* object) {
1561 inputs_[0] = object;
1564 LOperand* object() { return inputs_[0]; }
1566 DECLARE_CONCRETE_INSTRUCTION(LoadNamedField, "load-named-field")
1567 DECLARE_HYDROGEN_ACCESSOR(LoadNamedField)
1571 class LLoadNamedGeneric final : public LTemplateInstruction<1, 2, 1> {
1573 explicit LLoadNamedGeneric(LOperand* context, LOperand* object,
1575 inputs_[0] = context;
1576 inputs_[1] = object;
1580 DECLARE_CONCRETE_INSTRUCTION(LoadNamedGeneric, "load-named-generic")
1581 DECLARE_HYDROGEN_ACCESSOR(LoadNamedGeneric)
1583 LOperand* context() { return inputs_[0]; }
1584 LOperand* object() { return inputs_[1]; }
1585 LOperand* temp_vector() { return temps_[0]; }
1587 Handle<Object> name() const { return hydrogen()->name(); }
1591 class LLoadFunctionPrototype final : public LTemplateInstruction<1, 1, 0> {
1593 explicit LLoadFunctionPrototype(LOperand* function) {
1594 inputs_[0] = function;
1597 DECLARE_CONCRETE_INSTRUCTION(LoadFunctionPrototype, "load-function-prototype")
1598 DECLARE_HYDROGEN_ACCESSOR(LoadFunctionPrototype)
1600 LOperand* function() { return inputs_[0]; }
1604 class LLoadRoot final : public LTemplateInstruction<1, 0, 0> {
1606 DECLARE_CONCRETE_INSTRUCTION(LoadRoot, "load-root")
1607 DECLARE_HYDROGEN_ACCESSOR(LoadRoot)
1609 Heap::RootListIndex index() const { return hydrogen()->index(); }
1613 inline static bool ExternalArrayOpRequiresTemp(
1614 Representation key_representation,
1615 ElementsKind elements_kind) {
1616 // Operations that require the key to be divided by two to be converted into
1617 // an index cannot fold the scale operation into a load and need an extra
1618 // temp register to do the work.
1619 return SmiValuesAre31Bits() && key_representation.IsSmi() &&
1620 (elements_kind == EXTERNAL_INT8_ELEMENTS ||
1621 elements_kind == EXTERNAL_UINT8_ELEMENTS ||
1622 elements_kind == EXTERNAL_UINT8_CLAMPED_ELEMENTS ||
1623 elements_kind == UINT8_ELEMENTS ||
1624 elements_kind == INT8_ELEMENTS ||
1625 elements_kind == UINT8_CLAMPED_ELEMENTS);
1629 class LLoadKeyed final : public LTemplateInstruction<1, 2, 0> {
1631 LLoadKeyed(LOperand* elements, LOperand* key) {
1632 inputs_[0] = elements;
1636 DECLARE_CONCRETE_INSTRUCTION(LoadKeyed, "load-keyed")
1637 DECLARE_HYDROGEN_ACCESSOR(LoadKeyed)
1639 bool is_external() const {
1640 return hydrogen()->is_external();
1642 bool is_fixed_typed_array() const {
1643 return hydrogen()->is_fixed_typed_array();
1645 bool is_typed_elements() const {
1646 return is_external() || is_fixed_typed_array();
1648 LOperand* elements() { return inputs_[0]; }
1649 LOperand* key() { return inputs_[1]; }
1650 void PrintDataTo(StringStream* stream) override;
1651 uint32_t base_offset() const { return hydrogen()->base_offset(); }
1652 ElementsKind elements_kind() const {
1653 return hydrogen()->elements_kind();
1658 class LLoadKeyedGeneric final : public LTemplateInstruction<1, 3, 1> {
1660 LLoadKeyedGeneric(LOperand* context, LOperand* obj, LOperand* key,
1662 inputs_[0] = context;
1668 DECLARE_CONCRETE_INSTRUCTION(LoadKeyedGeneric, "load-keyed-generic")
1669 DECLARE_HYDROGEN_ACCESSOR(LoadKeyedGeneric)
1671 LOperand* context() { return inputs_[0]; }
1672 LOperand* object() { return inputs_[1]; }
1673 LOperand* key() { return inputs_[2]; }
1674 LOperand* temp_vector() { return temps_[0]; }
1678 class LLoadGlobalGeneric final : public LTemplateInstruction<1, 2, 1> {
1680 explicit LLoadGlobalGeneric(LOperand* context, LOperand* global_object,
1682 inputs_[0] = context;
1683 inputs_[1] = global_object;
1687 DECLARE_CONCRETE_INSTRUCTION(LoadGlobalGeneric, "load-global-generic")
1688 DECLARE_HYDROGEN_ACCESSOR(LoadGlobalGeneric)
1690 LOperand* context() { return inputs_[0]; }
1691 LOperand* global_object() { return inputs_[1]; }
1692 LOperand* temp_vector() { return temps_[0]; }
1694 Handle<Object> name() const { return hydrogen()->name(); }
1695 TypeofMode typeof_mode() const { return hydrogen()->typeof_mode(); }
1699 class LLoadGlobalViaContext final : public LTemplateInstruction<1, 1, 1> {
1701 explicit LLoadGlobalViaContext(LOperand* context) { inputs_[0] = context; }
1703 DECLARE_CONCRETE_INSTRUCTION(LoadGlobalViaContext, "load-global-via-context")
1704 DECLARE_HYDROGEN_ACCESSOR(LoadGlobalViaContext)
1706 void PrintDataTo(StringStream* stream) override;
1708 LOperand* context() { return inputs_[0]; }
1710 Handle<Object> name() const { return hydrogen()->name(); }
1711 int depth() const { return hydrogen()->depth(); }
1712 int slot_index() const { return hydrogen()->slot_index(); }
1716 class LLoadContextSlot final : public LTemplateInstruction<1, 1, 0> {
1718 explicit LLoadContextSlot(LOperand* context) {
1719 inputs_[0] = context;
1722 LOperand* context() { return inputs_[0]; }
1724 DECLARE_CONCRETE_INSTRUCTION(LoadContextSlot, "load-context-slot")
1725 DECLARE_HYDROGEN_ACCESSOR(LoadContextSlot)
1727 int slot_index() { return hydrogen()->slot_index(); }
1729 void PrintDataTo(StringStream* stream) override;
1733 class LStoreContextSlot final : public LTemplateInstruction<0, 2, 1> {
1735 LStoreContextSlot(LOperand* context, LOperand* value, LOperand* temp) {
1736 inputs_[0] = context;
1741 LOperand* context() { return inputs_[0]; }
1742 LOperand* value() { return inputs_[1]; }
1743 LOperand* temp() { return temps_[0]; }
1745 DECLARE_CONCRETE_INSTRUCTION(StoreContextSlot, "store-context-slot")
1746 DECLARE_HYDROGEN_ACCESSOR(StoreContextSlot)
1748 int slot_index() { return hydrogen()->slot_index(); }
1750 void PrintDataTo(StringStream* stream) override;
1754 class LPushArgument final : public LTemplateInstruction<0, 1, 0> {
1756 explicit LPushArgument(LOperand* value) {
1760 LOperand* value() { return inputs_[0]; }
1762 DECLARE_CONCRETE_INSTRUCTION(PushArgument, "push-argument")
1766 class LDrop final : public LTemplateInstruction<0, 0, 0> {
1768 explicit LDrop(int count) : count_(count) { }
1770 int count() const { return count_; }
1772 DECLARE_CONCRETE_INSTRUCTION(Drop, "drop")
1779 class LStoreCodeEntry final : public LTemplateInstruction<0, 2, 0> {
1781 LStoreCodeEntry(LOperand* function, LOperand* code_object) {
1782 inputs_[0] = function;
1783 inputs_[1] = code_object;
1786 LOperand* function() { return inputs_[0]; }
1787 LOperand* code_object() { return inputs_[1]; }
1789 void PrintDataTo(StringStream* stream) override;
1791 DECLARE_CONCRETE_INSTRUCTION(StoreCodeEntry, "store-code-entry")
1792 DECLARE_HYDROGEN_ACCESSOR(StoreCodeEntry)
1796 class LInnerAllocatedObject final : public LTemplateInstruction<1, 2, 0> {
1798 LInnerAllocatedObject(LOperand* base_object, LOperand* offset) {
1799 inputs_[0] = base_object;
1800 inputs_[1] = offset;
1803 LOperand* base_object() const { return inputs_[0]; }
1804 LOperand* offset() const { return inputs_[1]; }
1806 void PrintDataTo(StringStream* stream) override;
1808 DECLARE_CONCRETE_INSTRUCTION(InnerAllocatedObject, "inner-allocated-object")
1812 class LThisFunction final : public LTemplateInstruction<1, 0, 0> {
1814 DECLARE_CONCRETE_INSTRUCTION(ThisFunction, "this-function")
1815 DECLARE_HYDROGEN_ACCESSOR(ThisFunction)
1819 class LContext final : public LTemplateInstruction<1, 0, 0> {
1821 DECLARE_CONCRETE_INSTRUCTION(Context, "context")
1822 DECLARE_HYDROGEN_ACCESSOR(Context)
1826 class LDeclareGlobals final : public LTemplateInstruction<0, 1, 0> {
1828 explicit LDeclareGlobals(LOperand* context) {
1829 inputs_[0] = context;
1832 LOperand* context() { return inputs_[0]; }
1834 DECLARE_CONCRETE_INSTRUCTION(DeclareGlobals, "declare-globals")
1835 DECLARE_HYDROGEN_ACCESSOR(DeclareGlobals)
1839 class LCallJSFunction final : public LTemplateInstruction<1, 1, 0> {
1841 explicit LCallJSFunction(LOperand* function) {
1842 inputs_[0] = function;
1845 LOperand* function() { return inputs_[0]; }
1847 DECLARE_CONCRETE_INSTRUCTION(CallJSFunction, "call-js-function")
1848 DECLARE_HYDROGEN_ACCESSOR(CallJSFunction)
1850 void PrintDataTo(StringStream* stream) override;
1852 int arity() const { return hydrogen()->argument_count() - 1; }
1856 class LCallWithDescriptor final : public LTemplateResultInstruction<1> {
1858 LCallWithDescriptor(CallInterfaceDescriptor descriptor,
1859 const ZoneList<LOperand*>& operands, Zone* zone)
1860 : inputs_(descriptor.GetRegisterParameterCount() +
1861 kImplicitRegisterParameterCount,
1863 DCHECK(descriptor.GetRegisterParameterCount() +
1864 kImplicitRegisterParameterCount ==
1866 inputs_.AddAll(operands, zone);
1869 LOperand* target() const { return inputs_[0]; }
1871 DECLARE_HYDROGEN_ACCESSOR(CallWithDescriptor)
1873 // The target and context are passed as implicit parameters that are not
1874 // explicitly listed in the descriptor.
1875 static const int kImplicitRegisterParameterCount = 2;
1878 DECLARE_CONCRETE_INSTRUCTION(CallWithDescriptor, "call-with-descriptor")
1880 void PrintDataTo(StringStream* stream) override;
1882 int arity() const { return hydrogen()->argument_count() - 1; }
1884 ZoneList<LOperand*> inputs_;
1886 // Iterator support.
1887 int InputCount() final { return inputs_.length(); }
1888 LOperand* InputAt(int i) final { return inputs_[i]; }
1890 int TempCount() final { return 0; }
1891 LOperand* TempAt(int i) final { return NULL; }
1895 class LInvokeFunction final : public LTemplateInstruction<1, 2, 0> {
1897 LInvokeFunction(LOperand* context, LOperand* function) {
1898 inputs_[0] = context;
1899 inputs_[1] = function;
1902 LOperand* context() { return inputs_[0]; }
1903 LOperand* function() { return inputs_[1]; }
1905 DECLARE_CONCRETE_INSTRUCTION(InvokeFunction, "invoke-function")
1906 DECLARE_HYDROGEN_ACCESSOR(InvokeFunction)
1908 void PrintDataTo(StringStream* stream) override;
1910 int arity() const { return hydrogen()->argument_count() - 1; }
1914 class LCallFunction final : public LTemplateInstruction<1, 2, 2> {
1916 LCallFunction(LOperand* context, LOperand* function, LOperand* slot,
1918 inputs_[0] = context;
1919 inputs_[1] = function;
1924 DECLARE_CONCRETE_INSTRUCTION(CallFunction, "call-function")
1925 DECLARE_HYDROGEN_ACCESSOR(CallFunction)
1927 LOperand* context() { return inputs_[0]; }
1928 LOperand* function() { return inputs_[1]; }
1929 LOperand* temp_slot() { return temps_[0]; }
1930 LOperand* temp_vector() { return temps_[1]; }
1931 int arity() const { return hydrogen()->argument_count() - 1; }
1933 void PrintDataTo(StringStream* stream) override;
1937 class LCallNew final : public LTemplateInstruction<1, 2, 0> {
1939 LCallNew(LOperand* context, LOperand* constructor) {
1940 inputs_[0] = context;
1941 inputs_[1] = constructor;
1944 LOperand* context() { return inputs_[0]; }
1945 LOperand* constructor() { return inputs_[1]; }
1947 DECLARE_CONCRETE_INSTRUCTION(CallNew, "call-new")
1948 DECLARE_HYDROGEN_ACCESSOR(CallNew)
1950 void PrintDataTo(StringStream* stream) override;
1952 int arity() const { return hydrogen()->argument_count() - 1; }
1956 class LCallNewArray final : public LTemplateInstruction<1, 2, 0> {
1958 LCallNewArray(LOperand* context, LOperand* constructor) {
1959 inputs_[0] = context;
1960 inputs_[1] = constructor;
1963 LOperand* context() { return inputs_[0]; }
1964 LOperand* constructor() { return inputs_[1]; }
1966 DECLARE_CONCRETE_INSTRUCTION(CallNewArray, "call-new-array")
1967 DECLARE_HYDROGEN_ACCESSOR(CallNewArray)
1969 void PrintDataTo(StringStream* stream) override;
1971 int arity() const { return hydrogen()->argument_count() - 1; }
1975 class LCallRuntime final : public LTemplateInstruction<1, 1, 0> {
1977 explicit LCallRuntime(LOperand* context) {
1978 inputs_[0] = context;
1981 LOperand* context() { return inputs_[0]; }
1983 DECLARE_CONCRETE_INSTRUCTION(CallRuntime, "call-runtime")
1984 DECLARE_HYDROGEN_ACCESSOR(CallRuntime)
1986 bool ClobbersDoubleRegisters(Isolate* isolate) const override {
1987 return save_doubles() == kDontSaveFPRegs;
1990 const Runtime::Function* function() const { return hydrogen()->function(); }
1991 int arity() const { return hydrogen()->argument_count(); }
1992 SaveFPRegsMode save_doubles() const { return hydrogen()->save_doubles(); }
1996 class LInteger32ToDouble final : public LTemplateInstruction<1, 1, 0> {
1998 explicit LInteger32ToDouble(LOperand* value) {
2002 LOperand* value() { return inputs_[0]; }
2004 DECLARE_CONCRETE_INSTRUCTION(Integer32ToDouble, "int32-to-double")
2008 class LUint32ToDouble final : public LTemplateInstruction<1, 1, 0> {
2010 explicit LUint32ToDouble(LOperand* value) {
2014 LOperand* value() { return inputs_[0]; }
2016 DECLARE_CONCRETE_INSTRUCTION(Uint32ToDouble, "uint32-to-double")
2020 class LNumberTagI final : public LTemplateInstruction<1, 1, 2> {
2022 LNumberTagI(LOperand* value, LOperand* temp1, LOperand* temp2) {
2028 LOperand* value() { return inputs_[0]; }
2029 LOperand* temp1() { return temps_[0]; }
2030 LOperand* temp2() { return temps_[1]; }
2032 DECLARE_CONCRETE_INSTRUCTION(NumberTagI, "number-tag-i")
2036 class LNumberTagU final : public LTemplateInstruction<1, 1, 2> {
2038 LNumberTagU(LOperand* value, LOperand* temp1, LOperand* temp2) {
2044 LOperand* value() { return inputs_[0]; }
2045 LOperand* temp1() { return temps_[0]; }
2046 LOperand* temp2() { return temps_[1]; }
2048 DECLARE_CONCRETE_INSTRUCTION(NumberTagU, "number-tag-u")
2052 class LNumberTagD final : public LTemplateInstruction<1, 1, 1> {
2054 explicit LNumberTagD(LOperand* value, LOperand* temp) {
2059 LOperand* value() { return inputs_[0]; }
2060 LOperand* temp() { return temps_[0]; }
2062 DECLARE_CONCRETE_INSTRUCTION(NumberTagD, "number-tag-d")
2063 DECLARE_HYDROGEN_ACCESSOR(Change)
2067 // Sometimes truncating conversion from a tagged value to an int32.
2068 class LDoubleToI final : public LTemplateInstruction<1, 1, 0> {
2070 explicit LDoubleToI(LOperand* value) {
2074 LOperand* value() { return inputs_[0]; }
2076 DECLARE_CONCRETE_INSTRUCTION(DoubleToI, "double-to-i")
2077 DECLARE_HYDROGEN_ACCESSOR(UnaryOperation)
2079 bool truncating() { return hydrogen()->CanTruncateToInt32(); }
2083 class LDoubleToSmi final : public LTemplateInstruction<1, 1, 0> {
2085 explicit LDoubleToSmi(LOperand* value) {
2089 LOperand* value() { return inputs_[0]; }
2091 DECLARE_CONCRETE_INSTRUCTION(DoubleToSmi, "double-to-smi")
2092 DECLARE_HYDROGEN_ACCESSOR(UnaryOperation)
2096 // Truncating conversion from a tagged value to an int32.
2097 class LTaggedToI final : public LTemplateInstruction<1, 1, 1> {
2099 LTaggedToI(LOperand* value, LOperand* temp) {
2104 LOperand* value() { return inputs_[0]; }
2105 LOperand* temp() { return temps_[0]; }
2107 DECLARE_CONCRETE_INSTRUCTION(TaggedToI, "tagged-to-i")
2108 DECLARE_HYDROGEN_ACCESSOR(Change)
2110 bool truncating() { return hydrogen()->CanTruncateToInt32(); }
2114 class LSmiTag final : public LTemplateInstruction<1, 1, 0> {
2116 explicit LSmiTag(LOperand* value) {
2120 LOperand* value() { return inputs_[0]; }
2122 DECLARE_CONCRETE_INSTRUCTION(SmiTag, "smi-tag")
2123 DECLARE_HYDROGEN_ACCESSOR(Change)
2127 class LNumberUntagD final : public LTemplateInstruction<1, 1, 0> {
2129 explicit LNumberUntagD(LOperand* value) {
2133 LOperand* value() { return inputs_[0]; }
2135 DECLARE_CONCRETE_INSTRUCTION(NumberUntagD, "double-untag")
2136 DECLARE_HYDROGEN_ACCESSOR(Change);
2140 class LSmiUntag final : public LTemplateInstruction<1, 1, 0> {
2142 LSmiUntag(LOperand* value, bool needs_check)
2143 : needs_check_(needs_check) {
2147 LOperand* value() { return inputs_[0]; }
2148 bool needs_check() const { return needs_check_; }
2150 DECLARE_CONCRETE_INSTRUCTION(SmiUntag, "smi-untag")
2157 class LStoreNamedField final : public LTemplateInstruction<0, 2, 1> {
2159 LStoreNamedField(LOperand* object, LOperand* value, LOperand* temp) {
2160 inputs_[0] = object;
2165 LOperand* object() { return inputs_[0]; }
2166 LOperand* value() { return inputs_[1]; }
2167 LOperand* temp() { return temps_[0]; }
2169 DECLARE_CONCRETE_INSTRUCTION(StoreNamedField, "store-named-field")
2170 DECLARE_HYDROGEN_ACCESSOR(StoreNamedField)
2172 void PrintDataTo(StringStream* stream) override;
2174 Representation representation() const {
2175 return hydrogen()->field_representation();
2180 class LStoreNamedGeneric final : public LTemplateInstruction<0, 3, 2> {
2182 LStoreNamedGeneric(LOperand* context, LOperand* object, LOperand* value,
2183 LOperand* slot, LOperand* vector) {
2184 inputs_[0] = context;
2185 inputs_[1] = object;
2191 LOperand* context() { return inputs_[0]; }
2192 LOperand* object() { return inputs_[1]; }
2193 LOperand* value() { return inputs_[2]; }
2194 LOperand* temp_slot() { return temps_[0]; }
2195 LOperand* temp_vector() { return temps_[1]; }
2197 DECLARE_CONCRETE_INSTRUCTION(StoreNamedGeneric, "store-named-generic")
2198 DECLARE_HYDROGEN_ACCESSOR(StoreNamedGeneric)
2200 void PrintDataTo(StringStream* stream) override;
2202 Handle<Object> name() const { return hydrogen()->name(); }
2203 LanguageMode language_mode() { return hydrogen()->language_mode(); }
2207 class LStoreGlobalViaContext final : public LTemplateInstruction<0, 2, 0> {
2209 LStoreGlobalViaContext(LOperand* context, LOperand* value) {
2210 inputs_[0] = context;
2214 LOperand* context() { return inputs_[0]; }
2215 LOperand* value() { return inputs_[1]; }
2217 DECLARE_CONCRETE_INSTRUCTION(StoreGlobalViaContext,
2218 "store-global-via-context")
2219 DECLARE_HYDROGEN_ACCESSOR(StoreGlobalViaContext)
2221 void PrintDataTo(StringStream* stream) override;
2223 Handle<Object> name() const { return hydrogen()->name(); }
2224 int depth() { return hydrogen()->depth(); }
2225 int slot_index() { return hydrogen()->slot_index(); }
2226 LanguageMode language_mode() { return hydrogen()->language_mode(); }
2230 class LStoreKeyed final : public LTemplateInstruction<0, 3, 0> {
2232 LStoreKeyed(LOperand* object, LOperand* key, LOperand* value) {
2233 inputs_[0] = object;
2238 bool is_external() const { return hydrogen()->is_external(); }
2239 bool is_fixed_typed_array() const {
2240 return hydrogen()->is_fixed_typed_array();
2242 bool is_typed_elements() const {
2243 return is_external() || is_fixed_typed_array();
2245 LOperand* elements() { return inputs_[0]; }
2246 LOperand* key() { return inputs_[1]; }
2247 LOperand* value() { return inputs_[2]; }
2248 ElementsKind elements_kind() const { return hydrogen()->elements_kind(); }
2250 DECLARE_CONCRETE_INSTRUCTION(StoreKeyed, "store-keyed")
2251 DECLARE_HYDROGEN_ACCESSOR(StoreKeyed)
2253 void PrintDataTo(StringStream* stream) override;
2254 bool NeedsCanonicalization() { return hydrogen()->NeedsCanonicalization(); }
2255 uint32_t base_offset() const { return hydrogen()->base_offset(); }
2259 class LStoreKeyedGeneric final : public LTemplateInstruction<0, 4, 2> {
2261 LStoreKeyedGeneric(LOperand* context, LOperand* object, LOperand* key,
2262 LOperand* value, LOperand* slot, LOperand* vector) {
2263 inputs_[0] = context;
2264 inputs_[1] = object;
2271 LOperand* context() { return inputs_[0]; }
2272 LOperand* object() { return inputs_[1]; }
2273 LOperand* key() { return inputs_[2]; }
2274 LOperand* value() { return inputs_[3]; }
2275 LOperand* temp_slot() { return temps_[0]; }
2276 LOperand* temp_vector() { return temps_[1]; }
2278 DECLARE_CONCRETE_INSTRUCTION(StoreKeyedGeneric, "store-keyed-generic")
2279 DECLARE_HYDROGEN_ACCESSOR(StoreKeyedGeneric)
2281 void PrintDataTo(StringStream* stream) override;
2283 LanguageMode language_mode() { return hydrogen()->language_mode(); }
2287 class LTransitionElementsKind final : public LTemplateInstruction<0, 2, 2> {
2289 LTransitionElementsKind(LOperand* object,
2291 LOperand* new_map_temp,
2293 inputs_[0] = object;
2294 inputs_[1] = context;
2295 temps_[0] = new_map_temp;
2299 LOperand* object() { return inputs_[0]; }
2300 LOperand* context() { return inputs_[1]; }
2301 LOperand* new_map_temp() { return temps_[0]; }
2302 LOperand* temp() { return temps_[1]; }
2304 DECLARE_CONCRETE_INSTRUCTION(TransitionElementsKind,
2305 "transition-elements-kind")
2306 DECLARE_HYDROGEN_ACCESSOR(TransitionElementsKind)
2308 void PrintDataTo(StringStream* stream) override;
2310 Handle<Map> original_map() { return hydrogen()->original_map().handle(); }
2311 Handle<Map> transitioned_map() {
2312 return hydrogen()->transitioned_map().handle();
2314 ElementsKind from_kind() { return hydrogen()->from_kind(); }
2315 ElementsKind to_kind() { return hydrogen()->to_kind(); }
2319 class LTrapAllocationMemento final : public LTemplateInstruction<0, 1, 1> {
2321 LTrapAllocationMemento(LOperand* object,
2323 inputs_[0] = object;
2327 LOperand* object() { return inputs_[0]; }
2328 LOperand* temp() { return temps_[0]; }
2330 DECLARE_CONCRETE_INSTRUCTION(TrapAllocationMemento,
2331 "trap-allocation-memento")
2335 class LMaybeGrowElements final : public LTemplateInstruction<1, 5, 0> {
2337 LMaybeGrowElements(LOperand* context, LOperand* object, LOperand* elements,
2338 LOperand* key, LOperand* current_capacity) {
2339 inputs_[0] = context;
2340 inputs_[1] = object;
2341 inputs_[2] = elements;
2343 inputs_[4] = current_capacity;
2346 LOperand* context() { return inputs_[0]; }
2347 LOperand* object() { return inputs_[1]; }
2348 LOperand* elements() { return inputs_[2]; }
2349 LOperand* key() { return inputs_[3]; }
2350 LOperand* current_capacity() { return inputs_[4]; }
2352 DECLARE_HYDROGEN_ACCESSOR(MaybeGrowElements)
2353 DECLARE_CONCRETE_INSTRUCTION(MaybeGrowElements, "maybe-grow-elements")
2357 class LStringAdd final : public LTemplateInstruction<1, 3, 0> {
2359 LStringAdd(LOperand* context, LOperand* left, LOperand* right) {
2360 inputs_[0] = context;
2365 LOperand* context() { return inputs_[0]; }
2366 LOperand* left() { return inputs_[1]; }
2367 LOperand* right() { return inputs_[2]; }
2369 DECLARE_CONCRETE_INSTRUCTION(StringAdd, "string-add")
2370 DECLARE_HYDROGEN_ACCESSOR(StringAdd)
2374 class LStringCharCodeAt final : public LTemplateInstruction<1, 3, 0> {
2376 LStringCharCodeAt(LOperand* context, LOperand* string, LOperand* index) {
2377 inputs_[0] = context;
2378 inputs_[1] = string;
2382 LOperand* context() { return inputs_[0]; }
2383 LOperand* string() { return inputs_[1]; }
2384 LOperand* index() { return inputs_[2]; }
2386 DECLARE_CONCRETE_INSTRUCTION(StringCharCodeAt, "string-char-code-at")
2387 DECLARE_HYDROGEN_ACCESSOR(StringCharCodeAt)
2391 class LStringCharFromCode final : public LTemplateInstruction<1, 2, 0> {
2393 explicit LStringCharFromCode(LOperand* context, LOperand* char_code) {
2394 inputs_[0] = context;
2395 inputs_[1] = char_code;
2398 LOperand* context() { return inputs_[0]; }
2399 LOperand* char_code() { return inputs_[1]; }
2401 DECLARE_CONCRETE_INSTRUCTION(StringCharFromCode, "string-char-from-code")
2402 DECLARE_HYDROGEN_ACCESSOR(StringCharFromCode)
2406 class LCheckValue final : public LTemplateInstruction<0, 1, 0> {
2408 explicit LCheckValue(LOperand* value) {
2412 LOperand* value() { return inputs_[0]; }
2414 DECLARE_CONCRETE_INSTRUCTION(CheckValue, "check-value")
2415 DECLARE_HYDROGEN_ACCESSOR(CheckValue)
2419 class LCheckArrayBufferNotNeutered final
2420 : public LTemplateInstruction<0, 1, 0> {
2422 explicit LCheckArrayBufferNotNeutered(LOperand* view) { inputs_[0] = view; }
2424 LOperand* view() { return inputs_[0]; }
2426 DECLARE_CONCRETE_INSTRUCTION(CheckArrayBufferNotNeutered,
2427 "check-array-buffer-not-neutered")
2428 DECLARE_HYDROGEN_ACCESSOR(CheckArrayBufferNotNeutered)
2432 class LCheckInstanceType final : public LTemplateInstruction<0, 1, 0> {
2434 explicit LCheckInstanceType(LOperand* value) {
2438 LOperand* value() { return inputs_[0]; }
2440 DECLARE_CONCRETE_INSTRUCTION(CheckInstanceType, "check-instance-type")
2441 DECLARE_HYDROGEN_ACCESSOR(CheckInstanceType)
2445 class LCheckMaps final : public LTemplateInstruction<0, 1, 0> {
2447 explicit LCheckMaps(LOperand* value = NULL) {
2451 LOperand* value() { return inputs_[0]; }
2453 DECLARE_CONCRETE_INSTRUCTION(CheckMaps, "check-maps")
2454 DECLARE_HYDROGEN_ACCESSOR(CheckMaps)
2458 class LCheckSmi final : public LTemplateInstruction<1, 1, 0> {
2460 explicit LCheckSmi(LOperand* value) {
2464 LOperand* value() { return inputs_[0]; }
2466 DECLARE_CONCRETE_INSTRUCTION(CheckSmi, "check-smi")
2470 class LClampDToUint8 final : public LTemplateInstruction<1, 1, 0> {
2472 explicit LClampDToUint8(LOperand* unclamped) {
2473 inputs_[0] = unclamped;
2476 LOperand* unclamped() { return inputs_[0]; }
2478 DECLARE_CONCRETE_INSTRUCTION(ClampDToUint8, "clamp-d-to-uint8")
2482 class LClampIToUint8 final : public LTemplateInstruction<1, 1, 0> {
2484 explicit LClampIToUint8(LOperand* unclamped) {
2485 inputs_[0] = unclamped;
2488 LOperand* unclamped() { return inputs_[0]; }
2490 DECLARE_CONCRETE_INSTRUCTION(ClampIToUint8, "clamp-i-to-uint8")
2494 class LClampTToUint8 final : public LTemplateInstruction<1, 1, 1> {
2496 LClampTToUint8(LOperand* unclamped,
2497 LOperand* temp_xmm) {
2498 inputs_[0] = unclamped;
2499 temps_[0] = temp_xmm;
2502 LOperand* unclamped() { return inputs_[0]; }
2503 LOperand* temp_xmm() { return temps_[0]; }
2505 DECLARE_CONCRETE_INSTRUCTION(ClampTToUint8, "clamp-t-to-uint8")
2509 class LCheckNonSmi final : public LTemplateInstruction<0, 1, 0> {
2511 explicit LCheckNonSmi(LOperand* value) {
2515 LOperand* value() { return inputs_[0]; }
2517 DECLARE_CONCRETE_INSTRUCTION(CheckNonSmi, "check-non-smi")
2518 DECLARE_HYDROGEN_ACCESSOR(CheckHeapObject)
2522 class LDoubleBits final : public LTemplateInstruction<1, 1, 0> {
2524 explicit LDoubleBits(LOperand* value) {
2528 LOperand* value() { return inputs_[0]; }
2530 DECLARE_CONCRETE_INSTRUCTION(DoubleBits, "double-bits")
2531 DECLARE_HYDROGEN_ACCESSOR(DoubleBits)
2535 class LConstructDouble final : public LTemplateInstruction<1, 2, 0> {
2537 LConstructDouble(LOperand* hi, LOperand* lo) {
2542 LOperand* hi() { return inputs_[0]; }
2543 LOperand* lo() { return inputs_[1]; }
2545 DECLARE_CONCRETE_INSTRUCTION(ConstructDouble, "construct-double")
2549 class LAllocate final : public LTemplateInstruction<1, 2, 1> {
2551 LAllocate(LOperand* context, LOperand* size, LOperand* temp) {
2552 inputs_[0] = context;
2557 LOperand* context() { return inputs_[0]; }
2558 LOperand* size() { return inputs_[1]; }
2559 LOperand* temp() { return temps_[0]; }
2561 DECLARE_CONCRETE_INSTRUCTION(Allocate, "allocate")
2562 DECLARE_HYDROGEN_ACCESSOR(Allocate)
2566 class LRegExpLiteral final : public LTemplateInstruction<1, 1, 0> {
2568 explicit LRegExpLiteral(LOperand* context) {
2569 inputs_[0] = context;
2572 LOperand* context() { return inputs_[0]; }
2574 DECLARE_CONCRETE_INSTRUCTION(RegExpLiteral, "regexp-literal")
2575 DECLARE_HYDROGEN_ACCESSOR(RegExpLiteral)
2579 class LFunctionLiteral final : public LTemplateInstruction<1, 1, 0> {
2581 explicit LFunctionLiteral(LOperand* context) {
2582 inputs_[0] = context;
2585 LOperand* context() { return inputs_[0]; }
2587 DECLARE_CONCRETE_INSTRUCTION(FunctionLiteral, "function-literal")
2588 DECLARE_HYDROGEN_ACCESSOR(FunctionLiteral)
2592 class LToFastProperties final : public LTemplateInstruction<1, 1, 0> {
2594 explicit LToFastProperties(LOperand* value) {
2598 LOperand* value() { return inputs_[0]; }
2600 DECLARE_CONCRETE_INSTRUCTION(ToFastProperties, "to-fast-properties")
2601 DECLARE_HYDROGEN_ACCESSOR(ToFastProperties)
2605 class LTypeof final : public LTemplateInstruction<1, 2, 0> {
2607 LTypeof(LOperand* context, LOperand* value) {
2608 inputs_[0] = context;
2612 LOperand* context() { return inputs_[0]; }
2613 LOperand* value() { return inputs_[1]; }
2615 DECLARE_CONCRETE_INSTRUCTION(Typeof, "typeof")
2619 class LTypeofIsAndBranch final : public LControlInstruction<1, 0> {
2621 explicit LTypeofIsAndBranch(LOperand* value) {
2625 LOperand* value() { return inputs_[0]; }
2627 DECLARE_CONCRETE_INSTRUCTION(TypeofIsAndBranch, "typeof-is-and-branch")
2628 DECLARE_HYDROGEN_ACCESSOR(TypeofIsAndBranch)
2630 Handle<String> type_literal() { return hydrogen()->type_literal(); }
2632 void PrintDataTo(StringStream* stream) override;
2636 class LIsConstructCallAndBranch final : public LControlInstruction<0, 1> {
2638 explicit LIsConstructCallAndBranch(LOperand* temp) {
2642 LOperand* temp() { return temps_[0]; }
2644 DECLARE_CONCRETE_INSTRUCTION(IsConstructCallAndBranch,
2645 "is-construct-call-and-branch")
2646 DECLARE_HYDROGEN_ACCESSOR(IsConstructCallAndBranch)
2650 class LOsrEntry final : public LTemplateInstruction<0, 0, 0> {
2654 bool HasInterestingComment(LCodeGen* gen) const override { return false; }
2655 DECLARE_CONCRETE_INSTRUCTION(OsrEntry, "osr-entry")
2659 class LStackCheck final : public LTemplateInstruction<0, 1, 0> {
2661 explicit LStackCheck(LOperand* context) {
2662 inputs_[0] = context;
2665 LOperand* context() { return inputs_[0]; }
2667 DECLARE_CONCRETE_INSTRUCTION(StackCheck, "stack-check")
2668 DECLARE_HYDROGEN_ACCESSOR(StackCheck)
2670 Label* done_label() { return &done_label_; }
2677 class LForInPrepareMap final : public LTemplateInstruction<1, 2, 0> {
2679 LForInPrepareMap(LOperand* context, LOperand* object) {
2680 inputs_[0] = context;
2681 inputs_[1] = object;
2684 LOperand* context() { return inputs_[0]; }
2685 LOperand* object() { return inputs_[1]; }
2687 DECLARE_CONCRETE_INSTRUCTION(ForInPrepareMap, "for-in-prepare-map")
2691 class LForInCacheArray final : public LTemplateInstruction<1, 1, 0> {
2693 explicit LForInCacheArray(LOperand* map) {
2697 LOperand* map() { return inputs_[0]; }
2699 DECLARE_CONCRETE_INSTRUCTION(ForInCacheArray, "for-in-cache-array")
2702 return HForInCacheArray::cast(this->hydrogen_value())->idx();
2707 class LCheckMapValue final : public LTemplateInstruction<0, 2, 0> {
2709 LCheckMapValue(LOperand* value, LOperand* map) {
2714 LOperand* value() { return inputs_[0]; }
2715 LOperand* map() { return inputs_[1]; }
2717 DECLARE_CONCRETE_INSTRUCTION(CheckMapValue, "check-map-value")
2721 class LLoadFieldByIndex final : public LTemplateInstruction<1, 2, 0> {
2723 LLoadFieldByIndex(LOperand* object, LOperand* index) {
2724 inputs_[0] = object;
2728 LOperand* object() { return inputs_[0]; }
2729 LOperand* index() { return inputs_[1]; }
2731 DECLARE_CONCRETE_INSTRUCTION(LoadFieldByIndex, "load-field-by-index")
2735 class LStoreFrameContext: public LTemplateInstruction<0, 1, 0> {
2737 explicit LStoreFrameContext(LOperand* context) {
2738 inputs_[0] = context;
2741 LOperand* context() { return inputs_[0]; }
2743 DECLARE_CONCRETE_INSTRUCTION(StoreFrameContext, "store-frame-context")
2747 class LAllocateBlockContext: public LTemplateInstruction<1, 2, 0> {
2749 LAllocateBlockContext(LOperand* context, LOperand* function) {
2750 inputs_[0] = context;
2751 inputs_[1] = function;
2754 LOperand* context() { return inputs_[0]; }
2755 LOperand* function() { return inputs_[1]; }
2757 Handle<ScopeInfo> scope_info() { return hydrogen()->scope_info(); }
2759 DECLARE_CONCRETE_INSTRUCTION(AllocateBlockContext, "allocate-block-context")
2760 DECLARE_HYDROGEN_ACCESSOR(AllocateBlockContext)
2764 class LChunkBuilder;
2765 class LPlatformChunk final : public LChunk {
2767 LPlatformChunk(CompilationInfo* info, HGraph* graph)
2768 : LChunk(info, graph),
2769 dehoisted_key_ids_(graph->GetMaximumValueID(), graph->zone()) { }
2771 int GetNextSpillIndex(RegisterKind kind);
2772 LOperand* GetNextSpillSlot(RegisterKind kind);
2773 BitVector* GetDehoistedKeyIds() { return &dehoisted_key_ids_; }
2774 bool IsDehoistedKey(HValue* value) {
2775 return dehoisted_key_ids_.Contains(value->id());
2779 BitVector dehoisted_key_ids_;
2783 class LChunkBuilder final : public LChunkBuilderBase {
2785 LChunkBuilder(CompilationInfo* info, HGraph* graph, LAllocator* allocator)
2786 : LChunkBuilderBase(info, graph),
2787 current_instruction_(NULL),
2788 current_block_(NULL),
2790 allocator_(allocator) {}
2792 // Build the sequence for the graph.
2793 LPlatformChunk* Build();
2795 // Declare methods that deal with the individual node types.
2796 #define DECLARE_DO(type) LInstruction* Do##type(H##type* node);
2797 HYDROGEN_CONCRETE_INSTRUCTION_LIST(DECLARE_DO)
2800 LInstruction* DoMathFloor(HUnaryMathOperation* instr);
2801 LInstruction* DoMathRound(HUnaryMathOperation* instr);
2802 LInstruction* DoMathFround(HUnaryMathOperation* instr);
2803 LInstruction* DoMathAbs(HUnaryMathOperation* instr);
2804 LInstruction* DoMathLog(HUnaryMathOperation* instr);
2805 LInstruction* DoMathExp(HUnaryMathOperation* instr);
2806 LInstruction* DoMathSqrt(HUnaryMathOperation* instr);
2807 LInstruction* DoMathPowHalf(HUnaryMathOperation* instr);
2808 LInstruction* DoMathClz32(HUnaryMathOperation* instr);
2809 LInstruction* DoDivByPowerOf2I(HDiv* instr);
2810 LInstruction* DoDivByConstI(HDiv* instr);
2811 LInstruction* DoDivI(HDiv* instr);
2812 LInstruction* DoModByPowerOf2I(HMod* instr);
2813 LInstruction* DoModByConstI(HMod* instr);
2814 LInstruction* DoModI(HMod* instr);
2815 LInstruction* DoFlooringDivByPowerOf2I(HMathFloorOfDiv* instr);
2816 LInstruction* DoFlooringDivByConstI(HMathFloorOfDiv* instr);
2817 LInstruction* DoFlooringDivI(HMathFloorOfDiv* instr);
2820 // Methods for getting operands for Use / Define / Temp.
2821 LUnallocated* ToUnallocated(Register reg);
2822 LUnallocated* ToUnallocated(XMMRegister reg);
2824 // Methods for setting up define-use relationships.
2825 MUST_USE_RESULT LOperand* Use(HValue* value, LUnallocated* operand);
2826 MUST_USE_RESULT LOperand* UseFixed(HValue* value, Register fixed_register);
2827 MUST_USE_RESULT LOperand* UseFixedDouble(HValue* value,
2828 XMMRegister fixed_register);
2830 // A value that is guaranteed to be allocated to a register.
2831 // Operand created by UseRegister is guaranteed to be live until the end of
2832 // instruction. This means that register allocator will not reuse it's
2833 // register for any other operand inside instruction.
2834 // Operand created by UseRegisterAtStart is guaranteed to be live only at
2835 // instruction start. Register allocator is free to assign the same register
2836 // to some other operand used inside instruction (i.e. temporary or
2838 MUST_USE_RESULT LOperand* UseRegister(HValue* value);
2839 MUST_USE_RESULT LOperand* UseRegisterAtStart(HValue* value);
2841 // An input operand in a register that may be trashed.
2842 MUST_USE_RESULT LOperand* UseTempRegister(HValue* value);
2844 // An input operand in a register that may be trashed or a constant operand.
2845 MUST_USE_RESULT LOperand* UseTempRegisterOrConstant(HValue* value);
2847 // An input operand in a register or stack slot.
2848 MUST_USE_RESULT LOperand* Use(HValue* value);
2849 MUST_USE_RESULT LOperand* UseAtStart(HValue* value);
2851 // An input operand in a register, stack slot or a constant operand.
2852 MUST_USE_RESULT LOperand* UseOrConstant(HValue* value);
2853 MUST_USE_RESULT LOperand* UseOrConstantAtStart(HValue* value);
2855 // An input operand in a register or a constant operand.
2856 MUST_USE_RESULT LOperand* UseRegisterOrConstant(HValue* value);
2857 MUST_USE_RESULT LOperand* UseRegisterOrConstantAtStart(HValue* value);
2859 // An input operand in a constant operand.
2860 MUST_USE_RESULT LOperand* UseConstant(HValue* value);
2862 // An input operand in register, stack slot or a constant operand.
2863 // Will not be moved to a register even if one is freely available.
2864 MUST_USE_RESULT LOperand* UseAny(HValue* value) override;
2866 // Temporary operand that must be in a register.
2867 MUST_USE_RESULT LUnallocated* TempRegister();
2868 MUST_USE_RESULT LOperand* FixedTemp(Register reg);
2869 MUST_USE_RESULT LOperand* FixedTemp(XMMRegister reg);
2871 // Methods for setting up define-use relationships.
2872 // Return the same instruction that they are passed.
2873 LInstruction* Define(LTemplateResultInstruction<1>* instr,
2874 LUnallocated* result);
2875 LInstruction* DefineAsRegister(LTemplateResultInstruction<1>* instr);
2876 LInstruction* DefineAsSpilled(LTemplateResultInstruction<1>* instr,
2878 LInstruction* DefineSameAsFirst(LTemplateResultInstruction<1>* instr);
2879 LInstruction* DefineFixed(LTemplateResultInstruction<1>* instr,
2881 LInstruction* DefineFixedDouble(LTemplateResultInstruction<1>* instr,
2883 // Assigns an environment to an instruction. An instruction which can
2884 // deoptimize must have an environment.
2885 LInstruction* AssignEnvironment(LInstruction* instr);
2886 // Assigns a pointer map to an instruction. An instruction which can
2887 // trigger a GC or a lazy deoptimization must have a pointer map.
2888 LInstruction* AssignPointerMap(LInstruction* instr);
2890 enum CanDeoptimize { CAN_DEOPTIMIZE_EAGERLY, CANNOT_DEOPTIMIZE_EAGERLY };
2892 // Marks a call for the register allocator. Assigns a pointer map to
2893 // support GC and lazy deoptimization. Assigns an environment to support
2894 // eager deoptimization if CAN_DEOPTIMIZE_EAGERLY.
2895 LInstruction* MarkAsCall(
2896 LInstruction* instr,
2897 HInstruction* hinstr,
2898 CanDeoptimize can_deoptimize = CANNOT_DEOPTIMIZE_EAGERLY);
2900 void VisitInstruction(HInstruction* current);
2901 void AddInstruction(LInstruction* instr, HInstruction* current);
2903 void DoBasicBlock(HBasicBlock* block, HBasicBlock* next_block);
2904 LInstruction* DoShift(Token::Value op, HBitwiseBinaryOperation* instr);
2905 LInstruction* DoArithmeticD(Token::Value op,
2906 HArithmeticBinaryOperation* instr);
2907 LInstruction* DoArithmeticT(Token::Value op,
2908 HBinaryOperation* instr);
2909 void FindDehoistedKeyDefinitions(HValue* candidate);
2911 HInstruction* current_instruction_;
2912 HBasicBlock* current_block_;
2913 HBasicBlock* next_block_;
2914 LAllocator* allocator_;
2916 DISALLOW_COPY_AND_ASSIGN(LChunkBuilder);
2919 #undef DECLARE_HYDROGEN_ACCESSOR
2920 #undef DECLARE_CONCRETE_INSTRUCTION
2922 } } // namespace v8::int
2924 #endif // V8_X64_LITHIUM_X64_H_