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 == UINT8_ELEMENTS || elements_kind == INT8_ELEMENTS ||
1621 elements_kind == UINT8_CLAMPED_ELEMENTS);
1625 class LLoadKeyed final : public LTemplateInstruction<1, 2, 0> {
1627 LLoadKeyed(LOperand* elements, LOperand* key) {
1628 inputs_[0] = elements;
1632 DECLARE_CONCRETE_INSTRUCTION(LoadKeyed, "load-keyed")
1633 DECLARE_HYDROGEN_ACCESSOR(LoadKeyed)
1635 bool is_fixed_typed_array() const {
1636 return hydrogen()->is_fixed_typed_array();
1638 LOperand* elements() { return inputs_[0]; }
1639 LOperand* key() { return inputs_[1]; }
1640 void PrintDataTo(StringStream* stream) override;
1641 uint32_t base_offset() const { return hydrogen()->base_offset(); }
1642 ElementsKind elements_kind() const {
1643 return hydrogen()->elements_kind();
1648 class LLoadKeyedGeneric final : public LTemplateInstruction<1, 3, 1> {
1650 LLoadKeyedGeneric(LOperand* context, LOperand* obj, LOperand* key,
1652 inputs_[0] = context;
1658 DECLARE_CONCRETE_INSTRUCTION(LoadKeyedGeneric, "load-keyed-generic")
1659 DECLARE_HYDROGEN_ACCESSOR(LoadKeyedGeneric)
1661 LOperand* context() { return inputs_[0]; }
1662 LOperand* object() { return inputs_[1]; }
1663 LOperand* key() { return inputs_[2]; }
1664 LOperand* temp_vector() { return temps_[0]; }
1668 class LLoadGlobalGeneric final : public LTemplateInstruction<1, 2, 1> {
1670 explicit LLoadGlobalGeneric(LOperand* context, LOperand* global_object,
1672 inputs_[0] = context;
1673 inputs_[1] = global_object;
1677 DECLARE_CONCRETE_INSTRUCTION(LoadGlobalGeneric, "load-global-generic")
1678 DECLARE_HYDROGEN_ACCESSOR(LoadGlobalGeneric)
1680 LOperand* context() { return inputs_[0]; }
1681 LOperand* global_object() { return inputs_[1]; }
1682 LOperand* temp_vector() { return temps_[0]; }
1684 Handle<Object> name() const { return hydrogen()->name(); }
1685 TypeofMode typeof_mode() const { return hydrogen()->typeof_mode(); }
1689 class LLoadGlobalViaContext final : public LTemplateInstruction<1, 1, 1> {
1691 explicit LLoadGlobalViaContext(LOperand* context) { inputs_[0] = context; }
1693 DECLARE_CONCRETE_INSTRUCTION(LoadGlobalViaContext, "load-global-via-context")
1694 DECLARE_HYDROGEN_ACCESSOR(LoadGlobalViaContext)
1696 void PrintDataTo(StringStream* stream) override;
1698 LOperand* context() { return inputs_[0]; }
1700 Handle<Object> name() const { return hydrogen()->name(); }
1701 int depth() const { return hydrogen()->depth(); }
1702 int slot_index() const { return hydrogen()->slot_index(); }
1706 class LLoadContextSlot final : public LTemplateInstruction<1, 1, 0> {
1708 explicit LLoadContextSlot(LOperand* context) {
1709 inputs_[0] = context;
1712 LOperand* context() { return inputs_[0]; }
1714 DECLARE_CONCRETE_INSTRUCTION(LoadContextSlot, "load-context-slot")
1715 DECLARE_HYDROGEN_ACCESSOR(LoadContextSlot)
1717 int slot_index() { return hydrogen()->slot_index(); }
1719 void PrintDataTo(StringStream* stream) override;
1723 class LStoreContextSlot final : public LTemplateInstruction<0, 2, 1> {
1725 LStoreContextSlot(LOperand* context, LOperand* value, LOperand* temp) {
1726 inputs_[0] = context;
1731 LOperand* context() { return inputs_[0]; }
1732 LOperand* value() { return inputs_[1]; }
1733 LOperand* temp() { return temps_[0]; }
1735 DECLARE_CONCRETE_INSTRUCTION(StoreContextSlot, "store-context-slot")
1736 DECLARE_HYDROGEN_ACCESSOR(StoreContextSlot)
1738 int slot_index() { return hydrogen()->slot_index(); }
1740 void PrintDataTo(StringStream* stream) override;
1744 class LPushArgument final : public LTemplateInstruction<0, 1, 0> {
1746 explicit LPushArgument(LOperand* value) {
1750 LOperand* value() { return inputs_[0]; }
1752 DECLARE_CONCRETE_INSTRUCTION(PushArgument, "push-argument")
1756 class LDrop final : public LTemplateInstruction<0, 0, 0> {
1758 explicit LDrop(int count) : count_(count) { }
1760 int count() const { return count_; }
1762 DECLARE_CONCRETE_INSTRUCTION(Drop, "drop")
1769 class LStoreCodeEntry final : public LTemplateInstruction<0, 2, 0> {
1771 LStoreCodeEntry(LOperand* function, LOperand* code_object) {
1772 inputs_[0] = function;
1773 inputs_[1] = code_object;
1776 LOperand* function() { return inputs_[0]; }
1777 LOperand* code_object() { return inputs_[1]; }
1779 void PrintDataTo(StringStream* stream) override;
1781 DECLARE_CONCRETE_INSTRUCTION(StoreCodeEntry, "store-code-entry")
1782 DECLARE_HYDROGEN_ACCESSOR(StoreCodeEntry)
1786 class LInnerAllocatedObject final : public LTemplateInstruction<1, 2, 0> {
1788 LInnerAllocatedObject(LOperand* base_object, LOperand* offset) {
1789 inputs_[0] = base_object;
1790 inputs_[1] = offset;
1793 LOperand* base_object() const { return inputs_[0]; }
1794 LOperand* offset() const { return inputs_[1]; }
1796 void PrintDataTo(StringStream* stream) override;
1798 DECLARE_CONCRETE_INSTRUCTION(InnerAllocatedObject, "inner-allocated-object")
1802 class LThisFunction final : public LTemplateInstruction<1, 0, 0> {
1804 DECLARE_CONCRETE_INSTRUCTION(ThisFunction, "this-function")
1805 DECLARE_HYDROGEN_ACCESSOR(ThisFunction)
1809 class LContext final : public LTemplateInstruction<1, 0, 0> {
1811 DECLARE_CONCRETE_INSTRUCTION(Context, "context")
1812 DECLARE_HYDROGEN_ACCESSOR(Context)
1816 class LDeclareGlobals final : public LTemplateInstruction<0, 1, 0> {
1818 explicit LDeclareGlobals(LOperand* context) {
1819 inputs_[0] = context;
1822 LOperand* context() { return inputs_[0]; }
1824 DECLARE_CONCRETE_INSTRUCTION(DeclareGlobals, "declare-globals")
1825 DECLARE_HYDROGEN_ACCESSOR(DeclareGlobals)
1829 class LCallJSFunction final : public LTemplateInstruction<1, 1, 0> {
1831 explicit LCallJSFunction(LOperand* function) {
1832 inputs_[0] = function;
1835 LOperand* function() { return inputs_[0]; }
1837 DECLARE_CONCRETE_INSTRUCTION(CallJSFunction, "call-js-function")
1838 DECLARE_HYDROGEN_ACCESSOR(CallJSFunction)
1840 void PrintDataTo(StringStream* stream) override;
1842 int arity() const { return hydrogen()->argument_count() - 1; }
1846 class LCallWithDescriptor final : public LTemplateResultInstruction<1> {
1848 LCallWithDescriptor(CallInterfaceDescriptor descriptor,
1849 const ZoneList<LOperand*>& operands, Zone* zone)
1850 : inputs_(descriptor.GetRegisterParameterCount() +
1851 kImplicitRegisterParameterCount,
1853 DCHECK(descriptor.GetRegisterParameterCount() +
1854 kImplicitRegisterParameterCount ==
1856 inputs_.AddAll(operands, zone);
1859 LOperand* target() const { return inputs_[0]; }
1861 DECLARE_HYDROGEN_ACCESSOR(CallWithDescriptor)
1863 // The target and context are passed as implicit parameters that are not
1864 // explicitly listed in the descriptor.
1865 static const int kImplicitRegisterParameterCount = 2;
1868 DECLARE_CONCRETE_INSTRUCTION(CallWithDescriptor, "call-with-descriptor")
1870 void PrintDataTo(StringStream* stream) override;
1872 int arity() const { return hydrogen()->argument_count() - 1; }
1874 ZoneList<LOperand*> inputs_;
1876 // Iterator support.
1877 int InputCount() final { return inputs_.length(); }
1878 LOperand* InputAt(int i) final { return inputs_[i]; }
1880 int TempCount() final { return 0; }
1881 LOperand* TempAt(int i) final { return NULL; }
1885 class LInvokeFunction final : public LTemplateInstruction<1, 2, 0> {
1887 LInvokeFunction(LOperand* context, LOperand* function) {
1888 inputs_[0] = context;
1889 inputs_[1] = function;
1892 LOperand* context() { return inputs_[0]; }
1893 LOperand* function() { return inputs_[1]; }
1895 DECLARE_CONCRETE_INSTRUCTION(InvokeFunction, "invoke-function")
1896 DECLARE_HYDROGEN_ACCESSOR(InvokeFunction)
1898 void PrintDataTo(StringStream* stream) override;
1900 int arity() const { return hydrogen()->argument_count() - 1; }
1904 class LCallFunction final : public LTemplateInstruction<1, 2, 2> {
1906 LCallFunction(LOperand* context, LOperand* function, LOperand* slot,
1908 inputs_[0] = context;
1909 inputs_[1] = function;
1914 DECLARE_CONCRETE_INSTRUCTION(CallFunction, "call-function")
1915 DECLARE_HYDROGEN_ACCESSOR(CallFunction)
1917 LOperand* context() { return inputs_[0]; }
1918 LOperand* function() { return inputs_[1]; }
1919 LOperand* temp_slot() { return temps_[0]; }
1920 LOperand* temp_vector() { return temps_[1]; }
1921 int arity() const { return hydrogen()->argument_count() - 1; }
1923 void PrintDataTo(StringStream* stream) override;
1927 class LCallNew final : public LTemplateInstruction<1, 2, 0> {
1929 LCallNew(LOperand* context, LOperand* constructor) {
1930 inputs_[0] = context;
1931 inputs_[1] = constructor;
1934 LOperand* context() { return inputs_[0]; }
1935 LOperand* constructor() { return inputs_[1]; }
1937 DECLARE_CONCRETE_INSTRUCTION(CallNew, "call-new")
1938 DECLARE_HYDROGEN_ACCESSOR(CallNew)
1940 void PrintDataTo(StringStream* stream) override;
1942 int arity() const { return hydrogen()->argument_count() - 1; }
1946 class LCallNewArray final : public LTemplateInstruction<1, 2, 0> {
1948 LCallNewArray(LOperand* context, LOperand* constructor) {
1949 inputs_[0] = context;
1950 inputs_[1] = constructor;
1953 LOperand* context() { return inputs_[0]; }
1954 LOperand* constructor() { return inputs_[1]; }
1956 DECLARE_CONCRETE_INSTRUCTION(CallNewArray, "call-new-array")
1957 DECLARE_HYDROGEN_ACCESSOR(CallNewArray)
1959 void PrintDataTo(StringStream* stream) override;
1961 int arity() const { return hydrogen()->argument_count() - 1; }
1965 class LCallRuntime final : public LTemplateInstruction<1, 1, 0> {
1967 explicit LCallRuntime(LOperand* context) {
1968 inputs_[0] = context;
1971 LOperand* context() { return inputs_[0]; }
1973 DECLARE_CONCRETE_INSTRUCTION(CallRuntime, "call-runtime")
1974 DECLARE_HYDROGEN_ACCESSOR(CallRuntime)
1976 bool ClobbersDoubleRegisters(Isolate* isolate) const override {
1977 return save_doubles() == kDontSaveFPRegs;
1980 const Runtime::Function* function() const { return hydrogen()->function(); }
1981 int arity() const { return hydrogen()->argument_count(); }
1982 SaveFPRegsMode save_doubles() const { return hydrogen()->save_doubles(); }
1986 class LInteger32ToDouble final : public LTemplateInstruction<1, 1, 0> {
1988 explicit LInteger32ToDouble(LOperand* value) {
1992 LOperand* value() { return inputs_[0]; }
1994 DECLARE_CONCRETE_INSTRUCTION(Integer32ToDouble, "int32-to-double")
1998 class LUint32ToDouble final : public LTemplateInstruction<1, 1, 0> {
2000 explicit LUint32ToDouble(LOperand* value) {
2004 LOperand* value() { return inputs_[0]; }
2006 DECLARE_CONCRETE_INSTRUCTION(Uint32ToDouble, "uint32-to-double")
2010 class LNumberTagI final : public LTemplateInstruction<1, 1, 2> {
2012 LNumberTagI(LOperand* value, LOperand* temp1, LOperand* temp2) {
2018 LOperand* value() { return inputs_[0]; }
2019 LOperand* temp1() { return temps_[0]; }
2020 LOperand* temp2() { return temps_[1]; }
2022 DECLARE_CONCRETE_INSTRUCTION(NumberTagI, "number-tag-i")
2026 class LNumberTagU final : public LTemplateInstruction<1, 1, 2> {
2028 LNumberTagU(LOperand* value, LOperand* temp1, LOperand* temp2) {
2034 LOperand* value() { return inputs_[0]; }
2035 LOperand* temp1() { return temps_[0]; }
2036 LOperand* temp2() { return temps_[1]; }
2038 DECLARE_CONCRETE_INSTRUCTION(NumberTagU, "number-tag-u")
2042 class LNumberTagD final : public LTemplateInstruction<1, 1, 1> {
2044 explicit LNumberTagD(LOperand* value, LOperand* temp) {
2049 LOperand* value() { return inputs_[0]; }
2050 LOperand* temp() { return temps_[0]; }
2052 DECLARE_CONCRETE_INSTRUCTION(NumberTagD, "number-tag-d")
2053 DECLARE_HYDROGEN_ACCESSOR(Change)
2057 // Sometimes truncating conversion from a tagged value to an int32.
2058 class LDoubleToI final : public LTemplateInstruction<1, 1, 0> {
2060 explicit LDoubleToI(LOperand* value) {
2064 LOperand* value() { return inputs_[0]; }
2066 DECLARE_CONCRETE_INSTRUCTION(DoubleToI, "double-to-i")
2067 DECLARE_HYDROGEN_ACCESSOR(UnaryOperation)
2069 bool truncating() { return hydrogen()->CanTruncateToInt32(); }
2073 class LDoubleToSmi final : public LTemplateInstruction<1, 1, 0> {
2075 explicit LDoubleToSmi(LOperand* value) {
2079 LOperand* value() { return inputs_[0]; }
2081 DECLARE_CONCRETE_INSTRUCTION(DoubleToSmi, "double-to-smi")
2082 DECLARE_HYDROGEN_ACCESSOR(UnaryOperation)
2086 // Truncating conversion from a tagged value to an int32.
2087 class LTaggedToI final : public LTemplateInstruction<1, 1, 1> {
2089 LTaggedToI(LOperand* value, LOperand* temp) {
2094 LOperand* value() { return inputs_[0]; }
2095 LOperand* temp() { return temps_[0]; }
2097 DECLARE_CONCRETE_INSTRUCTION(TaggedToI, "tagged-to-i")
2098 DECLARE_HYDROGEN_ACCESSOR(Change)
2100 bool truncating() { return hydrogen()->CanTruncateToInt32(); }
2104 class LSmiTag final : public LTemplateInstruction<1, 1, 0> {
2106 explicit LSmiTag(LOperand* value) {
2110 LOperand* value() { return inputs_[0]; }
2112 DECLARE_CONCRETE_INSTRUCTION(SmiTag, "smi-tag")
2113 DECLARE_HYDROGEN_ACCESSOR(Change)
2117 class LNumberUntagD final : public LTemplateInstruction<1, 1, 0> {
2119 explicit LNumberUntagD(LOperand* value) {
2123 LOperand* value() { return inputs_[0]; }
2125 DECLARE_CONCRETE_INSTRUCTION(NumberUntagD, "double-untag")
2126 DECLARE_HYDROGEN_ACCESSOR(Change);
2130 class LSmiUntag final : public LTemplateInstruction<1, 1, 0> {
2132 LSmiUntag(LOperand* value, bool needs_check)
2133 : needs_check_(needs_check) {
2137 LOperand* value() { return inputs_[0]; }
2138 bool needs_check() const { return needs_check_; }
2140 DECLARE_CONCRETE_INSTRUCTION(SmiUntag, "smi-untag")
2147 class LStoreNamedField final : public LTemplateInstruction<0, 2, 1> {
2149 LStoreNamedField(LOperand* object, LOperand* value, LOperand* temp) {
2150 inputs_[0] = object;
2155 LOperand* object() { return inputs_[0]; }
2156 LOperand* value() { return inputs_[1]; }
2157 LOperand* temp() { return temps_[0]; }
2159 DECLARE_CONCRETE_INSTRUCTION(StoreNamedField, "store-named-field")
2160 DECLARE_HYDROGEN_ACCESSOR(StoreNamedField)
2162 void PrintDataTo(StringStream* stream) override;
2164 Representation representation() const {
2165 return hydrogen()->field_representation();
2170 class LStoreNamedGeneric final : public LTemplateInstruction<0, 3, 2> {
2172 LStoreNamedGeneric(LOperand* context, LOperand* object, LOperand* value,
2173 LOperand* slot, LOperand* vector) {
2174 inputs_[0] = context;
2175 inputs_[1] = object;
2181 LOperand* context() { return inputs_[0]; }
2182 LOperand* object() { return inputs_[1]; }
2183 LOperand* value() { return inputs_[2]; }
2184 LOperand* temp_slot() { return temps_[0]; }
2185 LOperand* temp_vector() { return temps_[1]; }
2187 DECLARE_CONCRETE_INSTRUCTION(StoreNamedGeneric, "store-named-generic")
2188 DECLARE_HYDROGEN_ACCESSOR(StoreNamedGeneric)
2190 void PrintDataTo(StringStream* stream) override;
2192 Handle<Object> name() const { return hydrogen()->name(); }
2193 LanguageMode language_mode() { return hydrogen()->language_mode(); }
2197 class LStoreGlobalViaContext final : public LTemplateInstruction<0, 2, 0> {
2199 LStoreGlobalViaContext(LOperand* context, LOperand* value) {
2200 inputs_[0] = context;
2204 LOperand* context() { return inputs_[0]; }
2205 LOperand* value() { return inputs_[1]; }
2207 DECLARE_CONCRETE_INSTRUCTION(StoreGlobalViaContext,
2208 "store-global-via-context")
2209 DECLARE_HYDROGEN_ACCESSOR(StoreGlobalViaContext)
2211 void PrintDataTo(StringStream* stream) override;
2213 Handle<Object> name() const { return hydrogen()->name(); }
2214 int depth() { return hydrogen()->depth(); }
2215 int slot_index() { return hydrogen()->slot_index(); }
2216 LanguageMode language_mode() { return hydrogen()->language_mode(); }
2220 class LStoreKeyed final : public LTemplateInstruction<0, 3, 0> {
2222 LStoreKeyed(LOperand* object, LOperand* key, LOperand* value) {
2223 inputs_[0] = object;
2228 bool is_fixed_typed_array() const {
2229 return hydrogen()->is_fixed_typed_array();
2231 LOperand* elements() { return inputs_[0]; }
2232 LOperand* key() { return inputs_[1]; }
2233 LOperand* value() { return inputs_[2]; }
2234 ElementsKind elements_kind() const { return hydrogen()->elements_kind(); }
2236 DECLARE_CONCRETE_INSTRUCTION(StoreKeyed, "store-keyed")
2237 DECLARE_HYDROGEN_ACCESSOR(StoreKeyed)
2239 void PrintDataTo(StringStream* stream) override;
2240 bool NeedsCanonicalization() { return hydrogen()->NeedsCanonicalization(); }
2241 uint32_t base_offset() const { return hydrogen()->base_offset(); }
2245 class LStoreKeyedGeneric final : public LTemplateInstruction<0, 4, 2> {
2247 LStoreKeyedGeneric(LOperand* context, LOperand* object, LOperand* key,
2248 LOperand* value, LOperand* slot, LOperand* vector) {
2249 inputs_[0] = context;
2250 inputs_[1] = object;
2257 LOperand* context() { return inputs_[0]; }
2258 LOperand* object() { return inputs_[1]; }
2259 LOperand* key() { return inputs_[2]; }
2260 LOperand* value() { return inputs_[3]; }
2261 LOperand* temp_slot() { return temps_[0]; }
2262 LOperand* temp_vector() { return temps_[1]; }
2264 DECLARE_CONCRETE_INSTRUCTION(StoreKeyedGeneric, "store-keyed-generic")
2265 DECLARE_HYDROGEN_ACCESSOR(StoreKeyedGeneric)
2267 void PrintDataTo(StringStream* stream) override;
2269 LanguageMode language_mode() { return hydrogen()->language_mode(); }
2273 class LTransitionElementsKind final : public LTemplateInstruction<0, 2, 2> {
2275 LTransitionElementsKind(LOperand* object,
2277 LOperand* new_map_temp,
2279 inputs_[0] = object;
2280 inputs_[1] = context;
2281 temps_[0] = new_map_temp;
2285 LOperand* object() { return inputs_[0]; }
2286 LOperand* context() { return inputs_[1]; }
2287 LOperand* new_map_temp() { return temps_[0]; }
2288 LOperand* temp() { return temps_[1]; }
2290 DECLARE_CONCRETE_INSTRUCTION(TransitionElementsKind,
2291 "transition-elements-kind")
2292 DECLARE_HYDROGEN_ACCESSOR(TransitionElementsKind)
2294 void PrintDataTo(StringStream* stream) override;
2296 Handle<Map> original_map() { return hydrogen()->original_map().handle(); }
2297 Handle<Map> transitioned_map() {
2298 return hydrogen()->transitioned_map().handle();
2300 ElementsKind from_kind() { return hydrogen()->from_kind(); }
2301 ElementsKind to_kind() { return hydrogen()->to_kind(); }
2305 class LTrapAllocationMemento final : public LTemplateInstruction<0, 1, 1> {
2307 LTrapAllocationMemento(LOperand* object,
2309 inputs_[0] = object;
2313 LOperand* object() { return inputs_[0]; }
2314 LOperand* temp() { return temps_[0]; }
2316 DECLARE_CONCRETE_INSTRUCTION(TrapAllocationMemento,
2317 "trap-allocation-memento")
2321 class LMaybeGrowElements final : public LTemplateInstruction<1, 5, 0> {
2323 LMaybeGrowElements(LOperand* context, LOperand* object, LOperand* elements,
2324 LOperand* key, LOperand* current_capacity) {
2325 inputs_[0] = context;
2326 inputs_[1] = object;
2327 inputs_[2] = elements;
2329 inputs_[4] = current_capacity;
2332 LOperand* context() { return inputs_[0]; }
2333 LOperand* object() { return inputs_[1]; }
2334 LOperand* elements() { return inputs_[2]; }
2335 LOperand* key() { return inputs_[3]; }
2336 LOperand* current_capacity() { return inputs_[4]; }
2338 DECLARE_HYDROGEN_ACCESSOR(MaybeGrowElements)
2339 DECLARE_CONCRETE_INSTRUCTION(MaybeGrowElements, "maybe-grow-elements")
2343 class LStringAdd final : public LTemplateInstruction<1, 3, 0> {
2345 LStringAdd(LOperand* context, LOperand* left, LOperand* right) {
2346 inputs_[0] = context;
2351 LOperand* context() { return inputs_[0]; }
2352 LOperand* left() { return inputs_[1]; }
2353 LOperand* right() { return inputs_[2]; }
2355 DECLARE_CONCRETE_INSTRUCTION(StringAdd, "string-add")
2356 DECLARE_HYDROGEN_ACCESSOR(StringAdd)
2360 class LStringCharCodeAt final : public LTemplateInstruction<1, 3, 0> {
2362 LStringCharCodeAt(LOperand* context, LOperand* string, LOperand* index) {
2363 inputs_[0] = context;
2364 inputs_[1] = string;
2368 LOperand* context() { return inputs_[0]; }
2369 LOperand* string() { return inputs_[1]; }
2370 LOperand* index() { return inputs_[2]; }
2372 DECLARE_CONCRETE_INSTRUCTION(StringCharCodeAt, "string-char-code-at")
2373 DECLARE_HYDROGEN_ACCESSOR(StringCharCodeAt)
2377 class LStringCharFromCode final : public LTemplateInstruction<1, 2, 0> {
2379 explicit LStringCharFromCode(LOperand* context, LOperand* char_code) {
2380 inputs_[0] = context;
2381 inputs_[1] = char_code;
2384 LOperand* context() { return inputs_[0]; }
2385 LOperand* char_code() { return inputs_[1]; }
2387 DECLARE_CONCRETE_INSTRUCTION(StringCharFromCode, "string-char-from-code")
2388 DECLARE_HYDROGEN_ACCESSOR(StringCharFromCode)
2392 class LCheckValue final : public LTemplateInstruction<0, 1, 0> {
2394 explicit LCheckValue(LOperand* value) {
2398 LOperand* value() { return inputs_[0]; }
2400 DECLARE_CONCRETE_INSTRUCTION(CheckValue, "check-value")
2401 DECLARE_HYDROGEN_ACCESSOR(CheckValue)
2405 class LCheckArrayBufferNotNeutered final
2406 : public LTemplateInstruction<0, 1, 0> {
2408 explicit LCheckArrayBufferNotNeutered(LOperand* view) { inputs_[0] = view; }
2410 LOperand* view() { return inputs_[0]; }
2412 DECLARE_CONCRETE_INSTRUCTION(CheckArrayBufferNotNeutered,
2413 "check-array-buffer-not-neutered")
2414 DECLARE_HYDROGEN_ACCESSOR(CheckArrayBufferNotNeutered)
2418 class LCheckInstanceType final : public LTemplateInstruction<0, 1, 0> {
2420 explicit LCheckInstanceType(LOperand* value) {
2424 LOperand* value() { return inputs_[0]; }
2426 DECLARE_CONCRETE_INSTRUCTION(CheckInstanceType, "check-instance-type")
2427 DECLARE_HYDROGEN_ACCESSOR(CheckInstanceType)
2431 class LCheckMaps final : public LTemplateInstruction<0, 1, 0> {
2433 explicit LCheckMaps(LOperand* value = NULL) {
2437 LOperand* value() { return inputs_[0]; }
2439 DECLARE_CONCRETE_INSTRUCTION(CheckMaps, "check-maps")
2440 DECLARE_HYDROGEN_ACCESSOR(CheckMaps)
2444 class LCheckSmi final : public LTemplateInstruction<1, 1, 0> {
2446 explicit LCheckSmi(LOperand* value) {
2450 LOperand* value() { return inputs_[0]; }
2452 DECLARE_CONCRETE_INSTRUCTION(CheckSmi, "check-smi")
2456 class LClampDToUint8 final : public LTemplateInstruction<1, 1, 0> {
2458 explicit LClampDToUint8(LOperand* unclamped) {
2459 inputs_[0] = unclamped;
2462 LOperand* unclamped() { return inputs_[0]; }
2464 DECLARE_CONCRETE_INSTRUCTION(ClampDToUint8, "clamp-d-to-uint8")
2468 class LClampIToUint8 final : public LTemplateInstruction<1, 1, 0> {
2470 explicit LClampIToUint8(LOperand* unclamped) {
2471 inputs_[0] = unclamped;
2474 LOperand* unclamped() { return inputs_[0]; }
2476 DECLARE_CONCRETE_INSTRUCTION(ClampIToUint8, "clamp-i-to-uint8")
2480 class LClampTToUint8 final : public LTemplateInstruction<1, 1, 1> {
2482 LClampTToUint8(LOperand* unclamped,
2483 LOperand* temp_xmm) {
2484 inputs_[0] = unclamped;
2485 temps_[0] = temp_xmm;
2488 LOperand* unclamped() { return inputs_[0]; }
2489 LOperand* temp_xmm() { return temps_[0]; }
2491 DECLARE_CONCRETE_INSTRUCTION(ClampTToUint8, "clamp-t-to-uint8")
2495 class LCheckNonSmi final : public LTemplateInstruction<0, 1, 0> {
2497 explicit LCheckNonSmi(LOperand* value) {
2501 LOperand* value() { return inputs_[0]; }
2503 DECLARE_CONCRETE_INSTRUCTION(CheckNonSmi, "check-non-smi")
2504 DECLARE_HYDROGEN_ACCESSOR(CheckHeapObject)
2508 class LDoubleBits final : public LTemplateInstruction<1, 1, 0> {
2510 explicit LDoubleBits(LOperand* value) {
2514 LOperand* value() { return inputs_[0]; }
2516 DECLARE_CONCRETE_INSTRUCTION(DoubleBits, "double-bits")
2517 DECLARE_HYDROGEN_ACCESSOR(DoubleBits)
2521 class LConstructDouble final : public LTemplateInstruction<1, 2, 0> {
2523 LConstructDouble(LOperand* hi, LOperand* lo) {
2528 LOperand* hi() { return inputs_[0]; }
2529 LOperand* lo() { return inputs_[1]; }
2531 DECLARE_CONCRETE_INSTRUCTION(ConstructDouble, "construct-double")
2535 class LAllocate final : public LTemplateInstruction<1, 2, 1> {
2537 LAllocate(LOperand* context, LOperand* size, LOperand* temp) {
2538 inputs_[0] = context;
2543 LOperand* context() { return inputs_[0]; }
2544 LOperand* size() { return inputs_[1]; }
2545 LOperand* temp() { return temps_[0]; }
2547 DECLARE_CONCRETE_INSTRUCTION(Allocate, "allocate")
2548 DECLARE_HYDROGEN_ACCESSOR(Allocate)
2552 class LRegExpLiteral final : public LTemplateInstruction<1, 1, 0> {
2554 explicit LRegExpLiteral(LOperand* context) {
2555 inputs_[0] = context;
2558 LOperand* context() { return inputs_[0]; }
2560 DECLARE_CONCRETE_INSTRUCTION(RegExpLiteral, "regexp-literal")
2561 DECLARE_HYDROGEN_ACCESSOR(RegExpLiteral)
2565 class LFunctionLiteral final : public LTemplateInstruction<1, 1, 0> {
2567 explicit LFunctionLiteral(LOperand* context) {
2568 inputs_[0] = context;
2571 LOperand* context() { return inputs_[0]; }
2573 DECLARE_CONCRETE_INSTRUCTION(FunctionLiteral, "function-literal")
2574 DECLARE_HYDROGEN_ACCESSOR(FunctionLiteral)
2578 class LToFastProperties final : public LTemplateInstruction<1, 1, 0> {
2580 explicit LToFastProperties(LOperand* value) {
2584 LOperand* value() { return inputs_[0]; }
2586 DECLARE_CONCRETE_INSTRUCTION(ToFastProperties, "to-fast-properties")
2587 DECLARE_HYDROGEN_ACCESSOR(ToFastProperties)
2591 class LTypeof final : public LTemplateInstruction<1, 2, 0> {
2593 LTypeof(LOperand* context, LOperand* value) {
2594 inputs_[0] = context;
2598 LOperand* context() { return inputs_[0]; }
2599 LOperand* value() { return inputs_[1]; }
2601 DECLARE_CONCRETE_INSTRUCTION(Typeof, "typeof")
2605 class LTypeofIsAndBranch final : public LControlInstruction<1, 0> {
2607 explicit LTypeofIsAndBranch(LOperand* value) {
2611 LOperand* value() { return inputs_[0]; }
2613 DECLARE_CONCRETE_INSTRUCTION(TypeofIsAndBranch, "typeof-is-and-branch")
2614 DECLARE_HYDROGEN_ACCESSOR(TypeofIsAndBranch)
2616 Handle<String> type_literal() { return hydrogen()->type_literal(); }
2618 void PrintDataTo(StringStream* stream) override;
2622 class LIsConstructCallAndBranch final : public LControlInstruction<0, 1> {
2624 explicit LIsConstructCallAndBranch(LOperand* temp) {
2628 LOperand* temp() { return temps_[0]; }
2630 DECLARE_CONCRETE_INSTRUCTION(IsConstructCallAndBranch,
2631 "is-construct-call-and-branch")
2632 DECLARE_HYDROGEN_ACCESSOR(IsConstructCallAndBranch)
2636 class LOsrEntry final : public LTemplateInstruction<0, 0, 0> {
2640 bool HasInterestingComment(LCodeGen* gen) const override { return false; }
2641 DECLARE_CONCRETE_INSTRUCTION(OsrEntry, "osr-entry")
2645 class LStackCheck final : public LTemplateInstruction<0, 1, 0> {
2647 explicit LStackCheck(LOperand* context) {
2648 inputs_[0] = context;
2651 LOperand* context() { return inputs_[0]; }
2653 DECLARE_CONCRETE_INSTRUCTION(StackCheck, "stack-check")
2654 DECLARE_HYDROGEN_ACCESSOR(StackCheck)
2656 Label* done_label() { return &done_label_; }
2663 class LForInPrepareMap final : public LTemplateInstruction<1, 2, 0> {
2665 LForInPrepareMap(LOperand* context, LOperand* object) {
2666 inputs_[0] = context;
2667 inputs_[1] = object;
2670 LOperand* context() { return inputs_[0]; }
2671 LOperand* object() { return inputs_[1]; }
2673 DECLARE_CONCRETE_INSTRUCTION(ForInPrepareMap, "for-in-prepare-map")
2677 class LForInCacheArray final : public LTemplateInstruction<1, 1, 0> {
2679 explicit LForInCacheArray(LOperand* map) {
2683 LOperand* map() { return inputs_[0]; }
2685 DECLARE_CONCRETE_INSTRUCTION(ForInCacheArray, "for-in-cache-array")
2688 return HForInCacheArray::cast(this->hydrogen_value())->idx();
2693 class LCheckMapValue final : public LTemplateInstruction<0, 2, 0> {
2695 LCheckMapValue(LOperand* value, LOperand* map) {
2700 LOperand* value() { return inputs_[0]; }
2701 LOperand* map() { return inputs_[1]; }
2703 DECLARE_CONCRETE_INSTRUCTION(CheckMapValue, "check-map-value")
2707 class LLoadFieldByIndex final : public LTemplateInstruction<1, 2, 0> {
2709 LLoadFieldByIndex(LOperand* object, LOperand* index) {
2710 inputs_[0] = object;
2714 LOperand* object() { return inputs_[0]; }
2715 LOperand* index() { return inputs_[1]; }
2717 DECLARE_CONCRETE_INSTRUCTION(LoadFieldByIndex, "load-field-by-index")
2721 class LStoreFrameContext: public LTemplateInstruction<0, 1, 0> {
2723 explicit LStoreFrameContext(LOperand* context) {
2724 inputs_[0] = context;
2727 LOperand* context() { return inputs_[0]; }
2729 DECLARE_CONCRETE_INSTRUCTION(StoreFrameContext, "store-frame-context")
2733 class LAllocateBlockContext: public LTemplateInstruction<1, 2, 0> {
2735 LAllocateBlockContext(LOperand* context, LOperand* function) {
2736 inputs_[0] = context;
2737 inputs_[1] = function;
2740 LOperand* context() { return inputs_[0]; }
2741 LOperand* function() { return inputs_[1]; }
2743 Handle<ScopeInfo> scope_info() { return hydrogen()->scope_info(); }
2745 DECLARE_CONCRETE_INSTRUCTION(AllocateBlockContext, "allocate-block-context")
2746 DECLARE_HYDROGEN_ACCESSOR(AllocateBlockContext)
2750 class LChunkBuilder;
2751 class LPlatformChunk final : public LChunk {
2753 LPlatformChunk(CompilationInfo* info, HGraph* graph)
2754 : LChunk(info, graph),
2755 dehoisted_key_ids_(graph->GetMaximumValueID(), graph->zone()) { }
2757 int GetNextSpillIndex(RegisterKind kind);
2758 LOperand* GetNextSpillSlot(RegisterKind kind);
2759 BitVector* GetDehoistedKeyIds() { return &dehoisted_key_ids_; }
2760 bool IsDehoistedKey(HValue* value) {
2761 return dehoisted_key_ids_.Contains(value->id());
2765 BitVector dehoisted_key_ids_;
2769 class LChunkBuilder final : public LChunkBuilderBase {
2771 LChunkBuilder(CompilationInfo* info, HGraph* graph, LAllocator* allocator)
2772 : LChunkBuilderBase(info, graph),
2773 current_instruction_(NULL),
2774 current_block_(NULL),
2776 allocator_(allocator) {}
2778 // Build the sequence for the graph.
2779 LPlatformChunk* Build();
2781 // Declare methods that deal with the individual node types.
2782 #define DECLARE_DO(type) LInstruction* Do##type(H##type* node);
2783 HYDROGEN_CONCRETE_INSTRUCTION_LIST(DECLARE_DO)
2786 LInstruction* DoMathFloor(HUnaryMathOperation* instr);
2787 LInstruction* DoMathRound(HUnaryMathOperation* instr);
2788 LInstruction* DoMathFround(HUnaryMathOperation* instr);
2789 LInstruction* DoMathAbs(HUnaryMathOperation* instr);
2790 LInstruction* DoMathLog(HUnaryMathOperation* instr);
2791 LInstruction* DoMathExp(HUnaryMathOperation* instr);
2792 LInstruction* DoMathSqrt(HUnaryMathOperation* instr);
2793 LInstruction* DoMathPowHalf(HUnaryMathOperation* instr);
2794 LInstruction* DoMathClz32(HUnaryMathOperation* instr);
2795 LInstruction* DoDivByPowerOf2I(HDiv* instr);
2796 LInstruction* DoDivByConstI(HDiv* instr);
2797 LInstruction* DoDivI(HDiv* instr);
2798 LInstruction* DoModByPowerOf2I(HMod* instr);
2799 LInstruction* DoModByConstI(HMod* instr);
2800 LInstruction* DoModI(HMod* instr);
2801 LInstruction* DoFlooringDivByPowerOf2I(HMathFloorOfDiv* instr);
2802 LInstruction* DoFlooringDivByConstI(HMathFloorOfDiv* instr);
2803 LInstruction* DoFlooringDivI(HMathFloorOfDiv* instr);
2806 // Methods for getting operands for Use / Define / Temp.
2807 LUnallocated* ToUnallocated(Register reg);
2808 LUnallocated* ToUnallocated(XMMRegister reg);
2810 // Methods for setting up define-use relationships.
2811 MUST_USE_RESULT LOperand* Use(HValue* value, LUnallocated* operand);
2812 MUST_USE_RESULT LOperand* UseFixed(HValue* value, Register fixed_register);
2813 MUST_USE_RESULT LOperand* UseFixedDouble(HValue* value,
2814 XMMRegister fixed_register);
2816 // A value that is guaranteed to be allocated to a register.
2817 // Operand created by UseRegister is guaranteed to be live until the end of
2818 // instruction. This means that register allocator will not reuse it's
2819 // register for any other operand inside instruction.
2820 // Operand created by UseRegisterAtStart is guaranteed to be live only at
2821 // instruction start. Register allocator is free to assign the same register
2822 // to some other operand used inside instruction (i.e. temporary or
2824 MUST_USE_RESULT LOperand* UseRegister(HValue* value);
2825 MUST_USE_RESULT LOperand* UseRegisterAtStart(HValue* value);
2827 // An input operand in a register that may be trashed.
2828 MUST_USE_RESULT LOperand* UseTempRegister(HValue* value);
2830 // An input operand in a register that may be trashed or a constant operand.
2831 MUST_USE_RESULT LOperand* UseTempRegisterOrConstant(HValue* value);
2833 // An input operand in a register or stack slot.
2834 MUST_USE_RESULT LOperand* Use(HValue* value);
2835 MUST_USE_RESULT LOperand* UseAtStart(HValue* value);
2837 // An input operand in a register, stack slot or a constant operand.
2838 MUST_USE_RESULT LOperand* UseOrConstant(HValue* value);
2839 MUST_USE_RESULT LOperand* UseOrConstantAtStart(HValue* value);
2841 // An input operand in a register or a constant operand.
2842 MUST_USE_RESULT LOperand* UseRegisterOrConstant(HValue* value);
2843 MUST_USE_RESULT LOperand* UseRegisterOrConstantAtStart(HValue* value);
2845 // An input operand in a constant operand.
2846 MUST_USE_RESULT LOperand* UseConstant(HValue* value);
2848 // An input operand in register, stack slot or a constant operand.
2849 // Will not be moved to a register even if one is freely available.
2850 MUST_USE_RESULT LOperand* UseAny(HValue* value) override;
2852 // Temporary operand that must be in a register.
2853 MUST_USE_RESULT LUnallocated* TempRegister();
2854 MUST_USE_RESULT LOperand* FixedTemp(Register reg);
2855 MUST_USE_RESULT LOperand* FixedTemp(XMMRegister reg);
2857 // Methods for setting up define-use relationships.
2858 // Return the same instruction that they are passed.
2859 LInstruction* Define(LTemplateResultInstruction<1>* instr,
2860 LUnallocated* result);
2861 LInstruction* DefineAsRegister(LTemplateResultInstruction<1>* instr);
2862 LInstruction* DefineAsSpilled(LTemplateResultInstruction<1>* instr,
2864 LInstruction* DefineSameAsFirst(LTemplateResultInstruction<1>* instr);
2865 LInstruction* DefineFixed(LTemplateResultInstruction<1>* instr,
2867 LInstruction* DefineFixedDouble(LTemplateResultInstruction<1>* instr,
2869 // Assigns an environment to an instruction. An instruction which can
2870 // deoptimize must have an environment.
2871 LInstruction* AssignEnvironment(LInstruction* instr);
2872 // Assigns a pointer map to an instruction. An instruction which can
2873 // trigger a GC or a lazy deoptimization must have a pointer map.
2874 LInstruction* AssignPointerMap(LInstruction* instr);
2876 enum CanDeoptimize { CAN_DEOPTIMIZE_EAGERLY, CANNOT_DEOPTIMIZE_EAGERLY };
2878 // Marks a call for the register allocator. Assigns a pointer map to
2879 // support GC and lazy deoptimization. Assigns an environment to support
2880 // eager deoptimization if CAN_DEOPTIMIZE_EAGERLY.
2881 LInstruction* MarkAsCall(
2882 LInstruction* instr,
2883 HInstruction* hinstr,
2884 CanDeoptimize can_deoptimize = CANNOT_DEOPTIMIZE_EAGERLY);
2886 void VisitInstruction(HInstruction* current);
2887 void AddInstruction(LInstruction* instr, HInstruction* current);
2889 void DoBasicBlock(HBasicBlock* block, HBasicBlock* next_block);
2890 LInstruction* DoShift(Token::Value op, HBitwiseBinaryOperation* instr);
2891 LInstruction* DoArithmeticD(Token::Value op,
2892 HArithmeticBinaryOperation* instr);
2893 LInstruction* DoArithmeticT(Token::Value op,
2894 HBinaryOperation* instr);
2895 void FindDehoistedKeyDefinitions(HValue* candidate);
2897 HInstruction* current_instruction_;
2898 HBasicBlock* current_block_;
2899 HBasicBlock* next_block_;
2900 LAllocator* allocator_;
2902 DISALLOW_COPY_AND_ASSIGN(LChunkBuilder);
2905 #undef DECLARE_HYDROGEN_ACCESSOR
2906 #undef DECLARE_CONCRETE_INSTRUCTION
2908 } } // namespace v8::int
2910 #endif // V8_X64_LITHIUM_X64_H_