1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef V8_X64_LITHIUM_X64_H_
6 #define V8_X64_LITHIUM_X64_H_
8 #include "src/hydrogen.h"
9 #include "src/lithium.h"
10 #include "src/lithium-allocator.h"
11 #include "src/safepoint-table.h"
12 #include "src/utils.h"
17 // Forward declarations.
20 #define LITHIUM_CONCRETE_INSTRUCTION_LIST(V) \
21 V(AccessArgumentsAt) \
24 V(AllocateBlockContext) \
26 V(ArgumentsElements) \
34 V(CallWithDescriptor) \
40 V(CheckArrayBufferNotNeutered) \
41 V(CheckInstanceType) \
50 V(ClassOfTestAndBranch) \
51 V(CompareMinusZeroAndBranch) \
52 V(CompareNumericAndBranch) \
53 V(CmpObjectEqAndBranch) \
77 V(FlooringDivByConstI) \
78 V(FlooringDivByPowerOf2I) \
82 V(GetCachedArrayIndex) \
84 V(HasCachedArrayIndexAndBranch) \
85 V(HasInPrototypeChainAndBranch) \
86 V(HasInstanceTypeAndBranch) \
87 V(InnerAllocatedObject) \
90 V(Integer32ToDouble) \
92 V(IsConstructCallAndBranch) \
93 V(IsStringAndBranch) \
95 V(IsUndetectableAndBranch) \
100 V(LoadFieldByIndex) \
101 V(LoadFunctionPrototype) \
102 V(LoadGlobalGeneric) \
103 V(LoadGlobalViaContext) \
105 V(LoadKeyedGeneric) \
107 V(LoadNamedGeneric) \
119 V(MaybeGrowElements) \
135 V(SeqStringGetChar) \
136 V(SeqStringSetChar) \
142 V(StoreContextSlot) \
143 V(StoreFrameContext) \
144 V(StoreGlobalViaContext) \
146 V(StoreKeyedGeneric) \
148 V(StoreNamedGeneric) \
150 V(StringCharCodeAt) \
151 V(StringCharFromCode) \
152 V(StringCompareAndBranch) \
156 V(ToFastProperties) \
157 V(TransitionElementsKind) \
158 V(TrapAllocationMemento) \
160 V(TypeofIsAndBranch) \
166 #define DECLARE_CONCRETE_INSTRUCTION(type, mnemonic) \
167 Opcode opcode() const final { return LInstruction::k##type; } \
168 void CompileToNative(LCodeGen* generator) final; \
169 const char* Mnemonic() const final { return mnemonic; } \
170 static L##type* cast(LInstruction* instr) { \
171 DCHECK(instr->Is##type()); \
172 return reinterpret_cast<L##type*>(instr); \
176 #define DECLARE_HYDROGEN_ACCESSOR(type) \
177 H##type* hydrogen() const { \
178 return H##type::cast(hydrogen_value()); \
182 class LInstruction : public ZoneObject {
185 : environment_(NULL),
186 hydrogen_value_(NULL),
187 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)
202 kNumberOfInstructions
203 #undef DECLARE_OPCODE
206 virtual Opcode opcode() const = 0;
208 // Declare non-virtual type testers for all leaf IR classes.
209 #define DECLARE_PREDICATE(type) \
210 bool Is##type() const { return opcode() == k##type; }
211 LITHIUM_CONCRETE_INSTRUCTION_LIST(DECLARE_PREDICATE)
212 #undef DECLARE_PREDICATE
214 // Declare virtual predicates for instructions that don't have
216 virtual bool IsGap() const { return false; }
218 virtual bool IsControl() const { return false; }
220 // Try deleting this instruction if possible.
221 virtual bool TryDelete() { return false; }
223 void set_environment(LEnvironment* env) { environment_ = env; }
224 LEnvironment* environment() const { return environment_; }
225 bool HasEnvironment() const { return environment_ != NULL; }
227 void set_pointer_map(LPointerMap* p) { pointer_map_.set(p); }
228 LPointerMap* pointer_map() const { return pointer_map_.get(); }
229 bool HasPointerMap() const { return pointer_map_.is_set(); }
231 void set_hydrogen_value(HValue* value) { hydrogen_value_ = value; }
232 HValue* hydrogen_value() const { return hydrogen_value_; }
234 void MarkAsCall() { bit_field_ = IsCallBits::update(bit_field_, true); }
235 bool IsCall() const { return IsCallBits::decode(bit_field_); }
237 // Interface to the register allocator and iterators.
238 bool ClobbersTemps() const { return IsCall(); }
239 bool ClobbersRegisters() const { return IsCall(); }
240 virtual bool ClobbersDoubleRegisters(Isolate* isolate) const {
244 // Interface to the register allocator and iterators.
245 bool IsMarkedAsCall() const { return IsCall(); }
247 virtual bool HasResult() const = 0;
248 virtual LOperand* result() const = 0;
250 LOperand* FirstInput() { return InputAt(0); }
251 LOperand* Output() { return HasResult() ? result() : NULL; }
253 virtual bool HasInterestingComment(LCodeGen* gen) const { return true; }
255 virtual bool MustSignExtendResult(LPlatformChunk* chunk) const {
263 virtual int InputCount() = 0;
264 virtual LOperand* InputAt(int i) = 0;
268 friend class InputIterator;
270 friend class TempIterator;
271 virtual int TempCount() = 0;
272 virtual LOperand* TempAt(int i) = 0;
274 class IsCallBits: public BitField<bool, 0, 1> {};
276 LEnvironment* environment_;
277 SetOncePointer<LPointerMap> pointer_map_;
278 HValue* hydrogen_value_;
283 // R = number of result operands (0 or 1).
285 class LTemplateResultInstruction : public LInstruction {
287 // Allow 0 or 1 output operands.
288 STATIC_ASSERT(R == 0 || R == 1);
289 bool HasResult() const final { return R != 0 && result() != NULL; }
290 void set_result(LOperand* operand) { results_[0] = operand; }
291 LOperand* result() const override { return results_[0]; }
293 bool MustSignExtendResult(LPlatformChunk* chunk) const final;
296 EmbeddedContainer<LOperand*, R> results_;
300 // R = number of result operands (0 or 1).
301 // I = number of input operands.
302 // T = number of temporary operands.
303 template<int R, int I, int T>
304 class LTemplateInstruction : public LTemplateResultInstruction<R> {
306 EmbeddedContainer<LOperand*, I> inputs_;
307 EmbeddedContainer<LOperand*, T> temps_;
311 int InputCount() final { return I; }
312 LOperand* InputAt(int i) final { return inputs_[i]; }
314 int TempCount() final { return T; }
315 LOperand* TempAt(int i) final { return temps_[i]; }
319 class LGap : public LTemplateInstruction<0, 0, 0> {
321 explicit LGap(HBasicBlock* block)
323 parallel_moves_[BEFORE] = NULL;
324 parallel_moves_[START] = NULL;
325 parallel_moves_[END] = NULL;
326 parallel_moves_[AFTER] = NULL;
329 // Can't use the DECLARE-macro here because of sub-classes.
330 bool IsGap() const final { return true; }
331 void PrintDataTo(StringStream* stream) override;
332 static LGap* cast(LInstruction* instr) {
333 DCHECK(instr->IsGap());
334 return reinterpret_cast<LGap*>(instr);
337 bool IsRedundant() const;
339 HBasicBlock* block() const { return block_; }
346 FIRST_INNER_POSITION = BEFORE,
347 LAST_INNER_POSITION = AFTER
350 LParallelMove* GetOrCreateParallelMove(InnerPosition pos,
352 if (parallel_moves_[pos] == NULL) {
353 parallel_moves_[pos] = new(zone) LParallelMove(zone);
355 return parallel_moves_[pos];
358 LParallelMove* GetParallelMove(InnerPosition pos) {
359 return parallel_moves_[pos];
363 LParallelMove* parallel_moves_[LAST_INNER_POSITION + 1];
368 class LInstructionGap final : public LGap {
370 explicit LInstructionGap(HBasicBlock* block) : LGap(block) { }
372 bool HasInterestingComment(LCodeGen* gen) const override {
373 return !IsRedundant();
376 DECLARE_CONCRETE_INSTRUCTION(InstructionGap, "gap")
380 class LGoto final : public LTemplateInstruction<0, 0, 0> {
382 explicit LGoto(HBasicBlock* block) : block_(block) { }
384 bool HasInterestingComment(LCodeGen* gen) const override;
385 DECLARE_CONCRETE_INSTRUCTION(Goto, "goto")
386 void PrintDataTo(StringStream* stream) override;
387 bool IsControl() const override { return true; }
389 int block_id() const { return block_->block_id(); }
396 class LPrologue final : public LTemplateInstruction<0, 0, 0> {
398 DECLARE_CONCRETE_INSTRUCTION(Prologue, "prologue")
402 class LLazyBailout final : public LTemplateInstruction<0, 0, 0> {
404 LLazyBailout() : gap_instructions_size_(0) { }
406 DECLARE_CONCRETE_INSTRUCTION(LazyBailout, "lazy-bailout")
408 void set_gap_instructions_size(int gap_instructions_size) {
409 gap_instructions_size_ = gap_instructions_size;
411 int gap_instructions_size() { return gap_instructions_size_; }
414 int gap_instructions_size_;
418 class LDummy final : public LTemplateInstruction<1, 0, 0> {
421 DECLARE_CONCRETE_INSTRUCTION(Dummy, "dummy")
425 class LDummyUse final : public LTemplateInstruction<1, 1, 0> {
427 explicit LDummyUse(LOperand* value) {
430 DECLARE_CONCRETE_INSTRUCTION(DummyUse, "dummy-use")
434 class LDeoptimize final : public LTemplateInstruction<0, 0, 0> {
436 bool IsControl() const override { return true; }
437 DECLARE_CONCRETE_INSTRUCTION(Deoptimize, "deoptimize")
438 DECLARE_HYDROGEN_ACCESSOR(Deoptimize)
442 class LLabel final : public LGap {
444 explicit LLabel(HBasicBlock* block)
445 : LGap(block), replacement_(NULL) { }
447 bool HasInterestingComment(LCodeGen* gen) const override { return false; }
448 DECLARE_CONCRETE_INSTRUCTION(Label, "label")
450 void PrintDataTo(StringStream* stream) override;
452 int block_id() const { return block()->block_id(); }
453 bool is_loop_header() const { return block()->IsLoopHeader(); }
454 bool is_osr_entry() const { return block()->is_osr_entry(); }
455 Label* label() { return &label_; }
456 LLabel* replacement() const { return replacement_; }
457 void set_replacement(LLabel* label) { replacement_ = label; }
458 bool HasReplacement() const { return replacement_ != NULL; }
462 LLabel* replacement_;
466 class LParameter final : public LTemplateInstruction<1, 0, 0> {
468 bool HasInterestingComment(LCodeGen* gen) const override { return false; }
469 DECLARE_CONCRETE_INSTRUCTION(Parameter, "parameter")
473 class LCallStub final : public LTemplateInstruction<1, 1, 0> {
475 explicit LCallStub(LOperand* context) {
476 inputs_[0] = context;
479 LOperand* context() { return inputs_[0]; }
481 DECLARE_CONCRETE_INSTRUCTION(CallStub, "call-stub")
482 DECLARE_HYDROGEN_ACCESSOR(CallStub)
486 class LUnknownOSRValue final : public LTemplateInstruction<1, 0, 0> {
488 bool HasInterestingComment(LCodeGen* gen) const override { return false; }
489 DECLARE_CONCRETE_INSTRUCTION(UnknownOSRValue, "unknown-osr-value")
493 template<int I, int T>
494 class LControlInstruction : public LTemplateInstruction<0, I, T> {
496 LControlInstruction() : false_label_(NULL), true_label_(NULL) { }
498 bool IsControl() const final { return true; }
500 int SuccessorCount() { return hydrogen()->SuccessorCount(); }
501 HBasicBlock* SuccessorAt(int i) { return hydrogen()->SuccessorAt(i); }
503 int TrueDestination(LChunk* chunk) {
504 return chunk->LookupDestination(true_block_id());
506 int FalseDestination(LChunk* chunk) {
507 return chunk->LookupDestination(false_block_id());
510 Label* TrueLabel(LChunk* chunk) {
511 if (true_label_ == NULL) {
512 true_label_ = chunk->GetAssemblyLabel(TrueDestination(chunk));
516 Label* FalseLabel(LChunk* chunk) {
517 if (false_label_ == NULL) {
518 false_label_ = chunk->GetAssemblyLabel(FalseDestination(chunk));
524 int true_block_id() { return SuccessorAt(0)->block_id(); }
525 int false_block_id() { return SuccessorAt(1)->block_id(); }
528 HControlInstruction* hydrogen() {
529 return HControlInstruction::cast(this->hydrogen_value());
537 class LWrapReceiver final : public LTemplateInstruction<1, 2, 0> {
539 LWrapReceiver(LOperand* receiver, LOperand* function) {
540 inputs_[0] = receiver;
541 inputs_[1] = function;
544 LOperand* receiver() { return inputs_[0]; }
545 LOperand* function() { return inputs_[1]; }
547 DECLARE_CONCRETE_INSTRUCTION(WrapReceiver, "wrap-receiver")
548 DECLARE_HYDROGEN_ACCESSOR(WrapReceiver)
552 class LApplyArguments final : public LTemplateInstruction<1, 4, 0> {
554 LApplyArguments(LOperand* function,
557 LOperand* elements) {
558 inputs_[0] = function;
559 inputs_[1] = receiver;
561 inputs_[3] = elements;
564 LOperand* function() { return inputs_[0]; }
565 LOperand* receiver() { return inputs_[1]; }
566 LOperand* length() { return inputs_[2]; }
567 LOperand* elements() { return inputs_[3]; }
569 DECLARE_CONCRETE_INSTRUCTION(ApplyArguments, "apply-arguments")
573 class LAccessArgumentsAt final : public LTemplateInstruction<1, 3, 0> {
575 LAccessArgumentsAt(LOperand* arguments, LOperand* length, LOperand* index) {
576 inputs_[0] = arguments;
581 LOperand* arguments() { return inputs_[0]; }
582 LOperand* length() { return inputs_[1]; }
583 LOperand* index() { return inputs_[2]; }
585 DECLARE_CONCRETE_INSTRUCTION(AccessArgumentsAt, "access-arguments-at")
587 void PrintDataTo(StringStream* stream) override;
591 class LArgumentsLength final : public LTemplateInstruction<1, 1, 0> {
593 explicit LArgumentsLength(LOperand* elements) {
594 inputs_[0] = elements;
597 LOperand* elements() { return inputs_[0]; }
599 DECLARE_CONCRETE_INSTRUCTION(ArgumentsLength, "arguments-length")
603 class LArgumentsElements final : public LTemplateInstruction<1, 0, 0> {
605 DECLARE_CONCRETE_INSTRUCTION(ArgumentsElements, "arguments-elements")
606 DECLARE_HYDROGEN_ACCESSOR(ArgumentsElements)
610 class LModByPowerOf2I final : public LTemplateInstruction<1, 1, 0> {
612 LModByPowerOf2I(LOperand* dividend, int32_t divisor) {
613 inputs_[0] = dividend;
617 LOperand* dividend() { return inputs_[0]; }
618 int32_t divisor() const { return divisor_; }
620 DECLARE_CONCRETE_INSTRUCTION(ModByPowerOf2I, "mod-by-power-of-2-i")
621 DECLARE_HYDROGEN_ACCESSOR(Mod)
628 class LModByConstI final : public LTemplateInstruction<1, 1, 2> {
630 LModByConstI(LOperand* dividend,
634 inputs_[0] = dividend;
640 LOperand* dividend() { return inputs_[0]; }
641 int32_t divisor() const { return divisor_; }
642 LOperand* temp1() { return temps_[0]; }
643 LOperand* temp2() { return temps_[1]; }
645 DECLARE_CONCRETE_INSTRUCTION(ModByConstI, "mod-by-const-i")
646 DECLARE_HYDROGEN_ACCESSOR(Mod)
653 class LModI final : public LTemplateInstruction<1, 2, 1> {
655 LModI(LOperand* left, LOperand* right, LOperand* temp) {
661 LOperand* left() { return inputs_[0]; }
662 LOperand* right() { return inputs_[1]; }
663 LOperand* temp() { return temps_[0]; }
665 DECLARE_CONCRETE_INSTRUCTION(ModI, "mod-i")
666 DECLARE_HYDROGEN_ACCESSOR(Mod)
670 class LDivByPowerOf2I final : public LTemplateInstruction<1, 1, 0> {
672 LDivByPowerOf2I(LOperand* dividend, int32_t divisor) {
673 inputs_[0] = dividend;
677 LOperand* dividend() { return inputs_[0]; }
678 int32_t divisor() const { return divisor_; }
680 DECLARE_CONCRETE_INSTRUCTION(DivByPowerOf2I, "div-by-power-of-2-i")
681 DECLARE_HYDROGEN_ACCESSOR(Div)
688 class LDivByConstI final : public LTemplateInstruction<1, 1, 2> {
690 LDivByConstI(LOperand* dividend,
694 inputs_[0] = dividend;
700 LOperand* dividend() { return inputs_[0]; }
701 int32_t divisor() const { return divisor_; }
702 LOperand* temp1() { return temps_[0]; }
703 LOperand* temp2() { return temps_[1]; }
705 DECLARE_CONCRETE_INSTRUCTION(DivByConstI, "div-by-const-i")
706 DECLARE_HYDROGEN_ACCESSOR(Div)
713 class LDivI final : public LTemplateInstruction<1, 2, 1> {
715 LDivI(LOperand* dividend, LOperand* divisor, LOperand* temp) {
716 inputs_[0] = dividend;
717 inputs_[1] = divisor;
721 LOperand* dividend() { return inputs_[0]; }
722 LOperand* divisor() { return inputs_[1]; }
723 LOperand* temp() { return temps_[0]; }
725 DECLARE_CONCRETE_INSTRUCTION(DivI, "div-i")
726 DECLARE_HYDROGEN_ACCESSOR(BinaryOperation)
730 class LFlooringDivByPowerOf2I final : public LTemplateInstruction<1, 1, 0> {
732 LFlooringDivByPowerOf2I(LOperand* dividend, int32_t divisor) {
733 inputs_[0] = dividend;
737 LOperand* dividend() { return inputs_[0]; }
738 int32_t divisor() const { return divisor_; }
740 DECLARE_CONCRETE_INSTRUCTION(FlooringDivByPowerOf2I,
741 "flooring-div-by-power-of-2-i")
742 DECLARE_HYDROGEN_ACCESSOR(MathFloorOfDiv)
749 class LFlooringDivByConstI final : public LTemplateInstruction<1, 1, 3> {
751 LFlooringDivByConstI(LOperand* dividend,
756 inputs_[0] = dividend;
763 LOperand* dividend() { return inputs_[0]; }
764 int32_t divisor() const { return divisor_; }
765 LOperand* temp1() { return temps_[0]; }
766 LOperand* temp2() { return temps_[1]; }
767 LOperand* temp3() { return temps_[2]; }
769 DECLARE_CONCRETE_INSTRUCTION(FlooringDivByConstI, "flooring-div-by-const-i")
770 DECLARE_HYDROGEN_ACCESSOR(MathFloorOfDiv)
777 class LFlooringDivI final : public LTemplateInstruction<1, 2, 1> {
779 LFlooringDivI(LOperand* dividend, LOperand* divisor, LOperand* temp) {
780 inputs_[0] = dividend;
781 inputs_[1] = divisor;
785 LOperand* dividend() { return inputs_[0]; }
786 LOperand* divisor() { return inputs_[1]; }
787 LOperand* temp() { return temps_[0]; }
789 DECLARE_CONCRETE_INSTRUCTION(FlooringDivI, "flooring-div-i")
790 DECLARE_HYDROGEN_ACCESSOR(MathFloorOfDiv)
794 class LMulI final : public LTemplateInstruction<1, 2, 0> {
796 LMulI(LOperand* left, LOperand* right) {
801 LOperand* left() { return inputs_[0]; }
802 LOperand* right() { return inputs_[1]; }
804 DECLARE_CONCRETE_INSTRUCTION(MulI, "mul-i")
805 DECLARE_HYDROGEN_ACCESSOR(Mul)
809 class LCompareNumericAndBranch final : public LControlInstruction<2, 0> {
811 LCompareNumericAndBranch(LOperand* left, LOperand* right) {
816 LOperand* left() { return inputs_[0]; }
817 LOperand* right() { return inputs_[1]; }
819 DECLARE_CONCRETE_INSTRUCTION(CompareNumericAndBranch,
820 "compare-numeric-and-branch")
821 DECLARE_HYDROGEN_ACCESSOR(CompareNumericAndBranch)
823 Token::Value op() const { return hydrogen()->token(); }
824 bool is_double() const {
825 return hydrogen()->representation().IsDouble();
828 void PrintDataTo(StringStream* stream) override;
832 class LMathFloor final : public LTemplateInstruction<1, 1, 0> {
834 explicit LMathFloor(LOperand* value) {
838 LOperand* value() { return inputs_[0]; }
840 DECLARE_CONCRETE_INSTRUCTION(MathFloor, "math-floor")
841 DECLARE_HYDROGEN_ACCESSOR(UnaryMathOperation)
845 class LMathRound final : public LTemplateInstruction<1, 1, 1> {
847 LMathRound(LOperand* value, LOperand* temp) {
852 LOperand* value() { return inputs_[0]; }
853 LOperand* temp() { return temps_[0]; }
855 DECLARE_CONCRETE_INSTRUCTION(MathRound, "math-round")
856 DECLARE_HYDROGEN_ACCESSOR(UnaryMathOperation)
860 class LMathFround final : public LTemplateInstruction<1, 1, 0> {
862 explicit LMathFround(LOperand* value) { inputs_[0] = value; }
864 LOperand* value() { return inputs_[0]; }
866 DECLARE_CONCRETE_INSTRUCTION(MathFround, "math-fround")
870 class LMathAbs final : public LTemplateInstruction<1, 2, 0> {
872 explicit LMathAbs(LOperand* context, LOperand* value) {
873 inputs_[1] = context;
877 LOperand* context() { return inputs_[1]; }
878 LOperand* value() { return inputs_[0]; }
880 DECLARE_CONCRETE_INSTRUCTION(MathAbs, "math-abs")
881 DECLARE_HYDROGEN_ACCESSOR(UnaryMathOperation)
885 class LMathLog final : public LTemplateInstruction<1, 1, 0> {
887 explicit LMathLog(LOperand* value) {
891 LOperand* value() { return inputs_[0]; }
893 DECLARE_CONCRETE_INSTRUCTION(MathLog, "math-log")
897 class LMathClz32 final : public LTemplateInstruction<1, 1, 0> {
899 explicit LMathClz32(LOperand* value) {
903 LOperand* value() { return inputs_[0]; }
905 DECLARE_CONCRETE_INSTRUCTION(MathClz32, "math-clz32")
909 class LMathExp final : public LTemplateInstruction<1, 1, 2> {
911 LMathExp(LOperand* value, LOperand* temp1, LOperand* temp2) {
915 ExternalReference::InitializeMathExpData();
918 LOperand* value() { return inputs_[0]; }
919 LOperand* temp1() { return temps_[0]; }
920 LOperand* temp2() { return temps_[1]; }
922 DECLARE_CONCRETE_INSTRUCTION(MathExp, "math-exp")
926 class LMathSqrt final : public LTemplateInstruction<1, 1, 0> {
928 explicit LMathSqrt(LOperand* value) {
932 LOperand* value() { return inputs_[0]; }
934 DECLARE_CONCRETE_INSTRUCTION(MathSqrt, "math-sqrt")
938 class LMathPowHalf final : public LTemplateInstruction<1, 1, 0> {
940 explicit LMathPowHalf(LOperand* value) {
944 LOperand* value() { return inputs_[0]; }
946 DECLARE_CONCRETE_INSTRUCTION(MathPowHalf, "math-pow-half")
950 class LCmpObjectEqAndBranch final : public LControlInstruction<2, 0> {
952 LCmpObjectEqAndBranch(LOperand* left, LOperand* right) {
957 LOperand* left() { return inputs_[0]; }
958 LOperand* right() { return inputs_[1]; }
960 DECLARE_CONCRETE_INSTRUCTION(CmpObjectEqAndBranch, "cmp-object-eq-and-branch")
964 class LCmpHoleAndBranch final : public LControlInstruction<1, 0> {
966 explicit LCmpHoleAndBranch(LOperand* object) {
970 LOperand* object() { return inputs_[0]; }
972 DECLARE_CONCRETE_INSTRUCTION(CmpHoleAndBranch, "cmp-hole-and-branch")
973 DECLARE_HYDROGEN_ACCESSOR(CompareHoleAndBranch)
977 class LCompareMinusZeroAndBranch final : public LControlInstruction<1, 0> {
979 explicit LCompareMinusZeroAndBranch(LOperand* value) {
983 LOperand* value() { return inputs_[0]; }
985 DECLARE_CONCRETE_INSTRUCTION(CompareMinusZeroAndBranch,
986 "cmp-minus-zero-and-branch")
987 DECLARE_HYDROGEN_ACCESSOR(CompareMinusZeroAndBranch)
991 class LIsStringAndBranch final : public LControlInstruction<1, 1> {
993 explicit LIsStringAndBranch(LOperand* value, LOperand* temp) {
998 LOperand* value() { return inputs_[0]; }
999 LOperand* temp() { return temps_[0]; }
1001 DECLARE_CONCRETE_INSTRUCTION(IsStringAndBranch, "is-string-and-branch")
1002 DECLARE_HYDROGEN_ACCESSOR(IsStringAndBranch)
1004 void PrintDataTo(StringStream* stream) override;
1008 class LIsSmiAndBranch final : public LControlInstruction<1, 0> {
1010 explicit LIsSmiAndBranch(LOperand* value) {
1014 LOperand* value() { return inputs_[0]; }
1016 DECLARE_CONCRETE_INSTRUCTION(IsSmiAndBranch, "is-smi-and-branch")
1017 DECLARE_HYDROGEN_ACCESSOR(IsSmiAndBranch)
1019 void PrintDataTo(StringStream* stream) override;
1023 class LIsUndetectableAndBranch final : public LControlInstruction<1, 1> {
1025 explicit LIsUndetectableAndBranch(LOperand* value, LOperand* temp) {
1030 LOperand* value() { return inputs_[0]; }
1031 LOperand* temp() { return temps_[0]; }
1033 DECLARE_CONCRETE_INSTRUCTION(IsUndetectableAndBranch,
1034 "is-undetectable-and-branch")
1035 DECLARE_HYDROGEN_ACCESSOR(IsUndetectableAndBranch)
1037 void PrintDataTo(StringStream* stream) override;
1041 class LStringCompareAndBranch final : public LControlInstruction<3, 0> {
1043 explicit LStringCompareAndBranch(LOperand* context,
1046 inputs_[0] = context;
1051 LOperand* context() { return inputs_[0]; }
1052 LOperand* left() { return inputs_[1]; }
1053 LOperand* right() { return inputs_[2]; }
1055 DECLARE_CONCRETE_INSTRUCTION(StringCompareAndBranch,
1056 "string-compare-and-branch")
1057 DECLARE_HYDROGEN_ACCESSOR(StringCompareAndBranch)
1059 void PrintDataTo(StringStream* stream) override;
1061 Token::Value op() const { return hydrogen()->token(); }
1065 class LHasInstanceTypeAndBranch final : public LControlInstruction<1, 0> {
1067 explicit LHasInstanceTypeAndBranch(LOperand* value) {
1071 LOperand* value() { return inputs_[0]; }
1073 DECLARE_CONCRETE_INSTRUCTION(HasInstanceTypeAndBranch,
1074 "has-instance-type-and-branch")
1075 DECLARE_HYDROGEN_ACCESSOR(HasInstanceTypeAndBranch)
1077 void PrintDataTo(StringStream* stream) override;
1081 class LGetCachedArrayIndex final : public LTemplateInstruction<1, 1, 0> {
1083 explicit LGetCachedArrayIndex(LOperand* value) {
1087 LOperand* value() { return inputs_[0]; }
1089 DECLARE_CONCRETE_INSTRUCTION(GetCachedArrayIndex, "get-cached-array-index")
1090 DECLARE_HYDROGEN_ACCESSOR(GetCachedArrayIndex)
1094 class LHasCachedArrayIndexAndBranch final : public LControlInstruction<1, 0> {
1096 explicit LHasCachedArrayIndexAndBranch(LOperand* value) {
1100 LOperand* value() { return inputs_[0]; }
1102 DECLARE_CONCRETE_INSTRUCTION(HasCachedArrayIndexAndBranch,
1103 "has-cached-array-index-and-branch")
1104 DECLARE_HYDROGEN_ACCESSOR(HasCachedArrayIndexAndBranch)
1106 void PrintDataTo(StringStream* stream) override;
1110 class LClassOfTestAndBranch final : public LControlInstruction<1, 2> {
1112 LClassOfTestAndBranch(LOperand* value, LOperand* temp, LOperand* temp2) {
1118 LOperand* value() { return inputs_[0]; }
1119 LOperand* temp() { return temps_[0]; }
1120 LOperand* temp2() { return temps_[1]; }
1122 DECLARE_CONCRETE_INSTRUCTION(ClassOfTestAndBranch,
1123 "class-of-test-and-branch")
1124 DECLARE_HYDROGEN_ACCESSOR(ClassOfTestAndBranch)
1126 void PrintDataTo(StringStream* stream) override;
1130 class LCmpT final : public LTemplateInstruction<1, 3, 0> {
1132 LCmpT(LOperand* context, LOperand* left, LOperand* right) {
1133 inputs_[0] = context;
1138 LOperand* context() { return inputs_[0]; }
1139 LOperand* left() { return inputs_[1]; }
1140 LOperand* right() { return inputs_[2]; }
1142 DECLARE_CONCRETE_INSTRUCTION(CmpT, "cmp-t")
1143 DECLARE_HYDROGEN_ACCESSOR(CompareGeneric)
1145 Strength strength() { return hydrogen()->strength(); }
1147 Token::Value op() const { return hydrogen()->token(); }
1151 class LInstanceOf final : public LTemplateInstruction<1, 3, 0> {
1153 LInstanceOf(LOperand* context, LOperand* left, LOperand* right) {
1154 inputs_[0] = context;
1159 LOperand* context() { return inputs_[0]; }
1160 LOperand* left() { return inputs_[1]; }
1161 LOperand* right() { return inputs_[2]; }
1163 DECLARE_CONCRETE_INSTRUCTION(InstanceOf, "instance-of")
1167 class LHasInPrototypeChainAndBranch final : public LControlInstruction<2, 0> {
1169 LHasInPrototypeChainAndBranch(LOperand* object, LOperand* prototype) {
1170 inputs_[0] = object;
1171 inputs_[1] = prototype;
1174 LOperand* object() const { return inputs_[0]; }
1175 LOperand* prototype() const { return inputs_[1]; }
1177 DECLARE_CONCRETE_INSTRUCTION(HasInPrototypeChainAndBranch,
1178 "has-in-prototype-chain-and-branch")
1179 DECLARE_HYDROGEN_ACCESSOR(HasInPrototypeChainAndBranch)
1183 class LBoundsCheck final : public LTemplateInstruction<0, 2, 0> {
1185 LBoundsCheck(LOperand* index, LOperand* length) {
1187 inputs_[1] = length;
1190 LOperand* index() { return inputs_[0]; }
1191 LOperand* length() { return inputs_[1]; }
1193 DECLARE_CONCRETE_INSTRUCTION(BoundsCheck, "bounds-check")
1194 DECLARE_HYDROGEN_ACCESSOR(BoundsCheck)
1198 class LBitI final : public LTemplateInstruction<1, 2, 0> {
1200 LBitI(LOperand* left, LOperand* right) {
1205 LOperand* left() { return inputs_[0]; }
1206 LOperand* right() { return inputs_[1]; }
1208 Token::Value op() const { return hydrogen()->op(); }
1209 bool IsInteger32() const {
1210 return hydrogen()->representation().IsInteger32();
1213 DECLARE_CONCRETE_INSTRUCTION(BitI, "bit-i")
1214 DECLARE_HYDROGEN_ACCESSOR(Bitwise)
1218 class LShiftI final : public LTemplateInstruction<1, 2, 0> {
1220 LShiftI(Token::Value op, LOperand* left, LOperand* right, bool can_deopt)
1221 : op_(op), can_deopt_(can_deopt) {
1226 Token::Value op() const { return op_; }
1227 LOperand* left() { return inputs_[0]; }
1228 LOperand* right() { return inputs_[1]; }
1229 bool can_deopt() const { return can_deopt_; }
1231 DECLARE_CONCRETE_INSTRUCTION(ShiftI, "shift-i")
1239 class LSubI final : public LTemplateInstruction<1, 2, 0> {
1241 LSubI(LOperand* left, LOperand* right) {
1246 LOperand* left() { return inputs_[0]; }
1247 LOperand* right() { return inputs_[1]; }
1249 DECLARE_CONCRETE_INSTRUCTION(SubI, "sub-i")
1250 DECLARE_HYDROGEN_ACCESSOR(Sub)
1254 class LConstantI final : public LTemplateInstruction<1, 0, 0> {
1256 DECLARE_CONCRETE_INSTRUCTION(ConstantI, "constant-i")
1257 DECLARE_HYDROGEN_ACCESSOR(Constant)
1259 int32_t value() const { return hydrogen()->Integer32Value(); }
1263 class LConstantS final : public LTemplateInstruction<1, 0, 0> {
1265 DECLARE_CONCRETE_INSTRUCTION(ConstantS, "constant-s")
1266 DECLARE_HYDROGEN_ACCESSOR(Constant)
1268 Smi* value() const { return Smi::FromInt(hydrogen()->Integer32Value()); }
1272 class LConstantD final : public LTemplateInstruction<1, 0, 0> {
1274 DECLARE_CONCRETE_INSTRUCTION(ConstantD, "constant-d")
1275 DECLARE_HYDROGEN_ACCESSOR(Constant)
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) {
1309 LOperand* value() { return inputs_[0]; }
1311 DECLARE_CONCRETE_INSTRUCTION(Branch, "branch")
1312 DECLARE_HYDROGEN_ACCESSOR(Branch)
1314 void PrintDataTo(StringStream* stream) override;
1318 class LDebugBreak final : public LTemplateInstruction<0, 0, 0> {
1320 DECLARE_CONCRETE_INSTRUCTION(DebugBreak, "break")
1324 class LCmpMapAndBranch final : public LControlInstruction<1, 0> {
1326 explicit LCmpMapAndBranch(LOperand* value) {
1330 LOperand* value() { return inputs_[0]; }
1332 DECLARE_CONCRETE_INSTRUCTION(CmpMapAndBranch, "cmp-map-and-branch")
1333 DECLARE_HYDROGEN_ACCESSOR(CompareMap)
1335 Handle<Map> map() const { return hydrogen()->map().handle(); }
1339 class LMapEnumLength final : public LTemplateInstruction<1, 1, 0> {
1341 explicit LMapEnumLength(LOperand* value) {
1345 LOperand* value() { return inputs_[0]; }
1347 DECLARE_CONCRETE_INSTRUCTION(MapEnumLength, "map-enum-length")
1351 class LDateField final : public LTemplateInstruction<1, 1, 0> {
1353 LDateField(LOperand* date, Smi* index) : index_(index) {
1357 LOperand* date() { return inputs_[0]; }
1358 Smi* index() const { return index_; }
1360 DECLARE_CONCRETE_INSTRUCTION(DateField, "date-field")
1361 DECLARE_HYDROGEN_ACCESSOR(DateField)
1368 class LSeqStringGetChar final : public LTemplateInstruction<1, 2, 0> {
1370 LSeqStringGetChar(LOperand* string, LOperand* index) {
1371 inputs_[0] = string;
1375 LOperand* string() const { return inputs_[0]; }
1376 LOperand* index() const { return inputs_[1]; }
1378 DECLARE_CONCRETE_INSTRUCTION(SeqStringGetChar, "seq-string-get-char")
1379 DECLARE_HYDROGEN_ACCESSOR(SeqStringGetChar)
1383 class LSeqStringSetChar final : public LTemplateInstruction<1, 4, 0> {
1385 LSeqStringSetChar(LOperand* context,
1389 inputs_[0] = context;
1390 inputs_[1] = string;
1395 LOperand* string() { return inputs_[1]; }
1396 LOperand* index() { return inputs_[2]; }
1397 LOperand* value() { return inputs_[3]; }
1399 DECLARE_CONCRETE_INSTRUCTION(SeqStringSetChar, "seq-string-set-char")
1400 DECLARE_HYDROGEN_ACCESSOR(SeqStringSetChar)
1404 class LAddI final : public LTemplateInstruction<1, 2, 0> {
1406 LAddI(LOperand* left, LOperand* right) {
1411 LOperand* left() { return inputs_[0]; }
1412 LOperand* right() { return inputs_[1]; }
1414 static bool UseLea(HAdd* add) {
1415 return !add->CheckFlag(HValue::kCanOverflow) &&
1416 add->BetterLeftOperand()->UseCount() > 1;
1419 DECLARE_CONCRETE_INSTRUCTION(AddI, "add-i")
1420 DECLARE_HYDROGEN_ACCESSOR(Add)
1424 class LMathMinMax final : public LTemplateInstruction<1, 2, 0> {
1426 LMathMinMax(LOperand* left, LOperand* right) {
1431 LOperand* left() { return inputs_[0]; }
1432 LOperand* right() { return inputs_[1]; }
1434 DECLARE_CONCRETE_INSTRUCTION(MathMinMax, "math-min-max")
1435 DECLARE_HYDROGEN_ACCESSOR(MathMinMax)
1439 class LPower final : public LTemplateInstruction<1, 2, 0> {
1441 LPower(LOperand* left, LOperand* right) {
1446 LOperand* left() { return inputs_[0]; }
1447 LOperand* right() { return inputs_[1]; }
1449 DECLARE_CONCRETE_INSTRUCTION(Power, "power")
1450 DECLARE_HYDROGEN_ACCESSOR(Power)
1454 class LArithmeticD final : public LTemplateInstruction<1, 2, 0> {
1456 LArithmeticD(Token::Value op, LOperand* left, LOperand* right)
1462 Token::Value op() const { return op_; }
1463 LOperand* left() { return inputs_[0]; }
1464 LOperand* right() { return inputs_[1]; }
1466 Opcode opcode() const override { return LInstruction::kArithmeticD; }
1467 void CompileToNative(LCodeGen* generator) override;
1468 const char* Mnemonic() const override;
1475 class LArithmeticT final : public LTemplateInstruction<1, 3, 0> {
1477 LArithmeticT(Token::Value op,
1482 inputs_[0] = context;
1487 Token::Value op() const { return op_; }
1488 LOperand* context() { return inputs_[0]; }
1489 LOperand* left() { return inputs_[1]; }
1490 LOperand* right() { return inputs_[2]; }
1492 Opcode opcode() const override { return LInstruction::kArithmeticT; }
1493 void CompileToNative(LCodeGen* generator) override;
1494 const char* Mnemonic() const override;
1496 DECLARE_HYDROGEN_ACCESSOR(BinaryOperation)
1498 Strength strength() { return hydrogen()->strength(); }
1505 class LReturn final : public LTemplateInstruction<0, 3, 0> {
1507 explicit LReturn(LOperand* value,
1509 LOperand* parameter_count) {
1511 inputs_[1] = context;
1512 inputs_[2] = parameter_count;
1515 LOperand* value() { return inputs_[0]; }
1516 LOperand* context() { return inputs_[1]; }
1518 bool has_constant_parameter_count() {
1519 return parameter_count()->IsConstantOperand();
1521 LConstantOperand* constant_parameter_count() {
1522 DCHECK(has_constant_parameter_count());
1523 return LConstantOperand::cast(parameter_count());
1525 LOperand* parameter_count() { return inputs_[2]; }
1527 DECLARE_CONCRETE_INSTRUCTION(Return, "return")
1528 DECLARE_HYDROGEN_ACCESSOR(Return)
1532 class LLoadNamedField final : public LTemplateInstruction<1, 1, 0> {
1534 explicit LLoadNamedField(LOperand* object) {
1535 inputs_[0] = object;
1538 LOperand* object() { return inputs_[0]; }
1540 DECLARE_CONCRETE_INSTRUCTION(LoadNamedField, "load-named-field")
1541 DECLARE_HYDROGEN_ACCESSOR(LoadNamedField)
1545 class LLoadNamedGeneric final : public LTemplateInstruction<1, 2, 1> {
1547 explicit LLoadNamedGeneric(LOperand* context, LOperand* object,
1549 inputs_[0] = context;
1550 inputs_[1] = object;
1554 DECLARE_CONCRETE_INSTRUCTION(LoadNamedGeneric, "load-named-generic")
1555 DECLARE_HYDROGEN_ACCESSOR(LoadNamedGeneric)
1557 LOperand* context() { return inputs_[0]; }
1558 LOperand* object() { return inputs_[1]; }
1559 LOperand* temp_vector() { return temps_[0]; }
1561 Handle<Object> name() const { return hydrogen()->name(); }
1565 class LLoadFunctionPrototype final : public LTemplateInstruction<1, 1, 0> {
1567 explicit LLoadFunctionPrototype(LOperand* function) {
1568 inputs_[0] = function;
1571 DECLARE_CONCRETE_INSTRUCTION(LoadFunctionPrototype, "load-function-prototype")
1572 DECLARE_HYDROGEN_ACCESSOR(LoadFunctionPrototype)
1574 LOperand* function() { return inputs_[0]; }
1578 class LLoadRoot final : public LTemplateInstruction<1, 0, 0> {
1580 DECLARE_CONCRETE_INSTRUCTION(LoadRoot, "load-root")
1581 DECLARE_HYDROGEN_ACCESSOR(LoadRoot)
1583 Heap::RootListIndex index() const { return hydrogen()->index(); }
1587 inline static bool ExternalArrayOpRequiresTemp(
1588 Representation key_representation,
1589 ElementsKind elements_kind) {
1590 // Operations that require the key to be divided by two to be converted into
1591 // an index cannot fold the scale operation into a load and need an extra
1592 // temp register to do the work.
1593 return SmiValuesAre31Bits() && key_representation.IsSmi() &&
1594 (elements_kind == UINT8_ELEMENTS || elements_kind == INT8_ELEMENTS ||
1595 elements_kind == UINT8_CLAMPED_ELEMENTS);
1599 class LLoadKeyed final : public LTemplateInstruction<1, 2, 0> {
1601 LLoadKeyed(LOperand* elements, LOperand* key) {
1602 inputs_[0] = elements;
1606 DECLARE_CONCRETE_INSTRUCTION(LoadKeyed, "load-keyed")
1607 DECLARE_HYDROGEN_ACCESSOR(LoadKeyed)
1609 bool is_fixed_typed_array() const {
1610 return hydrogen()->is_fixed_typed_array();
1612 LOperand* elements() { return inputs_[0]; }
1613 LOperand* key() { return inputs_[1]; }
1614 void PrintDataTo(StringStream* stream) override;
1615 uint32_t base_offset() const { return hydrogen()->base_offset(); }
1616 ElementsKind elements_kind() const {
1617 return hydrogen()->elements_kind();
1622 class LLoadKeyedGeneric final : public LTemplateInstruction<1, 3, 1> {
1624 LLoadKeyedGeneric(LOperand* context, LOperand* obj, LOperand* key,
1626 inputs_[0] = context;
1632 DECLARE_CONCRETE_INSTRUCTION(LoadKeyedGeneric, "load-keyed-generic")
1633 DECLARE_HYDROGEN_ACCESSOR(LoadKeyedGeneric)
1635 LOperand* context() { return inputs_[0]; }
1636 LOperand* object() { return inputs_[1]; }
1637 LOperand* key() { return inputs_[2]; }
1638 LOperand* temp_vector() { return temps_[0]; }
1642 class LLoadGlobalGeneric final : public LTemplateInstruction<1, 2, 1> {
1644 explicit LLoadGlobalGeneric(LOperand* context, LOperand* global_object,
1646 inputs_[0] = context;
1647 inputs_[1] = global_object;
1651 DECLARE_CONCRETE_INSTRUCTION(LoadGlobalGeneric, "load-global-generic")
1652 DECLARE_HYDROGEN_ACCESSOR(LoadGlobalGeneric)
1654 LOperand* context() { return inputs_[0]; }
1655 LOperand* global_object() { return inputs_[1]; }
1656 LOperand* temp_vector() { return temps_[0]; }
1658 Handle<Object> name() const { return hydrogen()->name(); }
1659 TypeofMode typeof_mode() const { return hydrogen()->typeof_mode(); }
1663 class LLoadGlobalViaContext final : public LTemplateInstruction<1, 1, 1> {
1665 explicit LLoadGlobalViaContext(LOperand* context) { inputs_[0] = context; }
1667 DECLARE_CONCRETE_INSTRUCTION(LoadGlobalViaContext, "load-global-via-context")
1668 DECLARE_HYDROGEN_ACCESSOR(LoadGlobalViaContext)
1670 void PrintDataTo(StringStream* stream) override;
1672 LOperand* context() { return inputs_[0]; }
1674 int depth() const { return hydrogen()->depth(); }
1675 int slot_index() const { return hydrogen()->slot_index(); }
1679 class LLoadContextSlot final : public LTemplateInstruction<1, 1, 0> {
1681 explicit LLoadContextSlot(LOperand* context) {
1682 inputs_[0] = context;
1685 LOperand* context() { return inputs_[0]; }
1687 DECLARE_CONCRETE_INSTRUCTION(LoadContextSlot, "load-context-slot")
1688 DECLARE_HYDROGEN_ACCESSOR(LoadContextSlot)
1690 int slot_index() { return hydrogen()->slot_index(); }
1692 void PrintDataTo(StringStream* stream) override;
1696 class LStoreContextSlot final : public LTemplateInstruction<0, 2, 1> {
1698 LStoreContextSlot(LOperand* context, LOperand* value, LOperand* temp) {
1699 inputs_[0] = context;
1704 LOperand* context() { return inputs_[0]; }
1705 LOperand* value() { return inputs_[1]; }
1706 LOperand* temp() { return temps_[0]; }
1708 DECLARE_CONCRETE_INSTRUCTION(StoreContextSlot, "store-context-slot")
1709 DECLARE_HYDROGEN_ACCESSOR(StoreContextSlot)
1711 int slot_index() { return hydrogen()->slot_index(); }
1713 void PrintDataTo(StringStream* stream) override;
1717 class LPushArgument final : public LTemplateInstruction<0, 1, 0> {
1719 explicit LPushArgument(LOperand* value) {
1723 LOperand* value() { return inputs_[0]; }
1725 DECLARE_CONCRETE_INSTRUCTION(PushArgument, "push-argument")
1729 class LDrop final : public LTemplateInstruction<0, 0, 0> {
1731 explicit LDrop(int count) : count_(count) { }
1733 int count() const { return count_; }
1735 DECLARE_CONCRETE_INSTRUCTION(Drop, "drop")
1742 class LStoreCodeEntry final : public LTemplateInstruction<0, 2, 0> {
1744 LStoreCodeEntry(LOperand* function, LOperand* code_object) {
1745 inputs_[0] = function;
1746 inputs_[1] = code_object;
1749 LOperand* function() { return inputs_[0]; }
1750 LOperand* code_object() { return inputs_[1]; }
1752 void PrintDataTo(StringStream* stream) override;
1754 DECLARE_CONCRETE_INSTRUCTION(StoreCodeEntry, "store-code-entry")
1755 DECLARE_HYDROGEN_ACCESSOR(StoreCodeEntry)
1759 class LInnerAllocatedObject final : public LTemplateInstruction<1, 2, 0> {
1761 LInnerAllocatedObject(LOperand* base_object, LOperand* offset) {
1762 inputs_[0] = base_object;
1763 inputs_[1] = offset;
1766 LOperand* base_object() const { return inputs_[0]; }
1767 LOperand* offset() const { return inputs_[1]; }
1769 void PrintDataTo(StringStream* stream) override;
1771 DECLARE_CONCRETE_INSTRUCTION(InnerAllocatedObject, "inner-allocated-object")
1775 class LThisFunction final : public LTemplateInstruction<1, 0, 0> {
1777 DECLARE_CONCRETE_INSTRUCTION(ThisFunction, "this-function")
1778 DECLARE_HYDROGEN_ACCESSOR(ThisFunction)
1782 class LContext final : public LTemplateInstruction<1, 0, 0> {
1784 DECLARE_CONCRETE_INSTRUCTION(Context, "context")
1785 DECLARE_HYDROGEN_ACCESSOR(Context)
1789 class LDeclareGlobals final : public LTemplateInstruction<0, 1, 0> {
1791 explicit LDeclareGlobals(LOperand* context) {
1792 inputs_[0] = context;
1795 LOperand* context() { return inputs_[0]; }
1797 DECLARE_CONCRETE_INSTRUCTION(DeclareGlobals, "declare-globals")
1798 DECLARE_HYDROGEN_ACCESSOR(DeclareGlobals)
1802 class LCallJSFunction final : public LTemplateInstruction<1, 1, 0> {
1804 explicit LCallJSFunction(LOperand* function) {
1805 inputs_[0] = function;
1808 LOperand* function() { return inputs_[0]; }
1810 DECLARE_CONCRETE_INSTRUCTION(CallJSFunction, "call-js-function")
1811 DECLARE_HYDROGEN_ACCESSOR(CallJSFunction)
1813 void PrintDataTo(StringStream* stream) override;
1815 int arity() const { return hydrogen()->argument_count() - 1; }
1819 class LCallWithDescriptor final : public LTemplateResultInstruction<1> {
1821 LCallWithDescriptor(CallInterfaceDescriptor descriptor,
1822 const ZoneList<LOperand*>& operands, Zone* zone)
1823 : inputs_(descriptor.GetRegisterParameterCount() +
1824 kImplicitRegisterParameterCount,
1826 DCHECK(descriptor.GetRegisterParameterCount() +
1827 kImplicitRegisterParameterCount ==
1829 inputs_.AddAll(operands, zone);
1832 LOperand* target() const { return inputs_[0]; }
1834 DECLARE_HYDROGEN_ACCESSOR(CallWithDescriptor)
1836 // The target and context are passed as implicit parameters that are not
1837 // explicitly listed in the descriptor.
1838 static const int kImplicitRegisterParameterCount = 2;
1841 DECLARE_CONCRETE_INSTRUCTION(CallWithDescriptor, "call-with-descriptor")
1843 void PrintDataTo(StringStream* stream) override;
1845 int arity() const { return hydrogen()->argument_count() - 1; }
1847 ZoneList<LOperand*> inputs_;
1849 // Iterator support.
1850 int InputCount() final { return inputs_.length(); }
1851 LOperand* InputAt(int i) final { return inputs_[i]; }
1853 int TempCount() final { return 0; }
1854 LOperand* TempAt(int i) final { return NULL; }
1858 class LInvokeFunction final : public LTemplateInstruction<1, 2, 0> {
1860 LInvokeFunction(LOperand* context, LOperand* function) {
1861 inputs_[0] = context;
1862 inputs_[1] = function;
1865 LOperand* context() { return inputs_[0]; }
1866 LOperand* function() { return inputs_[1]; }
1868 DECLARE_CONCRETE_INSTRUCTION(InvokeFunction, "invoke-function")
1869 DECLARE_HYDROGEN_ACCESSOR(InvokeFunction)
1871 void PrintDataTo(StringStream* stream) override;
1873 int arity() const { return hydrogen()->argument_count() - 1; }
1877 class LCallFunction final : public LTemplateInstruction<1, 2, 2> {
1879 LCallFunction(LOperand* context, LOperand* function, LOperand* slot,
1881 inputs_[0] = context;
1882 inputs_[1] = function;
1887 DECLARE_CONCRETE_INSTRUCTION(CallFunction, "call-function")
1888 DECLARE_HYDROGEN_ACCESSOR(CallFunction)
1890 LOperand* context() { return inputs_[0]; }
1891 LOperand* function() { return inputs_[1]; }
1892 LOperand* temp_slot() { return temps_[0]; }
1893 LOperand* temp_vector() { return temps_[1]; }
1894 int arity() const { return hydrogen()->argument_count() - 1; }
1896 void PrintDataTo(StringStream* stream) override;
1900 class LCallNew final : public LTemplateInstruction<1, 2, 0> {
1902 LCallNew(LOperand* context, LOperand* constructor) {
1903 inputs_[0] = context;
1904 inputs_[1] = constructor;
1907 LOperand* context() { return inputs_[0]; }
1908 LOperand* constructor() { return inputs_[1]; }
1910 DECLARE_CONCRETE_INSTRUCTION(CallNew, "call-new")
1911 DECLARE_HYDROGEN_ACCESSOR(CallNew)
1913 void PrintDataTo(StringStream* stream) override;
1915 int arity() const { return hydrogen()->argument_count() - 1; }
1919 class LCallNewArray final : public LTemplateInstruction<1, 2, 0> {
1921 LCallNewArray(LOperand* context, LOperand* constructor) {
1922 inputs_[0] = context;
1923 inputs_[1] = constructor;
1926 LOperand* context() { return inputs_[0]; }
1927 LOperand* constructor() { return inputs_[1]; }
1929 DECLARE_CONCRETE_INSTRUCTION(CallNewArray, "call-new-array")
1930 DECLARE_HYDROGEN_ACCESSOR(CallNewArray)
1932 void PrintDataTo(StringStream* stream) override;
1934 int arity() const { return hydrogen()->argument_count() - 1; }
1938 class LCallRuntime final : public LTemplateInstruction<1, 1, 0> {
1940 explicit LCallRuntime(LOperand* context) {
1941 inputs_[0] = context;
1944 LOperand* context() { return inputs_[0]; }
1946 DECLARE_CONCRETE_INSTRUCTION(CallRuntime, "call-runtime")
1947 DECLARE_HYDROGEN_ACCESSOR(CallRuntime)
1949 bool ClobbersDoubleRegisters(Isolate* isolate) const override {
1950 return save_doubles() == kDontSaveFPRegs;
1953 const Runtime::Function* function() const { return hydrogen()->function(); }
1954 int arity() const { return hydrogen()->argument_count(); }
1955 SaveFPRegsMode save_doubles() const { return hydrogen()->save_doubles(); }
1959 class LInteger32ToDouble final : public LTemplateInstruction<1, 1, 0> {
1961 explicit LInteger32ToDouble(LOperand* value) {
1965 LOperand* value() { return inputs_[0]; }
1967 DECLARE_CONCRETE_INSTRUCTION(Integer32ToDouble, "int32-to-double")
1971 class LUint32ToDouble final : public LTemplateInstruction<1, 1, 0> {
1973 explicit LUint32ToDouble(LOperand* value) {
1977 LOperand* value() { return inputs_[0]; }
1979 DECLARE_CONCRETE_INSTRUCTION(Uint32ToDouble, "uint32-to-double")
1983 class LNumberTagI final : public LTemplateInstruction<1, 1, 2> {
1985 LNumberTagI(LOperand* value, LOperand* temp1, LOperand* temp2) {
1991 LOperand* value() { return inputs_[0]; }
1992 LOperand* temp1() { return temps_[0]; }
1993 LOperand* temp2() { return temps_[1]; }
1995 DECLARE_CONCRETE_INSTRUCTION(NumberTagI, "number-tag-i")
1999 class LNumberTagU final : public LTemplateInstruction<1, 1, 2> {
2001 LNumberTagU(LOperand* value, LOperand* temp1, LOperand* temp2) {
2007 LOperand* value() { return inputs_[0]; }
2008 LOperand* temp1() { return temps_[0]; }
2009 LOperand* temp2() { return temps_[1]; }
2011 DECLARE_CONCRETE_INSTRUCTION(NumberTagU, "number-tag-u")
2015 class LNumberTagD final : public LTemplateInstruction<1, 1, 1> {
2017 explicit LNumberTagD(LOperand* value, LOperand* temp) {
2022 LOperand* value() { return inputs_[0]; }
2023 LOperand* temp() { return temps_[0]; }
2025 DECLARE_CONCRETE_INSTRUCTION(NumberTagD, "number-tag-d")
2026 DECLARE_HYDROGEN_ACCESSOR(Change)
2030 // Sometimes truncating conversion from a tagged value to an int32.
2031 class LDoubleToI final : public LTemplateInstruction<1, 1, 0> {
2033 explicit LDoubleToI(LOperand* value) {
2037 LOperand* value() { return inputs_[0]; }
2039 DECLARE_CONCRETE_INSTRUCTION(DoubleToI, "double-to-i")
2040 DECLARE_HYDROGEN_ACCESSOR(UnaryOperation)
2042 bool truncating() { return hydrogen()->CanTruncateToInt32(); }
2046 class LDoubleToSmi final : public LTemplateInstruction<1, 1, 0> {
2048 explicit LDoubleToSmi(LOperand* value) {
2052 LOperand* value() { return inputs_[0]; }
2054 DECLARE_CONCRETE_INSTRUCTION(DoubleToSmi, "double-to-smi")
2055 DECLARE_HYDROGEN_ACCESSOR(UnaryOperation)
2059 // Truncating conversion from a tagged value to an int32.
2060 class LTaggedToI final : public LTemplateInstruction<1, 1, 1> {
2062 LTaggedToI(LOperand* value, LOperand* temp) {
2067 LOperand* value() { return inputs_[0]; }
2068 LOperand* temp() { return temps_[0]; }
2070 DECLARE_CONCRETE_INSTRUCTION(TaggedToI, "tagged-to-i")
2071 DECLARE_HYDROGEN_ACCESSOR(Change)
2073 bool truncating() { return hydrogen()->CanTruncateToInt32(); }
2077 class LSmiTag final : public LTemplateInstruction<1, 1, 0> {
2079 explicit LSmiTag(LOperand* value) {
2083 LOperand* value() { return inputs_[0]; }
2085 DECLARE_CONCRETE_INSTRUCTION(SmiTag, "smi-tag")
2086 DECLARE_HYDROGEN_ACCESSOR(Change)
2090 class LNumberUntagD final : public LTemplateInstruction<1, 1, 0> {
2092 explicit LNumberUntagD(LOperand* value) {
2096 LOperand* value() { return inputs_[0]; }
2098 DECLARE_CONCRETE_INSTRUCTION(NumberUntagD, "double-untag")
2099 DECLARE_HYDROGEN_ACCESSOR(Change);
2103 class LSmiUntag final : public LTemplateInstruction<1, 1, 0> {
2105 LSmiUntag(LOperand* value, bool needs_check)
2106 : needs_check_(needs_check) {
2110 LOperand* value() { return inputs_[0]; }
2111 bool needs_check() const { return needs_check_; }
2113 DECLARE_CONCRETE_INSTRUCTION(SmiUntag, "smi-untag")
2120 class LStoreNamedField final : public LTemplateInstruction<0, 2, 1> {
2122 LStoreNamedField(LOperand* object, LOperand* value, LOperand* temp) {
2123 inputs_[0] = object;
2128 LOperand* object() { return inputs_[0]; }
2129 LOperand* value() { return inputs_[1]; }
2130 LOperand* temp() { return temps_[0]; }
2132 DECLARE_CONCRETE_INSTRUCTION(StoreNamedField, "store-named-field")
2133 DECLARE_HYDROGEN_ACCESSOR(StoreNamedField)
2135 void PrintDataTo(StringStream* stream) override;
2137 Representation representation() const {
2138 return hydrogen()->field_representation();
2143 class LStoreNamedGeneric final : public LTemplateInstruction<0, 3, 2> {
2145 LStoreNamedGeneric(LOperand* context, LOperand* object, LOperand* value,
2146 LOperand* slot, LOperand* vector) {
2147 inputs_[0] = context;
2148 inputs_[1] = object;
2154 LOperand* context() { return inputs_[0]; }
2155 LOperand* object() { return inputs_[1]; }
2156 LOperand* value() { return inputs_[2]; }
2157 LOperand* temp_slot() { return temps_[0]; }
2158 LOperand* temp_vector() { return temps_[1]; }
2160 DECLARE_CONCRETE_INSTRUCTION(StoreNamedGeneric, "store-named-generic")
2161 DECLARE_HYDROGEN_ACCESSOR(StoreNamedGeneric)
2163 void PrintDataTo(StringStream* stream) override;
2165 Handle<Object> name() const { return hydrogen()->name(); }
2166 LanguageMode language_mode() { return hydrogen()->language_mode(); }
2170 class LStoreGlobalViaContext final : public LTemplateInstruction<0, 2, 0> {
2172 LStoreGlobalViaContext(LOperand* context, LOperand* value) {
2173 inputs_[0] = context;
2177 LOperand* context() { return inputs_[0]; }
2178 LOperand* value() { return inputs_[1]; }
2180 DECLARE_CONCRETE_INSTRUCTION(StoreGlobalViaContext,
2181 "store-global-via-context")
2182 DECLARE_HYDROGEN_ACCESSOR(StoreGlobalViaContext)
2184 void PrintDataTo(StringStream* stream) override;
2186 int depth() { return hydrogen()->depth(); }
2187 int slot_index() { return hydrogen()->slot_index(); }
2188 LanguageMode language_mode() { return hydrogen()->language_mode(); }
2192 class LStoreKeyed final : public LTemplateInstruction<0, 3, 0> {
2194 LStoreKeyed(LOperand* object, LOperand* key, LOperand* value) {
2195 inputs_[0] = object;
2200 bool is_fixed_typed_array() const {
2201 return hydrogen()->is_fixed_typed_array();
2203 LOperand* elements() { return inputs_[0]; }
2204 LOperand* key() { return inputs_[1]; }
2205 LOperand* value() { return inputs_[2]; }
2206 ElementsKind elements_kind() const { return hydrogen()->elements_kind(); }
2208 DECLARE_CONCRETE_INSTRUCTION(StoreKeyed, "store-keyed")
2209 DECLARE_HYDROGEN_ACCESSOR(StoreKeyed)
2211 void PrintDataTo(StringStream* stream) override;
2212 bool NeedsCanonicalization() { return hydrogen()->NeedsCanonicalization(); }
2213 uint32_t base_offset() const { return hydrogen()->base_offset(); }
2217 class LStoreKeyedGeneric final : public LTemplateInstruction<0, 4, 2> {
2219 LStoreKeyedGeneric(LOperand* context, LOperand* object, LOperand* key,
2220 LOperand* value, LOperand* slot, LOperand* vector) {
2221 inputs_[0] = context;
2222 inputs_[1] = object;
2229 LOperand* context() { return inputs_[0]; }
2230 LOperand* object() { return inputs_[1]; }
2231 LOperand* key() { return inputs_[2]; }
2232 LOperand* value() { return inputs_[3]; }
2233 LOperand* temp_slot() { return temps_[0]; }
2234 LOperand* temp_vector() { return temps_[1]; }
2236 DECLARE_CONCRETE_INSTRUCTION(StoreKeyedGeneric, "store-keyed-generic")
2237 DECLARE_HYDROGEN_ACCESSOR(StoreKeyedGeneric)
2239 void PrintDataTo(StringStream* stream) override;
2241 LanguageMode language_mode() { return hydrogen()->language_mode(); }
2245 class LTransitionElementsKind final : public LTemplateInstruction<0, 2, 2> {
2247 LTransitionElementsKind(LOperand* object,
2249 LOperand* new_map_temp,
2251 inputs_[0] = object;
2252 inputs_[1] = context;
2253 temps_[0] = new_map_temp;
2257 LOperand* object() { return inputs_[0]; }
2258 LOperand* context() { return inputs_[1]; }
2259 LOperand* new_map_temp() { return temps_[0]; }
2260 LOperand* temp() { return temps_[1]; }
2262 DECLARE_CONCRETE_INSTRUCTION(TransitionElementsKind,
2263 "transition-elements-kind")
2264 DECLARE_HYDROGEN_ACCESSOR(TransitionElementsKind)
2266 void PrintDataTo(StringStream* stream) override;
2268 Handle<Map> original_map() { return hydrogen()->original_map().handle(); }
2269 Handle<Map> transitioned_map() {
2270 return hydrogen()->transitioned_map().handle();
2272 ElementsKind from_kind() { return hydrogen()->from_kind(); }
2273 ElementsKind to_kind() { return hydrogen()->to_kind(); }
2277 class LTrapAllocationMemento final : public LTemplateInstruction<0, 1, 1> {
2279 LTrapAllocationMemento(LOperand* object,
2281 inputs_[0] = object;
2285 LOperand* object() { return inputs_[0]; }
2286 LOperand* temp() { return temps_[0]; }
2288 DECLARE_CONCRETE_INSTRUCTION(TrapAllocationMemento,
2289 "trap-allocation-memento")
2293 class LMaybeGrowElements final : public LTemplateInstruction<1, 5, 0> {
2295 LMaybeGrowElements(LOperand* context, LOperand* object, LOperand* elements,
2296 LOperand* key, LOperand* current_capacity) {
2297 inputs_[0] = context;
2298 inputs_[1] = object;
2299 inputs_[2] = elements;
2301 inputs_[4] = current_capacity;
2304 LOperand* context() { return inputs_[0]; }
2305 LOperand* object() { return inputs_[1]; }
2306 LOperand* elements() { return inputs_[2]; }
2307 LOperand* key() { return inputs_[3]; }
2308 LOperand* current_capacity() { return inputs_[4]; }
2310 DECLARE_HYDROGEN_ACCESSOR(MaybeGrowElements)
2311 DECLARE_CONCRETE_INSTRUCTION(MaybeGrowElements, "maybe-grow-elements")
2315 class LStringAdd final : public LTemplateInstruction<1, 3, 0> {
2317 LStringAdd(LOperand* context, LOperand* left, LOperand* right) {
2318 inputs_[0] = context;
2323 LOperand* context() { return inputs_[0]; }
2324 LOperand* left() { return inputs_[1]; }
2325 LOperand* right() { return inputs_[2]; }
2327 DECLARE_CONCRETE_INSTRUCTION(StringAdd, "string-add")
2328 DECLARE_HYDROGEN_ACCESSOR(StringAdd)
2332 class LStringCharCodeAt final : public LTemplateInstruction<1, 3, 0> {
2334 LStringCharCodeAt(LOperand* context, LOperand* string, LOperand* index) {
2335 inputs_[0] = context;
2336 inputs_[1] = string;
2340 LOperand* context() { return inputs_[0]; }
2341 LOperand* string() { return inputs_[1]; }
2342 LOperand* index() { return inputs_[2]; }
2344 DECLARE_CONCRETE_INSTRUCTION(StringCharCodeAt, "string-char-code-at")
2345 DECLARE_HYDROGEN_ACCESSOR(StringCharCodeAt)
2349 class LStringCharFromCode final : public LTemplateInstruction<1, 2, 0> {
2351 explicit LStringCharFromCode(LOperand* context, LOperand* char_code) {
2352 inputs_[0] = context;
2353 inputs_[1] = char_code;
2356 LOperand* context() { return inputs_[0]; }
2357 LOperand* char_code() { return inputs_[1]; }
2359 DECLARE_CONCRETE_INSTRUCTION(StringCharFromCode, "string-char-from-code")
2360 DECLARE_HYDROGEN_ACCESSOR(StringCharFromCode)
2364 class LCheckValue final : public LTemplateInstruction<0, 1, 0> {
2366 explicit LCheckValue(LOperand* value) {
2370 LOperand* value() { return inputs_[0]; }
2372 DECLARE_CONCRETE_INSTRUCTION(CheckValue, "check-value")
2373 DECLARE_HYDROGEN_ACCESSOR(CheckValue)
2377 class LCheckArrayBufferNotNeutered final
2378 : public LTemplateInstruction<0, 1, 0> {
2380 explicit LCheckArrayBufferNotNeutered(LOperand* view) { inputs_[0] = view; }
2382 LOperand* view() { return inputs_[0]; }
2384 DECLARE_CONCRETE_INSTRUCTION(CheckArrayBufferNotNeutered,
2385 "check-array-buffer-not-neutered")
2386 DECLARE_HYDROGEN_ACCESSOR(CheckArrayBufferNotNeutered)
2390 class LCheckInstanceType final : public LTemplateInstruction<0, 1, 0> {
2392 explicit LCheckInstanceType(LOperand* value) {
2396 LOperand* value() { return inputs_[0]; }
2398 DECLARE_CONCRETE_INSTRUCTION(CheckInstanceType, "check-instance-type")
2399 DECLARE_HYDROGEN_ACCESSOR(CheckInstanceType)
2403 class LCheckMaps final : public LTemplateInstruction<0, 1, 0> {
2405 explicit LCheckMaps(LOperand* value = NULL) {
2409 LOperand* value() { return inputs_[0]; }
2411 DECLARE_CONCRETE_INSTRUCTION(CheckMaps, "check-maps")
2412 DECLARE_HYDROGEN_ACCESSOR(CheckMaps)
2416 class LCheckSmi final : public LTemplateInstruction<1, 1, 0> {
2418 explicit LCheckSmi(LOperand* value) {
2422 LOperand* value() { return inputs_[0]; }
2424 DECLARE_CONCRETE_INSTRUCTION(CheckSmi, "check-smi")
2428 class LClampDToUint8 final : public LTemplateInstruction<1, 1, 0> {
2430 explicit LClampDToUint8(LOperand* unclamped) {
2431 inputs_[0] = unclamped;
2434 LOperand* unclamped() { return inputs_[0]; }
2436 DECLARE_CONCRETE_INSTRUCTION(ClampDToUint8, "clamp-d-to-uint8")
2440 class LClampIToUint8 final : public LTemplateInstruction<1, 1, 0> {
2442 explicit LClampIToUint8(LOperand* unclamped) {
2443 inputs_[0] = unclamped;
2446 LOperand* unclamped() { return inputs_[0]; }
2448 DECLARE_CONCRETE_INSTRUCTION(ClampIToUint8, "clamp-i-to-uint8")
2452 class LClampTToUint8 final : public LTemplateInstruction<1, 1, 1> {
2454 LClampTToUint8(LOperand* unclamped,
2455 LOperand* temp_xmm) {
2456 inputs_[0] = unclamped;
2457 temps_[0] = temp_xmm;
2460 LOperand* unclamped() { return inputs_[0]; }
2461 LOperand* temp_xmm() { return temps_[0]; }
2463 DECLARE_CONCRETE_INSTRUCTION(ClampTToUint8, "clamp-t-to-uint8")
2467 class LCheckNonSmi final : public LTemplateInstruction<0, 1, 0> {
2469 explicit LCheckNonSmi(LOperand* value) {
2473 LOperand* value() { return inputs_[0]; }
2475 DECLARE_CONCRETE_INSTRUCTION(CheckNonSmi, "check-non-smi")
2476 DECLARE_HYDROGEN_ACCESSOR(CheckHeapObject)
2480 class LDoubleBits final : public LTemplateInstruction<1, 1, 0> {
2482 explicit LDoubleBits(LOperand* value) {
2486 LOperand* value() { return inputs_[0]; }
2488 DECLARE_CONCRETE_INSTRUCTION(DoubleBits, "double-bits")
2489 DECLARE_HYDROGEN_ACCESSOR(DoubleBits)
2493 class LConstructDouble final : public LTemplateInstruction<1, 2, 0> {
2495 LConstructDouble(LOperand* hi, LOperand* lo) {
2500 LOperand* hi() { return inputs_[0]; }
2501 LOperand* lo() { return inputs_[1]; }
2503 DECLARE_CONCRETE_INSTRUCTION(ConstructDouble, "construct-double")
2507 class LAllocate final : public LTemplateInstruction<1, 2, 1> {
2509 LAllocate(LOperand* context, LOperand* size, LOperand* temp) {
2510 inputs_[0] = context;
2515 LOperand* context() { return inputs_[0]; }
2516 LOperand* size() { return inputs_[1]; }
2517 LOperand* temp() { return temps_[0]; }
2519 DECLARE_CONCRETE_INSTRUCTION(Allocate, "allocate")
2520 DECLARE_HYDROGEN_ACCESSOR(Allocate)
2524 class LRegExpLiteral final : public LTemplateInstruction<1, 1, 0> {
2526 explicit LRegExpLiteral(LOperand* context) {
2527 inputs_[0] = context;
2530 LOperand* context() { return inputs_[0]; }
2532 DECLARE_CONCRETE_INSTRUCTION(RegExpLiteral, "regexp-literal")
2533 DECLARE_HYDROGEN_ACCESSOR(RegExpLiteral)
2537 class LToFastProperties final : public LTemplateInstruction<1, 1, 0> {
2539 explicit LToFastProperties(LOperand* value) {
2543 LOperand* value() { return inputs_[0]; }
2545 DECLARE_CONCRETE_INSTRUCTION(ToFastProperties, "to-fast-properties")
2546 DECLARE_HYDROGEN_ACCESSOR(ToFastProperties)
2550 class LTypeof final : public LTemplateInstruction<1, 2, 0> {
2552 LTypeof(LOperand* context, LOperand* value) {
2553 inputs_[0] = context;
2557 LOperand* context() { return inputs_[0]; }
2558 LOperand* value() { return inputs_[1]; }
2560 DECLARE_CONCRETE_INSTRUCTION(Typeof, "typeof")
2564 class LTypeofIsAndBranch final : public LControlInstruction<1, 0> {
2566 explicit LTypeofIsAndBranch(LOperand* value) {
2570 LOperand* value() { return inputs_[0]; }
2572 DECLARE_CONCRETE_INSTRUCTION(TypeofIsAndBranch, "typeof-is-and-branch")
2573 DECLARE_HYDROGEN_ACCESSOR(TypeofIsAndBranch)
2575 Handle<String> type_literal() { return hydrogen()->type_literal(); }
2577 void PrintDataTo(StringStream* stream) override;
2581 class LIsConstructCallAndBranch final : public LControlInstruction<0, 1> {
2583 explicit LIsConstructCallAndBranch(LOperand* temp) {
2587 LOperand* temp() { return temps_[0]; }
2589 DECLARE_CONCRETE_INSTRUCTION(IsConstructCallAndBranch,
2590 "is-construct-call-and-branch")
2591 DECLARE_HYDROGEN_ACCESSOR(IsConstructCallAndBranch)
2595 class LOsrEntry final : public LTemplateInstruction<0, 0, 0> {
2599 bool HasInterestingComment(LCodeGen* gen) const override { return false; }
2600 DECLARE_CONCRETE_INSTRUCTION(OsrEntry, "osr-entry")
2604 class LStackCheck final : public LTemplateInstruction<0, 1, 0> {
2606 explicit LStackCheck(LOperand* context) {
2607 inputs_[0] = context;
2610 LOperand* context() { return inputs_[0]; }
2612 DECLARE_CONCRETE_INSTRUCTION(StackCheck, "stack-check")
2613 DECLARE_HYDROGEN_ACCESSOR(StackCheck)
2615 Label* done_label() { return &done_label_; }
2622 class LForInPrepareMap final : public LTemplateInstruction<1, 2, 0> {
2624 LForInPrepareMap(LOperand* context, LOperand* object) {
2625 inputs_[0] = context;
2626 inputs_[1] = object;
2629 LOperand* context() { return inputs_[0]; }
2630 LOperand* object() { return inputs_[1]; }
2632 DECLARE_CONCRETE_INSTRUCTION(ForInPrepareMap, "for-in-prepare-map")
2636 class LForInCacheArray final : public LTemplateInstruction<1, 1, 0> {
2638 explicit LForInCacheArray(LOperand* map) {
2642 LOperand* map() { return inputs_[0]; }
2644 DECLARE_CONCRETE_INSTRUCTION(ForInCacheArray, "for-in-cache-array")
2647 return HForInCacheArray::cast(this->hydrogen_value())->idx();
2652 class LCheckMapValue final : public LTemplateInstruction<0, 2, 0> {
2654 LCheckMapValue(LOperand* value, LOperand* map) {
2659 LOperand* value() { return inputs_[0]; }
2660 LOperand* map() { return inputs_[1]; }
2662 DECLARE_CONCRETE_INSTRUCTION(CheckMapValue, "check-map-value")
2666 class LLoadFieldByIndex final : public LTemplateInstruction<1, 2, 0> {
2668 LLoadFieldByIndex(LOperand* object, LOperand* index) {
2669 inputs_[0] = object;
2673 LOperand* object() { return inputs_[0]; }
2674 LOperand* index() { return inputs_[1]; }
2676 DECLARE_CONCRETE_INSTRUCTION(LoadFieldByIndex, "load-field-by-index")
2680 class LStoreFrameContext: public LTemplateInstruction<0, 1, 0> {
2682 explicit LStoreFrameContext(LOperand* context) {
2683 inputs_[0] = context;
2686 LOperand* context() { return inputs_[0]; }
2688 DECLARE_CONCRETE_INSTRUCTION(StoreFrameContext, "store-frame-context")
2692 class LAllocateBlockContext: public LTemplateInstruction<1, 2, 0> {
2694 LAllocateBlockContext(LOperand* context, LOperand* function) {
2695 inputs_[0] = context;
2696 inputs_[1] = function;
2699 LOperand* context() { return inputs_[0]; }
2700 LOperand* function() { return inputs_[1]; }
2702 Handle<ScopeInfo> scope_info() { return hydrogen()->scope_info(); }
2704 DECLARE_CONCRETE_INSTRUCTION(AllocateBlockContext, "allocate-block-context")
2705 DECLARE_HYDROGEN_ACCESSOR(AllocateBlockContext)
2709 class LChunkBuilder;
2710 class LPlatformChunk final : public LChunk {
2712 LPlatformChunk(CompilationInfo* info, HGraph* graph)
2713 : LChunk(info, graph),
2714 dehoisted_key_ids_(graph->GetMaximumValueID(), graph->zone()) { }
2716 int GetNextSpillIndex(RegisterKind kind);
2717 LOperand* GetNextSpillSlot(RegisterKind kind);
2718 BitVector* GetDehoistedKeyIds() { return &dehoisted_key_ids_; }
2719 bool IsDehoistedKey(HValue* value) {
2720 return dehoisted_key_ids_.Contains(value->id());
2724 BitVector dehoisted_key_ids_;
2728 class LChunkBuilder final : public LChunkBuilderBase {
2730 LChunkBuilder(CompilationInfo* info, HGraph* graph, LAllocator* allocator)
2731 : LChunkBuilderBase(info, graph),
2732 current_instruction_(NULL),
2733 current_block_(NULL),
2735 allocator_(allocator) {}
2737 // Build the sequence for the graph.
2738 LPlatformChunk* Build();
2740 // Declare methods that deal with the individual node types.
2741 #define DECLARE_DO(type) LInstruction* Do##type(H##type* node);
2742 HYDROGEN_CONCRETE_INSTRUCTION_LIST(DECLARE_DO)
2745 LInstruction* DoMathFloor(HUnaryMathOperation* instr);
2746 LInstruction* DoMathRound(HUnaryMathOperation* instr);
2747 LInstruction* DoMathFround(HUnaryMathOperation* instr);
2748 LInstruction* DoMathAbs(HUnaryMathOperation* instr);
2749 LInstruction* DoMathLog(HUnaryMathOperation* instr);
2750 LInstruction* DoMathExp(HUnaryMathOperation* instr);
2751 LInstruction* DoMathSqrt(HUnaryMathOperation* instr);
2752 LInstruction* DoMathPowHalf(HUnaryMathOperation* instr);
2753 LInstruction* DoMathClz32(HUnaryMathOperation* instr);
2754 LInstruction* DoDivByPowerOf2I(HDiv* instr);
2755 LInstruction* DoDivByConstI(HDiv* instr);
2756 LInstruction* DoDivI(HDiv* instr);
2757 LInstruction* DoModByPowerOf2I(HMod* instr);
2758 LInstruction* DoModByConstI(HMod* instr);
2759 LInstruction* DoModI(HMod* instr);
2760 LInstruction* DoFlooringDivByPowerOf2I(HMathFloorOfDiv* instr);
2761 LInstruction* DoFlooringDivByConstI(HMathFloorOfDiv* instr);
2762 LInstruction* DoFlooringDivI(HMathFloorOfDiv* instr);
2765 // Methods for getting operands for Use / Define / Temp.
2766 LUnallocated* ToUnallocated(Register reg);
2767 LUnallocated* ToUnallocated(XMMRegister reg);
2769 // Methods for setting up define-use relationships.
2770 MUST_USE_RESULT LOperand* Use(HValue* value, LUnallocated* operand);
2771 MUST_USE_RESULT LOperand* UseFixed(HValue* value, Register fixed_register);
2772 MUST_USE_RESULT LOperand* UseFixedDouble(HValue* value,
2773 XMMRegister fixed_register);
2775 // A value that is guaranteed to be allocated to a register.
2776 // Operand created by UseRegister is guaranteed to be live until the end of
2777 // instruction. This means that register allocator will not reuse it's
2778 // register for any other operand inside instruction.
2779 // Operand created by UseRegisterAtStart is guaranteed to be live only at
2780 // instruction start. Register allocator is free to assign the same register
2781 // to some other operand used inside instruction (i.e. temporary or
2783 MUST_USE_RESULT LOperand* UseRegister(HValue* value);
2784 MUST_USE_RESULT LOperand* UseRegisterAtStart(HValue* value);
2786 // An input operand in a register that may be trashed.
2787 MUST_USE_RESULT LOperand* UseTempRegister(HValue* value);
2789 // An input operand in a register that may be trashed or a constant operand.
2790 MUST_USE_RESULT LOperand* UseTempRegisterOrConstant(HValue* value);
2792 // An input operand in a register or stack slot.
2793 MUST_USE_RESULT LOperand* Use(HValue* value);
2794 MUST_USE_RESULT LOperand* UseAtStart(HValue* value);
2796 // An input operand in a register, stack slot or a constant operand.
2797 MUST_USE_RESULT LOperand* UseOrConstant(HValue* value);
2798 MUST_USE_RESULT LOperand* UseOrConstantAtStart(HValue* value);
2800 // An input operand in a register or a constant operand.
2801 MUST_USE_RESULT LOperand* UseRegisterOrConstant(HValue* value);
2802 MUST_USE_RESULT LOperand* UseRegisterOrConstantAtStart(HValue* value);
2804 // An input operand in a constant operand.
2805 MUST_USE_RESULT LOperand* UseConstant(HValue* value);
2807 // An input operand in register, stack slot or a constant operand.
2808 // Will not be moved to a register even if one is freely available.
2809 MUST_USE_RESULT LOperand* UseAny(HValue* value) override;
2811 // Temporary operand that must be in a register.
2812 MUST_USE_RESULT LUnallocated* TempRegister();
2813 MUST_USE_RESULT LOperand* FixedTemp(Register reg);
2814 MUST_USE_RESULT LOperand* FixedTemp(XMMRegister reg);
2816 // Methods for setting up define-use relationships.
2817 // Return the same instruction that they are passed.
2818 LInstruction* Define(LTemplateResultInstruction<1>* instr,
2819 LUnallocated* result);
2820 LInstruction* DefineAsRegister(LTemplateResultInstruction<1>* instr);
2821 LInstruction* DefineAsSpilled(LTemplateResultInstruction<1>* instr,
2823 LInstruction* DefineSameAsFirst(LTemplateResultInstruction<1>* instr);
2824 LInstruction* DefineFixed(LTemplateResultInstruction<1>* instr,
2826 LInstruction* DefineFixedDouble(LTemplateResultInstruction<1>* instr,
2828 // Assigns an environment to an instruction. An instruction which can
2829 // deoptimize must have an environment.
2830 LInstruction* AssignEnvironment(LInstruction* instr);
2831 // Assigns a pointer map to an instruction. An instruction which can
2832 // trigger a GC or a lazy deoptimization must have a pointer map.
2833 LInstruction* AssignPointerMap(LInstruction* instr);
2835 enum CanDeoptimize { CAN_DEOPTIMIZE_EAGERLY, CANNOT_DEOPTIMIZE_EAGERLY };
2837 // Marks a call for the register allocator. Assigns a pointer map to
2838 // support GC and lazy deoptimization. Assigns an environment to support
2839 // eager deoptimization if CAN_DEOPTIMIZE_EAGERLY.
2840 LInstruction* MarkAsCall(
2841 LInstruction* instr,
2842 HInstruction* hinstr,
2843 CanDeoptimize can_deoptimize = CANNOT_DEOPTIMIZE_EAGERLY);
2845 void VisitInstruction(HInstruction* current);
2846 void AddInstruction(LInstruction* instr, HInstruction* current);
2848 void DoBasicBlock(HBasicBlock* block, HBasicBlock* next_block);
2849 LInstruction* DoShift(Token::Value op, HBitwiseBinaryOperation* instr);
2850 LInstruction* DoArithmeticD(Token::Value op,
2851 HArithmeticBinaryOperation* instr);
2852 LInstruction* DoArithmeticT(Token::Value op,
2853 HBinaryOperation* instr);
2854 void FindDehoistedKeyDefinitions(HValue* candidate);
2856 HInstruction* current_instruction_;
2857 HBasicBlock* current_block_;
2858 HBasicBlock* next_block_;
2859 LAllocator* allocator_;
2861 DISALLOW_COPY_AND_ASSIGN(LChunkBuilder);
2864 #undef DECLARE_HYDROGEN_ACCESSOR
2865 #undef DECLARE_CONCRETE_INSTRUCTION
2867 } // namespace internal
2870 #endif // V8_X64_LITHIUM_X64_H_