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_X87_LITHIUM_X87_H_
6 #define V8_X87_LITHIUM_X87_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"
18 class RCodeVisualizer;
21 // Forward declarations.
24 #define LITHIUM_CONCRETE_INSTRUCTION_LIST(V) \
25 V(AccessArgumentsAt) \
27 V(AllocateBlockContext) \
30 V(ArgumentsElements) \
38 V(CallWithDescriptor) \
44 V(CheckArrayBufferNotNeutered) \
45 V(CheckInstanceType) \
53 V(ClampTToUint8NoSSE2) \
54 V(ClassOfTestAndBranch) \
56 V(CompareMinusZeroAndBranch) \
57 V(CompareNumericAndBranch) \
58 V(CmpObjectEqAndBranch) \
82 V(FlooringDivByConstI) \
83 V(FlooringDivByPowerOf2I) \
88 V(GetCachedArrayIndex) \
90 V(HasCachedArrayIndexAndBranch) \
91 V(HasInPrototypeChainAndBranch) \
92 V(HasInstanceTypeAndBranch) \
93 V(InnerAllocatedObject) \
96 V(Integer32ToDouble) \
98 V(IsConstructCallAndBranch) \
99 V(IsStringAndBranch) \
101 V(IsUndetectableAndBranch) \
105 V(LoadFieldByIndex) \
106 V(LoadFunctionPrototype) \
107 V(LoadGlobalGeneric) \
108 V(LoadGlobalViaContext) \
110 V(LoadKeyedGeneric) \
112 V(LoadNamedGeneric) \
125 V(MaybeGrowElements) \
140 V(SeqStringGetChar) \
141 V(SeqStringSetChar) \
147 V(StoreContextSlot) \
148 V(StoreFrameContext) \
149 V(StoreGlobalViaContext) \
151 V(StoreKeyedGeneric) \
153 V(StoreNamedGeneric) \
155 V(StringCharCodeAt) \
156 V(StringCharFromCode) \
157 V(StringCompareAndBranch) \
161 V(ToFastProperties) \
162 V(TransitionElementsKind) \
163 V(TrapAllocationMemento) \
165 V(TypeofIsAndBranch) \
171 #define DECLARE_CONCRETE_INSTRUCTION(type, mnemonic) \
172 Opcode opcode() const final { return LInstruction::k##type; } \
173 void CompileToNative(LCodeGen* generator) final; \
174 const char* Mnemonic() const final { return mnemonic; } \
175 static L##type* cast(LInstruction* instr) { \
176 DCHECK(instr->Is##type()); \
177 return reinterpret_cast<L##type*>(instr); \
181 #define DECLARE_HYDROGEN_ACCESSOR(type) \
182 H##type* hydrogen() const { \
183 return H##type::cast(hydrogen_value()); \
187 class LInstruction : public ZoneObject {
190 : environment_(NULL),
191 hydrogen_value_(NULL),
192 bit_field_(IsCallBits::encode(false)) {
195 virtual ~LInstruction() {}
197 virtual void CompileToNative(LCodeGen* generator) = 0;
198 virtual const char* Mnemonic() const = 0;
199 virtual void PrintTo(StringStream* stream);
200 virtual void PrintDataTo(StringStream* stream);
201 virtual void PrintOutputOperandTo(StringStream* stream);
204 // Declare a unique enum value for each instruction.
205 #define DECLARE_OPCODE(type) k##type,
206 LITHIUM_CONCRETE_INSTRUCTION_LIST(DECLARE_OPCODE) kAdapter,
207 kNumberOfInstructions
208 #undef DECLARE_OPCODE
211 virtual Opcode opcode() const = 0;
213 // Declare non-virtual type testers for all leaf IR classes.
214 #define DECLARE_PREDICATE(type) \
215 bool Is##type() const { return opcode() == k##type; }
216 LITHIUM_CONCRETE_INSTRUCTION_LIST(DECLARE_PREDICATE)
217 #undef DECLARE_PREDICATE
219 // Declare virtual predicates for instructions that don't have
221 virtual bool IsGap() const { return false; }
223 virtual bool IsControl() const { return false; }
225 // Try deleting this instruction if possible.
226 virtual bool TryDelete() { return false; }
228 void set_environment(LEnvironment* env) { environment_ = env; }
229 LEnvironment* environment() const { return environment_; }
230 bool HasEnvironment() const { return environment_ != NULL; }
232 void set_pointer_map(LPointerMap* p) { pointer_map_.set(p); }
233 LPointerMap* pointer_map() const { return pointer_map_.get(); }
234 bool HasPointerMap() const { return pointer_map_.is_set(); }
236 void set_hydrogen_value(HValue* value) { hydrogen_value_ = value; }
237 HValue* hydrogen_value() const { return hydrogen_value_; }
239 void MarkAsCall() { bit_field_ = IsCallBits::update(bit_field_, true); }
240 bool IsCall() const { return IsCallBits::decode(bit_field_); }
242 // Interface to the register allocator and iterators.
243 bool ClobbersTemps() const { return IsCall(); }
244 bool ClobbersRegisters() const { return IsCall(); }
245 virtual bool ClobbersDoubleRegisters(Isolate* isolate) const {
247 // We only have rudimentary X87Stack tracking, thus in general
248 // cannot handle phi-nodes.
252 virtual bool HasResult() const = 0;
253 virtual LOperand* result() const = 0;
255 bool HasDoubleRegisterResult();
256 bool HasDoubleRegisterInput();
257 bool IsDoubleInput(X87Register reg, LCodeGen* cgen);
259 LOperand* FirstInput() { return InputAt(0); }
260 LOperand* Output() { return HasResult() ? result() : NULL; }
262 virtual bool HasInterestingComment(LCodeGen* gen) const { return true; }
268 virtual int InputCount() = 0;
269 virtual LOperand* InputAt(int i) = 0;
273 friend class InputIterator;
275 friend class TempIterator;
276 virtual int TempCount() = 0;
277 virtual LOperand* TempAt(int i) = 0;
279 class IsCallBits: public BitField<bool, 0, 1> {};
281 LEnvironment* environment_;
282 SetOncePointer<LPointerMap> pointer_map_;
283 HValue* hydrogen_value_;
288 // R = number of result operands (0 or 1).
290 class LTemplateResultInstruction : public LInstruction {
292 // Allow 0 or 1 output operands.
293 STATIC_ASSERT(R == 0 || R == 1);
294 bool HasResult() const final { return R != 0 && result() != NULL; }
295 void set_result(LOperand* operand) { results_[0] = operand; }
296 LOperand* result() const override { return results_[0]; }
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) : block_(block) {
325 parallel_moves_[BEFORE] = NULL;
326 parallel_moves_[START] = NULL;
327 parallel_moves_[END] = NULL;
328 parallel_moves_[AFTER] = NULL;
331 // Can't use the DECLARE-macro here because of sub-classes.
332 bool IsGap() const final { return true; }
333 void PrintDataTo(StringStream* stream) override;
334 static LGap* cast(LInstruction* instr) {
335 DCHECK(instr->IsGap());
336 return reinterpret_cast<LGap*>(instr);
339 bool IsRedundant() const;
341 HBasicBlock* block() const { return block_; }
348 FIRST_INNER_POSITION = BEFORE,
349 LAST_INNER_POSITION = AFTER
352 LParallelMove* GetOrCreateParallelMove(InnerPosition pos, Zone* zone) {
353 if (parallel_moves_[pos] == NULL) {
354 parallel_moves_[pos] = new(zone) LParallelMove(zone);
356 return parallel_moves_[pos];
359 LParallelMove* GetParallelMove(InnerPosition pos) {
360 return parallel_moves_[pos];
364 LParallelMove* parallel_moves_[LAST_INNER_POSITION + 1];
369 class LInstructionGap final : public LGap {
371 explicit LInstructionGap(HBasicBlock* block) : LGap(block) { }
373 bool HasInterestingComment(LCodeGen* gen) const override {
374 return !IsRedundant();
377 DECLARE_CONCRETE_INSTRUCTION(InstructionGap, "gap")
381 class LClobberDoubles final : public LTemplateInstruction<0, 0, 0> {
383 explicit LClobberDoubles(Isolate* isolate) { }
385 bool ClobbersDoubleRegisters(Isolate* isolate) const override { return true; }
387 DECLARE_CONCRETE_INSTRUCTION(ClobberDoubles, "clobber-d")
391 class LGoto final : public LTemplateInstruction<0, 0, 0> {
393 explicit LGoto(HBasicBlock* block) : block_(block) { }
395 bool HasInterestingComment(LCodeGen* gen) const override;
396 DECLARE_CONCRETE_INSTRUCTION(Goto, "goto")
397 void PrintDataTo(StringStream* stream) override;
398 bool IsControl() const override { return true; }
400 int block_id() const { return block_->block_id(); }
401 bool ClobbersDoubleRegisters(Isolate* isolate) const override {
405 bool jumps_to_join() const { return block_->predecessors()->length() > 1; }
406 HBasicBlock* block() const { return block_; }
413 class LLazyBailout final : public LTemplateInstruction<0, 0, 0> {
415 DECLARE_CONCRETE_INSTRUCTION(LazyBailout, "lazy-bailout")
419 class LDummy final : public LTemplateInstruction<1, 0, 0> {
422 DECLARE_CONCRETE_INSTRUCTION(Dummy, "dummy")
426 class LDummyUse final : public LTemplateInstruction<1, 1, 0> {
428 explicit LDummyUse(LOperand* value) {
431 DECLARE_CONCRETE_INSTRUCTION(DummyUse, "dummy-use")
435 class LDeoptimize final : public LTemplateInstruction<0, 0, 0> {
437 bool IsControl() const override { return true; }
438 DECLARE_CONCRETE_INSTRUCTION(Deoptimize, "deoptimize")
439 DECLARE_HYDROGEN_ACCESSOR(Deoptimize)
443 class LLabel final : public LGap {
445 explicit LLabel(HBasicBlock* block)
446 : LGap(block), replacement_(NULL) { }
448 bool HasInterestingComment(LCodeGen* gen) const override { return false; }
449 DECLARE_CONCRETE_INSTRUCTION(Label, "label")
451 void PrintDataTo(StringStream* stream) override;
453 int block_id() const { return block()->block_id(); }
454 bool is_loop_header() const { return block()->IsLoopHeader(); }
455 bool is_osr_entry() const { return block()->is_osr_entry(); }
456 Label* label() { return &label_; }
457 LLabel* replacement() const { return replacement_; }
458 void set_replacement(LLabel* label) { replacement_ = label; }
459 bool HasReplacement() const { return replacement_ != NULL; }
463 LLabel* replacement_;
467 class LParameter final : public LTemplateInstruction<1, 0, 0> {
469 bool HasInterestingComment(LCodeGen* gen) const override { return false; }
470 DECLARE_CONCRETE_INSTRUCTION(Parameter, "parameter")
474 class LCallStub final : public LTemplateInstruction<1, 1, 0> {
476 explicit LCallStub(LOperand* context) {
477 inputs_[0] = context;
480 LOperand* context() { return inputs_[0]; }
482 DECLARE_CONCRETE_INSTRUCTION(CallStub, "call-stub")
483 DECLARE_HYDROGEN_ACCESSOR(CallStub)
487 class LUnknownOSRValue final : public LTemplateInstruction<1, 0, 0> {
489 bool HasInterestingComment(LCodeGen* gen) const override { return false; }
490 DECLARE_CONCRETE_INSTRUCTION(UnknownOSRValue, "unknown-osr-value")
494 template<int I, int T>
495 class LControlInstruction: public LTemplateInstruction<0, I, T> {
497 LControlInstruction() : false_label_(NULL), true_label_(NULL) { }
499 bool IsControl() const final { return true; }
501 int SuccessorCount() { return hydrogen()->SuccessorCount(); }
502 HBasicBlock* SuccessorAt(int i) { return hydrogen()->SuccessorAt(i); }
504 int TrueDestination(LChunk* chunk) {
505 return chunk->LookupDestination(true_block_id());
507 int FalseDestination(LChunk* chunk) {
508 return chunk->LookupDestination(false_block_id());
511 Label* TrueLabel(LChunk* chunk) {
512 if (true_label_ == NULL) {
513 true_label_ = chunk->GetAssemblyLabel(TrueDestination(chunk));
517 Label* FalseLabel(LChunk* chunk) {
518 if (false_label_ == NULL) {
519 false_label_ = chunk->GetAssemblyLabel(FalseDestination(chunk));
525 int true_block_id() { return SuccessorAt(0)->block_id(); }
526 int false_block_id() { return SuccessorAt(1)->block_id(); }
529 HControlInstruction* hydrogen() {
530 return HControlInstruction::cast(this->hydrogen_value());
538 class LWrapReceiver final : public LTemplateInstruction<1, 2, 1> {
540 LWrapReceiver(LOperand* receiver,
543 inputs_[0] = receiver;
544 inputs_[1] = function;
548 LOperand* receiver() { return inputs_[0]; }
549 LOperand* function() { return inputs_[1]; }
550 LOperand* temp() { return temps_[0]; }
552 DECLARE_CONCRETE_INSTRUCTION(WrapReceiver, "wrap-receiver")
553 DECLARE_HYDROGEN_ACCESSOR(WrapReceiver)
557 class LApplyArguments final : public LTemplateInstruction<1, 4, 0> {
559 LApplyArguments(LOperand* function,
562 LOperand* elements) {
563 inputs_[0] = function;
564 inputs_[1] = receiver;
566 inputs_[3] = elements;
569 LOperand* function() { return inputs_[0]; }
570 LOperand* receiver() { return inputs_[1]; }
571 LOperand* length() { return inputs_[2]; }
572 LOperand* elements() { return inputs_[3]; }
574 DECLARE_CONCRETE_INSTRUCTION(ApplyArguments, "apply-arguments")
578 class LAccessArgumentsAt final : public LTemplateInstruction<1, 3, 0> {
580 LAccessArgumentsAt(LOperand* arguments, LOperand* length, LOperand* index) {
581 inputs_[0] = arguments;
586 LOperand* arguments() { return inputs_[0]; }
587 LOperand* length() { return inputs_[1]; }
588 LOperand* index() { return inputs_[2]; }
590 DECLARE_CONCRETE_INSTRUCTION(AccessArgumentsAt, "access-arguments-at")
592 void PrintDataTo(StringStream* stream) override;
596 class LArgumentsLength final : public LTemplateInstruction<1, 1, 0> {
598 explicit LArgumentsLength(LOperand* elements) {
599 inputs_[0] = elements;
602 LOperand* elements() { return inputs_[0]; }
604 DECLARE_CONCRETE_INSTRUCTION(ArgumentsLength, "arguments-length")
608 class LArgumentsElements final : public LTemplateInstruction<1, 0, 0> {
610 DECLARE_CONCRETE_INSTRUCTION(ArgumentsElements, "arguments-elements")
611 DECLARE_HYDROGEN_ACCESSOR(ArgumentsElements)
615 class LDebugBreak final : public LTemplateInstruction<0, 0, 0> {
617 DECLARE_CONCRETE_INSTRUCTION(DebugBreak, "break")
621 class LModByPowerOf2I final : public LTemplateInstruction<1, 1, 0> {
623 LModByPowerOf2I(LOperand* dividend, int32_t divisor) {
624 inputs_[0] = dividend;
628 LOperand* dividend() { return inputs_[0]; }
629 int32_t divisor() const { return divisor_; }
631 DECLARE_CONCRETE_INSTRUCTION(ModByPowerOf2I, "mod-by-power-of-2-i")
632 DECLARE_HYDROGEN_ACCESSOR(Mod)
639 class LModByConstI final : public LTemplateInstruction<1, 1, 2> {
641 LModByConstI(LOperand* dividend,
645 inputs_[0] = dividend;
651 LOperand* dividend() { return inputs_[0]; }
652 int32_t divisor() const { return divisor_; }
653 LOperand* temp1() { return temps_[0]; }
654 LOperand* temp2() { return temps_[1]; }
656 DECLARE_CONCRETE_INSTRUCTION(ModByConstI, "mod-by-const-i")
657 DECLARE_HYDROGEN_ACCESSOR(Mod)
664 class LModI final : public LTemplateInstruction<1, 2, 1> {
666 LModI(LOperand* left, LOperand* right, LOperand* temp) {
672 LOperand* left() { return inputs_[0]; }
673 LOperand* right() { return inputs_[1]; }
674 LOperand* temp() { return temps_[0]; }
676 DECLARE_CONCRETE_INSTRUCTION(ModI, "mod-i")
677 DECLARE_HYDROGEN_ACCESSOR(Mod)
681 class LDivByPowerOf2I final : public LTemplateInstruction<1, 1, 0> {
683 LDivByPowerOf2I(LOperand* dividend, int32_t divisor) {
684 inputs_[0] = dividend;
688 LOperand* dividend() { return inputs_[0]; }
689 int32_t divisor() const { return divisor_; }
691 DECLARE_CONCRETE_INSTRUCTION(DivByPowerOf2I, "div-by-power-of-2-i")
692 DECLARE_HYDROGEN_ACCESSOR(Div)
699 class LDivByConstI final : public LTemplateInstruction<1, 1, 2> {
701 LDivByConstI(LOperand* dividend,
705 inputs_[0] = dividend;
711 LOperand* dividend() { return inputs_[0]; }
712 int32_t divisor() const { return divisor_; }
713 LOperand* temp1() { return temps_[0]; }
714 LOperand* temp2() { return temps_[1]; }
716 DECLARE_CONCRETE_INSTRUCTION(DivByConstI, "div-by-const-i")
717 DECLARE_HYDROGEN_ACCESSOR(Div)
724 class LDivI final : public LTemplateInstruction<1, 2, 1> {
726 LDivI(LOperand* dividend, LOperand* divisor, LOperand* temp) {
727 inputs_[0] = dividend;
728 inputs_[1] = divisor;
732 LOperand* dividend() { return inputs_[0]; }
733 LOperand* divisor() { return inputs_[1]; }
734 LOperand* temp() { return temps_[0]; }
736 DECLARE_CONCRETE_INSTRUCTION(DivI, "div-i")
737 DECLARE_HYDROGEN_ACCESSOR(BinaryOperation)
741 class LFlooringDivByPowerOf2I final : public LTemplateInstruction<1, 1, 0> {
743 LFlooringDivByPowerOf2I(LOperand* dividend, int32_t divisor) {
744 inputs_[0] = dividend;
748 LOperand* dividend() { return inputs_[0]; }
749 int32_t divisor() const { return divisor_; }
751 DECLARE_CONCRETE_INSTRUCTION(FlooringDivByPowerOf2I,
752 "flooring-div-by-power-of-2-i")
753 DECLARE_HYDROGEN_ACCESSOR(MathFloorOfDiv)
760 class LFlooringDivByConstI final : public LTemplateInstruction<1, 1, 3> {
762 LFlooringDivByConstI(LOperand* dividend,
767 inputs_[0] = dividend;
774 LOperand* dividend() { return inputs_[0]; }
775 int32_t divisor() const { return divisor_; }
776 LOperand* temp1() { return temps_[0]; }
777 LOperand* temp2() { return temps_[1]; }
778 LOperand* temp3() { return temps_[2]; }
780 DECLARE_CONCRETE_INSTRUCTION(FlooringDivByConstI, "flooring-div-by-const-i")
781 DECLARE_HYDROGEN_ACCESSOR(MathFloorOfDiv)
788 class LFlooringDivI final : public LTemplateInstruction<1, 2, 1> {
790 LFlooringDivI(LOperand* dividend, LOperand* divisor, LOperand* temp) {
791 inputs_[0] = dividend;
792 inputs_[1] = divisor;
796 LOperand* dividend() { return inputs_[0]; }
797 LOperand* divisor() { return inputs_[1]; }
798 LOperand* temp() { return temps_[0]; }
800 DECLARE_CONCRETE_INSTRUCTION(FlooringDivI, "flooring-div-i")
801 DECLARE_HYDROGEN_ACCESSOR(MathFloorOfDiv)
805 class LMulI final : public LTemplateInstruction<1, 2, 1> {
807 LMulI(LOperand* left, LOperand* right, LOperand* temp) {
813 LOperand* left() { return inputs_[0]; }
814 LOperand* right() { return inputs_[1]; }
815 LOperand* temp() { return temps_[0]; }
817 DECLARE_CONCRETE_INSTRUCTION(MulI, "mul-i")
818 DECLARE_HYDROGEN_ACCESSOR(Mul)
822 class LCompareNumericAndBranch final : public LControlInstruction<2, 0> {
824 LCompareNumericAndBranch(LOperand* left, LOperand* right) {
829 LOperand* left() { return inputs_[0]; }
830 LOperand* right() { return inputs_[1]; }
832 DECLARE_CONCRETE_INSTRUCTION(CompareNumericAndBranch,
833 "compare-numeric-and-branch")
834 DECLARE_HYDROGEN_ACCESSOR(CompareNumericAndBranch)
836 Token::Value op() const { return hydrogen()->token(); }
837 bool is_double() const {
838 return hydrogen()->representation().IsDouble();
841 void PrintDataTo(StringStream* stream) override;
845 class LMathFloor final : public LTemplateInstruction<1, 1, 0> {
847 explicit LMathFloor(LOperand* value) {
851 LOperand* value() { return inputs_[0]; }
853 DECLARE_CONCRETE_INSTRUCTION(MathFloor, "math-floor")
854 DECLARE_HYDROGEN_ACCESSOR(UnaryMathOperation)
858 class LMathRound final : public LTemplateInstruction<1, 1, 0> {
860 explicit LMathRound(LOperand* value) {
864 LOperand* value() { return inputs_[0]; }
866 DECLARE_CONCRETE_INSTRUCTION(MathRound, "math-round")
867 DECLARE_HYDROGEN_ACCESSOR(UnaryMathOperation)
871 class LMathFround final : public LTemplateInstruction<1, 1, 0> {
873 explicit LMathFround(LOperand* value) { inputs_[0] = value; }
875 LOperand* value() { return inputs_[0]; }
877 DECLARE_CONCRETE_INSTRUCTION(MathFround, "math-fround")
881 class LMathAbs final : public LTemplateInstruction<1, 2, 0> {
883 LMathAbs(LOperand* context, LOperand* value) {
884 inputs_[1] = context;
888 LOperand* context() { return inputs_[1]; }
889 LOperand* value() { return inputs_[0]; }
891 DECLARE_CONCRETE_INSTRUCTION(MathAbs, "math-abs")
892 DECLARE_HYDROGEN_ACCESSOR(UnaryMathOperation)
896 class LMathLog final : public LTemplateInstruction<1, 1, 0> {
898 explicit LMathLog(LOperand* value) {
902 LOperand* value() { return inputs_[0]; }
904 DECLARE_CONCRETE_INSTRUCTION(MathLog, "math-log")
908 class LMathClz32 final : public LTemplateInstruction<1, 1, 0> {
910 explicit LMathClz32(LOperand* value) {
914 LOperand* value() { return inputs_[0]; }
916 DECLARE_CONCRETE_INSTRUCTION(MathClz32, "math-clz32")
920 class LMathExp final : public LTemplateInstruction<1, 1, 2> {
922 LMathExp(LOperand* value,
928 ExternalReference::InitializeMathExpData();
931 LOperand* value() { return inputs_[0]; }
932 LOperand* temp1() { return temps_[0]; }
933 LOperand* temp2() { return temps_[1]; }
935 DECLARE_CONCRETE_INSTRUCTION(MathExp, "math-exp")
939 class LMathSqrt final : public LTemplateInstruction<1, 1, 2> {
941 explicit LMathSqrt(LOperand* value,
949 LOperand* value() { return inputs_[0]; }
950 LOperand* temp1() { return temps_[0]; }
951 LOperand* temp2() { return temps_[1]; }
953 DECLARE_CONCRETE_INSTRUCTION(MathSqrt, "math-sqrt")
957 class LMathPowHalf final : public LTemplateInstruction<1, 1, 0> {
959 explicit LMathPowHalf(LOperand* value) { inputs_[0] = value; }
961 LOperand* value() { return inputs_[0]; }
963 DECLARE_CONCRETE_INSTRUCTION(MathPowHalf, "math-pow-half")
967 class LCmpObjectEqAndBranch final : public LControlInstruction<2, 0> {
969 LCmpObjectEqAndBranch(LOperand* left, LOperand* right) {
974 LOperand* left() { return inputs_[0]; }
975 LOperand* right() { return inputs_[1]; }
977 DECLARE_CONCRETE_INSTRUCTION(CmpObjectEqAndBranch, "cmp-object-eq-and-branch")
981 class LCmpHoleAndBranch final : public LControlInstruction<1, 0> {
983 explicit LCmpHoleAndBranch(LOperand* object) {
987 LOperand* object() { return inputs_[0]; }
989 DECLARE_CONCRETE_INSTRUCTION(CmpHoleAndBranch, "cmp-hole-and-branch")
990 DECLARE_HYDROGEN_ACCESSOR(CompareHoleAndBranch)
994 class LCompareMinusZeroAndBranch final : public LControlInstruction<1, 0> {
996 explicit LCompareMinusZeroAndBranch(LOperand* value) { inputs_[0] = 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 LIsStringAndBranch final : public LControlInstruction<1, 1> {
1008 LIsStringAndBranch(LOperand* value, LOperand* temp) {
1013 LOperand* value() { return inputs_[0]; }
1014 LOperand* temp() { return temps_[0]; }
1016 DECLARE_CONCRETE_INSTRUCTION(IsStringAndBranch, "is-string-and-branch")
1017 DECLARE_HYDROGEN_ACCESSOR(IsStringAndBranch)
1019 void PrintDataTo(StringStream* stream) override;
1023 class LIsSmiAndBranch final : public LControlInstruction<1, 0> {
1025 explicit LIsSmiAndBranch(LOperand* value) {
1029 LOperand* value() { return inputs_[0]; }
1031 DECLARE_CONCRETE_INSTRUCTION(IsSmiAndBranch, "is-smi-and-branch")
1032 DECLARE_HYDROGEN_ACCESSOR(IsSmiAndBranch)
1034 void PrintDataTo(StringStream* stream) override;
1038 class LIsUndetectableAndBranch final : public LControlInstruction<1, 1> {
1040 LIsUndetectableAndBranch(LOperand* value, LOperand* temp) {
1045 LOperand* value() { return inputs_[0]; }
1046 LOperand* temp() { return temps_[0]; }
1048 DECLARE_CONCRETE_INSTRUCTION(IsUndetectableAndBranch,
1049 "is-undetectable-and-branch")
1050 DECLARE_HYDROGEN_ACCESSOR(IsUndetectableAndBranch)
1052 void PrintDataTo(StringStream* stream) override;
1056 class LStringCompareAndBranch final : public LControlInstruction<3, 0> {
1058 LStringCompareAndBranch(LOperand* context, LOperand* left, LOperand* right) {
1059 inputs_[0] = context;
1064 LOperand* context() { return inputs_[1]; }
1065 LOperand* left() { return inputs_[1]; }
1066 LOperand* right() { return inputs_[2]; }
1068 DECLARE_CONCRETE_INSTRUCTION(StringCompareAndBranch,
1069 "string-compare-and-branch")
1070 DECLARE_HYDROGEN_ACCESSOR(StringCompareAndBranch)
1072 void PrintDataTo(StringStream* stream) override;
1074 Token::Value op() const { return hydrogen()->token(); }
1078 class LHasInstanceTypeAndBranch final : public LControlInstruction<1, 1> {
1080 LHasInstanceTypeAndBranch(LOperand* value, LOperand* temp) {
1085 LOperand* value() { return inputs_[0]; }
1086 LOperand* temp() { return temps_[0]; }
1088 DECLARE_CONCRETE_INSTRUCTION(HasInstanceTypeAndBranch,
1089 "has-instance-type-and-branch")
1090 DECLARE_HYDROGEN_ACCESSOR(HasInstanceTypeAndBranch)
1092 void PrintDataTo(StringStream* stream) override;
1096 class LGetCachedArrayIndex final : public LTemplateInstruction<1, 1, 0> {
1098 explicit LGetCachedArrayIndex(LOperand* value) {
1102 LOperand* value() { return inputs_[0]; }
1104 DECLARE_CONCRETE_INSTRUCTION(GetCachedArrayIndex, "get-cached-array-index")
1105 DECLARE_HYDROGEN_ACCESSOR(GetCachedArrayIndex)
1109 class LHasCachedArrayIndexAndBranch final : public LControlInstruction<1, 0> {
1111 explicit LHasCachedArrayIndexAndBranch(LOperand* value) {
1115 LOperand* value() { return inputs_[0]; }
1117 DECLARE_CONCRETE_INSTRUCTION(HasCachedArrayIndexAndBranch,
1118 "has-cached-array-index-and-branch")
1120 void PrintDataTo(StringStream* stream) override;
1124 class LIsConstructCallAndBranch final : public LControlInstruction<0, 1> {
1126 explicit LIsConstructCallAndBranch(LOperand* temp) {
1130 LOperand* temp() { return temps_[0]; }
1132 DECLARE_CONCRETE_INSTRUCTION(IsConstructCallAndBranch,
1133 "is-construct-call-and-branch")
1137 class LClassOfTestAndBranch final : public LControlInstruction<1, 2> {
1139 LClassOfTestAndBranch(LOperand* value, LOperand* temp, LOperand* temp2) {
1145 LOperand* value() { return inputs_[0]; }
1146 LOperand* temp() { return temps_[0]; }
1147 LOperand* temp2() { return temps_[1]; }
1149 DECLARE_CONCRETE_INSTRUCTION(ClassOfTestAndBranch,
1150 "class-of-test-and-branch")
1151 DECLARE_HYDROGEN_ACCESSOR(ClassOfTestAndBranch)
1153 void PrintDataTo(StringStream* stream) override;
1157 class LCmpT final : public LTemplateInstruction<1, 3, 0> {
1159 LCmpT(LOperand* context, LOperand* left, LOperand* right) {
1160 inputs_[0] = context;
1165 DECLARE_CONCRETE_INSTRUCTION(CmpT, "cmp-t")
1166 DECLARE_HYDROGEN_ACCESSOR(CompareGeneric)
1168 Strength strength() { return hydrogen()->strength(); }
1170 LOperand* context() { return inputs_[0]; }
1171 Token::Value op() const { return hydrogen()->token(); }
1175 class LInstanceOf final : public LTemplateInstruction<1, 3, 0> {
1177 LInstanceOf(LOperand* context, LOperand* left, LOperand* right) {
1178 inputs_[0] = context;
1183 LOperand* context() const { return inputs_[0]; }
1184 LOperand* left() const { return inputs_[1]; }
1185 LOperand* right() const { return inputs_[2]; }
1187 DECLARE_CONCRETE_INSTRUCTION(InstanceOf, "instance-of")
1191 class LHasInPrototypeChainAndBranch final : public LControlInstruction<2, 1> {
1193 LHasInPrototypeChainAndBranch(LOperand* object, LOperand* prototype,
1194 LOperand* scratch) {
1195 inputs_[0] = object;
1196 inputs_[1] = prototype;
1197 temps_[0] = scratch;
1200 LOperand* object() const { return inputs_[0]; }
1201 LOperand* prototype() const { return inputs_[1]; }
1202 LOperand* scratch() const { return temps_[0]; }
1204 DECLARE_CONCRETE_INSTRUCTION(HasInPrototypeChainAndBranch,
1205 "has-in-prototype-chain-and-branch")
1206 DECLARE_HYDROGEN_ACCESSOR(HasInPrototypeChainAndBranch)
1210 class LBoundsCheck final : public LTemplateInstruction<0, 2, 0> {
1212 LBoundsCheck(LOperand* index, LOperand* length) {
1214 inputs_[1] = length;
1217 LOperand* index() { return inputs_[0]; }
1218 LOperand* length() { return inputs_[1]; }
1220 DECLARE_CONCRETE_INSTRUCTION(BoundsCheck, "bounds-check")
1221 DECLARE_HYDROGEN_ACCESSOR(BoundsCheck)
1225 class LBitI final : public LTemplateInstruction<1, 2, 0> {
1227 LBitI(LOperand* left, LOperand* right) {
1232 LOperand* left() { return inputs_[0]; }
1233 LOperand* right() { return inputs_[1]; }
1235 DECLARE_CONCRETE_INSTRUCTION(BitI, "bit-i")
1236 DECLARE_HYDROGEN_ACCESSOR(Bitwise)
1238 Token::Value op() const { return hydrogen()->op(); }
1242 class LShiftI final : public LTemplateInstruction<1, 2, 0> {
1244 LShiftI(Token::Value op, LOperand* left, LOperand* right, bool can_deopt)
1245 : op_(op), can_deopt_(can_deopt) {
1250 LOperand* left() { return inputs_[0]; }
1251 LOperand* right() { return inputs_[1]; }
1253 DECLARE_CONCRETE_INSTRUCTION(ShiftI, "shift-i")
1255 Token::Value op() const { return op_; }
1256 bool can_deopt() const { return can_deopt_; }
1264 class LSubI final : public LTemplateInstruction<1, 2, 0> {
1266 LSubI(LOperand* left, LOperand* right) {
1271 LOperand* left() { return inputs_[0]; }
1272 LOperand* right() { return inputs_[1]; }
1274 DECLARE_CONCRETE_INSTRUCTION(SubI, "sub-i")
1275 DECLARE_HYDROGEN_ACCESSOR(Sub)
1279 class LConstantI final : public LTemplateInstruction<1, 0, 0> {
1281 DECLARE_CONCRETE_INSTRUCTION(ConstantI, "constant-i")
1282 DECLARE_HYDROGEN_ACCESSOR(Constant)
1284 int32_t value() const { return hydrogen()->Integer32Value(); }
1288 class LConstantS final : public LTemplateInstruction<1, 0, 0> {
1290 DECLARE_CONCRETE_INSTRUCTION(ConstantS, "constant-s")
1291 DECLARE_HYDROGEN_ACCESSOR(Constant)
1293 Smi* value() const { return Smi::FromInt(hydrogen()->Integer32Value()); }
1297 class LConstantD final : public LTemplateInstruction<1, 0, 1> {
1299 DECLARE_CONCRETE_INSTRUCTION(ConstantD, "constant-d")
1300 DECLARE_HYDROGEN_ACCESSOR(Constant)
1302 uint64_t bits() const { return hydrogen()->DoubleValueAsBits(); }
1306 class LConstantE final : public LTemplateInstruction<1, 0, 0> {
1308 DECLARE_CONCRETE_INSTRUCTION(ConstantE, "constant-e")
1309 DECLARE_HYDROGEN_ACCESSOR(Constant)
1311 ExternalReference value() const {
1312 return hydrogen()->ExternalReferenceValue();
1317 class LConstantT final : public LTemplateInstruction<1, 0, 0> {
1319 DECLARE_CONCRETE_INSTRUCTION(ConstantT, "constant-t")
1320 DECLARE_HYDROGEN_ACCESSOR(Constant)
1322 Handle<Object> value(Isolate* isolate) const {
1323 return hydrogen()->handle(isolate);
1328 class LBranch final : public LControlInstruction<1, 1> {
1330 LBranch(LOperand* value, LOperand* temp) {
1335 LOperand* value() { return inputs_[0]; }
1336 LOperand* temp() { return temps_[0]; }
1338 DECLARE_CONCRETE_INSTRUCTION(Branch, "branch")
1339 DECLARE_HYDROGEN_ACCESSOR(Branch)
1341 void PrintDataTo(StringStream* stream) override;
1345 class LCmpMapAndBranch final : public LControlInstruction<1, 0> {
1347 explicit LCmpMapAndBranch(LOperand* value) {
1351 LOperand* value() { return inputs_[0]; }
1353 DECLARE_CONCRETE_INSTRUCTION(CmpMapAndBranch, "cmp-map-and-branch")
1354 DECLARE_HYDROGEN_ACCESSOR(CompareMap)
1356 Handle<Map> map() const { return hydrogen()->map().handle(); }
1360 class LMapEnumLength final : public LTemplateInstruction<1, 1, 0> {
1362 explicit LMapEnumLength(LOperand* value) {
1366 LOperand* value() { return inputs_[0]; }
1368 DECLARE_CONCRETE_INSTRUCTION(MapEnumLength, "map-enum-length")
1372 class LDateField final : public LTemplateInstruction<1, 1, 1> {
1374 LDateField(LOperand* date, LOperand* temp, Smi* index)
1380 LOperand* date() { return inputs_[0]; }
1381 LOperand* temp() { return temps_[0]; }
1383 DECLARE_CONCRETE_INSTRUCTION(DateField, "date-field")
1384 DECLARE_HYDROGEN_ACCESSOR(DateField)
1386 Smi* index() const { return index_; }
1393 class LSeqStringGetChar final : public LTemplateInstruction<1, 2, 0> {
1395 LSeqStringGetChar(LOperand* string, LOperand* index) {
1396 inputs_[0] = string;
1400 LOperand* string() const { return inputs_[0]; }
1401 LOperand* index() const { return inputs_[1]; }
1403 DECLARE_CONCRETE_INSTRUCTION(SeqStringGetChar, "seq-string-get-char")
1404 DECLARE_HYDROGEN_ACCESSOR(SeqStringGetChar)
1408 class LSeqStringSetChar final : public LTemplateInstruction<1, 4, 0> {
1410 LSeqStringSetChar(LOperand* context,
1414 inputs_[0] = context;
1415 inputs_[1] = string;
1420 LOperand* string() { return inputs_[1]; }
1421 LOperand* index() { return inputs_[2]; }
1422 LOperand* value() { return inputs_[3]; }
1424 DECLARE_CONCRETE_INSTRUCTION(SeqStringSetChar, "seq-string-set-char")
1425 DECLARE_HYDROGEN_ACCESSOR(SeqStringSetChar)
1429 class LAddI final : public LTemplateInstruction<1, 2, 0> {
1431 LAddI(LOperand* left, LOperand* right) {
1436 LOperand* left() { return inputs_[0]; }
1437 LOperand* right() { return inputs_[1]; }
1439 static bool UseLea(HAdd* add) {
1440 return !add->CheckFlag(HValue::kCanOverflow) &&
1441 add->BetterLeftOperand()->UseCount() > 1;
1444 DECLARE_CONCRETE_INSTRUCTION(AddI, "add-i")
1445 DECLARE_HYDROGEN_ACCESSOR(Add)
1449 class LMathMinMax final : public LTemplateInstruction<1, 2, 1> {
1451 LMathMinMax(LOperand* left, LOperand* right, LOperand* temp) {
1457 LOperand* left() { return inputs_[0]; }
1458 LOperand* right() { return inputs_[1]; }
1459 LOperand* temp() { return temps_[0]; }
1461 DECLARE_CONCRETE_INSTRUCTION(MathMinMax, "math-min-max")
1462 DECLARE_HYDROGEN_ACCESSOR(MathMinMax)
1466 class LPower final : public LTemplateInstruction<1, 2, 0> {
1468 LPower(LOperand* left, LOperand* right) {
1473 LOperand* left() { return inputs_[0]; }
1474 LOperand* right() { return inputs_[1]; }
1476 DECLARE_CONCRETE_INSTRUCTION(Power, "power")
1477 DECLARE_HYDROGEN_ACCESSOR(Power)
1481 class LArithmeticD final : public LTemplateInstruction<1, 2, 0> {
1483 LArithmeticD(Token::Value op, LOperand* left, LOperand* right)
1489 LOperand* left() { return inputs_[0]; }
1490 LOperand* right() { return inputs_[1]; }
1492 Token::Value op() const { return op_; }
1494 Opcode opcode() const override { return LInstruction::kArithmeticD; }
1495 void CompileToNative(LCodeGen* generator) override;
1496 const char* Mnemonic() const override;
1503 class LArithmeticT final : public LTemplateInstruction<1, 3, 0> {
1505 LArithmeticT(Token::Value op,
1510 inputs_[0] = context;
1515 LOperand* context() { return inputs_[0]; }
1516 LOperand* left() { return inputs_[1]; }
1517 LOperand* right() { return inputs_[2]; }
1518 Token::Value op() const { return op_; }
1520 Opcode opcode() const override { return LInstruction::kArithmeticT; }
1521 void CompileToNative(LCodeGen* generator) override;
1522 const char* Mnemonic() const override;
1524 DECLARE_HYDROGEN_ACCESSOR(BinaryOperation)
1526 Strength strength() { return hydrogen()->strength(); }
1533 class LReturn final : public LTemplateInstruction<0, 3, 0> {
1535 explicit LReturn(LOperand* value,
1537 LOperand* parameter_count) {
1539 inputs_[1] = context;
1540 inputs_[2] = parameter_count;
1543 bool has_constant_parameter_count() {
1544 return parameter_count()->IsConstantOperand();
1546 LConstantOperand* constant_parameter_count() {
1547 DCHECK(has_constant_parameter_count());
1548 return LConstantOperand::cast(parameter_count());
1550 LOperand* parameter_count() { return inputs_[2]; }
1552 DECLARE_CONCRETE_INSTRUCTION(Return, "return")
1553 DECLARE_HYDROGEN_ACCESSOR(Return)
1557 class LLoadNamedField final : public LTemplateInstruction<1, 1, 0> {
1559 explicit LLoadNamedField(LOperand* object) {
1560 inputs_[0] = object;
1563 LOperand* object() { return inputs_[0]; }
1565 DECLARE_CONCRETE_INSTRUCTION(LoadNamedField, "load-named-field")
1566 DECLARE_HYDROGEN_ACCESSOR(LoadNamedField)
1570 class LLoadNamedGeneric final : public LTemplateInstruction<1, 2, 1> {
1572 LLoadNamedGeneric(LOperand* context, LOperand* object, LOperand* vector) {
1573 inputs_[0] = context;
1574 inputs_[1] = object;
1578 LOperand* context() { return inputs_[0]; }
1579 LOperand* object() { return inputs_[1]; }
1580 LOperand* temp_vector() { return temps_[0]; }
1582 DECLARE_CONCRETE_INSTRUCTION(LoadNamedGeneric, "load-named-generic")
1583 DECLARE_HYDROGEN_ACCESSOR(LoadNamedGeneric)
1585 Handle<Object> name() const { return hydrogen()->name(); }
1589 class LLoadFunctionPrototype final : public LTemplateInstruction<1, 1, 1> {
1591 LLoadFunctionPrototype(LOperand* function, LOperand* temp) {
1592 inputs_[0] = function;
1596 LOperand* function() { return inputs_[0]; }
1597 LOperand* temp() { return temps_[0]; }
1599 DECLARE_CONCRETE_INSTRUCTION(LoadFunctionPrototype, "load-function-prototype")
1600 DECLARE_HYDROGEN_ACCESSOR(LoadFunctionPrototype)
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 class LLoadKeyed final : public LTemplateInstruction<1, 2, 0> {
1615 LLoadKeyed(LOperand* elements, LOperand* key) {
1616 inputs_[0] = elements;
1619 LOperand* elements() { return inputs_[0]; }
1620 LOperand* key() { return inputs_[1]; }
1621 ElementsKind elements_kind() const {
1622 return hydrogen()->elements_kind();
1624 bool is_fixed_typed_array() const {
1625 return hydrogen()->is_fixed_typed_array();
1628 DECLARE_CONCRETE_INSTRUCTION(LoadKeyed, "load-keyed")
1629 DECLARE_HYDROGEN_ACCESSOR(LoadKeyed)
1631 void PrintDataTo(StringStream* stream) override;
1632 uint32_t base_offset() const { return hydrogen()->base_offset(); }
1634 return hydrogen()->key()->representation().IsTagged();
1639 inline static bool ExternalArrayOpRequiresTemp(
1640 Representation key_representation,
1641 ElementsKind elements_kind) {
1642 // Operations that require the key to be divided by two to be converted into
1643 // an index cannot fold the scale operation into a load and need an extra
1644 // temp register to do the work.
1645 return key_representation.IsSmi() &&
1646 (elements_kind == UINT8_ELEMENTS || elements_kind == INT8_ELEMENTS ||
1647 elements_kind == UINT8_CLAMPED_ELEMENTS);
1651 class LLoadKeyedGeneric final : public LTemplateInstruction<1, 3, 1> {
1653 LLoadKeyedGeneric(LOperand* context, LOperand* obj, LOperand* key,
1655 inputs_[0] = context;
1661 LOperand* context() { return inputs_[0]; }
1662 LOperand* object() { return inputs_[1]; }
1663 LOperand* key() { return inputs_[2]; }
1664 LOperand* temp_vector() { return temps_[0]; }
1666 DECLARE_CONCRETE_INSTRUCTION(LoadKeyedGeneric, "load-keyed-generic")
1667 DECLARE_HYDROGEN_ACCESSOR(LoadKeyedGeneric)
1671 class LLoadGlobalGeneric final : public LTemplateInstruction<1, 2, 1> {
1673 LLoadGlobalGeneric(LOperand* context, LOperand* global_object,
1675 inputs_[0] = context;
1676 inputs_[1] = global_object;
1680 LOperand* context() { return inputs_[0]; }
1681 LOperand* global_object() { return inputs_[1]; }
1682 LOperand* temp_vector() { return temps_[0]; }
1684 DECLARE_CONCRETE_INSTRUCTION(LoadGlobalGeneric, "load-global-generic")
1685 DECLARE_HYDROGEN_ACCESSOR(LoadGlobalGeneric)
1687 Handle<Object> name() const { return hydrogen()->name(); }
1688 TypeofMode typeof_mode() const { return hydrogen()->typeof_mode(); }
1692 class LLoadGlobalViaContext final : public LTemplateInstruction<1, 1, 1> {
1694 explicit LLoadGlobalViaContext(LOperand* context) { inputs_[0] = context; }
1696 DECLARE_CONCRETE_INSTRUCTION(LoadGlobalViaContext, "load-global-via-context")
1697 DECLARE_HYDROGEN_ACCESSOR(LoadGlobalViaContext)
1699 void PrintDataTo(StringStream* stream) override;
1701 LOperand* context() { return inputs_[0]; }
1703 int depth() const { return hydrogen()->depth(); }
1704 int slot_index() const { return hydrogen()->slot_index(); }
1708 class LLoadContextSlot final : public LTemplateInstruction<1, 1, 0> {
1710 explicit LLoadContextSlot(LOperand* context) {
1711 inputs_[0] = context;
1714 LOperand* context() { return inputs_[0]; }
1716 DECLARE_CONCRETE_INSTRUCTION(LoadContextSlot, "load-context-slot")
1717 DECLARE_HYDROGEN_ACCESSOR(LoadContextSlot)
1719 int slot_index() { return hydrogen()->slot_index(); }
1721 void PrintDataTo(StringStream* stream) override;
1725 class LStoreContextSlot final : public LTemplateInstruction<0, 2, 1> {
1727 LStoreContextSlot(LOperand* context, LOperand* value, LOperand* temp) {
1728 inputs_[0] = context;
1733 LOperand* context() { return inputs_[0]; }
1734 LOperand* value() { return inputs_[1]; }
1735 LOperand* temp() { return temps_[0]; }
1737 DECLARE_CONCRETE_INSTRUCTION(StoreContextSlot, "store-context-slot")
1738 DECLARE_HYDROGEN_ACCESSOR(StoreContextSlot)
1740 int slot_index() { return hydrogen()->slot_index(); }
1742 void PrintDataTo(StringStream* stream) override;
1746 class LPushArgument final : public LTemplateInstruction<0, 1, 0> {
1748 explicit LPushArgument(LOperand* value) {
1752 LOperand* value() { return inputs_[0]; }
1754 DECLARE_CONCRETE_INSTRUCTION(PushArgument, "push-argument")
1758 class LDrop final : public LTemplateInstruction<0, 0, 0> {
1760 explicit LDrop(int count) : count_(count) { }
1762 int count() const { return count_; }
1764 DECLARE_CONCRETE_INSTRUCTION(Drop, "drop")
1771 class LStoreCodeEntry final : public LTemplateInstruction<0, 2, 0> {
1773 LStoreCodeEntry(LOperand* function, LOperand* code_object) {
1774 inputs_[0] = function;
1775 inputs_[1] = code_object;
1778 LOperand* function() { return inputs_[0]; }
1779 LOperand* code_object() { return inputs_[1]; }
1781 void PrintDataTo(StringStream* stream) override;
1783 DECLARE_CONCRETE_INSTRUCTION(StoreCodeEntry, "store-code-entry")
1784 DECLARE_HYDROGEN_ACCESSOR(StoreCodeEntry)
1788 class LInnerAllocatedObject final : public LTemplateInstruction<1, 2, 0> {
1790 LInnerAllocatedObject(LOperand* base_object, LOperand* offset) {
1791 inputs_[0] = base_object;
1792 inputs_[1] = offset;
1795 LOperand* base_object() const { return inputs_[0]; }
1796 LOperand* offset() const { return inputs_[1]; }
1798 void PrintDataTo(StringStream* stream) override;
1800 DECLARE_CONCRETE_INSTRUCTION(InnerAllocatedObject, "inner-allocated-object")
1804 class LThisFunction final : public LTemplateInstruction<1, 0, 0> {
1806 DECLARE_CONCRETE_INSTRUCTION(ThisFunction, "this-function")
1807 DECLARE_HYDROGEN_ACCESSOR(ThisFunction)
1811 class LContext final : public LTemplateInstruction<1, 0, 0> {
1813 DECLARE_CONCRETE_INSTRUCTION(Context, "context")
1814 DECLARE_HYDROGEN_ACCESSOR(Context)
1818 class LDeclareGlobals final : public LTemplateInstruction<0, 1, 0> {
1820 explicit LDeclareGlobals(LOperand* context) {
1821 inputs_[0] = context;
1824 LOperand* context() { return inputs_[0]; }
1826 DECLARE_CONCRETE_INSTRUCTION(DeclareGlobals, "declare-globals")
1827 DECLARE_HYDROGEN_ACCESSOR(DeclareGlobals)
1831 class LCallJSFunction final : public LTemplateInstruction<1, 1, 0> {
1833 explicit LCallJSFunction(LOperand* function) {
1834 inputs_[0] = function;
1837 LOperand* function() { return inputs_[0]; }
1839 DECLARE_CONCRETE_INSTRUCTION(CallJSFunction, "call-js-function")
1840 DECLARE_HYDROGEN_ACCESSOR(CallJSFunction)
1842 void PrintDataTo(StringStream* stream) override;
1844 int arity() const { return hydrogen()->argument_count() - 1; }
1848 class LCallWithDescriptor final : public LTemplateResultInstruction<1> {
1850 LCallWithDescriptor(CallInterfaceDescriptor descriptor,
1851 const ZoneList<LOperand*>& operands, Zone* zone)
1852 : inputs_(descriptor.GetRegisterParameterCount() +
1853 kImplicitRegisterParameterCount,
1855 DCHECK(descriptor.GetRegisterParameterCount() +
1856 kImplicitRegisterParameterCount ==
1858 inputs_.AddAll(operands, zone);
1861 LOperand* target() const { return inputs_[0]; }
1863 DECLARE_HYDROGEN_ACCESSOR(CallWithDescriptor)
1865 // The target and context are passed as implicit parameters that are not
1866 // explicitly listed in the descriptor.
1867 static const int kImplicitRegisterParameterCount = 2;
1870 DECLARE_CONCRETE_INSTRUCTION(CallWithDescriptor, "call-with-descriptor")
1872 void PrintDataTo(StringStream* stream) override;
1874 int arity() const { return hydrogen()->argument_count() - 1; }
1876 ZoneList<LOperand*> inputs_;
1878 // Iterator support.
1879 int InputCount() final { return inputs_.length(); }
1880 LOperand* InputAt(int i) final { return inputs_[i]; }
1882 int TempCount() final { return 0; }
1883 LOperand* TempAt(int i) final { return NULL; }
1887 class LInvokeFunction final : public LTemplateInstruction<1, 2, 0> {
1889 LInvokeFunction(LOperand* context, LOperand* function) {
1890 inputs_[0] = context;
1891 inputs_[1] = function;
1894 LOperand* context() { return inputs_[0]; }
1895 LOperand* function() { return inputs_[1]; }
1897 DECLARE_CONCRETE_INSTRUCTION(InvokeFunction, "invoke-function")
1898 DECLARE_HYDROGEN_ACCESSOR(InvokeFunction)
1900 void PrintDataTo(StringStream* stream) override;
1902 int arity() const { return hydrogen()->argument_count() - 1; }
1906 class LCallFunction final : public LTemplateInstruction<1, 2, 2> {
1908 LCallFunction(LOperand* context, LOperand* function, LOperand* slot,
1910 inputs_[0] = context;
1911 inputs_[1] = function;
1916 LOperand* context() { return inputs_[0]; }
1917 LOperand* function() { return inputs_[1]; }
1918 LOperand* temp_slot() { return temps_[0]; }
1919 LOperand* temp_vector() { return temps_[1]; }
1921 DECLARE_CONCRETE_INSTRUCTION(CallFunction, "call-function")
1922 DECLARE_HYDROGEN_ACCESSOR(CallFunction)
1924 void PrintDataTo(StringStream* stream) override;
1925 int arity() const { return hydrogen()->argument_count() - 1; }
1929 class LCallNew final : public LTemplateInstruction<1, 2, 0> {
1931 LCallNew(LOperand* context, LOperand* constructor) {
1932 inputs_[0] = context;
1933 inputs_[1] = constructor;
1936 LOperand* context() { return inputs_[0]; }
1937 LOperand* constructor() { return inputs_[1]; }
1939 DECLARE_CONCRETE_INSTRUCTION(CallNew, "call-new")
1940 DECLARE_HYDROGEN_ACCESSOR(CallNew)
1942 void PrintDataTo(StringStream* stream) override;
1944 int arity() const { return hydrogen()->argument_count() - 1; }
1948 class LCallNewArray final : public LTemplateInstruction<1, 2, 0> {
1950 LCallNewArray(LOperand* context, LOperand* constructor) {
1951 inputs_[0] = context;
1952 inputs_[1] = constructor;
1955 LOperand* context() { return inputs_[0]; }
1956 LOperand* constructor() { return inputs_[1]; }
1958 DECLARE_CONCRETE_INSTRUCTION(CallNewArray, "call-new-array")
1959 DECLARE_HYDROGEN_ACCESSOR(CallNewArray)
1961 void PrintDataTo(StringStream* stream) override;
1963 int arity() const { return hydrogen()->argument_count() - 1; }
1967 class LCallRuntime final : public LTemplateInstruction<1, 1, 0> {
1969 explicit LCallRuntime(LOperand* context) {
1970 inputs_[0] = context;
1973 LOperand* context() { return inputs_[0]; }
1975 DECLARE_CONCRETE_INSTRUCTION(CallRuntime, "call-runtime")
1976 DECLARE_HYDROGEN_ACCESSOR(CallRuntime)
1978 bool ClobbersDoubleRegisters(Isolate* isolate) const override {
1979 return save_doubles() == kDontSaveFPRegs;
1982 const Runtime::Function* function() const { return hydrogen()->function(); }
1983 int arity() const { return hydrogen()->argument_count(); }
1984 SaveFPRegsMode save_doubles() const { return hydrogen()->save_doubles(); }
1988 class LInteger32ToDouble final : public LTemplateInstruction<1, 1, 0> {
1990 explicit LInteger32ToDouble(LOperand* value) {
1994 LOperand* value() { return inputs_[0]; }
1996 DECLARE_CONCRETE_INSTRUCTION(Integer32ToDouble, "int32-to-double")
2000 class LUint32ToDouble final : public LTemplateInstruction<1, 1, 1> {
2002 explicit LUint32ToDouble(LOperand* value) {
2006 LOperand* value() { return inputs_[0]; }
2008 DECLARE_CONCRETE_INSTRUCTION(Uint32ToDouble, "uint32-to-double")
2012 class LNumberTagI final : public LTemplateInstruction<1, 1, 1> {
2014 LNumberTagI(LOperand* value, LOperand* temp) {
2019 LOperand* value() { return inputs_[0]; }
2020 LOperand* temp() { return temps_[0]; }
2022 DECLARE_CONCRETE_INSTRUCTION(NumberTagI, "number-tag-i")
2026 class LNumberTagU final : public LTemplateInstruction<1, 1, 1> {
2028 LNumberTagU(LOperand* value, LOperand* temp) {
2033 LOperand* value() { return inputs_[0]; }
2034 LOperand* temp() { return temps_[0]; }
2036 DECLARE_CONCRETE_INSTRUCTION(NumberTagU, "number-tag-u")
2040 class LNumberTagD final : public LTemplateInstruction<1, 1, 1> {
2042 LNumberTagD(LOperand* value, LOperand* temp) {
2047 LOperand* value() { return inputs_[0]; }
2048 LOperand* temp() { return temps_[0]; }
2050 DECLARE_CONCRETE_INSTRUCTION(NumberTagD, "number-tag-d")
2051 DECLARE_HYDROGEN_ACCESSOR(Change)
2055 // Sometimes truncating conversion from a tagged value to an int32.
2056 class LDoubleToI final : public LTemplateInstruction<1, 1, 0> {
2058 explicit LDoubleToI(LOperand* value) {
2062 LOperand* value() { return inputs_[0]; }
2064 DECLARE_CONCRETE_INSTRUCTION(DoubleToI, "double-to-i")
2065 DECLARE_HYDROGEN_ACCESSOR(UnaryOperation)
2067 bool truncating() { return hydrogen()->CanTruncateToInt32(); }
2071 class LDoubleToSmi final : public LTemplateInstruction<1, 1, 0> {
2073 explicit LDoubleToSmi(LOperand* value) {
2077 LOperand* value() { return inputs_[0]; }
2079 DECLARE_CONCRETE_INSTRUCTION(DoubleToSmi, "double-to-smi")
2080 DECLARE_HYDROGEN_ACCESSOR(UnaryOperation)
2084 // Truncating conversion from a tagged value to an int32.
2085 class LTaggedToI final : public LTemplateInstruction<1, 1, 0> {
2087 explicit LTaggedToI(LOperand* value) {
2091 LOperand* value() { return inputs_[0]; }
2093 DECLARE_CONCRETE_INSTRUCTION(TaggedToI, "tagged-to-i")
2094 DECLARE_HYDROGEN_ACCESSOR(Change)
2096 bool truncating() { return hydrogen()->CanTruncateToInt32(); }
2100 class LSmiTag final : public LTemplateInstruction<1, 1, 0> {
2102 explicit LSmiTag(LOperand* value) {
2106 LOperand* value() { return inputs_[0]; }
2108 DECLARE_CONCRETE_INSTRUCTION(SmiTag, "smi-tag")
2109 DECLARE_HYDROGEN_ACCESSOR(Change)
2113 class LNumberUntagD final : public LTemplateInstruction<1, 1, 1> {
2115 explicit LNumberUntagD(LOperand* value, LOperand* temp) {
2120 LOperand* value() { return inputs_[0]; }
2121 LOperand* temp() { return temps_[0]; }
2123 DECLARE_CONCRETE_INSTRUCTION(NumberUntagD, "double-untag")
2124 DECLARE_HYDROGEN_ACCESSOR(Change);
2128 class LSmiUntag final : public LTemplateInstruction<1, 1, 0> {
2130 LSmiUntag(LOperand* value, bool needs_check)
2131 : needs_check_(needs_check) {
2135 LOperand* value() { return inputs_[0]; }
2137 DECLARE_CONCRETE_INSTRUCTION(SmiUntag, "smi-untag")
2139 bool needs_check() const { return needs_check_; }
2146 class LStoreNamedField final : public LTemplateInstruction<0, 2, 2> {
2148 LStoreNamedField(LOperand* obj,
2151 LOperand* temp_map) {
2155 temps_[1] = temp_map;
2158 LOperand* object() { return inputs_[0]; }
2159 LOperand* value() { return inputs_[1]; }
2160 LOperand* temp() { return temps_[0]; }
2161 LOperand* temp_map() { return temps_[1]; }
2163 DECLARE_CONCRETE_INSTRUCTION(StoreNamedField, "store-named-field")
2164 DECLARE_HYDROGEN_ACCESSOR(StoreNamedField)
2166 void PrintDataTo(StringStream* stream) override;
2170 class LStoreNamedGeneric final : public LTemplateInstruction<0, 3, 2> {
2172 LStoreNamedGeneric(LOperand* context, LOperand* object, LOperand* value,
2173 LOperand* slot, LOperand* vector) {
2174 inputs_[0] = context;
2175 inputs_[1] = object;
2181 LOperand* context() { return inputs_[0]; }
2182 LOperand* object() { return inputs_[1]; }
2183 LOperand* value() { return inputs_[2]; }
2184 LOperand* temp_slot() { return temps_[0]; }
2185 LOperand* temp_vector() { return temps_[1]; }
2187 DECLARE_CONCRETE_INSTRUCTION(StoreNamedGeneric, "store-named-generic")
2188 DECLARE_HYDROGEN_ACCESSOR(StoreNamedGeneric)
2190 void PrintDataTo(StringStream* stream) override;
2191 Handle<Object> name() const { return hydrogen()->name(); }
2192 LanguageMode language_mode() { return hydrogen()->language_mode(); }
2196 class LStoreGlobalViaContext final : public LTemplateInstruction<0, 2, 0> {
2198 LStoreGlobalViaContext(LOperand* context, LOperand* value) {
2199 inputs_[0] = context;
2203 LOperand* context() { return inputs_[0]; }
2204 LOperand* value() { return inputs_[1]; }
2206 DECLARE_CONCRETE_INSTRUCTION(StoreGlobalViaContext,
2207 "store-global-via-context")
2208 DECLARE_HYDROGEN_ACCESSOR(StoreGlobalViaContext)
2210 void PrintDataTo(StringStream* stream) override;
2212 int depth() { return hydrogen()->depth(); }
2213 int slot_index() { return hydrogen()->slot_index(); }
2214 LanguageMode language_mode() { return hydrogen()->language_mode(); }
2218 class LStoreKeyed final : public LTemplateInstruction<0, 3, 0> {
2220 LStoreKeyed(LOperand* obj, LOperand* key, LOperand* val) {
2226 bool is_fixed_typed_array() const {
2227 return hydrogen()->is_fixed_typed_array();
2229 LOperand* elements() { return inputs_[0]; }
2230 LOperand* key() { return inputs_[1]; }
2231 LOperand* value() { return inputs_[2]; }
2232 ElementsKind elements_kind() const {
2233 return hydrogen()->elements_kind();
2236 DECLARE_CONCRETE_INSTRUCTION(StoreKeyed, "store-keyed")
2237 DECLARE_HYDROGEN_ACCESSOR(StoreKeyed)
2239 void PrintDataTo(StringStream* stream) override;
2240 uint32_t base_offset() const { return hydrogen()->base_offset(); }
2241 bool NeedsCanonicalization() { return hydrogen()->NeedsCanonicalization(); }
2245 class LStoreKeyedGeneric final : public LTemplateInstruction<0, 4, 2> {
2247 LStoreKeyedGeneric(LOperand* context, LOperand* object, LOperand* key,
2248 LOperand* value, LOperand* slot, LOperand* vector) {
2249 inputs_[0] = context;
2250 inputs_[1] = object;
2257 LOperand* context() { return inputs_[0]; }
2258 LOperand* object() { return inputs_[1]; }
2259 LOperand* key() { return inputs_[2]; }
2260 LOperand* value() { return inputs_[3]; }
2261 LOperand* temp_slot() { return temps_[0]; }
2262 LOperand* temp_vector() { return temps_[1]; }
2264 DECLARE_CONCRETE_INSTRUCTION(StoreKeyedGeneric, "store-keyed-generic")
2265 DECLARE_HYDROGEN_ACCESSOR(StoreKeyedGeneric)
2267 void PrintDataTo(StringStream* stream) override;
2269 LanguageMode language_mode() { return hydrogen()->language_mode(); }
2273 class LTransitionElementsKind final : public LTemplateInstruction<0, 2, 2> {
2275 LTransitionElementsKind(LOperand* object,
2277 LOperand* new_map_temp,
2279 inputs_[0] = object;
2280 inputs_[1] = context;
2281 temps_[0] = new_map_temp;
2285 LOperand* context() { return inputs_[1]; }
2286 LOperand* object() { return inputs_[0]; }
2287 LOperand* new_map_temp() { return temps_[0]; }
2288 LOperand* temp() { return temps_[1]; }
2290 DECLARE_CONCRETE_INSTRUCTION(TransitionElementsKind,
2291 "transition-elements-kind")
2292 DECLARE_HYDROGEN_ACCESSOR(TransitionElementsKind)
2294 void PrintDataTo(StringStream* stream) override;
2296 Handle<Map> original_map() { return hydrogen()->original_map().handle(); }
2297 Handle<Map> transitioned_map() {
2298 return hydrogen()->transitioned_map().handle();
2300 ElementsKind from_kind() { return hydrogen()->from_kind(); }
2301 ElementsKind to_kind() { return hydrogen()->to_kind(); }
2305 class LTrapAllocationMemento final : public LTemplateInstruction<0, 1, 1> {
2307 LTrapAllocationMemento(LOperand* object,
2309 inputs_[0] = object;
2313 LOperand* object() { return inputs_[0]; }
2314 LOperand* temp() { return temps_[0]; }
2316 DECLARE_CONCRETE_INSTRUCTION(TrapAllocationMemento,
2317 "trap-allocation-memento")
2321 class LMaybeGrowElements final : public LTemplateInstruction<1, 5, 0> {
2323 LMaybeGrowElements(LOperand* context, LOperand* object, LOperand* elements,
2324 LOperand* key, LOperand* current_capacity) {
2325 inputs_[0] = context;
2326 inputs_[1] = object;
2327 inputs_[2] = elements;
2329 inputs_[4] = current_capacity;
2332 LOperand* context() { return inputs_[0]; }
2333 LOperand* object() { return inputs_[1]; }
2334 LOperand* elements() { return inputs_[2]; }
2335 LOperand* key() { return inputs_[3]; }
2336 LOperand* current_capacity() { return inputs_[4]; }
2338 DECLARE_HYDROGEN_ACCESSOR(MaybeGrowElements)
2339 DECLARE_CONCRETE_INSTRUCTION(MaybeGrowElements, "maybe-grow-elements")
2343 class LStringAdd final : public LTemplateInstruction<1, 3, 0> {
2345 LStringAdd(LOperand* context, LOperand* left, LOperand* right) {
2346 inputs_[0] = context;
2351 LOperand* context() { return inputs_[0]; }
2352 LOperand* left() { return inputs_[1]; }
2353 LOperand* right() { return inputs_[2]; }
2355 DECLARE_CONCRETE_INSTRUCTION(StringAdd, "string-add")
2356 DECLARE_HYDROGEN_ACCESSOR(StringAdd)
2360 class LStringCharCodeAt final : public LTemplateInstruction<1, 3, 0> {
2362 LStringCharCodeAt(LOperand* context, LOperand* string, LOperand* index) {
2363 inputs_[0] = context;
2364 inputs_[1] = string;
2368 LOperand* context() { return inputs_[0]; }
2369 LOperand* string() { return inputs_[1]; }
2370 LOperand* index() { return inputs_[2]; }
2372 DECLARE_CONCRETE_INSTRUCTION(StringCharCodeAt, "string-char-code-at")
2373 DECLARE_HYDROGEN_ACCESSOR(StringCharCodeAt)
2377 class LStringCharFromCode final : public LTemplateInstruction<1, 2, 0> {
2379 LStringCharFromCode(LOperand* context, LOperand* char_code) {
2380 inputs_[0] = context;
2381 inputs_[1] = char_code;
2384 LOperand* context() { return inputs_[0]; }
2385 LOperand* char_code() { return inputs_[1]; }
2387 DECLARE_CONCRETE_INSTRUCTION(StringCharFromCode, "string-char-from-code")
2388 DECLARE_HYDROGEN_ACCESSOR(StringCharFromCode)
2392 class LCheckValue final : public LTemplateInstruction<0, 1, 0> {
2394 explicit LCheckValue(LOperand* value) {
2398 LOperand* value() { return inputs_[0]; }
2400 DECLARE_CONCRETE_INSTRUCTION(CheckValue, "check-value")
2401 DECLARE_HYDROGEN_ACCESSOR(CheckValue)
2405 class LCheckArrayBufferNotNeutered final
2406 : public LTemplateInstruction<0, 1, 1> {
2408 explicit LCheckArrayBufferNotNeutered(LOperand* view, LOperand* scratch) {
2410 temps_[0] = scratch;
2413 LOperand* view() { return inputs_[0]; }
2414 LOperand* scratch() { return temps_[0]; }
2416 DECLARE_CONCRETE_INSTRUCTION(CheckArrayBufferNotNeutered,
2417 "check-array-buffer-not-neutered")
2418 DECLARE_HYDROGEN_ACCESSOR(CheckArrayBufferNotNeutered)
2422 class LCheckInstanceType final : public LTemplateInstruction<0, 1, 1> {
2424 LCheckInstanceType(LOperand* value, LOperand* temp) {
2429 LOperand* value() { return inputs_[0]; }
2430 LOperand* temp() { return temps_[0]; }
2432 DECLARE_CONCRETE_INSTRUCTION(CheckInstanceType, "check-instance-type")
2433 DECLARE_HYDROGEN_ACCESSOR(CheckInstanceType)
2437 class LCheckMaps final : public LTemplateInstruction<0, 1, 0> {
2439 explicit LCheckMaps(LOperand* value = NULL) {
2443 LOperand* value() { return inputs_[0]; }
2445 DECLARE_CONCRETE_INSTRUCTION(CheckMaps, "check-maps")
2446 DECLARE_HYDROGEN_ACCESSOR(CheckMaps)
2450 class LCheckSmi final : public LTemplateInstruction<1, 1, 0> {
2452 explicit LCheckSmi(LOperand* value) {
2456 LOperand* value() { return inputs_[0]; }
2458 DECLARE_CONCRETE_INSTRUCTION(CheckSmi, "check-smi")
2462 class LClampDToUint8 final : public LTemplateInstruction<1, 1, 0> {
2464 explicit LClampDToUint8(LOperand* value) {
2468 LOperand* unclamped() { return inputs_[0]; }
2470 DECLARE_CONCRETE_INSTRUCTION(ClampDToUint8, "clamp-d-to-uint8")
2474 class LClampIToUint8 final : public LTemplateInstruction<1, 1, 0> {
2476 explicit LClampIToUint8(LOperand* value) {
2480 LOperand* unclamped() { return inputs_[0]; }
2482 DECLARE_CONCRETE_INSTRUCTION(ClampIToUint8, "clamp-i-to-uint8")
2486 // Truncating conversion from a tagged value to an int32.
2487 class LClampTToUint8NoSSE2 final : public LTemplateInstruction<1, 1, 3> {
2489 LClampTToUint8NoSSE2(LOperand* unclamped,
2493 inputs_[0] = unclamped;
2499 LOperand* unclamped() { return inputs_[0]; }
2500 LOperand* scratch() { return temps_[0]; }
2501 LOperand* scratch2() { return temps_[1]; }
2502 LOperand* scratch3() { return temps_[2]; }
2504 DECLARE_CONCRETE_INSTRUCTION(ClampTToUint8NoSSE2,
2505 "clamp-t-to-uint8-nosse2")
2506 DECLARE_HYDROGEN_ACCESSOR(UnaryOperation)
2510 class LCheckNonSmi final : public LTemplateInstruction<0, 1, 0> {
2512 explicit LCheckNonSmi(LOperand* value) {
2516 LOperand* value() { return inputs_[0]; }
2518 DECLARE_CONCRETE_INSTRUCTION(CheckNonSmi, "check-non-smi")
2519 DECLARE_HYDROGEN_ACCESSOR(CheckHeapObject)
2523 class LDoubleBits final : public LTemplateInstruction<1, 1, 0> {
2525 explicit LDoubleBits(LOperand* value) {
2529 LOperand* value() { return inputs_[0]; }
2531 DECLARE_CONCRETE_INSTRUCTION(DoubleBits, "double-bits")
2532 DECLARE_HYDROGEN_ACCESSOR(DoubleBits)
2536 class LConstructDouble final : public LTemplateInstruction<1, 2, 0> {
2538 LConstructDouble(LOperand* hi, LOperand* lo) {
2543 LOperand* hi() { return inputs_[0]; }
2544 LOperand* lo() { return inputs_[1]; }
2546 DECLARE_CONCRETE_INSTRUCTION(ConstructDouble, "construct-double")
2550 class LAllocate final : public LTemplateInstruction<1, 2, 1> {
2552 LAllocate(LOperand* context, LOperand* size, LOperand* temp) {
2553 inputs_[0] = context;
2558 LOperand* context() { return inputs_[0]; }
2559 LOperand* size() { return inputs_[1]; }
2560 LOperand* temp() { return temps_[0]; }
2562 DECLARE_CONCRETE_INSTRUCTION(Allocate, "allocate")
2563 DECLARE_HYDROGEN_ACCESSOR(Allocate)
2567 class LRegExpLiteral final : public LTemplateInstruction<1, 1, 0> {
2569 explicit LRegExpLiteral(LOperand* context) {
2570 inputs_[0] = context;
2573 LOperand* context() { return inputs_[0]; }
2575 DECLARE_CONCRETE_INSTRUCTION(RegExpLiteral, "regexp-literal")
2576 DECLARE_HYDROGEN_ACCESSOR(RegExpLiteral)
2580 class LFunctionLiteral final : public LTemplateInstruction<1, 1, 0> {
2582 explicit LFunctionLiteral(LOperand* context) {
2583 inputs_[0] = context;
2586 LOperand* context() { return inputs_[0]; }
2588 DECLARE_CONCRETE_INSTRUCTION(FunctionLiteral, "function-literal")
2589 DECLARE_HYDROGEN_ACCESSOR(FunctionLiteral)
2593 class LToFastProperties final : public LTemplateInstruction<1, 1, 0> {
2595 explicit LToFastProperties(LOperand* value) {
2599 LOperand* value() { return inputs_[0]; }
2601 DECLARE_CONCRETE_INSTRUCTION(ToFastProperties, "to-fast-properties")
2602 DECLARE_HYDROGEN_ACCESSOR(ToFastProperties)
2606 class LTypeof final : public LTemplateInstruction<1, 2, 0> {
2608 LTypeof(LOperand* context, LOperand* value) {
2609 inputs_[0] = context;
2613 LOperand* context() { return inputs_[0]; }
2614 LOperand* value() { return inputs_[1]; }
2616 DECLARE_CONCRETE_INSTRUCTION(Typeof, "typeof")
2620 class LTypeofIsAndBranch final : public LControlInstruction<1, 0> {
2622 explicit LTypeofIsAndBranch(LOperand* value) {
2626 LOperand* value() { return inputs_[0]; }
2628 DECLARE_CONCRETE_INSTRUCTION(TypeofIsAndBranch, "typeof-is-and-branch")
2629 DECLARE_HYDROGEN_ACCESSOR(TypeofIsAndBranch)
2631 Handle<String> type_literal() { return hydrogen()->type_literal(); }
2633 void PrintDataTo(StringStream* stream) override;
2637 class LOsrEntry final : public LTemplateInstruction<0, 0, 0> {
2639 bool HasInterestingComment(LCodeGen* gen) const override { return false; }
2640 DECLARE_CONCRETE_INSTRUCTION(OsrEntry, "osr-entry")
2644 class LStackCheck final : public LTemplateInstruction<0, 1, 0> {
2646 explicit LStackCheck(LOperand* context) {
2647 inputs_[0] = context;
2650 LOperand* context() { return inputs_[0]; }
2652 DECLARE_CONCRETE_INSTRUCTION(StackCheck, "stack-check")
2653 DECLARE_HYDROGEN_ACCESSOR(StackCheck)
2655 Label* done_label() { return &done_label_; }
2662 class LForInPrepareMap final : public LTemplateInstruction<1, 2, 0> {
2664 LForInPrepareMap(LOperand* context, LOperand* object) {
2665 inputs_[0] = context;
2666 inputs_[1] = object;
2669 LOperand* context() { return inputs_[0]; }
2670 LOperand* object() { return inputs_[1]; }
2672 DECLARE_CONCRETE_INSTRUCTION(ForInPrepareMap, "for-in-prepare-map")
2676 class LForInCacheArray final : public LTemplateInstruction<1, 1, 0> {
2678 explicit LForInCacheArray(LOperand* map) {
2682 LOperand* map() { return inputs_[0]; }
2684 DECLARE_CONCRETE_INSTRUCTION(ForInCacheArray, "for-in-cache-array")
2687 return HForInCacheArray::cast(this->hydrogen_value())->idx();
2692 class LCheckMapValue final : public LTemplateInstruction<0, 2, 0> {
2694 LCheckMapValue(LOperand* value, LOperand* map) {
2699 LOperand* value() { return inputs_[0]; }
2700 LOperand* map() { return inputs_[1]; }
2702 DECLARE_CONCRETE_INSTRUCTION(CheckMapValue, "check-map-value")
2706 class LLoadFieldByIndex final : public LTemplateInstruction<1, 2, 0> {
2708 LLoadFieldByIndex(LOperand* object, LOperand* index) {
2709 inputs_[0] = object;
2713 LOperand* object() { return inputs_[0]; }
2714 LOperand* index() { return inputs_[1]; }
2716 DECLARE_CONCRETE_INSTRUCTION(LoadFieldByIndex, "load-field-by-index")
2720 class LStoreFrameContext: public LTemplateInstruction<0, 1, 0> {
2722 explicit LStoreFrameContext(LOperand* context) {
2723 inputs_[0] = context;
2726 LOperand* context() { return inputs_[0]; }
2728 DECLARE_CONCRETE_INSTRUCTION(StoreFrameContext, "store-frame-context")
2732 class LAllocateBlockContext: public LTemplateInstruction<1, 2, 0> {
2734 LAllocateBlockContext(LOperand* context, LOperand* function) {
2735 inputs_[0] = context;
2736 inputs_[1] = function;
2739 LOperand* context() { return inputs_[0]; }
2740 LOperand* function() { return inputs_[1]; }
2742 Handle<ScopeInfo> scope_info() { return hydrogen()->scope_info(); }
2744 DECLARE_CONCRETE_INSTRUCTION(AllocateBlockContext, "allocate-block-context")
2745 DECLARE_HYDROGEN_ACCESSOR(AllocateBlockContext)
2749 class LChunkBuilder;
2750 class LPlatformChunk final : public LChunk {
2752 LPlatformChunk(CompilationInfo* info, HGraph* graph)
2753 : LChunk(info, graph),
2754 num_double_slots_(0) { }
2756 int GetNextSpillIndex(RegisterKind kind);
2757 LOperand* GetNextSpillSlot(RegisterKind kind);
2759 int num_double_slots() const { return num_double_slots_; }
2762 int num_double_slots_;
2766 class LChunkBuilder final : public LChunkBuilderBase {
2768 LChunkBuilder(CompilationInfo* info, HGraph* graph, LAllocator* allocator)
2769 : LChunkBuilderBase(info, graph),
2770 current_instruction_(NULL),
2771 current_block_(NULL),
2773 allocator_(allocator) {}
2775 // Build the sequence for the graph.
2776 LPlatformChunk* Build();
2778 // Declare methods that deal with the individual node types.
2779 #define DECLARE_DO(type) LInstruction* Do##type(H##type* node);
2780 HYDROGEN_CONCRETE_INSTRUCTION_LIST(DECLARE_DO)
2783 LInstruction* DoMathFloor(HUnaryMathOperation* instr);
2784 LInstruction* DoMathRound(HUnaryMathOperation* instr);
2785 LInstruction* DoMathFround(HUnaryMathOperation* instr);
2786 LInstruction* DoMathAbs(HUnaryMathOperation* instr);
2787 LInstruction* DoMathLog(HUnaryMathOperation* instr);
2788 LInstruction* DoMathExp(HUnaryMathOperation* instr);
2789 LInstruction* DoMathSqrt(HUnaryMathOperation* instr);
2790 LInstruction* DoMathPowHalf(HUnaryMathOperation* instr);
2791 LInstruction* DoMathClz32(HUnaryMathOperation* instr);
2792 LInstruction* DoDivByPowerOf2I(HDiv* instr);
2793 LInstruction* DoDivByConstI(HDiv* instr);
2794 LInstruction* DoDivI(HDiv* instr);
2795 LInstruction* DoModByPowerOf2I(HMod* instr);
2796 LInstruction* DoModByConstI(HMod* instr);
2797 LInstruction* DoModI(HMod* instr);
2798 LInstruction* DoFlooringDivByPowerOf2I(HMathFloorOfDiv* instr);
2799 LInstruction* DoFlooringDivByConstI(HMathFloorOfDiv* instr);
2800 LInstruction* DoFlooringDivI(HMathFloorOfDiv* instr);
2803 // Methods for getting operands for Use / Define / Temp.
2804 LUnallocated* ToUnallocated(Register reg);
2805 LUnallocated* ToUnallocated(X87Register reg);
2807 // Methods for setting up define-use relationships.
2808 MUST_USE_RESULT LOperand* Use(HValue* value, LUnallocated* operand);
2809 MUST_USE_RESULT LOperand* UseFixed(HValue* value, Register fixed_register);
2811 // A value that is guaranteed to be allocated to a register.
2812 // Operand created by UseRegister is guaranteed to be live until the end of
2813 // instruction. This means that register allocator will not reuse it's
2814 // register for any other operand inside instruction.
2815 // Operand created by UseRegisterAtStart is guaranteed to be live only at
2816 // instruction start. Register allocator is free to assign the same register
2817 // to some other operand used inside instruction (i.e. temporary or
2819 MUST_USE_RESULT LOperand* UseRegister(HValue* value);
2820 MUST_USE_RESULT LOperand* UseRegisterAtStart(HValue* value);
2822 // An input operand in a register that may be trashed.
2823 MUST_USE_RESULT LOperand* UseTempRegister(HValue* value);
2825 // An input operand in a register or stack slot.
2826 MUST_USE_RESULT LOperand* Use(HValue* value);
2827 MUST_USE_RESULT LOperand* UseAtStart(HValue* value);
2829 // An input operand in a register, stack slot or a constant operand.
2830 MUST_USE_RESULT LOperand* UseOrConstant(HValue* value);
2831 MUST_USE_RESULT LOperand* UseOrConstantAtStart(HValue* value);
2833 // An input operand in a fixed register or a constant operand.
2834 MUST_USE_RESULT LOperand* UseFixedOrConstant(HValue* value,
2835 Register fixed_register);
2837 // An input operand in a register or a constant operand.
2838 MUST_USE_RESULT LOperand* UseRegisterOrConstant(HValue* value);
2839 MUST_USE_RESULT LOperand* UseRegisterOrConstantAtStart(HValue* value);
2841 // An input operand in a constant operand.
2842 MUST_USE_RESULT LOperand* UseConstant(HValue* value);
2844 // An input operand in register, stack slot or a constant operand.
2845 // Will not be moved to a register even if one is freely available.
2846 MUST_USE_RESULT LOperand* UseAny(HValue* value) override;
2848 // Temporary operand that must be in a register.
2849 MUST_USE_RESULT LUnallocated* TempRegister();
2850 MUST_USE_RESULT LOperand* FixedTemp(Register reg);
2852 // Methods for setting up define-use relationships.
2853 // Return the same instruction that they are passed.
2854 LInstruction* Define(LTemplateResultInstruction<1>* instr,
2855 LUnallocated* result);
2856 LInstruction* DefineAsRegister(LTemplateResultInstruction<1>* instr);
2857 LInstruction* DefineAsSpilled(LTemplateResultInstruction<1>* instr,
2859 LInstruction* DefineSameAsFirst(LTemplateResultInstruction<1>* instr);
2860 LInstruction* DefineFixed(LTemplateResultInstruction<1>* instr,
2862 LInstruction* DefineFixed(LTemplateResultInstruction<1>* instr,
2864 LInstruction* DefineX87TOS(LTemplateResultInstruction<1>* instr);
2865 // Assigns an environment to an instruction. An instruction which can
2866 // deoptimize must have an environment.
2867 LInstruction* AssignEnvironment(LInstruction* instr);
2868 // Assigns a pointer map to an instruction. An instruction which can
2869 // trigger a GC or a lazy deoptimization must have a pointer map.
2870 LInstruction* AssignPointerMap(LInstruction* instr);
2872 enum CanDeoptimize { CAN_DEOPTIMIZE_EAGERLY, CANNOT_DEOPTIMIZE_EAGERLY };
2874 LOperand* GetSeqStringSetCharOperand(HSeqStringSetChar* instr);
2876 // Marks a call for the register allocator. Assigns a pointer map to
2877 // support GC and lazy deoptimization. Assigns an environment to support
2878 // eager deoptimization if CAN_DEOPTIMIZE_EAGERLY.
2879 LInstruction* MarkAsCall(
2880 LInstruction* instr,
2881 HInstruction* hinstr,
2882 CanDeoptimize can_deoptimize = CANNOT_DEOPTIMIZE_EAGERLY);
2884 void VisitInstruction(HInstruction* current);
2885 void AddInstruction(LInstruction* instr, HInstruction* current);
2887 void DoBasicBlock(HBasicBlock* block, HBasicBlock* next_block);
2888 LInstruction* DoShift(Token::Value op, HBitwiseBinaryOperation* instr);
2889 LInstruction* DoArithmeticD(Token::Value op,
2890 HArithmeticBinaryOperation* instr);
2891 LInstruction* DoArithmeticT(Token::Value op,
2892 HBinaryOperation* instr);
2894 LOperand* GetStoreKeyedValueOperand(HStoreKeyed* instr);
2896 HInstruction* current_instruction_;
2897 HBasicBlock* current_block_;
2898 HBasicBlock* next_block_;
2899 LAllocator* allocator_;
2901 DISALLOW_COPY_AND_ASSIGN(LChunkBuilder);
2904 #undef DECLARE_HYDROGEN_ACCESSOR
2905 #undef DECLARE_CONCRETE_INSTRUCTION
2907 } } // namespace v8::internal
2909 #endif // V8_X87_LITHIUM_X87_H_