1 // Copyright 2013 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_ARM64_LITHIUM_ARM64_H_
6 #define V8_ARM64_LITHIUM_ARM64_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) \
26 V(AllocateBlockContext) \
28 V(ArgumentsElements) \
42 V(CallWithDescriptor) \
43 V(CheckArrayBufferNotNeutered) \
44 V(CheckInstanceType) \
53 V(ClassOfTestAndBranch) \
54 V(CmpHoleAndBranchD) \
55 V(CmpHoleAndBranchT) \
57 V(CmpObjectEqAndBranch) \
59 V(CompareMinusZeroAndBranch) \
60 V(CompareNumericAndBranch) \
80 V(FlooringDivByConstI) \
81 V(FlooringDivByPowerOf2I) \
86 V(GetCachedArrayIndex) \
88 V(HasCachedArrayIndexAndBranch) \
89 V(HasInstanceTypeAndBranch) \
90 V(InnerAllocatedObject) \
92 V(InstanceOfKnownGlobal) \
94 V(Integer32ToDouble) \
96 V(IsConstructCallAndBranch) \
97 V(IsObjectAndBranch) \
99 V(IsStringAndBranch) \
100 V(IsUndetectableAndBranch) \
104 V(LoadFieldByIndex) \
105 V(LoadFunctionPrototype) \
106 V(LoadGlobalGeneric) \
107 V(LoadKeyedExternal) \
109 V(LoadKeyedFixedDouble) \
110 V(LoadKeyedGeneric) \
112 V(LoadNamedGeneric) \
128 V(MaybeGrowElements) \
141 V(PreparePushArguments) \
145 V(SeqStringGetChar) \
146 V(SeqStringSetChar) \
153 V(StoreContextSlot) \
154 V(StoreFrameContext) \
155 V(StoreKeyedExternal) \
157 V(StoreKeyedFixedDouble) \
158 V(StoreKeyedGeneric) \
160 V(StoreNamedGeneric) \
162 V(StringCharCodeAt) \
163 V(StringCharFromCode) \
164 V(StringCompareAndBranch) \
169 V(ToFastProperties) \
170 V(TransitionElementsKind) \
171 V(TrapAllocationMemento) \
172 V(TruncateDoubleToIntOrSmi) \
174 V(TypeofIsAndBranch) \
180 #define DECLARE_CONCRETE_INSTRUCTION(type, mnemonic) \
181 Opcode opcode() const final { return LInstruction::k##type; } \
182 void CompileToNative(LCodeGen* generator) final; \
183 const char* Mnemonic() const final { return mnemonic; } \
184 static L##type* cast(LInstruction* instr) { \
185 DCHECK(instr->Is##type()); \
186 return reinterpret_cast<L##type*>(instr); \
190 #define DECLARE_HYDROGEN_ACCESSOR(type) \
191 H##type* hydrogen() const { \
192 return H##type::cast(this->hydrogen_value()); \
196 class LInstruction : public ZoneObject {
199 : environment_(NULL),
200 hydrogen_value_(NULL),
201 bit_field_(IsCallBits::encode(false)) { }
203 virtual ~LInstruction() { }
205 virtual void CompileToNative(LCodeGen* generator) = 0;
206 virtual const char* Mnemonic() const = 0;
207 virtual void PrintTo(StringStream* stream);
208 virtual void PrintDataTo(StringStream* stream);
209 virtual void PrintOutputOperandTo(StringStream* stream);
212 // Declare a unique enum value for each instruction.
213 #define DECLARE_OPCODE(type) k##type,
214 LITHIUM_CONCRETE_INSTRUCTION_LIST(DECLARE_OPCODE)
215 kNumberOfInstructions
216 #undef DECLARE_OPCODE
219 virtual Opcode opcode() const = 0;
221 // Declare non-virtual type testers for all leaf IR classes.
222 #define DECLARE_PREDICATE(type) \
223 bool Is##type() const { return opcode() == k##type; }
224 LITHIUM_CONCRETE_INSTRUCTION_LIST(DECLARE_PREDICATE)
225 #undef DECLARE_PREDICATE
227 // Declare virtual predicates for instructions that don't have
229 virtual bool IsGap() const { return false; }
231 virtual bool IsControl() const { return false; }
233 // Try deleting this instruction if possible.
234 virtual bool TryDelete() { return false; }
236 void set_environment(LEnvironment* env) { environment_ = env; }
237 LEnvironment* environment() const { return environment_; }
238 bool HasEnvironment() const { return environment_ != NULL; }
240 void set_pointer_map(LPointerMap* p) { pointer_map_.set(p); }
241 LPointerMap* pointer_map() const { return pointer_map_.get(); }
242 bool HasPointerMap() const { return pointer_map_.is_set(); }
244 void set_hydrogen_value(HValue* value) { hydrogen_value_ = value; }
245 HValue* hydrogen_value() const { return hydrogen_value_; }
247 virtual void SetDeferredLazyDeoptimizationEnvironment(LEnvironment* env) { }
249 void MarkAsCall() { bit_field_ = IsCallBits::update(bit_field_, true); }
250 bool IsCall() const { return IsCallBits::decode(bit_field_); }
252 // Interface to the register allocator and iterators.
253 bool ClobbersTemps() const { return IsCall(); }
254 bool ClobbersRegisters() const { return IsCall(); }
255 virtual bool ClobbersDoubleRegisters(Isolate* isolate) const {
258 bool IsMarkedAsCall() const { return IsCall(); }
260 virtual bool HasResult() const = 0;
261 virtual LOperand* result() const = 0;
263 virtual int InputCount() = 0;
264 virtual LOperand* InputAt(int i) = 0;
265 virtual int TempCount() = 0;
266 virtual LOperand* TempAt(int i) = 0;
268 LOperand* FirstInput() { return InputAt(0); }
269 LOperand* Output() { return HasResult() ? result() : NULL; }
271 virtual bool HasInterestingComment(LCodeGen* gen) const { return true; }
278 class IsCallBits: public BitField<bool, 0, 1> {};
280 LEnvironment* environment_;
281 SetOncePointer<LPointerMap> pointer_map_;
282 HValue* hydrogen_value_;
287 // R = number of result operands (0 or 1).
289 class LTemplateResultInstruction : public LInstruction {
291 // Allow 0 or 1 output operands.
292 STATIC_ASSERT(R == 0 || R == 1);
293 bool HasResult() const final { return (R != 0) && (result() != NULL); }
294 void set_result(LOperand* operand) { results_[0] = operand; }
295 LOperand* result() const override { return results_[0]; }
298 EmbeddedContainer<LOperand*, R> results_;
302 // R = number of result operands (0 or 1).
303 // I = number of input operands.
304 // T = number of temporary operands.
305 template<int R, int I, int T>
306 class LTemplateInstruction : public LTemplateResultInstruction<R> {
308 EmbeddedContainer<LOperand*, I> inputs_;
309 EmbeddedContainer<LOperand*, T> temps_;
313 int InputCount() final { return I; }
314 LOperand* InputAt(int i) final { return inputs_[i]; }
316 int TempCount() final { return T; }
317 LOperand* TempAt(int i) final { return temps_[i]; }
321 class LUnknownOSRValue final : public LTemplateInstruction<1, 0, 0> {
323 bool HasInterestingComment(LCodeGen* gen) const override { return false; }
324 DECLARE_CONCRETE_INSTRUCTION(UnknownOSRValue, "unknown-osr-value")
328 template<int I, int T>
329 class LControlInstruction : public LTemplateInstruction<0, I, T> {
331 LControlInstruction() : false_label_(NULL), true_label_(NULL) { }
333 bool IsControl() const final { return true; }
335 int SuccessorCount() { return hydrogen()->SuccessorCount(); }
336 HBasicBlock* SuccessorAt(int i) { return hydrogen()->SuccessorAt(i); }
338 int TrueDestination(LChunk* chunk) {
339 return chunk->LookupDestination(true_block_id());
342 int FalseDestination(LChunk* chunk) {
343 return chunk->LookupDestination(false_block_id());
346 Label* TrueLabel(LChunk* chunk) {
347 if (true_label_ == NULL) {
348 true_label_ = chunk->GetAssemblyLabel(TrueDestination(chunk));
353 Label* FalseLabel(LChunk* chunk) {
354 if (false_label_ == NULL) {
355 false_label_ = chunk->GetAssemblyLabel(FalseDestination(chunk));
361 int true_block_id() { return SuccessorAt(0)->block_id(); }
362 int false_block_id() { return SuccessorAt(1)->block_id(); }
365 DECLARE_HYDROGEN_ACCESSOR(ControlInstruction);
372 class LGap : public LTemplateInstruction<0, 0, 0> {
374 explicit LGap(HBasicBlock* block)
376 parallel_moves_[BEFORE] = NULL;
377 parallel_moves_[START] = NULL;
378 parallel_moves_[END] = NULL;
379 parallel_moves_[AFTER] = NULL;
382 // Can't use the DECLARE-macro here because of sub-classes.
383 bool IsGap() const override { return true; }
384 void PrintDataTo(StringStream* stream) override;
385 static LGap* cast(LInstruction* instr) {
386 DCHECK(instr->IsGap());
387 return reinterpret_cast<LGap*>(instr);
390 bool IsRedundant() const;
392 HBasicBlock* block() const { return block_; }
399 FIRST_INNER_POSITION = BEFORE,
400 LAST_INNER_POSITION = AFTER
403 LParallelMove* GetOrCreateParallelMove(InnerPosition pos, Zone* zone) {
404 if (parallel_moves_[pos] == NULL) {
405 parallel_moves_[pos] = new(zone) LParallelMove(zone);
407 return parallel_moves_[pos];
410 LParallelMove* GetParallelMove(InnerPosition pos) {
411 return parallel_moves_[pos];
415 LParallelMove* parallel_moves_[LAST_INNER_POSITION + 1];
420 class LInstructionGap final : public LGap {
422 explicit LInstructionGap(HBasicBlock* block) : LGap(block) { }
424 bool HasInterestingComment(LCodeGen* gen) const override {
425 return !IsRedundant();
428 DECLARE_CONCRETE_INSTRUCTION(InstructionGap, "gap")
432 class LDrop final : public LTemplateInstruction<0, 0, 0> {
434 explicit LDrop(int count) : count_(count) { }
436 int count() const { return count_; }
438 DECLARE_CONCRETE_INSTRUCTION(Drop, "drop")
445 class LDummy final : public LTemplateInstruction<1, 0, 0> {
448 DECLARE_CONCRETE_INSTRUCTION(Dummy, "dummy")
452 class LDummyUse final : public LTemplateInstruction<1, 1, 0> {
454 explicit LDummyUse(LOperand* value) {
457 DECLARE_CONCRETE_INSTRUCTION(DummyUse, "dummy-use")
461 class LGoto final : public LTemplateInstruction<0, 0, 0> {
463 explicit LGoto(HBasicBlock* block) : block_(block) { }
465 bool HasInterestingComment(LCodeGen* gen) const override;
466 DECLARE_CONCRETE_INSTRUCTION(Goto, "goto")
467 void PrintDataTo(StringStream* stream) override;
468 bool IsControl() const override { return true; }
470 int block_id() const { return block_->block_id(); }
477 class LLazyBailout final : public LTemplateInstruction<0, 0, 0> {
479 LLazyBailout() : gap_instructions_size_(0) { }
481 DECLARE_CONCRETE_INSTRUCTION(LazyBailout, "lazy-bailout")
483 void set_gap_instructions_size(int gap_instructions_size) {
484 gap_instructions_size_ = gap_instructions_size;
486 int gap_instructions_size() { return gap_instructions_size_; }
489 int gap_instructions_size_;
493 class LLabel final : public LGap {
495 explicit LLabel(HBasicBlock* block)
496 : LGap(block), replacement_(NULL) { }
498 bool HasInterestingComment(LCodeGen* gen) const override { return false; }
499 DECLARE_CONCRETE_INSTRUCTION(Label, "label")
501 void PrintDataTo(StringStream* stream) override;
503 int block_id() const { return block()->block_id(); }
504 bool is_loop_header() const { return block()->IsLoopHeader(); }
505 bool is_osr_entry() const { return block()->is_osr_entry(); }
506 Label* label() { return &label_; }
507 LLabel* replacement() const { return replacement_; }
508 void set_replacement(LLabel* label) { replacement_ = label; }
509 bool HasReplacement() const { return replacement_ != NULL; }
513 LLabel* replacement_;
517 class LOsrEntry final : public LTemplateInstruction<0, 0, 0> {
521 bool HasInterestingComment(LCodeGen* gen) const override { return false; }
522 DECLARE_CONCRETE_INSTRUCTION(OsrEntry, "osr-entry")
526 class LAccessArgumentsAt final : public LTemplateInstruction<1, 3, 0> {
528 LAccessArgumentsAt(LOperand* arguments,
531 inputs_[0] = arguments;
536 DECLARE_CONCRETE_INSTRUCTION(AccessArgumentsAt, "access-arguments-at")
538 LOperand* arguments() { return inputs_[0]; }
539 LOperand* length() { return inputs_[1]; }
540 LOperand* index() { return inputs_[2]; }
542 void PrintDataTo(StringStream* stream) override;
546 class LAddE final : public LTemplateInstruction<1, 2, 0> {
548 LAddE(LOperand* left, LOperand* right) {
553 LOperand* left() { return inputs_[0]; }
554 LOperand* right() { return inputs_[1]; }
556 DECLARE_CONCRETE_INSTRUCTION(AddE, "add-e")
557 DECLARE_HYDROGEN_ACCESSOR(Add)
561 class LAddI final : public LTemplateInstruction<1, 2, 0> {
563 LAddI(LOperand* left, LOperand* right)
564 : shift_(NO_SHIFT), shift_amount_(0) {
569 LAddI(LOperand* left, LOperand* right, Shift shift, LOperand* shift_amount)
570 : shift_(shift), shift_amount_(shift_amount) {
575 LOperand* left() { return inputs_[0]; }
576 LOperand* right() { return inputs_[1]; }
578 Shift shift() const { return shift_; }
579 LOperand* shift_amount() const { return shift_amount_; }
581 DECLARE_CONCRETE_INSTRUCTION(AddI, "add-i")
582 DECLARE_HYDROGEN_ACCESSOR(Add)
586 LOperand* shift_amount_;
590 class LAddS final : public LTemplateInstruction<1, 2, 0> {
592 LAddS(LOperand* left, LOperand* right) {
597 LOperand* left() { return inputs_[0]; }
598 LOperand* right() { return inputs_[1]; }
600 DECLARE_CONCRETE_INSTRUCTION(AddS, "add-s")
601 DECLARE_HYDROGEN_ACCESSOR(Add)
605 class LAllocate final : public LTemplateInstruction<1, 2, 3> {
607 LAllocate(LOperand* context,
612 inputs_[0] = context;
619 LOperand* context() { return inputs_[0]; }
620 LOperand* size() { return inputs_[1]; }
621 LOperand* temp1() { return temps_[0]; }
622 LOperand* temp2() { return temps_[1]; }
623 LOperand* temp3() { return temps_[2]; }
625 DECLARE_CONCRETE_INSTRUCTION(Allocate, "allocate")
626 DECLARE_HYDROGEN_ACCESSOR(Allocate)
630 class LApplyArguments final : public LTemplateInstruction<1, 4, 0> {
632 LApplyArguments(LOperand* function,
635 LOperand* elements) {
636 inputs_[0] = function;
637 inputs_[1] = receiver;
639 inputs_[3] = elements;
642 DECLARE_CONCRETE_INSTRUCTION(ApplyArguments, "apply-arguments")
644 LOperand* function() { return inputs_[0]; }
645 LOperand* receiver() { return inputs_[1]; }
646 LOperand* length() { return inputs_[2]; }
647 LOperand* elements() { return inputs_[3]; }
651 class LArgumentsElements final : public LTemplateInstruction<1, 0, 1> {
653 explicit LArgumentsElements(LOperand* temp) {
657 LOperand* temp() { return temps_[0]; }
659 DECLARE_CONCRETE_INSTRUCTION(ArgumentsElements, "arguments-elements")
660 DECLARE_HYDROGEN_ACCESSOR(ArgumentsElements)
664 class LArgumentsLength final : public LTemplateInstruction<1, 1, 0> {
666 explicit LArgumentsLength(LOperand* elements) {
667 inputs_[0] = elements;
670 LOperand* elements() { return inputs_[0]; }
672 DECLARE_CONCRETE_INSTRUCTION(ArgumentsLength, "arguments-length")
676 class LArithmeticD final : public LTemplateInstruction<1, 2, 0> {
678 LArithmeticD(Token::Value op,
686 Token::Value op() const { return op_; }
687 LOperand* left() { return inputs_[0]; }
688 LOperand* right() { return inputs_[1]; }
690 Opcode opcode() const override { return LInstruction::kArithmeticD; }
691 void CompileToNative(LCodeGen* generator) override;
692 const char* Mnemonic() const override;
699 class LArithmeticT final : public LTemplateInstruction<1, 3, 0> {
701 LArithmeticT(Token::Value op,
706 inputs_[0] = context;
711 LOperand* context() { return inputs_[0]; }
712 LOperand* left() { return inputs_[1]; }
713 LOperand* right() { return inputs_[2]; }
714 Token::Value op() const { return op_; }
716 Opcode opcode() const override { return LInstruction::kArithmeticT; }
717 void CompileToNative(LCodeGen* generator) override;
718 const char* Mnemonic() const override;
720 DECLARE_HYDROGEN_ACCESSOR(BinaryOperation)
722 Strength strength() { return hydrogen()->strength(); }
729 class LBoundsCheck final : public LTemplateInstruction<0, 2, 0> {
731 explicit LBoundsCheck(LOperand* index, LOperand* length) {
736 LOperand* index() { return inputs_[0]; }
737 LOperand* length() { return inputs_[1]; }
739 DECLARE_CONCRETE_INSTRUCTION(BoundsCheck, "bounds-check")
740 DECLARE_HYDROGEN_ACCESSOR(BoundsCheck)
744 class LBitI final : public LTemplateInstruction<1, 2, 0> {
746 LBitI(LOperand* left, LOperand* right)
747 : shift_(NO_SHIFT), shift_amount_(0) {
752 LBitI(LOperand* left, LOperand* right, Shift shift, LOperand* shift_amount)
753 : shift_(shift), shift_amount_(shift_amount) {
758 LOperand* left() { return inputs_[0]; }
759 LOperand* right() { return inputs_[1]; }
761 Shift shift() const { return shift_; }
762 LOperand* shift_amount() const { return shift_amount_; }
764 Token::Value op() const { return hydrogen()->op(); }
766 DECLARE_CONCRETE_INSTRUCTION(BitI, "bit-i")
767 DECLARE_HYDROGEN_ACCESSOR(Bitwise)
771 LOperand* shift_amount_;
775 class LBitS final : public LTemplateInstruction<1, 2, 0> {
777 LBitS(LOperand* left, LOperand* right) {
782 LOperand* left() { return inputs_[0]; }
783 LOperand* right() { return inputs_[1]; }
785 Token::Value op() const { return hydrogen()->op(); }
787 DECLARE_CONCRETE_INSTRUCTION(BitS, "bit-s")
788 DECLARE_HYDROGEN_ACCESSOR(Bitwise)
792 class LBranch final : public LControlInstruction<1, 2> {
794 explicit LBranch(LOperand* value, LOperand *temp1, LOperand *temp2) {
800 LOperand* value() { return inputs_[0]; }
801 LOperand* temp1() { return temps_[0]; }
802 LOperand* temp2() { return temps_[1]; }
804 DECLARE_CONCRETE_INSTRUCTION(Branch, "branch")
805 DECLARE_HYDROGEN_ACCESSOR(Branch)
807 void PrintDataTo(StringStream* stream) override;
811 class LCallJSFunction final : public LTemplateInstruction<1, 1, 0> {
813 explicit LCallJSFunction(LOperand* function) {
814 inputs_[0] = function;
817 LOperand* function() { return inputs_[0]; }
819 DECLARE_CONCRETE_INSTRUCTION(CallJSFunction, "call-js-function")
820 DECLARE_HYDROGEN_ACCESSOR(CallJSFunction)
822 void PrintDataTo(StringStream* stream) override;
824 int arity() const { return hydrogen()->argument_count() - 1; }
828 class LCallFunction final : public LTemplateInstruction<1, 2, 2> {
830 LCallFunction(LOperand* context, LOperand* function, LOperand* slot,
832 inputs_[0] = context;
833 inputs_[1] = function;
838 LOperand* context() { return inputs_[0]; }
839 LOperand* function() { return inputs_[1]; }
840 LOperand* temp_slot() { return temps_[0]; }
841 LOperand* temp_vector() { return temps_[1]; }
843 DECLARE_CONCRETE_INSTRUCTION(CallFunction, "call-function")
844 DECLARE_HYDROGEN_ACCESSOR(CallFunction)
846 int arity() const { return hydrogen()->argument_count() - 1; }
847 void PrintDataTo(StringStream* stream) override;
851 class LCallNew final : public LTemplateInstruction<1, 2, 0> {
853 LCallNew(LOperand* context, LOperand* constructor) {
854 inputs_[0] = context;
855 inputs_[1] = constructor;
858 LOperand* context() { return inputs_[0]; }
859 LOperand* constructor() { return inputs_[1]; }
861 DECLARE_CONCRETE_INSTRUCTION(CallNew, "call-new")
862 DECLARE_HYDROGEN_ACCESSOR(CallNew)
864 void PrintDataTo(StringStream* stream) override;
866 int arity() const { return hydrogen()->argument_count() - 1; }
870 class LCallNewArray final : public LTemplateInstruction<1, 2, 0> {
872 LCallNewArray(LOperand* context, LOperand* constructor) {
873 inputs_[0] = context;
874 inputs_[1] = constructor;
877 LOperand* context() { return inputs_[0]; }
878 LOperand* constructor() { return inputs_[1]; }
880 DECLARE_CONCRETE_INSTRUCTION(CallNewArray, "call-new-array")
881 DECLARE_HYDROGEN_ACCESSOR(CallNewArray)
883 void PrintDataTo(StringStream* stream) override;
885 int arity() const { return hydrogen()->argument_count() - 1; }
889 class LCallRuntime final : public LTemplateInstruction<1, 1, 0> {
891 explicit LCallRuntime(LOperand* context) {
892 inputs_[0] = context;
895 LOperand* context() { return inputs_[0]; }
897 DECLARE_CONCRETE_INSTRUCTION(CallRuntime, "call-runtime")
898 DECLARE_HYDROGEN_ACCESSOR(CallRuntime)
900 bool ClobbersDoubleRegisters(Isolate* isolate) const override {
901 return save_doubles() == kDontSaveFPRegs;
904 const Runtime::Function* function() const { return hydrogen()->function(); }
905 int arity() const { return hydrogen()->argument_count(); }
906 SaveFPRegsMode save_doubles() const { return hydrogen()->save_doubles(); }
910 class LCallStub final : public LTemplateInstruction<1, 1, 0> {
912 explicit LCallStub(LOperand* context) {
913 inputs_[0] = context;
916 LOperand* context() { return inputs_[0]; }
918 DECLARE_CONCRETE_INSTRUCTION(CallStub, "call-stub")
919 DECLARE_HYDROGEN_ACCESSOR(CallStub)
923 class LCheckArrayBufferNotNeutered final
924 : public LTemplateInstruction<0, 1, 0> {
926 explicit LCheckArrayBufferNotNeutered(LOperand* view) { inputs_[0] = view; }
928 LOperand* view() { return inputs_[0]; }
930 DECLARE_CONCRETE_INSTRUCTION(CheckArrayBufferNotNeutered,
931 "check-array-buffer-not-neutered")
932 DECLARE_HYDROGEN_ACCESSOR(CheckArrayBufferNotNeutered)
936 class LCheckInstanceType final : public LTemplateInstruction<0, 1, 1> {
938 explicit LCheckInstanceType(LOperand* value, LOperand* temp) {
943 LOperand* value() { return inputs_[0]; }
944 LOperand* temp() { return temps_[0]; }
946 DECLARE_CONCRETE_INSTRUCTION(CheckInstanceType, "check-instance-type")
947 DECLARE_HYDROGEN_ACCESSOR(CheckInstanceType)
951 class LCheckMaps final : public LTemplateInstruction<0, 1, 1> {
953 explicit LCheckMaps(LOperand* value = NULL, LOperand* temp = NULL) {
958 LOperand* value() { return inputs_[0]; }
959 LOperand* temp() { return temps_[0]; }
961 DECLARE_CONCRETE_INSTRUCTION(CheckMaps, "check-maps")
962 DECLARE_HYDROGEN_ACCESSOR(CheckMaps)
966 class LCheckNonSmi final : public LTemplateInstruction<0, 1, 0> {
968 explicit LCheckNonSmi(LOperand* value) {
972 LOperand* value() { return inputs_[0]; }
974 DECLARE_CONCRETE_INSTRUCTION(CheckNonSmi, "check-non-smi")
975 DECLARE_HYDROGEN_ACCESSOR(CheckHeapObject)
979 class LCheckSmi final : public LTemplateInstruction<1, 1, 0> {
981 explicit LCheckSmi(LOperand* value) {
985 LOperand* value() { return inputs_[0]; }
987 DECLARE_CONCRETE_INSTRUCTION(CheckSmi, "check-smi")
991 class LCheckValue final : public LTemplateInstruction<0, 1, 0> {
993 explicit LCheckValue(LOperand* value) {
997 LOperand* value() { return inputs_[0]; }
999 DECLARE_CONCRETE_INSTRUCTION(CheckValue, "check-value")
1000 DECLARE_HYDROGEN_ACCESSOR(CheckValue)
1004 class LClampDToUint8 final : public LTemplateInstruction<1, 1, 0> {
1006 explicit LClampDToUint8(LOperand* unclamped) {
1007 inputs_[0] = unclamped;
1010 LOperand* unclamped() { return inputs_[0]; }
1012 DECLARE_CONCRETE_INSTRUCTION(ClampDToUint8, "clamp-d-to-uint8")
1016 class LClampIToUint8 final : public LTemplateInstruction<1, 1, 0> {
1018 explicit LClampIToUint8(LOperand* unclamped) {
1019 inputs_[0] = unclamped;
1022 LOperand* unclamped() { return inputs_[0]; }
1024 DECLARE_CONCRETE_INSTRUCTION(ClampIToUint8, "clamp-i-to-uint8")
1028 class LClampTToUint8 final : public LTemplateInstruction<1, 1, 1> {
1030 LClampTToUint8(LOperand* unclamped, LOperand* temp1) {
1031 inputs_[0] = unclamped;
1035 LOperand* unclamped() { return inputs_[0]; }
1036 LOperand* temp1() { return temps_[0]; }
1038 DECLARE_CONCRETE_INSTRUCTION(ClampTToUint8, "clamp-t-to-uint8")
1042 class LDoubleBits final : public LTemplateInstruction<1, 1, 0> {
1044 explicit LDoubleBits(LOperand* value) {
1048 LOperand* value() { return inputs_[0]; }
1050 DECLARE_CONCRETE_INSTRUCTION(DoubleBits, "double-bits")
1051 DECLARE_HYDROGEN_ACCESSOR(DoubleBits)
1055 class LConstructDouble final : public LTemplateInstruction<1, 2, 0> {
1057 LConstructDouble(LOperand* hi, LOperand* lo) {
1062 LOperand* hi() { return inputs_[0]; }
1063 LOperand* lo() { return inputs_[1]; }
1065 DECLARE_CONCRETE_INSTRUCTION(ConstructDouble, "construct-double")
1069 class LClassOfTestAndBranch final : public LControlInstruction<1, 2> {
1071 LClassOfTestAndBranch(LOperand* value, LOperand* temp1, LOperand* temp2) {
1077 LOperand* value() { return inputs_[0]; }
1078 LOperand* temp1() { return temps_[0]; }
1079 LOperand* temp2() { return temps_[1]; }
1081 DECLARE_CONCRETE_INSTRUCTION(ClassOfTestAndBranch,
1082 "class-of-test-and-branch")
1083 DECLARE_HYDROGEN_ACCESSOR(ClassOfTestAndBranch)
1085 void PrintDataTo(StringStream* stream) override;
1089 class LCmpHoleAndBranchD final : public LControlInstruction<1, 1> {
1091 explicit LCmpHoleAndBranchD(LOperand* object, LOperand* temp) {
1092 inputs_[0] = object;
1096 LOperand* object() { return inputs_[0]; }
1097 LOperand* temp() { return temps_[0]; }
1099 DECLARE_CONCRETE_INSTRUCTION(CmpHoleAndBranchD, "cmp-hole-and-branch-d")
1100 DECLARE_HYDROGEN_ACCESSOR(CompareHoleAndBranch)
1104 class LCmpHoleAndBranchT final : public LControlInstruction<1, 0> {
1106 explicit LCmpHoleAndBranchT(LOperand* object) {
1107 inputs_[0] = object;
1110 LOperand* object() { return inputs_[0]; }
1112 DECLARE_CONCRETE_INSTRUCTION(CmpHoleAndBranchT, "cmp-hole-and-branch-t")
1113 DECLARE_HYDROGEN_ACCESSOR(CompareHoleAndBranch)
1117 class LCmpMapAndBranch final : public LControlInstruction<1, 1> {
1119 LCmpMapAndBranch(LOperand* value, LOperand* temp) {
1124 LOperand* value() { return inputs_[0]; }
1125 LOperand* temp() { return temps_[0]; }
1127 DECLARE_CONCRETE_INSTRUCTION(CmpMapAndBranch, "cmp-map-and-branch")
1128 DECLARE_HYDROGEN_ACCESSOR(CompareMap)
1130 Handle<Map> map() const { return hydrogen()->map().handle(); }
1134 class LCmpObjectEqAndBranch final : public LControlInstruction<2, 0> {
1136 LCmpObjectEqAndBranch(LOperand* left, LOperand* right) {
1141 LOperand* left() { return inputs_[0]; }
1142 LOperand* right() { return inputs_[1]; }
1144 DECLARE_CONCRETE_INSTRUCTION(CmpObjectEqAndBranch, "cmp-object-eq-and-branch")
1145 DECLARE_HYDROGEN_ACCESSOR(CompareObjectEqAndBranch)
1149 class LCmpT final : public LTemplateInstruction<1, 3, 0> {
1151 LCmpT(LOperand* context, LOperand* left, LOperand* right) {
1152 inputs_[0] = context;
1157 LOperand* context() { return inputs_[0]; }
1158 LOperand* left() { return inputs_[1]; }
1159 LOperand* right() { return inputs_[2]; }
1161 DECLARE_CONCRETE_INSTRUCTION(CmpT, "cmp-t")
1162 DECLARE_HYDROGEN_ACCESSOR(CompareGeneric)
1164 Strength strength() { return hydrogen()->strength(); }
1166 Token::Value op() const { return hydrogen()->token(); }
1170 class LCompareMinusZeroAndBranch final : public LControlInstruction<1, 1> {
1172 LCompareMinusZeroAndBranch(LOperand* value, LOperand* temp) {
1177 LOperand* value() { return inputs_[0]; }
1178 LOperand* temp() { return temps_[0]; }
1180 DECLARE_CONCRETE_INSTRUCTION(CompareMinusZeroAndBranch,
1181 "cmp-minus-zero-and-branch")
1182 DECLARE_HYDROGEN_ACCESSOR(CompareMinusZeroAndBranch)
1186 class LCompareNumericAndBranch final : public LControlInstruction<2, 0> {
1188 LCompareNumericAndBranch(LOperand* left, LOperand* right) {
1193 LOperand* left() { return inputs_[0]; }
1194 LOperand* right() { return inputs_[1]; }
1196 DECLARE_CONCRETE_INSTRUCTION(CompareNumericAndBranch,
1197 "compare-numeric-and-branch")
1198 DECLARE_HYDROGEN_ACCESSOR(CompareNumericAndBranch)
1200 Token::Value op() const { return hydrogen()->token(); }
1201 bool is_double() const {
1202 return hydrogen()->representation().IsDouble();
1205 void PrintDataTo(StringStream* stream) override;
1209 class LConstantD final : public LTemplateInstruction<1, 0, 0> {
1211 DECLARE_CONCRETE_INSTRUCTION(ConstantD, "constant-d")
1212 DECLARE_HYDROGEN_ACCESSOR(Constant)
1214 double value() const { return hydrogen()->DoubleValue(); }
1218 class LConstantE final : public LTemplateInstruction<1, 0, 0> {
1220 DECLARE_CONCRETE_INSTRUCTION(ConstantE, "constant-e")
1221 DECLARE_HYDROGEN_ACCESSOR(Constant)
1223 ExternalReference value() const {
1224 return hydrogen()->ExternalReferenceValue();
1229 class LConstantI final : public LTemplateInstruction<1, 0, 0> {
1231 DECLARE_CONCRETE_INSTRUCTION(ConstantI, "constant-i")
1232 DECLARE_HYDROGEN_ACCESSOR(Constant)
1234 int32_t value() const { return hydrogen()->Integer32Value(); }
1238 class LConstantS final : public LTemplateInstruction<1, 0, 0> {
1240 DECLARE_CONCRETE_INSTRUCTION(ConstantS, "constant-s")
1241 DECLARE_HYDROGEN_ACCESSOR(Constant)
1243 Smi* value() const { return Smi::FromInt(hydrogen()->Integer32Value()); }
1247 class LConstantT final : public LTemplateInstruction<1, 0, 0> {
1249 DECLARE_CONCRETE_INSTRUCTION(ConstantT, "constant-t")
1250 DECLARE_HYDROGEN_ACCESSOR(Constant)
1252 Handle<Object> value(Isolate* isolate) const {
1253 return hydrogen()->handle(isolate);
1258 class LContext final : public LTemplateInstruction<1, 0, 0> {
1260 DECLARE_CONCRETE_INSTRUCTION(Context, "context")
1261 DECLARE_HYDROGEN_ACCESSOR(Context)
1265 class LDateField final : public LTemplateInstruction<1, 1, 0> {
1267 LDateField(LOperand* date, Smi* index) : index_(index) {
1271 LOperand* date() { return inputs_[0]; }
1272 Smi* index() const { return index_; }
1274 DECLARE_CONCRETE_INSTRUCTION(DateField, "date-field")
1275 DECLARE_HYDROGEN_ACCESSOR(DateField)
1282 class LDebugBreak final : public LTemplateInstruction<0, 0, 0> {
1284 DECLARE_CONCRETE_INSTRUCTION(DebugBreak, "break")
1288 class LDeclareGlobals final : public LTemplateInstruction<0, 1, 0> {
1290 explicit LDeclareGlobals(LOperand* context) {
1291 inputs_[0] = context;
1294 LOperand* context() { return inputs_[0]; }
1296 DECLARE_CONCRETE_INSTRUCTION(DeclareGlobals, "declare-globals")
1297 DECLARE_HYDROGEN_ACCESSOR(DeclareGlobals)
1301 class LDeoptimize final : public LTemplateInstruction<0, 0, 0> {
1303 bool IsControl() const override { return true; }
1304 DECLARE_CONCRETE_INSTRUCTION(Deoptimize, "deoptimize")
1305 DECLARE_HYDROGEN_ACCESSOR(Deoptimize)
1309 class LDivByPowerOf2I final : public LTemplateInstruction<1, 1, 0> {
1311 LDivByPowerOf2I(LOperand* dividend, int32_t divisor) {
1312 inputs_[0] = dividend;
1316 LOperand* dividend() { return inputs_[0]; }
1317 int32_t divisor() const { return divisor_; }
1319 DECLARE_CONCRETE_INSTRUCTION(DivByPowerOf2I, "div-by-power-of-2-i")
1320 DECLARE_HYDROGEN_ACCESSOR(Div)
1327 class LDivByConstI final : public LTemplateInstruction<1, 1, 1> {
1329 LDivByConstI(LOperand* dividend, int32_t divisor, LOperand* temp) {
1330 inputs_[0] = dividend;
1335 LOperand* dividend() { return inputs_[0]; }
1336 int32_t divisor() const { return divisor_; }
1337 LOperand* temp() { return temps_[0]; }
1339 DECLARE_CONCRETE_INSTRUCTION(DivByConstI, "div-by-const-i")
1340 DECLARE_HYDROGEN_ACCESSOR(Div)
1347 class LDivI final : public LTemplateInstruction<1, 2, 1> {
1349 LDivI(LOperand* dividend, LOperand* divisor, LOperand* temp) {
1350 inputs_[0] = dividend;
1351 inputs_[1] = divisor;
1355 LOperand* dividend() { return inputs_[0]; }
1356 LOperand* divisor() { return inputs_[1]; }
1357 LOperand* temp() { return temps_[0]; }
1359 DECLARE_CONCRETE_INSTRUCTION(DivI, "div-i")
1360 DECLARE_HYDROGEN_ACCESSOR(BinaryOperation)
1364 class LDoubleToIntOrSmi final : public LTemplateInstruction<1, 1, 0> {
1366 explicit LDoubleToIntOrSmi(LOperand* value) {
1370 LOperand* value() { return inputs_[0]; }
1372 DECLARE_CONCRETE_INSTRUCTION(DoubleToIntOrSmi, "double-to-int-or-smi")
1373 DECLARE_HYDROGEN_ACCESSOR(UnaryOperation)
1375 bool tag_result() { return hydrogen()->representation().IsSmi(); }
1379 class LForInCacheArray final : public LTemplateInstruction<1, 1, 0> {
1381 explicit LForInCacheArray(LOperand* map) {
1385 LOperand* map() { return inputs_[0]; }
1387 DECLARE_CONCRETE_INSTRUCTION(ForInCacheArray, "for-in-cache-array")
1390 return HForInCacheArray::cast(this->hydrogen_value())->idx();
1395 class LForInPrepareMap final : public LTemplateInstruction<1, 2, 0> {
1397 LForInPrepareMap(LOperand* context, LOperand* object) {
1398 inputs_[0] = context;
1399 inputs_[1] = object;
1402 LOperand* context() { return inputs_[0]; }
1403 LOperand* object() { return inputs_[1]; }
1405 DECLARE_CONCRETE_INSTRUCTION(ForInPrepareMap, "for-in-prepare-map")
1409 class LGetCachedArrayIndex final : public LTemplateInstruction<1, 1, 0> {
1411 explicit LGetCachedArrayIndex(LOperand* value) {
1415 LOperand* value() { return inputs_[0]; }
1417 DECLARE_CONCRETE_INSTRUCTION(GetCachedArrayIndex, "get-cached-array-index")
1418 DECLARE_HYDROGEN_ACCESSOR(GetCachedArrayIndex)
1422 class LHasCachedArrayIndexAndBranch final : public LControlInstruction<1, 1> {
1424 LHasCachedArrayIndexAndBranch(LOperand* value, LOperand* temp) {
1429 LOperand* value() { return inputs_[0]; }
1430 LOperand* temp() { return temps_[0]; }
1432 DECLARE_CONCRETE_INSTRUCTION(HasCachedArrayIndexAndBranch,
1433 "has-cached-array-index-and-branch")
1434 DECLARE_HYDROGEN_ACCESSOR(HasCachedArrayIndexAndBranch)
1436 void PrintDataTo(StringStream* stream) override;
1440 class LHasInstanceTypeAndBranch final : public LControlInstruction<1, 1> {
1442 LHasInstanceTypeAndBranch(LOperand* value, LOperand* temp) {
1447 LOperand* value() { return inputs_[0]; }
1448 LOperand* temp() { return temps_[0]; }
1450 DECLARE_CONCRETE_INSTRUCTION(HasInstanceTypeAndBranch,
1451 "has-instance-type-and-branch")
1452 DECLARE_HYDROGEN_ACCESSOR(HasInstanceTypeAndBranch)
1454 void PrintDataTo(StringStream* stream) override;
1458 class LInnerAllocatedObject final : public LTemplateInstruction<1, 2, 0> {
1460 LInnerAllocatedObject(LOperand* base_object, LOperand* offset) {
1461 inputs_[0] = base_object;
1462 inputs_[1] = offset;
1465 LOperand* base_object() const { return inputs_[0]; }
1466 LOperand* offset() const { return inputs_[1]; }
1468 void PrintDataTo(StringStream* stream) override;
1470 DECLARE_CONCRETE_INSTRUCTION(InnerAllocatedObject, "inner-allocated-object")
1474 class LInstanceOf final : public LTemplateInstruction<1, 3, 0> {
1476 LInstanceOf(LOperand* context, LOperand* left, LOperand* right) {
1477 inputs_[0] = context;
1482 LOperand* context() { return inputs_[0]; }
1483 LOperand* left() { return inputs_[1]; }
1484 LOperand* right() { return inputs_[2]; }
1486 DECLARE_CONCRETE_INSTRUCTION(InstanceOf, "instance-of")
1490 class LInstanceOfKnownGlobal final : public LTemplateInstruction<1, 2, 0> {
1492 LInstanceOfKnownGlobal(LOperand* context, LOperand* value) {
1493 inputs_[0] = context;
1497 LOperand* context() { return inputs_[0]; }
1498 LOperand* value() { return inputs_[1]; }
1500 DECLARE_CONCRETE_INSTRUCTION(InstanceOfKnownGlobal,
1501 "instance-of-known-global")
1502 DECLARE_HYDROGEN_ACCESSOR(InstanceOfKnownGlobal)
1504 Handle<JSFunction> function() const { return hydrogen()->function(); }
1505 LEnvironment* GetDeferredLazyDeoptimizationEnvironment() {
1506 return lazy_deopt_env_;
1508 virtual void SetDeferredLazyDeoptimizationEnvironment(
1509 LEnvironment* env) override {
1510 lazy_deopt_env_ = env;
1514 LEnvironment* lazy_deopt_env_;
1518 class LInteger32ToDouble final : public LTemplateInstruction<1, 1, 0> {
1520 explicit LInteger32ToDouble(LOperand* value) {
1524 LOperand* value() { return inputs_[0]; }
1526 DECLARE_CONCRETE_INSTRUCTION(Integer32ToDouble, "int32-to-double")
1530 class LCallWithDescriptor final : public LTemplateResultInstruction<1> {
1532 LCallWithDescriptor(CallInterfaceDescriptor descriptor,
1533 const ZoneList<LOperand*>& operands, Zone* zone)
1534 : descriptor_(descriptor),
1535 inputs_(descriptor.GetRegisterParameterCount() + 1, zone) {
1536 DCHECK(descriptor.GetRegisterParameterCount() + 1 == operands.length());
1537 inputs_.AddAll(operands, zone);
1540 LOperand* target() const { return inputs_[0]; }
1542 CallInterfaceDescriptor descriptor() { return descriptor_; }
1544 DECLARE_HYDROGEN_ACCESSOR(CallWithDescriptor)
1547 DECLARE_CONCRETE_INSTRUCTION(CallWithDescriptor, "call-with-descriptor")
1549 void PrintDataTo(StringStream* stream) override;
1551 int arity() const { return hydrogen()->argument_count() - 1; }
1553 CallInterfaceDescriptor descriptor_;
1554 ZoneList<LOperand*> inputs_;
1556 // Iterator support.
1557 int InputCount() final { return inputs_.length(); }
1558 LOperand* InputAt(int i) final { return inputs_[i]; }
1560 int TempCount() final { return 0; }
1561 LOperand* TempAt(int i) final { return NULL; }
1565 class LInvokeFunction final : public LTemplateInstruction<1, 2, 0> {
1567 LInvokeFunction(LOperand* context, LOperand* function) {
1568 inputs_[0] = context;
1569 inputs_[1] = function;
1572 LOperand* context() { return inputs_[0]; }
1573 LOperand* function() { return inputs_[1]; }
1575 DECLARE_CONCRETE_INSTRUCTION(InvokeFunction, "invoke-function")
1576 DECLARE_HYDROGEN_ACCESSOR(InvokeFunction)
1578 void PrintDataTo(StringStream* stream) override;
1580 int arity() const { return hydrogen()->argument_count() - 1; }
1584 class LIsConstructCallAndBranch final : public LControlInstruction<0, 2> {
1586 LIsConstructCallAndBranch(LOperand* temp1, LOperand* temp2) {
1591 LOperand* temp1() { return temps_[0]; }
1592 LOperand* temp2() { return temps_[1]; }
1594 DECLARE_CONCRETE_INSTRUCTION(IsConstructCallAndBranch,
1595 "is-construct-call-and-branch")
1599 class LIsObjectAndBranch final : public LControlInstruction<1, 2> {
1601 LIsObjectAndBranch(LOperand* value, LOperand* temp1, LOperand* temp2) {
1607 LOperand* value() { return inputs_[0]; }
1608 LOperand* temp1() { return temps_[0]; }
1609 LOperand* temp2() { return temps_[1]; }
1611 DECLARE_CONCRETE_INSTRUCTION(IsObjectAndBranch, "is-object-and-branch")
1612 DECLARE_HYDROGEN_ACCESSOR(IsObjectAndBranch)
1614 void PrintDataTo(StringStream* stream) override;
1618 class LIsStringAndBranch final : public LControlInstruction<1, 1> {
1620 LIsStringAndBranch(LOperand* value, LOperand* temp) {
1625 LOperand* value() { return inputs_[0]; }
1626 LOperand* temp() { return temps_[0]; }
1628 DECLARE_CONCRETE_INSTRUCTION(IsStringAndBranch, "is-string-and-branch")
1629 DECLARE_HYDROGEN_ACCESSOR(IsStringAndBranch)
1631 void PrintDataTo(StringStream* stream) override;
1635 class LIsSmiAndBranch final : public LControlInstruction<1, 0> {
1637 explicit LIsSmiAndBranch(LOperand* value) {
1641 LOperand* value() { return inputs_[0]; }
1643 DECLARE_CONCRETE_INSTRUCTION(IsSmiAndBranch, "is-smi-and-branch")
1644 DECLARE_HYDROGEN_ACCESSOR(IsSmiAndBranch)
1646 void PrintDataTo(StringStream* stream) override;
1650 class LIsUndetectableAndBranch final : public LControlInstruction<1, 1> {
1652 explicit LIsUndetectableAndBranch(LOperand* value, LOperand* temp) {
1657 LOperand* value() { return inputs_[0]; }
1658 LOperand* temp() { return temps_[0]; }
1660 DECLARE_CONCRETE_INSTRUCTION(IsUndetectableAndBranch,
1661 "is-undetectable-and-branch")
1662 DECLARE_HYDROGEN_ACCESSOR(IsUndetectableAndBranch)
1664 void PrintDataTo(StringStream* stream) override;
1668 class LLoadContextSlot final : public LTemplateInstruction<1, 1, 0> {
1670 explicit LLoadContextSlot(LOperand* context) {
1671 inputs_[0] = context;
1674 LOperand* context() { return inputs_[0]; }
1676 DECLARE_CONCRETE_INSTRUCTION(LoadContextSlot, "load-context-slot")
1677 DECLARE_HYDROGEN_ACCESSOR(LoadContextSlot)
1679 int slot_index() const { return hydrogen()->slot_index(); }
1681 void PrintDataTo(StringStream* stream) override;
1685 class LLoadNamedField final : public LTemplateInstruction<1, 1, 0> {
1687 explicit LLoadNamedField(LOperand* object) {
1688 inputs_[0] = object;
1691 LOperand* object() { return inputs_[0]; }
1693 DECLARE_CONCRETE_INSTRUCTION(LoadNamedField, "load-named-field")
1694 DECLARE_HYDROGEN_ACCESSOR(LoadNamedField)
1698 class LFunctionLiteral final : public LTemplateInstruction<1, 1, 0> {
1700 explicit LFunctionLiteral(LOperand* context) {
1701 inputs_[0] = context;
1704 LOperand* context() { return inputs_[0]; }
1706 DECLARE_CONCRETE_INSTRUCTION(FunctionLiteral, "function-literal")
1707 DECLARE_HYDROGEN_ACCESSOR(FunctionLiteral)
1711 class LLoadFunctionPrototype final : public LTemplateInstruction<1, 1, 1> {
1713 LLoadFunctionPrototype(LOperand* function, LOperand* temp) {
1714 inputs_[0] = function;
1718 LOperand* function() { return inputs_[0]; }
1719 LOperand* temp() { return temps_[0]; }
1721 DECLARE_CONCRETE_INSTRUCTION(LoadFunctionPrototype, "load-function-prototype")
1722 DECLARE_HYDROGEN_ACCESSOR(LoadFunctionPrototype)
1726 class LLoadGlobalGeneric final : public LTemplateInstruction<1, 2, 1> {
1728 LLoadGlobalGeneric(LOperand* context, LOperand* global_object,
1730 inputs_[0] = context;
1731 inputs_[1] = global_object;
1735 LOperand* context() { return inputs_[0]; }
1736 LOperand* global_object() { return inputs_[1]; }
1737 LOperand* temp_vector() { return temps_[0]; }
1739 DECLARE_CONCRETE_INSTRUCTION(LoadGlobalGeneric, "load-global-generic")
1740 DECLARE_HYDROGEN_ACCESSOR(LoadGlobalGeneric)
1742 Handle<Object> name() const { return hydrogen()->name(); }
1743 bool for_typeof() const { return hydrogen()->for_typeof(); }
1748 class LLoadKeyed : public LTemplateInstruction<1, 2, T> {
1750 LLoadKeyed(LOperand* elements, LOperand* key) {
1751 this->inputs_[0] = elements;
1752 this->inputs_[1] = key;
1755 LOperand* elements() { return this->inputs_[0]; }
1756 LOperand* key() { return this->inputs_[1]; }
1757 ElementsKind elements_kind() const {
1758 return this->hydrogen()->elements_kind();
1760 bool is_external() const {
1761 return this->hydrogen()->is_external();
1763 bool is_fixed_typed_array() const {
1764 return hydrogen()->is_fixed_typed_array();
1766 bool is_typed_elements() const {
1767 return is_external() || is_fixed_typed_array();
1769 uint32_t base_offset() const {
1770 return this->hydrogen()->base_offset();
1772 void PrintDataTo(StringStream* stream) override {
1773 this->elements()->PrintTo(stream);
1775 this->key()->PrintTo(stream);
1776 if (this->base_offset() != 0) {
1777 stream->Add(" + %d]", this->base_offset());
1783 DECLARE_HYDROGEN_ACCESSOR(LoadKeyed)
1787 class LLoadKeyedExternal: public LLoadKeyed<1> {
1789 LLoadKeyedExternal(LOperand* elements, LOperand* key, LOperand* temp) :
1790 LLoadKeyed<1>(elements, key) {
1794 LOperand* temp() { return temps_[0]; }
1796 DECLARE_CONCRETE_INSTRUCTION(LoadKeyedExternal, "load-keyed-external");
1800 class LLoadKeyedFixed: public LLoadKeyed<1> {
1802 LLoadKeyedFixed(LOperand* elements, LOperand* key, LOperand* temp) :
1803 LLoadKeyed<1>(elements, key) {
1807 LOperand* temp() { return temps_[0]; }
1809 DECLARE_CONCRETE_INSTRUCTION(LoadKeyedFixed, "load-keyed-fixed");
1813 class LLoadKeyedFixedDouble: public LLoadKeyed<1> {
1815 LLoadKeyedFixedDouble(LOperand* elements, LOperand* key, LOperand* temp) :
1816 LLoadKeyed<1>(elements, key) {
1820 LOperand* temp() { return temps_[0]; }
1822 DECLARE_CONCRETE_INSTRUCTION(LoadKeyedFixedDouble, "load-keyed-fixed-double");
1826 class LLoadKeyedGeneric final : public LTemplateInstruction<1, 3, 1> {
1828 LLoadKeyedGeneric(LOperand* context, LOperand* object, LOperand* key,
1830 inputs_[0] = context;
1831 inputs_[1] = object;
1836 LOperand* context() { return inputs_[0]; }
1837 LOperand* object() { return inputs_[1]; }
1838 LOperand* key() { return inputs_[2]; }
1839 LOperand* temp_vector() { return temps_[0]; }
1841 DECLARE_CONCRETE_INSTRUCTION(LoadKeyedGeneric, "load-keyed-generic")
1842 DECLARE_HYDROGEN_ACCESSOR(LoadKeyedGeneric)
1846 class LLoadNamedGeneric final : public LTemplateInstruction<1, 2, 1> {
1848 LLoadNamedGeneric(LOperand* context, LOperand* object, LOperand* vector) {
1849 inputs_[0] = context;
1850 inputs_[1] = object;
1854 LOperand* context() { return inputs_[0]; }
1855 LOperand* object() { return inputs_[1]; }
1856 LOperand* temp_vector() { return temps_[0]; }
1858 DECLARE_CONCRETE_INSTRUCTION(LoadNamedGeneric, "load-named-generic")
1859 DECLARE_HYDROGEN_ACCESSOR(LoadNamedGeneric)
1861 Handle<Object> name() const { return hydrogen()->name(); }
1865 class LLoadRoot final : public LTemplateInstruction<1, 0, 0> {
1867 DECLARE_CONCRETE_INSTRUCTION(LoadRoot, "load-root")
1868 DECLARE_HYDROGEN_ACCESSOR(LoadRoot)
1870 Heap::RootListIndex index() const { return hydrogen()->index(); }
1874 class LMapEnumLength final : public LTemplateInstruction<1, 1, 0> {
1876 explicit LMapEnumLength(LOperand* value) {
1880 LOperand* value() { return inputs_[0]; }
1882 DECLARE_CONCRETE_INSTRUCTION(MapEnumLength, "map-enum-length")
1887 class LUnaryMathOperation : public LTemplateInstruction<1, 1, T> {
1889 explicit LUnaryMathOperation(LOperand* value) {
1890 this->inputs_[0] = value;
1893 LOperand* value() { return this->inputs_[0]; }
1894 BuiltinFunctionId op() const { return this->hydrogen()->op(); }
1896 void PrintDataTo(StringStream* stream) override;
1898 DECLARE_HYDROGEN_ACCESSOR(UnaryMathOperation)
1902 class LMathAbs final : public LUnaryMathOperation<0> {
1904 explicit LMathAbs(LOperand* value) : LUnaryMathOperation<0>(value) {}
1906 DECLARE_CONCRETE_INSTRUCTION(MathAbs, "math-abs")
1910 class LMathAbsTagged: public LTemplateInstruction<1, 2, 3> {
1912 LMathAbsTagged(LOperand* context, LOperand* value,
1913 LOperand* temp1, LOperand* temp2, LOperand* temp3) {
1914 inputs_[0] = context;
1921 LOperand* context() { return inputs_[0]; }
1922 LOperand* value() { return inputs_[1]; }
1923 LOperand* temp1() { return temps_[0]; }
1924 LOperand* temp2() { return temps_[1]; }
1925 LOperand* temp3() { return temps_[2]; }
1927 DECLARE_CONCRETE_INSTRUCTION(MathAbsTagged, "math-abs-tagged")
1928 DECLARE_HYDROGEN_ACCESSOR(UnaryMathOperation)
1932 class LMathExp final : public LUnaryMathOperation<4> {
1934 LMathExp(LOperand* value,
1935 LOperand* double_temp1,
1939 : LUnaryMathOperation<4>(value) {
1940 temps_[0] = double_temp1;
1944 ExternalReference::InitializeMathExpData();
1947 LOperand* double_temp1() { return temps_[0]; }
1948 LOperand* temp1() { return temps_[1]; }
1949 LOperand* temp2() { return temps_[2]; }
1950 LOperand* temp3() { return temps_[3]; }
1952 DECLARE_CONCRETE_INSTRUCTION(MathExp, "math-exp")
1956 // Math.floor with a double result.
1957 class LMathFloorD final : public LUnaryMathOperation<0> {
1959 explicit LMathFloorD(LOperand* value) : LUnaryMathOperation<0>(value) { }
1960 DECLARE_CONCRETE_INSTRUCTION(MathFloorD, "math-floor-d")
1964 // Math.floor with an integer result.
1965 class LMathFloorI final : public LUnaryMathOperation<0> {
1967 explicit LMathFloorI(LOperand* value) : LUnaryMathOperation<0>(value) { }
1968 DECLARE_CONCRETE_INSTRUCTION(MathFloorI, "math-floor-i")
1972 class LFlooringDivByPowerOf2I final : public LTemplateInstruction<1, 1, 0> {
1974 LFlooringDivByPowerOf2I(LOperand* dividend, int32_t divisor) {
1975 inputs_[0] = dividend;
1979 LOperand* dividend() { return inputs_[0]; }
1980 int32_t divisor() const { return divisor_; }
1982 DECLARE_CONCRETE_INSTRUCTION(FlooringDivByPowerOf2I,
1983 "flooring-div-by-power-of-2-i")
1984 DECLARE_HYDROGEN_ACCESSOR(MathFloorOfDiv)
1991 class LFlooringDivByConstI final : public LTemplateInstruction<1, 1, 2> {
1993 LFlooringDivByConstI(LOperand* dividend, int32_t divisor, LOperand* temp) {
1994 inputs_[0] = dividend;
1999 LOperand* dividend() { return inputs_[0]; }
2000 int32_t divisor() const { return divisor_; }
2001 LOperand* temp() { return temps_[0]; }
2003 DECLARE_CONCRETE_INSTRUCTION(FlooringDivByConstI, "flooring-div-by-const-i")
2004 DECLARE_HYDROGEN_ACCESSOR(MathFloorOfDiv)
2011 class LFlooringDivI final : public LTemplateInstruction<1, 2, 1> {
2013 LFlooringDivI(LOperand* dividend, LOperand* divisor, LOperand* temp) {
2014 inputs_[0] = dividend;
2015 inputs_[1] = divisor;
2019 LOperand* dividend() { return inputs_[0]; }
2020 LOperand* divisor() { return inputs_[1]; }
2021 LOperand* temp() { return temps_[0]; }
2023 DECLARE_CONCRETE_INSTRUCTION(FlooringDivI, "flooring-div-i")
2024 DECLARE_HYDROGEN_ACCESSOR(MathFloorOfDiv)
2028 class LMathLog final : public LUnaryMathOperation<0> {
2030 explicit LMathLog(LOperand* value) : LUnaryMathOperation<0>(value) { }
2031 DECLARE_CONCRETE_INSTRUCTION(MathLog, "math-log")
2035 class LMathClz32 final : public LUnaryMathOperation<0> {
2037 explicit LMathClz32(LOperand* value) : LUnaryMathOperation<0>(value) { }
2038 DECLARE_CONCRETE_INSTRUCTION(MathClz32, "math-clz32")
2042 class LMathMinMax final : public LTemplateInstruction<1, 2, 0> {
2044 LMathMinMax(LOperand* left, LOperand* right) {
2049 LOperand* left() { return inputs_[0]; }
2050 LOperand* right() { return inputs_[1]; }
2052 DECLARE_CONCRETE_INSTRUCTION(MathMinMax, "math-min-max")
2053 DECLARE_HYDROGEN_ACCESSOR(MathMinMax)
2057 class LMathPowHalf final : public LUnaryMathOperation<0> {
2059 explicit LMathPowHalf(LOperand* value) : LUnaryMathOperation<0>(value) { }
2060 DECLARE_CONCRETE_INSTRUCTION(MathPowHalf, "math-pow-half")
2064 // Math.round with an integer result.
2065 class LMathRoundD final : public LUnaryMathOperation<0> {
2067 explicit LMathRoundD(LOperand* value)
2068 : LUnaryMathOperation<0>(value) {
2071 DECLARE_CONCRETE_INSTRUCTION(MathRoundD, "math-round-d")
2075 // Math.round with an integer result.
2076 class LMathRoundI final : public LUnaryMathOperation<1> {
2078 LMathRoundI(LOperand* value, LOperand* temp1)
2079 : LUnaryMathOperation<1>(value) {
2083 LOperand* temp1() { return temps_[0]; }
2085 DECLARE_CONCRETE_INSTRUCTION(MathRoundI, "math-round-i")
2089 class LMathFround final : public LUnaryMathOperation<0> {
2091 explicit LMathFround(LOperand* value) : LUnaryMathOperation<0>(value) {}
2093 DECLARE_CONCRETE_INSTRUCTION(MathFround, "math-fround")
2097 class LMathSqrt final : public LUnaryMathOperation<0> {
2099 explicit LMathSqrt(LOperand* value) : LUnaryMathOperation<0>(value) { }
2100 DECLARE_CONCRETE_INSTRUCTION(MathSqrt, "math-sqrt")
2104 class LModByPowerOf2I final : public LTemplateInstruction<1, 1, 0> {
2106 LModByPowerOf2I(LOperand* dividend, int32_t divisor) {
2107 inputs_[0] = dividend;
2111 LOperand* dividend() { return inputs_[0]; }
2112 int32_t divisor() const { return divisor_; }
2114 DECLARE_CONCRETE_INSTRUCTION(ModByPowerOf2I, "mod-by-power-of-2-i")
2115 DECLARE_HYDROGEN_ACCESSOR(Mod)
2122 class LModByConstI final : public LTemplateInstruction<1, 1, 1> {
2124 LModByConstI(LOperand* dividend, int32_t divisor, LOperand* temp) {
2125 inputs_[0] = dividend;
2130 LOperand* dividend() { return inputs_[0]; }
2131 int32_t divisor() const { return divisor_; }
2132 LOperand* temp() { return temps_[0]; }
2134 DECLARE_CONCRETE_INSTRUCTION(ModByConstI, "mod-by-const-i")
2135 DECLARE_HYDROGEN_ACCESSOR(Mod)
2142 class LModI final : public LTemplateInstruction<1, 2, 0> {
2144 LModI(LOperand* left, LOperand* right) {
2149 LOperand* left() { return inputs_[0]; }
2150 LOperand* right() { return inputs_[1]; }
2152 DECLARE_CONCRETE_INSTRUCTION(ModI, "mod-i")
2153 DECLARE_HYDROGEN_ACCESSOR(Mod)
2157 class LMulConstIS final : public LTemplateInstruction<1, 2, 0> {
2159 LMulConstIS(LOperand* left, LConstantOperand* right) {
2164 LOperand* left() { return inputs_[0]; }
2165 LConstantOperand* right() { return LConstantOperand::cast(inputs_[1]); }
2167 DECLARE_CONCRETE_INSTRUCTION(MulConstIS, "mul-const-i-s")
2168 DECLARE_HYDROGEN_ACCESSOR(Mul)
2172 class LMulI final : public LTemplateInstruction<1, 2, 0> {
2174 LMulI(LOperand* left, LOperand* right) {
2179 LOperand* left() { return inputs_[0]; }
2180 LOperand* right() { return inputs_[1]; }
2182 DECLARE_CONCRETE_INSTRUCTION(MulI, "mul-i")
2183 DECLARE_HYDROGEN_ACCESSOR(Mul)
2187 class LMulS final : public LTemplateInstruction<1, 2, 0> {
2189 LMulS(LOperand* left, LOperand* right) {
2194 LOperand* left() { return inputs_[0]; }
2195 LOperand* right() { return inputs_[1]; }
2197 DECLARE_CONCRETE_INSTRUCTION(MulI, "mul-s")
2198 DECLARE_HYDROGEN_ACCESSOR(Mul)
2202 class LNumberTagD final : public LTemplateInstruction<1, 1, 2> {
2204 LNumberTagD(LOperand* value, LOperand* temp1, LOperand* temp2) {
2210 LOperand* value() { return inputs_[0]; }
2211 LOperand* temp1() { return temps_[0]; }
2212 LOperand* temp2() { return temps_[1]; }
2214 DECLARE_CONCRETE_INSTRUCTION(NumberTagD, "number-tag-d")
2215 DECLARE_HYDROGEN_ACCESSOR(Change)
2219 class LNumberTagU final : public LTemplateInstruction<1, 1, 2> {
2221 explicit LNumberTagU(LOperand* value,
2229 LOperand* value() { return inputs_[0]; }
2230 LOperand* temp1() { return temps_[0]; }
2231 LOperand* temp2() { return temps_[1]; }
2233 DECLARE_CONCRETE_INSTRUCTION(NumberTagU, "number-tag-u")
2237 class LNumberUntagD final : public LTemplateInstruction<1, 1, 1> {
2239 LNumberUntagD(LOperand* value, LOperand* temp) {
2244 LOperand* value() { return inputs_[0]; }
2246 LOperand* temp() { return temps_[0]; }
2248 DECLARE_CONCRETE_INSTRUCTION(NumberUntagD, "double-untag")
2249 DECLARE_HYDROGEN_ACCESSOR(Change)
2253 class LParameter final : public LTemplateInstruction<1, 0, 0> {
2255 bool HasInterestingComment(LCodeGen* gen) const override { return false; }
2256 DECLARE_CONCRETE_INSTRUCTION(Parameter, "parameter")
2260 class LPower final : public LTemplateInstruction<1, 2, 0> {
2262 LPower(LOperand* left, LOperand* right) {
2267 LOperand* left() { return inputs_[0]; }
2268 LOperand* right() { return inputs_[1]; }
2270 DECLARE_CONCRETE_INSTRUCTION(Power, "power")
2271 DECLARE_HYDROGEN_ACCESSOR(Power)
2275 class LPreparePushArguments final : public LTemplateInstruction<0, 0, 0> {
2277 explicit LPreparePushArguments(int argc) : argc_(argc) {}
2279 inline int argc() const { return argc_; }
2281 DECLARE_CONCRETE_INSTRUCTION(PreparePushArguments, "prepare-push-arguments")
2288 class LPushArguments final : public LTemplateResultInstruction<0> {
2290 explicit LPushArguments(Zone* zone,
2291 int capacity = kRecommendedMaxPushedArgs)
2292 : zone_(zone), inputs_(capacity, zone) {}
2294 LOperand* argument(int i) { return inputs_[i]; }
2295 int ArgumentCount() const { return inputs_.length(); }
2297 void AddArgument(LOperand* arg) { inputs_.Add(arg, zone_); }
2299 DECLARE_CONCRETE_INSTRUCTION(PushArguments, "push-arguments")
2301 // It is better to limit the number of arguments pushed simultaneously to
2302 // avoid pressure on the register allocator.
2303 static const int kRecommendedMaxPushedArgs = 4;
2304 bool ShouldSplitPush() const {
2305 return inputs_.length() >= kRecommendedMaxPushedArgs;
2310 ZoneList<LOperand*> inputs_;
2313 // Iterator support.
2314 int InputCount() final { return inputs_.length(); }
2315 LOperand* InputAt(int i) final { return inputs_[i]; }
2317 int TempCount() final { return 0; }
2318 LOperand* TempAt(int i) final { return NULL; }
2322 class LRegExpLiteral final : public LTemplateInstruction<1, 1, 0> {
2324 explicit LRegExpLiteral(LOperand* context) {
2325 inputs_[0] = context;
2328 LOperand* context() { return inputs_[0]; }
2330 DECLARE_CONCRETE_INSTRUCTION(RegExpLiteral, "regexp-literal")
2331 DECLARE_HYDROGEN_ACCESSOR(RegExpLiteral)
2335 class LReturn final : public LTemplateInstruction<0, 3, 0> {
2337 LReturn(LOperand* value, LOperand* context, LOperand* parameter_count) {
2339 inputs_[1] = context;
2340 inputs_[2] = parameter_count;
2343 LOperand* value() { return inputs_[0]; }
2344 LOperand* parameter_count() { return inputs_[2]; }
2346 bool has_constant_parameter_count() {
2347 return parameter_count()->IsConstantOperand();
2349 LConstantOperand* constant_parameter_count() {
2350 DCHECK(has_constant_parameter_count());
2351 return LConstantOperand::cast(parameter_count());
2354 DECLARE_CONCRETE_INSTRUCTION(Return, "return")
2358 class LSeqStringGetChar final : public LTemplateInstruction<1, 2, 1> {
2360 LSeqStringGetChar(LOperand* string,
2363 inputs_[0] = string;
2368 LOperand* string() { return inputs_[0]; }
2369 LOperand* index() { return inputs_[1]; }
2370 LOperand* temp() { return temps_[0]; }
2372 DECLARE_CONCRETE_INSTRUCTION(SeqStringGetChar, "seq-string-get-char")
2373 DECLARE_HYDROGEN_ACCESSOR(SeqStringGetChar)
2377 class LSeqStringSetChar final : public LTemplateInstruction<1, 4, 1> {
2379 LSeqStringSetChar(LOperand* context,
2384 inputs_[0] = context;
2385 inputs_[1] = string;
2391 LOperand* context() { return inputs_[0]; }
2392 LOperand* string() { return inputs_[1]; }
2393 LOperand* index() { return inputs_[2]; }
2394 LOperand* value() { return inputs_[3]; }
2395 LOperand* temp() { return temps_[0]; }
2397 DECLARE_CONCRETE_INSTRUCTION(SeqStringSetChar, "seq-string-set-char")
2398 DECLARE_HYDROGEN_ACCESSOR(SeqStringSetChar)
2402 class LSmiTag final : public LTemplateInstruction<1, 1, 0> {
2404 explicit LSmiTag(LOperand* value) {
2408 LOperand* value() { return inputs_[0]; }
2410 DECLARE_CONCRETE_INSTRUCTION(SmiTag, "smi-tag")
2411 DECLARE_HYDROGEN_ACCESSOR(Change)
2415 class LSmiUntag final : public LTemplateInstruction<1, 1, 0> {
2417 LSmiUntag(LOperand* value, bool needs_check)
2418 : needs_check_(needs_check) {
2422 LOperand* value() { return inputs_[0]; }
2423 bool needs_check() const { return needs_check_; }
2425 DECLARE_CONCRETE_INSTRUCTION(SmiUntag, "smi-untag")
2432 class LStackCheck final : public LTemplateInstruction<0, 1, 0> {
2434 explicit LStackCheck(LOperand* context) {
2435 inputs_[0] = context;
2438 LOperand* context() { return inputs_[0]; }
2440 DECLARE_CONCRETE_INSTRUCTION(StackCheck, "stack-check")
2441 DECLARE_HYDROGEN_ACCESSOR(StackCheck)
2443 Label* done_label() { return &done_label_; }
2451 class LStoreKeyed : public LTemplateInstruction<0, 3, T> {
2453 LStoreKeyed(LOperand* elements, LOperand* key, LOperand* value) {
2454 this->inputs_[0] = elements;
2455 this->inputs_[1] = key;
2456 this->inputs_[2] = value;
2459 bool is_external() const { return this->hydrogen()->is_external(); }
2460 bool is_fixed_typed_array() const {
2461 return hydrogen()->is_fixed_typed_array();
2463 bool is_typed_elements() const {
2464 return is_external() || is_fixed_typed_array();
2466 LOperand* elements() { return this->inputs_[0]; }
2467 LOperand* key() { return this->inputs_[1]; }
2468 LOperand* value() { return this->inputs_[2]; }
2469 ElementsKind elements_kind() const {
2470 return this->hydrogen()->elements_kind();
2473 bool NeedsCanonicalization() {
2474 if (hydrogen()->value()->IsAdd() || hydrogen()->value()->IsSub() ||
2475 hydrogen()->value()->IsMul() || hydrogen()->value()->IsDiv()) {
2478 return this->hydrogen()->NeedsCanonicalization();
2480 uint32_t base_offset() const { return this->hydrogen()->base_offset(); }
2482 void PrintDataTo(StringStream* stream) override {
2483 this->elements()->PrintTo(stream);
2485 this->key()->PrintTo(stream);
2486 if (this->base_offset() != 0) {
2487 stream->Add(" + %d] <-", this->base_offset());
2489 stream->Add("] <- ");
2492 if (this->value() == NULL) {
2493 DCHECK(hydrogen()->IsConstantHoleStore() &&
2494 hydrogen()->value()->representation().IsDouble());
2495 stream->Add("<the hole(nan)>");
2497 this->value()->PrintTo(stream);
2501 DECLARE_HYDROGEN_ACCESSOR(StoreKeyed)
2505 class LStoreKeyedExternal final : public LStoreKeyed<1> {
2507 LStoreKeyedExternal(LOperand* elements, LOperand* key, LOperand* value,
2509 LStoreKeyed<1>(elements, key, value) {
2513 LOperand* temp() { return temps_[0]; }
2515 DECLARE_CONCRETE_INSTRUCTION(StoreKeyedExternal, "store-keyed-external")
2519 class LStoreKeyedFixed final : public LStoreKeyed<1> {
2521 LStoreKeyedFixed(LOperand* elements, LOperand* key, LOperand* value,
2523 LStoreKeyed<1>(elements, key, value) {
2527 LOperand* temp() { return temps_[0]; }
2529 DECLARE_CONCRETE_INSTRUCTION(StoreKeyedFixed, "store-keyed-fixed")
2533 class LStoreKeyedFixedDouble final : public LStoreKeyed<1> {
2535 LStoreKeyedFixedDouble(LOperand* elements, LOperand* key, LOperand* value,
2537 LStoreKeyed<1>(elements, key, value) {
2541 LOperand* temp() { return temps_[0]; }
2543 DECLARE_CONCRETE_INSTRUCTION(StoreKeyedFixedDouble,
2544 "store-keyed-fixed-double")
2548 class LStoreKeyedGeneric final : public LTemplateInstruction<0, 4, 0> {
2550 LStoreKeyedGeneric(LOperand* context,
2554 inputs_[0] = context;
2560 LOperand* context() { return inputs_[0]; }
2561 LOperand* object() { return inputs_[1]; }
2562 LOperand* key() { return inputs_[2]; }
2563 LOperand* value() { return inputs_[3]; }
2565 DECLARE_CONCRETE_INSTRUCTION(StoreKeyedGeneric, "store-keyed-generic")
2566 DECLARE_HYDROGEN_ACCESSOR(StoreKeyedGeneric)
2568 void PrintDataTo(StringStream* stream) override;
2570 LanguageMode language_mode() { return hydrogen()->language_mode(); }
2574 class LStoreNamedField final : public LTemplateInstruction<0, 2, 2> {
2576 LStoreNamedField(LOperand* object, LOperand* value,
2577 LOperand* temp0, LOperand* temp1) {
2578 inputs_[0] = object;
2584 LOperand* object() { return inputs_[0]; }
2585 LOperand* value() { return inputs_[1]; }
2586 LOperand* temp0() { return temps_[0]; }
2587 LOperand* temp1() { return temps_[1]; }
2589 DECLARE_CONCRETE_INSTRUCTION(StoreNamedField, "store-named-field")
2590 DECLARE_HYDROGEN_ACCESSOR(StoreNamedField)
2592 void PrintDataTo(StringStream* stream) override;
2594 Representation representation() const {
2595 return hydrogen()->field_representation();
2600 class LStoreNamedGeneric final : public LTemplateInstruction<0, 3, 0> {
2602 LStoreNamedGeneric(LOperand* context, LOperand* object, LOperand* value) {
2603 inputs_[0] = context;
2604 inputs_[1] = object;
2608 LOperand* context() { return inputs_[0]; }
2609 LOperand* object() { return inputs_[1]; }
2610 LOperand* value() { return inputs_[2]; }
2612 DECLARE_CONCRETE_INSTRUCTION(StoreNamedGeneric, "store-named-generic")
2613 DECLARE_HYDROGEN_ACCESSOR(StoreNamedGeneric)
2615 void PrintDataTo(StringStream* stream) override;
2617 Handle<Object> name() const { return hydrogen()->name(); }
2618 LanguageMode language_mode() { return hydrogen()->language_mode(); }
2622 class LMaybeGrowElements final : public LTemplateInstruction<1, 5, 0> {
2624 LMaybeGrowElements(LOperand* context, LOperand* object, LOperand* elements,
2625 LOperand* key, LOperand* current_capacity) {
2626 inputs_[0] = context;
2627 inputs_[1] = object;
2628 inputs_[2] = elements;
2630 inputs_[4] = current_capacity;
2633 LOperand* context() { return inputs_[0]; }
2634 LOperand* object() { return inputs_[1]; }
2635 LOperand* elements() { return inputs_[2]; }
2636 LOperand* key() { return inputs_[3]; }
2637 LOperand* current_capacity() { return inputs_[4]; }
2639 DECLARE_HYDROGEN_ACCESSOR(MaybeGrowElements)
2640 DECLARE_CONCRETE_INSTRUCTION(MaybeGrowElements, "maybe-grow-elements")
2644 class LStringAdd final : public LTemplateInstruction<1, 3, 0> {
2646 LStringAdd(LOperand* context, LOperand* left, LOperand* right) {
2647 inputs_[0] = context;
2652 LOperand* context() { return inputs_[0]; }
2653 LOperand* left() { return inputs_[1]; }
2654 LOperand* right() { return inputs_[2]; }
2656 DECLARE_CONCRETE_INSTRUCTION(StringAdd, "string-add")
2657 DECLARE_HYDROGEN_ACCESSOR(StringAdd)
2661 class LStringCharCodeAt final : public LTemplateInstruction<1, 3, 0> {
2663 LStringCharCodeAt(LOperand* context, LOperand* string, LOperand* index) {
2664 inputs_[0] = context;
2665 inputs_[1] = string;
2669 LOperand* context() { return inputs_[0]; }
2670 LOperand* string() { return inputs_[1]; }
2671 LOperand* index() { return inputs_[2]; }
2673 DECLARE_CONCRETE_INSTRUCTION(StringCharCodeAt, "string-char-code-at")
2674 DECLARE_HYDROGEN_ACCESSOR(StringCharCodeAt)
2678 class LStringCharFromCode final : public LTemplateInstruction<1, 2, 0> {
2680 LStringCharFromCode(LOperand* context, LOperand* char_code) {
2681 inputs_[0] = context;
2682 inputs_[1] = char_code;
2685 LOperand* context() { return inputs_[0]; }
2686 LOperand* char_code() { return inputs_[1]; }
2688 DECLARE_CONCRETE_INSTRUCTION(StringCharFromCode, "string-char-from-code")
2689 DECLARE_HYDROGEN_ACCESSOR(StringCharFromCode)
2693 class LStringCompareAndBranch final : public LControlInstruction<3, 0> {
2695 LStringCompareAndBranch(LOperand* context, LOperand* left, LOperand* right) {
2696 inputs_[0] = context;
2701 LOperand* context() { return inputs_[0]; }
2702 LOperand* left() { return inputs_[1]; }
2703 LOperand* right() { return inputs_[2]; }
2705 DECLARE_CONCRETE_INSTRUCTION(StringCompareAndBranch,
2706 "string-compare-and-branch")
2707 DECLARE_HYDROGEN_ACCESSOR(StringCompareAndBranch)
2709 Token::Value op() const { return hydrogen()->token(); }
2711 void PrintDataTo(StringStream* stream) override;
2715 // Truncating conversion from a tagged value to an int32.
2716 class LTaggedToI final : public LTemplateInstruction<1, 1, 2> {
2718 explicit LTaggedToI(LOperand* value, LOperand* temp1, LOperand* temp2) {
2724 LOperand* value() { return inputs_[0]; }
2725 LOperand* temp1() { return temps_[0]; }
2726 LOperand* temp2() { return temps_[1]; }
2728 DECLARE_CONCRETE_INSTRUCTION(TaggedToI, "tagged-to-i")
2729 DECLARE_HYDROGEN_ACCESSOR(Change)
2731 bool truncating() { return hydrogen()->CanTruncateToInt32(); }
2735 class LShiftI final : public LTemplateInstruction<1, 2, 0> {
2737 LShiftI(Token::Value op, LOperand* left, LOperand* right, bool can_deopt)
2738 : op_(op), can_deopt_(can_deopt) {
2743 Token::Value op() const { return op_; }
2744 LOperand* left() { return inputs_[0]; }
2745 LOperand* right() { return inputs_[1]; }
2746 bool can_deopt() const { return can_deopt_; }
2748 DECLARE_CONCRETE_INSTRUCTION(ShiftI, "shift-i")
2756 class LShiftS final : public LTemplateInstruction<1, 2, 0> {
2758 LShiftS(Token::Value op, LOperand* left, LOperand* right, bool can_deopt)
2759 : op_(op), can_deopt_(can_deopt) {
2764 Token::Value op() const { return op_; }
2765 LOperand* left() { return inputs_[0]; }
2766 LOperand* right() { return inputs_[1]; }
2767 bool can_deopt() const { return can_deopt_; }
2769 DECLARE_CONCRETE_INSTRUCTION(ShiftS, "shift-s")
2777 class LStoreCodeEntry final : public LTemplateInstruction<0, 2, 1> {
2779 LStoreCodeEntry(LOperand* function, LOperand* code_object,
2781 inputs_[0] = function;
2782 inputs_[1] = code_object;
2786 LOperand* function() { return inputs_[0]; }
2787 LOperand* code_object() { return inputs_[1]; }
2788 LOperand* temp() { return temps_[0]; }
2790 void PrintDataTo(StringStream* stream) override;
2792 DECLARE_CONCRETE_INSTRUCTION(StoreCodeEntry, "store-code-entry")
2793 DECLARE_HYDROGEN_ACCESSOR(StoreCodeEntry)
2797 class LStoreContextSlot final : public LTemplateInstruction<0, 2, 1> {
2799 LStoreContextSlot(LOperand* context, LOperand* value, LOperand* temp) {
2800 inputs_[0] = context;
2805 LOperand* context() { return inputs_[0]; }
2806 LOperand* value() { return inputs_[1]; }
2807 LOperand* temp() { return temps_[0]; }
2809 DECLARE_CONCRETE_INSTRUCTION(StoreContextSlot, "store-context-slot")
2810 DECLARE_HYDROGEN_ACCESSOR(StoreContextSlot)
2812 int slot_index() { return hydrogen()->slot_index(); }
2814 void PrintDataTo(StringStream* stream) override;
2818 class LSubI final : public LTemplateInstruction<1, 2, 0> {
2820 LSubI(LOperand* left, LOperand* right)
2821 : shift_(NO_SHIFT), shift_amount_(0) {
2826 LSubI(LOperand* left, LOperand* right, Shift shift, LOperand* shift_amount)
2827 : shift_(shift), shift_amount_(shift_amount) {
2832 LOperand* left() { return inputs_[0]; }
2833 LOperand* right() { return inputs_[1]; }
2835 Shift shift() const { return shift_; }
2836 LOperand* shift_amount() const { return shift_amount_; }
2838 DECLARE_CONCRETE_INSTRUCTION(SubI, "sub-i")
2839 DECLARE_HYDROGEN_ACCESSOR(Sub)
2843 LOperand* shift_amount_;
2847 class LSubS: public LTemplateInstruction<1, 2, 0> {
2849 LSubS(LOperand* left, LOperand* right) {
2854 LOperand* left() { return inputs_[0]; }
2855 LOperand* right() { return inputs_[1]; }
2857 DECLARE_CONCRETE_INSTRUCTION(SubS, "sub-s")
2858 DECLARE_HYDROGEN_ACCESSOR(Sub)
2862 class LThisFunction final : public LTemplateInstruction<1, 0, 0> {
2864 DECLARE_CONCRETE_INSTRUCTION(ThisFunction, "this-function")
2865 DECLARE_HYDROGEN_ACCESSOR(ThisFunction)
2869 class LToFastProperties final : public LTemplateInstruction<1, 1, 0> {
2871 explicit LToFastProperties(LOperand* value) {
2875 LOperand* value() { return inputs_[0]; }
2877 DECLARE_CONCRETE_INSTRUCTION(ToFastProperties, "to-fast-properties")
2878 DECLARE_HYDROGEN_ACCESSOR(ToFastProperties)
2882 class LTransitionElementsKind final : public LTemplateInstruction<0, 2, 2> {
2884 LTransitionElementsKind(LOperand* object,
2888 inputs_[0] = object;
2889 inputs_[1] = context;
2894 LOperand* object() { return inputs_[0]; }
2895 LOperand* context() { return inputs_[1]; }
2896 LOperand* temp1() { return temps_[0]; }
2897 LOperand* temp2() { return temps_[1]; }
2899 DECLARE_CONCRETE_INSTRUCTION(TransitionElementsKind,
2900 "transition-elements-kind")
2901 DECLARE_HYDROGEN_ACCESSOR(TransitionElementsKind)
2903 void PrintDataTo(StringStream* stream) override;
2905 Handle<Map> original_map() { return hydrogen()->original_map().handle(); }
2906 Handle<Map> transitioned_map() {
2907 return hydrogen()->transitioned_map().handle();
2909 ElementsKind from_kind() const { return hydrogen()->from_kind(); }
2910 ElementsKind to_kind() const { return hydrogen()->to_kind(); }
2914 class LTrapAllocationMemento final : public LTemplateInstruction<0, 1, 2> {
2916 LTrapAllocationMemento(LOperand* object, LOperand* temp1, LOperand* temp2) {
2917 inputs_[0] = object;
2922 LOperand* object() { return inputs_[0]; }
2923 LOperand* temp1() { return temps_[0]; }
2924 LOperand* temp2() { return temps_[1]; }
2926 DECLARE_CONCRETE_INSTRUCTION(TrapAllocationMemento, "trap-allocation-memento")
2930 class LTruncateDoubleToIntOrSmi final : public LTemplateInstruction<1, 1, 0> {
2932 explicit LTruncateDoubleToIntOrSmi(LOperand* value) {
2936 LOperand* value() { return inputs_[0]; }
2938 DECLARE_CONCRETE_INSTRUCTION(TruncateDoubleToIntOrSmi,
2939 "truncate-double-to-int-or-smi")
2940 DECLARE_HYDROGEN_ACCESSOR(UnaryOperation)
2942 bool tag_result() { return hydrogen()->representation().IsSmi(); }
2946 class LTypeof final : public LTemplateInstruction<1, 2, 0> {
2948 LTypeof(LOperand* context, LOperand* value) {
2949 inputs_[0] = context;
2953 LOperand* context() { return inputs_[0]; }
2954 LOperand* value() { return inputs_[1]; }
2956 DECLARE_CONCRETE_INSTRUCTION(Typeof, "typeof")
2960 class LTypeofIsAndBranch final : public LControlInstruction<1, 2> {
2962 LTypeofIsAndBranch(LOperand* value, LOperand* temp1, LOperand* temp2) {
2968 LOperand* value() { return inputs_[0]; }
2969 LOperand* temp1() { return temps_[0]; }
2970 LOperand* temp2() { return temps_[1]; }
2972 DECLARE_CONCRETE_INSTRUCTION(TypeofIsAndBranch, "typeof-is-and-branch")
2973 DECLARE_HYDROGEN_ACCESSOR(TypeofIsAndBranch)
2975 Handle<String> type_literal() const { return hydrogen()->type_literal(); }
2977 void PrintDataTo(StringStream* stream) override;
2981 class LUint32ToDouble final : public LTemplateInstruction<1, 1, 0> {
2983 explicit LUint32ToDouble(LOperand* value) {
2987 LOperand* value() { return inputs_[0]; }
2989 DECLARE_CONCRETE_INSTRUCTION(Uint32ToDouble, "uint32-to-double")
2993 class LCheckMapValue final : public LTemplateInstruction<0, 2, 1> {
2995 LCheckMapValue(LOperand* value, LOperand* map, LOperand* temp) {
3001 LOperand* value() { return inputs_[0]; }
3002 LOperand* map() { return inputs_[1]; }
3003 LOperand* temp() { return temps_[0]; }
3005 DECLARE_CONCRETE_INSTRUCTION(CheckMapValue, "check-map-value")
3009 class LLoadFieldByIndex final : public LTemplateInstruction<1, 2, 0> {
3011 LLoadFieldByIndex(LOperand* object, LOperand* index) {
3012 inputs_[0] = object;
3016 LOperand* object() { return inputs_[0]; }
3017 LOperand* index() { return inputs_[1]; }
3019 DECLARE_CONCRETE_INSTRUCTION(LoadFieldByIndex, "load-field-by-index")
3023 class LStoreFrameContext: public LTemplateInstruction<0, 1, 0> {
3025 explicit LStoreFrameContext(LOperand* context) {
3026 inputs_[0] = context;
3029 LOperand* context() { return inputs_[0]; }
3031 DECLARE_CONCRETE_INSTRUCTION(StoreFrameContext, "store-frame-context")
3035 class LAllocateBlockContext: public LTemplateInstruction<1, 2, 0> {
3037 LAllocateBlockContext(LOperand* context, LOperand* function) {
3038 inputs_[0] = context;
3039 inputs_[1] = function;
3042 LOperand* context() { return inputs_[0]; }
3043 LOperand* function() { return inputs_[1]; }
3045 Handle<ScopeInfo> scope_info() { return hydrogen()->scope_info(); }
3047 DECLARE_CONCRETE_INSTRUCTION(AllocateBlockContext, "allocate-block-context")
3048 DECLARE_HYDROGEN_ACCESSOR(AllocateBlockContext)
3052 class LWrapReceiver final : public LTemplateInstruction<1, 2, 0> {
3054 LWrapReceiver(LOperand* receiver, LOperand* function) {
3055 inputs_[0] = receiver;
3056 inputs_[1] = function;
3059 DECLARE_CONCRETE_INSTRUCTION(WrapReceiver, "wrap-receiver")
3060 DECLARE_HYDROGEN_ACCESSOR(WrapReceiver)
3062 LOperand* receiver() { return inputs_[0]; }
3063 LOperand* function() { return inputs_[1]; }
3067 class LChunkBuilder;
3068 class LPlatformChunk final : public LChunk {
3070 LPlatformChunk(CompilationInfo* info, HGraph* graph)
3071 : LChunk(info, graph) { }
3073 int GetNextSpillIndex();
3074 LOperand* GetNextSpillSlot(RegisterKind kind);
3078 class LChunkBuilder final : public LChunkBuilderBase {
3080 LChunkBuilder(CompilationInfo* info, HGraph* graph, LAllocator* allocator)
3081 : LChunkBuilderBase(info, graph),
3082 current_instruction_(NULL),
3083 current_block_(NULL),
3084 allocator_(allocator) {}
3086 // Build the sequence for the graph.
3087 LPlatformChunk* Build();
3089 // Declare methods that deal with the individual node types.
3090 #define DECLARE_DO(type) LInstruction* Do##type(H##type* node);
3091 HYDROGEN_CONCRETE_INSTRUCTION_LIST(DECLARE_DO)
3094 LInstruction* DoDivByPowerOf2I(HDiv* instr);
3095 LInstruction* DoDivByConstI(HDiv* instr);
3096 LInstruction* DoDivI(HBinaryOperation* instr);
3097 LInstruction* DoModByPowerOf2I(HMod* instr);
3098 LInstruction* DoModByConstI(HMod* instr);
3099 LInstruction* DoModI(HMod* instr);
3100 LInstruction* DoFlooringDivByPowerOf2I(HMathFloorOfDiv* instr);
3101 LInstruction* DoFlooringDivByConstI(HMathFloorOfDiv* instr);
3102 LInstruction* DoFlooringDivI(HMathFloorOfDiv* instr);
3104 static bool HasMagicNumberForDivision(int32_t divisor);
3107 // Methods for getting operands for Use / Define / Temp.
3108 LUnallocated* ToUnallocated(Register reg);
3109 LUnallocated* ToUnallocated(DoubleRegister reg);
3111 // Methods for setting up define-use relationships.
3112 MUST_USE_RESULT LOperand* Use(HValue* value, LUnallocated* operand);
3113 MUST_USE_RESULT LOperand* UseFixed(HValue* value, Register fixed_register);
3114 MUST_USE_RESULT LOperand* UseFixedDouble(HValue* value,
3115 DoubleRegister fixed_register);
3117 // A value that is guaranteed to be allocated to a register.
3118 // The operand created by UseRegister is guaranteed to be live until the end
3119 // of the instruction. This means that register allocator will not reuse its
3120 // register for any other operand inside instruction.
3121 MUST_USE_RESULT LOperand* UseRegister(HValue* value);
3123 // The operand created by UseRegisterAndClobber is guaranteed to be live until
3124 // the end of the end of the instruction, and it may also be used as a scratch
3125 // register by the instruction implementation.
3127 // This behaves identically to ARM's UseTempRegister. However, it is renamed
3128 // to discourage its use in ARM64, since in most cases it is better to
3129 // allocate a temporary register for the Lithium instruction.
3130 MUST_USE_RESULT LOperand* UseRegisterAndClobber(HValue* value);
3132 // The operand created by UseRegisterAtStart is guaranteed to be live only at
3133 // instruction start. The register allocator is free to assign the same
3134 // register to some other operand used inside instruction (i.e. temporary or
3136 MUST_USE_RESULT LOperand* UseRegisterAtStart(HValue* value);
3138 // An input operand in a register or a constant operand.
3139 MUST_USE_RESULT LOperand* UseRegisterOrConstant(HValue* value);
3140 MUST_USE_RESULT LOperand* UseRegisterOrConstantAtStart(HValue* value);
3142 // A constant operand.
3143 MUST_USE_RESULT LConstantOperand* UseConstant(HValue* value);
3145 // An input operand in register, stack slot or a constant operand.
3146 // Will not be moved to a register even if one is freely available.
3147 virtual MUST_USE_RESULT LOperand* UseAny(HValue* value);
3149 // Temporary operand that must be in a register.
3150 MUST_USE_RESULT LUnallocated* TempRegister();
3152 // Temporary operand that must be in a double register.
3153 MUST_USE_RESULT LUnallocated* TempDoubleRegister();
3155 MUST_USE_RESULT LOperand* FixedTemp(Register reg);
3157 // Temporary operand that must be in a fixed double register.
3158 MUST_USE_RESULT LOperand* FixedTemp(DoubleRegister reg);
3160 // Methods for setting up define-use relationships.
3161 // Return the same instruction that they are passed.
3162 LInstruction* Define(LTemplateResultInstruction<1>* instr,
3163 LUnallocated* result);
3164 LInstruction* DefineAsRegister(LTemplateResultInstruction<1>* instr);
3165 LInstruction* DefineAsSpilled(LTemplateResultInstruction<1>* instr,
3168 LInstruction* DefineSameAsFirst(LTemplateResultInstruction<1>* instr);
3169 LInstruction* DefineFixed(LTemplateResultInstruction<1>* instr,
3171 LInstruction* DefineFixedDouble(LTemplateResultInstruction<1>* instr,
3172 DoubleRegister reg);
3174 enum CanDeoptimize { CAN_DEOPTIMIZE_EAGERLY, CANNOT_DEOPTIMIZE_EAGERLY };
3176 // By default we assume that instruction sequences generated for calls
3177 // cannot deoptimize eagerly and we do not attach environment to this
3179 LInstruction* MarkAsCall(
3180 LInstruction* instr,
3181 HInstruction* hinstr,
3182 CanDeoptimize can_deoptimize = CANNOT_DEOPTIMIZE_EAGERLY);
3184 LInstruction* AssignPointerMap(LInstruction* instr);
3185 LInstruction* AssignEnvironment(LInstruction* instr);
3187 void VisitInstruction(HInstruction* current);
3188 void AddInstruction(LInstruction* instr, HInstruction* current);
3189 void DoBasicBlock(HBasicBlock* block);
3191 int JSShiftAmountFromHConstant(HValue* constant) {
3192 return HConstant::cast(constant)->Integer32Value() & 0x1f;
3194 bool LikelyFitsImmField(HInstruction* instr, int imm) {
3195 if (instr->IsAdd() || instr->IsSub()) {
3196 return Assembler::IsImmAddSub(imm) || Assembler::IsImmAddSub(-imm);
3198 DCHECK(instr->IsBitwise());
3199 unsigned unused_n, unused_imm_s, unused_imm_r;
3200 return Assembler::IsImmLogical(imm, kWRegSizeInBits,
3201 &unused_n, &unused_imm_s, &unused_imm_r);
3205 // Indicates if a sequence of the form
3208 // can be replaced with:
3209 // add x0, x1, x9 LSL #imm
3210 // If this is not possible, the function returns NULL. Otherwise it returns a
3211 // pointer to the shift instruction that would be optimized away.
3212 HBitwiseBinaryOperation* CanTransformToShiftedOp(HValue* val,
3213 HValue** left = NULL);
3214 // Checks if all uses of the shift operation can optimize it away.
3215 bool ShiftCanBeOptimizedAway(HBitwiseBinaryOperation* shift);
3216 // Attempts to merge the binary operation and an eventual previous shift
3217 // operation into a single operation. Returns the merged instruction on
3218 // success, and NULL otherwise.
3219 LInstruction* TryDoOpWithShiftedRightOperand(HBinaryOperation* op);
3220 LInstruction* DoShiftedBinaryOp(HBinaryOperation* instr,
3222 HBitwiseBinaryOperation* shift);
3224 LInstruction* DoShift(Token::Value op, HBitwiseBinaryOperation* instr);
3225 LInstruction* DoArithmeticD(Token::Value op,
3226 HArithmeticBinaryOperation* instr);
3227 LInstruction* DoArithmeticT(Token::Value op,
3228 HBinaryOperation* instr);
3230 HInstruction* current_instruction_;
3231 HBasicBlock* current_block_;
3232 LAllocator* allocator_;
3234 DISALLOW_COPY_AND_ASSIGN(LChunkBuilder);
3237 #undef DECLARE_HYDROGEN_ACCESSOR
3238 #undef DECLARE_CONCRETE_INSTRUCTION
3240 } } // namespace v8::internal
3242 #endif // V8_ARM64_LITHIUM_ARM64_H_