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(CheckInstanceType) \
52 V(ClassOfTestAndBranch) \
53 V(CmpHoleAndBranchD) \
54 V(CmpHoleAndBranchT) \
56 V(CmpObjectEqAndBranch) \
58 V(CompareMinusZeroAndBranch) \
59 V(CompareNumericAndBranch) \
79 V(FlooringDivByConstI) \
80 V(FlooringDivByPowerOf2I) \
85 V(GetCachedArrayIndex) \
87 V(HasCachedArrayIndexAndBranch) \
88 V(HasInstanceTypeAndBranch) \
89 V(InnerAllocatedObject) \
91 V(InstanceOfKnownGlobal) \
93 V(Integer32ToDouble) \
95 V(IsConstructCallAndBranch) \
96 V(IsObjectAndBranch) \
98 V(IsStringAndBranch) \
99 V(IsUndetectableAndBranch) \
103 V(LoadFieldByIndex) \
104 V(LoadFunctionPrototype) \
106 V(LoadGlobalGeneric) \
107 V(LoadKeyedExternal) \
109 V(LoadKeyedFixedDouble) \
110 V(LoadKeyedGeneric) \
112 V(LoadNamedGeneric) \
140 V(PreparePushArguments) \
144 V(SeqStringGetChar) \
145 V(SeqStringSetChar) \
152 V(StoreContextSlot) \
153 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 virtual Opcode opcode() const V8_FINAL V8_OVERRIDE { \
182 return LInstruction::k##type; \
184 virtual void CompileToNative(LCodeGen* generator) V8_FINAL V8_OVERRIDE; \
185 virtual const char* Mnemonic() const V8_FINAL V8_OVERRIDE { \
188 static L##type* cast(LInstruction* instr) { \
189 DCHECK(instr->Is##type()); \
190 return reinterpret_cast<L##type*>(instr); \
194 #define DECLARE_HYDROGEN_ACCESSOR(type) \
195 H##type* hydrogen() const { \
196 return H##type::cast(this->hydrogen_value()); \
200 class LInstruction : public ZoneObject {
203 : environment_(NULL),
204 hydrogen_value_(NULL),
205 bit_field_(IsCallBits::encode(false)) { }
207 virtual ~LInstruction() { }
209 virtual void CompileToNative(LCodeGen* generator) = 0;
210 virtual const char* Mnemonic() const = 0;
211 virtual void PrintTo(StringStream* stream);
212 virtual void PrintDataTo(StringStream* stream);
213 virtual void PrintOutputOperandTo(StringStream* stream);
216 // Declare a unique enum value for each instruction.
217 #define DECLARE_OPCODE(type) k##type,
218 LITHIUM_CONCRETE_INSTRUCTION_LIST(DECLARE_OPCODE)
219 kNumberOfInstructions
220 #undef DECLARE_OPCODE
223 virtual Opcode opcode() const = 0;
225 // Declare non-virtual type testers for all leaf IR classes.
226 #define DECLARE_PREDICATE(type) \
227 bool Is##type() const { return opcode() == k##type; }
228 LITHIUM_CONCRETE_INSTRUCTION_LIST(DECLARE_PREDICATE)
229 #undef DECLARE_PREDICATE
231 // Declare virtual predicates for instructions that don't have
233 virtual bool IsGap() const { return false; }
235 virtual bool IsControl() const { return false; }
237 // Try deleting this instruction if possible.
238 virtual bool TryDelete() { return false; }
240 void set_environment(LEnvironment* env) { environment_ = env; }
241 LEnvironment* environment() const { return environment_; }
242 bool HasEnvironment() const { return environment_ != NULL; }
244 void set_pointer_map(LPointerMap* p) { pointer_map_.set(p); }
245 LPointerMap* pointer_map() const { return pointer_map_.get(); }
246 bool HasPointerMap() const { return pointer_map_.is_set(); }
248 void set_hydrogen_value(HValue* value) { hydrogen_value_ = value; }
249 HValue* hydrogen_value() const { return hydrogen_value_; }
251 virtual void SetDeferredLazyDeoptimizationEnvironment(LEnvironment* env) { }
253 void MarkAsCall() { bit_field_ = IsCallBits::update(bit_field_, true); }
254 bool IsCall() const { return IsCallBits::decode(bit_field_); }
256 // Interface to the register allocator and iterators.
257 bool ClobbersTemps() const { return IsCall(); }
258 bool ClobbersRegisters() const { return IsCall(); }
259 virtual bool ClobbersDoubleRegisters(Isolate* isolate) const {
262 bool IsMarkedAsCall() const { return IsCall(); }
264 virtual bool HasResult() const = 0;
265 virtual LOperand* result() const = 0;
267 virtual int InputCount() = 0;
268 virtual LOperand* InputAt(int i) = 0;
269 virtual int TempCount() = 0;
270 virtual LOperand* TempAt(int i) = 0;
272 LOperand* FirstInput() { return InputAt(0); }
273 LOperand* Output() { return HasResult() ? result() : NULL; }
275 virtual bool HasInterestingComment(LCodeGen* gen) const { return true; }
282 class IsCallBits: public BitField<bool, 0, 1> {};
284 LEnvironment* environment_;
285 SetOncePointer<LPointerMap> pointer_map_;
286 HValue* hydrogen_value_;
291 // R = number of result operands (0 or 1).
293 class LTemplateResultInstruction : public LInstruction {
295 // Allow 0 or 1 output operands.
296 STATIC_ASSERT(R == 0 || R == 1);
297 virtual bool HasResult() const V8_FINAL V8_OVERRIDE {
298 return (R != 0) && (result() != NULL);
300 void set_result(LOperand* operand) { results_[0] = operand; }
301 LOperand* result() const { return results_[0]; }
304 EmbeddedContainer<LOperand*, R> results_;
308 // R = number of result operands (0 or 1).
309 // I = number of input operands.
310 // T = number of temporary operands.
311 template<int R, int I, int T>
312 class LTemplateInstruction : public LTemplateResultInstruction<R> {
314 EmbeddedContainer<LOperand*, I> inputs_;
315 EmbeddedContainer<LOperand*, T> temps_;
319 virtual int InputCount() V8_FINAL V8_OVERRIDE { return I; }
320 virtual LOperand* InputAt(int i) V8_FINAL V8_OVERRIDE { return inputs_[i]; }
322 virtual int TempCount() V8_FINAL V8_OVERRIDE { return T; }
323 virtual LOperand* TempAt(int i) V8_FINAL V8_OVERRIDE { return temps_[i]; }
327 class LUnknownOSRValue V8_FINAL : public LTemplateInstruction<1, 0, 0> {
329 virtual bool HasInterestingComment(LCodeGen* gen) const V8_OVERRIDE {
332 DECLARE_CONCRETE_INSTRUCTION(UnknownOSRValue, "unknown-osr-value")
336 template<int I, int T>
337 class LControlInstruction : public LTemplateInstruction<0, I, T> {
339 LControlInstruction() : false_label_(NULL), true_label_(NULL) { }
341 virtual bool IsControl() const V8_FINAL V8_OVERRIDE { return true; }
343 int SuccessorCount() { return hydrogen()->SuccessorCount(); }
344 HBasicBlock* SuccessorAt(int i) { return hydrogen()->SuccessorAt(i); }
346 int TrueDestination(LChunk* chunk) {
347 return chunk->LookupDestination(true_block_id());
350 int FalseDestination(LChunk* chunk) {
351 return chunk->LookupDestination(false_block_id());
354 Label* TrueLabel(LChunk* chunk) {
355 if (true_label_ == NULL) {
356 true_label_ = chunk->GetAssemblyLabel(TrueDestination(chunk));
361 Label* FalseLabel(LChunk* chunk) {
362 if (false_label_ == NULL) {
363 false_label_ = chunk->GetAssemblyLabel(FalseDestination(chunk));
369 int true_block_id() { return SuccessorAt(0)->block_id(); }
370 int false_block_id() { return SuccessorAt(1)->block_id(); }
373 DECLARE_HYDROGEN_ACCESSOR(ControlInstruction);
380 class LGap : public LTemplateInstruction<0, 0, 0> {
382 explicit LGap(HBasicBlock* block)
384 parallel_moves_[BEFORE] = NULL;
385 parallel_moves_[START] = NULL;
386 parallel_moves_[END] = NULL;
387 parallel_moves_[AFTER] = NULL;
390 // Can't use the DECLARE-macro here because of sub-classes.
391 virtual bool IsGap() const V8_OVERRIDE { return true; }
392 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
393 static LGap* cast(LInstruction* instr) {
394 DCHECK(instr->IsGap());
395 return reinterpret_cast<LGap*>(instr);
398 bool IsRedundant() const;
400 HBasicBlock* block() const { return block_; }
407 FIRST_INNER_POSITION = BEFORE,
408 LAST_INNER_POSITION = AFTER
411 LParallelMove* GetOrCreateParallelMove(InnerPosition pos, Zone* zone) {
412 if (parallel_moves_[pos] == NULL) {
413 parallel_moves_[pos] = new(zone) LParallelMove(zone);
415 return parallel_moves_[pos];
418 LParallelMove* GetParallelMove(InnerPosition pos) {
419 return parallel_moves_[pos];
423 LParallelMove* parallel_moves_[LAST_INNER_POSITION + 1];
428 class LInstructionGap V8_FINAL : public LGap {
430 explicit LInstructionGap(HBasicBlock* block) : LGap(block) { }
432 virtual bool HasInterestingComment(LCodeGen* gen) const V8_OVERRIDE {
433 return !IsRedundant();
436 DECLARE_CONCRETE_INSTRUCTION(InstructionGap, "gap")
440 class LDrop V8_FINAL : public LTemplateInstruction<0, 0, 0> {
442 explicit LDrop(int count) : count_(count) { }
444 int count() const { return count_; }
446 DECLARE_CONCRETE_INSTRUCTION(Drop, "drop")
453 class LDummy V8_FINAL : public LTemplateInstruction<1, 0, 0> {
456 DECLARE_CONCRETE_INSTRUCTION(Dummy, "dummy")
460 class LDummyUse V8_FINAL : public LTemplateInstruction<1, 1, 0> {
462 explicit LDummyUse(LOperand* value) {
465 DECLARE_CONCRETE_INSTRUCTION(DummyUse, "dummy-use")
469 class LGoto V8_FINAL : public LTemplateInstruction<0, 0, 0> {
471 explicit LGoto(HBasicBlock* block) : block_(block) { }
473 virtual bool HasInterestingComment(LCodeGen* gen) const V8_OVERRIDE;
474 DECLARE_CONCRETE_INSTRUCTION(Goto, "goto")
475 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
476 virtual bool IsControl() const V8_OVERRIDE { return true; }
478 int block_id() const { return block_->block_id(); }
485 class LLazyBailout V8_FINAL : public LTemplateInstruction<0, 0, 0> {
487 LLazyBailout() : gap_instructions_size_(0) { }
489 DECLARE_CONCRETE_INSTRUCTION(LazyBailout, "lazy-bailout")
491 void set_gap_instructions_size(int gap_instructions_size) {
492 gap_instructions_size_ = gap_instructions_size;
494 int gap_instructions_size() { return gap_instructions_size_; }
497 int gap_instructions_size_;
501 class LLabel V8_FINAL : public LGap {
503 explicit LLabel(HBasicBlock* block)
504 : LGap(block), replacement_(NULL) { }
506 virtual bool HasInterestingComment(LCodeGen* gen) const V8_OVERRIDE {
509 DECLARE_CONCRETE_INSTRUCTION(Label, "label")
511 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
513 int block_id() const { return block()->block_id(); }
514 bool is_loop_header() const { return block()->IsLoopHeader(); }
515 bool is_osr_entry() const { return block()->is_osr_entry(); }
516 Label* label() { return &label_; }
517 LLabel* replacement() const { return replacement_; }
518 void set_replacement(LLabel* label) { replacement_ = label; }
519 bool HasReplacement() const { return replacement_ != NULL; }
523 LLabel* replacement_;
527 class LOsrEntry V8_FINAL : public LTemplateInstruction<0, 0, 0> {
531 virtual bool HasInterestingComment(LCodeGen* gen) const V8_OVERRIDE {
534 DECLARE_CONCRETE_INSTRUCTION(OsrEntry, "osr-entry")
538 class LAccessArgumentsAt V8_FINAL : public LTemplateInstruction<1, 3, 0> {
540 LAccessArgumentsAt(LOperand* arguments,
543 inputs_[0] = arguments;
548 DECLARE_CONCRETE_INSTRUCTION(AccessArgumentsAt, "access-arguments-at")
550 LOperand* arguments() { return inputs_[0]; }
551 LOperand* length() { return inputs_[1]; }
552 LOperand* index() { return inputs_[2]; }
554 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
558 class LAddE V8_FINAL : public LTemplateInstruction<1, 2, 0> {
560 LAddE(LOperand* left, LOperand* right) {
565 LOperand* left() { return inputs_[0]; }
566 LOperand* right() { return inputs_[1]; }
568 DECLARE_CONCRETE_INSTRUCTION(AddE, "add-e")
569 DECLARE_HYDROGEN_ACCESSOR(Add)
573 class LAddI V8_FINAL : public LTemplateInstruction<1, 2, 0> {
575 LAddI(LOperand* left, LOperand* right)
576 : shift_(NO_SHIFT), shift_amount_(0) {
581 LAddI(LOperand* left, LOperand* right, Shift shift, LOperand* shift_amount)
582 : shift_(shift), shift_amount_(shift_amount) {
587 LOperand* left() { return inputs_[0]; }
588 LOperand* right() { return inputs_[1]; }
590 Shift shift() const { return shift_; }
591 LOperand* shift_amount() const { return shift_amount_; }
593 DECLARE_CONCRETE_INSTRUCTION(AddI, "add-i")
594 DECLARE_HYDROGEN_ACCESSOR(Add)
598 LOperand* shift_amount_;
602 class LAddS V8_FINAL : public LTemplateInstruction<1, 2, 0> {
604 LAddS(LOperand* left, LOperand* right) {
609 LOperand* left() { return inputs_[0]; }
610 LOperand* right() { return inputs_[1]; }
612 DECLARE_CONCRETE_INSTRUCTION(AddS, "add-s")
613 DECLARE_HYDROGEN_ACCESSOR(Add)
617 class LAllocate V8_FINAL : public LTemplateInstruction<1, 2, 3> {
619 LAllocate(LOperand* context,
624 inputs_[0] = context;
631 LOperand* context() { return inputs_[0]; }
632 LOperand* size() { return inputs_[1]; }
633 LOperand* temp1() { return temps_[0]; }
634 LOperand* temp2() { return temps_[1]; }
635 LOperand* temp3() { return temps_[2]; }
637 DECLARE_CONCRETE_INSTRUCTION(Allocate, "allocate")
638 DECLARE_HYDROGEN_ACCESSOR(Allocate)
642 class LApplyArguments V8_FINAL : public LTemplateInstruction<1, 4, 0> {
644 LApplyArguments(LOperand* function,
647 LOperand* elements) {
648 inputs_[0] = function;
649 inputs_[1] = receiver;
651 inputs_[3] = elements;
654 DECLARE_CONCRETE_INSTRUCTION(ApplyArguments, "apply-arguments")
656 LOperand* function() { return inputs_[0]; }
657 LOperand* receiver() { return inputs_[1]; }
658 LOperand* length() { return inputs_[2]; }
659 LOperand* elements() { return inputs_[3]; }
663 class LArgumentsElements V8_FINAL : public LTemplateInstruction<1, 0, 1> {
665 explicit LArgumentsElements(LOperand* temp) {
669 LOperand* temp() { return temps_[0]; }
671 DECLARE_CONCRETE_INSTRUCTION(ArgumentsElements, "arguments-elements")
672 DECLARE_HYDROGEN_ACCESSOR(ArgumentsElements)
676 class LArgumentsLength V8_FINAL : public LTemplateInstruction<1, 1, 0> {
678 explicit LArgumentsLength(LOperand* elements) {
679 inputs_[0] = elements;
682 LOperand* elements() { return inputs_[0]; }
684 DECLARE_CONCRETE_INSTRUCTION(ArgumentsLength, "arguments-length")
688 class LArithmeticD V8_FINAL : public LTemplateInstruction<1, 2, 0> {
690 LArithmeticD(Token::Value op,
698 Token::Value op() const { return op_; }
699 LOperand* left() { return inputs_[0]; }
700 LOperand* right() { return inputs_[1]; }
702 virtual Opcode opcode() const V8_OVERRIDE {
703 return LInstruction::kArithmeticD;
705 virtual void CompileToNative(LCodeGen* generator) V8_OVERRIDE;
706 virtual const char* Mnemonic() const V8_OVERRIDE;
713 class LArithmeticT V8_FINAL : public LTemplateInstruction<1, 3, 0> {
715 LArithmeticT(Token::Value op,
720 inputs_[0] = context;
725 LOperand* context() { return inputs_[0]; }
726 LOperand* left() { return inputs_[1]; }
727 LOperand* right() { return inputs_[2]; }
728 Token::Value op() const { return op_; }
730 virtual Opcode opcode() const V8_OVERRIDE {
731 return LInstruction::kArithmeticT;
733 virtual void CompileToNative(LCodeGen* generator) V8_OVERRIDE;
734 virtual const char* Mnemonic() const V8_OVERRIDE;
741 class LBoundsCheck V8_FINAL : public LTemplateInstruction<0, 2, 0> {
743 explicit LBoundsCheck(LOperand* index, LOperand* length) {
748 LOperand* index() { return inputs_[0]; }
749 LOperand* length() { return inputs_[1]; }
751 DECLARE_CONCRETE_INSTRUCTION(BoundsCheck, "bounds-check")
752 DECLARE_HYDROGEN_ACCESSOR(BoundsCheck)
756 class LBitI V8_FINAL : public LTemplateInstruction<1, 2, 0> {
758 LBitI(LOperand* left, LOperand* right)
759 : shift_(NO_SHIFT), shift_amount_(0) {
764 LBitI(LOperand* left, LOperand* right, Shift shift, LOperand* shift_amount)
765 : shift_(shift), shift_amount_(shift_amount) {
770 LOperand* left() { return inputs_[0]; }
771 LOperand* right() { return inputs_[1]; }
773 Shift shift() const { return shift_; }
774 LOperand* shift_amount() const { return shift_amount_; }
776 Token::Value op() const { return hydrogen()->op(); }
778 DECLARE_CONCRETE_INSTRUCTION(BitI, "bit-i")
779 DECLARE_HYDROGEN_ACCESSOR(Bitwise)
783 LOperand* shift_amount_;
787 class LBitS V8_FINAL : public LTemplateInstruction<1, 2, 0> {
789 LBitS(LOperand* left, LOperand* right) {
794 LOperand* left() { return inputs_[0]; }
795 LOperand* right() { return inputs_[1]; }
797 Token::Value op() const { return hydrogen()->op(); }
799 DECLARE_CONCRETE_INSTRUCTION(BitS, "bit-s")
800 DECLARE_HYDROGEN_ACCESSOR(Bitwise)
804 class LBranch V8_FINAL : public LControlInstruction<1, 2> {
806 explicit LBranch(LOperand* value, LOperand *temp1, LOperand *temp2) {
812 LOperand* value() { return inputs_[0]; }
813 LOperand* temp1() { return temps_[0]; }
814 LOperand* temp2() { return temps_[1]; }
816 DECLARE_CONCRETE_INSTRUCTION(Branch, "branch")
817 DECLARE_HYDROGEN_ACCESSOR(Branch)
819 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
823 class LCallJSFunction V8_FINAL : public LTemplateInstruction<1, 1, 0> {
825 explicit LCallJSFunction(LOperand* function) {
826 inputs_[0] = function;
829 LOperand* function() { return inputs_[0]; }
831 DECLARE_CONCRETE_INSTRUCTION(CallJSFunction, "call-js-function")
832 DECLARE_HYDROGEN_ACCESSOR(CallJSFunction)
834 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
836 int arity() const { return hydrogen()->argument_count() - 1; }
840 class LCallFunction V8_FINAL : public LTemplateInstruction<1, 2, 0> {
842 LCallFunction(LOperand* context, LOperand* function) {
843 inputs_[0] = context;
844 inputs_[1] = function;
847 LOperand* context() { return inputs_[0]; }
848 LOperand* function() { return inputs_[1]; }
850 DECLARE_CONCRETE_INSTRUCTION(CallFunction, "call-function")
851 DECLARE_HYDROGEN_ACCESSOR(CallFunction)
853 int arity() const { return hydrogen()->argument_count() - 1; }
857 class LCallNew V8_FINAL : public LTemplateInstruction<1, 2, 0> {
859 LCallNew(LOperand* context, LOperand* constructor) {
860 inputs_[0] = context;
861 inputs_[1] = constructor;
864 LOperand* context() { return inputs_[0]; }
865 LOperand* constructor() { return inputs_[1]; }
867 DECLARE_CONCRETE_INSTRUCTION(CallNew, "call-new")
868 DECLARE_HYDROGEN_ACCESSOR(CallNew)
870 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
872 int arity() const { return hydrogen()->argument_count() - 1; }
876 class LCallNewArray V8_FINAL : public LTemplateInstruction<1, 2, 0> {
878 LCallNewArray(LOperand* context, LOperand* constructor) {
879 inputs_[0] = context;
880 inputs_[1] = constructor;
883 LOperand* context() { return inputs_[0]; }
884 LOperand* constructor() { return inputs_[1]; }
886 DECLARE_CONCRETE_INSTRUCTION(CallNewArray, "call-new-array")
887 DECLARE_HYDROGEN_ACCESSOR(CallNewArray)
889 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
891 int arity() const { return hydrogen()->argument_count() - 1; }
895 class LCallRuntime V8_FINAL : public LTemplateInstruction<1, 1, 0> {
897 explicit LCallRuntime(LOperand* context) {
898 inputs_[0] = context;
901 LOperand* context() { return inputs_[0]; }
903 DECLARE_CONCRETE_INSTRUCTION(CallRuntime, "call-runtime")
904 DECLARE_HYDROGEN_ACCESSOR(CallRuntime)
906 virtual bool ClobbersDoubleRegisters(Isolate* isolate) const V8_OVERRIDE {
907 return save_doubles() == kDontSaveFPRegs;
910 const Runtime::Function* function() const { return hydrogen()->function(); }
911 int arity() const { return hydrogen()->argument_count(); }
912 SaveFPRegsMode save_doubles() const { return hydrogen()->save_doubles(); }
916 class LCallStub V8_FINAL : public LTemplateInstruction<1, 1, 0> {
918 explicit LCallStub(LOperand* context) {
919 inputs_[0] = context;
922 LOperand* context() { return inputs_[0]; }
924 DECLARE_CONCRETE_INSTRUCTION(CallStub, "call-stub")
925 DECLARE_HYDROGEN_ACCESSOR(CallStub)
929 class LCheckInstanceType V8_FINAL : public LTemplateInstruction<0, 1, 1> {
931 explicit LCheckInstanceType(LOperand* value, LOperand* temp) {
936 LOperand* value() { return inputs_[0]; }
937 LOperand* temp() { return temps_[0]; }
939 DECLARE_CONCRETE_INSTRUCTION(CheckInstanceType, "check-instance-type")
940 DECLARE_HYDROGEN_ACCESSOR(CheckInstanceType)
944 class LCheckMaps V8_FINAL : public LTemplateInstruction<0, 1, 1> {
946 explicit LCheckMaps(LOperand* value = NULL, LOperand* temp = NULL) {
951 LOperand* value() { return inputs_[0]; }
952 LOperand* temp() { return temps_[0]; }
954 DECLARE_CONCRETE_INSTRUCTION(CheckMaps, "check-maps")
955 DECLARE_HYDROGEN_ACCESSOR(CheckMaps)
959 class LCheckNonSmi V8_FINAL : public LTemplateInstruction<0, 1, 0> {
961 explicit LCheckNonSmi(LOperand* value) {
965 LOperand* value() { return inputs_[0]; }
967 DECLARE_CONCRETE_INSTRUCTION(CheckNonSmi, "check-non-smi")
968 DECLARE_HYDROGEN_ACCESSOR(CheckHeapObject)
972 class LCheckSmi V8_FINAL : public LTemplateInstruction<1, 1, 0> {
974 explicit LCheckSmi(LOperand* value) {
978 LOperand* value() { return inputs_[0]; }
980 DECLARE_CONCRETE_INSTRUCTION(CheckSmi, "check-smi")
984 class LCheckValue V8_FINAL : public LTemplateInstruction<0, 1, 0> {
986 explicit LCheckValue(LOperand* value) {
990 LOperand* value() { return inputs_[0]; }
992 DECLARE_CONCRETE_INSTRUCTION(CheckValue, "check-value")
993 DECLARE_HYDROGEN_ACCESSOR(CheckValue)
997 class LClampDToUint8 V8_FINAL : public LTemplateInstruction<1, 1, 0> {
999 explicit LClampDToUint8(LOperand* unclamped) {
1000 inputs_[0] = unclamped;
1003 LOperand* unclamped() { return inputs_[0]; }
1005 DECLARE_CONCRETE_INSTRUCTION(ClampDToUint8, "clamp-d-to-uint8")
1009 class LClampIToUint8 V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1011 explicit LClampIToUint8(LOperand* unclamped) {
1012 inputs_[0] = unclamped;
1015 LOperand* unclamped() { return inputs_[0]; }
1017 DECLARE_CONCRETE_INSTRUCTION(ClampIToUint8, "clamp-i-to-uint8")
1021 class LClampTToUint8 V8_FINAL : public LTemplateInstruction<1, 1, 2> {
1023 LClampTToUint8(LOperand* unclamped, LOperand* temp1, LOperand* temp2) {
1024 inputs_[0] = unclamped;
1029 LOperand* unclamped() { return inputs_[0]; }
1030 LOperand* temp1() { return temps_[0]; }
1031 LOperand* temp2() { return temps_[1]; }
1033 DECLARE_CONCRETE_INSTRUCTION(ClampTToUint8, "clamp-t-to-uint8")
1037 class LDoubleBits V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1039 explicit LDoubleBits(LOperand* value) {
1043 LOperand* value() { return inputs_[0]; }
1045 DECLARE_CONCRETE_INSTRUCTION(DoubleBits, "double-bits")
1046 DECLARE_HYDROGEN_ACCESSOR(DoubleBits)
1050 class LConstructDouble V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1052 LConstructDouble(LOperand* hi, LOperand* lo) {
1057 LOperand* hi() { return inputs_[0]; }
1058 LOperand* lo() { return inputs_[1]; }
1060 DECLARE_CONCRETE_INSTRUCTION(ConstructDouble, "construct-double")
1064 class LClassOfTestAndBranch V8_FINAL : public LControlInstruction<1, 2> {
1066 LClassOfTestAndBranch(LOperand* value, LOperand* temp1, LOperand* temp2) {
1072 LOperand* value() { return inputs_[0]; }
1073 LOperand* temp1() { return temps_[0]; }
1074 LOperand* temp2() { return temps_[1]; }
1076 DECLARE_CONCRETE_INSTRUCTION(ClassOfTestAndBranch,
1077 "class-of-test-and-branch")
1078 DECLARE_HYDROGEN_ACCESSOR(ClassOfTestAndBranch)
1080 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1084 class LCmpHoleAndBranchD V8_FINAL : public LControlInstruction<1, 1> {
1086 explicit LCmpHoleAndBranchD(LOperand* object, LOperand* temp) {
1087 inputs_[0] = object;
1091 LOperand* object() { return inputs_[0]; }
1092 LOperand* temp() { return temps_[0]; }
1094 DECLARE_CONCRETE_INSTRUCTION(CmpHoleAndBranchD, "cmp-hole-and-branch-d")
1095 DECLARE_HYDROGEN_ACCESSOR(CompareHoleAndBranch)
1099 class LCmpHoleAndBranchT V8_FINAL : public LControlInstruction<1, 0> {
1101 explicit LCmpHoleAndBranchT(LOperand* object) {
1102 inputs_[0] = object;
1105 LOperand* object() { return inputs_[0]; }
1107 DECLARE_CONCRETE_INSTRUCTION(CmpHoleAndBranchT, "cmp-hole-and-branch-t")
1108 DECLARE_HYDROGEN_ACCESSOR(CompareHoleAndBranch)
1112 class LCmpMapAndBranch V8_FINAL : public LControlInstruction<1, 1> {
1114 LCmpMapAndBranch(LOperand* value, LOperand* temp) {
1119 LOperand* value() { return inputs_[0]; }
1120 LOperand* temp() { return temps_[0]; }
1122 DECLARE_CONCRETE_INSTRUCTION(CmpMapAndBranch, "cmp-map-and-branch")
1123 DECLARE_HYDROGEN_ACCESSOR(CompareMap)
1125 Handle<Map> map() const { return hydrogen()->map().handle(); }
1129 class LCmpObjectEqAndBranch V8_FINAL : public LControlInstruction<2, 0> {
1131 LCmpObjectEqAndBranch(LOperand* left, LOperand* right) {
1136 LOperand* left() { return inputs_[0]; }
1137 LOperand* right() { return inputs_[1]; }
1139 DECLARE_CONCRETE_INSTRUCTION(CmpObjectEqAndBranch, "cmp-object-eq-and-branch")
1140 DECLARE_HYDROGEN_ACCESSOR(CompareObjectEqAndBranch)
1144 class LCmpT V8_FINAL : public LTemplateInstruction<1, 3, 0> {
1146 LCmpT(LOperand* context, LOperand* left, LOperand* right) {
1147 inputs_[0] = context;
1152 LOperand* context() { return inputs_[0]; }
1153 LOperand* left() { return inputs_[1]; }
1154 LOperand* right() { return inputs_[2]; }
1156 DECLARE_CONCRETE_INSTRUCTION(CmpT, "cmp-t")
1157 DECLARE_HYDROGEN_ACCESSOR(CompareGeneric)
1159 Token::Value op() const { return hydrogen()->token(); }
1163 class LCompareMinusZeroAndBranch V8_FINAL : public LControlInstruction<1, 1> {
1165 LCompareMinusZeroAndBranch(LOperand* value, LOperand* temp) {
1170 LOperand* value() { return inputs_[0]; }
1171 LOperand* temp() { return temps_[0]; }
1173 DECLARE_CONCRETE_INSTRUCTION(CompareMinusZeroAndBranch,
1174 "cmp-minus-zero-and-branch")
1175 DECLARE_HYDROGEN_ACCESSOR(CompareMinusZeroAndBranch)
1179 class LCompareNumericAndBranch V8_FINAL : public LControlInstruction<2, 0> {
1181 LCompareNumericAndBranch(LOperand* left, LOperand* right) {
1186 LOperand* left() { return inputs_[0]; }
1187 LOperand* right() { return inputs_[1]; }
1189 DECLARE_CONCRETE_INSTRUCTION(CompareNumericAndBranch,
1190 "compare-numeric-and-branch")
1191 DECLARE_HYDROGEN_ACCESSOR(CompareNumericAndBranch)
1193 Token::Value op() const { return hydrogen()->token(); }
1194 bool is_double() const {
1195 return hydrogen()->representation().IsDouble();
1198 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1202 class LConstantD V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1204 DECLARE_CONCRETE_INSTRUCTION(ConstantD, "constant-d")
1205 DECLARE_HYDROGEN_ACCESSOR(Constant)
1207 double value() const { return hydrogen()->DoubleValue(); }
1211 class LConstantE V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1213 DECLARE_CONCRETE_INSTRUCTION(ConstantE, "constant-e")
1214 DECLARE_HYDROGEN_ACCESSOR(Constant)
1216 ExternalReference value() const {
1217 return hydrogen()->ExternalReferenceValue();
1222 class LConstantI V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1224 DECLARE_CONCRETE_INSTRUCTION(ConstantI, "constant-i")
1225 DECLARE_HYDROGEN_ACCESSOR(Constant)
1227 int32_t value() const { return hydrogen()->Integer32Value(); }
1231 class LConstantS V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1233 DECLARE_CONCRETE_INSTRUCTION(ConstantS, "constant-s")
1234 DECLARE_HYDROGEN_ACCESSOR(Constant)
1236 Smi* value() const { return Smi::FromInt(hydrogen()->Integer32Value()); }
1240 class LConstantT V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1242 DECLARE_CONCRETE_INSTRUCTION(ConstantT, "constant-t")
1243 DECLARE_HYDROGEN_ACCESSOR(Constant)
1245 Handle<Object> value(Isolate* isolate) const {
1246 return hydrogen()->handle(isolate);
1251 class LContext V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1253 DECLARE_CONCRETE_INSTRUCTION(Context, "context")
1254 DECLARE_HYDROGEN_ACCESSOR(Context)
1258 class LDateField V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1260 LDateField(LOperand* date, Smi* index) : index_(index) {
1264 LOperand* date() { return inputs_[0]; }
1265 Smi* index() const { return index_; }
1267 DECLARE_CONCRETE_INSTRUCTION(DateField, "date-field")
1268 DECLARE_HYDROGEN_ACCESSOR(DateField)
1275 class LDebugBreak V8_FINAL : public LTemplateInstruction<0, 0, 0> {
1277 DECLARE_CONCRETE_INSTRUCTION(DebugBreak, "break")
1281 class LDeclareGlobals V8_FINAL : public LTemplateInstruction<0, 1, 0> {
1283 explicit LDeclareGlobals(LOperand* context) {
1284 inputs_[0] = context;
1287 LOperand* context() { return inputs_[0]; }
1289 DECLARE_CONCRETE_INSTRUCTION(DeclareGlobals, "declare-globals")
1290 DECLARE_HYDROGEN_ACCESSOR(DeclareGlobals)
1294 class LDeoptimize V8_FINAL : public LTemplateInstruction<0, 0, 0> {
1296 virtual bool IsControl() const V8_OVERRIDE { return true; }
1297 DECLARE_CONCRETE_INSTRUCTION(Deoptimize, "deoptimize")
1298 DECLARE_HYDROGEN_ACCESSOR(Deoptimize)
1302 class LDivByPowerOf2I V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1304 LDivByPowerOf2I(LOperand* dividend, int32_t divisor) {
1305 inputs_[0] = dividend;
1309 LOperand* dividend() { return inputs_[0]; }
1310 int32_t divisor() const { return divisor_; }
1312 DECLARE_CONCRETE_INSTRUCTION(DivByPowerOf2I, "div-by-power-of-2-i")
1313 DECLARE_HYDROGEN_ACCESSOR(Div)
1320 class LDivByConstI V8_FINAL : public LTemplateInstruction<1, 1, 1> {
1322 LDivByConstI(LOperand* dividend, int32_t divisor, LOperand* temp) {
1323 inputs_[0] = dividend;
1328 LOperand* dividend() { return inputs_[0]; }
1329 int32_t divisor() const { return divisor_; }
1330 LOperand* temp() { return temps_[0]; }
1332 DECLARE_CONCRETE_INSTRUCTION(DivByConstI, "div-by-const-i")
1333 DECLARE_HYDROGEN_ACCESSOR(Div)
1340 class LDivI V8_FINAL : public LTemplateInstruction<1, 2, 1> {
1342 LDivI(LOperand* dividend, LOperand* divisor, LOperand* temp) {
1343 inputs_[0] = dividend;
1344 inputs_[1] = divisor;
1348 LOperand* dividend() { return inputs_[0]; }
1349 LOperand* divisor() { return inputs_[1]; }
1350 LOperand* temp() { return temps_[0]; }
1352 DECLARE_CONCRETE_INSTRUCTION(DivI, "div-i")
1353 DECLARE_HYDROGEN_ACCESSOR(BinaryOperation)
1357 class LDoubleToIntOrSmi V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1359 explicit LDoubleToIntOrSmi(LOperand* value) {
1363 LOperand* value() { return inputs_[0]; }
1365 DECLARE_CONCRETE_INSTRUCTION(DoubleToIntOrSmi, "double-to-int-or-smi")
1366 DECLARE_HYDROGEN_ACCESSOR(UnaryOperation)
1368 bool tag_result() { return hydrogen()->representation().IsSmi(); }
1372 class LForInCacheArray V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1374 explicit LForInCacheArray(LOperand* map) {
1378 LOperand* map() { return inputs_[0]; }
1380 DECLARE_CONCRETE_INSTRUCTION(ForInCacheArray, "for-in-cache-array")
1383 return HForInCacheArray::cast(this->hydrogen_value())->idx();
1388 class LForInPrepareMap V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1390 LForInPrepareMap(LOperand* context, LOperand* object) {
1391 inputs_[0] = context;
1392 inputs_[1] = object;
1395 LOperand* context() { return inputs_[0]; }
1396 LOperand* object() { return inputs_[1]; }
1398 DECLARE_CONCRETE_INSTRUCTION(ForInPrepareMap, "for-in-prepare-map")
1402 class LGetCachedArrayIndex V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1404 explicit LGetCachedArrayIndex(LOperand* value) {
1408 LOperand* value() { return inputs_[0]; }
1410 DECLARE_CONCRETE_INSTRUCTION(GetCachedArrayIndex, "get-cached-array-index")
1411 DECLARE_HYDROGEN_ACCESSOR(GetCachedArrayIndex)
1415 class LHasCachedArrayIndexAndBranch V8_FINAL
1416 : public LControlInstruction<1, 1> {
1418 LHasCachedArrayIndexAndBranch(LOperand* value, LOperand* temp) {
1423 LOperand* value() { return inputs_[0]; }
1424 LOperand* temp() { return temps_[0]; }
1426 DECLARE_CONCRETE_INSTRUCTION(HasCachedArrayIndexAndBranch,
1427 "has-cached-array-index-and-branch")
1428 DECLARE_HYDROGEN_ACCESSOR(HasCachedArrayIndexAndBranch)
1430 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1434 class LHasInstanceTypeAndBranch V8_FINAL : public LControlInstruction<1, 1> {
1436 LHasInstanceTypeAndBranch(LOperand* value, LOperand* temp) {
1441 LOperand* value() { return inputs_[0]; }
1442 LOperand* temp() { return temps_[0]; }
1444 DECLARE_CONCRETE_INSTRUCTION(HasInstanceTypeAndBranch,
1445 "has-instance-type-and-branch")
1446 DECLARE_HYDROGEN_ACCESSOR(HasInstanceTypeAndBranch)
1448 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1452 class LInnerAllocatedObject V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1454 LInnerAllocatedObject(LOperand* base_object, LOperand* offset) {
1455 inputs_[0] = base_object;
1456 inputs_[1] = offset;
1459 LOperand* base_object() const { return inputs_[0]; }
1460 LOperand* offset() const { return inputs_[1]; }
1462 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1464 DECLARE_CONCRETE_INSTRUCTION(InnerAllocatedObject, "inner-allocated-object")
1468 class LInstanceOf V8_FINAL : public LTemplateInstruction<1, 3, 0> {
1470 LInstanceOf(LOperand* context, LOperand* left, LOperand* right) {
1471 inputs_[0] = context;
1476 LOperand* context() { return inputs_[0]; }
1477 LOperand* left() { return inputs_[1]; }
1478 LOperand* right() { return inputs_[2]; }
1480 DECLARE_CONCRETE_INSTRUCTION(InstanceOf, "instance-of")
1484 class LInstanceOfKnownGlobal V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1486 LInstanceOfKnownGlobal(LOperand* context, LOperand* value) {
1487 inputs_[0] = context;
1491 LOperand* context() { return inputs_[0]; }
1492 LOperand* value() { return inputs_[1]; }
1494 DECLARE_CONCRETE_INSTRUCTION(InstanceOfKnownGlobal,
1495 "instance-of-known-global")
1496 DECLARE_HYDROGEN_ACCESSOR(InstanceOfKnownGlobal)
1498 Handle<JSFunction> function() const { return hydrogen()->function(); }
1499 LEnvironment* GetDeferredLazyDeoptimizationEnvironment() {
1500 return lazy_deopt_env_;
1502 virtual void SetDeferredLazyDeoptimizationEnvironment(
1503 LEnvironment* env) V8_OVERRIDE {
1504 lazy_deopt_env_ = env;
1508 LEnvironment* lazy_deopt_env_;
1512 class LInteger32ToDouble V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1514 explicit LInteger32ToDouble(LOperand* value) {
1518 LOperand* value() { return inputs_[0]; }
1520 DECLARE_CONCRETE_INSTRUCTION(Integer32ToDouble, "int32-to-double")
1524 class LCallWithDescriptor V8_FINAL : public LTemplateResultInstruction<1> {
1526 LCallWithDescriptor(const InterfaceDescriptor* descriptor,
1527 const ZoneList<LOperand*>& operands,
1529 : descriptor_(descriptor),
1530 inputs_(descriptor->GetRegisterParameterCount() + 1, zone) {
1531 DCHECK(descriptor->GetRegisterParameterCount() + 1 == operands.length());
1532 inputs_.AddAll(operands, zone);
1535 LOperand* target() const { return inputs_[0]; }
1537 const InterfaceDescriptor* descriptor() { return descriptor_; }
1540 DECLARE_CONCRETE_INSTRUCTION(CallWithDescriptor, "call-with-descriptor")
1541 DECLARE_HYDROGEN_ACCESSOR(CallWithDescriptor)
1543 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1545 int arity() const { return hydrogen()->argument_count() - 1; }
1547 const InterfaceDescriptor* descriptor_;
1548 ZoneList<LOperand*> inputs_;
1550 // Iterator support.
1551 virtual int InputCount() V8_FINAL V8_OVERRIDE { return inputs_.length(); }
1552 virtual LOperand* InputAt(int i) V8_FINAL V8_OVERRIDE { return inputs_[i]; }
1554 virtual int TempCount() V8_FINAL V8_OVERRIDE { return 0; }
1555 virtual LOperand* TempAt(int i) V8_FINAL V8_OVERRIDE { return NULL; }
1559 class LInvokeFunction V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1561 LInvokeFunction(LOperand* context, LOperand* function) {
1562 inputs_[0] = context;
1563 inputs_[1] = function;
1566 LOperand* context() { return inputs_[0]; }
1567 LOperand* function() { return inputs_[1]; }
1569 DECLARE_CONCRETE_INSTRUCTION(InvokeFunction, "invoke-function")
1570 DECLARE_HYDROGEN_ACCESSOR(InvokeFunction)
1572 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1574 int arity() const { return hydrogen()->argument_count() - 1; }
1578 class LIsConstructCallAndBranch V8_FINAL : public LControlInstruction<0, 2> {
1580 LIsConstructCallAndBranch(LOperand* temp1, LOperand* temp2) {
1585 LOperand* temp1() { return temps_[0]; }
1586 LOperand* temp2() { return temps_[1]; }
1588 DECLARE_CONCRETE_INSTRUCTION(IsConstructCallAndBranch,
1589 "is-construct-call-and-branch")
1593 class LIsObjectAndBranch V8_FINAL : public LControlInstruction<1, 2> {
1595 LIsObjectAndBranch(LOperand* value, LOperand* temp1, LOperand* temp2) {
1601 LOperand* value() { return inputs_[0]; }
1602 LOperand* temp1() { return temps_[0]; }
1603 LOperand* temp2() { return temps_[1]; }
1605 DECLARE_CONCRETE_INSTRUCTION(IsObjectAndBranch, "is-object-and-branch")
1606 DECLARE_HYDROGEN_ACCESSOR(IsObjectAndBranch)
1608 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1612 class LIsStringAndBranch V8_FINAL : public LControlInstruction<1, 1> {
1614 LIsStringAndBranch(LOperand* value, LOperand* temp) {
1619 LOperand* value() { return inputs_[0]; }
1620 LOperand* temp() { return temps_[0]; }
1622 DECLARE_CONCRETE_INSTRUCTION(IsStringAndBranch, "is-string-and-branch")
1623 DECLARE_HYDROGEN_ACCESSOR(IsStringAndBranch)
1625 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1629 class LIsSmiAndBranch V8_FINAL : public LControlInstruction<1, 0> {
1631 explicit LIsSmiAndBranch(LOperand* value) {
1635 LOperand* value() { return inputs_[0]; }
1637 DECLARE_CONCRETE_INSTRUCTION(IsSmiAndBranch, "is-smi-and-branch")
1638 DECLARE_HYDROGEN_ACCESSOR(IsSmiAndBranch)
1640 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1644 class LIsUndetectableAndBranch V8_FINAL : public LControlInstruction<1, 1> {
1646 explicit LIsUndetectableAndBranch(LOperand* value, LOperand* temp) {
1651 LOperand* value() { return inputs_[0]; }
1652 LOperand* temp() { return temps_[0]; }
1654 DECLARE_CONCRETE_INSTRUCTION(IsUndetectableAndBranch,
1655 "is-undetectable-and-branch")
1656 DECLARE_HYDROGEN_ACCESSOR(IsUndetectableAndBranch)
1658 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1662 class LLoadContextSlot V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1664 explicit LLoadContextSlot(LOperand* context) {
1665 inputs_[0] = context;
1668 LOperand* context() { return inputs_[0]; }
1670 DECLARE_CONCRETE_INSTRUCTION(LoadContextSlot, "load-context-slot")
1671 DECLARE_HYDROGEN_ACCESSOR(LoadContextSlot)
1673 int slot_index() const { return hydrogen()->slot_index(); }
1675 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1679 class LLoadNamedField V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1681 explicit LLoadNamedField(LOperand* object) {
1682 inputs_[0] = object;
1685 LOperand* object() { return inputs_[0]; }
1687 DECLARE_CONCRETE_INSTRUCTION(LoadNamedField, "load-named-field")
1688 DECLARE_HYDROGEN_ACCESSOR(LoadNamedField)
1692 class LFunctionLiteral V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1694 explicit LFunctionLiteral(LOperand* context) {
1695 inputs_[0] = context;
1698 LOperand* context() { return inputs_[0]; }
1700 DECLARE_CONCRETE_INSTRUCTION(FunctionLiteral, "function-literal")
1701 DECLARE_HYDROGEN_ACCESSOR(FunctionLiteral)
1705 class LLoadFunctionPrototype V8_FINAL : public LTemplateInstruction<1, 1, 1> {
1707 LLoadFunctionPrototype(LOperand* function, LOperand* temp) {
1708 inputs_[0] = function;
1712 LOperand* function() { return inputs_[0]; }
1713 LOperand* temp() { return temps_[0]; }
1715 DECLARE_CONCRETE_INSTRUCTION(LoadFunctionPrototype, "load-function-prototype")
1716 DECLARE_HYDROGEN_ACCESSOR(LoadFunctionPrototype)
1720 class LLoadGlobalCell V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1722 DECLARE_CONCRETE_INSTRUCTION(LoadGlobalCell, "load-global-cell")
1723 DECLARE_HYDROGEN_ACCESSOR(LoadGlobalCell)
1727 class LLoadGlobalGeneric V8_FINAL : public LTemplateInstruction<1, 2, 1> {
1729 LLoadGlobalGeneric(LOperand* context, LOperand* global_object,
1731 inputs_[0] = context;
1732 inputs_[1] = global_object;
1736 LOperand* context() { return inputs_[0]; }
1737 LOperand* global_object() { return inputs_[1]; }
1738 LOperand* temp_vector() { return temps_[0]; }
1740 DECLARE_CONCRETE_INSTRUCTION(LoadGlobalGeneric, "load-global-generic")
1741 DECLARE_HYDROGEN_ACCESSOR(LoadGlobalGeneric)
1743 Handle<Object> name() const { return hydrogen()->name(); }
1744 bool for_typeof() const { return hydrogen()->for_typeof(); }
1749 class LLoadKeyed : public LTemplateInstruction<1, 2, T> {
1751 LLoadKeyed(LOperand* elements, LOperand* key) {
1752 this->inputs_[0] = elements;
1753 this->inputs_[1] = key;
1756 LOperand* elements() { return this->inputs_[0]; }
1757 LOperand* key() { return this->inputs_[1]; }
1758 ElementsKind elements_kind() const {
1759 return this->hydrogen()->elements_kind();
1761 bool is_external() const {
1762 return this->hydrogen()->is_external();
1764 bool is_fixed_typed_array() const {
1765 return hydrogen()->is_fixed_typed_array();
1767 bool is_typed_elements() const {
1768 return is_external() || is_fixed_typed_array();
1770 uint32_t base_offset() const {
1771 return this->hydrogen()->base_offset();
1773 void PrintDataTo(StringStream* stream) V8_OVERRIDE {
1774 this->elements()->PrintTo(stream);
1776 this->key()->PrintTo(stream);
1777 if (this->base_offset() != 0) {
1778 stream->Add(" + %d]", this->base_offset());
1784 DECLARE_HYDROGEN_ACCESSOR(LoadKeyed)
1788 class LLoadKeyedExternal: public LLoadKeyed<1> {
1790 LLoadKeyedExternal(LOperand* elements, LOperand* key, LOperand* temp) :
1791 LLoadKeyed<1>(elements, key) {
1795 LOperand* temp() { return temps_[0]; }
1797 DECLARE_CONCRETE_INSTRUCTION(LoadKeyedExternal, "load-keyed-external");
1801 class LLoadKeyedFixed: public LLoadKeyed<1> {
1803 LLoadKeyedFixed(LOperand* elements, LOperand* key, LOperand* temp) :
1804 LLoadKeyed<1>(elements, key) {
1808 LOperand* temp() { return temps_[0]; }
1810 DECLARE_CONCRETE_INSTRUCTION(LoadKeyedFixed, "load-keyed-fixed");
1814 class LLoadKeyedFixedDouble: public LLoadKeyed<1> {
1816 LLoadKeyedFixedDouble(LOperand* elements, LOperand* key, LOperand* temp) :
1817 LLoadKeyed<1>(elements, key) {
1821 LOperand* temp() { return temps_[0]; }
1823 DECLARE_CONCRETE_INSTRUCTION(LoadKeyedFixedDouble, "load-keyed-fixed-double");
1827 class LLoadKeyedGeneric V8_FINAL : public LTemplateInstruction<1, 3, 1> {
1829 LLoadKeyedGeneric(LOperand* context, LOperand* object, LOperand* key,
1831 inputs_[0] = context;
1832 inputs_[1] = object;
1837 LOperand* context() { return inputs_[0]; }
1838 LOperand* object() { return inputs_[1]; }
1839 LOperand* key() { return inputs_[2]; }
1840 LOperand* temp_vector() { return temps_[0]; }
1842 DECLARE_CONCRETE_INSTRUCTION(LoadKeyedGeneric, "load-keyed-generic")
1843 DECLARE_HYDROGEN_ACCESSOR(LoadKeyedGeneric)
1847 class LLoadNamedGeneric V8_FINAL : public LTemplateInstruction<1, 2, 1> {
1849 LLoadNamedGeneric(LOperand* context, LOperand* object, LOperand* vector) {
1850 inputs_[0] = context;
1851 inputs_[1] = object;
1855 LOperand* context() { return inputs_[0]; }
1856 LOperand* object() { return inputs_[1]; }
1857 LOperand* temp_vector() { return temps_[0]; }
1859 DECLARE_CONCRETE_INSTRUCTION(LoadNamedGeneric, "load-named-generic")
1860 DECLARE_HYDROGEN_ACCESSOR(LoadNamedGeneric)
1862 Handle<Object> name() const { return hydrogen()->name(); }
1866 class LLoadRoot V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1868 DECLARE_CONCRETE_INSTRUCTION(LoadRoot, "load-root")
1869 DECLARE_HYDROGEN_ACCESSOR(LoadRoot)
1871 Heap::RootListIndex index() const { return hydrogen()->index(); }
1875 class LMapEnumLength V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1877 explicit LMapEnumLength(LOperand* value) {
1881 LOperand* value() { return inputs_[0]; }
1883 DECLARE_CONCRETE_INSTRUCTION(MapEnumLength, "map-enum-length")
1888 class LUnaryMathOperation : public LTemplateInstruction<1, 1, T> {
1890 explicit LUnaryMathOperation(LOperand* value) {
1891 this->inputs_[0] = value;
1894 LOperand* value() { return this->inputs_[0]; }
1895 BuiltinFunctionId op() const { return this->hydrogen()->op(); }
1897 void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1899 DECLARE_HYDROGEN_ACCESSOR(UnaryMathOperation)
1903 class LMathAbs V8_FINAL : public LUnaryMathOperation<0> {
1905 explicit LMathAbs(LOperand* value) : LUnaryMathOperation<0>(value) {}
1907 DECLARE_CONCRETE_INSTRUCTION(MathAbs, "math-abs")
1911 class LMathAbsTagged: public LTemplateInstruction<1, 2, 3> {
1913 LMathAbsTagged(LOperand* context, LOperand* value,
1914 LOperand* temp1, LOperand* temp2, LOperand* temp3) {
1915 inputs_[0] = context;
1922 LOperand* context() { return inputs_[0]; }
1923 LOperand* value() { return inputs_[1]; }
1924 LOperand* temp1() { return temps_[0]; }
1925 LOperand* temp2() { return temps_[1]; }
1926 LOperand* temp3() { return temps_[2]; }
1928 DECLARE_CONCRETE_INSTRUCTION(MathAbsTagged, "math-abs-tagged")
1929 DECLARE_HYDROGEN_ACCESSOR(UnaryMathOperation)
1933 class LMathExp V8_FINAL : public LUnaryMathOperation<4> {
1935 LMathExp(LOperand* value,
1936 LOperand* double_temp1,
1940 : LUnaryMathOperation<4>(value) {
1941 temps_[0] = double_temp1;
1945 ExternalReference::InitializeMathExpData();
1948 LOperand* double_temp1() { return temps_[0]; }
1949 LOperand* temp1() { return temps_[1]; }
1950 LOperand* temp2() { return temps_[2]; }
1951 LOperand* temp3() { return temps_[3]; }
1953 DECLARE_CONCRETE_INSTRUCTION(MathExp, "math-exp")
1957 // Math.floor with a double result.
1958 class LMathFloorD V8_FINAL : public LUnaryMathOperation<0> {
1960 explicit LMathFloorD(LOperand* value) : LUnaryMathOperation<0>(value) { }
1961 DECLARE_CONCRETE_INSTRUCTION(MathFloorD, "math-floor-d")
1965 // Math.floor with an integer result.
1966 class LMathFloorI V8_FINAL : public LUnaryMathOperation<0> {
1968 explicit LMathFloorI(LOperand* value) : LUnaryMathOperation<0>(value) { }
1969 DECLARE_CONCRETE_INSTRUCTION(MathFloorI, "math-floor-i")
1973 class LFlooringDivByPowerOf2I V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1975 LFlooringDivByPowerOf2I(LOperand* dividend, int32_t divisor) {
1976 inputs_[0] = dividend;
1980 LOperand* dividend() { return inputs_[0]; }
1981 int32_t divisor() const { return divisor_; }
1983 DECLARE_CONCRETE_INSTRUCTION(FlooringDivByPowerOf2I,
1984 "flooring-div-by-power-of-2-i")
1985 DECLARE_HYDROGEN_ACCESSOR(MathFloorOfDiv)
1992 class LFlooringDivByConstI V8_FINAL : public LTemplateInstruction<1, 1, 2> {
1994 LFlooringDivByConstI(LOperand* dividend, int32_t divisor, LOperand* temp) {
1995 inputs_[0] = dividend;
2000 LOperand* dividend() { return inputs_[0]; }
2001 int32_t divisor() const { return divisor_; }
2002 LOperand* temp() { return temps_[0]; }
2004 DECLARE_CONCRETE_INSTRUCTION(FlooringDivByConstI, "flooring-div-by-const-i")
2005 DECLARE_HYDROGEN_ACCESSOR(MathFloorOfDiv)
2012 class LFlooringDivI V8_FINAL : public LTemplateInstruction<1, 2, 1> {
2014 LFlooringDivI(LOperand* dividend, LOperand* divisor, LOperand* temp) {
2015 inputs_[0] = dividend;
2016 inputs_[1] = divisor;
2020 LOperand* dividend() { return inputs_[0]; }
2021 LOperand* divisor() { return inputs_[1]; }
2022 LOperand* temp() { return temps_[0]; }
2024 DECLARE_CONCRETE_INSTRUCTION(FlooringDivI, "flooring-div-i")
2025 DECLARE_HYDROGEN_ACCESSOR(MathFloorOfDiv)
2029 class LMathLog V8_FINAL : public LUnaryMathOperation<0> {
2031 explicit LMathLog(LOperand* value) : LUnaryMathOperation<0>(value) { }
2032 DECLARE_CONCRETE_INSTRUCTION(MathLog, "math-log")
2036 class LMathClz32 V8_FINAL : public LUnaryMathOperation<0> {
2038 explicit LMathClz32(LOperand* value) : LUnaryMathOperation<0>(value) { }
2039 DECLARE_CONCRETE_INSTRUCTION(MathClz32, "math-clz32")
2043 class LMathMinMax V8_FINAL : public LTemplateInstruction<1, 2, 0> {
2045 LMathMinMax(LOperand* left, LOperand* right) {
2050 LOperand* left() { return inputs_[0]; }
2051 LOperand* right() { return inputs_[1]; }
2053 DECLARE_CONCRETE_INSTRUCTION(MathMinMax, "math-min-max")
2054 DECLARE_HYDROGEN_ACCESSOR(MathMinMax)
2058 class LMathPowHalf V8_FINAL : public LUnaryMathOperation<0> {
2060 explicit LMathPowHalf(LOperand* value) : LUnaryMathOperation<0>(value) { }
2061 DECLARE_CONCRETE_INSTRUCTION(MathPowHalf, "math-pow-half")
2065 // Math.round with an integer result.
2066 class LMathRoundD V8_FINAL : public LUnaryMathOperation<0> {
2068 explicit LMathRoundD(LOperand* value)
2069 : LUnaryMathOperation<0>(value) {
2072 DECLARE_CONCRETE_INSTRUCTION(MathRoundD, "math-round-d")
2076 // Math.round with an integer result.
2077 class LMathRoundI V8_FINAL : public LUnaryMathOperation<1> {
2079 LMathRoundI(LOperand* value, LOperand* temp1)
2080 : LUnaryMathOperation<1>(value) {
2084 LOperand* temp1() { return temps_[0]; }
2086 DECLARE_CONCRETE_INSTRUCTION(MathRoundI, "math-round-i")
2090 class LMathFround V8_FINAL : public LUnaryMathOperation<0> {
2092 explicit LMathFround(LOperand* value) : LUnaryMathOperation<0>(value) {}
2094 DECLARE_CONCRETE_INSTRUCTION(MathFround, "math-fround")
2098 class LMathSqrt V8_FINAL : public LUnaryMathOperation<0> {
2100 explicit LMathSqrt(LOperand* value) : LUnaryMathOperation<0>(value) { }
2101 DECLARE_CONCRETE_INSTRUCTION(MathSqrt, "math-sqrt")
2105 class LModByPowerOf2I V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2107 LModByPowerOf2I(LOperand* dividend, int32_t divisor) {
2108 inputs_[0] = dividend;
2112 LOperand* dividend() { return inputs_[0]; }
2113 int32_t divisor() const { return divisor_; }
2115 DECLARE_CONCRETE_INSTRUCTION(ModByPowerOf2I, "mod-by-power-of-2-i")
2116 DECLARE_HYDROGEN_ACCESSOR(Mod)
2123 class LModByConstI V8_FINAL : public LTemplateInstruction<1, 1, 1> {
2125 LModByConstI(LOperand* dividend, int32_t divisor, LOperand* temp) {
2126 inputs_[0] = dividend;
2131 LOperand* dividend() { return inputs_[0]; }
2132 int32_t divisor() const { return divisor_; }
2133 LOperand* temp() { return temps_[0]; }
2135 DECLARE_CONCRETE_INSTRUCTION(ModByConstI, "mod-by-const-i")
2136 DECLARE_HYDROGEN_ACCESSOR(Mod)
2143 class LModI V8_FINAL : public LTemplateInstruction<1, 2, 0> {
2145 LModI(LOperand* left, LOperand* right) {
2150 LOperand* left() { return inputs_[0]; }
2151 LOperand* right() { return inputs_[1]; }
2153 DECLARE_CONCRETE_INSTRUCTION(ModI, "mod-i")
2154 DECLARE_HYDROGEN_ACCESSOR(Mod)
2158 class LMulConstIS V8_FINAL : public LTemplateInstruction<1, 2, 0> {
2160 LMulConstIS(LOperand* left, LConstantOperand* right) {
2165 LOperand* left() { return inputs_[0]; }
2166 LConstantOperand* right() { return LConstantOperand::cast(inputs_[1]); }
2168 DECLARE_CONCRETE_INSTRUCTION(MulConstIS, "mul-const-i-s")
2169 DECLARE_HYDROGEN_ACCESSOR(Mul)
2173 class LMulI V8_FINAL : public LTemplateInstruction<1, 2, 0> {
2175 LMulI(LOperand* left, LOperand* right) {
2180 LOperand* left() { return inputs_[0]; }
2181 LOperand* right() { return inputs_[1]; }
2183 DECLARE_CONCRETE_INSTRUCTION(MulI, "mul-i")
2184 DECLARE_HYDROGEN_ACCESSOR(Mul)
2188 class LMulS V8_FINAL : public LTemplateInstruction<1, 2, 0> {
2190 LMulS(LOperand* left, LOperand* right) {
2195 LOperand* left() { return inputs_[0]; }
2196 LOperand* right() { return inputs_[1]; }
2198 DECLARE_CONCRETE_INSTRUCTION(MulI, "mul-s")
2199 DECLARE_HYDROGEN_ACCESSOR(Mul)
2203 class LNumberTagD V8_FINAL : public LTemplateInstruction<1, 1, 2> {
2205 LNumberTagD(LOperand* value, LOperand* temp1, LOperand* temp2) {
2211 LOperand* value() { return inputs_[0]; }
2212 LOperand* temp1() { return temps_[0]; }
2213 LOperand* temp2() { return temps_[1]; }
2215 DECLARE_CONCRETE_INSTRUCTION(NumberTagD, "number-tag-d")
2216 DECLARE_HYDROGEN_ACCESSOR(Change)
2220 class LNumberTagU V8_FINAL : public LTemplateInstruction<1, 1, 2> {
2222 explicit LNumberTagU(LOperand* value,
2230 LOperand* value() { return inputs_[0]; }
2231 LOperand* temp1() { return temps_[0]; }
2232 LOperand* temp2() { return temps_[1]; }
2234 DECLARE_CONCRETE_INSTRUCTION(NumberTagU, "number-tag-u")
2238 class LNumberUntagD V8_FINAL : public LTemplateInstruction<1, 1, 1> {
2240 LNumberUntagD(LOperand* value, LOperand* temp) {
2245 LOperand* value() { return inputs_[0]; }
2247 LOperand* temp() { return temps_[0]; }
2249 DECLARE_CONCRETE_INSTRUCTION(NumberUntagD, "double-untag")
2250 DECLARE_HYDROGEN_ACCESSOR(Change)
2254 class LParameter V8_FINAL : public LTemplateInstruction<1, 0, 0> {
2256 virtual bool HasInterestingComment(LCodeGen* gen) const { return false; }
2257 DECLARE_CONCRETE_INSTRUCTION(Parameter, "parameter")
2261 class LPower V8_FINAL : public LTemplateInstruction<1, 2, 0> {
2263 LPower(LOperand* left, LOperand* right) {
2268 LOperand* left() { return inputs_[0]; }
2269 LOperand* right() { return inputs_[1]; }
2271 DECLARE_CONCRETE_INSTRUCTION(Power, "power")
2272 DECLARE_HYDROGEN_ACCESSOR(Power)
2276 class LPreparePushArguments V8_FINAL : public LTemplateInstruction<0, 0, 0> {
2278 explicit LPreparePushArguments(int argc) : argc_(argc) {}
2280 inline int argc() const { return argc_; }
2282 DECLARE_CONCRETE_INSTRUCTION(PreparePushArguments, "prepare-push-arguments")
2289 class LPushArguments V8_FINAL : public LTemplateResultInstruction<0> {
2291 explicit LPushArguments(Zone* zone,
2292 int capacity = kRecommendedMaxPushedArgs)
2293 : zone_(zone), inputs_(capacity, zone) {}
2295 LOperand* argument(int i) { return inputs_[i]; }
2296 int ArgumentCount() const { return inputs_.length(); }
2298 void AddArgument(LOperand* arg) { inputs_.Add(arg, zone_); }
2300 DECLARE_CONCRETE_INSTRUCTION(PushArguments, "push-arguments")
2302 // It is better to limit the number of arguments pushed simultaneously to
2303 // avoid pressure on the register allocator.
2304 static const int kRecommendedMaxPushedArgs = 4;
2305 bool ShouldSplitPush() const {
2306 return inputs_.length() >= kRecommendedMaxPushedArgs;
2311 ZoneList<LOperand*> inputs_;
2314 // Iterator support.
2315 virtual int InputCount() V8_FINAL V8_OVERRIDE { return inputs_.length(); }
2316 virtual LOperand* InputAt(int i) V8_FINAL V8_OVERRIDE { return inputs_[i]; }
2318 virtual int TempCount() V8_FINAL V8_OVERRIDE { return 0; }
2319 virtual LOperand* TempAt(int i) V8_FINAL V8_OVERRIDE { return NULL; }
2323 class LRegExpLiteral V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2325 explicit LRegExpLiteral(LOperand* context) {
2326 inputs_[0] = context;
2329 LOperand* context() { return inputs_[0]; }
2331 DECLARE_CONCRETE_INSTRUCTION(RegExpLiteral, "regexp-literal")
2332 DECLARE_HYDROGEN_ACCESSOR(RegExpLiteral)
2336 class LReturn V8_FINAL : public LTemplateInstruction<0, 3, 0> {
2338 LReturn(LOperand* value, LOperand* context, LOperand* parameter_count) {
2340 inputs_[1] = context;
2341 inputs_[2] = parameter_count;
2344 LOperand* value() { return inputs_[0]; }
2345 LOperand* parameter_count() { return inputs_[2]; }
2347 bool has_constant_parameter_count() {
2348 return parameter_count()->IsConstantOperand();
2350 LConstantOperand* constant_parameter_count() {
2351 DCHECK(has_constant_parameter_count());
2352 return LConstantOperand::cast(parameter_count());
2355 DECLARE_CONCRETE_INSTRUCTION(Return, "return")
2359 class LSeqStringGetChar V8_FINAL : public LTemplateInstruction<1, 2, 1> {
2361 LSeqStringGetChar(LOperand* string,
2364 inputs_[0] = string;
2369 LOperand* string() { return inputs_[0]; }
2370 LOperand* index() { return inputs_[1]; }
2371 LOperand* temp() { return temps_[0]; }
2373 DECLARE_CONCRETE_INSTRUCTION(SeqStringGetChar, "seq-string-get-char")
2374 DECLARE_HYDROGEN_ACCESSOR(SeqStringGetChar)
2378 class LSeqStringSetChar V8_FINAL : public LTemplateInstruction<1, 4, 1> {
2380 LSeqStringSetChar(LOperand* context,
2385 inputs_[0] = context;
2386 inputs_[1] = string;
2392 LOperand* context() { return inputs_[0]; }
2393 LOperand* string() { return inputs_[1]; }
2394 LOperand* index() { return inputs_[2]; }
2395 LOperand* value() { return inputs_[3]; }
2396 LOperand* temp() { return temps_[0]; }
2398 DECLARE_CONCRETE_INSTRUCTION(SeqStringSetChar, "seq-string-set-char")
2399 DECLARE_HYDROGEN_ACCESSOR(SeqStringSetChar)
2403 class LSmiTag V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2405 explicit LSmiTag(LOperand* value) {
2409 LOperand* value() { return inputs_[0]; }
2411 DECLARE_CONCRETE_INSTRUCTION(SmiTag, "smi-tag")
2412 DECLARE_HYDROGEN_ACCESSOR(Change)
2416 class LSmiUntag V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2418 LSmiUntag(LOperand* value, bool needs_check)
2419 : needs_check_(needs_check) {
2423 LOperand* value() { return inputs_[0]; }
2424 bool needs_check() const { return needs_check_; }
2426 DECLARE_CONCRETE_INSTRUCTION(SmiUntag, "smi-untag")
2433 class LStackCheck V8_FINAL : public LTemplateInstruction<0, 1, 0> {
2435 explicit LStackCheck(LOperand* context) {
2436 inputs_[0] = context;
2439 LOperand* context() { return inputs_[0]; }
2441 DECLARE_CONCRETE_INSTRUCTION(StackCheck, "stack-check")
2442 DECLARE_HYDROGEN_ACCESSOR(StackCheck)
2444 Label* done_label() { return &done_label_; }
2452 class LStoreKeyed : public LTemplateInstruction<0, 3, T> {
2454 LStoreKeyed(LOperand* elements, LOperand* key, LOperand* value) {
2455 this->inputs_[0] = elements;
2456 this->inputs_[1] = key;
2457 this->inputs_[2] = value;
2460 bool is_external() const { return this->hydrogen()->is_external(); }
2461 bool is_fixed_typed_array() const {
2462 return hydrogen()->is_fixed_typed_array();
2464 bool is_typed_elements() const {
2465 return is_external() || is_fixed_typed_array();
2467 LOperand* elements() { return this->inputs_[0]; }
2468 LOperand* key() { return this->inputs_[1]; }
2469 LOperand* value() { return this->inputs_[2]; }
2470 ElementsKind elements_kind() const {
2471 return this->hydrogen()->elements_kind();
2474 bool NeedsCanonicalization() {
2475 if (hydrogen()->value()->IsAdd() || hydrogen()->value()->IsSub() ||
2476 hydrogen()->value()->IsMul() || hydrogen()->value()->IsDiv()) {
2479 return this->hydrogen()->NeedsCanonicalization();
2481 uint32_t base_offset() const { return this->hydrogen()->base_offset(); }
2483 void PrintDataTo(StringStream* stream) V8_OVERRIDE {
2484 this->elements()->PrintTo(stream);
2486 this->key()->PrintTo(stream);
2487 if (this->base_offset() != 0) {
2488 stream->Add(" + %d] <-", this->base_offset());
2490 stream->Add("] <- ");
2493 if (this->value() == NULL) {
2494 DCHECK(hydrogen()->IsConstantHoleStore() &&
2495 hydrogen()->value()->representation().IsDouble());
2496 stream->Add("<the hole(nan)>");
2498 this->value()->PrintTo(stream);
2502 DECLARE_HYDROGEN_ACCESSOR(StoreKeyed)
2506 class LStoreKeyedExternal V8_FINAL : public LStoreKeyed<1> {
2508 LStoreKeyedExternal(LOperand* elements, LOperand* key, LOperand* value,
2510 LStoreKeyed<1>(elements, key, value) {
2514 LOperand* temp() { return temps_[0]; }
2516 DECLARE_CONCRETE_INSTRUCTION(StoreKeyedExternal, "store-keyed-external")
2520 class LStoreKeyedFixed V8_FINAL : public LStoreKeyed<1> {
2522 LStoreKeyedFixed(LOperand* elements, LOperand* key, LOperand* value,
2524 LStoreKeyed<1>(elements, key, value) {
2528 LOperand* temp() { return temps_[0]; }
2530 DECLARE_CONCRETE_INSTRUCTION(StoreKeyedFixed, "store-keyed-fixed")
2534 class LStoreKeyedFixedDouble V8_FINAL : public LStoreKeyed<1> {
2536 LStoreKeyedFixedDouble(LOperand* elements, LOperand* key, LOperand* value,
2538 LStoreKeyed<1>(elements, key, value) {
2542 LOperand* temp() { return temps_[0]; }
2544 DECLARE_CONCRETE_INSTRUCTION(StoreKeyedFixedDouble,
2545 "store-keyed-fixed-double")
2549 class LStoreKeyedGeneric V8_FINAL : public LTemplateInstruction<0, 4, 0> {
2551 LStoreKeyedGeneric(LOperand* context,
2555 inputs_[0] = context;
2561 LOperand* context() { return inputs_[0]; }
2562 LOperand* object() { return inputs_[1]; }
2563 LOperand* key() { return inputs_[2]; }
2564 LOperand* value() { return inputs_[3]; }
2566 DECLARE_CONCRETE_INSTRUCTION(StoreKeyedGeneric, "store-keyed-generic")
2567 DECLARE_HYDROGEN_ACCESSOR(StoreKeyedGeneric)
2569 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
2571 StrictMode strict_mode() { return hydrogen()->strict_mode(); }
2575 class LStoreNamedField V8_FINAL : public LTemplateInstruction<0, 2, 2> {
2577 LStoreNamedField(LOperand* object, LOperand* value,
2578 LOperand* temp0, LOperand* temp1) {
2579 inputs_[0] = object;
2585 LOperand* object() { return inputs_[0]; }
2586 LOperand* value() { return inputs_[1]; }
2587 LOperand* temp0() { return temps_[0]; }
2588 LOperand* temp1() { return temps_[1]; }
2590 DECLARE_CONCRETE_INSTRUCTION(StoreNamedField, "store-named-field")
2591 DECLARE_HYDROGEN_ACCESSOR(StoreNamedField)
2593 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
2595 Representation representation() const {
2596 return hydrogen()->field_representation();
2601 class LStoreNamedGeneric V8_FINAL: public LTemplateInstruction<0, 3, 0> {
2603 LStoreNamedGeneric(LOperand* context, LOperand* object, LOperand* value) {
2604 inputs_[0] = context;
2605 inputs_[1] = object;
2609 LOperand* context() { return inputs_[0]; }
2610 LOperand* object() { return inputs_[1]; }
2611 LOperand* value() { return inputs_[2]; }
2613 DECLARE_CONCRETE_INSTRUCTION(StoreNamedGeneric, "store-named-generic")
2614 DECLARE_HYDROGEN_ACCESSOR(StoreNamedGeneric)
2616 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
2618 Handle<Object> name() const { return hydrogen()->name(); }
2619 StrictMode strict_mode() { return hydrogen()->strict_mode(); }
2623 class LStringAdd V8_FINAL : public LTemplateInstruction<1, 3, 0> {
2625 LStringAdd(LOperand* context, LOperand* left, LOperand* right) {
2626 inputs_[0] = context;
2631 LOperand* context() { return inputs_[0]; }
2632 LOperand* left() { return inputs_[1]; }
2633 LOperand* right() { return inputs_[2]; }
2635 DECLARE_CONCRETE_INSTRUCTION(StringAdd, "string-add")
2636 DECLARE_HYDROGEN_ACCESSOR(StringAdd)
2641 class LStringCharCodeAt V8_FINAL : public LTemplateInstruction<1, 3, 0> {
2643 LStringCharCodeAt(LOperand* context, LOperand* string, LOperand* index) {
2644 inputs_[0] = context;
2645 inputs_[1] = string;
2649 LOperand* context() { return inputs_[0]; }
2650 LOperand* string() { return inputs_[1]; }
2651 LOperand* index() { return inputs_[2]; }
2653 DECLARE_CONCRETE_INSTRUCTION(StringCharCodeAt, "string-char-code-at")
2654 DECLARE_HYDROGEN_ACCESSOR(StringCharCodeAt)
2658 class LStringCharFromCode V8_FINAL : public LTemplateInstruction<1, 2, 0> {
2660 LStringCharFromCode(LOperand* context, LOperand* char_code) {
2661 inputs_[0] = context;
2662 inputs_[1] = char_code;
2665 LOperand* context() { return inputs_[0]; }
2666 LOperand* char_code() { return inputs_[1]; }
2668 DECLARE_CONCRETE_INSTRUCTION(StringCharFromCode, "string-char-from-code")
2669 DECLARE_HYDROGEN_ACCESSOR(StringCharFromCode)
2673 class LStringCompareAndBranch V8_FINAL : public LControlInstruction<3, 0> {
2675 LStringCompareAndBranch(LOperand* context, LOperand* left, LOperand* right) {
2676 inputs_[0] = context;
2681 LOperand* context() { return inputs_[0]; }
2682 LOperand* left() { return inputs_[1]; }
2683 LOperand* right() { return inputs_[2]; }
2685 DECLARE_CONCRETE_INSTRUCTION(StringCompareAndBranch,
2686 "string-compare-and-branch")
2687 DECLARE_HYDROGEN_ACCESSOR(StringCompareAndBranch)
2689 Token::Value op() const { return hydrogen()->token(); }
2691 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
2695 // Truncating conversion from a tagged value to an int32.
2696 class LTaggedToI V8_FINAL : public LTemplateInstruction<1, 1, 2> {
2698 explicit LTaggedToI(LOperand* value, LOperand* temp1, LOperand* temp2) {
2704 LOperand* value() { return inputs_[0]; }
2705 LOperand* temp1() { return temps_[0]; }
2706 LOperand* temp2() { return temps_[1]; }
2708 DECLARE_CONCRETE_INSTRUCTION(TaggedToI, "tagged-to-i")
2709 DECLARE_HYDROGEN_ACCESSOR(Change)
2711 bool truncating() { return hydrogen()->CanTruncateToInt32(); }
2715 class LShiftI V8_FINAL : public LTemplateInstruction<1, 2, 0> {
2717 LShiftI(Token::Value op, LOperand* left, LOperand* right, bool can_deopt)
2718 : op_(op), can_deopt_(can_deopt) {
2723 Token::Value op() const { return op_; }
2724 LOperand* left() { return inputs_[0]; }
2725 LOperand* right() { return inputs_[1]; }
2726 bool can_deopt() const { return can_deopt_; }
2728 DECLARE_CONCRETE_INSTRUCTION(ShiftI, "shift-i")
2736 class LShiftS V8_FINAL : public LTemplateInstruction<1, 2, 1> {
2738 LShiftS(Token::Value op, LOperand* left, LOperand* right, LOperand* temp,
2739 bool can_deopt) : op_(op), can_deopt_(can_deopt) {
2745 Token::Value op() const { return op_; }
2746 LOperand* left() { return inputs_[0]; }
2747 LOperand* right() { return inputs_[1]; }
2748 LOperand* temp() { return temps_[0]; }
2749 bool can_deopt() const { return can_deopt_; }
2751 DECLARE_CONCRETE_INSTRUCTION(ShiftS, "shift-s")
2759 class LStoreCodeEntry V8_FINAL: public LTemplateInstruction<0, 2, 1> {
2761 LStoreCodeEntry(LOperand* function, LOperand* code_object,
2763 inputs_[0] = function;
2764 inputs_[1] = code_object;
2768 LOperand* function() { return inputs_[0]; }
2769 LOperand* code_object() { return inputs_[1]; }
2770 LOperand* temp() { return temps_[0]; }
2772 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
2774 DECLARE_CONCRETE_INSTRUCTION(StoreCodeEntry, "store-code-entry")
2775 DECLARE_HYDROGEN_ACCESSOR(StoreCodeEntry)
2779 class LStoreContextSlot V8_FINAL : public LTemplateInstruction<0, 2, 1> {
2781 LStoreContextSlot(LOperand* context, LOperand* value, LOperand* temp) {
2782 inputs_[0] = context;
2787 LOperand* context() { return inputs_[0]; }
2788 LOperand* value() { return inputs_[1]; }
2789 LOperand* temp() { return temps_[0]; }
2791 DECLARE_CONCRETE_INSTRUCTION(StoreContextSlot, "store-context-slot")
2792 DECLARE_HYDROGEN_ACCESSOR(StoreContextSlot)
2794 int slot_index() { return hydrogen()->slot_index(); }
2796 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
2800 class LStoreGlobalCell V8_FINAL : public LTemplateInstruction<0, 1, 2> {
2802 LStoreGlobalCell(LOperand* value, LOperand* temp1, LOperand* temp2) {
2808 LOperand* value() { return inputs_[0]; }
2809 LOperand* temp1() { return temps_[0]; }
2810 LOperand* temp2() { return temps_[1]; }
2812 DECLARE_CONCRETE_INSTRUCTION(StoreGlobalCell, "store-global-cell")
2813 DECLARE_HYDROGEN_ACCESSOR(StoreGlobalCell)
2817 class LSubI V8_FINAL : public LTemplateInstruction<1, 2, 0> {
2819 LSubI(LOperand* left, LOperand* right)
2820 : shift_(NO_SHIFT), shift_amount_(0) {
2825 LSubI(LOperand* left, LOperand* right, Shift shift, LOperand* shift_amount)
2826 : shift_(shift), shift_amount_(shift_amount) {
2831 LOperand* left() { return inputs_[0]; }
2832 LOperand* right() { return inputs_[1]; }
2834 Shift shift() const { return shift_; }
2835 LOperand* shift_amount() const { return shift_amount_; }
2837 DECLARE_CONCRETE_INSTRUCTION(SubI, "sub-i")
2838 DECLARE_HYDROGEN_ACCESSOR(Sub)
2842 LOperand* shift_amount_;
2846 class LSubS: public LTemplateInstruction<1, 2, 0> {
2848 LSubS(LOperand* left, LOperand* right) {
2853 LOperand* left() { return inputs_[0]; }
2854 LOperand* right() { return inputs_[1]; }
2856 DECLARE_CONCRETE_INSTRUCTION(SubS, "sub-s")
2857 DECLARE_HYDROGEN_ACCESSOR(Sub)
2861 class LThisFunction V8_FINAL : public LTemplateInstruction<1, 0, 0> {
2863 DECLARE_CONCRETE_INSTRUCTION(ThisFunction, "this-function")
2864 DECLARE_HYDROGEN_ACCESSOR(ThisFunction)
2868 class LToFastProperties V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2870 explicit LToFastProperties(LOperand* value) {
2874 LOperand* value() { return inputs_[0]; }
2876 DECLARE_CONCRETE_INSTRUCTION(ToFastProperties, "to-fast-properties")
2877 DECLARE_HYDROGEN_ACCESSOR(ToFastProperties)
2881 class LTransitionElementsKind V8_FINAL : public LTemplateInstruction<0, 2, 2> {
2883 LTransitionElementsKind(LOperand* object,
2887 inputs_[0] = object;
2888 inputs_[1] = context;
2893 LOperand* object() { return inputs_[0]; }
2894 LOperand* context() { return inputs_[1]; }
2895 LOperand* temp1() { return temps_[0]; }
2896 LOperand* temp2() { return temps_[1]; }
2898 DECLARE_CONCRETE_INSTRUCTION(TransitionElementsKind,
2899 "transition-elements-kind")
2900 DECLARE_HYDROGEN_ACCESSOR(TransitionElementsKind)
2902 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
2904 Handle<Map> original_map() { return hydrogen()->original_map().handle(); }
2905 Handle<Map> transitioned_map() {
2906 return hydrogen()->transitioned_map().handle();
2908 ElementsKind from_kind() const { return hydrogen()->from_kind(); }
2909 ElementsKind to_kind() const { return hydrogen()->to_kind(); }
2913 class LTrapAllocationMemento V8_FINAL : public LTemplateInstruction<0, 1, 2> {
2915 LTrapAllocationMemento(LOperand* object, LOperand* temp1, LOperand* temp2) {
2916 inputs_[0] = object;
2921 LOperand* object() { return inputs_[0]; }
2922 LOperand* temp1() { return temps_[0]; }
2923 LOperand* temp2() { return temps_[1]; }
2925 DECLARE_CONCRETE_INSTRUCTION(TrapAllocationMemento, "trap-allocation-memento")
2929 class LTruncateDoubleToIntOrSmi V8_FINAL
2930 : 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 V8_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 V8_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 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
2981 class LUint32ToDouble V8_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 V8_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 V8_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 V8_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 V8_FINAL : public LChunk {
3070 LPlatformChunk(CompilationInfo* info, HGraph* graph)
3071 : LChunk(info, graph) { }
3073 int GetNextSpillIndex();
3074 LOperand* GetNextSpillSlot(RegisterKind kind);
3078 class LChunkBuilder V8_FINAL : public LChunkBuilderBase {
3080 LChunkBuilder(CompilationInfo* info, HGraph* graph, LAllocator* allocator)
3081 : LChunkBuilderBase(graph->zone()),
3086 current_instruction_(NULL),
3087 current_block_(NULL),
3088 allocator_(allocator) { }
3090 // Build the sequence for the graph.
3091 LPlatformChunk* Build();
3093 // Declare methods that deal with the individual node types.
3094 #define DECLARE_DO(type) LInstruction* Do##type(H##type* node);
3095 HYDROGEN_CONCRETE_INSTRUCTION_LIST(DECLARE_DO)
3098 LInstruction* DoDivByPowerOf2I(HDiv* instr);
3099 LInstruction* DoDivByConstI(HDiv* instr);
3100 LInstruction* DoDivI(HBinaryOperation* instr);
3101 LInstruction* DoModByPowerOf2I(HMod* instr);
3102 LInstruction* DoModByConstI(HMod* instr);
3103 LInstruction* DoModI(HMod* instr);
3104 LInstruction* DoFlooringDivByPowerOf2I(HMathFloorOfDiv* instr);
3105 LInstruction* DoFlooringDivByConstI(HMathFloorOfDiv* instr);
3106 LInstruction* DoFlooringDivI(HMathFloorOfDiv* instr);
3108 static bool HasMagicNumberForDivision(int32_t divisor);
3118 HGraph* graph() const { return graph_; }
3119 Isolate* isolate() const { return info_->isolate(); }
3121 bool is_unused() const { return status_ == UNUSED; }
3122 bool is_building() const { return status_ == BUILDING; }
3123 bool is_done() const { return status_ == DONE; }
3124 bool is_aborted() const { return status_ == ABORTED; }
3126 int argument_count() const { return argument_count_; }
3127 CompilationInfo* info() const { return info_; }
3128 Heap* heap() const { return isolate()->heap(); }
3130 void Abort(BailoutReason reason);
3132 // Methods for getting operands for Use / Define / Temp.
3133 LUnallocated* ToUnallocated(Register reg);
3134 LUnallocated* ToUnallocated(DoubleRegister reg);
3136 // Methods for setting up define-use relationships.
3137 MUST_USE_RESULT LOperand* Use(HValue* value, LUnallocated* operand);
3138 MUST_USE_RESULT LOperand* UseFixed(HValue* value, Register fixed_register);
3139 MUST_USE_RESULT LOperand* UseFixedDouble(HValue* value,
3140 DoubleRegister fixed_register);
3142 // A value that is guaranteed to be allocated to a register.
3143 // The operand created by UseRegister is guaranteed to be live until the end
3144 // of the instruction. This means that register allocator will not reuse its
3145 // register for any other operand inside instruction.
3146 MUST_USE_RESULT LOperand* UseRegister(HValue* value);
3148 // The operand created by UseRegisterAndClobber is guaranteed to be live until
3149 // the end of the end of the instruction, and it may also be used as a scratch
3150 // register by the instruction implementation.
3152 // This behaves identically to ARM's UseTempRegister. However, it is renamed
3153 // to discourage its use in ARM64, since in most cases it is better to
3154 // allocate a temporary register for the Lithium instruction.
3155 MUST_USE_RESULT LOperand* UseRegisterAndClobber(HValue* value);
3157 // The operand created by UseRegisterAtStart is guaranteed to be live only at
3158 // instruction start. The register allocator is free to assign the same
3159 // register to some other operand used inside instruction (i.e. temporary or
3161 MUST_USE_RESULT LOperand* UseRegisterAtStart(HValue* value);
3163 // An input operand in a register or a constant operand.
3164 MUST_USE_RESULT LOperand* UseRegisterOrConstant(HValue* value);
3165 MUST_USE_RESULT LOperand* UseRegisterOrConstantAtStart(HValue* value);
3167 // A constant operand.
3168 MUST_USE_RESULT LConstantOperand* UseConstant(HValue* value);
3170 // An input operand in register, stack slot or a constant operand.
3171 // Will not be moved to a register even if one is freely available.
3172 virtual MUST_USE_RESULT LOperand* UseAny(HValue* value);
3174 // Temporary operand that must be in a register.
3175 MUST_USE_RESULT LUnallocated* TempRegister();
3177 // Temporary operand that must be in a double register.
3178 MUST_USE_RESULT LUnallocated* TempDoubleRegister();
3180 MUST_USE_RESULT LOperand* FixedTemp(Register reg);
3182 // Temporary operand that must be in a fixed double register.
3183 MUST_USE_RESULT LOperand* FixedTemp(DoubleRegister reg);
3185 // Methods for setting up define-use relationships.
3186 // Return the same instruction that they are passed.
3187 LInstruction* Define(LTemplateResultInstruction<1>* instr,
3188 LUnallocated* result);
3189 LInstruction* DefineAsRegister(LTemplateResultInstruction<1>* instr);
3190 LInstruction* DefineAsSpilled(LTemplateResultInstruction<1>* instr,
3193 LInstruction* DefineSameAsFirst(LTemplateResultInstruction<1>* instr);
3194 LInstruction* DefineFixed(LTemplateResultInstruction<1>* instr,
3196 LInstruction* DefineFixedDouble(LTemplateResultInstruction<1>* instr,
3197 DoubleRegister reg);
3199 enum CanDeoptimize { CAN_DEOPTIMIZE_EAGERLY, CANNOT_DEOPTIMIZE_EAGERLY };
3201 // By default we assume that instruction sequences generated for calls
3202 // cannot deoptimize eagerly and we do not attach environment to this
3204 LInstruction* MarkAsCall(
3205 LInstruction* instr,
3206 HInstruction* hinstr,
3207 CanDeoptimize can_deoptimize = CANNOT_DEOPTIMIZE_EAGERLY);
3209 LInstruction* AssignPointerMap(LInstruction* instr);
3210 LInstruction* AssignEnvironment(LInstruction* instr);
3212 void VisitInstruction(HInstruction* current);
3213 void AddInstruction(LInstruction* instr, HInstruction* current);
3214 void DoBasicBlock(HBasicBlock* block);
3216 int JSShiftAmountFromHConstant(HValue* constant) {
3217 return HConstant::cast(constant)->Integer32Value() & 0x1f;
3219 bool LikelyFitsImmField(HInstruction* instr, int imm) {
3220 if (instr->IsAdd() || instr->IsSub()) {
3221 return Assembler::IsImmAddSub(imm) || Assembler::IsImmAddSub(-imm);
3223 DCHECK(instr->IsBitwise());
3224 unsigned unused_n, unused_imm_s, unused_imm_r;
3225 return Assembler::IsImmLogical(imm, kWRegSizeInBits,
3226 &unused_n, &unused_imm_s, &unused_imm_r);
3230 // Indicates if a sequence of the form
3233 // can be replaced with:
3234 // add x0, x1, x9 LSL #imm
3235 // If this is not possible, the function returns NULL. Otherwise it returns a
3236 // pointer to the shift instruction that would be optimized away.
3237 HBitwiseBinaryOperation* CanTransformToShiftedOp(HValue* val,
3238 HValue** left = NULL);
3239 // Checks if all uses of the shift operation can optimize it away.
3240 bool ShiftCanBeOptimizedAway(HBitwiseBinaryOperation* shift);
3241 // Attempts to merge the binary operation and an eventual previous shift
3242 // operation into a single operation. Returns the merged instruction on
3243 // success, and NULL otherwise.
3244 LInstruction* TryDoOpWithShiftedRightOperand(HBinaryOperation* op);
3245 LInstruction* DoShiftedBinaryOp(HBinaryOperation* instr,
3247 HBitwiseBinaryOperation* shift);
3249 LInstruction* DoShift(Token::Value op, HBitwiseBinaryOperation* instr);
3250 LInstruction* DoArithmeticD(Token::Value op,
3251 HArithmeticBinaryOperation* instr);
3252 LInstruction* DoArithmeticT(Token::Value op,
3253 HBinaryOperation* instr);
3255 LPlatformChunk* chunk_;
3256 CompilationInfo* info_;
3257 HGraph* const graph_;
3259 HInstruction* current_instruction_;
3260 HBasicBlock* current_block_;
3261 LAllocator* allocator_;
3263 DISALLOW_COPY_AND_ASSIGN(LChunkBuilder);
3266 #undef DECLARE_HYDROGEN_ACCESSOR
3267 #undef DECLARE_CONCRETE_INSTRUCTION
3269 } } // namespace v8::internal
3271 #endif // V8_ARM64_LITHIUM_ARM64_H_