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 int depth() const { return hydrogen()->depth(); }
1711 int slot_index() const { return hydrogen()->slot_index(); }
1715 class LLoadContextSlot final : public LTemplateInstruction<1, 1, 0> {
1717 explicit LLoadContextSlot(LOperand* context) {
1718 inputs_[0] = context;
1721 LOperand* context() { return inputs_[0]; }
1723 DECLARE_CONCRETE_INSTRUCTION(LoadContextSlot, "load-context-slot")
1724 DECLARE_HYDROGEN_ACCESSOR(LoadContextSlot)
1726 int slot_index() { return hydrogen()->slot_index(); }
1728 void PrintDataTo(StringStream* stream) override;
1732 class LStoreContextSlot final : public LTemplateInstruction<0, 2, 1> {
1734 LStoreContextSlot(LOperand* context, LOperand* value, LOperand* temp) {
1735 inputs_[0] = context;
1740 LOperand* context() { return inputs_[0]; }
1741 LOperand* value() { return inputs_[1]; }
1742 LOperand* temp() { return temps_[0]; }
1744 DECLARE_CONCRETE_INSTRUCTION(StoreContextSlot, "store-context-slot")
1745 DECLARE_HYDROGEN_ACCESSOR(StoreContextSlot)
1747 int slot_index() { return hydrogen()->slot_index(); }
1749 void PrintDataTo(StringStream* stream) override;
1753 class LPushArgument final : public LTemplateInstruction<0, 1, 0> {
1755 explicit LPushArgument(LOperand* value) {
1759 LOperand* value() { return inputs_[0]; }
1761 DECLARE_CONCRETE_INSTRUCTION(PushArgument, "push-argument")
1765 class LDrop final : public LTemplateInstruction<0, 0, 0> {
1767 explicit LDrop(int count) : count_(count) { }
1769 int count() const { return count_; }
1771 DECLARE_CONCRETE_INSTRUCTION(Drop, "drop")
1778 class LStoreCodeEntry final : public LTemplateInstruction<0, 2, 0> {
1780 LStoreCodeEntry(LOperand* function, LOperand* code_object) {
1781 inputs_[0] = function;
1782 inputs_[1] = code_object;
1785 LOperand* function() { return inputs_[0]; }
1786 LOperand* code_object() { return inputs_[1]; }
1788 void PrintDataTo(StringStream* stream) override;
1790 DECLARE_CONCRETE_INSTRUCTION(StoreCodeEntry, "store-code-entry")
1791 DECLARE_HYDROGEN_ACCESSOR(StoreCodeEntry)
1795 class LInnerAllocatedObject final : public LTemplateInstruction<1, 2, 0> {
1797 LInnerAllocatedObject(LOperand* base_object, LOperand* offset) {
1798 inputs_[0] = base_object;
1799 inputs_[1] = offset;
1802 LOperand* base_object() const { return inputs_[0]; }
1803 LOperand* offset() const { return inputs_[1]; }
1805 void PrintDataTo(StringStream* stream) override;
1807 DECLARE_CONCRETE_INSTRUCTION(InnerAllocatedObject, "inner-allocated-object")
1811 class LThisFunction final : public LTemplateInstruction<1, 0, 0> {
1813 DECLARE_CONCRETE_INSTRUCTION(ThisFunction, "this-function")
1814 DECLARE_HYDROGEN_ACCESSOR(ThisFunction)
1818 class LContext final : public LTemplateInstruction<1, 0, 0> {
1820 DECLARE_CONCRETE_INSTRUCTION(Context, "context")
1821 DECLARE_HYDROGEN_ACCESSOR(Context)
1825 class LDeclareGlobals final : public LTemplateInstruction<0, 1, 0> {
1827 explicit LDeclareGlobals(LOperand* context) {
1828 inputs_[0] = context;
1831 LOperand* context() { return inputs_[0]; }
1833 DECLARE_CONCRETE_INSTRUCTION(DeclareGlobals, "declare-globals")
1834 DECLARE_HYDROGEN_ACCESSOR(DeclareGlobals)
1838 class LCallJSFunction final : public LTemplateInstruction<1, 1, 0> {
1840 explicit LCallJSFunction(LOperand* function) {
1841 inputs_[0] = function;
1844 LOperand* function() { return inputs_[0]; }
1846 DECLARE_CONCRETE_INSTRUCTION(CallJSFunction, "call-js-function")
1847 DECLARE_HYDROGEN_ACCESSOR(CallJSFunction)
1849 void PrintDataTo(StringStream* stream) override;
1851 int arity() const { return hydrogen()->argument_count() - 1; }
1855 class LCallWithDescriptor final : public LTemplateResultInstruction<1> {
1857 LCallWithDescriptor(CallInterfaceDescriptor descriptor,
1858 const ZoneList<LOperand*>& operands, Zone* zone)
1859 : inputs_(descriptor.GetRegisterParameterCount() +
1860 kImplicitRegisterParameterCount,
1862 DCHECK(descriptor.GetRegisterParameterCount() +
1863 kImplicitRegisterParameterCount ==
1865 inputs_.AddAll(operands, zone);
1868 LOperand* target() const { return inputs_[0]; }
1870 DECLARE_HYDROGEN_ACCESSOR(CallWithDescriptor)
1872 // The target and context are passed as implicit parameters that are not
1873 // explicitly listed in the descriptor.
1874 static const int kImplicitRegisterParameterCount = 2;
1877 DECLARE_CONCRETE_INSTRUCTION(CallWithDescriptor, "call-with-descriptor")
1879 void PrintDataTo(StringStream* stream) override;
1881 int arity() const { return hydrogen()->argument_count() - 1; }
1883 ZoneList<LOperand*> inputs_;
1885 // Iterator support.
1886 int InputCount() final { return inputs_.length(); }
1887 LOperand* InputAt(int i) final { return inputs_[i]; }
1889 int TempCount() final { return 0; }
1890 LOperand* TempAt(int i) final { return NULL; }
1894 class LInvokeFunction final : public LTemplateInstruction<1, 2, 0> {
1896 LInvokeFunction(LOperand* context, LOperand* function) {
1897 inputs_[0] = context;
1898 inputs_[1] = function;
1901 LOperand* context() { return inputs_[0]; }
1902 LOperand* function() { return inputs_[1]; }
1904 DECLARE_CONCRETE_INSTRUCTION(InvokeFunction, "invoke-function")
1905 DECLARE_HYDROGEN_ACCESSOR(InvokeFunction)
1907 void PrintDataTo(StringStream* stream) override;
1909 int arity() const { return hydrogen()->argument_count() - 1; }
1913 class LCallFunction final : public LTemplateInstruction<1, 2, 2> {
1915 LCallFunction(LOperand* context, LOperand* function, LOperand* slot,
1917 inputs_[0] = context;
1918 inputs_[1] = function;
1923 DECLARE_CONCRETE_INSTRUCTION(CallFunction, "call-function")
1924 DECLARE_HYDROGEN_ACCESSOR(CallFunction)
1926 LOperand* context() { return inputs_[0]; }
1927 LOperand* function() { return inputs_[1]; }
1928 LOperand* temp_slot() { return temps_[0]; }
1929 LOperand* temp_vector() { return temps_[1]; }
1930 int arity() const { return hydrogen()->argument_count() - 1; }
1932 void PrintDataTo(StringStream* stream) override;
1936 class LCallNew final : public LTemplateInstruction<1, 2, 0> {
1938 LCallNew(LOperand* context, LOperand* constructor) {
1939 inputs_[0] = context;
1940 inputs_[1] = constructor;
1943 LOperand* context() { return inputs_[0]; }
1944 LOperand* constructor() { return inputs_[1]; }
1946 DECLARE_CONCRETE_INSTRUCTION(CallNew, "call-new")
1947 DECLARE_HYDROGEN_ACCESSOR(CallNew)
1949 void PrintDataTo(StringStream* stream) override;
1951 int arity() const { return hydrogen()->argument_count() - 1; }
1955 class LCallNewArray final : public LTemplateInstruction<1, 2, 0> {
1957 LCallNewArray(LOperand* context, LOperand* constructor) {
1958 inputs_[0] = context;
1959 inputs_[1] = constructor;
1962 LOperand* context() { return inputs_[0]; }
1963 LOperand* constructor() { return inputs_[1]; }
1965 DECLARE_CONCRETE_INSTRUCTION(CallNewArray, "call-new-array")
1966 DECLARE_HYDROGEN_ACCESSOR(CallNewArray)
1968 void PrintDataTo(StringStream* stream) override;
1970 int arity() const { return hydrogen()->argument_count() - 1; }
1974 class LCallRuntime final : public LTemplateInstruction<1, 1, 0> {
1976 explicit LCallRuntime(LOperand* context) {
1977 inputs_[0] = context;
1980 LOperand* context() { return inputs_[0]; }
1982 DECLARE_CONCRETE_INSTRUCTION(CallRuntime, "call-runtime")
1983 DECLARE_HYDROGEN_ACCESSOR(CallRuntime)
1985 bool ClobbersDoubleRegisters(Isolate* isolate) const override {
1986 return save_doubles() == kDontSaveFPRegs;
1989 const Runtime::Function* function() const { return hydrogen()->function(); }
1990 int arity() const { return hydrogen()->argument_count(); }
1991 SaveFPRegsMode save_doubles() const { return hydrogen()->save_doubles(); }
1995 class LInteger32ToDouble final : public LTemplateInstruction<1, 1, 0> {
1997 explicit LInteger32ToDouble(LOperand* value) {
2001 LOperand* value() { return inputs_[0]; }
2003 DECLARE_CONCRETE_INSTRUCTION(Integer32ToDouble, "int32-to-double")
2007 class LUint32ToDouble final : public LTemplateInstruction<1, 1, 0> {
2009 explicit LUint32ToDouble(LOperand* value) {
2013 LOperand* value() { return inputs_[0]; }
2015 DECLARE_CONCRETE_INSTRUCTION(Uint32ToDouble, "uint32-to-double")
2019 class LNumberTagI final : public LTemplateInstruction<1, 1, 2> {
2021 LNumberTagI(LOperand* value, LOperand* temp1, LOperand* temp2) {
2027 LOperand* value() { return inputs_[0]; }
2028 LOperand* temp1() { return temps_[0]; }
2029 LOperand* temp2() { return temps_[1]; }
2031 DECLARE_CONCRETE_INSTRUCTION(NumberTagI, "number-tag-i")
2035 class LNumberTagU final : public LTemplateInstruction<1, 1, 2> {
2037 LNumberTagU(LOperand* value, LOperand* temp1, LOperand* temp2) {
2043 LOperand* value() { return inputs_[0]; }
2044 LOperand* temp1() { return temps_[0]; }
2045 LOperand* temp2() { return temps_[1]; }
2047 DECLARE_CONCRETE_INSTRUCTION(NumberTagU, "number-tag-u")
2051 class LNumberTagD final : public LTemplateInstruction<1, 1, 1> {
2053 explicit LNumberTagD(LOperand* value, LOperand* temp) {
2058 LOperand* value() { return inputs_[0]; }
2059 LOperand* temp() { return temps_[0]; }
2061 DECLARE_CONCRETE_INSTRUCTION(NumberTagD, "number-tag-d")
2062 DECLARE_HYDROGEN_ACCESSOR(Change)
2066 // Sometimes truncating conversion from a tagged value to an int32.
2067 class LDoubleToI final : public LTemplateInstruction<1, 1, 0> {
2069 explicit LDoubleToI(LOperand* value) {
2073 LOperand* value() { return inputs_[0]; }
2075 DECLARE_CONCRETE_INSTRUCTION(DoubleToI, "double-to-i")
2076 DECLARE_HYDROGEN_ACCESSOR(UnaryOperation)
2078 bool truncating() { return hydrogen()->CanTruncateToInt32(); }
2082 class LDoubleToSmi final : public LTemplateInstruction<1, 1, 0> {
2084 explicit LDoubleToSmi(LOperand* value) {
2088 LOperand* value() { return inputs_[0]; }
2090 DECLARE_CONCRETE_INSTRUCTION(DoubleToSmi, "double-to-smi")
2091 DECLARE_HYDROGEN_ACCESSOR(UnaryOperation)
2095 // Truncating conversion from a tagged value to an int32.
2096 class LTaggedToI final : public LTemplateInstruction<1, 1, 1> {
2098 LTaggedToI(LOperand* value, LOperand* temp) {
2103 LOperand* value() { return inputs_[0]; }
2104 LOperand* temp() { return temps_[0]; }
2106 DECLARE_CONCRETE_INSTRUCTION(TaggedToI, "tagged-to-i")
2107 DECLARE_HYDROGEN_ACCESSOR(Change)
2109 bool truncating() { return hydrogen()->CanTruncateToInt32(); }
2113 class LSmiTag final : public LTemplateInstruction<1, 1, 0> {
2115 explicit LSmiTag(LOperand* value) {
2119 LOperand* value() { return inputs_[0]; }
2121 DECLARE_CONCRETE_INSTRUCTION(SmiTag, "smi-tag")
2122 DECLARE_HYDROGEN_ACCESSOR(Change)
2126 class LNumberUntagD final : public LTemplateInstruction<1, 1, 0> {
2128 explicit LNumberUntagD(LOperand* value) {
2132 LOperand* value() { return inputs_[0]; }
2134 DECLARE_CONCRETE_INSTRUCTION(NumberUntagD, "double-untag")
2135 DECLARE_HYDROGEN_ACCESSOR(Change);
2139 class LSmiUntag final : public LTemplateInstruction<1, 1, 0> {
2141 LSmiUntag(LOperand* value, bool needs_check)
2142 : needs_check_(needs_check) {
2146 LOperand* value() { return inputs_[0]; }
2147 bool needs_check() const { return needs_check_; }
2149 DECLARE_CONCRETE_INSTRUCTION(SmiUntag, "smi-untag")
2156 class LStoreNamedField final : public LTemplateInstruction<0, 2, 1> {
2158 LStoreNamedField(LOperand* object, LOperand* value, LOperand* temp) {
2159 inputs_[0] = object;
2164 LOperand* object() { return inputs_[0]; }
2165 LOperand* value() { return inputs_[1]; }
2166 LOperand* temp() { return temps_[0]; }
2168 DECLARE_CONCRETE_INSTRUCTION(StoreNamedField, "store-named-field")
2169 DECLARE_HYDROGEN_ACCESSOR(StoreNamedField)
2171 void PrintDataTo(StringStream* stream) override;
2173 Representation representation() const {
2174 return hydrogen()->field_representation();
2179 class LStoreNamedGeneric final : public LTemplateInstruction<0, 3, 2> {
2181 LStoreNamedGeneric(LOperand* context, LOperand* object, LOperand* value,
2182 LOperand* slot, LOperand* vector) {
2183 inputs_[0] = context;
2184 inputs_[1] = object;
2190 LOperand* context() { return inputs_[0]; }
2191 LOperand* object() { return inputs_[1]; }
2192 LOperand* value() { return inputs_[2]; }
2193 LOperand* temp_slot() { return temps_[0]; }
2194 LOperand* temp_vector() { return temps_[1]; }
2196 DECLARE_CONCRETE_INSTRUCTION(StoreNamedGeneric, "store-named-generic")
2197 DECLARE_HYDROGEN_ACCESSOR(StoreNamedGeneric)
2199 void PrintDataTo(StringStream* stream) override;
2201 Handle<Object> name() const { return hydrogen()->name(); }
2202 LanguageMode language_mode() { return hydrogen()->language_mode(); }
2206 class LStoreGlobalViaContext final : public LTemplateInstruction<0, 2, 0> {
2208 LStoreGlobalViaContext(LOperand* context, LOperand* value) {
2209 inputs_[0] = context;
2213 LOperand* context() { return inputs_[0]; }
2214 LOperand* value() { return inputs_[1]; }
2216 DECLARE_CONCRETE_INSTRUCTION(StoreGlobalViaContext,
2217 "store-global-via-context")
2218 DECLARE_HYDROGEN_ACCESSOR(StoreGlobalViaContext)
2220 void PrintDataTo(StringStream* stream) override;
2222 int depth() { return hydrogen()->depth(); }
2223 int slot_index() { return hydrogen()->slot_index(); }
2224 LanguageMode language_mode() { return hydrogen()->language_mode(); }
2228 class LStoreKeyed final : public LTemplateInstruction<0, 3, 0> {
2230 LStoreKeyed(LOperand* object, LOperand* key, LOperand* value) {
2231 inputs_[0] = object;
2236 bool is_external() const { return hydrogen()->is_external(); }
2237 bool is_fixed_typed_array() const {
2238 return hydrogen()->is_fixed_typed_array();
2240 bool is_typed_elements() const {
2241 return is_external() || is_fixed_typed_array();
2243 LOperand* elements() { return inputs_[0]; }
2244 LOperand* key() { return inputs_[1]; }
2245 LOperand* value() { return inputs_[2]; }
2246 ElementsKind elements_kind() const { return hydrogen()->elements_kind(); }
2248 DECLARE_CONCRETE_INSTRUCTION(StoreKeyed, "store-keyed")
2249 DECLARE_HYDROGEN_ACCESSOR(StoreKeyed)
2251 void PrintDataTo(StringStream* stream) override;
2252 bool NeedsCanonicalization() { return hydrogen()->NeedsCanonicalization(); }
2253 uint32_t base_offset() const { return hydrogen()->base_offset(); }
2257 class LStoreKeyedGeneric final : public LTemplateInstruction<0, 4, 2> {
2259 LStoreKeyedGeneric(LOperand* context, LOperand* object, LOperand* key,
2260 LOperand* value, LOperand* slot, LOperand* vector) {
2261 inputs_[0] = context;
2262 inputs_[1] = object;
2269 LOperand* context() { return inputs_[0]; }
2270 LOperand* object() { return inputs_[1]; }
2271 LOperand* key() { return inputs_[2]; }
2272 LOperand* value() { return inputs_[3]; }
2273 LOperand* temp_slot() { return temps_[0]; }
2274 LOperand* temp_vector() { return temps_[1]; }
2276 DECLARE_CONCRETE_INSTRUCTION(StoreKeyedGeneric, "store-keyed-generic")
2277 DECLARE_HYDROGEN_ACCESSOR(StoreKeyedGeneric)
2279 void PrintDataTo(StringStream* stream) override;
2281 LanguageMode language_mode() { return hydrogen()->language_mode(); }
2285 class LTransitionElementsKind final : public LTemplateInstruction<0, 2, 2> {
2287 LTransitionElementsKind(LOperand* object,
2289 LOperand* new_map_temp,
2291 inputs_[0] = object;
2292 inputs_[1] = context;
2293 temps_[0] = new_map_temp;
2297 LOperand* object() { return inputs_[0]; }
2298 LOperand* context() { return inputs_[1]; }
2299 LOperand* new_map_temp() { return temps_[0]; }
2300 LOperand* temp() { return temps_[1]; }
2302 DECLARE_CONCRETE_INSTRUCTION(TransitionElementsKind,
2303 "transition-elements-kind")
2304 DECLARE_HYDROGEN_ACCESSOR(TransitionElementsKind)
2306 void PrintDataTo(StringStream* stream) override;
2308 Handle<Map> original_map() { return hydrogen()->original_map().handle(); }
2309 Handle<Map> transitioned_map() {
2310 return hydrogen()->transitioned_map().handle();
2312 ElementsKind from_kind() { return hydrogen()->from_kind(); }
2313 ElementsKind to_kind() { return hydrogen()->to_kind(); }
2317 class LTrapAllocationMemento final : public LTemplateInstruction<0, 1, 1> {
2319 LTrapAllocationMemento(LOperand* object,
2321 inputs_[0] = object;
2325 LOperand* object() { return inputs_[0]; }
2326 LOperand* temp() { return temps_[0]; }
2328 DECLARE_CONCRETE_INSTRUCTION(TrapAllocationMemento,
2329 "trap-allocation-memento")
2333 class LMaybeGrowElements final : public LTemplateInstruction<1, 5, 0> {
2335 LMaybeGrowElements(LOperand* context, LOperand* object, LOperand* elements,
2336 LOperand* key, LOperand* current_capacity) {
2337 inputs_[0] = context;
2338 inputs_[1] = object;
2339 inputs_[2] = elements;
2341 inputs_[4] = current_capacity;
2344 LOperand* context() { return inputs_[0]; }
2345 LOperand* object() { return inputs_[1]; }
2346 LOperand* elements() { return inputs_[2]; }
2347 LOperand* key() { return inputs_[3]; }
2348 LOperand* current_capacity() { return inputs_[4]; }
2350 DECLARE_HYDROGEN_ACCESSOR(MaybeGrowElements)
2351 DECLARE_CONCRETE_INSTRUCTION(MaybeGrowElements, "maybe-grow-elements")
2355 class LStringAdd final : public LTemplateInstruction<1, 3, 0> {
2357 LStringAdd(LOperand* context, LOperand* left, LOperand* right) {
2358 inputs_[0] = context;
2363 LOperand* context() { return inputs_[0]; }
2364 LOperand* left() { return inputs_[1]; }
2365 LOperand* right() { return inputs_[2]; }
2367 DECLARE_CONCRETE_INSTRUCTION(StringAdd, "string-add")
2368 DECLARE_HYDROGEN_ACCESSOR(StringAdd)
2372 class LStringCharCodeAt final : public LTemplateInstruction<1, 3, 0> {
2374 LStringCharCodeAt(LOperand* context, LOperand* string, LOperand* index) {
2375 inputs_[0] = context;
2376 inputs_[1] = string;
2380 LOperand* context() { return inputs_[0]; }
2381 LOperand* string() { return inputs_[1]; }
2382 LOperand* index() { return inputs_[2]; }
2384 DECLARE_CONCRETE_INSTRUCTION(StringCharCodeAt, "string-char-code-at")
2385 DECLARE_HYDROGEN_ACCESSOR(StringCharCodeAt)
2389 class LStringCharFromCode final : public LTemplateInstruction<1, 2, 0> {
2391 explicit LStringCharFromCode(LOperand* context, LOperand* char_code) {
2392 inputs_[0] = context;
2393 inputs_[1] = char_code;
2396 LOperand* context() { return inputs_[0]; }
2397 LOperand* char_code() { return inputs_[1]; }
2399 DECLARE_CONCRETE_INSTRUCTION(StringCharFromCode, "string-char-from-code")
2400 DECLARE_HYDROGEN_ACCESSOR(StringCharFromCode)
2404 class LCheckValue final : public LTemplateInstruction<0, 1, 0> {
2406 explicit LCheckValue(LOperand* value) {
2410 LOperand* value() { return inputs_[0]; }
2412 DECLARE_CONCRETE_INSTRUCTION(CheckValue, "check-value")
2413 DECLARE_HYDROGEN_ACCESSOR(CheckValue)
2417 class LCheckArrayBufferNotNeutered final
2418 : public LTemplateInstruction<0, 1, 0> {
2420 explicit LCheckArrayBufferNotNeutered(LOperand* view) { inputs_[0] = view; }
2422 LOperand* view() { return inputs_[0]; }
2424 DECLARE_CONCRETE_INSTRUCTION(CheckArrayBufferNotNeutered,
2425 "check-array-buffer-not-neutered")
2426 DECLARE_HYDROGEN_ACCESSOR(CheckArrayBufferNotNeutered)
2430 class LCheckInstanceType final : public LTemplateInstruction<0, 1, 0> {
2432 explicit LCheckInstanceType(LOperand* value) {
2436 LOperand* value() { return inputs_[0]; }
2438 DECLARE_CONCRETE_INSTRUCTION(CheckInstanceType, "check-instance-type")
2439 DECLARE_HYDROGEN_ACCESSOR(CheckInstanceType)
2443 class LCheckMaps final : public LTemplateInstruction<0, 1, 0> {
2445 explicit LCheckMaps(LOperand* value = NULL) {
2449 LOperand* value() { return inputs_[0]; }
2451 DECLARE_CONCRETE_INSTRUCTION(CheckMaps, "check-maps")
2452 DECLARE_HYDROGEN_ACCESSOR(CheckMaps)
2456 class LCheckSmi final : public LTemplateInstruction<1, 1, 0> {
2458 explicit LCheckSmi(LOperand* value) {
2462 LOperand* value() { return inputs_[0]; }
2464 DECLARE_CONCRETE_INSTRUCTION(CheckSmi, "check-smi")
2468 class LClampDToUint8 final : public LTemplateInstruction<1, 1, 0> {
2470 explicit LClampDToUint8(LOperand* unclamped) {
2471 inputs_[0] = unclamped;
2474 LOperand* unclamped() { return inputs_[0]; }
2476 DECLARE_CONCRETE_INSTRUCTION(ClampDToUint8, "clamp-d-to-uint8")
2480 class LClampIToUint8 final : public LTemplateInstruction<1, 1, 0> {
2482 explicit LClampIToUint8(LOperand* unclamped) {
2483 inputs_[0] = unclamped;
2486 LOperand* unclamped() { return inputs_[0]; }
2488 DECLARE_CONCRETE_INSTRUCTION(ClampIToUint8, "clamp-i-to-uint8")
2492 class LClampTToUint8 final : public LTemplateInstruction<1, 1, 1> {
2494 LClampTToUint8(LOperand* unclamped,
2495 LOperand* temp_xmm) {
2496 inputs_[0] = unclamped;
2497 temps_[0] = temp_xmm;
2500 LOperand* unclamped() { return inputs_[0]; }
2501 LOperand* temp_xmm() { return temps_[0]; }
2503 DECLARE_CONCRETE_INSTRUCTION(ClampTToUint8, "clamp-t-to-uint8")
2507 class LCheckNonSmi final : public LTemplateInstruction<0, 1, 0> {
2509 explicit LCheckNonSmi(LOperand* value) {
2513 LOperand* value() { return inputs_[0]; }
2515 DECLARE_CONCRETE_INSTRUCTION(CheckNonSmi, "check-non-smi")
2516 DECLARE_HYDROGEN_ACCESSOR(CheckHeapObject)
2520 class LDoubleBits final : public LTemplateInstruction<1, 1, 0> {
2522 explicit LDoubleBits(LOperand* value) {
2526 LOperand* value() { return inputs_[0]; }
2528 DECLARE_CONCRETE_INSTRUCTION(DoubleBits, "double-bits")
2529 DECLARE_HYDROGEN_ACCESSOR(DoubleBits)
2533 class LConstructDouble final : public LTemplateInstruction<1, 2, 0> {
2535 LConstructDouble(LOperand* hi, LOperand* lo) {
2540 LOperand* hi() { return inputs_[0]; }
2541 LOperand* lo() { return inputs_[1]; }
2543 DECLARE_CONCRETE_INSTRUCTION(ConstructDouble, "construct-double")
2547 class LAllocate final : public LTemplateInstruction<1, 2, 1> {
2549 LAllocate(LOperand* context, LOperand* size, LOperand* temp) {
2550 inputs_[0] = context;
2555 LOperand* context() { return inputs_[0]; }
2556 LOperand* size() { return inputs_[1]; }
2557 LOperand* temp() { return temps_[0]; }
2559 DECLARE_CONCRETE_INSTRUCTION(Allocate, "allocate")
2560 DECLARE_HYDROGEN_ACCESSOR(Allocate)
2564 class LRegExpLiteral final : public LTemplateInstruction<1, 1, 0> {
2566 explicit LRegExpLiteral(LOperand* context) {
2567 inputs_[0] = context;
2570 LOperand* context() { return inputs_[0]; }
2572 DECLARE_CONCRETE_INSTRUCTION(RegExpLiteral, "regexp-literal")
2573 DECLARE_HYDROGEN_ACCESSOR(RegExpLiteral)
2577 class LFunctionLiteral final : public LTemplateInstruction<1, 1, 0> {
2579 explicit LFunctionLiteral(LOperand* context) {
2580 inputs_[0] = context;
2583 LOperand* context() { return inputs_[0]; }
2585 DECLARE_CONCRETE_INSTRUCTION(FunctionLiteral, "function-literal")
2586 DECLARE_HYDROGEN_ACCESSOR(FunctionLiteral)
2590 class LToFastProperties final : public LTemplateInstruction<1, 1, 0> {
2592 explicit LToFastProperties(LOperand* value) {
2596 LOperand* value() { return inputs_[0]; }
2598 DECLARE_CONCRETE_INSTRUCTION(ToFastProperties, "to-fast-properties")
2599 DECLARE_HYDROGEN_ACCESSOR(ToFastProperties)
2603 class LTypeof final : public LTemplateInstruction<1, 2, 0> {
2605 LTypeof(LOperand* context, LOperand* value) {
2606 inputs_[0] = context;
2610 LOperand* context() { return inputs_[0]; }
2611 LOperand* value() { return inputs_[1]; }
2613 DECLARE_CONCRETE_INSTRUCTION(Typeof, "typeof")
2617 class LTypeofIsAndBranch final : public LControlInstruction<1, 0> {
2619 explicit LTypeofIsAndBranch(LOperand* value) {
2623 LOperand* value() { return inputs_[0]; }
2625 DECLARE_CONCRETE_INSTRUCTION(TypeofIsAndBranch, "typeof-is-and-branch")
2626 DECLARE_HYDROGEN_ACCESSOR(TypeofIsAndBranch)
2628 Handle<String> type_literal() { return hydrogen()->type_literal(); }
2630 void PrintDataTo(StringStream* stream) override;
2634 class LIsConstructCallAndBranch final : public LControlInstruction<0, 1> {
2636 explicit LIsConstructCallAndBranch(LOperand* temp) {
2640 LOperand* temp() { return temps_[0]; }
2642 DECLARE_CONCRETE_INSTRUCTION(IsConstructCallAndBranch,
2643 "is-construct-call-and-branch")
2644 DECLARE_HYDROGEN_ACCESSOR(IsConstructCallAndBranch)
2648 class LOsrEntry final : public LTemplateInstruction<0, 0, 0> {
2652 bool HasInterestingComment(LCodeGen* gen) const override { return false; }
2653 DECLARE_CONCRETE_INSTRUCTION(OsrEntry, "osr-entry")
2657 class LStackCheck final : public LTemplateInstruction<0, 1, 0> {
2659 explicit LStackCheck(LOperand* context) {
2660 inputs_[0] = context;
2663 LOperand* context() { return inputs_[0]; }
2665 DECLARE_CONCRETE_INSTRUCTION(StackCheck, "stack-check")
2666 DECLARE_HYDROGEN_ACCESSOR(StackCheck)
2668 Label* done_label() { return &done_label_; }
2675 class LForInPrepareMap final : public LTemplateInstruction<1, 2, 0> {
2677 LForInPrepareMap(LOperand* context, LOperand* object) {
2678 inputs_[0] = context;
2679 inputs_[1] = object;
2682 LOperand* context() { return inputs_[0]; }
2683 LOperand* object() { return inputs_[1]; }
2685 DECLARE_CONCRETE_INSTRUCTION(ForInPrepareMap, "for-in-prepare-map")
2689 class LForInCacheArray final : public LTemplateInstruction<1, 1, 0> {
2691 explicit LForInCacheArray(LOperand* map) {
2695 LOperand* map() { return inputs_[0]; }
2697 DECLARE_CONCRETE_INSTRUCTION(ForInCacheArray, "for-in-cache-array")
2700 return HForInCacheArray::cast(this->hydrogen_value())->idx();
2705 class LCheckMapValue final : public LTemplateInstruction<0, 2, 0> {
2707 LCheckMapValue(LOperand* value, LOperand* map) {
2712 LOperand* value() { return inputs_[0]; }
2713 LOperand* map() { return inputs_[1]; }
2715 DECLARE_CONCRETE_INSTRUCTION(CheckMapValue, "check-map-value")
2719 class LLoadFieldByIndex final : public LTemplateInstruction<1, 2, 0> {
2721 LLoadFieldByIndex(LOperand* object, LOperand* index) {
2722 inputs_[0] = object;
2726 LOperand* object() { return inputs_[0]; }
2727 LOperand* index() { return inputs_[1]; }
2729 DECLARE_CONCRETE_INSTRUCTION(LoadFieldByIndex, "load-field-by-index")
2733 class LStoreFrameContext: public LTemplateInstruction<0, 1, 0> {
2735 explicit LStoreFrameContext(LOperand* context) {
2736 inputs_[0] = context;
2739 LOperand* context() { return inputs_[0]; }
2741 DECLARE_CONCRETE_INSTRUCTION(StoreFrameContext, "store-frame-context")
2745 class LAllocateBlockContext: public LTemplateInstruction<1, 2, 0> {
2747 LAllocateBlockContext(LOperand* context, LOperand* function) {
2748 inputs_[0] = context;
2749 inputs_[1] = function;
2752 LOperand* context() { return inputs_[0]; }
2753 LOperand* function() { return inputs_[1]; }
2755 Handle<ScopeInfo> scope_info() { return hydrogen()->scope_info(); }
2757 DECLARE_CONCRETE_INSTRUCTION(AllocateBlockContext, "allocate-block-context")
2758 DECLARE_HYDROGEN_ACCESSOR(AllocateBlockContext)
2762 class LChunkBuilder;
2763 class LPlatformChunk final : public LChunk {
2765 LPlatformChunk(CompilationInfo* info, HGraph* graph)
2766 : LChunk(info, graph),
2767 dehoisted_key_ids_(graph->GetMaximumValueID(), graph->zone()) { }
2769 int GetNextSpillIndex(RegisterKind kind);
2770 LOperand* GetNextSpillSlot(RegisterKind kind);
2771 BitVector* GetDehoistedKeyIds() { return &dehoisted_key_ids_; }
2772 bool IsDehoistedKey(HValue* value) {
2773 return dehoisted_key_ids_.Contains(value->id());
2777 BitVector dehoisted_key_ids_;
2781 class LChunkBuilder final : public LChunkBuilderBase {
2783 LChunkBuilder(CompilationInfo* info, HGraph* graph, LAllocator* allocator)
2784 : LChunkBuilderBase(info, graph),
2785 current_instruction_(NULL),
2786 current_block_(NULL),
2788 allocator_(allocator) {}
2790 // Build the sequence for the graph.
2791 LPlatformChunk* Build();
2793 // Declare methods that deal with the individual node types.
2794 #define DECLARE_DO(type) LInstruction* Do##type(H##type* node);
2795 HYDROGEN_CONCRETE_INSTRUCTION_LIST(DECLARE_DO)
2798 LInstruction* DoMathFloor(HUnaryMathOperation* instr);
2799 LInstruction* DoMathRound(HUnaryMathOperation* instr);
2800 LInstruction* DoMathFround(HUnaryMathOperation* instr);
2801 LInstruction* DoMathAbs(HUnaryMathOperation* instr);
2802 LInstruction* DoMathLog(HUnaryMathOperation* instr);
2803 LInstruction* DoMathExp(HUnaryMathOperation* instr);
2804 LInstruction* DoMathSqrt(HUnaryMathOperation* instr);
2805 LInstruction* DoMathPowHalf(HUnaryMathOperation* instr);
2806 LInstruction* DoMathClz32(HUnaryMathOperation* instr);
2807 LInstruction* DoDivByPowerOf2I(HDiv* instr);
2808 LInstruction* DoDivByConstI(HDiv* instr);
2809 LInstruction* DoDivI(HDiv* instr);
2810 LInstruction* DoModByPowerOf2I(HMod* instr);
2811 LInstruction* DoModByConstI(HMod* instr);
2812 LInstruction* DoModI(HMod* instr);
2813 LInstruction* DoFlooringDivByPowerOf2I(HMathFloorOfDiv* instr);
2814 LInstruction* DoFlooringDivByConstI(HMathFloorOfDiv* instr);
2815 LInstruction* DoFlooringDivI(HMathFloorOfDiv* instr);
2818 // Methods for getting operands for Use / Define / Temp.
2819 LUnallocated* ToUnallocated(Register reg);
2820 LUnallocated* ToUnallocated(XMMRegister reg);
2822 // Methods for setting up define-use relationships.
2823 MUST_USE_RESULT LOperand* Use(HValue* value, LUnallocated* operand);
2824 MUST_USE_RESULT LOperand* UseFixed(HValue* value, Register fixed_register);
2825 MUST_USE_RESULT LOperand* UseFixedDouble(HValue* value,
2826 XMMRegister fixed_register);
2828 // A value that is guaranteed to be allocated to a register.
2829 // Operand created by UseRegister is guaranteed to be live until the end of
2830 // instruction. This means that register allocator will not reuse it's
2831 // register for any other operand inside instruction.
2832 // Operand created by UseRegisterAtStart is guaranteed to be live only at
2833 // instruction start. Register allocator is free to assign the same register
2834 // to some other operand used inside instruction (i.e. temporary or
2836 MUST_USE_RESULT LOperand* UseRegister(HValue* value);
2837 MUST_USE_RESULT LOperand* UseRegisterAtStart(HValue* value);
2839 // An input operand in a register that may be trashed.
2840 MUST_USE_RESULT LOperand* UseTempRegister(HValue* value);
2842 // An input operand in a register that may be trashed or a constant operand.
2843 MUST_USE_RESULT LOperand* UseTempRegisterOrConstant(HValue* value);
2845 // An input operand in a register or stack slot.
2846 MUST_USE_RESULT LOperand* Use(HValue* value);
2847 MUST_USE_RESULT LOperand* UseAtStart(HValue* value);
2849 // An input operand in a register, stack slot or a constant operand.
2850 MUST_USE_RESULT LOperand* UseOrConstant(HValue* value);
2851 MUST_USE_RESULT LOperand* UseOrConstantAtStart(HValue* value);
2853 // An input operand in a register or a constant operand.
2854 MUST_USE_RESULT LOperand* UseRegisterOrConstant(HValue* value);
2855 MUST_USE_RESULT LOperand* UseRegisterOrConstantAtStart(HValue* value);
2857 // An input operand in a constant operand.
2858 MUST_USE_RESULT LOperand* UseConstant(HValue* value);
2860 // An input operand in register, stack slot or a constant operand.
2861 // Will not be moved to a register even if one is freely available.
2862 MUST_USE_RESULT LOperand* UseAny(HValue* value) override;
2864 // Temporary operand that must be in a register.
2865 MUST_USE_RESULT LUnallocated* TempRegister();
2866 MUST_USE_RESULT LOperand* FixedTemp(Register reg);
2867 MUST_USE_RESULT LOperand* FixedTemp(XMMRegister reg);
2869 // Methods for setting up define-use relationships.
2870 // Return the same instruction that they are passed.
2871 LInstruction* Define(LTemplateResultInstruction<1>* instr,
2872 LUnallocated* result);
2873 LInstruction* DefineAsRegister(LTemplateResultInstruction<1>* instr);
2874 LInstruction* DefineAsSpilled(LTemplateResultInstruction<1>* instr,
2876 LInstruction* DefineSameAsFirst(LTemplateResultInstruction<1>* instr);
2877 LInstruction* DefineFixed(LTemplateResultInstruction<1>* instr,
2879 LInstruction* DefineFixedDouble(LTemplateResultInstruction<1>* instr,
2881 // Assigns an environment to an instruction. An instruction which can
2882 // deoptimize must have an environment.
2883 LInstruction* AssignEnvironment(LInstruction* instr);
2884 // Assigns a pointer map to an instruction. An instruction which can
2885 // trigger a GC or a lazy deoptimization must have a pointer map.
2886 LInstruction* AssignPointerMap(LInstruction* instr);
2888 enum CanDeoptimize { CAN_DEOPTIMIZE_EAGERLY, CANNOT_DEOPTIMIZE_EAGERLY };
2890 // Marks a call for the register allocator. Assigns a pointer map to
2891 // support GC and lazy deoptimization. Assigns an environment to support
2892 // eager deoptimization if CAN_DEOPTIMIZE_EAGERLY.
2893 LInstruction* MarkAsCall(
2894 LInstruction* instr,
2895 HInstruction* hinstr,
2896 CanDeoptimize can_deoptimize = CANNOT_DEOPTIMIZE_EAGERLY);
2898 void VisitInstruction(HInstruction* current);
2899 void AddInstruction(LInstruction* instr, HInstruction* current);
2901 void DoBasicBlock(HBasicBlock* block, HBasicBlock* next_block);
2902 LInstruction* DoShift(Token::Value op, HBitwiseBinaryOperation* instr);
2903 LInstruction* DoArithmeticD(Token::Value op,
2904 HArithmeticBinaryOperation* instr);
2905 LInstruction* DoArithmeticT(Token::Value op,
2906 HBinaryOperation* instr);
2907 void FindDehoistedKeyDefinitions(HValue* candidate);
2909 HInstruction* current_instruction_;
2910 HBasicBlock* current_block_;
2911 HBasicBlock* next_block_;
2912 LAllocator* allocator_;
2914 DISALLOW_COPY_AND_ASSIGN(LChunkBuilder);
2917 #undef DECLARE_HYDROGEN_ACCESSOR
2918 #undef DECLARE_CONCRETE_INSTRUCTION
2920 } } // namespace v8::int
2922 #endif // V8_X64_LITHIUM_X64_H_