1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef V8_X64_LITHIUM_X64_H_
6 #define V8_X64_LITHIUM_X64_H_
8 #include "src/hydrogen.h"
9 #include "src/lithium.h"
10 #include "src/lithium-allocator.h"
11 #include "src/safepoint-table.h"
12 #include "src/utils.h"
17 // Forward declarations.
20 #define LITHIUM_CONCRETE_INSTRUCTION_LIST(V) \
21 V(AccessArgumentsAt) \
24 V(AllocateBlockContext) \
26 V(ArgumentsElements) \
34 V(CallWithDescriptor) \
40 V(CheckArrayBufferNotNeutered) \
41 V(CheckInstanceType) \
50 V(ClassOfTestAndBranch) \
51 V(CompareMinusZeroAndBranch) \
52 V(CompareNumericAndBranch) \
53 V(CmpObjectEqAndBranch) \
77 V(FlooringDivByConstI) \
78 V(FlooringDivByPowerOf2I) \
83 V(GetCachedArrayIndex) \
85 V(HasCachedArrayIndexAndBranch) \
86 V(HasInstanceTypeAndBranch) \
87 V(InnerAllocatedObject) \
89 V(InstanceOfKnownGlobal) \
91 V(Integer32ToDouble) \
93 V(IsConstructCallAndBranch) \
94 V(IsObjectAndBranch) \
95 V(IsStringAndBranch) \
97 V(IsUndetectableAndBranch) \
102 V(LoadFieldByIndex) \
103 V(LoadFunctionPrototype) \
104 V(LoadGlobalGeneric) \
106 V(LoadKeyedGeneric) \
108 V(LoadNamedGeneric) \
134 V(SeqStringGetChar) \
135 V(SeqStringSetChar) \
141 V(StoreContextSlot) \
142 V(StoreFrameContext) \
144 V(StoreKeyedGeneric) \
146 V(StoreNamedGeneric) \
148 V(StringCharCodeAt) \
149 V(StringCharFromCode) \
150 V(StringCompareAndBranch) \
153 V(TailCallThroughMegamorphicCache) \
155 V(ToFastProperties) \
156 V(TransitionElementsKind) \
157 V(TrapAllocationMemento) \
159 V(TypeofIsAndBranch) \
165 #define DECLARE_CONCRETE_INSTRUCTION(type, mnemonic) \
166 Opcode opcode() const final { return LInstruction::k##type; } \
167 void CompileToNative(LCodeGen* generator) final; \
168 const char* Mnemonic() const final { return mnemonic; } \
169 static L##type* cast(LInstruction* instr) { \
170 DCHECK(instr->Is##type()); \
171 return reinterpret_cast<L##type*>(instr); \
175 #define DECLARE_HYDROGEN_ACCESSOR(type) \
176 H##type* hydrogen() const { \
177 return H##type::cast(hydrogen_value()); \
181 class LInstruction : public ZoneObject {
184 : environment_(NULL),
185 hydrogen_value_(NULL),
186 bit_field_(IsCallBits::encode(false)) {
189 virtual ~LInstruction() {}
191 virtual void CompileToNative(LCodeGen* generator) = 0;
192 virtual const char* Mnemonic() const = 0;
193 virtual void PrintTo(StringStream* stream);
194 virtual void PrintDataTo(StringStream* stream);
195 virtual void PrintOutputOperandTo(StringStream* stream);
198 // Declare a unique enum value for each instruction.
199 #define DECLARE_OPCODE(type) k##type,
200 LITHIUM_CONCRETE_INSTRUCTION_LIST(DECLARE_OPCODE)
201 kNumberOfInstructions
202 #undef DECLARE_OPCODE
205 virtual Opcode opcode() const = 0;
207 // Declare non-virtual type testers for all leaf IR classes.
208 #define DECLARE_PREDICATE(type) \
209 bool Is##type() const { return opcode() == k##type; }
210 LITHIUM_CONCRETE_INSTRUCTION_LIST(DECLARE_PREDICATE)
211 #undef DECLARE_PREDICATE
213 // Declare virtual predicates for instructions that don't have
215 virtual bool IsGap() const { return false; }
217 virtual bool IsControl() const { return false; }
219 // Try deleting this instruction if possible.
220 virtual bool TryDelete() { return false; }
222 void set_environment(LEnvironment* env) { environment_ = env; }
223 LEnvironment* environment() const { return environment_; }
224 bool HasEnvironment() const { return environment_ != NULL; }
226 void set_pointer_map(LPointerMap* p) { pointer_map_.set(p); }
227 LPointerMap* pointer_map() const { return pointer_map_.get(); }
228 bool HasPointerMap() const { return pointer_map_.is_set(); }
230 void set_hydrogen_value(HValue* value) { hydrogen_value_ = value; }
231 HValue* hydrogen_value() const { return hydrogen_value_; }
233 void MarkAsCall() { bit_field_ = IsCallBits::update(bit_field_, true); }
234 bool IsCall() const { return IsCallBits::decode(bit_field_); }
236 // Interface to the register allocator and iterators.
237 bool ClobbersTemps() const { return IsCall(); }
238 bool ClobbersRegisters() const { return IsCall(); }
239 virtual bool ClobbersDoubleRegisters(Isolate* isolate) const {
243 virtual void SetDeferredLazyDeoptimizationEnvironment(LEnvironment* env) { }
245 // Interface to the register allocator and iterators.
246 bool IsMarkedAsCall() const { return IsCall(); }
248 virtual bool HasResult() const = 0;
249 virtual LOperand* result() const = 0;
251 LOperand* FirstInput() { return InputAt(0); }
252 LOperand* Output() { return HasResult() ? result() : NULL; }
254 virtual bool HasInterestingComment(LCodeGen* gen) const { return true; }
256 virtual bool MustSignExtendResult(LPlatformChunk* chunk) const {
264 virtual int InputCount() = 0;
265 virtual LOperand* InputAt(int i) = 0;
269 friend class InputIterator;
271 friend class TempIterator;
272 virtual int TempCount() = 0;
273 virtual LOperand* TempAt(int i) = 0;
275 class IsCallBits: public BitField<bool, 0, 1> {};
277 LEnvironment* environment_;
278 SetOncePointer<LPointerMap> pointer_map_;
279 HValue* hydrogen_value_;
284 // R = number of result operands (0 or 1).
286 class LTemplateResultInstruction : public LInstruction {
288 // Allow 0 or 1 output operands.
289 STATIC_ASSERT(R == 0 || R == 1);
290 bool HasResult() const final { return R != 0 && result() != NULL; }
291 void set_result(LOperand* operand) { results_[0] = operand; }
292 LOperand* result() const override { return results_[0]; }
294 bool MustSignExtendResult(LPlatformChunk* chunk) const final;
297 EmbeddedContainer<LOperand*, R> results_;
301 // R = number of result operands (0 or 1).
302 // I = number of input operands.
303 // T = number of temporary operands.
304 template<int R, int I, int T>
305 class LTemplateInstruction : public LTemplateResultInstruction<R> {
307 EmbeddedContainer<LOperand*, I> inputs_;
308 EmbeddedContainer<LOperand*, T> temps_;
312 int InputCount() final { return I; }
313 LOperand* InputAt(int i) final { return inputs_[i]; }
315 int TempCount() final { return T; }
316 LOperand* TempAt(int i) final { return temps_[i]; }
320 class LGap : public LTemplateInstruction<0, 0, 0> {
322 explicit LGap(HBasicBlock* block)
324 parallel_moves_[BEFORE] = NULL;
325 parallel_moves_[START] = NULL;
326 parallel_moves_[END] = NULL;
327 parallel_moves_[AFTER] = NULL;
330 // Can't use the DECLARE-macro here because of sub-classes.
331 bool IsGap() const final { return true; }
332 void PrintDataTo(StringStream* stream) override;
333 static LGap* cast(LInstruction* instr) {
334 DCHECK(instr->IsGap());
335 return reinterpret_cast<LGap*>(instr);
338 bool IsRedundant() const;
340 HBasicBlock* block() const { return block_; }
347 FIRST_INNER_POSITION = BEFORE,
348 LAST_INNER_POSITION = AFTER
351 LParallelMove* GetOrCreateParallelMove(InnerPosition pos,
353 if (parallel_moves_[pos] == NULL) {
354 parallel_moves_[pos] = new(zone) LParallelMove(zone);
356 return parallel_moves_[pos];
359 LParallelMove* GetParallelMove(InnerPosition pos) {
360 return parallel_moves_[pos];
364 LParallelMove* parallel_moves_[LAST_INNER_POSITION + 1];
369 class LInstructionGap final : public LGap {
371 explicit LInstructionGap(HBasicBlock* block) : LGap(block) { }
373 bool HasInterestingComment(LCodeGen* gen) const override {
374 return !IsRedundant();
377 DECLARE_CONCRETE_INSTRUCTION(InstructionGap, "gap")
381 class LGoto final : public LTemplateInstruction<0, 0, 0> {
383 explicit LGoto(HBasicBlock* block) : block_(block) { }
385 bool HasInterestingComment(LCodeGen* gen) const override;
386 DECLARE_CONCRETE_INSTRUCTION(Goto, "goto")
387 void PrintDataTo(StringStream* stream) override;
388 bool IsControl() const override { return true; }
390 int block_id() const { return block_->block_id(); }
397 class LLazyBailout final : public LTemplateInstruction<0, 0, 0> {
399 LLazyBailout() : gap_instructions_size_(0) { }
401 DECLARE_CONCRETE_INSTRUCTION(LazyBailout, "lazy-bailout")
403 void set_gap_instructions_size(int gap_instructions_size) {
404 gap_instructions_size_ = gap_instructions_size;
406 int gap_instructions_size() { return gap_instructions_size_; }
409 int gap_instructions_size_;
413 class LDummy final : public LTemplateInstruction<1, 0, 0> {
416 DECLARE_CONCRETE_INSTRUCTION(Dummy, "dummy")
420 class LDummyUse final : public LTemplateInstruction<1, 1, 0> {
422 explicit LDummyUse(LOperand* value) {
425 DECLARE_CONCRETE_INSTRUCTION(DummyUse, "dummy-use")
429 class LDeoptimize final : public LTemplateInstruction<0, 0, 0> {
431 bool IsControl() const override { return true; }
432 DECLARE_CONCRETE_INSTRUCTION(Deoptimize, "deoptimize")
433 DECLARE_HYDROGEN_ACCESSOR(Deoptimize)
437 class LLabel final : public LGap {
439 explicit LLabel(HBasicBlock* block)
440 : LGap(block), replacement_(NULL) { }
442 bool HasInterestingComment(LCodeGen* gen) const override { return false; }
443 DECLARE_CONCRETE_INSTRUCTION(Label, "label")
445 void PrintDataTo(StringStream* stream) override;
447 int block_id() const { return block()->block_id(); }
448 bool is_loop_header() const { return block()->IsLoopHeader(); }
449 bool is_osr_entry() const { return block()->is_osr_entry(); }
450 Label* label() { return &label_; }
451 LLabel* replacement() const { return replacement_; }
452 void set_replacement(LLabel* label) { replacement_ = label; }
453 bool HasReplacement() const { return replacement_ != NULL; }
457 LLabel* replacement_;
461 class LParameter final : public LTemplateInstruction<1, 0, 0> {
463 bool HasInterestingComment(LCodeGen* gen) const override { return false; }
464 DECLARE_CONCRETE_INSTRUCTION(Parameter, "parameter")
468 class LCallStub final : public LTemplateInstruction<1, 1, 0> {
470 explicit LCallStub(LOperand* context) {
471 inputs_[0] = context;
474 LOperand* context() { return inputs_[0]; }
476 DECLARE_CONCRETE_INSTRUCTION(CallStub, "call-stub")
477 DECLARE_HYDROGEN_ACCESSOR(CallStub)
481 class LTailCallThroughMegamorphicCache final
482 : public LTemplateInstruction<0, 3, 0> {
484 explicit LTailCallThroughMegamorphicCache(LOperand* context,
487 inputs_[0] = context;
488 inputs_[1] = receiver;
492 LOperand* context() { return inputs_[0]; }
493 LOperand* receiver() { return inputs_[1]; }
494 LOperand* name() { return inputs_[2]; }
496 DECLARE_CONCRETE_INSTRUCTION(TailCallThroughMegamorphicCache,
497 "tail-call-through-megamorphic-cache")
498 DECLARE_HYDROGEN_ACCESSOR(TailCallThroughMegamorphicCache)
502 class LUnknownOSRValue final : public LTemplateInstruction<1, 0, 0> {
504 bool HasInterestingComment(LCodeGen* gen) const override { return false; }
505 DECLARE_CONCRETE_INSTRUCTION(UnknownOSRValue, "unknown-osr-value")
509 template<int I, int T>
510 class LControlInstruction : public LTemplateInstruction<0, I, T> {
512 LControlInstruction() : false_label_(NULL), true_label_(NULL) { }
514 bool IsControl() const final { return true; }
516 int SuccessorCount() { return hydrogen()->SuccessorCount(); }
517 HBasicBlock* SuccessorAt(int i) { return hydrogen()->SuccessorAt(i); }
519 int TrueDestination(LChunk* chunk) {
520 return chunk->LookupDestination(true_block_id());
522 int FalseDestination(LChunk* chunk) {
523 return chunk->LookupDestination(false_block_id());
526 Label* TrueLabel(LChunk* chunk) {
527 if (true_label_ == NULL) {
528 true_label_ = chunk->GetAssemblyLabel(TrueDestination(chunk));
532 Label* FalseLabel(LChunk* chunk) {
533 if (false_label_ == NULL) {
534 false_label_ = chunk->GetAssemblyLabel(FalseDestination(chunk));
540 int true_block_id() { return SuccessorAt(0)->block_id(); }
541 int false_block_id() { return SuccessorAt(1)->block_id(); }
544 HControlInstruction* hydrogen() {
545 return HControlInstruction::cast(this->hydrogen_value());
553 class LWrapReceiver final : public LTemplateInstruction<1, 2, 0> {
555 LWrapReceiver(LOperand* receiver, LOperand* function) {
556 inputs_[0] = receiver;
557 inputs_[1] = function;
560 LOperand* receiver() { return inputs_[0]; }
561 LOperand* function() { return inputs_[1]; }
563 DECLARE_CONCRETE_INSTRUCTION(WrapReceiver, "wrap-receiver")
564 DECLARE_HYDROGEN_ACCESSOR(WrapReceiver)
568 class LApplyArguments final : public LTemplateInstruction<1, 4, 0> {
570 LApplyArguments(LOperand* function,
573 LOperand* elements) {
574 inputs_[0] = function;
575 inputs_[1] = receiver;
577 inputs_[3] = elements;
580 LOperand* function() { return inputs_[0]; }
581 LOperand* receiver() { return inputs_[1]; }
582 LOperand* length() { return inputs_[2]; }
583 LOperand* elements() { return inputs_[3]; }
585 DECLARE_CONCRETE_INSTRUCTION(ApplyArguments, "apply-arguments")
589 class LAccessArgumentsAt final : public LTemplateInstruction<1, 3, 0> {
591 LAccessArgumentsAt(LOperand* arguments, LOperand* length, LOperand* index) {
592 inputs_[0] = arguments;
597 LOperand* arguments() { return inputs_[0]; }
598 LOperand* length() { return inputs_[1]; }
599 LOperand* index() { return inputs_[2]; }
601 DECLARE_CONCRETE_INSTRUCTION(AccessArgumentsAt, "access-arguments-at")
603 void PrintDataTo(StringStream* stream) override;
607 class LArgumentsLength final : public LTemplateInstruction<1, 1, 0> {
609 explicit LArgumentsLength(LOperand* elements) {
610 inputs_[0] = elements;
613 LOperand* elements() { return inputs_[0]; }
615 DECLARE_CONCRETE_INSTRUCTION(ArgumentsLength, "arguments-length")
619 class LArgumentsElements final : public LTemplateInstruction<1, 0, 0> {
621 DECLARE_CONCRETE_INSTRUCTION(ArgumentsElements, "arguments-elements")
622 DECLARE_HYDROGEN_ACCESSOR(ArgumentsElements)
626 class LModByPowerOf2I final : public LTemplateInstruction<1, 1, 0> {
628 LModByPowerOf2I(LOperand* dividend, int32_t divisor) {
629 inputs_[0] = dividend;
633 LOperand* dividend() { return inputs_[0]; }
634 int32_t divisor() const { return divisor_; }
636 DECLARE_CONCRETE_INSTRUCTION(ModByPowerOf2I, "mod-by-power-of-2-i")
637 DECLARE_HYDROGEN_ACCESSOR(Mod)
644 class LModByConstI final : public LTemplateInstruction<1, 1, 2> {
646 LModByConstI(LOperand* dividend,
650 inputs_[0] = dividend;
656 LOperand* dividend() { return inputs_[0]; }
657 int32_t divisor() const { return divisor_; }
658 LOperand* temp1() { return temps_[0]; }
659 LOperand* temp2() { return temps_[1]; }
661 DECLARE_CONCRETE_INSTRUCTION(ModByConstI, "mod-by-const-i")
662 DECLARE_HYDROGEN_ACCESSOR(Mod)
669 class LModI final : public LTemplateInstruction<1, 2, 1> {
671 LModI(LOperand* left, LOperand* right, LOperand* temp) {
677 LOperand* left() { return inputs_[0]; }
678 LOperand* right() { return inputs_[1]; }
679 LOperand* temp() { return temps_[0]; }
681 DECLARE_CONCRETE_INSTRUCTION(ModI, "mod-i")
682 DECLARE_HYDROGEN_ACCESSOR(Mod)
686 class LDivByPowerOf2I final : public LTemplateInstruction<1, 1, 0> {
688 LDivByPowerOf2I(LOperand* dividend, int32_t divisor) {
689 inputs_[0] = dividend;
693 LOperand* dividend() { return inputs_[0]; }
694 int32_t divisor() const { return divisor_; }
696 DECLARE_CONCRETE_INSTRUCTION(DivByPowerOf2I, "div-by-power-of-2-i")
697 DECLARE_HYDROGEN_ACCESSOR(Div)
704 class LDivByConstI final : public LTemplateInstruction<1, 1, 2> {
706 LDivByConstI(LOperand* dividend,
710 inputs_[0] = dividend;
716 LOperand* dividend() { return inputs_[0]; }
717 int32_t divisor() const { return divisor_; }
718 LOperand* temp1() { return temps_[0]; }
719 LOperand* temp2() { return temps_[1]; }
721 DECLARE_CONCRETE_INSTRUCTION(DivByConstI, "div-by-const-i")
722 DECLARE_HYDROGEN_ACCESSOR(Div)
729 class LDivI final : public LTemplateInstruction<1, 2, 1> {
731 LDivI(LOperand* dividend, LOperand* divisor, LOperand* temp) {
732 inputs_[0] = dividend;
733 inputs_[1] = divisor;
737 LOperand* dividend() { return inputs_[0]; }
738 LOperand* divisor() { return inputs_[1]; }
739 LOperand* temp() { return temps_[0]; }
741 DECLARE_CONCRETE_INSTRUCTION(DivI, "div-i")
742 DECLARE_HYDROGEN_ACCESSOR(BinaryOperation)
746 class LFlooringDivByPowerOf2I final : public LTemplateInstruction<1, 1, 0> {
748 LFlooringDivByPowerOf2I(LOperand* dividend, int32_t divisor) {
749 inputs_[0] = dividend;
753 LOperand* dividend() { return inputs_[0]; }
754 int32_t divisor() const { return divisor_; }
756 DECLARE_CONCRETE_INSTRUCTION(FlooringDivByPowerOf2I,
757 "flooring-div-by-power-of-2-i")
758 DECLARE_HYDROGEN_ACCESSOR(MathFloorOfDiv)
765 class LFlooringDivByConstI final : public LTemplateInstruction<1, 1, 3> {
767 LFlooringDivByConstI(LOperand* dividend,
772 inputs_[0] = dividend;
779 LOperand* dividend() { return inputs_[0]; }
780 int32_t divisor() const { return divisor_; }
781 LOperand* temp1() { return temps_[0]; }
782 LOperand* temp2() { return temps_[1]; }
783 LOperand* temp3() { return temps_[2]; }
785 DECLARE_CONCRETE_INSTRUCTION(FlooringDivByConstI, "flooring-div-by-const-i")
786 DECLARE_HYDROGEN_ACCESSOR(MathFloorOfDiv)
793 class LFlooringDivI final : public LTemplateInstruction<1, 2, 1> {
795 LFlooringDivI(LOperand* dividend, LOperand* divisor, LOperand* temp) {
796 inputs_[0] = dividend;
797 inputs_[1] = divisor;
801 LOperand* dividend() { return inputs_[0]; }
802 LOperand* divisor() { return inputs_[1]; }
803 LOperand* temp() { return temps_[0]; }
805 DECLARE_CONCRETE_INSTRUCTION(FlooringDivI, "flooring-div-i")
806 DECLARE_HYDROGEN_ACCESSOR(MathFloorOfDiv)
810 class LMulI final : public LTemplateInstruction<1, 2, 0> {
812 LMulI(LOperand* left, LOperand* right) {
817 LOperand* left() { return inputs_[0]; }
818 LOperand* right() { return inputs_[1]; }
820 DECLARE_CONCRETE_INSTRUCTION(MulI, "mul-i")
821 DECLARE_HYDROGEN_ACCESSOR(Mul)
825 class LCompareNumericAndBranch final : public LControlInstruction<2, 0> {
827 LCompareNumericAndBranch(LOperand* left, LOperand* right) {
832 LOperand* left() { return inputs_[0]; }
833 LOperand* right() { return inputs_[1]; }
835 DECLARE_CONCRETE_INSTRUCTION(CompareNumericAndBranch,
836 "compare-numeric-and-branch")
837 DECLARE_HYDROGEN_ACCESSOR(CompareNumericAndBranch)
839 Token::Value op() const { return hydrogen()->token(); }
840 bool is_double() const {
841 return hydrogen()->representation().IsDouble();
844 void PrintDataTo(StringStream* stream) override;
848 class LMathFloor final : public LTemplateInstruction<1, 1, 0> {
850 explicit LMathFloor(LOperand* value) {
854 LOperand* value() { return inputs_[0]; }
856 DECLARE_CONCRETE_INSTRUCTION(MathFloor, "math-floor")
857 DECLARE_HYDROGEN_ACCESSOR(UnaryMathOperation)
861 class LMathRound final : public LTemplateInstruction<1, 1, 1> {
863 LMathRound(LOperand* value, LOperand* temp) {
868 LOperand* value() { return inputs_[0]; }
869 LOperand* temp() { return temps_[0]; }
871 DECLARE_CONCRETE_INSTRUCTION(MathRound, "math-round")
872 DECLARE_HYDROGEN_ACCESSOR(UnaryMathOperation)
876 class LMathFround final : public LTemplateInstruction<1, 1, 0> {
878 explicit LMathFround(LOperand* value) { inputs_[0] = value; }
880 LOperand* value() { return inputs_[0]; }
882 DECLARE_CONCRETE_INSTRUCTION(MathFround, "math-fround")
886 class LMathAbs final : public LTemplateInstruction<1, 2, 0> {
888 explicit LMathAbs(LOperand* context, LOperand* value) {
889 inputs_[1] = context;
893 LOperand* context() { return inputs_[1]; }
894 LOperand* value() { return inputs_[0]; }
896 DECLARE_CONCRETE_INSTRUCTION(MathAbs, "math-abs")
897 DECLARE_HYDROGEN_ACCESSOR(UnaryMathOperation)
901 class LMathLog final : public LTemplateInstruction<1, 1, 0> {
903 explicit LMathLog(LOperand* value) {
907 LOperand* value() { return inputs_[0]; }
909 DECLARE_CONCRETE_INSTRUCTION(MathLog, "math-log")
913 class LMathClz32 final : public LTemplateInstruction<1, 1, 0> {
915 explicit LMathClz32(LOperand* value) {
919 LOperand* value() { return inputs_[0]; }
921 DECLARE_CONCRETE_INSTRUCTION(MathClz32, "math-clz32")
925 class LMathExp final : public LTemplateInstruction<1, 1, 2> {
927 LMathExp(LOperand* value, LOperand* temp1, LOperand* temp2) {
931 ExternalReference::InitializeMathExpData();
934 LOperand* value() { return inputs_[0]; }
935 LOperand* temp1() { return temps_[0]; }
936 LOperand* temp2() { return temps_[1]; }
938 DECLARE_CONCRETE_INSTRUCTION(MathExp, "math-exp")
942 class LMathSqrt final : public LTemplateInstruction<1, 1, 0> {
944 explicit LMathSqrt(LOperand* value) {
948 LOperand* value() { return inputs_[0]; }
950 DECLARE_CONCRETE_INSTRUCTION(MathSqrt, "math-sqrt")
954 class LMathPowHalf final : public LTemplateInstruction<1, 1, 0> {
956 explicit LMathPowHalf(LOperand* value) {
960 LOperand* value() { return inputs_[0]; }
962 DECLARE_CONCRETE_INSTRUCTION(MathPowHalf, "math-pow-half")
966 class LCmpObjectEqAndBranch final : public LControlInstruction<2, 0> {
968 LCmpObjectEqAndBranch(LOperand* left, LOperand* right) {
973 LOperand* left() { return inputs_[0]; }
974 LOperand* right() { return inputs_[1]; }
976 DECLARE_CONCRETE_INSTRUCTION(CmpObjectEqAndBranch, "cmp-object-eq-and-branch")
980 class LCmpHoleAndBranch final : public LControlInstruction<1, 0> {
982 explicit LCmpHoleAndBranch(LOperand* object) {
986 LOperand* object() { return inputs_[0]; }
988 DECLARE_CONCRETE_INSTRUCTION(CmpHoleAndBranch, "cmp-hole-and-branch")
989 DECLARE_HYDROGEN_ACCESSOR(CompareHoleAndBranch)
993 class LCompareMinusZeroAndBranch final : public LControlInstruction<1, 0> {
995 explicit LCompareMinusZeroAndBranch(LOperand* value) {
999 LOperand* value() { return inputs_[0]; }
1001 DECLARE_CONCRETE_INSTRUCTION(CompareMinusZeroAndBranch,
1002 "cmp-minus-zero-and-branch")
1003 DECLARE_HYDROGEN_ACCESSOR(CompareMinusZeroAndBranch)
1007 class LIsObjectAndBranch final : public LControlInstruction<1, 0> {
1009 explicit LIsObjectAndBranch(LOperand* value) {
1013 LOperand* value() { return inputs_[0]; }
1015 DECLARE_CONCRETE_INSTRUCTION(IsObjectAndBranch, "is-object-and-branch")
1016 DECLARE_HYDROGEN_ACCESSOR(IsObjectAndBranch)
1018 void PrintDataTo(StringStream* stream) override;
1022 class LIsStringAndBranch final : public LControlInstruction<1, 1> {
1024 explicit LIsStringAndBranch(LOperand* value, LOperand* temp) {
1029 LOperand* value() { return inputs_[0]; }
1030 LOperand* temp() { return temps_[0]; }
1032 DECLARE_CONCRETE_INSTRUCTION(IsStringAndBranch, "is-string-and-branch")
1033 DECLARE_HYDROGEN_ACCESSOR(IsStringAndBranch)
1035 void PrintDataTo(StringStream* stream) override;
1039 class LIsSmiAndBranch final : public LControlInstruction<1, 0> {
1041 explicit LIsSmiAndBranch(LOperand* value) {
1045 LOperand* value() { return inputs_[0]; }
1047 DECLARE_CONCRETE_INSTRUCTION(IsSmiAndBranch, "is-smi-and-branch")
1048 DECLARE_HYDROGEN_ACCESSOR(IsSmiAndBranch)
1050 void PrintDataTo(StringStream* stream) override;
1054 class LIsUndetectableAndBranch final : public LControlInstruction<1, 1> {
1056 explicit LIsUndetectableAndBranch(LOperand* value, LOperand* temp) {
1061 LOperand* value() { return inputs_[0]; }
1062 LOperand* temp() { return temps_[0]; }
1064 DECLARE_CONCRETE_INSTRUCTION(IsUndetectableAndBranch,
1065 "is-undetectable-and-branch")
1066 DECLARE_HYDROGEN_ACCESSOR(IsUndetectableAndBranch)
1068 void PrintDataTo(StringStream* stream) override;
1072 class LStringCompareAndBranch final : public LControlInstruction<3, 0> {
1074 explicit LStringCompareAndBranch(LOperand* context,
1077 inputs_[0] = context;
1082 LOperand* context() { return inputs_[0]; }
1083 LOperand* left() { return inputs_[1]; }
1084 LOperand* right() { return inputs_[2]; }
1086 DECLARE_CONCRETE_INSTRUCTION(StringCompareAndBranch,
1087 "string-compare-and-branch")
1088 DECLARE_HYDROGEN_ACCESSOR(StringCompareAndBranch)
1090 void PrintDataTo(StringStream* stream) override;
1092 Token::Value op() const { return hydrogen()->token(); }
1096 class LHasInstanceTypeAndBranch final : public LControlInstruction<1, 0> {
1098 explicit LHasInstanceTypeAndBranch(LOperand* value) {
1102 LOperand* value() { return inputs_[0]; }
1104 DECLARE_CONCRETE_INSTRUCTION(HasInstanceTypeAndBranch,
1105 "has-instance-type-and-branch")
1106 DECLARE_HYDROGEN_ACCESSOR(HasInstanceTypeAndBranch)
1108 void PrintDataTo(StringStream* stream) override;
1112 class LGetCachedArrayIndex final : public LTemplateInstruction<1, 1, 0> {
1114 explicit LGetCachedArrayIndex(LOperand* value) {
1118 LOperand* value() { return inputs_[0]; }
1120 DECLARE_CONCRETE_INSTRUCTION(GetCachedArrayIndex, "get-cached-array-index")
1121 DECLARE_HYDROGEN_ACCESSOR(GetCachedArrayIndex)
1125 class LHasCachedArrayIndexAndBranch final : public LControlInstruction<1, 0> {
1127 explicit LHasCachedArrayIndexAndBranch(LOperand* value) {
1131 LOperand* value() { return inputs_[0]; }
1133 DECLARE_CONCRETE_INSTRUCTION(HasCachedArrayIndexAndBranch,
1134 "has-cached-array-index-and-branch")
1135 DECLARE_HYDROGEN_ACCESSOR(HasCachedArrayIndexAndBranch)
1137 void PrintDataTo(StringStream* stream) override;
1141 class LClassOfTestAndBranch final : public LControlInstruction<1, 2> {
1143 LClassOfTestAndBranch(LOperand* value, LOperand* temp, LOperand* temp2) {
1149 LOperand* value() { return inputs_[0]; }
1150 LOperand* temp() { return temps_[0]; }
1151 LOperand* temp2() { return temps_[1]; }
1153 DECLARE_CONCRETE_INSTRUCTION(ClassOfTestAndBranch,
1154 "class-of-test-and-branch")
1155 DECLARE_HYDROGEN_ACCESSOR(ClassOfTestAndBranch)
1157 void PrintDataTo(StringStream* stream) override;
1161 class LCmpT final : public LTemplateInstruction<1, 3, 0> {
1163 LCmpT(LOperand* context, LOperand* left, LOperand* right) {
1164 inputs_[0] = context;
1169 LOperand* context() { return inputs_[0]; }
1170 LOperand* left() { return inputs_[1]; }
1171 LOperand* right() { return inputs_[2]; }
1173 DECLARE_CONCRETE_INSTRUCTION(CmpT, "cmp-t")
1174 DECLARE_HYDROGEN_ACCESSOR(CompareGeneric)
1176 Token::Value op() const { return hydrogen()->token(); }
1180 class LInstanceOf final : public LTemplateInstruction<1, 3, 0> {
1182 LInstanceOf(LOperand* context, LOperand* left, LOperand* right) {
1183 inputs_[0] = context;
1188 LOperand* context() { return inputs_[0]; }
1189 LOperand* left() { return inputs_[1]; }
1190 LOperand* right() { return inputs_[2]; }
1192 DECLARE_CONCRETE_INSTRUCTION(InstanceOf, "instance-of")
1196 class LInstanceOfKnownGlobal final : public LTemplateInstruction<1, 2, 1> {
1198 LInstanceOfKnownGlobal(LOperand* context, LOperand* value, LOperand* temp) {
1199 inputs_[0] = context;
1204 LOperand* context() { return inputs_[0]; }
1205 LOperand* value() { return inputs_[1]; }
1206 LOperand* temp() { return temps_[0]; }
1208 DECLARE_CONCRETE_INSTRUCTION(InstanceOfKnownGlobal,
1209 "instance-of-known-global")
1210 DECLARE_HYDROGEN_ACCESSOR(InstanceOfKnownGlobal)
1212 Handle<JSFunction> function() const { return hydrogen()->function(); }
1213 LEnvironment* GetDeferredLazyDeoptimizationEnvironment() {
1214 return lazy_deopt_env_;
1216 virtual void SetDeferredLazyDeoptimizationEnvironment(
1217 LEnvironment* env) override {
1218 lazy_deopt_env_ = env;
1222 LEnvironment* lazy_deopt_env_;
1226 class LBoundsCheck final : public LTemplateInstruction<0, 2, 0> {
1228 LBoundsCheck(LOperand* index, LOperand* length) {
1230 inputs_[1] = length;
1233 LOperand* index() { return inputs_[0]; }
1234 LOperand* length() { return inputs_[1]; }
1236 DECLARE_CONCRETE_INSTRUCTION(BoundsCheck, "bounds-check")
1237 DECLARE_HYDROGEN_ACCESSOR(BoundsCheck)
1241 class LBitI final : public LTemplateInstruction<1, 2, 0> {
1243 LBitI(LOperand* left, LOperand* right) {
1248 LOperand* left() { return inputs_[0]; }
1249 LOperand* right() { return inputs_[1]; }
1251 Token::Value op() const { return hydrogen()->op(); }
1252 bool IsInteger32() const {
1253 return hydrogen()->representation().IsInteger32();
1256 DECLARE_CONCRETE_INSTRUCTION(BitI, "bit-i")
1257 DECLARE_HYDROGEN_ACCESSOR(Bitwise)
1261 class LShiftI final : public LTemplateInstruction<1, 2, 0> {
1263 LShiftI(Token::Value op, LOperand* left, LOperand* right, bool can_deopt)
1264 : op_(op), can_deopt_(can_deopt) {
1269 Token::Value op() const { return op_; }
1270 LOperand* left() { return inputs_[0]; }
1271 LOperand* right() { return inputs_[1]; }
1272 bool can_deopt() const { return can_deopt_; }
1274 DECLARE_CONCRETE_INSTRUCTION(ShiftI, "shift-i")
1282 class LSubI final : public LTemplateInstruction<1, 2, 0> {
1284 LSubI(LOperand* left, LOperand* right) {
1289 LOperand* left() { return inputs_[0]; }
1290 LOperand* right() { return inputs_[1]; }
1292 DECLARE_CONCRETE_INSTRUCTION(SubI, "sub-i")
1293 DECLARE_HYDROGEN_ACCESSOR(Sub)
1297 class LConstantI final : public LTemplateInstruction<1, 0, 0> {
1299 DECLARE_CONCRETE_INSTRUCTION(ConstantI, "constant-i")
1300 DECLARE_HYDROGEN_ACCESSOR(Constant)
1302 int32_t value() const { return hydrogen()->Integer32Value(); }
1306 class LConstantS final : public LTemplateInstruction<1, 0, 0> {
1308 DECLARE_CONCRETE_INSTRUCTION(ConstantS, "constant-s")
1309 DECLARE_HYDROGEN_ACCESSOR(Constant)
1311 Smi* value() const { return Smi::FromInt(hydrogen()->Integer32Value()); }
1315 class LConstantD final : public LTemplateInstruction<1, 0, 0> {
1317 DECLARE_CONCRETE_INSTRUCTION(ConstantD, "constant-d")
1318 DECLARE_HYDROGEN_ACCESSOR(Constant)
1320 uint64_t bits() const { return hydrogen()->DoubleValueAsBits(); }
1324 class LConstantE final : public LTemplateInstruction<1, 0, 0> {
1326 DECLARE_CONCRETE_INSTRUCTION(ConstantE, "constant-e")
1327 DECLARE_HYDROGEN_ACCESSOR(Constant)
1329 ExternalReference value() const {
1330 return hydrogen()->ExternalReferenceValue();
1335 class LConstantT final : public LTemplateInstruction<1, 0, 0> {
1337 DECLARE_CONCRETE_INSTRUCTION(ConstantT, "constant-t")
1338 DECLARE_HYDROGEN_ACCESSOR(Constant)
1340 Handle<Object> value(Isolate* isolate) const {
1341 return hydrogen()->handle(isolate);
1346 class LBranch final : public LControlInstruction<1, 0> {
1348 explicit LBranch(LOperand* value) {
1352 LOperand* value() { return inputs_[0]; }
1354 DECLARE_CONCRETE_INSTRUCTION(Branch, "branch")
1355 DECLARE_HYDROGEN_ACCESSOR(Branch)
1357 void PrintDataTo(StringStream* stream) override;
1361 class LDebugBreak final : public LTemplateInstruction<0, 0, 0> {
1363 DECLARE_CONCRETE_INSTRUCTION(DebugBreak, "break")
1367 class LCmpMapAndBranch final : public LControlInstruction<1, 0> {
1369 explicit LCmpMapAndBranch(LOperand* value) {
1373 LOperand* value() { return inputs_[0]; }
1375 DECLARE_CONCRETE_INSTRUCTION(CmpMapAndBranch, "cmp-map-and-branch")
1376 DECLARE_HYDROGEN_ACCESSOR(CompareMap)
1378 Handle<Map> map() const { return hydrogen()->map().handle(); }
1382 class LMapEnumLength final : public LTemplateInstruction<1, 1, 0> {
1384 explicit LMapEnumLength(LOperand* value) {
1388 LOperand* value() { return inputs_[0]; }
1390 DECLARE_CONCRETE_INSTRUCTION(MapEnumLength, "map-enum-length")
1394 class LDateField final : public LTemplateInstruction<1, 1, 0> {
1396 LDateField(LOperand* date, Smi* index) : index_(index) {
1400 LOperand* date() { return inputs_[0]; }
1401 Smi* index() const { return index_; }
1403 DECLARE_CONCRETE_INSTRUCTION(DateField, "date-field")
1404 DECLARE_HYDROGEN_ACCESSOR(DateField)
1411 class LSeqStringGetChar final : public LTemplateInstruction<1, 2, 0> {
1413 LSeqStringGetChar(LOperand* string, LOperand* index) {
1414 inputs_[0] = string;
1418 LOperand* string() const { return inputs_[0]; }
1419 LOperand* index() const { return inputs_[1]; }
1421 DECLARE_CONCRETE_INSTRUCTION(SeqStringGetChar, "seq-string-get-char")
1422 DECLARE_HYDROGEN_ACCESSOR(SeqStringGetChar)
1426 class LSeqStringSetChar final : public LTemplateInstruction<1, 4, 0> {
1428 LSeqStringSetChar(LOperand* context,
1432 inputs_[0] = context;
1433 inputs_[1] = string;
1438 LOperand* string() { return inputs_[1]; }
1439 LOperand* index() { return inputs_[2]; }
1440 LOperand* value() { return inputs_[3]; }
1442 DECLARE_CONCRETE_INSTRUCTION(SeqStringSetChar, "seq-string-set-char")
1443 DECLARE_HYDROGEN_ACCESSOR(SeqStringSetChar)
1447 class LAddI final : public LTemplateInstruction<1, 2, 0> {
1449 LAddI(LOperand* left, LOperand* right) {
1454 LOperand* left() { return inputs_[0]; }
1455 LOperand* right() { return inputs_[1]; }
1457 static bool UseLea(HAdd* add) {
1458 return !add->CheckFlag(HValue::kCanOverflow) &&
1459 add->BetterLeftOperand()->UseCount() > 1;
1462 DECLARE_CONCRETE_INSTRUCTION(AddI, "add-i")
1463 DECLARE_HYDROGEN_ACCESSOR(Add)
1467 class LMathMinMax final : public LTemplateInstruction<1, 2, 0> {
1469 LMathMinMax(LOperand* left, LOperand* right) {
1474 LOperand* left() { return inputs_[0]; }
1475 LOperand* right() { return inputs_[1]; }
1477 DECLARE_CONCRETE_INSTRUCTION(MathMinMax, "math-min-max")
1478 DECLARE_HYDROGEN_ACCESSOR(MathMinMax)
1482 class LPower final : public LTemplateInstruction<1, 2, 0> {
1484 LPower(LOperand* left, LOperand* right) {
1489 LOperand* left() { return inputs_[0]; }
1490 LOperand* right() { return inputs_[1]; }
1492 DECLARE_CONCRETE_INSTRUCTION(Power, "power")
1493 DECLARE_HYDROGEN_ACCESSOR(Power)
1497 class LArithmeticD final : public LTemplateInstruction<1, 2, 0> {
1499 LArithmeticD(Token::Value op, LOperand* left, LOperand* right)
1505 Token::Value op() const { return op_; }
1506 LOperand* left() { return inputs_[0]; }
1507 LOperand* right() { return inputs_[1]; }
1509 Opcode opcode() const override { return LInstruction::kArithmeticD; }
1510 void CompileToNative(LCodeGen* generator) override;
1511 const char* Mnemonic() const override;
1518 class LArithmeticT final : public LTemplateInstruction<1, 3, 0> {
1520 LArithmeticT(Token::Value op,
1525 inputs_[0] = context;
1530 Token::Value op() const { return op_; }
1531 LOperand* context() { return inputs_[0]; }
1532 LOperand* left() { return inputs_[1]; }
1533 LOperand* right() { return inputs_[2]; }
1535 Opcode opcode() const override { return LInstruction::kArithmeticT; }
1536 void CompileToNative(LCodeGen* generator) override;
1537 const char* Mnemonic() const override;
1544 class LReturn final : public LTemplateInstruction<0, 3, 0> {
1546 explicit LReturn(LOperand* value,
1548 LOperand* parameter_count) {
1550 inputs_[1] = context;
1551 inputs_[2] = parameter_count;
1554 LOperand* value() { return inputs_[0]; }
1555 LOperand* context() { return inputs_[1]; }
1557 bool has_constant_parameter_count() {
1558 return parameter_count()->IsConstantOperand();
1560 LConstantOperand* constant_parameter_count() {
1561 DCHECK(has_constant_parameter_count());
1562 return LConstantOperand::cast(parameter_count());
1564 LOperand* parameter_count() { return inputs_[2]; }
1566 DECLARE_CONCRETE_INSTRUCTION(Return, "return")
1567 DECLARE_HYDROGEN_ACCESSOR(Return)
1571 class LLoadNamedField final : public LTemplateInstruction<1, 1, 0> {
1573 explicit LLoadNamedField(LOperand* object) {
1574 inputs_[0] = object;
1577 LOperand* object() { return inputs_[0]; }
1579 DECLARE_CONCRETE_INSTRUCTION(LoadNamedField, "load-named-field")
1580 DECLARE_HYDROGEN_ACCESSOR(LoadNamedField)
1584 class LLoadNamedGeneric final : public LTemplateInstruction<1, 2, 1> {
1586 explicit LLoadNamedGeneric(LOperand* context, LOperand* object,
1588 inputs_[0] = context;
1589 inputs_[1] = object;
1593 DECLARE_CONCRETE_INSTRUCTION(LoadNamedGeneric, "load-named-generic")
1594 DECLARE_HYDROGEN_ACCESSOR(LoadNamedGeneric)
1596 LOperand* context() { return inputs_[0]; }
1597 LOperand* object() { return inputs_[1]; }
1598 LOperand* temp_vector() { return temps_[0]; }
1600 Handle<Object> name() const { return hydrogen()->name(); }
1604 class LLoadFunctionPrototype final : public LTemplateInstruction<1, 1, 0> {
1606 explicit LLoadFunctionPrototype(LOperand* function) {
1607 inputs_[0] = function;
1610 DECLARE_CONCRETE_INSTRUCTION(LoadFunctionPrototype, "load-function-prototype")
1611 DECLARE_HYDROGEN_ACCESSOR(LoadFunctionPrototype)
1613 LOperand* function() { return inputs_[0]; }
1617 class LLoadRoot final : public LTemplateInstruction<1, 0, 0> {
1619 DECLARE_CONCRETE_INSTRUCTION(LoadRoot, "load-root")
1620 DECLARE_HYDROGEN_ACCESSOR(LoadRoot)
1622 Heap::RootListIndex index() const { return hydrogen()->index(); }
1626 inline static bool ExternalArrayOpRequiresTemp(
1627 Representation key_representation,
1628 ElementsKind elements_kind) {
1629 // Operations that require the key to be divided by two to be converted into
1630 // an index cannot fold the scale operation into a load and need an extra
1631 // temp register to do the work.
1632 return SmiValuesAre31Bits() && key_representation.IsSmi() &&
1633 (elements_kind == EXTERNAL_INT8_ELEMENTS ||
1634 elements_kind == EXTERNAL_UINT8_ELEMENTS ||
1635 elements_kind == EXTERNAL_UINT8_CLAMPED_ELEMENTS ||
1636 elements_kind == UINT8_ELEMENTS ||
1637 elements_kind == INT8_ELEMENTS ||
1638 elements_kind == UINT8_CLAMPED_ELEMENTS);
1642 class LLoadKeyed final : public LTemplateInstruction<1, 2, 0> {
1644 LLoadKeyed(LOperand* elements, LOperand* key) {
1645 inputs_[0] = elements;
1649 DECLARE_CONCRETE_INSTRUCTION(LoadKeyed, "load-keyed")
1650 DECLARE_HYDROGEN_ACCESSOR(LoadKeyed)
1652 bool is_external() const {
1653 return hydrogen()->is_external();
1655 bool is_fixed_typed_array() const {
1656 return hydrogen()->is_fixed_typed_array();
1658 bool is_typed_elements() const {
1659 return is_external() || is_fixed_typed_array();
1661 LOperand* elements() { return inputs_[0]; }
1662 LOperand* key() { return inputs_[1]; }
1663 void PrintDataTo(StringStream* stream) override;
1664 uint32_t base_offset() const { return hydrogen()->base_offset(); }
1665 ElementsKind elements_kind() const {
1666 return hydrogen()->elements_kind();
1671 class LLoadKeyedGeneric final : public LTemplateInstruction<1, 3, 1> {
1673 LLoadKeyedGeneric(LOperand* context, LOperand* obj, LOperand* key,
1675 inputs_[0] = context;
1681 DECLARE_CONCRETE_INSTRUCTION(LoadKeyedGeneric, "load-keyed-generic")
1682 DECLARE_HYDROGEN_ACCESSOR(LoadKeyedGeneric)
1684 LOperand* context() { return inputs_[0]; }
1685 LOperand* object() { return inputs_[1]; }
1686 LOperand* key() { return inputs_[2]; }
1687 LOperand* temp_vector() { return temps_[0]; }
1691 class LLoadGlobalGeneric final : public LTemplateInstruction<1, 2, 1> {
1693 explicit LLoadGlobalGeneric(LOperand* context, LOperand* global_object,
1695 inputs_[0] = context;
1696 inputs_[1] = global_object;
1700 DECLARE_CONCRETE_INSTRUCTION(LoadGlobalGeneric, "load-global-generic")
1701 DECLARE_HYDROGEN_ACCESSOR(LoadGlobalGeneric)
1703 LOperand* context() { return inputs_[0]; }
1704 LOperand* global_object() { return inputs_[1]; }
1705 LOperand* temp_vector() { return temps_[0]; }
1707 Handle<Object> name() const { return hydrogen()->name(); }
1708 bool for_typeof() const { return hydrogen()->for_typeof(); }
1712 class LLoadContextSlot final : public LTemplateInstruction<1, 1, 0> {
1714 explicit LLoadContextSlot(LOperand* context) {
1715 inputs_[0] = context;
1718 LOperand* context() { return inputs_[0]; }
1720 DECLARE_CONCRETE_INSTRUCTION(LoadContextSlot, "load-context-slot")
1721 DECLARE_HYDROGEN_ACCESSOR(LoadContextSlot)
1723 int slot_index() { return hydrogen()->slot_index(); }
1725 void PrintDataTo(StringStream* stream) override;
1729 class LStoreContextSlot final : public LTemplateInstruction<0, 2, 1> {
1731 LStoreContextSlot(LOperand* context, LOperand* value, LOperand* temp) {
1732 inputs_[0] = context;
1737 LOperand* context() { return inputs_[0]; }
1738 LOperand* value() { return inputs_[1]; }
1739 LOperand* temp() { return temps_[0]; }
1741 DECLARE_CONCRETE_INSTRUCTION(StoreContextSlot, "store-context-slot")
1742 DECLARE_HYDROGEN_ACCESSOR(StoreContextSlot)
1744 int slot_index() { return hydrogen()->slot_index(); }
1746 void PrintDataTo(StringStream* stream) override;
1750 class LPushArgument final : public LTemplateInstruction<0, 1, 0> {
1752 explicit LPushArgument(LOperand* value) {
1756 LOperand* value() { return inputs_[0]; }
1758 DECLARE_CONCRETE_INSTRUCTION(PushArgument, "push-argument")
1762 class LDrop final : public LTemplateInstruction<0, 0, 0> {
1764 explicit LDrop(int count) : count_(count) { }
1766 int count() const { return count_; }
1768 DECLARE_CONCRETE_INSTRUCTION(Drop, "drop")
1775 class LStoreCodeEntry final : public LTemplateInstruction<0, 2, 0> {
1777 LStoreCodeEntry(LOperand* function, LOperand* code_object) {
1778 inputs_[0] = function;
1779 inputs_[1] = code_object;
1782 LOperand* function() { return inputs_[0]; }
1783 LOperand* code_object() { return inputs_[1]; }
1785 void PrintDataTo(StringStream* stream) override;
1787 DECLARE_CONCRETE_INSTRUCTION(StoreCodeEntry, "store-code-entry")
1788 DECLARE_HYDROGEN_ACCESSOR(StoreCodeEntry)
1792 class LInnerAllocatedObject final : public LTemplateInstruction<1, 2, 0> {
1794 LInnerAllocatedObject(LOperand* base_object, LOperand* offset) {
1795 inputs_[0] = base_object;
1796 inputs_[1] = offset;
1799 LOperand* base_object() const { return inputs_[0]; }
1800 LOperand* offset() const { return inputs_[1]; }
1802 void PrintDataTo(StringStream* stream) override;
1804 DECLARE_CONCRETE_INSTRUCTION(InnerAllocatedObject, "inner-allocated-object")
1808 class LThisFunction final : public LTemplateInstruction<1, 0, 0> {
1810 DECLARE_CONCRETE_INSTRUCTION(ThisFunction, "this-function")
1811 DECLARE_HYDROGEN_ACCESSOR(ThisFunction)
1815 class LContext final : public LTemplateInstruction<1, 0, 0> {
1817 DECLARE_CONCRETE_INSTRUCTION(Context, "context")
1818 DECLARE_HYDROGEN_ACCESSOR(Context)
1822 class LDeclareGlobals final : public LTemplateInstruction<0, 1, 0> {
1824 explicit LDeclareGlobals(LOperand* context) {
1825 inputs_[0] = context;
1828 LOperand* context() { return inputs_[0]; }
1830 DECLARE_CONCRETE_INSTRUCTION(DeclareGlobals, "declare-globals")
1831 DECLARE_HYDROGEN_ACCESSOR(DeclareGlobals)
1835 class LCallJSFunction final : public LTemplateInstruction<1, 1, 0> {
1837 explicit LCallJSFunction(LOperand* function) {
1838 inputs_[0] = function;
1841 LOperand* function() { return inputs_[0]; }
1843 DECLARE_CONCRETE_INSTRUCTION(CallJSFunction, "call-js-function")
1844 DECLARE_HYDROGEN_ACCESSOR(CallJSFunction)
1846 void PrintDataTo(StringStream* stream) override;
1848 int arity() const { return hydrogen()->argument_count() - 1; }
1852 class LCallWithDescriptor final : public LTemplateResultInstruction<1> {
1854 LCallWithDescriptor(CallInterfaceDescriptor descriptor,
1855 const ZoneList<LOperand*>& operands, Zone* zone)
1856 : inputs_(descriptor.GetRegisterParameterCount() + 1, zone) {
1857 DCHECK(descriptor.GetRegisterParameterCount() + 1 == operands.length());
1858 inputs_.AddAll(operands, zone);
1861 LOperand* target() const { return inputs_[0]; }
1863 DECLARE_HYDROGEN_ACCESSOR(CallWithDescriptor)
1866 DECLARE_CONCRETE_INSTRUCTION(CallWithDescriptor, "call-with-descriptor")
1868 void PrintDataTo(StringStream* stream) override;
1870 int arity() const { return hydrogen()->argument_count() - 1; }
1872 ZoneList<LOperand*> inputs_;
1874 // Iterator support.
1875 int InputCount() final { return inputs_.length(); }
1876 LOperand* InputAt(int i) final { return inputs_[i]; }
1878 int TempCount() final { return 0; }
1879 LOperand* TempAt(int i) final { return NULL; }
1883 class LInvokeFunction final : public LTemplateInstruction<1, 2, 0> {
1885 LInvokeFunction(LOperand* context, LOperand* function) {
1886 inputs_[0] = context;
1887 inputs_[1] = function;
1890 LOperand* context() { return inputs_[0]; }
1891 LOperand* function() { return inputs_[1]; }
1893 DECLARE_CONCRETE_INSTRUCTION(InvokeFunction, "invoke-function")
1894 DECLARE_HYDROGEN_ACCESSOR(InvokeFunction)
1896 void PrintDataTo(StringStream* stream) override;
1898 int arity() const { return hydrogen()->argument_count() - 1; }
1902 class LCallFunction final : public LTemplateInstruction<1, 2, 2> {
1904 LCallFunction(LOperand* context, LOperand* function, LOperand* slot,
1906 inputs_[0] = context;
1907 inputs_[1] = function;
1912 DECLARE_CONCRETE_INSTRUCTION(CallFunction, "call-function")
1913 DECLARE_HYDROGEN_ACCESSOR(CallFunction)
1915 LOperand* context() { return inputs_[0]; }
1916 LOperand* function() { return inputs_[1]; }
1917 LOperand* temp_slot() { return temps_[0]; }
1918 LOperand* temp_vector() { return temps_[1]; }
1919 int arity() const { return hydrogen()->argument_count() - 1; }
1921 void PrintDataTo(StringStream* stream) override;
1925 class LCallNew final : public LTemplateInstruction<1, 2, 0> {
1927 LCallNew(LOperand* context, LOperand* constructor) {
1928 inputs_[0] = context;
1929 inputs_[1] = constructor;
1932 LOperand* context() { return inputs_[0]; }
1933 LOperand* constructor() { return inputs_[1]; }
1935 DECLARE_CONCRETE_INSTRUCTION(CallNew, "call-new")
1936 DECLARE_HYDROGEN_ACCESSOR(CallNew)
1938 void PrintDataTo(StringStream* stream) override;
1940 int arity() const { return hydrogen()->argument_count() - 1; }
1944 class LCallNewArray final : public LTemplateInstruction<1, 2, 0> {
1946 LCallNewArray(LOperand* context, LOperand* constructor) {
1947 inputs_[0] = context;
1948 inputs_[1] = constructor;
1951 LOperand* context() { return inputs_[0]; }
1952 LOperand* constructor() { return inputs_[1]; }
1954 DECLARE_CONCRETE_INSTRUCTION(CallNewArray, "call-new-array")
1955 DECLARE_HYDROGEN_ACCESSOR(CallNewArray)
1957 void PrintDataTo(StringStream* stream) override;
1959 int arity() const { return hydrogen()->argument_count() - 1; }
1963 class LCallRuntime final : public LTemplateInstruction<1, 1, 0> {
1965 explicit LCallRuntime(LOperand* context) {
1966 inputs_[0] = context;
1969 LOperand* context() { return inputs_[0]; }
1971 DECLARE_CONCRETE_INSTRUCTION(CallRuntime, "call-runtime")
1972 DECLARE_HYDROGEN_ACCESSOR(CallRuntime)
1974 bool ClobbersDoubleRegisters(Isolate* isolate) const override {
1975 return save_doubles() == kDontSaveFPRegs;
1978 const Runtime::Function* function() const { return hydrogen()->function(); }
1979 int arity() const { return hydrogen()->argument_count(); }
1980 SaveFPRegsMode save_doubles() const { return hydrogen()->save_doubles(); }
1984 class LInteger32ToDouble final : public LTemplateInstruction<1, 1, 0> {
1986 explicit LInteger32ToDouble(LOperand* value) {
1990 LOperand* value() { return inputs_[0]; }
1992 DECLARE_CONCRETE_INSTRUCTION(Integer32ToDouble, "int32-to-double")
1996 class LUint32ToDouble final : public LTemplateInstruction<1, 1, 0> {
1998 explicit LUint32ToDouble(LOperand* value) {
2002 LOperand* value() { return inputs_[0]; }
2004 DECLARE_CONCRETE_INSTRUCTION(Uint32ToDouble, "uint32-to-double")
2008 class LNumberTagI final : public LTemplateInstruction<1, 1, 2> {
2010 LNumberTagI(LOperand* value, LOperand* temp1, LOperand* temp2) {
2016 LOperand* value() { return inputs_[0]; }
2017 LOperand* temp1() { return temps_[0]; }
2018 LOperand* temp2() { return temps_[1]; }
2020 DECLARE_CONCRETE_INSTRUCTION(NumberTagI, "number-tag-i")
2024 class LNumberTagU final : public LTemplateInstruction<1, 1, 2> {
2026 LNumberTagU(LOperand* value, LOperand* temp1, LOperand* temp2) {
2032 LOperand* value() { return inputs_[0]; }
2033 LOperand* temp1() { return temps_[0]; }
2034 LOperand* temp2() { return temps_[1]; }
2036 DECLARE_CONCRETE_INSTRUCTION(NumberTagU, "number-tag-u")
2040 class LNumberTagD final : public LTemplateInstruction<1, 1, 1> {
2042 explicit LNumberTagD(LOperand* value, LOperand* temp) {
2047 LOperand* value() { return inputs_[0]; }
2048 LOperand* temp() { return temps_[0]; }
2050 DECLARE_CONCRETE_INSTRUCTION(NumberTagD, "number-tag-d")
2051 DECLARE_HYDROGEN_ACCESSOR(Change)
2055 // Sometimes truncating conversion from a tagged value to an int32.
2056 class LDoubleToI final : public LTemplateInstruction<1, 1, 0> {
2058 explicit LDoubleToI(LOperand* value) {
2062 LOperand* value() { return inputs_[0]; }
2064 DECLARE_CONCRETE_INSTRUCTION(DoubleToI, "double-to-i")
2065 DECLARE_HYDROGEN_ACCESSOR(UnaryOperation)
2067 bool truncating() { return hydrogen()->CanTruncateToInt32(); }
2071 class LDoubleToSmi final : public LTemplateInstruction<1, 1, 0> {
2073 explicit LDoubleToSmi(LOperand* value) {
2077 LOperand* value() { return inputs_[0]; }
2079 DECLARE_CONCRETE_INSTRUCTION(DoubleToSmi, "double-to-smi")
2080 DECLARE_HYDROGEN_ACCESSOR(UnaryOperation)
2084 // Truncating conversion from a tagged value to an int32.
2085 class LTaggedToI final : public LTemplateInstruction<1, 1, 1> {
2087 LTaggedToI(LOperand* value, LOperand* temp) {
2092 LOperand* value() { return inputs_[0]; }
2093 LOperand* temp() { return temps_[0]; }
2095 DECLARE_CONCRETE_INSTRUCTION(TaggedToI, "tagged-to-i")
2096 DECLARE_HYDROGEN_ACCESSOR(Change)
2098 bool truncating() { return hydrogen()->CanTruncateToInt32(); }
2102 class LSmiTag final : public LTemplateInstruction<1, 1, 0> {
2104 explicit LSmiTag(LOperand* value) {
2108 LOperand* value() { return inputs_[0]; }
2110 DECLARE_CONCRETE_INSTRUCTION(SmiTag, "smi-tag")
2111 DECLARE_HYDROGEN_ACCESSOR(Change)
2115 class LNumberUntagD final : public LTemplateInstruction<1, 1, 0> {
2117 explicit LNumberUntagD(LOperand* value) {
2121 LOperand* value() { return inputs_[0]; }
2123 DECLARE_CONCRETE_INSTRUCTION(NumberUntagD, "double-untag")
2124 DECLARE_HYDROGEN_ACCESSOR(Change);
2128 class LSmiUntag final : public LTemplateInstruction<1, 1, 0> {
2130 LSmiUntag(LOperand* value, bool needs_check)
2131 : needs_check_(needs_check) {
2135 LOperand* value() { return inputs_[0]; }
2136 bool needs_check() const { return needs_check_; }
2138 DECLARE_CONCRETE_INSTRUCTION(SmiUntag, "smi-untag")
2145 class LStoreNamedField final : public LTemplateInstruction<0, 2, 1> {
2147 LStoreNamedField(LOperand* object, LOperand* value, LOperand* temp) {
2148 inputs_[0] = object;
2153 LOperand* object() { return inputs_[0]; }
2154 LOperand* value() { return inputs_[1]; }
2155 LOperand* temp() { return temps_[0]; }
2157 DECLARE_CONCRETE_INSTRUCTION(StoreNamedField, "store-named-field")
2158 DECLARE_HYDROGEN_ACCESSOR(StoreNamedField)
2160 void PrintDataTo(StringStream* stream) override;
2162 Representation representation() const {
2163 return hydrogen()->field_representation();
2168 class LStoreNamedGeneric final : public LTemplateInstruction<0, 3, 0> {
2170 LStoreNamedGeneric(LOperand* context, LOperand* object, LOperand* value) {
2171 inputs_[0] = context;
2172 inputs_[1] = object;
2176 LOperand* context() { return inputs_[0]; }
2177 LOperand* object() { return inputs_[1]; }
2178 LOperand* value() { return inputs_[2]; }
2180 DECLARE_CONCRETE_INSTRUCTION(StoreNamedGeneric, "store-named-generic")
2181 DECLARE_HYDROGEN_ACCESSOR(StoreNamedGeneric)
2183 void PrintDataTo(StringStream* stream) override;
2185 Handle<Object> name() const { return hydrogen()->name(); }
2186 LanguageMode language_mode() { return hydrogen()->language_mode(); }
2190 class LStoreKeyed final : public LTemplateInstruction<0, 3, 0> {
2192 LStoreKeyed(LOperand* object, LOperand* key, LOperand* value) {
2193 inputs_[0] = object;
2198 bool is_external() const { return hydrogen()->is_external(); }
2199 bool is_fixed_typed_array() const {
2200 return hydrogen()->is_fixed_typed_array();
2202 bool is_typed_elements() const {
2203 return is_external() || is_fixed_typed_array();
2205 LOperand* elements() { return inputs_[0]; }
2206 LOperand* key() { return inputs_[1]; }
2207 LOperand* value() { return inputs_[2]; }
2208 ElementsKind elements_kind() const { return hydrogen()->elements_kind(); }
2210 DECLARE_CONCRETE_INSTRUCTION(StoreKeyed, "store-keyed")
2211 DECLARE_HYDROGEN_ACCESSOR(StoreKeyed)
2213 void PrintDataTo(StringStream* stream) override;
2214 bool NeedsCanonicalization() { return hydrogen()->NeedsCanonicalization(); }
2215 uint32_t base_offset() const { return hydrogen()->base_offset(); }
2219 class LStoreKeyedGeneric final : public LTemplateInstruction<0, 4, 0> {
2221 LStoreKeyedGeneric(LOperand* context,
2225 inputs_[0] = context;
2226 inputs_[1] = object;
2231 LOperand* context() { return inputs_[0]; }
2232 LOperand* object() { return inputs_[1]; }
2233 LOperand* key() { return inputs_[2]; }
2234 LOperand* value() { return inputs_[3]; }
2236 DECLARE_CONCRETE_INSTRUCTION(StoreKeyedGeneric, "store-keyed-generic")
2237 DECLARE_HYDROGEN_ACCESSOR(StoreKeyedGeneric)
2239 void PrintDataTo(StringStream* stream) override;
2241 LanguageMode language_mode() { return hydrogen()->language_mode(); }
2245 class LTransitionElementsKind final : public LTemplateInstruction<0, 2, 2> {
2247 LTransitionElementsKind(LOperand* object,
2249 LOperand* new_map_temp,
2251 inputs_[0] = object;
2252 inputs_[1] = context;
2253 temps_[0] = new_map_temp;
2257 LOperand* object() { return inputs_[0]; }
2258 LOperand* context() { return inputs_[1]; }
2259 LOperand* new_map_temp() { return temps_[0]; }
2260 LOperand* temp() { return temps_[1]; }
2262 DECLARE_CONCRETE_INSTRUCTION(TransitionElementsKind,
2263 "transition-elements-kind")
2264 DECLARE_HYDROGEN_ACCESSOR(TransitionElementsKind)
2266 void PrintDataTo(StringStream* stream) override;
2268 Handle<Map> original_map() { return hydrogen()->original_map().handle(); }
2269 Handle<Map> transitioned_map() {
2270 return hydrogen()->transitioned_map().handle();
2272 ElementsKind from_kind() { return hydrogen()->from_kind(); }
2273 ElementsKind to_kind() { return hydrogen()->to_kind(); }
2277 class LTrapAllocationMemento final : public LTemplateInstruction<0, 1, 1> {
2279 LTrapAllocationMemento(LOperand* object,
2281 inputs_[0] = object;
2285 LOperand* object() { return inputs_[0]; }
2286 LOperand* temp() { return temps_[0]; }
2288 DECLARE_CONCRETE_INSTRUCTION(TrapAllocationMemento,
2289 "trap-allocation-memento")
2293 class LStringAdd final : public LTemplateInstruction<1, 3, 0> {
2295 LStringAdd(LOperand* context, LOperand* left, LOperand* right) {
2296 inputs_[0] = context;
2301 LOperand* context() { return inputs_[0]; }
2302 LOperand* left() { return inputs_[1]; }
2303 LOperand* right() { return inputs_[2]; }
2305 DECLARE_CONCRETE_INSTRUCTION(StringAdd, "string-add")
2306 DECLARE_HYDROGEN_ACCESSOR(StringAdd)
2310 class LStringCharCodeAt final : public LTemplateInstruction<1, 3, 0> {
2312 LStringCharCodeAt(LOperand* context, LOperand* string, LOperand* index) {
2313 inputs_[0] = context;
2314 inputs_[1] = string;
2318 LOperand* context() { return inputs_[0]; }
2319 LOperand* string() { return inputs_[1]; }
2320 LOperand* index() { return inputs_[2]; }
2322 DECLARE_CONCRETE_INSTRUCTION(StringCharCodeAt, "string-char-code-at")
2323 DECLARE_HYDROGEN_ACCESSOR(StringCharCodeAt)
2327 class LStringCharFromCode final : public LTemplateInstruction<1, 2, 0> {
2329 explicit LStringCharFromCode(LOperand* context, LOperand* char_code) {
2330 inputs_[0] = context;
2331 inputs_[1] = char_code;
2334 LOperand* context() { return inputs_[0]; }
2335 LOperand* char_code() { return inputs_[1]; }
2337 DECLARE_CONCRETE_INSTRUCTION(StringCharFromCode, "string-char-from-code")
2338 DECLARE_HYDROGEN_ACCESSOR(StringCharFromCode)
2342 class LCheckValue final : public LTemplateInstruction<0, 1, 0> {
2344 explicit LCheckValue(LOperand* value) {
2348 LOperand* value() { return inputs_[0]; }
2350 DECLARE_CONCRETE_INSTRUCTION(CheckValue, "check-value")
2351 DECLARE_HYDROGEN_ACCESSOR(CheckValue)
2355 class LCheckArrayBufferNotNeutered final
2356 : public LTemplateInstruction<0, 1, 0> {
2358 explicit LCheckArrayBufferNotNeutered(LOperand* view) { inputs_[0] = view; }
2360 LOperand* view() { return inputs_[0]; }
2362 DECLARE_CONCRETE_INSTRUCTION(CheckArrayBufferNotNeutered,
2363 "check-array-buffer-not-neutered")
2364 DECLARE_HYDROGEN_ACCESSOR(CheckArrayBufferNotNeutered)
2368 class LCheckInstanceType final : public LTemplateInstruction<0, 1, 0> {
2370 explicit LCheckInstanceType(LOperand* value) {
2374 LOperand* value() { return inputs_[0]; }
2376 DECLARE_CONCRETE_INSTRUCTION(CheckInstanceType, "check-instance-type")
2377 DECLARE_HYDROGEN_ACCESSOR(CheckInstanceType)
2381 class LCheckMaps final : public LTemplateInstruction<0, 1, 0> {
2383 explicit LCheckMaps(LOperand* value = NULL) {
2387 LOperand* value() { return inputs_[0]; }
2389 DECLARE_CONCRETE_INSTRUCTION(CheckMaps, "check-maps")
2390 DECLARE_HYDROGEN_ACCESSOR(CheckMaps)
2394 class LCheckSmi final : public LTemplateInstruction<1, 1, 0> {
2396 explicit LCheckSmi(LOperand* value) {
2400 LOperand* value() { return inputs_[0]; }
2402 DECLARE_CONCRETE_INSTRUCTION(CheckSmi, "check-smi")
2406 class LClampDToUint8 final : public LTemplateInstruction<1, 1, 0> {
2408 explicit LClampDToUint8(LOperand* unclamped) {
2409 inputs_[0] = unclamped;
2412 LOperand* unclamped() { return inputs_[0]; }
2414 DECLARE_CONCRETE_INSTRUCTION(ClampDToUint8, "clamp-d-to-uint8")
2418 class LClampIToUint8 final : public LTemplateInstruction<1, 1, 0> {
2420 explicit LClampIToUint8(LOperand* unclamped) {
2421 inputs_[0] = unclamped;
2424 LOperand* unclamped() { return inputs_[0]; }
2426 DECLARE_CONCRETE_INSTRUCTION(ClampIToUint8, "clamp-i-to-uint8")
2430 class LClampTToUint8 final : public LTemplateInstruction<1, 1, 1> {
2432 LClampTToUint8(LOperand* unclamped,
2433 LOperand* temp_xmm) {
2434 inputs_[0] = unclamped;
2435 temps_[0] = temp_xmm;
2438 LOperand* unclamped() { return inputs_[0]; }
2439 LOperand* temp_xmm() { return temps_[0]; }
2441 DECLARE_CONCRETE_INSTRUCTION(ClampTToUint8, "clamp-t-to-uint8")
2445 class LCheckNonSmi final : public LTemplateInstruction<0, 1, 0> {
2447 explicit LCheckNonSmi(LOperand* value) {
2451 LOperand* value() { return inputs_[0]; }
2453 DECLARE_CONCRETE_INSTRUCTION(CheckNonSmi, "check-non-smi")
2454 DECLARE_HYDROGEN_ACCESSOR(CheckHeapObject)
2458 class LDoubleBits final : public LTemplateInstruction<1, 1, 0> {
2460 explicit LDoubleBits(LOperand* value) {
2464 LOperand* value() { return inputs_[0]; }
2466 DECLARE_CONCRETE_INSTRUCTION(DoubleBits, "double-bits")
2467 DECLARE_HYDROGEN_ACCESSOR(DoubleBits)
2471 class LConstructDouble final : public LTemplateInstruction<1, 2, 0> {
2473 LConstructDouble(LOperand* hi, LOperand* lo) {
2478 LOperand* hi() { return inputs_[0]; }
2479 LOperand* lo() { return inputs_[1]; }
2481 DECLARE_CONCRETE_INSTRUCTION(ConstructDouble, "construct-double")
2485 class LAllocate final : public LTemplateInstruction<1, 2, 1> {
2487 LAllocate(LOperand* context, LOperand* size, LOperand* temp) {
2488 inputs_[0] = context;
2493 LOperand* context() { return inputs_[0]; }
2494 LOperand* size() { return inputs_[1]; }
2495 LOperand* temp() { return temps_[0]; }
2497 DECLARE_CONCRETE_INSTRUCTION(Allocate, "allocate")
2498 DECLARE_HYDROGEN_ACCESSOR(Allocate)
2502 class LRegExpLiteral final : public LTemplateInstruction<1, 1, 0> {
2504 explicit LRegExpLiteral(LOperand* context) {
2505 inputs_[0] = context;
2508 LOperand* context() { return inputs_[0]; }
2510 DECLARE_CONCRETE_INSTRUCTION(RegExpLiteral, "regexp-literal")
2511 DECLARE_HYDROGEN_ACCESSOR(RegExpLiteral)
2515 class LFunctionLiteral final : public LTemplateInstruction<1, 1, 0> {
2517 explicit LFunctionLiteral(LOperand* context) {
2518 inputs_[0] = context;
2521 LOperand* context() { return inputs_[0]; }
2523 DECLARE_CONCRETE_INSTRUCTION(FunctionLiteral, "function-literal")
2524 DECLARE_HYDROGEN_ACCESSOR(FunctionLiteral)
2528 class LToFastProperties final : public LTemplateInstruction<1, 1, 0> {
2530 explicit LToFastProperties(LOperand* value) {
2534 LOperand* value() { return inputs_[0]; }
2536 DECLARE_CONCRETE_INSTRUCTION(ToFastProperties, "to-fast-properties")
2537 DECLARE_HYDROGEN_ACCESSOR(ToFastProperties)
2541 class LTypeof final : public LTemplateInstruction<1, 2, 0> {
2543 LTypeof(LOperand* context, LOperand* value) {
2544 inputs_[0] = context;
2548 LOperand* context() { return inputs_[0]; }
2549 LOperand* value() { return inputs_[1]; }
2551 DECLARE_CONCRETE_INSTRUCTION(Typeof, "typeof")
2555 class LTypeofIsAndBranch final : public LControlInstruction<1, 0> {
2557 explicit LTypeofIsAndBranch(LOperand* value) {
2561 LOperand* value() { return inputs_[0]; }
2563 DECLARE_CONCRETE_INSTRUCTION(TypeofIsAndBranch, "typeof-is-and-branch")
2564 DECLARE_HYDROGEN_ACCESSOR(TypeofIsAndBranch)
2566 Handle<String> type_literal() { return hydrogen()->type_literal(); }
2568 void PrintDataTo(StringStream* stream) override;
2572 class LIsConstructCallAndBranch final : public LControlInstruction<0, 1> {
2574 explicit LIsConstructCallAndBranch(LOperand* temp) {
2578 LOperand* temp() { return temps_[0]; }
2580 DECLARE_CONCRETE_INSTRUCTION(IsConstructCallAndBranch,
2581 "is-construct-call-and-branch")
2582 DECLARE_HYDROGEN_ACCESSOR(IsConstructCallAndBranch)
2586 class LOsrEntry final : public LTemplateInstruction<0, 0, 0> {
2590 bool HasInterestingComment(LCodeGen* gen) const override { return false; }
2591 DECLARE_CONCRETE_INSTRUCTION(OsrEntry, "osr-entry")
2595 class LStackCheck final : public LTemplateInstruction<0, 1, 0> {
2597 explicit LStackCheck(LOperand* context) {
2598 inputs_[0] = context;
2601 LOperand* context() { return inputs_[0]; }
2603 DECLARE_CONCRETE_INSTRUCTION(StackCheck, "stack-check")
2604 DECLARE_HYDROGEN_ACCESSOR(StackCheck)
2606 Label* done_label() { return &done_label_; }
2613 class LForInPrepareMap final : public LTemplateInstruction<1, 2, 0> {
2615 LForInPrepareMap(LOperand* context, LOperand* object) {
2616 inputs_[0] = context;
2617 inputs_[1] = object;
2620 LOperand* context() { return inputs_[0]; }
2621 LOperand* object() { return inputs_[1]; }
2623 DECLARE_CONCRETE_INSTRUCTION(ForInPrepareMap, "for-in-prepare-map")
2627 class LForInCacheArray final : public LTemplateInstruction<1, 1, 0> {
2629 explicit LForInCacheArray(LOperand* map) {
2633 LOperand* map() { return inputs_[0]; }
2635 DECLARE_CONCRETE_INSTRUCTION(ForInCacheArray, "for-in-cache-array")
2638 return HForInCacheArray::cast(this->hydrogen_value())->idx();
2643 class LCheckMapValue final : public LTemplateInstruction<0, 2, 0> {
2645 LCheckMapValue(LOperand* value, LOperand* map) {
2650 LOperand* value() { return inputs_[0]; }
2651 LOperand* map() { return inputs_[1]; }
2653 DECLARE_CONCRETE_INSTRUCTION(CheckMapValue, "check-map-value")
2657 class LLoadFieldByIndex final : public LTemplateInstruction<1, 2, 0> {
2659 LLoadFieldByIndex(LOperand* object, LOperand* index) {
2660 inputs_[0] = object;
2664 LOperand* object() { return inputs_[0]; }
2665 LOperand* index() { return inputs_[1]; }
2667 DECLARE_CONCRETE_INSTRUCTION(LoadFieldByIndex, "load-field-by-index")
2671 class LStoreFrameContext: public LTemplateInstruction<0, 1, 0> {
2673 explicit LStoreFrameContext(LOperand* context) {
2674 inputs_[0] = context;
2677 LOperand* context() { return inputs_[0]; }
2679 DECLARE_CONCRETE_INSTRUCTION(StoreFrameContext, "store-frame-context")
2683 class LAllocateBlockContext: public LTemplateInstruction<1, 2, 0> {
2685 LAllocateBlockContext(LOperand* context, LOperand* function) {
2686 inputs_[0] = context;
2687 inputs_[1] = function;
2690 LOperand* context() { return inputs_[0]; }
2691 LOperand* function() { return inputs_[1]; }
2693 Handle<ScopeInfo> scope_info() { return hydrogen()->scope_info(); }
2695 DECLARE_CONCRETE_INSTRUCTION(AllocateBlockContext, "allocate-block-context")
2696 DECLARE_HYDROGEN_ACCESSOR(AllocateBlockContext)
2700 class LChunkBuilder;
2701 class LPlatformChunk final : public LChunk {
2703 LPlatformChunk(CompilationInfo* info, HGraph* graph)
2704 : LChunk(info, graph),
2705 dehoisted_key_ids_(graph->GetMaximumValueID(), graph->zone()) { }
2707 int GetNextSpillIndex(RegisterKind kind);
2708 LOperand* GetNextSpillSlot(RegisterKind kind);
2709 BitVector* GetDehoistedKeyIds() { return &dehoisted_key_ids_; }
2710 bool IsDehoistedKey(HValue* value) {
2711 return dehoisted_key_ids_.Contains(value->id());
2715 BitVector dehoisted_key_ids_;
2719 class LChunkBuilder final : public LChunkBuilderBase {
2721 LChunkBuilder(CompilationInfo* info, HGraph* graph, LAllocator* allocator)
2722 : LChunkBuilderBase(info, graph),
2723 current_instruction_(NULL),
2724 current_block_(NULL),
2726 allocator_(allocator) {}
2728 // Build the sequence for the graph.
2729 LPlatformChunk* Build();
2731 // Declare methods that deal with the individual node types.
2732 #define DECLARE_DO(type) LInstruction* Do##type(H##type* node);
2733 HYDROGEN_CONCRETE_INSTRUCTION_LIST(DECLARE_DO)
2736 LInstruction* DoMathFloor(HUnaryMathOperation* instr);
2737 LInstruction* DoMathRound(HUnaryMathOperation* instr);
2738 LInstruction* DoMathFround(HUnaryMathOperation* instr);
2739 LInstruction* DoMathAbs(HUnaryMathOperation* instr);
2740 LInstruction* DoMathLog(HUnaryMathOperation* instr);
2741 LInstruction* DoMathExp(HUnaryMathOperation* instr);
2742 LInstruction* DoMathSqrt(HUnaryMathOperation* instr);
2743 LInstruction* DoMathPowHalf(HUnaryMathOperation* instr);
2744 LInstruction* DoMathClz32(HUnaryMathOperation* instr);
2745 LInstruction* DoDivByPowerOf2I(HDiv* instr);
2746 LInstruction* DoDivByConstI(HDiv* instr);
2747 LInstruction* DoDivI(HDiv* instr);
2748 LInstruction* DoModByPowerOf2I(HMod* instr);
2749 LInstruction* DoModByConstI(HMod* instr);
2750 LInstruction* DoModI(HMod* instr);
2751 LInstruction* DoFlooringDivByPowerOf2I(HMathFloorOfDiv* instr);
2752 LInstruction* DoFlooringDivByConstI(HMathFloorOfDiv* instr);
2753 LInstruction* DoFlooringDivI(HMathFloorOfDiv* instr);
2756 // Methods for getting operands for Use / Define / Temp.
2757 LUnallocated* ToUnallocated(Register reg);
2758 LUnallocated* ToUnallocated(XMMRegister reg);
2760 // Methods for setting up define-use relationships.
2761 MUST_USE_RESULT LOperand* Use(HValue* value, LUnallocated* operand);
2762 MUST_USE_RESULT LOperand* UseFixed(HValue* value, Register fixed_register);
2763 MUST_USE_RESULT LOperand* UseFixedDouble(HValue* value,
2764 XMMRegister fixed_register);
2766 // A value that is guaranteed to be allocated to a register.
2767 // Operand created by UseRegister is guaranteed to be live until the end of
2768 // instruction. This means that register allocator will not reuse it's
2769 // register for any other operand inside instruction.
2770 // Operand created by UseRegisterAtStart is guaranteed to be live only at
2771 // instruction start. Register allocator is free to assign the same register
2772 // to some other operand used inside instruction (i.e. temporary or
2774 MUST_USE_RESULT LOperand* UseRegister(HValue* value);
2775 MUST_USE_RESULT LOperand* UseRegisterAtStart(HValue* value);
2777 // An input operand in a register that may be trashed.
2778 MUST_USE_RESULT LOperand* UseTempRegister(HValue* value);
2780 // An input operand in a register that may be trashed or a constant operand.
2781 MUST_USE_RESULT LOperand* UseTempRegisterOrConstant(HValue* value);
2783 // An input operand in a register or stack slot.
2784 MUST_USE_RESULT LOperand* Use(HValue* value);
2785 MUST_USE_RESULT LOperand* UseAtStart(HValue* value);
2787 // An input operand in a register, stack slot or a constant operand.
2788 MUST_USE_RESULT LOperand* UseOrConstant(HValue* value);
2789 MUST_USE_RESULT LOperand* UseOrConstantAtStart(HValue* value);
2791 // An input operand in a register or a constant operand.
2792 MUST_USE_RESULT LOperand* UseRegisterOrConstant(HValue* value);
2793 MUST_USE_RESULT LOperand* UseRegisterOrConstantAtStart(HValue* value);
2795 // An input operand in a constant operand.
2796 MUST_USE_RESULT LOperand* UseConstant(HValue* value);
2798 // An input operand in register, stack slot or a constant operand.
2799 // Will not be moved to a register even if one is freely available.
2800 MUST_USE_RESULT LOperand* UseAny(HValue* value) override;
2802 // Temporary operand that must be in a register.
2803 MUST_USE_RESULT LUnallocated* TempRegister();
2804 MUST_USE_RESULT LOperand* FixedTemp(Register reg);
2805 MUST_USE_RESULT LOperand* FixedTemp(XMMRegister reg);
2807 // Methods for setting up define-use relationships.
2808 // Return the same instruction that they are passed.
2809 LInstruction* Define(LTemplateResultInstruction<1>* instr,
2810 LUnallocated* result);
2811 LInstruction* DefineAsRegister(LTemplateResultInstruction<1>* instr);
2812 LInstruction* DefineAsSpilled(LTemplateResultInstruction<1>* instr,
2814 LInstruction* DefineSameAsFirst(LTemplateResultInstruction<1>* instr);
2815 LInstruction* DefineFixed(LTemplateResultInstruction<1>* instr,
2817 LInstruction* DefineFixedDouble(LTemplateResultInstruction<1>* instr,
2819 // Assigns an environment to an instruction. An instruction which can
2820 // deoptimize must have an environment.
2821 LInstruction* AssignEnvironment(LInstruction* instr);
2822 // Assigns a pointer map to an instruction. An instruction which can
2823 // trigger a GC or a lazy deoptimization must have a pointer map.
2824 LInstruction* AssignPointerMap(LInstruction* instr);
2826 enum CanDeoptimize { CAN_DEOPTIMIZE_EAGERLY, CANNOT_DEOPTIMIZE_EAGERLY };
2828 // Marks a call for the register allocator. Assigns a pointer map to
2829 // support GC and lazy deoptimization. Assigns an environment to support
2830 // eager deoptimization if CAN_DEOPTIMIZE_EAGERLY.
2831 LInstruction* MarkAsCall(
2832 LInstruction* instr,
2833 HInstruction* hinstr,
2834 CanDeoptimize can_deoptimize = CANNOT_DEOPTIMIZE_EAGERLY);
2836 void VisitInstruction(HInstruction* current);
2837 void AddInstruction(LInstruction* instr, HInstruction* current);
2839 void DoBasicBlock(HBasicBlock* block, HBasicBlock* next_block);
2840 LInstruction* DoShift(Token::Value op, HBitwiseBinaryOperation* instr);
2841 LInstruction* DoArithmeticD(Token::Value op,
2842 HArithmeticBinaryOperation* instr);
2843 LInstruction* DoArithmeticT(Token::Value op,
2844 HBinaryOperation* instr);
2845 void FindDehoistedKeyDefinitions(HValue* candidate);
2847 HInstruction* current_instruction_;
2848 HBasicBlock* current_block_;
2849 HBasicBlock* next_block_;
2850 LAllocator* allocator_;
2852 DISALLOW_COPY_AND_ASSIGN(LChunkBuilder);
2855 #undef DECLARE_HYDROGEN_ACCESSOR
2856 #undef DECLARE_CONCRETE_INSTRUCTION
2858 } } // namespace v8::int
2860 #endif // V8_X64_LITHIUM_X64_H_