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_X87_LITHIUM_X87_H_
6 #define V8_X87_LITHIUM_X87_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"
18 class RCodeVisualizer;
21 // Forward declarations.
24 #define LITHIUM_CONCRETE_INSTRUCTION_LIST(V) \
25 V(AccessArgumentsAt) \
27 V(AllocateBlockContext) \
30 V(ArgumentsElements) \
38 V(CallWithDescriptor) \
44 V(CheckArrayBufferNotNeutered) \
45 V(CheckInstanceType) \
53 V(ClampTToUint8NoSSE2) \
54 V(ClassOfTestAndBranch) \
56 V(CompareMinusZeroAndBranch) \
57 V(CompareNumericAndBranch) \
58 V(CmpObjectEqAndBranch) \
82 V(FlooringDivByConstI) \
83 V(FlooringDivByPowerOf2I) \
87 V(GetCachedArrayIndex) \
89 V(HasCachedArrayIndexAndBranch) \
90 V(HasInPrototypeChainAndBranch) \
91 V(HasInstanceTypeAndBranch) \
92 V(InnerAllocatedObject) \
95 V(Integer32ToDouble) \
97 V(IsConstructCallAndBranch) \
98 V(IsStringAndBranch) \
100 V(IsUndetectableAndBranch) \
104 V(LoadFieldByIndex) \
105 V(LoadFunctionPrototype) \
106 V(LoadGlobalGeneric) \
107 V(LoadGlobalViaContext) \
109 V(LoadKeyedGeneric) \
111 V(LoadNamedGeneric) \
124 V(MaybeGrowElements) \
140 V(SeqStringGetChar) \
141 V(SeqStringSetChar) \
147 V(StoreContextSlot) \
148 V(StoreFrameContext) \
149 V(StoreGlobalViaContext) \
151 V(StoreKeyedGeneric) \
153 V(StoreNamedGeneric) \
155 V(StringCharCodeAt) \
156 V(StringCharFromCode) \
157 V(StringCompareAndBranch) \
161 V(ToFastProperties) \
162 V(TransitionElementsKind) \
163 V(TrapAllocationMemento) \
165 V(TypeofIsAndBranch) \
171 #define DECLARE_CONCRETE_INSTRUCTION(type, mnemonic) \
172 Opcode opcode() const final { return LInstruction::k##type; } \
173 void CompileToNative(LCodeGen* generator) final; \
174 const char* Mnemonic() const final { return mnemonic; } \
175 static L##type* cast(LInstruction* instr) { \
176 DCHECK(instr->Is##type()); \
177 return reinterpret_cast<L##type*>(instr); \
181 #define DECLARE_HYDROGEN_ACCESSOR(type) \
182 H##type* hydrogen() const { \
183 return H##type::cast(hydrogen_value()); \
187 class LInstruction : public ZoneObject {
190 : environment_(NULL),
191 hydrogen_value_(NULL),
192 bit_field_(IsCallBits::encode(false)) {
195 virtual ~LInstruction() {}
197 virtual void CompileToNative(LCodeGen* generator) = 0;
198 virtual const char* Mnemonic() const = 0;
199 virtual void PrintTo(StringStream* stream);
200 virtual void PrintDataTo(StringStream* stream);
201 virtual void PrintOutputOperandTo(StringStream* stream);
204 // Declare a unique enum value for each instruction.
205 #define DECLARE_OPCODE(type) k##type,
206 LITHIUM_CONCRETE_INSTRUCTION_LIST(DECLARE_OPCODE) kAdapter,
207 kNumberOfInstructions
208 #undef DECLARE_OPCODE
211 virtual Opcode opcode() const = 0;
213 // Declare non-virtual type testers for all leaf IR classes.
214 #define DECLARE_PREDICATE(type) \
215 bool Is##type() const { return opcode() == k##type; }
216 LITHIUM_CONCRETE_INSTRUCTION_LIST(DECLARE_PREDICATE)
217 #undef DECLARE_PREDICATE
219 // Declare virtual predicates for instructions that don't have
221 virtual bool IsGap() const { return false; }
223 virtual bool IsControl() const { return false; }
225 // Try deleting this instruction if possible.
226 virtual bool TryDelete() { return false; }
228 void set_environment(LEnvironment* env) { environment_ = env; }
229 LEnvironment* environment() const { return environment_; }
230 bool HasEnvironment() const { return environment_ != NULL; }
232 void set_pointer_map(LPointerMap* p) { pointer_map_.set(p); }
233 LPointerMap* pointer_map() const { return pointer_map_.get(); }
234 bool HasPointerMap() const { return pointer_map_.is_set(); }
236 void set_hydrogen_value(HValue* value) { hydrogen_value_ = value; }
237 HValue* hydrogen_value() const { return hydrogen_value_; }
239 void MarkAsCall() { bit_field_ = IsCallBits::update(bit_field_, true); }
240 bool IsCall() const { return IsCallBits::decode(bit_field_); }
242 // Interface to the register allocator and iterators.
243 bool ClobbersTemps() const { return IsCall(); }
244 bool ClobbersRegisters() const { return IsCall(); }
245 virtual bool ClobbersDoubleRegisters(Isolate* isolate) const {
247 // We only have rudimentary X87Stack tracking, thus in general
248 // cannot handle phi-nodes.
252 virtual bool HasResult() const = 0;
253 virtual LOperand* result() const = 0;
255 bool HasDoubleRegisterResult();
256 bool HasDoubleRegisterInput();
257 bool IsDoubleInput(X87Register reg, LCodeGen* cgen);
259 LOperand* FirstInput() { return InputAt(0); }
260 LOperand* Output() { return HasResult() ? result() : NULL; }
262 virtual bool HasInterestingComment(LCodeGen* gen) const { return true; }
268 virtual int InputCount() = 0;
269 virtual LOperand* InputAt(int i) = 0;
273 friend class InputIterator;
275 friend class TempIterator;
276 virtual int TempCount() = 0;
277 virtual LOperand* TempAt(int i) = 0;
279 class IsCallBits: public BitField<bool, 0, 1> {};
281 LEnvironment* environment_;
282 SetOncePointer<LPointerMap> pointer_map_;
283 HValue* hydrogen_value_;
288 // R = number of result operands (0 or 1).
290 class LTemplateResultInstruction : public LInstruction {
292 // Allow 0 or 1 output operands.
293 STATIC_ASSERT(R == 0 || R == 1);
294 bool HasResult() const final { return R != 0 && result() != NULL; }
295 void set_result(LOperand* operand) { results_[0] = operand; }
296 LOperand* result() const override { return results_[0]; }
299 EmbeddedContainer<LOperand*, R> results_;
303 // R = number of result operands (0 or 1).
304 // I = number of input operands.
305 // T = number of temporary operands.
306 template<int R, int I, int T>
307 class LTemplateInstruction : public LTemplateResultInstruction<R> {
309 EmbeddedContainer<LOperand*, I> inputs_;
310 EmbeddedContainer<LOperand*, T> temps_;
314 int InputCount() final { return I; }
315 LOperand* InputAt(int i) final { return inputs_[i]; }
317 int TempCount() final { return T; }
318 LOperand* TempAt(int i) final { return temps_[i]; }
322 class LGap : public LTemplateInstruction<0, 0, 0> {
324 explicit LGap(HBasicBlock* block) : block_(block) {
325 parallel_moves_[BEFORE] = NULL;
326 parallel_moves_[START] = NULL;
327 parallel_moves_[END] = NULL;
328 parallel_moves_[AFTER] = NULL;
331 // Can't use the DECLARE-macro here because of sub-classes.
332 bool IsGap() const final { return true; }
333 void PrintDataTo(StringStream* stream) override;
334 static LGap* cast(LInstruction* instr) {
335 DCHECK(instr->IsGap());
336 return reinterpret_cast<LGap*>(instr);
339 bool IsRedundant() const;
341 HBasicBlock* block() const { return block_; }
348 FIRST_INNER_POSITION = BEFORE,
349 LAST_INNER_POSITION = AFTER
352 LParallelMove* GetOrCreateParallelMove(InnerPosition pos, Zone* zone) {
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 LClobberDoubles final : public LTemplateInstruction<0, 0, 0> {
383 explicit LClobberDoubles(Isolate* isolate) { }
385 bool ClobbersDoubleRegisters(Isolate* isolate) const override { return true; }
387 DECLARE_CONCRETE_INSTRUCTION(ClobberDoubles, "clobber-d")
391 class LGoto final : public LTemplateInstruction<0, 0, 0> {
393 explicit LGoto(HBasicBlock* block) : block_(block) { }
395 bool HasInterestingComment(LCodeGen* gen) const override;
396 DECLARE_CONCRETE_INSTRUCTION(Goto, "goto")
397 void PrintDataTo(StringStream* stream) override;
398 bool IsControl() const override { return true; }
400 int block_id() const { return block_->block_id(); }
401 bool ClobbersDoubleRegisters(Isolate* isolate) const override {
405 bool jumps_to_join() const { return block_->predecessors()->length() > 1; }
406 HBasicBlock* block() const { return block_; }
413 class LPrologue final : public LTemplateInstruction<0, 0, 0> {
415 DECLARE_CONCRETE_INSTRUCTION(Prologue, "prologue")
419 class LLazyBailout final : public LTemplateInstruction<0, 0, 0> {
421 DECLARE_CONCRETE_INSTRUCTION(LazyBailout, "lazy-bailout")
425 class LDummy final : public LTemplateInstruction<1, 0, 0> {
428 DECLARE_CONCRETE_INSTRUCTION(Dummy, "dummy")
432 class LDummyUse final : public LTemplateInstruction<1, 1, 0> {
434 explicit LDummyUse(LOperand* value) {
437 DECLARE_CONCRETE_INSTRUCTION(DummyUse, "dummy-use")
441 class LDeoptimize final : public LTemplateInstruction<0, 0, 0> {
443 bool IsControl() const override { return true; }
444 DECLARE_CONCRETE_INSTRUCTION(Deoptimize, "deoptimize")
445 DECLARE_HYDROGEN_ACCESSOR(Deoptimize)
449 class LLabel final : public LGap {
451 explicit LLabel(HBasicBlock* block)
452 : LGap(block), replacement_(NULL) { }
454 bool HasInterestingComment(LCodeGen* gen) const override { return false; }
455 DECLARE_CONCRETE_INSTRUCTION(Label, "label")
457 void PrintDataTo(StringStream* stream) override;
459 int block_id() const { return block()->block_id(); }
460 bool is_loop_header() const { return block()->IsLoopHeader(); }
461 bool is_osr_entry() const { return block()->is_osr_entry(); }
462 Label* label() { return &label_; }
463 LLabel* replacement() const { return replacement_; }
464 void set_replacement(LLabel* label) { replacement_ = label; }
465 bool HasReplacement() const { return replacement_ != NULL; }
469 LLabel* replacement_;
473 class LParameter final : public LTemplateInstruction<1, 0, 0> {
475 bool HasInterestingComment(LCodeGen* gen) const override { return false; }
476 DECLARE_CONCRETE_INSTRUCTION(Parameter, "parameter")
480 class LCallStub final : public LTemplateInstruction<1, 1, 0> {
482 explicit LCallStub(LOperand* context) {
483 inputs_[0] = context;
486 LOperand* context() { return inputs_[0]; }
488 DECLARE_CONCRETE_INSTRUCTION(CallStub, "call-stub")
489 DECLARE_HYDROGEN_ACCESSOR(CallStub)
493 class LUnknownOSRValue final : public LTemplateInstruction<1, 0, 0> {
495 bool HasInterestingComment(LCodeGen* gen) const override { return false; }
496 DECLARE_CONCRETE_INSTRUCTION(UnknownOSRValue, "unknown-osr-value")
500 template<int I, int T>
501 class LControlInstruction: public LTemplateInstruction<0, I, T> {
503 LControlInstruction() : false_label_(NULL), true_label_(NULL) { }
505 bool IsControl() const final { return true; }
507 int SuccessorCount() { return hydrogen()->SuccessorCount(); }
508 HBasicBlock* SuccessorAt(int i) { return hydrogen()->SuccessorAt(i); }
510 int TrueDestination(LChunk* chunk) {
511 return chunk->LookupDestination(true_block_id());
513 int FalseDestination(LChunk* chunk) {
514 return chunk->LookupDestination(false_block_id());
517 Label* TrueLabel(LChunk* chunk) {
518 if (true_label_ == NULL) {
519 true_label_ = chunk->GetAssemblyLabel(TrueDestination(chunk));
523 Label* FalseLabel(LChunk* chunk) {
524 if (false_label_ == NULL) {
525 false_label_ = chunk->GetAssemblyLabel(FalseDestination(chunk));
531 int true_block_id() { return SuccessorAt(0)->block_id(); }
532 int false_block_id() { return SuccessorAt(1)->block_id(); }
535 HControlInstruction* hydrogen() {
536 return HControlInstruction::cast(this->hydrogen_value());
544 class LWrapReceiver final : public LTemplateInstruction<1, 2, 1> {
546 LWrapReceiver(LOperand* receiver,
549 inputs_[0] = receiver;
550 inputs_[1] = function;
554 LOperand* receiver() { return inputs_[0]; }
555 LOperand* function() { return inputs_[1]; }
556 LOperand* temp() { return temps_[0]; }
558 DECLARE_CONCRETE_INSTRUCTION(WrapReceiver, "wrap-receiver")
559 DECLARE_HYDROGEN_ACCESSOR(WrapReceiver)
563 class LApplyArguments final : public LTemplateInstruction<1, 4, 0> {
565 LApplyArguments(LOperand* function,
568 LOperand* elements) {
569 inputs_[0] = function;
570 inputs_[1] = receiver;
572 inputs_[3] = elements;
575 LOperand* function() { return inputs_[0]; }
576 LOperand* receiver() { return inputs_[1]; }
577 LOperand* length() { return inputs_[2]; }
578 LOperand* elements() { return inputs_[3]; }
580 DECLARE_CONCRETE_INSTRUCTION(ApplyArguments, "apply-arguments")
584 class LAccessArgumentsAt final : public LTemplateInstruction<1, 3, 0> {
586 LAccessArgumentsAt(LOperand* arguments, LOperand* length, LOperand* index) {
587 inputs_[0] = arguments;
592 LOperand* arguments() { return inputs_[0]; }
593 LOperand* length() { return inputs_[1]; }
594 LOperand* index() { return inputs_[2]; }
596 DECLARE_CONCRETE_INSTRUCTION(AccessArgumentsAt, "access-arguments-at")
598 void PrintDataTo(StringStream* stream) override;
602 class LArgumentsLength final : public LTemplateInstruction<1, 1, 0> {
604 explicit LArgumentsLength(LOperand* elements) {
605 inputs_[0] = elements;
608 LOperand* elements() { return inputs_[0]; }
610 DECLARE_CONCRETE_INSTRUCTION(ArgumentsLength, "arguments-length")
614 class LArgumentsElements final : public LTemplateInstruction<1, 0, 0> {
616 DECLARE_CONCRETE_INSTRUCTION(ArgumentsElements, "arguments-elements")
617 DECLARE_HYDROGEN_ACCESSOR(ArgumentsElements)
621 class LDebugBreak final : public LTemplateInstruction<0, 0, 0> {
623 DECLARE_CONCRETE_INSTRUCTION(DebugBreak, "break")
627 class LModByPowerOf2I final : public LTemplateInstruction<1, 1, 0> {
629 LModByPowerOf2I(LOperand* dividend, int32_t divisor) {
630 inputs_[0] = dividend;
634 LOperand* dividend() { return inputs_[0]; }
635 int32_t divisor() const { return divisor_; }
637 DECLARE_CONCRETE_INSTRUCTION(ModByPowerOf2I, "mod-by-power-of-2-i")
638 DECLARE_HYDROGEN_ACCESSOR(Mod)
645 class LModByConstI final : public LTemplateInstruction<1, 1, 2> {
647 LModByConstI(LOperand* dividend,
651 inputs_[0] = dividend;
657 LOperand* dividend() { return inputs_[0]; }
658 int32_t divisor() const { return divisor_; }
659 LOperand* temp1() { return temps_[0]; }
660 LOperand* temp2() { return temps_[1]; }
662 DECLARE_CONCRETE_INSTRUCTION(ModByConstI, "mod-by-const-i")
663 DECLARE_HYDROGEN_ACCESSOR(Mod)
670 class LModI final : public LTemplateInstruction<1, 2, 1> {
672 LModI(LOperand* left, LOperand* right, LOperand* temp) {
678 LOperand* left() { return inputs_[0]; }
679 LOperand* right() { return inputs_[1]; }
680 LOperand* temp() { return temps_[0]; }
682 DECLARE_CONCRETE_INSTRUCTION(ModI, "mod-i")
683 DECLARE_HYDROGEN_ACCESSOR(Mod)
687 class LDivByPowerOf2I final : public LTemplateInstruction<1, 1, 0> {
689 LDivByPowerOf2I(LOperand* dividend, int32_t divisor) {
690 inputs_[0] = dividend;
694 LOperand* dividend() { return inputs_[0]; }
695 int32_t divisor() const { return divisor_; }
697 DECLARE_CONCRETE_INSTRUCTION(DivByPowerOf2I, "div-by-power-of-2-i")
698 DECLARE_HYDROGEN_ACCESSOR(Div)
705 class LDivByConstI final : public LTemplateInstruction<1, 1, 2> {
707 LDivByConstI(LOperand* dividend,
711 inputs_[0] = dividend;
717 LOperand* dividend() { return inputs_[0]; }
718 int32_t divisor() const { return divisor_; }
719 LOperand* temp1() { return temps_[0]; }
720 LOperand* temp2() { return temps_[1]; }
722 DECLARE_CONCRETE_INSTRUCTION(DivByConstI, "div-by-const-i")
723 DECLARE_HYDROGEN_ACCESSOR(Div)
730 class LDivI final : public LTemplateInstruction<1, 2, 1> {
732 LDivI(LOperand* dividend, LOperand* divisor, LOperand* temp) {
733 inputs_[0] = dividend;
734 inputs_[1] = divisor;
738 LOperand* dividend() { return inputs_[0]; }
739 LOperand* divisor() { return inputs_[1]; }
740 LOperand* temp() { return temps_[0]; }
742 DECLARE_CONCRETE_INSTRUCTION(DivI, "div-i")
743 DECLARE_HYDROGEN_ACCESSOR(BinaryOperation)
747 class LFlooringDivByPowerOf2I final : public LTemplateInstruction<1, 1, 0> {
749 LFlooringDivByPowerOf2I(LOperand* dividend, int32_t divisor) {
750 inputs_[0] = dividend;
754 LOperand* dividend() { return inputs_[0]; }
755 int32_t divisor() const { return divisor_; }
757 DECLARE_CONCRETE_INSTRUCTION(FlooringDivByPowerOf2I,
758 "flooring-div-by-power-of-2-i")
759 DECLARE_HYDROGEN_ACCESSOR(MathFloorOfDiv)
766 class LFlooringDivByConstI final : public LTemplateInstruction<1, 1, 3> {
768 LFlooringDivByConstI(LOperand* dividend,
773 inputs_[0] = dividend;
780 LOperand* dividend() { return inputs_[0]; }
781 int32_t divisor() const { return divisor_; }
782 LOperand* temp1() { return temps_[0]; }
783 LOperand* temp2() { return temps_[1]; }
784 LOperand* temp3() { return temps_[2]; }
786 DECLARE_CONCRETE_INSTRUCTION(FlooringDivByConstI, "flooring-div-by-const-i")
787 DECLARE_HYDROGEN_ACCESSOR(MathFloorOfDiv)
794 class LFlooringDivI final : public LTemplateInstruction<1, 2, 1> {
796 LFlooringDivI(LOperand* dividend, LOperand* divisor, LOperand* temp) {
797 inputs_[0] = dividend;
798 inputs_[1] = divisor;
802 LOperand* dividend() { return inputs_[0]; }
803 LOperand* divisor() { return inputs_[1]; }
804 LOperand* temp() { return temps_[0]; }
806 DECLARE_CONCRETE_INSTRUCTION(FlooringDivI, "flooring-div-i")
807 DECLARE_HYDROGEN_ACCESSOR(MathFloorOfDiv)
811 class LMulI final : public LTemplateInstruction<1, 2, 1> {
813 LMulI(LOperand* left, LOperand* right, LOperand* temp) {
819 LOperand* left() { return inputs_[0]; }
820 LOperand* right() { return inputs_[1]; }
821 LOperand* temp() { return temps_[0]; }
823 DECLARE_CONCRETE_INSTRUCTION(MulI, "mul-i")
824 DECLARE_HYDROGEN_ACCESSOR(Mul)
828 class LCompareNumericAndBranch final : public LControlInstruction<2, 0> {
830 LCompareNumericAndBranch(LOperand* left, LOperand* right) {
835 LOperand* left() { return inputs_[0]; }
836 LOperand* right() { return inputs_[1]; }
838 DECLARE_CONCRETE_INSTRUCTION(CompareNumericAndBranch,
839 "compare-numeric-and-branch")
840 DECLARE_HYDROGEN_ACCESSOR(CompareNumericAndBranch)
842 Token::Value op() const { return hydrogen()->token(); }
843 bool is_double() const {
844 return hydrogen()->representation().IsDouble();
847 void PrintDataTo(StringStream* stream) override;
851 class LMathFloor final : public LTemplateInstruction<1, 1, 0> {
853 explicit LMathFloor(LOperand* value) {
857 LOperand* value() { return inputs_[0]; }
859 DECLARE_CONCRETE_INSTRUCTION(MathFloor, "math-floor")
860 DECLARE_HYDROGEN_ACCESSOR(UnaryMathOperation)
864 class LMathRound final : public LTemplateInstruction<1, 1, 0> {
866 explicit LMathRound(LOperand* value) {
870 LOperand* value() { return inputs_[0]; }
872 DECLARE_CONCRETE_INSTRUCTION(MathRound, "math-round")
873 DECLARE_HYDROGEN_ACCESSOR(UnaryMathOperation)
877 class LMathFround final : public LTemplateInstruction<1, 1, 0> {
879 explicit LMathFround(LOperand* value) { inputs_[0] = value; }
881 LOperand* value() { return inputs_[0]; }
883 DECLARE_CONCRETE_INSTRUCTION(MathFround, "math-fround")
887 class LMathAbs final : public LTemplateInstruction<1, 2, 0> {
889 LMathAbs(LOperand* context, LOperand* value) {
890 inputs_[1] = context;
894 LOperand* context() { return inputs_[1]; }
895 LOperand* value() { return inputs_[0]; }
897 DECLARE_CONCRETE_INSTRUCTION(MathAbs, "math-abs")
898 DECLARE_HYDROGEN_ACCESSOR(UnaryMathOperation)
902 class LMathLog final : public LTemplateInstruction<1, 1, 0> {
904 explicit LMathLog(LOperand* value) {
908 LOperand* value() { return inputs_[0]; }
910 DECLARE_CONCRETE_INSTRUCTION(MathLog, "math-log")
914 class LMathClz32 final : public LTemplateInstruction<1, 1, 0> {
916 explicit LMathClz32(LOperand* value) {
920 LOperand* value() { return inputs_[0]; }
922 DECLARE_CONCRETE_INSTRUCTION(MathClz32, "math-clz32")
926 class LMathExp final : public LTemplateInstruction<1, 1, 2> {
928 LMathExp(LOperand* value,
934 ExternalReference::InitializeMathExpData();
937 LOperand* value() { return inputs_[0]; }
938 LOperand* temp1() { return temps_[0]; }
939 LOperand* temp2() { return temps_[1]; }
941 DECLARE_CONCRETE_INSTRUCTION(MathExp, "math-exp")
945 class LMathSqrt final : public LTemplateInstruction<1, 1, 2> {
947 explicit LMathSqrt(LOperand* value,
955 LOperand* value() { return inputs_[0]; }
956 LOperand* temp1() { return temps_[0]; }
957 LOperand* temp2() { return temps_[1]; }
959 DECLARE_CONCRETE_INSTRUCTION(MathSqrt, "math-sqrt")
963 class LMathPowHalf final : public LTemplateInstruction<1, 1, 0> {
965 explicit LMathPowHalf(LOperand* value) { inputs_[0] = value; }
967 LOperand* value() { return inputs_[0]; }
969 DECLARE_CONCRETE_INSTRUCTION(MathPowHalf, "math-pow-half")
973 class LCmpObjectEqAndBranch final : public LControlInstruction<2, 0> {
975 LCmpObjectEqAndBranch(LOperand* left, LOperand* right) {
980 LOperand* left() { return inputs_[0]; }
981 LOperand* right() { return inputs_[1]; }
983 DECLARE_CONCRETE_INSTRUCTION(CmpObjectEqAndBranch, "cmp-object-eq-and-branch")
987 class LCmpHoleAndBranch final : public LControlInstruction<1, 0> {
989 explicit LCmpHoleAndBranch(LOperand* object) {
993 LOperand* object() { return inputs_[0]; }
995 DECLARE_CONCRETE_INSTRUCTION(CmpHoleAndBranch, "cmp-hole-and-branch")
996 DECLARE_HYDROGEN_ACCESSOR(CompareHoleAndBranch)
1000 class LCompareMinusZeroAndBranch final : public LControlInstruction<1, 0> {
1002 explicit LCompareMinusZeroAndBranch(LOperand* value) { inputs_[0] = value; }
1004 LOperand* value() { return inputs_[0]; }
1006 DECLARE_CONCRETE_INSTRUCTION(CompareMinusZeroAndBranch,
1007 "cmp-minus-zero-and-branch")
1008 DECLARE_HYDROGEN_ACCESSOR(CompareMinusZeroAndBranch)
1012 class LIsStringAndBranch final : public LControlInstruction<1, 1> {
1014 LIsStringAndBranch(LOperand* value, LOperand* temp) {
1019 LOperand* value() { return inputs_[0]; }
1020 LOperand* temp() { return temps_[0]; }
1022 DECLARE_CONCRETE_INSTRUCTION(IsStringAndBranch, "is-string-and-branch")
1023 DECLARE_HYDROGEN_ACCESSOR(IsStringAndBranch)
1025 void PrintDataTo(StringStream* stream) override;
1029 class LIsSmiAndBranch final : public LControlInstruction<1, 0> {
1031 explicit LIsSmiAndBranch(LOperand* value) {
1035 LOperand* value() { return inputs_[0]; }
1037 DECLARE_CONCRETE_INSTRUCTION(IsSmiAndBranch, "is-smi-and-branch")
1038 DECLARE_HYDROGEN_ACCESSOR(IsSmiAndBranch)
1040 void PrintDataTo(StringStream* stream) override;
1044 class LIsUndetectableAndBranch final : public LControlInstruction<1, 1> {
1046 LIsUndetectableAndBranch(LOperand* value, LOperand* temp) {
1051 LOperand* value() { return inputs_[0]; }
1052 LOperand* temp() { return temps_[0]; }
1054 DECLARE_CONCRETE_INSTRUCTION(IsUndetectableAndBranch,
1055 "is-undetectable-and-branch")
1056 DECLARE_HYDROGEN_ACCESSOR(IsUndetectableAndBranch)
1058 void PrintDataTo(StringStream* stream) override;
1062 class LStringCompareAndBranch final : public LControlInstruction<3, 0> {
1064 LStringCompareAndBranch(LOperand* context, LOperand* left, LOperand* right) {
1065 inputs_[0] = context;
1070 LOperand* context() { return inputs_[0]; }
1071 LOperand* left() { return inputs_[1]; }
1072 LOperand* right() { return inputs_[2]; }
1074 DECLARE_CONCRETE_INSTRUCTION(StringCompareAndBranch,
1075 "string-compare-and-branch")
1076 DECLARE_HYDROGEN_ACCESSOR(StringCompareAndBranch)
1078 void PrintDataTo(StringStream* stream) override;
1080 Token::Value op() const { return hydrogen()->token(); }
1084 class LHasInstanceTypeAndBranch final : public LControlInstruction<1, 1> {
1086 LHasInstanceTypeAndBranch(LOperand* value, LOperand* temp) {
1091 LOperand* value() { return inputs_[0]; }
1092 LOperand* temp() { return temps_[0]; }
1094 DECLARE_CONCRETE_INSTRUCTION(HasInstanceTypeAndBranch,
1095 "has-instance-type-and-branch")
1096 DECLARE_HYDROGEN_ACCESSOR(HasInstanceTypeAndBranch)
1098 void PrintDataTo(StringStream* stream) override;
1102 class LGetCachedArrayIndex final : public LTemplateInstruction<1, 1, 0> {
1104 explicit LGetCachedArrayIndex(LOperand* value) {
1108 LOperand* value() { return inputs_[0]; }
1110 DECLARE_CONCRETE_INSTRUCTION(GetCachedArrayIndex, "get-cached-array-index")
1111 DECLARE_HYDROGEN_ACCESSOR(GetCachedArrayIndex)
1115 class LHasCachedArrayIndexAndBranch final : public LControlInstruction<1, 0> {
1117 explicit LHasCachedArrayIndexAndBranch(LOperand* value) {
1121 LOperand* value() { return inputs_[0]; }
1123 DECLARE_CONCRETE_INSTRUCTION(HasCachedArrayIndexAndBranch,
1124 "has-cached-array-index-and-branch")
1126 void PrintDataTo(StringStream* stream) override;
1130 class LIsConstructCallAndBranch final : public LControlInstruction<0, 1> {
1132 explicit LIsConstructCallAndBranch(LOperand* temp) {
1136 LOperand* temp() { return temps_[0]; }
1138 DECLARE_CONCRETE_INSTRUCTION(IsConstructCallAndBranch,
1139 "is-construct-call-and-branch")
1143 class LClassOfTestAndBranch final : public LControlInstruction<1, 2> {
1145 LClassOfTestAndBranch(LOperand* value, LOperand* temp, LOperand* temp2) {
1151 LOperand* value() { return inputs_[0]; }
1152 LOperand* temp() { return temps_[0]; }
1153 LOperand* temp2() { return temps_[1]; }
1155 DECLARE_CONCRETE_INSTRUCTION(ClassOfTestAndBranch,
1156 "class-of-test-and-branch")
1157 DECLARE_HYDROGEN_ACCESSOR(ClassOfTestAndBranch)
1159 void PrintDataTo(StringStream* stream) override;
1163 class LCmpT final : public LTemplateInstruction<1, 3, 0> {
1165 LCmpT(LOperand* context, LOperand* left, LOperand* right) {
1166 inputs_[0] = context;
1171 DECLARE_CONCRETE_INSTRUCTION(CmpT, "cmp-t")
1172 DECLARE_HYDROGEN_ACCESSOR(CompareGeneric)
1174 Strength strength() { return hydrogen()->strength(); }
1176 LOperand* context() { return inputs_[0]; }
1177 Token::Value op() const { return hydrogen()->token(); }
1181 class LInstanceOf final : public LTemplateInstruction<1, 3, 0> {
1183 LInstanceOf(LOperand* context, LOperand* left, LOperand* right) {
1184 inputs_[0] = context;
1189 LOperand* context() const { return inputs_[0]; }
1190 LOperand* left() const { return inputs_[1]; }
1191 LOperand* right() const { return inputs_[2]; }
1193 DECLARE_CONCRETE_INSTRUCTION(InstanceOf, "instance-of")
1197 class LHasInPrototypeChainAndBranch final : public LControlInstruction<2, 1> {
1199 LHasInPrototypeChainAndBranch(LOperand* object, LOperand* prototype,
1200 LOperand* scratch) {
1201 inputs_[0] = object;
1202 inputs_[1] = prototype;
1203 temps_[0] = scratch;
1206 LOperand* object() const { return inputs_[0]; }
1207 LOperand* prototype() const { return inputs_[1]; }
1208 LOperand* scratch() const { return temps_[0]; }
1210 DECLARE_CONCRETE_INSTRUCTION(HasInPrototypeChainAndBranch,
1211 "has-in-prototype-chain-and-branch")
1212 DECLARE_HYDROGEN_ACCESSOR(HasInPrototypeChainAndBranch)
1216 class LBoundsCheck final : public LTemplateInstruction<0, 2, 0> {
1218 LBoundsCheck(LOperand* index, LOperand* length) {
1220 inputs_[1] = length;
1223 LOperand* index() { return inputs_[0]; }
1224 LOperand* length() { return inputs_[1]; }
1226 DECLARE_CONCRETE_INSTRUCTION(BoundsCheck, "bounds-check")
1227 DECLARE_HYDROGEN_ACCESSOR(BoundsCheck)
1231 class LBitI final : public LTemplateInstruction<1, 2, 0> {
1233 LBitI(LOperand* left, LOperand* right) {
1238 LOperand* left() { return inputs_[0]; }
1239 LOperand* right() { return inputs_[1]; }
1241 DECLARE_CONCRETE_INSTRUCTION(BitI, "bit-i")
1242 DECLARE_HYDROGEN_ACCESSOR(Bitwise)
1244 Token::Value op() const { return hydrogen()->op(); }
1248 class LShiftI final : public LTemplateInstruction<1, 2, 0> {
1250 LShiftI(Token::Value op, LOperand* left, LOperand* right, bool can_deopt)
1251 : op_(op), can_deopt_(can_deopt) {
1256 LOperand* left() { return inputs_[0]; }
1257 LOperand* right() { return inputs_[1]; }
1259 DECLARE_CONCRETE_INSTRUCTION(ShiftI, "shift-i")
1261 Token::Value op() const { return op_; }
1262 bool can_deopt() const { return can_deopt_; }
1270 class LSubI final : public LTemplateInstruction<1, 2, 0> {
1272 LSubI(LOperand* left, LOperand* right) {
1277 LOperand* left() { return inputs_[0]; }
1278 LOperand* right() { return inputs_[1]; }
1280 DECLARE_CONCRETE_INSTRUCTION(SubI, "sub-i")
1281 DECLARE_HYDROGEN_ACCESSOR(Sub)
1285 class LConstantI final : public LTemplateInstruction<1, 0, 0> {
1287 DECLARE_CONCRETE_INSTRUCTION(ConstantI, "constant-i")
1288 DECLARE_HYDROGEN_ACCESSOR(Constant)
1290 int32_t value() const { return hydrogen()->Integer32Value(); }
1294 class LConstantS final : public LTemplateInstruction<1, 0, 0> {
1296 DECLARE_CONCRETE_INSTRUCTION(ConstantS, "constant-s")
1297 DECLARE_HYDROGEN_ACCESSOR(Constant)
1299 Smi* value() const { return Smi::FromInt(hydrogen()->Integer32Value()); }
1303 class LConstantD final : public LTemplateInstruction<1, 0, 1> {
1305 DECLARE_CONCRETE_INSTRUCTION(ConstantD, "constant-d")
1306 DECLARE_HYDROGEN_ACCESSOR(Constant)
1308 uint64_t bits() const { return hydrogen()->DoubleValueAsBits(); }
1312 class LConstantE final : public LTemplateInstruction<1, 0, 0> {
1314 DECLARE_CONCRETE_INSTRUCTION(ConstantE, "constant-e")
1315 DECLARE_HYDROGEN_ACCESSOR(Constant)
1317 ExternalReference value() const {
1318 return hydrogen()->ExternalReferenceValue();
1323 class LConstantT final : public LTemplateInstruction<1, 0, 0> {
1325 DECLARE_CONCRETE_INSTRUCTION(ConstantT, "constant-t")
1326 DECLARE_HYDROGEN_ACCESSOR(Constant)
1328 Handle<Object> value(Isolate* isolate) const {
1329 return hydrogen()->handle(isolate);
1334 class LBranch final : public LControlInstruction<1, 1> {
1336 LBranch(LOperand* value, LOperand* temp) {
1341 LOperand* value() { return inputs_[0]; }
1342 LOperand* temp() { return temps_[0]; }
1344 DECLARE_CONCRETE_INSTRUCTION(Branch, "branch")
1345 DECLARE_HYDROGEN_ACCESSOR(Branch)
1347 void PrintDataTo(StringStream* stream) override;
1351 class LCmpMapAndBranch final : public LControlInstruction<1, 0> {
1353 explicit LCmpMapAndBranch(LOperand* value) {
1357 LOperand* value() { return inputs_[0]; }
1359 DECLARE_CONCRETE_INSTRUCTION(CmpMapAndBranch, "cmp-map-and-branch")
1360 DECLARE_HYDROGEN_ACCESSOR(CompareMap)
1362 Handle<Map> map() const { return hydrogen()->map().handle(); }
1366 class LMapEnumLength final : public LTemplateInstruction<1, 1, 0> {
1368 explicit LMapEnumLength(LOperand* value) {
1372 LOperand* value() { return inputs_[0]; }
1374 DECLARE_CONCRETE_INSTRUCTION(MapEnumLength, "map-enum-length")
1378 class LDateField final : public LTemplateInstruction<1, 1, 1> {
1380 LDateField(LOperand* date, LOperand* temp, Smi* index)
1386 LOperand* date() { return inputs_[0]; }
1387 LOperand* temp() { return temps_[0]; }
1389 DECLARE_CONCRETE_INSTRUCTION(DateField, "date-field")
1390 DECLARE_HYDROGEN_ACCESSOR(DateField)
1392 Smi* index() const { return index_; }
1399 class LSeqStringGetChar final : public LTemplateInstruction<1, 2, 0> {
1401 LSeqStringGetChar(LOperand* string, LOperand* index) {
1402 inputs_[0] = string;
1406 LOperand* string() const { return inputs_[0]; }
1407 LOperand* index() const { return inputs_[1]; }
1409 DECLARE_CONCRETE_INSTRUCTION(SeqStringGetChar, "seq-string-get-char")
1410 DECLARE_HYDROGEN_ACCESSOR(SeqStringGetChar)
1414 class LSeqStringSetChar final : public LTemplateInstruction<1, 4, 0> {
1416 LSeqStringSetChar(LOperand* context,
1420 inputs_[0] = context;
1421 inputs_[1] = string;
1426 LOperand* string() { return inputs_[1]; }
1427 LOperand* index() { return inputs_[2]; }
1428 LOperand* value() { return inputs_[3]; }
1430 DECLARE_CONCRETE_INSTRUCTION(SeqStringSetChar, "seq-string-set-char")
1431 DECLARE_HYDROGEN_ACCESSOR(SeqStringSetChar)
1435 class LAddI final : public LTemplateInstruction<1, 2, 0> {
1437 LAddI(LOperand* left, LOperand* right) {
1442 LOperand* left() { return inputs_[0]; }
1443 LOperand* right() { return inputs_[1]; }
1445 static bool UseLea(HAdd* add) {
1446 return !add->CheckFlag(HValue::kCanOverflow) &&
1447 add->BetterLeftOperand()->UseCount() > 1;
1450 DECLARE_CONCRETE_INSTRUCTION(AddI, "add-i")
1451 DECLARE_HYDROGEN_ACCESSOR(Add)
1455 class LMathMinMax final : public LTemplateInstruction<1, 2, 1> {
1457 LMathMinMax(LOperand* left, LOperand* right, LOperand* temp) {
1463 LOperand* left() { return inputs_[0]; }
1464 LOperand* right() { return inputs_[1]; }
1465 LOperand* temp() { return temps_[0]; }
1467 DECLARE_CONCRETE_INSTRUCTION(MathMinMax, "math-min-max")
1468 DECLARE_HYDROGEN_ACCESSOR(MathMinMax)
1472 class LPower final : public LTemplateInstruction<1, 2, 0> {
1474 LPower(LOperand* left, LOperand* right) {
1479 LOperand* left() { return inputs_[0]; }
1480 LOperand* right() { return inputs_[1]; }
1482 DECLARE_CONCRETE_INSTRUCTION(Power, "power")
1483 DECLARE_HYDROGEN_ACCESSOR(Power)
1487 class LArithmeticD final : public LTemplateInstruction<1, 2, 0> {
1489 LArithmeticD(Token::Value op, LOperand* left, LOperand* right)
1495 LOperand* left() { return inputs_[0]; }
1496 LOperand* right() { return inputs_[1]; }
1498 Token::Value op() const { return op_; }
1500 Opcode opcode() const override { return LInstruction::kArithmeticD; }
1501 void CompileToNative(LCodeGen* generator) override;
1502 const char* Mnemonic() const override;
1509 class LArithmeticT final : public LTemplateInstruction<1, 3, 0> {
1511 LArithmeticT(Token::Value op,
1516 inputs_[0] = context;
1521 LOperand* context() { return inputs_[0]; }
1522 LOperand* left() { return inputs_[1]; }
1523 LOperand* right() { return inputs_[2]; }
1524 Token::Value op() const { return op_; }
1526 Opcode opcode() const override { return LInstruction::kArithmeticT; }
1527 void CompileToNative(LCodeGen* generator) override;
1528 const char* Mnemonic() const override;
1530 DECLARE_HYDROGEN_ACCESSOR(BinaryOperation)
1532 Strength strength() { return hydrogen()->strength(); }
1539 class LReturn final : public LTemplateInstruction<0, 3, 0> {
1541 explicit LReturn(LOperand* value,
1543 LOperand* parameter_count) {
1545 inputs_[1] = context;
1546 inputs_[2] = parameter_count;
1549 bool has_constant_parameter_count() {
1550 return parameter_count()->IsConstantOperand();
1552 LConstantOperand* constant_parameter_count() {
1553 DCHECK(has_constant_parameter_count());
1554 return LConstantOperand::cast(parameter_count());
1556 LOperand* parameter_count() { return inputs_[2]; }
1558 DECLARE_CONCRETE_INSTRUCTION(Return, "return")
1559 DECLARE_HYDROGEN_ACCESSOR(Return)
1563 class LLoadNamedField final : public LTemplateInstruction<1, 1, 0> {
1565 explicit LLoadNamedField(LOperand* object) {
1566 inputs_[0] = object;
1569 LOperand* object() { return inputs_[0]; }
1571 DECLARE_CONCRETE_INSTRUCTION(LoadNamedField, "load-named-field")
1572 DECLARE_HYDROGEN_ACCESSOR(LoadNamedField)
1576 class LLoadNamedGeneric final : public LTemplateInstruction<1, 2, 1> {
1578 LLoadNamedGeneric(LOperand* context, LOperand* object, LOperand* vector) {
1579 inputs_[0] = context;
1580 inputs_[1] = object;
1584 LOperand* context() { return inputs_[0]; }
1585 LOperand* object() { return inputs_[1]; }
1586 LOperand* temp_vector() { return temps_[0]; }
1588 DECLARE_CONCRETE_INSTRUCTION(LoadNamedGeneric, "load-named-generic")
1589 DECLARE_HYDROGEN_ACCESSOR(LoadNamedGeneric)
1591 Handle<Object> name() const { return hydrogen()->name(); }
1595 class LLoadFunctionPrototype final : public LTemplateInstruction<1, 1, 1> {
1597 LLoadFunctionPrototype(LOperand* function, LOperand* temp) {
1598 inputs_[0] = function;
1602 LOperand* function() { return inputs_[0]; }
1603 LOperand* temp() { return temps_[0]; }
1605 DECLARE_CONCRETE_INSTRUCTION(LoadFunctionPrototype, "load-function-prototype")
1606 DECLARE_HYDROGEN_ACCESSOR(LoadFunctionPrototype)
1610 class LLoadRoot final : public LTemplateInstruction<1, 0, 0> {
1612 DECLARE_CONCRETE_INSTRUCTION(LoadRoot, "load-root")
1613 DECLARE_HYDROGEN_ACCESSOR(LoadRoot)
1615 Heap::RootListIndex index() const { return hydrogen()->index(); }
1619 class LLoadKeyed final : public LTemplateInstruction<1, 2, 0> {
1621 LLoadKeyed(LOperand* elements, LOperand* key) {
1622 inputs_[0] = elements;
1625 LOperand* elements() { return inputs_[0]; }
1626 LOperand* key() { return inputs_[1]; }
1627 ElementsKind elements_kind() const {
1628 return hydrogen()->elements_kind();
1630 bool is_fixed_typed_array() const {
1631 return hydrogen()->is_fixed_typed_array();
1634 DECLARE_CONCRETE_INSTRUCTION(LoadKeyed, "load-keyed")
1635 DECLARE_HYDROGEN_ACCESSOR(LoadKeyed)
1637 void PrintDataTo(StringStream* stream) override;
1638 uint32_t base_offset() const { return hydrogen()->base_offset(); }
1640 return hydrogen()->key()->representation().IsTagged();
1645 inline static bool ExternalArrayOpRequiresTemp(
1646 Representation key_representation,
1647 ElementsKind elements_kind) {
1648 // Operations that require the key to be divided by two to be converted into
1649 // an index cannot fold the scale operation into a load and need an extra
1650 // temp register to do the work.
1651 return key_representation.IsSmi() &&
1652 (elements_kind == UINT8_ELEMENTS || elements_kind == INT8_ELEMENTS ||
1653 elements_kind == UINT8_CLAMPED_ELEMENTS);
1657 class LLoadKeyedGeneric final : public LTemplateInstruction<1, 3, 1> {
1659 LLoadKeyedGeneric(LOperand* context, LOperand* obj, LOperand* key,
1661 inputs_[0] = context;
1667 LOperand* context() { return inputs_[0]; }
1668 LOperand* object() { return inputs_[1]; }
1669 LOperand* key() { return inputs_[2]; }
1670 LOperand* temp_vector() { return temps_[0]; }
1672 DECLARE_CONCRETE_INSTRUCTION(LoadKeyedGeneric, "load-keyed-generic")
1673 DECLARE_HYDROGEN_ACCESSOR(LoadKeyedGeneric)
1677 class LLoadGlobalGeneric final : public LTemplateInstruction<1, 2, 1> {
1679 LLoadGlobalGeneric(LOperand* context, LOperand* global_object,
1681 inputs_[0] = context;
1682 inputs_[1] = global_object;
1686 LOperand* context() { return inputs_[0]; }
1687 LOperand* global_object() { return inputs_[1]; }
1688 LOperand* temp_vector() { return temps_[0]; }
1690 DECLARE_CONCRETE_INSTRUCTION(LoadGlobalGeneric, "load-global-generic")
1691 DECLARE_HYDROGEN_ACCESSOR(LoadGlobalGeneric)
1693 Handle<Object> name() const { return hydrogen()->name(); }
1694 TypeofMode typeof_mode() const { return hydrogen()->typeof_mode(); }
1698 class LLoadGlobalViaContext final : public LTemplateInstruction<1, 1, 1> {
1700 explicit LLoadGlobalViaContext(LOperand* context) { inputs_[0] = context; }
1702 DECLARE_CONCRETE_INSTRUCTION(LoadGlobalViaContext, "load-global-via-context")
1703 DECLARE_HYDROGEN_ACCESSOR(LoadGlobalViaContext)
1705 void PrintDataTo(StringStream* stream) override;
1707 LOperand* context() { return inputs_[0]; }
1709 int depth() const { return hydrogen()->depth(); }
1710 int slot_index() const { return hydrogen()->slot_index(); }
1714 class LLoadContextSlot final : public LTemplateInstruction<1, 1, 0> {
1716 explicit LLoadContextSlot(LOperand* context) {
1717 inputs_[0] = context;
1720 LOperand* context() { return inputs_[0]; }
1722 DECLARE_CONCRETE_INSTRUCTION(LoadContextSlot, "load-context-slot")
1723 DECLARE_HYDROGEN_ACCESSOR(LoadContextSlot)
1725 int slot_index() { return hydrogen()->slot_index(); }
1727 void PrintDataTo(StringStream* stream) override;
1731 class LStoreContextSlot final : public LTemplateInstruction<0, 2, 1> {
1733 LStoreContextSlot(LOperand* context, LOperand* value, LOperand* temp) {
1734 inputs_[0] = context;
1739 LOperand* context() { return inputs_[0]; }
1740 LOperand* value() { return inputs_[1]; }
1741 LOperand* temp() { return temps_[0]; }
1743 DECLARE_CONCRETE_INSTRUCTION(StoreContextSlot, "store-context-slot")
1744 DECLARE_HYDROGEN_ACCESSOR(StoreContextSlot)
1746 int slot_index() { return hydrogen()->slot_index(); }
1748 void PrintDataTo(StringStream* stream) override;
1752 class LPushArgument final : public LTemplateInstruction<0, 1, 0> {
1754 explicit LPushArgument(LOperand* value) {
1758 LOperand* value() { return inputs_[0]; }
1760 DECLARE_CONCRETE_INSTRUCTION(PushArgument, "push-argument")
1764 class LDrop final : public LTemplateInstruction<0, 0, 0> {
1766 explicit LDrop(int count) : count_(count) { }
1768 int count() const { return count_; }
1770 DECLARE_CONCRETE_INSTRUCTION(Drop, "drop")
1777 class LStoreCodeEntry final : public LTemplateInstruction<0, 2, 0> {
1779 LStoreCodeEntry(LOperand* function, LOperand* code_object) {
1780 inputs_[0] = function;
1781 inputs_[1] = code_object;
1784 LOperand* function() { return inputs_[0]; }
1785 LOperand* code_object() { return inputs_[1]; }
1787 void PrintDataTo(StringStream* stream) override;
1789 DECLARE_CONCRETE_INSTRUCTION(StoreCodeEntry, "store-code-entry")
1790 DECLARE_HYDROGEN_ACCESSOR(StoreCodeEntry)
1794 class LInnerAllocatedObject final : public LTemplateInstruction<1, 2, 0> {
1796 LInnerAllocatedObject(LOperand* base_object, LOperand* offset) {
1797 inputs_[0] = base_object;
1798 inputs_[1] = offset;
1801 LOperand* base_object() const { return inputs_[0]; }
1802 LOperand* offset() const { return inputs_[1]; }
1804 void PrintDataTo(StringStream* stream) override;
1806 DECLARE_CONCRETE_INSTRUCTION(InnerAllocatedObject, "inner-allocated-object")
1810 class LThisFunction final : public LTemplateInstruction<1, 0, 0> {
1812 DECLARE_CONCRETE_INSTRUCTION(ThisFunction, "this-function")
1813 DECLARE_HYDROGEN_ACCESSOR(ThisFunction)
1817 class LContext final : public LTemplateInstruction<1, 0, 0> {
1819 DECLARE_CONCRETE_INSTRUCTION(Context, "context")
1820 DECLARE_HYDROGEN_ACCESSOR(Context)
1824 class LDeclareGlobals final : public LTemplateInstruction<0, 1, 0> {
1826 explicit LDeclareGlobals(LOperand* context) {
1827 inputs_[0] = context;
1830 LOperand* context() { return inputs_[0]; }
1832 DECLARE_CONCRETE_INSTRUCTION(DeclareGlobals, "declare-globals")
1833 DECLARE_HYDROGEN_ACCESSOR(DeclareGlobals)
1837 class LCallJSFunction final : public LTemplateInstruction<1, 1, 0> {
1839 explicit LCallJSFunction(LOperand* function) {
1840 inputs_[0] = function;
1843 LOperand* function() { return inputs_[0]; }
1845 DECLARE_CONCRETE_INSTRUCTION(CallJSFunction, "call-js-function")
1846 DECLARE_HYDROGEN_ACCESSOR(CallJSFunction)
1848 void PrintDataTo(StringStream* stream) override;
1850 int arity() const { return hydrogen()->argument_count() - 1; }
1854 class LCallWithDescriptor final : public LTemplateResultInstruction<1> {
1856 LCallWithDescriptor(CallInterfaceDescriptor descriptor,
1857 const ZoneList<LOperand*>& operands, Zone* zone)
1858 : inputs_(descriptor.GetRegisterParameterCount() +
1859 kImplicitRegisterParameterCount,
1861 DCHECK(descriptor.GetRegisterParameterCount() +
1862 kImplicitRegisterParameterCount ==
1864 inputs_.AddAll(operands, zone);
1867 LOperand* target() const { return inputs_[0]; }
1869 DECLARE_HYDROGEN_ACCESSOR(CallWithDescriptor)
1871 // The target and context are passed as implicit parameters that are not
1872 // explicitly listed in the descriptor.
1873 static const int kImplicitRegisterParameterCount = 2;
1876 DECLARE_CONCRETE_INSTRUCTION(CallWithDescriptor, "call-with-descriptor")
1878 void PrintDataTo(StringStream* stream) override;
1880 int arity() const { return hydrogen()->argument_count() - 1; }
1882 ZoneList<LOperand*> inputs_;
1884 // Iterator support.
1885 int InputCount() final { return inputs_.length(); }
1886 LOperand* InputAt(int i) final { return inputs_[i]; }
1888 int TempCount() final { return 0; }
1889 LOperand* TempAt(int i) final { return NULL; }
1893 class LInvokeFunction final : public LTemplateInstruction<1, 2, 0> {
1895 LInvokeFunction(LOperand* context, LOperand* function) {
1896 inputs_[0] = context;
1897 inputs_[1] = function;
1900 LOperand* context() { return inputs_[0]; }
1901 LOperand* function() { return inputs_[1]; }
1903 DECLARE_CONCRETE_INSTRUCTION(InvokeFunction, "invoke-function")
1904 DECLARE_HYDROGEN_ACCESSOR(InvokeFunction)
1906 void PrintDataTo(StringStream* stream) override;
1908 int arity() const { return hydrogen()->argument_count() - 1; }
1912 class LCallFunction final : public LTemplateInstruction<1, 2, 2> {
1914 LCallFunction(LOperand* context, LOperand* function, LOperand* slot,
1916 inputs_[0] = context;
1917 inputs_[1] = function;
1922 LOperand* context() { return inputs_[0]; }
1923 LOperand* function() { return inputs_[1]; }
1924 LOperand* temp_slot() { return temps_[0]; }
1925 LOperand* temp_vector() { return temps_[1]; }
1927 DECLARE_CONCRETE_INSTRUCTION(CallFunction, "call-function")
1928 DECLARE_HYDROGEN_ACCESSOR(CallFunction)
1930 void PrintDataTo(StringStream* stream) override;
1931 int arity() const { return hydrogen()->argument_count() - 1; }
1935 class LCallNew final : public LTemplateInstruction<1, 2, 0> {
1937 LCallNew(LOperand* context, LOperand* constructor) {
1938 inputs_[0] = context;
1939 inputs_[1] = constructor;
1942 LOperand* context() { return inputs_[0]; }
1943 LOperand* constructor() { return inputs_[1]; }
1945 DECLARE_CONCRETE_INSTRUCTION(CallNew, "call-new")
1946 DECLARE_HYDROGEN_ACCESSOR(CallNew)
1948 void PrintDataTo(StringStream* stream) override;
1950 int arity() const { return hydrogen()->argument_count() - 1; }
1954 class LCallNewArray final : public LTemplateInstruction<1, 2, 0> {
1956 LCallNewArray(LOperand* context, LOperand* constructor) {
1957 inputs_[0] = context;
1958 inputs_[1] = constructor;
1961 LOperand* context() { return inputs_[0]; }
1962 LOperand* constructor() { return inputs_[1]; }
1964 DECLARE_CONCRETE_INSTRUCTION(CallNewArray, "call-new-array")
1965 DECLARE_HYDROGEN_ACCESSOR(CallNewArray)
1967 void PrintDataTo(StringStream* stream) override;
1969 int arity() const { return hydrogen()->argument_count() - 1; }
1973 class LCallRuntime final : public LTemplateInstruction<1, 1, 0> {
1975 explicit LCallRuntime(LOperand* context) {
1976 inputs_[0] = context;
1979 LOperand* context() { return inputs_[0]; }
1981 DECLARE_CONCRETE_INSTRUCTION(CallRuntime, "call-runtime")
1982 DECLARE_HYDROGEN_ACCESSOR(CallRuntime)
1984 bool ClobbersDoubleRegisters(Isolate* isolate) const override {
1985 return save_doubles() == kDontSaveFPRegs;
1988 const Runtime::Function* function() const { return hydrogen()->function(); }
1989 int arity() const { return hydrogen()->argument_count(); }
1990 SaveFPRegsMode save_doubles() const { return hydrogen()->save_doubles(); }
1994 class LInteger32ToDouble final : public LTemplateInstruction<1, 1, 0> {
1996 explicit LInteger32ToDouble(LOperand* value) {
2000 LOperand* value() { return inputs_[0]; }
2002 DECLARE_CONCRETE_INSTRUCTION(Integer32ToDouble, "int32-to-double")
2006 class LUint32ToDouble final : public LTemplateInstruction<1, 1, 1> {
2008 explicit LUint32ToDouble(LOperand* value) {
2012 LOperand* value() { return inputs_[0]; }
2014 DECLARE_CONCRETE_INSTRUCTION(Uint32ToDouble, "uint32-to-double")
2018 class LNumberTagI final : public LTemplateInstruction<1, 1, 1> {
2020 LNumberTagI(LOperand* value, LOperand* temp) {
2025 LOperand* value() { return inputs_[0]; }
2026 LOperand* temp() { return temps_[0]; }
2028 DECLARE_CONCRETE_INSTRUCTION(NumberTagI, "number-tag-i")
2032 class LNumberTagU final : public LTemplateInstruction<1, 1, 1> {
2034 LNumberTagU(LOperand* value, LOperand* temp) {
2039 LOperand* value() { return inputs_[0]; }
2040 LOperand* temp() { return temps_[0]; }
2042 DECLARE_CONCRETE_INSTRUCTION(NumberTagU, "number-tag-u")
2046 class LNumberTagD final : public LTemplateInstruction<1, 1, 1> {
2048 LNumberTagD(LOperand* value, LOperand* temp) {
2053 LOperand* value() { return inputs_[0]; }
2054 LOperand* temp() { return temps_[0]; }
2056 DECLARE_CONCRETE_INSTRUCTION(NumberTagD, "number-tag-d")
2057 DECLARE_HYDROGEN_ACCESSOR(Change)
2061 // Sometimes truncating conversion from a tagged value to an int32.
2062 class LDoubleToI final : public LTemplateInstruction<1, 1, 0> {
2064 explicit LDoubleToI(LOperand* value) {
2068 LOperand* value() { return inputs_[0]; }
2070 DECLARE_CONCRETE_INSTRUCTION(DoubleToI, "double-to-i")
2071 DECLARE_HYDROGEN_ACCESSOR(UnaryOperation)
2073 bool truncating() { return hydrogen()->CanTruncateToInt32(); }
2077 class LDoubleToSmi final : public LTemplateInstruction<1, 1, 0> {
2079 explicit LDoubleToSmi(LOperand* value) {
2083 LOperand* value() { return inputs_[0]; }
2085 DECLARE_CONCRETE_INSTRUCTION(DoubleToSmi, "double-to-smi")
2086 DECLARE_HYDROGEN_ACCESSOR(UnaryOperation)
2090 // Truncating conversion from a tagged value to an int32.
2091 class LTaggedToI final : public LTemplateInstruction<1, 1, 0> {
2093 explicit LTaggedToI(LOperand* value) {
2097 LOperand* value() { return inputs_[0]; }
2099 DECLARE_CONCRETE_INSTRUCTION(TaggedToI, "tagged-to-i")
2100 DECLARE_HYDROGEN_ACCESSOR(Change)
2102 bool truncating() { return hydrogen()->CanTruncateToInt32(); }
2106 class LSmiTag final : public LTemplateInstruction<1, 1, 0> {
2108 explicit LSmiTag(LOperand* value) {
2112 LOperand* value() { return inputs_[0]; }
2114 DECLARE_CONCRETE_INSTRUCTION(SmiTag, "smi-tag")
2115 DECLARE_HYDROGEN_ACCESSOR(Change)
2119 class LNumberUntagD final : public LTemplateInstruction<1, 1, 1> {
2121 explicit LNumberUntagD(LOperand* value, LOperand* temp) {
2126 LOperand* value() { return inputs_[0]; }
2127 LOperand* temp() { return temps_[0]; }
2129 DECLARE_CONCRETE_INSTRUCTION(NumberUntagD, "double-untag")
2130 DECLARE_HYDROGEN_ACCESSOR(Change);
2134 class LSmiUntag final : public LTemplateInstruction<1, 1, 0> {
2136 LSmiUntag(LOperand* value, bool needs_check)
2137 : needs_check_(needs_check) {
2141 LOperand* value() { return inputs_[0]; }
2143 DECLARE_CONCRETE_INSTRUCTION(SmiUntag, "smi-untag")
2145 bool needs_check() const { return needs_check_; }
2152 class LStoreNamedField final : public LTemplateInstruction<0, 2, 2> {
2154 LStoreNamedField(LOperand* obj,
2157 LOperand* temp_map) {
2161 temps_[1] = temp_map;
2164 LOperand* object() { return inputs_[0]; }
2165 LOperand* value() { return inputs_[1]; }
2166 LOperand* temp() { return temps_[0]; }
2167 LOperand* temp_map() { return temps_[1]; }
2169 DECLARE_CONCRETE_INSTRUCTION(StoreNamedField, "store-named-field")
2170 DECLARE_HYDROGEN_ACCESSOR(StoreNamedField)
2172 void PrintDataTo(StringStream* stream) override;
2176 class LStoreNamedGeneric final : public LTemplateInstruction<0, 3, 2> {
2178 LStoreNamedGeneric(LOperand* context, LOperand* object, LOperand* value,
2179 LOperand* slot, LOperand* vector) {
2180 inputs_[0] = context;
2181 inputs_[1] = object;
2187 LOperand* context() { return inputs_[0]; }
2188 LOperand* object() { return inputs_[1]; }
2189 LOperand* value() { return inputs_[2]; }
2190 LOperand* temp_slot() { return temps_[0]; }
2191 LOperand* temp_vector() { return temps_[1]; }
2193 DECLARE_CONCRETE_INSTRUCTION(StoreNamedGeneric, "store-named-generic")
2194 DECLARE_HYDROGEN_ACCESSOR(StoreNamedGeneric)
2196 void PrintDataTo(StringStream* stream) override;
2197 Handle<Object> name() const { return hydrogen()->name(); }
2198 LanguageMode language_mode() { return hydrogen()->language_mode(); }
2202 class LStoreGlobalViaContext final : public LTemplateInstruction<0, 2, 0> {
2204 LStoreGlobalViaContext(LOperand* context, LOperand* value) {
2205 inputs_[0] = context;
2209 LOperand* context() { return inputs_[0]; }
2210 LOperand* value() { return inputs_[1]; }
2212 DECLARE_CONCRETE_INSTRUCTION(StoreGlobalViaContext,
2213 "store-global-via-context")
2214 DECLARE_HYDROGEN_ACCESSOR(StoreGlobalViaContext)
2216 void PrintDataTo(StringStream* stream) override;
2218 int depth() { return hydrogen()->depth(); }
2219 int slot_index() { return hydrogen()->slot_index(); }
2220 LanguageMode language_mode() { return hydrogen()->language_mode(); }
2224 class LStoreKeyed final : public LTemplateInstruction<0, 3, 0> {
2226 LStoreKeyed(LOperand* obj, LOperand* key, LOperand* val) {
2232 bool is_fixed_typed_array() const {
2233 return hydrogen()->is_fixed_typed_array();
2235 LOperand* elements() { return inputs_[0]; }
2236 LOperand* key() { return inputs_[1]; }
2237 LOperand* value() { return inputs_[2]; }
2238 ElementsKind elements_kind() const {
2239 return hydrogen()->elements_kind();
2242 DECLARE_CONCRETE_INSTRUCTION(StoreKeyed, "store-keyed")
2243 DECLARE_HYDROGEN_ACCESSOR(StoreKeyed)
2245 void PrintDataTo(StringStream* stream) override;
2246 uint32_t base_offset() const { return hydrogen()->base_offset(); }
2247 bool NeedsCanonicalization() { return hydrogen()->NeedsCanonicalization(); }
2251 class LStoreKeyedGeneric final : public LTemplateInstruction<0, 4, 2> {
2253 LStoreKeyedGeneric(LOperand* context, LOperand* object, LOperand* key,
2254 LOperand* value, LOperand* slot, LOperand* vector) {
2255 inputs_[0] = context;
2256 inputs_[1] = object;
2263 LOperand* context() { return inputs_[0]; }
2264 LOperand* object() { return inputs_[1]; }
2265 LOperand* key() { return inputs_[2]; }
2266 LOperand* value() { return inputs_[3]; }
2267 LOperand* temp_slot() { return temps_[0]; }
2268 LOperand* temp_vector() { return temps_[1]; }
2270 DECLARE_CONCRETE_INSTRUCTION(StoreKeyedGeneric, "store-keyed-generic")
2271 DECLARE_HYDROGEN_ACCESSOR(StoreKeyedGeneric)
2273 void PrintDataTo(StringStream* stream) override;
2275 LanguageMode language_mode() { return hydrogen()->language_mode(); }
2279 class LTransitionElementsKind final : public LTemplateInstruction<0, 2, 2> {
2281 LTransitionElementsKind(LOperand* object,
2283 LOperand* new_map_temp,
2285 inputs_[0] = object;
2286 inputs_[1] = context;
2287 temps_[0] = new_map_temp;
2291 LOperand* context() { return inputs_[1]; }
2292 LOperand* object() { return inputs_[0]; }
2293 LOperand* new_map_temp() { return temps_[0]; }
2294 LOperand* temp() { return temps_[1]; }
2296 DECLARE_CONCRETE_INSTRUCTION(TransitionElementsKind,
2297 "transition-elements-kind")
2298 DECLARE_HYDROGEN_ACCESSOR(TransitionElementsKind)
2300 void PrintDataTo(StringStream* stream) override;
2302 Handle<Map> original_map() { return hydrogen()->original_map().handle(); }
2303 Handle<Map> transitioned_map() {
2304 return hydrogen()->transitioned_map().handle();
2306 ElementsKind from_kind() { return hydrogen()->from_kind(); }
2307 ElementsKind to_kind() { return hydrogen()->to_kind(); }
2311 class LTrapAllocationMemento final : public LTemplateInstruction<0, 1, 1> {
2313 LTrapAllocationMemento(LOperand* object,
2315 inputs_[0] = object;
2319 LOperand* object() { return inputs_[0]; }
2320 LOperand* temp() { return temps_[0]; }
2322 DECLARE_CONCRETE_INSTRUCTION(TrapAllocationMemento,
2323 "trap-allocation-memento")
2327 class LMaybeGrowElements final : public LTemplateInstruction<1, 5, 0> {
2329 LMaybeGrowElements(LOperand* context, LOperand* object, LOperand* elements,
2330 LOperand* key, LOperand* current_capacity) {
2331 inputs_[0] = context;
2332 inputs_[1] = object;
2333 inputs_[2] = elements;
2335 inputs_[4] = current_capacity;
2338 LOperand* context() { return inputs_[0]; }
2339 LOperand* object() { return inputs_[1]; }
2340 LOperand* elements() { return inputs_[2]; }
2341 LOperand* key() { return inputs_[3]; }
2342 LOperand* current_capacity() { return inputs_[4]; }
2344 DECLARE_HYDROGEN_ACCESSOR(MaybeGrowElements)
2345 DECLARE_CONCRETE_INSTRUCTION(MaybeGrowElements, "maybe-grow-elements")
2349 class LStringAdd final : public LTemplateInstruction<1, 3, 0> {
2351 LStringAdd(LOperand* context, LOperand* left, LOperand* right) {
2352 inputs_[0] = context;
2357 LOperand* context() { return inputs_[0]; }
2358 LOperand* left() { return inputs_[1]; }
2359 LOperand* right() { return inputs_[2]; }
2361 DECLARE_CONCRETE_INSTRUCTION(StringAdd, "string-add")
2362 DECLARE_HYDROGEN_ACCESSOR(StringAdd)
2366 class LStringCharCodeAt final : public LTemplateInstruction<1, 3, 0> {
2368 LStringCharCodeAt(LOperand* context, LOperand* string, LOperand* index) {
2369 inputs_[0] = context;
2370 inputs_[1] = string;
2374 LOperand* context() { return inputs_[0]; }
2375 LOperand* string() { return inputs_[1]; }
2376 LOperand* index() { return inputs_[2]; }
2378 DECLARE_CONCRETE_INSTRUCTION(StringCharCodeAt, "string-char-code-at")
2379 DECLARE_HYDROGEN_ACCESSOR(StringCharCodeAt)
2383 class LStringCharFromCode final : public LTemplateInstruction<1, 2, 0> {
2385 LStringCharFromCode(LOperand* context, LOperand* char_code) {
2386 inputs_[0] = context;
2387 inputs_[1] = char_code;
2390 LOperand* context() { return inputs_[0]; }
2391 LOperand* char_code() { return inputs_[1]; }
2393 DECLARE_CONCRETE_INSTRUCTION(StringCharFromCode, "string-char-from-code")
2394 DECLARE_HYDROGEN_ACCESSOR(StringCharFromCode)
2398 class LCheckValue final : public LTemplateInstruction<0, 1, 0> {
2400 explicit LCheckValue(LOperand* value) {
2404 LOperand* value() { return inputs_[0]; }
2406 DECLARE_CONCRETE_INSTRUCTION(CheckValue, "check-value")
2407 DECLARE_HYDROGEN_ACCESSOR(CheckValue)
2411 class LCheckArrayBufferNotNeutered final
2412 : public LTemplateInstruction<0, 1, 1> {
2414 explicit LCheckArrayBufferNotNeutered(LOperand* view, LOperand* scratch) {
2416 temps_[0] = scratch;
2419 LOperand* view() { return inputs_[0]; }
2420 LOperand* scratch() { return temps_[0]; }
2422 DECLARE_CONCRETE_INSTRUCTION(CheckArrayBufferNotNeutered,
2423 "check-array-buffer-not-neutered")
2424 DECLARE_HYDROGEN_ACCESSOR(CheckArrayBufferNotNeutered)
2428 class LCheckInstanceType final : public LTemplateInstruction<0, 1, 1> {
2430 LCheckInstanceType(LOperand* value, LOperand* temp) {
2435 LOperand* value() { return inputs_[0]; }
2436 LOperand* temp() { return temps_[0]; }
2438 DECLARE_CONCRETE_INSTRUCTION(CheckInstanceType, "check-instance-type")
2439 DECLARE_HYDROGEN_ACCESSOR(CheckInstanceType)
2443 class LCheckMaps final : public LTemplateInstruction<0, 1, 0> {
2445 explicit LCheckMaps(LOperand* value = NULL) {
2449 LOperand* value() { return inputs_[0]; }
2451 DECLARE_CONCRETE_INSTRUCTION(CheckMaps, "check-maps")
2452 DECLARE_HYDROGEN_ACCESSOR(CheckMaps)
2456 class LCheckSmi final : public LTemplateInstruction<1, 1, 0> {
2458 explicit LCheckSmi(LOperand* value) {
2462 LOperand* value() { return inputs_[0]; }
2464 DECLARE_CONCRETE_INSTRUCTION(CheckSmi, "check-smi")
2468 class LClampDToUint8 final : public LTemplateInstruction<1, 1, 0> {
2470 explicit LClampDToUint8(LOperand* value) {
2474 LOperand* unclamped() { return inputs_[0]; }
2476 DECLARE_CONCRETE_INSTRUCTION(ClampDToUint8, "clamp-d-to-uint8")
2480 class LClampIToUint8 final : public LTemplateInstruction<1, 1, 0> {
2482 explicit LClampIToUint8(LOperand* value) {
2486 LOperand* unclamped() { return inputs_[0]; }
2488 DECLARE_CONCRETE_INSTRUCTION(ClampIToUint8, "clamp-i-to-uint8")
2492 // Truncating conversion from a tagged value to an int32.
2493 class LClampTToUint8NoSSE2 final : public LTemplateInstruction<1, 1, 3> {
2495 LClampTToUint8NoSSE2(LOperand* unclamped,
2499 inputs_[0] = unclamped;
2505 LOperand* unclamped() { return inputs_[0]; }
2506 LOperand* scratch() { return temps_[0]; }
2507 LOperand* scratch2() { return temps_[1]; }
2508 LOperand* scratch3() { return temps_[2]; }
2510 DECLARE_CONCRETE_INSTRUCTION(ClampTToUint8NoSSE2,
2511 "clamp-t-to-uint8-nosse2")
2512 DECLARE_HYDROGEN_ACCESSOR(UnaryOperation)
2516 class LCheckNonSmi final : public LTemplateInstruction<0, 1, 0> {
2518 explicit LCheckNonSmi(LOperand* value) {
2522 LOperand* value() { return inputs_[0]; }
2524 DECLARE_CONCRETE_INSTRUCTION(CheckNonSmi, "check-non-smi")
2525 DECLARE_HYDROGEN_ACCESSOR(CheckHeapObject)
2529 class LDoubleBits final : public LTemplateInstruction<1, 1, 0> {
2531 explicit LDoubleBits(LOperand* value) {
2535 LOperand* value() { return inputs_[0]; }
2537 DECLARE_CONCRETE_INSTRUCTION(DoubleBits, "double-bits")
2538 DECLARE_HYDROGEN_ACCESSOR(DoubleBits)
2542 class LConstructDouble final : public LTemplateInstruction<1, 2, 0> {
2544 LConstructDouble(LOperand* hi, LOperand* lo) {
2549 LOperand* hi() { return inputs_[0]; }
2550 LOperand* lo() { return inputs_[1]; }
2552 DECLARE_CONCRETE_INSTRUCTION(ConstructDouble, "construct-double")
2556 class LAllocate final : public LTemplateInstruction<1, 2, 1> {
2558 LAllocate(LOperand* context, LOperand* size, LOperand* temp) {
2559 inputs_[0] = context;
2564 LOperand* context() { return inputs_[0]; }
2565 LOperand* size() { return inputs_[1]; }
2566 LOperand* temp() { return temps_[0]; }
2568 DECLARE_CONCRETE_INSTRUCTION(Allocate, "allocate")
2569 DECLARE_HYDROGEN_ACCESSOR(Allocate)
2573 class LRegExpLiteral final : public LTemplateInstruction<1, 1, 0> {
2575 explicit LRegExpLiteral(LOperand* context) {
2576 inputs_[0] = context;
2579 LOperand* context() { return inputs_[0]; }
2581 DECLARE_CONCRETE_INSTRUCTION(RegExpLiteral, "regexp-literal")
2582 DECLARE_HYDROGEN_ACCESSOR(RegExpLiteral)
2586 class LToFastProperties final : public LTemplateInstruction<1, 1, 0> {
2588 explicit LToFastProperties(LOperand* value) {
2592 LOperand* value() { return inputs_[0]; }
2594 DECLARE_CONCRETE_INSTRUCTION(ToFastProperties, "to-fast-properties")
2595 DECLARE_HYDROGEN_ACCESSOR(ToFastProperties)
2599 class LTypeof final : public LTemplateInstruction<1, 2, 0> {
2601 LTypeof(LOperand* context, LOperand* value) {
2602 inputs_[0] = context;
2606 LOperand* context() { return inputs_[0]; }
2607 LOperand* value() { return inputs_[1]; }
2609 DECLARE_CONCRETE_INSTRUCTION(Typeof, "typeof")
2613 class LTypeofIsAndBranch final : public LControlInstruction<1, 0> {
2615 explicit LTypeofIsAndBranch(LOperand* value) {
2619 LOperand* value() { return inputs_[0]; }
2621 DECLARE_CONCRETE_INSTRUCTION(TypeofIsAndBranch, "typeof-is-and-branch")
2622 DECLARE_HYDROGEN_ACCESSOR(TypeofIsAndBranch)
2624 Handle<String> type_literal() { return hydrogen()->type_literal(); }
2626 void PrintDataTo(StringStream* stream) override;
2630 class LOsrEntry final : public LTemplateInstruction<0, 0, 0> {
2632 bool HasInterestingComment(LCodeGen* gen) const override { return false; }
2633 DECLARE_CONCRETE_INSTRUCTION(OsrEntry, "osr-entry")
2637 class LStackCheck final : public LTemplateInstruction<0, 1, 0> {
2639 explicit LStackCheck(LOperand* context) {
2640 inputs_[0] = context;
2643 LOperand* context() { return inputs_[0]; }
2645 DECLARE_CONCRETE_INSTRUCTION(StackCheck, "stack-check")
2646 DECLARE_HYDROGEN_ACCESSOR(StackCheck)
2648 Label* done_label() { return &done_label_; }
2655 class LForInPrepareMap final : public LTemplateInstruction<1, 2, 0> {
2657 LForInPrepareMap(LOperand* context, LOperand* object) {
2658 inputs_[0] = context;
2659 inputs_[1] = object;
2662 LOperand* context() { return inputs_[0]; }
2663 LOperand* object() { return inputs_[1]; }
2665 DECLARE_CONCRETE_INSTRUCTION(ForInPrepareMap, "for-in-prepare-map")
2669 class LForInCacheArray final : public LTemplateInstruction<1, 1, 0> {
2671 explicit LForInCacheArray(LOperand* map) {
2675 LOperand* map() { return inputs_[0]; }
2677 DECLARE_CONCRETE_INSTRUCTION(ForInCacheArray, "for-in-cache-array")
2680 return HForInCacheArray::cast(this->hydrogen_value())->idx();
2685 class LCheckMapValue final : public LTemplateInstruction<0, 2, 0> {
2687 LCheckMapValue(LOperand* value, LOperand* map) {
2692 LOperand* value() { return inputs_[0]; }
2693 LOperand* map() { return inputs_[1]; }
2695 DECLARE_CONCRETE_INSTRUCTION(CheckMapValue, "check-map-value")
2699 class LLoadFieldByIndex final : public LTemplateInstruction<1, 2, 0> {
2701 LLoadFieldByIndex(LOperand* object, LOperand* index) {
2702 inputs_[0] = object;
2706 LOperand* object() { return inputs_[0]; }
2707 LOperand* index() { return inputs_[1]; }
2709 DECLARE_CONCRETE_INSTRUCTION(LoadFieldByIndex, "load-field-by-index")
2713 class LStoreFrameContext: public LTemplateInstruction<0, 1, 0> {
2715 explicit LStoreFrameContext(LOperand* context) {
2716 inputs_[0] = context;
2719 LOperand* context() { return inputs_[0]; }
2721 DECLARE_CONCRETE_INSTRUCTION(StoreFrameContext, "store-frame-context")
2725 class LAllocateBlockContext: public LTemplateInstruction<1, 2, 0> {
2727 LAllocateBlockContext(LOperand* context, LOperand* function) {
2728 inputs_[0] = context;
2729 inputs_[1] = function;
2732 LOperand* context() { return inputs_[0]; }
2733 LOperand* function() { return inputs_[1]; }
2735 Handle<ScopeInfo> scope_info() { return hydrogen()->scope_info(); }
2737 DECLARE_CONCRETE_INSTRUCTION(AllocateBlockContext, "allocate-block-context")
2738 DECLARE_HYDROGEN_ACCESSOR(AllocateBlockContext)
2742 class LChunkBuilder;
2743 class LPlatformChunk final : public LChunk {
2745 LPlatformChunk(CompilationInfo* info, HGraph* graph)
2746 : LChunk(info, graph),
2747 num_double_slots_(0) { }
2749 int GetNextSpillIndex(RegisterKind kind);
2750 LOperand* GetNextSpillSlot(RegisterKind kind);
2752 int num_double_slots() const { return num_double_slots_; }
2755 int num_double_slots_;
2759 class LChunkBuilder final : public LChunkBuilderBase {
2761 LChunkBuilder(CompilationInfo* info, HGraph* graph, LAllocator* allocator)
2762 : LChunkBuilderBase(info, graph),
2763 current_instruction_(NULL),
2764 current_block_(NULL),
2766 allocator_(allocator) {}
2768 // Build the sequence for the graph.
2769 LPlatformChunk* Build();
2771 // Declare methods that deal with the individual node types.
2772 #define DECLARE_DO(type) LInstruction* Do##type(H##type* node);
2773 HYDROGEN_CONCRETE_INSTRUCTION_LIST(DECLARE_DO)
2776 LInstruction* DoMathFloor(HUnaryMathOperation* instr);
2777 LInstruction* DoMathRound(HUnaryMathOperation* instr);
2778 LInstruction* DoMathFround(HUnaryMathOperation* instr);
2779 LInstruction* DoMathAbs(HUnaryMathOperation* instr);
2780 LInstruction* DoMathLog(HUnaryMathOperation* instr);
2781 LInstruction* DoMathExp(HUnaryMathOperation* instr);
2782 LInstruction* DoMathSqrt(HUnaryMathOperation* instr);
2783 LInstruction* DoMathPowHalf(HUnaryMathOperation* instr);
2784 LInstruction* DoMathClz32(HUnaryMathOperation* instr);
2785 LInstruction* DoDivByPowerOf2I(HDiv* instr);
2786 LInstruction* DoDivByConstI(HDiv* instr);
2787 LInstruction* DoDivI(HDiv* instr);
2788 LInstruction* DoModByPowerOf2I(HMod* instr);
2789 LInstruction* DoModByConstI(HMod* instr);
2790 LInstruction* DoModI(HMod* instr);
2791 LInstruction* DoFlooringDivByPowerOf2I(HMathFloorOfDiv* instr);
2792 LInstruction* DoFlooringDivByConstI(HMathFloorOfDiv* instr);
2793 LInstruction* DoFlooringDivI(HMathFloorOfDiv* instr);
2796 // Methods for getting operands for Use / Define / Temp.
2797 LUnallocated* ToUnallocated(Register reg);
2798 LUnallocated* ToUnallocated(X87Register reg);
2800 // Methods for setting up define-use relationships.
2801 MUST_USE_RESULT LOperand* Use(HValue* value, LUnallocated* operand);
2802 MUST_USE_RESULT LOperand* UseFixed(HValue* value, Register fixed_register);
2804 // A value that is guaranteed to be allocated to a register.
2805 // Operand created by UseRegister is guaranteed to be live until the end of
2806 // instruction. This means that register allocator will not reuse it's
2807 // register for any other operand inside instruction.
2808 // Operand created by UseRegisterAtStart is guaranteed to be live only at
2809 // instruction start. Register allocator is free to assign the same register
2810 // to some other operand used inside instruction (i.e. temporary or
2812 MUST_USE_RESULT LOperand* UseRegister(HValue* value);
2813 MUST_USE_RESULT LOperand* UseRegisterAtStart(HValue* value);
2815 // An input operand in a register that may be trashed.
2816 MUST_USE_RESULT LOperand* UseTempRegister(HValue* value);
2818 // An input operand in a register or stack slot.
2819 MUST_USE_RESULT LOperand* Use(HValue* value);
2820 MUST_USE_RESULT LOperand* UseAtStart(HValue* value);
2822 // An input operand in a register, stack slot or a constant operand.
2823 MUST_USE_RESULT LOperand* UseOrConstant(HValue* value);
2824 MUST_USE_RESULT LOperand* UseOrConstantAtStart(HValue* value);
2826 // An input operand in a fixed register or a constant operand.
2827 MUST_USE_RESULT LOperand* UseFixedOrConstant(HValue* value,
2828 Register fixed_register);
2830 // An input operand in a register or a constant operand.
2831 MUST_USE_RESULT LOperand* UseRegisterOrConstant(HValue* value);
2832 MUST_USE_RESULT LOperand* UseRegisterOrConstantAtStart(HValue* value);
2834 // An input operand in a constant operand.
2835 MUST_USE_RESULT LOperand* UseConstant(HValue* value);
2837 // An input operand in register, stack slot or a constant operand.
2838 // Will not be moved to a register even if one is freely available.
2839 MUST_USE_RESULT LOperand* UseAny(HValue* value) override;
2841 // Temporary operand that must be in a register.
2842 MUST_USE_RESULT LUnallocated* TempRegister();
2843 MUST_USE_RESULT LOperand* FixedTemp(Register reg);
2845 // Methods for setting up define-use relationships.
2846 // Return the same instruction that they are passed.
2847 LInstruction* Define(LTemplateResultInstruction<1>* instr,
2848 LUnallocated* result);
2849 LInstruction* DefineAsRegister(LTemplateResultInstruction<1>* instr);
2850 LInstruction* DefineAsSpilled(LTemplateResultInstruction<1>* instr,
2852 LInstruction* DefineSameAsFirst(LTemplateResultInstruction<1>* instr);
2853 LInstruction* DefineFixed(LTemplateResultInstruction<1>* instr,
2855 LInstruction* DefineFixed(LTemplateResultInstruction<1>* instr,
2857 LInstruction* DefineX87TOS(LTemplateResultInstruction<1>* instr);
2858 // Assigns an environment to an instruction. An instruction which can
2859 // deoptimize must have an environment.
2860 LInstruction* AssignEnvironment(LInstruction* instr);
2861 // Assigns a pointer map to an instruction. An instruction which can
2862 // trigger a GC or a lazy deoptimization must have a pointer map.
2863 LInstruction* AssignPointerMap(LInstruction* instr);
2865 enum CanDeoptimize { CAN_DEOPTIMIZE_EAGERLY, CANNOT_DEOPTIMIZE_EAGERLY };
2867 LOperand* GetSeqStringSetCharOperand(HSeqStringSetChar* instr);
2869 // Marks a call for the register allocator. Assigns a pointer map to
2870 // support GC and lazy deoptimization. Assigns an environment to support
2871 // eager deoptimization if CAN_DEOPTIMIZE_EAGERLY.
2872 LInstruction* MarkAsCall(
2873 LInstruction* instr,
2874 HInstruction* hinstr,
2875 CanDeoptimize can_deoptimize = CANNOT_DEOPTIMIZE_EAGERLY);
2877 void VisitInstruction(HInstruction* current);
2878 void AddInstruction(LInstruction* instr, HInstruction* current);
2880 void DoBasicBlock(HBasicBlock* block, HBasicBlock* next_block);
2881 LInstruction* DoShift(Token::Value op, HBitwiseBinaryOperation* instr);
2882 LInstruction* DoArithmeticD(Token::Value op,
2883 HArithmeticBinaryOperation* instr);
2884 LInstruction* DoArithmeticT(Token::Value op,
2885 HBinaryOperation* instr);
2887 LOperand* GetStoreKeyedValueOperand(HStoreKeyed* instr);
2889 HInstruction* current_instruction_;
2890 HBasicBlock* current_block_;
2891 HBasicBlock* next_block_;
2892 LAllocator* allocator_;
2894 DISALLOW_COPY_AND_ASSIGN(LChunkBuilder);
2897 #undef DECLARE_HYDROGEN_ACCESSOR
2898 #undef DECLARE_CONCRETE_INSTRUCTION
2900 } // namespace internal
2903 #endif // V8_X87_LITHIUM_X87_H_