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_IA32_LITHIUM_IA32_H_
6 #define V8_IA32_LITHIUM_IA32_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) \
54 V(ClassOfTestAndBranch) \
55 V(CompareMinusZeroAndBranch) \
56 V(CompareNumericAndBranch) \
57 V(CmpObjectEqAndBranch) \
81 V(FlooringDivByConstI) \
82 V(FlooringDivByPowerOf2I) \
87 V(GetCachedArrayIndex) \
89 V(HasCachedArrayIndexAndBranch) \
90 V(HasInstanceTypeAndBranch) \
91 V(InnerAllocatedObject) \
93 V(InstanceOfKnownGlobal) \
95 V(Integer32ToDouble) \
97 V(IsConstructCallAndBranch) \
98 V(IsObjectAndBranch) \
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 virtual void SetDeferredLazyDeoptimizationEnvironment(LEnvironment* env) { }
241 void MarkAsCall() { bit_field_ = IsCallBits::update(bit_field_, true); }
242 bool IsCall() const { return IsCallBits::decode(bit_field_); }
244 // Interface to the register allocator and iterators.
245 bool ClobbersTemps() const { return IsCall(); }
246 bool ClobbersRegisters() const { return IsCall(); }
247 virtual bool ClobbersDoubleRegisters(Isolate* isolate) const {
251 virtual bool HasResult() const = 0;
252 virtual LOperand* result() const = 0;
254 bool HasDoubleRegisterResult();
255 bool HasDoubleRegisterInput();
257 LOperand* FirstInput() { return InputAt(0); }
258 LOperand* Output() { return HasResult() ? result() : NULL; }
260 virtual bool HasInterestingComment(LCodeGen* gen) const { return true; }
266 virtual int InputCount() = 0;
267 virtual LOperand* InputAt(int i) = 0;
271 friend class InputIterator;
273 friend class TempIterator;
274 virtual int TempCount() = 0;
275 virtual LOperand* TempAt(int i) = 0;
277 class IsCallBits: public BitField<bool, 0, 1> {};
279 LEnvironment* environment_;
280 SetOncePointer<LPointerMap> pointer_map_;
281 HValue* hydrogen_value_;
286 // R = number of result operands (0 or 1).
288 class LTemplateResultInstruction : public LInstruction {
290 // Allow 0 or 1 output operands.
291 STATIC_ASSERT(R == 0 || R == 1);
292 bool HasResult() const final { return R != 0 && result() != NULL; }
293 void set_result(LOperand* operand) { results_[0] = operand; }
294 LOperand* result() const override { return results_[0]; }
297 EmbeddedContainer<LOperand*, R> results_;
301 // R = number of result operands (0 or 1).
302 // I = number of input operands.
303 // T = number of temporary operands.
304 template<int R, int I, int T>
305 class LTemplateInstruction : public LTemplateResultInstruction<R> {
307 EmbeddedContainer<LOperand*, I> inputs_;
308 EmbeddedContainer<LOperand*, T> temps_;
312 int InputCount() final { return I; }
313 LOperand* InputAt(int i) final { return inputs_[i]; }
315 int TempCount() final { return T; }
316 LOperand* TempAt(int i) final { return temps_[i]; }
320 class LGap : public LTemplateInstruction<0, 0, 0> {
322 explicit LGap(HBasicBlock* block) : block_(block) {
323 parallel_moves_[BEFORE] = NULL;
324 parallel_moves_[START] = NULL;
325 parallel_moves_[END] = NULL;
326 parallel_moves_[AFTER] = NULL;
329 // Can't use the DECLARE-macro here because of sub-classes.
330 bool IsGap() const final { return true; }
331 void PrintDataTo(StringStream* stream) override;
332 static LGap* cast(LInstruction* instr) {
333 DCHECK(instr->IsGap());
334 return reinterpret_cast<LGap*>(instr);
337 bool IsRedundant() const;
339 HBasicBlock* block() const { return block_; }
346 FIRST_INNER_POSITION = BEFORE,
347 LAST_INNER_POSITION = AFTER
350 LParallelMove* GetOrCreateParallelMove(InnerPosition pos, Zone* zone) {
351 if (parallel_moves_[pos] == NULL) {
352 parallel_moves_[pos] = new(zone) LParallelMove(zone);
354 return parallel_moves_[pos];
357 LParallelMove* GetParallelMove(InnerPosition pos) {
358 return parallel_moves_[pos];
362 LParallelMove* parallel_moves_[LAST_INNER_POSITION + 1];
367 class LInstructionGap final : public LGap {
369 explicit LInstructionGap(HBasicBlock* block) : LGap(block) { }
371 bool HasInterestingComment(LCodeGen* gen) const override {
372 return !IsRedundant();
375 DECLARE_CONCRETE_INSTRUCTION(InstructionGap, "gap")
379 class LGoto final : public LTemplateInstruction<0, 0, 0> {
381 explicit LGoto(HBasicBlock* block) : block_(block) { }
383 bool HasInterestingComment(LCodeGen* gen) const override;
384 DECLARE_CONCRETE_INSTRUCTION(Goto, "goto")
385 void PrintDataTo(StringStream* stream) override;
386 bool IsControl() const override { return true; }
388 int block_id() const { return block_->block_id(); }
389 bool ClobbersDoubleRegisters(Isolate* isolate) const override {
393 bool jumps_to_join() const { return block_->predecessors()->length() > 1; }
400 class LLazyBailout final : public LTemplateInstruction<0, 0, 0> {
402 DECLARE_CONCRETE_INSTRUCTION(LazyBailout, "lazy-bailout")
406 class LDummy final : public LTemplateInstruction<1, 0, 0> {
409 DECLARE_CONCRETE_INSTRUCTION(Dummy, "dummy")
413 class LDummyUse final : public LTemplateInstruction<1, 1, 0> {
415 explicit LDummyUse(LOperand* value) {
418 DECLARE_CONCRETE_INSTRUCTION(DummyUse, "dummy-use")
422 class LDeoptimize final : public LTemplateInstruction<0, 0, 0> {
424 bool IsControl() const override { return true; }
425 DECLARE_CONCRETE_INSTRUCTION(Deoptimize, "deoptimize")
426 DECLARE_HYDROGEN_ACCESSOR(Deoptimize)
430 class LLabel final : public LGap {
432 explicit LLabel(HBasicBlock* block)
433 : LGap(block), replacement_(NULL) { }
435 bool HasInterestingComment(LCodeGen* gen) const override { return false; }
436 DECLARE_CONCRETE_INSTRUCTION(Label, "label")
438 void PrintDataTo(StringStream* stream) override;
440 int block_id() const { return block()->block_id(); }
441 bool is_loop_header() const { return block()->IsLoopHeader(); }
442 bool is_osr_entry() const { return block()->is_osr_entry(); }
443 Label* label() { return &label_; }
444 LLabel* replacement() const { return replacement_; }
445 void set_replacement(LLabel* label) { replacement_ = label; }
446 bool HasReplacement() const { return replacement_ != NULL; }
450 LLabel* replacement_;
454 class LParameter final : public LTemplateInstruction<1, 0, 0> {
456 bool HasInterestingComment(LCodeGen* gen) const override { return false; }
457 DECLARE_CONCRETE_INSTRUCTION(Parameter, "parameter")
461 class LCallStub final : public LTemplateInstruction<1, 1, 0> {
463 explicit LCallStub(LOperand* context) {
464 inputs_[0] = context;
467 LOperand* context() { return inputs_[0]; }
469 DECLARE_CONCRETE_INSTRUCTION(CallStub, "call-stub")
470 DECLARE_HYDROGEN_ACCESSOR(CallStub)
474 class LUnknownOSRValue final : public LTemplateInstruction<1, 0, 0> {
476 bool HasInterestingComment(LCodeGen* gen) const override { return false; }
477 DECLARE_CONCRETE_INSTRUCTION(UnknownOSRValue, "unknown-osr-value")
481 template<int I, int T>
482 class LControlInstruction: public LTemplateInstruction<0, I, T> {
484 LControlInstruction() : false_label_(NULL), true_label_(NULL) { }
486 bool IsControl() const final { return true; }
488 int SuccessorCount() { return hydrogen()->SuccessorCount(); }
489 HBasicBlock* SuccessorAt(int i) { return hydrogen()->SuccessorAt(i); }
491 int TrueDestination(LChunk* chunk) {
492 return chunk->LookupDestination(true_block_id());
494 int FalseDestination(LChunk* chunk) {
495 return chunk->LookupDestination(false_block_id());
498 Label* TrueLabel(LChunk* chunk) {
499 if (true_label_ == NULL) {
500 true_label_ = chunk->GetAssemblyLabel(TrueDestination(chunk));
504 Label* FalseLabel(LChunk* chunk) {
505 if (false_label_ == NULL) {
506 false_label_ = chunk->GetAssemblyLabel(FalseDestination(chunk));
512 int true_block_id() { return SuccessorAt(0)->block_id(); }
513 int false_block_id() { return SuccessorAt(1)->block_id(); }
516 HControlInstruction* hydrogen() {
517 return HControlInstruction::cast(this->hydrogen_value());
525 class LWrapReceiver final : public LTemplateInstruction<1, 2, 1> {
527 LWrapReceiver(LOperand* receiver,
530 inputs_[0] = receiver;
531 inputs_[1] = function;
535 LOperand* receiver() { return inputs_[0]; }
536 LOperand* function() { return inputs_[1]; }
537 LOperand* temp() { return temps_[0]; }
539 DECLARE_CONCRETE_INSTRUCTION(WrapReceiver, "wrap-receiver")
540 DECLARE_HYDROGEN_ACCESSOR(WrapReceiver)
544 class LApplyArguments final : public LTemplateInstruction<1, 4, 0> {
546 LApplyArguments(LOperand* function,
549 LOperand* elements) {
550 inputs_[0] = function;
551 inputs_[1] = receiver;
553 inputs_[3] = elements;
556 LOperand* function() { return inputs_[0]; }
557 LOperand* receiver() { return inputs_[1]; }
558 LOperand* length() { return inputs_[2]; }
559 LOperand* elements() { return inputs_[3]; }
561 DECLARE_CONCRETE_INSTRUCTION(ApplyArguments, "apply-arguments")
565 class LAccessArgumentsAt final : public LTemplateInstruction<1, 3, 0> {
567 LAccessArgumentsAt(LOperand* arguments, LOperand* length, LOperand* index) {
568 inputs_[0] = arguments;
573 LOperand* arguments() { return inputs_[0]; }
574 LOperand* length() { return inputs_[1]; }
575 LOperand* index() { return inputs_[2]; }
577 DECLARE_CONCRETE_INSTRUCTION(AccessArgumentsAt, "access-arguments-at")
579 void PrintDataTo(StringStream* stream) override;
583 class LArgumentsLength final : public LTemplateInstruction<1, 1, 0> {
585 explicit LArgumentsLength(LOperand* elements) {
586 inputs_[0] = elements;
589 LOperand* elements() { return inputs_[0]; }
591 DECLARE_CONCRETE_INSTRUCTION(ArgumentsLength, "arguments-length")
595 class LArgumentsElements final : public LTemplateInstruction<1, 0, 0> {
597 DECLARE_CONCRETE_INSTRUCTION(ArgumentsElements, "arguments-elements")
598 DECLARE_HYDROGEN_ACCESSOR(ArgumentsElements)
602 class LDebugBreak final : public LTemplateInstruction<0, 0, 0> {
604 DECLARE_CONCRETE_INSTRUCTION(DebugBreak, "break")
608 class LModByPowerOf2I final : public LTemplateInstruction<1, 1, 0> {
610 LModByPowerOf2I(LOperand* dividend, int32_t divisor) {
611 inputs_[0] = dividend;
615 LOperand* dividend() { return inputs_[0]; }
616 int32_t divisor() const { return divisor_; }
618 DECLARE_CONCRETE_INSTRUCTION(ModByPowerOf2I, "mod-by-power-of-2-i")
619 DECLARE_HYDROGEN_ACCESSOR(Mod)
626 class LModByConstI final : public LTemplateInstruction<1, 1, 2> {
628 LModByConstI(LOperand* dividend,
632 inputs_[0] = dividend;
638 LOperand* dividend() { return inputs_[0]; }
639 int32_t divisor() const { return divisor_; }
640 LOperand* temp1() { return temps_[0]; }
641 LOperand* temp2() { return temps_[1]; }
643 DECLARE_CONCRETE_INSTRUCTION(ModByConstI, "mod-by-const-i")
644 DECLARE_HYDROGEN_ACCESSOR(Mod)
651 class LModI final : public LTemplateInstruction<1, 2, 1> {
653 LModI(LOperand* left, LOperand* right, LOperand* temp) {
659 LOperand* left() { return inputs_[0]; }
660 LOperand* right() { return inputs_[1]; }
661 LOperand* temp() { return temps_[0]; }
663 DECLARE_CONCRETE_INSTRUCTION(ModI, "mod-i")
664 DECLARE_HYDROGEN_ACCESSOR(Mod)
668 class LDivByPowerOf2I final : public LTemplateInstruction<1, 1, 0> {
670 LDivByPowerOf2I(LOperand* dividend, int32_t divisor) {
671 inputs_[0] = dividend;
675 LOperand* dividend() { return inputs_[0]; }
676 int32_t divisor() const { return divisor_; }
678 DECLARE_CONCRETE_INSTRUCTION(DivByPowerOf2I, "div-by-power-of-2-i")
679 DECLARE_HYDROGEN_ACCESSOR(Div)
686 class LDivByConstI final : public LTemplateInstruction<1, 1, 2> {
688 LDivByConstI(LOperand* dividend,
692 inputs_[0] = dividend;
698 LOperand* dividend() { return inputs_[0]; }
699 int32_t divisor() const { return divisor_; }
700 LOperand* temp1() { return temps_[0]; }
701 LOperand* temp2() { return temps_[1]; }
703 DECLARE_CONCRETE_INSTRUCTION(DivByConstI, "div-by-const-i")
704 DECLARE_HYDROGEN_ACCESSOR(Div)
711 class LDivI final : public LTemplateInstruction<1, 2, 1> {
713 LDivI(LOperand* dividend, LOperand* divisor, LOperand* temp) {
714 inputs_[0] = dividend;
715 inputs_[1] = divisor;
719 LOperand* dividend() { return inputs_[0]; }
720 LOperand* divisor() { return inputs_[1]; }
721 LOperand* temp() { return temps_[0]; }
723 DECLARE_CONCRETE_INSTRUCTION(DivI, "div-i")
724 DECLARE_HYDROGEN_ACCESSOR(BinaryOperation)
728 class LFlooringDivByPowerOf2I final : public LTemplateInstruction<1, 1, 0> {
730 LFlooringDivByPowerOf2I(LOperand* dividend, int32_t divisor) {
731 inputs_[0] = dividend;
735 LOperand* dividend() { return inputs_[0]; }
736 int32_t divisor() const { return divisor_; }
738 DECLARE_CONCRETE_INSTRUCTION(FlooringDivByPowerOf2I,
739 "flooring-div-by-power-of-2-i")
740 DECLARE_HYDROGEN_ACCESSOR(MathFloorOfDiv)
747 class LFlooringDivByConstI final : public LTemplateInstruction<1, 1, 3> {
749 LFlooringDivByConstI(LOperand* dividend,
754 inputs_[0] = dividend;
761 LOperand* dividend() { return inputs_[0]; }
762 int32_t divisor() const { return divisor_; }
763 LOperand* temp1() { return temps_[0]; }
764 LOperand* temp2() { return temps_[1]; }
765 LOperand* temp3() { return temps_[2]; }
767 DECLARE_CONCRETE_INSTRUCTION(FlooringDivByConstI, "flooring-div-by-const-i")
768 DECLARE_HYDROGEN_ACCESSOR(MathFloorOfDiv)
775 class LFlooringDivI final : public LTemplateInstruction<1, 2, 1> {
777 LFlooringDivI(LOperand* dividend, LOperand* divisor, LOperand* temp) {
778 inputs_[0] = dividend;
779 inputs_[1] = divisor;
783 LOperand* dividend() { return inputs_[0]; }
784 LOperand* divisor() { return inputs_[1]; }
785 LOperand* temp() { return temps_[0]; }
787 DECLARE_CONCRETE_INSTRUCTION(FlooringDivI, "flooring-div-i")
788 DECLARE_HYDROGEN_ACCESSOR(MathFloorOfDiv)
792 class LMulI final : public LTemplateInstruction<1, 2, 1> {
794 LMulI(LOperand* left, LOperand* right, LOperand* temp) {
800 LOperand* left() { return inputs_[0]; }
801 LOperand* right() { return inputs_[1]; }
802 LOperand* temp() { return temps_[0]; }
804 DECLARE_CONCRETE_INSTRUCTION(MulI, "mul-i")
805 DECLARE_HYDROGEN_ACCESSOR(Mul)
809 class LCompareNumericAndBranch final : public LControlInstruction<2, 0> {
811 LCompareNumericAndBranch(LOperand* left, LOperand* right) {
816 LOperand* left() { return inputs_[0]; }
817 LOperand* right() { return inputs_[1]; }
819 DECLARE_CONCRETE_INSTRUCTION(CompareNumericAndBranch,
820 "compare-numeric-and-branch")
821 DECLARE_HYDROGEN_ACCESSOR(CompareNumericAndBranch)
823 Token::Value op() const { return hydrogen()->token(); }
824 bool is_double() const {
825 return hydrogen()->representation().IsDouble();
828 void PrintDataTo(StringStream* stream) override;
832 class LMathFloor final : public LTemplateInstruction<1, 1, 0> {
834 explicit LMathFloor(LOperand* value) {
838 LOperand* value() { return inputs_[0]; }
840 DECLARE_CONCRETE_INSTRUCTION(MathFloor, "math-floor")
841 DECLARE_HYDROGEN_ACCESSOR(UnaryMathOperation)
845 class LMathRound final : public LTemplateInstruction<1, 1, 1> {
847 LMathRound(LOperand* value, LOperand* temp) {
852 LOperand* temp() { return temps_[0]; }
853 LOperand* value() { return inputs_[0]; }
855 DECLARE_CONCRETE_INSTRUCTION(MathRound, "math-round")
856 DECLARE_HYDROGEN_ACCESSOR(UnaryMathOperation)
860 class LMathFround final : public LTemplateInstruction<1, 1, 0> {
862 explicit LMathFround(LOperand* value) { inputs_[0] = value; }
864 LOperand* value() { return inputs_[0]; }
866 DECLARE_CONCRETE_INSTRUCTION(MathFround, "math-fround")
870 class LMathAbs final : public LTemplateInstruction<1, 2, 0> {
872 LMathAbs(LOperand* context, LOperand* value) {
873 inputs_[1] = context;
877 LOperand* context() { return inputs_[1]; }
878 LOperand* value() { return inputs_[0]; }
880 DECLARE_CONCRETE_INSTRUCTION(MathAbs, "math-abs")
881 DECLARE_HYDROGEN_ACCESSOR(UnaryMathOperation)
885 class LMathLog final : public LTemplateInstruction<1, 1, 0> {
887 explicit LMathLog(LOperand* value) {
891 LOperand* value() { return inputs_[0]; }
893 DECLARE_CONCRETE_INSTRUCTION(MathLog, "math-log")
897 class LMathClz32 final : public LTemplateInstruction<1, 1, 0> {
899 explicit LMathClz32(LOperand* value) {
903 LOperand* value() { return inputs_[0]; }
905 DECLARE_CONCRETE_INSTRUCTION(MathClz32, "math-clz32")
909 class LMathExp final : public LTemplateInstruction<1, 1, 2> {
911 LMathExp(LOperand* value,
917 ExternalReference::InitializeMathExpData();
920 LOperand* value() { return inputs_[0]; }
921 LOperand* temp1() { return temps_[0]; }
922 LOperand* temp2() { return temps_[1]; }
924 DECLARE_CONCRETE_INSTRUCTION(MathExp, "math-exp")
928 class LMathSqrt final : public LTemplateInstruction<1, 1, 0> {
930 explicit LMathSqrt(LOperand* value) {
934 LOperand* value() { return inputs_[0]; }
936 DECLARE_CONCRETE_INSTRUCTION(MathSqrt, "math-sqrt")
940 class LMathPowHalf final : public LTemplateInstruction<1, 1, 1> {
942 LMathPowHalf(LOperand* value, LOperand* temp) {
947 LOperand* value() { return inputs_[0]; }
948 LOperand* temp() { return temps_[0]; }
950 DECLARE_CONCRETE_INSTRUCTION(MathPowHalf, "math-pow-half")
954 class LCmpObjectEqAndBranch final : public LControlInstruction<2, 0> {
956 LCmpObjectEqAndBranch(LOperand* left, LOperand* right) {
961 LOperand* left() { return inputs_[0]; }
962 LOperand* right() { return inputs_[1]; }
964 DECLARE_CONCRETE_INSTRUCTION(CmpObjectEqAndBranch, "cmp-object-eq-and-branch")
968 class LCmpHoleAndBranch final : public LControlInstruction<1, 0> {
970 explicit LCmpHoleAndBranch(LOperand* object) {
974 LOperand* object() { return inputs_[0]; }
976 DECLARE_CONCRETE_INSTRUCTION(CmpHoleAndBranch, "cmp-hole-and-branch")
977 DECLARE_HYDROGEN_ACCESSOR(CompareHoleAndBranch)
981 class LCompareMinusZeroAndBranch final : public LControlInstruction<1, 1> {
983 LCompareMinusZeroAndBranch(LOperand* value, LOperand* temp) {
988 LOperand* value() { return inputs_[0]; }
989 LOperand* temp() { return temps_[0]; }
991 DECLARE_CONCRETE_INSTRUCTION(CompareMinusZeroAndBranch,
992 "cmp-minus-zero-and-branch")
993 DECLARE_HYDROGEN_ACCESSOR(CompareMinusZeroAndBranch)
997 class LIsObjectAndBranch final : public LControlInstruction<1, 1> {
999 LIsObjectAndBranch(LOperand* value, LOperand* temp) {
1004 LOperand* value() { return inputs_[0]; }
1005 LOperand* temp() { return temps_[0]; }
1007 DECLARE_CONCRETE_INSTRUCTION(IsObjectAndBranch, "is-object-and-branch")
1009 void PrintDataTo(StringStream* stream) override;
1013 class LIsStringAndBranch final : public LControlInstruction<1, 1> {
1015 LIsStringAndBranch(LOperand* value, LOperand* temp) {
1020 LOperand* value() { return inputs_[0]; }
1021 LOperand* temp() { return temps_[0]; }
1023 DECLARE_CONCRETE_INSTRUCTION(IsStringAndBranch, "is-string-and-branch")
1024 DECLARE_HYDROGEN_ACCESSOR(IsStringAndBranch)
1026 void PrintDataTo(StringStream* stream) override;
1030 class LIsSmiAndBranch final : public LControlInstruction<1, 0> {
1032 explicit LIsSmiAndBranch(LOperand* value) {
1036 LOperand* value() { return inputs_[0]; }
1038 DECLARE_CONCRETE_INSTRUCTION(IsSmiAndBranch, "is-smi-and-branch")
1039 DECLARE_HYDROGEN_ACCESSOR(IsSmiAndBranch)
1041 void PrintDataTo(StringStream* stream) override;
1045 class LIsUndetectableAndBranch final : public LControlInstruction<1, 1> {
1047 LIsUndetectableAndBranch(LOperand* value, LOperand* temp) {
1052 LOperand* value() { return inputs_[0]; }
1053 LOperand* temp() { return temps_[0]; }
1055 DECLARE_CONCRETE_INSTRUCTION(IsUndetectableAndBranch,
1056 "is-undetectable-and-branch")
1057 DECLARE_HYDROGEN_ACCESSOR(IsUndetectableAndBranch)
1059 void PrintDataTo(StringStream* stream) override;
1063 class LStringCompareAndBranch final : public LControlInstruction<3, 0> {
1065 LStringCompareAndBranch(LOperand* context, LOperand* left, LOperand* right) {
1066 inputs_[0] = context;
1071 LOperand* context() { return inputs_[1]; }
1072 LOperand* left() { return inputs_[1]; }
1073 LOperand* right() { return inputs_[2]; }
1075 DECLARE_CONCRETE_INSTRUCTION(StringCompareAndBranch,
1076 "string-compare-and-branch")
1077 DECLARE_HYDROGEN_ACCESSOR(StringCompareAndBranch)
1079 void PrintDataTo(StringStream* stream) override;
1081 Token::Value op() const { return hydrogen()->token(); }
1085 class LHasInstanceTypeAndBranch final : public LControlInstruction<1, 1> {
1087 LHasInstanceTypeAndBranch(LOperand* value, LOperand* temp) {
1092 LOperand* value() { return inputs_[0]; }
1093 LOperand* temp() { return temps_[0]; }
1095 DECLARE_CONCRETE_INSTRUCTION(HasInstanceTypeAndBranch,
1096 "has-instance-type-and-branch")
1097 DECLARE_HYDROGEN_ACCESSOR(HasInstanceTypeAndBranch)
1099 void PrintDataTo(StringStream* stream) override;
1103 class LGetCachedArrayIndex final : public LTemplateInstruction<1, 1, 0> {
1105 explicit LGetCachedArrayIndex(LOperand* value) {
1109 LOperand* value() { return inputs_[0]; }
1111 DECLARE_CONCRETE_INSTRUCTION(GetCachedArrayIndex, "get-cached-array-index")
1112 DECLARE_HYDROGEN_ACCESSOR(GetCachedArrayIndex)
1116 class LHasCachedArrayIndexAndBranch final : public LControlInstruction<1, 0> {
1118 explicit LHasCachedArrayIndexAndBranch(LOperand* value) {
1122 LOperand* value() { return inputs_[0]; }
1124 DECLARE_CONCRETE_INSTRUCTION(HasCachedArrayIndexAndBranch,
1125 "has-cached-array-index-and-branch")
1127 void PrintDataTo(StringStream* stream) override;
1131 class LIsConstructCallAndBranch final : public LControlInstruction<0, 1> {
1133 explicit LIsConstructCallAndBranch(LOperand* temp) {
1137 LOperand* temp() { return temps_[0]; }
1139 DECLARE_CONCRETE_INSTRUCTION(IsConstructCallAndBranch,
1140 "is-construct-call-and-branch")
1144 class LClassOfTestAndBranch final : public LControlInstruction<1, 2> {
1146 LClassOfTestAndBranch(LOperand* value, LOperand* temp, LOperand* temp2) {
1152 LOperand* value() { return inputs_[0]; }
1153 LOperand* temp() { return temps_[0]; }
1154 LOperand* temp2() { return temps_[1]; }
1156 DECLARE_CONCRETE_INSTRUCTION(ClassOfTestAndBranch,
1157 "class-of-test-and-branch")
1158 DECLARE_HYDROGEN_ACCESSOR(ClassOfTestAndBranch)
1160 void PrintDataTo(StringStream* stream) override;
1164 class LCmpT final : public LTemplateInstruction<1, 3, 0> {
1166 LCmpT(LOperand* context, LOperand* left, LOperand* right) {
1167 inputs_[0] = context;
1172 DECLARE_CONCRETE_INSTRUCTION(CmpT, "cmp-t")
1173 DECLARE_HYDROGEN_ACCESSOR(CompareGeneric)
1175 Strength strength() { return hydrogen()->strength(); }
1177 LOperand* context() { return inputs_[0]; }
1178 Token::Value op() const { return hydrogen()->token(); }
1182 class LInstanceOf final : public LTemplateInstruction<1, 3, 0> {
1184 LInstanceOf(LOperand* context, LOperand* left, LOperand* right) {
1185 inputs_[0] = context;
1190 LOperand* context() { return inputs_[0]; }
1192 DECLARE_CONCRETE_INSTRUCTION(InstanceOf, "instance-of")
1196 class LInstanceOfKnownGlobal final : public LTemplateInstruction<1, 2, 1> {
1198 LInstanceOfKnownGlobal(LOperand* context, LOperand* value, LOperand* temp) {
1199 inputs_[0] = context;
1204 LOperand* context() { return inputs_[0]; }
1205 LOperand* value() { return inputs_[1]; }
1206 LOperand* temp() { return temps_[0]; }
1208 DECLARE_CONCRETE_INSTRUCTION(InstanceOfKnownGlobal,
1209 "instance-of-known-global")
1210 DECLARE_HYDROGEN_ACCESSOR(InstanceOfKnownGlobal)
1212 Handle<JSFunction> function() const { return hydrogen()->function(); }
1213 LEnvironment* GetDeferredLazyDeoptimizationEnvironment() {
1214 return lazy_deopt_env_;
1216 virtual void SetDeferredLazyDeoptimizationEnvironment(
1217 LEnvironment* env) override {
1218 lazy_deopt_env_ = env;
1222 LEnvironment* lazy_deopt_env_;
1226 class LBoundsCheck final : public LTemplateInstruction<0, 2, 0> {
1228 LBoundsCheck(LOperand* index, LOperand* length) {
1230 inputs_[1] = length;
1233 LOperand* index() { return inputs_[0]; }
1234 LOperand* length() { return inputs_[1]; }
1236 DECLARE_CONCRETE_INSTRUCTION(BoundsCheck, "bounds-check")
1237 DECLARE_HYDROGEN_ACCESSOR(BoundsCheck)
1241 class LBitI final : public LTemplateInstruction<1, 2, 0> {
1243 LBitI(LOperand* left, LOperand* right) {
1248 LOperand* left() { return inputs_[0]; }
1249 LOperand* right() { return inputs_[1]; }
1251 DECLARE_CONCRETE_INSTRUCTION(BitI, "bit-i")
1252 DECLARE_HYDROGEN_ACCESSOR(Bitwise)
1254 Token::Value op() const { return hydrogen()->op(); }
1258 class LShiftI final : public LTemplateInstruction<1, 2, 0> {
1260 LShiftI(Token::Value op, LOperand* left, LOperand* right, bool can_deopt)
1261 : op_(op), can_deopt_(can_deopt) {
1266 LOperand* left() { return inputs_[0]; }
1267 LOperand* right() { return inputs_[1]; }
1269 DECLARE_CONCRETE_INSTRUCTION(ShiftI, "shift-i")
1271 Token::Value op() const { return op_; }
1272 bool can_deopt() const { return can_deopt_; }
1280 class LSubI final : public LTemplateInstruction<1, 2, 0> {
1282 LSubI(LOperand* left, LOperand* right) {
1287 LOperand* left() { return inputs_[0]; }
1288 LOperand* right() { return inputs_[1]; }
1290 DECLARE_CONCRETE_INSTRUCTION(SubI, "sub-i")
1291 DECLARE_HYDROGEN_ACCESSOR(Sub)
1295 class LConstantI final : public LTemplateInstruction<1, 0, 0> {
1297 DECLARE_CONCRETE_INSTRUCTION(ConstantI, "constant-i")
1298 DECLARE_HYDROGEN_ACCESSOR(Constant)
1300 int32_t value() const { return hydrogen()->Integer32Value(); }
1304 class LConstantS final : public LTemplateInstruction<1, 0, 0> {
1306 DECLARE_CONCRETE_INSTRUCTION(ConstantS, "constant-s")
1307 DECLARE_HYDROGEN_ACCESSOR(Constant)
1309 Smi* value() const { return Smi::FromInt(hydrogen()->Integer32Value()); }
1313 class LConstantD final : public LTemplateInstruction<1, 0, 1> {
1315 explicit LConstantD(LOperand* temp) {
1319 LOperand* temp() { return temps_[0]; }
1321 DECLARE_CONCRETE_INSTRUCTION(ConstantD, "constant-d")
1322 DECLARE_HYDROGEN_ACCESSOR(Constant)
1324 uint64_t bits() const { return hydrogen()->DoubleValueAsBits(); }
1328 class LConstantE final : public LTemplateInstruction<1, 0, 0> {
1330 DECLARE_CONCRETE_INSTRUCTION(ConstantE, "constant-e")
1331 DECLARE_HYDROGEN_ACCESSOR(Constant)
1333 ExternalReference value() const {
1334 return hydrogen()->ExternalReferenceValue();
1339 class LConstantT final : public LTemplateInstruction<1, 0, 0> {
1341 DECLARE_CONCRETE_INSTRUCTION(ConstantT, "constant-t")
1342 DECLARE_HYDROGEN_ACCESSOR(Constant)
1344 Handle<Object> value(Isolate* isolate) const {
1345 return hydrogen()->handle(isolate);
1350 class LBranch final : public LControlInstruction<1, 1> {
1352 LBranch(LOperand* value, LOperand* temp) {
1357 LOperand* value() { return inputs_[0]; }
1358 LOperand* temp() { return temps_[0]; }
1360 DECLARE_CONCRETE_INSTRUCTION(Branch, "branch")
1361 DECLARE_HYDROGEN_ACCESSOR(Branch)
1363 void PrintDataTo(StringStream* stream) override;
1367 class LCmpMapAndBranch final : public LControlInstruction<1, 0> {
1369 explicit LCmpMapAndBranch(LOperand* value) {
1373 LOperand* value() { return inputs_[0]; }
1375 DECLARE_CONCRETE_INSTRUCTION(CmpMapAndBranch, "cmp-map-and-branch")
1376 DECLARE_HYDROGEN_ACCESSOR(CompareMap)
1378 Handle<Map> map() const { return hydrogen()->map().handle(); }
1382 class LMapEnumLength final : public LTemplateInstruction<1, 1, 0> {
1384 explicit LMapEnumLength(LOperand* value) {
1388 LOperand* value() { return inputs_[0]; }
1390 DECLARE_CONCRETE_INSTRUCTION(MapEnumLength, "map-enum-length")
1394 class LDateField final : public LTemplateInstruction<1, 1, 1> {
1396 LDateField(LOperand* date, LOperand* temp, Smi* index)
1402 LOperand* date() { return inputs_[0]; }
1403 LOperand* temp() { return temps_[0]; }
1405 DECLARE_CONCRETE_INSTRUCTION(DateField, "date-field")
1406 DECLARE_HYDROGEN_ACCESSOR(DateField)
1408 Smi* index() const { return index_; }
1415 class LSeqStringGetChar final : public LTemplateInstruction<1, 2, 0> {
1417 LSeqStringGetChar(LOperand* string, LOperand* index) {
1418 inputs_[0] = string;
1422 LOperand* string() const { return inputs_[0]; }
1423 LOperand* index() const { return inputs_[1]; }
1425 DECLARE_CONCRETE_INSTRUCTION(SeqStringGetChar, "seq-string-get-char")
1426 DECLARE_HYDROGEN_ACCESSOR(SeqStringGetChar)
1430 class LSeqStringSetChar final : public LTemplateInstruction<1, 4, 0> {
1432 LSeqStringSetChar(LOperand* context,
1436 inputs_[0] = context;
1437 inputs_[1] = string;
1442 LOperand* string() { return inputs_[1]; }
1443 LOperand* index() { return inputs_[2]; }
1444 LOperand* value() { return inputs_[3]; }
1446 DECLARE_CONCRETE_INSTRUCTION(SeqStringSetChar, "seq-string-set-char")
1447 DECLARE_HYDROGEN_ACCESSOR(SeqStringSetChar)
1451 class LAddI final : public LTemplateInstruction<1, 2, 0> {
1453 LAddI(LOperand* left, LOperand* right) {
1458 LOperand* left() { return inputs_[0]; }
1459 LOperand* right() { return inputs_[1]; }
1461 static bool UseLea(HAdd* add) {
1462 return !add->CheckFlag(HValue::kCanOverflow) &&
1463 add->BetterLeftOperand()->UseCount() > 1;
1466 DECLARE_CONCRETE_INSTRUCTION(AddI, "add-i")
1467 DECLARE_HYDROGEN_ACCESSOR(Add)
1471 class LMathMinMax final : public LTemplateInstruction<1, 2, 0> {
1473 LMathMinMax(LOperand* left, LOperand* right) {
1478 LOperand* left() { return inputs_[0]; }
1479 LOperand* right() { return inputs_[1]; }
1481 DECLARE_CONCRETE_INSTRUCTION(MathMinMax, "math-min-max")
1482 DECLARE_HYDROGEN_ACCESSOR(MathMinMax)
1486 class LPower final : public LTemplateInstruction<1, 2, 0> {
1488 LPower(LOperand* left, LOperand* right) {
1493 LOperand* left() { return inputs_[0]; }
1494 LOperand* right() { return inputs_[1]; }
1496 DECLARE_CONCRETE_INSTRUCTION(Power, "power")
1497 DECLARE_HYDROGEN_ACCESSOR(Power)
1501 class LArithmeticD final : public LTemplateInstruction<1, 2, 0> {
1503 LArithmeticD(Token::Value op, LOperand* left, LOperand* right)
1509 LOperand* left() { return inputs_[0]; }
1510 LOperand* right() { return inputs_[1]; }
1512 Token::Value op() const { return op_; }
1514 Opcode opcode() const override { return LInstruction::kArithmeticD; }
1515 void CompileToNative(LCodeGen* generator) override;
1516 const char* Mnemonic() const override;
1523 class LArithmeticT final : public LTemplateInstruction<1, 3, 0> {
1525 LArithmeticT(Token::Value op,
1530 inputs_[0] = context;
1535 LOperand* context() { return inputs_[0]; }
1536 LOperand* left() { return inputs_[1]; }
1537 LOperand* right() { return inputs_[2]; }
1538 Token::Value op() const { return op_; }
1540 Opcode opcode() const override { return LInstruction::kArithmeticT; }
1541 void CompileToNative(LCodeGen* generator) override;
1542 const char* Mnemonic() const override;
1544 DECLARE_HYDROGEN_ACCESSOR(BinaryOperation)
1546 Strength strength() { return hydrogen()->strength(); }
1553 class LReturn final : public LTemplateInstruction<0, 3, 0> {
1555 explicit LReturn(LOperand* value,
1557 LOperand* parameter_count) {
1559 inputs_[1] = context;
1560 inputs_[2] = parameter_count;
1563 bool has_constant_parameter_count() {
1564 return parameter_count()->IsConstantOperand();
1566 LConstantOperand* constant_parameter_count() {
1567 DCHECK(has_constant_parameter_count());
1568 return LConstantOperand::cast(parameter_count());
1570 LOperand* parameter_count() { return inputs_[2]; }
1572 DECLARE_CONCRETE_INSTRUCTION(Return, "return")
1573 DECLARE_HYDROGEN_ACCESSOR(Return)
1577 class LLoadNamedField final : public LTemplateInstruction<1, 1, 0> {
1579 explicit LLoadNamedField(LOperand* object) {
1580 inputs_[0] = object;
1583 LOperand* object() { return inputs_[0]; }
1585 DECLARE_CONCRETE_INSTRUCTION(LoadNamedField, "load-named-field")
1586 DECLARE_HYDROGEN_ACCESSOR(LoadNamedField)
1590 class LLoadNamedGeneric final : public LTemplateInstruction<1, 2, 1> {
1592 LLoadNamedGeneric(LOperand* context, LOperand* object, LOperand* vector) {
1593 inputs_[0] = context;
1594 inputs_[1] = object;
1598 LOperand* context() { return inputs_[0]; }
1599 LOperand* object() { return inputs_[1]; }
1600 LOperand* temp_vector() { return temps_[0]; }
1602 DECLARE_CONCRETE_INSTRUCTION(LoadNamedGeneric, "load-named-generic")
1603 DECLARE_HYDROGEN_ACCESSOR(LoadNamedGeneric)
1605 Handle<Object> name() const { return hydrogen()->name(); }
1609 class LLoadFunctionPrototype final : public LTemplateInstruction<1, 1, 1> {
1611 LLoadFunctionPrototype(LOperand* function, LOperand* temp) {
1612 inputs_[0] = function;
1616 LOperand* function() { return inputs_[0]; }
1617 LOperand* temp() { return temps_[0]; }
1619 DECLARE_CONCRETE_INSTRUCTION(LoadFunctionPrototype, "load-function-prototype")
1620 DECLARE_HYDROGEN_ACCESSOR(LoadFunctionPrototype)
1624 class LLoadRoot final : public LTemplateInstruction<1, 0, 0> {
1626 DECLARE_CONCRETE_INSTRUCTION(LoadRoot, "load-root")
1627 DECLARE_HYDROGEN_ACCESSOR(LoadRoot)
1629 Heap::RootListIndex index() const { return hydrogen()->index(); }
1633 class LLoadKeyed final : public LTemplateInstruction<1, 2, 0> {
1635 LLoadKeyed(LOperand* elements, LOperand* key) {
1636 inputs_[0] = elements;
1639 LOperand* elements() { return inputs_[0]; }
1640 LOperand* key() { return inputs_[1]; }
1641 ElementsKind elements_kind() const {
1642 return hydrogen()->elements_kind();
1644 bool is_external() const {
1645 return hydrogen()->is_external();
1647 bool is_fixed_typed_array() const {
1648 return hydrogen()->is_fixed_typed_array();
1650 bool is_typed_elements() const {
1651 return is_external() || is_fixed_typed_array();
1654 DECLARE_CONCRETE_INSTRUCTION(LoadKeyed, "load-keyed")
1655 DECLARE_HYDROGEN_ACCESSOR(LoadKeyed)
1657 void PrintDataTo(StringStream* stream) override;
1658 uint32_t base_offset() const { return hydrogen()->base_offset(); }
1660 return hydrogen()->key()->representation().IsTagged();
1665 inline static bool ExternalArrayOpRequiresTemp(
1666 Representation key_representation,
1667 ElementsKind elements_kind) {
1668 // Operations that require the key to be divided by two to be converted into
1669 // an index cannot fold the scale operation into a load and need an extra
1670 // temp register to do the work.
1671 return key_representation.IsSmi() &&
1672 (elements_kind == EXTERNAL_INT8_ELEMENTS ||
1673 elements_kind == EXTERNAL_UINT8_ELEMENTS ||
1674 elements_kind == EXTERNAL_UINT8_CLAMPED_ELEMENTS ||
1675 elements_kind == UINT8_ELEMENTS ||
1676 elements_kind == INT8_ELEMENTS ||
1677 elements_kind == UINT8_CLAMPED_ELEMENTS);
1681 class LLoadKeyedGeneric final : public LTemplateInstruction<1, 3, 1> {
1683 LLoadKeyedGeneric(LOperand* context, LOperand* obj, LOperand* key,
1685 inputs_[0] = context;
1691 LOperand* context() { return inputs_[0]; }
1692 LOperand* object() { return inputs_[1]; }
1693 LOperand* key() { return inputs_[2]; }
1694 LOperand* temp_vector() { return temps_[0]; }
1696 DECLARE_CONCRETE_INSTRUCTION(LoadKeyedGeneric, "load-keyed-generic")
1697 DECLARE_HYDROGEN_ACCESSOR(LoadKeyedGeneric)
1701 class LLoadGlobalGeneric final : public LTemplateInstruction<1, 2, 1> {
1703 LLoadGlobalGeneric(LOperand* context, LOperand* global_object,
1705 inputs_[0] = context;
1706 inputs_[1] = global_object;
1710 LOperand* context() { return inputs_[0]; }
1711 LOperand* global_object() { return inputs_[1]; }
1712 LOperand* temp_vector() { return temps_[0]; }
1714 DECLARE_CONCRETE_INSTRUCTION(LoadGlobalGeneric, "load-global-generic")
1715 DECLARE_HYDROGEN_ACCESSOR(LoadGlobalGeneric)
1717 Handle<Object> name() const { return hydrogen()->name(); }
1718 TypeofMode typeof_mode() const { return hydrogen()->typeof_mode(); }
1722 class LLoadGlobalViaContext final : public LTemplateInstruction<1, 1, 1> {
1724 explicit LLoadGlobalViaContext(LOperand* context) { inputs_[0] = context; }
1726 DECLARE_CONCRETE_INSTRUCTION(LoadGlobalViaContext, "load-global-via-context")
1727 DECLARE_HYDROGEN_ACCESSOR(LoadGlobalViaContext)
1729 void PrintDataTo(StringStream* stream) override;
1731 LOperand* context() { return inputs_[0]; }
1733 int depth() const { return hydrogen()->depth(); }
1734 int slot_index() const { return hydrogen()->slot_index(); }
1738 class LLoadContextSlot final : public LTemplateInstruction<1, 1, 0> {
1740 explicit LLoadContextSlot(LOperand* context) {
1741 inputs_[0] = context;
1744 LOperand* context() { return inputs_[0]; }
1746 DECLARE_CONCRETE_INSTRUCTION(LoadContextSlot, "load-context-slot")
1747 DECLARE_HYDROGEN_ACCESSOR(LoadContextSlot)
1749 int slot_index() { return hydrogen()->slot_index(); }
1751 void PrintDataTo(StringStream* stream) override;
1755 class LStoreContextSlot final : public LTemplateInstruction<0, 2, 1> {
1757 LStoreContextSlot(LOperand* context, LOperand* value, LOperand* temp) {
1758 inputs_[0] = context;
1763 LOperand* context() { return inputs_[0]; }
1764 LOperand* value() { return inputs_[1]; }
1765 LOperand* temp() { return temps_[0]; }
1767 DECLARE_CONCRETE_INSTRUCTION(StoreContextSlot, "store-context-slot")
1768 DECLARE_HYDROGEN_ACCESSOR(StoreContextSlot)
1770 int slot_index() { return hydrogen()->slot_index(); }
1772 void PrintDataTo(StringStream* stream) override;
1776 class LPushArgument final : public LTemplateInstruction<0, 1, 0> {
1778 explicit LPushArgument(LOperand* value) {
1782 LOperand* value() { return inputs_[0]; }
1784 DECLARE_CONCRETE_INSTRUCTION(PushArgument, "push-argument")
1788 class LDrop final : public LTemplateInstruction<0, 0, 0> {
1790 explicit LDrop(int count) : count_(count) { }
1792 int count() const { return count_; }
1794 DECLARE_CONCRETE_INSTRUCTION(Drop, "drop")
1801 class LStoreCodeEntry final : public LTemplateInstruction<0, 2, 0> {
1803 LStoreCodeEntry(LOperand* function, LOperand* code_object) {
1804 inputs_[0] = function;
1805 inputs_[1] = code_object;
1808 LOperand* function() { return inputs_[0]; }
1809 LOperand* code_object() { return inputs_[1]; }
1811 void PrintDataTo(StringStream* stream) override;
1813 DECLARE_CONCRETE_INSTRUCTION(StoreCodeEntry, "store-code-entry")
1814 DECLARE_HYDROGEN_ACCESSOR(StoreCodeEntry)
1818 class LInnerAllocatedObject final : public LTemplateInstruction<1, 2, 0> {
1820 LInnerAllocatedObject(LOperand* base_object, LOperand* offset) {
1821 inputs_[0] = base_object;
1822 inputs_[1] = offset;
1825 LOperand* base_object() const { return inputs_[0]; }
1826 LOperand* offset() const { return inputs_[1]; }
1828 void PrintDataTo(StringStream* stream) override;
1830 DECLARE_CONCRETE_INSTRUCTION(InnerAllocatedObject, "inner-allocated-object")
1834 class LThisFunction final : public LTemplateInstruction<1, 0, 0> {
1836 DECLARE_CONCRETE_INSTRUCTION(ThisFunction, "this-function")
1837 DECLARE_HYDROGEN_ACCESSOR(ThisFunction)
1841 class LContext final : public LTemplateInstruction<1, 0, 0> {
1843 DECLARE_CONCRETE_INSTRUCTION(Context, "context")
1844 DECLARE_HYDROGEN_ACCESSOR(Context)
1848 class LDeclareGlobals final : public LTemplateInstruction<0, 1, 0> {
1850 explicit LDeclareGlobals(LOperand* context) {
1851 inputs_[0] = context;
1854 LOperand* context() { return inputs_[0]; }
1856 DECLARE_CONCRETE_INSTRUCTION(DeclareGlobals, "declare-globals")
1857 DECLARE_HYDROGEN_ACCESSOR(DeclareGlobals)
1861 class LCallJSFunction final : public LTemplateInstruction<1, 1, 0> {
1863 explicit LCallJSFunction(LOperand* function) {
1864 inputs_[0] = function;
1867 LOperand* function() { return inputs_[0]; }
1869 DECLARE_CONCRETE_INSTRUCTION(CallJSFunction, "call-js-function")
1870 DECLARE_HYDROGEN_ACCESSOR(CallJSFunction)
1872 void PrintDataTo(StringStream* stream) override;
1874 int arity() const { return hydrogen()->argument_count() - 1; }
1878 class LCallWithDescriptor final : public LTemplateResultInstruction<1> {
1880 LCallWithDescriptor(CallInterfaceDescriptor descriptor,
1881 const ZoneList<LOperand*>& operands, Zone* zone)
1882 : inputs_(descriptor.GetRegisterParameterCount() +
1883 kImplicitRegisterParameterCount,
1885 DCHECK(descriptor.GetRegisterParameterCount() +
1886 kImplicitRegisterParameterCount ==
1888 inputs_.AddAll(operands, zone);
1891 LOperand* target() const { return inputs_[0]; }
1893 DECLARE_HYDROGEN_ACCESSOR(CallWithDescriptor)
1895 // The target and context are passed as implicit parameters that are not
1896 // explicitly listed in the descriptor.
1897 static const int kImplicitRegisterParameterCount = 2;
1900 DECLARE_CONCRETE_INSTRUCTION(CallWithDescriptor, "call-with-descriptor")
1902 void PrintDataTo(StringStream* stream) override;
1904 int arity() const { return hydrogen()->argument_count() - 1; }
1906 ZoneList<LOperand*> inputs_;
1908 // Iterator support.
1909 int InputCount() final { return inputs_.length(); }
1910 LOperand* InputAt(int i) final { return inputs_[i]; }
1912 int TempCount() final { return 0; }
1913 LOperand* TempAt(int i) final { return NULL; }
1917 class LInvokeFunction final : public LTemplateInstruction<1, 2, 0> {
1919 LInvokeFunction(LOperand* context, LOperand* function) {
1920 inputs_[0] = context;
1921 inputs_[1] = function;
1924 LOperand* context() { return inputs_[0]; }
1925 LOperand* function() { return inputs_[1]; }
1927 DECLARE_CONCRETE_INSTRUCTION(InvokeFunction, "invoke-function")
1928 DECLARE_HYDROGEN_ACCESSOR(InvokeFunction)
1930 void PrintDataTo(StringStream* stream) override;
1932 int arity() const { return hydrogen()->argument_count() - 1; }
1936 class LCallFunction final : public LTemplateInstruction<1, 2, 2> {
1938 LCallFunction(LOperand* context, LOperand* function, LOperand* slot,
1940 inputs_[0] = context;
1941 inputs_[1] = function;
1946 LOperand* context() { return inputs_[0]; }
1947 LOperand* function() { return inputs_[1]; }
1948 LOperand* temp_slot() { return temps_[0]; }
1949 LOperand* temp_vector() { return temps_[1]; }
1951 DECLARE_CONCRETE_INSTRUCTION(CallFunction, "call-function")
1952 DECLARE_HYDROGEN_ACCESSOR(CallFunction)
1954 void PrintDataTo(StringStream* stream) override;
1955 int arity() const { return hydrogen()->argument_count() - 1; }
1959 class LCallNew final : public LTemplateInstruction<1, 2, 0> {
1961 LCallNew(LOperand* context, LOperand* constructor) {
1962 inputs_[0] = context;
1963 inputs_[1] = constructor;
1966 LOperand* context() { return inputs_[0]; }
1967 LOperand* constructor() { return inputs_[1]; }
1969 DECLARE_CONCRETE_INSTRUCTION(CallNew, "call-new")
1970 DECLARE_HYDROGEN_ACCESSOR(CallNew)
1972 void PrintDataTo(StringStream* stream) override;
1974 int arity() const { return hydrogen()->argument_count() - 1; }
1978 class LCallNewArray final : public LTemplateInstruction<1, 2, 0> {
1980 LCallNewArray(LOperand* context, LOperand* constructor) {
1981 inputs_[0] = context;
1982 inputs_[1] = constructor;
1985 LOperand* context() { return inputs_[0]; }
1986 LOperand* constructor() { return inputs_[1]; }
1988 DECLARE_CONCRETE_INSTRUCTION(CallNewArray, "call-new-array")
1989 DECLARE_HYDROGEN_ACCESSOR(CallNewArray)
1991 void PrintDataTo(StringStream* stream) override;
1993 int arity() const { return hydrogen()->argument_count() - 1; }
1997 class LCallRuntime final : public LTemplateInstruction<1, 1, 0> {
1999 explicit LCallRuntime(LOperand* context) {
2000 inputs_[0] = context;
2003 LOperand* context() { return inputs_[0]; }
2005 DECLARE_CONCRETE_INSTRUCTION(CallRuntime, "call-runtime")
2006 DECLARE_HYDROGEN_ACCESSOR(CallRuntime)
2008 bool ClobbersDoubleRegisters(Isolate* isolate) const override {
2009 return save_doubles() == kDontSaveFPRegs;
2012 const Runtime::Function* function() const { return hydrogen()->function(); }
2013 int arity() const { return hydrogen()->argument_count(); }
2014 SaveFPRegsMode save_doubles() const { return hydrogen()->save_doubles(); }
2018 class LInteger32ToDouble final : public LTemplateInstruction<1, 1, 0> {
2020 explicit LInteger32ToDouble(LOperand* value) {
2024 LOperand* value() { return inputs_[0]; }
2026 DECLARE_CONCRETE_INSTRUCTION(Integer32ToDouble, "int32-to-double")
2030 class LUint32ToDouble final : public LTemplateInstruction<1, 1, 0> {
2032 explicit LUint32ToDouble(LOperand* value) {
2036 LOperand* value() { return inputs_[0]; }
2038 DECLARE_CONCRETE_INSTRUCTION(Uint32ToDouble, "uint32-to-double")
2042 class LNumberTagI final : public LTemplateInstruction<1, 1, 1> {
2044 LNumberTagI(LOperand* value, LOperand* temp) {
2049 LOperand* value() { return inputs_[0]; }
2050 LOperand* temp() { return temps_[0]; }
2052 DECLARE_CONCRETE_INSTRUCTION(NumberTagI, "number-tag-i")
2056 class LNumberTagU final : public LTemplateInstruction<1, 1, 1> {
2058 LNumberTagU(LOperand* value, LOperand* temp) {
2063 LOperand* value() { return inputs_[0]; }
2064 LOperand* temp() { return temps_[0]; }
2066 DECLARE_CONCRETE_INSTRUCTION(NumberTagU, "number-tag-u")
2070 class LNumberTagD final : public LTemplateInstruction<1, 1, 1> {
2072 LNumberTagD(LOperand* value, LOperand* temp) {
2077 LOperand* value() { return inputs_[0]; }
2078 LOperand* temp() { return temps_[0]; }
2080 DECLARE_CONCRETE_INSTRUCTION(NumberTagD, "number-tag-d")
2081 DECLARE_HYDROGEN_ACCESSOR(Change)
2085 // Sometimes truncating conversion from a tagged value to an int32.
2086 class LDoubleToI final : public LTemplateInstruction<1, 1, 1> {
2088 LDoubleToI(LOperand* value, LOperand* temp) {
2093 LOperand* value() { return inputs_[0]; }
2094 LOperand* temp() { return temps_[0]; }
2096 DECLARE_CONCRETE_INSTRUCTION(DoubleToI, "double-to-i")
2097 DECLARE_HYDROGEN_ACCESSOR(UnaryOperation)
2099 bool truncating() { return hydrogen()->CanTruncateToInt32(); }
2103 class LDoubleToSmi final : public LTemplateInstruction<1, 1, 0> {
2105 explicit LDoubleToSmi(LOperand* value) {
2109 LOperand* value() { return inputs_[0]; }
2111 DECLARE_CONCRETE_INSTRUCTION(DoubleToSmi, "double-to-smi")
2112 DECLARE_HYDROGEN_ACCESSOR(UnaryOperation)
2116 // Truncating conversion from a tagged value to an int32.
2117 class LTaggedToI final : public LTemplateInstruction<1, 1, 1> {
2119 LTaggedToI(LOperand* value, LOperand* temp) {
2124 LOperand* value() { return inputs_[0]; }
2125 LOperand* temp() { return temps_[0]; }
2127 DECLARE_CONCRETE_INSTRUCTION(TaggedToI, "tagged-to-i")
2128 DECLARE_HYDROGEN_ACCESSOR(Change)
2130 bool truncating() { return hydrogen()->CanTruncateToInt32(); }
2134 class LSmiTag final : public LTemplateInstruction<1, 1, 0> {
2136 explicit LSmiTag(LOperand* value) {
2140 LOperand* value() { return inputs_[0]; }
2142 DECLARE_CONCRETE_INSTRUCTION(SmiTag, "smi-tag")
2143 DECLARE_HYDROGEN_ACCESSOR(Change)
2147 class LNumberUntagD final : public LTemplateInstruction<1, 1, 1> {
2149 explicit LNumberUntagD(LOperand* value, LOperand* temp) {
2154 LOperand* value() { return inputs_[0]; }
2155 LOperand* temp() { return temps_[0]; }
2157 DECLARE_CONCRETE_INSTRUCTION(NumberUntagD, "double-untag")
2158 DECLARE_HYDROGEN_ACCESSOR(Change);
2162 class LSmiUntag final : public LTemplateInstruction<1, 1, 0> {
2164 LSmiUntag(LOperand* value, bool needs_check)
2165 : needs_check_(needs_check) {
2169 LOperand* value() { return inputs_[0]; }
2171 DECLARE_CONCRETE_INSTRUCTION(SmiUntag, "smi-untag")
2173 bool needs_check() const { return needs_check_; }
2180 class LStoreNamedField final : public LTemplateInstruction<0, 2, 2> {
2182 LStoreNamedField(LOperand* obj,
2185 LOperand* temp_map) {
2189 temps_[1] = temp_map;
2192 LOperand* object() { return inputs_[0]; }
2193 LOperand* value() { return inputs_[1]; }
2194 LOperand* temp() { return temps_[0]; }
2195 LOperand* temp_map() { return temps_[1]; }
2197 DECLARE_CONCRETE_INSTRUCTION(StoreNamedField, "store-named-field")
2198 DECLARE_HYDROGEN_ACCESSOR(StoreNamedField)
2200 void PrintDataTo(StringStream* stream) override;
2204 class LStoreNamedGeneric final : public LTemplateInstruction<0, 3, 2> {
2206 LStoreNamedGeneric(LOperand* context, LOperand* object, LOperand* value,
2207 LOperand* slot, LOperand* vector) {
2208 inputs_[0] = context;
2209 inputs_[1] = object;
2215 LOperand* context() { return inputs_[0]; }
2216 LOperand* object() { return inputs_[1]; }
2217 LOperand* value() { return inputs_[2]; }
2218 LOperand* temp_slot() { return temps_[0]; }
2219 LOperand* temp_vector() { return temps_[1]; }
2221 DECLARE_CONCRETE_INSTRUCTION(StoreNamedGeneric, "store-named-generic")
2222 DECLARE_HYDROGEN_ACCESSOR(StoreNamedGeneric)
2224 void PrintDataTo(StringStream* stream) override;
2225 Handle<Object> name() const { return hydrogen()->name(); }
2226 LanguageMode language_mode() { return hydrogen()->language_mode(); }
2230 class LStoreGlobalViaContext final : public LTemplateInstruction<0, 2, 0> {
2232 LStoreGlobalViaContext(LOperand* context, LOperand* value) {
2233 inputs_[0] = context;
2237 LOperand* context() { return inputs_[0]; }
2238 LOperand* value() { return inputs_[1]; }
2240 DECLARE_CONCRETE_INSTRUCTION(StoreGlobalViaContext,
2241 "store-global-via-context")
2242 DECLARE_HYDROGEN_ACCESSOR(StoreGlobalViaContext)
2244 void PrintDataTo(StringStream* stream) override;
2246 int depth() { return hydrogen()->depth(); }
2247 int slot_index() { return hydrogen()->slot_index(); }
2248 LanguageMode language_mode() { return hydrogen()->language_mode(); }
2252 class LStoreKeyed final : public LTemplateInstruction<0, 3, 0> {
2254 LStoreKeyed(LOperand* obj, LOperand* key, LOperand* val) {
2260 bool is_external() const { return hydrogen()->is_external(); }
2261 bool is_fixed_typed_array() const {
2262 return hydrogen()->is_fixed_typed_array();
2264 bool is_typed_elements() const {
2265 return is_external() || is_fixed_typed_array();
2267 LOperand* elements() { return inputs_[0]; }
2268 LOperand* key() { return inputs_[1]; }
2269 LOperand* value() { return inputs_[2]; }
2270 ElementsKind elements_kind() const {
2271 return hydrogen()->elements_kind();
2274 DECLARE_CONCRETE_INSTRUCTION(StoreKeyed, "store-keyed")
2275 DECLARE_HYDROGEN_ACCESSOR(StoreKeyed)
2277 void PrintDataTo(StringStream* stream) override;
2278 uint32_t base_offset() const { return hydrogen()->base_offset(); }
2279 bool NeedsCanonicalization() { return hydrogen()->NeedsCanonicalization(); }
2283 class LStoreKeyedGeneric final : public LTemplateInstruction<0, 4, 2> {
2285 LStoreKeyedGeneric(LOperand* context, LOperand* object, LOperand* key,
2286 LOperand* value, LOperand* slot, LOperand* vector) {
2287 inputs_[0] = context;
2288 inputs_[1] = object;
2295 LOperand* context() { return inputs_[0]; }
2296 LOperand* object() { return inputs_[1]; }
2297 LOperand* key() { return inputs_[2]; }
2298 LOperand* value() { return inputs_[3]; }
2299 LOperand* temp_slot() { return temps_[0]; }
2300 LOperand* temp_vector() { return temps_[1]; }
2302 DECLARE_CONCRETE_INSTRUCTION(StoreKeyedGeneric, "store-keyed-generic")
2303 DECLARE_HYDROGEN_ACCESSOR(StoreKeyedGeneric)
2305 void PrintDataTo(StringStream* stream) override;
2307 LanguageMode language_mode() { return hydrogen()->language_mode(); }
2311 class LTransitionElementsKind final : public LTemplateInstruction<0, 2, 2> {
2313 LTransitionElementsKind(LOperand* object,
2315 LOperand* new_map_temp,
2317 inputs_[0] = object;
2318 inputs_[1] = context;
2319 temps_[0] = new_map_temp;
2323 LOperand* context() { return inputs_[1]; }
2324 LOperand* object() { return inputs_[0]; }
2325 LOperand* new_map_temp() { return temps_[0]; }
2326 LOperand* temp() { return temps_[1]; }
2328 DECLARE_CONCRETE_INSTRUCTION(TransitionElementsKind,
2329 "transition-elements-kind")
2330 DECLARE_HYDROGEN_ACCESSOR(TransitionElementsKind)
2332 void PrintDataTo(StringStream* stream) override;
2334 Handle<Map> original_map() { return hydrogen()->original_map().handle(); }
2335 Handle<Map> transitioned_map() {
2336 return hydrogen()->transitioned_map().handle();
2338 ElementsKind from_kind() { return hydrogen()->from_kind(); }
2339 ElementsKind to_kind() { return hydrogen()->to_kind(); }
2343 class LTrapAllocationMemento final : public LTemplateInstruction<0, 1, 1> {
2345 LTrapAllocationMemento(LOperand* object,
2347 inputs_[0] = object;
2351 LOperand* object() { return inputs_[0]; }
2352 LOperand* temp() { return temps_[0]; }
2354 DECLARE_CONCRETE_INSTRUCTION(TrapAllocationMemento,
2355 "trap-allocation-memento")
2359 class LMaybeGrowElements final : public LTemplateInstruction<1, 5, 0> {
2361 LMaybeGrowElements(LOperand* context, LOperand* object, LOperand* elements,
2362 LOperand* key, LOperand* current_capacity) {
2363 inputs_[0] = context;
2364 inputs_[1] = object;
2365 inputs_[2] = elements;
2367 inputs_[4] = current_capacity;
2370 LOperand* context() { return inputs_[0]; }
2371 LOperand* object() { return inputs_[1]; }
2372 LOperand* elements() { return inputs_[2]; }
2373 LOperand* key() { return inputs_[3]; }
2374 LOperand* current_capacity() { return inputs_[4]; }
2376 DECLARE_HYDROGEN_ACCESSOR(MaybeGrowElements)
2377 DECLARE_CONCRETE_INSTRUCTION(MaybeGrowElements, "maybe-grow-elements")
2381 class LStringAdd final : public LTemplateInstruction<1, 3, 0> {
2383 LStringAdd(LOperand* context, LOperand* left, LOperand* right) {
2384 inputs_[0] = context;
2389 LOperand* context() { return inputs_[0]; }
2390 LOperand* left() { return inputs_[1]; }
2391 LOperand* right() { return inputs_[2]; }
2393 DECLARE_CONCRETE_INSTRUCTION(StringAdd, "string-add")
2394 DECLARE_HYDROGEN_ACCESSOR(StringAdd)
2398 class LStringCharCodeAt final : public LTemplateInstruction<1, 3, 0> {
2400 LStringCharCodeAt(LOperand* context, LOperand* string, LOperand* index) {
2401 inputs_[0] = context;
2402 inputs_[1] = string;
2406 LOperand* context() { return inputs_[0]; }
2407 LOperand* string() { return inputs_[1]; }
2408 LOperand* index() { return inputs_[2]; }
2410 DECLARE_CONCRETE_INSTRUCTION(StringCharCodeAt, "string-char-code-at")
2411 DECLARE_HYDROGEN_ACCESSOR(StringCharCodeAt)
2415 class LStringCharFromCode final : public LTemplateInstruction<1, 2, 0> {
2417 LStringCharFromCode(LOperand* context, LOperand* char_code) {
2418 inputs_[0] = context;
2419 inputs_[1] = char_code;
2422 LOperand* context() { return inputs_[0]; }
2423 LOperand* char_code() { return inputs_[1]; }
2425 DECLARE_CONCRETE_INSTRUCTION(StringCharFromCode, "string-char-from-code")
2426 DECLARE_HYDROGEN_ACCESSOR(StringCharFromCode)
2430 class LCheckValue final : public LTemplateInstruction<0, 1, 0> {
2432 explicit LCheckValue(LOperand* value) {
2436 LOperand* value() { return inputs_[0]; }
2438 DECLARE_CONCRETE_INSTRUCTION(CheckValue, "check-value")
2439 DECLARE_HYDROGEN_ACCESSOR(CheckValue)
2443 class LCheckArrayBufferNotNeutered final
2444 : public LTemplateInstruction<0, 1, 1> {
2446 explicit LCheckArrayBufferNotNeutered(LOperand* view, LOperand* scratch) {
2448 temps_[0] = scratch;
2451 LOperand* view() { return inputs_[0]; }
2452 LOperand* scratch() { return temps_[0]; }
2454 DECLARE_CONCRETE_INSTRUCTION(CheckArrayBufferNotNeutered,
2455 "check-array-buffer-not-neutered")
2456 DECLARE_HYDROGEN_ACCESSOR(CheckArrayBufferNotNeutered)
2460 class LCheckInstanceType final : public LTemplateInstruction<0, 1, 1> {
2462 LCheckInstanceType(LOperand* value, LOperand* temp) {
2467 LOperand* value() { return inputs_[0]; }
2468 LOperand* temp() { return temps_[0]; }
2470 DECLARE_CONCRETE_INSTRUCTION(CheckInstanceType, "check-instance-type")
2471 DECLARE_HYDROGEN_ACCESSOR(CheckInstanceType)
2475 class LCheckMaps final : public LTemplateInstruction<0, 1, 0> {
2477 explicit LCheckMaps(LOperand* value = NULL) {
2481 LOperand* value() { return inputs_[0]; }
2483 DECLARE_CONCRETE_INSTRUCTION(CheckMaps, "check-maps")
2484 DECLARE_HYDROGEN_ACCESSOR(CheckMaps)
2488 class LCheckSmi final : public LTemplateInstruction<1, 1, 0> {
2490 explicit LCheckSmi(LOperand* value) {
2494 LOperand* value() { return inputs_[0]; }
2496 DECLARE_CONCRETE_INSTRUCTION(CheckSmi, "check-smi")
2500 class LClampDToUint8 final : public LTemplateInstruction<1, 1, 0> {
2502 explicit LClampDToUint8(LOperand* value) {
2506 LOperand* unclamped() { return inputs_[0]; }
2508 DECLARE_CONCRETE_INSTRUCTION(ClampDToUint8, "clamp-d-to-uint8")
2512 class LClampIToUint8 final : public LTemplateInstruction<1, 1, 0> {
2514 explicit LClampIToUint8(LOperand* value) {
2518 LOperand* unclamped() { return inputs_[0]; }
2520 DECLARE_CONCRETE_INSTRUCTION(ClampIToUint8, "clamp-i-to-uint8")
2524 class LClampTToUint8 final : public LTemplateInstruction<1, 1, 1> {
2526 LClampTToUint8(LOperand* value, LOperand* temp_xmm) {
2528 temps_[0] = temp_xmm;
2531 LOperand* unclamped() { return inputs_[0]; }
2532 LOperand* temp_xmm() { return temps_[0]; }
2534 DECLARE_CONCRETE_INSTRUCTION(ClampTToUint8, "clamp-t-to-uint8")
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(XMMRegister 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);
2838 MUST_USE_RESULT LOperand* UseFixedDouble(HValue* value,
2839 XMMRegister fixed_register);
2841 // A value that is guaranteed to be allocated to a register.
2842 // Operand created by UseRegister is guaranteed to be live until the end of
2843 // instruction. This means that register allocator will not reuse it's
2844 // register for any other operand inside instruction.
2845 // Operand created by UseRegisterAtStart is guaranteed to be live only at
2846 // instruction start. Register allocator is free to assign the same register
2847 // to some other operand used inside instruction (i.e. temporary or
2849 MUST_USE_RESULT LOperand* UseRegister(HValue* value);
2850 MUST_USE_RESULT LOperand* UseRegisterAtStart(HValue* value);
2852 // An input operand in a register that may be trashed.
2853 MUST_USE_RESULT LOperand* UseTempRegister(HValue* value);
2855 // An input operand in a register or stack slot.
2856 MUST_USE_RESULT LOperand* Use(HValue* value);
2857 MUST_USE_RESULT LOperand* UseAtStart(HValue* value);
2859 // An input operand in a register, stack slot or a constant operand.
2860 MUST_USE_RESULT LOperand* UseOrConstant(HValue* value);
2861 MUST_USE_RESULT LOperand* UseOrConstantAtStart(HValue* value);
2863 // An input operand in a fixed register or a constant operand.
2864 MUST_USE_RESULT LOperand* UseFixedOrConstant(HValue* value,
2865 Register fixed_register);
2867 // An input operand in a register or a constant operand.
2868 MUST_USE_RESULT LOperand* UseRegisterOrConstant(HValue* value);
2869 MUST_USE_RESULT LOperand* UseRegisterOrConstantAtStart(HValue* value);
2871 // An input operand in a constant operand.
2872 MUST_USE_RESULT LOperand* UseConstant(HValue* value);
2874 // An input operand in register, stack slot or a constant operand.
2875 // Will not be moved to a register even if one is freely available.
2876 MUST_USE_RESULT LOperand* UseAny(HValue* value) override;
2878 // Temporary operand that must be in a register.
2879 MUST_USE_RESULT LUnallocated* TempRegister();
2880 MUST_USE_RESULT LOperand* FixedTemp(Register reg);
2881 MUST_USE_RESULT LOperand* FixedTemp(XMMRegister reg);
2883 // Methods for setting up define-use relationships.
2884 // Return the same instruction that they are passed.
2885 LInstruction* Define(LTemplateResultInstruction<1>* instr,
2886 LUnallocated* result);
2887 LInstruction* DefineAsRegister(LTemplateResultInstruction<1>* instr);
2888 LInstruction* DefineAsSpilled(LTemplateResultInstruction<1>* instr,
2890 LInstruction* DefineSameAsFirst(LTemplateResultInstruction<1>* instr);
2891 LInstruction* DefineFixed(LTemplateResultInstruction<1>* instr,
2893 LInstruction* DefineFixedDouble(LTemplateResultInstruction<1>* instr,
2895 // Assigns an environment to an instruction. An instruction which can
2896 // deoptimize must have an environment.
2897 LInstruction* AssignEnvironment(LInstruction* instr);
2898 // Assigns a pointer map to an instruction. An instruction which can
2899 // trigger a GC or a lazy deoptimization must have a pointer map.
2900 LInstruction* AssignPointerMap(LInstruction* instr);
2902 enum CanDeoptimize { CAN_DEOPTIMIZE_EAGERLY, CANNOT_DEOPTIMIZE_EAGERLY };
2904 LOperand* GetSeqStringSetCharOperand(HSeqStringSetChar* instr);
2906 // Marks a call for the register allocator. Assigns a pointer map to
2907 // support GC and lazy deoptimization. Assigns an environment to support
2908 // eager deoptimization if CAN_DEOPTIMIZE_EAGERLY.
2909 LInstruction* MarkAsCall(
2910 LInstruction* instr,
2911 HInstruction* hinstr,
2912 CanDeoptimize can_deoptimize = CANNOT_DEOPTIMIZE_EAGERLY);
2914 void VisitInstruction(HInstruction* current);
2915 void AddInstruction(LInstruction* instr, HInstruction* current);
2917 void DoBasicBlock(HBasicBlock* block, HBasicBlock* next_block);
2918 LInstruction* DoShift(Token::Value op, HBitwiseBinaryOperation* instr);
2919 LInstruction* DoArithmeticD(Token::Value op,
2920 HArithmeticBinaryOperation* instr);
2921 LInstruction* DoArithmeticT(Token::Value op,
2922 HBinaryOperation* instr);
2924 LOperand* GetStoreKeyedValueOperand(HStoreKeyed* instr);
2926 HInstruction* current_instruction_;
2927 HBasicBlock* current_block_;
2928 HBasicBlock* next_block_;
2929 LAllocator* allocator_;
2931 DISALLOW_COPY_AND_ASSIGN(LChunkBuilder);
2934 #undef DECLARE_HYDROGEN_ACCESSOR
2935 #undef DECLARE_CONCRETE_INSTRUCTION
2937 } } // namespace v8::internal
2939 #endif // V8_IA32_LITHIUM_IA32_H_