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) \
86 V(GetCachedArrayIndex) \
88 V(HasCachedArrayIndexAndBranch) \
89 V(HasInPrototypeChainAndBranch) \
90 V(HasInstanceTypeAndBranch) \
91 V(InnerAllocatedObject) \
94 V(Integer32ToDouble) \
96 V(IsConstructCallAndBranch) \
97 V(IsStringAndBranch) \
99 V(IsUndetectableAndBranch) \
103 V(LoadFieldByIndex) \
104 V(LoadFunctionPrototype) \
105 V(LoadGlobalGeneric) \
106 V(LoadGlobalViaContext) \
108 V(LoadKeyedGeneric) \
110 V(LoadNamedGeneric) \
123 V(MaybeGrowElements) \
139 V(SeqStringGetChar) \
140 V(SeqStringSetChar) \
146 V(StoreContextSlot) \
147 V(StoreFrameContext) \
148 V(StoreGlobalViaContext) \
150 V(StoreKeyedGeneric) \
152 V(StoreNamedGeneric) \
154 V(StringCharCodeAt) \
155 V(StringCharFromCode) \
156 V(StringCompareAndBranch) \
160 V(ToFastProperties) \
161 V(TransitionElementsKind) \
162 V(TrapAllocationMemento) \
164 V(TypeofIsAndBranch) \
170 #define DECLARE_CONCRETE_INSTRUCTION(type, mnemonic) \
171 Opcode opcode() const final { return LInstruction::k##type; } \
172 void CompileToNative(LCodeGen* generator) final; \
173 const char* Mnemonic() const final { return mnemonic; } \
174 static L##type* cast(LInstruction* instr) { \
175 DCHECK(instr->Is##type()); \
176 return reinterpret_cast<L##type*>(instr); \
180 #define DECLARE_HYDROGEN_ACCESSOR(type) \
181 H##type* hydrogen() const { \
182 return H##type::cast(hydrogen_value()); \
186 class LInstruction : public ZoneObject {
189 : environment_(NULL),
190 hydrogen_value_(NULL),
191 bit_field_(IsCallBits::encode(false)) {
194 virtual ~LInstruction() {}
196 virtual void CompileToNative(LCodeGen* generator) = 0;
197 virtual const char* Mnemonic() const = 0;
198 virtual void PrintTo(StringStream* stream);
199 virtual void PrintDataTo(StringStream* stream);
200 virtual void PrintOutputOperandTo(StringStream* stream);
203 // Declare a unique enum value for each instruction.
204 #define DECLARE_OPCODE(type) k##type,
205 LITHIUM_CONCRETE_INSTRUCTION_LIST(DECLARE_OPCODE) kAdapter,
206 kNumberOfInstructions
207 #undef DECLARE_OPCODE
210 virtual Opcode opcode() const = 0;
212 // Declare non-virtual type testers for all leaf IR classes.
213 #define DECLARE_PREDICATE(type) \
214 bool Is##type() const { return opcode() == k##type; }
215 LITHIUM_CONCRETE_INSTRUCTION_LIST(DECLARE_PREDICATE)
216 #undef DECLARE_PREDICATE
218 // Declare virtual predicates for instructions that don't have
220 virtual bool IsGap() const { return false; }
222 virtual bool IsControl() const { return false; }
224 // Try deleting this instruction if possible.
225 virtual bool TryDelete() { return false; }
227 void set_environment(LEnvironment* env) { environment_ = env; }
228 LEnvironment* environment() const { return environment_; }
229 bool HasEnvironment() const { return environment_ != NULL; }
231 void set_pointer_map(LPointerMap* p) { pointer_map_.set(p); }
232 LPointerMap* pointer_map() const { return pointer_map_.get(); }
233 bool HasPointerMap() const { return pointer_map_.is_set(); }
235 void set_hydrogen_value(HValue* value) { hydrogen_value_ = value; }
236 HValue* hydrogen_value() const { return hydrogen_value_; }
238 void MarkAsCall() { bit_field_ = IsCallBits::update(bit_field_, true); }
239 bool IsCall() const { return IsCallBits::decode(bit_field_); }
241 // Interface to the register allocator and iterators.
242 bool ClobbersTemps() const { return IsCall(); }
243 bool ClobbersRegisters() const { return IsCall(); }
244 virtual bool ClobbersDoubleRegisters(Isolate* isolate) const {
248 virtual bool HasResult() const = 0;
249 virtual LOperand* result() const = 0;
251 bool HasDoubleRegisterResult();
252 bool HasDoubleRegisterInput();
254 LOperand* FirstInput() { return InputAt(0); }
255 LOperand* Output() { return HasResult() ? result() : NULL; }
257 virtual bool HasInterestingComment(LCodeGen* gen) const { return true; }
263 virtual int InputCount() = 0;
264 virtual LOperand* InputAt(int i) = 0;
268 friend class InputIterator;
270 friend class TempIterator;
271 virtual int TempCount() = 0;
272 virtual LOperand* TempAt(int i) = 0;
274 class IsCallBits: public BitField<bool, 0, 1> {};
276 LEnvironment* environment_;
277 SetOncePointer<LPointerMap> pointer_map_;
278 HValue* hydrogen_value_;
283 // R = number of result operands (0 or 1).
285 class LTemplateResultInstruction : public LInstruction {
287 // Allow 0 or 1 output operands.
288 STATIC_ASSERT(R == 0 || R == 1);
289 bool HasResult() const final { return R != 0 && result() != NULL; }
290 void set_result(LOperand* operand) { results_[0] = operand; }
291 LOperand* result() const override { return results_[0]; }
294 EmbeddedContainer<LOperand*, R> results_;
298 // R = number of result operands (0 or 1).
299 // I = number of input operands.
300 // T = number of temporary operands.
301 template<int R, int I, int T>
302 class LTemplateInstruction : public LTemplateResultInstruction<R> {
304 EmbeddedContainer<LOperand*, I> inputs_;
305 EmbeddedContainer<LOperand*, T> temps_;
309 int InputCount() final { return I; }
310 LOperand* InputAt(int i) final { return inputs_[i]; }
312 int TempCount() final { return T; }
313 LOperand* TempAt(int i) final { return temps_[i]; }
317 class LGap : public LTemplateInstruction<0, 0, 0> {
319 explicit LGap(HBasicBlock* block) : block_(block) {
320 parallel_moves_[BEFORE] = NULL;
321 parallel_moves_[START] = NULL;
322 parallel_moves_[END] = NULL;
323 parallel_moves_[AFTER] = NULL;
326 // Can't use the DECLARE-macro here because of sub-classes.
327 bool IsGap() const final { return true; }
328 void PrintDataTo(StringStream* stream) override;
329 static LGap* cast(LInstruction* instr) {
330 DCHECK(instr->IsGap());
331 return reinterpret_cast<LGap*>(instr);
334 bool IsRedundant() const;
336 HBasicBlock* block() const { return block_; }
343 FIRST_INNER_POSITION = BEFORE,
344 LAST_INNER_POSITION = AFTER
347 LParallelMove* GetOrCreateParallelMove(InnerPosition pos, Zone* zone) {
348 if (parallel_moves_[pos] == NULL) {
349 parallel_moves_[pos] = new(zone) LParallelMove(zone);
351 return parallel_moves_[pos];
354 LParallelMove* GetParallelMove(InnerPosition pos) {
355 return parallel_moves_[pos];
359 LParallelMove* parallel_moves_[LAST_INNER_POSITION + 1];
364 class LInstructionGap final : public LGap {
366 explicit LInstructionGap(HBasicBlock* block) : LGap(block) { }
368 bool HasInterestingComment(LCodeGen* gen) const override {
369 return !IsRedundant();
372 DECLARE_CONCRETE_INSTRUCTION(InstructionGap, "gap")
376 class LGoto final : public LTemplateInstruction<0, 0, 0> {
378 explicit LGoto(HBasicBlock* block) : block_(block) { }
380 bool HasInterestingComment(LCodeGen* gen) const override;
381 DECLARE_CONCRETE_INSTRUCTION(Goto, "goto")
382 void PrintDataTo(StringStream* stream) override;
383 bool IsControl() const override { return true; }
385 int block_id() const { return block_->block_id(); }
386 bool ClobbersDoubleRegisters(Isolate* isolate) const override {
390 bool jumps_to_join() const { return block_->predecessors()->length() > 1; }
397 class LPrologue final : public LTemplateInstruction<0, 0, 0> {
399 DECLARE_CONCRETE_INSTRUCTION(Prologue, "prologue")
403 class LLazyBailout final : public LTemplateInstruction<0, 0, 0> {
405 DECLARE_CONCRETE_INSTRUCTION(LazyBailout, "lazy-bailout")
409 class LDummy final : public LTemplateInstruction<1, 0, 0> {
412 DECLARE_CONCRETE_INSTRUCTION(Dummy, "dummy")
416 class LDummyUse final : public LTemplateInstruction<1, 1, 0> {
418 explicit LDummyUse(LOperand* value) {
421 DECLARE_CONCRETE_INSTRUCTION(DummyUse, "dummy-use")
425 class LDeoptimize final : public LTemplateInstruction<0, 0, 0> {
427 bool IsControl() const override { return true; }
428 DECLARE_CONCRETE_INSTRUCTION(Deoptimize, "deoptimize")
429 DECLARE_HYDROGEN_ACCESSOR(Deoptimize)
433 class LLabel final : public LGap {
435 explicit LLabel(HBasicBlock* block)
436 : LGap(block), replacement_(NULL) { }
438 bool HasInterestingComment(LCodeGen* gen) const override { return false; }
439 DECLARE_CONCRETE_INSTRUCTION(Label, "label")
441 void PrintDataTo(StringStream* stream) override;
443 int block_id() const { return block()->block_id(); }
444 bool is_loop_header() const { return block()->IsLoopHeader(); }
445 bool is_osr_entry() const { return block()->is_osr_entry(); }
446 Label* label() { return &label_; }
447 LLabel* replacement() const { return replacement_; }
448 void set_replacement(LLabel* label) { replacement_ = label; }
449 bool HasReplacement() const { return replacement_ != NULL; }
453 LLabel* replacement_;
457 class LParameter final : public LTemplateInstruction<1, 0, 0> {
459 bool HasInterestingComment(LCodeGen* gen) const override { return false; }
460 DECLARE_CONCRETE_INSTRUCTION(Parameter, "parameter")
464 class LCallStub final : public LTemplateInstruction<1, 1, 0> {
466 explicit LCallStub(LOperand* context) {
467 inputs_[0] = context;
470 LOperand* context() { return inputs_[0]; }
472 DECLARE_CONCRETE_INSTRUCTION(CallStub, "call-stub")
473 DECLARE_HYDROGEN_ACCESSOR(CallStub)
477 class LUnknownOSRValue final : public LTemplateInstruction<1, 0, 0> {
479 bool HasInterestingComment(LCodeGen* gen) const override { return false; }
480 DECLARE_CONCRETE_INSTRUCTION(UnknownOSRValue, "unknown-osr-value")
484 template<int I, int T>
485 class LControlInstruction: public LTemplateInstruction<0, I, T> {
487 LControlInstruction() : false_label_(NULL), true_label_(NULL) { }
489 bool IsControl() const final { return true; }
491 int SuccessorCount() { return hydrogen()->SuccessorCount(); }
492 HBasicBlock* SuccessorAt(int i) { return hydrogen()->SuccessorAt(i); }
494 int TrueDestination(LChunk* chunk) {
495 return chunk->LookupDestination(true_block_id());
497 int FalseDestination(LChunk* chunk) {
498 return chunk->LookupDestination(false_block_id());
501 Label* TrueLabel(LChunk* chunk) {
502 if (true_label_ == NULL) {
503 true_label_ = chunk->GetAssemblyLabel(TrueDestination(chunk));
507 Label* FalseLabel(LChunk* chunk) {
508 if (false_label_ == NULL) {
509 false_label_ = chunk->GetAssemblyLabel(FalseDestination(chunk));
515 int true_block_id() { return SuccessorAt(0)->block_id(); }
516 int false_block_id() { return SuccessorAt(1)->block_id(); }
519 HControlInstruction* hydrogen() {
520 return HControlInstruction::cast(this->hydrogen_value());
528 class LWrapReceiver final : public LTemplateInstruction<1, 2, 1> {
530 LWrapReceiver(LOperand* receiver,
533 inputs_[0] = receiver;
534 inputs_[1] = function;
538 LOperand* receiver() { return inputs_[0]; }
539 LOperand* function() { return inputs_[1]; }
540 LOperand* temp() { return temps_[0]; }
542 DECLARE_CONCRETE_INSTRUCTION(WrapReceiver, "wrap-receiver")
543 DECLARE_HYDROGEN_ACCESSOR(WrapReceiver)
547 class LApplyArguments final : public LTemplateInstruction<1, 4, 0> {
549 LApplyArguments(LOperand* function,
552 LOperand* elements) {
553 inputs_[0] = function;
554 inputs_[1] = receiver;
556 inputs_[3] = elements;
559 LOperand* function() { return inputs_[0]; }
560 LOperand* receiver() { return inputs_[1]; }
561 LOperand* length() { return inputs_[2]; }
562 LOperand* elements() { return inputs_[3]; }
564 DECLARE_CONCRETE_INSTRUCTION(ApplyArguments, "apply-arguments")
568 class LAccessArgumentsAt final : public LTemplateInstruction<1, 3, 0> {
570 LAccessArgumentsAt(LOperand* arguments, LOperand* length, LOperand* index) {
571 inputs_[0] = arguments;
576 LOperand* arguments() { return inputs_[0]; }
577 LOperand* length() { return inputs_[1]; }
578 LOperand* index() { return inputs_[2]; }
580 DECLARE_CONCRETE_INSTRUCTION(AccessArgumentsAt, "access-arguments-at")
582 void PrintDataTo(StringStream* stream) override;
586 class LArgumentsLength final : public LTemplateInstruction<1, 1, 0> {
588 explicit LArgumentsLength(LOperand* elements) {
589 inputs_[0] = elements;
592 LOperand* elements() { return inputs_[0]; }
594 DECLARE_CONCRETE_INSTRUCTION(ArgumentsLength, "arguments-length")
598 class LArgumentsElements final : public LTemplateInstruction<1, 0, 0> {
600 DECLARE_CONCRETE_INSTRUCTION(ArgumentsElements, "arguments-elements")
601 DECLARE_HYDROGEN_ACCESSOR(ArgumentsElements)
605 class LDebugBreak final : public LTemplateInstruction<0, 0, 0> {
607 DECLARE_CONCRETE_INSTRUCTION(DebugBreak, "break")
611 class LModByPowerOf2I final : public LTemplateInstruction<1, 1, 0> {
613 LModByPowerOf2I(LOperand* dividend, int32_t divisor) {
614 inputs_[0] = dividend;
618 LOperand* dividend() { return inputs_[0]; }
619 int32_t divisor() const { return divisor_; }
621 DECLARE_CONCRETE_INSTRUCTION(ModByPowerOf2I, "mod-by-power-of-2-i")
622 DECLARE_HYDROGEN_ACCESSOR(Mod)
629 class LModByConstI final : public LTemplateInstruction<1, 1, 2> {
631 LModByConstI(LOperand* dividend,
635 inputs_[0] = dividend;
641 LOperand* dividend() { return inputs_[0]; }
642 int32_t divisor() const { return divisor_; }
643 LOperand* temp1() { return temps_[0]; }
644 LOperand* temp2() { return temps_[1]; }
646 DECLARE_CONCRETE_INSTRUCTION(ModByConstI, "mod-by-const-i")
647 DECLARE_HYDROGEN_ACCESSOR(Mod)
654 class LModI final : public LTemplateInstruction<1, 2, 1> {
656 LModI(LOperand* left, LOperand* right, LOperand* temp) {
662 LOperand* left() { return inputs_[0]; }
663 LOperand* right() { return inputs_[1]; }
664 LOperand* temp() { return temps_[0]; }
666 DECLARE_CONCRETE_INSTRUCTION(ModI, "mod-i")
667 DECLARE_HYDROGEN_ACCESSOR(Mod)
671 class LDivByPowerOf2I final : public LTemplateInstruction<1, 1, 0> {
673 LDivByPowerOf2I(LOperand* dividend, int32_t divisor) {
674 inputs_[0] = dividend;
678 LOperand* dividend() { return inputs_[0]; }
679 int32_t divisor() const { return divisor_; }
681 DECLARE_CONCRETE_INSTRUCTION(DivByPowerOf2I, "div-by-power-of-2-i")
682 DECLARE_HYDROGEN_ACCESSOR(Div)
689 class LDivByConstI final : public LTemplateInstruction<1, 1, 2> {
691 LDivByConstI(LOperand* dividend,
695 inputs_[0] = dividend;
701 LOperand* dividend() { return inputs_[0]; }
702 int32_t divisor() const { return divisor_; }
703 LOperand* temp1() { return temps_[0]; }
704 LOperand* temp2() { return temps_[1]; }
706 DECLARE_CONCRETE_INSTRUCTION(DivByConstI, "div-by-const-i")
707 DECLARE_HYDROGEN_ACCESSOR(Div)
714 class LDivI final : public LTemplateInstruction<1, 2, 1> {
716 LDivI(LOperand* dividend, LOperand* divisor, LOperand* temp) {
717 inputs_[0] = dividend;
718 inputs_[1] = divisor;
722 LOperand* dividend() { return inputs_[0]; }
723 LOperand* divisor() { return inputs_[1]; }
724 LOperand* temp() { return temps_[0]; }
726 DECLARE_CONCRETE_INSTRUCTION(DivI, "div-i")
727 DECLARE_HYDROGEN_ACCESSOR(BinaryOperation)
731 class LFlooringDivByPowerOf2I final : public LTemplateInstruction<1, 1, 0> {
733 LFlooringDivByPowerOf2I(LOperand* dividend, int32_t divisor) {
734 inputs_[0] = dividend;
738 LOperand* dividend() { return inputs_[0]; }
739 int32_t divisor() const { return divisor_; }
741 DECLARE_CONCRETE_INSTRUCTION(FlooringDivByPowerOf2I,
742 "flooring-div-by-power-of-2-i")
743 DECLARE_HYDROGEN_ACCESSOR(MathFloorOfDiv)
750 class LFlooringDivByConstI final : public LTemplateInstruction<1, 1, 3> {
752 LFlooringDivByConstI(LOperand* dividend,
757 inputs_[0] = dividend;
764 LOperand* dividend() { return inputs_[0]; }
765 int32_t divisor() const { return divisor_; }
766 LOperand* temp1() { return temps_[0]; }
767 LOperand* temp2() { return temps_[1]; }
768 LOperand* temp3() { return temps_[2]; }
770 DECLARE_CONCRETE_INSTRUCTION(FlooringDivByConstI, "flooring-div-by-const-i")
771 DECLARE_HYDROGEN_ACCESSOR(MathFloorOfDiv)
778 class LFlooringDivI final : public LTemplateInstruction<1, 2, 1> {
780 LFlooringDivI(LOperand* dividend, LOperand* divisor, LOperand* temp) {
781 inputs_[0] = dividend;
782 inputs_[1] = divisor;
786 LOperand* dividend() { return inputs_[0]; }
787 LOperand* divisor() { return inputs_[1]; }
788 LOperand* temp() { return temps_[0]; }
790 DECLARE_CONCRETE_INSTRUCTION(FlooringDivI, "flooring-div-i")
791 DECLARE_HYDROGEN_ACCESSOR(MathFloorOfDiv)
795 class LMulI final : public LTemplateInstruction<1, 2, 1> {
797 LMulI(LOperand* left, LOperand* right, LOperand* temp) {
803 LOperand* left() { return inputs_[0]; }
804 LOperand* right() { return inputs_[1]; }
805 LOperand* temp() { return temps_[0]; }
807 DECLARE_CONCRETE_INSTRUCTION(MulI, "mul-i")
808 DECLARE_HYDROGEN_ACCESSOR(Mul)
812 class LCompareNumericAndBranch final : public LControlInstruction<2, 0> {
814 LCompareNumericAndBranch(LOperand* left, LOperand* right) {
819 LOperand* left() { return inputs_[0]; }
820 LOperand* right() { return inputs_[1]; }
822 DECLARE_CONCRETE_INSTRUCTION(CompareNumericAndBranch,
823 "compare-numeric-and-branch")
824 DECLARE_HYDROGEN_ACCESSOR(CompareNumericAndBranch)
826 Token::Value op() const { return hydrogen()->token(); }
827 bool is_double() const {
828 return hydrogen()->representation().IsDouble();
831 void PrintDataTo(StringStream* stream) override;
835 class LMathFloor final : public LTemplateInstruction<1, 1, 0> {
837 explicit LMathFloor(LOperand* value) {
841 LOperand* value() { return inputs_[0]; }
843 DECLARE_CONCRETE_INSTRUCTION(MathFloor, "math-floor")
844 DECLARE_HYDROGEN_ACCESSOR(UnaryMathOperation)
848 class LMathRound final : public LTemplateInstruction<1, 1, 1> {
850 LMathRound(LOperand* value, LOperand* temp) {
855 LOperand* temp() { return temps_[0]; }
856 LOperand* value() { return inputs_[0]; }
858 DECLARE_CONCRETE_INSTRUCTION(MathRound, "math-round")
859 DECLARE_HYDROGEN_ACCESSOR(UnaryMathOperation)
863 class LMathFround final : public LTemplateInstruction<1, 1, 0> {
865 explicit LMathFround(LOperand* value) { inputs_[0] = value; }
867 LOperand* value() { return inputs_[0]; }
869 DECLARE_CONCRETE_INSTRUCTION(MathFround, "math-fround")
873 class LMathAbs final : public LTemplateInstruction<1, 2, 0> {
875 LMathAbs(LOperand* context, LOperand* value) {
876 inputs_[1] = context;
880 LOperand* context() { return inputs_[1]; }
881 LOperand* value() { return inputs_[0]; }
883 DECLARE_CONCRETE_INSTRUCTION(MathAbs, "math-abs")
884 DECLARE_HYDROGEN_ACCESSOR(UnaryMathOperation)
888 class LMathLog final : public LTemplateInstruction<1, 1, 0> {
890 explicit LMathLog(LOperand* value) {
894 LOperand* value() { return inputs_[0]; }
896 DECLARE_CONCRETE_INSTRUCTION(MathLog, "math-log")
900 class LMathClz32 final : public LTemplateInstruction<1, 1, 0> {
902 explicit LMathClz32(LOperand* value) {
906 LOperand* value() { return inputs_[0]; }
908 DECLARE_CONCRETE_INSTRUCTION(MathClz32, "math-clz32")
912 class LMathExp final : public LTemplateInstruction<1, 1, 2> {
914 LMathExp(LOperand* value,
920 ExternalReference::InitializeMathExpData();
923 LOperand* value() { return inputs_[0]; }
924 LOperand* temp1() { return temps_[0]; }
925 LOperand* temp2() { return temps_[1]; }
927 DECLARE_CONCRETE_INSTRUCTION(MathExp, "math-exp")
931 class LMathSqrt final : public LTemplateInstruction<1, 1, 0> {
933 explicit LMathSqrt(LOperand* value) {
937 LOperand* value() { return inputs_[0]; }
939 DECLARE_CONCRETE_INSTRUCTION(MathSqrt, "math-sqrt")
943 class LMathPowHalf final : public LTemplateInstruction<1, 1, 1> {
945 LMathPowHalf(LOperand* value, LOperand* temp) {
950 LOperand* value() { return inputs_[0]; }
951 LOperand* temp() { return temps_[0]; }
953 DECLARE_CONCRETE_INSTRUCTION(MathPowHalf, "math-pow-half")
957 class LCmpObjectEqAndBranch final : public LControlInstruction<2, 0> {
959 LCmpObjectEqAndBranch(LOperand* left, LOperand* right) {
964 LOperand* left() { return inputs_[0]; }
965 LOperand* right() { return inputs_[1]; }
967 DECLARE_CONCRETE_INSTRUCTION(CmpObjectEqAndBranch, "cmp-object-eq-and-branch")
971 class LCmpHoleAndBranch final : public LControlInstruction<1, 0> {
973 explicit LCmpHoleAndBranch(LOperand* object) {
977 LOperand* object() { return inputs_[0]; }
979 DECLARE_CONCRETE_INSTRUCTION(CmpHoleAndBranch, "cmp-hole-and-branch")
980 DECLARE_HYDROGEN_ACCESSOR(CompareHoleAndBranch)
984 class LCompareMinusZeroAndBranch final : public LControlInstruction<1, 1> {
986 LCompareMinusZeroAndBranch(LOperand* value, LOperand* temp) {
991 LOperand* value() { return inputs_[0]; }
992 LOperand* temp() { return temps_[0]; }
994 DECLARE_CONCRETE_INSTRUCTION(CompareMinusZeroAndBranch,
995 "cmp-minus-zero-and-branch")
996 DECLARE_HYDROGEN_ACCESSOR(CompareMinusZeroAndBranch)
1000 class LIsStringAndBranch final : public LControlInstruction<1, 1> {
1002 LIsStringAndBranch(LOperand* value, LOperand* temp) {
1007 LOperand* value() { return inputs_[0]; }
1008 LOperand* temp() { return temps_[0]; }
1010 DECLARE_CONCRETE_INSTRUCTION(IsStringAndBranch, "is-string-and-branch")
1011 DECLARE_HYDROGEN_ACCESSOR(IsStringAndBranch)
1013 void PrintDataTo(StringStream* stream) override;
1017 class LIsSmiAndBranch final : public LControlInstruction<1, 0> {
1019 explicit LIsSmiAndBranch(LOperand* value) {
1023 LOperand* value() { return inputs_[0]; }
1025 DECLARE_CONCRETE_INSTRUCTION(IsSmiAndBranch, "is-smi-and-branch")
1026 DECLARE_HYDROGEN_ACCESSOR(IsSmiAndBranch)
1028 void PrintDataTo(StringStream* stream) override;
1032 class LIsUndetectableAndBranch final : public LControlInstruction<1, 1> {
1034 LIsUndetectableAndBranch(LOperand* value, LOperand* temp) {
1039 LOperand* value() { return inputs_[0]; }
1040 LOperand* temp() { return temps_[0]; }
1042 DECLARE_CONCRETE_INSTRUCTION(IsUndetectableAndBranch,
1043 "is-undetectable-and-branch")
1044 DECLARE_HYDROGEN_ACCESSOR(IsUndetectableAndBranch)
1046 void PrintDataTo(StringStream* stream) override;
1050 class LStringCompareAndBranch final : public LControlInstruction<3, 0> {
1052 LStringCompareAndBranch(LOperand* context, LOperand* left, LOperand* right) {
1053 inputs_[0] = context;
1058 LOperand* context() { return inputs_[1]; }
1059 LOperand* left() { return inputs_[1]; }
1060 LOperand* right() { return inputs_[2]; }
1062 DECLARE_CONCRETE_INSTRUCTION(StringCompareAndBranch,
1063 "string-compare-and-branch")
1064 DECLARE_HYDROGEN_ACCESSOR(StringCompareAndBranch)
1066 void PrintDataTo(StringStream* stream) override;
1068 Token::Value op() const { return hydrogen()->token(); }
1072 class LHasInstanceTypeAndBranch final : public LControlInstruction<1, 1> {
1074 LHasInstanceTypeAndBranch(LOperand* value, LOperand* temp) {
1079 LOperand* value() { return inputs_[0]; }
1080 LOperand* temp() { return temps_[0]; }
1082 DECLARE_CONCRETE_INSTRUCTION(HasInstanceTypeAndBranch,
1083 "has-instance-type-and-branch")
1084 DECLARE_HYDROGEN_ACCESSOR(HasInstanceTypeAndBranch)
1086 void PrintDataTo(StringStream* stream) override;
1090 class LGetCachedArrayIndex final : public LTemplateInstruction<1, 1, 0> {
1092 explicit LGetCachedArrayIndex(LOperand* value) {
1096 LOperand* value() { return inputs_[0]; }
1098 DECLARE_CONCRETE_INSTRUCTION(GetCachedArrayIndex, "get-cached-array-index")
1099 DECLARE_HYDROGEN_ACCESSOR(GetCachedArrayIndex)
1103 class LHasCachedArrayIndexAndBranch final : public LControlInstruction<1, 0> {
1105 explicit LHasCachedArrayIndexAndBranch(LOperand* value) {
1109 LOperand* value() { return inputs_[0]; }
1111 DECLARE_CONCRETE_INSTRUCTION(HasCachedArrayIndexAndBranch,
1112 "has-cached-array-index-and-branch")
1114 void PrintDataTo(StringStream* stream) override;
1118 class LIsConstructCallAndBranch final : public LControlInstruction<0, 1> {
1120 explicit LIsConstructCallAndBranch(LOperand* temp) {
1124 LOperand* temp() { return temps_[0]; }
1126 DECLARE_CONCRETE_INSTRUCTION(IsConstructCallAndBranch,
1127 "is-construct-call-and-branch")
1131 class LClassOfTestAndBranch final : public LControlInstruction<1, 2> {
1133 LClassOfTestAndBranch(LOperand* value, LOperand* temp, LOperand* temp2) {
1139 LOperand* value() { return inputs_[0]; }
1140 LOperand* temp() { return temps_[0]; }
1141 LOperand* temp2() { return temps_[1]; }
1143 DECLARE_CONCRETE_INSTRUCTION(ClassOfTestAndBranch,
1144 "class-of-test-and-branch")
1145 DECLARE_HYDROGEN_ACCESSOR(ClassOfTestAndBranch)
1147 void PrintDataTo(StringStream* stream) override;
1151 class LCmpT final : public LTemplateInstruction<1, 3, 0> {
1153 LCmpT(LOperand* context, LOperand* left, LOperand* right) {
1154 inputs_[0] = context;
1159 DECLARE_CONCRETE_INSTRUCTION(CmpT, "cmp-t")
1160 DECLARE_HYDROGEN_ACCESSOR(CompareGeneric)
1162 Strength strength() { return hydrogen()->strength(); }
1164 LOperand* context() { return inputs_[0]; }
1165 Token::Value op() const { return hydrogen()->token(); }
1169 class LInstanceOf final : public LTemplateInstruction<1, 3, 0> {
1171 LInstanceOf(LOperand* context, LOperand* left, LOperand* right) {
1172 inputs_[0] = context;
1177 LOperand* context() const { return inputs_[0]; }
1178 LOperand* left() const { return inputs_[1]; }
1179 LOperand* right() const { return inputs_[2]; }
1181 DECLARE_CONCRETE_INSTRUCTION(InstanceOf, "instance-of")
1185 class LHasInPrototypeChainAndBranch final : public LControlInstruction<2, 1> {
1187 LHasInPrototypeChainAndBranch(LOperand* object, LOperand* prototype,
1188 LOperand* scratch) {
1189 inputs_[0] = object;
1190 inputs_[1] = prototype;
1191 temps_[0] = scratch;
1194 LOperand* object() const { return inputs_[0]; }
1195 LOperand* prototype() const { return inputs_[1]; }
1196 LOperand* scratch() const { return temps_[0]; }
1198 DECLARE_CONCRETE_INSTRUCTION(HasInPrototypeChainAndBranch,
1199 "has-in-prototype-chain-and-branch")
1200 DECLARE_HYDROGEN_ACCESSOR(HasInPrototypeChainAndBranch)
1204 class LBoundsCheck final : public LTemplateInstruction<0, 2, 0> {
1206 LBoundsCheck(LOperand* index, LOperand* length) {
1208 inputs_[1] = length;
1211 LOperand* index() { return inputs_[0]; }
1212 LOperand* length() { return inputs_[1]; }
1214 DECLARE_CONCRETE_INSTRUCTION(BoundsCheck, "bounds-check")
1215 DECLARE_HYDROGEN_ACCESSOR(BoundsCheck)
1219 class LBitI final : public LTemplateInstruction<1, 2, 0> {
1221 LBitI(LOperand* left, LOperand* right) {
1226 LOperand* left() { return inputs_[0]; }
1227 LOperand* right() { return inputs_[1]; }
1229 DECLARE_CONCRETE_INSTRUCTION(BitI, "bit-i")
1230 DECLARE_HYDROGEN_ACCESSOR(Bitwise)
1232 Token::Value op() const { return hydrogen()->op(); }
1236 class LShiftI final : public LTemplateInstruction<1, 2, 0> {
1238 LShiftI(Token::Value op, LOperand* left, LOperand* right, bool can_deopt)
1239 : op_(op), can_deopt_(can_deopt) {
1244 LOperand* left() { return inputs_[0]; }
1245 LOperand* right() { return inputs_[1]; }
1247 DECLARE_CONCRETE_INSTRUCTION(ShiftI, "shift-i")
1249 Token::Value op() const { return op_; }
1250 bool can_deopt() const { return can_deopt_; }
1258 class LSubI final : public LTemplateInstruction<1, 2, 0> {
1260 LSubI(LOperand* left, LOperand* right) {
1265 LOperand* left() { return inputs_[0]; }
1266 LOperand* right() { return inputs_[1]; }
1268 DECLARE_CONCRETE_INSTRUCTION(SubI, "sub-i")
1269 DECLARE_HYDROGEN_ACCESSOR(Sub)
1273 class LConstantI final : public LTemplateInstruction<1, 0, 0> {
1275 DECLARE_CONCRETE_INSTRUCTION(ConstantI, "constant-i")
1276 DECLARE_HYDROGEN_ACCESSOR(Constant)
1278 int32_t value() const { return hydrogen()->Integer32Value(); }
1282 class LConstantS final : public LTemplateInstruction<1, 0, 0> {
1284 DECLARE_CONCRETE_INSTRUCTION(ConstantS, "constant-s")
1285 DECLARE_HYDROGEN_ACCESSOR(Constant)
1287 Smi* value() const { return Smi::FromInt(hydrogen()->Integer32Value()); }
1291 class LConstantD final : public LTemplateInstruction<1, 0, 1> {
1293 explicit LConstantD(LOperand* temp) {
1297 LOperand* temp() { return temps_[0]; }
1299 DECLARE_CONCRETE_INSTRUCTION(ConstantD, "constant-d")
1300 DECLARE_HYDROGEN_ACCESSOR(Constant)
1302 uint64_t bits() const { return hydrogen()->DoubleValueAsBits(); }
1306 class LConstantE final : public LTemplateInstruction<1, 0, 0> {
1308 DECLARE_CONCRETE_INSTRUCTION(ConstantE, "constant-e")
1309 DECLARE_HYDROGEN_ACCESSOR(Constant)
1311 ExternalReference value() const {
1312 return hydrogen()->ExternalReferenceValue();
1317 class LConstantT final : public LTemplateInstruction<1, 0, 0> {
1319 DECLARE_CONCRETE_INSTRUCTION(ConstantT, "constant-t")
1320 DECLARE_HYDROGEN_ACCESSOR(Constant)
1322 Handle<Object> value(Isolate* isolate) const {
1323 return hydrogen()->handle(isolate);
1328 class LBranch final : public LControlInstruction<1, 1> {
1330 LBranch(LOperand* value, LOperand* temp) {
1335 LOperand* value() { return inputs_[0]; }
1336 LOperand* temp() { return temps_[0]; }
1338 DECLARE_CONCRETE_INSTRUCTION(Branch, "branch")
1339 DECLARE_HYDROGEN_ACCESSOR(Branch)
1341 void PrintDataTo(StringStream* stream) override;
1345 class LCmpMapAndBranch final : public LControlInstruction<1, 0> {
1347 explicit LCmpMapAndBranch(LOperand* value) {
1351 LOperand* value() { return inputs_[0]; }
1353 DECLARE_CONCRETE_INSTRUCTION(CmpMapAndBranch, "cmp-map-and-branch")
1354 DECLARE_HYDROGEN_ACCESSOR(CompareMap)
1356 Handle<Map> map() const { return hydrogen()->map().handle(); }
1360 class LMapEnumLength final : public LTemplateInstruction<1, 1, 0> {
1362 explicit LMapEnumLength(LOperand* value) {
1366 LOperand* value() { return inputs_[0]; }
1368 DECLARE_CONCRETE_INSTRUCTION(MapEnumLength, "map-enum-length")
1372 class LDateField final : public LTemplateInstruction<1, 1, 1> {
1374 LDateField(LOperand* date, LOperand* temp, Smi* index)
1380 LOperand* date() { return inputs_[0]; }
1381 LOperand* temp() { return temps_[0]; }
1383 DECLARE_CONCRETE_INSTRUCTION(DateField, "date-field")
1384 DECLARE_HYDROGEN_ACCESSOR(DateField)
1386 Smi* index() const { return index_; }
1393 class LSeqStringGetChar final : public LTemplateInstruction<1, 2, 0> {
1395 LSeqStringGetChar(LOperand* string, LOperand* index) {
1396 inputs_[0] = string;
1400 LOperand* string() const { return inputs_[0]; }
1401 LOperand* index() const { return inputs_[1]; }
1403 DECLARE_CONCRETE_INSTRUCTION(SeqStringGetChar, "seq-string-get-char")
1404 DECLARE_HYDROGEN_ACCESSOR(SeqStringGetChar)
1408 class LSeqStringSetChar final : public LTemplateInstruction<1, 4, 0> {
1410 LSeqStringSetChar(LOperand* context,
1414 inputs_[0] = context;
1415 inputs_[1] = string;
1420 LOperand* string() { return inputs_[1]; }
1421 LOperand* index() { return inputs_[2]; }
1422 LOperand* value() { return inputs_[3]; }
1424 DECLARE_CONCRETE_INSTRUCTION(SeqStringSetChar, "seq-string-set-char")
1425 DECLARE_HYDROGEN_ACCESSOR(SeqStringSetChar)
1429 class LAddI final : public LTemplateInstruction<1, 2, 0> {
1431 LAddI(LOperand* left, LOperand* right) {
1436 LOperand* left() { return inputs_[0]; }
1437 LOperand* right() { return inputs_[1]; }
1439 static bool UseLea(HAdd* add) {
1440 return !add->CheckFlag(HValue::kCanOverflow) &&
1441 add->BetterLeftOperand()->UseCount() > 1;
1444 DECLARE_CONCRETE_INSTRUCTION(AddI, "add-i")
1445 DECLARE_HYDROGEN_ACCESSOR(Add)
1449 class LMathMinMax final : public LTemplateInstruction<1, 2, 0> {
1451 LMathMinMax(LOperand* left, LOperand* right) {
1456 LOperand* left() { return inputs_[0]; }
1457 LOperand* right() { return inputs_[1]; }
1459 DECLARE_CONCRETE_INSTRUCTION(MathMinMax, "math-min-max")
1460 DECLARE_HYDROGEN_ACCESSOR(MathMinMax)
1464 class LPower final : public LTemplateInstruction<1, 2, 0> {
1466 LPower(LOperand* left, LOperand* right) {
1471 LOperand* left() { return inputs_[0]; }
1472 LOperand* right() { return inputs_[1]; }
1474 DECLARE_CONCRETE_INSTRUCTION(Power, "power")
1475 DECLARE_HYDROGEN_ACCESSOR(Power)
1479 class LArithmeticD final : public LTemplateInstruction<1, 2, 0> {
1481 LArithmeticD(Token::Value op, LOperand* left, LOperand* right)
1487 LOperand* left() { return inputs_[0]; }
1488 LOperand* right() { return inputs_[1]; }
1490 Token::Value op() const { return op_; }
1492 Opcode opcode() const override { return LInstruction::kArithmeticD; }
1493 void CompileToNative(LCodeGen* generator) override;
1494 const char* Mnemonic() const override;
1501 class LArithmeticT final : public LTemplateInstruction<1, 3, 0> {
1503 LArithmeticT(Token::Value op,
1508 inputs_[0] = context;
1513 LOperand* context() { return inputs_[0]; }
1514 LOperand* left() { return inputs_[1]; }
1515 LOperand* right() { return inputs_[2]; }
1516 Token::Value op() const { return op_; }
1518 Opcode opcode() const override { return LInstruction::kArithmeticT; }
1519 void CompileToNative(LCodeGen* generator) override;
1520 const char* Mnemonic() const override;
1522 DECLARE_HYDROGEN_ACCESSOR(BinaryOperation)
1524 Strength strength() { return hydrogen()->strength(); }
1531 class LReturn final : public LTemplateInstruction<0, 3, 0> {
1533 explicit LReturn(LOperand* value,
1535 LOperand* parameter_count) {
1537 inputs_[1] = context;
1538 inputs_[2] = parameter_count;
1541 bool has_constant_parameter_count() {
1542 return parameter_count()->IsConstantOperand();
1544 LConstantOperand* constant_parameter_count() {
1545 DCHECK(has_constant_parameter_count());
1546 return LConstantOperand::cast(parameter_count());
1548 LOperand* parameter_count() { return inputs_[2]; }
1550 DECLARE_CONCRETE_INSTRUCTION(Return, "return")
1551 DECLARE_HYDROGEN_ACCESSOR(Return)
1555 class LLoadNamedField final : public LTemplateInstruction<1, 1, 0> {
1557 explicit LLoadNamedField(LOperand* object) {
1558 inputs_[0] = object;
1561 LOperand* object() { return inputs_[0]; }
1563 DECLARE_CONCRETE_INSTRUCTION(LoadNamedField, "load-named-field")
1564 DECLARE_HYDROGEN_ACCESSOR(LoadNamedField)
1568 class LLoadNamedGeneric final : public LTemplateInstruction<1, 2, 1> {
1570 LLoadNamedGeneric(LOperand* context, LOperand* object, LOperand* vector) {
1571 inputs_[0] = context;
1572 inputs_[1] = object;
1576 LOperand* context() { return inputs_[0]; }
1577 LOperand* object() { return inputs_[1]; }
1578 LOperand* temp_vector() { return temps_[0]; }
1580 DECLARE_CONCRETE_INSTRUCTION(LoadNamedGeneric, "load-named-generic")
1581 DECLARE_HYDROGEN_ACCESSOR(LoadNamedGeneric)
1583 Handle<Object> name() const { return hydrogen()->name(); }
1587 class LLoadFunctionPrototype final : public LTemplateInstruction<1, 1, 1> {
1589 LLoadFunctionPrototype(LOperand* function, LOperand* temp) {
1590 inputs_[0] = function;
1594 LOperand* function() { return inputs_[0]; }
1595 LOperand* temp() { return temps_[0]; }
1597 DECLARE_CONCRETE_INSTRUCTION(LoadFunctionPrototype, "load-function-prototype")
1598 DECLARE_HYDROGEN_ACCESSOR(LoadFunctionPrototype)
1602 class LLoadRoot final : public LTemplateInstruction<1, 0, 0> {
1604 DECLARE_CONCRETE_INSTRUCTION(LoadRoot, "load-root")
1605 DECLARE_HYDROGEN_ACCESSOR(LoadRoot)
1607 Heap::RootListIndex index() const { return hydrogen()->index(); }
1611 class LLoadKeyed final : public LTemplateInstruction<1, 2, 0> {
1613 LLoadKeyed(LOperand* elements, LOperand* key) {
1614 inputs_[0] = elements;
1617 LOperand* elements() { return inputs_[0]; }
1618 LOperand* key() { return inputs_[1]; }
1619 ElementsKind elements_kind() const {
1620 return hydrogen()->elements_kind();
1622 bool is_fixed_typed_array() const {
1623 return hydrogen()->is_fixed_typed_array();
1626 DECLARE_CONCRETE_INSTRUCTION(LoadKeyed, "load-keyed")
1627 DECLARE_HYDROGEN_ACCESSOR(LoadKeyed)
1629 void PrintDataTo(StringStream* stream) override;
1630 uint32_t base_offset() const { return hydrogen()->base_offset(); }
1632 return hydrogen()->key()->representation().IsTagged();
1637 inline static bool ExternalArrayOpRequiresTemp(
1638 Representation key_representation,
1639 ElementsKind elements_kind) {
1640 // Operations that require the key to be divided by two to be converted into
1641 // an index cannot fold the scale operation into a load and need an extra
1642 // temp register to do the work.
1643 return key_representation.IsSmi() &&
1644 (elements_kind == UINT8_ELEMENTS || elements_kind == INT8_ELEMENTS ||
1645 elements_kind == UINT8_CLAMPED_ELEMENTS);
1649 class LLoadKeyedGeneric final : public LTemplateInstruction<1, 3, 1> {
1651 LLoadKeyedGeneric(LOperand* context, LOperand* obj, LOperand* key,
1653 inputs_[0] = context;
1659 LOperand* context() { return inputs_[0]; }
1660 LOperand* object() { return inputs_[1]; }
1661 LOperand* key() { return inputs_[2]; }
1662 LOperand* temp_vector() { return temps_[0]; }
1664 DECLARE_CONCRETE_INSTRUCTION(LoadKeyedGeneric, "load-keyed-generic")
1665 DECLARE_HYDROGEN_ACCESSOR(LoadKeyedGeneric)
1669 class LLoadGlobalGeneric final : public LTemplateInstruction<1, 2, 1> {
1671 LLoadGlobalGeneric(LOperand* context, LOperand* global_object,
1673 inputs_[0] = context;
1674 inputs_[1] = global_object;
1678 LOperand* context() { return inputs_[0]; }
1679 LOperand* global_object() { return inputs_[1]; }
1680 LOperand* temp_vector() { return temps_[0]; }
1682 DECLARE_CONCRETE_INSTRUCTION(LoadGlobalGeneric, "load-global-generic")
1683 DECLARE_HYDROGEN_ACCESSOR(LoadGlobalGeneric)
1685 Handle<Object> name() const { return hydrogen()->name(); }
1686 TypeofMode typeof_mode() const { return hydrogen()->typeof_mode(); }
1690 class LLoadGlobalViaContext final : public LTemplateInstruction<1, 1, 1> {
1692 explicit LLoadGlobalViaContext(LOperand* context) { inputs_[0] = context; }
1694 DECLARE_CONCRETE_INSTRUCTION(LoadGlobalViaContext, "load-global-via-context")
1695 DECLARE_HYDROGEN_ACCESSOR(LoadGlobalViaContext)
1697 void PrintDataTo(StringStream* stream) override;
1699 LOperand* context() { return inputs_[0]; }
1701 int depth() const { return hydrogen()->depth(); }
1702 int slot_index() const { return hydrogen()->slot_index(); }
1706 class LLoadContextSlot final : public LTemplateInstruction<1, 1, 0> {
1708 explicit LLoadContextSlot(LOperand* context) {
1709 inputs_[0] = context;
1712 LOperand* context() { return inputs_[0]; }
1714 DECLARE_CONCRETE_INSTRUCTION(LoadContextSlot, "load-context-slot")
1715 DECLARE_HYDROGEN_ACCESSOR(LoadContextSlot)
1717 int slot_index() { return hydrogen()->slot_index(); }
1719 void PrintDataTo(StringStream* stream) override;
1723 class LStoreContextSlot final : public LTemplateInstruction<0, 2, 1> {
1725 LStoreContextSlot(LOperand* context, LOperand* value, LOperand* temp) {
1726 inputs_[0] = context;
1731 LOperand* context() { return inputs_[0]; }
1732 LOperand* value() { return inputs_[1]; }
1733 LOperand* temp() { return temps_[0]; }
1735 DECLARE_CONCRETE_INSTRUCTION(StoreContextSlot, "store-context-slot")
1736 DECLARE_HYDROGEN_ACCESSOR(StoreContextSlot)
1738 int slot_index() { return hydrogen()->slot_index(); }
1740 void PrintDataTo(StringStream* stream) override;
1744 class LPushArgument final : public LTemplateInstruction<0, 1, 0> {
1746 explicit LPushArgument(LOperand* value) {
1750 LOperand* value() { return inputs_[0]; }
1752 DECLARE_CONCRETE_INSTRUCTION(PushArgument, "push-argument")
1756 class LDrop final : public LTemplateInstruction<0, 0, 0> {
1758 explicit LDrop(int count) : count_(count) { }
1760 int count() const { return count_; }
1762 DECLARE_CONCRETE_INSTRUCTION(Drop, "drop")
1769 class LStoreCodeEntry final : public LTemplateInstruction<0, 2, 0> {
1771 LStoreCodeEntry(LOperand* function, LOperand* code_object) {
1772 inputs_[0] = function;
1773 inputs_[1] = code_object;
1776 LOperand* function() { return inputs_[0]; }
1777 LOperand* code_object() { return inputs_[1]; }
1779 void PrintDataTo(StringStream* stream) override;
1781 DECLARE_CONCRETE_INSTRUCTION(StoreCodeEntry, "store-code-entry")
1782 DECLARE_HYDROGEN_ACCESSOR(StoreCodeEntry)
1786 class LInnerAllocatedObject final : public LTemplateInstruction<1, 2, 0> {
1788 LInnerAllocatedObject(LOperand* base_object, LOperand* offset) {
1789 inputs_[0] = base_object;
1790 inputs_[1] = offset;
1793 LOperand* base_object() const { return inputs_[0]; }
1794 LOperand* offset() const { return inputs_[1]; }
1796 void PrintDataTo(StringStream* stream) override;
1798 DECLARE_CONCRETE_INSTRUCTION(InnerAllocatedObject, "inner-allocated-object")
1802 class LThisFunction final : public LTemplateInstruction<1, 0, 0> {
1804 DECLARE_CONCRETE_INSTRUCTION(ThisFunction, "this-function")
1805 DECLARE_HYDROGEN_ACCESSOR(ThisFunction)
1809 class LContext final : public LTemplateInstruction<1, 0, 0> {
1811 DECLARE_CONCRETE_INSTRUCTION(Context, "context")
1812 DECLARE_HYDROGEN_ACCESSOR(Context)
1816 class LDeclareGlobals final : public LTemplateInstruction<0, 1, 0> {
1818 explicit LDeclareGlobals(LOperand* context) {
1819 inputs_[0] = context;
1822 LOperand* context() { return inputs_[0]; }
1824 DECLARE_CONCRETE_INSTRUCTION(DeclareGlobals, "declare-globals")
1825 DECLARE_HYDROGEN_ACCESSOR(DeclareGlobals)
1829 class LCallJSFunction final : public LTemplateInstruction<1, 1, 0> {
1831 explicit LCallJSFunction(LOperand* function) {
1832 inputs_[0] = function;
1835 LOperand* function() { return inputs_[0]; }
1837 DECLARE_CONCRETE_INSTRUCTION(CallJSFunction, "call-js-function")
1838 DECLARE_HYDROGEN_ACCESSOR(CallJSFunction)
1840 void PrintDataTo(StringStream* stream) override;
1842 int arity() const { return hydrogen()->argument_count() - 1; }
1846 class LCallWithDescriptor final : public LTemplateResultInstruction<1> {
1848 LCallWithDescriptor(CallInterfaceDescriptor descriptor,
1849 const ZoneList<LOperand*>& operands, Zone* zone)
1850 : inputs_(descriptor.GetRegisterParameterCount() +
1851 kImplicitRegisterParameterCount,
1853 DCHECK(descriptor.GetRegisterParameterCount() +
1854 kImplicitRegisterParameterCount ==
1856 inputs_.AddAll(operands, zone);
1859 LOperand* target() const { return inputs_[0]; }
1861 DECLARE_HYDROGEN_ACCESSOR(CallWithDescriptor)
1863 // The target and context are passed as implicit parameters that are not
1864 // explicitly listed in the descriptor.
1865 static const int kImplicitRegisterParameterCount = 2;
1868 DECLARE_CONCRETE_INSTRUCTION(CallWithDescriptor, "call-with-descriptor")
1870 void PrintDataTo(StringStream* stream) override;
1872 int arity() const { return hydrogen()->argument_count() - 1; }
1874 ZoneList<LOperand*> inputs_;
1876 // Iterator support.
1877 int InputCount() final { return inputs_.length(); }
1878 LOperand* InputAt(int i) final { return inputs_[i]; }
1880 int TempCount() final { return 0; }
1881 LOperand* TempAt(int i) final { return NULL; }
1885 class LInvokeFunction final : public LTemplateInstruction<1, 2, 0> {
1887 LInvokeFunction(LOperand* context, LOperand* function) {
1888 inputs_[0] = context;
1889 inputs_[1] = function;
1892 LOperand* context() { return inputs_[0]; }
1893 LOperand* function() { return inputs_[1]; }
1895 DECLARE_CONCRETE_INSTRUCTION(InvokeFunction, "invoke-function")
1896 DECLARE_HYDROGEN_ACCESSOR(InvokeFunction)
1898 void PrintDataTo(StringStream* stream) override;
1900 int arity() const { return hydrogen()->argument_count() - 1; }
1904 class LCallFunction final : public LTemplateInstruction<1, 2, 2> {
1906 LCallFunction(LOperand* context, LOperand* function, LOperand* slot,
1908 inputs_[0] = context;
1909 inputs_[1] = function;
1914 LOperand* context() { return inputs_[0]; }
1915 LOperand* function() { return inputs_[1]; }
1916 LOperand* temp_slot() { return temps_[0]; }
1917 LOperand* temp_vector() { return temps_[1]; }
1919 DECLARE_CONCRETE_INSTRUCTION(CallFunction, "call-function")
1920 DECLARE_HYDROGEN_ACCESSOR(CallFunction)
1922 void PrintDataTo(StringStream* stream) override;
1923 int arity() const { return hydrogen()->argument_count() - 1; }
1927 class LCallNew final : public LTemplateInstruction<1, 2, 0> {
1929 LCallNew(LOperand* context, LOperand* constructor) {
1930 inputs_[0] = context;
1931 inputs_[1] = constructor;
1934 LOperand* context() { return inputs_[0]; }
1935 LOperand* constructor() { return inputs_[1]; }
1937 DECLARE_CONCRETE_INSTRUCTION(CallNew, "call-new")
1938 DECLARE_HYDROGEN_ACCESSOR(CallNew)
1940 void PrintDataTo(StringStream* stream) override;
1942 int arity() const { return hydrogen()->argument_count() - 1; }
1946 class LCallNewArray final : public LTemplateInstruction<1, 2, 0> {
1948 LCallNewArray(LOperand* context, LOperand* constructor) {
1949 inputs_[0] = context;
1950 inputs_[1] = constructor;
1953 LOperand* context() { return inputs_[0]; }
1954 LOperand* constructor() { return inputs_[1]; }
1956 DECLARE_CONCRETE_INSTRUCTION(CallNewArray, "call-new-array")
1957 DECLARE_HYDROGEN_ACCESSOR(CallNewArray)
1959 void PrintDataTo(StringStream* stream) override;
1961 int arity() const { return hydrogen()->argument_count() - 1; }
1965 class LCallRuntime final : public LTemplateInstruction<1, 1, 0> {
1967 explicit LCallRuntime(LOperand* context) {
1968 inputs_[0] = context;
1971 LOperand* context() { return inputs_[0]; }
1973 DECLARE_CONCRETE_INSTRUCTION(CallRuntime, "call-runtime")
1974 DECLARE_HYDROGEN_ACCESSOR(CallRuntime)
1976 bool ClobbersDoubleRegisters(Isolate* isolate) const override {
1977 return save_doubles() == kDontSaveFPRegs;
1980 const Runtime::Function* function() const { return hydrogen()->function(); }
1981 int arity() const { return hydrogen()->argument_count(); }
1982 SaveFPRegsMode save_doubles() const { return hydrogen()->save_doubles(); }
1986 class LInteger32ToDouble final : public LTemplateInstruction<1, 1, 0> {
1988 explicit LInteger32ToDouble(LOperand* value) {
1992 LOperand* value() { return inputs_[0]; }
1994 DECLARE_CONCRETE_INSTRUCTION(Integer32ToDouble, "int32-to-double")
1998 class LUint32ToDouble final : public LTemplateInstruction<1, 1, 0> {
2000 explicit LUint32ToDouble(LOperand* value) {
2004 LOperand* value() { return inputs_[0]; }
2006 DECLARE_CONCRETE_INSTRUCTION(Uint32ToDouble, "uint32-to-double")
2010 class LNumberTagI final : public LTemplateInstruction<1, 1, 1> {
2012 LNumberTagI(LOperand* value, LOperand* temp) {
2017 LOperand* value() { return inputs_[0]; }
2018 LOperand* temp() { return temps_[0]; }
2020 DECLARE_CONCRETE_INSTRUCTION(NumberTagI, "number-tag-i")
2024 class LNumberTagU final : public LTemplateInstruction<1, 1, 1> {
2026 LNumberTagU(LOperand* value, LOperand* temp) {
2031 LOperand* value() { return inputs_[0]; }
2032 LOperand* temp() { return temps_[0]; }
2034 DECLARE_CONCRETE_INSTRUCTION(NumberTagU, "number-tag-u")
2038 class LNumberTagD final : public LTemplateInstruction<1, 1, 1> {
2040 LNumberTagD(LOperand* value, LOperand* temp) {
2045 LOperand* value() { return inputs_[0]; }
2046 LOperand* temp() { return temps_[0]; }
2048 DECLARE_CONCRETE_INSTRUCTION(NumberTagD, "number-tag-d")
2049 DECLARE_HYDROGEN_ACCESSOR(Change)
2053 // Sometimes truncating conversion from a tagged value to an int32.
2054 class LDoubleToI final : public LTemplateInstruction<1, 1, 1> {
2056 LDoubleToI(LOperand* value, LOperand* temp) {
2061 LOperand* value() { return inputs_[0]; }
2062 LOperand* temp() { return temps_[0]; }
2064 DECLARE_CONCRETE_INSTRUCTION(DoubleToI, "double-to-i")
2065 DECLARE_HYDROGEN_ACCESSOR(UnaryOperation)
2067 bool truncating() { return hydrogen()->CanTruncateToInt32(); }
2071 class LDoubleToSmi final : public LTemplateInstruction<1, 1, 0> {
2073 explicit LDoubleToSmi(LOperand* value) {
2077 LOperand* value() { return inputs_[0]; }
2079 DECLARE_CONCRETE_INSTRUCTION(DoubleToSmi, "double-to-smi")
2080 DECLARE_HYDROGEN_ACCESSOR(UnaryOperation)
2084 // Truncating conversion from a tagged value to an int32.
2085 class LTaggedToI final : public LTemplateInstruction<1, 1, 1> {
2087 LTaggedToI(LOperand* value, LOperand* temp) {
2092 LOperand* value() { return inputs_[0]; }
2093 LOperand* temp() { return temps_[0]; }
2095 DECLARE_CONCRETE_INSTRUCTION(TaggedToI, "tagged-to-i")
2096 DECLARE_HYDROGEN_ACCESSOR(Change)
2098 bool truncating() { return hydrogen()->CanTruncateToInt32(); }
2102 class LSmiTag final : public LTemplateInstruction<1, 1, 0> {
2104 explicit LSmiTag(LOperand* value) {
2108 LOperand* value() { return inputs_[0]; }
2110 DECLARE_CONCRETE_INSTRUCTION(SmiTag, "smi-tag")
2111 DECLARE_HYDROGEN_ACCESSOR(Change)
2115 class LNumberUntagD final : public LTemplateInstruction<1, 1, 1> {
2117 explicit LNumberUntagD(LOperand* value, LOperand* temp) {
2122 LOperand* value() { return inputs_[0]; }
2123 LOperand* temp() { return temps_[0]; }
2125 DECLARE_CONCRETE_INSTRUCTION(NumberUntagD, "double-untag")
2126 DECLARE_HYDROGEN_ACCESSOR(Change);
2130 class LSmiUntag final : public LTemplateInstruction<1, 1, 0> {
2132 LSmiUntag(LOperand* value, bool needs_check)
2133 : needs_check_(needs_check) {
2137 LOperand* value() { return inputs_[0]; }
2139 DECLARE_CONCRETE_INSTRUCTION(SmiUntag, "smi-untag")
2141 bool needs_check() const { return needs_check_; }
2148 class LStoreNamedField final : public LTemplateInstruction<0, 2, 2> {
2150 LStoreNamedField(LOperand* obj,
2153 LOperand* temp_map) {
2157 temps_[1] = temp_map;
2160 LOperand* object() { return inputs_[0]; }
2161 LOperand* value() { return inputs_[1]; }
2162 LOperand* temp() { return temps_[0]; }
2163 LOperand* temp_map() { return temps_[1]; }
2165 DECLARE_CONCRETE_INSTRUCTION(StoreNamedField, "store-named-field")
2166 DECLARE_HYDROGEN_ACCESSOR(StoreNamedField)
2168 void PrintDataTo(StringStream* stream) override;
2172 class LStoreNamedGeneric final : public LTemplateInstruction<0, 3, 2> {
2174 LStoreNamedGeneric(LOperand* context, LOperand* object, LOperand* value,
2175 LOperand* slot, LOperand* vector) {
2176 inputs_[0] = context;
2177 inputs_[1] = object;
2183 LOperand* context() { return inputs_[0]; }
2184 LOperand* object() { return inputs_[1]; }
2185 LOperand* value() { return inputs_[2]; }
2186 LOperand* temp_slot() { return temps_[0]; }
2187 LOperand* temp_vector() { return temps_[1]; }
2189 DECLARE_CONCRETE_INSTRUCTION(StoreNamedGeneric, "store-named-generic")
2190 DECLARE_HYDROGEN_ACCESSOR(StoreNamedGeneric)
2192 void PrintDataTo(StringStream* stream) override;
2193 Handle<Object> name() const { return hydrogen()->name(); }
2194 LanguageMode language_mode() { return hydrogen()->language_mode(); }
2198 class LStoreGlobalViaContext final : public LTemplateInstruction<0, 2, 0> {
2200 LStoreGlobalViaContext(LOperand* context, LOperand* value) {
2201 inputs_[0] = context;
2205 LOperand* context() { return inputs_[0]; }
2206 LOperand* value() { return inputs_[1]; }
2208 DECLARE_CONCRETE_INSTRUCTION(StoreGlobalViaContext,
2209 "store-global-via-context")
2210 DECLARE_HYDROGEN_ACCESSOR(StoreGlobalViaContext)
2212 void PrintDataTo(StringStream* stream) override;
2214 int depth() { return hydrogen()->depth(); }
2215 int slot_index() { return hydrogen()->slot_index(); }
2216 LanguageMode language_mode() { return hydrogen()->language_mode(); }
2220 class LStoreKeyed final : public LTemplateInstruction<0, 3, 0> {
2222 LStoreKeyed(LOperand* obj, LOperand* key, LOperand* val) {
2228 bool is_fixed_typed_array() const {
2229 return hydrogen()->is_fixed_typed_array();
2231 LOperand* elements() { return inputs_[0]; }
2232 LOperand* key() { return inputs_[1]; }
2233 LOperand* value() { return inputs_[2]; }
2234 ElementsKind elements_kind() const {
2235 return hydrogen()->elements_kind();
2238 DECLARE_CONCRETE_INSTRUCTION(StoreKeyed, "store-keyed")
2239 DECLARE_HYDROGEN_ACCESSOR(StoreKeyed)
2241 void PrintDataTo(StringStream* stream) override;
2242 uint32_t base_offset() const { return hydrogen()->base_offset(); }
2243 bool NeedsCanonicalization() { return hydrogen()->NeedsCanonicalization(); }
2247 class LStoreKeyedGeneric final : public LTemplateInstruction<0, 4, 2> {
2249 LStoreKeyedGeneric(LOperand* context, LOperand* object, LOperand* key,
2250 LOperand* value, LOperand* slot, LOperand* vector) {
2251 inputs_[0] = context;
2252 inputs_[1] = object;
2259 LOperand* context() { return inputs_[0]; }
2260 LOperand* object() { return inputs_[1]; }
2261 LOperand* key() { return inputs_[2]; }
2262 LOperand* value() { return inputs_[3]; }
2263 LOperand* temp_slot() { return temps_[0]; }
2264 LOperand* temp_vector() { return temps_[1]; }
2266 DECLARE_CONCRETE_INSTRUCTION(StoreKeyedGeneric, "store-keyed-generic")
2267 DECLARE_HYDROGEN_ACCESSOR(StoreKeyedGeneric)
2269 void PrintDataTo(StringStream* stream) override;
2271 LanguageMode language_mode() { return hydrogen()->language_mode(); }
2275 class LTransitionElementsKind final : public LTemplateInstruction<0, 2, 2> {
2277 LTransitionElementsKind(LOperand* object,
2279 LOperand* new_map_temp,
2281 inputs_[0] = object;
2282 inputs_[1] = context;
2283 temps_[0] = new_map_temp;
2287 LOperand* context() { return inputs_[1]; }
2288 LOperand* object() { return inputs_[0]; }
2289 LOperand* new_map_temp() { return temps_[0]; }
2290 LOperand* temp() { return temps_[1]; }
2292 DECLARE_CONCRETE_INSTRUCTION(TransitionElementsKind,
2293 "transition-elements-kind")
2294 DECLARE_HYDROGEN_ACCESSOR(TransitionElementsKind)
2296 void PrintDataTo(StringStream* stream) override;
2298 Handle<Map> original_map() { return hydrogen()->original_map().handle(); }
2299 Handle<Map> transitioned_map() {
2300 return hydrogen()->transitioned_map().handle();
2302 ElementsKind from_kind() { return hydrogen()->from_kind(); }
2303 ElementsKind to_kind() { return hydrogen()->to_kind(); }
2307 class LTrapAllocationMemento final : public LTemplateInstruction<0, 1, 1> {
2309 LTrapAllocationMemento(LOperand* object,
2311 inputs_[0] = object;
2315 LOperand* object() { return inputs_[0]; }
2316 LOperand* temp() { return temps_[0]; }
2318 DECLARE_CONCRETE_INSTRUCTION(TrapAllocationMemento,
2319 "trap-allocation-memento")
2323 class LMaybeGrowElements final : public LTemplateInstruction<1, 5, 0> {
2325 LMaybeGrowElements(LOperand* context, LOperand* object, LOperand* elements,
2326 LOperand* key, LOperand* current_capacity) {
2327 inputs_[0] = context;
2328 inputs_[1] = object;
2329 inputs_[2] = elements;
2331 inputs_[4] = current_capacity;
2334 LOperand* context() { return inputs_[0]; }
2335 LOperand* object() { return inputs_[1]; }
2336 LOperand* elements() { return inputs_[2]; }
2337 LOperand* key() { return inputs_[3]; }
2338 LOperand* current_capacity() { return inputs_[4]; }
2340 DECLARE_HYDROGEN_ACCESSOR(MaybeGrowElements)
2341 DECLARE_CONCRETE_INSTRUCTION(MaybeGrowElements, "maybe-grow-elements")
2345 class LStringAdd final : public LTemplateInstruction<1, 3, 0> {
2347 LStringAdd(LOperand* context, LOperand* left, LOperand* right) {
2348 inputs_[0] = context;
2353 LOperand* context() { return inputs_[0]; }
2354 LOperand* left() { return inputs_[1]; }
2355 LOperand* right() { return inputs_[2]; }
2357 DECLARE_CONCRETE_INSTRUCTION(StringAdd, "string-add")
2358 DECLARE_HYDROGEN_ACCESSOR(StringAdd)
2362 class LStringCharCodeAt final : public LTemplateInstruction<1, 3, 0> {
2364 LStringCharCodeAt(LOperand* context, LOperand* string, LOperand* index) {
2365 inputs_[0] = context;
2366 inputs_[1] = string;
2370 LOperand* context() { return inputs_[0]; }
2371 LOperand* string() { return inputs_[1]; }
2372 LOperand* index() { return inputs_[2]; }
2374 DECLARE_CONCRETE_INSTRUCTION(StringCharCodeAt, "string-char-code-at")
2375 DECLARE_HYDROGEN_ACCESSOR(StringCharCodeAt)
2379 class LStringCharFromCode final : public LTemplateInstruction<1, 2, 0> {
2381 LStringCharFromCode(LOperand* context, LOperand* char_code) {
2382 inputs_[0] = context;
2383 inputs_[1] = char_code;
2386 LOperand* context() { return inputs_[0]; }
2387 LOperand* char_code() { return inputs_[1]; }
2389 DECLARE_CONCRETE_INSTRUCTION(StringCharFromCode, "string-char-from-code")
2390 DECLARE_HYDROGEN_ACCESSOR(StringCharFromCode)
2394 class LCheckValue final : public LTemplateInstruction<0, 1, 0> {
2396 explicit LCheckValue(LOperand* value) {
2400 LOperand* value() { return inputs_[0]; }
2402 DECLARE_CONCRETE_INSTRUCTION(CheckValue, "check-value")
2403 DECLARE_HYDROGEN_ACCESSOR(CheckValue)
2407 class LCheckArrayBufferNotNeutered final
2408 : public LTemplateInstruction<0, 1, 1> {
2410 explicit LCheckArrayBufferNotNeutered(LOperand* view, LOperand* scratch) {
2412 temps_[0] = scratch;
2415 LOperand* view() { return inputs_[0]; }
2416 LOperand* scratch() { return temps_[0]; }
2418 DECLARE_CONCRETE_INSTRUCTION(CheckArrayBufferNotNeutered,
2419 "check-array-buffer-not-neutered")
2420 DECLARE_HYDROGEN_ACCESSOR(CheckArrayBufferNotNeutered)
2424 class LCheckInstanceType final : public LTemplateInstruction<0, 1, 1> {
2426 LCheckInstanceType(LOperand* value, LOperand* temp) {
2431 LOperand* value() { return inputs_[0]; }
2432 LOperand* temp() { return temps_[0]; }
2434 DECLARE_CONCRETE_INSTRUCTION(CheckInstanceType, "check-instance-type")
2435 DECLARE_HYDROGEN_ACCESSOR(CheckInstanceType)
2439 class LCheckMaps final : public LTemplateInstruction<0, 1, 0> {
2441 explicit LCheckMaps(LOperand* value = NULL) {
2445 LOperand* value() { return inputs_[0]; }
2447 DECLARE_CONCRETE_INSTRUCTION(CheckMaps, "check-maps")
2448 DECLARE_HYDROGEN_ACCESSOR(CheckMaps)
2452 class LCheckSmi final : public LTemplateInstruction<1, 1, 0> {
2454 explicit LCheckSmi(LOperand* value) {
2458 LOperand* value() { return inputs_[0]; }
2460 DECLARE_CONCRETE_INSTRUCTION(CheckSmi, "check-smi")
2464 class LClampDToUint8 final : public LTemplateInstruction<1, 1, 0> {
2466 explicit LClampDToUint8(LOperand* value) {
2470 LOperand* unclamped() { return inputs_[0]; }
2472 DECLARE_CONCRETE_INSTRUCTION(ClampDToUint8, "clamp-d-to-uint8")
2476 class LClampIToUint8 final : public LTemplateInstruction<1, 1, 0> {
2478 explicit LClampIToUint8(LOperand* value) {
2482 LOperand* unclamped() { return inputs_[0]; }
2484 DECLARE_CONCRETE_INSTRUCTION(ClampIToUint8, "clamp-i-to-uint8")
2488 class LClampTToUint8 final : public LTemplateInstruction<1, 1, 1> {
2490 LClampTToUint8(LOperand* value, LOperand* temp_xmm) {
2492 temps_[0] = temp_xmm;
2495 LOperand* unclamped() { return inputs_[0]; }
2496 LOperand* temp_xmm() { return temps_[0]; }
2498 DECLARE_CONCRETE_INSTRUCTION(ClampTToUint8, "clamp-t-to-uint8")
2502 class LCheckNonSmi final : public LTemplateInstruction<0, 1, 0> {
2504 explicit LCheckNonSmi(LOperand* value) {
2508 LOperand* value() { return inputs_[0]; }
2510 DECLARE_CONCRETE_INSTRUCTION(CheckNonSmi, "check-non-smi")
2511 DECLARE_HYDROGEN_ACCESSOR(CheckHeapObject)
2515 class LDoubleBits final : public LTemplateInstruction<1, 1, 0> {
2517 explicit LDoubleBits(LOperand* value) {
2521 LOperand* value() { return inputs_[0]; }
2523 DECLARE_CONCRETE_INSTRUCTION(DoubleBits, "double-bits")
2524 DECLARE_HYDROGEN_ACCESSOR(DoubleBits)
2528 class LConstructDouble final : public LTemplateInstruction<1, 2, 0> {
2530 LConstructDouble(LOperand* hi, LOperand* lo) {
2535 LOperand* hi() { return inputs_[0]; }
2536 LOperand* lo() { return inputs_[1]; }
2538 DECLARE_CONCRETE_INSTRUCTION(ConstructDouble, "construct-double")
2542 class LAllocate final : public LTemplateInstruction<1, 2, 1> {
2544 LAllocate(LOperand* context, LOperand* size, LOperand* temp) {
2545 inputs_[0] = context;
2550 LOperand* context() { return inputs_[0]; }
2551 LOperand* size() { return inputs_[1]; }
2552 LOperand* temp() { return temps_[0]; }
2554 DECLARE_CONCRETE_INSTRUCTION(Allocate, "allocate")
2555 DECLARE_HYDROGEN_ACCESSOR(Allocate)
2559 class LRegExpLiteral final : public LTemplateInstruction<1, 1, 0> {
2561 explicit LRegExpLiteral(LOperand* context) {
2562 inputs_[0] = context;
2565 LOperand* context() { return inputs_[0]; }
2567 DECLARE_CONCRETE_INSTRUCTION(RegExpLiteral, "regexp-literal")
2568 DECLARE_HYDROGEN_ACCESSOR(RegExpLiteral)
2572 class LToFastProperties final : public LTemplateInstruction<1, 1, 0> {
2574 explicit LToFastProperties(LOperand* value) {
2578 LOperand* value() { return inputs_[0]; }
2580 DECLARE_CONCRETE_INSTRUCTION(ToFastProperties, "to-fast-properties")
2581 DECLARE_HYDROGEN_ACCESSOR(ToFastProperties)
2585 class LTypeof final : public LTemplateInstruction<1, 2, 0> {
2587 LTypeof(LOperand* context, LOperand* value) {
2588 inputs_[0] = context;
2592 LOperand* context() { return inputs_[0]; }
2593 LOperand* value() { return inputs_[1]; }
2595 DECLARE_CONCRETE_INSTRUCTION(Typeof, "typeof")
2599 class LTypeofIsAndBranch final : public LControlInstruction<1, 0> {
2601 explicit LTypeofIsAndBranch(LOperand* value) {
2605 LOperand* value() { return inputs_[0]; }
2607 DECLARE_CONCRETE_INSTRUCTION(TypeofIsAndBranch, "typeof-is-and-branch")
2608 DECLARE_HYDROGEN_ACCESSOR(TypeofIsAndBranch)
2610 Handle<String> type_literal() { return hydrogen()->type_literal(); }
2612 void PrintDataTo(StringStream* stream) override;
2616 class LOsrEntry final : public LTemplateInstruction<0, 0, 0> {
2618 bool HasInterestingComment(LCodeGen* gen) const override { return false; }
2619 DECLARE_CONCRETE_INSTRUCTION(OsrEntry, "osr-entry")
2623 class LStackCheck final : public LTemplateInstruction<0, 1, 0> {
2625 explicit LStackCheck(LOperand* context) {
2626 inputs_[0] = context;
2629 LOperand* context() { return inputs_[0]; }
2631 DECLARE_CONCRETE_INSTRUCTION(StackCheck, "stack-check")
2632 DECLARE_HYDROGEN_ACCESSOR(StackCheck)
2634 Label* done_label() { return &done_label_; }
2641 class LForInPrepareMap final : public LTemplateInstruction<1, 2, 0> {
2643 LForInPrepareMap(LOperand* context, LOperand* object) {
2644 inputs_[0] = context;
2645 inputs_[1] = object;
2648 LOperand* context() { return inputs_[0]; }
2649 LOperand* object() { return inputs_[1]; }
2651 DECLARE_CONCRETE_INSTRUCTION(ForInPrepareMap, "for-in-prepare-map")
2655 class LForInCacheArray final : public LTemplateInstruction<1, 1, 0> {
2657 explicit LForInCacheArray(LOperand* map) {
2661 LOperand* map() { return inputs_[0]; }
2663 DECLARE_CONCRETE_INSTRUCTION(ForInCacheArray, "for-in-cache-array")
2666 return HForInCacheArray::cast(this->hydrogen_value())->idx();
2671 class LCheckMapValue final : public LTemplateInstruction<0, 2, 0> {
2673 LCheckMapValue(LOperand* value, LOperand* map) {
2678 LOperand* value() { return inputs_[0]; }
2679 LOperand* map() { return inputs_[1]; }
2681 DECLARE_CONCRETE_INSTRUCTION(CheckMapValue, "check-map-value")
2685 class LLoadFieldByIndex final : public LTemplateInstruction<1, 2, 0> {
2687 LLoadFieldByIndex(LOperand* object, LOperand* index) {
2688 inputs_[0] = object;
2692 LOperand* object() { return inputs_[0]; }
2693 LOperand* index() { return inputs_[1]; }
2695 DECLARE_CONCRETE_INSTRUCTION(LoadFieldByIndex, "load-field-by-index")
2699 class LStoreFrameContext: public LTemplateInstruction<0, 1, 0> {
2701 explicit LStoreFrameContext(LOperand* context) {
2702 inputs_[0] = context;
2705 LOperand* context() { return inputs_[0]; }
2707 DECLARE_CONCRETE_INSTRUCTION(StoreFrameContext, "store-frame-context")
2711 class LAllocateBlockContext: public LTemplateInstruction<1, 2, 0> {
2713 LAllocateBlockContext(LOperand* context, LOperand* function) {
2714 inputs_[0] = context;
2715 inputs_[1] = function;
2718 LOperand* context() { return inputs_[0]; }
2719 LOperand* function() { return inputs_[1]; }
2721 Handle<ScopeInfo> scope_info() { return hydrogen()->scope_info(); }
2723 DECLARE_CONCRETE_INSTRUCTION(AllocateBlockContext, "allocate-block-context")
2724 DECLARE_HYDROGEN_ACCESSOR(AllocateBlockContext)
2728 class LChunkBuilder;
2729 class LPlatformChunk final : public LChunk {
2731 LPlatformChunk(CompilationInfo* info, HGraph* graph)
2732 : LChunk(info, graph),
2733 num_double_slots_(0) { }
2735 int GetNextSpillIndex(RegisterKind kind);
2736 LOperand* GetNextSpillSlot(RegisterKind kind);
2738 int num_double_slots() const { return num_double_slots_; }
2741 int num_double_slots_;
2745 class LChunkBuilder final : public LChunkBuilderBase {
2747 LChunkBuilder(CompilationInfo* info, HGraph* graph, LAllocator* allocator)
2748 : LChunkBuilderBase(info, graph),
2749 current_instruction_(NULL),
2750 current_block_(NULL),
2752 allocator_(allocator) {}
2754 // Build the sequence for the graph.
2755 LPlatformChunk* Build();
2757 // Declare methods that deal with the individual node types.
2758 #define DECLARE_DO(type) LInstruction* Do##type(H##type* node);
2759 HYDROGEN_CONCRETE_INSTRUCTION_LIST(DECLARE_DO)
2762 LInstruction* DoMathFloor(HUnaryMathOperation* instr);
2763 LInstruction* DoMathRound(HUnaryMathOperation* instr);
2764 LInstruction* DoMathFround(HUnaryMathOperation* instr);
2765 LInstruction* DoMathAbs(HUnaryMathOperation* instr);
2766 LInstruction* DoMathLog(HUnaryMathOperation* instr);
2767 LInstruction* DoMathExp(HUnaryMathOperation* instr);
2768 LInstruction* DoMathSqrt(HUnaryMathOperation* instr);
2769 LInstruction* DoMathPowHalf(HUnaryMathOperation* instr);
2770 LInstruction* DoMathClz32(HUnaryMathOperation* instr);
2771 LInstruction* DoDivByPowerOf2I(HDiv* instr);
2772 LInstruction* DoDivByConstI(HDiv* instr);
2773 LInstruction* DoDivI(HDiv* instr);
2774 LInstruction* DoModByPowerOf2I(HMod* instr);
2775 LInstruction* DoModByConstI(HMod* instr);
2776 LInstruction* DoModI(HMod* instr);
2777 LInstruction* DoFlooringDivByPowerOf2I(HMathFloorOfDiv* instr);
2778 LInstruction* DoFlooringDivByConstI(HMathFloorOfDiv* instr);
2779 LInstruction* DoFlooringDivI(HMathFloorOfDiv* instr);
2782 // Methods for getting operands for Use / Define / Temp.
2783 LUnallocated* ToUnallocated(Register reg);
2784 LUnallocated* ToUnallocated(XMMRegister reg);
2786 // Methods for setting up define-use relationships.
2787 MUST_USE_RESULT LOperand* Use(HValue* value, LUnallocated* operand);
2788 MUST_USE_RESULT LOperand* UseFixed(HValue* value, Register fixed_register);
2789 MUST_USE_RESULT LOperand* UseFixedDouble(HValue* value,
2790 XMMRegister fixed_register);
2792 // A value that is guaranteed to be allocated to a register.
2793 // Operand created by UseRegister is guaranteed to be live until the end of
2794 // instruction. This means that register allocator will not reuse it's
2795 // register for any other operand inside instruction.
2796 // Operand created by UseRegisterAtStart is guaranteed to be live only at
2797 // instruction start. Register allocator is free to assign the same register
2798 // to some other operand used inside instruction (i.e. temporary or
2800 MUST_USE_RESULT LOperand* UseRegister(HValue* value);
2801 MUST_USE_RESULT LOperand* UseRegisterAtStart(HValue* value);
2803 // An input operand in a register that may be trashed.
2804 MUST_USE_RESULT LOperand* UseTempRegister(HValue* value);
2806 // An input operand in a register or stack slot.
2807 MUST_USE_RESULT LOperand* Use(HValue* value);
2808 MUST_USE_RESULT LOperand* UseAtStart(HValue* value);
2810 // An input operand in a register, stack slot or a constant operand.
2811 MUST_USE_RESULT LOperand* UseOrConstant(HValue* value);
2812 MUST_USE_RESULT LOperand* UseOrConstantAtStart(HValue* value);
2814 // An input operand in a fixed register or a constant operand.
2815 MUST_USE_RESULT LOperand* UseFixedOrConstant(HValue* value,
2816 Register fixed_register);
2818 // An input operand in a register or a constant operand.
2819 MUST_USE_RESULT LOperand* UseRegisterOrConstant(HValue* value);
2820 MUST_USE_RESULT LOperand* UseRegisterOrConstantAtStart(HValue* value);
2822 // An input operand in a constant operand.
2823 MUST_USE_RESULT LOperand* UseConstant(HValue* value);
2825 // An input operand in register, stack slot or a constant operand.
2826 // Will not be moved to a register even if one is freely available.
2827 MUST_USE_RESULT LOperand* UseAny(HValue* value) override;
2829 // Temporary operand that must be in a register.
2830 MUST_USE_RESULT LUnallocated* TempRegister();
2831 MUST_USE_RESULT LOperand* FixedTemp(Register reg);
2832 MUST_USE_RESULT LOperand* FixedTemp(XMMRegister reg);
2834 // Methods for setting up define-use relationships.
2835 // Return the same instruction that they are passed.
2836 LInstruction* Define(LTemplateResultInstruction<1>* instr,
2837 LUnallocated* result);
2838 LInstruction* DefineAsRegister(LTemplateResultInstruction<1>* instr);
2839 LInstruction* DefineAsSpilled(LTemplateResultInstruction<1>* instr,
2841 LInstruction* DefineSameAsFirst(LTemplateResultInstruction<1>* instr);
2842 LInstruction* DefineFixed(LTemplateResultInstruction<1>* instr,
2844 LInstruction* DefineFixedDouble(LTemplateResultInstruction<1>* instr,
2846 // Assigns an environment to an instruction. An instruction which can
2847 // deoptimize must have an environment.
2848 LInstruction* AssignEnvironment(LInstruction* instr);
2849 // Assigns a pointer map to an instruction. An instruction which can
2850 // trigger a GC or a lazy deoptimization must have a pointer map.
2851 LInstruction* AssignPointerMap(LInstruction* instr);
2853 enum CanDeoptimize { CAN_DEOPTIMIZE_EAGERLY, CANNOT_DEOPTIMIZE_EAGERLY };
2855 LOperand* GetSeqStringSetCharOperand(HSeqStringSetChar* instr);
2857 // Marks a call for the register allocator. Assigns a pointer map to
2858 // support GC and lazy deoptimization. Assigns an environment to support
2859 // eager deoptimization if CAN_DEOPTIMIZE_EAGERLY.
2860 LInstruction* MarkAsCall(
2861 LInstruction* instr,
2862 HInstruction* hinstr,
2863 CanDeoptimize can_deoptimize = CANNOT_DEOPTIMIZE_EAGERLY);
2865 void VisitInstruction(HInstruction* current);
2866 void AddInstruction(LInstruction* instr, HInstruction* current);
2868 void DoBasicBlock(HBasicBlock* block, HBasicBlock* next_block);
2869 LInstruction* DoShift(Token::Value op, HBitwiseBinaryOperation* instr);
2870 LInstruction* DoArithmeticD(Token::Value op,
2871 HArithmeticBinaryOperation* instr);
2872 LInstruction* DoArithmeticT(Token::Value op,
2873 HBinaryOperation* instr);
2875 LOperand* GetStoreKeyedValueOperand(HStoreKeyed* instr);
2877 HInstruction* current_instruction_;
2878 HBasicBlock* current_block_;
2879 HBasicBlock* next_block_;
2880 LAllocator* allocator_;
2882 DISALLOW_COPY_AND_ASSIGN(LChunkBuilder);
2885 #undef DECLARE_HYDROGEN_ACCESSOR
2886 #undef DECLARE_CONCRETE_INSTRUCTION
2888 } } // namespace v8::internal
2890 #endif // V8_IA32_LITHIUM_IA32_H_