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_X64_LITHIUM_X64_H_
6 #define V8_X64_LITHIUM_X64_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"
17 // Forward declarations.
20 #define LITHIUM_CONCRETE_INSTRUCTION_LIST(V) \
21 V(AccessArgumentsAt) \
24 V(AllocateBlockContext) \
26 V(ArgumentsElements) \
34 V(CallWithDescriptor) \
40 V(CheckArrayBufferNotNeutered) \
41 V(CheckInstanceType) \
50 V(ClassOfTestAndBranch) \
51 V(CompareMinusZeroAndBranch) \
52 V(CompareNumericAndBranch) \
53 V(CmpObjectEqAndBranch) \
77 V(FlooringDivByConstI) \
78 V(FlooringDivByPowerOf2I) \
83 V(GetCachedArrayIndex) \
85 V(HasCachedArrayIndexAndBranch) \
86 V(HasInstanceTypeAndBranch) \
87 V(InnerAllocatedObject) \
89 V(InstanceOfKnownGlobal) \
91 V(Integer32ToDouble) \
93 V(IsConstructCallAndBranch) \
94 V(IsObjectAndBranch) \
95 V(IsStringAndBranch) \
97 V(IsUndetectableAndBranch) \
102 V(LoadFieldByIndex) \
103 V(LoadFunctionPrototype) \
104 V(LoadGlobalGeneric) \
106 V(LoadKeyedGeneric) \
108 V(LoadNamedGeneric) \
120 V(MaybeGrowElements) \
135 V(SeqStringGetChar) \
136 V(SeqStringSetChar) \
142 V(StoreContextSlot) \
143 V(StoreFrameContext) \
145 V(StoreKeyedGeneric) \
147 V(StoreNamedGeneric) \
149 V(StringCharCodeAt) \
150 V(StringCharFromCode) \
151 V(StringCompareAndBranch) \
155 V(ToFastProperties) \
156 V(TransitionElementsKind) \
157 V(TrapAllocationMemento) \
159 V(TypeofIsAndBranch) \
165 #define DECLARE_CONCRETE_INSTRUCTION(type, mnemonic) \
166 Opcode opcode() const final { return LInstruction::k##type; } \
167 void CompileToNative(LCodeGen* generator) final; \
168 const char* Mnemonic() const final { return mnemonic; } \
169 static L##type* cast(LInstruction* instr) { \
170 DCHECK(instr->Is##type()); \
171 return reinterpret_cast<L##type*>(instr); \
175 #define DECLARE_HYDROGEN_ACCESSOR(type) \
176 H##type* hydrogen() const { \
177 return H##type::cast(hydrogen_value()); \
181 class LInstruction : public ZoneObject {
184 : environment_(NULL),
185 hydrogen_value_(NULL),
186 bit_field_(IsCallBits::encode(false)) {
189 virtual ~LInstruction() {}
191 virtual void CompileToNative(LCodeGen* generator) = 0;
192 virtual const char* Mnemonic() const = 0;
193 virtual void PrintTo(StringStream* stream);
194 virtual void PrintDataTo(StringStream* stream);
195 virtual void PrintOutputOperandTo(StringStream* stream);
198 // Declare a unique enum value for each instruction.
199 #define DECLARE_OPCODE(type) k##type,
200 LITHIUM_CONCRETE_INSTRUCTION_LIST(DECLARE_OPCODE)
201 kNumberOfInstructions
202 #undef DECLARE_OPCODE
205 virtual Opcode opcode() const = 0;
207 // Declare non-virtual type testers for all leaf IR classes.
208 #define DECLARE_PREDICATE(type) \
209 bool Is##type() const { return opcode() == k##type; }
210 LITHIUM_CONCRETE_INSTRUCTION_LIST(DECLARE_PREDICATE)
211 #undef DECLARE_PREDICATE
213 // Declare virtual predicates for instructions that don't have
215 virtual bool IsGap() const { return false; }
217 virtual bool IsControl() const { return false; }
219 // Try deleting this instruction if possible.
220 virtual bool TryDelete() { return false; }
222 void set_environment(LEnvironment* env) { environment_ = env; }
223 LEnvironment* environment() const { return environment_; }
224 bool HasEnvironment() const { return environment_ != NULL; }
226 void set_pointer_map(LPointerMap* p) { pointer_map_.set(p); }
227 LPointerMap* pointer_map() const { return pointer_map_.get(); }
228 bool HasPointerMap() const { return pointer_map_.is_set(); }
230 void set_hydrogen_value(HValue* value) { hydrogen_value_ = value; }
231 HValue* hydrogen_value() const { return hydrogen_value_; }
233 void MarkAsCall() { bit_field_ = IsCallBits::update(bit_field_, true); }
234 bool IsCall() const { return IsCallBits::decode(bit_field_); }
236 // Interface to the register allocator and iterators.
237 bool ClobbersTemps() const { return IsCall(); }
238 bool ClobbersRegisters() const { return IsCall(); }
239 virtual bool ClobbersDoubleRegisters(Isolate* isolate) const {
243 virtual void SetDeferredLazyDeoptimizationEnvironment(LEnvironment* env) { }
245 // Interface to the register allocator and iterators.
246 bool IsMarkedAsCall() const { return IsCall(); }
248 virtual bool HasResult() const = 0;
249 virtual LOperand* result() const = 0;
251 LOperand* FirstInput() { return InputAt(0); }
252 LOperand* Output() { return HasResult() ? result() : NULL; }
254 virtual bool HasInterestingComment(LCodeGen* gen) const { return true; }
256 virtual bool MustSignExtendResult(LPlatformChunk* chunk) const {
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]; }
294 bool MustSignExtendResult(LPlatformChunk* chunk) const final;
297 EmbeddedContainer<LOperand*, R> results_;
301 // R = number of result operands (0 or 1).
302 // I = number of input operands.
303 // T = number of temporary operands.
304 template<int R, int I, int T>
305 class LTemplateInstruction : public LTemplateResultInstruction<R> {
307 EmbeddedContainer<LOperand*, I> inputs_;
308 EmbeddedContainer<LOperand*, T> temps_;
312 int InputCount() final { return I; }
313 LOperand* InputAt(int i) final { return inputs_[i]; }
315 int TempCount() final { return T; }
316 LOperand* TempAt(int i) final { return temps_[i]; }
320 class LGap : public LTemplateInstruction<0, 0, 0> {
322 explicit LGap(HBasicBlock* block)
324 parallel_moves_[BEFORE] = NULL;
325 parallel_moves_[START] = NULL;
326 parallel_moves_[END] = NULL;
327 parallel_moves_[AFTER] = NULL;
330 // Can't use the DECLARE-macro here because of sub-classes.
331 bool IsGap() const final { return true; }
332 void PrintDataTo(StringStream* stream) override;
333 static LGap* cast(LInstruction* instr) {
334 DCHECK(instr->IsGap());
335 return reinterpret_cast<LGap*>(instr);
338 bool IsRedundant() const;
340 HBasicBlock* block() const { return block_; }
347 FIRST_INNER_POSITION = BEFORE,
348 LAST_INNER_POSITION = AFTER
351 LParallelMove* GetOrCreateParallelMove(InnerPosition pos,
353 if (parallel_moves_[pos] == NULL) {
354 parallel_moves_[pos] = new(zone) LParallelMove(zone);
356 return parallel_moves_[pos];
359 LParallelMove* GetParallelMove(InnerPosition pos) {
360 return parallel_moves_[pos];
364 LParallelMove* parallel_moves_[LAST_INNER_POSITION + 1];
369 class LInstructionGap final : public LGap {
371 explicit LInstructionGap(HBasicBlock* block) : LGap(block) { }
373 bool HasInterestingComment(LCodeGen* gen) const override {
374 return !IsRedundant();
377 DECLARE_CONCRETE_INSTRUCTION(InstructionGap, "gap")
381 class LGoto final : public LTemplateInstruction<0, 0, 0> {
383 explicit LGoto(HBasicBlock* block) : block_(block) { }
385 bool HasInterestingComment(LCodeGen* gen) const override;
386 DECLARE_CONCRETE_INSTRUCTION(Goto, "goto")
387 void PrintDataTo(StringStream* stream) override;
388 bool IsControl() const override { return true; }
390 int block_id() const { return block_->block_id(); }
397 class LLazyBailout final : public LTemplateInstruction<0, 0, 0> {
399 LLazyBailout() : gap_instructions_size_(0) { }
401 DECLARE_CONCRETE_INSTRUCTION(LazyBailout, "lazy-bailout")
403 void set_gap_instructions_size(int gap_instructions_size) {
404 gap_instructions_size_ = gap_instructions_size;
406 int gap_instructions_size() { return gap_instructions_size_; }
409 int gap_instructions_size_;
413 class LDummy final : public LTemplateInstruction<1, 0, 0> {
416 DECLARE_CONCRETE_INSTRUCTION(Dummy, "dummy")
420 class LDummyUse final : public LTemplateInstruction<1, 1, 0> {
422 explicit LDummyUse(LOperand* value) {
425 DECLARE_CONCRETE_INSTRUCTION(DummyUse, "dummy-use")
429 class LDeoptimize final : public LTemplateInstruction<0, 0, 0> {
431 bool IsControl() const override { return true; }
432 DECLARE_CONCRETE_INSTRUCTION(Deoptimize, "deoptimize")
433 DECLARE_HYDROGEN_ACCESSOR(Deoptimize)
437 class LLabel final : public LGap {
439 explicit LLabel(HBasicBlock* block)
440 : LGap(block), replacement_(NULL) { }
442 bool HasInterestingComment(LCodeGen* gen) const override { return false; }
443 DECLARE_CONCRETE_INSTRUCTION(Label, "label")
445 void PrintDataTo(StringStream* stream) override;
447 int block_id() const { return block()->block_id(); }
448 bool is_loop_header() const { return block()->IsLoopHeader(); }
449 bool is_osr_entry() const { return block()->is_osr_entry(); }
450 Label* label() { return &label_; }
451 LLabel* replacement() const { return replacement_; }
452 void set_replacement(LLabel* label) { replacement_ = label; }
453 bool HasReplacement() const { return replacement_ != NULL; }
457 LLabel* replacement_;
461 class LParameter final : public LTemplateInstruction<1, 0, 0> {
463 bool HasInterestingComment(LCodeGen* gen) const override { return false; }
464 DECLARE_CONCRETE_INSTRUCTION(Parameter, "parameter")
468 class LCallStub final : public LTemplateInstruction<1, 1, 0> {
470 explicit LCallStub(LOperand* context) {
471 inputs_[0] = context;
474 LOperand* context() { return inputs_[0]; }
476 DECLARE_CONCRETE_INSTRUCTION(CallStub, "call-stub")
477 DECLARE_HYDROGEN_ACCESSOR(CallStub)
481 class LUnknownOSRValue final : public LTemplateInstruction<1, 0, 0> {
483 bool HasInterestingComment(LCodeGen* gen) const override { return false; }
484 DECLARE_CONCRETE_INSTRUCTION(UnknownOSRValue, "unknown-osr-value")
488 template<int I, int T>
489 class LControlInstruction : public LTemplateInstruction<0, I, T> {
491 LControlInstruction() : false_label_(NULL), true_label_(NULL) { }
493 bool IsControl() const final { return true; }
495 int SuccessorCount() { return hydrogen()->SuccessorCount(); }
496 HBasicBlock* SuccessorAt(int i) { return hydrogen()->SuccessorAt(i); }
498 int TrueDestination(LChunk* chunk) {
499 return chunk->LookupDestination(true_block_id());
501 int FalseDestination(LChunk* chunk) {
502 return chunk->LookupDestination(false_block_id());
505 Label* TrueLabel(LChunk* chunk) {
506 if (true_label_ == NULL) {
507 true_label_ = chunk->GetAssemblyLabel(TrueDestination(chunk));
511 Label* FalseLabel(LChunk* chunk) {
512 if (false_label_ == NULL) {
513 false_label_ = chunk->GetAssemblyLabel(FalseDestination(chunk));
519 int true_block_id() { return SuccessorAt(0)->block_id(); }
520 int false_block_id() { return SuccessorAt(1)->block_id(); }
523 HControlInstruction* hydrogen() {
524 return HControlInstruction::cast(this->hydrogen_value());
532 class LWrapReceiver final : public LTemplateInstruction<1, 2, 0> {
534 LWrapReceiver(LOperand* receiver, LOperand* function) {
535 inputs_[0] = receiver;
536 inputs_[1] = function;
539 LOperand* receiver() { return inputs_[0]; }
540 LOperand* function() { return inputs_[1]; }
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 LModByPowerOf2I final : public LTemplateInstruction<1, 1, 0> {
607 LModByPowerOf2I(LOperand* dividend, int32_t divisor) {
608 inputs_[0] = dividend;
612 LOperand* dividend() { return inputs_[0]; }
613 int32_t divisor() const { return divisor_; }
615 DECLARE_CONCRETE_INSTRUCTION(ModByPowerOf2I, "mod-by-power-of-2-i")
616 DECLARE_HYDROGEN_ACCESSOR(Mod)
623 class LModByConstI final : public LTemplateInstruction<1, 1, 2> {
625 LModByConstI(LOperand* dividend,
629 inputs_[0] = dividend;
635 LOperand* dividend() { return inputs_[0]; }
636 int32_t divisor() const { return divisor_; }
637 LOperand* temp1() { return temps_[0]; }
638 LOperand* temp2() { return temps_[1]; }
640 DECLARE_CONCRETE_INSTRUCTION(ModByConstI, "mod-by-const-i")
641 DECLARE_HYDROGEN_ACCESSOR(Mod)
648 class LModI final : public LTemplateInstruction<1, 2, 1> {
650 LModI(LOperand* left, LOperand* right, LOperand* temp) {
656 LOperand* left() { return inputs_[0]; }
657 LOperand* right() { return inputs_[1]; }
658 LOperand* temp() { return temps_[0]; }
660 DECLARE_CONCRETE_INSTRUCTION(ModI, "mod-i")
661 DECLARE_HYDROGEN_ACCESSOR(Mod)
665 class LDivByPowerOf2I final : public LTemplateInstruction<1, 1, 0> {
667 LDivByPowerOf2I(LOperand* dividend, int32_t divisor) {
668 inputs_[0] = dividend;
672 LOperand* dividend() { return inputs_[0]; }
673 int32_t divisor() const { return divisor_; }
675 DECLARE_CONCRETE_INSTRUCTION(DivByPowerOf2I, "div-by-power-of-2-i")
676 DECLARE_HYDROGEN_ACCESSOR(Div)
683 class LDivByConstI final : public LTemplateInstruction<1, 1, 2> {
685 LDivByConstI(LOperand* dividend,
689 inputs_[0] = dividend;
695 LOperand* dividend() { return inputs_[0]; }
696 int32_t divisor() const { return divisor_; }
697 LOperand* temp1() { return temps_[0]; }
698 LOperand* temp2() { return temps_[1]; }
700 DECLARE_CONCRETE_INSTRUCTION(DivByConstI, "div-by-const-i")
701 DECLARE_HYDROGEN_ACCESSOR(Div)
708 class LDivI final : public LTemplateInstruction<1, 2, 1> {
710 LDivI(LOperand* dividend, LOperand* divisor, LOperand* temp) {
711 inputs_[0] = dividend;
712 inputs_[1] = divisor;
716 LOperand* dividend() { return inputs_[0]; }
717 LOperand* divisor() { return inputs_[1]; }
718 LOperand* temp() { return temps_[0]; }
720 DECLARE_CONCRETE_INSTRUCTION(DivI, "div-i")
721 DECLARE_HYDROGEN_ACCESSOR(BinaryOperation)
725 class LFlooringDivByPowerOf2I final : public LTemplateInstruction<1, 1, 0> {
727 LFlooringDivByPowerOf2I(LOperand* dividend, int32_t divisor) {
728 inputs_[0] = dividend;
732 LOperand* dividend() { return inputs_[0]; }
733 int32_t divisor() const { return divisor_; }
735 DECLARE_CONCRETE_INSTRUCTION(FlooringDivByPowerOf2I,
736 "flooring-div-by-power-of-2-i")
737 DECLARE_HYDROGEN_ACCESSOR(MathFloorOfDiv)
744 class LFlooringDivByConstI final : public LTemplateInstruction<1, 1, 3> {
746 LFlooringDivByConstI(LOperand* dividend,
751 inputs_[0] = dividend;
758 LOperand* dividend() { return inputs_[0]; }
759 int32_t divisor() const { return divisor_; }
760 LOperand* temp1() { return temps_[0]; }
761 LOperand* temp2() { return temps_[1]; }
762 LOperand* temp3() { return temps_[2]; }
764 DECLARE_CONCRETE_INSTRUCTION(FlooringDivByConstI, "flooring-div-by-const-i")
765 DECLARE_HYDROGEN_ACCESSOR(MathFloorOfDiv)
772 class LFlooringDivI final : public LTemplateInstruction<1, 2, 1> {
774 LFlooringDivI(LOperand* dividend, LOperand* divisor, LOperand* temp) {
775 inputs_[0] = dividend;
776 inputs_[1] = divisor;
780 LOperand* dividend() { return inputs_[0]; }
781 LOperand* divisor() { return inputs_[1]; }
782 LOperand* temp() { return temps_[0]; }
784 DECLARE_CONCRETE_INSTRUCTION(FlooringDivI, "flooring-div-i")
785 DECLARE_HYDROGEN_ACCESSOR(MathFloorOfDiv)
789 class LMulI final : public LTemplateInstruction<1, 2, 0> {
791 LMulI(LOperand* left, LOperand* right) {
796 LOperand* left() { return inputs_[0]; }
797 LOperand* right() { return inputs_[1]; }
799 DECLARE_CONCRETE_INSTRUCTION(MulI, "mul-i")
800 DECLARE_HYDROGEN_ACCESSOR(Mul)
804 class LCompareNumericAndBranch final : public LControlInstruction<2, 0> {
806 LCompareNumericAndBranch(LOperand* left, LOperand* right) {
811 LOperand* left() { return inputs_[0]; }
812 LOperand* right() { return inputs_[1]; }
814 DECLARE_CONCRETE_INSTRUCTION(CompareNumericAndBranch,
815 "compare-numeric-and-branch")
816 DECLARE_HYDROGEN_ACCESSOR(CompareNumericAndBranch)
818 Token::Value op() const { return hydrogen()->token(); }
819 bool is_double() const {
820 return hydrogen()->representation().IsDouble();
823 void PrintDataTo(StringStream* stream) override;
827 class LMathFloor final : public LTemplateInstruction<1, 1, 0> {
829 explicit LMathFloor(LOperand* value) {
833 LOperand* value() { return inputs_[0]; }
835 DECLARE_CONCRETE_INSTRUCTION(MathFloor, "math-floor")
836 DECLARE_HYDROGEN_ACCESSOR(UnaryMathOperation)
840 class LMathRound final : public LTemplateInstruction<1, 1, 1> {
842 LMathRound(LOperand* value, LOperand* temp) {
847 LOperand* value() { return inputs_[0]; }
848 LOperand* temp() { return temps_[0]; }
850 DECLARE_CONCRETE_INSTRUCTION(MathRound, "math-round")
851 DECLARE_HYDROGEN_ACCESSOR(UnaryMathOperation)
855 class LMathFround final : public LTemplateInstruction<1, 1, 0> {
857 explicit LMathFround(LOperand* value) { inputs_[0] = value; }
859 LOperand* value() { return inputs_[0]; }
861 DECLARE_CONCRETE_INSTRUCTION(MathFround, "math-fround")
865 class LMathAbs final : public LTemplateInstruction<1, 2, 0> {
867 explicit LMathAbs(LOperand* context, LOperand* value) {
868 inputs_[1] = context;
872 LOperand* context() { return inputs_[1]; }
873 LOperand* value() { return inputs_[0]; }
875 DECLARE_CONCRETE_INSTRUCTION(MathAbs, "math-abs")
876 DECLARE_HYDROGEN_ACCESSOR(UnaryMathOperation)
880 class LMathLog final : public LTemplateInstruction<1, 1, 0> {
882 explicit LMathLog(LOperand* value) {
886 LOperand* value() { return inputs_[0]; }
888 DECLARE_CONCRETE_INSTRUCTION(MathLog, "math-log")
892 class LMathClz32 final : public LTemplateInstruction<1, 1, 0> {
894 explicit LMathClz32(LOperand* value) {
898 LOperand* value() { return inputs_[0]; }
900 DECLARE_CONCRETE_INSTRUCTION(MathClz32, "math-clz32")
904 class LMathExp final : public LTemplateInstruction<1, 1, 2> {
906 LMathExp(LOperand* value, LOperand* temp1, LOperand* temp2) {
910 ExternalReference::InitializeMathExpData();
913 LOperand* value() { return inputs_[0]; }
914 LOperand* temp1() { return temps_[0]; }
915 LOperand* temp2() { return temps_[1]; }
917 DECLARE_CONCRETE_INSTRUCTION(MathExp, "math-exp")
921 class LMathSqrt final : public LTemplateInstruction<1, 1, 0> {
923 explicit LMathSqrt(LOperand* value) {
927 LOperand* value() { return inputs_[0]; }
929 DECLARE_CONCRETE_INSTRUCTION(MathSqrt, "math-sqrt")
933 class LMathPowHalf final : public LTemplateInstruction<1, 1, 0> {
935 explicit LMathPowHalf(LOperand* value) {
939 LOperand* value() { return inputs_[0]; }
941 DECLARE_CONCRETE_INSTRUCTION(MathPowHalf, "math-pow-half")
945 class LCmpObjectEqAndBranch final : public LControlInstruction<2, 0> {
947 LCmpObjectEqAndBranch(LOperand* left, LOperand* right) {
952 LOperand* left() { return inputs_[0]; }
953 LOperand* right() { return inputs_[1]; }
955 DECLARE_CONCRETE_INSTRUCTION(CmpObjectEqAndBranch, "cmp-object-eq-and-branch")
959 class LCmpHoleAndBranch final : public LControlInstruction<1, 0> {
961 explicit LCmpHoleAndBranch(LOperand* object) {
965 LOperand* object() { return inputs_[0]; }
967 DECLARE_CONCRETE_INSTRUCTION(CmpHoleAndBranch, "cmp-hole-and-branch")
968 DECLARE_HYDROGEN_ACCESSOR(CompareHoleAndBranch)
972 class LCompareMinusZeroAndBranch final : public LControlInstruction<1, 0> {
974 explicit LCompareMinusZeroAndBranch(LOperand* value) {
978 LOperand* value() { return inputs_[0]; }
980 DECLARE_CONCRETE_INSTRUCTION(CompareMinusZeroAndBranch,
981 "cmp-minus-zero-and-branch")
982 DECLARE_HYDROGEN_ACCESSOR(CompareMinusZeroAndBranch)
986 class LIsObjectAndBranch final : public LControlInstruction<1, 0> {
988 explicit LIsObjectAndBranch(LOperand* value) {
992 LOperand* value() { return inputs_[0]; }
994 DECLARE_CONCRETE_INSTRUCTION(IsObjectAndBranch, "is-object-and-branch")
995 DECLARE_HYDROGEN_ACCESSOR(IsObjectAndBranch)
997 void PrintDataTo(StringStream* stream) override;
1001 class LIsStringAndBranch final : public LControlInstruction<1, 1> {
1003 explicit LIsStringAndBranch(LOperand* value, LOperand* temp) {
1008 LOperand* value() { return inputs_[0]; }
1009 LOperand* temp() { return temps_[0]; }
1011 DECLARE_CONCRETE_INSTRUCTION(IsStringAndBranch, "is-string-and-branch")
1012 DECLARE_HYDROGEN_ACCESSOR(IsStringAndBranch)
1014 void PrintDataTo(StringStream* stream) override;
1018 class LIsSmiAndBranch final : public LControlInstruction<1, 0> {
1020 explicit LIsSmiAndBranch(LOperand* value) {
1024 LOperand* value() { return inputs_[0]; }
1026 DECLARE_CONCRETE_INSTRUCTION(IsSmiAndBranch, "is-smi-and-branch")
1027 DECLARE_HYDROGEN_ACCESSOR(IsSmiAndBranch)
1029 void PrintDataTo(StringStream* stream) override;
1033 class LIsUndetectableAndBranch final : public LControlInstruction<1, 1> {
1035 explicit LIsUndetectableAndBranch(LOperand* value, LOperand* temp) {
1040 LOperand* value() { return inputs_[0]; }
1041 LOperand* temp() { return temps_[0]; }
1043 DECLARE_CONCRETE_INSTRUCTION(IsUndetectableAndBranch,
1044 "is-undetectable-and-branch")
1045 DECLARE_HYDROGEN_ACCESSOR(IsUndetectableAndBranch)
1047 void PrintDataTo(StringStream* stream) override;
1051 class LStringCompareAndBranch final : public LControlInstruction<3, 0> {
1053 explicit LStringCompareAndBranch(LOperand* context,
1056 inputs_[0] = context;
1061 LOperand* context() { return inputs_[0]; }
1062 LOperand* left() { return inputs_[1]; }
1063 LOperand* right() { return inputs_[2]; }
1065 DECLARE_CONCRETE_INSTRUCTION(StringCompareAndBranch,
1066 "string-compare-and-branch")
1067 DECLARE_HYDROGEN_ACCESSOR(StringCompareAndBranch)
1069 void PrintDataTo(StringStream* stream) override;
1071 Token::Value op() const { return hydrogen()->token(); }
1075 class LHasInstanceTypeAndBranch final : public LControlInstruction<1, 0> {
1077 explicit LHasInstanceTypeAndBranch(LOperand* value) {
1081 LOperand* value() { return inputs_[0]; }
1083 DECLARE_CONCRETE_INSTRUCTION(HasInstanceTypeAndBranch,
1084 "has-instance-type-and-branch")
1085 DECLARE_HYDROGEN_ACCESSOR(HasInstanceTypeAndBranch)
1087 void PrintDataTo(StringStream* stream) override;
1091 class LGetCachedArrayIndex final : public LTemplateInstruction<1, 1, 0> {
1093 explicit LGetCachedArrayIndex(LOperand* value) {
1097 LOperand* value() { return inputs_[0]; }
1099 DECLARE_CONCRETE_INSTRUCTION(GetCachedArrayIndex, "get-cached-array-index")
1100 DECLARE_HYDROGEN_ACCESSOR(GetCachedArrayIndex)
1104 class LHasCachedArrayIndexAndBranch final : public LControlInstruction<1, 0> {
1106 explicit LHasCachedArrayIndexAndBranch(LOperand* value) {
1110 LOperand* value() { return inputs_[0]; }
1112 DECLARE_CONCRETE_INSTRUCTION(HasCachedArrayIndexAndBranch,
1113 "has-cached-array-index-and-branch")
1114 DECLARE_HYDROGEN_ACCESSOR(HasCachedArrayIndexAndBranch)
1116 void PrintDataTo(StringStream* stream) override;
1120 class LClassOfTestAndBranch final : public LControlInstruction<1, 2> {
1122 LClassOfTestAndBranch(LOperand* value, LOperand* temp, LOperand* temp2) {
1128 LOperand* value() { return inputs_[0]; }
1129 LOperand* temp() { return temps_[0]; }
1130 LOperand* temp2() { return temps_[1]; }
1132 DECLARE_CONCRETE_INSTRUCTION(ClassOfTestAndBranch,
1133 "class-of-test-and-branch")
1134 DECLARE_HYDROGEN_ACCESSOR(ClassOfTestAndBranch)
1136 void PrintDataTo(StringStream* stream) override;
1140 class LCmpT final : public LTemplateInstruction<1, 3, 0> {
1142 LCmpT(LOperand* context, LOperand* left, LOperand* right) {
1143 inputs_[0] = context;
1148 LOperand* context() { return inputs_[0]; }
1149 LOperand* left() { return inputs_[1]; }
1150 LOperand* right() { return inputs_[2]; }
1152 DECLARE_CONCRETE_INSTRUCTION(CmpT, "cmp-t")
1153 DECLARE_HYDROGEN_ACCESSOR(CompareGeneric)
1155 Strength strength() { return hydrogen()->strength(); }
1157 Token::Value op() const { return hydrogen()->token(); }
1161 class LInstanceOf final : public LTemplateInstruction<1, 3, 0> {
1163 LInstanceOf(LOperand* context, LOperand* left, LOperand* right) {
1164 inputs_[0] = context;
1169 LOperand* context() { return inputs_[0]; }
1170 LOperand* left() { return inputs_[1]; }
1171 LOperand* right() { return inputs_[2]; }
1173 DECLARE_CONCRETE_INSTRUCTION(InstanceOf, "instance-of")
1177 class LInstanceOfKnownGlobal final : public LTemplateInstruction<1, 2, 1> {
1179 LInstanceOfKnownGlobal(LOperand* context, LOperand* value, LOperand* temp) {
1180 inputs_[0] = context;
1185 LOperand* context() { return inputs_[0]; }
1186 LOperand* value() { return inputs_[1]; }
1187 LOperand* temp() { return temps_[0]; }
1189 DECLARE_CONCRETE_INSTRUCTION(InstanceOfKnownGlobal,
1190 "instance-of-known-global")
1191 DECLARE_HYDROGEN_ACCESSOR(InstanceOfKnownGlobal)
1193 Handle<JSFunction> function() const { return hydrogen()->function(); }
1194 LEnvironment* GetDeferredLazyDeoptimizationEnvironment() {
1195 return lazy_deopt_env_;
1197 virtual void SetDeferredLazyDeoptimizationEnvironment(
1198 LEnvironment* env) override {
1199 lazy_deopt_env_ = env;
1203 LEnvironment* lazy_deopt_env_;
1207 class LBoundsCheck final : public LTemplateInstruction<0, 2, 0> {
1209 LBoundsCheck(LOperand* index, LOperand* length) {
1211 inputs_[1] = length;
1214 LOperand* index() { return inputs_[0]; }
1215 LOperand* length() { return inputs_[1]; }
1217 DECLARE_CONCRETE_INSTRUCTION(BoundsCheck, "bounds-check")
1218 DECLARE_HYDROGEN_ACCESSOR(BoundsCheck)
1222 class LBitI final : public LTemplateInstruction<1, 2, 0> {
1224 LBitI(LOperand* left, LOperand* right) {
1229 LOperand* left() { return inputs_[0]; }
1230 LOperand* right() { return inputs_[1]; }
1232 Token::Value op() const { return hydrogen()->op(); }
1233 bool IsInteger32() const {
1234 return hydrogen()->representation().IsInteger32();
1237 DECLARE_CONCRETE_INSTRUCTION(BitI, "bit-i")
1238 DECLARE_HYDROGEN_ACCESSOR(Bitwise)
1242 class LShiftI final : public LTemplateInstruction<1, 2, 0> {
1244 LShiftI(Token::Value op, LOperand* left, LOperand* right, bool can_deopt)
1245 : op_(op), can_deopt_(can_deopt) {
1250 Token::Value op() const { return op_; }
1251 LOperand* left() { return inputs_[0]; }
1252 LOperand* right() { return inputs_[1]; }
1253 bool can_deopt() const { return can_deopt_; }
1255 DECLARE_CONCRETE_INSTRUCTION(ShiftI, "shift-i")
1263 class LSubI final : public LTemplateInstruction<1, 2, 0> {
1265 LSubI(LOperand* left, LOperand* right) {
1270 LOperand* left() { return inputs_[0]; }
1271 LOperand* right() { return inputs_[1]; }
1273 DECLARE_CONCRETE_INSTRUCTION(SubI, "sub-i")
1274 DECLARE_HYDROGEN_ACCESSOR(Sub)
1278 class LConstantI final : public LTemplateInstruction<1, 0, 0> {
1280 DECLARE_CONCRETE_INSTRUCTION(ConstantI, "constant-i")
1281 DECLARE_HYDROGEN_ACCESSOR(Constant)
1283 int32_t value() const { return hydrogen()->Integer32Value(); }
1287 class LConstantS final : public LTemplateInstruction<1, 0, 0> {
1289 DECLARE_CONCRETE_INSTRUCTION(ConstantS, "constant-s")
1290 DECLARE_HYDROGEN_ACCESSOR(Constant)
1292 Smi* value() const { return Smi::FromInt(hydrogen()->Integer32Value()); }
1296 class LConstantD final : public LTemplateInstruction<1, 0, 0> {
1298 DECLARE_CONCRETE_INSTRUCTION(ConstantD, "constant-d")
1299 DECLARE_HYDROGEN_ACCESSOR(Constant)
1301 uint64_t bits() const { return hydrogen()->DoubleValueAsBits(); }
1305 class LConstantE final : public LTemplateInstruction<1, 0, 0> {
1307 DECLARE_CONCRETE_INSTRUCTION(ConstantE, "constant-e")
1308 DECLARE_HYDROGEN_ACCESSOR(Constant)
1310 ExternalReference value() const {
1311 return hydrogen()->ExternalReferenceValue();
1316 class LConstantT final : public LTemplateInstruction<1, 0, 0> {
1318 DECLARE_CONCRETE_INSTRUCTION(ConstantT, "constant-t")
1319 DECLARE_HYDROGEN_ACCESSOR(Constant)
1321 Handle<Object> value(Isolate* isolate) const {
1322 return hydrogen()->handle(isolate);
1327 class LBranch final : public LControlInstruction<1, 0> {
1329 explicit LBranch(LOperand* value) {
1333 LOperand* value() { return inputs_[0]; }
1335 DECLARE_CONCRETE_INSTRUCTION(Branch, "branch")
1336 DECLARE_HYDROGEN_ACCESSOR(Branch)
1338 void PrintDataTo(StringStream* stream) override;
1342 class LDebugBreak final : public LTemplateInstruction<0, 0, 0> {
1344 DECLARE_CONCRETE_INSTRUCTION(DebugBreak, "break")
1348 class LCmpMapAndBranch final : public LControlInstruction<1, 0> {
1350 explicit LCmpMapAndBranch(LOperand* value) {
1354 LOperand* value() { return inputs_[0]; }
1356 DECLARE_CONCRETE_INSTRUCTION(CmpMapAndBranch, "cmp-map-and-branch")
1357 DECLARE_HYDROGEN_ACCESSOR(CompareMap)
1359 Handle<Map> map() const { return hydrogen()->map().handle(); }
1363 class LMapEnumLength final : public LTemplateInstruction<1, 1, 0> {
1365 explicit LMapEnumLength(LOperand* value) {
1369 LOperand* value() { return inputs_[0]; }
1371 DECLARE_CONCRETE_INSTRUCTION(MapEnumLength, "map-enum-length")
1375 class LDateField final : public LTemplateInstruction<1, 1, 0> {
1377 LDateField(LOperand* date, Smi* index) : index_(index) {
1381 LOperand* date() { return inputs_[0]; }
1382 Smi* index() const { return index_; }
1384 DECLARE_CONCRETE_INSTRUCTION(DateField, "date-field")
1385 DECLARE_HYDROGEN_ACCESSOR(DateField)
1392 class LSeqStringGetChar final : public LTemplateInstruction<1, 2, 0> {
1394 LSeqStringGetChar(LOperand* string, LOperand* index) {
1395 inputs_[0] = string;
1399 LOperand* string() const { return inputs_[0]; }
1400 LOperand* index() const { return inputs_[1]; }
1402 DECLARE_CONCRETE_INSTRUCTION(SeqStringGetChar, "seq-string-get-char")
1403 DECLARE_HYDROGEN_ACCESSOR(SeqStringGetChar)
1407 class LSeqStringSetChar final : public LTemplateInstruction<1, 4, 0> {
1409 LSeqStringSetChar(LOperand* context,
1413 inputs_[0] = context;
1414 inputs_[1] = string;
1419 LOperand* string() { return inputs_[1]; }
1420 LOperand* index() { return inputs_[2]; }
1421 LOperand* value() { return inputs_[3]; }
1423 DECLARE_CONCRETE_INSTRUCTION(SeqStringSetChar, "seq-string-set-char")
1424 DECLARE_HYDROGEN_ACCESSOR(SeqStringSetChar)
1428 class LAddI final : public LTemplateInstruction<1, 2, 0> {
1430 LAddI(LOperand* left, LOperand* right) {
1435 LOperand* left() { return inputs_[0]; }
1436 LOperand* right() { return inputs_[1]; }
1438 static bool UseLea(HAdd* add) {
1439 return !add->CheckFlag(HValue::kCanOverflow) &&
1440 add->BetterLeftOperand()->UseCount() > 1;
1443 DECLARE_CONCRETE_INSTRUCTION(AddI, "add-i")
1444 DECLARE_HYDROGEN_ACCESSOR(Add)
1448 class LMathMinMax final : public LTemplateInstruction<1, 2, 0> {
1450 LMathMinMax(LOperand* left, LOperand* right) {
1455 LOperand* left() { return inputs_[0]; }
1456 LOperand* right() { return inputs_[1]; }
1458 DECLARE_CONCRETE_INSTRUCTION(MathMinMax, "math-min-max")
1459 DECLARE_HYDROGEN_ACCESSOR(MathMinMax)
1463 class LPower final : public LTemplateInstruction<1, 2, 0> {
1465 LPower(LOperand* left, LOperand* right) {
1470 LOperand* left() { return inputs_[0]; }
1471 LOperand* right() { return inputs_[1]; }
1473 DECLARE_CONCRETE_INSTRUCTION(Power, "power")
1474 DECLARE_HYDROGEN_ACCESSOR(Power)
1478 class LArithmeticD final : public LTemplateInstruction<1, 2, 0> {
1480 LArithmeticD(Token::Value op, LOperand* left, LOperand* right)
1486 Token::Value op() const { return op_; }
1487 LOperand* left() { return inputs_[0]; }
1488 LOperand* right() { return inputs_[1]; }
1490 Opcode opcode() const override { return LInstruction::kArithmeticD; }
1491 void CompileToNative(LCodeGen* generator) override;
1492 const char* Mnemonic() const override;
1499 class LArithmeticT final : public LTemplateInstruction<1, 3, 0> {
1501 LArithmeticT(Token::Value op,
1506 inputs_[0] = context;
1511 Token::Value op() const { return op_; }
1512 LOperand* context() { return inputs_[0]; }
1513 LOperand* left() { return inputs_[1]; }
1514 LOperand* right() { return inputs_[2]; }
1516 Opcode opcode() const override { return LInstruction::kArithmeticT; }
1517 void CompileToNative(LCodeGen* generator) override;
1518 const char* Mnemonic() const override;
1520 DECLARE_HYDROGEN_ACCESSOR(BinaryOperation)
1522 Strength strength() { return hydrogen()->strength(); }
1529 class LReturn final : public LTemplateInstruction<0, 3, 0> {
1531 explicit LReturn(LOperand* value,
1533 LOperand* parameter_count) {
1535 inputs_[1] = context;
1536 inputs_[2] = parameter_count;
1539 LOperand* value() { return inputs_[0]; }
1540 LOperand* context() { return inputs_[1]; }
1542 bool has_constant_parameter_count() {
1543 return parameter_count()->IsConstantOperand();
1545 LConstantOperand* constant_parameter_count() {
1546 DCHECK(has_constant_parameter_count());
1547 return LConstantOperand::cast(parameter_count());
1549 LOperand* parameter_count() { return inputs_[2]; }
1551 DECLARE_CONCRETE_INSTRUCTION(Return, "return")
1552 DECLARE_HYDROGEN_ACCESSOR(Return)
1556 class LLoadNamedField final : public LTemplateInstruction<1, 1, 0> {
1558 explicit LLoadNamedField(LOperand* object) {
1559 inputs_[0] = object;
1562 LOperand* object() { return inputs_[0]; }
1564 DECLARE_CONCRETE_INSTRUCTION(LoadNamedField, "load-named-field")
1565 DECLARE_HYDROGEN_ACCESSOR(LoadNamedField)
1569 class LLoadNamedGeneric final : public LTemplateInstruction<1, 2, 1> {
1571 explicit LLoadNamedGeneric(LOperand* context, LOperand* object,
1573 inputs_[0] = context;
1574 inputs_[1] = object;
1578 DECLARE_CONCRETE_INSTRUCTION(LoadNamedGeneric, "load-named-generic")
1579 DECLARE_HYDROGEN_ACCESSOR(LoadNamedGeneric)
1581 LOperand* context() { return inputs_[0]; }
1582 LOperand* object() { return inputs_[1]; }
1583 LOperand* temp_vector() { return temps_[0]; }
1585 Handle<Object> name() const { return hydrogen()->name(); }
1589 class LLoadFunctionPrototype final : public LTemplateInstruction<1, 1, 0> {
1591 explicit LLoadFunctionPrototype(LOperand* function) {
1592 inputs_[0] = function;
1595 DECLARE_CONCRETE_INSTRUCTION(LoadFunctionPrototype, "load-function-prototype")
1596 DECLARE_HYDROGEN_ACCESSOR(LoadFunctionPrototype)
1598 LOperand* function() { return inputs_[0]; }
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 inline static bool ExternalArrayOpRequiresTemp(
1612 Representation key_representation,
1613 ElementsKind elements_kind) {
1614 // Operations that require the key to be divided by two to be converted into
1615 // an index cannot fold the scale operation into a load and need an extra
1616 // temp register to do the work.
1617 return SmiValuesAre31Bits() && key_representation.IsSmi() &&
1618 (elements_kind == EXTERNAL_INT8_ELEMENTS ||
1619 elements_kind == EXTERNAL_UINT8_ELEMENTS ||
1620 elements_kind == EXTERNAL_UINT8_CLAMPED_ELEMENTS ||
1621 elements_kind == UINT8_ELEMENTS ||
1622 elements_kind == INT8_ELEMENTS ||
1623 elements_kind == UINT8_CLAMPED_ELEMENTS);
1627 class LLoadKeyed final : public LTemplateInstruction<1, 2, 0> {
1629 LLoadKeyed(LOperand* elements, LOperand* key) {
1630 inputs_[0] = elements;
1634 DECLARE_CONCRETE_INSTRUCTION(LoadKeyed, "load-keyed")
1635 DECLARE_HYDROGEN_ACCESSOR(LoadKeyed)
1637 bool is_external() const {
1638 return hydrogen()->is_external();
1640 bool is_fixed_typed_array() const {
1641 return hydrogen()->is_fixed_typed_array();
1643 bool is_typed_elements() const {
1644 return is_external() || is_fixed_typed_array();
1646 LOperand* elements() { return inputs_[0]; }
1647 LOperand* key() { return inputs_[1]; }
1648 void PrintDataTo(StringStream* stream) override;
1649 uint32_t base_offset() const { return hydrogen()->base_offset(); }
1650 ElementsKind elements_kind() const {
1651 return hydrogen()->elements_kind();
1656 class LLoadKeyedGeneric final : public LTemplateInstruction<1, 3, 1> {
1658 LLoadKeyedGeneric(LOperand* context, LOperand* obj, LOperand* key,
1660 inputs_[0] = context;
1666 DECLARE_CONCRETE_INSTRUCTION(LoadKeyedGeneric, "load-keyed-generic")
1667 DECLARE_HYDROGEN_ACCESSOR(LoadKeyedGeneric)
1669 LOperand* context() { return inputs_[0]; }
1670 LOperand* object() { return inputs_[1]; }
1671 LOperand* key() { return inputs_[2]; }
1672 LOperand* temp_vector() { return temps_[0]; }
1676 class LLoadGlobalGeneric final : public LTemplateInstruction<1, 2, 1> {
1678 explicit LLoadGlobalGeneric(LOperand* context, LOperand* global_object,
1680 inputs_[0] = context;
1681 inputs_[1] = global_object;
1685 DECLARE_CONCRETE_INSTRUCTION(LoadGlobalGeneric, "load-global-generic")
1686 DECLARE_HYDROGEN_ACCESSOR(LoadGlobalGeneric)
1688 LOperand* context() { return inputs_[0]; }
1689 LOperand* global_object() { return inputs_[1]; }
1690 LOperand* temp_vector() { return temps_[0]; }
1692 Handle<Object> name() const { return hydrogen()->name(); }
1693 bool for_typeof() const { return hydrogen()->for_typeof(); }
1697 class LLoadContextSlot final : public LTemplateInstruction<1, 1, 0> {
1699 explicit LLoadContextSlot(LOperand* context) {
1700 inputs_[0] = context;
1703 LOperand* context() { return inputs_[0]; }
1705 DECLARE_CONCRETE_INSTRUCTION(LoadContextSlot, "load-context-slot")
1706 DECLARE_HYDROGEN_ACCESSOR(LoadContextSlot)
1708 int slot_index() { return hydrogen()->slot_index(); }
1710 void PrintDataTo(StringStream* stream) override;
1714 class LStoreContextSlot final : public LTemplateInstruction<0, 2, 1> {
1716 LStoreContextSlot(LOperand* context, LOperand* value, LOperand* temp) {
1717 inputs_[0] = context;
1722 LOperand* context() { return inputs_[0]; }
1723 LOperand* value() { return inputs_[1]; }
1724 LOperand* temp() { return temps_[0]; }
1726 DECLARE_CONCRETE_INSTRUCTION(StoreContextSlot, "store-context-slot")
1727 DECLARE_HYDROGEN_ACCESSOR(StoreContextSlot)
1729 int slot_index() { return hydrogen()->slot_index(); }
1731 void PrintDataTo(StringStream* stream) override;
1735 class LPushArgument final : public LTemplateInstruction<0, 1, 0> {
1737 explicit LPushArgument(LOperand* value) {
1741 LOperand* value() { return inputs_[0]; }
1743 DECLARE_CONCRETE_INSTRUCTION(PushArgument, "push-argument")
1747 class LDrop final : public LTemplateInstruction<0, 0, 0> {
1749 explicit LDrop(int count) : count_(count) { }
1751 int count() const { return count_; }
1753 DECLARE_CONCRETE_INSTRUCTION(Drop, "drop")
1760 class LStoreCodeEntry final : public LTemplateInstruction<0, 2, 0> {
1762 LStoreCodeEntry(LOperand* function, LOperand* code_object) {
1763 inputs_[0] = function;
1764 inputs_[1] = code_object;
1767 LOperand* function() { return inputs_[0]; }
1768 LOperand* code_object() { return inputs_[1]; }
1770 void PrintDataTo(StringStream* stream) override;
1772 DECLARE_CONCRETE_INSTRUCTION(StoreCodeEntry, "store-code-entry")
1773 DECLARE_HYDROGEN_ACCESSOR(StoreCodeEntry)
1777 class LInnerAllocatedObject final : public LTemplateInstruction<1, 2, 0> {
1779 LInnerAllocatedObject(LOperand* base_object, LOperand* offset) {
1780 inputs_[0] = base_object;
1781 inputs_[1] = offset;
1784 LOperand* base_object() const { return inputs_[0]; }
1785 LOperand* offset() const { return inputs_[1]; }
1787 void PrintDataTo(StringStream* stream) override;
1789 DECLARE_CONCRETE_INSTRUCTION(InnerAllocatedObject, "inner-allocated-object")
1793 class LThisFunction final : public LTemplateInstruction<1, 0, 0> {
1795 DECLARE_CONCRETE_INSTRUCTION(ThisFunction, "this-function")
1796 DECLARE_HYDROGEN_ACCESSOR(ThisFunction)
1800 class LContext final : public LTemplateInstruction<1, 0, 0> {
1802 DECLARE_CONCRETE_INSTRUCTION(Context, "context")
1803 DECLARE_HYDROGEN_ACCESSOR(Context)
1807 class LDeclareGlobals final : public LTemplateInstruction<0, 1, 0> {
1809 explicit LDeclareGlobals(LOperand* context) {
1810 inputs_[0] = context;
1813 LOperand* context() { return inputs_[0]; }
1815 DECLARE_CONCRETE_INSTRUCTION(DeclareGlobals, "declare-globals")
1816 DECLARE_HYDROGEN_ACCESSOR(DeclareGlobals)
1820 class LCallJSFunction final : public LTemplateInstruction<1, 1, 0> {
1822 explicit LCallJSFunction(LOperand* function) {
1823 inputs_[0] = function;
1826 LOperand* function() { return inputs_[0]; }
1828 DECLARE_CONCRETE_INSTRUCTION(CallJSFunction, "call-js-function")
1829 DECLARE_HYDROGEN_ACCESSOR(CallJSFunction)
1831 void PrintDataTo(StringStream* stream) override;
1833 int arity() const { return hydrogen()->argument_count() - 1; }
1837 class LCallWithDescriptor final : public LTemplateResultInstruction<1> {
1839 LCallWithDescriptor(CallInterfaceDescriptor descriptor,
1840 const ZoneList<LOperand*>& operands, Zone* zone)
1841 : inputs_(descriptor.GetRegisterParameterCount() +
1842 kImplicitRegisterParameterCount,
1844 DCHECK(descriptor.GetRegisterParameterCount() +
1845 kImplicitRegisterParameterCount ==
1847 inputs_.AddAll(operands, zone);
1850 LOperand* target() const { return inputs_[0]; }
1852 DECLARE_HYDROGEN_ACCESSOR(CallWithDescriptor)
1854 // The target and context are passed as implicit parameters that are not
1855 // explicitly listed in the descriptor.
1856 static const int kImplicitRegisterParameterCount = 2;
1859 DECLARE_CONCRETE_INSTRUCTION(CallWithDescriptor, "call-with-descriptor")
1861 void PrintDataTo(StringStream* stream) override;
1863 int arity() const { return hydrogen()->argument_count() - 1; }
1865 ZoneList<LOperand*> inputs_;
1867 // Iterator support.
1868 int InputCount() final { return inputs_.length(); }
1869 LOperand* InputAt(int i) final { return inputs_[i]; }
1871 int TempCount() final { return 0; }
1872 LOperand* TempAt(int i) final { return NULL; }
1876 class LInvokeFunction final : public LTemplateInstruction<1, 2, 0> {
1878 LInvokeFunction(LOperand* context, LOperand* function) {
1879 inputs_[0] = context;
1880 inputs_[1] = function;
1883 LOperand* context() { return inputs_[0]; }
1884 LOperand* function() { return inputs_[1]; }
1886 DECLARE_CONCRETE_INSTRUCTION(InvokeFunction, "invoke-function")
1887 DECLARE_HYDROGEN_ACCESSOR(InvokeFunction)
1889 void PrintDataTo(StringStream* stream) override;
1891 int arity() const { return hydrogen()->argument_count() - 1; }
1895 class LCallFunction final : public LTemplateInstruction<1, 2, 2> {
1897 LCallFunction(LOperand* context, LOperand* function, LOperand* slot,
1899 inputs_[0] = context;
1900 inputs_[1] = function;
1905 DECLARE_CONCRETE_INSTRUCTION(CallFunction, "call-function")
1906 DECLARE_HYDROGEN_ACCESSOR(CallFunction)
1908 LOperand* context() { return inputs_[0]; }
1909 LOperand* function() { return inputs_[1]; }
1910 LOperand* temp_slot() { return temps_[0]; }
1911 LOperand* temp_vector() { return temps_[1]; }
1912 int arity() const { return hydrogen()->argument_count() - 1; }
1914 void PrintDataTo(StringStream* stream) override;
1918 class LCallNew final : public LTemplateInstruction<1, 2, 0> {
1920 LCallNew(LOperand* context, LOperand* constructor) {
1921 inputs_[0] = context;
1922 inputs_[1] = constructor;
1925 LOperand* context() { return inputs_[0]; }
1926 LOperand* constructor() { return inputs_[1]; }
1928 DECLARE_CONCRETE_INSTRUCTION(CallNew, "call-new")
1929 DECLARE_HYDROGEN_ACCESSOR(CallNew)
1931 void PrintDataTo(StringStream* stream) override;
1933 int arity() const { return hydrogen()->argument_count() - 1; }
1937 class LCallNewArray final : public LTemplateInstruction<1, 2, 0> {
1939 LCallNewArray(LOperand* context, LOperand* constructor) {
1940 inputs_[0] = context;
1941 inputs_[1] = constructor;
1944 LOperand* context() { return inputs_[0]; }
1945 LOperand* constructor() { return inputs_[1]; }
1947 DECLARE_CONCRETE_INSTRUCTION(CallNewArray, "call-new-array")
1948 DECLARE_HYDROGEN_ACCESSOR(CallNewArray)
1950 void PrintDataTo(StringStream* stream) override;
1952 int arity() const { return hydrogen()->argument_count() - 1; }
1956 class LCallRuntime final : public LTemplateInstruction<1, 1, 0> {
1958 explicit LCallRuntime(LOperand* context) {
1959 inputs_[0] = context;
1962 LOperand* context() { return inputs_[0]; }
1964 DECLARE_CONCRETE_INSTRUCTION(CallRuntime, "call-runtime")
1965 DECLARE_HYDROGEN_ACCESSOR(CallRuntime)
1967 bool ClobbersDoubleRegisters(Isolate* isolate) const override {
1968 return save_doubles() == kDontSaveFPRegs;
1971 const Runtime::Function* function() const { return hydrogen()->function(); }
1972 int arity() const { return hydrogen()->argument_count(); }
1973 SaveFPRegsMode save_doubles() const { return hydrogen()->save_doubles(); }
1977 class LInteger32ToDouble final : public LTemplateInstruction<1, 1, 0> {
1979 explicit LInteger32ToDouble(LOperand* value) {
1983 LOperand* value() { return inputs_[0]; }
1985 DECLARE_CONCRETE_INSTRUCTION(Integer32ToDouble, "int32-to-double")
1989 class LUint32ToDouble final : public LTemplateInstruction<1, 1, 0> {
1991 explicit LUint32ToDouble(LOperand* value) {
1995 LOperand* value() { return inputs_[0]; }
1997 DECLARE_CONCRETE_INSTRUCTION(Uint32ToDouble, "uint32-to-double")
2001 class LNumberTagI final : public LTemplateInstruction<1, 1, 2> {
2003 LNumberTagI(LOperand* value, LOperand* temp1, LOperand* temp2) {
2009 LOperand* value() { return inputs_[0]; }
2010 LOperand* temp1() { return temps_[0]; }
2011 LOperand* temp2() { return temps_[1]; }
2013 DECLARE_CONCRETE_INSTRUCTION(NumberTagI, "number-tag-i")
2017 class LNumberTagU final : public LTemplateInstruction<1, 1, 2> {
2019 LNumberTagU(LOperand* value, LOperand* temp1, LOperand* temp2) {
2025 LOperand* value() { return inputs_[0]; }
2026 LOperand* temp1() { return temps_[0]; }
2027 LOperand* temp2() { return temps_[1]; }
2029 DECLARE_CONCRETE_INSTRUCTION(NumberTagU, "number-tag-u")
2033 class LNumberTagD final : public LTemplateInstruction<1, 1, 1> {
2035 explicit LNumberTagD(LOperand* value, LOperand* temp) {
2040 LOperand* value() { return inputs_[0]; }
2041 LOperand* temp() { return temps_[0]; }
2043 DECLARE_CONCRETE_INSTRUCTION(NumberTagD, "number-tag-d")
2044 DECLARE_HYDROGEN_ACCESSOR(Change)
2048 // Sometimes truncating conversion from a tagged value to an int32.
2049 class LDoubleToI final : public LTemplateInstruction<1, 1, 0> {
2051 explicit LDoubleToI(LOperand* value) {
2055 LOperand* value() { return inputs_[0]; }
2057 DECLARE_CONCRETE_INSTRUCTION(DoubleToI, "double-to-i")
2058 DECLARE_HYDROGEN_ACCESSOR(UnaryOperation)
2060 bool truncating() { return hydrogen()->CanTruncateToInt32(); }
2064 class LDoubleToSmi final : public LTemplateInstruction<1, 1, 0> {
2066 explicit LDoubleToSmi(LOperand* value) {
2070 LOperand* value() { return inputs_[0]; }
2072 DECLARE_CONCRETE_INSTRUCTION(DoubleToSmi, "double-to-smi")
2073 DECLARE_HYDROGEN_ACCESSOR(UnaryOperation)
2077 // Truncating conversion from a tagged value to an int32.
2078 class LTaggedToI final : public LTemplateInstruction<1, 1, 1> {
2080 LTaggedToI(LOperand* value, LOperand* temp) {
2085 LOperand* value() { return inputs_[0]; }
2086 LOperand* temp() { return temps_[0]; }
2088 DECLARE_CONCRETE_INSTRUCTION(TaggedToI, "tagged-to-i")
2089 DECLARE_HYDROGEN_ACCESSOR(Change)
2091 bool truncating() { return hydrogen()->CanTruncateToInt32(); }
2095 class LSmiTag final : public LTemplateInstruction<1, 1, 0> {
2097 explicit LSmiTag(LOperand* value) {
2101 LOperand* value() { return inputs_[0]; }
2103 DECLARE_CONCRETE_INSTRUCTION(SmiTag, "smi-tag")
2104 DECLARE_HYDROGEN_ACCESSOR(Change)
2108 class LNumberUntagD final : public LTemplateInstruction<1, 1, 0> {
2110 explicit LNumberUntagD(LOperand* value) {
2114 LOperand* value() { return inputs_[0]; }
2116 DECLARE_CONCRETE_INSTRUCTION(NumberUntagD, "double-untag")
2117 DECLARE_HYDROGEN_ACCESSOR(Change);
2121 class LSmiUntag final : public LTemplateInstruction<1, 1, 0> {
2123 LSmiUntag(LOperand* value, bool needs_check)
2124 : needs_check_(needs_check) {
2128 LOperand* value() { return inputs_[0]; }
2129 bool needs_check() const { return needs_check_; }
2131 DECLARE_CONCRETE_INSTRUCTION(SmiUntag, "smi-untag")
2138 class LStoreNamedField final : public LTemplateInstruction<0, 2, 1> {
2140 LStoreNamedField(LOperand* object, LOperand* value, LOperand* temp) {
2141 inputs_[0] = object;
2146 LOperand* object() { return inputs_[0]; }
2147 LOperand* value() { return inputs_[1]; }
2148 LOperand* temp() { return temps_[0]; }
2150 DECLARE_CONCRETE_INSTRUCTION(StoreNamedField, "store-named-field")
2151 DECLARE_HYDROGEN_ACCESSOR(StoreNamedField)
2153 void PrintDataTo(StringStream* stream) override;
2155 Representation representation() const {
2156 return hydrogen()->field_representation();
2161 class LStoreNamedGeneric final : public LTemplateInstruction<0, 3, 2> {
2163 LStoreNamedGeneric(LOperand* context, LOperand* object, LOperand* value,
2164 LOperand* slot, LOperand* vector) {
2165 inputs_[0] = context;
2166 inputs_[1] = object;
2172 LOperand* context() { return inputs_[0]; }
2173 LOperand* object() { return inputs_[1]; }
2174 LOperand* value() { return inputs_[2]; }
2175 LOperand* temp_slot() { return temps_[0]; }
2176 LOperand* temp_vector() { return temps_[1]; }
2178 DECLARE_CONCRETE_INSTRUCTION(StoreNamedGeneric, "store-named-generic")
2179 DECLARE_HYDROGEN_ACCESSOR(StoreNamedGeneric)
2181 void PrintDataTo(StringStream* stream) override;
2183 Handle<Object> name() const { return hydrogen()->name(); }
2184 LanguageMode language_mode() { return hydrogen()->language_mode(); }
2188 class LStoreKeyed final : public LTemplateInstruction<0, 3, 0> {
2190 LStoreKeyed(LOperand* object, LOperand* key, LOperand* value) {
2191 inputs_[0] = object;
2196 bool is_external() const { return hydrogen()->is_external(); }
2197 bool is_fixed_typed_array() const {
2198 return hydrogen()->is_fixed_typed_array();
2200 bool is_typed_elements() const {
2201 return is_external() || is_fixed_typed_array();
2203 LOperand* elements() { return inputs_[0]; }
2204 LOperand* key() { return inputs_[1]; }
2205 LOperand* value() { return inputs_[2]; }
2206 ElementsKind elements_kind() const { return hydrogen()->elements_kind(); }
2208 DECLARE_CONCRETE_INSTRUCTION(StoreKeyed, "store-keyed")
2209 DECLARE_HYDROGEN_ACCESSOR(StoreKeyed)
2211 void PrintDataTo(StringStream* stream) override;
2212 bool NeedsCanonicalization() { return hydrogen()->NeedsCanonicalization(); }
2213 uint32_t base_offset() const { return hydrogen()->base_offset(); }
2217 class LStoreKeyedGeneric final : public LTemplateInstruction<0, 4, 2> {
2219 LStoreKeyedGeneric(LOperand* context, LOperand* object, LOperand* key,
2220 LOperand* value, LOperand* slot, LOperand* vector) {
2221 inputs_[0] = context;
2222 inputs_[1] = object;
2229 LOperand* context() { return inputs_[0]; }
2230 LOperand* object() { return inputs_[1]; }
2231 LOperand* key() { return inputs_[2]; }
2232 LOperand* value() { return inputs_[3]; }
2233 LOperand* temp_slot() { return temps_[0]; }
2234 LOperand* temp_vector() { return temps_[1]; }
2236 DECLARE_CONCRETE_INSTRUCTION(StoreKeyedGeneric, "store-keyed-generic")
2237 DECLARE_HYDROGEN_ACCESSOR(StoreKeyedGeneric)
2239 void PrintDataTo(StringStream* stream) override;
2241 LanguageMode language_mode() { return hydrogen()->language_mode(); }
2245 class LTransitionElementsKind final : public LTemplateInstruction<0, 2, 2> {
2247 LTransitionElementsKind(LOperand* object,
2249 LOperand* new_map_temp,
2251 inputs_[0] = object;
2252 inputs_[1] = context;
2253 temps_[0] = new_map_temp;
2257 LOperand* object() { return inputs_[0]; }
2258 LOperand* context() { return inputs_[1]; }
2259 LOperand* new_map_temp() { return temps_[0]; }
2260 LOperand* temp() { return temps_[1]; }
2262 DECLARE_CONCRETE_INSTRUCTION(TransitionElementsKind,
2263 "transition-elements-kind")
2264 DECLARE_HYDROGEN_ACCESSOR(TransitionElementsKind)
2266 void PrintDataTo(StringStream* stream) override;
2268 Handle<Map> original_map() { return hydrogen()->original_map().handle(); }
2269 Handle<Map> transitioned_map() {
2270 return hydrogen()->transitioned_map().handle();
2272 ElementsKind from_kind() { return hydrogen()->from_kind(); }
2273 ElementsKind to_kind() { return hydrogen()->to_kind(); }
2277 class LTrapAllocationMemento final : public LTemplateInstruction<0, 1, 1> {
2279 LTrapAllocationMemento(LOperand* object,
2281 inputs_[0] = object;
2285 LOperand* object() { return inputs_[0]; }
2286 LOperand* temp() { return temps_[0]; }
2288 DECLARE_CONCRETE_INSTRUCTION(TrapAllocationMemento,
2289 "trap-allocation-memento")
2293 class LMaybeGrowElements final : public LTemplateInstruction<1, 5, 0> {
2295 LMaybeGrowElements(LOperand* context, LOperand* object, LOperand* elements,
2296 LOperand* key, LOperand* current_capacity) {
2297 inputs_[0] = context;
2298 inputs_[1] = object;
2299 inputs_[2] = elements;
2301 inputs_[4] = current_capacity;
2304 LOperand* context() { return inputs_[0]; }
2305 LOperand* object() { return inputs_[1]; }
2306 LOperand* elements() { return inputs_[2]; }
2307 LOperand* key() { return inputs_[3]; }
2308 LOperand* current_capacity() { return inputs_[4]; }
2310 DECLARE_HYDROGEN_ACCESSOR(MaybeGrowElements)
2311 DECLARE_CONCRETE_INSTRUCTION(MaybeGrowElements, "maybe-grow-elements")
2315 class LStringAdd final : public LTemplateInstruction<1, 3, 0> {
2317 LStringAdd(LOperand* context, LOperand* left, LOperand* right) {
2318 inputs_[0] = context;
2323 LOperand* context() { return inputs_[0]; }
2324 LOperand* left() { return inputs_[1]; }
2325 LOperand* right() { return inputs_[2]; }
2327 DECLARE_CONCRETE_INSTRUCTION(StringAdd, "string-add")
2328 DECLARE_HYDROGEN_ACCESSOR(StringAdd)
2332 class LStringCharCodeAt final : public LTemplateInstruction<1, 3, 0> {
2334 LStringCharCodeAt(LOperand* context, LOperand* string, LOperand* index) {
2335 inputs_[0] = context;
2336 inputs_[1] = string;
2340 LOperand* context() { return inputs_[0]; }
2341 LOperand* string() { return inputs_[1]; }
2342 LOperand* index() { return inputs_[2]; }
2344 DECLARE_CONCRETE_INSTRUCTION(StringCharCodeAt, "string-char-code-at")
2345 DECLARE_HYDROGEN_ACCESSOR(StringCharCodeAt)
2349 class LStringCharFromCode final : public LTemplateInstruction<1, 2, 0> {
2351 explicit LStringCharFromCode(LOperand* context, LOperand* char_code) {
2352 inputs_[0] = context;
2353 inputs_[1] = char_code;
2356 LOperand* context() { return inputs_[0]; }
2357 LOperand* char_code() { return inputs_[1]; }
2359 DECLARE_CONCRETE_INSTRUCTION(StringCharFromCode, "string-char-from-code")
2360 DECLARE_HYDROGEN_ACCESSOR(StringCharFromCode)
2364 class LCheckValue final : public LTemplateInstruction<0, 1, 0> {
2366 explicit LCheckValue(LOperand* value) {
2370 LOperand* value() { return inputs_[0]; }
2372 DECLARE_CONCRETE_INSTRUCTION(CheckValue, "check-value")
2373 DECLARE_HYDROGEN_ACCESSOR(CheckValue)
2377 class LCheckArrayBufferNotNeutered final
2378 : public LTemplateInstruction<0, 1, 0> {
2380 explicit LCheckArrayBufferNotNeutered(LOperand* view) { inputs_[0] = view; }
2382 LOperand* view() { return inputs_[0]; }
2384 DECLARE_CONCRETE_INSTRUCTION(CheckArrayBufferNotNeutered,
2385 "check-array-buffer-not-neutered")
2386 DECLARE_HYDROGEN_ACCESSOR(CheckArrayBufferNotNeutered)
2390 class LCheckInstanceType final : public LTemplateInstruction<0, 1, 0> {
2392 explicit LCheckInstanceType(LOperand* value) {
2396 LOperand* value() { return inputs_[0]; }
2398 DECLARE_CONCRETE_INSTRUCTION(CheckInstanceType, "check-instance-type")
2399 DECLARE_HYDROGEN_ACCESSOR(CheckInstanceType)
2403 class LCheckMaps final : public LTemplateInstruction<0, 1, 0> {
2405 explicit LCheckMaps(LOperand* value = NULL) {
2409 LOperand* value() { return inputs_[0]; }
2411 DECLARE_CONCRETE_INSTRUCTION(CheckMaps, "check-maps")
2412 DECLARE_HYDROGEN_ACCESSOR(CheckMaps)
2416 class LCheckSmi final : public LTemplateInstruction<1, 1, 0> {
2418 explicit LCheckSmi(LOperand* value) {
2422 LOperand* value() { return inputs_[0]; }
2424 DECLARE_CONCRETE_INSTRUCTION(CheckSmi, "check-smi")
2428 class LClampDToUint8 final : public LTemplateInstruction<1, 1, 0> {
2430 explicit LClampDToUint8(LOperand* unclamped) {
2431 inputs_[0] = unclamped;
2434 LOperand* unclamped() { return inputs_[0]; }
2436 DECLARE_CONCRETE_INSTRUCTION(ClampDToUint8, "clamp-d-to-uint8")
2440 class LClampIToUint8 final : public LTemplateInstruction<1, 1, 0> {
2442 explicit LClampIToUint8(LOperand* unclamped) {
2443 inputs_[0] = unclamped;
2446 LOperand* unclamped() { return inputs_[0]; }
2448 DECLARE_CONCRETE_INSTRUCTION(ClampIToUint8, "clamp-i-to-uint8")
2452 class LClampTToUint8 final : public LTemplateInstruction<1, 1, 1> {
2454 LClampTToUint8(LOperand* unclamped,
2455 LOperand* temp_xmm) {
2456 inputs_[0] = unclamped;
2457 temps_[0] = temp_xmm;
2460 LOperand* unclamped() { return inputs_[0]; }
2461 LOperand* temp_xmm() { return temps_[0]; }
2463 DECLARE_CONCRETE_INSTRUCTION(ClampTToUint8, "clamp-t-to-uint8")
2467 class LCheckNonSmi final : public LTemplateInstruction<0, 1, 0> {
2469 explicit LCheckNonSmi(LOperand* value) {
2473 LOperand* value() { return inputs_[0]; }
2475 DECLARE_CONCRETE_INSTRUCTION(CheckNonSmi, "check-non-smi")
2476 DECLARE_HYDROGEN_ACCESSOR(CheckHeapObject)
2480 class LDoubleBits final : public LTemplateInstruction<1, 1, 0> {
2482 explicit LDoubleBits(LOperand* value) {
2486 LOperand* value() { return inputs_[0]; }
2488 DECLARE_CONCRETE_INSTRUCTION(DoubleBits, "double-bits")
2489 DECLARE_HYDROGEN_ACCESSOR(DoubleBits)
2493 class LConstructDouble final : public LTemplateInstruction<1, 2, 0> {
2495 LConstructDouble(LOperand* hi, LOperand* lo) {
2500 LOperand* hi() { return inputs_[0]; }
2501 LOperand* lo() { return inputs_[1]; }
2503 DECLARE_CONCRETE_INSTRUCTION(ConstructDouble, "construct-double")
2507 class LAllocate final : public LTemplateInstruction<1, 2, 1> {
2509 LAllocate(LOperand* context, LOperand* size, LOperand* temp) {
2510 inputs_[0] = context;
2515 LOperand* context() { return inputs_[0]; }
2516 LOperand* size() { return inputs_[1]; }
2517 LOperand* temp() { return temps_[0]; }
2519 DECLARE_CONCRETE_INSTRUCTION(Allocate, "allocate")
2520 DECLARE_HYDROGEN_ACCESSOR(Allocate)
2524 class LRegExpLiteral final : public LTemplateInstruction<1, 1, 0> {
2526 explicit LRegExpLiteral(LOperand* context) {
2527 inputs_[0] = context;
2530 LOperand* context() { return inputs_[0]; }
2532 DECLARE_CONCRETE_INSTRUCTION(RegExpLiteral, "regexp-literal")
2533 DECLARE_HYDROGEN_ACCESSOR(RegExpLiteral)
2537 class LFunctionLiteral final : public LTemplateInstruction<1, 1, 0> {
2539 explicit LFunctionLiteral(LOperand* context) {
2540 inputs_[0] = context;
2543 LOperand* context() { return inputs_[0]; }
2545 DECLARE_CONCRETE_INSTRUCTION(FunctionLiteral, "function-literal")
2546 DECLARE_HYDROGEN_ACCESSOR(FunctionLiteral)
2550 class LToFastProperties final : public LTemplateInstruction<1, 1, 0> {
2552 explicit LToFastProperties(LOperand* value) {
2556 LOperand* value() { return inputs_[0]; }
2558 DECLARE_CONCRETE_INSTRUCTION(ToFastProperties, "to-fast-properties")
2559 DECLARE_HYDROGEN_ACCESSOR(ToFastProperties)
2563 class LTypeof final : public LTemplateInstruction<1, 2, 0> {
2565 LTypeof(LOperand* context, LOperand* value) {
2566 inputs_[0] = context;
2570 LOperand* context() { return inputs_[0]; }
2571 LOperand* value() { return inputs_[1]; }
2573 DECLARE_CONCRETE_INSTRUCTION(Typeof, "typeof")
2577 class LTypeofIsAndBranch final : public LControlInstruction<1, 0> {
2579 explicit LTypeofIsAndBranch(LOperand* value) {
2583 LOperand* value() { return inputs_[0]; }
2585 DECLARE_CONCRETE_INSTRUCTION(TypeofIsAndBranch, "typeof-is-and-branch")
2586 DECLARE_HYDROGEN_ACCESSOR(TypeofIsAndBranch)
2588 Handle<String> type_literal() { return hydrogen()->type_literal(); }
2590 void PrintDataTo(StringStream* stream) override;
2594 class LIsConstructCallAndBranch final : public LControlInstruction<0, 1> {
2596 explicit LIsConstructCallAndBranch(LOperand* temp) {
2600 LOperand* temp() { return temps_[0]; }
2602 DECLARE_CONCRETE_INSTRUCTION(IsConstructCallAndBranch,
2603 "is-construct-call-and-branch")
2604 DECLARE_HYDROGEN_ACCESSOR(IsConstructCallAndBranch)
2608 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 dehoisted_key_ids_(graph->GetMaximumValueID(), graph->zone()) { }
2729 int GetNextSpillIndex(RegisterKind kind);
2730 LOperand* GetNextSpillSlot(RegisterKind kind);
2731 BitVector* GetDehoistedKeyIds() { return &dehoisted_key_ids_; }
2732 bool IsDehoistedKey(HValue* value) {
2733 return dehoisted_key_ids_.Contains(value->id());
2737 BitVector dehoisted_key_ids_;
2741 class LChunkBuilder final : public LChunkBuilderBase {
2743 LChunkBuilder(CompilationInfo* info, HGraph* graph, LAllocator* allocator)
2744 : LChunkBuilderBase(info, graph),
2745 current_instruction_(NULL),
2746 current_block_(NULL),
2748 allocator_(allocator) {}
2750 // Build the sequence for the graph.
2751 LPlatformChunk* Build();
2753 // Declare methods that deal with the individual node types.
2754 #define DECLARE_DO(type) LInstruction* Do##type(H##type* node);
2755 HYDROGEN_CONCRETE_INSTRUCTION_LIST(DECLARE_DO)
2758 LInstruction* DoMathFloor(HUnaryMathOperation* instr);
2759 LInstruction* DoMathRound(HUnaryMathOperation* instr);
2760 LInstruction* DoMathFround(HUnaryMathOperation* instr);
2761 LInstruction* DoMathAbs(HUnaryMathOperation* instr);
2762 LInstruction* DoMathLog(HUnaryMathOperation* instr);
2763 LInstruction* DoMathExp(HUnaryMathOperation* instr);
2764 LInstruction* DoMathSqrt(HUnaryMathOperation* instr);
2765 LInstruction* DoMathPowHalf(HUnaryMathOperation* instr);
2766 LInstruction* DoMathClz32(HUnaryMathOperation* instr);
2767 LInstruction* DoDivByPowerOf2I(HDiv* instr);
2768 LInstruction* DoDivByConstI(HDiv* instr);
2769 LInstruction* DoDivI(HDiv* instr);
2770 LInstruction* DoModByPowerOf2I(HMod* instr);
2771 LInstruction* DoModByConstI(HMod* instr);
2772 LInstruction* DoModI(HMod* instr);
2773 LInstruction* DoFlooringDivByPowerOf2I(HMathFloorOfDiv* instr);
2774 LInstruction* DoFlooringDivByConstI(HMathFloorOfDiv* instr);
2775 LInstruction* DoFlooringDivI(HMathFloorOfDiv* instr);
2778 // Methods for getting operands for Use / Define / Temp.
2779 LUnallocated* ToUnallocated(Register reg);
2780 LUnallocated* ToUnallocated(XMMRegister reg);
2782 // Methods for setting up define-use relationships.
2783 MUST_USE_RESULT LOperand* Use(HValue* value, LUnallocated* operand);
2784 MUST_USE_RESULT LOperand* UseFixed(HValue* value, Register fixed_register);
2785 MUST_USE_RESULT LOperand* UseFixedDouble(HValue* value,
2786 XMMRegister fixed_register);
2788 // A value that is guaranteed to be allocated to a register.
2789 // Operand created by UseRegister is guaranteed to be live until the end of
2790 // instruction. This means that register allocator will not reuse it's
2791 // register for any other operand inside instruction.
2792 // Operand created by UseRegisterAtStart is guaranteed to be live only at
2793 // instruction start. Register allocator is free to assign the same register
2794 // to some other operand used inside instruction (i.e. temporary or
2796 MUST_USE_RESULT LOperand* UseRegister(HValue* value);
2797 MUST_USE_RESULT LOperand* UseRegisterAtStart(HValue* value);
2799 // An input operand in a register that may be trashed.
2800 MUST_USE_RESULT LOperand* UseTempRegister(HValue* value);
2802 // An input operand in a register that may be trashed or a constant operand.
2803 MUST_USE_RESULT LOperand* UseTempRegisterOrConstant(HValue* value);
2805 // An input operand in a register or stack slot.
2806 MUST_USE_RESULT LOperand* Use(HValue* value);
2807 MUST_USE_RESULT LOperand* UseAtStart(HValue* value);
2809 // An input operand in a register, stack slot or a constant operand.
2810 MUST_USE_RESULT LOperand* UseOrConstant(HValue* value);
2811 MUST_USE_RESULT LOperand* UseOrConstantAtStart(HValue* value);
2813 // An input operand in a register or a constant operand.
2814 MUST_USE_RESULT LOperand* UseRegisterOrConstant(HValue* value);
2815 MUST_USE_RESULT LOperand* UseRegisterOrConstantAtStart(HValue* value);
2817 // An input operand in a constant operand.
2818 MUST_USE_RESULT LOperand* UseConstant(HValue* value);
2820 // An input operand in register, stack slot or a constant operand.
2821 // Will not be moved to a register even if one is freely available.
2822 MUST_USE_RESULT LOperand* UseAny(HValue* value) override;
2824 // Temporary operand that must be in a register.
2825 MUST_USE_RESULT LUnallocated* TempRegister();
2826 MUST_USE_RESULT LOperand* FixedTemp(Register reg);
2827 MUST_USE_RESULT LOperand* FixedTemp(XMMRegister reg);
2829 // Methods for setting up define-use relationships.
2830 // Return the same instruction that they are passed.
2831 LInstruction* Define(LTemplateResultInstruction<1>* instr,
2832 LUnallocated* result);
2833 LInstruction* DefineAsRegister(LTemplateResultInstruction<1>* instr);
2834 LInstruction* DefineAsSpilled(LTemplateResultInstruction<1>* instr,
2836 LInstruction* DefineSameAsFirst(LTemplateResultInstruction<1>* instr);
2837 LInstruction* DefineFixed(LTemplateResultInstruction<1>* instr,
2839 LInstruction* DefineFixedDouble(LTemplateResultInstruction<1>* instr,
2841 // Assigns an environment to an instruction. An instruction which can
2842 // deoptimize must have an environment.
2843 LInstruction* AssignEnvironment(LInstruction* instr);
2844 // Assigns a pointer map to an instruction. An instruction which can
2845 // trigger a GC or a lazy deoptimization must have a pointer map.
2846 LInstruction* AssignPointerMap(LInstruction* instr);
2848 enum CanDeoptimize { CAN_DEOPTIMIZE_EAGERLY, CANNOT_DEOPTIMIZE_EAGERLY };
2850 // Marks a call for the register allocator. Assigns a pointer map to
2851 // support GC and lazy deoptimization. Assigns an environment to support
2852 // eager deoptimization if CAN_DEOPTIMIZE_EAGERLY.
2853 LInstruction* MarkAsCall(
2854 LInstruction* instr,
2855 HInstruction* hinstr,
2856 CanDeoptimize can_deoptimize = CANNOT_DEOPTIMIZE_EAGERLY);
2858 void VisitInstruction(HInstruction* current);
2859 void AddInstruction(LInstruction* instr, HInstruction* current);
2861 void DoBasicBlock(HBasicBlock* block, HBasicBlock* next_block);
2862 LInstruction* DoShift(Token::Value op, HBitwiseBinaryOperation* instr);
2863 LInstruction* DoArithmeticD(Token::Value op,
2864 HArithmeticBinaryOperation* instr);
2865 LInstruction* DoArithmeticT(Token::Value op,
2866 HBinaryOperation* instr);
2867 void FindDehoistedKeyDefinitions(HValue* candidate);
2869 HInstruction* current_instruction_;
2870 HBasicBlock* current_block_;
2871 HBasicBlock* next_block_;
2872 LAllocator* allocator_;
2874 DISALLOW_COPY_AND_ASSIGN(LChunkBuilder);
2877 #undef DECLARE_HYDROGEN_ACCESSOR
2878 #undef DECLARE_CONCRETE_INSTRUCTION
2880 } } // namespace v8::int
2882 #endif // V8_X64_LITHIUM_X64_H_