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) \
109 V(LoadKeyedGeneric) \
111 V(LoadNamedGeneric) \
124 V(MaybeGrowElements) \
139 V(SeqStringGetChar) \
140 V(SeqStringSetChar) \
146 V(StoreContextSlot) \
147 V(StoreFrameContext) \
149 V(StoreKeyedGeneric) \
151 V(StoreNamedGeneric) \
153 V(StringCharCodeAt) \
154 V(StringCharFromCode) \
155 V(StringCompareAndBranch) \
159 V(ToFastProperties) \
160 V(TransitionElementsKind) \
161 V(TrapAllocationMemento) \
163 V(TypeofIsAndBranch) \
169 #define DECLARE_CONCRETE_INSTRUCTION(type, mnemonic) \
170 Opcode opcode() const final { return LInstruction::k##type; } \
171 void CompileToNative(LCodeGen* generator) final; \
172 const char* Mnemonic() const final { return mnemonic; } \
173 static L##type* cast(LInstruction* instr) { \
174 DCHECK(instr->Is##type()); \
175 return reinterpret_cast<L##type*>(instr); \
179 #define DECLARE_HYDROGEN_ACCESSOR(type) \
180 H##type* hydrogen() const { \
181 return H##type::cast(hydrogen_value()); \
185 class LInstruction : public ZoneObject {
188 : environment_(NULL),
189 hydrogen_value_(NULL),
190 bit_field_(IsCallBits::encode(false)) {
193 virtual ~LInstruction() {}
195 virtual void CompileToNative(LCodeGen* generator) = 0;
196 virtual const char* Mnemonic() const = 0;
197 virtual void PrintTo(StringStream* stream);
198 virtual void PrintDataTo(StringStream* stream);
199 virtual void PrintOutputOperandTo(StringStream* stream);
202 // Declare a unique enum value for each instruction.
203 #define DECLARE_OPCODE(type) k##type,
204 LITHIUM_CONCRETE_INSTRUCTION_LIST(DECLARE_OPCODE) kAdapter,
205 kNumberOfInstructions
206 #undef DECLARE_OPCODE
209 virtual Opcode opcode() const = 0;
211 // Declare non-virtual type testers for all leaf IR classes.
212 #define DECLARE_PREDICATE(type) \
213 bool Is##type() const { return opcode() == k##type; }
214 LITHIUM_CONCRETE_INSTRUCTION_LIST(DECLARE_PREDICATE)
215 #undef DECLARE_PREDICATE
217 // Declare virtual predicates for instructions that don't have
219 virtual bool IsGap() const { return false; }
221 virtual bool IsControl() const { return false; }
223 // Try deleting this instruction if possible.
224 virtual bool TryDelete() { return false; }
226 void set_environment(LEnvironment* env) { environment_ = env; }
227 LEnvironment* environment() const { return environment_; }
228 bool HasEnvironment() const { return environment_ != NULL; }
230 void set_pointer_map(LPointerMap* p) { pointer_map_.set(p); }
231 LPointerMap* pointer_map() const { return pointer_map_.get(); }
232 bool HasPointerMap() const { return pointer_map_.is_set(); }
234 void set_hydrogen_value(HValue* value) { hydrogen_value_ = value; }
235 HValue* hydrogen_value() const { return hydrogen_value_; }
237 virtual void SetDeferredLazyDeoptimizationEnvironment(LEnvironment* env) { }
239 void MarkAsCall() { bit_field_ = IsCallBits::update(bit_field_, true); }
240 bool IsCall() const { return IsCallBits::decode(bit_field_); }
242 // Interface to the register allocator and iterators.
243 bool ClobbersTemps() const { return IsCall(); }
244 bool ClobbersRegisters() const { return IsCall(); }
245 virtual bool ClobbersDoubleRegisters(Isolate* isolate) const {
249 virtual bool HasResult() const = 0;
250 virtual LOperand* result() const = 0;
252 bool HasDoubleRegisterResult();
253 bool HasDoubleRegisterInput();
255 LOperand* FirstInput() { return InputAt(0); }
256 LOperand* Output() { return HasResult() ? result() : NULL; }
258 virtual bool HasInterestingComment(LCodeGen* gen) const { return true; }
264 virtual int InputCount() = 0;
265 virtual LOperand* InputAt(int i) = 0;
269 friend class InputIterator;
271 friend class TempIterator;
272 virtual int TempCount() = 0;
273 virtual LOperand* TempAt(int i) = 0;
275 class IsCallBits: public BitField<bool, 0, 1> {};
277 LEnvironment* environment_;
278 SetOncePointer<LPointerMap> pointer_map_;
279 HValue* hydrogen_value_;
284 // R = number of result operands (0 or 1).
286 class LTemplateResultInstruction : public LInstruction {
288 // Allow 0 or 1 output operands.
289 STATIC_ASSERT(R == 0 || R == 1);
290 bool HasResult() const final { return R != 0 && result() != NULL; }
291 void set_result(LOperand* operand) { results_[0] = operand; }
292 LOperand* result() const override { return results_[0]; }
295 EmbeddedContainer<LOperand*, R> results_;
299 // R = number of result operands (0 or 1).
300 // I = number of input operands.
301 // T = number of temporary operands.
302 template<int R, int I, int T>
303 class LTemplateInstruction : public LTemplateResultInstruction<R> {
305 EmbeddedContainer<LOperand*, I> inputs_;
306 EmbeddedContainer<LOperand*, T> temps_;
310 int InputCount() final { return I; }
311 LOperand* InputAt(int i) final { return inputs_[i]; }
313 int TempCount() final { return T; }
314 LOperand* TempAt(int i) final { return temps_[i]; }
318 class LGap : public LTemplateInstruction<0, 0, 0> {
320 explicit LGap(HBasicBlock* block) : block_(block) {
321 parallel_moves_[BEFORE] = NULL;
322 parallel_moves_[START] = NULL;
323 parallel_moves_[END] = NULL;
324 parallel_moves_[AFTER] = NULL;
327 // Can't use the DECLARE-macro here because of sub-classes.
328 bool IsGap() const final { return true; }
329 void PrintDataTo(StringStream* stream) override;
330 static LGap* cast(LInstruction* instr) {
331 DCHECK(instr->IsGap());
332 return reinterpret_cast<LGap*>(instr);
335 bool IsRedundant() const;
337 HBasicBlock* block() const { return block_; }
344 FIRST_INNER_POSITION = BEFORE,
345 LAST_INNER_POSITION = AFTER
348 LParallelMove* GetOrCreateParallelMove(InnerPosition pos, Zone* zone) {
349 if (parallel_moves_[pos] == NULL) {
350 parallel_moves_[pos] = new(zone) LParallelMove(zone);
352 return parallel_moves_[pos];
355 LParallelMove* GetParallelMove(InnerPosition pos) {
356 return parallel_moves_[pos];
360 LParallelMove* parallel_moves_[LAST_INNER_POSITION + 1];
365 class LInstructionGap final : public LGap {
367 explicit LInstructionGap(HBasicBlock* block) : LGap(block) { }
369 bool HasInterestingComment(LCodeGen* gen) const override {
370 return !IsRedundant();
373 DECLARE_CONCRETE_INSTRUCTION(InstructionGap, "gap")
377 class LGoto final : public LTemplateInstruction<0, 0, 0> {
379 explicit LGoto(HBasicBlock* block) : block_(block) { }
381 bool HasInterestingComment(LCodeGen* gen) const override;
382 DECLARE_CONCRETE_INSTRUCTION(Goto, "goto")
383 void PrintDataTo(StringStream* stream) override;
384 bool IsControl() const override { return true; }
386 int block_id() const { return block_->block_id(); }
387 bool ClobbersDoubleRegisters(Isolate* isolate) const override {
391 bool jumps_to_join() const { return block_->predecessors()->length() > 1; }
398 class LLazyBailout final : public LTemplateInstruction<0, 0, 0> {
400 DECLARE_CONCRETE_INSTRUCTION(LazyBailout, "lazy-bailout")
404 class LDummy final : public LTemplateInstruction<1, 0, 0> {
407 DECLARE_CONCRETE_INSTRUCTION(Dummy, "dummy")
411 class LDummyUse final : public LTemplateInstruction<1, 1, 0> {
413 explicit LDummyUse(LOperand* value) {
416 DECLARE_CONCRETE_INSTRUCTION(DummyUse, "dummy-use")
420 class LDeoptimize final : public LTemplateInstruction<0, 0, 0> {
422 bool IsControl() const override { return true; }
423 DECLARE_CONCRETE_INSTRUCTION(Deoptimize, "deoptimize")
424 DECLARE_HYDROGEN_ACCESSOR(Deoptimize)
428 class LLabel final : public LGap {
430 explicit LLabel(HBasicBlock* block)
431 : LGap(block), replacement_(NULL) { }
433 bool HasInterestingComment(LCodeGen* gen) const override { return false; }
434 DECLARE_CONCRETE_INSTRUCTION(Label, "label")
436 void PrintDataTo(StringStream* stream) override;
438 int block_id() const { return block()->block_id(); }
439 bool is_loop_header() const { return block()->IsLoopHeader(); }
440 bool is_osr_entry() const { return block()->is_osr_entry(); }
441 Label* label() { return &label_; }
442 LLabel* replacement() const { return replacement_; }
443 void set_replacement(LLabel* label) { replacement_ = label; }
444 bool HasReplacement() const { return replacement_ != NULL; }
448 LLabel* replacement_;
452 class LParameter final : public LTemplateInstruction<1, 0, 0> {
454 bool HasInterestingComment(LCodeGen* gen) const override { return false; }
455 DECLARE_CONCRETE_INSTRUCTION(Parameter, "parameter")
459 class LCallStub final : public LTemplateInstruction<1, 1, 0> {
461 explicit LCallStub(LOperand* context) {
462 inputs_[0] = context;
465 LOperand* context() { return inputs_[0]; }
467 DECLARE_CONCRETE_INSTRUCTION(CallStub, "call-stub")
468 DECLARE_HYDROGEN_ACCESSOR(CallStub)
472 class LUnknownOSRValue final : public LTemplateInstruction<1, 0, 0> {
474 bool HasInterestingComment(LCodeGen* gen) const override { return false; }
475 DECLARE_CONCRETE_INSTRUCTION(UnknownOSRValue, "unknown-osr-value")
479 template<int I, int T>
480 class LControlInstruction: public LTemplateInstruction<0, I, T> {
482 LControlInstruction() : false_label_(NULL), true_label_(NULL) { }
484 bool IsControl() const final { return true; }
486 int SuccessorCount() { return hydrogen()->SuccessorCount(); }
487 HBasicBlock* SuccessorAt(int i) { return hydrogen()->SuccessorAt(i); }
489 int TrueDestination(LChunk* chunk) {
490 return chunk->LookupDestination(true_block_id());
492 int FalseDestination(LChunk* chunk) {
493 return chunk->LookupDestination(false_block_id());
496 Label* TrueLabel(LChunk* chunk) {
497 if (true_label_ == NULL) {
498 true_label_ = chunk->GetAssemblyLabel(TrueDestination(chunk));
502 Label* FalseLabel(LChunk* chunk) {
503 if (false_label_ == NULL) {
504 false_label_ = chunk->GetAssemblyLabel(FalseDestination(chunk));
510 int true_block_id() { return SuccessorAt(0)->block_id(); }
511 int false_block_id() { return SuccessorAt(1)->block_id(); }
514 HControlInstruction* hydrogen() {
515 return HControlInstruction::cast(this->hydrogen_value());
523 class LWrapReceiver final : public LTemplateInstruction<1, 2, 1> {
525 LWrapReceiver(LOperand* receiver,
528 inputs_[0] = receiver;
529 inputs_[1] = function;
533 LOperand* receiver() { return inputs_[0]; }
534 LOperand* function() { return inputs_[1]; }
535 LOperand* temp() { return temps_[0]; }
537 DECLARE_CONCRETE_INSTRUCTION(WrapReceiver, "wrap-receiver")
538 DECLARE_HYDROGEN_ACCESSOR(WrapReceiver)
542 class LApplyArguments final : public LTemplateInstruction<1, 4, 0> {
544 LApplyArguments(LOperand* function,
547 LOperand* elements) {
548 inputs_[0] = function;
549 inputs_[1] = receiver;
551 inputs_[3] = elements;
554 LOperand* function() { return inputs_[0]; }
555 LOperand* receiver() { return inputs_[1]; }
556 LOperand* length() { return inputs_[2]; }
557 LOperand* elements() { return inputs_[3]; }
559 DECLARE_CONCRETE_INSTRUCTION(ApplyArguments, "apply-arguments")
563 class LAccessArgumentsAt final : public LTemplateInstruction<1, 3, 0> {
565 LAccessArgumentsAt(LOperand* arguments, LOperand* length, LOperand* index) {
566 inputs_[0] = arguments;
571 LOperand* arguments() { return inputs_[0]; }
572 LOperand* length() { return inputs_[1]; }
573 LOperand* index() { return inputs_[2]; }
575 DECLARE_CONCRETE_INSTRUCTION(AccessArgumentsAt, "access-arguments-at")
577 void PrintDataTo(StringStream* stream) override;
581 class LArgumentsLength final : public LTemplateInstruction<1, 1, 0> {
583 explicit LArgumentsLength(LOperand* elements) {
584 inputs_[0] = elements;
587 LOperand* elements() { return inputs_[0]; }
589 DECLARE_CONCRETE_INSTRUCTION(ArgumentsLength, "arguments-length")
593 class LArgumentsElements final : public LTemplateInstruction<1, 0, 0> {
595 DECLARE_CONCRETE_INSTRUCTION(ArgumentsElements, "arguments-elements")
596 DECLARE_HYDROGEN_ACCESSOR(ArgumentsElements)
600 class LDebugBreak final : public LTemplateInstruction<0, 0, 0> {
602 DECLARE_CONCRETE_INSTRUCTION(DebugBreak, "break")
606 class LModByPowerOf2I final : public LTemplateInstruction<1, 1, 0> {
608 LModByPowerOf2I(LOperand* dividend, int32_t divisor) {
609 inputs_[0] = dividend;
613 LOperand* dividend() { return inputs_[0]; }
614 int32_t divisor() const { return divisor_; }
616 DECLARE_CONCRETE_INSTRUCTION(ModByPowerOf2I, "mod-by-power-of-2-i")
617 DECLARE_HYDROGEN_ACCESSOR(Mod)
624 class LModByConstI final : public LTemplateInstruction<1, 1, 2> {
626 LModByConstI(LOperand* dividend,
630 inputs_[0] = dividend;
636 LOperand* dividend() { return inputs_[0]; }
637 int32_t divisor() const { return divisor_; }
638 LOperand* temp1() { return temps_[0]; }
639 LOperand* temp2() { return temps_[1]; }
641 DECLARE_CONCRETE_INSTRUCTION(ModByConstI, "mod-by-const-i")
642 DECLARE_HYDROGEN_ACCESSOR(Mod)
649 class LModI final : public LTemplateInstruction<1, 2, 1> {
651 LModI(LOperand* left, LOperand* right, LOperand* temp) {
657 LOperand* left() { return inputs_[0]; }
658 LOperand* right() { return inputs_[1]; }
659 LOperand* temp() { return temps_[0]; }
661 DECLARE_CONCRETE_INSTRUCTION(ModI, "mod-i")
662 DECLARE_HYDROGEN_ACCESSOR(Mod)
666 class LDivByPowerOf2I final : public LTemplateInstruction<1, 1, 0> {
668 LDivByPowerOf2I(LOperand* dividend, int32_t divisor) {
669 inputs_[0] = dividend;
673 LOperand* dividend() { return inputs_[0]; }
674 int32_t divisor() const { return divisor_; }
676 DECLARE_CONCRETE_INSTRUCTION(DivByPowerOf2I, "div-by-power-of-2-i")
677 DECLARE_HYDROGEN_ACCESSOR(Div)
684 class LDivByConstI final : public LTemplateInstruction<1, 1, 2> {
686 LDivByConstI(LOperand* dividend,
690 inputs_[0] = dividend;
696 LOperand* dividend() { return inputs_[0]; }
697 int32_t divisor() const { return divisor_; }
698 LOperand* temp1() { return temps_[0]; }
699 LOperand* temp2() { return temps_[1]; }
701 DECLARE_CONCRETE_INSTRUCTION(DivByConstI, "div-by-const-i")
702 DECLARE_HYDROGEN_ACCESSOR(Div)
709 class LDivI final : public LTemplateInstruction<1, 2, 1> {
711 LDivI(LOperand* dividend, LOperand* divisor, LOperand* temp) {
712 inputs_[0] = dividend;
713 inputs_[1] = divisor;
717 LOperand* dividend() { return inputs_[0]; }
718 LOperand* divisor() { return inputs_[1]; }
719 LOperand* temp() { return temps_[0]; }
721 DECLARE_CONCRETE_INSTRUCTION(DivI, "div-i")
722 DECLARE_HYDROGEN_ACCESSOR(BinaryOperation)
726 class LFlooringDivByPowerOf2I final : public LTemplateInstruction<1, 1, 0> {
728 LFlooringDivByPowerOf2I(LOperand* dividend, int32_t divisor) {
729 inputs_[0] = dividend;
733 LOperand* dividend() { return inputs_[0]; }
734 int32_t divisor() const { return divisor_; }
736 DECLARE_CONCRETE_INSTRUCTION(FlooringDivByPowerOf2I,
737 "flooring-div-by-power-of-2-i")
738 DECLARE_HYDROGEN_ACCESSOR(MathFloorOfDiv)
745 class LFlooringDivByConstI final : public LTemplateInstruction<1, 1, 3> {
747 LFlooringDivByConstI(LOperand* dividend,
752 inputs_[0] = dividend;
759 LOperand* dividend() { return inputs_[0]; }
760 int32_t divisor() const { return divisor_; }
761 LOperand* temp1() { return temps_[0]; }
762 LOperand* temp2() { return temps_[1]; }
763 LOperand* temp3() { return temps_[2]; }
765 DECLARE_CONCRETE_INSTRUCTION(FlooringDivByConstI, "flooring-div-by-const-i")
766 DECLARE_HYDROGEN_ACCESSOR(MathFloorOfDiv)
773 class LFlooringDivI final : public LTemplateInstruction<1, 2, 1> {
775 LFlooringDivI(LOperand* dividend, LOperand* divisor, LOperand* temp) {
776 inputs_[0] = dividend;
777 inputs_[1] = divisor;
781 LOperand* dividend() { return inputs_[0]; }
782 LOperand* divisor() { return inputs_[1]; }
783 LOperand* temp() { return temps_[0]; }
785 DECLARE_CONCRETE_INSTRUCTION(FlooringDivI, "flooring-div-i")
786 DECLARE_HYDROGEN_ACCESSOR(MathFloorOfDiv)
790 class LMulI final : public LTemplateInstruction<1, 2, 1> {
792 LMulI(LOperand* left, LOperand* right, LOperand* temp) {
798 LOperand* left() { return inputs_[0]; }
799 LOperand* right() { return inputs_[1]; }
800 LOperand* temp() { return temps_[0]; }
802 DECLARE_CONCRETE_INSTRUCTION(MulI, "mul-i")
803 DECLARE_HYDROGEN_ACCESSOR(Mul)
807 class LCompareNumericAndBranch final : public LControlInstruction<2, 0> {
809 LCompareNumericAndBranch(LOperand* left, LOperand* right) {
814 LOperand* left() { return inputs_[0]; }
815 LOperand* right() { return inputs_[1]; }
817 DECLARE_CONCRETE_INSTRUCTION(CompareNumericAndBranch,
818 "compare-numeric-and-branch")
819 DECLARE_HYDROGEN_ACCESSOR(CompareNumericAndBranch)
821 Token::Value op() const { return hydrogen()->token(); }
822 bool is_double() const {
823 return hydrogen()->representation().IsDouble();
826 void PrintDataTo(StringStream* stream) override;
830 class LMathFloor final : public LTemplateInstruction<1, 1, 0> {
832 explicit LMathFloor(LOperand* value) {
836 LOperand* value() { return inputs_[0]; }
838 DECLARE_CONCRETE_INSTRUCTION(MathFloor, "math-floor")
839 DECLARE_HYDROGEN_ACCESSOR(UnaryMathOperation)
843 class LMathRound final : public LTemplateInstruction<1, 1, 1> {
845 LMathRound(LOperand* value, LOperand* temp) {
850 LOperand* temp() { return temps_[0]; }
851 LOperand* value() { return inputs_[0]; }
853 DECLARE_CONCRETE_INSTRUCTION(MathRound, "math-round")
854 DECLARE_HYDROGEN_ACCESSOR(UnaryMathOperation)
858 class LMathFround final : public LTemplateInstruction<1, 1, 0> {
860 explicit LMathFround(LOperand* value) { inputs_[0] = value; }
862 LOperand* value() { return inputs_[0]; }
864 DECLARE_CONCRETE_INSTRUCTION(MathFround, "math-fround")
868 class LMathAbs final : public LTemplateInstruction<1, 2, 0> {
870 LMathAbs(LOperand* context, LOperand* value) {
871 inputs_[1] = context;
875 LOperand* context() { return inputs_[1]; }
876 LOperand* value() { return inputs_[0]; }
878 DECLARE_CONCRETE_INSTRUCTION(MathAbs, "math-abs")
879 DECLARE_HYDROGEN_ACCESSOR(UnaryMathOperation)
883 class LMathLog final : public LTemplateInstruction<1, 1, 0> {
885 explicit LMathLog(LOperand* value) {
889 LOperand* value() { return inputs_[0]; }
891 DECLARE_CONCRETE_INSTRUCTION(MathLog, "math-log")
895 class LMathClz32 final : public LTemplateInstruction<1, 1, 0> {
897 explicit LMathClz32(LOperand* value) {
901 LOperand* value() { return inputs_[0]; }
903 DECLARE_CONCRETE_INSTRUCTION(MathClz32, "math-clz32")
907 class LMathExp final : public LTemplateInstruction<1, 1, 2> {
909 LMathExp(LOperand* value,
915 ExternalReference::InitializeMathExpData();
918 LOperand* value() { return inputs_[0]; }
919 LOperand* temp1() { return temps_[0]; }
920 LOperand* temp2() { return temps_[1]; }
922 DECLARE_CONCRETE_INSTRUCTION(MathExp, "math-exp")
926 class LMathSqrt final : public LTemplateInstruction<1, 1, 0> {
928 explicit LMathSqrt(LOperand* value) {
932 LOperand* value() { return inputs_[0]; }
934 DECLARE_CONCRETE_INSTRUCTION(MathSqrt, "math-sqrt")
938 class LMathPowHalf final : public LTemplateInstruction<1, 1, 1> {
940 LMathPowHalf(LOperand* value, LOperand* temp) {
945 LOperand* value() { return inputs_[0]; }
946 LOperand* temp() { return temps_[0]; }
948 DECLARE_CONCRETE_INSTRUCTION(MathPowHalf, "math-pow-half")
952 class LCmpObjectEqAndBranch final : public LControlInstruction<2, 0> {
954 LCmpObjectEqAndBranch(LOperand* left, LOperand* right) {
959 LOperand* left() { return inputs_[0]; }
960 LOperand* right() { return inputs_[1]; }
962 DECLARE_CONCRETE_INSTRUCTION(CmpObjectEqAndBranch, "cmp-object-eq-and-branch")
966 class LCmpHoleAndBranch final : public LControlInstruction<1, 0> {
968 explicit LCmpHoleAndBranch(LOperand* object) {
972 LOperand* object() { return inputs_[0]; }
974 DECLARE_CONCRETE_INSTRUCTION(CmpHoleAndBranch, "cmp-hole-and-branch")
975 DECLARE_HYDROGEN_ACCESSOR(CompareHoleAndBranch)
979 class LCompareMinusZeroAndBranch final : public LControlInstruction<1, 1> {
981 LCompareMinusZeroAndBranch(LOperand* value, LOperand* temp) {
986 LOperand* value() { return inputs_[0]; }
987 LOperand* temp() { return temps_[0]; }
989 DECLARE_CONCRETE_INSTRUCTION(CompareMinusZeroAndBranch,
990 "cmp-minus-zero-and-branch")
991 DECLARE_HYDROGEN_ACCESSOR(CompareMinusZeroAndBranch)
995 class LIsObjectAndBranch final : public LControlInstruction<1, 1> {
997 LIsObjectAndBranch(LOperand* value, LOperand* temp) {
1002 LOperand* value() { return inputs_[0]; }
1003 LOperand* temp() { return temps_[0]; }
1005 DECLARE_CONCRETE_INSTRUCTION(IsObjectAndBranch, "is-object-and-branch")
1007 void PrintDataTo(StringStream* stream) override;
1011 class LIsStringAndBranch final : public LControlInstruction<1, 1> {
1013 LIsStringAndBranch(LOperand* value, LOperand* temp) {
1018 LOperand* value() { return inputs_[0]; }
1019 LOperand* temp() { return temps_[0]; }
1021 DECLARE_CONCRETE_INSTRUCTION(IsStringAndBranch, "is-string-and-branch")
1022 DECLARE_HYDROGEN_ACCESSOR(IsStringAndBranch)
1024 void PrintDataTo(StringStream* stream) override;
1028 class LIsSmiAndBranch final : public LControlInstruction<1, 0> {
1030 explicit LIsSmiAndBranch(LOperand* value) {
1034 LOperand* value() { return inputs_[0]; }
1036 DECLARE_CONCRETE_INSTRUCTION(IsSmiAndBranch, "is-smi-and-branch")
1037 DECLARE_HYDROGEN_ACCESSOR(IsSmiAndBranch)
1039 void PrintDataTo(StringStream* stream) override;
1043 class LIsUndetectableAndBranch final : public LControlInstruction<1, 1> {
1045 LIsUndetectableAndBranch(LOperand* value, LOperand* temp) {
1050 LOperand* value() { return inputs_[0]; }
1051 LOperand* temp() { return temps_[0]; }
1053 DECLARE_CONCRETE_INSTRUCTION(IsUndetectableAndBranch,
1054 "is-undetectable-and-branch")
1055 DECLARE_HYDROGEN_ACCESSOR(IsUndetectableAndBranch)
1057 void PrintDataTo(StringStream* stream) override;
1061 class LStringCompareAndBranch final : public LControlInstruction<3, 0> {
1063 LStringCompareAndBranch(LOperand* context, LOperand* left, LOperand* right) {
1064 inputs_[0] = context;
1069 LOperand* context() { return inputs_[1]; }
1070 LOperand* left() { return inputs_[1]; }
1071 LOperand* right() { return inputs_[2]; }
1073 DECLARE_CONCRETE_INSTRUCTION(StringCompareAndBranch,
1074 "string-compare-and-branch")
1075 DECLARE_HYDROGEN_ACCESSOR(StringCompareAndBranch)
1077 void PrintDataTo(StringStream* stream) override;
1079 Token::Value op() const { return hydrogen()->token(); }
1083 class LHasInstanceTypeAndBranch final : public LControlInstruction<1, 1> {
1085 LHasInstanceTypeAndBranch(LOperand* value, LOperand* temp) {
1090 LOperand* value() { return inputs_[0]; }
1091 LOperand* temp() { return temps_[0]; }
1093 DECLARE_CONCRETE_INSTRUCTION(HasInstanceTypeAndBranch,
1094 "has-instance-type-and-branch")
1095 DECLARE_HYDROGEN_ACCESSOR(HasInstanceTypeAndBranch)
1097 void PrintDataTo(StringStream* stream) override;
1101 class LGetCachedArrayIndex final : public LTemplateInstruction<1, 1, 0> {
1103 explicit LGetCachedArrayIndex(LOperand* value) {
1107 LOperand* value() { return inputs_[0]; }
1109 DECLARE_CONCRETE_INSTRUCTION(GetCachedArrayIndex, "get-cached-array-index")
1110 DECLARE_HYDROGEN_ACCESSOR(GetCachedArrayIndex)
1114 class LHasCachedArrayIndexAndBranch final : public LControlInstruction<1, 0> {
1116 explicit LHasCachedArrayIndexAndBranch(LOperand* value) {
1120 LOperand* value() { return inputs_[0]; }
1122 DECLARE_CONCRETE_INSTRUCTION(HasCachedArrayIndexAndBranch,
1123 "has-cached-array-index-and-branch")
1125 void PrintDataTo(StringStream* stream) override;
1129 class LIsConstructCallAndBranch final : public LControlInstruction<0, 1> {
1131 explicit LIsConstructCallAndBranch(LOperand* temp) {
1135 LOperand* temp() { return temps_[0]; }
1137 DECLARE_CONCRETE_INSTRUCTION(IsConstructCallAndBranch,
1138 "is-construct-call-and-branch")
1142 class LClassOfTestAndBranch final : public LControlInstruction<1, 2> {
1144 LClassOfTestAndBranch(LOperand* value, LOperand* temp, LOperand* temp2) {
1150 LOperand* value() { return inputs_[0]; }
1151 LOperand* temp() { return temps_[0]; }
1152 LOperand* temp2() { return temps_[1]; }
1154 DECLARE_CONCRETE_INSTRUCTION(ClassOfTestAndBranch,
1155 "class-of-test-and-branch")
1156 DECLARE_HYDROGEN_ACCESSOR(ClassOfTestAndBranch)
1158 void PrintDataTo(StringStream* stream) override;
1162 class LCmpT final : public LTemplateInstruction<1, 3, 0> {
1164 LCmpT(LOperand* context, LOperand* left, LOperand* right) {
1165 inputs_[0] = context;
1170 DECLARE_CONCRETE_INSTRUCTION(CmpT, "cmp-t")
1171 DECLARE_HYDROGEN_ACCESSOR(CompareGeneric)
1173 Strength strength() { return hydrogen()->strength(); }
1175 LOperand* context() { return inputs_[0]; }
1176 Token::Value op() const { return hydrogen()->token(); }
1180 class LInstanceOf final : public LTemplateInstruction<1, 3, 0> {
1182 LInstanceOf(LOperand* context, LOperand* left, LOperand* right) {
1183 inputs_[0] = context;
1188 LOperand* context() { return inputs_[0]; }
1190 DECLARE_CONCRETE_INSTRUCTION(InstanceOf, "instance-of")
1194 class LInstanceOfKnownGlobal final : public LTemplateInstruction<1, 2, 1> {
1196 LInstanceOfKnownGlobal(LOperand* context, LOperand* value, LOperand* temp) {
1197 inputs_[0] = context;
1202 LOperand* context() { return inputs_[0]; }
1203 LOperand* value() { return inputs_[1]; }
1204 LOperand* temp() { return temps_[0]; }
1206 DECLARE_CONCRETE_INSTRUCTION(InstanceOfKnownGlobal,
1207 "instance-of-known-global")
1208 DECLARE_HYDROGEN_ACCESSOR(InstanceOfKnownGlobal)
1210 Handle<JSFunction> function() const { return hydrogen()->function(); }
1211 LEnvironment* GetDeferredLazyDeoptimizationEnvironment() {
1212 return lazy_deopt_env_;
1214 virtual void SetDeferredLazyDeoptimizationEnvironment(
1215 LEnvironment* env) override {
1216 lazy_deopt_env_ = env;
1220 LEnvironment* lazy_deopt_env_;
1224 class LBoundsCheck final : public LTemplateInstruction<0, 2, 0> {
1226 LBoundsCheck(LOperand* index, LOperand* length) {
1228 inputs_[1] = length;
1231 LOperand* index() { return inputs_[0]; }
1232 LOperand* length() { return inputs_[1]; }
1234 DECLARE_CONCRETE_INSTRUCTION(BoundsCheck, "bounds-check")
1235 DECLARE_HYDROGEN_ACCESSOR(BoundsCheck)
1239 class LBitI final : public LTemplateInstruction<1, 2, 0> {
1241 LBitI(LOperand* left, LOperand* right) {
1246 LOperand* left() { return inputs_[0]; }
1247 LOperand* right() { return inputs_[1]; }
1249 DECLARE_CONCRETE_INSTRUCTION(BitI, "bit-i")
1250 DECLARE_HYDROGEN_ACCESSOR(Bitwise)
1252 Token::Value op() const { return hydrogen()->op(); }
1256 class LShiftI final : public LTemplateInstruction<1, 2, 0> {
1258 LShiftI(Token::Value op, LOperand* left, LOperand* right, bool can_deopt)
1259 : op_(op), can_deopt_(can_deopt) {
1264 LOperand* left() { return inputs_[0]; }
1265 LOperand* right() { return inputs_[1]; }
1267 DECLARE_CONCRETE_INSTRUCTION(ShiftI, "shift-i")
1269 Token::Value op() const { return op_; }
1270 bool can_deopt() const { return can_deopt_; }
1278 class LSubI final : public LTemplateInstruction<1, 2, 0> {
1280 LSubI(LOperand* left, LOperand* right) {
1285 LOperand* left() { return inputs_[0]; }
1286 LOperand* right() { return inputs_[1]; }
1288 DECLARE_CONCRETE_INSTRUCTION(SubI, "sub-i")
1289 DECLARE_HYDROGEN_ACCESSOR(Sub)
1293 class LConstantI final : public LTemplateInstruction<1, 0, 0> {
1295 DECLARE_CONCRETE_INSTRUCTION(ConstantI, "constant-i")
1296 DECLARE_HYDROGEN_ACCESSOR(Constant)
1298 int32_t value() const { return hydrogen()->Integer32Value(); }
1302 class LConstantS final : public LTemplateInstruction<1, 0, 0> {
1304 DECLARE_CONCRETE_INSTRUCTION(ConstantS, "constant-s")
1305 DECLARE_HYDROGEN_ACCESSOR(Constant)
1307 Smi* value() const { return Smi::FromInt(hydrogen()->Integer32Value()); }
1311 class LConstantD final : public LTemplateInstruction<1, 0, 1> {
1313 explicit LConstantD(LOperand* temp) {
1317 LOperand* temp() { return temps_[0]; }
1319 DECLARE_CONCRETE_INSTRUCTION(ConstantD, "constant-d")
1320 DECLARE_HYDROGEN_ACCESSOR(Constant)
1322 uint64_t bits() const { return hydrogen()->DoubleValueAsBits(); }
1326 class LConstantE final : public LTemplateInstruction<1, 0, 0> {
1328 DECLARE_CONCRETE_INSTRUCTION(ConstantE, "constant-e")
1329 DECLARE_HYDROGEN_ACCESSOR(Constant)
1331 ExternalReference value() const {
1332 return hydrogen()->ExternalReferenceValue();
1337 class LConstantT final : public LTemplateInstruction<1, 0, 0> {
1339 DECLARE_CONCRETE_INSTRUCTION(ConstantT, "constant-t")
1340 DECLARE_HYDROGEN_ACCESSOR(Constant)
1342 Handle<Object> value(Isolate* isolate) const {
1343 return hydrogen()->handle(isolate);
1348 class LBranch final : public LControlInstruction<1, 1> {
1350 LBranch(LOperand* value, LOperand* temp) {
1355 LOperand* value() { return inputs_[0]; }
1356 LOperand* temp() { return temps_[0]; }
1358 DECLARE_CONCRETE_INSTRUCTION(Branch, "branch")
1359 DECLARE_HYDROGEN_ACCESSOR(Branch)
1361 void PrintDataTo(StringStream* stream) override;
1365 class LCmpMapAndBranch final : public LControlInstruction<1, 0> {
1367 explicit LCmpMapAndBranch(LOperand* value) {
1371 LOperand* value() { return inputs_[0]; }
1373 DECLARE_CONCRETE_INSTRUCTION(CmpMapAndBranch, "cmp-map-and-branch")
1374 DECLARE_HYDROGEN_ACCESSOR(CompareMap)
1376 Handle<Map> map() const { return hydrogen()->map().handle(); }
1380 class LMapEnumLength final : public LTemplateInstruction<1, 1, 0> {
1382 explicit LMapEnumLength(LOperand* value) {
1386 LOperand* value() { return inputs_[0]; }
1388 DECLARE_CONCRETE_INSTRUCTION(MapEnumLength, "map-enum-length")
1392 class LDateField final : public LTemplateInstruction<1, 1, 1> {
1394 LDateField(LOperand* date, LOperand* temp, Smi* index)
1400 LOperand* date() { return inputs_[0]; }
1401 LOperand* temp() { return temps_[0]; }
1403 DECLARE_CONCRETE_INSTRUCTION(DateField, "date-field")
1404 DECLARE_HYDROGEN_ACCESSOR(DateField)
1406 Smi* index() const { return index_; }
1413 class LSeqStringGetChar final : public LTemplateInstruction<1, 2, 0> {
1415 LSeqStringGetChar(LOperand* string, LOperand* index) {
1416 inputs_[0] = string;
1420 LOperand* string() const { return inputs_[0]; }
1421 LOperand* index() const { return inputs_[1]; }
1423 DECLARE_CONCRETE_INSTRUCTION(SeqStringGetChar, "seq-string-get-char")
1424 DECLARE_HYDROGEN_ACCESSOR(SeqStringGetChar)
1428 class LSeqStringSetChar final : public LTemplateInstruction<1, 4, 0> {
1430 LSeqStringSetChar(LOperand* context,
1434 inputs_[0] = context;
1435 inputs_[1] = string;
1440 LOperand* string() { return inputs_[1]; }
1441 LOperand* index() { return inputs_[2]; }
1442 LOperand* value() { return inputs_[3]; }
1444 DECLARE_CONCRETE_INSTRUCTION(SeqStringSetChar, "seq-string-set-char")
1445 DECLARE_HYDROGEN_ACCESSOR(SeqStringSetChar)
1449 class LAddI final : public LTemplateInstruction<1, 2, 0> {
1451 LAddI(LOperand* left, LOperand* right) {
1456 LOperand* left() { return inputs_[0]; }
1457 LOperand* right() { return inputs_[1]; }
1459 static bool UseLea(HAdd* add) {
1460 return !add->CheckFlag(HValue::kCanOverflow) &&
1461 add->BetterLeftOperand()->UseCount() > 1;
1464 DECLARE_CONCRETE_INSTRUCTION(AddI, "add-i")
1465 DECLARE_HYDROGEN_ACCESSOR(Add)
1469 class LMathMinMax final : public LTemplateInstruction<1, 2, 0> {
1471 LMathMinMax(LOperand* left, LOperand* right) {
1476 LOperand* left() { return inputs_[0]; }
1477 LOperand* right() { return inputs_[1]; }
1479 DECLARE_CONCRETE_INSTRUCTION(MathMinMax, "math-min-max")
1480 DECLARE_HYDROGEN_ACCESSOR(MathMinMax)
1484 class LPower final : public LTemplateInstruction<1, 2, 0> {
1486 LPower(LOperand* left, LOperand* right) {
1491 LOperand* left() { return inputs_[0]; }
1492 LOperand* right() { return inputs_[1]; }
1494 DECLARE_CONCRETE_INSTRUCTION(Power, "power")
1495 DECLARE_HYDROGEN_ACCESSOR(Power)
1499 class LArithmeticD final : public LTemplateInstruction<1, 2, 0> {
1501 LArithmeticD(Token::Value op, LOperand* left, LOperand* right)
1507 LOperand* left() { return inputs_[0]; }
1508 LOperand* right() { return inputs_[1]; }
1510 Token::Value op() const { return op_; }
1512 Opcode opcode() const override { return LInstruction::kArithmeticD; }
1513 void CompileToNative(LCodeGen* generator) override;
1514 const char* Mnemonic() const override;
1521 class LArithmeticT final : public LTemplateInstruction<1, 3, 0> {
1523 LArithmeticT(Token::Value op,
1528 inputs_[0] = context;
1533 LOperand* context() { return inputs_[0]; }
1534 LOperand* left() { return inputs_[1]; }
1535 LOperand* right() { return inputs_[2]; }
1536 Token::Value op() const { return op_; }
1538 Opcode opcode() const override { return LInstruction::kArithmeticT; }
1539 void CompileToNative(LCodeGen* generator) override;
1540 const char* Mnemonic() const override;
1542 DECLARE_HYDROGEN_ACCESSOR(BinaryOperation)
1544 Strength strength() { return hydrogen()->strength(); }
1551 class LReturn final : public LTemplateInstruction<0, 3, 0> {
1553 explicit LReturn(LOperand* value,
1555 LOperand* parameter_count) {
1557 inputs_[1] = context;
1558 inputs_[2] = parameter_count;
1561 bool has_constant_parameter_count() {
1562 return parameter_count()->IsConstantOperand();
1564 LConstantOperand* constant_parameter_count() {
1565 DCHECK(has_constant_parameter_count());
1566 return LConstantOperand::cast(parameter_count());
1568 LOperand* parameter_count() { return inputs_[2]; }
1570 DECLARE_CONCRETE_INSTRUCTION(Return, "return")
1571 DECLARE_HYDROGEN_ACCESSOR(Return)
1575 class LLoadNamedField final : public LTemplateInstruction<1, 1, 0> {
1577 explicit LLoadNamedField(LOperand* object) {
1578 inputs_[0] = object;
1581 LOperand* object() { return inputs_[0]; }
1583 DECLARE_CONCRETE_INSTRUCTION(LoadNamedField, "load-named-field")
1584 DECLARE_HYDROGEN_ACCESSOR(LoadNamedField)
1588 class LLoadNamedGeneric final : public LTemplateInstruction<1, 2, 1> {
1590 LLoadNamedGeneric(LOperand* context, LOperand* object, LOperand* vector) {
1591 inputs_[0] = context;
1592 inputs_[1] = object;
1596 LOperand* context() { return inputs_[0]; }
1597 LOperand* object() { return inputs_[1]; }
1598 LOperand* temp_vector() { return temps_[0]; }
1600 DECLARE_CONCRETE_INSTRUCTION(LoadNamedGeneric, "load-named-generic")
1601 DECLARE_HYDROGEN_ACCESSOR(LoadNamedGeneric)
1603 Handle<Object> name() const { return hydrogen()->name(); }
1607 class LLoadFunctionPrototype final : public LTemplateInstruction<1, 1, 1> {
1609 LLoadFunctionPrototype(LOperand* function, LOperand* temp) {
1610 inputs_[0] = function;
1614 LOperand* function() { return inputs_[0]; }
1615 LOperand* temp() { return temps_[0]; }
1617 DECLARE_CONCRETE_INSTRUCTION(LoadFunctionPrototype, "load-function-prototype")
1618 DECLARE_HYDROGEN_ACCESSOR(LoadFunctionPrototype)
1622 class LLoadRoot final : public LTemplateInstruction<1, 0, 0> {
1624 DECLARE_CONCRETE_INSTRUCTION(LoadRoot, "load-root")
1625 DECLARE_HYDROGEN_ACCESSOR(LoadRoot)
1627 Heap::RootListIndex index() const { return hydrogen()->index(); }
1631 class LLoadKeyed final : public LTemplateInstruction<1, 2, 0> {
1633 LLoadKeyed(LOperand* elements, LOperand* key) {
1634 inputs_[0] = elements;
1637 LOperand* elements() { return inputs_[0]; }
1638 LOperand* key() { return inputs_[1]; }
1639 ElementsKind elements_kind() const {
1640 return hydrogen()->elements_kind();
1642 bool is_external() const {
1643 return hydrogen()->is_external();
1645 bool is_fixed_typed_array() const {
1646 return hydrogen()->is_fixed_typed_array();
1648 bool is_typed_elements() const {
1649 return is_external() || is_fixed_typed_array();
1652 DECLARE_CONCRETE_INSTRUCTION(LoadKeyed, "load-keyed")
1653 DECLARE_HYDROGEN_ACCESSOR(LoadKeyed)
1655 void PrintDataTo(StringStream* stream) override;
1656 uint32_t base_offset() const { return hydrogen()->base_offset(); }
1658 return hydrogen()->key()->representation().IsTagged();
1663 inline static bool ExternalArrayOpRequiresTemp(
1664 Representation key_representation,
1665 ElementsKind elements_kind) {
1666 // Operations that require the key to be divided by two to be converted into
1667 // an index cannot fold the scale operation into a load and need an extra
1668 // temp register to do the work.
1669 return key_representation.IsSmi() &&
1670 (elements_kind == EXTERNAL_INT8_ELEMENTS ||
1671 elements_kind == EXTERNAL_UINT8_ELEMENTS ||
1672 elements_kind == EXTERNAL_UINT8_CLAMPED_ELEMENTS ||
1673 elements_kind == UINT8_ELEMENTS ||
1674 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 bool for_typeof() const { return hydrogen()->for_typeof(); }
1720 class LLoadContextSlot final : public LTemplateInstruction<1, 1, 0> {
1722 explicit LLoadContextSlot(LOperand* context) {
1723 inputs_[0] = context;
1726 LOperand* context() { return inputs_[0]; }
1728 DECLARE_CONCRETE_INSTRUCTION(LoadContextSlot, "load-context-slot")
1729 DECLARE_HYDROGEN_ACCESSOR(LoadContextSlot)
1731 int slot_index() { return hydrogen()->slot_index(); }
1733 void PrintDataTo(StringStream* stream) override;
1737 class LStoreContextSlot final : public LTemplateInstruction<0, 2, 1> {
1739 LStoreContextSlot(LOperand* context, LOperand* value, LOperand* temp) {
1740 inputs_[0] = context;
1745 LOperand* context() { return inputs_[0]; }
1746 LOperand* value() { return inputs_[1]; }
1747 LOperand* temp() { return temps_[0]; }
1749 DECLARE_CONCRETE_INSTRUCTION(StoreContextSlot, "store-context-slot")
1750 DECLARE_HYDROGEN_ACCESSOR(StoreContextSlot)
1752 int slot_index() { return hydrogen()->slot_index(); }
1754 void PrintDataTo(StringStream* stream) override;
1758 class LPushArgument final : public LTemplateInstruction<0, 1, 0> {
1760 explicit LPushArgument(LOperand* value) {
1764 LOperand* value() { return inputs_[0]; }
1766 DECLARE_CONCRETE_INSTRUCTION(PushArgument, "push-argument")
1770 class LDrop final : public LTemplateInstruction<0, 0, 0> {
1772 explicit LDrop(int count) : count_(count) { }
1774 int count() const { return count_; }
1776 DECLARE_CONCRETE_INSTRUCTION(Drop, "drop")
1783 class LStoreCodeEntry final : public LTemplateInstruction<0, 2, 0> {
1785 LStoreCodeEntry(LOperand* function, LOperand* code_object) {
1786 inputs_[0] = function;
1787 inputs_[1] = code_object;
1790 LOperand* function() { return inputs_[0]; }
1791 LOperand* code_object() { return inputs_[1]; }
1793 void PrintDataTo(StringStream* stream) override;
1795 DECLARE_CONCRETE_INSTRUCTION(StoreCodeEntry, "store-code-entry")
1796 DECLARE_HYDROGEN_ACCESSOR(StoreCodeEntry)
1800 class LInnerAllocatedObject final : public LTemplateInstruction<1, 2, 0> {
1802 LInnerAllocatedObject(LOperand* base_object, LOperand* offset) {
1803 inputs_[0] = base_object;
1804 inputs_[1] = offset;
1807 LOperand* base_object() const { return inputs_[0]; }
1808 LOperand* offset() const { return inputs_[1]; }
1810 void PrintDataTo(StringStream* stream) override;
1812 DECLARE_CONCRETE_INSTRUCTION(InnerAllocatedObject, "inner-allocated-object")
1816 class LThisFunction final : public LTemplateInstruction<1, 0, 0> {
1818 DECLARE_CONCRETE_INSTRUCTION(ThisFunction, "this-function")
1819 DECLARE_HYDROGEN_ACCESSOR(ThisFunction)
1823 class LContext final : public LTemplateInstruction<1, 0, 0> {
1825 DECLARE_CONCRETE_INSTRUCTION(Context, "context")
1826 DECLARE_HYDROGEN_ACCESSOR(Context)
1830 class LDeclareGlobals final : public LTemplateInstruction<0, 1, 0> {
1832 explicit LDeclareGlobals(LOperand* context) {
1833 inputs_[0] = context;
1836 LOperand* context() { return inputs_[0]; }
1838 DECLARE_CONCRETE_INSTRUCTION(DeclareGlobals, "declare-globals")
1839 DECLARE_HYDROGEN_ACCESSOR(DeclareGlobals)
1843 class LCallJSFunction final : public LTemplateInstruction<1, 1, 0> {
1845 explicit LCallJSFunction(LOperand* function) {
1846 inputs_[0] = function;
1849 LOperand* function() { return inputs_[0]; }
1851 DECLARE_CONCRETE_INSTRUCTION(CallJSFunction, "call-js-function")
1852 DECLARE_HYDROGEN_ACCESSOR(CallJSFunction)
1854 void PrintDataTo(StringStream* stream) override;
1856 int arity() const { return hydrogen()->argument_count() - 1; }
1860 class LCallWithDescriptor final : public LTemplateResultInstruction<1> {
1862 LCallWithDescriptor(CallInterfaceDescriptor descriptor,
1863 const ZoneList<LOperand*>& operands, Zone* zone)
1864 : inputs_(descriptor.GetRegisterParameterCount() + 1, zone) {
1865 DCHECK(descriptor.GetRegisterParameterCount() + 1 == operands.length());
1866 inputs_.AddAll(operands, zone);
1869 LOperand* target() const { return inputs_[0]; }
1871 DECLARE_HYDROGEN_ACCESSOR(CallWithDescriptor)
1874 DECLARE_CONCRETE_INSTRUCTION(CallWithDescriptor, "call-with-descriptor")
1876 void PrintDataTo(StringStream* stream) override;
1878 int arity() const { return hydrogen()->argument_count() - 1; }
1880 ZoneList<LOperand*> inputs_;
1882 // Iterator support.
1883 int InputCount() final { return inputs_.length(); }
1884 LOperand* InputAt(int i) final { return inputs_[i]; }
1886 int TempCount() final { return 0; }
1887 LOperand* TempAt(int i) final { return NULL; }
1891 class LInvokeFunction final : public LTemplateInstruction<1, 2, 0> {
1893 LInvokeFunction(LOperand* context, LOperand* function) {
1894 inputs_[0] = context;
1895 inputs_[1] = function;
1898 LOperand* context() { return inputs_[0]; }
1899 LOperand* function() { return inputs_[1]; }
1901 DECLARE_CONCRETE_INSTRUCTION(InvokeFunction, "invoke-function")
1902 DECLARE_HYDROGEN_ACCESSOR(InvokeFunction)
1904 void PrintDataTo(StringStream* stream) override;
1906 int arity() const { return hydrogen()->argument_count() - 1; }
1910 class LCallFunction final : public LTemplateInstruction<1, 2, 2> {
1912 LCallFunction(LOperand* context, LOperand* function, LOperand* slot,
1914 inputs_[0] = context;
1915 inputs_[1] = function;
1920 LOperand* context() { return inputs_[0]; }
1921 LOperand* function() { return inputs_[1]; }
1922 LOperand* temp_slot() { return temps_[0]; }
1923 LOperand* temp_vector() { return temps_[1]; }
1925 DECLARE_CONCRETE_INSTRUCTION(CallFunction, "call-function")
1926 DECLARE_HYDROGEN_ACCESSOR(CallFunction)
1928 void PrintDataTo(StringStream* stream) override;
1929 int arity() const { return hydrogen()->argument_count() - 1; }
1933 class LCallNew final : public LTemplateInstruction<1, 2, 0> {
1935 LCallNew(LOperand* context, LOperand* constructor) {
1936 inputs_[0] = context;
1937 inputs_[1] = constructor;
1940 LOperand* context() { return inputs_[0]; }
1941 LOperand* constructor() { return inputs_[1]; }
1943 DECLARE_CONCRETE_INSTRUCTION(CallNew, "call-new")
1944 DECLARE_HYDROGEN_ACCESSOR(CallNew)
1946 void PrintDataTo(StringStream* stream) override;
1948 int arity() const { return hydrogen()->argument_count() - 1; }
1952 class LCallNewArray final : public LTemplateInstruction<1, 2, 0> {
1954 LCallNewArray(LOperand* context, LOperand* constructor) {
1955 inputs_[0] = context;
1956 inputs_[1] = constructor;
1959 LOperand* context() { return inputs_[0]; }
1960 LOperand* constructor() { return inputs_[1]; }
1962 DECLARE_CONCRETE_INSTRUCTION(CallNewArray, "call-new-array")
1963 DECLARE_HYDROGEN_ACCESSOR(CallNewArray)
1965 void PrintDataTo(StringStream* stream) override;
1967 int arity() const { return hydrogen()->argument_count() - 1; }
1971 class LCallRuntime final : public LTemplateInstruction<1, 1, 0> {
1973 explicit LCallRuntime(LOperand* context) {
1974 inputs_[0] = context;
1977 LOperand* context() { return inputs_[0]; }
1979 DECLARE_CONCRETE_INSTRUCTION(CallRuntime, "call-runtime")
1980 DECLARE_HYDROGEN_ACCESSOR(CallRuntime)
1982 bool ClobbersDoubleRegisters(Isolate* isolate) const override {
1983 return save_doubles() == kDontSaveFPRegs;
1986 const Runtime::Function* function() const { return hydrogen()->function(); }
1987 int arity() const { return hydrogen()->argument_count(); }
1988 SaveFPRegsMode save_doubles() const { return hydrogen()->save_doubles(); }
1992 class LInteger32ToDouble final : public LTemplateInstruction<1, 1, 0> {
1994 explicit LInteger32ToDouble(LOperand* value) {
1998 LOperand* value() { return inputs_[0]; }
2000 DECLARE_CONCRETE_INSTRUCTION(Integer32ToDouble, "int32-to-double")
2004 class LUint32ToDouble final : public LTemplateInstruction<1, 1, 0> {
2006 explicit LUint32ToDouble(LOperand* value) {
2010 LOperand* value() { return inputs_[0]; }
2012 DECLARE_CONCRETE_INSTRUCTION(Uint32ToDouble, "uint32-to-double")
2016 class LNumberTagI final : public LTemplateInstruction<1, 1, 1> {
2018 LNumberTagI(LOperand* value, LOperand* temp) {
2023 LOperand* value() { return inputs_[0]; }
2024 LOperand* temp() { return temps_[0]; }
2026 DECLARE_CONCRETE_INSTRUCTION(NumberTagI, "number-tag-i")
2030 class LNumberTagU final : public LTemplateInstruction<1, 1, 1> {
2032 LNumberTagU(LOperand* value, LOperand* temp) {
2037 LOperand* value() { return inputs_[0]; }
2038 LOperand* temp() { return temps_[0]; }
2040 DECLARE_CONCRETE_INSTRUCTION(NumberTagU, "number-tag-u")
2044 class LNumberTagD final : public LTemplateInstruction<1, 1, 1> {
2046 LNumberTagD(LOperand* value, LOperand* temp) {
2051 LOperand* value() { return inputs_[0]; }
2052 LOperand* temp() { return temps_[0]; }
2054 DECLARE_CONCRETE_INSTRUCTION(NumberTagD, "number-tag-d")
2055 DECLARE_HYDROGEN_ACCESSOR(Change)
2059 // Sometimes truncating conversion from a tagged value to an int32.
2060 class LDoubleToI final : public LTemplateInstruction<1, 1, 1> {
2062 LDoubleToI(LOperand* value, LOperand* temp) {
2067 LOperand* value() { return inputs_[0]; }
2068 LOperand* temp() { return temps_[0]; }
2070 DECLARE_CONCRETE_INSTRUCTION(DoubleToI, "double-to-i")
2071 DECLARE_HYDROGEN_ACCESSOR(UnaryOperation)
2073 bool truncating() { return hydrogen()->CanTruncateToInt32(); }
2077 class LDoubleToSmi final : public LTemplateInstruction<1, 1, 0> {
2079 explicit LDoubleToSmi(LOperand* value) {
2083 LOperand* value() { return inputs_[0]; }
2085 DECLARE_CONCRETE_INSTRUCTION(DoubleToSmi, "double-to-smi")
2086 DECLARE_HYDROGEN_ACCESSOR(UnaryOperation)
2090 // Truncating conversion from a tagged value to an int32.
2091 class LTaggedToI final : public LTemplateInstruction<1, 1, 1> {
2093 LTaggedToI(LOperand* value, LOperand* temp) {
2098 LOperand* value() { return inputs_[0]; }
2099 LOperand* temp() { return temps_[0]; }
2101 DECLARE_CONCRETE_INSTRUCTION(TaggedToI, "tagged-to-i")
2102 DECLARE_HYDROGEN_ACCESSOR(Change)
2104 bool truncating() { return hydrogen()->CanTruncateToInt32(); }
2108 class LSmiTag final : public LTemplateInstruction<1, 1, 0> {
2110 explicit LSmiTag(LOperand* value) {
2114 LOperand* value() { return inputs_[0]; }
2116 DECLARE_CONCRETE_INSTRUCTION(SmiTag, "smi-tag")
2117 DECLARE_HYDROGEN_ACCESSOR(Change)
2121 class LNumberUntagD final : public LTemplateInstruction<1, 1, 1> {
2123 explicit LNumberUntagD(LOperand* value, LOperand* temp) {
2128 LOperand* value() { return inputs_[0]; }
2129 LOperand* temp() { return temps_[0]; }
2131 DECLARE_CONCRETE_INSTRUCTION(NumberUntagD, "double-untag")
2132 DECLARE_HYDROGEN_ACCESSOR(Change);
2136 class LSmiUntag final : public LTemplateInstruction<1, 1, 0> {
2138 LSmiUntag(LOperand* value, bool needs_check)
2139 : needs_check_(needs_check) {
2143 LOperand* value() { return inputs_[0]; }
2145 DECLARE_CONCRETE_INSTRUCTION(SmiUntag, "smi-untag")
2147 bool needs_check() const { return needs_check_; }
2154 class LStoreNamedField final : public LTemplateInstruction<0, 2, 2> {
2156 LStoreNamedField(LOperand* obj,
2159 LOperand* temp_map) {
2163 temps_[1] = temp_map;
2166 LOperand* object() { return inputs_[0]; }
2167 LOperand* value() { return inputs_[1]; }
2168 LOperand* temp() { return temps_[0]; }
2169 LOperand* temp_map() { return temps_[1]; }
2171 DECLARE_CONCRETE_INSTRUCTION(StoreNamedField, "store-named-field")
2172 DECLARE_HYDROGEN_ACCESSOR(StoreNamedField)
2174 void PrintDataTo(StringStream* stream) override;
2178 class LStoreNamedGeneric final : public LTemplateInstruction<0, 3, 0> {
2180 LStoreNamedGeneric(LOperand* context, LOperand* object, LOperand* value) {
2181 inputs_[0] = context;
2182 inputs_[1] = object;
2186 LOperand* context() { return inputs_[0]; }
2187 LOperand* object() { return inputs_[1]; }
2188 LOperand* value() { return inputs_[2]; }
2190 DECLARE_CONCRETE_INSTRUCTION(StoreNamedGeneric, "store-named-generic")
2191 DECLARE_HYDROGEN_ACCESSOR(StoreNamedGeneric)
2193 void PrintDataTo(StringStream* stream) override;
2194 Handle<Object> name() const { return hydrogen()->name(); }
2195 LanguageMode language_mode() { return hydrogen()->language_mode(); }
2199 class LStoreKeyed final : public LTemplateInstruction<0, 3, 0> {
2201 LStoreKeyed(LOperand* obj, LOperand* key, LOperand* val) {
2207 bool is_external() const { return hydrogen()->is_external(); }
2208 bool is_fixed_typed_array() const {
2209 return hydrogen()->is_fixed_typed_array();
2211 bool is_typed_elements() const {
2212 return is_external() || is_fixed_typed_array();
2214 LOperand* elements() { return inputs_[0]; }
2215 LOperand* key() { return inputs_[1]; }
2216 LOperand* value() { return inputs_[2]; }
2217 ElementsKind elements_kind() const {
2218 return hydrogen()->elements_kind();
2221 DECLARE_CONCRETE_INSTRUCTION(StoreKeyed, "store-keyed")
2222 DECLARE_HYDROGEN_ACCESSOR(StoreKeyed)
2224 void PrintDataTo(StringStream* stream) override;
2225 uint32_t base_offset() const { return hydrogen()->base_offset(); }
2226 bool NeedsCanonicalization() { return hydrogen()->NeedsCanonicalization(); }
2230 class LStoreKeyedGeneric final : public LTemplateInstruction<0, 4, 0> {
2232 LStoreKeyedGeneric(LOperand* context,
2236 inputs_[0] = context;
2237 inputs_[1] = object;
2242 LOperand* context() { return inputs_[0]; }
2243 LOperand* object() { return inputs_[1]; }
2244 LOperand* key() { return inputs_[2]; }
2245 LOperand* value() { return inputs_[3]; }
2247 DECLARE_CONCRETE_INSTRUCTION(StoreKeyedGeneric, "store-keyed-generic")
2248 DECLARE_HYDROGEN_ACCESSOR(StoreKeyedGeneric)
2250 void PrintDataTo(StringStream* stream) override;
2252 LanguageMode language_mode() { return hydrogen()->language_mode(); }
2256 class LTransitionElementsKind final : public LTemplateInstruction<0, 2, 2> {
2258 LTransitionElementsKind(LOperand* object,
2260 LOperand* new_map_temp,
2262 inputs_[0] = object;
2263 inputs_[1] = context;
2264 temps_[0] = new_map_temp;
2268 LOperand* context() { return inputs_[1]; }
2269 LOperand* object() { return inputs_[0]; }
2270 LOperand* new_map_temp() { return temps_[0]; }
2271 LOperand* temp() { return temps_[1]; }
2273 DECLARE_CONCRETE_INSTRUCTION(TransitionElementsKind,
2274 "transition-elements-kind")
2275 DECLARE_HYDROGEN_ACCESSOR(TransitionElementsKind)
2277 void PrintDataTo(StringStream* stream) override;
2279 Handle<Map> original_map() { return hydrogen()->original_map().handle(); }
2280 Handle<Map> transitioned_map() {
2281 return hydrogen()->transitioned_map().handle();
2283 ElementsKind from_kind() { return hydrogen()->from_kind(); }
2284 ElementsKind to_kind() { return hydrogen()->to_kind(); }
2288 class LTrapAllocationMemento final : public LTemplateInstruction<0, 1, 1> {
2290 LTrapAllocationMemento(LOperand* object,
2292 inputs_[0] = object;
2296 LOperand* object() { return inputs_[0]; }
2297 LOperand* temp() { return temps_[0]; }
2299 DECLARE_CONCRETE_INSTRUCTION(TrapAllocationMemento,
2300 "trap-allocation-memento")
2304 class LMaybeGrowElements final : public LTemplateInstruction<1, 5, 0> {
2306 LMaybeGrowElements(LOperand* context, LOperand* object, LOperand* elements,
2307 LOperand* key, LOperand* current_capacity) {
2308 inputs_[0] = context;
2309 inputs_[1] = object;
2310 inputs_[2] = elements;
2312 inputs_[4] = current_capacity;
2315 LOperand* context() { return inputs_[0]; }
2316 LOperand* object() { return inputs_[1]; }
2317 LOperand* elements() { return inputs_[2]; }
2318 LOperand* key() { return inputs_[3]; }
2319 LOperand* current_capacity() { return inputs_[4]; }
2321 DECLARE_HYDROGEN_ACCESSOR(MaybeGrowElements)
2322 DECLARE_CONCRETE_INSTRUCTION(MaybeGrowElements, "maybe-grow-elements")
2326 class LStringAdd final : public LTemplateInstruction<1, 3, 0> {
2328 LStringAdd(LOperand* context, LOperand* left, LOperand* right) {
2329 inputs_[0] = context;
2334 LOperand* context() { return inputs_[0]; }
2335 LOperand* left() { return inputs_[1]; }
2336 LOperand* right() { return inputs_[2]; }
2338 DECLARE_CONCRETE_INSTRUCTION(StringAdd, "string-add")
2339 DECLARE_HYDROGEN_ACCESSOR(StringAdd)
2343 class LStringCharCodeAt final : public LTemplateInstruction<1, 3, 0> {
2345 LStringCharCodeAt(LOperand* context, LOperand* string, LOperand* index) {
2346 inputs_[0] = context;
2347 inputs_[1] = string;
2351 LOperand* context() { return inputs_[0]; }
2352 LOperand* string() { return inputs_[1]; }
2353 LOperand* index() { return inputs_[2]; }
2355 DECLARE_CONCRETE_INSTRUCTION(StringCharCodeAt, "string-char-code-at")
2356 DECLARE_HYDROGEN_ACCESSOR(StringCharCodeAt)
2360 class LStringCharFromCode final : public LTemplateInstruction<1, 2, 0> {
2362 LStringCharFromCode(LOperand* context, LOperand* char_code) {
2363 inputs_[0] = context;
2364 inputs_[1] = char_code;
2367 LOperand* context() { return inputs_[0]; }
2368 LOperand* char_code() { return inputs_[1]; }
2370 DECLARE_CONCRETE_INSTRUCTION(StringCharFromCode, "string-char-from-code")
2371 DECLARE_HYDROGEN_ACCESSOR(StringCharFromCode)
2375 class LCheckValue final : public LTemplateInstruction<0, 1, 0> {
2377 explicit LCheckValue(LOperand* value) {
2381 LOperand* value() { return inputs_[0]; }
2383 DECLARE_CONCRETE_INSTRUCTION(CheckValue, "check-value")
2384 DECLARE_HYDROGEN_ACCESSOR(CheckValue)
2388 class LCheckArrayBufferNotNeutered final
2389 : public LTemplateInstruction<0, 1, 1> {
2391 explicit LCheckArrayBufferNotNeutered(LOperand* view, LOperand* scratch) {
2393 temps_[0] = scratch;
2396 LOperand* view() { return inputs_[0]; }
2397 LOperand* scratch() { return temps_[0]; }
2399 DECLARE_CONCRETE_INSTRUCTION(CheckArrayBufferNotNeutered,
2400 "check-array-buffer-not-neutered")
2401 DECLARE_HYDROGEN_ACCESSOR(CheckArrayBufferNotNeutered)
2405 class LCheckInstanceType final : public LTemplateInstruction<0, 1, 1> {
2407 LCheckInstanceType(LOperand* value, LOperand* temp) {
2412 LOperand* value() { return inputs_[0]; }
2413 LOperand* temp() { return temps_[0]; }
2415 DECLARE_CONCRETE_INSTRUCTION(CheckInstanceType, "check-instance-type")
2416 DECLARE_HYDROGEN_ACCESSOR(CheckInstanceType)
2420 class LCheckMaps final : public LTemplateInstruction<0, 1, 0> {
2422 explicit LCheckMaps(LOperand* value = NULL) {
2426 LOperand* value() { return inputs_[0]; }
2428 DECLARE_CONCRETE_INSTRUCTION(CheckMaps, "check-maps")
2429 DECLARE_HYDROGEN_ACCESSOR(CheckMaps)
2433 class LCheckSmi final : public LTemplateInstruction<1, 1, 0> {
2435 explicit LCheckSmi(LOperand* value) {
2439 LOperand* value() { return inputs_[0]; }
2441 DECLARE_CONCRETE_INSTRUCTION(CheckSmi, "check-smi")
2445 class LClampDToUint8 final : public LTemplateInstruction<1, 1, 0> {
2447 explicit LClampDToUint8(LOperand* value) {
2451 LOperand* unclamped() { return inputs_[0]; }
2453 DECLARE_CONCRETE_INSTRUCTION(ClampDToUint8, "clamp-d-to-uint8")
2457 class LClampIToUint8 final : public LTemplateInstruction<1, 1, 0> {
2459 explicit LClampIToUint8(LOperand* value) {
2463 LOperand* unclamped() { return inputs_[0]; }
2465 DECLARE_CONCRETE_INSTRUCTION(ClampIToUint8, "clamp-i-to-uint8")
2469 class LClampTToUint8 final : public LTemplateInstruction<1, 1, 1> {
2471 LClampTToUint8(LOperand* value, LOperand* temp_xmm) {
2473 temps_[0] = temp_xmm;
2476 LOperand* unclamped() { return inputs_[0]; }
2477 LOperand* temp_xmm() { return temps_[0]; }
2479 DECLARE_CONCRETE_INSTRUCTION(ClampTToUint8, "clamp-t-to-uint8")
2483 class LCheckNonSmi final : public LTemplateInstruction<0, 1, 0> {
2485 explicit LCheckNonSmi(LOperand* value) {
2489 LOperand* value() { return inputs_[0]; }
2491 DECLARE_CONCRETE_INSTRUCTION(CheckNonSmi, "check-non-smi")
2492 DECLARE_HYDROGEN_ACCESSOR(CheckHeapObject)
2496 class LDoubleBits final : public LTemplateInstruction<1, 1, 0> {
2498 explicit LDoubleBits(LOperand* value) {
2502 LOperand* value() { return inputs_[0]; }
2504 DECLARE_CONCRETE_INSTRUCTION(DoubleBits, "double-bits")
2505 DECLARE_HYDROGEN_ACCESSOR(DoubleBits)
2509 class LConstructDouble final : public LTemplateInstruction<1, 2, 0> {
2511 LConstructDouble(LOperand* hi, LOperand* lo) {
2516 LOperand* hi() { return inputs_[0]; }
2517 LOperand* lo() { return inputs_[1]; }
2519 DECLARE_CONCRETE_INSTRUCTION(ConstructDouble, "construct-double")
2523 class LAllocate final : public LTemplateInstruction<1, 2, 1> {
2525 LAllocate(LOperand* context, LOperand* size, LOperand* temp) {
2526 inputs_[0] = context;
2531 LOperand* context() { return inputs_[0]; }
2532 LOperand* size() { return inputs_[1]; }
2533 LOperand* temp() { return temps_[0]; }
2535 DECLARE_CONCRETE_INSTRUCTION(Allocate, "allocate")
2536 DECLARE_HYDROGEN_ACCESSOR(Allocate)
2540 class LRegExpLiteral final : public LTemplateInstruction<1, 1, 0> {
2542 explicit LRegExpLiteral(LOperand* context) {
2543 inputs_[0] = context;
2546 LOperand* context() { return inputs_[0]; }
2548 DECLARE_CONCRETE_INSTRUCTION(RegExpLiteral, "regexp-literal")
2549 DECLARE_HYDROGEN_ACCESSOR(RegExpLiteral)
2553 class LFunctionLiteral final : public LTemplateInstruction<1, 1, 0> {
2555 explicit LFunctionLiteral(LOperand* context) {
2556 inputs_[0] = context;
2559 LOperand* context() { return inputs_[0]; }
2561 DECLARE_CONCRETE_INSTRUCTION(FunctionLiteral, "function-literal")
2562 DECLARE_HYDROGEN_ACCESSOR(FunctionLiteral)
2566 class LToFastProperties final : public LTemplateInstruction<1, 1, 0> {
2568 explicit LToFastProperties(LOperand* value) {
2572 LOperand* value() { return inputs_[0]; }
2574 DECLARE_CONCRETE_INSTRUCTION(ToFastProperties, "to-fast-properties")
2575 DECLARE_HYDROGEN_ACCESSOR(ToFastProperties)
2579 class LTypeof final : public LTemplateInstruction<1, 2, 0> {
2581 LTypeof(LOperand* context, LOperand* value) {
2582 inputs_[0] = context;
2586 LOperand* context() { return inputs_[0]; }
2587 LOperand* value() { return inputs_[1]; }
2589 DECLARE_CONCRETE_INSTRUCTION(Typeof, "typeof")
2593 class LTypeofIsAndBranch final : public LControlInstruction<1, 0> {
2595 explicit LTypeofIsAndBranch(LOperand* value) {
2599 LOperand* value() { return inputs_[0]; }
2601 DECLARE_CONCRETE_INSTRUCTION(TypeofIsAndBranch, "typeof-is-and-branch")
2602 DECLARE_HYDROGEN_ACCESSOR(TypeofIsAndBranch)
2604 Handle<String> type_literal() { return hydrogen()->type_literal(); }
2606 void PrintDataTo(StringStream* stream) override;
2610 class LOsrEntry final : public LTemplateInstruction<0, 0, 0> {
2612 bool HasInterestingComment(LCodeGen* gen) const override { return false; }
2613 DECLARE_CONCRETE_INSTRUCTION(OsrEntry, "osr-entry")
2617 class LStackCheck final : public LTemplateInstruction<0, 1, 0> {
2619 explicit LStackCheck(LOperand* context) {
2620 inputs_[0] = context;
2623 LOperand* context() { return inputs_[0]; }
2625 DECLARE_CONCRETE_INSTRUCTION(StackCheck, "stack-check")
2626 DECLARE_HYDROGEN_ACCESSOR(StackCheck)
2628 Label* done_label() { return &done_label_; }
2635 class LForInPrepareMap final : public LTemplateInstruction<1, 2, 0> {
2637 LForInPrepareMap(LOperand* context, LOperand* object) {
2638 inputs_[0] = context;
2639 inputs_[1] = object;
2642 LOperand* context() { return inputs_[0]; }
2643 LOperand* object() { return inputs_[1]; }
2645 DECLARE_CONCRETE_INSTRUCTION(ForInPrepareMap, "for-in-prepare-map")
2649 class LForInCacheArray final : public LTemplateInstruction<1, 1, 0> {
2651 explicit LForInCacheArray(LOperand* map) {
2655 LOperand* map() { return inputs_[0]; }
2657 DECLARE_CONCRETE_INSTRUCTION(ForInCacheArray, "for-in-cache-array")
2660 return HForInCacheArray::cast(this->hydrogen_value())->idx();
2665 class LCheckMapValue final : public LTemplateInstruction<0, 2, 0> {
2667 LCheckMapValue(LOperand* value, LOperand* map) {
2672 LOperand* value() { return inputs_[0]; }
2673 LOperand* map() { return inputs_[1]; }
2675 DECLARE_CONCRETE_INSTRUCTION(CheckMapValue, "check-map-value")
2679 class LLoadFieldByIndex final : public LTemplateInstruction<1, 2, 0> {
2681 LLoadFieldByIndex(LOperand* object, LOperand* index) {
2682 inputs_[0] = object;
2686 LOperand* object() { return inputs_[0]; }
2687 LOperand* index() { return inputs_[1]; }
2689 DECLARE_CONCRETE_INSTRUCTION(LoadFieldByIndex, "load-field-by-index")
2693 class LStoreFrameContext: public LTemplateInstruction<0, 1, 0> {
2695 explicit LStoreFrameContext(LOperand* context) {
2696 inputs_[0] = context;
2699 LOperand* context() { return inputs_[0]; }
2701 DECLARE_CONCRETE_INSTRUCTION(StoreFrameContext, "store-frame-context")
2705 class LAllocateBlockContext: public LTemplateInstruction<1, 2, 0> {
2707 LAllocateBlockContext(LOperand* context, LOperand* function) {
2708 inputs_[0] = context;
2709 inputs_[1] = function;
2712 LOperand* context() { return inputs_[0]; }
2713 LOperand* function() { return inputs_[1]; }
2715 Handle<ScopeInfo> scope_info() { return hydrogen()->scope_info(); }
2717 DECLARE_CONCRETE_INSTRUCTION(AllocateBlockContext, "allocate-block-context")
2718 DECLARE_HYDROGEN_ACCESSOR(AllocateBlockContext)
2722 class LChunkBuilder;
2723 class LPlatformChunk final : public LChunk {
2725 LPlatformChunk(CompilationInfo* info, HGraph* graph)
2726 : LChunk(info, graph),
2727 num_double_slots_(0) { }
2729 int GetNextSpillIndex(RegisterKind kind);
2730 LOperand* GetNextSpillSlot(RegisterKind kind);
2732 int num_double_slots() const { return num_double_slots_; }
2735 int num_double_slots_;
2739 class LChunkBuilder final : public LChunkBuilderBase {
2741 LChunkBuilder(CompilationInfo* info, HGraph* graph, LAllocator* allocator)
2742 : LChunkBuilderBase(info, graph),
2743 current_instruction_(NULL),
2744 current_block_(NULL),
2746 allocator_(allocator) {}
2748 // Build the sequence for the graph.
2749 LPlatformChunk* Build();
2751 // Declare methods that deal with the individual node types.
2752 #define DECLARE_DO(type) LInstruction* Do##type(H##type* node);
2753 HYDROGEN_CONCRETE_INSTRUCTION_LIST(DECLARE_DO)
2756 LInstruction* DoMathFloor(HUnaryMathOperation* instr);
2757 LInstruction* DoMathRound(HUnaryMathOperation* instr);
2758 LInstruction* DoMathFround(HUnaryMathOperation* instr);
2759 LInstruction* DoMathAbs(HUnaryMathOperation* instr);
2760 LInstruction* DoMathLog(HUnaryMathOperation* instr);
2761 LInstruction* DoMathExp(HUnaryMathOperation* instr);
2762 LInstruction* DoMathSqrt(HUnaryMathOperation* instr);
2763 LInstruction* DoMathPowHalf(HUnaryMathOperation* instr);
2764 LInstruction* DoMathClz32(HUnaryMathOperation* instr);
2765 LInstruction* DoDivByPowerOf2I(HDiv* instr);
2766 LInstruction* DoDivByConstI(HDiv* instr);
2767 LInstruction* DoDivI(HDiv* instr);
2768 LInstruction* DoModByPowerOf2I(HMod* instr);
2769 LInstruction* DoModByConstI(HMod* instr);
2770 LInstruction* DoModI(HMod* instr);
2771 LInstruction* DoFlooringDivByPowerOf2I(HMathFloorOfDiv* instr);
2772 LInstruction* DoFlooringDivByConstI(HMathFloorOfDiv* instr);
2773 LInstruction* DoFlooringDivI(HMathFloorOfDiv* instr);
2776 // Methods for getting operands for Use / Define / Temp.
2777 LUnallocated* ToUnallocated(Register reg);
2778 LUnallocated* ToUnallocated(XMMRegister reg);
2780 // Methods for setting up define-use relationships.
2781 MUST_USE_RESULT LOperand* Use(HValue* value, LUnallocated* operand);
2782 MUST_USE_RESULT LOperand* UseFixed(HValue* value, Register fixed_register);
2783 MUST_USE_RESULT LOperand* UseFixedDouble(HValue* value,
2784 XMMRegister fixed_register);
2786 // A value that is guaranteed to be allocated to a register.
2787 // Operand created by UseRegister is guaranteed to be live until the end of
2788 // instruction. This means that register allocator will not reuse it's
2789 // register for any other operand inside instruction.
2790 // Operand created by UseRegisterAtStart is guaranteed to be live only at
2791 // instruction start. Register allocator is free to assign the same register
2792 // to some other operand used inside instruction (i.e. temporary or
2794 MUST_USE_RESULT LOperand* UseRegister(HValue* value);
2795 MUST_USE_RESULT LOperand* UseRegisterAtStart(HValue* value);
2797 // An input operand in a register that may be trashed.
2798 MUST_USE_RESULT LOperand* UseTempRegister(HValue* value);
2800 // An input operand in a register or stack slot.
2801 MUST_USE_RESULT LOperand* Use(HValue* value);
2802 MUST_USE_RESULT LOperand* UseAtStart(HValue* value);
2804 // An input operand in a register, stack slot or a constant operand.
2805 MUST_USE_RESULT LOperand* UseOrConstant(HValue* value);
2806 MUST_USE_RESULT LOperand* UseOrConstantAtStart(HValue* value);
2808 // An input operand in a fixed register or a constant operand.
2809 MUST_USE_RESULT LOperand* UseFixedOrConstant(HValue* value,
2810 Register fixed_register);
2812 // An input operand in a register or a constant operand.
2813 MUST_USE_RESULT LOperand* UseRegisterOrConstant(HValue* value);
2814 MUST_USE_RESULT LOperand* UseRegisterOrConstantAtStart(HValue* value);
2816 // An input operand in a constant operand.
2817 MUST_USE_RESULT LOperand* UseConstant(HValue* value);
2819 // An input operand in register, stack slot or a constant operand.
2820 // Will not be moved to a register even if one is freely available.
2821 MUST_USE_RESULT LOperand* UseAny(HValue* value) override;
2823 // Temporary operand that must be in a register.
2824 MUST_USE_RESULT LUnallocated* TempRegister();
2825 MUST_USE_RESULT LOperand* FixedTemp(Register reg);
2826 MUST_USE_RESULT LOperand* FixedTemp(XMMRegister reg);
2828 // Methods for setting up define-use relationships.
2829 // Return the same instruction that they are passed.
2830 LInstruction* Define(LTemplateResultInstruction<1>* instr,
2831 LUnallocated* result);
2832 LInstruction* DefineAsRegister(LTemplateResultInstruction<1>* instr);
2833 LInstruction* DefineAsSpilled(LTemplateResultInstruction<1>* instr,
2835 LInstruction* DefineSameAsFirst(LTemplateResultInstruction<1>* instr);
2836 LInstruction* DefineFixed(LTemplateResultInstruction<1>* instr,
2838 LInstruction* DefineFixedDouble(LTemplateResultInstruction<1>* instr,
2840 // Assigns an environment to an instruction. An instruction which can
2841 // deoptimize must have an environment.
2842 LInstruction* AssignEnvironment(LInstruction* instr);
2843 // Assigns a pointer map to an instruction. An instruction which can
2844 // trigger a GC or a lazy deoptimization must have a pointer map.
2845 LInstruction* AssignPointerMap(LInstruction* instr);
2847 enum CanDeoptimize { CAN_DEOPTIMIZE_EAGERLY, CANNOT_DEOPTIMIZE_EAGERLY };
2849 LOperand* GetSeqStringSetCharOperand(HSeqStringSetChar* instr);
2851 // Marks a call for the register allocator. Assigns a pointer map to
2852 // support GC and lazy deoptimization. Assigns an environment to support
2853 // eager deoptimization if CAN_DEOPTIMIZE_EAGERLY.
2854 LInstruction* MarkAsCall(
2855 LInstruction* instr,
2856 HInstruction* hinstr,
2857 CanDeoptimize can_deoptimize = CANNOT_DEOPTIMIZE_EAGERLY);
2859 void VisitInstruction(HInstruction* current);
2860 void AddInstruction(LInstruction* instr, HInstruction* current);
2862 void DoBasicBlock(HBasicBlock* block, HBasicBlock* next_block);
2863 LInstruction* DoShift(Token::Value op, HBitwiseBinaryOperation* instr);
2864 LInstruction* DoArithmeticD(Token::Value op,
2865 HArithmeticBinaryOperation* instr);
2866 LInstruction* DoArithmeticT(Token::Value op,
2867 HBinaryOperation* instr);
2869 LOperand* GetStoreKeyedValueOperand(HStoreKeyed* instr);
2871 HInstruction* current_instruction_;
2872 HBasicBlock* current_block_;
2873 HBasicBlock* next_block_;
2874 LAllocator* allocator_;
2876 DISALLOW_COPY_AND_ASSIGN(LChunkBuilder);
2879 #undef DECLARE_HYDROGEN_ACCESSOR
2880 #undef DECLARE_CONCRETE_INSTRUCTION
2882 } } // namespace v8::internal
2884 #endif // V8_IA32_LITHIUM_IA32_H_