1 // Copyright 2014 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_PPC_LITHIUM_PPC_H_
6 #define V8_PPC_LITHIUM_PPC_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(IsStringAndBranch) \
96 V(IsUndetectableAndBranch) \
101 V(LoadFieldByIndex) \
102 V(LoadFunctionPrototype) \
103 V(LoadGlobalGeneric) \
104 V(LoadGlobalViaContext) \
106 V(LoadKeyedGeneric) \
108 V(LoadNamedGeneric) \
120 V(MaybeGrowElements) \
137 V(SeqStringGetChar) \
138 V(SeqStringSetChar) \
144 V(StoreContextSlot) \
145 V(StoreFrameContext) \
146 V(StoreGlobalViaContext) \
148 V(StoreKeyedGeneric) \
150 V(StoreNamedGeneric) \
152 V(StringCharCodeAt) \
153 V(StringCharFromCode) \
154 V(StringCompareAndBranch) \
159 V(ToFastProperties) \
160 V(TransitionElementsKind) \
161 V(TrapAllocationMemento) \
163 V(TypeofIsAndBranch) \
169 #define DECLARE_CONCRETE_INSTRUCTION(type, mnemonic) \
170 Opcode opcode() const final { return LInstruction::k##type; } \
171 void CompileToNative(LCodeGen* generator) final; \
172 const char* Mnemonic() const final { return mnemonic; } \
173 static L##type* cast(LInstruction* instr) { \
174 DCHECK(instr->Is##type()); \
175 return reinterpret_cast<L##type*>(instr); \
179 #define DECLARE_HYDROGEN_ACCESSOR(type) \
180 H##type* hydrogen() const { return H##type::cast(hydrogen_value()); }
183 class LInstruction : public ZoneObject {
186 : environment_(NULL),
187 hydrogen_value_(NULL),
188 bit_field_(IsCallBits::encode(false)) {}
190 virtual ~LInstruction() {}
192 virtual void CompileToNative(LCodeGen* generator) = 0;
193 virtual const char* Mnemonic() const = 0;
194 virtual void PrintTo(StringStream* stream);
195 virtual void PrintDataTo(StringStream* stream);
196 virtual void PrintOutputOperandTo(StringStream* stream);
199 // Declare a unique enum value for each instruction.
200 #define DECLARE_OPCODE(type) k##type,
201 LITHIUM_CONCRETE_INSTRUCTION_LIST(DECLARE_OPCODE) 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 virtual void SetDeferredLazyDeoptimizationEnvironment(LEnvironment* env) {}
235 void MarkAsCall() { bit_field_ = IsCallBits::update(bit_field_, true); }
236 bool IsCall() const { return IsCallBits::decode(bit_field_); }
238 // Interface to the register allocator and iterators.
239 bool ClobbersTemps() const { return IsCall(); }
240 bool ClobbersRegisters() const { return IsCall(); }
241 virtual bool ClobbersDoubleRegisters(Isolate* isolate) const {
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; }
260 virtual int InputCount() = 0;
261 virtual LOperand* InputAt(int i) = 0;
265 friend class InputIterator;
267 friend class TempIterator;
268 virtual int TempCount() = 0;
269 virtual LOperand* TempAt(int i) = 0;
271 class IsCallBits : public BitField<bool, 0, 1> {};
273 LEnvironment* environment_;
274 SetOncePointer<LPointerMap> pointer_map_;
275 HValue* hydrogen_value_;
280 // R = number of result operands (0 or 1).
282 class LTemplateResultInstruction : public LInstruction {
284 // Allow 0 or 1 output operands.
285 STATIC_ASSERT(R == 0 || R == 1);
286 bool HasResult() const final { return R != 0 && result() != NULL; }
287 void set_result(LOperand* operand) { results_[0] = operand; }
288 LOperand* result() const override { return results_[0]; }
291 EmbeddedContainer<LOperand*, R> results_;
295 // R = number of result operands (0 or 1).
296 // I = number of input operands.
297 // T = number of temporary operands.
298 template <int R, int I, int T>
299 class LTemplateInstruction : public LTemplateResultInstruction<R> {
301 EmbeddedContainer<LOperand*, I> inputs_;
302 EmbeddedContainer<LOperand*, T> temps_;
306 int InputCount() final { return I; }
307 LOperand* InputAt(int i) final { return inputs_[i]; }
309 int TempCount() final { return T; }
310 LOperand* TempAt(int i) final { return temps_[i]; }
314 class LGap : public LTemplateInstruction<0, 0, 0> {
316 explicit LGap(HBasicBlock* block) : block_(block) {
317 parallel_moves_[BEFORE] = NULL;
318 parallel_moves_[START] = NULL;
319 parallel_moves_[END] = NULL;
320 parallel_moves_[AFTER] = NULL;
323 // Can't use the DECLARE-macro here because of sub-classes.
324 bool IsGap() const override { return true; }
325 void PrintDataTo(StringStream* stream) override;
326 static LGap* cast(LInstruction* instr) {
327 DCHECK(instr->IsGap());
328 return reinterpret_cast<LGap*>(instr);
331 bool IsRedundant() const;
333 HBasicBlock* block() const { return block_; }
340 FIRST_INNER_POSITION = BEFORE,
341 LAST_INNER_POSITION = AFTER
344 LParallelMove* GetOrCreateParallelMove(InnerPosition pos, Zone* zone) {
345 if (parallel_moves_[pos] == NULL) {
346 parallel_moves_[pos] = new (zone) LParallelMove(zone);
348 return parallel_moves_[pos];
351 LParallelMove* GetParallelMove(InnerPosition pos) {
352 return parallel_moves_[pos];
356 LParallelMove* parallel_moves_[LAST_INNER_POSITION + 1];
361 class LInstructionGap final : public LGap {
363 explicit LInstructionGap(HBasicBlock* block) : LGap(block) {}
365 bool HasInterestingComment(LCodeGen* gen) const override {
366 return !IsRedundant();
369 DECLARE_CONCRETE_INSTRUCTION(InstructionGap, "gap")
373 class LGoto final : public LTemplateInstruction<0, 0, 0> {
375 explicit LGoto(HBasicBlock* block) : block_(block) {}
377 bool HasInterestingComment(LCodeGen* gen) const override;
378 DECLARE_CONCRETE_INSTRUCTION(Goto, "goto")
379 void PrintDataTo(StringStream* stream) override;
380 bool IsControl() const override { return true; }
382 int block_id() const { return block_->block_id(); }
389 class LLazyBailout final : public LTemplateInstruction<0, 0, 0> {
391 LLazyBailout() : gap_instructions_size_(0) {}
393 DECLARE_CONCRETE_INSTRUCTION(LazyBailout, "lazy-bailout")
395 void set_gap_instructions_size(int gap_instructions_size) {
396 gap_instructions_size_ = gap_instructions_size;
398 int gap_instructions_size() { return gap_instructions_size_; }
401 int gap_instructions_size_;
405 class LDummy final : public LTemplateInstruction<1, 0, 0> {
408 DECLARE_CONCRETE_INSTRUCTION(Dummy, "dummy")
412 class LDummyUse final : public LTemplateInstruction<1, 1, 0> {
414 explicit LDummyUse(LOperand* value) { inputs_[0] = value; }
415 DECLARE_CONCRETE_INSTRUCTION(DummyUse, "dummy-use")
419 class LDeoptimize final : public LTemplateInstruction<0, 0, 0> {
421 bool IsControl() const override { return true; }
422 DECLARE_CONCRETE_INSTRUCTION(Deoptimize, "deoptimize")
423 DECLARE_HYDROGEN_ACCESSOR(Deoptimize)
427 class LLabel final : public LGap {
429 explicit LLabel(HBasicBlock* block) : LGap(block), replacement_(NULL) {}
431 bool HasInterestingComment(LCodeGen* gen) const override { return false; }
432 DECLARE_CONCRETE_INSTRUCTION(Label, "label")
434 void PrintDataTo(StringStream* stream) override;
436 int block_id() const { return block()->block_id(); }
437 bool is_loop_header() const { return block()->IsLoopHeader(); }
438 bool is_osr_entry() const { return block()->is_osr_entry(); }
439 Label* label() { return &label_; }
440 LLabel* replacement() const { return replacement_; }
441 void set_replacement(LLabel* label) { replacement_ = label; }
442 bool HasReplacement() const { return replacement_ != NULL; }
446 LLabel* replacement_;
450 class LParameter final : public LTemplateInstruction<1, 0, 0> {
452 virtual bool HasInterestingComment(LCodeGen* gen) const { return false; }
453 DECLARE_CONCRETE_INSTRUCTION(Parameter, "parameter")
457 class LCallStub final : public LTemplateInstruction<1, 1, 0> {
459 explicit LCallStub(LOperand* context) { inputs_[0] = context; }
461 LOperand* context() { return inputs_[0]; }
463 DECLARE_CONCRETE_INSTRUCTION(CallStub, "call-stub")
464 DECLARE_HYDROGEN_ACCESSOR(CallStub)
468 class LUnknownOSRValue final : public LTemplateInstruction<1, 0, 0> {
470 bool HasInterestingComment(LCodeGen* gen) const override { return false; }
471 DECLARE_CONCRETE_INSTRUCTION(UnknownOSRValue, "unknown-osr-value")
475 template <int I, int T>
476 class LControlInstruction : public LTemplateInstruction<0, I, T> {
478 LControlInstruction() : false_label_(NULL), true_label_(NULL) {}
480 bool IsControl() const final { return true; }
482 int SuccessorCount() { return hydrogen()->SuccessorCount(); }
483 HBasicBlock* SuccessorAt(int i) { return hydrogen()->SuccessorAt(i); }
485 int TrueDestination(LChunk* chunk) {
486 return chunk->LookupDestination(true_block_id());
488 int FalseDestination(LChunk* chunk) {
489 return chunk->LookupDestination(false_block_id());
492 Label* TrueLabel(LChunk* chunk) {
493 if (true_label_ == NULL) {
494 true_label_ = chunk->GetAssemblyLabel(TrueDestination(chunk));
498 Label* FalseLabel(LChunk* chunk) {
499 if (false_label_ == NULL) {
500 false_label_ = chunk->GetAssemblyLabel(FalseDestination(chunk));
506 int true_block_id() { return SuccessorAt(0)->block_id(); }
507 int false_block_id() { return SuccessorAt(1)->block_id(); }
510 HControlInstruction* hydrogen() {
511 return HControlInstruction::cast(this->hydrogen_value());
519 class LWrapReceiver final : public LTemplateInstruction<1, 2, 0> {
521 LWrapReceiver(LOperand* receiver, LOperand* function) {
522 inputs_[0] = receiver;
523 inputs_[1] = function;
526 DECLARE_CONCRETE_INSTRUCTION(WrapReceiver, "wrap-receiver")
527 DECLARE_HYDROGEN_ACCESSOR(WrapReceiver)
529 LOperand* receiver() { return inputs_[0]; }
530 LOperand* function() { return inputs_[1]; }
534 class LApplyArguments final : public LTemplateInstruction<1, 4, 0> {
536 LApplyArguments(LOperand* function, LOperand* receiver, LOperand* length,
537 LOperand* elements) {
538 inputs_[0] = function;
539 inputs_[1] = receiver;
541 inputs_[3] = elements;
544 DECLARE_CONCRETE_INSTRUCTION(ApplyArguments, "apply-arguments")
546 LOperand* function() { return inputs_[0]; }
547 LOperand* receiver() { return inputs_[1]; }
548 LOperand* length() { return inputs_[2]; }
549 LOperand* elements() { return inputs_[3]; }
553 class LAccessArgumentsAt final : public LTemplateInstruction<1, 3, 0> {
555 LAccessArgumentsAt(LOperand* arguments, LOperand* length, LOperand* index) {
556 inputs_[0] = arguments;
561 DECLARE_CONCRETE_INSTRUCTION(AccessArgumentsAt, "access-arguments-at")
563 LOperand* arguments() { return inputs_[0]; }
564 LOperand* length() { return inputs_[1]; }
565 LOperand* index() { return inputs_[2]; }
567 void PrintDataTo(StringStream* stream) override;
571 class LArgumentsLength final : public LTemplateInstruction<1, 1, 0> {
573 explicit LArgumentsLength(LOperand* elements) { inputs_[0] = elements; }
575 LOperand* elements() { return inputs_[0]; }
577 DECLARE_CONCRETE_INSTRUCTION(ArgumentsLength, "arguments-length")
581 class LArgumentsElements final : public LTemplateInstruction<1, 0, 0> {
583 DECLARE_CONCRETE_INSTRUCTION(ArgumentsElements, "arguments-elements")
584 DECLARE_HYDROGEN_ACCESSOR(ArgumentsElements)
588 class LModByPowerOf2I final : public LTemplateInstruction<1, 1, 0> {
590 LModByPowerOf2I(LOperand* dividend, int32_t divisor) {
591 inputs_[0] = dividend;
595 LOperand* dividend() { return inputs_[0]; }
596 int32_t divisor() const { return divisor_; }
598 DECLARE_CONCRETE_INSTRUCTION(ModByPowerOf2I, "mod-by-power-of-2-i")
599 DECLARE_HYDROGEN_ACCESSOR(Mod)
606 class LModByConstI final : public LTemplateInstruction<1, 1, 0> {
608 LModByConstI(LOperand* dividend, int32_t divisor) {
609 inputs_[0] = dividend;
613 LOperand* dividend() { return inputs_[0]; }
614 int32_t divisor() const { return divisor_; }
616 DECLARE_CONCRETE_INSTRUCTION(ModByConstI, "mod-by-const-i")
617 DECLARE_HYDROGEN_ACCESSOR(Mod)
624 class LModI final : public LTemplateInstruction<1, 2, 0> {
626 LModI(LOperand* left, LOperand* right) {
631 LOperand* left() { return inputs_[0]; }
632 LOperand* right() { return inputs_[1]; }
634 DECLARE_CONCRETE_INSTRUCTION(ModI, "mod-i")
635 DECLARE_HYDROGEN_ACCESSOR(Mod)
639 class LDivByPowerOf2I final : public LTemplateInstruction<1, 1, 0> {
641 LDivByPowerOf2I(LOperand* dividend, int32_t divisor) {
642 inputs_[0] = dividend;
646 LOperand* dividend() { return inputs_[0]; }
647 int32_t divisor() const { return divisor_; }
649 DECLARE_CONCRETE_INSTRUCTION(DivByPowerOf2I, "div-by-power-of-2-i")
650 DECLARE_HYDROGEN_ACCESSOR(Div)
657 class LDivByConstI final : public LTemplateInstruction<1, 1, 0> {
659 LDivByConstI(LOperand* dividend, int32_t divisor) {
660 inputs_[0] = dividend;
664 LOperand* dividend() { return inputs_[0]; }
665 int32_t divisor() const { return divisor_; }
667 DECLARE_CONCRETE_INSTRUCTION(DivByConstI, "div-by-const-i")
668 DECLARE_HYDROGEN_ACCESSOR(Div)
675 class LDivI final : public LTemplateInstruction<1, 2, 0> {
677 LDivI(LOperand* dividend, LOperand* divisor) {
678 inputs_[0] = dividend;
679 inputs_[1] = divisor;
682 LOperand* dividend() { return inputs_[0]; }
683 LOperand* divisor() { return inputs_[1]; }
685 DECLARE_CONCRETE_INSTRUCTION(DivI, "div-i")
686 DECLARE_HYDROGEN_ACCESSOR(BinaryOperation)
690 class LFlooringDivByPowerOf2I final : public LTemplateInstruction<1, 1, 0> {
692 LFlooringDivByPowerOf2I(LOperand* dividend, int32_t divisor) {
693 inputs_[0] = dividend;
697 LOperand* dividend() { return inputs_[0]; }
698 int32_t divisor() { return divisor_; }
700 DECLARE_CONCRETE_INSTRUCTION(FlooringDivByPowerOf2I,
701 "flooring-div-by-power-of-2-i")
702 DECLARE_HYDROGEN_ACCESSOR(MathFloorOfDiv)
709 class LFlooringDivByConstI final : public LTemplateInstruction<1, 1, 1> {
711 LFlooringDivByConstI(LOperand* dividend, int32_t divisor, LOperand* temp) {
712 inputs_[0] = dividend;
717 LOperand* dividend() { return inputs_[0]; }
718 int32_t divisor() const { return divisor_; }
719 LOperand* temp() { return temps_[0]; }
721 DECLARE_CONCRETE_INSTRUCTION(FlooringDivByConstI, "flooring-div-by-const-i")
722 DECLARE_HYDROGEN_ACCESSOR(MathFloorOfDiv)
729 class LFlooringDivI final : public LTemplateInstruction<1, 2, 0> {
731 LFlooringDivI(LOperand* dividend, LOperand* divisor) {
732 inputs_[0] = dividend;
733 inputs_[1] = divisor;
736 LOperand* dividend() { return inputs_[0]; }
737 LOperand* divisor() { return inputs_[1]; }
739 DECLARE_CONCRETE_INSTRUCTION(FlooringDivI, "flooring-div-i")
740 DECLARE_HYDROGEN_ACCESSOR(MathFloorOfDiv)
744 class LMulI final : public LTemplateInstruction<1, 2, 0> {
746 LMulI(LOperand* left, LOperand* right) {
751 LOperand* left() { return inputs_[0]; }
752 LOperand* right() { return inputs_[1]; }
754 DECLARE_CONCRETE_INSTRUCTION(MulI, "mul-i")
755 DECLARE_HYDROGEN_ACCESSOR(Mul)
759 // Instruction for computing multiplier * multiplicand + addend.
760 class LMultiplyAddD final : public LTemplateInstruction<1, 3, 0> {
762 LMultiplyAddD(LOperand* addend, LOperand* multiplier,
763 LOperand* multiplicand) {
765 inputs_[1] = multiplier;
766 inputs_[2] = multiplicand;
769 LOperand* addend() { return inputs_[0]; }
770 LOperand* multiplier() { return inputs_[1]; }
771 LOperand* multiplicand() { return inputs_[2]; }
773 DECLARE_CONCRETE_INSTRUCTION(MultiplyAddD, "multiply-add-d")
777 // Instruction for computing minuend - multiplier * multiplicand.
778 class LMultiplySubD final : public LTemplateInstruction<1, 3, 0> {
780 LMultiplySubD(LOperand* minuend, LOperand* multiplier,
781 LOperand* multiplicand) {
782 inputs_[0] = minuend;
783 inputs_[1] = multiplier;
784 inputs_[2] = multiplicand;
787 LOperand* minuend() { return inputs_[0]; }
788 LOperand* multiplier() { return inputs_[1]; }
789 LOperand* multiplicand() { return inputs_[2]; }
791 DECLARE_CONCRETE_INSTRUCTION(MultiplySubD, "multiply-sub-d")
795 class LDebugBreak final : public LTemplateInstruction<0, 0, 0> {
797 DECLARE_CONCRETE_INSTRUCTION(DebugBreak, "break")
801 class LCompareNumericAndBranch final : public LControlInstruction<2, 0> {
803 LCompareNumericAndBranch(LOperand* left, LOperand* right) {
808 LOperand* left() { return inputs_[0]; }
809 LOperand* right() { return inputs_[1]; }
811 DECLARE_CONCRETE_INSTRUCTION(CompareNumericAndBranch,
812 "compare-numeric-and-branch")
813 DECLARE_HYDROGEN_ACCESSOR(CompareNumericAndBranch)
815 Token::Value op() const { return hydrogen()->token(); }
816 bool is_double() const { return hydrogen()->representation().IsDouble(); }
818 void PrintDataTo(StringStream* stream) override;
822 class LMathFloor final : public LTemplateInstruction<1, 1, 0> {
824 explicit LMathFloor(LOperand* value) { inputs_[0] = value; }
826 LOperand* value() { return inputs_[0]; }
828 DECLARE_CONCRETE_INSTRUCTION(MathFloor, "math-floor")
829 DECLARE_HYDROGEN_ACCESSOR(UnaryMathOperation)
833 class LMathRound final : public LTemplateInstruction<1, 1, 1> {
835 LMathRound(LOperand* value, LOperand* temp) {
840 LOperand* value() { return inputs_[0]; }
841 LOperand* temp() { return temps_[0]; }
843 DECLARE_CONCRETE_INSTRUCTION(MathRound, "math-round")
844 DECLARE_HYDROGEN_ACCESSOR(UnaryMathOperation)
848 class LMathFround final : public LTemplateInstruction<1, 1, 0> {
850 explicit LMathFround(LOperand* value) { inputs_[0] = value; }
852 LOperand* value() { return inputs_[0]; }
854 DECLARE_CONCRETE_INSTRUCTION(MathFround, "math-fround")
858 class LMathAbs final : public LTemplateInstruction<1, 2, 0> {
860 LMathAbs(LOperand* context, LOperand* value) {
861 inputs_[1] = context;
865 LOperand* context() { return inputs_[1]; }
866 LOperand* value() { return inputs_[0]; }
868 DECLARE_CONCRETE_INSTRUCTION(MathAbs, "math-abs")
869 DECLARE_HYDROGEN_ACCESSOR(UnaryMathOperation)
873 class LMathLog final : public LTemplateInstruction<1, 1, 0> {
875 explicit LMathLog(LOperand* value) { inputs_[0] = value; }
877 LOperand* value() { return inputs_[0]; }
879 DECLARE_CONCRETE_INSTRUCTION(MathLog, "math-log")
883 class LMathClz32 final : public LTemplateInstruction<1, 1, 0> {
885 explicit LMathClz32(LOperand* value) { inputs_[0] = value; }
887 LOperand* value() { return inputs_[0]; }
889 DECLARE_CONCRETE_INSTRUCTION(MathClz32, "math-clz32")
893 class LMathExp final : public LTemplateInstruction<1, 1, 3> {
895 LMathExp(LOperand* value, LOperand* double_temp, LOperand* temp1,
900 temps_[2] = double_temp;
901 ExternalReference::InitializeMathExpData();
904 LOperand* value() { return inputs_[0]; }
905 LOperand* temp1() { return temps_[0]; }
906 LOperand* temp2() { return temps_[1]; }
907 LOperand* double_temp() { return temps_[2]; }
909 DECLARE_CONCRETE_INSTRUCTION(MathExp, "math-exp")
913 class LMathSqrt final : public LTemplateInstruction<1, 1, 0> {
915 explicit LMathSqrt(LOperand* value) { inputs_[0] = value; }
917 LOperand* value() { return inputs_[0]; }
919 DECLARE_CONCRETE_INSTRUCTION(MathSqrt, "math-sqrt")
923 class LMathPowHalf final : public LTemplateInstruction<1, 1, 0> {
925 explicit LMathPowHalf(LOperand* value) { inputs_[0] = value; }
927 LOperand* value() { return inputs_[0]; }
929 DECLARE_CONCRETE_INSTRUCTION(MathPowHalf, "math-pow-half")
933 class LCmpObjectEqAndBranch final : public LControlInstruction<2, 0> {
935 LCmpObjectEqAndBranch(LOperand* left, LOperand* right) {
940 LOperand* left() { return inputs_[0]; }
941 LOperand* right() { return inputs_[1]; }
943 DECLARE_CONCRETE_INSTRUCTION(CmpObjectEqAndBranch, "cmp-object-eq-and-branch")
944 DECLARE_HYDROGEN_ACCESSOR(CompareObjectEqAndBranch)
948 class LCmpHoleAndBranch final : public LControlInstruction<1, 0> {
950 explicit LCmpHoleAndBranch(LOperand* object) { inputs_[0] = object; }
952 LOperand* object() { return inputs_[0]; }
954 DECLARE_CONCRETE_INSTRUCTION(CmpHoleAndBranch, "cmp-hole-and-branch")
955 DECLARE_HYDROGEN_ACCESSOR(CompareHoleAndBranch)
959 class LCompareMinusZeroAndBranch final : public LControlInstruction<1, 1> {
961 LCompareMinusZeroAndBranch(LOperand* value, LOperand* temp) {
966 LOperand* value() { return inputs_[0]; }
967 LOperand* temp() { return temps_[0]; }
969 DECLARE_CONCRETE_INSTRUCTION(CompareMinusZeroAndBranch,
970 "cmp-minus-zero-and-branch")
971 DECLARE_HYDROGEN_ACCESSOR(CompareMinusZeroAndBranch)
975 class LIsStringAndBranch final : public LControlInstruction<1, 1> {
977 LIsStringAndBranch(LOperand* value, LOperand* temp) {
982 LOperand* value() { return inputs_[0]; }
983 LOperand* temp() { return temps_[0]; }
985 DECLARE_CONCRETE_INSTRUCTION(IsStringAndBranch, "is-string-and-branch")
986 DECLARE_HYDROGEN_ACCESSOR(IsStringAndBranch)
988 void PrintDataTo(StringStream* stream) override;
992 class LIsSmiAndBranch final : public LControlInstruction<1, 0> {
994 explicit LIsSmiAndBranch(LOperand* value) { inputs_[0] = value; }
996 LOperand* value() { return inputs_[0]; }
998 DECLARE_CONCRETE_INSTRUCTION(IsSmiAndBranch, "is-smi-and-branch")
999 DECLARE_HYDROGEN_ACCESSOR(IsSmiAndBranch)
1001 void PrintDataTo(StringStream* stream) override;
1005 class LIsUndetectableAndBranch final : public LControlInstruction<1, 1> {
1007 explicit LIsUndetectableAndBranch(LOperand* value, LOperand* temp) {
1012 LOperand* value() { return inputs_[0]; }
1013 LOperand* temp() { return temps_[0]; }
1015 DECLARE_CONCRETE_INSTRUCTION(IsUndetectableAndBranch,
1016 "is-undetectable-and-branch")
1017 DECLARE_HYDROGEN_ACCESSOR(IsUndetectableAndBranch)
1019 void PrintDataTo(StringStream* stream) override;
1023 class LStringCompareAndBranch final : public LControlInstruction<3, 0> {
1025 LStringCompareAndBranch(LOperand* context, LOperand* left, LOperand* right) {
1026 inputs_[0] = context;
1031 LOperand* context() { return inputs_[0]; }
1032 LOperand* left() { return inputs_[1]; }
1033 LOperand* right() { return inputs_[2]; }
1035 DECLARE_CONCRETE_INSTRUCTION(StringCompareAndBranch,
1036 "string-compare-and-branch")
1037 DECLARE_HYDROGEN_ACCESSOR(StringCompareAndBranch)
1039 Token::Value op() const { return hydrogen()->token(); }
1041 void PrintDataTo(StringStream* stream) override;
1045 class LHasInstanceTypeAndBranch final : public LControlInstruction<1, 0> {
1047 explicit LHasInstanceTypeAndBranch(LOperand* value) { inputs_[0] = value; }
1049 LOperand* value() { return inputs_[0]; }
1051 DECLARE_CONCRETE_INSTRUCTION(HasInstanceTypeAndBranch,
1052 "has-instance-type-and-branch")
1053 DECLARE_HYDROGEN_ACCESSOR(HasInstanceTypeAndBranch)
1055 void PrintDataTo(StringStream* stream) override;
1059 class LGetCachedArrayIndex final : public LTemplateInstruction<1, 1, 0> {
1061 explicit LGetCachedArrayIndex(LOperand* value) { inputs_[0] = value; }
1063 LOperand* value() { return inputs_[0]; }
1065 DECLARE_CONCRETE_INSTRUCTION(GetCachedArrayIndex, "get-cached-array-index")
1066 DECLARE_HYDROGEN_ACCESSOR(GetCachedArrayIndex)
1070 class LHasCachedArrayIndexAndBranch final : public LControlInstruction<1, 0> {
1072 explicit LHasCachedArrayIndexAndBranch(LOperand* value) {
1076 LOperand* value() { return inputs_[0]; }
1078 DECLARE_CONCRETE_INSTRUCTION(HasCachedArrayIndexAndBranch,
1079 "has-cached-array-index-and-branch")
1080 DECLARE_HYDROGEN_ACCESSOR(HasCachedArrayIndexAndBranch)
1082 void PrintDataTo(StringStream* stream) override;
1086 class LClassOfTestAndBranch final : public LControlInstruction<1, 1> {
1088 LClassOfTestAndBranch(LOperand* value, LOperand* temp) {
1093 LOperand* value() { return inputs_[0]; }
1094 LOperand* temp() { return temps_[0]; }
1096 DECLARE_CONCRETE_INSTRUCTION(ClassOfTestAndBranch, "class-of-test-and-branch")
1097 DECLARE_HYDROGEN_ACCESSOR(ClassOfTestAndBranch)
1099 void PrintDataTo(StringStream* stream) override;
1103 class LCmpT final : public LTemplateInstruction<1, 3, 0> {
1105 LCmpT(LOperand* context, LOperand* left, LOperand* right) {
1106 inputs_[0] = context;
1111 LOperand* context() { return inputs_[0]; }
1112 LOperand* left() { return inputs_[1]; }
1113 LOperand* right() { return inputs_[2]; }
1115 DECLARE_CONCRETE_INSTRUCTION(CmpT, "cmp-t")
1116 DECLARE_HYDROGEN_ACCESSOR(CompareGeneric)
1118 Strength strength() { return hydrogen()->strength(); }
1120 Token::Value op() const { return hydrogen()->token(); }
1124 class LInstanceOf final : public LTemplateInstruction<1, 3, 0> {
1126 LInstanceOf(LOperand* context, LOperand* left, LOperand* right) {
1127 inputs_[0] = context;
1132 LOperand* context() { return inputs_[0]; }
1133 LOperand* left() { return inputs_[1]; }
1134 LOperand* right() { return inputs_[2]; }
1136 DECLARE_CONCRETE_INSTRUCTION(InstanceOf, "instance-of")
1140 class LInstanceOfKnownGlobal final : public LTemplateInstruction<1, 2, 1> {
1142 LInstanceOfKnownGlobal(LOperand* context, LOperand* value, LOperand* temp) {
1143 inputs_[0] = context;
1148 LOperand* context() { return inputs_[0]; }
1149 LOperand* value() { return inputs_[1]; }
1150 LOperand* temp() { return temps_[0]; }
1152 DECLARE_CONCRETE_INSTRUCTION(InstanceOfKnownGlobal,
1153 "instance-of-known-global")
1154 DECLARE_HYDROGEN_ACCESSOR(InstanceOfKnownGlobal)
1156 Handle<JSFunction> function() const { return hydrogen()->function(); }
1157 LEnvironment* GetDeferredLazyDeoptimizationEnvironment() {
1158 return lazy_deopt_env_;
1160 virtual void SetDeferredLazyDeoptimizationEnvironment(
1161 LEnvironment* env) override {
1162 lazy_deopt_env_ = env;
1166 LEnvironment* lazy_deopt_env_;
1170 class LBoundsCheck final : public LTemplateInstruction<0, 2, 0> {
1172 LBoundsCheck(LOperand* index, LOperand* length) {
1174 inputs_[1] = length;
1177 LOperand* index() { return inputs_[0]; }
1178 LOperand* length() { return inputs_[1]; }
1180 DECLARE_CONCRETE_INSTRUCTION(BoundsCheck, "bounds-check")
1181 DECLARE_HYDROGEN_ACCESSOR(BoundsCheck)
1185 class LBitI final : public LTemplateInstruction<1, 2, 0> {
1187 LBitI(LOperand* left, LOperand* right) {
1192 LOperand* left() { return inputs_[0]; }
1193 LOperand* right() { return inputs_[1]; }
1195 Token::Value op() const { return hydrogen()->op(); }
1197 DECLARE_CONCRETE_INSTRUCTION(BitI, "bit-i")
1198 DECLARE_HYDROGEN_ACCESSOR(Bitwise)
1202 class LShiftI final : public LTemplateInstruction<1, 2, 0> {
1204 LShiftI(Token::Value op, LOperand* left, LOperand* right, bool can_deopt)
1205 : op_(op), can_deopt_(can_deopt) {
1210 Token::Value op() const { return op_; }
1211 LOperand* left() { return inputs_[0]; }
1212 LOperand* right() { return inputs_[1]; }
1213 bool can_deopt() const { return can_deopt_; }
1215 DECLARE_CONCRETE_INSTRUCTION(ShiftI, "shift-i")
1223 class LSubI final : public LTemplateInstruction<1, 2, 0> {
1225 LSubI(LOperand* left, LOperand* right) {
1230 LOperand* left() { return inputs_[0]; }
1231 LOperand* right() { return inputs_[1]; }
1233 DECLARE_CONCRETE_INSTRUCTION(SubI, "sub-i")
1234 DECLARE_HYDROGEN_ACCESSOR(Sub)
1238 class LRSubI final : public LTemplateInstruction<1, 2, 0> {
1240 LRSubI(LOperand* left, LOperand* right) {
1245 LOperand* left() { return inputs_[0]; }
1246 LOperand* right() { return inputs_[1]; }
1248 DECLARE_CONCRETE_INSTRUCTION(RSubI, "rsub-i")
1249 DECLARE_HYDROGEN_ACCESSOR(Sub)
1253 class LConstantI final : public LTemplateInstruction<1, 0, 0> {
1255 DECLARE_CONCRETE_INSTRUCTION(ConstantI, "constant-i")
1256 DECLARE_HYDROGEN_ACCESSOR(Constant)
1258 int32_t value() const { return hydrogen()->Integer32Value(); }
1262 class LConstantS final : public LTemplateInstruction<1, 0, 0> {
1264 DECLARE_CONCRETE_INSTRUCTION(ConstantS, "constant-s")
1265 DECLARE_HYDROGEN_ACCESSOR(Constant)
1267 Smi* value() const { return Smi::FromInt(hydrogen()->Integer32Value()); }
1271 class LConstantD final : public LTemplateInstruction<1, 0, 0> {
1273 DECLARE_CONCRETE_INSTRUCTION(ConstantD, "constant-d")
1274 DECLARE_HYDROGEN_ACCESSOR(Constant)
1276 double value() const { return hydrogen()->DoubleValue(); }
1277 uint64_t bits() const { return hydrogen()->DoubleValueAsBits(); }
1281 class LConstantE final : public LTemplateInstruction<1, 0, 0> {
1283 DECLARE_CONCRETE_INSTRUCTION(ConstantE, "constant-e")
1284 DECLARE_HYDROGEN_ACCESSOR(Constant)
1286 ExternalReference value() const {
1287 return hydrogen()->ExternalReferenceValue();
1292 class LConstantT final : public LTemplateInstruction<1, 0, 0> {
1294 DECLARE_CONCRETE_INSTRUCTION(ConstantT, "constant-t")
1295 DECLARE_HYDROGEN_ACCESSOR(Constant)
1297 Handle<Object> value(Isolate* isolate) const {
1298 return hydrogen()->handle(isolate);
1303 class LBranch final : public LControlInstruction<1, 0> {
1305 explicit LBranch(LOperand* value) { inputs_[0] = value; }
1307 LOperand* value() { return inputs_[0]; }
1309 DECLARE_CONCRETE_INSTRUCTION(Branch, "branch")
1310 DECLARE_HYDROGEN_ACCESSOR(Branch)
1312 void PrintDataTo(StringStream* stream) override;
1316 class LCmpMapAndBranch final : public LControlInstruction<1, 1> {
1318 LCmpMapAndBranch(LOperand* value, LOperand* temp) {
1323 LOperand* value() { return inputs_[0]; }
1324 LOperand* temp() { return temps_[0]; }
1326 DECLARE_CONCRETE_INSTRUCTION(CmpMapAndBranch, "cmp-map-and-branch")
1327 DECLARE_HYDROGEN_ACCESSOR(CompareMap)
1329 Handle<Map> map() const { return hydrogen()->map().handle(); }
1333 class LMapEnumLength final : public LTemplateInstruction<1, 1, 0> {
1335 explicit LMapEnumLength(LOperand* value) { inputs_[0] = value; }
1337 LOperand* value() { return inputs_[0]; }
1339 DECLARE_CONCRETE_INSTRUCTION(MapEnumLength, "map-enum-length")
1343 class LDateField final : public LTemplateInstruction<1, 1, 1> {
1345 LDateField(LOperand* date, LOperand* temp, Smi* index) : index_(index) {
1350 LOperand* date() { return inputs_[0]; }
1351 LOperand* temp() { return temps_[0]; }
1352 Smi* index() const { return index_; }
1354 DECLARE_CONCRETE_INSTRUCTION(DateField, "date-field")
1355 DECLARE_HYDROGEN_ACCESSOR(DateField)
1362 class LSeqStringGetChar final : public LTemplateInstruction<1, 2, 0> {
1364 LSeqStringGetChar(LOperand* string, LOperand* index) {
1365 inputs_[0] = string;
1369 LOperand* string() const { return inputs_[0]; }
1370 LOperand* index() const { return inputs_[1]; }
1372 DECLARE_CONCRETE_INSTRUCTION(SeqStringGetChar, "seq-string-get-char")
1373 DECLARE_HYDROGEN_ACCESSOR(SeqStringGetChar)
1377 class LSeqStringSetChar final : public LTemplateInstruction<1, 4, 0> {
1379 LSeqStringSetChar(LOperand* context, LOperand* string, LOperand* index,
1381 inputs_[0] = context;
1382 inputs_[1] = string;
1387 LOperand* string() { return inputs_[1]; }
1388 LOperand* index() { return inputs_[2]; }
1389 LOperand* value() { return inputs_[3]; }
1391 DECLARE_CONCRETE_INSTRUCTION(SeqStringSetChar, "seq-string-set-char")
1392 DECLARE_HYDROGEN_ACCESSOR(SeqStringSetChar)
1396 class LAddI final : public LTemplateInstruction<1, 2, 0> {
1398 LAddI(LOperand* left, LOperand* right) {
1403 LOperand* left() { return inputs_[0]; }
1404 LOperand* right() { return inputs_[1]; }
1406 DECLARE_CONCRETE_INSTRUCTION(AddI, "add-i")
1407 DECLARE_HYDROGEN_ACCESSOR(Add)
1411 class LMathMinMax final : public LTemplateInstruction<1, 2, 0> {
1413 LMathMinMax(LOperand* left, LOperand* right) {
1418 LOperand* left() { return inputs_[0]; }
1419 LOperand* right() { return inputs_[1]; }
1421 DECLARE_CONCRETE_INSTRUCTION(MathMinMax, "math-min-max")
1422 DECLARE_HYDROGEN_ACCESSOR(MathMinMax)
1426 class LPower final : public LTemplateInstruction<1, 2, 0> {
1428 LPower(LOperand* left, LOperand* right) {
1433 LOperand* left() { return inputs_[0]; }
1434 LOperand* right() { return inputs_[1]; }
1436 DECLARE_CONCRETE_INSTRUCTION(Power, "power")
1437 DECLARE_HYDROGEN_ACCESSOR(Power)
1441 class LArithmeticD final : public LTemplateInstruction<1, 2, 0> {
1443 LArithmeticD(Token::Value op, LOperand* left, LOperand* right) : op_(op) {
1448 Token::Value op() const { return op_; }
1449 LOperand* left() { return inputs_[0]; }
1450 LOperand* right() { return inputs_[1]; }
1452 Opcode opcode() const override { return LInstruction::kArithmeticD; }
1453 void CompileToNative(LCodeGen* generator) override;
1454 const char* Mnemonic() const override;
1461 class LArithmeticT final : public LTemplateInstruction<1, 3, 0> {
1463 LArithmeticT(Token::Value op, LOperand* context, LOperand* left,
1466 inputs_[0] = context;
1471 LOperand* context() { return inputs_[0]; }
1472 LOperand* left() { return inputs_[1]; }
1473 LOperand* right() { return inputs_[2]; }
1474 Token::Value op() const { return op_; }
1476 Opcode opcode() const override { return LInstruction::kArithmeticT; }
1477 void CompileToNative(LCodeGen* generator) override;
1478 const char* Mnemonic() const override;
1480 DECLARE_HYDROGEN_ACCESSOR(BinaryOperation)
1482 Strength strength() { return hydrogen()->strength(); }
1489 class LReturn final : public LTemplateInstruction<0, 3, 0> {
1491 LReturn(LOperand* value, LOperand* context, LOperand* parameter_count) {
1493 inputs_[1] = context;
1494 inputs_[2] = parameter_count;
1497 LOperand* value() { return inputs_[0]; }
1499 bool has_constant_parameter_count() {
1500 return parameter_count()->IsConstantOperand();
1502 LConstantOperand* constant_parameter_count() {
1503 DCHECK(has_constant_parameter_count());
1504 return LConstantOperand::cast(parameter_count());
1506 LOperand* parameter_count() { return inputs_[2]; }
1508 DECLARE_CONCRETE_INSTRUCTION(Return, "return")
1512 class LLoadNamedField final : public LTemplateInstruction<1, 1, 0> {
1514 explicit LLoadNamedField(LOperand* object) { inputs_[0] = object; }
1516 LOperand* object() { return inputs_[0]; }
1518 DECLARE_CONCRETE_INSTRUCTION(LoadNamedField, "load-named-field")
1519 DECLARE_HYDROGEN_ACCESSOR(LoadNamedField)
1523 class LLoadNamedGeneric final : public LTemplateInstruction<1, 2, 1> {
1525 LLoadNamedGeneric(LOperand* context, LOperand* object, LOperand* vector) {
1526 inputs_[0] = context;
1527 inputs_[1] = object;
1531 LOperand* context() { return inputs_[0]; }
1532 LOperand* object() { return inputs_[1]; }
1533 LOperand* temp_vector() { return temps_[0]; }
1535 DECLARE_CONCRETE_INSTRUCTION(LoadNamedGeneric, "load-named-generic")
1536 DECLARE_HYDROGEN_ACCESSOR(LoadNamedGeneric)
1538 Handle<Object> name() const { return hydrogen()->name(); }
1542 class LLoadFunctionPrototype final : public LTemplateInstruction<1, 1, 0> {
1544 explicit LLoadFunctionPrototype(LOperand* function) { inputs_[0] = function; }
1546 LOperand* function() { return inputs_[0]; }
1548 DECLARE_CONCRETE_INSTRUCTION(LoadFunctionPrototype, "load-function-prototype")
1549 DECLARE_HYDROGEN_ACCESSOR(LoadFunctionPrototype)
1553 class LLoadRoot final : public LTemplateInstruction<1, 0, 0> {
1555 DECLARE_CONCRETE_INSTRUCTION(LoadRoot, "load-root")
1556 DECLARE_HYDROGEN_ACCESSOR(LoadRoot)
1558 Heap::RootListIndex index() const { return hydrogen()->index(); }
1562 class LLoadKeyed final : public LTemplateInstruction<1, 2, 0> {
1564 LLoadKeyed(LOperand* elements, LOperand* key) {
1565 inputs_[0] = elements;
1569 LOperand* elements() { return inputs_[0]; }
1570 LOperand* key() { return inputs_[1]; }
1571 ElementsKind elements_kind() const { return hydrogen()->elements_kind(); }
1572 bool is_fixed_typed_array() const {
1573 return hydrogen()->is_fixed_typed_array();
1576 DECLARE_CONCRETE_INSTRUCTION(LoadKeyed, "load-keyed")
1577 DECLARE_HYDROGEN_ACCESSOR(LoadKeyed)
1579 void PrintDataTo(StringStream* stream) override;
1580 uint32_t base_offset() const { return hydrogen()->base_offset(); }
1584 class LLoadKeyedGeneric final : public LTemplateInstruction<1, 3, 1> {
1586 LLoadKeyedGeneric(LOperand* context, LOperand* object, LOperand* key,
1588 inputs_[0] = context;
1589 inputs_[1] = object;
1594 LOperand* context() { return inputs_[0]; }
1595 LOperand* object() { return inputs_[1]; }
1596 LOperand* key() { return inputs_[2]; }
1597 LOperand* temp_vector() { return temps_[0]; }
1599 DECLARE_CONCRETE_INSTRUCTION(LoadKeyedGeneric, "load-keyed-generic")
1600 DECLARE_HYDROGEN_ACCESSOR(LoadKeyedGeneric)
1604 class LLoadGlobalGeneric final : public LTemplateInstruction<1, 2, 1> {
1606 LLoadGlobalGeneric(LOperand* context, LOperand* global_object,
1608 inputs_[0] = context;
1609 inputs_[1] = global_object;
1613 LOperand* context() { return inputs_[0]; }
1614 LOperand* global_object() { return inputs_[1]; }
1615 LOperand* temp_vector() { return temps_[0]; }
1617 DECLARE_CONCRETE_INSTRUCTION(LoadGlobalGeneric, "load-global-generic")
1618 DECLARE_HYDROGEN_ACCESSOR(LoadGlobalGeneric)
1620 Handle<Object> name() const { return hydrogen()->name(); }
1621 TypeofMode typeof_mode() const { return hydrogen()->typeof_mode(); }
1625 class LLoadGlobalViaContext final : public LTemplateInstruction<1, 1, 1> {
1627 explicit LLoadGlobalViaContext(LOperand* context) { inputs_[0] = context; }
1629 DECLARE_CONCRETE_INSTRUCTION(LoadGlobalViaContext, "load-global-via-context")
1630 DECLARE_HYDROGEN_ACCESSOR(LoadGlobalViaContext)
1632 void PrintDataTo(StringStream* stream) override;
1634 LOperand* context() { return inputs_[0]; }
1636 int depth() const { return hydrogen()->depth(); }
1637 int slot_index() const { return hydrogen()->slot_index(); }
1641 class LLoadContextSlot final : public LTemplateInstruction<1, 1, 0> {
1643 explicit LLoadContextSlot(LOperand* context) { inputs_[0] = context; }
1645 LOperand* context() { return inputs_[0]; }
1647 DECLARE_CONCRETE_INSTRUCTION(LoadContextSlot, "load-context-slot")
1648 DECLARE_HYDROGEN_ACCESSOR(LoadContextSlot)
1650 int slot_index() { return hydrogen()->slot_index(); }
1652 void PrintDataTo(StringStream* stream) override;
1656 class LStoreContextSlot final : public LTemplateInstruction<0, 2, 0> {
1658 LStoreContextSlot(LOperand* context, LOperand* value) {
1659 inputs_[0] = context;
1663 LOperand* context() { return inputs_[0]; }
1664 LOperand* value() { return inputs_[1]; }
1666 DECLARE_CONCRETE_INSTRUCTION(StoreContextSlot, "store-context-slot")
1667 DECLARE_HYDROGEN_ACCESSOR(StoreContextSlot)
1669 int slot_index() { return hydrogen()->slot_index(); }
1671 void PrintDataTo(StringStream* stream) override;
1675 class LPushArgument final : public LTemplateInstruction<0, 1, 0> {
1677 explicit LPushArgument(LOperand* value) { inputs_[0] = value; }
1679 LOperand* value() { return inputs_[0]; }
1681 DECLARE_CONCRETE_INSTRUCTION(PushArgument, "push-argument")
1685 class LDrop final : public LTemplateInstruction<0, 0, 0> {
1687 explicit LDrop(int count) : count_(count) {}
1689 int count() const { return count_; }
1691 DECLARE_CONCRETE_INSTRUCTION(Drop, "drop")
1698 class LStoreCodeEntry final : public LTemplateInstruction<0, 2, 0> {
1700 LStoreCodeEntry(LOperand* function, LOperand* code_object) {
1701 inputs_[0] = function;
1702 inputs_[1] = code_object;
1705 LOperand* function() { return inputs_[0]; }
1706 LOperand* code_object() { return inputs_[1]; }
1708 void PrintDataTo(StringStream* stream) override;
1710 DECLARE_CONCRETE_INSTRUCTION(StoreCodeEntry, "store-code-entry")
1711 DECLARE_HYDROGEN_ACCESSOR(StoreCodeEntry)
1715 class LInnerAllocatedObject final : public LTemplateInstruction<1, 2, 0> {
1717 LInnerAllocatedObject(LOperand* base_object, LOperand* offset) {
1718 inputs_[0] = base_object;
1719 inputs_[1] = offset;
1722 LOperand* base_object() const { return inputs_[0]; }
1723 LOperand* offset() const { return inputs_[1]; }
1725 void PrintDataTo(StringStream* stream) override;
1727 DECLARE_CONCRETE_INSTRUCTION(InnerAllocatedObject, "inner-allocated-object")
1731 class LThisFunction final : public LTemplateInstruction<1, 0, 0> {
1733 DECLARE_CONCRETE_INSTRUCTION(ThisFunction, "this-function")
1734 DECLARE_HYDROGEN_ACCESSOR(ThisFunction)
1738 class LContext final : public LTemplateInstruction<1, 0, 0> {
1740 DECLARE_CONCRETE_INSTRUCTION(Context, "context")
1741 DECLARE_HYDROGEN_ACCESSOR(Context)
1745 class LDeclareGlobals final : public LTemplateInstruction<0, 1, 0> {
1747 explicit LDeclareGlobals(LOperand* context) { inputs_[0] = context; }
1749 LOperand* context() { return inputs_[0]; }
1751 DECLARE_CONCRETE_INSTRUCTION(DeclareGlobals, "declare-globals")
1752 DECLARE_HYDROGEN_ACCESSOR(DeclareGlobals)
1756 class LCallJSFunction final : public LTemplateInstruction<1, 1, 0> {
1758 explicit LCallJSFunction(LOperand* function) { inputs_[0] = function; }
1760 LOperand* function() { return inputs_[0]; }
1762 DECLARE_CONCRETE_INSTRUCTION(CallJSFunction, "call-js-function")
1763 DECLARE_HYDROGEN_ACCESSOR(CallJSFunction)
1765 void PrintDataTo(StringStream* stream) override;
1767 int arity() const { return hydrogen()->argument_count() - 1; }
1771 class LCallWithDescriptor final : public LTemplateResultInstruction<1> {
1773 LCallWithDescriptor(CallInterfaceDescriptor descriptor,
1774 const ZoneList<LOperand*>& operands, Zone* zone)
1775 : descriptor_(descriptor),
1776 inputs_(descriptor.GetRegisterParameterCount() +
1777 kImplicitRegisterParameterCount,
1779 DCHECK(descriptor.GetRegisterParameterCount() +
1780 kImplicitRegisterParameterCount ==
1782 inputs_.AddAll(operands, zone);
1785 LOperand* target() const { return inputs_[0]; }
1787 const CallInterfaceDescriptor descriptor() { return descriptor_; }
1789 DECLARE_HYDROGEN_ACCESSOR(CallWithDescriptor)
1791 // The target and context are passed as implicit parameters that are not
1792 // explicitly listed in the descriptor.
1793 static const int kImplicitRegisterParameterCount = 2;
1796 DECLARE_CONCRETE_INSTRUCTION(CallWithDescriptor, "call-with-descriptor")
1798 void PrintDataTo(StringStream* stream) override;
1800 int arity() const { return hydrogen()->argument_count() - 1; }
1802 CallInterfaceDescriptor descriptor_;
1803 ZoneList<LOperand*> inputs_;
1805 // Iterator support.
1806 int InputCount() final { return inputs_.length(); }
1807 LOperand* InputAt(int i) final { return inputs_[i]; }
1809 int TempCount() final { return 0; }
1810 LOperand* TempAt(int i) final { return NULL; }
1814 class LInvokeFunction final : public LTemplateInstruction<1, 2, 0> {
1816 LInvokeFunction(LOperand* context, LOperand* function) {
1817 inputs_[0] = context;
1818 inputs_[1] = function;
1821 LOperand* context() { return inputs_[0]; }
1822 LOperand* function() { return inputs_[1]; }
1824 DECLARE_CONCRETE_INSTRUCTION(InvokeFunction, "invoke-function")
1825 DECLARE_HYDROGEN_ACCESSOR(InvokeFunction)
1827 void PrintDataTo(StringStream* stream) override;
1829 int arity() const { return hydrogen()->argument_count() - 1; }
1833 class LCallFunction final : public LTemplateInstruction<1, 2, 2> {
1835 LCallFunction(LOperand* context, LOperand* function, LOperand* slot,
1837 inputs_[0] = context;
1838 inputs_[1] = function;
1843 LOperand* context() { return inputs_[0]; }
1844 LOperand* function() { return inputs_[1]; }
1845 LOperand* temp_slot() { return temps_[0]; }
1846 LOperand* temp_vector() { return temps_[1]; }
1848 DECLARE_CONCRETE_INSTRUCTION(CallFunction, "call-function")
1849 DECLARE_HYDROGEN_ACCESSOR(CallFunction)
1851 int arity() const { return hydrogen()->argument_count() - 1; }
1852 void PrintDataTo(StringStream* stream) override;
1856 class LCallNew final : public LTemplateInstruction<1, 2, 0> {
1858 LCallNew(LOperand* context, LOperand* constructor) {
1859 inputs_[0] = context;
1860 inputs_[1] = constructor;
1863 LOperand* context() { return inputs_[0]; }
1864 LOperand* constructor() { return inputs_[1]; }
1866 DECLARE_CONCRETE_INSTRUCTION(CallNew, "call-new")
1867 DECLARE_HYDROGEN_ACCESSOR(CallNew)
1869 void PrintDataTo(StringStream* stream) override;
1871 int arity() const { return hydrogen()->argument_count() - 1; }
1875 class LCallNewArray final : public LTemplateInstruction<1, 2, 0> {
1877 LCallNewArray(LOperand* context, LOperand* constructor) {
1878 inputs_[0] = context;
1879 inputs_[1] = constructor;
1882 LOperand* context() { return inputs_[0]; }
1883 LOperand* constructor() { return inputs_[1]; }
1885 DECLARE_CONCRETE_INSTRUCTION(CallNewArray, "call-new-array")
1886 DECLARE_HYDROGEN_ACCESSOR(CallNewArray)
1888 void PrintDataTo(StringStream* stream) override;
1890 int arity() const { return hydrogen()->argument_count() - 1; }
1894 class LCallRuntime final : public LTemplateInstruction<1, 1, 0> {
1896 explicit LCallRuntime(LOperand* context) { inputs_[0] = context; }
1898 LOperand* context() { return inputs_[0]; }
1900 DECLARE_CONCRETE_INSTRUCTION(CallRuntime, "call-runtime")
1901 DECLARE_HYDROGEN_ACCESSOR(CallRuntime)
1903 bool ClobbersDoubleRegisters(Isolate* isolate) const override {
1904 return save_doubles() == kDontSaveFPRegs;
1907 const Runtime::Function* function() const { return hydrogen()->function(); }
1908 int arity() const { return hydrogen()->argument_count(); }
1909 SaveFPRegsMode save_doubles() const { return hydrogen()->save_doubles(); }
1913 class LInteger32ToDouble final : public LTemplateInstruction<1, 1, 0> {
1915 explicit LInteger32ToDouble(LOperand* value) { inputs_[0] = value; }
1917 LOperand* value() { return inputs_[0]; }
1919 DECLARE_CONCRETE_INSTRUCTION(Integer32ToDouble, "int32-to-double")
1923 class LUint32ToDouble final : public LTemplateInstruction<1, 1, 0> {
1925 explicit LUint32ToDouble(LOperand* value) { inputs_[0] = value; }
1927 LOperand* value() { return inputs_[0]; }
1929 DECLARE_CONCRETE_INSTRUCTION(Uint32ToDouble, "uint32-to-double")
1933 class LNumberTagI final : public LTemplateInstruction<1, 1, 2> {
1935 LNumberTagI(LOperand* value, LOperand* temp1, LOperand* temp2) {
1941 LOperand* value() { return inputs_[0]; }
1942 LOperand* temp1() { return temps_[0]; }
1943 LOperand* temp2() { return temps_[1]; }
1945 DECLARE_CONCRETE_INSTRUCTION(NumberTagI, "number-tag-i")
1949 class LNumberTagU final : public LTemplateInstruction<1, 1, 2> {
1951 LNumberTagU(LOperand* value, LOperand* temp1, LOperand* temp2) {
1957 LOperand* value() { return inputs_[0]; }
1958 LOperand* temp1() { return temps_[0]; }
1959 LOperand* temp2() { return temps_[1]; }
1961 DECLARE_CONCRETE_INSTRUCTION(NumberTagU, "number-tag-u")
1965 class LNumberTagD final : public LTemplateInstruction<1, 1, 2> {
1967 LNumberTagD(LOperand* value, LOperand* temp, LOperand* temp2) {
1973 LOperand* value() { return inputs_[0]; }
1974 LOperand* temp() { return temps_[0]; }
1975 LOperand* temp2() { return temps_[1]; }
1977 DECLARE_CONCRETE_INSTRUCTION(NumberTagD, "number-tag-d")
1978 DECLARE_HYDROGEN_ACCESSOR(Change)
1982 class LDoubleToSmi final : public LTemplateInstruction<1, 1, 0> {
1984 explicit LDoubleToSmi(LOperand* value) { inputs_[0] = value; }
1986 LOperand* value() { return inputs_[0]; }
1988 DECLARE_CONCRETE_INSTRUCTION(DoubleToSmi, "double-to-smi")
1989 DECLARE_HYDROGEN_ACCESSOR(UnaryOperation)
1991 bool truncating() { return hydrogen()->CanTruncateToInt32(); }
1995 // Sometimes truncating conversion from a tagged value to an int32.
1996 class LDoubleToI final : public LTemplateInstruction<1, 1, 0> {
1998 explicit LDoubleToI(LOperand* value) { inputs_[0] = value; }
2000 LOperand* value() { return inputs_[0]; }
2002 DECLARE_CONCRETE_INSTRUCTION(DoubleToI, "double-to-i")
2003 DECLARE_HYDROGEN_ACCESSOR(UnaryOperation)
2005 bool truncating() { return hydrogen()->CanTruncateToInt32(); }
2009 // Truncating conversion from a tagged value to an int32.
2010 class LTaggedToI final : public LTemplateInstruction<1, 1, 2> {
2012 LTaggedToI(LOperand* value, LOperand* temp, LOperand* temp2) {
2018 LOperand* value() { return inputs_[0]; }
2019 LOperand* temp() { return temps_[0]; }
2020 LOperand* temp2() { return temps_[1]; }
2022 DECLARE_CONCRETE_INSTRUCTION(TaggedToI, "tagged-to-i")
2023 DECLARE_HYDROGEN_ACCESSOR(Change)
2025 bool truncating() { return hydrogen()->CanTruncateToInt32(); }
2029 class LSmiTag final : public LTemplateInstruction<1, 1, 0> {
2031 explicit LSmiTag(LOperand* value) { inputs_[0] = value; }
2033 LOperand* value() { return inputs_[0]; }
2035 DECLARE_CONCRETE_INSTRUCTION(SmiTag, "smi-tag")
2036 DECLARE_HYDROGEN_ACCESSOR(Change)
2040 class LNumberUntagD final : public LTemplateInstruction<1, 1, 0> {
2042 explicit LNumberUntagD(LOperand* value) { inputs_[0] = value; }
2044 LOperand* value() { return inputs_[0]; }
2046 DECLARE_CONCRETE_INSTRUCTION(NumberUntagD, "double-untag")
2047 DECLARE_HYDROGEN_ACCESSOR(Change)
2051 class LSmiUntag final : public LTemplateInstruction<1, 1, 0> {
2053 LSmiUntag(LOperand* value, bool needs_check) : needs_check_(needs_check) {
2057 LOperand* value() { return inputs_[0]; }
2058 bool needs_check() const { return needs_check_; }
2060 DECLARE_CONCRETE_INSTRUCTION(SmiUntag, "smi-untag")
2067 class LStoreNamedField final : public LTemplateInstruction<0, 2, 1> {
2069 LStoreNamedField(LOperand* object, LOperand* value, LOperand* temp) {
2070 inputs_[0] = object;
2075 LOperand* object() { return inputs_[0]; }
2076 LOperand* value() { return inputs_[1]; }
2077 LOperand* temp() { return temps_[0]; }
2079 DECLARE_CONCRETE_INSTRUCTION(StoreNamedField, "store-named-field")
2080 DECLARE_HYDROGEN_ACCESSOR(StoreNamedField)
2082 void PrintDataTo(StringStream* stream) override;
2084 Representation representation() const {
2085 return hydrogen()->field_representation();
2090 class LStoreNamedGeneric final : public LTemplateInstruction<0, 3, 2> {
2092 LStoreNamedGeneric(LOperand* context, LOperand* object, LOperand* value,
2093 LOperand* slot, LOperand* vector) {
2094 inputs_[0] = context;
2095 inputs_[1] = object;
2101 LOperand* context() { return inputs_[0]; }
2102 LOperand* object() { return inputs_[1]; }
2103 LOperand* value() { return inputs_[2]; }
2104 LOperand* temp_slot() { return temps_[0]; }
2105 LOperand* temp_vector() { return temps_[1]; }
2107 DECLARE_CONCRETE_INSTRUCTION(StoreNamedGeneric, "store-named-generic")
2108 DECLARE_HYDROGEN_ACCESSOR(StoreNamedGeneric)
2110 void PrintDataTo(StringStream* stream) override;
2112 Handle<Object> name() const { return hydrogen()->name(); }
2113 LanguageMode language_mode() { return hydrogen()->language_mode(); }
2117 class LStoreGlobalViaContext final : public LTemplateInstruction<0, 2, 0> {
2119 LStoreGlobalViaContext(LOperand* context, LOperand* value) {
2120 inputs_[0] = context;
2124 LOperand* context() { return inputs_[0]; }
2125 LOperand* value() { return inputs_[1]; }
2127 DECLARE_CONCRETE_INSTRUCTION(StoreGlobalViaContext,
2128 "store-global-via-context")
2129 DECLARE_HYDROGEN_ACCESSOR(StoreGlobalViaContext)
2131 void PrintDataTo(StringStream* stream) override;
2133 int depth() { return hydrogen()->depth(); }
2134 int slot_index() { return hydrogen()->slot_index(); }
2135 LanguageMode language_mode() { return hydrogen()->language_mode(); }
2139 class LStoreKeyed final : public LTemplateInstruction<0, 3, 0> {
2141 LStoreKeyed(LOperand* object, LOperand* key, LOperand* value) {
2142 inputs_[0] = object;
2147 bool is_fixed_typed_array() const {
2148 return hydrogen()->is_fixed_typed_array();
2150 LOperand* elements() { return inputs_[0]; }
2151 LOperand* key() { return inputs_[1]; }
2152 LOperand* value() { return inputs_[2]; }
2153 ElementsKind elements_kind() const { return hydrogen()->elements_kind(); }
2155 DECLARE_CONCRETE_INSTRUCTION(StoreKeyed, "store-keyed")
2156 DECLARE_HYDROGEN_ACCESSOR(StoreKeyed)
2158 void PrintDataTo(StringStream* stream) override;
2159 bool NeedsCanonicalization() {
2160 if (hydrogen()->value()->IsAdd() || hydrogen()->value()->IsSub() ||
2161 hydrogen()->value()->IsMul() || hydrogen()->value()->IsDiv()) {
2164 return hydrogen()->NeedsCanonicalization();
2166 uint32_t base_offset() const { return hydrogen()->base_offset(); }
2170 class LStoreKeyedGeneric final : public LTemplateInstruction<0, 4, 2> {
2172 LStoreKeyedGeneric(LOperand* context, LOperand* object, LOperand* key,
2173 LOperand* value, LOperand* slot, LOperand* vector) {
2174 inputs_[0] = context;
2175 inputs_[1] = object;
2182 LOperand* context() { return inputs_[0]; }
2183 LOperand* object() { return inputs_[1]; }
2184 LOperand* key() { return inputs_[2]; }
2185 LOperand* value() { return inputs_[3]; }
2186 LOperand* temp_slot() { return temps_[0]; }
2187 LOperand* temp_vector() { return temps_[1]; }
2189 DECLARE_CONCRETE_INSTRUCTION(StoreKeyedGeneric, "store-keyed-generic")
2190 DECLARE_HYDROGEN_ACCESSOR(StoreKeyedGeneric)
2192 void PrintDataTo(StringStream* stream) override;
2194 LanguageMode language_mode() { return hydrogen()->language_mode(); }
2198 class LTransitionElementsKind final : public LTemplateInstruction<0, 2, 1> {
2200 LTransitionElementsKind(LOperand* object, LOperand* context,
2201 LOperand* new_map_temp) {
2202 inputs_[0] = object;
2203 inputs_[1] = context;
2204 temps_[0] = new_map_temp;
2207 LOperand* context() { return inputs_[1]; }
2208 LOperand* object() { return inputs_[0]; }
2209 LOperand* new_map_temp() { return temps_[0]; }
2211 DECLARE_CONCRETE_INSTRUCTION(TransitionElementsKind,
2212 "transition-elements-kind")
2213 DECLARE_HYDROGEN_ACCESSOR(TransitionElementsKind)
2215 void PrintDataTo(StringStream* stream) override;
2217 Handle<Map> original_map() { return hydrogen()->original_map().handle(); }
2218 Handle<Map> transitioned_map() {
2219 return hydrogen()->transitioned_map().handle();
2221 ElementsKind from_kind() { return hydrogen()->from_kind(); }
2222 ElementsKind to_kind() { return hydrogen()->to_kind(); }
2226 class LTrapAllocationMemento final : public LTemplateInstruction<0, 1, 1> {
2228 LTrapAllocationMemento(LOperand* object, LOperand* temp) {
2229 inputs_[0] = object;
2233 LOperand* object() { return inputs_[0]; }
2234 LOperand* temp() { return temps_[0]; }
2236 DECLARE_CONCRETE_INSTRUCTION(TrapAllocationMemento, "trap-allocation-memento")
2240 class LMaybeGrowElements final : public LTemplateInstruction<1, 5, 0> {
2242 LMaybeGrowElements(LOperand* context, LOperand* object, LOperand* elements,
2243 LOperand* key, LOperand* current_capacity) {
2244 inputs_[0] = context;
2245 inputs_[1] = object;
2246 inputs_[2] = elements;
2248 inputs_[4] = current_capacity;
2251 LOperand* context() { return inputs_[0]; }
2252 LOperand* object() { return inputs_[1]; }
2253 LOperand* elements() { return inputs_[2]; }
2254 LOperand* key() { return inputs_[3]; }
2255 LOperand* current_capacity() { return inputs_[4]; }
2257 DECLARE_HYDROGEN_ACCESSOR(MaybeGrowElements)
2258 DECLARE_CONCRETE_INSTRUCTION(MaybeGrowElements, "maybe-grow-elements")
2262 class LStringAdd final : public LTemplateInstruction<1, 3, 0> {
2264 LStringAdd(LOperand* context, LOperand* left, LOperand* right) {
2265 inputs_[0] = context;
2270 LOperand* context() { return inputs_[0]; }
2271 LOperand* left() { return inputs_[1]; }
2272 LOperand* right() { return inputs_[2]; }
2274 DECLARE_CONCRETE_INSTRUCTION(StringAdd, "string-add")
2275 DECLARE_HYDROGEN_ACCESSOR(StringAdd)
2279 class LStringCharCodeAt final : public LTemplateInstruction<1, 3, 0> {
2281 LStringCharCodeAt(LOperand* context, LOperand* string, LOperand* index) {
2282 inputs_[0] = context;
2283 inputs_[1] = string;
2287 LOperand* context() { return inputs_[0]; }
2288 LOperand* string() { return inputs_[1]; }
2289 LOperand* index() { return inputs_[2]; }
2291 DECLARE_CONCRETE_INSTRUCTION(StringCharCodeAt, "string-char-code-at")
2292 DECLARE_HYDROGEN_ACCESSOR(StringCharCodeAt)
2296 class LStringCharFromCode final : public LTemplateInstruction<1, 2, 0> {
2298 explicit LStringCharFromCode(LOperand* context, LOperand* char_code) {
2299 inputs_[0] = context;
2300 inputs_[1] = char_code;
2303 LOperand* context() { return inputs_[0]; }
2304 LOperand* char_code() { return inputs_[1]; }
2306 DECLARE_CONCRETE_INSTRUCTION(StringCharFromCode, "string-char-from-code")
2307 DECLARE_HYDROGEN_ACCESSOR(StringCharFromCode)
2311 class LCheckValue final : public LTemplateInstruction<0, 1, 0> {
2313 explicit LCheckValue(LOperand* value) { inputs_[0] = value; }
2315 LOperand* value() { return inputs_[0]; }
2317 DECLARE_CONCRETE_INSTRUCTION(CheckValue, "check-value")
2318 DECLARE_HYDROGEN_ACCESSOR(CheckValue)
2322 class LCheckArrayBufferNotNeutered final
2323 : public LTemplateInstruction<0, 1, 0> {
2325 explicit LCheckArrayBufferNotNeutered(LOperand* view) { inputs_[0] = view; }
2327 LOperand* view() { return inputs_[0]; }
2329 DECLARE_CONCRETE_INSTRUCTION(CheckArrayBufferNotNeutered,
2330 "check-array-buffer-not-neutered")
2331 DECLARE_HYDROGEN_ACCESSOR(CheckArrayBufferNotNeutered)
2335 class LCheckInstanceType final : public LTemplateInstruction<0, 1, 0> {
2337 explicit LCheckInstanceType(LOperand* value) { inputs_[0] = value; }
2339 LOperand* value() { return inputs_[0]; }
2341 DECLARE_CONCRETE_INSTRUCTION(CheckInstanceType, "check-instance-type")
2342 DECLARE_HYDROGEN_ACCESSOR(CheckInstanceType)
2346 class LCheckMaps final : public LTemplateInstruction<0, 1, 1> {
2348 explicit LCheckMaps(LOperand* value = NULL, LOperand* temp = NULL) {
2353 LOperand* value() { return inputs_[0]; }
2354 LOperand* temp() { return temps_[0]; }
2356 DECLARE_CONCRETE_INSTRUCTION(CheckMaps, "check-maps")
2357 DECLARE_HYDROGEN_ACCESSOR(CheckMaps)
2361 class LCheckSmi final : public LTemplateInstruction<1, 1, 0> {
2363 explicit LCheckSmi(LOperand* value) { inputs_[0] = value; }
2365 LOperand* value() { return inputs_[0]; }
2367 DECLARE_CONCRETE_INSTRUCTION(CheckSmi, "check-smi")
2371 class LCheckNonSmi final : public LTemplateInstruction<0, 1, 0> {
2373 explicit LCheckNonSmi(LOperand* value) { inputs_[0] = value; }
2375 LOperand* value() { return inputs_[0]; }
2377 DECLARE_CONCRETE_INSTRUCTION(CheckNonSmi, "check-non-smi")
2378 DECLARE_HYDROGEN_ACCESSOR(CheckHeapObject)
2382 class LClampDToUint8 final : public LTemplateInstruction<1, 1, 0> {
2384 explicit LClampDToUint8(LOperand* unclamped) { inputs_[0] = unclamped; }
2386 LOperand* unclamped() { return inputs_[0]; }
2388 DECLARE_CONCRETE_INSTRUCTION(ClampDToUint8, "clamp-d-to-uint8")
2392 class LClampIToUint8 final : public LTemplateInstruction<1, 1, 0> {
2394 explicit LClampIToUint8(LOperand* unclamped) { inputs_[0] = unclamped; }
2396 LOperand* unclamped() { return inputs_[0]; }
2398 DECLARE_CONCRETE_INSTRUCTION(ClampIToUint8, "clamp-i-to-uint8")
2402 class LClampTToUint8 final : public LTemplateInstruction<1, 1, 1> {
2404 LClampTToUint8(LOperand* unclamped, LOperand* temp) {
2405 inputs_[0] = unclamped;
2409 LOperand* unclamped() { return inputs_[0]; }
2410 LOperand* temp() { return temps_[0]; }
2412 DECLARE_CONCRETE_INSTRUCTION(ClampTToUint8, "clamp-t-to-uint8")
2416 class LDoubleBits final : public LTemplateInstruction<1, 1, 0> {
2418 explicit LDoubleBits(LOperand* value) { inputs_[0] = value; }
2420 LOperand* value() { return inputs_[0]; }
2422 DECLARE_CONCRETE_INSTRUCTION(DoubleBits, "double-bits")
2423 DECLARE_HYDROGEN_ACCESSOR(DoubleBits)
2427 class LConstructDouble final : public LTemplateInstruction<1, 2, 0> {
2429 LConstructDouble(LOperand* hi, LOperand* lo) {
2434 LOperand* hi() { return inputs_[0]; }
2435 LOperand* lo() { return inputs_[1]; }
2437 DECLARE_CONCRETE_INSTRUCTION(ConstructDouble, "construct-double")
2441 class LAllocate final : public LTemplateInstruction<1, 2, 2> {
2443 LAllocate(LOperand* context, LOperand* size, LOperand* temp1,
2445 inputs_[0] = context;
2451 LOperand* context() { return inputs_[0]; }
2452 LOperand* size() { return inputs_[1]; }
2453 LOperand* temp1() { return temps_[0]; }
2454 LOperand* temp2() { return temps_[1]; }
2456 DECLARE_CONCRETE_INSTRUCTION(Allocate, "allocate")
2457 DECLARE_HYDROGEN_ACCESSOR(Allocate)
2461 class LRegExpLiteral final : public LTemplateInstruction<1, 1, 0> {
2463 explicit LRegExpLiteral(LOperand* context) { inputs_[0] = context; }
2465 LOperand* context() { return inputs_[0]; }
2467 DECLARE_CONCRETE_INSTRUCTION(RegExpLiteral, "regexp-literal")
2468 DECLARE_HYDROGEN_ACCESSOR(RegExpLiteral)
2472 class LFunctionLiteral final : public LTemplateInstruction<1, 1, 0> {
2474 explicit LFunctionLiteral(LOperand* context) { inputs_[0] = context; }
2476 LOperand* context() { return inputs_[0]; }
2478 DECLARE_CONCRETE_INSTRUCTION(FunctionLiteral, "function-literal")
2479 DECLARE_HYDROGEN_ACCESSOR(FunctionLiteral)
2483 class LToFastProperties final : public LTemplateInstruction<1, 1, 0> {
2485 explicit LToFastProperties(LOperand* value) { inputs_[0] = value; }
2487 LOperand* value() { return inputs_[0]; }
2489 DECLARE_CONCRETE_INSTRUCTION(ToFastProperties, "to-fast-properties")
2490 DECLARE_HYDROGEN_ACCESSOR(ToFastProperties)
2494 class LTypeof final : public LTemplateInstruction<1, 2, 0> {
2496 LTypeof(LOperand* context, LOperand* value) {
2497 inputs_[0] = context;
2501 LOperand* context() { return inputs_[0]; }
2502 LOperand* value() { return inputs_[1]; }
2504 DECLARE_CONCRETE_INSTRUCTION(Typeof, "typeof")
2508 class LTypeofIsAndBranch final : public LControlInstruction<1, 0> {
2510 explicit LTypeofIsAndBranch(LOperand* value) { inputs_[0] = value; }
2512 LOperand* value() { return inputs_[0]; }
2514 DECLARE_CONCRETE_INSTRUCTION(TypeofIsAndBranch, "typeof-is-and-branch")
2515 DECLARE_HYDROGEN_ACCESSOR(TypeofIsAndBranch)
2517 Handle<String> type_literal() { return hydrogen()->type_literal(); }
2519 void PrintDataTo(StringStream* stream) override;
2523 class LIsConstructCallAndBranch final : public LControlInstruction<0, 1> {
2525 explicit LIsConstructCallAndBranch(LOperand* temp) { temps_[0] = temp; }
2527 LOperand* temp() { return temps_[0]; }
2529 DECLARE_CONCRETE_INSTRUCTION(IsConstructCallAndBranch,
2530 "is-construct-call-and-branch")
2534 class LOsrEntry final : public LTemplateInstruction<0, 0, 0> {
2538 bool HasInterestingComment(LCodeGen* gen) const override { return false; }
2539 DECLARE_CONCRETE_INSTRUCTION(OsrEntry, "osr-entry")
2543 class LStackCheck final : public LTemplateInstruction<0, 1, 0> {
2545 explicit LStackCheck(LOperand* context) { inputs_[0] = context; }
2547 LOperand* context() { return inputs_[0]; }
2549 DECLARE_CONCRETE_INSTRUCTION(StackCheck, "stack-check")
2550 DECLARE_HYDROGEN_ACCESSOR(StackCheck)
2552 Label* done_label() { return &done_label_; }
2559 class LForInPrepareMap final : public LTemplateInstruction<1, 2, 0> {
2561 LForInPrepareMap(LOperand* context, LOperand* object) {
2562 inputs_[0] = context;
2563 inputs_[1] = object;
2566 LOperand* context() { return inputs_[0]; }
2567 LOperand* object() { return inputs_[1]; }
2569 DECLARE_CONCRETE_INSTRUCTION(ForInPrepareMap, "for-in-prepare-map")
2573 class LForInCacheArray final : public LTemplateInstruction<1, 1, 0> {
2575 explicit LForInCacheArray(LOperand* map) { inputs_[0] = map; }
2577 LOperand* map() { return inputs_[0]; }
2579 DECLARE_CONCRETE_INSTRUCTION(ForInCacheArray, "for-in-cache-array")
2581 int idx() { return HForInCacheArray::cast(this->hydrogen_value())->idx(); }
2585 class LCheckMapValue final : public LTemplateInstruction<0, 2, 0> {
2587 LCheckMapValue(LOperand* value, LOperand* map) {
2592 LOperand* value() { return inputs_[0]; }
2593 LOperand* map() { return inputs_[1]; }
2595 DECLARE_CONCRETE_INSTRUCTION(CheckMapValue, "check-map-value")
2599 class LLoadFieldByIndex final : public LTemplateInstruction<1, 2, 0> {
2601 LLoadFieldByIndex(LOperand* object, LOperand* index) {
2602 inputs_[0] = object;
2606 LOperand* object() { return inputs_[0]; }
2607 LOperand* index() { return inputs_[1]; }
2609 DECLARE_CONCRETE_INSTRUCTION(LoadFieldByIndex, "load-field-by-index")
2613 class LStoreFrameContext : public LTemplateInstruction<0, 1, 0> {
2615 explicit LStoreFrameContext(LOperand* context) { inputs_[0] = context; }
2617 LOperand* context() { return inputs_[0]; }
2619 DECLARE_CONCRETE_INSTRUCTION(StoreFrameContext, "store-frame-context")
2623 class LAllocateBlockContext : public LTemplateInstruction<1, 2, 0> {
2625 LAllocateBlockContext(LOperand* context, LOperand* function) {
2626 inputs_[0] = context;
2627 inputs_[1] = function;
2630 LOperand* context() { return inputs_[0]; }
2631 LOperand* function() { return inputs_[1]; }
2633 Handle<ScopeInfo> scope_info() { return hydrogen()->scope_info(); }
2635 DECLARE_CONCRETE_INSTRUCTION(AllocateBlockContext, "allocate-block-context")
2636 DECLARE_HYDROGEN_ACCESSOR(AllocateBlockContext)
2640 class LChunkBuilder;
2641 class LPlatformChunk final : public LChunk {
2643 LPlatformChunk(CompilationInfo* info, HGraph* graph) : LChunk(info, graph) {}
2645 int GetNextSpillIndex(RegisterKind kind);
2646 LOperand* GetNextSpillSlot(RegisterKind kind);
2650 class LChunkBuilder final : public LChunkBuilderBase {
2652 LChunkBuilder(CompilationInfo* info, HGraph* graph, LAllocator* allocator)
2653 : LChunkBuilderBase(info, graph),
2654 current_instruction_(NULL),
2655 current_block_(NULL),
2657 allocator_(allocator) {}
2659 // Build the sequence for the graph.
2660 LPlatformChunk* Build();
2662 // Declare methods that deal with the individual node types.
2663 #define DECLARE_DO(type) LInstruction* Do##type(H##type* node);
2664 HYDROGEN_CONCRETE_INSTRUCTION_LIST(DECLARE_DO)
2667 LInstruction* DoMultiplyAdd(HMul* mul, HValue* addend);
2668 LInstruction* DoMultiplySub(HValue* minuend, HMul* mul);
2669 LInstruction* DoRSub(HSub* instr);
2671 static bool HasMagicNumberForDivisor(int32_t divisor);
2673 LInstruction* DoMathFloor(HUnaryMathOperation* instr);
2674 LInstruction* DoMathRound(HUnaryMathOperation* instr);
2675 LInstruction* DoMathFround(HUnaryMathOperation* instr);
2676 LInstruction* DoMathAbs(HUnaryMathOperation* instr);
2677 LInstruction* DoMathLog(HUnaryMathOperation* instr);
2678 LInstruction* DoMathExp(HUnaryMathOperation* instr);
2679 LInstruction* DoMathSqrt(HUnaryMathOperation* instr);
2680 LInstruction* DoMathPowHalf(HUnaryMathOperation* instr);
2681 LInstruction* DoMathClz32(HUnaryMathOperation* instr);
2682 LInstruction* DoDivByPowerOf2I(HDiv* instr);
2683 LInstruction* DoDivByConstI(HDiv* instr);
2684 LInstruction* DoDivI(HDiv* instr);
2685 LInstruction* DoModByPowerOf2I(HMod* instr);
2686 LInstruction* DoModByConstI(HMod* instr);
2687 LInstruction* DoModI(HMod* instr);
2688 LInstruction* DoFlooringDivByPowerOf2I(HMathFloorOfDiv* instr);
2689 LInstruction* DoFlooringDivByConstI(HMathFloorOfDiv* instr);
2690 LInstruction* DoFlooringDivI(HMathFloorOfDiv* instr);
2693 // Methods for getting operands for Use / Define / Temp.
2694 LUnallocated* ToUnallocated(Register reg);
2695 LUnallocated* ToUnallocated(DoubleRegister reg);
2697 // Methods for setting up define-use relationships.
2698 MUST_USE_RESULT LOperand* Use(HValue* value, LUnallocated* operand);
2699 MUST_USE_RESULT LOperand* UseFixed(HValue* value, Register fixed_register);
2700 MUST_USE_RESULT LOperand* UseFixedDouble(HValue* value,
2701 DoubleRegister fixed_register);
2703 // A value that is guaranteed to be allocated to a register.
2704 // Operand created by UseRegister is guaranteed to be live until the end of
2705 // instruction. This means that register allocator will not reuse it's
2706 // register for any other operand inside instruction.
2707 // Operand created by UseRegisterAtStart is guaranteed to be live only at
2708 // instruction start. Register allocator is free to assign the same register
2709 // to some other operand used inside instruction (i.e. temporary or
2711 MUST_USE_RESULT LOperand* UseRegister(HValue* value);
2712 MUST_USE_RESULT LOperand* UseRegisterAtStart(HValue* value);
2714 // An input operand in a register that may be trashed.
2715 MUST_USE_RESULT LOperand* UseTempRegister(HValue* value);
2717 // An input operand in a register or stack slot.
2718 MUST_USE_RESULT LOperand* Use(HValue* value);
2719 MUST_USE_RESULT LOperand* UseAtStart(HValue* value);
2721 // An input operand in a register, stack slot or a constant operand.
2722 MUST_USE_RESULT LOperand* UseOrConstant(HValue* value);
2723 MUST_USE_RESULT LOperand* UseOrConstantAtStart(HValue* value);
2725 // An input operand in a register or a constant operand.
2726 MUST_USE_RESULT LOperand* UseRegisterOrConstant(HValue* value);
2727 MUST_USE_RESULT LOperand* UseRegisterOrConstantAtStart(HValue* value);
2729 // An input operand in a constant operand.
2730 MUST_USE_RESULT LOperand* UseConstant(HValue* value);
2732 // An input operand in register, stack slot or a constant operand.
2733 // Will not be moved to a register even if one is freely available.
2734 MUST_USE_RESULT LOperand* UseAny(HValue* value) override;
2736 // Temporary operand that must be in a register.
2737 MUST_USE_RESULT LUnallocated* TempRegister();
2738 MUST_USE_RESULT LUnallocated* TempDoubleRegister();
2739 MUST_USE_RESULT LOperand* FixedTemp(Register reg);
2740 MUST_USE_RESULT LOperand* FixedTemp(DoubleRegister reg);
2742 // Methods for setting up define-use relationships.
2743 // Return the same instruction that they are passed.
2744 LInstruction* Define(LTemplateResultInstruction<1>* instr,
2745 LUnallocated* result);
2746 LInstruction* DefineAsRegister(LTemplateResultInstruction<1>* instr);
2747 LInstruction* DefineAsSpilled(LTemplateResultInstruction<1>* instr,
2749 LInstruction* DefineSameAsFirst(LTemplateResultInstruction<1>* instr);
2750 LInstruction* DefineFixed(LTemplateResultInstruction<1>* instr, Register reg);
2751 LInstruction* DefineFixedDouble(LTemplateResultInstruction<1>* instr,
2752 DoubleRegister reg);
2753 LInstruction* AssignEnvironment(LInstruction* instr);
2754 LInstruction* AssignPointerMap(LInstruction* instr);
2756 enum CanDeoptimize { CAN_DEOPTIMIZE_EAGERLY, CANNOT_DEOPTIMIZE_EAGERLY };
2758 // By default we assume that instruction sequences generated for calls
2759 // cannot deoptimize eagerly and we do not attach environment to this
2761 LInstruction* MarkAsCall(
2762 LInstruction* instr, HInstruction* hinstr,
2763 CanDeoptimize can_deoptimize = CANNOT_DEOPTIMIZE_EAGERLY);
2765 void VisitInstruction(HInstruction* current);
2766 void AddInstruction(LInstruction* instr, HInstruction* current);
2768 void DoBasicBlock(HBasicBlock* block, HBasicBlock* next_block);
2769 LInstruction* DoShift(Token::Value op, HBitwiseBinaryOperation* instr);
2770 LInstruction* DoArithmeticD(Token::Value op,
2771 HArithmeticBinaryOperation* instr);
2772 LInstruction* DoArithmeticT(Token::Value op, HBinaryOperation* instr);
2774 HInstruction* current_instruction_;
2775 HBasicBlock* current_block_;
2776 HBasicBlock* next_block_;
2777 LAllocator* allocator_;
2779 DISALLOW_COPY_AND_ASSIGN(LChunkBuilder);
2782 #undef DECLARE_HYDROGEN_ACCESSOR
2783 #undef DECLARE_CONCRETE_INSTRUCTION
2785 } // namespace v8::internal
2787 #endif // V8_PPC_LITHIUM_PPC_H_