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(CheckInstanceType) \
49 V(ClassOfTestAndBranch) \
50 V(CompareMinusZeroAndBranch) \
51 V(CompareNumericAndBranch) \
52 V(CmpObjectEqAndBranch) \
76 V(FlooringDivByConstI) \
77 V(FlooringDivByPowerOf2I) \
82 V(GetCachedArrayIndex) \
84 V(HasCachedArrayIndexAndBranch) \
85 V(HasInstanceTypeAndBranch) \
86 V(InnerAllocatedObject) \
88 V(InstanceOfKnownGlobal) \
90 V(Integer32ToDouble) \
92 V(IsConstructCallAndBranch) \
93 V(IsObjectAndBranch) \
94 V(IsStringAndBranch) \
96 V(IsUndetectableAndBranch) \
101 V(LoadFieldByIndex) \
102 V(LoadFunctionPrototype) \
103 V(LoadGlobalGeneric) \
105 V(LoadKeyedGeneric) \
107 V(LoadNamedGeneric) \
133 V(SeqStringGetChar) \
134 V(SeqStringSetChar) \
140 V(StoreContextSlot) \
141 V(StoreFrameContext) \
143 V(StoreKeyedGeneric) \
145 V(StoreNamedGeneric) \
147 V(StringCharCodeAt) \
148 V(StringCharFromCode) \
149 V(StringCompareAndBranch) \
152 V(TailCallThroughMegamorphicCache) \
154 V(ToFastProperties) \
155 V(TransitionElementsKind) \
156 V(TrapAllocationMemento) \
158 V(TypeofIsAndBranch) \
164 #define DECLARE_CONCRETE_INSTRUCTION(type, mnemonic) \
165 Opcode opcode() const final { return LInstruction::k##type; } \
166 void CompileToNative(LCodeGen* generator) final; \
167 const char* Mnemonic() const final { return mnemonic; } \
168 static L##type* cast(LInstruction* instr) { \
169 DCHECK(instr->Is##type()); \
170 return reinterpret_cast<L##type*>(instr); \
174 #define DECLARE_HYDROGEN_ACCESSOR(type) \
175 H##type* hydrogen() const { \
176 return H##type::cast(hydrogen_value()); \
180 class LInstruction : public ZoneObject {
183 : environment_(NULL),
184 hydrogen_value_(NULL),
185 bit_field_(IsCallBits::encode(false)) {
188 virtual ~LInstruction() {}
190 virtual void CompileToNative(LCodeGen* generator) = 0;
191 virtual const char* Mnemonic() const = 0;
192 virtual void PrintTo(StringStream* stream);
193 virtual void PrintDataTo(StringStream* stream);
194 virtual void PrintOutputOperandTo(StringStream* stream);
197 // Declare a unique enum value for each instruction.
198 #define DECLARE_OPCODE(type) k##type,
199 LITHIUM_CONCRETE_INSTRUCTION_LIST(DECLARE_OPCODE)
200 kNumberOfInstructions
201 #undef DECLARE_OPCODE
204 virtual Opcode opcode() const = 0;
206 // Declare non-virtual type testers for all leaf IR classes.
207 #define DECLARE_PREDICATE(type) \
208 bool Is##type() const { return opcode() == k##type; }
209 LITHIUM_CONCRETE_INSTRUCTION_LIST(DECLARE_PREDICATE)
210 #undef DECLARE_PREDICATE
212 // Declare virtual predicates for instructions that don't have
214 virtual bool IsGap() const { return false; }
216 virtual bool IsControl() const { return false; }
218 // Try deleting this instruction if possible.
219 virtual bool TryDelete() { return false; }
221 void set_environment(LEnvironment* env) { environment_ = env; }
222 LEnvironment* environment() const { return environment_; }
223 bool HasEnvironment() const { return environment_ != NULL; }
225 void set_pointer_map(LPointerMap* p) { pointer_map_.set(p); }
226 LPointerMap* pointer_map() const { return pointer_map_.get(); }
227 bool HasPointerMap() const { return pointer_map_.is_set(); }
229 void set_hydrogen_value(HValue* value) { hydrogen_value_ = value; }
230 HValue* hydrogen_value() const { return hydrogen_value_; }
232 void MarkAsCall() { bit_field_ = IsCallBits::update(bit_field_, true); }
233 bool IsCall() const { return IsCallBits::decode(bit_field_); }
235 // Interface to the register allocator and iterators.
236 bool ClobbersTemps() const { return IsCall(); }
237 bool ClobbersRegisters() const { return IsCall(); }
238 virtual bool ClobbersDoubleRegisters(Isolate* isolate) const {
242 virtual void SetDeferredLazyDeoptimizationEnvironment(LEnvironment* env) { }
244 // Interface to the register allocator and iterators.
245 bool IsMarkedAsCall() const { return IsCall(); }
247 virtual bool HasResult() const = 0;
248 virtual LOperand* result() const = 0;
250 LOperand* FirstInput() { return InputAt(0); }
251 LOperand* Output() { return HasResult() ? result() : NULL; }
253 virtual bool HasInterestingComment(LCodeGen* gen) const { return true; }
255 virtual bool MustSignExtendResult(LPlatformChunk* chunk) const {
263 virtual int InputCount() = 0;
264 virtual LOperand* InputAt(int i) = 0;
268 friend class InputIterator;
270 friend class TempIterator;
271 virtual int TempCount() = 0;
272 virtual LOperand* TempAt(int i) = 0;
274 class IsCallBits: public BitField<bool, 0, 1> {};
276 LEnvironment* environment_;
277 SetOncePointer<LPointerMap> pointer_map_;
278 HValue* hydrogen_value_;
283 // R = number of result operands (0 or 1).
285 class LTemplateResultInstruction : public LInstruction {
287 // Allow 0 or 1 output operands.
288 STATIC_ASSERT(R == 0 || R == 1);
289 bool HasResult() const final { return R != 0 && result() != NULL; }
290 void set_result(LOperand* operand) { results_[0] = operand; }
291 LOperand* result() const override { return results_[0]; }
293 bool MustSignExtendResult(LPlatformChunk* chunk) const final;
296 EmbeddedContainer<LOperand*, R> results_;
300 // R = number of result operands (0 or 1).
301 // I = number of input operands.
302 // T = number of temporary operands.
303 template<int R, int I, int T>
304 class LTemplateInstruction : public LTemplateResultInstruction<R> {
306 EmbeddedContainer<LOperand*, I> inputs_;
307 EmbeddedContainer<LOperand*, T> temps_;
311 int InputCount() final { return I; }
312 LOperand* InputAt(int i) final { return inputs_[i]; }
314 int TempCount() final { return T; }
315 LOperand* TempAt(int i) final { return temps_[i]; }
319 class LGap : public LTemplateInstruction<0, 0, 0> {
321 explicit LGap(HBasicBlock* block)
323 parallel_moves_[BEFORE] = NULL;
324 parallel_moves_[START] = NULL;
325 parallel_moves_[END] = NULL;
326 parallel_moves_[AFTER] = NULL;
329 // Can't use the DECLARE-macro here because of sub-classes.
330 bool IsGap() const final { return true; }
331 void PrintDataTo(StringStream* stream) override;
332 static LGap* cast(LInstruction* instr) {
333 DCHECK(instr->IsGap());
334 return reinterpret_cast<LGap*>(instr);
337 bool IsRedundant() const;
339 HBasicBlock* block() const { return block_; }
346 FIRST_INNER_POSITION = BEFORE,
347 LAST_INNER_POSITION = AFTER
350 LParallelMove* GetOrCreateParallelMove(InnerPosition pos,
352 if (parallel_moves_[pos] == NULL) {
353 parallel_moves_[pos] = new(zone) LParallelMove(zone);
355 return parallel_moves_[pos];
358 LParallelMove* GetParallelMove(InnerPosition pos) {
359 return parallel_moves_[pos];
363 LParallelMove* parallel_moves_[LAST_INNER_POSITION + 1];
368 class LInstructionGap final : public LGap {
370 explicit LInstructionGap(HBasicBlock* block) : LGap(block) { }
372 bool HasInterestingComment(LCodeGen* gen) const override {
373 return !IsRedundant();
376 DECLARE_CONCRETE_INSTRUCTION(InstructionGap, "gap")
380 class LGoto final : public LTemplateInstruction<0, 0, 0> {
382 explicit LGoto(HBasicBlock* block) : block_(block) { }
384 bool HasInterestingComment(LCodeGen* gen) const override;
385 DECLARE_CONCRETE_INSTRUCTION(Goto, "goto")
386 void PrintDataTo(StringStream* stream) override;
387 bool IsControl() const override { return true; }
389 int block_id() const { return block_->block_id(); }
396 class LLazyBailout final : public LTemplateInstruction<0, 0, 0> {
398 LLazyBailout() : gap_instructions_size_(0) { }
400 DECLARE_CONCRETE_INSTRUCTION(LazyBailout, "lazy-bailout")
402 void set_gap_instructions_size(int gap_instructions_size) {
403 gap_instructions_size_ = gap_instructions_size;
405 int gap_instructions_size() { return gap_instructions_size_; }
408 int gap_instructions_size_;
412 class LDummy final : public LTemplateInstruction<1, 0, 0> {
415 DECLARE_CONCRETE_INSTRUCTION(Dummy, "dummy")
419 class LDummyUse final : public LTemplateInstruction<1, 1, 0> {
421 explicit LDummyUse(LOperand* value) {
424 DECLARE_CONCRETE_INSTRUCTION(DummyUse, "dummy-use")
428 class LDeoptimize final : public LTemplateInstruction<0, 0, 0> {
430 bool IsControl() const override { return true; }
431 DECLARE_CONCRETE_INSTRUCTION(Deoptimize, "deoptimize")
432 DECLARE_HYDROGEN_ACCESSOR(Deoptimize)
436 class LLabel final : public LGap {
438 explicit LLabel(HBasicBlock* block)
439 : LGap(block), replacement_(NULL) { }
441 bool HasInterestingComment(LCodeGen* gen) const override { return false; }
442 DECLARE_CONCRETE_INSTRUCTION(Label, "label")
444 void PrintDataTo(StringStream* stream) override;
446 int block_id() const { return block()->block_id(); }
447 bool is_loop_header() const { return block()->IsLoopHeader(); }
448 bool is_osr_entry() const { return block()->is_osr_entry(); }
449 Label* label() { return &label_; }
450 LLabel* replacement() const { return replacement_; }
451 void set_replacement(LLabel* label) { replacement_ = label; }
452 bool HasReplacement() const { return replacement_ != NULL; }
456 LLabel* replacement_;
460 class LParameter final : public LTemplateInstruction<1, 0, 0> {
462 bool HasInterestingComment(LCodeGen* gen) const override { return false; }
463 DECLARE_CONCRETE_INSTRUCTION(Parameter, "parameter")
467 class LCallStub final : public LTemplateInstruction<1, 1, 0> {
469 explicit LCallStub(LOperand* context) {
470 inputs_[0] = context;
473 LOperand* context() { return inputs_[0]; }
475 DECLARE_CONCRETE_INSTRUCTION(CallStub, "call-stub")
476 DECLARE_HYDROGEN_ACCESSOR(CallStub)
480 class LTailCallThroughMegamorphicCache final
481 : public LTemplateInstruction<0, 3, 0> {
483 explicit LTailCallThroughMegamorphicCache(LOperand* context,
486 inputs_[0] = context;
487 inputs_[1] = receiver;
491 LOperand* context() { return inputs_[0]; }
492 LOperand* receiver() { return inputs_[1]; }
493 LOperand* name() { return inputs_[2]; }
495 DECLARE_CONCRETE_INSTRUCTION(TailCallThroughMegamorphicCache,
496 "tail-call-through-megamorphic-cache")
497 DECLARE_HYDROGEN_ACCESSOR(TailCallThroughMegamorphicCache)
501 class LUnknownOSRValue final : public LTemplateInstruction<1, 0, 0> {
503 bool HasInterestingComment(LCodeGen* gen) const override { return false; }
504 DECLARE_CONCRETE_INSTRUCTION(UnknownOSRValue, "unknown-osr-value")
508 template<int I, int T>
509 class LControlInstruction : public LTemplateInstruction<0, I, T> {
511 LControlInstruction() : false_label_(NULL), true_label_(NULL) { }
513 bool IsControl() const final { return true; }
515 int SuccessorCount() { return hydrogen()->SuccessorCount(); }
516 HBasicBlock* SuccessorAt(int i) { return hydrogen()->SuccessorAt(i); }
518 int TrueDestination(LChunk* chunk) {
519 return chunk->LookupDestination(true_block_id());
521 int FalseDestination(LChunk* chunk) {
522 return chunk->LookupDestination(false_block_id());
525 Label* TrueLabel(LChunk* chunk) {
526 if (true_label_ == NULL) {
527 true_label_ = chunk->GetAssemblyLabel(TrueDestination(chunk));
531 Label* FalseLabel(LChunk* chunk) {
532 if (false_label_ == NULL) {
533 false_label_ = chunk->GetAssemblyLabel(FalseDestination(chunk));
539 int true_block_id() { return SuccessorAt(0)->block_id(); }
540 int false_block_id() { return SuccessorAt(1)->block_id(); }
543 HControlInstruction* hydrogen() {
544 return HControlInstruction::cast(this->hydrogen_value());
552 class LWrapReceiver final : public LTemplateInstruction<1, 2, 0> {
554 LWrapReceiver(LOperand* receiver, LOperand* function) {
555 inputs_[0] = receiver;
556 inputs_[1] = function;
559 LOperand* receiver() { return inputs_[0]; }
560 LOperand* function() { return inputs_[1]; }
562 DECLARE_CONCRETE_INSTRUCTION(WrapReceiver, "wrap-receiver")
563 DECLARE_HYDROGEN_ACCESSOR(WrapReceiver)
567 class LApplyArguments final : public LTemplateInstruction<1, 4, 0> {
569 LApplyArguments(LOperand* function,
572 LOperand* elements) {
573 inputs_[0] = function;
574 inputs_[1] = receiver;
576 inputs_[3] = elements;
579 LOperand* function() { return inputs_[0]; }
580 LOperand* receiver() { return inputs_[1]; }
581 LOperand* length() { return inputs_[2]; }
582 LOperand* elements() { return inputs_[3]; }
584 DECLARE_CONCRETE_INSTRUCTION(ApplyArguments, "apply-arguments")
588 class LAccessArgumentsAt final : public LTemplateInstruction<1, 3, 0> {
590 LAccessArgumentsAt(LOperand* arguments, LOperand* length, LOperand* index) {
591 inputs_[0] = arguments;
596 LOperand* arguments() { return inputs_[0]; }
597 LOperand* length() { return inputs_[1]; }
598 LOperand* index() { return inputs_[2]; }
600 DECLARE_CONCRETE_INSTRUCTION(AccessArgumentsAt, "access-arguments-at")
602 void PrintDataTo(StringStream* stream) override;
606 class LArgumentsLength final : public LTemplateInstruction<1, 1, 0> {
608 explicit LArgumentsLength(LOperand* elements) {
609 inputs_[0] = elements;
612 LOperand* elements() { return inputs_[0]; }
614 DECLARE_CONCRETE_INSTRUCTION(ArgumentsLength, "arguments-length")
618 class LArgumentsElements final : public LTemplateInstruction<1, 0, 0> {
620 DECLARE_CONCRETE_INSTRUCTION(ArgumentsElements, "arguments-elements")
621 DECLARE_HYDROGEN_ACCESSOR(ArgumentsElements)
625 class LModByPowerOf2I final : public LTemplateInstruction<1, 1, 0> {
627 LModByPowerOf2I(LOperand* dividend, int32_t divisor) {
628 inputs_[0] = dividend;
632 LOperand* dividend() { return inputs_[0]; }
633 int32_t divisor() const { return divisor_; }
635 DECLARE_CONCRETE_INSTRUCTION(ModByPowerOf2I, "mod-by-power-of-2-i")
636 DECLARE_HYDROGEN_ACCESSOR(Mod)
643 class LModByConstI final : public LTemplateInstruction<1, 1, 2> {
645 LModByConstI(LOperand* dividend,
649 inputs_[0] = dividend;
655 LOperand* dividend() { return inputs_[0]; }
656 int32_t divisor() const { return divisor_; }
657 LOperand* temp1() { return temps_[0]; }
658 LOperand* temp2() { return temps_[1]; }
660 DECLARE_CONCRETE_INSTRUCTION(ModByConstI, "mod-by-const-i")
661 DECLARE_HYDROGEN_ACCESSOR(Mod)
668 class LModI final : public LTemplateInstruction<1, 2, 1> {
670 LModI(LOperand* left, LOperand* right, LOperand* temp) {
676 LOperand* left() { return inputs_[0]; }
677 LOperand* right() { return inputs_[1]; }
678 LOperand* temp() { return temps_[0]; }
680 DECLARE_CONCRETE_INSTRUCTION(ModI, "mod-i")
681 DECLARE_HYDROGEN_ACCESSOR(Mod)
685 class LDivByPowerOf2I final : public LTemplateInstruction<1, 1, 0> {
687 LDivByPowerOf2I(LOperand* dividend, int32_t divisor) {
688 inputs_[0] = dividend;
692 LOperand* dividend() { return inputs_[0]; }
693 int32_t divisor() const { return divisor_; }
695 DECLARE_CONCRETE_INSTRUCTION(DivByPowerOf2I, "div-by-power-of-2-i")
696 DECLARE_HYDROGEN_ACCESSOR(Div)
703 class LDivByConstI final : public LTemplateInstruction<1, 1, 2> {
705 LDivByConstI(LOperand* dividend,
709 inputs_[0] = dividend;
715 LOperand* dividend() { return inputs_[0]; }
716 int32_t divisor() const { return divisor_; }
717 LOperand* temp1() { return temps_[0]; }
718 LOperand* temp2() { return temps_[1]; }
720 DECLARE_CONCRETE_INSTRUCTION(DivByConstI, "div-by-const-i")
721 DECLARE_HYDROGEN_ACCESSOR(Div)
728 class LDivI final : public LTemplateInstruction<1, 2, 1> {
730 LDivI(LOperand* dividend, LOperand* divisor, LOperand* temp) {
731 inputs_[0] = dividend;
732 inputs_[1] = divisor;
736 LOperand* dividend() { return inputs_[0]; }
737 LOperand* divisor() { return inputs_[1]; }
738 LOperand* temp() { return temps_[0]; }
740 DECLARE_CONCRETE_INSTRUCTION(DivI, "div-i")
741 DECLARE_HYDROGEN_ACCESSOR(BinaryOperation)
745 class LFlooringDivByPowerOf2I final : public LTemplateInstruction<1, 1, 0> {
747 LFlooringDivByPowerOf2I(LOperand* dividend, int32_t divisor) {
748 inputs_[0] = dividend;
752 LOperand* dividend() { return inputs_[0]; }
753 int32_t divisor() const { return divisor_; }
755 DECLARE_CONCRETE_INSTRUCTION(FlooringDivByPowerOf2I,
756 "flooring-div-by-power-of-2-i")
757 DECLARE_HYDROGEN_ACCESSOR(MathFloorOfDiv)
764 class LFlooringDivByConstI final : public LTemplateInstruction<1, 1, 3> {
766 LFlooringDivByConstI(LOperand* dividend,
771 inputs_[0] = dividend;
778 LOperand* dividend() { return inputs_[0]; }
779 int32_t divisor() const { return divisor_; }
780 LOperand* temp1() { return temps_[0]; }
781 LOperand* temp2() { return temps_[1]; }
782 LOperand* temp3() { return temps_[2]; }
784 DECLARE_CONCRETE_INSTRUCTION(FlooringDivByConstI, "flooring-div-by-const-i")
785 DECLARE_HYDROGEN_ACCESSOR(MathFloorOfDiv)
792 class LFlooringDivI final : public LTemplateInstruction<1, 2, 1> {
794 LFlooringDivI(LOperand* dividend, LOperand* divisor, LOperand* temp) {
795 inputs_[0] = dividend;
796 inputs_[1] = divisor;
800 LOperand* dividend() { return inputs_[0]; }
801 LOperand* divisor() { return inputs_[1]; }
802 LOperand* temp() { return temps_[0]; }
804 DECLARE_CONCRETE_INSTRUCTION(FlooringDivI, "flooring-div-i")
805 DECLARE_HYDROGEN_ACCESSOR(MathFloorOfDiv)
809 class LMulI final : public LTemplateInstruction<1, 2, 0> {
811 LMulI(LOperand* left, LOperand* right) {
816 LOperand* left() { return inputs_[0]; }
817 LOperand* right() { return inputs_[1]; }
819 DECLARE_CONCRETE_INSTRUCTION(MulI, "mul-i")
820 DECLARE_HYDROGEN_ACCESSOR(Mul)
824 class LCompareNumericAndBranch final : public LControlInstruction<2, 0> {
826 LCompareNumericAndBranch(LOperand* left, LOperand* right) {
831 LOperand* left() { return inputs_[0]; }
832 LOperand* right() { return inputs_[1]; }
834 DECLARE_CONCRETE_INSTRUCTION(CompareNumericAndBranch,
835 "compare-numeric-and-branch")
836 DECLARE_HYDROGEN_ACCESSOR(CompareNumericAndBranch)
838 Token::Value op() const { return hydrogen()->token(); }
839 bool is_double() const {
840 return hydrogen()->representation().IsDouble();
843 void PrintDataTo(StringStream* stream) override;
847 class LMathFloor final : public LTemplateInstruction<1, 1, 0> {
849 explicit LMathFloor(LOperand* value) {
853 LOperand* value() { return inputs_[0]; }
855 DECLARE_CONCRETE_INSTRUCTION(MathFloor, "math-floor")
856 DECLARE_HYDROGEN_ACCESSOR(UnaryMathOperation)
860 class LMathRound final : public LTemplateInstruction<1, 1, 1> {
862 LMathRound(LOperand* value, LOperand* temp) {
867 LOperand* value() { return inputs_[0]; }
868 LOperand* temp() { return temps_[0]; }
870 DECLARE_CONCRETE_INSTRUCTION(MathRound, "math-round")
871 DECLARE_HYDROGEN_ACCESSOR(UnaryMathOperation)
875 class LMathFround final : public LTemplateInstruction<1, 1, 0> {
877 explicit LMathFround(LOperand* value) { inputs_[0] = value; }
879 LOperand* value() { return inputs_[0]; }
881 DECLARE_CONCRETE_INSTRUCTION(MathFround, "math-fround")
885 class LMathAbs final : public LTemplateInstruction<1, 2, 0> {
887 explicit LMathAbs(LOperand* context, LOperand* value) {
888 inputs_[1] = context;
892 LOperand* context() { return inputs_[1]; }
893 LOperand* value() { return inputs_[0]; }
895 DECLARE_CONCRETE_INSTRUCTION(MathAbs, "math-abs")
896 DECLARE_HYDROGEN_ACCESSOR(UnaryMathOperation)
900 class LMathLog final : public LTemplateInstruction<1, 1, 0> {
902 explicit LMathLog(LOperand* value) {
906 LOperand* value() { return inputs_[0]; }
908 DECLARE_CONCRETE_INSTRUCTION(MathLog, "math-log")
912 class LMathClz32 final : public LTemplateInstruction<1, 1, 0> {
914 explicit LMathClz32(LOperand* value) {
918 LOperand* value() { return inputs_[0]; }
920 DECLARE_CONCRETE_INSTRUCTION(MathClz32, "math-clz32")
924 class LMathExp final : public LTemplateInstruction<1, 1, 2> {
926 LMathExp(LOperand* value, LOperand* temp1, LOperand* temp2) {
930 ExternalReference::InitializeMathExpData();
933 LOperand* value() { return inputs_[0]; }
934 LOperand* temp1() { return temps_[0]; }
935 LOperand* temp2() { return temps_[1]; }
937 DECLARE_CONCRETE_INSTRUCTION(MathExp, "math-exp")
941 class LMathSqrt final : public LTemplateInstruction<1, 1, 0> {
943 explicit LMathSqrt(LOperand* value) {
947 LOperand* value() { return inputs_[0]; }
949 DECLARE_CONCRETE_INSTRUCTION(MathSqrt, "math-sqrt")
953 class LMathPowHalf final : public LTemplateInstruction<1, 1, 0> {
955 explicit LMathPowHalf(LOperand* value) {
959 LOperand* value() { return inputs_[0]; }
961 DECLARE_CONCRETE_INSTRUCTION(MathPowHalf, "math-pow-half")
965 class LCmpObjectEqAndBranch final : public LControlInstruction<2, 0> {
967 LCmpObjectEqAndBranch(LOperand* left, LOperand* right) {
972 LOperand* left() { return inputs_[0]; }
973 LOperand* right() { return inputs_[1]; }
975 DECLARE_CONCRETE_INSTRUCTION(CmpObjectEqAndBranch, "cmp-object-eq-and-branch")
979 class LCmpHoleAndBranch final : public LControlInstruction<1, 0> {
981 explicit LCmpHoleAndBranch(LOperand* object) {
985 LOperand* object() { return inputs_[0]; }
987 DECLARE_CONCRETE_INSTRUCTION(CmpHoleAndBranch, "cmp-hole-and-branch")
988 DECLARE_HYDROGEN_ACCESSOR(CompareHoleAndBranch)
992 class LCompareMinusZeroAndBranch final : public LControlInstruction<1, 0> {
994 explicit LCompareMinusZeroAndBranch(LOperand* value) {
998 LOperand* value() { return inputs_[0]; }
1000 DECLARE_CONCRETE_INSTRUCTION(CompareMinusZeroAndBranch,
1001 "cmp-minus-zero-and-branch")
1002 DECLARE_HYDROGEN_ACCESSOR(CompareMinusZeroAndBranch)
1006 class LIsObjectAndBranch final : public LControlInstruction<1, 0> {
1008 explicit LIsObjectAndBranch(LOperand* value) {
1012 LOperand* value() { return inputs_[0]; }
1014 DECLARE_CONCRETE_INSTRUCTION(IsObjectAndBranch, "is-object-and-branch")
1015 DECLARE_HYDROGEN_ACCESSOR(IsObjectAndBranch)
1017 void PrintDataTo(StringStream* stream) override;
1021 class LIsStringAndBranch final : public LControlInstruction<1, 1> {
1023 explicit LIsStringAndBranch(LOperand* value, LOperand* temp) {
1028 LOperand* value() { return inputs_[0]; }
1029 LOperand* temp() { return temps_[0]; }
1031 DECLARE_CONCRETE_INSTRUCTION(IsStringAndBranch, "is-string-and-branch")
1032 DECLARE_HYDROGEN_ACCESSOR(IsStringAndBranch)
1034 void PrintDataTo(StringStream* stream) override;
1038 class LIsSmiAndBranch final : public LControlInstruction<1, 0> {
1040 explicit LIsSmiAndBranch(LOperand* value) {
1044 LOperand* value() { return inputs_[0]; }
1046 DECLARE_CONCRETE_INSTRUCTION(IsSmiAndBranch, "is-smi-and-branch")
1047 DECLARE_HYDROGEN_ACCESSOR(IsSmiAndBranch)
1049 void PrintDataTo(StringStream* stream) override;
1053 class LIsUndetectableAndBranch final : public LControlInstruction<1, 1> {
1055 explicit LIsUndetectableAndBranch(LOperand* value, LOperand* temp) {
1060 LOperand* value() { return inputs_[0]; }
1061 LOperand* temp() { return temps_[0]; }
1063 DECLARE_CONCRETE_INSTRUCTION(IsUndetectableAndBranch,
1064 "is-undetectable-and-branch")
1065 DECLARE_HYDROGEN_ACCESSOR(IsUndetectableAndBranch)
1067 void PrintDataTo(StringStream* stream) override;
1071 class LStringCompareAndBranch final : public LControlInstruction<3, 0> {
1073 explicit LStringCompareAndBranch(LOperand* context,
1076 inputs_[0] = context;
1081 LOperand* context() { return inputs_[0]; }
1082 LOperand* left() { return inputs_[1]; }
1083 LOperand* right() { return inputs_[2]; }
1085 DECLARE_CONCRETE_INSTRUCTION(StringCompareAndBranch,
1086 "string-compare-and-branch")
1087 DECLARE_HYDROGEN_ACCESSOR(StringCompareAndBranch)
1089 void PrintDataTo(StringStream* stream) override;
1091 Token::Value op() const { return hydrogen()->token(); }
1095 class LHasInstanceTypeAndBranch final : public LControlInstruction<1, 0> {
1097 explicit LHasInstanceTypeAndBranch(LOperand* value) {
1101 LOperand* value() { return inputs_[0]; }
1103 DECLARE_CONCRETE_INSTRUCTION(HasInstanceTypeAndBranch,
1104 "has-instance-type-and-branch")
1105 DECLARE_HYDROGEN_ACCESSOR(HasInstanceTypeAndBranch)
1107 void PrintDataTo(StringStream* stream) override;
1111 class LGetCachedArrayIndex final : public LTemplateInstruction<1, 1, 0> {
1113 explicit LGetCachedArrayIndex(LOperand* value) {
1117 LOperand* value() { return inputs_[0]; }
1119 DECLARE_CONCRETE_INSTRUCTION(GetCachedArrayIndex, "get-cached-array-index")
1120 DECLARE_HYDROGEN_ACCESSOR(GetCachedArrayIndex)
1124 class LHasCachedArrayIndexAndBranch final : public LControlInstruction<1, 0> {
1126 explicit LHasCachedArrayIndexAndBranch(LOperand* value) {
1130 LOperand* value() { return inputs_[0]; }
1132 DECLARE_CONCRETE_INSTRUCTION(HasCachedArrayIndexAndBranch,
1133 "has-cached-array-index-and-branch")
1134 DECLARE_HYDROGEN_ACCESSOR(HasCachedArrayIndexAndBranch)
1136 void PrintDataTo(StringStream* stream) override;
1140 class LClassOfTestAndBranch final : public LControlInstruction<1, 2> {
1142 LClassOfTestAndBranch(LOperand* value, LOperand* temp, LOperand* temp2) {
1148 LOperand* value() { return inputs_[0]; }
1149 LOperand* temp() { return temps_[0]; }
1150 LOperand* temp2() { return temps_[1]; }
1152 DECLARE_CONCRETE_INSTRUCTION(ClassOfTestAndBranch,
1153 "class-of-test-and-branch")
1154 DECLARE_HYDROGEN_ACCESSOR(ClassOfTestAndBranch)
1156 void PrintDataTo(StringStream* stream) override;
1160 class LCmpT final : public LTemplateInstruction<1, 3, 0> {
1162 LCmpT(LOperand* context, LOperand* left, LOperand* right) {
1163 inputs_[0] = context;
1168 LOperand* context() { return inputs_[0]; }
1169 LOperand* left() { return inputs_[1]; }
1170 LOperand* right() { return inputs_[2]; }
1172 DECLARE_CONCRETE_INSTRUCTION(CmpT, "cmp-t")
1173 DECLARE_HYDROGEN_ACCESSOR(CompareGeneric)
1175 Token::Value op() const { return hydrogen()->token(); }
1179 class LInstanceOf final : public LTemplateInstruction<1, 3, 0> {
1181 LInstanceOf(LOperand* context, LOperand* left, LOperand* right) {
1182 inputs_[0] = context;
1187 LOperand* context() { return inputs_[0]; }
1188 LOperand* left() { return inputs_[1]; }
1189 LOperand* right() { return inputs_[2]; }
1191 DECLARE_CONCRETE_INSTRUCTION(InstanceOf, "instance-of")
1195 class LInstanceOfKnownGlobal final : public LTemplateInstruction<1, 2, 1> {
1197 LInstanceOfKnownGlobal(LOperand* context, LOperand* value, LOperand* temp) {
1198 inputs_[0] = context;
1203 LOperand* context() { return inputs_[0]; }
1204 LOperand* value() { return inputs_[1]; }
1205 LOperand* temp() { return temps_[0]; }
1207 DECLARE_CONCRETE_INSTRUCTION(InstanceOfKnownGlobal,
1208 "instance-of-known-global")
1209 DECLARE_HYDROGEN_ACCESSOR(InstanceOfKnownGlobal)
1211 Handle<JSFunction> function() const { return hydrogen()->function(); }
1212 LEnvironment* GetDeferredLazyDeoptimizationEnvironment() {
1213 return lazy_deopt_env_;
1215 virtual void SetDeferredLazyDeoptimizationEnvironment(
1216 LEnvironment* env) override {
1217 lazy_deopt_env_ = env;
1221 LEnvironment* lazy_deopt_env_;
1225 class LBoundsCheck final : public LTemplateInstruction<0, 2, 0> {
1227 LBoundsCheck(LOperand* index, LOperand* length) {
1229 inputs_[1] = length;
1232 LOperand* index() { return inputs_[0]; }
1233 LOperand* length() { return inputs_[1]; }
1235 DECLARE_CONCRETE_INSTRUCTION(BoundsCheck, "bounds-check")
1236 DECLARE_HYDROGEN_ACCESSOR(BoundsCheck)
1240 class LBitI final : public LTemplateInstruction<1, 2, 0> {
1242 LBitI(LOperand* left, LOperand* right) {
1247 LOperand* left() { return inputs_[0]; }
1248 LOperand* right() { return inputs_[1]; }
1250 Token::Value op() const { return hydrogen()->op(); }
1251 bool IsInteger32() const {
1252 return hydrogen()->representation().IsInteger32();
1255 DECLARE_CONCRETE_INSTRUCTION(BitI, "bit-i")
1256 DECLARE_HYDROGEN_ACCESSOR(Bitwise)
1260 class LShiftI final : public LTemplateInstruction<1, 2, 0> {
1262 LShiftI(Token::Value op, LOperand* left, LOperand* right, bool can_deopt)
1263 : op_(op), can_deopt_(can_deopt) {
1268 Token::Value op() const { return op_; }
1269 LOperand* left() { return inputs_[0]; }
1270 LOperand* right() { return inputs_[1]; }
1271 bool can_deopt() const { return can_deopt_; }
1273 DECLARE_CONCRETE_INSTRUCTION(ShiftI, "shift-i")
1281 class LSubI final : public LTemplateInstruction<1, 2, 0> {
1283 LSubI(LOperand* left, LOperand* right) {
1288 LOperand* left() { return inputs_[0]; }
1289 LOperand* right() { return inputs_[1]; }
1291 DECLARE_CONCRETE_INSTRUCTION(SubI, "sub-i")
1292 DECLARE_HYDROGEN_ACCESSOR(Sub)
1296 class LConstantI final : public LTemplateInstruction<1, 0, 0> {
1298 DECLARE_CONCRETE_INSTRUCTION(ConstantI, "constant-i")
1299 DECLARE_HYDROGEN_ACCESSOR(Constant)
1301 int32_t value() const { return hydrogen()->Integer32Value(); }
1305 class LConstantS final : public LTemplateInstruction<1, 0, 0> {
1307 DECLARE_CONCRETE_INSTRUCTION(ConstantS, "constant-s")
1308 DECLARE_HYDROGEN_ACCESSOR(Constant)
1310 Smi* value() const { return Smi::FromInt(hydrogen()->Integer32Value()); }
1314 class LConstantD final : public LTemplateInstruction<1, 0, 0> {
1316 DECLARE_CONCRETE_INSTRUCTION(ConstantD, "constant-d")
1317 DECLARE_HYDROGEN_ACCESSOR(Constant)
1319 uint64_t bits() const { return hydrogen()->DoubleValueAsBits(); }
1323 class LConstantE final : public LTemplateInstruction<1, 0, 0> {
1325 DECLARE_CONCRETE_INSTRUCTION(ConstantE, "constant-e")
1326 DECLARE_HYDROGEN_ACCESSOR(Constant)
1328 ExternalReference value() const {
1329 return hydrogen()->ExternalReferenceValue();
1334 class LConstantT final : public LTemplateInstruction<1, 0, 0> {
1336 DECLARE_CONCRETE_INSTRUCTION(ConstantT, "constant-t")
1337 DECLARE_HYDROGEN_ACCESSOR(Constant)
1339 Handle<Object> value(Isolate* isolate) const {
1340 return hydrogen()->handle(isolate);
1345 class LBranch final : public LControlInstruction<1, 0> {
1347 explicit LBranch(LOperand* value) {
1351 LOperand* value() { return inputs_[0]; }
1353 DECLARE_CONCRETE_INSTRUCTION(Branch, "branch")
1354 DECLARE_HYDROGEN_ACCESSOR(Branch)
1356 void PrintDataTo(StringStream* stream) override;
1360 class LDebugBreak final : public LTemplateInstruction<0, 0, 0> {
1362 DECLARE_CONCRETE_INSTRUCTION(DebugBreak, "break")
1366 class LCmpMapAndBranch final : public LControlInstruction<1, 0> {
1368 explicit LCmpMapAndBranch(LOperand* value) {
1372 LOperand* value() { return inputs_[0]; }
1374 DECLARE_CONCRETE_INSTRUCTION(CmpMapAndBranch, "cmp-map-and-branch")
1375 DECLARE_HYDROGEN_ACCESSOR(CompareMap)
1377 Handle<Map> map() const { return hydrogen()->map().handle(); }
1381 class LMapEnumLength final : public LTemplateInstruction<1, 1, 0> {
1383 explicit LMapEnumLength(LOperand* value) {
1387 LOperand* value() { return inputs_[0]; }
1389 DECLARE_CONCRETE_INSTRUCTION(MapEnumLength, "map-enum-length")
1393 class LDateField final : public LTemplateInstruction<1, 1, 0> {
1395 LDateField(LOperand* date, Smi* index) : index_(index) {
1399 LOperand* date() { return inputs_[0]; }
1400 Smi* index() const { return index_; }
1402 DECLARE_CONCRETE_INSTRUCTION(DateField, "date-field")
1403 DECLARE_HYDROGEN_ACCESSOR(DateField)
1410 class LSeqStringGetChar final : public LTemplateInstruction<1, 2, 0> {
1412 LSeqStringGetChar(LOperand* string, LOperand* index) {
1413 inputs_[0] = string;
1417 LOperand* string() const { return inputs_[0]; }
1418 LOperand* index() const { return inputs_[1]; }
1420 DECLARE_CONCRETE_INSTRUCTION(SeqStringGetChar, "seq-string-get-char")
1421 DECLARE_HYDROGEN_ACCESSOR(SeqStringGetChar)
1425 class LSeqStringSetChar final : public LTemplateInstruction<1, 4, 0> {
1427 LSeqStringSetChar(LOperand* context,
1431 inputs_[0] = context;
1432 inputs_[1] = string;
1437 LOperand* string() { return inputs_[1]; }
1438 LOperand* index() { return inputs_[2]; }
1439 LOperand* value() { return inputs_[3]; }
1441 DECLARE_CONCRETE_INSTRUCTION(SeqStringSetChar, "seq-string-set-char")
1442 DECLARE_HYDROGEN_ACCESSOR(SeqStringSetChar)
1446 class LAddI final : public LTemplateInstruction<1, 2, 0> {
1448 LAddI(LOperand* left, LOperand* right) {
1453 LOperand* left() { return inputs_[0]; }
1454 LOperand* right() { return inputs_[1]; }
1456 static bool UseLea(HAdd* add) {
1457 return !add->CheckFlag(HValue::kCanOverflow) &&
1458 add->BetterLeftOperand()->UseCount() > 1;
1461 DECLARE_CONCRETE_INSTRUCTION(AddI, "add-i")
1462 DECLARE_HYDROGEN_ACCESSOR(Add)
1466 class LMathMinMax final : public LTemplateInstruction<1, 2, 0> {
1468 LMathMinMax(LOperand* left, LOperand* right) {
1473 LOperand* left() { return inputs_[0]; }
1474 LOperand* right() { return inputs_[1]; }
1476 DECLARE_CONCRETE_INSTRUCTION(MathMinMax, "math-min-max")
1477 DECLARE_HYDROGEN_ACCESSOR(MathMinMax)
1481 class LPower final : public LTemplateInstruction<1, 2, 0> {
1483 LPower(LOperand* left, LOperand* right) {
1488 LOperand* left() { return inputs_[0]; }
1489 LOperand* right() { return inputs_[1]; }
1491 DECLARE_CONCRETE_INSTRUCTION(Power, "power")
1492 DECLARE_HYDROGEN_ACCESSOR(Power)
1496 class LArithmeticD final : public LTemplateInstruction<1, 2, 0> {
1498 LArithmeticD(Token::Value op, LOperand* left, LOperand* right)
1504 Token::Value op() const { return op_; }
1505 LOperand* left() { return inputs_[0]; }
1506 LOperand* right() { return inputs_[1]; }
1508 Opcode opcode() const override { return LInstruction::kArithmeticD; }
1509 void CompileToNative(LCodeGen* generator) override;
1510 const char* Mnemonic() const override;
1517 class LArithmeticT final : public LTemplateInstruction<1, 3, 0> {
1519 LArithmeticT(Token::Value op,
1524 inputs_[0] = context;
1529 Token::Value op() const { return op_; }
1530 LOperand* context() { return inputs_[0]; }
1531 LOperand* left() { return inputs_[1]; }
1532 LOperand* right() { return inputs_[2]; }
1534 Opcode opcode() const override { return LInstruction::kArithmeticT; }
1535 void CompileToNative(LCodeGen* generator) override;
1536 const char* Mnemonic() const override;
1543 class LReturn final : public LTemplateInstruction<0, 3, 0> {
1545 explicit LReturn(LOperand* value,
1547 LOperand* parameter_count) {
1549 inputs_[1] = context;
1550 inputs_[2] = parameter_count;
1553 LOperand* value() { return inputs_[0]; }
1554 LOperand* context() { return inputs_[1]; }
1556 bool has_constant_parameter_count() {
1557 return parameter_count()->IsConstantOperand();
1559 LConstantOperand* constant_parameter_count() {
1560 DCHECK(has_constant_parameter_count());
1561 return LConstantOperand::cast(parameter_count());
1563 LOperand* parameter_count() { return inputs_[2]; }
1565 DECLARE_CONCRETE_INSTRUCTION(Return, "return")
1566 DECLARE_HYDROGEN_ACCESSOR(Return)
1570 class LLoadNamedField final : public LTemplateInstruction<1, 1, 0> {
1572 explicit LLoadNamedField(LOperand* object) {
1573 inputs_[0] = object;
1576 LOperand* object() { return inputs_[0]; }
1578 DECLARE_CONCRETE_INSTRUCTION(LoadNamedField, "load-named-field")
1579 DECLARE_HYDROGEN_ACCESSOR(LoadNamedField)
1583 class LLoadNamedGeneric final : public LTemplateInstruction<1, 2, 1> {
1585 explicit LLoadNamedGeneric(LOperand* context, LOperand* object,
1587 inputs_[0] = context;
1588 inputs_[1] = object;
1592 DECLARE_CONCRETE_INSTRUCTION(LoadNamedGeneric, "load-named-generic")
1593 DECLARE_HYDROGEN_ACCESSOR(LoadNamedGeneric)
1595 LOperand* context() { return inputs_[0]; }
1596 LOperand* object() { return inputs_[1]; }
1597 LOperand* temp_vector() { return temps_[0]; }
1599 Handle<Object> name() const { return hydrogen()->name(); }
1603 class LLoadFunctionPrototype final : public LTemplateInstruction<1, 1, 0> {
1605 explicit LLoadFunctionPrototype(LOperand* function) {
1606 inputs_[0] = function;
1609 DECLARE_CONCRETE_INSTRUCTION(LoadFunctionPrototype, "load-function-prototype")
1610 DECLARE_HYDROGEN_ACCESSOR(LoadFunctionPrototype)
1612 LOperand* function() { return inputs_[0]; }
1616 class LLoadRoot final : public LTemplateInstruction<1, 0, 0> {
1618 DECLARE_CONCRETE_INSTRUCTION(LoadRoot, "load-root")
1619 DECLARE_HYDROGEN_ACCESSOR(LoadRoot)
1621 Heap::RootListIndex index() const { return hydrogen()->index(); }
1625 inline static bool ExternalArrayOpRequiresTemp(
1626 Representation key_representation,
1627 ElementsKind elements_kind) {
1628 // Operations that require the key to be divided by two to be converted into
1629 // an index cannot fold the scale operation into a load and need an extra
1630 // temp register to do the work.
1631 return SmiValuesAre31Bits() && key_representation.IsSmi() &&
1632 (elements_kind == EXTERNAL_INT8_ELEMENTS ||
1633 elements_kind == EXTERNAL_UINT8_ELEMENTS ||
1634 elements_kind == EXTERNAL_UINT8_CLAMPED_ELEMENTS ||
1635 elements_kind == UINT8_ELEMENTS ||
1636 elements_kind == INT8_ELEMENTS ||
1637 elements_kind == UINT8_CLAMPED_ELEMENTS);
1641 class LLoadKeyed final : public LTemplateInstruction<1, 2, 0> {
1643 LLoadKeyed(LOperand* elements, LOperand* key) {
1644 inputs_[0] = elements;
1648 DECLARE_CONCRETE_INSTRUCTION(LoadKeyed, "load-keyed")
1649 DECLARE_HYDROGEN_ACCESSOR(LoadKeyed)
1651 bool is_external() const {
1652 return hydrogen()->is_external();
1654 bool is_fixed_typed_array() const {
1655 return hydrogen()->is_fixed_typed_array();
1657 bool is_typed_elements() const {
1658 return is_external() || is_fixed_typed_array();
1660 LOperand* elements() { return inputs_[0]; }
1661 LOperand* key() { return inputs_[1]; }
1662 void PrintDataTo(StringStream* stream) override;
1663 uint32_t base_offset() const { return hydrogen()->base_offset(); }
1664 ElementsKind elements_kind() const {
1665 return hydrogen()->elements_kind();
1670 class LLoadKeyedGeneric final : public LTemplateInstruction<1, 3, 1> {
1672 LLoadKeyedGeneric(LOperand* context, LOperand* obj, LOperand* key,
1674 inputs_[0] = context;
1680 DECLARE_CONCRETE_INSTRUCTION(LoadKeyedGeneric, "load-keyed-generic")
1681 DECLARE_HYDROGEN_ACCESSOR(LoadKeyedGeneric)
1683 LOperand* context() { return inputs_[0]; }
1684 LOperand* object() { return inputs_[1]; }
1685 LOperand* key() { return inputs_[2]; }
1686 LOperand* temp_vector() { return temps_[0]; }
1690 class LLoadGlobalGeneric final : public LTemplateInstruction<1, 2, 1> {
1692 explicit LLoadGlobalGeneric(LOperand* context, LOperand* global_object,
1694 inputs_[0] = context;
1695 inputs_[1] = global_object;
1699 DECLARE_CONCRETE_INSTRUCTION(LoadGlobalGeneric, "load-global-generic")
1700 DECLARE_HYDROGEN_ACCESSOR(LoadGlobalGeneric)
1702 LOperand* context() { return inputs_[0]; }
1703 LOperand* global_object() { return inputs_[1]; }
1704 LOperand* temp_vector() { return temps_[0]; }
1706 Handle<Object> name() const { return hydrogen()->name(); }
1707 bool for_typeof() const { return hydrogen()->for_typeof(); }
1711 class LLoadContextSlot final : public LTemplateInstruction<1, 1, 0> {
1713 explicit LLoadContextSlot(LOperand* context) {
1714 inputs_[0] = context;
1717 LOperand* context() { return inputs_[0]; }
1719 DECLARE_CONCRETE_INSTRUCTION(LoadContextSlot, "load-context-slot")
1720 DECLARE_HYDROGEN_ACCESSOR(LoadContextSlot)
1722 int slot_index() { return hydrogen()->slot_index(); }
1724 void PrintDataTo(StringStream* stream) override;
1728 class LStoreContextSlot final : public LTemplateInstruction<0, 2, 1> {
1730 LStoreContextSlot(LOperand* context, LOperand* value, LOperand* temp) {
1731 inputs_[0] = context;
1736 LOperand* context() { return inputs_[0]; }
1737 LOperand* value() { return inputs_[1]; }
1738 LOperand* temp() { return temps_[0]; }
1740 DECLARE_CONCRETE_INSTRUCTION(StoreContextSlot, "store-context-slot")
1741 DECLARE_HYDROGEN_ACCESSOR(StoreContextSlot)
1743 int slot_index() { return hydrogen()->slot_index(); }
1745 void PrintDataTo(StringStream* stream) override;
1749 class LPushArgument final : public LTemplateInstruction<0, 1, 0> {
1751 explicit LPushArgument(LOperand* value) {
1755 LOperand* value() { return inputs_[0]; }
1757 DECLARE_CONCRETE_INSTRUCTION(PushArgument, "push-argument")
1761 class LDrop final : public LTemplateInstruction<0, 0, 0> {
1763 explicit LDrop(int count) : count_(count) { }
1765 int count() const { return count_; }
1767 DECLARE_CONCRETE_INSTRUCTION(Drop, "drop")
1774 class LStoreCodeEntry final : public LTemplateInstruction<0, 2, 0> {
1776 LStoreCodeEntry(LOperand* function, LOperand* code_object) {
1777 inputs_[0] = function;
1778 inputs_[1] = code_object;
1781 LOperand* function() { return inputs_[0]; }
1782 LOperand* code_object() { return inputs_[1]; }
1784 void PrintDataTo(StringStream* stream) override;
1786 DECLARE_CONCRETE_INSTRUCTION(StoreCodeEntry, "store-code-entry")
1787 DECLARE_HYDROGEN_ACCESSOR(StoreCodeEntry)
1791 class LInnerAllocatedObject final : public LTemplateInstruction<1, 2, 0> {
1793 LInnerAllocatedObject(LOperand* base_object, LOperand* offset) {
1794 inputs_[0] = base_object;
1795 inputs_[1] = offset;
1798 LOperand* base_object() const { return inputs_[0]; }
1799 LOperand* offset() const { return inputs_[1]; }
1801 void PrintDataTo(StringStream* stream) override;
1803 DECLARE_CONCRETE_INSTRUCTION(InnerAllocatedObject, "inner-allocated-object")
1807 class LThisFunction final : public LTemplateInstruction<1, 0, 0> {
1809 DECLARE_CONCRETE_INSTRUCTION(ThisFunction, "this-function")
1810 DECLARE_HYDROGEN_ACCESSOR(ThisFunction)
1814 class LContext final : public LTemplateInstruction<1, 0, 0> {
1816 DECLARE_CONCRETE_INSTRUCTION(Context, "context")
1817 DECLARE_HYDROGEN_ACCESSOR(Context)
1821 class LDeclareGlobals final : public LTemplateInstruction<0, 1, 0> {
1823 explicit LDeclareGlobals(LOperand* context) {
1824 inputs_[0] = context;
1827 LOperand* context() { return inputs_[0]; }
1829 DECLARE_CONCRETE_INSTRUCTION(DeclareGlobals, "declare-globals")
1830 DECLARE_HYDROGEN_ACCESSOR(DeclareGlobals)
1834 class LCallJSFunction final : public LTemplateInstruction<1, 1, 0> {
1836 explicit LCallJSFunction(LOperand* function) {
1837 inputs_[0] = function;
1840 LOperand* function() { return inputs_[0]; }
1842 DECLARE_CONCRETE_INSTRUCTION(CallJSFunction, "call-js-function")
1843 DECLARE_HYDROGEN_ACCESSOR(CallJSFunction)
1845 void PrintDataTo(StringStream* stream) override;
1847 int arity() const { return hydrogen()->argument_count() - 1; }
1851 class LCallWithDescriptor final : public LTemplateResultInstruction<1> {
1853 LCallWithDescriptor(CallInterfaceDescriptor descriptor,
1854 const ZoneList<LOperand*>& operands, Zone* zone)
1855 : inputs_(descriptor.GetRegisterParameterCount() + 1, zone) {
1856 DCHECK(descriptor.GetRegisterParameterCount() + 1 == operands.length());
1857 inputs_.AddAll(operands, zone);
1860 LOperand* target() const { return inputs_[0]; }
1862 DECLARE_HYDROGEN_ACCESSOR(CallWithDescriptor)
1865 DECLARE_CONCRETE_INSTRUCTION(CallWithDescriptor, "call-with-descriptor")
1867 void PrintDataTo(StringStream* stream) override;
1869 int arity() const { return hydrogen()->argument_count() - 1; }
1871 ZoneList<LOperand*> inputs_;
1873 // Iterator support.
1874 int InputCount() final { return inputs_.length(); }
1875 LOperand* InputAt(int i) final { return inputs_[i]; }
1877 int TempCount() final { return 0; }
1878 LOperand* TempAt(int i) final { return NULL; }
1882 class LInvokeFunction final : public LTemplateInstruction<1, 2, 0> {
1884 LInvokeFunction(LOperand* context, LOperand* function) {
1885 inputs_[0] = context;
1886 inputs_[1] = function;
1889 LOperand* context() { return inputs_[0]; }
1890 LOperand* function() { return inputs_[1]; }
1892 DECLARE_CONCRETE_INSTRUCTION(InvokeFunction, "invoke-function")
1893 DECLARE_HYDROGEN_ACCESSOR(InvokeFunction)
1895 void PrintDataTo(StringStream* stream) override;
1897 int arity() const { return hydrogen()->argument_count() - 1; }
1901 class LCallFunction final : public LTemplateInstruction<1, 2, 2> {
1903 LCallFunction(LOperand* context, LOperand* function, LOperand* slot,
1905 inputs_[0] = context;
1906 inputs_[1] = function;
1911 DECLARE_CONCRETE_INSTRUCTION(CallFunction, "call-function")
1912 DECLARE_HYDROGEN_ACCESSOR(CallFunction)
1914 LOperand* context() { return inputs_[0]; }
1915 LOperand* function() { return inputs_[1]; }
1916 LOperand* temp_slot() { return temps_[0]; }
1917 LOperand* temp_vector() { return temps_[1]; }
1918 int arity() const { return hydrogen()->argument_count() - 1; }
1920 void PrintDataTo(StringStream* stream) override;
1924 class LCallNew final : public LTemplateInstruction<1, 2, 0> {
1926 LCallNew(LOperand* context, LOperand* constructor) {
1927 inputs_[0] = context;
1928 inputs_[1] = constructor;
1931 LOperand* context() { return inputs_[0]; }
1932 LOperand* constructor() { return inputs_[1]; }
1934 DECLARE_CONCRETE_INSTRUCTION(CallNew, "call-new")
1935 DECLARE_HYDROGEN_ACCESSOR(CallNew)
1937 void PrintDataTo(StringStream* stream) override;
1939 int arity() const { return hydrogen()->argument_count() - 1; }
1943 class LCallNewArray final : public LTemplateInstruction<1, 2, 0> {
1945 LCallNewArray(LOperand* context, LOperand* constructor) {
1946 inputs_[0] = context;
1947 inputs_[1] = constructor;
1950 LOperand* context() { return inputs_[0]; }
1951 LOperand* constructor() { return inputs_[1]; }
1953 DECLARE_CONCRETE_INSTRUCTION(CallNewArray, "call-new-array")
1954 DECLARE_HYDROGEN_ACCESSOR(CallNewArray)
1956 void PrintDataTo(StringStream* stream) override;
1958 int arity() const { return hydrogen()->argument_count() - 1; }
1962 class LCallRuntime final : public LTemplateInstruction<1, 1, 0> {
1964 explicit LCallRuntime(LOperand* context) {
1965 inputs_[0] = context;
1968 LOperand* context() { return inputs_[0]; }
1970 DECLARE_CONCRETE_INSTRUCTION(CallRuntime, "call-runtime")
1971 DECLARE_HYDROGEN_ACCESSOR(CallRuntime)
1973 bool ClobbersDoubleRegisters(Isolate* isolate) const override {
1974 return save_doubles() == kDontSaveFPRegs;
1977 const Runtime::Function* function() const { return hydrogen()->function(); }
1978 int arity() const { return hydrogen()->argument_count(); }
1979 SaveFPRegsMode save_doubles() const { return hydrogen()->save_doubles(); }
1983 class LInteger32ToDouble final : public LTemplateInstruction<1, 1, 0> {
1985 explicit LInteger32ToDouble(LOperand* value) {
1989 LOperand* value() { return inputs_[0]; }
1991 DECLARE_CONCRETE_INSTRUCTION(Integer32ToDouble, "int32-to-double")
1995 class LUint32ToDouble final : public LTemplateInstruction<1, 1, 0> {
1997 explicit LUint32ToDouble(LOperand* value) {
2001 LOperand* value() { return inputs_[0]; }
2003 DECLARE_CONCRETE_INSTRUCTION(Uint32ToDouble, "uint32-to-double")
2007 class LNumberTagI final : public LTemplateInstruction<1, 1, 2> {
2009 LNumberTagI(LOperand* value, LOperand* temp1, LOperand* temp2) {
2015 LOperand* value() { return inputs_[0]; }
2016 LOperand* temp1() { return temps_[0]; }
2017 LOperand* temp2() { return temps_[1]; }
2019 DECLARE_CONCRETE_INSTRUCTION(NumberTagI, "number-tag-i")
2023 class LNumberTagU final : public LTemplateInstruction<1, 1, 2> {
2025 LNumberTagU(LOperand* value, LOperand* temp1, LOperand* temp2) {
2031 LOperand* value() { return inputs_[0]; }
2032 LOperand* temp1() { return temps_[0]; }
2033 LOperand* temp2() { return temps_[1]; }
2035 DECLARE_CONCRETE_INSTRUCTION(NumberTagU, "number-tag-u")
2039 class LNumberTagD final : public LTemplateInstruction<1, 1, 1> {
2041 explicit LNumberTagD(LOperand* value, LOperand* temp) {
2046 LOperand* value() { return inputs_[0]; }
2047 LOperand* temp() { return temps_[0]; }
2049 DECLARE_CONCRETE_INSTRUCTION(NumberTagD, "number-tag-d")
2050 DECLARE_HYDROGEN_ACCESSOR(Change)
2054 // Sometimes truncating conversion from a tagged value to an int32.
2055 class LDoubleToI final : public LTemplateInstruction<1, 1, 0> {
2057 explicit LDoubleToI(LOperand* value) {
2061 LOperand* value() { return inputs_[0]; }
2063 DECLARE_CONCRETE_INSTRUCTION(DoubleToI, "double-to-i")
2064 DECLARE_HYDROGEN_ACCESSOR(UnaryOperation)
2066 bool truncating() { return hydrogen()->CanTruncateToInt32(); }
2070 class LDoubleToSmi final : public LTemplateInstruction<1, 1, 0> {
2072 explicit LDoubleToSmi(LOperand* value) {
2076 LOperand* value() { return inputs_[0]; }
2078 DECLARE_CONCRETE_INSTRUCTION(DoubleToSmi, "double-to-smi")
2079 DECLARE_HYDROGEN_ACCESSOR(UnaryOperation)
2083 // Truncating conversion from a tagged value to an int32.
2084 class LTaggedToI final : public LTemplateInstruction<1, 1, 1> {
2086 LTaggedToI(LOperand* value, LOperand* temp) {
2091 LOperand* value() { return inputs_[0]; }
2092 LOperand* temp() { return temps_[0]; }
2094 DECLARE_CONCRETE_INSTRUCTION(TaggedToI, "tagged-to-i")
2095 DECLARE_HYDROGEN_ACCESSOR(Change)
2097 bool truncating() { return hydrogen()->CanTruncateToInt32(); }
2101 class LSmiTag final : public LTemplateInstruction<1, 1, 0> {
2103 explicit LSmiTag(LOperand* value) {
2107 LOperand* value() { return inputs_[0]; }
2109 DECLARE_CONCRETE_INSTRUCTION(SmiTag, "smi-tag")
2110 DECLARE_HYDROGEN_ACCESSOR(Change)
2114 class LNumberUntagD final : public LTemplateInstruction<1, 1, 0> {
2116 explicit LNumberUntagD(LOperand* value) {
2120 LOperand* value() { return inputs_[0]; }
2122 DECLARE_CONCRETE_INSTRUCTION(NumberUntagD, "double-untag")
2123 DECLARE_HYDROGEN_ACCESSOR(Change);
2127 class LSmiUntag final : public LTemplateInstruction<1, 1, 0> {
2129 LSmiUntag(LOperand* value, bool needs_check)
2130 : needs_check_(needs_check) {
2134 LOperand* value() { return inputs_[0]; }
2135 bool needs_check() const { return needs_check_; }
2137 DECLARE_CONCRETE_INSTRUCTION(SmiUntag, "smi-untag")
2144 class LStoreNamedField final : public LTemplateInstruction<0, 2, 1> {
2146 LStoreNamedField(LOperand* object, LOperand* value, LOperand* temp) {
2147 inputs_[0] = object;
2152 LOperand* object() { return inputs_[0]; }
2153 LOperand* value() { return inputs_[1]; }
2154 LOperand* temp() { return temps_[0]; }
2156 DECLARE_CONCRETE_INSTRUCTION(StoreNamedField, "store-named-field")
2157 DECLARE_HYDROGEN_ACCESSOR(StoreNamedField)
2159 void PrintDataTo(StringStream* stream) override;
2161 Representation representation() const {
2162 return hydrogen()->field_representation();
2167 class LStoreNamedGeneric final : public LTemplateInstruction<0, 3, 0> {
2169 LStoreNamedGeneric(LOperand* context, LOperand* object, LOperand* value) {
2170 inputs_[0] = context;
2171 inputs_[1] = object;
2175 LOperand* context() { return inputs_[0]; }
2176 LOperand* object() { return inputs_[1]; }
2177 LOperand* value() { return inputs_[2]; }
2179 DECLARE_CONCRETE_INSTRUCTION(StoreNamedGeneric, "store-named-generic")
2180 DECLARE_HYDROGEN_ACCESSOR(StoreNamedGeneric)
2182 void PrintDataTo(StringStream* stream) override;
2184 Handle<Object> name() const { return hydrogen()->name(); }
2185 LanguageMode language_mode() { return hydrogen()->language_mode(); }
2189 class LStoreKeyed final : public LTemplateInstruction<0, 3, 0> {
2191 LStoreKeyed(LOperand* object, LOperand* key, LOperand* value) {
2192 inputs_[0] = object;
2197 bool is_external() const { return hydrogen()->is_external(); }
2198 bool is_fixed_typed_array() const {
2199 return hydrogen()->is_fixed_typed_array();
2201 bool is_typed_elements() const {
2202 return is_external() || is_fixed_typed_array();
2204 LOperand* elements() { return inputs_[0]; }
2205 LOperand* key() { return inputs_[1]; }
2206 LOperand* value() { return inputs_[2]; }
2207 ElementsKind elements_kind() const { return hydrogen()->elements_kind(); }
2209 DECLARE_CONCRETE_INSTRUCTION(StoreKeyed, "store-keyed")
2210 DECLARE_HYDROGEN_ACCESSOR(StoreKeyed)
2212 void PrintDataTo(StringStream* stream) override;
2213 bool NeedsCanonicalization() { return hydrogen()->NeedsCanonicalization(); }
2214 uint32_t base_offset() const { return hydrogen()->base_offset(); }
2218 class LStoreKeyedGeneric final : public LTemplateInstruction<0, 4, 0> {
2220 LStoreKeyedGeneric(LOperand* context,
2224 inputs_[0] = context;
2225 inputs_[1] = object;
2230 LOperand* context() { return inputs_[0]; }
2231 LOperand* object() { return inputs_[1]; }
2232 LOperand* key() { return inputs_[2]; }
2233 LOperand* value() { return inputs_[3]; }
2235 DECLARE_CONCRETE_INSTRUCTION(StoreKeyedGeneric, "store-keyed-generic")
2236 DECLARE_HYDROGEN_ACCESSOR(StoreKeyedGeneric)
2238 void PrintDataTo(StringStream* stream) override;
2240 LanguageMode language_mode() { return hydrogen()->language_mode(); }
2244 class LTransitionElementsKind final : public LTemplateInstruction<0, 2, 2> {
2246 LTransitionElementsKind(LOperand* object,
2248 LOperand* new_map_temp,
2250 inputs_[0] = object;
2251 inputs_[1] = context;
2252 temps_[0] = new_map_temp;
2256 LOperand* object() { return inputs_[0]; }
2257 LOperand* context() { return inputs_[1]; }
2258 LOperand* new_map_temp() { return temps_[0]; }
2259 LOperand* temp() { return temps_[1]; }
2261 DECLARE_CONCRETE_INSTRUCTION(TransitionElementsKind,
2262 "transition-elements-kind")
2263 DECLARE_HYDROGEN_ACCESSOR(TransitionElementsKind)
2265 void PrintDataTo(StringStream* stream) override;
2267 Handle<Map> original_map() { return hydrogen()->original_map().handle(); }
2268 Handle<Map> transitioned_map() {
2269 return hydrogen()->transitioned_map().handle();
2271 ElementsKind from_kind() { return hydrogen()->from_kind(); }
2272 ElementsKind to_kind() { return hydrogen()->to_kind(); }
2276 class LTrapAllocationMemento final : public LTemplateInstruction<0, 1, 1> {
2278 LTrapAllocationMemento(LOperand* object,
2280 inputs_[0] = object;
2284 LOperand* object() { return inputs_[0]; }
2285 LOperand* temp() { return temps_[0]; }
2287 DECLARE_CONCRETE_INSTRUCTION(TrapAllocationMemento,
2288 "trap-allocation-memento")
2292 class LStringAdd final : public LTemplateInstruction<1, 3, 0> {
2294 LStringAdd(LOperand* context, LOperand* left, LOperand* right) {
2295 inputs_[0] = context;
2300 LOperand* context() { return inputs_[0]; }
2301 LOperand* left() { return inputs_[1]; }
2302 LOperand* right() { return inputs_[2]; }
2304 DECLARE_CONCRETE_INSTRUCTION(StringAdd, "string-add")
2305 DECLARE_HYDROGEN_ACCESSOR(StringAdd)
2309 class LStringCharCodeAt final : public LTemplateInstruction<1, 3, 0> {
2311 LStringCharCodeAt(LOperand* context, LOperand* string, LOperand* index) {
2312 inputs_[0] = context;
2313 inputs_[1] = string;
2317 LOperand* context() { return inputs_[0]; }
2318 LOperand* string() { return inputs_[1]; }
2319 LOperand* index() { return inputs_[2]; }
2321 DECLARE_CONCRETE_INSTRUCTION(StringCharCodeAt, "string-char-code-at")
2322 DECLARE_HYDROGEN_ACCESSOR(StringCharCodeAt)
2326 class LStringCharFromCode final : public LTemplateInstruction<1, 2, 0> {
2328 explicit LStringCharFromCode(LOperand* context, LOperand* char_code) {
2329 inputs_[0] = context;
2330 inputs_[1] = char_code;
2333 LOperand* context() { return inputs_[0]; }
2334 LOperand* char_code() { return inputs_[1]; }
2336 DECLARE_CONCRETE_INSTRUCTION(StringCharFromCode, "string-char-from-code")
2337 DECLARE_HYDROGEN_ACCESSOR(StringCharFromCode)
2341 class LCheckValue final : public LTemplateInstruction<0, 1, 0> {
2343 explicit LCheckValue(LOperand* value) {
2347 LOperand* value() { return inputs_[0]; }
2349 DECLARE_CONCRETE_INSTRUCTION(CheckValue, "check-value")
2350 DECLARE_HYDROGEN_ACCESSOR(CheckValue)
2354 class LCheckInstanceType final : public LTemplateInstruction<0, 1, 0> {
2356 explicit LCheckInstanceType(LOperand* value) {
2360 LOperand* value() { return inputs_[0]; }
2362 DECLARE_CONCRETE_INSTRUCTION(CheckInstanceType, "check-instance-type")
2363 DECLARE_HYDROGEN_ACCESSOR(CheckInstanceType)
2367 class LCheckMaps final : public LTemplateInstruction<0, 1, 0> {
2369 explicit LCheckMaps(LOperand* value = NULL) {
2373 LOperand* value() { return inputs_[0]; }
2375 DECLARE_CONCRETE_INSTRUCTION(CheckMaps, "check-maps")
2376 DECLARE_HYDROGEN_ACCESSOR(CheckMaps)
2380 class LCheckSmi final : public LTemplateInstruction<1, 1, 0> {
2382 explicit LCheckSmi(LOperand* value) {
2386 LOperand* value() { return inputs_[0]; }
2388 DECLARE_CONCRETE_INSTRUCTION(CheckSmi, "check-smi")
2392 class LClampDToUint8 final : public LTemplateInstruction<1, 1, 0> {
2394 explicit LClampDToUint8(LOperand* unclamped) {
2395 inputs_[0] = unclamped;
2398 LOperand* unclamped() { return inputs_[0]; }
2400 DECLARE_CONCRETE_INSTRUCTION(ClampDToUint8, "clamp-d-to-uint8")
2404 class LClampIToUint8 final : public LTemplateInstruction<1, 1, 0> {
2406 explicit LClampIToUint8(LOperand* unclamped) {
2407 inputs_[0] = unclamped;
2410 LOperand* unclamped() { return inputs_[0]; }
2412 DECLARE_CONCRETE_INSTRUCTION(ClampIToUint8, "clamp-i-to-uint8")
2416 class LClampTToUint8 final : public LTemplateInstruction<1, 1, 1> {
2418 LClampTToUint8(LOperand* unclamped,
2419 LOperand* temp_xmm) {
2420 inputs_[0] = unclamped;
2421 temps_[0] = temp_xmm;
2424 LOperand* unclamped() { return inputs_[0]; }
2425 LOperand* temp_xmm() { return temps_[0]; }
2427 DECLARE_CONCRETE_INSTRUCTION(ClampTToUint8, "clamp-t-to-uint8")
2431 class LCheckNonSmi final : public LTemplateInstruction<0, 1, 0> {
2433 explicit LCheckNonSmi(LOperand* value) {
2437 LOperand* value() { return inputs_[0]; }
2439 DECLARE_CONCRETE_INSTRUCTION(CheckNonSmi, "check-non-smi")
2440 DECLARE_HYDROGEN_ACCESSOR(CheckHeapObject)
2444 class LDoubleBits final : public LTemplateInstruction<1, 1, 0> {
2446 explicit LDoubleBits(LOperand* value) {
2450 LOperand* value() { return inputs_[0]; }
2452 DECLARE_CONCRETE_INSTRUCTION(DoubleBits, "double-bits")
2453 DECLARE_HYDROGEN_ACCESSOR(DoubleBits)
2457 class LConstructDouble final : public LTemplateInstruction<1, 2, 0> {
2459 LConstructDouble(LOperand* hi, LOperand* lo) {
2464 LOperand* hi() { return inputs_[0]; }
2465 LOperand* lo() { return inputs_[1]; }
2467 DECLARE_CONCRETE_INSTRUCTION(ConstructDouble, "construct-double")
2471 class LAllocate final : public LTemplateInstruction<1, 2, 1> {
2473 LAllocate(LOperand* context, LOperand* size, LOperand* temp) {
2474 inputs_[0] = context;
2479 LOperand* context() { return inputs_[0]; }
2480 LOperand* size() { return inputs_[1]; }
2481 LOperand* temp() { return temps_[0]; }
2483 DECLARE_CONCRETE_INSTRUCTION(Allocate, "allocate")
2484 DECLARE_HYDROGEN_ACCESSOR(Allocate)
2488 class LRegExpLiteral final : public LTemplateInstruction<1, 1, 0> {
2490 explicit LRegExpLiteral(LOperand* context) {
2491 inputs_[0] = context;
2494 LOperand* context() { return inputs_[0]; }
2496 DECLARE_CONCRETE_INSTRUCTION(RegExpLiteral, "regexp-literal")
2497 DECLARE_HYDROGEN_ACCESSOR(RegExpLiteral)
2501 class LFunctionLiteral final : public LTemplateInstruction<1, 1, 0> {
2503 explicit LFunctionLiteral(LOperand* context) {
2504 inputs_[0] = context;
2507 LOperand* context() { return inputs_[0]; }
2509 DECLARE_CONCRETE_INSTRUCTION(FunctionLiteral, "function-literal")
2510 DECLARE_HYDROGEN_ACCESSOR(FunctionLiteral)
2514 class LToFastProperties final : public LTemplateInstruction<1, 1, 0> {
2516 explicit LToFastProperties(LOperand* value) {
2520 LOperand* value() { return inputs_[0]; }
2522 DECLARE_CONCRETE_INSTRUCTION(ToFastProperties, "to-fast-properties")
2523 DECLARE_HYDROGEN_ACCESSOR(ToFastProperties)
2527 class LTypeof final : public LTemplateInstruction<1, 2, 0> {
2529 LTypeof(LOperand* context, LOperand* value) {
2530 inputs_[0] = context;
2534 LOperand* context() { return inputs_[0]; }
2535 LOperand* value() { return inputs_[1]; }
2537 DECLARE_CONCRETE_INSTRUCTION(Typeof, "typeof")
2541 class LTypeofIsAndBranch final : public LControlInstruction<1, 0> {
2543 explicit LTypeofIsAndBranch(LOperand* value) {
2547 LOperand* value() { return inputs_[0]; }
2549 DECLARE_CONCRETE_INSTRUCTION(TypeofIsAndBranch, "typeof-is-and-branch")
2550 DECLARE_HYDROGEN_ACCESSOR(TypeofIsAndBranch)
2552 Handle<String> type_literal() { return hydrogen()->type_literal(); }
2554 void PrintDataTo(StringStream* stream) override;
2558 class LIsConstructCallAndBranch final : public LControlInstruction<0, 1> {
2560 explicit LIsConstructCallAndBranch(LOperand* temp) {
2564 LOperand* temp() { return temps_[0]; }
2566 DECLARE_CONCRETE_INSTRUCTION(IsConstructCallAndBranch,
2567 "is-construct-call-and-branch")
2568 DECLARE_HYDROGEN_ACCESSOR(IsConstructCallAndBranch)
2572 class LOsrEntry final : public LTemplateInstruction<0, 0, 0> {
2576 bool HasInterestingComment(LCodeGen* gen) const override { return false; }
2577 DECLARE_CONCRETE_INSTRUCTION(OsrEntry, "osr-entry")
2581 class LStackCheck final : public LTemplateInstruction<0, 1, 0> {
2583 explicit LStackCheck(LOperand* context) {
2584 inputs_[0] = context;
2587 LOperand* context() { return inputs_[0]; }
2589 DECLARE_CONCRETE_INSTRUCTION(StackCheck, "stack-check")
2590 DECLARE_HYDROGEN_ACCESSOR(StackCheck)
2592 Label* done_label() { return &done_label_; }
2599 class LForInPrepareMap final : public LTemplateInstruction<1, 2, 0> {
2601 LForInPrepareMap(LOperand* context, LOperand* object) {
2602 inputs_[0] = context;
2603 inputs_[1] = object;
2606 LOperand* context() { return inputs_[0]; }
2607 LOperand* object() { return inputs_[1]; }
2609 DECLARE_CONCRETE_INSTRUCTION(ForInPrepareMap, "for-in-prepare-map")
2613 class LForInCacheArray final : public LTemplateInstruction<1, 1, 0> {
2615 explicit LForInCacheArray(LOperand* map) {
2619 LOperand* map() { return inputs_[0]; }
2621 DECLARE_CONCRETE_INSTRUCTION(ForInCacheArray, "for-in-cache-array")
2624 return HForInCacheArray::cast(this->hydrogen_value())->idx();
2629 class LCheckMapValue final : public LTemplateInstruction<0, 2, 0> {
2631 LCheckMapValue(LOperand* value, LOperand* map) {
2636 LOperand* value() { return inputs_[0]; }
2637 LOperand* map() { return inputs_[1]; }
2639 DECLARE_CONCRETE_INSTRUCTION(CheckMapValue, "check-map-value")
2643 class LLoadFieldByIndex final : public LTemplateInstruction<1, 2, 0> {
2645 LLoadFieldByIndex(LOperand* object, LOperand* index) {
2646 inputs_[0] = object;
2650 LOperand* object() { return inputs_[0]; }
2651 LOperand* index() { return inputs_[1]; }
2653 DECLARE_CONCRETE_INSTRUCTION(LoadFieldByIndex, "load-field-by-index")
2657 class LStoreFrameContext: public LTemplateInstruction<0, 1, 0> {
2659 explicit LStoreFrameContext(LOperand* context) {
2660 inputs_[0] = context;
2663 LOperand* context() { return inputs_[0]; }
2665 DECLARE_CONCRETE_INSTRUCTION(StoreFrameContext, "store-frame-context")
2669 class LAllocateBlockContext: public LTemplateInstruction<1, 2, 0> {
2671 LAllocateBlockContext(LOperand* context, LOperand* function) {
2672 inputs_[0] = context;
2673 inputs_[1] = function;
2676 LOperand* context() { return inputs_[0]; }
2677 LOperand* function() { return inputs_[1]; }
2679 Handle<ScopeInfo> scope_info() { return hydrogen()->scope_info(); }
2681 DECLARE_CONCRETE_INSTRUCTION(AllocateBlockContext, "allocate-block-context")
2682 DECLARE_HYDROGEN_ACCESSOR(AllocateBlockContext)
2686 class LChunkBuilder;
2687 class LPlatformChunk final : public LChunk {
2689 LPlatformChunk(CompilationInfo* info, HGraph* graph)
2690 : LChunk(info, graph),
2691 dehoisted_key_ids_(graph->GetMaximumValueID(), graph->zone()) { }
2693 int GetNextSpillIndex(RegisterKind kind);
2694 LOperand* GetNextSpillSlot(RegisterKind kind);
2695 BitVector* GetDehoistedKeyIds() { return &dehoisted_key_ids_; }
2696 bool IsDehoistedKey(HValue* value) {
2697 return dehoisted_key_ids_.Contains(value->id());
2701 BitVector dehoisted_key_ids_;
2705 class LChunkBuilder final : public LChunkBuilderBase {
2707 LChunkBuilder(CompilationInfo* info, HGraph* graph, LAllocator* allocator)
2708 : LChunkBuilderBase(info, graph),
2709 current_instruction_(NULL),
2710 current_block_(NULL),
2712 allocator_(allocator) {}
2714 // Build the sequence for the graph.
2715 LPlatformChunk* Build();
2717 // Declare methods that deal with the individual node types.
2718 #define DECLARE_DO(type) LInstruction* Do##type(H##type* node);
2719 HYDROGEN_CONCRETE_INSTRUCTION_LIST(DECLARE_DO)
2722 LInstruction* DoMathFloor(HUnaryMathOperation* instr);
2723 LInstruction* DoMathRound(HUnaryMathOperation* instr);
2724 LInstruction* DoMathFround(HUnaryMathOperation* instr);
2725 LInstruction* DoMathAbs(HUnaryMathOperation* instr);
2726 LInstruction* DoMathLog(HUnaryMathOperation* instr);
2727 LInstruction* DoMathExp(HUnaryMathOperation* instr);
2728 LInstruction* DoMathSqrt(HUnaryMathOperation* instr);
2729 LInstruction* DoMathPowHalf(HUnaryMathOperation* instr);
2730 LInstruction* DoMathClz32(HUnaryMathOperation* instr);
2731 LInstruction* DoDivByPowerOf2I(HDiv* instr);
2732 LInstruction* DoDivByConstI(HDiv* instr);
2733 LInstruction* DoDivI(HDiv* instr);
2734 LInstruction* DoModByPowerOf2I(HMod* instr);
2735 LInstruction* DoModByConstI(HMod* instr);
2736 LInstruction* DoModI(HMod* instr);
2737 LInstruction* DoFlooringDivByPowerOf2I(HMathFloorOfDiv* instr);
2738 LInstruction* DoFlooringDivByConstI(HMathFloorOfDiv* instr);
2739 LInstruction* DoFlooringDivI(HMathFloorOfDiv* instr);
2742 // Methods for getting operands for Use / Define / Temp.
2743 LUnallocated* ToUnallocated(Register reg);
2744 LUnallocated* ToUnallocated(XMMRegister reg);
2746 // Methods for setting up define-use relationships.
2747 MUST_USE_RESULT LOperand* Use(HValue* value, LUnallocated* operand);
2748 MUST_USE_RESULT LOperand* UseFixed(HValue* value, Register fixed_register);
2749 MUST_USE_RESULT LOperand* UseFixedDouble(HValue* value,
2750 XMMRegister fixed_register);
2752 // A value that is guaranteed to be allocated to a register.
2753 // Operand created by UseRegister is guaranteed to be live until the end of
2754 // instruction. This means that register allocator will not reuse it's
2755 // register for any other operand inside instruction.
2756 // Operand created by UseRegisterAtStart is guaranteed to be live only at
2757 // instruction start. Register allocator is free to assign the same register
2758 // to some other operand used inside instruction (i.e. temporary or
2760 MUST_USE_RESULT LOperand* UseRegister(HValue* value);
2761 MUST_USE_RESULT LOperand* UseRegisterAtStart(HValue* value);
2763 // An input operand in a register that may be trashed.
2764 MUST_USE_RESULT LOperand* UseTempRegister(HValue* value);
2766 // An input operand in a register that may be trashed or a constant operand.
2767 MUST_USE_RESULT LOperand* UseTempRegisterOrConstant(HValue* value);
2769 // An input operand in a register or stack slot.
2770 MUST_USE_RESULT LOperand* Use(HValue* value);
2771 MUST_USE_RESULT LOperand* UseAtStart(HValue* value);
2773 // An input operand in a register, stack slot or a constant operand.
2774 MUST_USE_RESULT LOperand* UseOrConstant(HValue* value);
2775 MUST_USE_RESULT LOperand* UseOrConstantAtStart(HValue* value);
2777 // An input operand in a register or a constant operand.
2778 MUST_USE_RESULT LOperand* UseRegisterOrConstant(HValue* value);
2779 MUST_USE_RESULT LOperand* UseRegisterOrConstantAtStart(HValue* value);
2781 // An input operand in a constant operand.
2782 MUST_USE_RESULT LOperand* UseConstant(HValue* value);
2784 // An input operand in register, stack slot or a constant operand.
2785 // Will not be moved to a register even if one is freely available.
2786 MUST_USE_RESULT LOperand* UseAny(HValue* value) override;
2788 // Temporary operand that must be in a register.
2789 MUST_USE_RESULT LUnallocated* TempRegister();
2790 MUST_USE_RESULT LOperand* FixedTemp(Register reg);
2791 MUST_USE_RESULT LOperand* FixedTemp(XMMRegister reg);
2793 // Methods for setting up define-use relationships.
2794 // Return the same instruction that they are passed.
2795 LInstruction* Define(LTemplateResultInstruction<1>* instr,
2796 LUnallocated* result);
2797 LInstruction* DefineAsRegister(LTemplateResultInstruction<1>* instr);
2798 LInstruction* DefineAsSpilled(LTemplateResultInstruction<1>* instr,
2800 LInstruction* DefineSameAsFirst(LTemplateResultInstruction<1>* instr);
2801 LInstruction* DefineFixed(LTemplateResultInstruction<1>* instr,
2803 LInstruction* DefineFixedDouble(LTemplateResultInstruction<1>* instr,
2805 // Assigns an environment to an instruction. An instruction which can
2806 // deoptimize must have an environment.
2807 LInstruction* AssignEnvironment(LInstruction* instr);
2808 // Assigns a pointer map to an instruction. An instruction which can
2809 // trigger a GC or a lazy deoptimization must have a pointer map.
2810 LInstruction* AssignPointerMap(LInstruction* instr);
2812 enum CanDeoptimize { CAN_DEOPTIMIZE_EAGERLY, CANNOT_DEOPTIMIZE_EAGERLY };
2814 // Marks a call for the register allocator. Assigns a pointer map to
2815 // support GC and lazy deoptimization. Assigns an environment to support
2816 // eager deoptimization if CAN_DEOPTIMIZE_EAGERLY.
2817 LInstruction* MarkAsCall(
2818 LInstruction* instr,
2819 HInstruction* hinstr,
2820 CanDeoptimize can_deoptimize = CANNOT_DEOPTIMIZE_EAGERLY);
2822 void VisitInstruction(HInstruction* current);
2823 void AddInstruction(LInstruction* instr, HInstruction* current);
2825 void DoBasicBlock(HBasicBlock* block, HBasicBlock* next_block);
2826 LInstruction* DoShift(Token::Value op, HBitwiseBinaryOperation* instr);
2827 LInstruction* DoArithmeticD(Token::Value op,
2828 HArithmeticBinaryOperation* instr);
2829 LInstruction* DoArithmeticT(Token::Value op,
2830 HBinaryOperation* instr);
2831 void FindDehoistedKeyDefinitions(HValue* candidate);
2833 HInstruction* current_instruction_;
2834 HBasicBlock* current_block_;
2835 HBasicBlock* next_block_;
2836 LAllocator* allocator_;
2838 DISALLOW_COPY_AND_ASSIGN(LChunkBuilder);
2841 #undef DECLARE_HYDROGEN_ACCESSOR
2842 #undef DECLARE_CONCRETE_INSTRUCTION
2844 } } // namespace v8::int
2846 #endif // V8_X64_LITHIUM_X64_H_