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(CheckInstanceType) \
49 V(ClassOfTestAndBranch) \
50 V(CompareMinusZeroAndBranch) \
51 V(CompareNumericAndBranch) \
52 V(CmpObjectEqAndBranch) \
76 V(FlooringDivByConstI) \
77 V(FlooringDivByPowerOf2I) \
82 V(GetCachedArrayIndex) \
84 V(HasCachedArrayIndexAndBranch) \
85 V(HasInstanceTypeAndBranch) \
86 V(InnerAllocatedObject) \
88 V(InstanceOfKnownGlobal) \
90 V(Integer32ToDouble) \
92 V(IsConstructCallAndBranch) \
93 V(IsObjectAndBranch) \
94 V(IsStringAndBranch) \
96 V(IsUndetectableAndBranch) \
101 V(LoadFieldByIndex) \
102 V(LoadFunctionPrototype) \
104 V(LoadGlobalGeneric) \
106 V(LoadKeyedGeneric) \
108 V(LoadNamedGeneric) \
134 V(SeqStringGetChar) \
135 V(SeqStringSetChar) \
141 V(StoreContextSlot) \
142 V(StoreFrameContext) \
145 V(StoreKeyedGeneric) \
147 V(StoreNamedGeneric) \
149 V(StringCharCodeAt) \
150 V(StringCharFromCode) \
151 V(StringCompareAndBranch) \
154 V(TailCallThroughMegamorphicCache) \
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 virtual void SetDeferredLazyDeoptimizationEnvironment(LEnvironment* env) { }
246 // Interface to the register allocator and iterators.
247 bool IsMarkedAsCall() const { return IsCall(); }
249 virtual bool HasResult() const = 0;
250 virtual LOperand* result() const = 0;
252 LOperand* FirstInput() { return InputAt(0); }
253 LOperand* Output() { return HasResult() ? result() : NULL; }
255 virtual bool HasInterestingComment(LCodeGen* gen) const { return true; }
257 virtual bool MustSignExtendResult(LPlatformChunk* chunk) const {
265 virtual int InputCount() = 0;
266 virtual LOperand* InputAt(int i) = 0;
270 friend class InputIterator;
272 friend class TempIterator;
273 virtual int TempCount() = 0;
274 virtual LOperand* TempAt(int i) = 0;
276 class IsCallBits: public BitField<bool, 0, 1> {};
278 LEnvironment* environment_;
279 SetOncePointer<LPointerMap> pointer_map_;
280 HValue* hydrogen_value_;
285 // R = number of result operands (0 or 1).
287 class LTemplateResultInstruction : public LInstruction {
289 // Allow 0 or 1 output operands.
290 STATIC_ASSERT(R == 0 || R == 1);
291 bool HasResult() const FINAL { return R != 0 && result() != NULL; }
292 void set_result(LOperand* operand) { results_[0] = operand; }
293 LOperand* result() const OVERRIDE { return results_[0]; }
295 bool MustSignExtendResult(LPlatformChunk* chunk) const FINAL;
298 EmbeddedContainer<LOperand*, R> results_;
302 // R = number of result operands (0 or 1).
303 // I = number of input operands.
304 // T = number of temporary operands.
305 template<int R, int I, int T>
306 class LTemplateInstruction : public LTemplateResultInstruction<R> {
308 EmbeddedContainer<LOperand*, I> inputs_;
309 EmbeddedContainer<LOperand*, T> temps_;
313 int InputCount() FINAL { return I; }
314 LOperand* InputAt(int i) FINAL { return inputs_[i]; }
316 int TempCount() FINAL { return T; }
317 LOperand* TempAt(int i) FINAL { return temps_[i]; }
321 class LGap : public LTemplateInstruction<0, 0, 0> {
323 explicit LGap(HBasicBlock* 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,
354 if (parallel_moves_[pos] == NULL) {
355 parallel_moves_[pos] = new(zone) LParallelMove(zone);
357 return parallel_moves_[pos];
360 LParallelMove* GetParallelMove(InnerPosition pos) {
361 return parallel_moves_[pos];
365 LParallelMove* parallel_moves_[LAST_INNER_POSITION + 1];
370 class LInstructionGap FINAL : public LGap {
372 explicit LInstructionGap(HBasicBlock* block) : LGap(block) { }
374 bool HasInterestingComment(LCodeGen* gen) const OVERRIDE {
375 return !IsRedundant();
378 DECLARE_CONCRETE_INSTRUCTION(InstructionGap, "gap")
382 class LGoto FINAL : public LTemplateInstruction<0, 0, 0> {
384 explicit LGoto(HBasicBlock* block) : block_(block) { }
386 bool HasInterestingComment(LCodeGen* gen) const OVERRIDE;
387 DECLARE_CONCRETE_INSTRUCTION(Goto, "goto")
388 void PrintDataTo(StringStream* stream) OVERRIDE;
389 bool IsControl() const OVERRIDE { return true; }
391 int block_id() const { return block_->block_id(); }
398 class LLazyBailout FINAL : public LTemplateInstruction<0, 0, 0> {
400 LLazyBailout() : gap_instructions_size_(0) { }
402 DECLARE_CONCRETE_INSTRUCTION(LazyBailout, "lazy-bailout")
404 void set_gap_instructions_size(int gap_instructions_size) {
405 gap_instructions_size_ = gap_instructions_size;
407 int gap_instructions_size() { return gap_instructions_size_; }
410 int gap_instructions_size_;
414 class LDummy FINAL : public LTemplateInstruction<1, 0, 0> {
417 DECLARE_CONCRETE_INSTRUCTION(Dummy, "dummy")
421 class LDummyUse FINAL : public LTemplateInstruction<1, 1, 0> {
423 explicit LDummyUse(LOperand* value) {
426 DECLARE_CONCRETE_INSTRUCTION(DummyUse, "dummy-use")
430 class LDeoptimize FINAL : public LTemplateInstruction<0, 0, 0> {
432 bool IsControl() const OVERRIDE { return true; }
433 DECLARE_CONCRETE_INSTRUCTION(Deoptimize, "deoptimize")
434 DECLARE_HYDROGEN_ACCESSOR(Deoptimize)
438 class LLabel FINAL : public LGap {
440 explicit LLabel(HBasicBlock* block)
441 : LGap(block), replacement_(NULL) { }
443 bool HasInterestingComment(LCodeGen* gen) const OVERRIDE { return false; }
444 DECLARE_CONCRETE_INSTRUCTION(Label, "label")
446 void PrintDataTo(StringStream* stream) OVERRIDE;
448 int block_id() const { return block()->block_id(); }
449 bool is_loop_header() const { return block()->IsLoopHeader(); }
450 bool is_osr_entry() const { return block()->is_osr_entry(); }
451 Label* label() { return &label_; }
452 LLabel* replacement() const { return replacement_; }
453 void set_replacement(LLabel* label) { replacement_ = label; }
454 bool HasReplacement() const { return replacement_ != NULL; }
458 LLabel* replacement_;
462 class LParameter FINAL : public LTemplateInstruction<1, 0, 0> {
464 bool HasInterestingComment(LCodeGen* gen) const OVERRIDE { return false; }
465 DECLARE_CONCRETE_INSTRUCTION(Parameter, "parameter")
469 class LCallStub FINAL : public LTemplateInstruction<1, 1, 0> {
471 explicit LCallStub(LOperand* context) {
472 inputs_[0] = context;
475 LOperand* context() { return inputs_[0]; }
477 DECLARE_CONCRETE_INSTRUCTION(CallStub, "call-stub")
478 DECLARE_HYDROGEN_ACCESSOR(CallStub)
482 class LTailCallThroughMegamorphicCache FINAL
483 : public LTemplateInstruction<0, 5, 0> {
485 explicit LTailCallThroughMegamorphicCache(LOperand* context,
486 LOperand* receiver, LOperand* name,
487 LOperand* slot, LOperand* vector) {
488 inputs_[0] = context;
489 inputs_[1] = receiver;
495 LOperand* context() { return inputs_[0]; }
496 LOperand* receiver() { return inputs_[1]; }
497 LOperand* name() { return inputs_[2]; }
498 LOperand* slot() { return inputs_[3]; }
499 LOperand* vector() { return inputs_[4]; }
501 DECLARE_CONCRETE_INSTRUCTION(TailCallThroughMegamorphicCache,
502 "tail-call-through-megamorphic-cache")
503 DECLARE_HYDROGEN_ACCESSOR(TailCallThroughMegamorphicCache)
507 class LUnknownOSRValue FINAL : public LTemplateInstruction<1, 0, 0> {
509 bool HasInterestingComment(LCodeGen* gen) const OVERRIDE { return false; }
510 DECLARE_CONCRETE_INSTRUCTION(UnknownOSRValue, "unknown-osr-value")
514 template<int I, int T>
515 class LControlInstruction : public LTemplateInstruction<0, I, T> {
517 LControlInstruction() : false_label_(NULL), true_label_(NULL) { }
519 bool IsControl() const FINAL { return true; }
521 int SuccessorCount() { return hydrogen()->SuccessorCount(); }
522 HBasicBlock* SuccessorAt(int i) { return hydrogen()->SuccessorAt(i); }
524 int TrueDestination(LChunk* chunk) {
525 return chunk->LookupDestination(true_block_id());
527 int FalseDestination(LChunk* chunk) {
528 return chunk->LookupDestination(false_block_id());
531 Label* TrueLabel(LChunk* chunk) {
532 if (true_label_ == NULL) {
533 true_label_ = chunk->GetAssemblyLabel(TrueDestination(chunk));
537 Label* FalseLabel(LChunk* chunk) {
538 if (false_label_ == NULL) {
539 false_label_ = chunk->GetAssemblyLabel(FalseDestination(chunk));
545 int true_block_id() { return SuccessorAt(0)->block_id(); }
546 int false_block_id() { return SuccessorAt(1)->block_id(); }
549 HControlInstruction* hydrogen() {
550 return HControlInstruction::cast(this->hydrogen_value());
558 class LWrapReceiver FINAL : public LTemplateInstruction<1, 2, 0> {
560 LWrapReceiver(LOperand* receiver, LOperand* function) {
561 inputs_[0] = receiver;
562 inputs_[1] = function;
565 LOperand* receiver() { return inputs_[0]; }
566 LOperand* function() { return inputs_[1]; }
568 DECLARE_CONCRETE_INSTRUCTION(WrapReceiver, "wrap-receiver")
569 DECLARE_HYDROGEN_ACCESSOR(WrapReceiver)
573 class LApplyArguments FINAL : public LTemplateInstruction<1, 4, 0> {
575 LApplyArguments(LOperand* function,
578 LOperand* elements) {
579 inputs_[0] = function;
580 inputs_[1] = receiver;
582 inputs_[3] = elements;
585 LOperand* function() { return inputs_[0]; }
586 LOperand* receiver() { return inputs_[1]; }
587 LOperand* length() { return inputs_[2]; }
588 LOperand* elements() { return inputs_[3]; }
590 DECLARE_CONCRETE_INSTRUCTION(ApplyArguments, "apply-arguments")
594 class LAccessArgumentsAt FINAL : public LTemplateInstruction<1, 3, 0> {
596 LAccessArgumentsAt(LOperand* arguments, LOperand* length, LOperand* index) {
597 inputs_[0] = arguments;
602 LOperand* arguments() { return inputs_[0]; }
603 LOperand* length() { return inputs_[1]; }
604 LOperand* index() { return inputs_[2]; }
606 DECLARE_CONCRETE_INSTRUCTION(AccessArgumentsAt, "access-arguments-at")
608 void PrintDataTo(StringStream* stream) OVERRIDE;
612 class LArgumentsLength FINAL : public LTemplateInstruction<1, 1, 0> {
614 explicit LArgumentsLength(LOperand* elements) {
615 inputs_[0] = elements;
618 LOperand* elements() { return inputs_[0]; }
620 DECLARE_CONCRETE_INSTRUCTION(ArgumentsLength, "arguments-length")
624 class LArgumentsElements FINAL : public LTemplateInstruction<1, 0, 0> {
626 DECLARE_CONCRETE_INSTRUCTION(ArgumentsElements, "arguments-elements")
627 DECLARE_HYDROGEN_ACCESSOR(ArgumentsElements)
631 class LModByPowerOf2I FINAL : public LTemplateInstruction<1, 1, 0> {
633 LModByPowerOf2I(LOperand* dividend, int32_t divisor) {
634 inputs_[0] = dividend;
638 LOperand* dividend() { return inputs_[0]; }
639 int32_t divisor() const { return divisor_; }
641 DECLARE_CONCRETE_INSTRUCTION(ModByPowerOf2I, "mod-by-power-of-2-i")
642 DECLARE_HYDROGEN_ACCESSOR(Mod)
649 class LModByConstI FINAL : public LTemplateInstruction<1, 1, 2> {
651 LModByConstI(LOperand* dividend,
655 inputs_[0] = dividend;
661 LOperand* dividend() { return inputs_[0]; }
662 int32_t divisor() const { return divisor_; }
663 LOperand* temp1() { return temps_[0]; }
664 LOperand* temp2() { return temps_[1]; }
666 DECLARE_CONCRETE_INSTRUCTION(ModByConstI, "mod-by-const-i")
667 DECLARE_HYDROGEN_ACCESSOR(Mod)
674 class LModI FINAL : public LTemplateInstruction<1, 2, 1> {
676 LModI(LOperand* left, LOperand* right, LOperand* temp) {
682 LOperand* left() { return inputs_[0]; }
683 LOperand* right() { return inputs_[1]; }
684 LOperand* temp() { return temps_[0]; }
686 DECLARE_CONCRETE_INSTRUCTION(ModI, "mod-i")
687 DECLARE_HYDROGEN_ACCESSOR(Mod)
691 class LDivByPowerOf2I FINAL : public LTemplateInstruction<1, 1, 0> {
693 LDivByPowerOf2I(LOperand* dividend, int32_t divisor) {
694 inputs_[0] = dividend;
698 LOperand* dividend() { return inputs_[0]; }
699 int32_t divisor() const { return divisor_; }
701 DECLARE_CONCRETE_INSTRUCTION(DivByPowerOf2I, "div-by-power-of-2-i")
702 DECLARE_HYDROGEN_ACCESSOR(Div)
709 class LDivByConstI FINAL : public LTemplateInstruction<1, 1, 2> {
711 LDivByConstI(LOperand* dividend,
715 inputs_[0] = dividend;
721 LOperand* dividend() { return inputs_[0]; }
722 int32_t divisor() const { return divisor_; }
723 LOperand* temp1() { return temps_[0]; }
724 LOperand* temp2() { return temps_[1]; }
726 DECLARE_CONCRETE_INSTRUCTION(DivByConstI, "div-by-const-i")
727 DECLARE_HYDROGEN_ACCESSOR(Div)
734 class LDivI FINAL : public LTemplateInstruction<1, 2, 1> {
736 LDivI(LOperand* dividend, LOperand* divisor, LOperand* temp) {
737 inputs_[0] = dividend;
738 inputs_[1] = divisor;
742 LOperand* dividend() { return inputs_[0]; }
743 LOperand* divisor() { return inputs_[1]; }
744 LOperand* temp() { return temps_[0]; }
746 DECLARE_CONCRETE_INSTRUCTION(DivI, "div-i")
747 DECLARE_HYDROGEN_ACCESSOR(BinaryOperation)
751 class LFlooringDivByPowerOf2I FINAL : public LTemplateInstruction<1, 1, 0> {
753 LFlooringDivByPowerOf2I(LOperand* dividend, int32_t divisor) {
754 inputs_[0] = dividend;
758 LOperand* dividend() { return inputs_[0]; }
759 int32_t divisor() const { return divisor_; }
761 DECLARE_CONCRETE_INSTRUCTION(FlooringDivByPowerOf2I,
762 "flooring-div-by-power-of-2-i")
763 DECLARE_HYDROGEN_ACCESSOR(MathFloorOfDiv)
770 class LFlooringDivByConstI FINAL : public LTemplateInstruction<1, 1, 3> {
772 LFlooringDivByConstI(LOperand* dividend,
777 inputs_[0] = dividend;
784 LOperand* dividend() { return inputs_[0]; }
785 int32_t divisor() const { return divisor_; }
786 LOperand* temp1() { return temps_[0]; }
787 LOperand* temp2() { return temps_[1]; }
788 LOperand* temp3() { return temps_[2]; }
790 DECLARE_CONCRETE_INSTRUCTION(FlooringDivByConstI, "flooring-div-by-const-i")
791 DECLARE_HYDROGEN_ACCESSOR(MathFloorOfDiv)
798 class LFlooringDivI FINAL : public LTemplateInstruction<1, 2, 1> {
800 LFlooringDivI(LOperand* dividend, LOperand* divisor, LOperand* temp) {
801 inputs_[0] = dividend;
802 inputs_[1] = divisor;
806 LOperand* dividend() { return inputs_[0]; }
807 LOperand* divisor() { return inputs_[1]; }
808 LOperand* temp() { return temps_[0]; }
810 DECLARE_CONCRETE_INSTRUCTION(FlooringDivI, "flooring-div-i")
811 DECLARE_HYDROGEN_ACCESSOR(MathFloorOfDiv)
815 class LMulI FINAL : public LTemplateInstruction<1, 2, 0> {
817 LMulI(LOperand* left, LOperand* right) {
822 LOperand* left() { return inputs_[0]; }
823 LOperand* right() { return inputs_[1]; }
825 DECLARE_CONCRETE_INSTRUCTION(MulI, "mul-i")
826 DECLARE_HYDROGEN_ACCESSOR(Mul)
830 class LCompareNumericAndBranch FINAL : public LControlInstruction<2, 0> {
832 LCompareNumericAndBranch(LOperand* left, LOperand* right) {
837 LOperand* left() { return inputs_[0]; }
838 LOperand* right() { return inputs_[1]; }
840 DECLARE_CONCRETE_INSTRUCTION(CompareNumericAndBranch,
841 "compare-numeric-and-branch")
842 DECLARE_HYDROGEN_ACCESSOR(CompareNumericAndBranch)
844 Token::Value op() const { return hydrogen()->token(); }
845 bool is_double() const {
846 return hydrogen()->representation().IsDouble();
849 void PrintDataTo(StringStream* stream) OVERRIDE;
853 class LMathFloor FINAL : public LTemplateInstruction<1, 1, 0> {
855 explicit LMathFloor(LOperand* value) {
859 LOperand* value() { return inputs_[0]; }
861 DECLARE_CONCRETE_INSTRUCTION(MathFloor, "math-floor")
862 DECLARE_HYDROGEN_ACCESSOR(UnaryMathOperation)
866 class LMathRound FINAL : public LTemplateInstruction<1, 1, 1> {
868 LMathRound(LOperand* value, LOperand* temp) {
873 LOperand* value() { return inputs_[0]; }
874 LOperand* temp() { return temps_[0]; }
876 DECLARE_CONCRETE_INSTRUCTION(MathRound, "math-round")
877 DECLARE_HYDROGEN_ACCESSOR(UnaryMathOperation)
881 class LMathFround FINAL : public LTemplateInstruction<1, 1, 0> {
883 explicit LMathFround(LOperand* value) { inputs_[0] = value; }
885 LOperand* value() { return inputs_[0]; }
887 DECLARE_CONCRETE_INSTRUCTION(MathFround, "math-fround")
891 class LMathAbs FINAL : public LTemplateInstruction<1, 2, 0> {
893 explicit LMathAbs(LOperand* context, LOperand* value) {
894 inputs_[1] = context;
898 LOperand* context() { return inputs_[1]; }
899 LOperand* value() { return inputs_[0]; }
901 DECLARE_CONCRETE_INSTRUCTION(MathAbs, "math-abs")
902 DECLARE_HYDROGEN_ACCESSOR(UnaryMathOperation)
906 class LMathLog FINAL : public LTemplateInstruction<1, 1, 0> {
908 explicit LMathLog(LOperand* value) {
912 LOperand* value() { return inputs_[0]; }
914 DECLARE_CONCRETE_INSTRUCTION(MathLog, "math-log")
918 class LMathClz32 FINAL : public LTemplateInstruction<1, 1, 0> {
920 explicit LMathClz32(LOperand* value) {
924 LOperand* value() { return inputs_[0]; }
926 DECLARE_CONCRETE_INSTRUCTION(MathClz32, "math-clz32")
930 class LMathExp FINAL : public LTemplateInstruction<1, 1, 2> {
932 LMathExp(LOperand* value, LOperand* temp1, LOperand* temp2) {
936 ExternalReference::InitializeMathExpData();
939 LOperand* value() { return inputs_[0]; }
940 LOperand* temp1() { return temps_[0]; }
941 LOperand* temp2() { return temps_[1]; }
943 DECLARE_CONCRETE_INSTRUCTION(MathExp, "math-exp")
947 class LMathSqrt FINAL : public LTemplateInstruction<1, 1, 0> {
949 explicit LMathSqrt(LOperand* value) {
953 LOperand* value() { return inputs_[0]; }
955 DECLARE_CONCRETE_INSTRUCTION(MathSqrt, "math-sqrt")
959 class LMathPowHalf FINAL : public LTemplateInstruction<1, 1, 0> {
961 explicit LMathPowHalf(LOperand* value) {
965 LOperand* value() { return inputs_[0]; }
967 DECLARE_CONCRETE_INSTRUCTION(MathPowHalf, "math-pow-half")
971 class LCmpObjectEqAndBranch FINAL : public LControlInstruction<2, 0> {
973 LCmpObjectEqAndBranch(LOperand* left, LOperand* right) {
978 LOperand* left() { return inputs_[0]; }
979 LOperand* right() { return inputs_[1]; }
981 DECLARE_CONCRETE_INSTRUCTION(CmpObjectEqAndBranch, "cmp-object-eq-and-branch")
985 class LCmpHoleAndBranch FINAL : public LControlInstruction<1, 0> {
987 explicit LCmpHoleAndBranch(LOperand* object) {
991 LOperand* object() { return inputs_[0]; }
993 DECLARE_CONCRETE_INSTRUCTION(CmpHoleAndBranch, "cmp-hole-and-branch")
994 DECLARE_HYDROGEN_ACCESSOR(CompareHoleAndBranch)
998 class LCompareMinusZeroAndBranch FINAL : public LControlInstruction<1, 0> {
1000 explicit LCompareMinusZeroAndBranch(LOperand* value) {
1004 LOperand* value() { return inputs_[0]; }
1006 DECLARE_CONCRETE_INSTRUCTION(CompareMinusZeroAndBranch,
1007 "cmp-minus-zero-and-branch")
1008 DECLARE_HYDROGEN_ACCESSOR(CompareMinusZeroAndBranch)
1013 class LIsObjectAndBranch FINAL : public LControlInstruction<1, 0> {
1015 explicit LIsObjectAndBranch(LOperand* value) {
1019 LOperand* value() { return inputs_[0]; }
1021 DECLARE_CONCRETE_INSTRUCTION(IsObjectAndBranch, "is-object-and-branch")
1022 DECLARE_HYDROGEN_ACCESSOR(IsObjectAndBranch)
1024 void PrintDataTo(StringStream* stream) OVERRIDE;
1028 class LIsStringAndBranch FINAL : public LControlInstruction<1, 1> {
1030 explicit LIsStringAndBranch(LOperand* value, LOperand* temp) {
1035 LOperand* value() { return inputs_[0]; }
1036 LOperand* temp() { return temps_[0]; }
1038 DECLARE_CONCRETE_INSTRUCTION(IsStringAndBranch, "is-string-and-branch")
1039 DECLARE_HYDROGEN_ACCESSOR(IsStringAndBranch)
1041 void PrintDataTo(StringStream* stream) OVERRIDE;
1045 class LIsSmiAndBranch FINAL : public LControlInstruction<1, 0> {
1047 explicit LIsSmiAndBranch(LOperand* value) {
1051 LOperand* value() { return inputs_[0]; }
1053 DECLARE_CONCRETE_INSTRUCTION(IsSmiAndBranch, "is-smi-and-branch")
1054 DECLARE_HYDROGEN_ACCESSOR(IsSmiAndBranch)
1056 void PrintDataTo(StringStream* stream) OVERRIDE;
1060 class LIsUndetectableAndBranch FINAL : public LControlInstruction<1, 1> {
1062 explicit LIsUndetectableAndBranch(LOperand* value, LOperand* temp) {
1067 LOperand* value() { return inputs_[0]; }
1068 LOperand* temp() { return temps_[0]; }
1070 DECLARE_CONCRETE_INSTRUCTION(IsUndetectableAndBranch,
1071 "is-undetectable-and-branch")
1072 DECLARE_HYDROGEN_ACCESSOR(IsUndetectableAndBranch)
1074 void PrintDataTo(StringStream* stream) OVERRIDE;
1078 class LStringCompareAndBranch FINAL : public LControlInstruction<3, 0> {
1080 explicit LStringCompareAndBranch(LOperand* context,
1083 inputs_[0] = context;
1088 LOperand* context() { return inputs_[0]; }
1089 LOperand* left() { return inputs_[1]; }
1090 LOperand* right() { return inputs_[2]; }
1092 DECLARE_CONCRETE_INSTRUCTION(StringCompareAndBranch,
1093 "string-compare-and-branch")
1094 DECLARE_HYDROGEN_ACCESSOR(StringCompareAndBranch)
1096 void PrintDataTo(StringStream* stream) OVERRIDE;
1098 Token::Value op() const { return hydrogen()->token(); }
1102 class LHasInstanceTypeAndBranch FINAL : public LControlInstruction<1, 0> {
1104 explicit LHasInstanceTypeAndBranch(LOperand* value) {
1108 LOperand* value() { return inputs_[0]; }
1110 DECLARE_CONCRETE_INSTRUCTION(HasInstanceTypeAndBranch,
1111 "has-instance-type-and-branch")
1112 DECLARE_HYDROGEN_ACCESSOR(HasInstanceTypeAndBranch)
1114 void PrintDataTo(StringStream* stream) OVERRIDE;
1118 class LGetCachedArrayIndex FINAL : public LTemplateInstruction<1, 1, 0> {
1120 explicit LGetCachedArrayIndex(LOperand* value) {
1124 LOperand* value() { return inputs_[0]; }
1126 DECLARE_CONCRETE_INSTRUCTION(GetCachedArrayIndex, "get-cached-array-index")
1127 DECLARE_HYDROGEN_ACCESSOR(GetCachedArrayIndex)
1131 class LHasCachedArrayIndexAndBranch FINAL
1132 : public LControlInstruction<1, 0> {
1134 explicit LHasCachedArrayIndexAndBranch(LOperand* value) {
1138 LOperand* value() { return inputs_[0]; }
1140 DECLARE_CONCRETE_INSTRUCTION(HasCachedArrayIndexAndBranch,
1141 "has-cached-array-index-and-branch")
1142 DECLARE_HYDROGEN_ACCESSOR(HasCachedArrayIndexAndBranch)
1144 void PrintDataTo(StringStream* stream) OVERRIDE;
1148 class LClassOfTestAndBranch FINAL : public LControlInstruction<1, 2> {
1150 LClassOfTestAndBranch(LOperand* value, LOperand* temp, LOperand* temp2) {
1156 LOperand* value() { return inputs_[0]; }
1157 LOperand* temp() { return temps_[0]; }
1158 LOperand* temp2() { return temps_[1]; }
1160 DECLARE_CONCRETE_INSTRUCTION(ClassOfTestAndBranch,
1161 "class-of-test-and-branch")
1162 DECLARE_HYDROGEN_ACCESSOR(ClassOfTestAndBranch)
1164 void PrintDataTo(StringStream* stream) OVERRIDE;
1168 class LCmpT FINAL : public LTemplateInstruction<1, 3, 0> {
1170 LCmpT(LOperand* context, LOperand* left, LOperand* right) {
1171 inputs_[0] = context;
1176 LOperand* context() { return inputs_[0]; }
1177 LOperand* left() { return inputs_[1]; }
1178 LOperand* right() { return inputs_[2]; }
1180 DECLARE_CONCRETE_INSTRUCTION(CmpT, "cmp-t")
1181 DECLARE_HYDROGEN_ACCESSOR(CompareGeneric)
1183 Token::Value op() const { return hydrogen()->token(); }
1187 class LInstanceOf FINAL : public LTemplateInstruction<1, 3, 0> {
1189 LInstanceOf(LOperand* context, LOperand* left, LOperand* right) {
1190 inputs_[0] = context;
1195 LOperand* context() { return inputs_[0]; }
1196 LOperand* left() { return inputs_[1]; }
1197 LOperand* right() { return inputs_[2]; }
1199 DECLARE_CONCRETE_INSTRUCTION(InstanceOf, "instance-of")
1203 class LInstanceOfKnownGlobal FINAL : public LTemplateInstruction<1, 2, 1> {
1205 LInstanceOfKnownGlobal(LOperand* context, LOperand* value, LOperand* temp) {
1206 inputs_[0] = context;
1211 LOperand* context() { return inputs_[0]; }
1212 LOperand* value() { return inputs_[1]; }
1213 LOperand* temp() { return temps_[0]; }
1215 DECLARE_CONCRETE_INSTRUCTION(InstanceOfKnownGlobal,
1216 "instance-of-known-global")
1217 DECLARE_HYDROGEN_ACCESSOR(InstanceOfKnownGlobal)
1219 Handle<JSFunction> function() const { return hydrogen()->function(); }
1220 LEnvironment* GetDeferredLazyDeoptimizationEnvironment() {
1221 return lazy_deopt_env_;
1223 virtual void SetDeferredLazyDeoptimizationEnvironment(
1224 LEnvironment* env) OVERRIDE {
1225 lazy_deopt_env_ = env;
1229 LEnvironment* lazy_deopt_env_;
1233 class LBoundsCheck FINAL : public LTemplateInstruction<0, 2, 0> {
1235 LBoundsCheck(LOperand* index, LOperand* length) {
1237 inputs_[1] = length;
1240 LOperand* index() { return inputs_[0]; }
1241 LOperand* length() { return inputs_[1]; }
1243 DECLARE_CONCRETE_INSTRUCTION(BoundsCheck, "bounds-check")
1244 DECLARE_HYDROGEN_ACCESSOR(BoundsCheck)
1248 class LBitI FINAL : public LTemplateInstruction<1, 2, 0> {
1250 LBitI(LOperand* left, LOperand* right) {
1255 LOperand* left() { return inputs_[0]; }
1256 LOperand* right() { return inputs_[1]; }
1258 Token::Value op() const { return hydrogen()->op(); }
1259 bool IsInteger32() const {
1260 return hydrogen()->representation().IsInteger32();
1263 DECLARE_CONCRETE_INSTRUCTION(BitI, "bit-i")
1264 DECLARE_HYDROGEN_ACCESSOR(Bitwise)
1268 class LShiftI FINAL : public LTemplateInstruction<1, 2, 0> {
1270 LShiftI(Token::Value op, LOperand* left, LOperand* right, bool can_deopt)
1271 : op_(op), can_deopt_(can_deopt) {
1276 Token::Value op() const { return op_; }
1277 LOperand* left() { return inputs_[0]; }
1278 LOperand* right() { return inputs_[1]; }
1279 bool can_deopt() const { return can_deopt_; }
1281 DECLARE_CONCRETE_INSTRUCTION(ShiftI, "shift-i")
1289 class LSubI FINAL : public LTemplateInstruction<1, 2, 0> {
1291 LSubI(LOperand* left, LOperand* right) {
1296 LOperand* left() { return inputs_[0]; }
1297 LOperand* right() { return inputs_[1]; }
1299 DECLARE_CONCRETE_INSTRUCTION(SubI, "sub-i")
1300 DECLARE_HYDROGEN_ACCESSOR(Sub)
1304 class LConstantI FINAL : public LTemplateInstruction<1, 0, 0> {
1306 DECLARE_CONCRETE_INSTRUCTION(ConstantI, "constant-i")
1307 DECLARE_HYDROGEN_ACCESSOR(Constant)
1309 int32_t value() const { return hydrogen()->Integer32Value(); }
1313 class LConstantS FINAL : public LTemplateInstruction<1, 0, 0> {
1315 DECLARE_CONCRETE_INSTRUCTION(ConstantS, "constant-s")
1316 DECLARE_HYDROGEN_ACCESSOR(Constant)
1318 Smi* value() const { return Smi::FromInt(hydrogen()->Integer32Value()); }
1322 class LConstantD FINAL : public LTemplateInstruction<1, 0, 0> {
1324 DECLARE_CONCRETE_INSTRUCTION(ConstantD, "constant-d")
1325 DECLARE_HYDROGEN_ACCESSOR(Constant)
1327 uint64_t bits() const { return hydrogen()->DoubleValueAsBits(); }
1331 class LConstantE FINAL : public LTemplateInstruction<1, 0, 0> {
1333 DECLARE_CONCRETE_INSTRUCTION(ConstantE, "constant-e")
1334 DECLARE_HYDROGEN_ACCESSOR(Constant)
1336 ExternalReference value() const {
1337 return hydrogen()->ExternalReferenceValue();
1342 class LConstantT FINAL : public LTemplateInstruction<1, 0, 0> {
1344 DECLARE_CONCRETE_INSTRUCTION(ConstantT, "constant-t")
1345 DECLARE_HYDROGEN_ACCESSOR(Constant)
1347 Handle<Object> value(Isolate* isolate) const {
1348 return hydrogen()->handle(isolate);
1353 class LBranch FINAL : public LControlInstruction<1, 0> {
1355 explicit LBranch(LOperand* value) {
1359 LOperand* value() { return inputs_[0]; }
1361 DECLARE_CONCRETE_INSTRUCTION(Branch, "branch")
1362 DECLARE_HYDROGEN_ACCESSOR(Branch)
1364 void PrintDataTo(StringStream* stream) OVERRIDE;
1368 class LDebugBreak FINAL : public LTemplateInstruction<0, 0, 0> {
1370 DECLARE_CONCRETE_INSTRUCTION(DebugBreak, "break")
1374 class LCmpMapAndBranch FINAL : public LControlInstruction<1, 0> {
1376 explicit LCmpMapAndBranch(LOperand* value) {
1380 LOperand* value() { return inputs_[0]; }
1382 DECLARE_CONCRETE_INSTRUCTION(CmpMapAndBranch, "cmp-map-and-branch")
1383 DECLARE_HYDROGEN_ACCESSOR(CompareMap)
1385 Handle<Map> map() const { return hydrogen()->map().handle(); }
1389 class LMapEnumLength FINAL : public LTemplateInstruction<1, 1, 0> {
1391 explicit LMapEnumLength(LOperand* value) {
1395 LOperand* value() { return inputs_[0]; }
1397 DECLARE_CONCRETE_INSTRUCTION(MapEnumLength, "map-enum-length")
1401 class LDateField FINAL : public LTemplateInstruction<1, 1, 0> {
1403 LDateField(LOperand* date, Smi* index) : index_(index) {
1407 LOperand* date() { return inputs_[0]; }
1408 Smi* index() const { return index_; }
1410 DECLARE_CONCRETE_INSTRUCTION(DateField, "date-field")
1411 DECLARE_HYDROGEN_ACCESSOR(DateField)
1418 class LSeqStringGetChar FINAL : public LTemplateInstruction<1, 2, 0> {
1420 LSeqStringGetChar(LOperand* string, LOperand* index) {
1421 inputs_[0] = string;
1425 LOperand* string() const { return inputs_[0]; }
1426 LOperand* index() const { return inputs_[1]; }
1428 DECLARE_CONCRETE_INSTRUCTION(SeqStringGetChar, "seq-string-get-char")
1429 DECLARE_HYDROGEN_ACCESSOR(SeqStringGetChar)
1433 class LSeqStringSetChar FINAL : public LTemplateInstruction<1, 4, 0> {
1435 LSeqStringSetChar(LOperand* context,
1439 inputs_[0] = context;
1440 inputs_[1] = string;
1445 LOperand* string() { return inputs_[1]; }
1446 LOperand* index() { return inputs_[2]; }
1447 LOperand* value() { return inputs_[3]; }
1449 DECLARE_CONCRETE_INSTRUCTION(SeqStringSetChar, "seq-string-set-char")
1450 DECLARE_HYDROGEN_ACCESSOR(SeqStringSetChar)
1454 class LAddI FINAL : public LTemplateInstruction<1, 2, 0> {
1456 LAddI(LOperand* left, LOperand* right) {
1461 LOperand* left() { return inputs_[0]; }
1462 LOperand* right() { return inputs_[1]; }
1464 static bool UseLea(HAdd* add) {
1465 return !add->CheckFlag(HValue::kCanOverflow) &&
1466 add->BetterLeftOperand()->UseCount() > 1;
1469 DECLARE_CONCRETE_INSTRUCTION(AddI, "add-i")
1470 DECLARE_HYDROGEN_ACCESSOR(Add)
1474 class LMathMinMax FINAL : public LTemplateInstruction<1, 2, 0> {
1476 LMathMinMax(LOperand* left, LOperand* right) {
1481 LOperand* left() { return inputs_[0]; }
1482 LOperand* right() { return inputs_[1]; }
1484 DECLARE_CONCRETE_INSTRUCTION(MathMinMax, "math-min-max")
1485 DECLARE_HYDROGEN_ACCESSOR(MathMinMax)
1489 class LPower FINAL : public LTemplateInstruction<1, 2, 0> {
1491 LPower(LOperand* left, LOperand* right) {
1496 LOperand* left() { return inputs_[0]; }
1497 LOperand* right() { return inputs_[1]; }
1499 DECLARE_CONCRETE_INSTRUCTION(Power, "power")
1500 DECLARE_HYDROGEN_ACCESSOR(Power)
1504 class LArithmeticD FINAL : public LTemplateInstruction<1, 2, 0> {
1506 LArithmeticD(Token::Value op, LOperand* left, LOperand* right)
1512 Token::Value op() const { return op_; }
1513 LOperand* left() { return inputs_[0]; }
1514 LOperand* right() { return inputs_[1]; }
1516 Opcode opcode() const OVERRIDE { return LInstruction::kArithmeticD; }
1517 void CompileToNative(LCodeGen* generator) OVERRIDE;
1518 const char* Mnemonic() const OVERRIDE;
1525 class LArithmeticT FINAL : public LTemplateInstruction<1, 3, 0> {
1527 LArithmeticT(Token::Value op,
1532 inputs_[0] = context;
1537 Token::Value op() const { return op_; }
1538 LOperand* context() { return inputs_[0]; }
1539 LOperand* left() { return inputs_[1]; }
1540 LOperand* right() { return inputs_[2]; }
1542 Opcode opcode() const OVERRIDE { return LInstruction::kArithmeticT; }
1543 void CompileToNative(LCodeGen* generator) OVERRIDE;
1544 const char* Mnemonic() const OVERRIDE;
1551 class LReturn FINAL : public LTemplateInstruction<0, 3, 0> {
1553 explicit LReturn(LOperand* value,
1555 LOperand* parameter_count) {
1557 inputs_[1] = context;
1558 inputs_[2] = parameter_count;
1561 LOperand* value() { return inputs_[0]; }
1562 LOperand* context() { return inputs_[1]; }
1564 bool has_constant_parameter_count() {
1565 return parameter_count()->IsConstantOperand();
1567 LConstantOperand* constant_parameter_count() {
1568 DCHECK(has_constant_parameter_count());
1569 return LConstantOperand::cast(parameter_count());
1571 LOperand* parameter_count() { return inputs_[2]; }
1573 DECLARE_CONCRETE_INSTRUCTION(Return, "return")
1574 DECLARE_HYDROGEN_ACCESSOR(Return)
1578 class LLoadNamedField FINAL : public LTemplateInstruction<1, 1, 0> {
1580 explicit LLoadNamedField(LOperand* object) {
1581 inputs_[0] = object;
1584 LOperand* object() { return inputs_[0]; }
1586 DECLARE_CONCRETE_INSTRUCTION(LoadNamedField, "load-named-field")
1587 DECLARE_HYDROGEN_ACCESSOR(LoadNamedField)
1591 class LLoadNamedGeneric FINAL : public LTemplateInstruction<1, 2, 1> {
1593 explicit LLoadNamedGeneric(LOperand* context, LOperand* object,
1595 inputs_[0] = context;
1596 inputs_[1] = object;
1600 DECLARE_CONCRETE_INSTRUCTION(LoadNamedGeneric, "load-named-generic")
1601 DECLARE_HYDROGEN_ACCESSOR(LoadNamedGeneric)
1603 LOperand* context() { return inputs_[0]; }
1604 LOperand* object() { return inputs_[1]; }
1605 LOperand* temp_vector() { return temps_[0]; }
1607 Handle<Object> name() const { return hydrogen()->name(); }
1611 class LLoadFunctionPrototype FINAL : public LTemplateInstruction<1, 1, 0> {
1613 explicit LLoadFunctionPrototype(LOperand* function) {
1614 inputs_[0] = function;
1617 DECLARE_CONCRETE_INSTRUCTION(LoadFunctionPrototype, "load-function-prototype")
1618 DECLARE_HYDROGEN_ACCESSOR(LoadFunctionPrototype)
1620 LOperand* function() { return inputs_[0]; }
1624 class LLoadRoot FINAL : public LTemplateInstruction<1, 0, 0> {
1626 DECLARE_CONCRETE_INSTRUCTION(LoadRoot, "load-root")
1627 DECLARE_HYDROGEN_ACCESSOR(LoadRoot)
1629 Heap::RootListIndex index() const { return hydrogen()->index(); }
1633 inline static bool ExternalArrayOpRequiresTemp(
1634 Representation key_representation,
1635 ElementsKind elements_kind) {
1636 // Operations that require the key to be divided by two to be converted into
1637 // an index cannot fold the scale operation into a load and need an extra
1638 // temp register to do the work.
1639 return SmiValuesAre31Bits() && key_representation.IsSmi() &&
1640 (elements_kind == EXTERNAL_INT8_ELEMENTS ||
1641 elements_kind == EXTERNAL_UINT8_ELEMENTS ||
1642 elements_kind == EXTERNAL_UINT8_CLAMPED_ELEMENTS ||
1643 elements_kind == UINT8_ELEMENTS ||
1644 elements_kind == INT8_ELEMENTS ||
1645 elements_kind == UINT8_CLAMPED_ELEMENTS);
1649 class LLoadKeyed FINAL : public LTemplateInstruction<1, 2, 0> {
1651 LLoadKeyed(LOperand* elements, LOperand* key) {
1652 inputs_[0] = elements;
1656 DECLARE_CONCRETE_INSTRUCTION(LoadKeyed, "load-keyed")
1657 DECLARE_HYDROGEN_ACCESSOR(LoadKeyed)
1659 bool is_external() const {
1660 return hydrogen()->is_external();
1662 bool is_fixed_typed_array() const {
1663 return hydrogen()->is_fixed_typed_array();
1665 bool is_typed_elements() const {
1666 return is_external() || is_fixed_typed_array();
1668 LOperand* elements() { return inputs_[0]; }
1669 LOperand* key() { return inputs_[1]; }
1670 void PrintDataTo(StringStream* stream) OVERRIDE;
1671 uint32_t base_offset() const { return hydrogen()->base_offset(); }
1672 ElementsKind elements_kind() const {
1673 return hydrogen()->elements_kind();
1678 class LLoadKeyedGeneric FINAL : public LTemplateInstruction<1, 3, 1> {
1680 LLoadKeyedGeneric(LOperand* context, LOperand* obj, LOperand* key,
1682 inputs_[0] = context;
1688 DECLARE_CONCRETE_INSTRUCTION(LoadKeyedGeneric, "load-keyed-generic")
1689 DECLARE_HYDROGEN_ACCESSOR(LoadKeyedGeneric)
1691 LOperand* context() { return inputs_[0]; }
1692 LOperand* object() { return inputs_[1]; }
1693 LOperand* key() { return inputs_[2]; }
1694 LOperand* temp_vector() { return temps_[0]; }
1698 class LLoadGlobalCell FINAL : public LTemplateInstruction<1, 0, 0> {
1700 DECLARE_CONCRETE_INSTRUCTION(LoadGlobalCell, "load-global-cell")
1701 DECLARE_HYDROGEN_ACCESSOR(LoadGlobalCell)
1705 class LLoadGlobalGeneric FINAL : public LTemplateInstruction<1, 2, 1> {
1707 explicit LLoadGlobalGeneric(LOperand* context, LOperand* global_object,
1709 inputs_[0] = context;
1710 inputs_[1] = global_object;
1714 DECLARE_CONCRETE_INSTRUCTION(LoadGlobalGeneric, "load-global-generic")
1715 DECLARE_HYDROGEN_ACCESSOR(LoadGlobalGeneric)
1717 LOperand* context() { return inputs_[0]; }
1718 LOperand* global_object() { return inputs_[1]; }
1719 LOperand* temp_vector() { return temps_[0]; }
1721 Handle<Object> name() const { return hydrogen()->name(); }
1722 bool for_typeof() const { return hydrogen()->for_typeof(); }
1726 class LStoreGlobalCell FINAL : public LTemplateInstruction<0, 1, 1> {
1728 explicit LStoreGlobalCell(LOperand* value, LOperand* temp) {
1733 LOperand* value() { return inputs_[0]; }
1734 LOperand* temp() { return temps_[0]; }
1736 DECLARE_CONCRETE_INSTRUCTION(StoreGlobalCell, "store-global-cell")
1737 DECLARE_HYDROGEN_ACCESSOR(StoreGlobalCell)
1741 class LLoadContextSlot FINAL : public LTemplateInstruction<1, 1, 0> {
1743 explicit LLoadContextSlot(LOperand* context) {
1744 inputs_[0] = context;
1747 LOperand* context() { return inputs_[0]; }
1749 DECLARE_CONCRETE_INSTRUCTION(LoadContextSlot, "load-context-slot")
1750 DECLARE_HYDROGEN_ACCESSOR(LoadContextSlot)
1752 int slot_index() { return hydrogen()->slot_index(); }
1754 void PrintDataTo(StringStream* stream) OVERRIDE;
1758 class LStoreContextSlot FINAL : public LTemplateInstruction<0, 2, 1> {
1760 LStoreContextSlot(LOperand* context, LOperand* value, LOperand* temp) {
1761 inputs_[0] = context;
1766 LOperand* context() { return inputs_[0]; }
1767 LOperand* value() { return inputs_[1]; }
1768 LOperand* temp() { return temps_[0]; }
1770 DECLARE_CONCRETE_INSTRUCTION(StoreContextSlot, "store-context-slot")
1771 DECLARE_HYDROGEN_ACCESSOR(StoreContextSlot)
1773 int slot_index() { return hydrogen()->slot_index(); }
1775 void PrintDataTo(StringStream* stream) OVERRIDE;
1779 class LPushArgument FINAL : public LTemplateInstruction<0, 1, 0> {
1781 explicit LPushArgument(LOperand* value) {
1785 LOperand* value() { return inputs_[0]; }
1787 DECLARE_CONCRETE_INSTRUCTION(PushArgument, "push-argument")
1791 class LDrop FINAL : public LTemplateInstruction<0, 0, 0> {
1793 explicit LDrop(int count) : count_(count) { }
1795 int count() const { return count_; }
1797 DECLARE_CONCRETE_INSTRUCTION(Drop, "drop")
1804 class LStoreCodeEntry FINAL: public LTemplateInstruction<0, 2, 0> {
1806 LStoreCodeEntry(LOperand* function, LOperand* code_object) {
1807 inputs_[0] = function;
1808 inputs_[1] = code_object;
1811 LOperand* function() { return inputs_[0]; }
1812 LOperand* code_object() { return inputs_[1]; }
1814 void PrintDataTo(StringStream* stream) OVERRIDE;
1816 DECLARE_CONCRETE_INSTRUCTION(StoreCodeEntry, "store-code-entry")
1817 DECLARE_HYDROGEN_ACCESSOR(StoreCodeEntry)
1821 class LInnerAllocatedObject FINAL: public LTemplateInstruction<1, 2, 0> {
1823 LInnerAllocatedObject(LOperand* base_object, LOperand* offset) {
1824 inputs_[0] = base_object;
1825 inputs_[1] = offset;
1828 LOperand* base_object() const { return inputs_[0]; }
1829 LOperand* offset() const { return inputs_[1]; }
1831 void PrintDataTo(StringStream* stream) OVERRIDE;
1833 DECLARE_CONCRETE_INSTRUCTION(InnerAllocatedObject, "inner-allocated-object")
1837 class LThisFunction FINAL : public LTemplateInstruction<1, 0, 0> {
1839 DECLARE_CONCRETE_INSTRUCTION(ThisFunction, "this-function")
1840 DECLARE_HYDROGEN_ACCESSOR(ThisFunction)
1844 class LContext FINAL : public LTemplateInstruction<1, 0, 0> {
1846 DECLARE_CONCRETE_INSTRUCTION(Context, "context")
1847 DECLARE_HYDROGEN_ACCESSOR(Context)
1851 class LDeclareGlobals FINAL : public LTemplateInstruction<0, 1, 0> {
1853 explicit LDeclareGlobals(LOperand* context) {
1854 inputs_[0] = context;
1857 LOperand* context() { return inputs_[0]; }
1859 DECLARE_CONCRETE_INSTRUCTION(DeclareGlobals, "declare-globals")
1860 DECLARE_HYDROGEN_ACCESSOR(DeclareGlobals)
1864 class LCallJSFunction FINAL : public LTemplateInstruction<1, 1, 0> {
1866 explicit LCallJSFunction(LOperand* function) {
1867 inputs_[0] = function;
1870 LOperand* function() { return inputs_[0]; }
1872 DECLARE_CONCRETE_INSTRUCTION(CallJSFunction, "call-js-function")
1873 DECLARE_HYDROGEN_ACCESSOR(CallJSFunction)
1875 void PrintDataTo(StringStream* stream) OVERRIDE;
1877 int arity() const { return hydrogen()->argument_count() - 1; }
1881 class LCallWithDescriptor FINAL : public LTemplateResultInstruction<1> {
1883 LCallWithDescriptor(CallInterfaceDescriptor descriptor,
1884 const ZoneList<LOperand*>& operands, Zone* zone)
1885 : inputs_(descriptor.GetRegisterParameterCount() + 1, zone) {
1886 DCHECK(descriptor.GetRegisterParameterCount() + 1 == operands.length());
1887 inputs_.AddAll(operands, zone);
1890 LOperand* target() const { return inputs_[0]; }
1892 DECLARE_HYDROGEN_ACCESSOR(CallWithDescriptor)
1895 DECLARE_CONCRETE_INSTRUCTION(CallWithDescriptor, "call-with-descriptor")
1897 void PrintDataTo(StringStream* stream) OVERRIDE;
1899 int arity() const { return hydrogen()->argument_count() - 1; }
1901 ZoneList<LOperand*> inputs_;
1903 // Iterator support.
1904 int InputCount() FINAL { return inputs_.length(); }
1905 LOperand* InputAt(int i) FINAL { return inputs_[i]; }
1907 int TempCount() FINAL { return 0; }
1908 LOperand* TempAt(int i) FINAL { return NULL; }
1912 class LInvokeFunction FINAL : public LTemplateInstruction<1, 2, 0> {
1914 LInvokeFunction(LOperand* context, LOperand* function) {
1915 inputs_[0] = context;
1916 inputs_[1] = function;
1919 LOperand* context() { return inputs_[0]; }
1920 LOperand* function() { return inputs_[1]; }
1922 DECLARE_CONCRETE_INSTRUCTION(InvokeFunction, "invoke-function")
1923 DECLARE_HYDROGEN_ACCESSOR(InvokeFunction)
1925 void PrintDataTo(StringStream* stream) OVERRIDE;
1927 int arity() const { return hydrogen()->argument_count() - 1; }
1931 class LCallFunction FINAL : public LTemplateInstruction<1, 2, 2> {
1933 LCallFunction(LOperand* context, LOperand* function, LOperand* slot,
1935 inputs_[0] = context;
1936 inputs_[1] = function;
1941 DECLARE_CONCRETE_INSTRUCTION(CallFunction, "call-function")
1942 DECLARE_HYDROGEN_ACCESSOR(CallFunction)
1944 LOperand* context() { return inputs_[0]; }
1945 LOperand* function() { return inputs_[1]; }
1946 LOperand* temp_slot() { return temps_[0]; }
1947 LOperand* temp_vector() { return temps_[1]; }
1948 int arity() const { return hydrogen()->argument_count() - 1; }
1950 void PrintDataTo(StringStream* stream) OVERRIDE;
1954 class LCallNew FINAL : public LTemplateInstruction<1, 2, 0> {
1956 LCallNew(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(CallNew, "call-new")
1965 DECLARE_HYDROGEN_ACCESSOR(CallNew)
1967 void PrintDataTo(StringStream* stream) OVERRIDE;
1969 int arity() const { return hydrogen()->argument_count() - 1; }
1973 class LCallNewArray FINAL : public LTemplateInstruction<1, 2, 0> {
1975 LCallNewArray(LOperand* context, LOperand* constructor) {
1976 inputs_[0] = context;
1977 inputs_[1] = constructor;
1980 LOperand* context() { return inputs_[0]; }
1981 LOperand* constructor() { return inputs_[1]; }
1983 DECLARE_CONCRETE_INSTRUCTION(CallNewArray, "call-new-array")
1984 DECLARE_HYDROGEN_ACCESSOR(CallNewArray)
1986 void PrintDataTo(StringStream* stream) OVERRIDE;
1988 int arity() const { return hydrogen()->argument_count() - 1; }
1992 class LCallRuntime FINAL : public LTemplateInstruction<1, 1, 0> {
1994 explicit LCallRuntime(LOperand* context) {
1995 inputs_[0] = context;
1998 LOperand* context() { return inputs_[0]; }
2000 DECLARE_CONCRETE_INSTRUCTION(CallRuntime, "call-runtime")
2001 DECLARE_HYDROGEN_ACCESSOR(CallRuntime)
2003 bool ClobbersDoubleRegisters(Isolate* isolate) const OVERRIDE {
2004 return save_doubles() == kDontSaveFPRegs;
2007 const Runtime::Function* function() const { return hydrogen()->function(); }
2008 int arity() const { return hydrogen()->argument_count(); }
2009 SaveFPRegsMode save_doubles() const { return hydrogen()->save_doubles(); }
2013 class LInteger32ToDouble FINAL : public LTemplateInstruction<1, 1, 0> {
2015 explicit LInteger32ToDouble(LOperand* value) {
2019 LOperand* value() { return inputs_[0]; }
2021 DECLARE_CONCRETE_INSTRUCTION(Integer32ToDouble, "int32-to-double")
2025 class LUint32ToDouble FINAL : public LTemplateInstruction<1, 1, 0> {
2027 explicit LUint32ToDouble(LOperand* value) {
2031 LOperand* value() { return inputs_[0]; }
2033 DECLARE_CONCRETE_INSTRUCTION(Uint32ToDouble, "uint32-to-double")
2037 class LNumberTagI FINAL : public LTemplateInstruction<1, 1, 2> {
2039 LNumberTagI(LOperand* value, LOperand* temp1, LOperand* temp2) {
2045 LOperand* value() { return inputs_[0]; }
2046 LOperand* temp1() { return temps_[0]; }
2047 LOperand* temp2() { return temps_[1]; }
2049 DECLARE_CONCRETE_INSTRUCTION(NumberTagI, "number-tag-i")
2053 class LNumberTagU FINAL : public LTemplateInstruction<1, 1, 2> {
2055 LNumberTagU(LOperand* value, LOperand* temp1, LOperand* temp2) {
2061 LOperand* value() { return inputs_[0]; }
2062 LOperand* temp1() { return temps_[0]; }
2063 LOperand* temp2() { return temps_[1]; }
2065 DECLARE_CONCRETE_INSTRUCTION(NumberTagU, "number-tag-u")
2069 class LNumberTagD FINAL : public LTemplateInstruction<1, 1, 1> {
2071 explicit LNumberTagD(LOperand* value, LOperand* temp) {
2076 LOperand* value() { return inputs_[0]; }
2077 LOperand* temp() { return temps_[0]; }
2079 DECLARE_CONCRETE_INSTRUCTION(NumberTagD, "number-tag-d")
2080 DECLARE_HYDROGEN_ACCESSOR(Change)
2084 // Sometimes truncating conversion from a tagged value to an int32.
2085 class LDoubleToI FINAL : public LTemplateInstruction<1, 1, 0> {
2087 explicit LDoubleToI(LOperand* value) {
2091 LOperand* value() { return inputs_[0]; }
2093 DECLARE_CONCRETE_INSTRUCTION(DoubleToI, "double-to-i")
2094 DECLARE_HYDROGEN_ACCESSOR(UnaryOperation)
2096 bool truncating() { return hydrogen()->CanTruncateToInt32(); }
2100 class LDoubleToSmi FINAL : public LTemplateInstruction<1, 1, 0> {
2102 explicit LDoubleToSmi(LOperand* value) {
2106 LOperand* value() { return inputs_[0]; }
2108 DECLARE_CONCRETE_INSTRUCTION(DoubleToSmi, "double-to-smi")
2109 DECLARE_HYDROGEN_ACCESSOR(UnaryOperation)
2113 // Truncating conversion from a tagged value to an int32.
2114 class LTaggedToI FINAL : public LTemplateInstruction<1, 1, 1> {
2116 LTaggedToI(LOperand* value, LOperand* temp) {
2121 LOperand* value() { return inputs_[0]; }
2122 LOperand* temp() { return temps_[0]; }
2124 DECLARE_CONCRETE_INSTRUCTION(TaggedToI, "tagged-to-i")
2125 DECLARE_HYDROGEN_ACCESSOR(Change)
2127 bool truncating() { return hydrogen()->CanTruncateToInt32(); }
2131 class LSmiTag FINAL : public LTemplateInstruction<1, 1, 0> {
2133 explicit LSmiTag(LOperand* value) {
2137 LOperand* value() { return inputs_[0]; }
2139 DECLARE_CONCRETE_INSTRUCTION(SmiTag, "smi-tag")
2140 DECLARE_HYDROGEN_ACCESSOR(Change)
2144 class LNumberUntagD FINAL : public LTemplateInstruction<1, 1, 0> {
2146 explicit LNumberUntagD(LOperand* value) {
2150 LOperand* value() { return inputs_[0]; }
2152 DECLARE_CONCRETE_INSTRUCTION(NumberUntagD, "double-untag")
2153 DECLARE_HYDROGEN_ACCESSOR(Change);
2157 class LSmiUntag FINAL : public LTemplateInstruction<1, 1, 0> {
2159 LSmiUntag(LOperand* value, bool needs_check)
2160 : needs_check_(needs_check) {
2164 LOperand* value() { return inputs_[0]; }
2165 bool needs_check() const { return needs_check_; }
2167 DECLARE_CONCRETE_INSTRUCTION(SmiUntag, "smi-untag")
2174 class LStoreNamedField FINAL : public LTemplateInstruction<0, 2, 1> {
2176 LStoreNamedField(LOperand* object, LOperand* value, LOperand* temp) {
2177 inputs_[0] = object;
2182 LOperand* object() { return inputs_[0]; }
2183 LOperand* value() { return inputs_[1]; }
2184 LOperand* temp() { return temps_[0]; }
2186 DECLARE_CONCRETE_INSTRUCTION(StoreNamedField, "store-named-field")
2187 DECLARE_HYDROGEN_ACCESSOR(StoreNamedField)
2189 void PrintDataTo(StringStream* stream) OVERRIDE;
2191 Representation representation() const {
2192 return hydrogen()->field_representation();
2197 class LStoreNamedGeneric FINAL : public LTemplateInstruction<0, 3, 0> {
2199 LStoreNamedGeneric(LOperand* context, LOperand* object, LOperand* value) {
2200 inputs_[0] = context;
2201 inputs_[1] = object;
2205 LOperand* context() { return inputs_[0]; }
2206 LOperand* object() { return inputs_[1]; }
2207 LOperand* value() { return inputs_[2]; }
2209 DECLARE_CONCRETE_INSTRUCTION(StoreNamedGeneric, "store-named-generic")
2210 DECLARE_HYDROGEN_ACCESSOR(StoreNamedGeneric)
2212 void PrintDataTo(StringStream* stream) OVERRIDE;
2214 Handle<Object> name() const { return hydrogen()->name(); }
2215 StrictMode strict_mode() { return hydrogen()->strict_mode(); }
2219 class LStoreKeyed FINAL : public LTemplateInstruction<0, 3, 0> {
2221 LStoreKeyed(LOperand* object, LOperand* key, LOperand* value) {
2222 inputs_[0] = object;
2227 bool is_external() const { return hydrogen()->is_external(); }
2228 bool is_fixed_typed_array() const {
2229 return hydrogen()->is_fixed_typed_array();
2231 bool is_typed_elements() const {
2232 return is_external() || is_fixed_typed_array();
2234 LOperand* elements() { return inputs_[0]; }
2235 LOperand* key() { return inputs_[1]; }
2236 LOperand* value() { return inputs_[2]; }
2237 ElementsKind elements_kind() const { return hydrogen()->elements_kind(); }
2239 DECLARE_CONCRETE_INSTRUCTION(StoreKeyed, "store-keyed")
2240 DECLARE_HYDROGEN_ACCESSOR(StoreKeyed)
2242 void PrintDataTo(StringStream* stream) OVERRIDE;
2243 bool NeedsCanonicalization() { return hydrogen()->NeedsCanonicalization(); }
2244 uint32_t base_offset() const { return hydrogen()->base_offset(); }
2248 class LStoreKeyedGeneric FINAL : public LTemplateInstruction<0, 4, 0> {
2250 LStoreKeyedGeneric(LOperand* context,
2254 inputs_[0] = context;
2255 inputs_[1] = object;
2260 LOperand* context() { return inputs_[0]; }
2261 LOperand* object() { return inputs_[1]; }
2262 LOperand* key() { return inputs_[2]; }
2263 LOperand* value() { return inputs_[3]; }
2265 DECLARE_CONCRETE_INSTRUCTION(StoreKeyedGeneric, "store-keyed-generic")
2266 DECLARE_HYDROGEN_ACCESSOR(StoreKeyedGeneric)
2268 void PrintDataTo(StringStream* stream) OVERRIDE;
2270 StrictMode strict_mode() { return hydrogen()->strict_mode(); }
2274 class LTransitionElementsKind FINAL : public LTemplateInstruction<0, 2, 2> {
2276 LTransitionElementsKind(LOperand* object,
2278 LOperand* new_map_temp,
2280 inputs_[0] = object;
2281 inputs_[1] = context;
2282 temps_[0] = new_map_temp;
2286 LOperand* object() { return inputs_[0]; }
2287 LOperand* context() { return inputs_[1]; }
2288 LOperand* new_map_temp() { return temps_[0]; }
2289 LOperand* temp() { return temps_[1]; }
2291 DECLARE_CONCRETE_INSTRUCTION(TransitionElementsKind,
2292 "transition-elements-kind")
2293 DECLARE_HYDROGEN_ACCESSOR(TransitionElementsKind)
2295 void PrintDataTo(StringStream* stream) OVERRIDE;
2297 Handle<Map> original_map() { return hydrogen()->original_map().handle(); }
2298 Handle<Map> transitioned_map() {
2299 return hydrogen()->transitioned_map().handle();
2301 ElementsKind from_kind() { return hydrogen()->from_kind(); }
2302 ElementsKind to_kind() { return hydrogen()->to_kind(); }
2306 class LTrapAllocationMemento FINAL : public LTemplateInstruction<0, 1, 1> {
2308 LTrapAllocationMemento(LOperand* object,
2310 inputs_[0] = object;
2314 LOperand* object() { return inputs_[0]; }
2315 LOperand* temp() { return temps_[0]; }
2317 DECLARE_CONCRETE_INSTRUCTION(TrapAllocationMemento,
2318 "trap-allocation-memento")
2322 class LStringAdd FINAL : public LTemplateInstruction<1, 3, 0> {
2324 LStringAdd(LOperand* context, LOperand* left, LOperand* right) {
2325 inputs_[0] = context;
2330 LOperand* context() { return inputs_[0]; }
2331 LOperand* left() { return inputs_[1]; }
2332 LOperand* right() { return inputs_[2]; }
2334 DECLARE_CONCRETE_INSTRUCTION(StringAdd, "string-add")
2335 DECLARE_HYDROGEN_ACCESSOR(StringAdd)
2339 class LStringCharCodeAt FINAL : public LTemplateInstruction<1, 3, 0> {
2341 LStringCharCodeAt(LOperand* context, LOperand* string, LOperand* index) {
2342 inputs_[0] = context;
2343 inputs_[1] = string;
2347 LOperand* context() { return inputs_[0]; }
2348 LOperand* string() { return inputs_[1]; }
2349 LOperand* index() { return inputs_[2]; }
2351 DECLARE_CONCRETE_INSTRUCTION(StringCharCodeAt, "string-char-code-at")
2352 DECLARE_HYDROGEN_ACCESSOR(StringCharCodeAt)
2356 class LStringCharFromCode FINAL : public LTemplateInstruction<1, 2, 0> {
2358 explicit LStringCharFromCode(LOperand* context, LOperand* char_code) {
2359 inputs_[0] = context;
2360 inputs_[1] = char_code;
2363 LOperand* context() { return inputs_[0]; }
2364 LOperand* char_code() { return inputs_[1]; }
2366 DECLARE_CONCRETE_INSTRUCTION(StringCharFromCode, "string-char-from-code")
2367 DECLARE_HYDROGEN_ACCESSOR(StringCharFromCode)
2371 class LCheckValue FINAL : public LTemplateInstruction<0, 1, 0> {
2373 explicit LCheckValue(LOperand* value) {
2377 LOperand* value() { return inputs_[0]; }
2379 DECLARE_CONCRETE_INSTRUCTION(CheckValue, "check-value")
2380 DECLARE_HYDROGEN_ACCESSOR(CheckValue)
2384 class LCheckInstanceType FINAL : public LTemplateInstruction<0, 1, 0> {
2386 explicit LCheckInstanceType(LOperand* value) {
2390 LOperand* value() { return inputs_[0]; }
2392 DECLARE_CONCRETE_INSTRUCTION(CheckInstanceType, "check-instance-type")
2393 DECLARE_HYDROGEN_ACCESSOR(CheckInstanceType)
2397 class LCheckMaps FINAL : public LTemplateInstruction<0, 1, 0> {
2399 explicit LCheckMaps(LOperand* value = NULL) {
2403 LOperand* value() { return inputs_[0]; }
2405 DECLARE_CONCRETE_INSTRUCTION(CheckMaps, "check-maps")
2406 DECLARE_HYDROGEN_ACCESSOR(CheckMaps)
2410 class LCheckSmi FINAL : public LTemplateInstruction<1, 1, 0> {
2412 explicit LCheckSmi(LOperand* value) {
2416 LOperand* value() { return inputs_[0]; }
2418 DECLARE_CONCRETE_INSTRUCTION(CheckSmi, "check-smi")
2422 class LClampDToUint8 FINAL : public LTemplateInstruction<1, 1, 0> {
2424 explicit LClampDToUint8(LOperand* unclamped) {
2425 inputs_[0] = unclamped;
2428 LOperand* unclamped() { return inputs_[0]; }
2430 DECLARE_CONCRETE_INSTRUCTION(ClampDToUint8, "clamp-d-to-uint8")
2434 class LClampIToUint8 FINAL : public LTemplateInstruction<1, 1, 0> {
2436 explicit LClampIToUint8(LOperand* unclamped) {
2437 inputs_[0] = unclamped;
2440 LOperand* unclamped() { return inputs_[0]; }
2442 DECLARE_CONCRETE_INSTRUCTION(ClampIToUint8, "clamp-i-to-uint8")
2446 class LClampTToUint8 FINAL : public LTemplateInstruction<1, 1, 1> {
2448 LClampTToUint8(LOperand* unclamped,
2449 LOperand* temp_xmm) {
2450 inputs_[0] = unclamped;
2451 temps_[0] = temp_xmm;
2454 LOperand* unclamped() { return inputs_[0]; }
2455 LOperand* temp_xmm() { return temps_[0]; }
2457 DECLARE_CONCRETE_INSTRUCTION(ClampTToUint8, "clamp-t-to-uint8")
2461 class LCheckNonSmi FINAL : public LTemplateInstruction<0, 1, 0> {
2463 explicit LCheckNonSmi(LOperand* value) {
2467 LOperand* value() { return inputs_[0]; }
2469 DECLARE_CONCRETE_INSTRUCTION(CheckNonSmi, "check-non-smi")
2470 DECLARE_HYDROGEN_ACCESSOR(CheckHeapObject)
2474 class LDoubleBits FINAL : public LTemplateInstruction<1, 1, 0> {
2476 explicit LDoubleBits(LOperand* value) {
2480 LOperand* value() { return inputs_[0]; }
2482 DECLARE_CONCRETE_INSTRUCTION(DoubleBits, "double-bits")
2483 DECLARE_HYDROGEN_ACCESSOR(DoubleBits)
2487 class LConstructDouble FINAL : public LTemplateInstruction<1, 2, 0> {
2489 LConstructDouble(LOperand* hi, LOperand* lo) {
2494 LOperand* hi() { return inputs_[0]; }
2495 LOperand* lo() { return inputs_[1]; }
2497 DECLARE_CONCRETE_INSTRUCTION(ConstructDouble, "construct-double")
2501 class LAllocate FINAL : public LTemplateInstruction<1, 2, 1> {
2503 LAllocate(LOperand* context, LOperand* size, LOperand* temp) {
2504 inputs_[0] = context;
2509 LOperand* context() { return inputs_[0]; }
2510 LOperand* size() { return inputs_[1]; }
2511 LOperand* temp() { return temps_[0]; }
2513 DECLARE_CONCRETE_INSTRUCTION(Allocate, "allocate")
2514 DECLARE_HYDROGEN_ACCESSOR(Allocate)
2518 class LRegExpLiteral FINAL : public LTemplateInstruction<1, 1, 0> {
2520 explicit LRegExpLiteral(LOperand* context) {
2521 inputs_[0] = context;
2524 LOperand* context() { return inputs_[0]; }
2526 DECLARE_CONCRETE_INSTRUCTION(RegExpLiteral, "regexp-literal")
2527 DECLARE_HYDROGEN_ACCESSOR(RegExpLiteral)
2531 class LFunctionLiteral FINAL : public LTemplateInstruction<1, 1, 0> {
2533 explicit LFunctionLiteral(LOperand* context) {
2534 inputs_[0] = context;
2537 LOperand* context() { return inputs_[0]; }
2539 DECLARE_CONCRETE_INSTRUCTION(FunctionLiteral, "function-literal")
2540 DECLARE_HYDROGEN_ACCESSOR(FunctionLiteral)
2544 class LToFastProperties FINAL : public LTemplateInstruction<1, 1, 0> {
2546 explicit LToFastProperties(LOperand* value) {
2550 LOperand* value() { return inputs_[0]; }
2552 DECLARE_CONCRETE_INSTRUCTION(ToFastProperties, "to-fast-properties")
2553 DECLARE_HYDROGEN_ACCESSOR(ToFastProperties)
2557 class LTypeof FINAL : public LTemplateInstruction<1, 2, 0> {
2559 LTypeof(LOperand* context, LOperand* value) {
2560 inputs_[0] = context;
2564 LOperand* context() { return inputs_[0]; }
2565 LOperand* value() { return inputs_[1]; }
2567 DECLARE_CONCRETE_INSTRUCTION(Typeof, "typeof")
2571 class LTypeofIsAndBranch FINAL : public LControlInstruction<1, 0> {
2573 explicit LTypeofIsAndBranch(LOperand* value) {
2577 LOperand* value() { return inputs_[0]; }
2579 DECLARE_CONCRETE_INSTRUCTION(TypeofIsAndBranch, "typeof-is-and-branch")
2580 DECLARE_HYDROGEN_ACCESSOR(TypeofIsAndBranch)
2582 Handle<String> type_literal() { return hydrogen()->type_literal(); }
2584 void PrintDataTo(StringStream* stream) OVERRIDE;
2588 class LIsConstructCallAndBranch FINAL : public LControlInstruction<0, 1> {
2590 explicit LIsConstructCallAndBranch(LOperand* temp) {
2594 LOperand* temp() { return temps_[0]; }
2596 DECLARE_CONCRETE_INSTRUCTION(IsConstructCallAndBranch,
2597 "is-construct-call-and-branch")
2598 DECLARE_HYDROGEN_ACCESSOR(IsConstructCallAndBranch)
2602 class LOsrEntry FINAL : public LTemplateInstruction<0, 0, 0> {
2606 bool HasInterestingComment(LCodeGen* gen) const OVERRIDE { return false; }
2607 DECLARE_CONCRETE_INSTRUCTION(OsrEntry, "osr-entry")
2611 class LStackCheck FINAL : public LTemplateInstruction<0, 1, 0> {
2613 explicit LStackCheck(LOperand* context) {
2614 inputs_[0] = context;
2617 LOperand* context() { return inputs_[0]; }
2619 DECLARE_CONCRETE_INSTRUCTION(StackCheck, "stack-check")
2620 DECLARE_HYDROGEN_ACCESSOR(StackCheck)
2622 Label* done_label() { return &done_label_; }
2629 class LForInPrepareMap FINAL : public LTemplateInstruction<1, 2, 0> {
2631 LForInPrepareMap(LOperand* context, LOperand* object) {
2632 inputs_[0] = context;
2633 inputs_[1] = object;
2636 LOperand* context() { return inputs_[0]; }
2637 LOperand* object() { return inputs_[1]; }
2639 DECLARE_CONCRETE_INSTRUCTION(ForInPrepareMap, "for-in-prepare-map")
2643 class LForInCacheArray FINAL : public LTemplateInstruction<1, 1, 0> {
2645 explicit LForInCacheArray(LOperand* map) {
2649 LOperand* map() { return inputs_[0]; }
2651 DECLARE_CONCRETE_INSTRUCTION(ForInCacheArray, "for-in-cache-array")
2654 return HForInCacheArray::cast(this->hydrogen_value())->idx();
2659 class LCheckMapValue FINAL : public LTemplateInstruction<0, 2, 0> {
2661 LCheckMapValue(LOperand* value, LOperand* map) {
2666 LOperand* value() { return inputs_[0]; }
2667 LOperand* map() { return inputs_[1]; }
2669 DECLARE_CONCRETE_INSTRUCTION(CheckMapValue, "check-map-value")
2673 class LLoadFieldByIndex FINAL : public LTemplateInstruction<1, 2, 0> {
2675 LLoadFieldByIndex(LOperand* object, LOperand* index) {
2676 inputs_[0] = object;
2680 LOperand* object() { return inputs_[0]; }
2681 LOperand* index() { return inputs_[1]; }
2683 DECLARE_CONCRETE_INSTRUCTION(LoadFieldByIndex, "load-field-by-index")
2687 class LStoreFrameContext: public LTemplateInstruction<0, 1, 0> {
2689 explicit LStoreFrameContext(LOperand* context) {
2690 inputs_[0] = context;
2693 LOperand* context() { return inputs_[0]; }
2695 DECLARE_CONCRETE_INSTRUCTION(StoreFrameContext, "store-frame-context")
2699 class LAllocateBlockContext: public LTemplateInstruction<1, 2, 0> {
2701 LAllocateBlockContext(LOperand* context, LOperand* function) {
2702 inputs_[0] = context;
2703 inputs_[1] = function;
2706 LOperand* context() { return inputs_[0]; }
2707 LOperand* function() { return inputs_[1]; }
2709 Handle<ScopeInfo> scope_info() { return hydrogen()->scope_info(); }
2711 DECLARE_CONCRETE_INSTRUCTION(AllocateBlockContext, "allocate-block-context")
2712 DECLARE_HYDROGEN_ACCESSOR(AllocateBlockContext)
2716 class LChunkBuilder;
2717 class LPlatformChunk FINAL : public LChunk {
2719 LPlatformChunk(CompilationInfo* info, HGraph* graph)
2720 : LChunk(info, graph),
2721 dehoisted_key_ids_(graph->GetMaximumValueID(), graph->zone()) { }
2723 int GetNextSpillIndex(RegisterKind kind);
2724 LOperand* GetNextSpillSlot(RegisterKind kind);
2725 BitVector* GetDehoistedKeyIds() { return &dehoisted_key_ids_; }
2726 bool IsDehoistedKey(HValue* value) {
2727 return dehoisted_key_ids_.Contains(value->id());
2731 BitVector dehoisted_key_ids_;
2735 class LChunkBuilder FINAL : public LChunkBuilderBase {
2737 LChunkBuilder(CompilationInfo* info, HGraph* graph, LAllocator* allocator)
2738 : LChunkBuilderBase(info, graph),
2739 current_instruction_(NULL),
2740 current_block_(NULL),
2742 allocator_(allocator) {}
2744 // Build the sequence for the graph.
2745 LPlatformChunk* Build();
2747 // Declare methods that deal with the individual node types.
2748 #define DECLARE_DO(type) LInstruction* Do##type(H##type* node);
2749 HYDROGEN_CONCRETE_INSTRUCTION_LIST(DECLARE_DO)
2752 LInstruction* DoMathFloor(HUnaryMathOperation* instr);
2753 LInstruction* DoMathRound(HUnaryMathOperation* instr);
2754 LInstruction* DoMathFround(HUnaryMathOperation* instr);
2755 LInstruction* DoMathAbs(HUnaryMathOperation* instr);
2756 LInstruction* DoMathLog(HUnaryMathOperation* instr);
2757 LInstruction* DoMathExp(HUnaryMathOperation* instr);
2758 LInstruction* DoMathSqrt(HUnaryMathOperation* instr);
2759 LInstruction* DoMathPowHalf(HUnaryMathOperation* instr);
2760 LInstruction* DoMathClz32(HUnaryMathOperation* instr);
2761 LInstruction* DoDivByPowerOf2I(HDiv* instr);
2762 LInstruction* DoDivByConstI(HDiv* instr);
2763 LInstruction* DoDivI(HDiv* instr);
2764 LInstruction* DoModByPowerOf2I(HMod* instr);
2765 LInstruction* DoModByConstI(HMod* instr);
2766 LInstruction* DoModI(HMod* instr);
2767 LInstruction* DoFlooringDivByPowerOf2I(HMathFloorOfDiv* instr);
2768 LInstruction* DoFlooringDivByConstI(HMathFloorOfDiv* instr);
2769 LInstruction* DoFlooringDivI(HMathFloorOfDiv* instr);
2772 // Methods for getting operands for Use / Define / Temp.
2773 LUnallocated* ToUnallocated(Register reg);
2774 LUnallocated* ToUnallocated(XMMRegister reg);
2776 // Methods for setting up define-use relationships.
2777 MUST_USE_RESULT LOperand* Use(HValue* value, LUnallocated* operand);
2778 MUST_USE_RESULT LOperand* UseFixed(HValue* value, Register fixed_register);
2779 MUST_USE_RESULT LOperand* UseFixedDouble(HValue* value,
2780 XMMRegister fixed_register);
2782 // A value that is guaranteed to be allocated to a register.
2783 // Operand created by UseRegister is guaranteed to be live until the end of
2784 // instruction. This means that register allocator will not reuse it's
2785 // register for any other operand inside instruction.
2786 // Operand created by UseRegisterAtStart is guaranteed to be live only at
2787 // instruction start. Register allocator is free to assign the same register
2788 // to some other operand used inside instruction (i.e. temporary or
2790 MUST_USE_RESULT LOperand* UseRegister(HValue* value);
2791 MUST_USE_RESULT LOperand* UseRegisterAtStart(HValue* value);
2793 // An input operand in a register that may be trashed.
2794 MUST_USE_RESULT LOperand* UseTempRegister(HValue* value);
2796 // An input operand in a register that may be trashed or a constant operand.
2797 MUST_USE_RESULT LOperand* UseTempRegisterOrConstant(HValue* value);
2799 // An input operand in a register or stack slot.
2800 MUST_USE_RESULT LOperand* Use(HValue* value);
2801 MUST_USE_RESULT LOperand* UseAtStart(HValue* value);
2803 // An input operand in a register, stack slot or a constant operand.
2804 MUST_USE_RESULT LOperand* UseOrConstant(HValue* value);
2805 MUST_USE_RESULT LOperand* UseOrConstantAtStart(HValue* value);
2807 // An input operand in a register or a constant operand.
2808 MUST_USE_RESULT LOperand* UseRegisterOrConstant(HValue* value);
2809 MUST_USE_RESULT LOperand* UseRegisterOrConstantAtStart(HValue* value);
2811 // An input operand in a constant operand.
2812 MUST_USE_RESULT LOperand* UseConstant(HValue* value);
2814 // An input operand in register, stack slot or a constant operand.
2815 // Will not be moved to a register even if one is freely available.
2816 MUST_USE_RESULT LOperand* UseAny(HValue* value) OVERRIDE;
2818 // Temporary operand that must be in a register.
2819 MUST_USE_RESULT LUnallocated* TempRegister();
2820 MUST_USE_RESULT LOperand* FixedTemp(Register reg);
2821 MUST_USE_RESULT LOperand* FixedTemp(XMMRegister reg);
2823 // Methods for setting up define-use relationships.
2824 // Return the same instruction that they are passed.
2825 LInstruction* Define(LTemplateResultInstruction<1>* instr,
2826 LUnallocated* result);
2827 LInstruction* DefineAsRegister(LTemplateResultInstruction<1>* instr);
2828 LInstruction* DefineAsSpilled(LTemplateResultInstruction<1>* instr,
2830 LInstruction* DefineSameAsFirst(LTemplateResultInstruction<1>* instr);
2831 LInstruction* DefineFixed(LTemplateResultInstruction<1>* instr,
2833 LInstruction* DefineFixedDouble(LTemplateResultInstruction<1>* instr,
2835 // Assigns an environment to an instruction. An instruction which can
2836 // deoptimize must have an environment.
2837 LInstruction* AssignEnvironment(LInstruction* instr);
2838 // Assigns a pointer map to an instruction. An instruction which can
2839 // trigger a GC or a lazy deoptimization must have a pointer map.
2840 LInstruction* AssignPointerMap(LInstruction* instr);
2842 enum CanDeoptimize { CAN_DEOPTIMIZE_EAGERLY, CANNOT_DEOPTIMIZE_EAGERLY };
2844 // Marks a call for the register allocator. Assigns a pointer map to
2845 // support GC and lazy deoptimization. Assigns an environment to support
2846 // eager deoptimization if CAN_DEOPTIMIZE_EAGERLY.
2847 LInstruction* MarkAsCall(
2848 LInstruction* instr,
2849 HInstruction* hinstr,
2850 CanDeoptimize can_deoptimize = CANNOT_DEOPTIMIZE_EAGERLY);
2852 void VisitInstruction(HInstruction* current);
2853 void AddInstruction(LInstruction* instr, HInstruction* current);
2855 void DoBasicBlock(HBasicBlock* block, HBasicBlock* next_block);
2856 LInstruction* DoShift(Token::Value op, HBitwiseBinaryOperation* instr);
2857 LInstruction* DoArithmeticD(Token::Value op,
2858 HArithmeticBinaryOperation* instr);
2859 LInstruction* DoArithmeticT(Token::Value op,
2860 HBinaryOperation* instr);
2861 void FindDehoistedKeyDefinitions(HValue* candidate);
2863 HInstruction* current_instruction_;
2864 HBasicBlock* current_block_;
2865 HBasicBlock* next_block_;
2866 LAllocator* allocator_;
2868 DISALLOW_COPY_AND_ASSIGN(LChunkBuilder);
2871 #undef DECLARE_HYDROGEN_ACCESSOR
2872 #undef DECLARE_CONCRETE_INSTRUCTION
2874 } } // namespace v8::int
2876 #endif // V8_X64_LITHIUM_X64_H_