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(HasInstanceTypeAndBranch) \
92 V(InnerAllocatedObject) \
94 V(InstanceOfKnownGlobal) \
96 V(Integer32ToDouble) \
98 V(IsConstructCallAndBranch) \
99 V(IsObjectAndBranch) \
100 V(IsStringAndBranch) \
102 V(IsUndetectableAndBranch) \
106 V(LoadFieldByIndex) \
107 V(LoadFunctionPrototype) \
108 V(LoadGlobalGeneric) \
109 V(LoadGlobalViaContext) \
111 V(LoadKeyedGeneric) \
113 V(LoadNamedGeneric) \
126 V(MaybeGrowElements) \
141 V(SeqStringGetChar) \
142 V(SeqStringSetChar) \
148 V(StoreContextSlot) \
149 V(StoreFrameContext) \
150 V(StoreGlobalViaContext) \
152 V(StoreKeyedGeneric) \
154 V(StoreNamedGeneric) \
156 V(StringCharCodeAt) \
157 V(StringCharFromCode) \
158 V(StringCompareAndBranch) \
162 V(ToFastProperties) \
163 V(TransitionElementsKind) \
164 V(TrapAllocationMemento) \
166 V(TypeofIsAndBranch) \
172 #define DECLARE_CONCRETE_INSTRUCTION(type, mnemonic) \
173 Opcode opcode() const final { return LInstruction::k##type; } \
174 void CompileToNative(LCodeGen* generator) final; \
175 const char* Mnemonic() const final { return mnemonic; } \
176 static L##type* cast(LInstruction* instr) { \
177 DCHECK(instr->Is##type()); \
178 return reinterpret_cast<L##type*>(instr); \
182 #define DECLARE_HYDROGEN_ACCESSOR(type) \
183 H##type* hydrogen() const { \
184 return H##type::cast(hydrogen_value()); \
188 class LInstruction : public ZoneObject {
191 : environment_(NULL),
192 hydrogen_value_(NULL),
193 bit_field_(IsCallBits::encode(false)) {
196 virtual ~LInstruction() {}
198 virtual void CompileToNative(LCodeGen* generator) = 0;
199 virtual const char* Mnemonic() const = 0;
200 virtual void PrintTo(StringStream* stream);
201 virtual void PrintDataTo(StringStream* stream);
202 virtual void PrintOutputOperandTo(StringStream* stream);
205 // Declare a unique enum value for each instruction.
206 #define DECLARE_OPCODE(type) k##type,
207 LITHIUM_CONCRETE_INSTRUCTION_LIST(DECLARE_OPCODE) kAdapter,
208 kNumberOfInstructions
209 #undef DECLARE_OPCODE
212 virtual Opcode opcode() const = 0;
214 // Declare non-virtual type testers for all leaf IR classes.
215 #define DECLARE_PREDICATE(type) \
216 bool Is##type() const { return opcode() == k##type; }
217 LITHIUM_CONCRETE_INSTRUCTION_LIST(DECLARE_PREDICATE)
218 #undef DECLARE_PREDICATE
220 // Declare virtual predicates for instructions that don't have
222 virtual bool IsGap() const { return false; }
224 virtual bool IsControl() const { return false; }
226 // Try deleting this instruction if possible.
227 virtual bool TryDelete() { return false; }
229 void set_environment(LEnvironment* env) { environment_ = env; }
230 LEnvironment* environment() const { return environment_; }
231 bool HasEnvironment() const { return environment_ != NULL; }
233 void set_pointer_map(LPointerMap* p) { pointer_map_.set(p); }
234 LPointerMap* pointer_map() const { return pointer_map_.get(); }
235 bool HasPointerMap() const { return pointer_map_.is_set(); }
237 void set_hydrogen_value(HValue* value) { hydrogen_value_ = value; }
238 HValue* hydrogen_value() const { return hydrogen_value_; }
240 virtual void SetDeferredLazyDeoptimizationEnvironment(LEnvironment* env) { }
242 void MarkAsCall() { bit_field_ = IsCallBits::update(bit_field_, true); }
243 bool IsCall() const { return IsCallBits::decode(bit_field_); }
245 // Interface to the register allocator and iterators.
246 bool ClobbersTemps() const { return IsCall(); }
247 bool ClobbersRegisters() const { return IsCall(); }
248 virtual bool ClobbersDoubleRegisters(Isolate* isolate) const {
250 // We only have rudimentary X87Stack tracking, thus in general
251 // cannot handle phi-nodes.
255 virtual bool HasResult() const = 0;
256 virtual LOperand* result() const = 0;
258 bool HasDoubleRegisterResult();
259 bool HasDoubleRegisterInput();
260 bool IsDoubleInput(X87Register reg, LCodeGen* cgen);
262 LOperand* FirstInput() { return InputAt(0); }
263 LOperand* Output() { return HasResult() ? result() : NULL; }
265 virtual bool HasInterestingComment(LCodeGen* gen) const { return true; }
271 virtual int InputCount() = 0;
272 virtual LOperand* InputAt(int i) = 0;
276 friend class InputIterator;
278 friend class TempIterator;
279 virtual int TempCount() = 0;
280 virtual LOperand* TempAt(int i) = 0;
282 class IsCallBits: public BitField<bool, 0, 1> {};
284 LEnvironment* environment_;
285 SetOncePointer<LPointerMap> pointer_map_;
286 HValue* hydrogen_value_;
291 // R = number of result operands (0 or 1).
293 class LTemplateResultInstruction : public LInstruction {
295 // Allow 0 or 1 output operands.
296 STATIC_ASSERT(R == 0 || R == 1);
297 bool HasResult() const final { return R != 0 && result() != NULL; }
298 void set_result(LOperand* operand) { results_[0] = operand; }
299 LOperand* result() const override { return results_[0]; }
302 EmbeddedContainer<LOperand*, R> results_;
306 // R = number of result operands (0 or 1).
307 // I = number of input operands.
308 // T = number of temporary operands.
309 template<int R, int I, int T>
310 class LTemplateInstruction : public LTemplateResultInstruction<R> {
312 EmbeddedContainer<LOperand*, I> inputs_;
313 EmbeddedContainer<LOperand*, T> temps_;
317 int InputCount() final { return I; }
318 LOperand* InputAt(int i) final { return inputs_[i]; }
320 int TempCount() final { return T; }
321 LOperand* TempAt(int i) final { return temps_[i]; }
325 class LGap : public LTemplateInstruction<0, 0, 0> {
327 explicit LGap(HBasicBlock* block) : block_(block) {
328 parallel_moves_[BEFORE] = NULL;
329 parallel_moves_[START] = NULL;
330 parallel_moves_[END] = NULL;
331 parallel_moves_[AFTER] = NULL;
334 // Can't use the DECLARE-macro here because of sub-classes.
335 bool IsGap() const final { return true; }
336 void PrintDataTo(StringStream* stream) override;
337 static LGap* cast(LInstruction* instr) {
338 DCHECK(instr->IsGap());
339 return reinterpret_cast<LGap*>(instr);
342 bool IsRedundant() const;
344 HBasicBlock* block() const { return block_; }
351 FIRST_INNER_POSITION = BEFORE,
352 LAST_INNER_POSITION = AFTER
355 LParallelMove* GetOrCreateParallelMove(InnerPosition pos, Zone* zone) {
356 if (parallel_moves_[pos] == NULL) {
357 parallel_moves_[pos] = new(zone) LParallelMove(zone);
359 return parallel_moves_[pos];
362 LParallelMove* GetParallelMove(InnerPosition pos) {
363 return parallel_moves_[pos];
367 LParallelMove* parallel_moves_[LAST_INNER_POSITION + 1];
372 class LInstructionGap final : public LGap {
374 explicit LInstructionGap(HBasicBlock* block) : LGap(block) { }
376 bool HasInterestingComment(LCodeGen* gen) const override {
377 return !IsRedundant();
380 DECLARE_CONCRETE_INSTRUCTION(InstructionGap, "gap")
384 class LClobberDoubles final : public LTemplateInstruction<0, 0, 0> {
386 explicit LClobberDoubles(Isolate* isolate) { }
388 bool ClobbersDoubleRegisters(Isolate* isolate) const override { return true; }
390 DECLARE_CONCRETE_INSTRUCTION(ClobberDoubles, "clobber-d")
394 class LGoto final : public LTemplateInstruction<0, 0, 0> {
396 explicit LGoto(HBasicBlock* block) : block_(block) { }
398 bool HasInterestingComment(LCodeGen* gen) const override;
399 DECLARE_CONCRETE_INSTRUCTION(Goto, "goto")
400 void PrintDataTo(StringStream* stream) override;
401 bool IsControl() const override { return true; }
403 int block_id() const { return block_->block_id(); }
404 bool ClobbersDoubleRegisters(Isolate* isolate) const override {
408 bool jumps_to_join() const { return block_->predecessors()->length() > 1; }
409 HBasicBlock* block() const { return block_; }
416 class LLazyBailout final : public LTemplateInstruction<0, 0, 0> {
418 DECLARE_CONCRETE_INSTRUCTION(LazyBailout, "lazy-bailout")
422 class LDummy final : public LTemplateInstruction<1, 0, 0> {
425 DECLARE_CONCRETE_INSTRUCTION(Dummy, "dummy")
429 class LDummyUse final : public LTemplateInstruction<1, 1, 0> {
431 explicit LDummyUse(LOperand* value) {
434 DECLARE_CONCRETE_INSTRUCTION(DummyUse, "dummy-use")
438 class LDeoptimize final : public LTemplateInstruction<0, 0, 0> {
440 bool IsControl() const override { return true; }
441 DECLARE_CONCRETE_INSTRUCTION(Deoptimize, "deoptimize")
442 DECLARE_HYDROGEN_ACCESSOR(Deoptimize)
446 class LLabel final : public LGap {
448 explicit LLabel(HBasicBlock* block)
449 : LGap(block), replacement_(NULL) { }
451 bool HasInterestingComment(LCodeGen* gen) const override { return false; }
452 DECLARE_CONCRETE_INSTRUCTION(Label, "label")
454 void PrintDataTo(StringStream* stream) override;
456 int block_id() const { return block()->block_id(); }
457 bool is_loop_header() const { return block()->IsLoopHeader(); }
458 bool is_osr_entry() const { return block()->is_osr_entry(); }
459 Label* label() { return &label_; }
460 LLabel* replacement() const { return replacement_; }
461 void set_replacement(LLabel* label) { replacement_ = label; }
462 bool HasReplacement() const { return replacement_ != NULL; }
466 LLabel* replacement_;
470 class LParameter final : public LTemplateInstruction<1, 0, 0> {
472 bool HasInterestingComment(LCodeGen* gen) const override { return false; }
473 DECLARE_CONCRETE_INSTRUCTION(Parameter, "parameter")
477 class LCallStub final : public LTemplateInstruction<1, 1, 0> {
479 explicit LCallStub(LOperand* context) {
480 inputs_[0] = context;
483 LOperand* context() { return inputs_[0]; }
485 DECLARE_CONCRETE_INSTRUCTION(CallStub, "call-stub")
486 DECLARE_HYDROGEN_ACCESSOR(CallStub)
490 class LUnknownOSRValue final : public LTemplateInstruction<1, 0, 0> {
492 bool HasInterestingComment(LCodeGen* gen) const override { return false; }
493 DECLARE_CONCRETE_INSTRUCTION(UnknownOSRValue, "unknown-osr-value")
497 template<int I, int T>
498 class LControlInstruction: public LTemplateInstruction<0, I, T> {
500 LControlInstruction() : false_label_(NULL), true_label_(NULL) { }
502 bool IsControl() const final { return true; }
504 int SuccessorCount() { return hydrogen()->SuccessorCount(); }
505 HBasicBlock* SuccessorAt(int i) { return hydrogen()->SuccessorAt(i); }
507 int TrueDestination(LChunk* chunk) {
508 return chunk->LookupDestination(true_block_id());
510 int FalseDestination(LChunk* chunk) {
511 return chunk->LookupDestination(false_block_id());
514 Label* TrueLabel(LChunk* chunk) {
515 if (true_label_ == NULL) {
516 true_label_ = chunk->GetAssemblyLabel(TrueDestination(chunk));
520 Label* FalseLabel(LChunk* chunk) {
521 if (false_label_ == NULL) {
522 false_label_ = chunk->GetAssemblyLabel(FalseDestination(chunk));
528 int true_block_id() { return SuccessorAt(0)->block_id(); }
529 int false_block_id() { return SuccessorAt(1)->block_id(); }
532 HControlInstruction* hydrogen() {
533 return HControlInstruction::cast(this->hydrogen_value());
541 class LWrapReceiver final : public LTemplateInstruction<1, 2, 1> {
543 LWrapReceiver(LOperand* receiver,
546 inputs_[0] = receiver;
547 inputs_[1] = function;
551 LOperand* receiver() { return inputs_[0]; }
552 LOperand* function() { return inputs_[1]; }
553 LOperand* temp() { return temps_[0]; }
555 DECLARE_CONCRETE_INSTRUCTION(WrapReceiver, "wrap-receiver")
556 DECLARE_HYDROGEN_ACCESSOR(WrapReceiver)
560 class LApplyArguments final : public LTemplateInstruction<1, 4, 0> {
562 LApplyArguments(LOperand* function,
565 LOperand* elements) {
566 inputs_[0] = function;
567 inputs_[1] = receiver;
569 inputs_[3] = elements;
572 LOperand* function() { return inputs_[0]; }
573 LOperand* receiver() { return inputs_[1]; }
574 LOperand* length() { return inputs_[2]; }
575 LOperand* elements() { return inputs_[3]; }
577 DECLARE_CONCRETE_INSTRUCTION(ApplyArguments, "apply-arguments")
581 class LAccessArgumentsAt final : public LTemplateInstruction<1, 3, 0> {
583 LAccessArgumentsAt(LOperand* arguments, LOperand* length, LOperand* index) {
584 inputs_[0] = arguments;
589 LOperand* arguments() { return inputs_[0]; }
590 LOperand* length() { return inputs_[1]; }
591 LOperand* index() { return inputs_[2]; }
593 DECLARE_CONCRETE_INSTRUCTION(AccessArgumentsAt, "access-arguments-at")
595 void PrintDataTo(StringStream* stream) override;
599 class LArgumentsLength final : public LTemplateInstruction<1, 1, 0> {
601 explicit LArgumentsLength(LOperand* elements) {
602 inputs_[0] = elements;
605 LOperand* elements() { return inputs_[0]; }
607 DECLARE_CONCRETE_INSTRUCTION(ArgumentsLength, "arguments-length")
611 class LArgumentsElements final : public LTemplateInstruction<1, 0, 0> {
613 DECLARE_CONCRETE_INSTRUCTION(ArgumentsElements, "arguments-elements")
614 DECLARE_HYDROGEN_ACCESSOR(ArgumentsElements)
618 class LDebugBreak final : public LTemplateInstruction<0, 0, 0> {
620 DECLARE_CONCRETE_INSTRUCTION(DebugBreak, "break")
624 class LModByPowerOf2I final : public LTemplateInstruction<1, 1, 0> {
626 LModByPowerOf2I(LOperand* dividend, int32_t divisor) {
627 inputs_[0] = dividend;
631 LOperand* dividend() { return inputs_[0]; }
632 int32_t divisor() const { return divisor_; }
634 DECLARE_CONCRETE_INSTRUCTION(ModByPowerOf2I, "mod-by-power-of-2-i")
635 DECLARE_HYDROGEN_ACCESSOR(Mod)
642 class LModByConstI final : public LTemplateInstruction<1, 1, 2> {
644 LModByConstI(LOperand* dividend,
648 inputs_[0] = dividend;
654 LOperand* dividend() { return inputs_[0]; }
655 int32_t divisor() const { return divisor_; }
656 LOperand* temp1() { return temps_[0]; }
657 LOperand* temp2() { return temps_[1]; }
659 DECLARE_CONCRETE_INSTRUCTION(ModByConstI, "mod-by-const-i")
660 DECLARE_HYDROGEN_ACCESSOR(Mod)
667 class LModI final : public LTemplateInstruction<1, 2, 1> {
669 LModI(LOperand* left, LOperand* right, LOperand* temp) {
675 LOperand* left() { return inputs_[0]; }
676 LOperand* right() { return inputs_[1]; }
677 LOperand* temp() { return temps_[0]; }
679 DECLARE_CONCRETE_INSTRUCTION(ModI, "mod-i")
680 DECLARE_HYDROGEN_ACCESSOR(Mod)
684 class LDivByPowerOf2I final : public LTemplateInstruction<1, 1, 0> {
686 LDivByPowerOf2I(LOperand* dividend, int32_t divisor) {
687 inputs_[0] = dividend;
691 LOperand* dividend() { return inputs_[0]; }
692 int32_t divisor() const { return divisor_; }
694 DECLARE_CONCRETE_INSTRUCTION(DivByPowerOf2I, "div-by-power-of-2-i")
695 DECLARE_HYDROGEN_ACCESSOR(Div)
702 class LDivByConstI final : public LTemplateInstruction<1, 1, 2> {
704 LDivByConstI(LOperand* dividend,
708 inputs_[0] = dividend;
714 LOperand* dividend() { return inputs_[0]; }
715 int32_t divisor() const { return divisor_; }
716 LOperand* temp1() { return temps_[0]; }
717 LOperand* temp2() { return temps_[1]; }
719 DECLARE_CONCRETE_INSTRUCTION(DivByConstI, "div-by-const-i")
720 DECLARE_HYDROGEN_ACCESSOR(Div)
727 class LDivI final : public LTemplateInstruction<1, 2, 1> {
729 LDivI(LOperand* dividend, LOperand* divisor, LOperand* temp) {
730 inputs_[0] = dividend;
731 inputs_[1] = divisor;
735 LOperand* dividend() { return inputs_[0]; }
736 LOperand* divisor() { return inputs_[1]; }
737 LOperand* temp() { return temps_[0]; }
739 DECLARE_CONCRETE_INSTRUCTION(DivI, "div-i")
740 DECLARE_HYDROGEN_ACCESSOR(BinaryOperation)
744 class LFlooringDivByPowerOf2I final : public LTemplateInstruction<1, 1, 0> {
746 LFlooringDivByPowerOf2I(LOperand* dividend, int32_t divisor) {
747 inputs_[0] = dividend;
751 LOperand* dividend() { return inputs_[0]; }
752 int32_t divisor() const { return divisor_; }
754 DECLARE_CONCRETE_INSTRUCTION(FlooringDivByPowerOf2I,
755 "flooring-div-by-power-of-2-i")
756 DECLARE_HYDROGEN_ACCESSOR(MathFloorOfDiv)
763 class LFlooringDivByConstI final : public LTemplateInstruction<1, 1, 3> {
765 LFlooringDivByConstI(LOperand* dividend,
770 inputs_[0] = dividend;
777 LOperand* dividend() { return inputs_[0]; }
778 int32_t divisor() const { return divisor_; }
779 LOperand* temp1() { return temps_[0]; }
780 LOperand* temp2() { return temps_[1]; }
781 LOperand* temp3() { return temps_[2]; }
783 DECLARE_CONCRETE_INSTRUCTION(FlooringDivByConstI, "flooring-div-by-const-i")
784 DECLARE_HYDROGEN_ACCESSOR(MathFloorOfDiv)
791 class LFlooringDivI final : public LTemplateInstruction<1, 2, 1> {
793 LFlooringDivI(LOperand* dividend, LOperand* divisor, LOperand* temp) {
794 inputs_[0] = dividend;
795 inputs_[1] = divisor;
799 LOperand* dividend() { return inputs_[0]; }
800 LOperand* divisor() { return inputs_[1]; }
801 LOperand* temp() { return temps_[0]; }
803 DECLARE_CONCRETE_INSTRUCTION(FlooringDivI, "flooring-div-i")
804 DECLARE_HYDROGEN_ACCESSOR(MathFloorOfDiv)
808 class LMulI final : public LTemplateInstruction<1, 2, 1> {
810 LMulI(LOperand* left, LOperand* right, LOperand* temp) {
816 LOperand* left() { return inputs_[0]; }
817 LOperand* right() { return inputs_[1]; }
818 LOperand* temp() { return temps_[0]; }
820 DECLARE_CONCRETE_INSTRUCTION(MulI, "mul-i")
821 DECLARE_HYDROGEN_ACCESSOR(Mul)
825 class LCompareNumericAndBranch final : public LControlInstruction<2, 0> {
827 LCompareNumericAndBranch(LOperand* left, LOperand* right) {
832 LOperand* left() { return inputs_[0]; }
833 LOperand* right() { return inputs_[1]; }
835 DECLARE_CONCRETE_INSTRUCTION(CompareNumericAndBranch,
836 "compare-numeric-and-branch")
837 DECLARE_HYDROGEN_ACCESSOR(CompareNumericAndBranch)
839 Token::Value op() const { return hydrogen()->token(); }
840 bool is_double() const {
841 return hydrogen()->representation().IsDouble();
844 void PrintDataTo(StringStream* stream) override;
848 class LMathFloor final : public LTemplateInstruction<1, 1, 0> {
850 explicit LMathFloor(LOperand* value) {
854 LOperand* value() { return inputs_[0]; }
856 DECLARE_CONCRETE_INSTRUCTION(MathFloor, "math-floor")
857 DECLARE_HYDROGEN_ACCESSOR(UnaryMathOperation)
861 class LMathRound final : public LTemplateInstruction<1, 1, 0> {
863 explicit LMathRound(LOperand* value) {
867 LOperand* value() { return inputs_[0]; }
869 DECLARE_CONCRETE_INSTRUCTION(MathRound, "math-round")
870 DECLARE_HYDROGEN_ACCESSOR(UnaryMathOperation)
874 class LMathFround final : public LTemplateInstruction<1, 1, 0> {
876 explicit LMathFround(LOperand* value) { inputs_[0] = value; }
878 LOperand* value() { return inputs_[0]; }
880 DECLARE_CONCRETE_INSTRUCTION(MathFround, "math-fround")
884 class LMathAbs final : public LTemplateInstruction<1, 2, 0> {
886 LMathAbs(LOperand* context, LOperand* value) {
887 inputs_[1] = context;
891 LOperand* context() { return inputs_[1]; }
892 LOperand* value() { return inputs_[0]; }
894 DECLARE_CONCRETE_INSTRUCTION(MathAbs, "math-abs")
895 DECLARE_HYDROGEN_ACCESSOR(UnaryMathOperation)
899 class LMathLog final : public LTemplateInstruction<1, 1, 0> {
901 explicit LMathLog(LOperand* value) {
905 LOperand* value() { return inputs_[0]; }
907 DECLARE_CONCRETE_INSTRUCTION(MathLog, "math-log")
911 class LMathClz32 final : public LTemplateInstruction<1, 1, 0> {
913 explicit LMathClz32(LOperand* value) {
917 LOperand* value() { return inputs_[0]; }
919 DECLARE_CONCRETE_INSTRUCTION(MathClz32, "math-clz32")
923 class LMathExp final : public LTemplateInstruction<1, 1, 2> {
925 LMathExp(LOperand* value,
931 ExternalReference::InitializeMathExpData();
934 LOperand* value() { return inputs_[0]; }
935 LOperand* temp1() { return temps_[0]; }
936 LOperand* temp2() { return temps_[1]; }
938 DECLARE_CONCRETE_INSTRUCTION(MathExp, "math-exp")
942 class LMathSqrt final : public LTemplateInstruction<1, 1, 2> {
944 explicit LMathSqrt(LOperand* value,
952 LOperand* value() { return inputs_[0]; }
953 LOperand* temp1() { return temps_[0]; }
954 LOperand* temp2() { return temps_[1]; }
956 DECLARE_CONCRETE_INSTRUCTION(MathSqrt, "math-sqrt")
960 class LMathPowHalf final : public LTemplateInstruction<1, 1, 0> {
962 explicit LMathPowHalf(LOperand* value) { inputs_[0] = value; }
964 LOperand* value() { return inputs_[0]; }
966 DECLARE_CONCRETE_INSTRUCTION(MathPowHalf, "math-pow-half")
970 class LCmpObjectEqAndBranch final : public LControlInstruction<2, 0> {
972 LCmpObjectEqAndBranch(LOperand* left, LOperand* right) {
977 LOperand* left() { return inputs_[0]; }
978 LOperand* right() { return inputs_[1]; }
980 DECLARE_CONCRETE_INSTRUCTION(CmpObjectEqAndBranch, "cmp-object-eq-and-branch")
984 class LCmpHoleAndBranch final : public LControlInstruction<1, 0> {
986 explicit LCmpHoleAndBranch(LOperand* object) {
990 LOperand* object() { return inputs_[0]; }
992 DECLARE_CONCRETE_INSTRUCTION(CmpHoleAndBranch, "cmp-hole-and-branch")
993 DECLARE_HYDROGEN_ACCESSOR(CompareHoleAndBranch)
997 class LCompareMinusZeroAndBranch final : public LControlInstruction<1, 0> {
999 explicit LCompareMinusZeroAndBranch(LOperand* value) { inputs_[0] = value; }
1001 LOperand* value() { return inputs_[0]; }
1003 DECLARE_CONCRETE_INSTRUCTION(CompareMinusZeroAndBranch,
1004 "cmp-minus-zero-and-branch")
1005 DECLARE_HYDROGEN_ACCESSOR(CompareMinusZeroAndBranch)
1009 class LIsObjectAndBranch final : public LControlInstruction<1, 1> {
1011 LIsObjectAndBranch(LOperand* value, LOperand* temp) {
1016 LOperand* value() { return inputs_[0]; }
1017 LOperand* temp() { return temps_[0]; }
1019 DECLARE_CONCRETE_INSTRUCTION(IsObjectAndBranch, "is-object-and-branch")
1021 void PrintDataTo(StringStream* stream) override;
1025 class LIsStringAndBranch final : public LControlInstruction<1, 1> {
1027 LIsStringAndBranch(LOperand* value, LOperand* temp) {
1032 LOperand* value() { return inputs_[0]; }
1033 LOperand* temp() { return temps_[0]; }
1035 DECLARE_CONCRETE_INSTRUCTION(IsStringAndBranch, "is-string-and-branch")
1036 DECLARE_HYDROGEN_ACCESSOR(IsStringAndBranch)
1038 void PrintDataTo(StringStream* stream) override;
1042 class LIsSmiAndBranch final : public LControlInstruction<1, 0> {
1044 explicit LIsSmiAndBranch(LOperand* value) {
1048 LOperand* value() { return inputs_[0]; }
1050 DECLARE_CONCRETE_INSTRUCTION(IsSmiAndBranch, "is-smi-and-branch")
1051 DECLARE_HYDROGEN_ACCESSOR(IsSmiAndBranch)
1053 void PrintDataTo(StringStream* stream) override;
1057 class LIsUndetectableAndBranch final : public LControlInstruction<1, 1> {
1059 LIsUndetectableAndBranch(LOperand* value, LOperand* temp) {
1064 LOperand* value() { return inputs_[0]; }
1065 LOperand* temp() { return temps_[0]; }
1067 DECLARE_CONCRETE_INSTRUCTION(IsUndetectableAndBranch,
1068 "is-undetectable-and-branch")
1069 DECLARE_HYDROGEN_ACCESSOR(IsUndetectableAndBranch)
1071 void PrintDataTo(StringStream* stream) override;
1075 class LStringCompareAndBranch final : public LControlInstruction<3, 0> {
1077 LStringCompareAndBranch(LOperand* context, LOperand* left, LOperand* right) {
1078 inputs_[0] = context;
1083 LOperand* context() { return inputs_[1]; }
1084 LOperand* left() { return inputs_[1]; }
1085 LOperand* right() { return inputs_[2]; }
1087 DECLARE_CONCRETE_INSTRUCTION(StringCompareAndBranch,
1088 "string-compare-and-branch")
1089 DECLARE_HYDROGEN_ACCESSOR(StringCompareAndBranch)
1091 void PrintDataTo(StringStream* stream) override;
1093 Token::Value op() const { return hydrogen()->token(); }
1097 class LHasInstanceTypeAndBranch final : public LControlInstruction<1, 1> {
1099 LHasInstanceTypeAndBranch(LOperand* value, LOperand* temp) {
1104 LOperand* value() { return inputs_[0]; }
1105 LOperand* temp() { return temps_[0]; }
1107 DECLARE_CONCRETE_INSTRUCTION(HasInstanceTypeAndBranch,
1108 "has-instance-type-and-branch")
1109 DECLARE_HYDROGEN_ACCESSOR(HasInstanceTypeAndBranch)
1111 void PrintDataTo(StringStream* stream) override;
1115 class LGetCachedArrayIndex final : public LTemplateInstruction<1, 1, 0> {
1117 explicit LGetCachedArrayIndex(LOperand* value) {
1121 LOperand* value() { return inputs_[0]; }
1123 DECLARE_CONCRETE_INSTRUCTION(GetCachedArrayIndex, "get-cached-array-index")
1124 DECLARE_HYDROGEN_ACCESSOR(GetCachedArrayIndex)
1128 class LHasCachedArrayIndexAndBranch final : public LControlInstruction<1, 0> {
1130 explicit LHasCachedArrayIndexAndBranch(LOperand* value) {
1134 LOperand* value() { return inputs_[0]; }
1136 DECLARE_CONCRETE_INSTRUCTION(HasCachedArrayIndexAndBranch,
1137 "has-cached-array-index-and-branch")
1139 void PrintDataTo(StringStream* stream) override;
1143 class LIsConstructCallAndBranch final : public LControlInstruction<0, 1> {
1145 explicit LIsConstructCallAndBranch(LOperand* temp) {
1149 LOperand* temp() { return temps_[0]; }
1151 DECLARE_CONCRETE_INSTRUCTION(IsConstructCallAndBranch,
1152 "is-construct-call-and-branch")
1156 class LClassOfTestAndBranch final : public LControlInstruction<1, 2> {
1158 LClassOfTestAndBranch(LOperand* value, LOperand* temp, LOperand* temp2) {
1164 LOperand* value() { return inputs_[0]; }
1165 LOperand* temp() { return temps_[0]; }
1166 LOperand* temp2() { return temps_[1]; }
1168 DECLARE_CONCRETE_INSTRUCTION(ClassOfTestAndBranch,
1169 "class-of-test-and-branch")
1170 DECLARE_HYDROGEN_ACCESSOR(ClassOfTestAndBranch)
1172 void PrintDataTo(StringStream* stream) override;
1176 class LCmpT final : public LTemplateInstruction<1, 3, 0> {
1178 LCmpT(LOperand* context, LOperand* left, LOperand* right) {
1179 inputs_[0] = context;
1184 DECLARE_CONCRETE_INSTRUCTION(CmpT, "cmp-t")
1185 DECLARE_HYDROGEN_ACCESSOR(CompareGeneric)
1187 Strength strength() { return hydrogen()->strength(); }
1189 LOperand* context() { return inputs_[0]; }
1190 Token::Value op() const { return hydrogen()->token(); }
1194 class LInstanceOf final : public LTemplateInstruction<1, 3, 0> {
1196 LInstanceOf(LOperand* context, LOperand* left, LOperand* right) {
1197 inputs_[0] = context;
1202 LOperand* context() { return inputs_[0]; }
1204 DECLARE_CONCRETE_INSTRUCTION(InstanceOf, "instance-of")
1208 class LInstanceOfKnownGlobal final : public LTemplateInstruction<1, 2, 1> {
1210 LInstanceOfKnownGlobal(LOperand* context, LOperand* value, LOperand* temp) {
1211 inputs_[0] = context;
1216 LOperand* context() { return inputs_[0]; }
1217 LOperand* value() { return inputs_[1]; }
1218 LOperand* temp() { return temps_[0]; }
1220 DECLARE_CONCRETE_INSTRUCTION(InstanceOfKnownGlobal,
1221 "instance-of-known-global")
1222 DECLARE_HYDROGEN_ACCESSOR(InstanceOfKnownGlobal)
1224 Handle<JSFunction> function() const { return hydrogen()->function(); }
1225 LEnvironment* GetDeferredLazyDeoptimizationEnvironment() {
1226 return lazy_deopt_env_;
1228 virtual void SetDeferredLazyDeoptimizationEnvironment(
1229 LEnvironment* env) override {
1230 lazy_deopt_env_ = env;
1234 LEnvironment* lazy_deopt_env_;
1238 class LBoundsCheck final : public LTemplateInstruction<0, 2, 0> {
1240 LBoundsCheck(LOperand* index, LOperand* length) {
1242 inputs_[1] = length;
1245 LOperand* index() { return inputs_[0]; }
1246 LOperand* length() { return inputs_[1]; }
1248 DECLARE_CONCRETE_INSTRUCTION(BoundsCheck, "bounds-check")
1249 DECLARE_HYDROGEN_ACCESSOR(BoundsCheck)
1253 class LBitI final : public LTemplateInstruction<1, 2, 0> {
1255 LBitI(LOperand* left, LOperand* right) {
1260 LOperand* left() { return inputs_[0]; }
1261 LOperand* right() { return inputs_[1]; }
1263 DECLARE_CONCRETE_INSTRUCTION(BitI, "bit-i")
1264 DECLARE_HYDROGEN_ACCESSOR(Bitwise)
1266 Token::Value op() const { return hydrogen()->op(); }
1270 class LShiftI final : public LTemplateInstruction<1, 2, 0> {
1272 LShiftI(Token::Value op, LOperand* left, LOperand* right, bool can_deopt)
1273 : op_(op), can_deopt_(can_deopt) {
1278 LOperand* left() { return inputs_[0]; }
1279 LOperand* right() { return inputs_[1]; }
1281 DECLARE_CONCRETE_INSTRUCTION(ShiftI, "shift-i")
1283 Token::Value op() const { return op_; }
1284 bool can_deopt() const { return can_deopt_; }
1292 class LSubI final : public LTemplateInstruction<1, 2, 0> {
1294 LSubI(LOperand* left, LOperand* right) {
1299 LOperand* left() { return inputs_[0]; }
1300 LOperand* right() { return inputs_[1]; }
1302 DECLARE_CONCRETE_INSTRUCTION(SubI, "sub-i")
1303 DECLARE_HYDROGEN_ACCESSOR(Sub)
1307 class LConstantI final : public LTemplateInstruction<1, 0, 0> {
1309 DECLARE_CONCRETE_INSTRUCTION(ConstantI, "constant-i")
1310 DECLARE_HYDROGEN_ACCESSOR(Constant)
1312 int32_t value() const { return hydrogen()->Integer32Value(); }
1316 class LConstantS final : public LTemplateInstruction<1, 0, 0> {
1318 DECLARE_CONCRETE_INSTRUCTION(ConstantS, "constant-s")
1319 DECLARE_HYDROGEN_ACCESSOR(Constant)
1321 Smi* value() const { return Smi::FromInt(hydrogen()->Integer32Value()); }
1325 class LConstantD final : public LTemplateInstruction<1, 0, 1> {
1327 DECLARE_CONCRETE_INSTRUCTION(ConstantD, "constant-d")
1328 DECLARE_HYDROGEN_ACCESSOR(Constant)
1330 uint64_t bits() const { return hydrogen()->DoubleValueAsBits(); }
1334 class LConstantE final : public LTemplateInstruction<1, 0, 0> {
1336 DECLARE_CONCRETE_INSTRUCTION(ConstantE, "constant-e")
1337 DECLARE_HYDROGEN_ACCESSOR(Constant)
1339 ExternalReference value() const {
1340 return hydrogen()->ExternalReferenceValue();
1345 class LConstantT final : public LTemplateInstruction<1, 0, 0> {
1347 DECLARE_CONCRETE_INSTRUCTION(ConstantT, "constant-t")
1348 DECLARE_HYDROGEN_ACCESSOR(Constant)
1350 Handle<Object> value(Isolate* isolate) const {
1351 return hydrogen()->handle(isolate);
1356 class LBranch final : public LControlInstruction<1, 1> {
1358 LBranch(LOperand* value, LOperand* temp) {
1363 LOperand* value() { return inputs_[0]; }
1364 LOperand* temp() { return temps_[0]; }
1366 DECLARE_CONCRETE_INSTRUCTION(Branch, "branch")
1367 DECLARE_HYDROGEN_ACCESSOR(Branch)
1369 void PrintDataTo(StringStream* stream) override;
1373 class LCmpMapAndBranch final : public LControlInstruction<1, 0> {
1375 explicit LCmpMapAndBranch(LOperand* value) {
1379 LOperand* value() { return inputs_[0]; }
1381 DECLARE_CONCRETE_INSTRUCTION(CmpMapAndBranch, "cmp-map-and-branch")
1382 DECLARE_HYDROGEN_ACCESSOR(CompareMap)
1384 Handle<Map> map() const { return hydrogen()->map().handle(); }
1388 class LMapEnumLength final : public LTemplateInstruction<1, 1, 0> {
1390 explicit LMapEnumLength(LOperand* value) {
1394 LOperand* value() { return inputs_[0]; }
1396 DECLARE_CONCRETE_INSTRUCTION(MapEnumLength, "map-enum-length")
1400 class LDateField final : public LTemplateInstruction<1, 1, 1> {
1402 LDateField(LOperand* date, LOperand* temp, Smi* index)
1408 LOperand* date() { return inputs_[0]; }
1409 LOperand* temp() { return temps_[0]; }
1411 DECLARE_CONCRETE_INSTRUCTION(DateField, "date-field")
1412 DECLARE_HYDROGEN_ACCESSOR(DateField)
1414 Smi* index() const { return index_; }
1421 class LSeqStringGetChar final : public LTemplateInstruction<1, 2, 0> {
1423 LSeqStringGetChar(LOperand* string, LOperand* index) {
1424 inputs_[0] = string;
1428 LOperand* string() const { return inputs_[0]; }
1429 LOperand* index() const { return inputs_[1]; }
1431 DECLARE_CONCRETE_INSTRUCTION(SeqStringGetChar, "seq-string-get-char")
1432 DECLARE_HYDROGEN_ACCESSOR(SeqStringGetChar)
1436 class LSeqStringSetChar final : public LTemplateInstruction<1, 4, 0> {
1438 LSeqStringSetChar(LOperand* context,
1442 inputs_[0] = context;
1443 inputs_[1] = string;
1448 LOperand* string() { return inputs_[1]; }
1449 LOperand* index() { return inputs_[2]; }
1450 LOperand* value() { return inputs_[3]; }
1452 DECLARE_CONCRETE_INSTRUCTION(SeqStringSetChar, "seq-string-set-char")
1453 DECLARE_HYDROGEN_ACCESSOR(SeqStringSetChar)
1457 class LAddI final : public LTemplateInstruction<1, 2, 0> {
1459 LAddI(LOperand* left, LOperand* right) {
1464 LOperand* left() { return inputs_[0]; }
1465 LOperand* right() { return inputs_[1]; }
1467 static bool UseLea(HAdd* add) {
1468 return !add->CheckFlag(HValue::kCanOverflow) &&
1469 add->BetterLeftOperand()->UseCount() > 1;
1472 DECLARE_CONCRETE_INSTRUCTION(AddI, "add-i")
1473 DECLARE_HYDROGEN_ACCESSOR(Add)
1477 class LMathMinMax final : public LTemplateInstruction<1, 2, 1> {
1479 LMathMinMax(LOperand* left, LOperand* right, LOperand* temp) {
1485 LOperand* left() { return inputs_[0]; }
1486 LOperand* right() { return inputs_[1]; }
1487 LOperand* temp() { return temps_[0]; }
1489 DECLARE_CONCRETE_INSTRUCTION(MathMinMax, "math-min-max")
1490 DECLARE_HYDROGEN_ACCESSOR(MathMinMax)
1494 class LPower final : public LTemplateInstruction<1, 2, 0> {
1496 LPower(LOperand* left, LOperand* right) {
1501 LOperand* left() { return inputs_[0]; }
1502 LOperand* right() { return inputs_[1]; }
1504 DECLARE_CONCRETE_INSTRUCTION(Power, "power")
1505 DECLARE_HYDROGEN_ACCESSOR(Power)
1509 class LArithmeticD final : public LTemplateInstruction<1, 2, 0> {
1511 LArithmeticD(Token::Value op, LOperand* left, LOperand* right)
1517 LOperand* left() { return inputs_[0]; }
1518 LOperand* right() { return inputs_[1]; }
1520 Token::Value op() const { return op_; }
1522 Opcode opcode() const override { return LInstruction::kArithmeticD; }
1523 void CompileToNative(LCodeGen* generator) override;
1524 const char* Mnemonic() const override;
1531 class LArithmeticT final : public LTemplateInstruction<1, 3, 0> {
1533 LArithmeticT(Token::Value op,
1538 inputs_[0] = context;
1543 LOperand* context() { return inputs_[0]; }
1544 LOperand* left() { return inputs_[1]; }
1545 LOperand* right() { return inputs_[2]; }
1546 Token::Value op() const { return op_; }
1548 Opcode opcode() const override { return LInstruction::kArithmeticT; }
1549 void CompileToNative(LCodeGen* generator) override;
1550 const char* Mnemonic() const override;
1552 DECLARE_HYDROGEN_ACCESSOR(BinaryOperation)
1554 Strength strength() { return hydrogen()->strength(); }
1561 class LReturn final : public LTemplateInstruction<0, 3, 0> {
1563 explicit LReturn(LOperand* value,
1565 LOperand* parameter_count) {
1567 inputs_[1] = context;
1568 inputs_[2] = parameter_count;
1571 bool has_constant_parameter_count() {
1572 return parameter_count()->IsConstantOperand();
1574 LConstantOperand* constant_parameter_count() {
1575 DCHECK(has_constant_parameter_count());
1576 return LConstantOperand::cast(parameter_count());
1578 LOperand* parameter_count() { return inputs_[2]; }
1580 DECLARE_CONCRETE_INSTRUCTION(Return, "return")
1581 DECLARE_HYDROGEN_ACCESSOR(Return)
1585 class LLoadNamedField final : public LTemplateInstruction<1, 1, 0> {
1587 explicit LLoadNamedField(LOperand* object) {
1588 inputs_[0] = object;
1591 LOperand* object() { return inputs_[0]; }
1593 DECLARE_CONCRETE_INSTRUCTION(LoadNamedField, "load-named-field")
1594 DECLARE_HYDROGEN_ACCESSOR(LoadNamedField)
1598 class LLoadNamedGeneric final : public LTemplateInstruction<1, 2, 1> {
1600 LLoadNamedGeneric(LOperand* context, LOperand* object, LOperand* vector) {
1601 inputs_[0] = context;
1602 inputs_[1] = object;
1606 LOperand* context() { return inputs_[0]; }
1607 LOperand* object() { return inputs_[1]; }
1608 LOperand* temp_vector() { return temps_[0]; }
1610 DECLARE_CONCRETE_INSTRUCTION(LoadNamedGeneric, "load-named-generic")
1611 DECLARE_HYDROGEN_ACCESSOR(LoadNamedGeneric)
1613 Handle<Object> name() const { return hydrogen()->name(); }
1617 class LLoadFunctionPrototype final : public LTemplateInstruction<1, 1, 1> {
1619 LLoadFunctionPrototype(LOperand* function, LOperand* temp) {
1620 inputs_[0] = function;
1624 LOperand* function() { return inputs_[0]; }
1625 LOperand* temp() { return temps_[0]; }
1627 DECLARE_CONCRETE_INSTRUCTION(LoadFunctionPrototype, "load-function-prototype")
1628 DECLARE_HYDROGEN_ACCESSOR(LoadFunctionPrototype)
1632 class LLoadRoot final : public LTemplateInstruction<1, 0, 0> {
1634 DECLARE_CONCRETE_INSTRUCTION(LoadRoot, "load-root")
1635 DECLARE_HYDROGEN_ACCESSOR(LoadRoot)
1637 Heap::RootListIndex index() const { return hydrogen()->index(); }
1641 class LLoadKeyed final : public LTemplateInstruction<1, 2, 0> {
1643 LLoadKeyed(LOperand* elements, LOperand* key) {
1644 inputs_[0] = elements;
1647 LOperand* elements() { return inputs_[0]; }
1648 LOperand* key() { return inputs_[1]; }
1649 ElementsKind elements_kind() const {
1650 return hydrogen()->elements_kind();
1652 bool is_fixed_typed_array() const {
1653 return hydrogen()->is_fixed_typed_array();
1656 DECLARE_CONCRETE_INSTRUCTION(LoadKeyed, "load-keyed")
1657 DECLARE_HYDROGEN_ACCESSOR(LoadKeyed)
1659 void PrintDataTo(StringStream* stream) override;
1660 uint32_t base_offset() const { return hydrogen()->base_offset(); }
1662 return hydrogen()->key()->representation().IsTagged();
1667 inline static bool ExternalArrayOpRequiresTemp(
1668 Representation key_representation,
1669 ElementsKind elements_kind) {
1670 // Operations that require the key to be divided by two to be converted into
1671 // an index cannot fold the scale operation into a load and need an extra
1672 // temp register to do the work.
1673 return key_representation.IsSmi() &&
1674 (elements_kind == UINT8_ELEMENTS || elements_kind == INT8_ELEMENTS ||
1675 elements_kind == UINT8_CLAMPED_ELEMENTS);
1679 class LLoadKeyedGeneric final : public LTemplateInstruction<1, 3, 1> {
1681 LLoadKeyedGeneric(LOperand* context, LOperand* obj, LOperand* key,
1683 inputs_[0] = context;
1689 LOperand* context() { return inputs_[0]; }
1690 LOperand* object() { return inputs_[1]; }
1691 LOperand* key() { return inputs_[2]; }
1692 LOperand* temp_vector() { return temps_[0]; }
1694 DECLARE_CONCRETE_INSTRUCTION(LoadKeyedGeneric, "load-keyed-generic")
1695 DECLARE_HYDROGEN_ACCESSOR(LoadKeyedGeneric)
1699 class LLoadGlobalGeneric final : public LTemplateInstruction<1, 2, 1> {
1701 LLoadGlobalGeneric(LOperand* context, LOperand* global_object,
1703 inputs_[0] = context;
1704 inputs_[1] = global_object;
1708 LOperand* context() { return inputs_[0]; }
1709 LOperand* global_object() { return inputs_[1]; }
1710 LOperand* temp_vector() { return temps_[0]; }
1712 DECLARE_CONCRETE_INSTRUCTION(LoadGlobalGeneric, "load-global-generic")
1713 DECLARE_HYDROGEN_ACCESSOR(LoadGlobalGeneric)
1715 Handle<Object> name() const { return hydrogen()->name(); }
1716 TypeofMode typeof_mode() const { return hydrogen()->typeof_mode(); }
1720 class LLoadGlobalViaContext final : public LTemplateInstruction<1, 1, 1> {
1722 explicit LLoadGlobalViaContext(LOperand* context) { inputs_[0] = context; }
1724 DECLARE_CONCRETE_INSTRUCTION(LoadGlobalViaContext, "load-global-via-context")
1725 DECLARE_HYDROGEN_ACCESSOR(LoadGlobalViaContext)
1727 void PrintDataTo(StringStream* stream) override;
1729 LOperand* context() { return inputs_[0]; }
1731 int depth() const { return hydrogen()->depth(); }
1732 int slot_index() const { return hydrogen()->slot_index(); }
1736 class LLoadContextSlot final : public LTemplateInstruction<1, 1, 0> {
1738 explicit LLoadContextSlot(LOperand* context) {
1739 inputs_[0] = context;
1742 LOperand* context() { return inputs_[0]; }
1744 DECLARE_CONCRETE_INSTRUCTION(LoadContextSlot, "load-context-slot")
1745 DECLARE_HYDROGEN_ACCESSOR(LoadContextSlot)
1747 int slot_index() { return hydrogen()->slot_index(); }
1749 void PrintDataTo(StringStream* stream) override;
1753 class LStoreContextSlot final : public LTemplateInstruction<0, 2, 1> {
1755 LStoreContextSlot(LOperand* context, LOperand* value, LOperand* temp) {
1756 inputs_[0] = context;
1761 LOperand* context() { return inputs_[0]; }
1762 LOperand* value() { return inputs_[1]; }
1763 LOperand* temp() { return temps_[0]; }
1765 DECLARE_CONCRETE_INSTRUCTION(StoreContextSlot, "store-context-slot")
1766 DECLARE_HYDROGEN_ACCESSOR(StoreContextSlot)
1768 int slot_index() { return hydrogen()->slot_index(); }
1770 void PrintDataTo(StringStream* stream) override;
1774 class LPushArgument final : public LTemplateInstruction<0, 1, 0> {
1776 explicit LPushArgument(LOperand* value) {
1780 LOperand* value() { return inputs_[0]; }
1782 DECLARE_CONCRETE_INSTRUCTION(PushArgument, "push-argument")
1786 class LDrop final : public LTemplateInstruction<0, 0, 0> {
1788 explicit LDrop(int count) : count_(count) { }
1790 int count() const { return count_; }
1792 DECLARE_CONCRETE_INSTRUCTION(Drop, "drop")
1799 class LStoreCodeEntry final : public LTemplateInstruction<0, 2, 0> {
1801 LStoreCodeEntry(LOperand* function, LOperand* code_object) {
1802 inputs_[0] = function;
1803 inputs_[1] = code_object;
1806 LOperand* function() { return inputs_[0]; }
1807 LOperand* code_object() { return inputs_[1]; }
1809 void PrintDataTo(StringStream* stream) override;
1811 DECLARE_CONCRETE_INSTRUCTION(StoreCodeEntry, "store-code-entry")
1812 DECLARE_HYDROGEN_ACCESSOR(StoreCodeEntry)
1816 class LInnerAllocatedObject final : public LTemplateInstruction<1, 2, 0> {
1818 LInnerAllocatedObject(LOperand* base_object, LOperand* offset) {
1819 inputs_[0] = base_object;
1820 inputs_[1] = offset;
1823 LOperand* base_object() const { return inputs_[0]; }
1824 LOperand* offset() const { return inputs_[1]; }
1826 void PrintDataTo(StringStream* stream) override;
1828 DECLARE_CONCRETE_INSTRUCTION(InnerAllocatedObject, "inner-allocated-object")
1832 class LThisFunction final : public LTemplateInstruction<1, 0, 0> {
1834 DECLARE_CONCRETE_INSTRUCTION(ThisFunction, "this-function")
1835 DECLARE_HYDROGEN_ACCESSOR(ThisFunction)
1839 class LContext final : public LTemplateInstruction<1, 0, 0> {
1841 DECLARE_CONCRETE_INSTRUCTION(Context, "context")
1842 DECLARE_HYDROGEN_ACCESSOR(Context)
1846 class LDeclareGlobals final : public LTemplateInstruction<0, 1, 0> {
1848 explicit LDeclareGlobals(LOperand* context) {
1849 inputs_[0] = context;
1852 LOperand* context() { return inputs_[0]; }
1854 DECLARE_CONCRETE_INSTRUCTION(DeclareGlobals, "declare-globals")
1855 DECLARE_HYDROGEN_ACCESSOR(DeclareGlobals)
1859 class LCallJSFunction final : public LTemplateInstruction<1, 1, 0> {
1861 explicit LCallJSFunction(LOperand* function) {
1862 inputs_[0] = function;
1865 LOperand* function() { return inputs_[0]; }
1867 DECLARE_CONCRETE_INSTRUCTION(CallJSFunction, "call-js-function")
1868 DECLARE_HYDROGEN_ACCESSOR(CallJSFunction)
1870 void PrintDataTo(StringStream* stream) override;
1872 int arity() const { return hydrogen()->argument_count() - 1; }
1876 class LCallWithDescriptor final : public LTemplateResultInstruction<1> {
1878 LCallWithDescriptor(CallInterfaceDescriptor descriptor,
1879 const ZoneList<LOperand*>& operands, Zone* zone)
1880 : inputs_(descriptor.GetRegisterParameterCount() +
1881 kImplicitRegisterParameterCount,
1883 DCHECK(descriptor.GetRegisterParameterCount() +
1884 kImplicitRegisterParameterCount ==
1886 inputs_.AddAll(operands, zone);
1889 LOperand* target() const { return inputs_[0]; }
1891 DECLARE_HYDROGEN_ACCESSOR(CallWithDescriptor)
1893 // The target and context are passed as implicit parameters that are not
1894 // explicitly listed in the descriptor.
1895 static const int kImplicitRegisterParameterCount = 2;
1898 DECLARE_CONCRETE_INSTRUCTION(CallWithDescriptor, "call-with-descriptor")
1900 void PrintDataTo(StringStream* stream) override;
1902 int arity() const { return hydrogen()->argument_count() - 1; }
1904 ZoneList<LOperand*> inputs_;
1906 // Iterator support.
1907 int InputCount() final { return inputs_.length(); }
1908 LOperand* InputAt(int i) final { return inputs_[i]; }
1910 int TempCount() final { return 0; }
1911 LOperand* TempAt(int i) final { return NULL; }
1915 class LInvokeFunction final : public LTemplateInstruction<1, 2, 0> {
1917 LInvokeFunction(LOperand* context, LOperand* function) {
1918 inputs_[0] = context;
1919 inputs_[1] = function;
1922 LOperand* context() { return inputs_[0]; }
1923 LOperand* function() { return inputs_[1]; }
1925 DECLARE_CONCRETE_INSTRUCTION(InvokeFunction, "invoke-function")
1926 DECLARE_HYDROGEN_ACCESSOR(InvokeFunction)
1928 void PrintDataTo(StringStream* stream) override;
1930 int arity() const { return hydrogen()->argument_count() - 1; }
1934 class LCallFunction final : public LTemplateInstruction<1, 2, 2> {
1936 LCallFunction(LOperand* context, LOperand* function, LOperand* slot,
1938 inputs_[0] = context;
1939 inputs_[1] = function;
1944 LOperand* context() { return inputs_[0]; }
1945 LOperand* function() { return inputs_[1]; }
1946 LOperand* temp_slot() { return temps_[0]; }
1947 LOperand* temp_vector() { return temps_[1]; }
1949 DECLARE_CONCRETE_INSTRUCTION(CallFunction, "call-function")
1950 DECLARE_HYDROGEN_ACCESSOR(CallFunction)
1952 void PrintDataTo(StringStream* stream) override;
1953 int arity() const { return hydrogen()->argument_count() - 1; }
1957 class LCallNew final : public LTemplateInstruction<1, 2, 0> {
1959 LCallNew(LOperand* context, LOperand* constructor) {
1960 inputs_[0] = context;
1961 inputs_[1] = constructor;
1964 LOperand* context() { return inputs_[0]; }
1965 LOperand* constructor() { return inputs_[1]; }
1967 DECLARE_CONCRETE_INSTRUCTION(CallNew, "call-new")
1968 DECLARE_HYDROGEN_ACCESSOR(CallNew)
1970 void PrintDataTo(StringStream* stream) override;
1972 int arity() const { return hydrogen()->argument_count() - 1; }
1976 class LCallNewArray final : public LTemplateInstruction<1, 2, 0> {
1978 LCallNewArray(LOperand* context, LOperand* constructor) {
1979 inputs_[0] = context;
1980 inputs_[1] = constructor;
1983 LOperand* context() { return inputs_[0]; }
1984 LOperand* constructor() { return inputs_[1]; }
1986 DECLARE_CONCRETE_INSTRUCTION(CallNewArray, "call-new-array")
1987 DECLARE_HYDROGEN_ACCESSOR(CallNewArray)
1989 void PrintDataTo(StringStream* stream) override;
1991 int arity() const { return hydrogen()->argument_count() - 1; }
1995 class LCallRuntime final : public LTemplateInstruction<1, 1, 0> {
1997 explicit LCallRuntime(LOperand* context) {
1998 inputs_[0] = context;
2001 LOperand* context() { return inputs_[0]; }
2003 DECLARE_CONCRETE_INSTRUCTION(CallRuntime, "call-runtime")
2004 DECLARE_HYDROGEN_ACCESSOR(CallRuntime)
2006 bool ClobbersDoubleRegisters(Isolate* isolate) const override {
2007 return save_doubles() == kDontSaveFPRegs;
2010 const Runtime::Function* function() const { return hydrogen()->function(); }
2011 int arity() const { return hydrogen()->argument_count(); }
2012 SaveFPRegsMode save_doubles() const { return hydrogen()->save_doubles(); }
2016 class LInteger32ToDouble final : public LTemplateInstruction<1, 1, 0> {
2018 explicit LInteger32ToDouble(LOperand* value) {
2022 LOperand* value() { return inputs_[0]; }
2024 DECLARE_CONCRETE_INSTRUCTION(Integer32ToDouble, "int32-to-double")
2028 class LUint32ToDouble final : public LTemplateInstruction<1, 1, 1> {
2030 explicit LUint32ToDouble(LOperand* value) {
2034 LOperand* value() { return inputs_[0]; }
2036 DECLARE_CONCRETE_INSTRUCTION(Uint32ToDouble, "uint32-to-double")
2040 class LNumberTagI final : public LTemplateInstruction<1, 1, 1> {
2042 LNumberTagI(LOperand* value, LOperand* temp) {
2047 LOperand* value() { return inputs_[0]; }
2048 LOperand* temp() { return temps_[0]; }
2050 DECLARE_CONCRETE_INSTRUCTION(NumberTagI, "number-tag-i")
2054 class LNumberTagU final : public LTemplateInstruction<1, 1, 1> {
2056 LNumberTagU(LOperand* value, LOperand* temp) {
2061 LOperand* value() { return inputs_[0]; }
2062 LOperand* temp() { return temps_[0]; }
2064 DECLARE_CONCRETE_INSTRUCTION(NumberTagU, "number-tag-u")
2068 class LNumberTagD final : public LTemplateInstruction<1, 1, 1> {
2070 LNumberTagD(LOperand* value, LOperand* temp) {
2075 LOperand* value() { return inputs_[0]; }
2076 LOperand* temp() { return temps_[0]; }
2078 DECLARE_CONCRETE_INSTRUCTION(NumberTagD, "number-tag-d")
2079 DECLARE_HYDROGEN_ACCESSOR(Change)
2083 // Sometimes truncating conversion from a tagged value to an int32.
2084 class LDoubleToI final : public LTemplateInstruction<1, 1, 0> {
2086 explicit LDoubleToI(LOperand* value) {
2090 LOperand* value() { return inputs_[0]; }
2092 DECLARE_CONCRETE_INSTRUCTION(DoubleToI, "double-to-i")
2093 DECLARE_HYDROGEN_ACCESSOR(UnaryOperation)
2095 bool truncating() { return hydrogen()->CanTruncateToInt32(); }
2099 class LDoubleToSmi final : public LTemplateInstruction<1, 1, 0> {
2101 explicit LDoubleToSmi(LOperand* value) {
2105 LOperand* value() { return inputs_[0]; }
2107 DECLARE_CONCRETE_INSTRUCTION(DoubleToSmi, "double-to-smi")
2108 DECLARE_HYDROGEN_ACCESSOR(UnaryOperation)
2112 // Truncating conversion from a tagged value to an int32.
2113 class LTaggedToI final : public LTemplateInstruction<1, 1, 0> {
2115 explicit LTaggedToI(LOperand* value) {
2119 LOperand* value() { return inputs_[0]; }
2121 DECLARE_CONCRETE_INSTRUCTION(TaggedToI, "tagged-to-i")
2122 DECLARE_HYDROGEN_ACCESSOR(Change)
2124 bool truncating() { return hydrogen()->CanTruncateToInt32(); }
2128 class LSmiTag final : public LTemplateInstruction<1, 1, 0> {
2130 explicit LSmiTag(LOperand* value) {
2134 LOperand* value() { return inputs_[0]; }
2136 DECLARE_CONCRETE_INSTRUCTION(SmiTag, "smi-tag")
2137 DECLARE_HYDROGEN_ACCESSOR(Change)
2141 class LNumberUntagD final : public LTemplateInstruction<1, 1, 1> {
2143 explicit LNumberUntagD(LOperand* value, LOperand* temp) {
2148 LOperand* value() { return inputs_[0]; }
2149 LOperand* temp() { return temps_[0]; }
2151 DECLARE_CONCRETE_INSTRUCTION(NumberUntagD, "double-untag")
2152 DECLARE_HYDROGEN_ACCESSOR(Change);
2156 class LSmiUntag final : public LTemplateInstruction<1, 1, 0> {
2158 LSmiUntag(LOperand* value, bool needs_check)
2159 : needs_check_(needs_check) {
2163 LOperand* value() { return inputs_[0]; }
2165 DECLARE_CONCRETE_INSTRUCTION(SmiUntag, "smi-untag")
2167 bool needs_check() const { return needs_check_; }
2174 class LStoreNamedField final : public LTemplateInstruction<0, 2, 2> {
2176 LStoreNamedField(LOperand* obj,
2179 LOperand* temp_map) {
2183 temps_[1] = temp_map;
2186 LOperand* object() { return inputs_[0]; }
2187 LOperand* value() { return inputs_[1]; }
2188 LOperand* temp() { return temps_[0]; }
2189 LOperand* temp_map() { return temps_[1]; }
2191 DECLARE_CONCRETE_INSTRUCTION(StoreNamedField, "store-named-field")
2192 DECLARE_HYDROGEN_ACCESSOR(StoreNamedField)
2194 void PrintDataTo(StringStream* stream) override;
2198 class LStoreNamedGeneric final : public LTemplateInstruction<0, 3, 2> {
2200 LStoreNamedGeneric(LOperand* context, LOperand* object, LOperand* value,
2201 LOperand* slot, LOperand* vector) {
2202 inputs_[0] = context;
2203 inputs_[1] = object;
2209 LOperand* context() { return inputs_[0]; }
2210 LOperand* object() { return inputs_[1]; }
2211 LOperand* value() { return inputs_[2]; }
2212 LOperand* temp_slot() { return temps_[0]; }
2213 LOperand* temp_vector() { return temps_[1]; }
2215 DECLARE_CONCRETE_INSTRUCTION(StoreNamedGeneric, "store-named-generic")
2216 DECLARE_HYDROGEN_ACCESSOR(StoreNamedGeneric)
2218 void PrintDataTo(StringStream* stream) override;
2219 Handle<Object> name() const { return hydrogen()->name(); }
2220 LanguageMode language_mode() { return hydrogen()->language_mode(); }
2224 class LStoreGlobalViaContext final : public LTemplateInstruction<0, 2, 0> {
2226 LStoreGlobalViaContext(LOperand* context, LOperand* value) {
2227 inputs_[0] = context;
2231 LOperand* context() { return inputs_[0]; }
2232 LOperand* value() { return inputs_[1]; }
2234 DECLARE_CONCRETE_INSTRUCTION(StoreGlobalViaContext,
2235 "store-global-via-context")
2236 DECLARE_HYDROGEN_ACCESSOR(StoreGlobalViaContext)
2238 void PrintDataTo(StringStream* stream) override;
2240 int depth() { return hydrogen()->depth(); }
2241 int slot_index() { return hydrogen()->slot_index(); }
2242 LanguageMode language_mode() { return hydrogen()->language_mode(); }
2246 class LStoreKeyed final : public LTemplateInstruction<0, 3, 0> {
2248 LStoreKeyed(LOperand* obj, LOperand* key, LOperand* val) {
2254 bool is_fixed_typed_array() const {
2255 return hydrogen()->is_fixed_typed_array();
2257 LOperand* elements() { return inputs_[0]; }
2258 LOperand* key() { return inputs_[1]; }
2259 LOperand* value() { return inputs_[2]; }
2260 ElementsKind elements_kind() const {
2261 return hydrogen()->elements_kind();
2264 DECLARE_CONCRETE_INSTRUCTION(StoreKeyed, "store-keyed")
2265 DECLARE_HYDROGEN_ACCESSOR(StoreKeyed)
2267 void PrintDataTo(StringStream* stream) override;
2268 uint32_t base_offset() const { return hydrogen()->base_offset(); }
2269 bool NeedsCanonicalization() { return hydrogen()->NeedsCanonicalization(); }
2273 class LStoreKeyedGeneric final : public LTemplateInstruction<0, 4, 2> {
2275 LStoreKeyedGeneric(LOperand* context, LOperand* object, LOperand* key,
2276 LOperand* value, LOperand* slot, LOperand* vector) {
2277 inputs_[0] = context;
2278 inputs_[1] = object;
2285 LOperand* context() { return inputs_[0]; }
2286 LOperand* object() { return inputs_[1]; }
2287 LOperand* key() { return inputs_[2]; }
2288 LOperand* value() { return inputs_[3]; }
2289 LOperand* temp_slot() { return temps_[0]; }
2290 LOperand* temp_vector() { return temps_[1]; }
2292 DECLARE_CONCRETE_INSTRUCTION(StoreKeyedGeneric, "store-keyed-generic")
2293 DECLARE_HYDROGEN_ACCESSOR(StoreKeyedGeneric)
2295 void PrintDataTo(StringStream* stream) override;
2297 LanguageMode language_mode() { return hydrogen()->language_mode(); }
2301 class LTransitionElementsKind final : public LTemplateInstruction<0, 2, 2> {
2303 LTransitionElementsKind(LOperand* object,
2305 LOperand* new_map_temp,
2307 inputs_[0] = object;
2308 inputs_[1] = context;
2309 temps_[0] = new_map_temp;
2313 LOperand* context() { return inputs_[1]; }
2314 LOperand* object() { return inputs_[0]; }
2315 LOperand* new_map_temp() { return temps_[0]; }
2316 LOperand* temp() { return temps_[1]; }
2318 DECLARE_CONCRETE_INSTRUCTION(TransitionElementsKind,
2319 "transition-elements-kind")
2320 DECLARE_HYDROGEN_ACCESSOR(TransitionElementsKind)
2322 void PrintDataTo(StringStream* stream) override;
2324 Handle<Map> original_map() { return hydrogen()->original_map().handle(); }
2325 Handle<Map> transitioned_map() {
2326 return hydrogen()->transitioned_map().handle();
2328 ElementsKind from_kind() { return hydrogen()->from_kind(); }
2329 ElementsKind to_kind() { return hydrogen()->to_kind(); }
2333 class LTrapAllocationMemento final : public LTemplateInstruction<0, 1, 1> {
2335 LTrapAllocationMemento(LOperand* object,
2337 inputs_[0] = object;
2341 LOperand* object() { return inputs_[0]; }
2342 LOperand* temp() { return temps_[0]; }
2344 DECLARE_CONCRETE_INSTRUCTION(TrapAllocationMemento,
2345 "trap-allocation-memento")
2349 class LMaybeGrowElements final : public LTemplateInstruction<1, 5, 0> {
2351 LMaybeGrowElements(LOperand* context, LOperand* object, LOperand* elements,
2352 LOperand* key, LOperand* current_capacity) {
2353 inputs_[0] = context;
2354 inputs_[1] = object;
2355 inputs_[2] = elements;
2357 inputs_[4] = current_capacity;
2360 LOperand* context() { return inputs_[0]; }
2361 LOperand* object() { return inputs_[1]; }
2362 LOperand* elements() { return inputs_[2]; }
2363 LOperand* key() { return inputs_[3]; }
2364 LOperand* current_capacity() { return inputs_[4]; }
2366 DECLARE_HYDROGEN_ACCESSOR(MaybeGrowElements)
2367 DECLARE_CONCRETE_INSTRUCTION(MaybeGrowElements, "maybe-grow-elements")
2371 class LStringAdd final : public LTemplateInstruction<1, 3, 0> {
2373 LStringAdd(LOperand* context, LOperand* left, LOperand* right) {
2374 inputs_[0] = context;
2379 LOperand* context() { return inputs_[0]; }
2380 LOperand* left() { return inputs_[1]; }
2381 LOperand* right() { return inputs_[2]; }
2383 DECLARE_CONCRETE_INSTRUCTION(StringAdd, "string-add")
2384 DECLARE_HYDROGEN_ACCESSOR(StringAdd)
2388 class LStringCharCodeAt final : public LTemplateInstruction<1, 3, 0> {
2390 LStringCharCodeAt(LOperand* context, LOperand* string, LOperand* index) {
2391 inputs_[0] = context;
2392 inputs_[1] = string;
2396 LOperand* context() { return inputs_[0]; }
2397 LOperand* string() { return inputs_[1]; }
2398 LOperand* index() { return inputs_[2]; }
2400 DECLARE_CONCRETE_INSTRUCTION(StringCharCodeAt, "string-char-code-at")
2401 DECLARE_HYDROGEN_ACCESSOR(StringCharCodeAt)
2405 class LStringCharFromCode final : public LTemplateInstruction<1, 2, 0> {
2407 LStringCharFromCode(LOperand* context, LOperand* char_code) {
2408 inputs_[0] = context;
2409 inputs_[1] = char_code;
2412 LOperand* context() { return inputs_[0]; }
2413 LOperand* char_code() { return inputs_[1]; }
2415 DECLARE_CONCRETE_INSTRUCTION(StringCharFromCode, "string-char-from-code")
2416 DECLARE_HYDROGEN_ACCESSOR(StringCharFromCode)
2420 class LCheckValue final : public LTemplateInstruction<0, 1, 0> {
2422 explicit LCheckValue(LOperand* value) {
2426 LOperand* value() { return inputs_[0]; }
2428 DECLARE_CONCRETE_INSTRUCTION(CheckValue, "check-value")
2429 DECLARE_HYDROGEN_ACCESSOR(CheckValue)
2433 class LCheckArrayBufferNotNeutered final
2434 : public LTemplateInstruction<0, 1, 1> {
2436 explicit LCheckArrayBufferNotNeutered(LOperand* view, LOperand* scratch) {
2438 temps_[0] = scratch;
2441 LOperand* view() { return inputs_[0]; }
2442 LOperand* scratch() { return temps_[0]; }
2444 DECLARE_CONCRETE_INSTRUCTION(CheckArrayBufferNotNeutered,
2445 "check-array-buffer-not-neutered")
2446 DECLARE_HYDROGEN_ACCESSOR(CheckArrayBufferNotNeutered)
2450 class LCheckInstanceType final : public LTemplateInstruction<0, 1, 1> {
2452 LCheckInstanceType(LOperand* value, LOperand* temp) {
2457 LOperand* value() { return inputs_[0]; }
2458 LOperand* temp() { return temps_[0]; }
2460 DECLARE_CONCRETE_INSTRUCTION(CheckInstanceType, "check-instance-type")
2461 DECLARE_HYDROGEN_ACCESSOR(CheckInstanceType)
2465 class LCheckMaps final : public LTemplateInstruction<0, 1, 0> {
2467 explicit LCheckMaps(LOperand* value = NULL) {
2471 LOperand* value() { return inputs_[0]; }
2473 DECLARE_CONCRETE_INSTRUCTION(CheckMaps, "check-maps")
2474 DECLARE_HYDROGEN_ACCESSOR(CheckMaps)
2478 class LCheckSmi final : public LTemplateInstruction<1, 1, 0> {
2480 explicit LCheckSmi(LOperand* value) {
2484 LOperand* value() { return inputs_[0]; }
2486 DECLARE_CONCRETE_INSTRUCTION(CheckSmi, "check-smi")
2490 class LClampDToUint8 final : public LTemplateInstruction<1, 1, 0> {
2492 explicit LClampDToUint8(LOperand* value) {
2496 LOperand* unclamped() { return inputs_[0]; }
2498 DECLARE_CONCRETE_INSTRUCTION(ClampDToUint8, "clamp-d-to-uint8")
2502 class LClampIToUint8 final : public LTemplateInstruction<1, 1, 0> {
2504 explicit LClampIToUint8(LOperand* value) {
2508 LOperand* unclamped() { return inputs_[0]; }
2510 DECLARE_CONCRETE_INSTRUCTION(ClampIToUint8, "clamp-i-to-uint8")
2514 // Truncating conversion from a tagged value to an int32.
2515 class LClampTToUint8NoSSE2 final : public LTemplateInstruction<1, 1, 3> {
2517 LClampTToUint8NoSSE2(LOperand* unclamped,
2521 inputs_[0] = unclamped;
2527 LOperand* unclamped() { return inputs_[0]; }
2528 LOperand* scratch() { return temps_[0]; }
2529 LOperand* scratch2() { return temps_[1]; }
2530 LOperand* scratch3() { return temps_[2]; }
2532 DECLARE_CONCRETE_INSTRUCTION(ClampTToUint8NoSSE2,
2533 "clamp-t-to-uint8-nosse2")
2534 DECLARE_HYDROGEN_ACCESSOR(UnaryOperation)
2538 class LCheckNonSmi final : public LTemplateInstruction<0, 1, 0> {
2540 explicit LCheckNonSmi(LOperand* value) {
2544 LOperand* value() { return inputs_[0]; }
2546 DECLARE_CONCRETE_INSTRUCTION(CheckNonSmi, "check-non-smi")
2547 DECLARE_HYDROGEN_ACCESSOR(CheckHeapObject)
2551 class LDoubleBits final : public LTemplateInstruction<1, 1, 0> {
2553 explicit LDoubleBits(LOperand* value) {
2557 LOperand* value() { return inputs_[0]; }
2559 DECLARE_CONCRETE_INSTRUCTION(DoubleBits, "double-bits")
2560 DECLARE_HYDROGEN_ACCESSOR(DoubleBits)
2564 class LConstructDouble final : public LTemplateInstruction<1, 2, 0> {
2566 LConstructDouble(LOperand* hi, LOperand* lo) {
2571 LOperand* hi() { return inputs_[0]; }
2572 LOperand* lo() { return inputs_[1]; }
2574 DECLARE_CONCRETE_INSTRUCTION(ConstructDouble, "construct-double")
2578 class LAllocate final : public LTemplateInstruction<1, 2, 1> {
2580 LAllocate(LOperand* context, LOperand* size, LOperand* temp) {
2581 inputs_[0] = context;
2586 LOperand* context() { return inputs_[0]; }
2587 LOperand* size() { return inputs_[1]; }
2588 LOperand* temp() { return temps_[0]; }
2590 DECLARE_CONCRETE_INSTRUCTION(Allocate, "allocate")
2591 DECLARE_HYDROGEN_ACCESSOR(Allocate)
2595 class LRegExpLiteral final : public LTemplateInstruction<1, 1, 0> {
2597 explicit LRegExpLiteral(LOperand* context) {
2598 inputs_[0] = context;
2601 LOperand* context() { return inputs_[0]; }
2603 DECLARE_CONCRETE_INSTRUCTION(RegExpLiteral, "regexp-literal")
2604 DECLARE_HYDROGEN_ACCESSOR(RegExpLiteral)
2608 class LFunctionLiteral final : public LTemplateInstruction<1, 1, 0> {
2610 explicit LFunctionLiteral(LOperand* context) {
2611 inputs_[0] = context;
2614 LOperand* context() { return inputs_[0]; }
2616 DECLARE_CONCRETE_INSTRUCTION(FunctionLiteral, "function-literal")
2617 DECLARE_HYDROGEN_ACCESSOR(FunctionLiteral)
2621 class LToFastProperties final : public LTemplateInstruction<1, 1, 0> {
2623 explicit LToFastProperties(LOperand* value) {
2627 LOperand* value() { return inputs_[0]; }
2629 DECLARE_CONCRETE_INSTRUCTION(ToFastProperties, "to-fast-properties")
2630 DECLARE_HYDROGEN_ACCESSOR(ToFastProperties)
2634 class LTypeof final : public LTemplateInstruction<1, 2, 0> {
2636 LTypeof(LOperand* context, LOperand* value) {
2637 inputs_[0] = context;
2641 LOperand* context() { return inputs_[0]; }
2642 LOperand* value() { return inputs_[1]; }
2644 DECLARE_CONCRETE_INSTRUCTION(Typeof, "typeof")
2648 class LTypeofIsAndBranch final : public LControlInstruction<1, 0> {
2650 explicit LTypeofIsAndBranch(LOperand* value) {
2654 LOperand* value() { return inputs_[0]; }
2656 DECLARE_CONCRETE_INSTRUCTION(TypeofIsAndBranch, "typeof-is-and-branch")
2657 DECLARE_HYDROGEN_ACCESSOR(TypeofIsAndBranch)
2659 Handle<String> type_literal() { return hydrogen()->type_literal(); }
2661 void PrintDataTo(StringStream* stream) override;
2665 class LOsrEntry final : public LTemplateInstruction<0, 0, 0> {
2667 bool HasInterestingComment(LCodeGen* gen) const override { return false; }
2668 DECLARE_CONCRETE_INSTRUCTION(OsrEntry, "osr-entry")
2672 class LStackCheck final : public LTemplateInstruction<0, 1, 0> {
2674 explicit LStackCheck(LOperand* context) {
2675 inputs_[0] = context;
2678 LOperand* context() { return inputs_[0]; }
2680 DECLARE_CONCRETE_INSTRUCTION(StackCheck, "stack-check")
2681 DECLARE_HYDROGEN_ACCESSOR(StackCheck)
2683 Label* done_label() { return &done_label_; }
2690 class LForInPrepareMap final : public LTemplateInstruction<1, 2, 0> {
2692 LForInPrepareMap(LOperand* context, LOperand* object) {
2693 inputs_[0] = context;
2694 inputs_[1] = object;
2697 LOperand* context() { return inputs_[0]; }
2698 LOperand* object() { return inputs_[1]; }
2700 DECLARE_CONCRETE_INSTRUCTION(ForInPrepareMap, "for-in-prepare-map")
2704 class LForInCacheArray final : public LTemplateInstruction<1, 1, 0> {
2706 explicit LForInCacheArray(LOperand* map) {
2710 LOperand* map() { return inputs_[0]; }
2712 DECLARE_CONCRETE_INSTRUCTION(ForInCacheArray, "for-in-cache-array")
2715 return HForInCacheArray::cast(this->hydrogen_value())->idx();
2720 class LCheckMapValue final : public LTemplateInstruction<0, 2, 0> {
2722 LCheckMapValue(LOperand* value, LOperand* map) {
2727 LOperand* value() { return inputs_[0]; }
2728 LOperand* map() { return inputs_[1]; }
2730 DECLARE_CONCRETE_INSTRUCTION(CheckMapValue, "check-map-value")
2734 class LLoadFieldByIndex final : public LTemplateInstruction<1, 2, 0> {
2736 LLoadFieldByIndex(LOperand* object, LOperand* index) {
2737 inputs_[0] = object;
2741 LOperand* object() { return inputs_[0]; }
2742 LOperand* index() { return inputs_[1]; }
2744 DECLARE_CONCRETE_INSTRUCTION(LoadFieldByIndex, "load-field-by-index")
2748 class LStoreFrameContext: public LTemplateInstruction<0, 1, 0> {
2750 explicit LStoreFrameContext(LOperand* context) {
2751 inputs_[0] = context;
2754 LOperand* context() { return inputs_[0]; }
2756 DECLARE_CONCRETE_INSTRUCTION(StoreFrameContext, "store-frame-context")
2760 class LAllocateBlockContext: public LTemplateInstruction<1, 2, 0> {
2762 LAllocateBlockContext(LOperand* context, LOperand* function) {
2763 inputs_[0] = context;
2764 inputs_[1] = function;
2767 LOperand* context() { return inputs_[0]; }
2768 LOperand* function() { return inputs_[1]; }
2770 Handle<ScopeInfo> scope_info() { return hydrogen()->scope_info(); }
2772 DECLARE_CONCRETE_INSTRUCTION(AllocateBlockContext, "allocate-block-context")
2773 DECLARE_HYDROGEN_ACCESSOR(AllocateBlockContext)
2777 class LChunkBuilder;
2778 class LPlatformChunk final : public LChunk {
2780 LPlatformChunk(CompilationInfo* info, HGraph* graph)
2781 : LChunk(info, graph),
2782 num_double_slots_(0) { }
2784 int GetNextSpillIndex(RegisterKind kind);
2785 LOperand* GetNextSpillSlot(RegisterKind kind);
2787 int num_double_slots() const { return num_double_slots_; }
2790 int num_double_slots_;
2794 class LChunkBuilder final : public LChunkBuilderBase {
2796 LChunkBuilder(CompilationInfo* info, HGraph* graph, LAllocator* allocator)
2797 : LChunkBuilderBase(info, graph),
2798 current_instruction_(NULL),
2799 current_block_(NULL),
2801 allocator_(allocator) {}
2803 // Build the sequence for the graph.
2804 LPlatformChunk* Build();
2806 // Declare methods that deal with the individual node types.
2807 #define DECLARE_DO(type) LInstruction* Do##type(H##type* node);
2808 HYDROGEN_CONCRETE_INSTRUCTION_LIST(DECLARE_DO)
2811 LInstruction* DoMathFloor(HUnaryMathOperation* instr);
2812 LInstruction* DoMathRound(HUnaryMathOperation* instr);
2813 LInstruction* DoMathFround(HUnaryMathOperation* instr);
2814 LInstruction* DoMathAbs(HUnaryMathOperation* instr);
2815 LInstruction* DoMathLog(HUnaryMathOperation* instr);
2816 LInstruction* DoMathExp(HUnaryMathOperation* instr);
2817 LInstruction* DoMathSqrt(HUnaryMathOperation* instr);
2818 LInstruction* DoMathPowHalf(HUnaryMathOperation* instr);
2819 LInstruction* DoMathClz32(HUnaryMathOperation* instr);
2820 LInstruction* DoDivByPowerOf2I(HDiv* instr);
2821 LInstruction* DoDivByConstI(HDiv* instr);
2822 LInstruction* DoDivI(HDiv* instr);
2823 LInstruction* DoModByPowerOf2I(HMod* instr);
2824 LInstruction* DoModByConstI(HMod* instr);
2825 LInstruction* DoModI(HMod* instr);
2826 LInstruction* DoFlooringDivByPowerOf2I(HMathFloorOfDiv* instr);
2827 LInstruction* DoFlooringDivByConstI(HMathFloorOfDiv* instr);
2828 LInstruction* DoFlooringDivI(HMathFloorOfDiv* instr);
2831 // Methods for getting operands for Use / Define / Temp.
2832 LUnallocated* ToUnallocated(Register reg);
2833 LUnallocated* ToUnallocated(X87Register reg);
2835 // Methods for setting up define-use relationships.
2836 MUST_USE_RESULT LOperand* Use(HValue* value, LUnallocated* operand);
2837 MUST_USE_RESULT LOperand* UseFixed(HValue* value, Register fixed_register);
2839 // A value that is guaranteed to be allocated to a register.
2840 // Operand created by UseRegister is guaranteed to be live until the end of
2841 // instruction. This means that register allocator will not reuse it's
2842 // register for any other operand inside instruction.
2843 // Operand created by UseRegisterAtStart is guaranteed to be live only at
2844 // instruction start. Register allocator is free to assign the same register
2845 // to some other operand used inside instruction (i.e. temporary or
2847 MUST_USE_RESULT LOperand* UseRegister(HValue* value);
2848 MUST_USE_RESULT LOperand* UseRegisterAtStart(HValue* value);
2850 // An input operand in a register that may be trashed.
2851 MUST_USE_RESULT LOperand* UseTempRegister(HValue* value);
2853 // An input operand in a register or stack slot.
2854 MUST_USE_RESULT LOperand* Use(HValue* value);
2855 MUST_USE_RESULT LOperand* UseAtStart(HValue* value);
2857 // An input operand in a register, stack slot or a constant operand.
2858 MUST_USE_RESULT LOperand* UseOrConstant(HValue* value);
2859 MUST_USE_RESULT LOperand* UseOrConstantAtStart(HValue* value);
2861 // An input operand in a fixed register or a constant operand.
2862 MUST_USE_RESULT LOperand* UseFixedOrConstant(HValue* value,
2863 Register fixed_register);
2865 // An input operand in a register or a constant operand.
2866 MUST_USE_RESULT LOperand* UseRegisterOrConstant(HValue* value);
2867 MUST_USE_RESULT LOperand* UseRegisterOrConstantAtStart(HValue* value);
2869 // An input operand in a constant operand.
2870 MUST_USE_RESULT LOperand* UseConstant(HValue* value);
2872 // An input operand in register, stack slot or a constant operand.
2873 // Will not be moved to a register even if one is freely available.
2874 MUST_USE_RESULT LOperand* UseAny(HValue* value) override;
2876 // Temporary operand that must be in a register.
2877 MUST_USE_RESULT LUnallocated* TempRegister();
2878 MUST_USE_RESULT LOperand* FixedTemp(Register reg);
2880 // Methods for setting up define-use relationships.
2881 // Return the same instruction that they are passed.
2882 LInstruction* Define(LTemplateResultInstruction<1>* instr,
2883 LUnallocated* result);
2884 LInstruction* DefineAsRegister(LTemplateResultInstruction<1>* instr);
2885 LInstruction* DefineAsSpilled(LTemplateResultInstruction<1>* instr,
2887 LInstruction* DefineSameAsFirst(LTemplateResultInstruction<1>* instr);
2888 LInstruction* DefineFixed(LTemplateResultInstruction<1>* instr,
2890 LInstruction* DefineFixed(LTemplateResultInstruction<1>* instr,
2892 LInstruction* DefineX87TOS(LTemplateResultInstruction<1>* instr);
2893 // Assigns an environment to an instruction. An instruction which can
2894 // deoptimize must have an environment.
2895 LInstruction* AssignEnvironment(LInstruction* instr);
2896 // Assigns a pointer map to an instruction. An instruction which can
2897 // trigger a GC or a lazy deoptimization must have a pointer map.
2898 LInstruction* AssignPointerMap(LInstruction* instr);
2900 enum CanDeoptimize { CAN_DEOPTIMIZE_EAGERLY, CANNOT_DEOPTIMIZE_EAGERLY };
2902 LOperand* GetSeqStringSetCharOperand(HSeqStringSetChar* instr);
2904 // Marks a call for the register allocator. Assigns a pointer map to
2905 // support GC and lazy deoptimization. Assigns an environment to support
2906 // eager deoptimization if CAN_DEOPTIMIZE_EAGERLY.
2907 LInstruction* MarkAsCall(
2908 LInstruction* instr,
2909 HInstruction* hinstr,
2910 CanDeoptimize can_deoptimize = CANNOT_DEOPTIMIZE_EAGERLY);
2912 void VisitInstruction(HInstruction* current);
2913 void AddInstruction(LInstruction* instr, HInstruction* current);
2915 void DoBasicBlock(HBasicBlock* block, HBasicBlock* next_block);
2916 LInstruction* DoShift(Token::Value op, HBitwiseBinaryOperation* instr);
2917 LInstruction* DoArithmeticD(Token::Value op,
2918 HArithmeticBinaryOperation* instr);
2919 LInstruction* DoArithmeticT(Token::Value op,
2920 HBinaryOperation* instr);
2922 LOperand* GetStoreKeyedValueOperand(HStoreKeyed* instr);
2924 HInstruction* current_instruction_;
2925 HBasicBlock* current_block_;
2926 HBasicBlock* next_block_;
2927 LAllocator* allocator_;
2929 DISALLOW_COPY_AND_ASSIGN(LChunkBuilder);
2932 #undef DECLARE_HYDROGEN_ACCESSOR
2933 #undef DECLARE_CONCRETE_INSTRUCTION
2935 } } // namespace v8::internal
2937 #endif // V8_X87_LITHIUM_X87_H_