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, 3, 0> {
485 explicit LTailCallThroughMegamorphicCache(LOperand* context,
488 inputs_[0] = context;
489 inputs_[1] = receiver;
493 LOperand* context() { return inputs_[0]; }
494 LOperand* receiver() { return inputs_[1]; }
495 LOperand* name() { return inputs_[2]; }
497 DECLARE_CONCRETE_INSTRUCTION(TailCallThroughMegamorphicCache,
498 "tail-call-through-megamorphic-cache")
499 DECLARE_HYDROGEN_ACCESSOR(TailCallThroughMegamorphicCache)
503 class LUnknownOSRValue FINAL : public LTemplateInstruction<1, 0, 0> {
505 bool HasInterestingComment(LCodeGen* gen) const OVERRIDE { return false; }
506 DECLARE_CONCRETE_INSTRUCTION(UnknownOSRValue, "unknown-osr-value")
510 template<int I, int T>
511 class LControlInstruction : public LTemplateInstruction<0, I, T> {
513 LControlInstruction() : false_label_(NULL), true_label_(NULL) { }
515 bool IsControl() const FINAL { return true; }
517 int SuccessorCount() { return hydrogen()->SuccessorCount(); }
518 HBasicBlock* SuccessorAt(int i) { return hydrogen()->SuccessorAt(i); }
520 int TrueDestination(LChunk* chunk) {
521 return chunk->LookupDestination(true_block_id());
523 int FalseDestination(LChunk* chunk) {
524 return chunk->LookupDestination(false_block_id());
527 Label* TrueLabel(LChunk* chunk) {
528 if (true_label_ == NULL) {
529 true_label_ = chunk->GetAssemblyLabel(TrueDestination(chunk));
533 Label* FalseLabel(LChunk* chunk) {
534 if (false_label_ == NULL) {
535 false_label_ = chunk->GetAssemblyLabel(FalseDestination(chunk));
541 int true_block_id() { return SuccessorAt(0)->block_id(); }
542 int false_block_id() { return SuccessorAt(1)->block_id(); }
545 HControlInstruction* hydrogen() {
546 return HControlInstruction::cast(this->hydrogen_value());
554 class LWrapReceiver FINAL : public LTemplateInstruction<1, 2, 0> {
556 LWrapReceiver(LOperand* receiver, LOperand* function) {
557 inputs_[0] = receiver;
558 inputs_[1] = function;
561 LOperand* receiver() { return inputs_[0]; }
562 LOperand* function() { return inputs_[1]; }
564 DECLARE_CONCRETE_INSTRUCTION(WrapReceiver, "wrap-receiver")
565 DECLARE_HYDROGEN_ACCESSOR(WrapReceiver)
569 class LApplyArguments FINAL : public LTemplateInstruction<1, 4, 0> {
571 LApplyArguments(LOperand* function,
574 LOperand* elements) {
575 inputs_[0] = function;
576 inputs_[1] = receiver;
578 inputs_[3] = elements;
581 LOperand* function() { return inputs_[0]; }
582 LOperand* receiver() { return inputs_[1]; }
583 LOperand* length() { return inputs_[2]; }
584 LOperand* elements() { return inputs_[3]; }
586 DECLARE_CONCRETE_INSTRUCTION(ApplyArguments, "apply-arguments")
590 class LAccessArgumentsAt FINAL : public LTemplateInstruction<1, 3, 0> {
592 LAccessArgumentsAt(LOperand* arguments, LOperand* length, LOperand* index) {
593 inputs_[0] = arguments;
598 LOperand* arguments() { return inputs_[0]; }
599 LOperand* length() { return inputs_[1]; }
600 LOperand* index() { return inputs_[2]; }
602 DECLARE_CONCRETE_INSTRUCTION(AccessArgumentsAt, "access-arguments-at")
604 void PrintDataTo(StringStream* stream) OVERRIDE;
608 class LArgumentsLength FINAL : public LTemplateInstruction<1, 1, 0> {
610 explicit LArgumentsLength(LOperand* elements) {
611 inputs_[0] = elements;
614 LOperand* elements() { return inputs_[0]; }
616 DECLARE_CONCRETE_INSTRUCTION(ArgumentsLength, "arguments-length")
620 class LArgumentsElements FINAL : public LTemplateInstruction<1, 0, 0> {
622 DECLARE_CONCRETE_INSTRUCTION(ArgumentsElements, "arguments-elements")
623 DECLARE_HYDROGEN_ACCESSOR(ArgumentsElements)
627 class LModByPowerOf2I FINAL : public LTemplateInstruction<1, 1, 0> {
629 LModByPowerOf2I(LOperand* dividend, int32_t divisor) {
630 inputs_[0] = dividend;
634 LOperand* dividend() { return inputs_[0]; }
635 int32_t divisor() const { return divisor_; }
637 DECLARE_CONCRETE_INSTRUCTION(ModByPowerOf2I, "mod-by-power-of-2-i")
638 DECLARE_HYDROGEN_ACCESSOR(Mod)
645 class LModByConstI FINAL : public LTemplateInstruction<1, 1, 2> {
647 LModByConstI(LOperand* dividend,
651 inputs_[0] = dividend;
657 LOperand* dividend() { return inputs_[0]; }
658 int32_t divisor() const { return divisor_; }
659 LOperand* temp1() { return temps_[0]; }
660 LOperand* temp2() { return temps_[1]; }
662 DECLARE_CONCRETE_INSTRUCTION(ModByConstI, "mod-by-const-i")
663 DECLARE_HYDROGEN_ACCESSOR(Mod)
670 class LModI FINAL : public LTemplateInstruction<1, 2, 1> {
672 LModI(LOperand* left, LOperand* right, LOperand* temp) {
678 LOperand* left() { return inputs_[0]; }
679 LOperand* right() { return inputs_[1]; }
680 LOperand* temp() { return temps_[0]; }
682 DECLARE_CONCRETE_INSTRUCTION(ModI, "mod-i")
683 DECLARE_HYDROGEN_ACCESSOR(Mod)
687 class LDivByPowerOf2I FINAL : public LTemplateInstruction<1, 1, 0> {
689 LDivByPowerOf2I(LOperand* dividend, int32_t divisor) {
690 inputs_[0] = dividend;
694 LOperand* dividend() { return inputs_[0]; }
695 int32_t divisor() const { return divisor_; }
697 DECLARE_CONCRETE_INSTRUCTION(DivByPowerOf2I, "div-by-power-of-2-i")
698 DECLARE_HYDROGEN_ACCESSOR(Div)
705 class LDivByConstI FINAL : public LTemplateInstruction<1, 1, 2> {
707 LDivByConstI(LOperand* dividend,
711 inputs_[0] = dividend;
717 LOperand* dividend() { return inputs_[0]; }
718 int32_t divisor() const { return divisor_; }
719 LOperand* temp1() { return temps_[0]; }
720 LOperand* temp2() { return temps_[1]; }
722 DECLARE_CONCRETE_INSTRUCTION(DivByConstI, "div-by-const-i")
723 DECLARE_HYDROGEN_ACCESSOR(Div)
730 class LDivI FINAL : public LTemplateInstruction<1, 2, 1> {
732 LDivI(LOperand* dividend, LOperand* divisor, LOperand* temp) {
733 inputs_[0] = dividend;
734 inputs_[1] = divisor;
738 LOperand* dividend() { return inputs_[0]; }
739 LOperand* divisor() { return inputs_[1]; }
740 LOperand* temp() { return temps_[0]; }
742 DECLARE_CONCRETE_INSTRUCTION(DivI, "div-i")
743 DECLARE_HYDROGEN_ACCESSOR(BinaryOperation)
747 class LFlooringDivByPowerOf2I FINAL : public LTemplateInstruction<1, 1, 0> {
749 LFlooringDivByPowerOf2I(LOperand* dividend, int32_t divisor) {
750 inputs_[0] = dividend;
754 LOperand* dividend() { return inputs_[0]; }
755 int32_t divisor() const { return divisor_; }
757 DECLARE_CONCRETE_INSTRUCTION(FlooringDivByPowerOf2I,
758 "flooring-div-by-power-of-2-i")
759 DECLARE_HYDROGEN_ACCESSOR(MathFloorOfDiv)
766 class LFlooringDivByConstI FINAL : public LTemplateInstruction<1, 1, 3> {
768 LFlooringDivByConstI(LOperand* dividend,
773 inputs_[0] = dividend;
780 LOperand* dividend() { return inputs_[0]; }
781 int32_t divisor() const { return divisor_; }
782 LOperand* temp1() { return temps_[0]; }
783 LOperand* temp2() { return temps_[1]; }
784 LOperand* temp3() { return temps_[2]; }
786 DECLARE_CONCRETE_INSTRUCTION(FlooringDivByConstI, "flooring-div-by-const-i")
787 DECLARE_HYDROGEN_ACCESSOR(MathFloorOfDiv)
794 class LFlooringDivI FINAL : public LTemplateInstruction<1, 2, 1> {
796 LFlooringDivI(LOperand* dividend, LOperand* divisor, LOperand* temp) {
797 inputs_[0] = dividend;
798 inputs_[1] = divisor;
802 LOperand* dividend() { return inputs_[0]; }
803 LOperand* divisor() { return inputs_[1]; }
804 LOperand* temp() { return temps_[0]; }
806 DECLARE_CONCRETE_INSTRUCTION(FlooringDivI, "flooring-div-i")
807 DECLARE_HYDROGEN_ACCESSOR(MathFloorOfDiv)
811 class LMulI FINAL : public LTemplateInstruction<1, 2, 0> {
813 LMulI(LOperand* left, LOperand* right) {
818 LOperand* left() { return inputs_[0]; }
819 LOperand* right() { return inputs_[1]; }
821 DECLARE_CONCRETE_INSTRUCTION(MulI, "mul-i")
822 DECLARE_HYDROGEN_ACCESSOR(Mul)
826 class LCompareNumericAndBranch FINAL : public LControlInstruction<2, 0> {
828 LCompareNumericAndBranch(LOperand* left, LOperand* right) {
833 LOperand* left() { return inputs_[0]; }
834 LOperand* right() { return inputs_[1]; }
836 DECLARE_CONCRETE_INSTRUCTION(CompareNumericAndBranch,
837 "compare-numeric-and-branch")
838 DECLARE_HYDROGEN_ACCESSOR(CompareNumericAndBranch)
840 Token::Value op() const { return hydrogen()->token(); }
841 bool is_double() const {
842 return hydrogen()->representation().IsDouble();
845 void PrintDataTo(StringStream* stream) OVERRIDE;
849 class LMathFloor FINAL : public LTemplateInstruction<1, 1, 0> {
851 explicit LMathFloor(LOperand* value) {
855 LOperand* value() { return inputs_[0]; }
857 DECLARE_CONCRETE_INSTRUCTION(MathFloor, "math-floor")
858 DECLARE_HYDROGEN_ACCESSOR(UnaryMathOperation)
862 class LMathRound FINAL : public LTemplateInstruction<1, 1, 1> {
864 LMathRound(LOperand* value, LOperand* temp) {
869 LOperand* value() { return inputs_[0]; }
870 LOperand* temp() { return temps_[0]; }
872 DECLARE_CONCRETE_INSTRUCTION(MathRound, "math-round")
873 DECLARE_HYDROGEN_ACCESSOR(UnaryMathOperation)
877 class LMathFround FINAL : public LTemplateInstruction<1, 1, 0> {
879 explicit LMathFround(LOperand* value) { inputs_[0] = value; }
881 LOperand* value() { return inputs_[0]; }
883 DECLARE_CONCRETE_INSTRUCTION(MathFround, "math-fround")
887 class LMathAbs FINAL : public LTemplateInstruction<1, 2, 0> {
889 explicit LMathAbs(LOperand* context, LOperand* value) {
890 inputs_[1] = context;
894 LOperand* context() { return inputs_[1]; }
895 LOperand* value() { return inputs_[0]; }
897 DECLARE_CONCRETE_INSTRUCTION(MathAbs, "math-abs")
898 DECLARE_HYDROGEN_ACCESSOR(UnaryMathOperation)
902 class LMathLog FINAL : public LTemplateInstruction<1, 1, 0> {
904 explicit LMathLog(LOperand* value) {
908 LOperand* value() { return inputs_[0]; }
910 DECLARE_CONCRETE_INSTRUCTION(MathLog, "math-log")
914 class LMathClz32 FINAL : public LTemplateInstruction<1, 1, 0> {
916 explicit LMathClz32(LOperand* value) {
920 LOperand* value() { return inputs_[0]; }
922 DECLARE_CONCRETE_INSTRUCTION(MathClz32, "math-clz32")
926 class LMathExp FINAL : public LTemplateInstruction<1, 1, 2> {
928 LMathExp(LOperand* value, LOperand* temp1, LOperand* temp2) {
932 ExternalReference::InitializeMathExpData();
935 LOperand* value() { return inputs_[0]; }
936 LOperand* temp1() { return temps_[0]; }
937 LOperand* temp2() { return temps_[1]; }
939 DECLARE_CONCRETE_INSTRUCTION(MathExp, "math-exp")
943 class LMathSqrt FINAL : public LTemplateInstruction<1, 1, 0> {
945 explicit LMathSqrt(LOperand* value) {
949 LOperand* value() { return inputs_[0]; }
951 DECLARE_CONCRETE_INSTRUCTION(MathSqrt, "math-sqrt")
955 class LMathPowHalf FINAL : public LTemplateInstruction<1, 1, 0> {
957 explicit LMathPowHalf(LOperand* value) {
961 LOperand* value() { return inputs_[0]; }
963 DECLARE_CONCRETE_INSTRUCTION(MathPowHalf, "math-pow-half")
967 class LCmpObjectEqAndBranch FINAL : public LControlInstruction<2, 0> {
969 LCmpObjectEqAndBranch(LOperand* left, LOperand* right) {
974 LOperand* left() { return inputs_[0]; }
975 LOperand* right() { return inputs_[1]; }
977 DECLARE_CONCRETE_INSTRUCTION(CmpObjectEqAndBranch, "cmp-object-eq-and-branch")
981 class LCmpHoleAndBranch FINAL : public LControlInstruction<1, 0> {
983 explicit LCmpHoleAndBranch(LOperand* object) {
987 LOperand* object() { return inputs_[0]; }
989 DECLARE_CONCRETE_INSTRUCTION(CmpHoleAndBranch, "cmp-hole-and-branch")
990 DECLARE_HYDROGEN_ACCESSOR(CompareHoleAndBranch)
994 class LCompareMinusZeroAndBranch FINAL : public LControlInstruction<1, 0> {
996 explicit LCompareMinusZeroAndBranch(LOperand* value) {
1000 LOperand* value() { return inputs_[0]; }
1002 DECLARE_CONCRETE_INSTRUCTION(CompareMinusZeroAndBranch,
1003 "cmp-minus-zero-and-branch")
1004 DECLARE_HYDROGEN_ACCESSOR(CompareMinusZeroAndBranch)
1009 class LIsObjectAndBranch FINAL : public LControlInstruction<1, 0> {
1011 explicit LIsObjectAndBranch(LOperand* value) {
1015 LOperand* value() { return inputs_[0]; }
1017 DECLARE_CONCRETE_INSTRUCTION(IsObjectAndBranch, "is-object-and-branch")
1018 DECLARE_HYDROGEN_ACCESSOR(IsObjectAndBranch)
1020 void PrintDataTo(StringStream* stream) OVERRIDE;
1024 class LIsStringAndBranch FINAL : public LControlInstruction<1, 1> {
1026 explicit LIsStringAndBranch(LOperand* value, LOperand* temp) {
1031 LOperand* value() { return inputs_[0]; }
1032 LOperand* temp() { return temps_[0]; }
1034 DECLARE_CONCRETE_INSTRUCTION(IsStringAndBranch, "is-string-and-branch")
1035 DECLARE_HYDROGEN_ACCESSOR(IsStringAndBranch)
1037 void PrintDataTo(StringStream* stream) OVERRIDE;
1041 class LIsSmiAndBranch FINAL : public LControlInstruction<1, 0> {
1043 explicit LIsSmiAndBranch(LOperand* value) {
1047 LOperand* value() { return inputs_[0]; }
1049 DECLARE_CONCRETE_INSTRUCTION(IsSmiAndBranch, "is-smi-and-branch")
1050 DECLARE_HYDROGEN_ACCESSOR(IsSmiAndBranch)
1052 void PrintDataTo(StringStream* stream) OVERRIDE;
1056 class LIsUndetectableAndBranch FINAL : public LControlInstruction<1, 1> {
1058 explicit LIsUndetectableAndBranch(LOperand* value, LOperand* temp) {
1063 LOperand* value() { return inputs_[0]; }
1064 LOperand* temp() { return temps_[0]; }
1066 DECLARE_CONCRETE_INSTRUCTION(IsUndetectableAndBranch,
1067 "is-undetectable-and-branch")
1068 DECLARE_HYDROGEN_ACCESSOR(IsUndetectableAndBranch)
1070 void PrintDataTo(StringStream* stream) OVERRIDE;
1074 class LStringCompareAndBranch FINAL : public LControlInstruction<3, 0> {
1076 explicit LStringCompareAndBranch(LOperand* context,
1079 inputs_[0] = context;
1084 LOperand* context() { return inputs_[0]; }
1085 LOperand* left() { return inputs_[1]; }
1086 LOperand* right() { return inputs_[2]; }
1088 DECLARE_CONCRETE_INSTRUCTION(StringCompareAndBranch,
1089 "string-compare-and-branch")
1090 DECLARE_HYDROGEN_ACCESSOR(StringCompareAndBranch)
1092 void PrintDataTo(StringStream* stream) OVERRIDE;
1094 Token::Value op() const { return hydrogen()->token(); }
1098 class LHasInstanceTypeAndBranch FINAL : public LControlInstruction<1, 0> {
1100 explicit LHasInstanceTypeAndBranch(LOperand* value) {
1104 LOperand* value() { return inputs_[0]; }
1106 DECLARE_CONCRETE_INSTRUCTION(HasInstanceTypeAndBranch,
1107 "has-instance-type-and-branch")
1108 DECLARE_HYDROGEN_ACCESSOR(HasInstanceTypeAndBranch)
1110 void PrintDataTo(StringStream* stream) OVERRIDE;
1114 class LGetCachedArrayIndex FINAL : public LTemplateInstruction<1, 1, 0> {
1116 explicit LGetCachedArrayIndex(LOperand* value) {
1120 LOperand* value() { return inputs_[0]; }
1122 DECLARE_CONCRETE_INSTRUCTION(GetCachedArrayIndex, "get-cached-array-index")
1123 DECLARE_HYDROGEN_ACCESSOR(GetCachedArrayIndex)
1127 class LHasCachedArrayIndexAndBranch FINAL
1128 : public LControlInstruction<1, 0> {
1130 explicit LHasCachedArrayIndexAndBranch(LOperand* value) {
1134 LOperand* value() { return inputs_[0]; }
1136 DECLARE_CONCRETE_INSTRUCTION(HasCachedArrayIndexAndBranch,
1137 "has-cached-array-index-and-branch")
1138 DECLARE_HYDROGEN_ACCESSOR(HasCachedArrayIndexAndBranch)
1140 void PrintDataTo(StringStream* stream) OVERRIDE;
1144 class LClassOfTestAndBranch FINAL : public LControlInstruction<1, 2> {
1146 LClassOfTestAndBranch(LOperand* value, LOperand* temp, LOperand* temp2) {
1152 LOperand* value() { return inputs_[0]; }
1153 LOperand* temp() { return temps_[0]; }
1154 LOperand* temp2() { return temps_[1]; }
1156 DECLARE_CONCRETE_INSTRUCTION(ClassOfTestAndBranch,
1157 "class-of-test-and-branch")
1158 DECLARE_HYDROGEN_ACCESSOR(ClassOfTestAndBranch)
1160 void PrintDataTo(StringStream* stream) OVERRIDE;
1164 class LCmpT FINAL : public LTemplateInstruction<1, 3, 0> {
1166 LCmpT(LOperand* context, LOperand* left, LOperand* right) {
1167 inputs_[0] = context;
1172 LOperand* context() { return inputs_[0]; }
1173 LOperand* left() { return inputs_[1]; }
1174 LOperand* right() { return inputs_[2]; }
1176 DECLARE_CONCRETE_INSTRUCTION(CmpT, "cmp-t")
1177 DECLARE_HYDROGEN_ACCESSOR(CompareGeneric)
1179 Token::Value op() const { return hydrogen()->token(); }
1183 class LInstanceOf FINAL : public LTemplateInstruction<1, 3, 0> {
1185 LInstanceOf(LOperand* context, LOperand* left, LOperand* right) {
1186 inputs_[0] = context;
1191 LOperand* context() { return inputs_[0]; }
1192 LOperand* left() { return inputs_[1]; }
1193 LOperand* right() { return inputs_[2]; }
1195 DECLARE_CONCRETE_INSTRUCTION(InstanceOf, "instance-of")
1199 class LInstanceOfKnownGlobal FINAL : public LTemplateInstruction<1, 2, 1> {
1201 LInstanceOfKnownGlobal(LOperand* context, LOperand* value, LOperand* temp) {
1202 inputs_[0] = context;
1207 LOperand* context() { return inputs_[0]; }
1208 LOperand* value() { return inputs_[1]; }
1209 LOperand* temp() { return temps_[0]; }
1211 DECLARE_CONCRETE_INSTRUCTION(InstanceOfKnownGlobal,
1212 "instance-of-known-global")
1213 DECLARE_HYDROGEN_ACCESSOR(InstanceOfKnownGlobal)
1215 Handle<JSFunction> function() const { return hydrogen()->function(); }
1216 LEnvironment* GetDeferredLazyDeoptimizationEnvironment() {
1217 return lazy_deopt_env_;
1219 virtual void SetDeferredLazyDeoptimizationEnvironment(
1220 LEnvironment* env) OVERRIDE {
1221 lazy_deopt_env_ = env;
1225 LEnvironment* lazy_deopt_env_;
1229 class LBoundsCheck FINAL : public LTemplateInstruction<0, 2, 0> {
1231 LBoundsCheck(LOperand* index, LOperand* length) {
1233 inputs_[1] = length;
1236 LOperand* index() { return inputs_[0]; }
1237 LOperand* length() { return inputs_[1]; }
1239 DECLARE_CONCRETE_INSTRUCTION(BoundsCheck, "bounds-check")
1240 DECLARE_HYDROGEN_ACCESSOR(BoundsCheck)
1244 class LBitI FINAL : public LTemplateInstruction<1, 2, 0> {
1246 LBitI(LOperand* left, LOperand* right) {
1251 LOperand* left() { return inputs_[0]; }
1252 LOperand* right() { return inputs_[1]; }
1254 Token::Value op() const { return hydrogen()->op(); }
1255 bool IsInteger32() const {
1256 return hydrogen()->representation().IsInteger32();
1259 DECLARE_CONCRETE_INSTRUCTION(BitI, "bit-i")
1260 DECLARE_HYDROGEN_ACCESSOR(Bitwise)
1264 class LShiftI FINAL : public LTemplateInstruction<1, 2, 0> {
1266 LShiftI(Token::Value op, LOperand* left, LOperand* right, bool can_deopt)
1267 : op_(op), can_deopt_(can_deopt) {
1272 Token::Value op() const { return op_; }
1273 LOperand* left() { return inputs_[0]; }
1274 LOperand* right() { return inputs_[1]; }
1275 bool can_deopt() const { return can_deopt_; }
1277 DECLARE_CONCRETE_INSTRUCTION(ShiftI, "shift-i")
1285 class LSubI FINAL : public LTemplateInstruction<1, 2, 0> {
1287 LSubI(LOperand* left, LOperand* right) {
1292 LOperand* left() { return inputs_[0]; }
1293 LOperand* right() { return inputs_[1]; }
1295 DECLARE_CONCRETE_INSTRUCTION(SubI, "sub-i")
1296 DECLARE_HYDROGEN_ACCESSOR(Sub)
1300 class LConstantI FINAL : public LTemplateInstruction<1, 0, 0> {
1302 DECLARE_CONCRETE_INSTRUCTION(ConstantI, "constant-i")
1303 DECLARE_HYDROGEN_ACCESSOR(Constant)
1305 int32_t value() const { return hydrogen()->Integer32Value(); }
1309 class LConstantS FINAL : public LTemplateInstruction<1, 0, 0> {
1311 DECLARE_CONCRETE_INSTRUCTION(ConstantS, "constant-s")
1312 DECLARE_HYDROGEN_ACCESSOR(Constant)
1314 Smi* value() const { return Smi::FromInt(hydrogen()->Integer32Value()); }
1318 class LConstantD FINAL : public LTemplateInstruction<1, 0, 1> {
1320 explicit LConstantD(LOperand* temp) {
1324 LOperand* temp() { return temps_[0]; }
1326 DECLARE_CONCRETE_INSTRUCTION(ConstantD, "constant-d")
1327 DECLARE_HYDROGEN_ACCESSOR(Constant)
1329 double value() const { return hydrogen()->DoubleValue(); }
1333 class LConstantE FINAL : public LTemplateInstruction<1, 0, 0> {
1335 DECLARE_CONCRETE_INSTRUCTION(ConstantE, "constant-e")
1336 DECLARE_HYDROGEN_ACCESSOR(Constant)
1338 ExternalReference value() const {
1339 return hydrogen()->ExternalReferenceValue();
1344 class LConstantT FINAL : public LTemplateInstruction<1, 0, 0> {
1346 DECLARE_CONCRETE_INSTRUCTION(ConstantT, "constant-t")
1347 DECLARE_HYDROGEN_ACCESSOR(Constant)
1349 Handle<Object> value(Isolate* isolate) const {
1350 return hydrogen()->handle(isolate);
1355 class LBranch FINAL : public LControlInstruction<1, 0> {
1357 explicit LBranch(LOperand* value) {
1361 LOperand* value() { return inputs_[0]; }
1363 DECLARE_CONCRETE_INSTRUCTION(Branch, "branch")
1364 DECLARE_HYDROGEN_ACCESSOR(Branch)
1366 void PrintDataTo(StringStream* stream) OVERRIDE;
1370 class LDebugBreak FINAL : public LTemplateInstruction<0, 0, 0> {
1372 DECLARE_CONCRETE_INSTRUCTION(DebugBreak, "break")
1376 class LCmpMapAndBranch FINAL : public LControlInstruction<1, 0> {
1378 explicit LCmpMapAndBranch(LOperand* value) {
1382 LOperand* value() { return inputs_[0]; }
1384 DECLARE_CONCRETE_INSTRUCTION(CmpMapAndBranch, "cmp-map-and-branch")
1385 DECLARE_HYDROGEN_ACCESSOR(CompareMap)
1387 Handle<Map> map() const { return hydrogen()->map().handle(); }
1391 class LMapEnumLength FINAL : public LTemplateInstruction<1, 1, 0> {
1393 explicit LMapEnumLength(LOperand* value) {
1397 LOperand* value() { return inputs_[0]; }
1399 DECLARE_CONCRETE_INSTRUCTION(MapEnumLength, "map-enum-length")
1403 class LDateField FINAL : public LTemplateInstruction<1, 1, 0> {
1405 LDateField(LOperand* date, Smi* index) : index_(index) {
1409 LOperand* date() { return inputs_[0]; }
1410 Smi* index() const { return index_; }
1412 DECLARE_CONCRETE_INSTRUCTION(DateField, "date-field")
1413 DECLARE_HYDROGEN_ACCESSOR(DateField)
1420 class LSeqStringGetChar FINAL : public LTemplateInstruction<1, 2, 0> {
1422 LSeqStringGetChar(LOperand* string, LOperand* index) {
1423 inputs_[0] = string;
1427 LOperand* string() const { return inputs_[0]; }
1428 LOperand* index() const { return inputs_[1]; }
1430 DECLARE_CONCRETE_INSTRUCTION(SeqStringGetChar, "seq-string-get-char")
1431 DECLARE_HYDROGEN_ACCESSOR(SeqStringGetChar)
1435 class LSeqStringSetChar FINAL : public LTemplateInstruction<1, 4, 0> {
1437 LSeqStringSetChar(LOperand* context,
1441 inputs_[0] = context;
1442 inputs_[1] = string;
1447 LOperand* string() { return inputs_[1]; }
1448 LOperand* index() { return inputs_[2]; }
1449 LOperand* value() { return inputs_[3]; }
1451 DECLARE_CONCRETE_INSTRUCTION(SeqStringSetChar, "seq-string-set-char")
1452 DECLARE_HYDROGEN_ACCESSOR(SeqStringSetChar)
1456 class LAddI FINAL : public LTemplateInstruction<1, 2, 0> {
1458 LAddI(LOperand* left, LOperand* right) {
1463 LOperand* left() { return inputs_[0]; }
1464 LOperand* right() { return inputs_[1]; }
1466 static bool UseLea(HAdd* add) {
1467 return !add->CheckFlag(HValue::kCanOverflow) &&
1468 add->BetterLeftOperand()->UseCount() > 1;
1471 DECLARE_CONCRETE_INSTRUCTION(AddI, "add-i")
1472 DECLARE_HYDROGEN_ACCESSOR(Add)
1476 class LMathMinMax FINAL : public LTemplateInstruction<1, 2, 0> {
1478 LMathMinMax(LOperand* left, LOperand* right) {
1483 LOperand* left() { return inputs_[0]; }
1484 LOperand* right() { return inputs_[1]; }
1486 DECLARE_CONCRETE_INSTRUCTION(MathMinMax, "math-min-max")
1487 DECLARE_HYDROGEN_ACCESSOR(MathMinMax)
1491 class LPower FINAL : public LTemplateInstruction<1, 2, 0> {
1493 LPower(LOperand* left, LOperand* right) {
1498 LOperand* left() { return inputs_[0]; }
1499 LOperand* right() { return inputs_[1]; }
1501 DECLARE_CONCRETE_INSTRUCTION(Power, "power")
1502 DECLARE_HYDROGEN_ACCESSOR(Power)
1506 class LArithmeticD FINAL : public LTemplateInstruction<1, 2, 0> {
1508 LArithmeticD(Token::Value op, LOperand* left, LOperand* right)
1514 Token::Value op() const { return op_; }
1515 LOperand* left() { return inputs_[0]; }
1516 LOperand* right() { return inputs_[1]; }
1518 Opcode opcode() const OVERRIDE { return LInstruction::kArithmeticD; }
1519 void CompileToNative(LCodeGen* generator) OVERRIDE;
1520 const char* Mnemonic() const OVERRIDE;
1527 class LArithmeticT FINAL : public LTemplateInstruction<1, 3, 0> {
1529 LArithmeticT(Token::Value op,
1534 inputs_[0] = context;
1539 Token::Value op() const { return op_; }
1540 LOperand* context() { return inputs_[0]; }
1541 LOperand* left() { return inputs_[1]; }
1542 LOperand* right() { return inputs_[2]; }
1544 Opcode opcode() const OVERRIDE { return LInstruction::kArithmeticT; }
1545 void CompileToNative(LCodeGen* generator) OVERRIDE;
1546 const char* Mnemonic() const OVERRIDE;
1553 class LReturn FINAL : public LTemplateInstruction<0, 3, 0> {
1555 explicit LReturn(LOperand* value,
1557 LOperand* parameter_count) {
1559 inputs_[1] = context;
1560 inputs_[2] = parameter_count;
1563 LOperand* value() { return inputs_[0]; }
1564 LOperand* context() { return inputs_[1]; }
1566 bool has_constant_parameter_count() {
1567 return parameter_count()->IsConstantOperand();
1569 LConstantOperand* constant_parameter_count() {
1570 DCHECK(has_constant_parameter_count());
1571 return LConstantOperand::cast(parameter_count());
1573 LOperand* parameter_count() { return inputs_[2]; }
1575 DECLARE_CONCRETE_INSTRUCTION(Return, "return")
1576 DECLARE_HYDROGEN_ACCESSOR(Return)
1580 class LLoadNamedField FINAL : public LTemplateInstruction<1, 1, 0> {
1582 explicit LLoadNamedField(LOperand* object) {
1583 inputs_[0] = object;
1586 LOperand* object() { return inputs_[0]; }
1588 DECLARE_CONCRETE_INSTRUCTION(LoadNamedField, "load-named-field")
1589 DECLARE_HYDROGEN_ACCESSOR(LoadNamedField)
1593 class LLoadNamedGeneric FINAL : public LTemplateInstruction<1, 2, 1> {
1595 explicit LLoadNamedGeneric(LOperand* context, LOperand* object,
1597 inputs_[0] = context;
1598 inputs_[1] = object;
1602 DECLARE_CONCRETE_INSTRUCTION(LoadNamedGeneric, "load-named-generic")
1603 DECLARE_HYDROGEN_ACCESSOR(LoadNamedGeneric)
1605 LOperand* context() { return inputs_[0]; }
1606 LOperand* object() { return inputs_[1]; }
1607 LOperand* temp_vector() { return temps_[0]; }
1609 Handle<Object> name() const { return hydrogen()->name(); }
1613 class LLoadFunctionPrototype FINAL : public LTemplateInstruction<1, 1, 0> {
1615 explicit LLoadFunctionPrototype(LOperand* function) {
1616 inputs_[0] = function;
1619 DECLARE_CONCRETE_INSTRUCTION(LoadFunctionPrototype, "load-function-prototype")
1620 DECLARE_HYDROGEN_ACCESSOR(LoadFunctionPrototype)
1622 LOperand* function() { return inputs_[0]; }
1626 class LLoadRoot FINAL : public LTemplateInstruction<1, 0, 0> {
1628 DECLARE_CONCRETE_INSTRUCTION(LoadRoot, "load-root")
1629 DECLARE_HYDROGEN_ACCESSOR(LoadRoot)
1631 Heap::RootListIndex index() const { return hydrogen()->index(); }
1635 inline static bool ExternalArrayOpRequiresTemp(
1636 Representation key_representation,
1637 ElementsKind elements_kind) {
1638 // Operations that require the key to be divided by two to be converted into
1639 // an index cannot fold the scale operation into a load and need an extra
1640 // temp register to do the work.
1641 return SmiValuesAre31Bits() && key_representation.IsSmi() &&
1642 (elements_kind == EXTERNAL_INT8_ELEMENTS ||
1643 elements_kind == EXTERNAL_UINT8_ELEMENTS ||
1644 elements_kind == EXTERNAL_UINT8_CLAMPED_ELEMENTS ||
1645 elements_kind == UINT8_ELEMENTS ||
1646 elements_kind == INT8_ELEMENTS ||
1647 elements_kind == UINT8_CLAMPED_ELEMENTS);
1651 class LLoadKeyed FINAL : public LTemplateInstruction<1, 2, 0> {
1653 LLoadKeyed(LOperand* elements, LOperand* key) {
1654 inputs_[0] = elements;
1658 DECLARE_CONCRETE_INSTRUCTION(LoadKeyed, "load-keyed")
1659 DECLARE_HYDROGEN_ACCESSOR(LoadKeyed)
1661 bool is_external() const {
1662 return hydrogen()->is_external();
1664 bool is_fixed_typed_array() const {
1665 return hydrogen()->is_fixed_typed_array();
1667 bool is_typed_elements() const {
1668 return is_external() || is_fixed_typed_array();
1670 LOperand* elements() { return inputs_[0]; }
1671 LOperand* key() { return inputs_[1]; }
1672 void PrintDataTo(StringStream* stream) OVERRIDE;
1673 uint32_t base_offset() const { return hydrogen()->base_offset(); }
1674 ElementsKind elements_kind() const {
1675 return hydrogen()->elements_kind();
1680 class LLoadKeyedGeneric FINAL : public LTemplateInstruction<1, 3, 1> {
1682 LLoadKeyedGeneric(LOperand* context, LOperand* obj, LOperand* key,
1684 inputs_[0] = context;
1690 DECLARE_CONCRETE_INSTRUCTION(LoadKeyedGeneric, "load-keyed-generic")
1691 DECLARE_HYDROGEN_ACCESSOR(LoadKeyedGeneric)
1693 LOperand* context() { return inputs_[0]; }
1694 LOperand* object() { return inputs_[1]; }
1695 LOperand* key() { return inputs_[2]; }
1696 LOperand* temp_vector() { return temps_[0]; }
1700 class LLoadGlobalCell FINAL : public LTemplateInstruction<1, 0, 0> {
1702 DECLARE_CONCRETE_INSTRUCTION(LoadGlobalCell, "load-global-cell")
1703 DECLARE_HYDROGEN_ACCESSOR(LoadGlobalCell)
1707 class LLoadGlobalGeneric FINAL : public LTemplateInstruction<1, 2, 1> {
1709 explicit LLoadGlobalGeneric(LOperand* context, LOperand* global_object,
1711 inputs_[0] = context;
1712 inputs_[1] = global_object;
1716 DECLARE_CONCRETE_INSTRUCTION(LoadGlobalGeneric, "load-global-generic")
1717 DECLARE_HYDROGEN_ACCESSOR(LoadGlobalGeneric)
1719 LOperand* context() { return inputs_[0]; }
1720 LOperand* global_object() { return inputs_[1]; }
1721 LOperand* temp_vector() { return temps_[0]; }
1723 Handle<Object> name() const { return hydrogen()->name(); }
1724 bool for_typeof() const { return hydrogen()->for_typeof(); }
1728 class LStoreGlobalCell FINAL : public LTemplateInstruction<0, 1, 1> {
1730 explicit LStoreGlobalCell(LOperand* value, LOperand* temp) {
1735 LOperand* value() { return inputs_[0]; }
1736 LOperand* temp() { return temps_[0]; }
1738 DECLARE_CONCRETE_INSTRUCTION(StoreGlobalCell, "store-global-cell")
1739 DECLARE_HYDROGEN_ACCESSOR(StoreGlobalCell)
1743 class LLoadContextSlot FINAL : public LTemplateInstruction<1, 1, 0> {
1745 explicit LLoadContextSlot(LOperand* context) {
1746 inputs_[0] = context;
1749 LOperand* context() { return inputs_[0]; }
1751 DECLARE_CONCRETE_INSTRUCTION(LoadContextSlot, "load-context-slot")
1752 DECLARE_HYDROGEN_ACCESSOR(LoadContextSlot)
1754 int slot_index() { return hydrogen()->slot_index(); }
1756 void PrintDataTo(StringStream* stream) OVERRIDE;
1760 class LStoreContextSlot FINAL : public LTemplateInstruction<0, 2, 1> {
1762 LStoreContextSlot(LOperand* context, LOperand* value, LOperand* temp) {
1763 inputs_[0] = context;
1768 LOperand* context() { return inputs_[0]; }
1769 LOperand* value() { return inputs_[1]; }
1770 LOperand* temp() { return temps_[0]; }
1772 DECLARE_CONCRETE_INSTRUCTION(StoreContextSlot, "store-context-slot")
1773 DECLARE_HYDROGEN_ACCESSOR(StoreContextSlot)
1775 int slot_index() { return hydrogen()->slot_index(); }
1777 void PrintDataTo(StringStream* stream) OVERRIDE;
1781 class LPushArgument FINAL : public LTemplateInstruction<0, 1, 0> {
1783 explicit LPushArgument(LOperand* value) {
1787 LOperand* value() { return inputs_[0]; }
1789 DECLARE_CONCRETE_INSTRUCTION(PushArgument, "push-argument")
1793 class LDrop FINAL : public LTemplateInstruction<0, 0, 0> {
1795 explicit LDrop(int count) : count_(count) { }
1797 int count() const { return count_; }
1799 DECLARE_CONCRETE_INSTRUCTION(Drop, "drop")
1806 class LStoreCodeEntry FINAL: public LTemplateInstruction<0, 2, 0> {
1808 LStoreCodeEntry(LOperand* function, LOperand* code_object) {
1809 inputs_[0] = function;
1810 inputs_[1] = code_object;
1813 LOperand* function() { return inputs_[0]; }
1814 LOperand* code_object() { return inputs_[1]; }
1816 void PrintDataTo(StringStream* stream) OVERRIDE;
1818 DECLARE_CONCRETE_INSTRUCTION(StoreCodeEntry, "store-code-entry")
1819 DECLARE_HYDROGEN_ACCESSOR(StoreCodeEntry)
1823 class LInnerAllocatedObject FINAL: public LTemplateInstruction<1, 2, 0> {
1825 LInnerAllocatedObject(LOperand* base_object, LOperand* offset) {
1826 inputs_[0] = base_object;
1827 inputs_[1] = offset;
1830 LOperand* base_object() const { return inputs_[0]; }
1831 LOperand* offset() const { return inputs_[1]; }
1833 void PrintDataTo(StringStream* stream) OVERRIDE;
1835 DECLARE_CONCRETE_INSTRUCTION(InnerAllocatedObject, "inner-allocated-object")
1839 class LThisFunction FINAL : public LTemplateInstruction<1, 0, 0> {
1841 DECLARE_CONCRETE_INSTRUCTION(ThisFunction, "this-function")
1842 DECLARE_HYDROGEN_ACCESSOR(ThisFunction)
1846 class LContext FINAL : public LTemplateInstruction<1, 0, 0> {
1848 DECLARE_CONCRETE_INSTRUCTION(Context, "context")
1849 DECLARE_HYDROGEN_ACCESSOR(Context)
1853 class LDeclareGlobals FINAL : public LTemplateInstruction<0, 1, 0> {
1855 explicit LDeclareGlobals(LOperand* context) {
1856 inputs_[0] = context;
1859 LOperand* context() { return inputs_[0]; }
1861 DECLARE_CONCRETE_INSTRUCTION(DeclareGlobals, "declare-globals")
1862 DECLARE_HYDROGEN_ACCESSOR(DeclareGlobals)
1866 class LCallJSFunction FINAL : public LTemplateInstruction<1, 1, 0> {
1868 explicit LCallJSFunction(LOperand* function) {
1869 inputs_[0] = function;
1872 LOperand* function() { return inputs_[0]; }
1874 DECLARE_CONCRETE_INSTRUCTION(CallJSFunction, "call-js-function")
1875 DECLARE_HYDROGEN_ACCESSOR(CallJSFunction)
1877 void PrintDataTo(StringStream* stream) OVERRIDE;
1879 int arity() const { return hydrogen()->argument_count() - 1; }
1883 class LCallWithDescriptor FINAL : public LTemplateResultInstruction<1> {
1885 LCallWithDescriptor(CallInterfaceDescriptor descriptor,
1886 const ZoneList<LOperand*>& operands, Zone* zone)
1887 : inputs_(descriptor.GetRegisterParameterCount() + 1, zone) {
1888 DCHECK(descriptor.GetRegisterParameterCount() + 1 == operands.length());
1889 inputs_.AddAll(operands, zone);
1892 LOperand* target() const { return inputs_[0]; }
1894 DECLARE_HYDROGEN_ACCESSOR(CallWithDescriptor)
1897 DECLARE_CONCRETE_INSTRUCTION(CallWithDescriptor, "call-with-descriptor")
1899 void PrintDataTo(StringStream* stream) OVERRIDE;
1901 int arity() const { return hydrogen()->argument_count() - 1; }
1903 ZoneList<LOperand*> inputs_;
1905 // Iterator support.
1906 int InputCount() FINAL { return inputs_.length(); }
1907 LOperand* InputAt(int i) FINAL { return inputs_[i]; }
1909 int TempCount() FINAL { return 0; }
1910 LOperand* TempAt(int i) FINAL { return NULL; }
1914 class LInvokeFunction FINAL : public LTemplateInstruction<1, 2, 0> {
1916 LInvokeFunction(LOperand* context, LOperand* function) {
1917 inputs_[0] = context;
1918 inputs_[1] = function;
1921 LOperand* context() { return inputs_[0]; }
1922 LOperand* function() { return inputs_[1]; }
1924 DECLARE_CONCRETE_INSTRUCTION(InvokeFunction, "invoke-function")
1925 DECLARE_HYDROGEN_ACCESSOR(InvokeFunction)
1927 void PrintDataTo(StringStream* stream) OVERRIDE;
1929 int arity() const { return hydrogen()->argument_count() - 1; }
1933 class LCallFunction FINAL : public LTemplateInstruction<1, 2, 0> {
1935 LCallFunction(LOperand* context, LOperand* function) {
1936 inputs_[0] = context;
1937 inputs_[1] = function;
1940 DECLARE_CONCRETE_INSTRUCTION(CallFunction, "call-function")
1941 DECLARE_HYDROGEN_ACCESSOR(CallFunction)
1943 LOperand* context() { return inputs_[0]; }
1944 LOperand* function() { return inputs_[1]; }
1945 int arity() const { return hydrogen()->argument_count() - 1; }
1949 class LCallNew FINAL : public LTemplateInstruction<1, 2, 0> {
1951 LCallNew(LOperand* context, LOperand* constructor) {
1952 inputs_[0] = context;
1953 inputs_[1] = constructor;
1956 LOperand* context() { return inputs_[0]; }
1957 LOperand* constructor() { return inputs_[1]; }
1959 DECLARE_CONCRETE_INSTRUCTION(CallNew, "call-new")
1960 DECLARE_HYDROGEN_ACCESSOR(CallNew)
1962 void PrintDataTo(StringStream* stream) OVERRIDE;
1964 int arity() const { return hydrogen()->argument_count() - 1; }
1968 class LCallNewArray FINAL : public LTemplateInstruction<1, 2, 0> {
1970 LCallNewArray(LOperand* context, LOperand* constructor) {
1971 inputs_[0] = context;
1972 inputs_[1] = constructor;
1975 LOperand* context() { return inputs_[0]; }
1976 LOperand* constructor() { return inputs_[1]; }
1978 DECLARE_CONCRETE_INSTRUCTION(CallNewArray, "call-new-array")
1979 DECLARE_HYDROGEN_ACCESSOR(CallNewArray)
1981 void PrintDataTo(StringStream* stream) OVERRIDE;
1983 int arity() const { return hydrogen()->argument_count() - 1; }
1987 class LCallRuntime FINAL : public LTemplateInstruction<1, 1, 0> {
1989 explicit LCallRuntime(LOperand* context) {
1990 inputs_[0] = context;
1993 LOperand* context() { return inputs_[0]; }
1995 DECLARE_CONCRETE_INSTRUCTION(CallRuntime, "call-runtime")
1996 DECLARE_HYDROGEN_ACCESSOR(CallRuntime)
1998 bool ClobbersDoubleRegisters(Isolate* isolate) const OVERRIDE {
1999 return save_doubles() == kDontSaveFPRegs;
2002 const Runtime::Function* function() const { return hydrogen()->function(); }
2003 int arity() const { return hydrogen()->argument_count(); }
2004 SaveFPRegsMode save_doubles() const { return hydrogen()->save_doubles(); }
2008 class LInteger32ToDouble FINAL : public LTemplateInstruction<1, 1, 0> {
2010 explicit LInteger32ToDouble(LOperand* value) {
2014 LOperand* value() { return inputs_[0]; }
2016 DECLARE_CONCRETE_INSTRUCTION(Integer32ToDouble, "int32-to-double")
2020 class LUint32ToDouble FINAL : public LTemplateInstruction<1, 1, 0> {
2022 explicit LUint32ToDouble(LOperand* value) {
2026 LOperand* value() { return inputs_[0]; }
2028 DECLARE_CONCRETE_INSTRUCTION(Uint32ToDouble, "uint32-to-double")
2032 class LNumberTagI FINAL : public LTemplateInstruction<1, 1, 2> {
2034 LNumberTagI(LOperand* value, LOperand* temp1, LOperand* temp2) {
2040 LOperand* value() { return inputs_[0]; }
2041 LOperand* temp1() { return temps_[0]; }
2042 LOperand* temp2() { return temps_[1]; }
2044 DECLARE_CONCRETE_INSTRUCTION(NumberTagI, "number-tag-i")
2048 class LNumberTagU FINAL : public LTemplateInstruction<1, 1, 2> {
2050 LNumberTagU(LOperand* value, LOperand* temp1, LOperand* temp2) {
2056 LOperand* value() { return inputs_[0]; }
2057 LOperand* temp1() { return temps_[0]; }
2058 LOperand* temp2() { return temps_[1]; }
2060 DECLARE_CONCRETE_INSTRUCTION(NumberTagU, "number-tag-u")
2064 class LNumberTagD FINAL : public LTemplateInstruction<1, 1, 1> {
2066 explicit LNumberTagD(LOperand* value, LOperand* temp) {
2071 LOperand* value() { return inputs_[0]; }
2072 LOperand* temp() { return temps_[0]; }
2074 DECLARE_CONCRETE_INSTRUCTION(NumberTagD, "number-tag-d")
2075 DECLARE_HYDROGEN_ACCESSOR(Change)
2079 // Sometimes truncating conversion from a tagged value to an int32.
2080 class LDoubleToI FINAL : public LTemplateInstruction<1, 1, 0> {
2082 explicit LDoubleToI(LOperand* value) {
2086 LOperand* value() { return inputs_[0]; }
2088 DECLARE_CONCRETE_INSTRUCTION(DoubleToI, "double-to-i")
2089 DECLARE_HYDROGEN_ACCESSOR(UnaryOperation)
2091 bool truncating() { return hydrogen()->CanTruncateToInt32(); }
2095 class LDoubleToSmi FINAL : public LTemplateInstruction<1, 1, 0> {
2097 explicit LDoubleToSmi(LOperand* value) {
2101 LOperand* value() { return inputs_[0]; }
2103 DECLARE_CONCRETE_INSTRUCTION(DoubleToSmi, "double-to-smi")
2104 DECLARE_HYDROGEN_ACCESSOR(UnaryOperation)
2108 // Truncating conversion from a tagged value to an int32.
2109 class LTaggedToI FINAL : public LTemplateInstruction<1, 1, 1> {
2111 LTaggedToI(LOperand* value, LOperand* temp) {
2116 LOperand* value() { return inputs_[0]; }
2117 LOperand* temp() { return temps_[0]; }
2119 DECLARE_CONCRETE_INSTRUCTION(TaggedToI, "tagged-to-i")
2120 DECLARE_HYDROGEN_ACCESSOR(Change)
2122 bool truncating() { return hydrogen()->CanTruncateToInt32(); }
2126 class LSmiTag FINAL : public LTemplateInstruction<1, 1, 0> {
2128 explicit LSmiTag(LOperand* value) {
2132 LOperand* value() { return inputs_[0]; }
2134 DECLARE_CONCRETE_INSTRUCTION(SmiTag, "smi-tag")
2135 DECLARE_HYDROGEN_ACCESSOR(Change)
2139 class LNumberUntagD FINAL : public LTemplateInstruction<1, 1, 0> {
2141 explicit LNumberUntagD(LOperand* value) {
2145 LOperand* value() { return inputs_[0]; }
2147 DECLARE_CONCRETE_INSTRUCTION(NumberUntagD, "double-untag")
2148 DECLARE_HYDROGEN_ACCESSOR(Change);
2152 class LSmiUntag FINAL : public LTemplateInstruction<1, 1, 0> {
2154 LSmiUntag(LOperand* value, bool needs_check)
2155 : needs_check_(needs_check) {
2159 LOperand* value() { return inputs_[0]; }
2160 bool needs_check() const { return needs_check_; }
2162 DECLARE_CONCRETE_INSTRUCTION(SmiUntag, "smi-untag")
2169 class LStoreNamedField FINAL : public LTemplateInstruction<0, 2, 1> {
2171 LStoreNamedField(LOperand* object, LOperand* value, LOperand* temp) {
2172 inputs_[0] = object;
2177 LOperand* object() { return inputs_[0]; }
2178 LOperand* value() { return inputs_[1]; }
2179 LOperand* temp() { return temps_[0]; }
2181 DECLARE_CONCRETE_INSTRUCTION(StoreNamedField, "store-named-field")
2182 DECLARE_HYDROGEN_ACCESSOR(StoreNamedField)
2184 void PrintDataTo(StringStream* stream) OVERRIDE;
2186 Representation representation() const {
2187 return hydrogen()->field_representation();
2192 class LStoreNamedGeneric FINAL : public LTemplateInstruction<0, 3, 0> {
2194 LStoreNamedGeneric(LOperand* context, LOperand* object, LOperand* value) {
2195 inputs_[0] = context;
2196 inputs_[1] = object;
2200 LOperand* context() { return inputs_[0]; }
2201 LOperand* object() { return inputs_[1]; }
2202 LOperand* value() { return inputs_[2]; }
2204 DECLARE_CONCRETE_INSTRUCTION(StoreNamedGeneric, "store-named-generic")
2205 DECLARE_HYDROGEN_ACCESSOR(StoreNamedGeneric)
2207 void PrintDataTo(StringStream* stream) OVERRIDE;
2209 Handle<Object> name() const { return hydrogen()->name(); }
2210 StrictMode strict_mode() { return hydrogen()->strict_mode(); }
2214 class LStoreKeyed FINAL : public LTemplateInstruction<0, 3, 0> {
2216 LStoreKeyed(LOperand* object, LOperand* key, LOperand* value) {
2217 inputs_[0] = object;
2222 bool is_external() const { return hydrogen()->is_external(); }
2223 bool is_fixed_typed_array() const {
2224 return hydrogen()->is_fixed_typed_array();
2226 bool is_typed_elements() const {
2227 return is_external() || is_fixed_typed_array();
2229 LOperand* elements() { return inputs_[0]; }
2230 LOperand* key() { return inputs_[1]; }
2231 LOperand* value() { return inputs_[2]; }
2232 ElementsKind elements_kind() const { return hydrogen()->elements_kind(); }
2234 DECLARE_CONCRETE_INSTRUCTION(StoreKeyed, "store-keyed")
2235 DECLARE_HYDROGEN_ACCESSOR(StoreKeyed)
2237 void PrintDataTo(StringStream* stream) OVERRIDE;
2238 bool NeedsCanonicalization() { return hydrogen()->NeedsCanonicalization(); }
2239 uint32_t base_offset() const { return hydrogen()->base_offset(); }
2243 class LStoreKeyedGeneric FINAL : public LTemplateInstruction<0, 4, 0> {
2245 LStoreKeyedGeneric(LOperand* context,
2249 inputs_[0] = context;
2250 inputs_[1] = object;
2255 LOperand* context() { return inputs_[0]; }
2256 LOperand* object() { return inputs_[1]; }
2257 LOperand* key() { return inputs_[2]; }
2258 LOperand* value() { return inputs_[3]; }
2260 DECLARE_CONCRETE_INSTRUCTION(StoreKeyedGeneric, "store-keyed-generic")
2261 DECLARE_HYDROGEN_ACCESSOR(StoreKeyedGeneric)
2263 void PrintDataTo(StringStream* stream) OVERRIDE;
2265 StrictMode strict_mode() { return hydrogen()->strict_mode(); }
2269 class LTransitionElementsKind FINAL : public LTemplateInstruction<0, 2, 2> {
2271 LTransitionElementsKind(LOperand* object,
2273 LOperand* new_map_temp,
2275 inputs_[0] = object;
2276 inputs_[1] = context;
2277 temps_[0] = new_map_temp;
2281 LOperand* object() { return inputs_[0]; }
2282 LOperand* context() { return inputs_[1]; }
2283 LOperand* new_map_temp() { return temps_[0]; }
2284 LOperand* temp() { return temps_[1]; }
2286 DECLARE_CONCRETE_INSTRUCTION(TransitionElementsKind,
2287 "transition-elements-kind")
2288 DECLARE_HYDROGEN_ACCESSOR(TransitionElementsKind)
2290 void PrintDataTo(StringStream* stream) OVERRIDE;
2292 Handle<Map> original_map() { return hydrogen()->original_map().handle(); }
2293 Handle<Map> transitioned_map() {
2294 return hydrogen()->transitioned_map().handle();
2296 ElementsKind from_kind() { return hydrogen()->from_kind(); }
2297 ElementsKind to_kind() { return hydrogen()->to_kind(); }
2301 class LTrapAllocationMemento FINAL : public LTemplateInstruction<0, 1, 1> {
2303 LTrapAllocationMemento(LOperand* object,
2305 inputs_[0] = object;
2309 LOperand* object() { return inputs_[0]; }
2310 LOperand* temp() { return temps_[0]; }
2312 DECLARE_CONCRETE_INSTRUCTION(TrapAllocationMemento,
2313 "trap-allocation-memento")
2317 class LStringAdd FINAL : public LTemplateInstruction<1, 3, 0> {
2319 LStringAdd(LOperand* context, LOperand* left, LOperand* right) {
2320 inputs_[0] = context;
2325 LOperand* context() { return inputs_[0]; }
2326 LOperand* left() { return inputs_[1]; }
2327 LOperand* right() { return inputs_[2]; }
2329 DECLARE_CONCRETE_INSTRUCTION(StringAdd, "string-add")
2330 DECLARE_HYDROGEN_ACCESSOR(StringAdd)
2334 class LStringCharCodeAt FINAL : public LTemplateInstruction<1, 3, 0> {
2336 LStringCharCodeAt(LOperand* context, LOperand* string, LOperand* index) {
2337 inputs_[0] = context;
2338 inputs_[1] = string;
2342 LOperand* context() { return inputs_[0]; }
2343 LOperand* string() { return inputs_[1]; }
2344 LOperand* index() { return inputs_[2]; }
2346 DECLARE_CONCRETE_INSTRUCTION(StringCharCodeAt, "string-char-code-at")
2347 DECLARE_HYDROGEN_ACCESSOR(StringCharCodeAt)
2351 class LStringCharFromCode FINAL : public LTemplateInstruction<1, 2, 0> {
2353 explicit LStringCharFromCode(LOperand* context, LOperand* char_code) {
2354 inputs_[0] = context;
2355 inputs_[1] = char_code;
2358 LOperand* context() { return inputs_[0]; }
2359 LOperand* char_code() { return inputs_[1]; }
2361 DECLARE_CONCRETE_INSTRUCTION(StringCharFromCode, "string-char-from-code")
2362 DECLARE_HYDROGEN_ACCESSOR(StringCharFromCode)
2366 class LCheckValue FINAL : public LTemplateInstruction<0, 1, 0> {
2368 explicit LCheckValue(LOperand* value) {
2372 LOperand* value() { return inputs_[0]; }
2374 DECLARE_CONCRETE_INSTRUCTION(CheckValue, "check-value")
2375 DECLARE_HYDROGEN_ACCESSOR(CheckValue)
2379 class LCheckInstanceType FINAL : public LTemplateInstruction<0, 1, 0> {
2381 explicit LCheckInstanceType(LOperand* value) {
2385 LOperand* value() { return inputs_[0]; }
2387 DECLARE_CONCRETE_INSTRUCTION(CheckInstanceType, "check-instance-type")
2388 DECLARE_HYDROGEN_ACCESSOR(CheckInstanceType)
2392 class LCheckMaps FINAL : public LTemplateInstruction<0, 1, 0> {
2394 explicit LCheckMaps(LOperand* value = NULL) {
2398 LOperand* value() { return inputs_[0]; }
2400 DECLARE_CONCRETE_INSTRUCTION(CheckMaps, "check-maps")
2401 DECLARE_HYDROGEN_ACCESSOR(CheckMaps)
2405 class LCheckSmi FINAL : public LTemplateInstruction<1, 1, 0> {
2407 explicit LCheckSmi(LOperand* value) {
2411 LOperand* value() { return inputs_[0]; }
2413 DECLARE_CONCRETE_INSTRUCTION(CheckSmi, "check-smi")
2417 class LClampDToUint8 FINAL : public LTemplateInstruction<1, 1, 0> {
2419 explicit LClampDToUint8(LOperand* unclamped) {
2420 inputs_[0] = unclamped;
2423 LOperand* unclamped() { return inputs_[0]; }
2425 DECLARE_CONCRETE_INSTRUCTION(ClampDToUint8, "clamp-d-to-uint8")
2429 class LClampIToUint8 FINAL : public LTemplateInstruction<1, 1, 0> {
2431 explicit LClampIToUint8(LOperand* unclamped) {
2432 inputs_[0] = unclamped;
2435 LOperand* unclamped() { return inputs_[0]; }
2437 DECLARE_CONCRETE_INSTRUCTION(ClampIToUint8, "clamp-i-to-uint8")
2441 class LClampTToUint8 FINAL : public LTemplateInstruction<1, 1, 1> {
2443 LClampTToUint8(LOperand* unclamped,
2444 LOperand* temp_xmm) {
2445 inputs_[0] = unclamped;
2446 temps_[0] = temp_xmm;
2449 LOperand* unclamped() { return inputs_[0]; }
2450 LOperand* temp_xmm() { return temps_[0]; }
2452 DECLARE_CONCRETE_INSTRUCTION(ClampTToUint8, "clamp-t-to-uint8")
2456 class LCheckNonSmi FINAL : public LTemplateInstruction<0, 1, 0> {
2458 explicit LCheckNonSmi(LOperand* value) {
2462 LOperand* value() { return inputs_[0]; }
2464 DECLARE_CONCRETE_INSTRUCTION(CheckNonSmi, "check-non-smi")
2465 DECLARE_HYDROGEN_ACCESSOR(CheckHeapObject)
2469 class LDoubleBits FINAL : public LTemplateInstruction<1, 1, 0> {
2471 explicit LDoubleBits(LOperand* value) {
2475 LOperand* value() { return inputs_[0]; }
2477 DECLARE_CONCRETE_INSTRUCTION(DoubleBits, "double-bits")
2478 DECLARE_HYDROGEN_ACCESSOR(DoubleBits)
2482 class LConstructDouble FINAL : public LTemplateInstruction<1, 2, 0> {
2484 LConstructDouble(LOperand* hi, LOperand* lo) {
2489 LOperand* hi() { return inputs_[0]; }
2490 LOperand* lo() { return inputs_[1]; }
2492 DECLARE_CONCRETE_INSTRUCTION(ConstructDouble, "construct-double")
2496 class LAllocate FINAL : public LTemplateInstruction<1, 2, 1> {
2498 LAllocate(LOperand* context, LOperand* size, LOperand* temp) {
2499 inputs_[0] = context;
2504 LOperand* context() { return inputs_[0]; }
2505 LOperand* size() { return inputs_[1]; }
2506 LOperand* temp() { return temps_[0]; }
2508 DECLARE_CONCRETE_INSTRUCTION(Allocate, "allocate")
2509 DECLARE_HYDROGEN_ACCESSOR(Allocate)
2513 class LRegExpLiteral FINAL : public LTemplateInstruction<1, 1, 0> {
2515 explicit LRegExpLiteral(LOperand* context) {
2516 inputs_[0] = context;
2519 LOperand* context() { return inputs_[0]; }
2521 DECLARE_CONCRETE_INSTRUCTION(RegExpLiteral, "regexp-literal")
2522 DECLARE_HYDROGEN_ACCESSOR(RegExpLiteral)
2526 class LFunctionLiteral FINAL : public LTemplateInstruction<1, 1, 0> {
2528 explicit LFunctionLiteral(LOperand* context) {
2529 inputs_[0] = context;
2532 LOperand* context() { return inputs_[0]; }
2534 DECLARE_CONCRETE_INSTRUCTION(FunctionLiteral, "function-literal")
2535 DECLARE_HYDROGEN_ACCESSOR(FunctionLiteral)
2539 class LToFastProperties FINAL : public LTemplateInstruction<1, 1, 0> {
2541 explicit LToFastProperties(LOperand* value) {
2545 LOperand* value() { return inputs_[0]; }
2547 DECLARE_CONCRETE_INSTRUCTION(ToFastProperties, "to-fast-properties")
2548 DECLARE_HYDROGEN_ACCESSOR(ToFastProperties)
2552 class LTypeof FINAL : public LTemplateInstruction<1, 2, 0> {
2554 LTypeof(LOperand* context, LOperand* value) {
2555 inputs_[0] = context;
2559 LOperand* context() { return inputs_[0]; }
2560 LOperand* value() { return inputs_[1]; }
2562 DECLARE_CONCRETE_INSTRUCTION(Typeof, "typeof")
2566 class LTypeofIsAndBranch FINAL : public LControlInstruction<1, 0> {
2568 explicit LTypeofIsAndBranch(LOperand* value) {
2572 LOperand* value() { return inputs_[0]; }
2574 DECLARE_CONCRETE_INSTRUCTION(TypeofIsAndBranch, "typeof-is-and-branch")
2575 DECLARE_HYDROGEN_ACCESSOR(TypeofIsAndBranch)
2577 Handle<String> type_literal() { return hydrogen()->type_literal(); }
2579 void PrintDataTo(StringStream* stream) OVERRIDE;
2583 class LIsConstructCallAndBranch FINAL : public LControlInstruction<0, 1> {
2585 explicit LIsConstructCallAndBranch(LOperand* temp) {
2589 LOperand* temp() { return temps_[0]; }
2591 DECLARE_CONCRETE_INSTRUCTION(IsConstructCallAndBranch,
2592 "is-construct-call-and-branch")
2593 DECLARE_HYDROGEN_ACCESSOR(IsConstructCallAndBranch)
2597 class LOsrEntry FINAL : public LTemplateInstruction<0, 0, 0> {
2601 bool HasInterestingComment(LCodeGen* gen) const OVERRIDE { return false; }
2602 DECLARE_CONCRETE_INSTRUCTION(OsrEntry, "osr-entry")
2606 class LStackCheck FINAL : public LTemplateInstruction<0, 1, 0> {
2608 explicit LStackCheck(LOperand* context) {
2609 inputs_[0] = context;
2612 LOperand* context() { return inputs_[0]; }
2614 DECLARE_CONCRETE_INSTRUCTION(StackCheck, "stack-check")
2615 DECLARE_HYDROGEN_ACCESSOR(StackCheck)
2617 Label* done_label() { return &done_label_; }
2624 class LForInPrepareMap FINAL : public LTemplateInstruction<1, 2, 0> {
2626 LForInPrepareMap(LOperand* context, LOperand* object) {
2627 inputs_[0] = context;
2628 inputs_[1] = object;
2631 LOperand* context() { return inputs_[0]; }
2632 LOperand* object() { return inputs_[1]; }
2634 DECLARE_CONCRETE_INSTRUCTION(ForInPrepareMap, "for-in-prepare-map")
2638 class LForInCacheArray FINAL : public LTemplateInstruction<1, 1, 0> {
2640 explicit LForInCacheArray(LOperand* map) {
2644 LOperand* map() { return inputs_[0]; }
2646 DECLARE_CONCRETE_INSTRUCTION(ForInCacheArray, "for-in-cache-array")
2649 return HForInCacheArray::cast(this->hydrogen_value())->idx();
2654 class LCheckMapValue FINAL : public LTemplateInstruction<0, 2, 0> {
2656 LCheckMapValue(LOperand* value, LOperand* map) {
2661 LOperand* value() { return inputs_[0]; }
2662 LOperand* map() { return inputs_[1]; }
2664 DECLARE_CONCRETE_INSTRUCTION(CheckMapValue, "check-map-value")
2668 class LLoadFieldByIndex FINAL : public LTemplateInstruction<1, 2, 0> {
2670 LLoadFieldByIndex(LOperand* object, LOperand* index) {
2671 inputs_[0] = object;
2675 LOperand* object() { return inputs_[0]; }
2676 LOperand* index() { return inputs_[1]; }
2678 DECLARE_CONCRETE_INSTRUCTION(LoadFieldByIndex, "load-field-by-index")
2682 class LStoreFrameContext: public LTemplateInstruction<0, 1, 0> {
2684 explicit LStoreFrameContext(LOperand* context) {
2685 inputs_[0] = context;
2688 LOperand* context() { return inputs_[0]; }
2690 DECLARE_CONCRETE_INSTRUCTION(StoreFrameContext, "store-frame-context")
2694 class LAllocateBlockContext: public LTemplateInstruction<1, 2, 0> {
2696 LAllocateBlockContext(LOperand* context, LOperand* function) {
2697 inputs_[0] = context;
2698 inputs_[1] = function;
2701 LOperand* context() { return inputs_[0]; }
2702 LOperand* function() { return inputs_[1]; }
2704 Handle<ScopeInfo> scope_info() { return hydrogen()->scope_info(); }
2706 DECLARE_CONCRETE_INSTRUCTION(AllocateBlockContext, "allocate-block-context")
2707 DECLARE_HYDROGEN_ACCESSOR(AllocateBlockContext)
2711 class LChunkBuilder;
2712 class LPlatformChunk FINAL : public LChunk {
2714 LPlatformChunk(CompilationInfo* info, HGraph* graph)
2715 : LChunk(info, graph),
2716 dehoisted_key_ids_(graph->GetMaximumValueID(), graph->zone()) { }
2718 int GetNextSpillIndex(RegisterKind kind);
2719 LOperand* GetNextSpillSlot(RegisterKind kind);
2720 BitVector* GetDehoistedKeyIds() { return &dehoisted_key_ids_; }
2721 bool IsDehoistedKey(HValue* value) {
2722 return dehoisted_key_ids_.Contains(value->id());
2726 BitVector dehoisted_key_ids_;
2730 class LChunkBuilder FINAL : public LChunkBuilderBase {
2732 LChunkBuilder(CompilationInfo* info, HGraph* graph, LAllocator* allocator)
2733 : LChunkBuilderBase(info, graph),
2734 current_instruction_(NULL),
2735 current_block_(NULL),
2737 allocator_(allocator) {}
2739 // Build the sequence for the graph.
2740 LPlatformChunk* Build();
2742 // Declare methods that deal with the individual node types.
2743 #define DECLARE_DO(type) LInstruction* Do##type(H##type* node);
2744 HYDROGEN_CONCRETE_INSTRUCTION_LIST(DECLARE_DO)
2747 LInstruction* DoMathFloor(HUnaryMathOperation* instr);
2748 LInstruction* DoMathRound(HUnaryMathOperation* instr);
2749 LInstruction* DoMathFround(HUnaryMathOperation* instr);
2750 LInstruction* DoMathAbs(HUnaryMathOperation* instr);
2751 LInstruction* DoMathLog(HUnaryMathOperation* instr);
2752 LInstruction* DoMathExp(HUnaryMathOperation* instr);
2753 LInstruction* DoMathSqrt(HUnaryMathOperation* instr);
2754 LInstruction* DoMathPowHalf(HUnaryMathOperation* instr);
2755 LInstruction* DoMathClz32(HUnaryMathOperation* instr);
2756 LInstruction* DoDivByPowerOf2I(HDiv* instr);
2757 LInstruction* DoDivByConstI(HDiv* instr);
2758 LInstruction* DoDivI(HDiv* instr);
2759 LInstruction* DoModByPowerOf2I(HMod* instr);
2760 LInstruction* DoModByConstI(HMod* instr);
2761 LInstruction* DoModI(HMod* instr);
2762 LInstruction* DoFlooringDivByPowerOf2I(HMathFloorOfDiv* instr);
2763 LInstruction* DoFlooringDivByConstI(HMathFloorOfDiv* instr);
2764 LInstruction* DoFlooringDivI(HMathFloorOfDiv* instr);
2767 // Methods for getting operands for Use / Define / Temp.
2768 LUnallocated* ToUnallocated(Register reg);
2769 LUnallocated* ToUnallocated(XMMRegister reg);
2771 // Methods for setting up define-use relationships.
2772 MUST_USE_RESULT LOperand* Use(HValue* value, LUnallocated* operand);
2773 MUST_USE_RESULT LOperand* UseFixed(HValue* value, Register fixed_register);
2774 MUST_USE_RESULT LOperand* UseFixedDouble(HValue* value,
2775 XMMRegister fixed_register);
2777 // A value that is guaranteed to be allocated to a register.
2778 // Operand created by UseRegister is guaranteed to be live until the end of
2779 // instruction. This means that register allocator will not reuse it's
2780 // register for any other operand inside instruction.
2781 // Operand created by UseRegisterAtStart is guaranteed to be live only at
2782 // instruction start. Register allocator is free to assign the same register
2783 // to some other operand used inside instruction (i.e. temporary or
2785 MUST_USE_RESULT LOperand* UseRegister(HValue* value);
2786 MUST_USE_RESULT LOperand* UseRegisterAtStart(HValue* value);
2788 // An input operand in a register that may be trashed.
2789 MUST_USE_RESULT LOperand* UseTempRegister(HValue* value);
2791 // An input operand in a register that may be trashed or a constant operand.
2792 MUST_USE_RESULT LOperand* UseTempRegisterOrConstant(HValue* value);
2794 // An input operand in a register or stack slot.
2795 MUST_USE_RESULT LOperand* Use(HValue* value);
2796 MUST_USE_RESULT LOperand* UseAtStart(HValue* value);
2798 // An input operand in a register, stack slot or a constant operand.
2799 MUST_USE_RESULT LOperand* UseOrConstant(HValue* value);
2800 MUST_USE_RESULT LOperand* UseOrConstantAtStart(HValue* value);
2802 // An input operand in a register or a constant operand.
2803 MUST_USE_RESULT LOperand* UseRegisterOrConstant(HValue* value);
2804 MUST_USE_RESULT LOperand* UseRegisterOrConstantAtStart(HValue* value);
2806 // An input operand in a constant operand.
2807 MUST_USE_RESULT LOperand* UseConstant(HValue* value);
2809 // An input operand in register, stack slot or a constant operand.
2810 // Will not be moved to a register even if one is freely available.
2811 MUST_USE_RESULT LOperand* UseAny(HValue* value) OVERRIDE;
2813 // Temporary operand that must be in a register.
2814 MUST_USE_RESULT LUnallocated* TempRegister();
2815 MUST_USE_RESULT LOperand* FixedTemp(Register reg);
2816 MUST_USE_RESULT LOperand* FixedTemp(XMMRegister reg);
2818 // Methods for setting up define-use relationships.
2819 // Return the same instruction that they are passed.
2820 LInstruction* Define(LTemplateResultInstruction<1>* instr,
2821 LUnallocated* result);
2822 LInstruction* DefineAsRegister(LTemplateResultInstruction<1>* instr);
2823 LInstruction* DefineAsSpilled(LTemplateResultInstruction<1>* instr,
2825 LInstruction* DefineSameAsFirst(LTemplateResultInstruction<1>* instr);
2826 LInstruction* DefineFixed(LTemplateResultInstruction<1>* instr,
2828 LInstruction* DefineFixedDouble(LTemplateResultInstruction<1>* instr,
2830 // Assigns an environment to an instruction. An instruction which can
2831 // deoptimize must have an environment.
2832 LInstruction* AssignEnvironment(LInstruction* instr);
2833 // Assigns a pointer map to an instruction. An instruction which can
2834 // trigger a GC or a lazy deoptimization must have a pointer map.
2835 LInstruction* AssignPointerMap(LInstruction* instr);
2837 enum CanDeoptimize { CAN_DEOPTIMIZE_EAGERLY, CANNOT_DEOPTIMIZE_EAGERLY };
2839 // Marks a call for the register allocator. Assigns a pointer map to
2840 // support GC and lazy deoptimization. Assigns an environment to support
2841 // eager deoptimization if CAN_DEOPTIMIZE_EAGERLY.
2842 LInstruction* MarkAsCall(
2843 LInstruction* instr,
2844 HInstruction* hinstr,
2845 CanDeoptimize can_deoptimize = CANNOT_DEOPTIMIZE_EAGERLY);
2847 void VisitInstruction(HInstruction* current);
2848 void AddInstruction(LInstruction* instr, HInstruction* current);
2850 void DoBasicBlock(HBasicBlock* block, HBasicBlock* next_block);
2851 LInstruction* DoShift(Token::Value op, HBitwiseBinaryOperation* instr);
2852 LInstruction* DoArithmeticD(Token::Value op,
2853 HArithmeticBinaryOperation* instr);
2854 LInstruction* DoArithmeticT(Token::Value op,
2855 HBinaryOperation* instr);
2856 void FindDehoistedKeyDefinitions(HValue* candidate);
2858 HInstruction* current_instruction_;
2859 HBasicBlock* current_block_;
2860 HBasicBlock* next_block_;
2861 LAllocator* allocator_;
2863 DISALLOW_COPY_AND_ASSIGN(LChunkBuilder);
2866 #undef DECLARE_HYDROGEN_ACCESSOR
2867 #undef DECLARE_CONCRETE_INSTRUCTION
2869 } } // namespace v8::int
2871 #endif // V8_X64_LITHIUM_X64_H_