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() + 1, zone) {
1842 DCHECK(descriptor.GetRegisterParameterCount() + 1 == operands.length());
1843 inputs_.AddAll(operands, zone);
1846 LOperand* target() const { return inputs_[0]; }
1848 DECLARE_HYDROGEN_ACCESSOR(CallWithDescriptor)
1851 DECLARE_CONCRETE_INSTRUCTION(CallWithDescriptor, "call-with-descriptor")
1853 void PrintDataTo(StringStream* stream) override;
1855 int arity() const { return hydrogen()->argument_count() - 1; }
1857 ZoneList<LOperand*> inputs_;
1859 // Iterator support.
1860 int InputCount() final { return inputs_.length(); }
1861 LOperand* InputAt(int i) final { return inputs_[i]; }
1863 int TempCount() final { return 0; }
1864 LOperand* TempAt(int i) final { return NULL; }
1868 class LInvokeFunction final : public LTemplateInstruction<1, 2, 0> {
1870 LInvokeFunction(LOperand* context, LOperand* function) {
1871 inputs_[0] = context;
1872 inputs_[1] = function;
1875 LOperand* context() { return inputs_[0]; }
1876 LOperand* function() { return inputs_[1]; }
1878 DECLARE_CONCRETE_INSTRUCTION(InvokeFunction, "invoke-function")
1879 DECLARE_HYDROGEN_ACCESSOR(InvokeFunction)
1881 void PrintDataTo(StringStream* stream) override;
1883 int arity() const { return hydrogen()->argument_count() - 1; }
1887 class LCallFunction final : public LTemplateInstruction<1, 2, 2> {
1889 LCallFunction(LOperand* context, LOperand* function, LOperand* slot,
1891 inputs_[0] = context;
1892 inputs_[1] = function;
1897 DECLARE_CONCRETE_INSTRUCTION(CallFunction, "call-function")
1898 DECLARE_HYDROGEN_ACCESSOR(CallFunction)
1900 LOperand* context() { return inputs_[0]; }
1901 LOperand* function() { return inputs_[1]; }
1902 LOperand* temp_slot() { return temps_[0]; }
1903 LOperand* temp_vector() { return temps_[1]; }
1904 int arity() const { return hydrogen()->argument_count() - 1; }
1906 void PrintDataTo(StringStream* stream) override;
1910 class LCallNew final : public LTemplateInstruction<1, 2, 0> {
1912 LCallNew(LOperand* context, LOperand* constructor) {
1913 inputs_[0] = context;
1914 inputs_[1] = constructor;
1917 LOperand* context() { return inputs_[0]; }
1918 LOperand* constructor() { return inputs_[1]; }
1920 DECLARE_CONCRETE_INSTRUCTION(CallNew, "call-new")
1921 DECLARE_HYDROGEN_ACCESSOR(CallNew)
1923 void PrintDataTo(StringStream* stream) override;
1925 int arity() const { return hydrogen()->argument_count() - 1; }
1929 class LCallNewArray final : public LTemplateInstruction<1, 2, 0> {
1931 LCallNewArray(LOperand* context, LOperand* constructor) {
1932 inputs_[0] = context;
1933 inputs_[1] = constructor;
1936 LOperand* context() { return inputs_[0]; }
1937 LOperand* constructor() { return inputs_[1]; }
1939 DECLARE_CONCRETE_INSTRUCTION(CallNewArray, "call-new-array")
1940 DECLARE_HYDROGEN_ACCESSOR(CallNewArray)
1942 void PrintDataTo(StringStream* stream) override;
1944 int arity() const { return hydrogen()->argument_count() - 1; }
1948 class LCallRuntime final : public LTemplateInstruction<1, 1, 0> {
1950 explicit LCallRuntime(LOperand* context) {
1951 inputs_[0] = context;
1954 LOperand* context() { return inputs_[0]; }
1956 DECLARE_CONCRETE_INSTRUCTION(CallRuntime, "call-runtime")
1957 DECLARE_HYDROGEN_ACCESSOR(CallRuntime)
1959 bool ClobbersDoubleRegisters(Isolate* isolate) const override {
1960 return save_doubles() == kDontSaveFPRegs;
1963 const Runtime::Function* function() const { return hydrogen()->function(); }
1964 int arity() const { return hydrogen()->argument_count(); }
1965 SaveFPRegsMode save_doubles() const { return hydrogen()->save_doubles(); }
1969 class LInteger32ToDouble final : public LTemplateInstruction<1, 1, 0> {
1971 explicit LInteger32ToDouble(LOperand* value) {
1975 LOperand* value() { return inputs_[0]; }
1977 DECLARE_CONCRETE_INSTRUCTION(Integer32ToDouble, "int32-to-double")
1981 class LUint32ToDouble final : public LTemplateInstruction<1, 1, 0> {
1983 explicit LUint32ToDouble(LOperand* value) {
1987 LOperand* value() { return inputs_[0]; }
1989 DECLARE_CONCRETE_INSTRUCTION(Uint32ToDouble, "uint32-to-double")
1993 class LNumberTagI final : public LTemplateInstruction<1, 1, 2> {
1995 LNumberTagI(LOperand* value, LOperand* temp1, LOperand* temp2) {
2001 LOperand* value() { return inputs_[0]; }
2002 LOperand* temp1() { return temps_[0]; }
2003 LOperand* temp2() { return temps_[1]; }
2005 DECLARE_CONCRETE_INSTRUCTION(NumberTagI, "number-tag-i")
2009 class LNumberTagU final : public LTemplateInstruction<1, 1, 2> {
2011 LNumberTagU(LOperand* value, LOperand* temp1, LOperand* temp2) {
2017 LOperand* value() { return inputs_[0]; }
2018 LOperand* temp1() { return temps_[0]; }
2019 LOperand* temp2() { return temps_[1]; }
2021 DECLARE_CONCRETE_INSTRUCTION(NumberTagU, "number-tag-u")
2025 class LNumberTagD final : public LTemplateInstruction<1, 1, 1> {
2027 explicit LNumberTagD(LOperand* value, LOperand* temp) {
2032 LOperand* value() { return inputs_[0]; }
2033 LOperand* temp() { return temps_[0]; }
2035 DECLARE_CONCRETE_INSTRUCTION(NumberTagD, "number-tag-d")
2036 DECLARE_HYDROGEN_ACCESSOR(Change)
2040 // Sometimes truncating conversion from a tagged value to an int32.
2041 class LDoubleToI final : public LTemplateInstruction<1, 1, 0> {
2043 explicit LDoubleToI(LOperand* value) {
2047 LOperand* value() { return inputs_[0]; }
2049 DECLARE_CONCRETE_INSTRUCTION(DoubleToI, "double-to-i")
2050 DECLARE_HYDROGEN_ACCESSOR(UnaryOperation)
2052 bool truncating() { return hydrogen()->CanTruncateToInt32(); }
2056 class LDoubleToSmi final : public LTemplateInstruction<1, 1, 0> {
2058 explicit LDoubleToSmi(LOperand* value) {
2062 LOperand* value() { return inputs_[0]; }
2064 DECLARE_CONCRETE_INSTRUCTION(DoubleToSmi, "double-to-smi")
2065 DECLARE_HYDROGEN_ACCESSOR(UnaryOperation)
2069 // Truncating conversion from a tagged value to an int32.
2070 class LTaggedToI final : public LTemplateInstruction<1, 1, 1> {
2072 LTaggedToI(LOperand* value, LOperand* temp) {
2077 LOperand* value() { return inputs_[0]; }
2078 LOperand* temp() { return temps_[0]; }
2080 DECLARE_CONCRETE_INSTRUCTION(TaggedToI, "tagged-to-i")
2081 DECLARE_HYDROGEN_ACCESSOR(Change)
2083 bool truncating() { return hydrogen()->CanTruncateToInt32(); }
2087 class LSmiTag final : public LTemplateInstruction<1, 1, 0> {
2089 explicit LSmiTag(LOperand* value) {
2093 LOperand* value() { return inputs_[0]; }
2095 DECLARE_CONCRETE_INSTRUCTION(SmiTag, "smi-tag")
2096 DECLARE_HYDROGEN_ACCESSOR(Change)
2100 class LNumberUntagD final : public LTemplateInstruction<1, 1, 0> {
2102 explicit LNumberUntagD(LOperand* value) {
2106 LOperand* value() { return inputs_[0]; }
2108 DECLARE_CONCRETE_INSTRUCTION(NumberUntagD, "double-untag")
2109 DECLARE_HYDROGEN_ACCESSOR(Change);
2113 class LSmiUntag final : public LTemplateInstruction<1, 1, 0> {
2115 LSmiUntag(LOperand* value, bool needs_check)
2116 : needs_check_(needs_check) {
2120 LOperand* value() { return inputs_[0]; }
2121 bool needs_check() const { return needs_check_; }
2123 DECLARE_CONCRETE_INSTRUCTION(SmiUntag, "smi-untag")
2130 class LStoreNamedField final : public LTemplateInstruction<0, 2, 1> {
2132 LStoreNamedField(LOperand* object, LOperand* value, LOperand* temp) {
2133 inputs_[0] = object;
2138 LOperand* object() { return inputs_[0]; }
2139 LOperand* value() { return inputs_[1]; }
2140 LOperand* temp() { return temps_[0]; }
2142 DECLARE_CONCRETE_INSTRUCTION(StoreNamedField, "store-named-field")
2143 DECLARE_HYDROGEN_ACCESSOR(StoreNamedField)
2145 void PrintDataTo(StringStream* stream) override;
2147 Representation representation() const {
2148 return hydrogen()->field_representation();
2153 class LStoreNamedGeneric final : public LTemplateInstruction<0, 3, 0> {
2155 LStoreNamedGeneric(LOperand* context, LOperand* object, LOperand* value) {
2156 inputs_[0] = context;
2157 inputs_[1] = object;
2161 LOperand* context() { return inputs_[0]; }
2162 LOperand* object() { return inputs_[1]; }
2163 LOperand* value() { return inputs_[2]; }
2165 DECLARE_CONCRETE_INSTRUCTION(StoreNamedGeneric, "store-named-generic")
2166 DECLARE_HYDROGEN_ACCESSOR(StoreNamedGeneric)
2168 void PrintDataTo(StringStream* stream) override;
2170 Handle<Object> name() const { return hydrogen()->name(); }
2171 LanguageMode language_mode() { return hydrogen()->language_mode(); }
2175 class LStoreKeyed final : public LTemplateInstruction<0, 3, 0> {
2177 LStoreKeyed(LOperand* object, LOperand* key, LOperand* value) {
2178 inputs_[0] = object;
2183 bool is_external() const { return hydrogen()->is_external(); }
2184 bool is_fixed_typed_array() const {
2185 return hydrogen()->is_fixed_typed_array();
2187 bool is_typed_elements() const {
2188 return is_external() || is_fixed_typed_array();
2190 LOperand* elements() { return inputs_[0]; }
2191 LOperand* key() { return inputs_[1]; }
2192 LOperand* value() { return inputs_[2]; }
2193 ElementsKind elements_kind() const { return hydrogen()->elements_kind(); }
2195 DECLARE_CONCRETE_INSTRUCTION(StoreKeyed, "store-keyed")
2196 DECLARE_HYDROGEN_ACCESSOR(StoreKeyed)
2198 void PrintDataTo(StringStream* stream) override;
2199 bool NeedsCanonicalization() { return hydrogen()->NeedsCanonicalization(); }
2200 uint32_t base_offset() const { return hydrogen()->base_offset(); }
2204 class LStoreKeyedGeneric final : public LTemplateInstruction<0, 4, 0> {
2206 LStoreKeyedGeneric(LOperand* context,
2210 inputs_[0] = context;
2211 inputs_[1] = object;
2216 LOperand* context() { return inputs_[0]; }
2217 LOperand* object() { return inputs_[1]; }
2218 LOperand* key() { return inputs_[2]; }
2219 LOperand* value() { return inputs_[3]; }
2221 DECLARE_CONCRETE_INSTRUCTION(StoreKeyedGeneric, "store-keyed-generic")
2222 DECLARE_HYDROGEN_ACCESSOR(StoreKeyedGeneric)
2224 void PrintDataTo(StringStream* stream) override;
2226 LanguageMode language_mode() { return hydrogen()->language_mode(); }
2230 class LTransitionElementsKind final : public LTemplateInstruction<0, 2, 2> {
2232 LTransitionElementsKind(LOperand* object,
2234 LOperand* new_map_temp,
2236 inputs_[0] = object;
2237 inputs_[1] = context;
2238 temps_[0] = new_map_temp;
2242 LOperand* object() { return inputs_[0]; }
2243 LOperand* context() { return inputs_[1]; }
2244 LOperand* new_map_temp() { return temps_[0]; }
2245 LOperand* temp() { return temps_[1]; }
2247 DECLARE_CONCRETE_INSTRUCTION(TransitionElementsKind,
2248 "transition-elements-kind")
2249 DECLARE_HYDROGEN_ACCESSOR(TransitionElementsKind)
2251 void PrintDataTo(StringStream* stream) override;
2253 Handle<Map> original_map() { return hydrogen()->original_map().handle(); }
2254 Handle<Map> transitioned_map() {
2255 return hydrogen()->transitioned_map().handle();
2257 ElementsKind from_kind() { return hydrogen()->from_kind(); }
2258 ElementsKind to_kind() { return hydrogen()->to_kind(); }
2262 class LTrapAllocationMemento final : public LTemplateInstruction<0, 1, 1> {
2264 LTrapAllocationMemento(LOperand* object,
2266 inputs_[0] = object;
2270 LOperand* object() { return inputs_[0]; }
2271 LOperand* temp() { return temps_[0]; }
2273 DECLARE_CONCRETE_INSTRUCTION(TrapAllocationMemento,
2274 "trap-allocation-memento")
2278 class LMaybeGrowElements final : public LTemplateInstruction<1, 5, 0> {
2280 LMaybeGrowElements(LOperand* context, LOperand* object, LOperand* elements,
2281 LOperand* key, LOperand* current_capacity) {
2282 inputs_[0] = context;
2283 inputs_[1] = object;
2284 inputs_[2] = elements;
2286 inputs_[4] = current_capacity;
2289 LOperand* context() { return inputs_[0]; }
2290 LOperand* object() { return inputs_[1]; }
2291 LOperand* elements() { return inputs_[2]; }
2292 LOperand* key() { return inputs_[3]; }
2293 LOperand* current_capacity() { return inputs_[4]; }
2295 DECLARE_HYDROGEN_ACCESSOR(MaybeGrowElements)
2296 DECLARE_CONCRETE_INSTRUCTION(MaybeGrowElements, "maybe-grow-elements")
2300 class LStringAdd final : public LTemplateInstruction<1, 3, 0> {
2302 LStringAdd(LOperand* context, LOperand* left, LOperand* right) {
2303 inputs_[0] = context;
2308 LOperand* context() { return inputs_[0]; }
2309 LOperand* left() { return inputs_[1]; }
2310 LOperand* right() { return inputs_[2]; }
2312 DECLARE_CONCRETE_INSTRUCTION(StringAdd, "string-add")
2313 DECLARE_HYDROGEN_ACCESSOR(StringAdd)
2317 class LStringCharCodeAt final : public LTemplateInstruction<1, 3, 0> {
2319 LStringCharCodeAt(LOperand* context, LOperand* string, LOperand* index) {
2320 inputs_[0] = context;
2321 inputs_[1] = string;
2325 LOperand* context() { return inputs_[0]; }
2326 LOperand* string() { return inputs_[1]; }
2327 LOperand* index() { return inputs_[2]; }
2329 DECLARE_CONCRETE_INSTRUCTION(StringCharCodeAt, "string-char-code-at")
2330 DECLARE_HYDROGEN_ACCESSOR(StringCharCodeAt)
2334 class LStringCharFromCode final : public LTemplateInstruction<1, 2, 0> {
2336 explicit LStringCharFromCode(LOperand* context, LOperand* char_code) {
2337 inputs_[0] = context;
2338 inputs_[1] = char_code;
2341 LOperand* context() { return inputs_[0]; }
2342 LOperand* char_code() { return inputs_[1]; }
2344 DECLARE_CONCRETE_INSTRUCTION(StringCharFromCode, "string-char-from-code")
2345 DECLARE_HYDROGEN_ACCESSOR(StringCharFromCode)
2349 class LCheckValue final : public LTemplateInstruction<0, 1, 0> {
2351 explicit LCheckValue(LOperand* value) {
2355 LOperand* value() { return inputs_[0]; }
2357 DECLARE_CONCRETE_INSTRUCTION(CheckValue, "check-value")
2358 DECLARE_HYDROGEN_ACCESSOR(CheckValue)
2362 class LCheckArrayBufferNotNeutered final
2363 : public LTemplateInstruction<0, 1, 0> {
2365 explicit LCheckArrayBufferNotNeutered(LOperand* view) { inputs_[0] = view; }
2367 LOperand* view() { return inputs_[0]; }
2369 DECLARE_CONCRETE_INSTRUCTION(CheckArrayBufferNotNeutered,
2370 "check-array-buffer-not-neutered")
2371 DECLARE_HYDROGEN_ACCESSOR(CheckArrayBufferNotNeutered)
2375 class LCheckInstanceType final : public LTemplateInstruction<0, 1, 0> {
2377 explicit LCheckInstanceType(LOperand* value) {
2381 LOperand* value() { return inputs_[0]; }
2383 DECLARE_CONCRETE_INSTRUCTION(CheckInstanceType, "check-instance-type")
2384 DECLARE_HYDROGEN_ACCESSOR(CheckInstanceType)
2388 class LCheckMaps final : public LTemplateInstruction<0, 1, 0> {
2390 explicit LCheckMaps(LOperand* value = NULL) {
2394 LOperand* value() { return inputs_[0]; }
2396 DECLARE_CONCRETE_INSTRUCTION(CheckMaps, "check-maps")
2397 DECLARE_HYDROGEN_ACCESSOR(CheckMaps)
2401 class LCheckSmi final : public LTemplateInstruction<1, 1, 0> {
2403 explicit LCheckSmi(LOperand* value) {
2407 LOperand* value() { return inputs_[0]; }
2409 DECLARE_CONCRETE_INSTRUCTION(CheckSmi, "check-smi")
2413 class LClampDToUint8 final : public LTemplateInstruction<1, 1, 0> {
2415 explicit LClampDToUint8(LOperand* unclamped) {
2416 inputs_[0] = unclamped;
2419 LOperand* unclamped() { return inputs_[0]; }
2421 DECLARE_CONCRETE_INSTRUCTION(ClampDToUint8, "clamp-d-to-uint8")
2425 class LClampIToUint8 final : public LTemplateInstruction<1, 1, 0> {
2427 explicit LClampIToUint8(LOperand* unclamped) {
2428 inputs_[0] = unclamped;
2431 LOperand* unclamped() { return inputs_[0]; }
2433 DECLARE_CONCRETE_INSTRUCTION(ClampIToUint8, "clamp-i-to-uint8")
2437 class LClampTToUint8 final : public LTemplateInstruction<1, 1, 1> {
2439 LClampTToUint8(LOperand* unclamped,
2440 LOperand* temp_xmm) {
2441 inputs_[0] = unclamped;
2442 temps_[0] = temp_xmm;
2445 LOperand* unclamped() { return inputs_[0]; }
2446 LOperand* temp_xmm() { return temps_[0]; }
2448 DECLARE_CONCRETE_INSTRUCTION(ClampTToUint8, "clamp-t-to-uint8")
2452 class LCheckNonSmi final : public LTemplateInstruction<0, 1, 0> {
2454 explicit LCheckNonSmi(LOperand* value) {
2458 LOperand* value() { return inputs_[0]; }
2460 DECLARE_CONCRETE_INSTRUCTION(CheckNonSmi, "check-non-smi")
2461 DECLARE_HYDROGEN_ACCESSOR(CheckHeapObject)
2465 class LDoubleBits final : public LTemplateInstruction<1, 1, 0> {
2467 explicit LDoubleBits(LOperand* value) {
2471 LOperand* value() { return inputs_[0]; }
2473 DECLARE_CONCRETE_INSTRUCTION(DoubleBits, "double-bits")
2474 DECLARE_HYDROGEN_ACCESSOR(DoubleBits)
2478 class LConstructDouble final : public LTemplateInstruction<1, 2, 0> {
2480 LConstructDouble(LOperand* hi, LOperand* lo) {
2485 LOperand* hi() { return inputs_[0]; }
2486 LOperand* lo() { return inputs_[1]; }
2488 DECLARE_CONCRETE_INSTRUCTION(ConstructDouble, "construct-double")
2492 class LAllocate final : public LTemplateInstruction<1, 2, 1> {
2494 LAllocate(LOperand* context, LOperand* size, LOperand* temp) {
2495 inputs_[0] = context;
2500 LOperand* context() { return inputs_[0]; }
2501 LOperand* size() { return inputs_[1]; }
2502 LOperand* temp() { return temps_[0]; }
2504 DECLARE_CONCRETE_INSTRUCTION(Allocate, "allocate")
2505 DECLARE_HYDROGEN_ACCESSOR(Allocate)
2509 class LRegExpLiteral final : public LTemplateInstruction<1, 1, 0> {
2511 explicit LRegExpLiteral(LOperand* context) {
2512 inputs_[0] = context;
2515 LOperand* context() { return inputs_[0]; }
2517 DECLARE_CONCRETE_INSTRUCTION(RegExpLiteral, "regexp-literal")
2518 DECLARE_HYDROGEN_ACCESSOR(RegExpLiteral)
2522 class LFunctionLiteral final : public LTemplateInstruction<1, 1, 0> {
2524 explicit LFunctionLiteral(LOperand* context) {
2525 inputs_[0] = context;
2528 LOperand* context() { return inputs_[0]; }
2530 DECLARE_CONCRETE_INSTRUCTION(FunctionLiteral, "function-literal")
2531 DECLARE_HYDROGEN_ACCESSOR(FunctionLiteral)
2535 class LToFastProperties final : public LTemplateInstruction<1, 1, 0> {
2537 explicit LToFastProperties(LOperand* value) {
2541 LOperand* value() { return inputs_[0]; }
2543 DECLARE_CONCRETE_INSTRUCTION(ToFastProperties, "to-fast-properties")
2544 DECLARE_HYDROGEN_ACCESSOR(ToFastProperties)
2548 class LTypeof final : public LTemplateInstruction<1, 2, 0> {
2550 LTypeof(LOperand* context, LOperand* value) {
2551 inputs_[0] = context;
2555 LOperand* context() { return inputs_[0]; }
2556 LOperand* value() { return inputs_[1]; }
2558 DECLARE_CONCRETE_INSTRUCTION(Typeof, "typeof")
2562 class LTypeofIsAndBranch final : public LControlInstruction<1, 0> {
2564 explicit LTypeofIsAndBranch(LOperand* value) {
2568 LOperand* value() { return inputs_[0]; }
2570 DECLARE_CONCRETE_INSTRUCTION(TypeofIsAndBranch, "typeof-is-and-branch")
2571 DECLARE_HYDROGEN_ACCESSOR(TypeofIsAndBranch)
2573 Handle<String> type_literal() { return hydrogen()->type_literal(); }
2575 void PrintDataTo(StringStream* stream) override;
2579 class LIsConstructCallAndBranch final : public LControlInstruction<0, 1> {
2581 explicit LIsConstructCallAndBranch(LOperand* temp) {
2585 LOperand* temp() { return temps_[0]; }
2587 DECLARE_CONCRETE_INSTRUCTION(IsConstructCallAndBranch,
2588 "is-construct-call-and-branch")
2589 DECLARE_HYDROGEN_ACCESSOR(IsConstructCallAndBranch)
2593 class LOsrEntry final : public LTemplateInstruction<0, 0, 0> {
2597 bool HasInterestingComment(LCodeGen* gen) const override { return false; }
2598 DECLARE_CONCRETE_INSTRUCTION(OsrEntry, "osr-entry")
2602 class LStackCheck final : public LTemplateInstruction<0, 1, 0> {
2604 explicit LStackCheck(LOperand* context) {
2605 inputs_[0] = context;
2608 LOperand* context() { return inputs_[0]; }
2610 DECLARE_CONCRETE_INSTRUCTION(StackCheck, "stack-check")
2611 DECLARE_HYDROGEN_ACCESSOR(StackCheck)
2613 Label* done_label() { return &done_label_; }
2620 class LForInPrepareMap final : public LTemplateInstruction<1, 2, 0> {
2622 LForInPrepareMap(LOperand* context, LOperand* object) {
2623 inputs_[0] = context;
2624 inputs_[1] = object;
2627 LOperand* context() { return inputs_[0]; }
2628 LOperand* object() { return inputs_[1]; }
2630 DECLARE_CONCRETE_INSTRUCTION(ForInPrepareMap, "for-in-prepare-map")
2634 class LForInCacheArray final : public LTemplateInstruction<1, 1, 0> {
2636 explicit LForInCacheArray(LOperand* map) {
2640 LOperand* map() { return inputs_[0]; }
2642 DECLARE_CONCRETE_INSTRUCTION(ForInCacheArray, "for-in-cache-array")
2645 return HForInCacheArray::cast(this->hydrogen_value())->idx();
2650 class LCheckMapValue final : public LTemplateInstruction<0, 2, 0> {
2652 LCheckMapValue(LOperand* value, LOperand* map) {
2657 LOperand* value() { return inputs_[0]; }
2658 LOperand* map() { return inputs_[1]; }
2660 DECLARE_CONCRETE_INSTRUCTION(CheckMapValue, "check-map-value")
2664 class LLoadFieldByIndex final : public LTemplateInstruction<1, 2, 0> {
2666 LLoadFieldByIndex(LOperand* object, LOperand* index) {
2667 inputs_[0] = object;
2671 LOperand* object() { return inputs_[0]; }
2672 LOperand* index() { return inputs_[1]; }
2674 DECLARE_CONCRETE_INSTRUCTION(LoadFieldByIndex, "load-field-by-index")
2678 class LStoreFrameContext: public LTemplateInstruction<0, 1, 0> {
2680 explicit LStoreFrameContext(LOperand* context) {
2681 inputs_[0] = context;
2684 LOperand* context() { return inputs_[0]; }
2686 DECLARE_CONCRETE_INSTRUCTION(StoreFrameContext, "store-frame-context")
2690 class LAllocateBlockContext: public LTemplateInstruction<1, 2, 0> {
2692 LAllocateBlockContext(LOperand* context, LOperand* function) {
2693 inputs_[0] = context;
2694 inputs_[1] = function;
2697 LOperand* context() { return inputs_[0]; }
2698 LOperand* function() { return inputs_[1]; }
2700 Handle<ScopeInfo> scope_info() { return hydrogen()->scope_info(); }
2702 DECLARE_CONCRETE_INSTRUCTION(AllocateBlockContext, "allocate-block-context")
2703 DECLARE_HYDROGEN_ACCESSOR(AllocateBlockContext)
2707 class LChunkBuilder;
2708 class LPlatformChunk final : public LChunk {
2710 LPlatformChunk(CompilationInfo* info, HGraph* graph)
2711 : LChunk(info, graph),
2712 dehoisted_key_ids_(graph->GetMaximumValueID(), graph->zone()) { }
2714 int GetNextSpillIndex(RegisterKind kind);
2715 LOperand* GetNextSpillSlot(RegisterKind kind);
2716 BitVector* GetDehoistedKeyIds() { return &dehoisted_key_ids_; }
2717 bool IsDehoistedKey(HValue* value) {
2718 return dehoisted_key_ids_.Contains(value->id());
2722 BitVector dehoisted_key_ids_;
2726 class LChunkBuilder final : public LChunkBuilderBase {
2728 LChunkBuilder(CompilationInfo* info, HGraph* graph, LAllocator* allocator)
2729 : LChunkBuilderBase(info, graph),
2730 current_instruction_(NULL),
2731 current_block_(NULL),
2733 allocator_(allocator) {}
2735 // Build the sequence for the graph.
2736 LPlatformChunk* Build();
2738 // Declare methods that deal with the individual node types.
2739 #define DECLARE_DO(type) LInstruction* Do##type(H##type* node);
2740 HYDROGEN_CONCRETE_INSTRUCTION_LIST(DECLARE_DO)
2743 LInstruction* DoMathFloor(HUnaryMathOperation* instr);
2744 LInstruction* DoMathRound(HUnaryMathOperation* instr);
2745 LInstruction* DoMathFround(HUnaryMathOperation* instr);
2746 LInstruction* DoMathAbs(HUnaryMathOperation* instr);
2747 LInstruction* DoMathLog(HUnaryMathOperation* instr);
2748 LInstruction* DoMathExp(HUnaryMathOperation* instr);
2749 LInstruction* DoMathSqrt(HUnaryMathOperation* instr);
2750 LInstruction* DoMathPowHalf(HUnaryMathOperation* instr);
2751 LInstruction* DoMathClz32(HUnaryMathOperation* instr);
2752 LInstruction* DoDivByPowerOf2I(HDiv* instr);
2753 LInstruction* DoDivByConstI(HDiv* instr);
2754 LInstruction* DoDivI(HDiv* instr);
2755 LInstruction* DoModByPowerOf2I(HMod* instr);
2756 LInstruction* DoModByConstI(HMod* instr);
2757 LInstruction* DoModI(HMod* instr);
2758 LInstruction* DoFlooringDivByPowerOf2I(HMathFloorOfDiv* instr);
2759 LInstruction* DoFlooringDivByConstI(HMathFloorOfDiv* instr);
2760 LInstruction* DoFlooringDivI(HMathFloorOfDiv* instr);
2763 // Methods for getting operands for Use / Define / Temp.
2764 LUnallocated* ToUnallocated(Register reg);
2765 LUnallocated* ToUnallocated(XMMRegister reg);
2767 // Methods for setting up define-use relationships.
2768 MUST_USE_RESULT LOperand* Use(HValue* value, LUnallocated* operand);
2769 MUST_USE_RESULT LOperand* UseFixed(HValue* value, Register fixed_register);
2770 MUST_USE_RESULT LOperand* UseFixedDouble(HValue* value,
2771 XMMRegister fixed_register);
2773 // A value that is guaranteed to be allocated to a register.
2774 // Operand created by UseRegister is guaranteed to be live until the end of
2775 // instruction. This means that register allocator will not reuse it's
2776 // register for any other operand inside instruction.
2777 // Operand created by UseRegisterAtStart is guaranteed to be live only at
2778 // instruction start. Register allocator is free to assign the same register
2779 // to some other operand used inside instruction (i.e. temporary or
2781 MUST_USE_RESULT LOperand* UseRegister(HValue* value);
2782 MUST_USE_RESULT LOperand* UseRegisterAtStart(HValue* value);
2784 // An input operand in a register that may be trashed.
2785 MUST_USE_RESULT LOperand* UseTempRegister(HValue* value);
2787 // An input operand in a register that may be trashed or a constant operand.
2788 MUST_USE_RESULT LOperand* UseTempRegisterOrConstant(HValue* value);
2790 // An input operand in a register or stack slot.
2791 MUST_USE_RESULT LOperand* Use(HValue* value);
2792 MUST_USE_RESULT LOperand* UseAtStart(HValue* value);
2794 // An input operand in a register, stack slot or a constant operand.
2795 MUST_USE_RESULT LOperand* UseOrConstant(HValue* value);
2796 MUST_USE_RESULT LOperand* UseOrConstantAtStart(HValue* value);
2798 // An input operand in a register or a constant operand.
2799 MUST_USE_RESULT LOperand* UseRegisterOrConstant(HValue* value);
2800 MUST_USE_RESULT LOperand* UseRegisterOrConstantAtStart(HValue* value);
2802 // An input operand in a constant operand.
2803 MUST_USE_RESULT LOperand* UseConstant(HValue* value);
2805 // An input operand in register, stack slot or a constant operand.
2806 // Will not be moved to a register even if one is freely available.
2807 MUST_USE_RESULT LOperand* UseAny(HValue* value) override;
2809 // Temporary operand that must be in a register.
2810 MUST_USE_RESULT LUnallocated* TempRegister();
2811 MUST_USE_RESULT LOperand* FixedTemp(Register reg);
2812 MUST_USE_RESULT LOperand* FixedTemp(XMMRegister reg);
2814 // Methods for setting up define-use relationships.
2815 // Return the same instruction that they are passed.
2816 LInstruction* Define(LTemplateResultInstruction<1>* instr,
2817 LUnallocated* result);
2818 LInstruction* DefineAsRegister(LTemplateResultInstruction<1>* instr);
2819 LInstruction* DefineAsSpilled(LTemplateResultInstruction<1>* instr,
2821 LInstruction* DefineSameAsFirst(LTemplateResultInstruction<1>* instr);
2822 LInstruction* DefineFixed(LTemplateResultInstruction<1>* instr,
2824 LInstruction* DefineFixedDouble(LTemplateResultInstruction<1>* instr,
2826 // Assigns an environment to an instruction. An instruction which can
2827 // deoptimize must have an environment.
2828 LInstruction* AssignEnvironment(LInstruction* instr);
2829 // Assigns a pointer map to an instruction. An instruction which can
2830 // trigger a GC or a lazy deoptimization must have a pointer map.
2831 LInstruction* AssignPointerMap(LInstruction* instr);
2833 enum CanDeoptimize { CAN_DEOPTIMIZE_EAGERLY, CANNOT_DEOPTIMIZE_EAGERLY };
2835 // Marks a call for the register allocator. Assigns a pointer map to
2836 // support GC and lazy deoptimization. Assigns an environment to support
2837 // eager deoptimization if CAN_DEOPTIMIZE_EAGERLY.
2838 LInstruction* MarkAsCall(
2839 LInstruction* instr,
2840 HInstruction* hinstr,
2841 CanDeoptimize can_deoptimize = CANNOT_DEOPTIMIZE_EAGERLY);
2843 void VisitInstruction(HInstruction* current);
2844 void AddInstruction(LInstruction* instr, HInstruction* current);
2846 void DoBasicBlock(HBasicBlock* block, HBasicBlock* next_block);
2847 LInstruction* DoShift(Token::Value op, HBitwiseBinaryOperation* instr);
2848 LInstruction* DoArithmeticD(Token::Value op,
2849 HArithmeticBinaryOperation* instr);
2850 LInstruction* DoArithmeticT(Token::Value op,
2851 HBinaryOperation* instr);
2852 void FindDehoistedKeyDefinitions(HValue* candidate);
2854 HInstruction* current_instruction_;
2855 HBasicBlock* current_block_;
2856 HBasicBlock* next_block_;
2857 LAllocator* allocator_;
2859 DISALLOW_COPY_AND_ASSIGN(LChunkBuilder);
2862 #undef DECLARE_HYDROGEN_ACCESSOR
2863 #undef DECLARE_CONCRETE_INSTRUCTION
2865 } } // namespace v8::int
2867 #endif // V8_X64_LITHIUM_X64_H_