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) \
155 V(ToFastProperties) \
156 V(TransitionElementsKind) \
157 V(TrapAllocationMemento) \
159 V(TypeofIsAndBranch) \
165 #define DECLARE_CONCRETE_INSTRUCTION(type, mnemonic) \
166 virtual Opcode opcode() const FINAL OVERRIDE { \
167 return LInstruction::k##type; \
169 virtual void CompileToNative(LCodeGen* generator) FINAL OVERRIDE; \
170 virtual const char* Mnemonic() const FINAL OVERRIDE { \
173 static L##type* cast(LInstruction* instr) { \
174 DCHECK(instr->Is##type()); \
175 return reinterpret_cast<L##type*>(instr); \
179 #define DECLARE_HYDROGEN_ACCESSOR(type) \
180 H##type* hydrogen() const { \
181 return H##type::cast(hydrogen_value()); \
185 class LInstruction : public ZoneObject {
188 : environment_(NULL),
189 hydrogen_value_(NULL),
190 bit_field_(IsCallBits::encode(false)) {
193 virtual ~LInstruction() {}
195 virtual void CompileToNative(LCodeGen* generator) = 0;
196 virtual const char* Mnemonic() const = 0;
197 virtual void PrintTo(StringStream* stream);
198 virtual void PrintDataTo(StringStream* stream);
199 virtual void PrintOutputOperandTo(StringStream* stream);
202 // Declare a unique enum value for each instruction.
203 #define DECLARE_OPCODE(type) k##type,
204 LITHIUM_CONCRETE_INSTRUCTION_LIST(DECLARE_OPCODE)
205 kNumberOfInstructions
206 #undef DECLARE_OPCODE
209 virtual Opcode opcode() const = 0;
211 // Declare non-virtual type testers for all leaf IR classes.
212 #define DECLARE_PREDICATE(type) \
213 bool Is##type() const { return opcode() == k##type; }
214 LITHIUM_CONCRETE_INSTRUCTION_LIST(DECLARE_PREDICATE)
215 #undef DECLARE_PREDICATE
217 // Declare virtual predicates for instructions that don't have
219 virtual bool IsGap() const { return false; }
221 virtual bool IsControl() const { return false; }
223 // Try deleting this instruction if possible.
224 virtual bool TryDelete() { return false; }
226 void set_environment(LEnvironment* env) { environment_ = env; }
227 LEnvironment* environment() const { return environment_; }
228 bool HasEnvironment() const { return environment_ != NULL; }
230 void set_pointer_map(LPointerMap* p) { pointer_map_.set(p); }
231 LPointerMap* pointer_map() const { return pointer_map_.get(); }
232 bool HasPointerMap() const { return pointer_map_.is_set(); }
234 void set_hydrogen_value(HValue* value) { hydrogen_value_ = value; }
235 HValue* hydrogen_value() const { return hydrogen_value_; }
237 void MarkAsCall() { bit_field_ = IsCallBits::update(bit_field_, true); }
238 bool IsCall() const { return IsCallBits::decode(bit_field_); }
240 // Interface to the register allocator and iterators.
241 bool ClobbersTemps() const { return IsCall(); }
242 bool ClobbersRegisters() const { return IsCall(); }
243 virtual bool ClobbersDoubleRegisters(Isolate* isolate) const {
247 virtual void SetDeferredLazyDeoptimizationEnvironment(LEnvironment* env) { }
249 // Interface to the register allocator and iterators.
250 bool IsMarkedAsCall() const { return IsCall(); }
252 virtual bool HasResult() const = 0;
253 virtual LOperand* result() const = 0;
255 LOperand* FirstInput() { return InputAt(0); }
256 LOperand* Output() { return HasResult() ? result() : NULL; }
258 virtual bool HasInterestingComment(LCodeGen* gen) const { return true; }
260 virtual bool MustSignExtendResult(LPlatformChunk* chunk) const {
268 virtual int InputCount() = 0;
269 virtual LOperand* InputAt(int i) = 0;
273 friend class InputIterator;
275 friend class TempIterator;
276 virtual int TempCount() = 0;
277 virtual LOperand* TempAt(int i) = 0;
279 class IsCallBits: public BitField<bool, 0, 1> {};
281 LEnvironment* environment_;
282 SetOncePointer<LPointerMap> pointer_map_;
283 HValue* hydrogen_value_;
288 // R = number of result operands (0 or 1).
290 class LTemplateResultInstruction : public LInstruction {
292 // Allow 0 or 1 output operands.
293 STATIC_ASSERT(R == 0 || R == 1);
294 virtual bool HasResult() const FINAL OVERRIDE {
295 return R != 0 && result() != NULL;
297 void set_result(LOperand* operand) { results_[0] = operand; }
298 LOperand* result() const { return results_[0]; }
300 virtual bool MustSignExtendResult(
301 LPlatformChunk* chunk) const FINAL OVERRIDE;
304 EmbeddedContainer<LOperand*, R> results_;
308 // R = number of result operands (0 or 1).
309 // I = number of input operands.
310 // T = number of temporary operands.
311 template<int R, int I, int T>
312 class LTemplateInstruction : public LTemplateResultInstruction<R> {
314 EmbeddedContainer<LOperand*, I> inputs_;
315 EmbeddedContainer<LOperand*, T> temps_;
319 virtual int InputCount() FINAL OVERRIDE { return I; }
320 virtual LOperand* InputAt(int i) FINAL OVERRIDE { return inputs_[i]; }
322 virtual int TempCount() FINAL OVERRIDE { return T; }
323 virtual LOperand* TempAt(int i) FINAL OVERRIDE { return temps_[i]; }
327 class LGap : public LTemplateInstruction<0, 0, 0> {
329 explicit LGap(HBasicBlock* block)
331 parallel_moves_[BEFORE] = NULL;
332 parallel_moves_[START] = NULL;
333 parallel_moves_[END] = NULL;
334 parallel_moves_[AFTER] = NULL;
337 // Can't use the DECLARE-macro here because of sub-classes.
338 virtual bool IsGap() const FINAL OVERRIDE { return true; }
339 virtual void PrintDataTo(StringStream* stream) OVERRIDE;
340 static LGap* cast(LInstruction* instr) {
341 DCHECK(instr->IsGap());
342 return reinterpret_cast<LGap*>(instr);
345 bool IsRedundant() const;
347 HBasicBlock* block() const { return block_; }
354 FIRST_INNER_POSITION = BEFORE,
355 LAST_INNER_POSITION = AFTER
358 LParallelMove* GetOrCreateParallelMove(InnerPosition pos,
360 if (parallel_moves_[pos] == NULL) {
361 parallel_moves_[pos] = new(zone) LParallelMove(zone);
363 return parallel_moves_[pos];
366 LParallelMove* GetParallelMove(InnerPosition pos) {
367 return parallel_moves_[pos];
371 LParallelMove* parallel_moves_[LAST_INNER_POSITION + 1];
376 class LInstructionGap FINAL : public LGap {
378 explicit LInstructionGap(HBasicBlock* block) : LGap(block) { }
380 virtual bool HasInterestingComment(LCodeGen* gen) const OVERRIDE {
381 return !IsRedundant();
384 DECLARE_CONCRETE_INSTRUCTION(InstructionGap, "gap")
388 class LGoto FINAL : public LTemplateInstruction<0, 0, 0> {
390 explicit LGoto(HBasicBlock* block) : block_(block) { }
392 virtual bool HasInterestingComment(LCodeGen* gen) const OVERRIDE;
393 DECLARE_CONCRETE_INSTRUCTION(Goto, "goto")
394 virtual void PrintDataTo(StringStream* stream) OVERRIDE;
395 virtual bool IsControl() const OVERRIDE { return true; }
397 int block_id() const { return block_->block_id(); }
404 class LLazyBailout FINAL : public LTemplateInstruction<0, 0, 0> {
406 LLazyBailout() : gap_instructions_size_(0) { }
408 DECLARE_CONCRETE_INSTRUCTION(LazyBailout, "lazy-bailout")
410 void set_gap_instructions_size(int gap_instructions_size) {
411 gap_instructions_size_ = gap_instructions_size;
413 int gap_instructions_size() { return gap_instructions_size_; }
416 int gap_instructions_size_;
420 class LDummy FINAL : public LTemplateInstruction<1, 0, 0> {
423 DECLARE_CONCRETE_INSTRUCTION(Dummy, "dummy")
427 class LDummyUse FINAL : public LTemplateInstruction<1, 1, 0> {
429 explicit LDummyUse(LOperand* value) {
432 DECLARE_CONCRETE_INSTRUCTION(DummyUse, "dummy-use")
436 class LDeoptimize FINAL : public LTemplateInstruction<0, 0, 0> {
438 virtual bool IsControl() const OVERRIDE { return true; }
439 DECLARE_CONCRETE_INSTRUCTION(Deoptimize, "deoptimize")
440 DECLARE_HYDROGEN_ACCESSOR(Deoptimize)
444 class LLabel FINAL : public LGap {
446 explicit LLabel(HBasicBlock* block)
447 : LGap(block), replacement_(NULL) { }
449 virtual bool HasInterestingComment(LCodeGen* gen) const OVERRIDE {
452 DECLARE_CONCRETE_INSTRUCTION(Label, "label")
454 virtual void PrintDataTo(StringStream* stream) OVERRIDE;
456 int block_id() const { return block()->block_id(); }
457 bool is_loop_header() const { return block()->IsLoopHeader(); }
458 bool is_osr_entry() const { return block()->is_osr_entry(); }
459 Label* label() { return &label_; }
460 LLabel* replacement() const { return replacement_; }
461 void set_replacement(LLabel* label) { replacement_ = label; }
462 bool HasReplacement() const { return replacement_ != NULL; }
466 LLabel* replacement_;
470 class LParameter FINAL : public LTemplateInstruction<1, 0, 0> {
472 virtual bool HasInterestingComment(LCodeGen* gen) const OVERRIDE {
475 DECLARE_CONCRETE_INSTRUCTION(Parameter, "parameter")
479 class LCallStub FINAL : public LTemplateInstruction<1, 1, 0> {
481 explicit LCallStub(LOperand* context) {
482 inputs_[0] = context;
485 LOperand* context() { return inputs_[0]; }
487 DECLARE_CONCRETE_INSTRUCTION(CallStub, "call-stub")
488 DECLARE_HYDROGEN_ACCESSOR(CallStub)
492 class LUnknownOSRValue FINAL : public LTemplateInstruction<1, 0, 0> {
494 virtual bool HasInterestingComment(LCodeGen* gen) const OVERRIDE {
497 DECLARE_CONCRETE_INSTRUCTION(UnknownOSRValue, "unknown-osr-value")
501 template<int I, int T>
502 class LControlInstruction : public LTemplateInstruction<0, I, T> {
504 LControlInstruction() : false_label_(NULL), true_label_(NULL) { }
506 virtual bool IsControl() const FINAL OVERRIDE { return true; }
508 int SuccessorCount() { return hydrogen()->SuccessorCount(); }
509 HBasicBlock* SuccessorAt(int i) { return hydrogen()->SuccessorAt(i); }
511 int TrueDestination(LChunk* chunk) {
512 return chunk->LookupDestination(true_block_id());
514 int FalseDestination(LChunk* chunk) {
515 return chunk->LookupDestination(false_block_id());
518 Label* TrueLabel(LChunk* chunk) {
519 if (true_label_ == NULL) {
520 true_label_ = chunk->GetAssemblyLabel(TrueDestination(chunk));
524 Label* FalseLabel(LChunk* chunk) {
525 if (false_label_ == NULL) {
526 false_label_ = chunk->GetAssemblyLabel(FalseDestination(chunk));
532 int true_block_id() { return SuccessorAt(0)->block_id(); }
533 int false_block_id() { return SuccessorAt(1)->block_id(); }
536 HControlInstruction* hydrogen() {
537 return HControlInstruction::cast(this->hydrogen_value());
545 class LWrapReceiver FINAL : public LTemplateInstruction<1, 2, 0> {
547 LWrapReceiver(LOperand* receiver, LOperand* function) {
548 inputs_[0] = receiver;
549 inputs_[1] = function;
552 LOperand* receiver() { return inputs_[0]; }
553 LOperand* function() { return inputs_[1]; }
555 DECLARE_CONCRETE_INSTRUCTION(WrapReceiver, "wrap-receiver")
556 DECLARE_HYDROGEN_ACCESSOR(WrapReceiver)
560 class LApplyArguments FINAL : public LTemplateInstruction<1, 4, 0> {
562 LApplyArguments(LOperand* function,
565 LOperand* elements) {
566 inputs_[0] = function;
567 inputs_[1] = receiver;
569 inputs_[3] = elements;
572 LOperand* function() { return inputs_[0]; }
573 LOperand* receiver() { return inputs_[1]; }
574 LOperand* length() { return inputs_[2]; }
575 LOperand* elements() { return inputs_[3]; }
577 DECLARE_CONCRETE_INSTRUCTION(ApplyArguments, "apply-arguments")
581 class LAccessArgumentsAt FINAL : public LTemplateInstruction<1, 3, 0> {
583 LAccessArgumentsAt(LOperand* arguments, LOperand* length, LOperand* index) {
584 inputs_[0] = arguments;
589 LOperand* arguments() { return inputs_[0]; }
590 LOperand* length() { return inputs_[1]; }
591 LOperand* index() { return inputs_[2]; }
593 DECLARE_CONCRETE_INSTRUCTION(AccessArgumentsAt, "access-arguments-at")
595 virtual void PrintDataTo(StringStream* stream) OVERRIDE;
599 class LArgumentsLength FINAL : public LTemplateInstruction<1, 1, 0> {
601 explicit LArgumentsLength(LOperand* elements) {
602 inputs_[0] = elements;
605 LOperand* elements() { return inputs_[0]; }
607 DECLARE_CONCRETE_INSTRUCTION(ArgumentsLength, "arguments-length")
611 class LArgumentsElements FINAL : public LTemplateInstruction<1, 0, 0> {
613 DECLARE_CONCRETE_INSTRUCTION(ArgumentsElements, "arguments-elements")
614 DECLARE_HYDROGEN_ACCESSOR(ArgumentsElements)
618 class LModByPowerOf2I FINAL : public LTemplateInstruction<1, 1, 0> {
620 LModByPowerOf2I(LOperand* dividend, int32_t divisor) {
621 inputs_[0] = dividend;
625 LOperand* dividend() { return inputs_[0]; }
626 int32_t divisor() const { return divisor_; }
628 DECLARE_CONCRETE_INSTRUCTION(ModByPowerOf2I, "mod-by-power-of-2-i")
629 DECLARE_HYDROGEN_ACCESSOR(Mod)
636 class LModByConstI FINAL : public LTemplateInstruction<1, 1, 2> {
638 LModByConstI(LOperand* dividend,
642 inputs_[0] = dividend;
648 LOperand* dividend() { return inputs_[0]; }
649 int32_t divisor() const { return divisor_; }
650 LOperand* temp1() { return temps_[0]; }
651 LOperand* temp2() { return temps_[1]; }
653 DECLARE_CONCRETE_INSTRUCTION(ModByConstI, "mod-by-const-i")
654 DECLARE_HYDROGEN_ACCESSOR(Mod)
661 class LModI FINAL : public LTemplateInstruction<1, 2, 1> {
663 LModI(LOperand* left, LOperand* right, LOperand* temp) {
669 LOperand* left() { return inputs_[0]; }
670 LOperand* right() { return inputs_[1]; }
671 LOperand* temp() { return temps_[0]; }
673 DECLARE_CONCRETE_INSTRUCTION(ModI, "mod-i")
674 DECLARE_HYDROGEN_ACCESSOR(Mod)
678 class LDivByPowerOf2I FINAL : public LTemplateInstruction<1, 1, 0> {
680 LDivByPowerOf2I(LOperand* dividend, int32_t divisor) {
681 inputs_[0] = dividend;
685 LOperand* dividend() { return inputs_[0]; }
686 int32_t divisor() const { return divisor_; }
688 DECLARE_CONCRETE_INSTRUCTION(DivByPowerOf2I, "div-by-power-of-2-i")
689 DECLARE_HYDROGEN_ACCESSOR(Div)
696 class LDivByConstI FINAL : public LTemplateInstruction<1, 1, 2> {
698 LDivByConstI(LOperand* dividend,
702 inputs_[0] = dividend;
708 LOperand* dividend() { return inputs_[0]; }
709 int32_t divisor() const { return divisor_; }
710 LOperand* temp1() { return temps_[0]; }
711 LOperand* temp2() { return temps_[1]; }
713 DECLARE_CONCRETE_INSTRUCTION(DivByConstI, "div-by-const-i")
714 DECLARE_HYDROGEN_ACCESSOR(Div)
721 class LDivI FINAL : public LTemplateInstruction<1, 2, 1> {
723 LDivI(LOperand* dividend, LOperand* divisor, LOperand* temp) {
724 inputs_[0] = dividend;
725 inputs_[1] = divisor;
729 LOperand* dividend() { return inputs_[0]; }
730 LOperand* divisor() { return inputs_[1]; }
731 LOperand* temp() { return temps_[0]; }
733 DECLARE_CONCRETE_INSTRUCTION(DivI, "div-i")
734 DECLARE_HYDROGEN_ACCESSOR(BinaryOperation)
738 class LFlooringDivByPowerOf2I FINAL : public LTemplateInstruction<1, 1, 0> {
740 LFlooringDivByPowerOf2I(LOperand* dividend, int32_t divisor) {
741 inputs_[0] = dividend;
745 LOperand* dividend() { return inputs_[0]; }
746 int32_t divisor() const { return divisor_; }
748 DECLARE_CONCRETE_INSTRUCTION(FlooringDivByPowerOf2I,
749 "flooring-div-by-power-of-2-i")
750 DECLARE_HYDROGEN_ACCESSOR(MathFloorOfDiv)
757 class LFlooringDivByConstI FINAL : public LTemplateInstruction<1, 1, 3> {
759 LFlooringDivByConstI(LOperand* dividend,
764 inputs_[0] = dividend;
771 LOperand* dividend() { return inputs_[0]; }
772 int32_t divisor() const { return divisor_; }
773 LOperand* temp1() { return temps_[0]; }
774 LOperand* temp2() { return temps_[1]; }
775 LOperand* temp3() { return temps_[2]; }
777 DECLARE_CONCRETE_INSTRUCTION(FlooringDivByConstI, "flooring-div-by-const-i")
778 DECLARE_HYDROGEN_ACCESSOR(MathFloorOfDiv)
785 class LFlooringDivI FINAL : public LTemplateInstruction<1, 2, 1> {
787 LFlooringDivI(LOperand* dividend, LOperand* divisor, LOperand* temp) {
788 inputs_[0] = dividend;
789 inputs_[1] = divisor;
793 LOperand* dividend() { return inputs_[0]; }
794 LOperand* divisor() { return inputs_[1]; }
795 LOperand* temp() { return temps_[0]; }
797 DECLARE_CONCRETE_INSTRUCTION(FlooringDivI, "flooring-div-i")
798 DECLARE_HYDROGEN_ACCESSOR(MathFloorOfDiv)
802 class LMulI FINAL : public LTemplateInstruction<1, 2, 0> {
804 LMulI(LOperand* left, LOperand* right) {
809 LOperand* left() { return inputs_[0]; }
810 LOperand* right() { return inputs_[1]; }
812 DECLARE_CONCRETE_INSTRUCTION(MulI, "mul-i")
813 DECLARE_HYDROGEN_ACCESSOR(Mul)
817 class LCompareNumericAndBranch FINAL : public LControlInstruction<2, 0> {
819 LCompareNumericAndBranch(LOperand* left, LOperand* right) {
824 LOperand* left() { return inputs_[0]; }
825 LOperand* right() { return inputs_[1]; }
827 DECLARE_CONCRETE_INSTRUCTION(CompareNumericAndBranch,
828 "compare-numeric-and-branch")
829 DECLARE_HYDROGEN_ACCESSOR(CompareNumericAndBranch)
831 Token::Value op() const { return hydrogen()->token(); }
832 bool is_double() const {
833 return hydrogen()->representation().IsDouble();
836 virtual void PrintDataTo(StringStream* stream) OVERRIDE;
840 class LMathFloor FINAL : public LTemplateInstruction<1, 1, 0> {
842 explicit LMathFloor(LOperand* value) {
846 LOperand* value() { return inputs_[0]; }
848 DECLARE_CONCRETE_INSTRUCTION(MathFloor, "math-floor")
849 DECLARE_HYDROGEN_ACCESSOR(UnaryMathOperation)
853 class LMathRound FINAL : public LTemplateInstruction<1, 1, 1> {
855 LMathRound(LOperand* value, LOperand* temp) {
860 LOperand* value() { return inputs_[0]; }
861 LOperand* temp() { return temps_[0]; }
863 DECLARE_CONCRETE_INSTRUCTION(MathRound, "math-round")
864 DECLARE_HYDROGEN_ACCESSOR(UnaryMathOperation)
868 class LMathFround FINAL : public LTemplateInstruction<1, 1, 0> {
870 explicit LMathFround(LOperand* value) { inputs_[0] = value; }
872 LOperand* value() { return inputs_[0]; }
874 DECLARE_CONCRETE_INSTRUCTION(MathFround, "math-fround")
878 class LMathAbs FINAL : public LTemplateInstruction<1, 2, 0> {
880 explicit LMathAbs(LOperand* context, LOperand* value) {
881 inputs_[1] = context;
885 LOperand* context() { return inputs_[1]; }
886 LOperand* value() { return inputs_[0]; }
888 DECLARE_CONCRETE_INSTRUCTION(MathAbs, "math-abs")
889 DECLARE_HYDROGEN_ACCESSOR(UnaryMathOperation)
893 class LMathLog FINAL : public LTemplateInstruction<1, 1, 0> {
895 explicit LMathLog(LOperand* value) {
899 LOperand* value() { return inputs_[0]; }
901 DECLARE_CONCRETE_INSTRUCTION(MathLog, "math-log")
905 class LMathClz32 FINAL : public LTemplateInstruction<1, 1, 0> {
907 explicit LMathClz32(LOperand* value) {
911 LOperand* value() { return inputs_[0]; }
913 DECLARE_CONCRETE_INSTRUCTION(MathClz32, "math-clz32")
917 class LMathExp FINAL : public LTemplateInstruction<1, 1, 2> {
919 LMathExp(LOperand* value, LOperand* temp1, LOperand* temp2) {
923 ExternalReference::InitializeMathExpData();
926 LOperand* value() { return inputs_[0]; }
927 LOperand* temp1() { return temps_[0]; }
928 LOperand* temp2() { return temps_[1]; }
930 DECLARE_CONCRETE_INSTRUCTION(MathExp, "math-exp")
934 class LMathSqrt FINAL : public LTemplateInstruction<1, 1, 0> {
936 explicit LMathSqrt(LOperand* value) {
940 LOperand* value() { return inputs_[0]; }
942 DECLARE_CONCRETE_INSTRUCTION(MathSqrt, "math-sqrt")
946 class LMathPowHalf FINAL : public LTemplateInstruction<1, 1, 0> {
948 explicit LMathPowHalf(LOperand* value) {
952 LOperand* value() { return inputs_[0]; }
954 DECLARE_CONCRETE_INSTRUCTION(MathPowHalf, "math-pow-half")
958 class LCmpObjectEqAndBranch FINAL : public LControlInstruction<2, 0> {
960 LCmpObjectEqAndBranch(LOperand* left, LOperand* right) {
965 LOperand* left() { return inputs_[0]; }
966 LOperand* right() { return inputs_[1]; }
968 DECLARE_CONCRETE_INSTRUCTION(CmpObjectEqAndBranch, "cmp-object-eq-and-branch")
972 class LCmpHoleAndBranch FINAL : public LControlInstruction<1, 0> {
974 explicit LCmpHoleAndBranch(LOperand* object) {
978 LOperand* object() { return inputs_[0]; }
980 DECLARE_CONCRETE_INSTRUCTION(CmpHoleAndBranch, "cmp-hole-and-branch")
981 DECLARE_HYDROGEN_ACCESSOR(CompareHoleAndBranch)
985 class LCompareMinusZeroAndBranch FINAL : public LControlInstruction<1, 0> {
987 explicit LCompareMinusZeroAndBranch(LOperand* value) {
991 LOperand* value() { return inputs_[0]; }
993 DECLARE_CONCRETE_INSTRUCTION(CompareMinusZeroAndBranch,
994 "cmp-minus-zero-and-branch")
995 DECLARE_HYDROGEN_ACCESSOR(CompareMinusZeroAndBranch)
1000 class LIsObjectAndBranch FINAL : public LControlInstruction<1, 0> {
1002 explicit LIsObjectAndBranch(LOperand* value) {
1006 LOperand* value() { return inputs_[0]; }
1008 DECLARE_CONCRETE_INSTRUCTION(IsObjectAndBranch, "is-object-and-branch")
1009 DECLARE_HYDROGEN_ACCESSOR(IsObjectAndBranch)
1011 virtual void PrintDataTo(StringStream* stream) OVERRIDE;
1015 class LIsStringAndBranch FINAL : public LControlInstruction<1, 1> {
1017 explicit LIsStringAndBranch(LOperand* value, LOperand* temp) {
1022 LOperand* value() { return inputs_[0]; }
1023 LOperand* temp() { return temps_[0]; }
1025 DECLARE_CONCRETE_INSTRUCTION(IsStringAndBranch, "is-string-and-branch")
1026 DECLARE_HYDROGEN_ACCESSOR(IsStringAndBranch)
1028 virtual void PrintDataTo(StringStream* stream) OVERRIDE;
1032 class LIsSmiAndBranch FINAL : public LControlInstruction<1, 0> {
1034 explicit LIsSmiAndBranch(LOperand* value) {
1038 LOperand* value() { return inputs_[0]; }
1040 DECLARE_CONCRETE_INSTRUCTION(IsSmiAndBranch, "is-smi-and-branch")
1041 DECLARE_HYDROGEN_ACCESSOR(IsSmiAndBranch)
1043 virtual void PrintDataTo(StringStream* stream) OVERRIDE;
1047 class LIsUndetectableAndBranch FINAL : public LControlInstruction<1, 1> {
1049 explicit LIsUndetectableAndBranch(LOperand* value, LOperand* temp) {
1054 LOperand* value() { return inputs_[0]; }
1055 LOperand* temp() { return temps_[0]; }
1057 DECLARE_CONCRETE_INSTRUCTION(IsUndetectableAndBranch,
1058 "is-undetectable-and-branch")
1059 DECLARE_HYDROGEN_ACCESSOR(IsUndetectableAndBranch)
1061 virtual void PrintDataTo(StringStream* stream) OVERRIDE;
1065 class LStringCompareAndBranch FINAL : public LControlInstruction<3, 0> {
1067 explicit LStringCompareAndBranch(LOperand* context,
1070 inputs_[0] = context;
1075 LOperand* context() { return inputs_[0]; }
1076 LOperand* left() { return inputs_[1]; }
1077 LOperand* right() { return inputs_[2]; }
1079 DECLARE_CONCRETE_INSTRUCTION(StringCompareAndBranch,
1080 "string-compare-and-branch")
1081 DECLARE_HYDROGEN_ACCESSOR(StringCompareAndBranch)
1083 virtual void PrintDataTo(StringStream* stream) OVERRIDE;
1085 Token::Value op() const { return hydrogen()->token(); }
1089 class LHasInstanceTypeAndBranch FINAL : public LControlInstruction<1, 0> {
1091 explicit LHasInstanceTypeAndBranch(LOperand* value) {
1095 LOperand* value() { return inputs_[0]; }
1097 DECLARE_CONCRETE_INSTRUCTION(HasInstanceTypeAndBranch,
1098 "has-instance-type-and-branch")
1099 DECLARE_HYDROGEN_ACCESSOR(HasInstanceTypeAndBranch)
1101 virtual void PrintDataTo(StringStream* stream) OVERRIDE;
1105 class LGetCachedArrayIndex FINAL : public LTemplateInstruction<1, 1, 0> {
1107 explicit LGetCachedArrayIndex(LOperand* value) {
1111 LOperand* value() { return inputs_[0]; }
1113 DECLARE_CONCRETE_INSTRUCTION(GetCachedArrayIndex, "get-cached-array-index")
1114 DECLARE_HYDROGEN_ACCESSOR(GetCachedArrayIndex)
1118 class LHasCachedArrayIndexAndBranch FINAL
1119 : public LControlInstruction<1, 0> {
1121 explicit LHasCachedArrayIndexAndBranch(LOperand* value) {
1125 LOperand* value() { return inputs_[0]; }
1127 DECLARE_CONCRETE_INSTRUCTION(HasCachedArrayIndexAndBranch,
1128 "has-cached-array-index-and-branch")
1129 DECLARE_HYDROGEN_ACCESSOR(HasCachedArrayIndexAndBranch)
1131 virtual void PrintDataTo(StringStream* stream) OVERRIDE;
1135 class LClassOfTestAndBranch FINAL : public LControlInstruction<1, 2> {
1137 LClassOfTestAndBranch(LOperand* value, LOperand* temp, LOperand* temp2) {
1143 LOperand* value() { return inputs_[0]; }
1144 LOperand* temp() { return temps_[0]; }
1145 LOperand* temp2() { return temps_[1]; }
1147 DECLARE_CONCRETE_INSTRUCTION(ClassOfTestAndBranch,
1148 "class-of-test-and-branch")
1149 DECLARE_HYDROGEN_ACCESSOR(ClassOfTestAndBranch)
1151 virtual void PrintDataTo(StringStream* stream) OVERRIDE;
1155 class LCmpT FINAL : public LTemplateInstruction<1, 3, 0> {
1157 LCmpT(LOperand* context, LOperand* left, LOperand* right) {
1158 inputs_[0] = context;
1163 LOperand* context() { return inputs_[0]; }
1164 LOperand* left() { return inputs_[1]; }
1165 LOperand* right() { return inputs_[2]; }
1167 DECLARE_CONCRETE_INSTRUCTION(CmpT, "cmp-t")
1168 DECLARE_HYDROGEN_ACCESSOR(CompareGeneric)
1170 Token::Value op() const { return hydrogen()->token(); }
1174 class LInstanceOf FINAL : public LTemplateInstruction<1, 3, 0> {
1176 LInstanceOf(LOperand* context, LOperand* left, LOperand* right) {
1177 inputs_[0] = context;
1182 LOperand* context() { return inputs_[0]; }
1183 LOperand* left() { return inputs_[1]; }
1184 LOperand* right() { return inputs_[2]; }
1186 DECLARE_CONCRETE_INSTRUCTION(InstanceOf, "instance-of")
1190 class LInstanceOfKnownGlobal FINAL : public LTemplateInstruction<1, 2, 1> {
1192 LInstanceOfKnownGlobal(LOperand* context, LOperand* value, LOperand* temp) {
1193 inputs_[0] = context;
1198 LOperand* context() { return inputs_[0]; }
1199 LOperand* value() { return inputs_[1]; }
1200 LOperand* temp() { return temps_[0]; }
1202 DECLARE_CONCRETE_INSTRUCTION(InstanceOfKnownGlobal,
1203 "instance-of-known-global")
1204 DECLARE_HYDROGEN_ACCESSOR(InstanceOfKnownGlobal)
1206 Handle<JSFunction> function() const { return hydrogen()->function(); }
1207 LEnvironment* GetDeferredLazyDeoptimizationEnvironment() {
1208 return lazy_deopt_env_;
1210 virtual void SetDeferredLazyDeoptimizationEnvironment(
1211 LEnvironment* env) OVERRIDE {
1212 lazy_deopt_env_ = env;
1216 LEnvironment* lazy_deopt_env_;
1220 class LBoundsCheck FINAL : public LTemplateInstruction<0, 2, 0> {
1222 LBoundsCheck(LOperand* index, LOperand* length) {
1224 inputs_[1] = length;
1227 LOperand* index() { return inputs_[0]; }
1228 LOperand* length() { return inputs_[1]; }
1230 DECLARE_CONCRETE_INSTRUCTION(BoundsCheck, "bounds-check")
1231 DECLARE_HYDROGEN_ACCESSOR(BoundsCheck)
1235 class LBitI FINAL : public LTemplateInstruction<1, 2, 0> {
1237 LBitI(LOperand* left, LOperand* right) {
1242 LOperand* left() { return inputs_[0]; }
1243 LOperand* right() { return inputs_[1]; }
1245 Token::Value op() const { return hydrogen()->op(); }
1246 bool IsInteger32() const {
1247 return hydrogen()->representation().IsInteger32();
1250 DECLARE_CONCRETE_INSTRUCTION(BitI, "bit-i")
1251 DECLARE_HYDROGEN_ACCESSOR(Bitwise)
1255 class LShiftI FINAL : public LTemplateInstruction<1, 2, 0> {
1257 LShiftI(Token::Value op, LOperand* left, LOperand* right, bool can_deopt)
1258 : op_(op), can_deopt_(can_deopt) {
1263 Token::Value op() const { return op_; }
1264 LOperand* left() { return inputs_[0]; }
1265 LOperand* right() { return inputs_[1]; }
1266 bool can_deopt() const { return can_deopt_; }
1268 DECLARE_CONCRETE_INSTRUCTION(ShiftI, "shift-i")
1276 class LSubI FINAL : public LTemplateInstruction<1, 2, 0> {
1278 LSubI(LOperand* left, LOperand* right) {
1283 LOperand* left() { return inputs_[0]; }
1284 LOperand* right() { return inputs_[1]; }
1286 DECLARE_CONCRETE_INSTRUCTION(SubI, "sub-i")
1287 DECLARE_HYDROGEN_ACCESSOR(Sub)
1291 class LConstantI FINAL : public LTemplateInstruction<1, 0, 0> {
1293 DECLARE_CONCRETE_INSTRUCTION(ConstantI, "constant-i")
1294 DECLARE_HYDROGEN_ACCESSOR(Constant)
1296 int32_t value() const { return hydrogen()->Integer32Value(); }
1300 class LConstantS FINAL : public LTemplateInstruction<1, 0, 0> {
1302 DECLARE_CONCRETE_INSTRUCTION(ConstantS, "constant-s")
1303 DECLARE_HYDROGEN_ACCESSOR(Constant)
1305 Smi* value() const { return Smi::FromInt(hydrogen()->Integer32Value()); }
1309 class LConstantD FINAL : public LTemplateInstruction<1, 0, 1> {
1311 explicit LConstantD(LOperand* temp) {
1315 LOperand* temp() { return temps_[0]; }
1317 DECLARE_CONCRETE_INSTRUCTION(ConstantD, "constant-d")
1318 DECLARE_HYDROGEN_ACCESSOR(Constant)
1320 double value() const { return hydrogen()->DoubleValue(); }
1324 class LConstantE FINAL : public LTemplateInstruction<1, 0, 0> {
1326 DECLARE_CONCRETE_INSTRUCTION(ConstantE, "constant-e")
1327 DECLARE_HYDROGEN_ACCESSOR(Constant)
1329 ExternalReference value() const {
1330 return hydrogen()->ExternalReferenceValue();
1335 class LConstantT FINAL : public LTemplateInstruction<1, 0, 0> {
1337 DECLARE_CONCRETE_INSTRUCTION(ConstantT, "constant-t")
1338 DECLARE_HYDROGEN_ACCESSOR(Constant)
1340 Handle<Object> value(Isolate* isolate) const {
1341 return hydrogen()->handle(isolate);
1346 class LBranch FINAL : public LControlInstruction<1, 0> {
1348 explicit LBranch(LOperand* value) {
1352 LOperand* value() { return inputs_[0]; }
1354 DECLARE_CONCRETE_INSTRUCTION(Branch, "branch")
1355 DECLARE_HYDROGEN_ACCESSOR(Branch)
1357 virtual void PrintDataTo(StringStream* stream) OVERRIDE;
1361 class LDebugBreak FINAL : public LTemplateInstruction<0, 0, 0> {
1363 DECLARE_CONCRETE_INSTRUCTION(DebugBreak, "break")
1367 class LCmpMapAndBranch FINAL : public LControlInstruction<1, 0> {
1369 explicit LCmpMapAndBranch(LOperand* value) {
1373 LOperand* value() { return inputs_[0]; }
1375 DECLARE_CONCRETE_INSTRUCTION(CmpMapAndBranch, "cmp-map-and-branch")
1376 DECLARE_HYDROGEN_ACCESSOR(CompareMap)
1378 Handle<Map> map() const { return hydrogen()->map().handle(); }
1382 class LMapEnumLength FINAL : public LTemplateInstruction<1, 1, 0> {
1384 explicit LMapEnumLength(LOperand* value) {
1388 LOperand* value() { return inputs_[0]; }
1390 DECLARE_CONCRETE_INSTRUCTION(MapEnumLength, "map-enum-length")
1394 class LDateField FINAL : public LTemplateInstruction<1, 1, 0> {
1396 LDateField(LOperand* date, Smi* index) : index_(index) {
1400 LOperand* date() { return inputs_[0]; }
1401 Smi* index() const { return index_; }
1403 DECLARE_CONCRETE_INSTRUCTION(DateField, "date-field")
1404 DECLARE_HYDROGEN_ACCESSOR(DateField)
1411 class LSeqStringGetChar FINAL : public LTemplateInstruction<1, 2, 0> {
1413 LSeqStringGetChar(LOperand* string, LOperand* index) {
1414 inputs_[0] = string;
1418 LOperand* string() const { return inputs_[0]; }
1419 LOperand* index() const { return inputs_[1]; }
1421 DECLARE_CONCRETE_INSTRUCTION(SeqStringGetChar, "seq-string-get-char")
1422 DECLARE_HYDROGEN_ACCESSOR(SeqStringGetChar)
1426 class LSeqStringSetChar FINAL : public LTemplateInstruction<1, 4, 0> {
1428 LSeqStringSetChar(LOperand* context,
1432 inputs_[0] = context;
1433 inputs_[1] = string;
1438 LOperand* string() { return inputs_[1]; }
1439 LOperand* index() { return inputs_[2]; }
1440 LOperand* value() { return inputs_[3]; }
1442 DECLARE_CONCRETE_INSTRUCTION(SeqStringSetChar, "seq-string-set-char")
1443 DECLARE_HYDROGEN_ACCESSOR(SeqStringSetChar)
1447 class LAddI FINAL : public LTemplateInstruction<1, 2, 0> {
1449 LAddI(LOperand* left, LOperand* right) {
1454 LOperand* left() { return inputs_[0]; }
1455 LOperand* right() { return inputs_[1]; }
1457 static bool UseLea(HAdd* add) {
1458 return !add->CheckFlag(HValue::kCanOverflow) &&
1459 add->BetterLeftOperand()->UseCount() > 1;
1462 DECLARE_CONCRETE_INSTRUCTION(AddI, "add-i")
1463 DECLARE_HYDROGEN_ACCESSOR(Add)
1467 class LMathMinMax FINAL : public LTemplateInstruction<1, 2, 0> {
1469 LMathMinMax(LOperand* left, LOperand* right) {
1474 LOperand* left() { return inputs_[0]; }
1475 LOperand* right() { return inputs_[1]; }
1477 DECLARE_CONCRETE_INSTRUCTION(MathMinMax, "math-min-max")
1478 DECLARE_HYDROGEN_ACCESSOR(MathMinMax)
1482 class LPower FINAL : public LTemplateInstruction<1, 2, 0> {
1484 LPower(LOperand* left, LOperand* right) {
1489 LOperand* left() { return inputs_[0]; }
1490 LOperand* right() { return inputs_[1]; }
1492 DECLARE_CONCRETE_INSTRUCTION(Power, "power")
1493 DECLARE_HYDROGEN_ACCESSOR(Power)
1497 class LArithmeticD FINAL : public LTemplateInstruction<1, 2, 0> {
1499 LArithmeticD(Token::Value op, LOperand* left, LOperand* right)
1505 Token::Value op() const { return op_; }
1506 LOperand* left() { return inputs_[0]; }
1507 LOperand* right() { return inputs_[1]; }
1509 virtual Opcode opcode() const OVERRIDE {
1510 return LInstruction::kArithmeticD;
1512 virtual void CompileToNative(LCodeGen* generator) OVERRIDE;
1513 virtual const char* Mnemonic() const OVERRIDE;
1520 class LArithmeticT FINAL : public LTemplateInstruction<1, 3, 0> {
1522 LArithmeticT(Token::Value op,
1527 inputs_[0] = context;
1532 Token::Value op() const { return op_; }
1533 LOperand* context() { return inputs_[0]; }
1534 LOperand* left() { return inputs_[1]; }
1535 LOperand* right() { return inputs_[2]; }
1537 virtual Opcode opcode() const OVERRIDE {
1538 return LInstruction::kArithmeticT;
1540 virtual void CompileToNative(LCodeGen* generator) OVERRIDE;
1541 virtual const char* Mnemonic() const OVERRIDE;
1548 class LReturn FINAL : public LTemplateInstruction<0, 3, 0> {
1550 explicit LReturn(LOperand* value,
1552 LOperand* parameter_count) {
1554 inputs_[1] = context;
1555 inputs_[2] = parameter_count;
1558 LOperand* value() { return inputs_[0]; }
1559 LOperand* context() { return inputs_[1]; }
1561 bool has_constant_parameter_count() {
1562 return parameter_count()->IsConstantOperand();
1564 LConstantOperand* constant_parameter_count() {
1565 DCHECK(has_constant_parameter_count());
1566 return LConstantOperand::cast(parameter_count());
1568 LOperand* parameter_count() { return inputs_[2]; }
1570 DECLARE_CONCRETE_INSTRUCTION(Return, "return")
1571 DECLARE_HYDROGEN_ACCESSOR(Return)
1575 class LLoadNamedField FINAL : public LTemplateInstruction<1, 1, 0> {
1577 explicit LLoadNamedField(LOperand* object) {
1578 inputs_[0] = object;
1581 LOperand* object() { return inputs_[0]; }
1583 DECLARE_CONCRETE_INSTRUCTION(LoadNamedField, "load-named-field")
1584 DECLARE_HYDROGEN_ACCESSOR(LoadNamedField)
1588 class LLoadNamedGeneric FINAL : public LTemplateInstruction<1, 2, 1> {
1590 explicit LLoadNamedGeneric(LOperand* context, LOperand* object,
1592 inputs_[0] = context;
1593 inputs_[1] = object;
1597 DECLARE_CONCRETE_INSTRUCTION(LoadNamedGeneric, "load-named-generic")
1598 DECLARE_HYDROGEN_ACCESSOR(LoadNamedGeneric)
1600 LOperand* context() { return inputs_[0]; }
1601 LOperand* object() { return inputs_[1]; }
1602 LOperand* temp_vector() { return temps_[0]; }
1604 Handle<Object> name() const { return hydrogen()->name(); }
1608 class LLoadFunctionPrototype FINAL : public LTemplateInstruction<1, 1, 0> {
1610 explicit LLoadFunctionPrototype(LOperand* function) {
1611 inputs_[0] = function;
1614 DECLARE_CONCRETE_INSTRUCTION(LoadFunctionPrototype, "load-function-prototype")
1615 DECLARE_HYDROGEN_ACCESSOR(LoadFunctionPrototype)
1617 LOperand* function() { return inputs_[0]; }
1621 class LLoadRoot FINAL : public LTemplateInstruction<1, 0, 0> {
1623 DECLARE_CONCRETE_INSTRUCTION(LoadRoot, "load-root")
1624 DECLARE_HYDROGEN_ACCESSOR(LoadRoot)
1626 Heap::RootListIndex index() const { return hydrogen()->index(); }
1630 inline static bool ExternalArrayOpRequiresTemp(
1631 Representation key_representation,
1632 ElementsKind elements_kind) {
1633 // Operations that require the key to be divided by two to be converted into
1634 // an index cannot fold the scale operation into a load and need an extra
1635 // temp register to do the work.
1636 return SmiValuesAre31Bits() && key_representation.IsSmi() &&
1637 (elements_kind == EXTERNAL_INT8_ELEMENTS ||
1638 elements_kind == EXTERNAL_UINT8_ELEMENTS ||
1639 elements_kind == EXTERNAL_UINT8_CLAMPED_ELEMENTS ||
1640 elements_kind == UINT8_ELEMENTS ||
1641 elements_kind == INT8_ELEMENTS ||
1642 elements_kind == UINT8_CLAMPED_ELEMENTS);
1646 class LLoadKeyed FINAL : public LTemplateInstruction<1, 2, 0> {
1648 LLoadKeyed(LOperand* elements, LOperand* key) {
1649 inputs_[0] = elements;
1653 DECLARE_CONCRETE_INSTRUCTION(LoadKeyed, "load-keyed")
1654 DECLARE_HYDROGEN_ACCESSOR(LoadKeyed)
1656 bool is_external() const {
1657 return hydrogen()->is_external();
1659 bool is_fixed_typed_array() const {
1660 return hydrogen()->is_fixed_typed_array();
1662 bool is_typed_elements() const {
1663 return is_external() || is_fixed_typed_array();
1665 LOperand* elements() { return inputs_[0]; }
1666 LOperand* key() { return inputs_[1]; }
1667 virtual void PrintDataTo(StringStream* stream) OVERRIDE;
1668 uint32_t base_offset() const { return hydrogen()->base_offset(); }
1669 ElementsKind elements_kind() const {
1670 return hydrogen()->elements_kind();
1675 class LLoadKeyedGeneric FINAL : public LTemplateInstruction<1, 3, 1> {
1677 LLoadKeyedGeneric(LOperand* context, LOperand* obj, LOperand* key,
1679 inputs_[0] = context;
1685 DECLARE_CONCRETE_INSTRUCTION(LoadKeyedGeneric, "load-keyed-generic")
1686 DECLARE_HYDROGEN_ACCESSOR(LoadKeyedGeneric)
1688 LOperand* context() { return inputs_[0]; }
1689 LOperand* object() { return inputs_[1]; }
1690 LOperand* key() { return inputs_[2]; }
1691 LOperand* temp_vector() { return temps_[0]; }
1695 class LLoadGlobalCell FINAL : public LTemplateInstruction<1, 0, 0> {
1697 DECLARE_CONCRETE_INSTRUCTION(LoadGlobalCell, "load-global-cell")
1698 DECLARE_HYDROGEN_ACCESSOR(LoadGlobalCell)
1702 class LLoadGlobalGeneric FINAL : public LTemplateInstruction<1, 2, 1> {
1704 explicit LLoadGlobalGeneric(LOperand* context, LOperand* global_object,
1706 inputs_[0] = context;
1707 inputs_[1] = global_object;
1711 DECLARE_CONCRETE_INSTRUCTION(LoadGlobalGeneric, "load-global-generic")
1712 DECLARE_HYDROGEN_ACCESSOR(LoadGlobalGeneric)
1714 LOperand* context() { return inputs_[0]; }
1715 LOperand* global_object() { return inputs_[1]; }
1716 LOperand* temp_vector() { return temps_[0]; }
1718 Handle<Object> name() const { return hydrogen()->name(); }
1719 bool for_typeof() const { return hydrogen()->for_typeof(); }
1723 class LStoreGlobalCell FINAL : public LTemplateInstruction<0, 1, 1> {
1725 explicit LStoreGlobalCell(LOperand* value, LOperand* temp) {
1730 LOperand* value() { return inputs_[0]; }
1731 LOperand* temp() { return temps_[0]; }
1733 DECLARE_CONCRETE_INSTRUCTION(StoreGlobalCell, "store-global-cell")
1734 DECLARE_HYDROGEN_ACCESSOR(StoreGlobalCell)
1738 class LLoadContextSlot FINAL : public LTemplateInstruction<1, 1, 0> {
1740 explicit LLoadContextSlot(LOperand* context) {
1741 inputs_[0] = context;
1744 LOperand* context() { return inputs_[0]; }
1746 DECLARE_CONCRETE_INSTRUCTION(LoadContextSlot, "load-context-slot")
1747 DECLARE_HYDROGEN_ACCESSOR(LoadContextSlot)
1749 int slot_index() { return hydrogen()->slot_index(); }
1751 virtual void PrintDataTo(StringStream* stream) OVERRIDE;
1755 class LStoreContextSlot FINAL : public LTemplateInstruction<0, 2, 1> {
1757 LStoreContextSlot(LOperand* context, LOperand* value, LOperand* temp) {
1758 inputs_[0] = context;
1763 LOperand* context() { return inputs_[0]; }
1764 LOperand* value() { return inputs_[1]; }
1765 LOperand* temp() { return temps_[0]; }
1767 DECLARE_CONCRETE_INSTRUCTION(StoreContextSlot, "store-context-slot")
1768 DECLARE_HYDROGEN_ACCESSOR(StoreContextSlot)
1770 int slot_index() { return hydrogen()->slot_index(); }
1772 virtual void PrintDataTo(StringStream* stream) OVERRIDE;
1776 class LPushArgument FINAL : public LTemplateInstruction<0, 1, 0> {
1778 explicit LPushArgument(LOperand* value) {
1782 LOperand* value() { return inputs_[0]; }
1784 DECLARE_CONCRETE_INSTRUCTION(PushArgument, "push-argument")
1788 class LDrop FINAL : public LTemplateInstruction<0, 0, 0> {
1790 explicit LDrop(int count) : count_(count) { }
1792 int count() const { return count_; }
1794 DECLARE_CONCRETE_INSTRUCTION(Drop, "drop")
1801 class LStoreCodeEntry FINAL: public LTemplateInstruction<0, 2, 0> {
1803 LStoreCodeEntry(LOperand* function, LOperand* code_object) {
1804 inputs_[0] = function;
1805 inputs_[1] = code_object;
1808 LOperand* function() { return inputs_[0]; }
1809 LOperand* code_object() { return inputs_[1]; }
1811 virtual void PrintDataTo(StringStream* stream);
1813 DECLARE_CONCRETE_INSTRUCTION(StoreCodeEntry, "store-code-entry")
1814 DECLARE_HYDROGEN_ACCESSOR(StoreCodeEntry)
1818 class LInnerAllocatedObject FINAL: public LTemplateInstruction<1, 2, 0> {
1820 LInnerAllocatedObject(LOperand* base_object, LOperand* offset) {
1821 inputs_[0] = base_object;
1822 inputs_[1] = offset;
1825 LOperand* base_object() const { return inputs_[0]; }
1826 LOperand* offset() const { return inputs_[1]; }
1828 virtual void PrintDataTo(StringStream* stream) OVERRIDE;
1830 DECLARE_CONCRETE_INSTRUCTION(InnerAllocatedObject, "inner-allocated-object")
1834 class LThisFunction FINAL : public LTemplateInstruction<1, 0, 0> {
1836 DECLARE_CONCRETE_INSTRUCTION(ThisFunction, "this-function")
1837 DECLARE_HYDROGEN_ACCESSOR(ThisFunction)
1841 class LContext FINAL : public LTemplateInstruction<1, 0, 0> {
1843 DECLARE_CONCRETE_INSTRUCTION(Context, "context")
1844 DECLARE_HYDROGEN_ACCESSOR(Context)
1848 class LDeclareGlobals FINAL : public LTemplateInstruction<0, 1, 0> {
1850 explicit LDeclareGlobals(LOperand* context) {
1851 inputs_[0] = context;
1854 LOperand* context() { return inputs_[0]; }
1856 DECLARE_CONCRETE_INSTRUCTION(DeclareGlobals, "declare-globals")
1857 DECLARE_HYDROGEN_ACCESSOR(DeclareGlobals)
1861 class LCallJSFunction FINAL : public LTemplateInstruction<1, 1, 0> {
1863 explicit LCallJSFunction(LOperand* function) {
1864 inputs_[0] = function;
1867 LOperand* function() { return inputs_[0]; }
1869 DECLARE_CONCRETE_INSTRUCTION(CallJSFunction, "call-js-function")
1870 DECLARE_HYDROGEN_ACCESSOR(CallJSFunction)
1872 virtual void PrintDataTo(StringStream* stream) OVERRIDE;
1874 int arity() const { return hydrogen()->argument_count() - 1; }
1878 class LCallWithDescriptor FINAL : public LTemplateResultInstruction<1> {
1880 LCallWithDescriptor(CallInterfaceDescriptor descriptor,
1881 const ZoneList<LOperand*>& operands, Zone* zone)
1882 : inputs_(descriptor.GetRegisterParameterCount() + 1, zone) {
1883 DCHECK(descriptor.GetRegisterParameterCount() + 1 == operands.length());
1884 inputs_.AddAll(operands, zone);
1887 LOperand* target() const { return inputs_[0]; }
1890 DECLARE_CONCRETE_INSTRUCTION(CallWithDescriptor, "call-with-descriptor")
1891 DECLARE_HYDROGEN_ACCESSOR(CallWithDescriptor)
1893 virtual void PrintDataTo(StringStream* stream) OVERRIDE;
1895 int arity() const { return hydrogen()->argument_count() - 1; }
1897 ZoneList<LOperand*> inputs_;
1899 // Iterator support.
1900 virtual int InputCount() FINAL OVERRIDE { return inputs_.length(); }
1901 virtual LOperand* InputAt(int i) FINAL OVERRIDE { return inputs_[i]; }
1903 virtual int TempCount() FINAL OVERRIDE { return 0; }
1904 virtual LOperand* TempAt(int i) FINAL OVERRIDE { return NULL; }
1908 class LInvokeFunction FINAL : public LTemplateInstruction<1, 2, 0> {
1910 LInvokeFunction(LOperand* context, LOperand* function) {
1911 inputs_[0] = context;
1912 inputs_[1] = function;
1915 LOperand* context() { return inputs_[0]; }
1916 LOperand* function() { return inputs_[1]; }
1918 DECLARE_CONCRETE_INSTRUCTION(InvokeFunction, "invoke-function")
1919 DECLARE_HYDROGEN_ACCESSOR(InvokeFunction)
1921 virtual void PrintDataTo(StringStream* stream) OVERRIDE;
1923 int arity() const { return hydrogen()->argument_count() - 1; }
1927 class LCallFunction FINAL : public LTemplateInstruction<1, 2, 0> {
1929 LCallFunction(LOperand* context, LOperand* function) {
1930 inputs_[0] = context;
1931 inputs_[1] = function;
1934 DECLARE_CONCRETE_INSTRUCTION(CallFunction, "call-function")
1935 DECLARE_HYDROGEN_ACCESSOR(CallFunction)
1937 LOperand* context() { return inputs_[0]; }
1938 LOperand* function() { return inputs_[1]; }
1939 int arity() const { return hydrogen()->argument_count() - 1; }
1943 class LCallNew FINAL : public LTemplateInstruction<1, 2, 0> {
1945 LCallNew(LOperand* context, LOperand* constructor) {
1946 inputs_[0] = context;
1947 inputs_[1] = constructor;
1950 LOperand* context() { return inputs_[0]; }
1951 LOperand* constructor() { return inputs_[1]; }
1953 DECLARE_CONCRETE_INSTRUCTION(CallNew, "call-new")
1954 DECLARE_HYDROGEN_ACCESSOR(CallNew)
1956 virtual void PrintDataTo(StringStream* stream) OVERRIDE;
1958 int arity() const { return hydrogen()->argument_count() - 1; }
1962 class LCallNewArray FINAL : public LTemplateInstruction<1, 2, 0> {
1964 LCallNewArray(LOperand* context, LOperand* constructor) {
1965 inputs_[0] = context;
1966 inputs_[1] = constructor;
1969 LOperand* context() { return inputs_[0]; }
1970 LOperand* constructor() { return inputs_[1]; }
1972 DECLARE_CONCRETE_INSTRUCTION(CallNewArray, "call-new-array")
1973 DECLARE_HYDROGEN_ACCESSOR(CallNewArray)
1975 virtual void PrintDataTo(StringStream* stream) OVERRIDE;
1977 int arity() const { return hydrogen()->argument_count() - 1; }
1981 class LCallRuntime FINAL : public LTemplateInstruction<1, 1, 0> {
1983 explicit LCallRuntime(LOperand* context) {
1984 inputs_[0] = context;
1987 LOperand* context() { return inputs_[0]; }
1989 DECLARE_CONCRETE_INSTRUCTION(CallRuntime, "call-runtime")
1990 DECLARE_HYDROGEN_ACCESSOR(CallRuntime)
1992 virtual bool ClobbersDoubleRegisters(Isolate* isolate) const OVERRIDE {
1993 return save_doubles() == kDontSaveFPRegs;
1996 const Runtime::Function* function() const { return hydrogen()->function(); }
1997 int arity() const { return hydrogen()->argument_count(); }
1998 SaveFPRegsMode save_doubles() const { return hydrogen()->save_doubles(); }
2002 class LInteger32ToDouble FINAL : public LTemplateInstruction<1, 1, 0> {
2004 explicit LInteger32ToDouble(LOperand* value) {
2008 LOperand* value() { return inputs_[0]; }
2010 DECLARE_CONCRETE_INSTRUCTION(Integer32ToDouble, "int32-to-double")
2014 class LUint32ToDouble FINAL : public LTemplateInstruction<1, 1, 0> {
2016 explicit LUint32ToDouble(LOperand* value) {
2020 LOperand* value() { return inputs_[0]; }
2022 DECLARE_CONCRETE_INSTRUCTION(Uint32ToDouble, "uint32-to-double")
2026 class LNumberTagI FINAL : public LTemplateInstruction<1, 1, 2> {
2028 LNumberTagI(LOperand* value, LOperand* temp1, LOperand* temp2) {
2034 LOperand* value() { return inputs_[0]; }
2035 LOperand* temp1() { return temps_[0]; }
2036 LOperand* temp2() { return temps_[1]; }
2038 DECLARE_CONCRETE_INSTRUCTION(NumberTagI, "number-tag-i")
2042 class LNumberTagU FINAL : public LTemplateInstruction<1, 1, 2> {
2044 LNumberTagU(LOperand* value, LOperand* temp1, LOperand* temp2) {
2050 LOperand* value() { return inputs_[0]; }
2051 LOperand* temp1() { return temps_[0]; }
2052 LOperand* temp2() { return temps_[1]; }
2054 DECLARE_CONCRETE_INSTRUCTION(NumberTagU, "number-tag-u")
2058 class LNumberTagD FINAL : public LTemplateInstruction<1, 1, 1> {
2060 explicit LNumberTagD(LOperand* value, LOperand* temp) {
2065 LOperand* value() { return inputs_[0]; }
2066 LOperand* temp() { return temps_[0]; }
2068 DECLARE_CONCRETE_INSTRUCTION(NumberTagD, "number-tag-d")
2069 DECLARE_HYDROGEN_ACCESSOR(Change)
2073 // Sometimes truncating conversion from a tagged value to an int32.
2074 class LDoubleToI FINAL : public LTemplateInstruction<1, 1, 0> {
2076 explicit LDoubleToI(LOperand* value) {
2080 LOperand* value() { return inputs_[0]; }
2082 DECLARE_CONCRETE_INSTRUCTION(DoubleToI, "double-to-i")
2083 DECLARE_HYDROGEN_ACCESSOR(UnaryOperation)
2085 bool truncating() { return hydrogen()->CanTruncateToInt32(); }
2089 class LDoubleToSmi FINAL : public LTemplateInstruction<1, 1, 0> {
2091 explicit LDoubleToSmi(LOperand* value) {
2095 LOperand* value() { return inputs_[0]; }
2097 DECLARE_CONCRETE_INSTRUCTION(DoubleToSmi, "double-to-smi")
2098 DECLARE_HYDROGEN_ACCESSOR(UnaryOperation)
2102 // Truncating conversion from a tagged value to an int32.
2103 class LTaggedToI FINAL : public LTemplateInstruction<1, 1, 1> {
2105 LTaggedToI(LOperand* value, LOperand* temp) {
2110 LOperand* value() { return inputs_[0]; }
2111 LOperand* temp() { return temps_[0]; }
2113 DECLARE_CONCRETE_INSTRUCTION(TaggedToI, "tagged-to-i")
2114 DECLARE_HYDROGEN_ACCESSOR(Change)
2116 bool truncating() { return hydrogen()->CanTruncateToInt32(); }
2120 class LSmiTag FINAL : public LTemplateInstruction<1, 1, 0> {
2122 explicit LSmiTag(LOperand* value) {
2126 LOperand* value() { return inputs_[0]; }
2128 DECLARE_CONCRETE_INSTRUCTION(SmiTag, "smi-tag")
2129 DECLARE_HYDROGEN_ACCESSOR(Change)
2133 class LNumberUntagD FINAL : public LTemplateInstruction<1, 1, 0> {
2135 explicit LNumberUntagD(LOperand* value) {
2139 LOperand* value() { return inputs_[0]; }
2141 DECLARE_CONCRETE_INSTRUCTION(NumberUntagD, "double-untag")
2142 DECLARE_HYDROGEN_ACCESSOR(Change);
2146 class LSmiUntag FINAL : public LTemplateInstruction<1, 1, 0> {
2148 LSmiUntag(LOperand* value, bool needs_check)
2149 : needs_check_(needs_check) {
2153 LOperand* value() { return inputs_[0]; }
2154 bool needs_check() const { return needs_check_; }
2156 DECLARE_CONCRETE_INSTRUCTION(SmiUntag, "smi-untag")
2163 class LStoreNamedField FINAL : public LTemplateInstruction<0, 2, 1> {
2165 LStoreNamedField(LOperand* object, LOperand* value, LOperand* temp) {
2166 inputs_[0] = object;
2171 LOperand* object() { return inputs_[0]; }
2172 LOperand* value() { return inputs_[1]; }
2173 LOperand* temp() { return temps_[0]; }
2175 DECLARE_CONCRETE_INSTRUCTION(StoreNamedField, "store-named-field")
2176 DECLARE_HYDROGEN_ACCESSOR(StoreNamedField)
2178 virtual void PrintDataTo(StringStream* stream) OVERRIDE;
2180 Representation representation() const {
2181 return hydrogen()->field_representation();
2186 class LStoreNamedGeneric FINAL : public LTemplateInstruction<0, 3, 0> {
2188 LStoreNamedGeneric(LOperand* context, LOperand* object, LOperand* value) {
2189 inputs_[0] = context;
2190 inputs_[1] = object;
2194 LOperand* context() { return inputs_[0]; }
2195 LOperand* object() { return inputs_[1]; }
2196 LOperand* value() { return inputs_[2]; }
2198 DECLARE_CONCRETE_INSTRUCTION(StoreNamedGeneric, "store-named-generic")
2199 DECLARE_HYDROGEN_ACCESSOR(StoreNamedGeneric)
2201 virtual void PrintDataTo(StringStream* stream) OVERRIDE;
2203 Handle<Object> name() const { return hydrogen()->name(); }
2204 StrictMode strict_mode() { return hydrogen()->strict_mode(); }
2208 class LStoreKeyed FINAL : public LTemplateInstruction<0, 3, 0> {
2210 LStoreKeyed(LOperand* object, LOperand* key, LOperand* value) {
2211 inputs_[0] = object;
2216 bool is_external() const { return hydrogen()->is_external(); }
2217 bool is_fixed_typed_array() const {
2218 return hydrogen()->is_fixed_typed_array();
2220 bool is_typed_elements() const {
2221 return is_external() || is_fixed_typed_array();
2223 LOperand* elements() { return inputs_[0]; }
2224 LOperand* key() { return inputs_[1]; }
2225 LOperand* value() { return inputs_[2]; }
2226 ElementsKind elements_kind() const { return hydrogen()->elements_kind(); }
2228 DECLARE_CONCRETE_INSTRUCTION(StoreKeyed, "store-keyed")
2229 DECLARE_HYDROGEN_ACCESSOR(StoreKeyed)
2231 virtual void PrintDataTo(StringStream* stream) OVERRIDE;
2232 bool NeedsCanonicalization() { return hydrogen()->NeedsCanonicalization(); }
2233 uint32_t base_offset() const { return hydrogen()->base_offset(); }
2237 class LStoreKeyedGeneric FINAL : public LTemplateInstruction<0, 4, 0> {
2239 LStoreKeyedGeneric(LOperand* context,
2243 inputs_[0] = context;
2244 inputs_[1] = object;
2249 LOperand* context() { return inputs_[0]; }
2250 LOperand* object() { return inputs_[1]; }
2251 LOperand* key() { return inputs_[2]; }
2252 LOperand* value() { return inputs_[3]; }
2254 DECLARE_CONCRETE_INSTRUCTION(StoreKeyedGeneric, "store-keyed-generic")
2255 DECLARE_HYDROGEN_ACCESSOR(StoreKeyedGeneric)
2257 virtual void PrintDataTo(StringStream* stream) OVERRIDE;
2259 StrictMode strict_mode() { return hydrogen()->strict_mode(); }
2263 class LTransitionElementsKind FINAL : public LTemplateInstruction<0, 2, 2> {
2265 LTransitionElementsKind(LOperand* object,
2267 LOperand* new_map_temp,
2269 inputs_[0] = object;
2270 inputs_[1] = context;
2271 temps_[0] = new_map_temp;
2275 LOperand* object() { return inputs_[0]; }
2276 LOperand* context() { return inputs_[1]; }
2277 LOperand* new_map_temp() { return temps_[0]; }
2278 LOperand* temp() { return temps_[1]; }
2280 DECLARE_CONCRETE_INSTRUCTION(TransitionElementsKind,
2281 "transition-elements-kind")
2282 DECLARE_HYDROGEN_ACCESSOR(TransitionElementsKind)
2284 virtual void PrintDataTo(StringStream* stream) OVERRIDE;
2286 Handle<Map> original_map() { return hydrogen()->original_map().handle(); }
2287 Handle<Map> transitioned_map() {
2288 return hydrogen()->transitioned_map().handle();
2290 ElementsKind from_kind() { return hydrogen()->from_kind(); }
2291 ElementsKind to_kind() { return hydrogen()->to_kind(); }
2295 class LTrapAllocationMemento FINAL : public LTemplateInstruction<0, 1, 1> {
2297 LTrapAllocationMemento(LOperand* object,
2299 inputs_[0] = object;
2303 LOperand* object() { return inputs_[0]; }
2304 LOperand* temp() { return temps_[0]; }
2306 DECLARE_CONCRETE_INSTRUCTION(TrapAllocationMemento,
2307 "trap-allocation-memento")
2311 class LStringAdd FINAL : public LTemplateInstruction<1, 3, 0> {
2313 LStringAdd(LOperand* context, LOperand* left, LOperand* right) {
2314 inputs_[0] = context;
2319 LOperand* context() { return inputs_[0]; }
2320 LOperand* left() { return inputs_[1]; }
2321 LOperand* right() { return inputs_[2]; }
2323 DECLARE_CONCRETE_INSTRUCTION(StringAdd, "string-add")
2324 DECLARE_HYDROGEN_ACCESSOR(StringAdd)
2328 class LStringCharCodeAt FINAL : public LTemplateInstruction<1, 3, 0> {
2330 LStringCharCodeAt(LOperand* context, LOperand* string, LOperand* index) {
2331 inputs_[0] = context;
2332 inputs_[1] = string;
2336 LOperand* context() { return inputs_[0]; }
2337 LOperand* string() { return inputs_[1]; }
2338 LOperand* index() { return inputs_[2]; }
2340 DECLARE_CONCRETE_INSTRUCTION(StringCharCodeAt, "string-char-code-at")
2341 DECLARE_HYDROGEN_ACCESSOR(StringCharCodeAt)
2345 class LStringCharFromCode FINAL : public LTemplateInstruction<1, 2, 0> {
2347 explicit LStringCharFromCode(LOperand* context, LOperand* char_code) {
2348 inputs_[0] = context;
2349 inputs_[1] = char_code;
2352 LOperand* context() { return inputs_[0]; }
2353 LOperand* char_code() { return inputs_[1]; }
2355 DECLARE_CONCRETE_INSTRUCTION(StringCharFromCode, "string-char-from-code")
2356 DECLARE_HYDROGEN_ACCESSOR(StringCharFromCode)
2360 class LCheckValue FINAL : public LTemplateInstruction<0, 1, 0> {
2362 explicit LCheckValue(LOperand* value) {
2366 LOperand* value() { return inputs_[0]; }
2368 DECLARE_CONCRETE_INSTRUCTION(CheckValue, "check-value")
2369 DECLARE_HYDROGEN_ACCESSOR(CheckValue)
2373 class LCheckInstanceType FINAL : public LTemplateInstruction<0, 1, 0> {
2375 explicit LCheckInstanceType(LOperand* value) {
2379 LOperand* value() { return inputs_[0]; }
2381 DECLARE_CONCRETE_INSTRUCTION(CheckInstanceType, "check-instance-type")
2382 DECLARE_HYDROGEN_ACCESSOR(CheckInstanceType)
2386 class LCheckMaps FINAL : public LTemplateInstruction<0, 1, 0> {
2388 explicit LCheckMaps(LOperand* value = NULL) {
2392 LOperand* value() { return inputs_[0]; }
2394 DECLARE_CONCRETE_INSTRUCTION(CheckMaps, "check-maps")
2395 DECLARE_HYDROGEN_ACCESSOR(CheckMaps)
2399 class LCheckSmi FINAL : public LTemplateInstruction<1, 1, 0> {
2401 explicit LCheckSmi(LOperand* value) {
2405 LOperand* value() { return inputs_[0]; }
2407 DECLARE_CONCRETE_INSTRUCTION(CheckSmi, "check-smi")
2411 class LClampDToUint8 FINAL : public LTemplateInstruction<1, 1, 0> {
2413 explicit LClampDToUint8(LOperand* unclamped) {
2414 inputs_[0] = unclamped;
2417 LOperand* unclamped() { return inputs_[0]; }
2419 DECLARE_CONCRETE_INSTRUCTION(ClampDToUint8, "clamp-d-to-uint8")
2423 class LClampIToUint8 FINAL : public LTemplateInstruction<1, 1, 0> {
2425 explicit LClampIToUint8(LOperand* unclamped) {
2426 inputs_[0] = unclamped;
2429 LOperand* unclamped() { return inputs_[0]; }
2431 DECLARE_CONCRETE_INSTRUCTION(ClampIToUint8, "clamp-i-to-uint8")
2435 class LClampTToUint8 FINAL : public LTemplateInstruction<1, 1, 1> {
2437 LClampTToUint8(LOperand* unclamped,
2438 LOperand* temp_xmm) {
2439 inputs_[0] = unclamped;
2440 temps_[0] = temp_xmm;
2443 LOperand* unclamped() { return inputs_[0]; }
2444 LOperand* temp_xmm() { return temps_[0]; }
2446 DECLARE_CONCRETE_INSTRUCTION(ClampTToUint8, "clamp-t-to-uint8")
2450 class LCheckNonSmi FINAL : public LTemplateInstruction<0, 1, 0> {
2452 explicit LCheckNonSmi(LOperand* value) {
2456 LOperand* value() { return inputs_[0]; }
2458 DECLARE_CONCRETE_INSTRUCTION(CheckNonSmi, "check-non-smi")
2459 DECLARE_HYDROGEN_ACCESSOR(CheckHeapObject)
2463 class LDoubleBits FINAL : public LTemplateInstruction<1, 1, 0> {
2465 explicit LDoubleBits(LOperand* value) {
2469 LOperand* value() { return inputs_[0]; }
2471 DECLARE_CONCRETE_INSTRUCTION(DoubleBits, "double-bits")
2472 DECLARE_HYDROGEN_ACCESSOR(DoubleBits)
2476 class LConstructDouble FINAL : public LTemplateInstruction<1, 2, 0> {
2478 LConstructDouble(LOperand* hi, LOperand* lo) {
2483 LOperand* hi() { return inputs_[0]; }
2484 LOperand* lo() { return inputs_[1]; }
2486 DECLARE_CONCRETE_INSTRUCTION(ConstructDouble, "construct-double")
2490 class LAllocate FINAL : public LTemplateInstruction<1, 2, 1> {
2492 LAllocate(LOperand* context, LOperand* size, LOperand* temp) {
2493 inputs_[0] = context;
2498 LOperand* context() { return inputs_[0]; }
2499 LOperand* size() { return inputs_[1]; }
2500 LOperand* temp() { return temps_[0]; }
2502 DECLARE_CONCRETE_INSTRUCTION(Allocate, "allocate")
2503 DECLARE_HYDROGEN_ACCESSOR(Allocate)
2507 class LRegExpLiteral FINAL : public LTemplateInstruction<1, 1, 0> {
2509 explicit LRegExpLiteral(LOperand* context) {
2510 inputs_[0] = context;
2513 LOperand* context() { return inputs_[0]; }
2515 DECLARE_CONCRETE_INSTRUCTION(RegExpLiteral, "regexp-literal")
2516 DECLARE_HYDROGEN_ACCESSOR(RegExpLiteral)
2520 class LFunctionLiteral FINAL : public LTemplateInstruction<1, 1, 0> {
2522 explicit LFunctionLiteral(LOperand* context) {
2523 inputs_[0] = context;
2526 LOperand* context() { return inputs_[0]; }
2528 DECLARE_CONCRETE_INSTRUCTION(FunctionLiteral, "function-literal")
2529 DECLARE_HYDROGEN_ACCESSOR(FunctionLiteral)
2533 class LToFastProperties FINAL : public LTemplateInstruction<1, 1, 0> {
2535 explicit LToFastProperties(LOperand* value) {
2539 LOperand* value() { return inputs_[0]; }
2541 DECLARE_CONCRETE_INSTRUCTION(ToFastProperties, "to-fast-properties")
2542 DECLARE_HYDROGEN_ACCESSOR(ToFastProperties)
2546 class LTypeof FINAL : public LTemplateInstruction<1, 2, 0> {
2548 LTypeof(LOperand* context, LOperand* value) {
2549 inputs_[0] = context;
2553 LOperand* context() { return inputs_[0]; }
2554 LOperand* value() { return inputs_[1]; }
2556 DECLARE_CONCRETE_INSTRUCTION(Typeof, "typeof")
2560 class LTypeofIsAndBranch FINAL : public LControlInstruction<1, 0> {
2562 explicit LTypeofIsAndBranch(LOperand* value) {
2566 LOperand* value() { return inputs_[0]; }
2568 DECLARE_CONCRETE_INSTRUCTION(TypeofIsAndBranch, "typeof-is-and-branch")
2569 DECLARE_HYDROGEN_ACCESSOR(TypeofIsAndBranch)
2571 Handle<String> type_literal() { return hydrogen()->type_literal(); }
2573 virtual void PrintDataTo(StringStream* stream) OVERRIDE;
2577 class LIsConstructCallAndBranch FINAL : public LControlInstruction<0, 1> {
2579 explicit LIsConstructCallAndBranch(LOperand* temp) {
2583 LOperand* temp() { return temps_[0]; }
2585 DECLARE_CONCRETE_INSTRUCTION(IsConstructCallAndBranch,
2586 "is-construct-call-and-branch")
2587 DECLARE_HYDROGEN_ACCESSOR(IsConstructCallAndBranch)
2591 class LOsrEntry FINAL : public LTemplateInstruction<0, 0, 0> {
2595 virtual bool HasInterestingComment(LCodeGen* gen) const OVERRIDE {
2598 DECLARE_CONCRETE_INSTRUCTION(OsrEntry, "osr-entry")
2602 class LStackCheck FINAL : public LTemplateInstruction<0, 1, 0> {
2604 explicit LStackCheck(LOperand* context) {
2605 inputs_[0] = context;
2608 LOperand* context() { return inputs_[0]; }
2610 DECLARE_CONCRETE_INSTRUCTION(StackCheck, "stack-check")
2611 DECLARE_HYDROGEN_ACCESSOR(StackCheck)
2613 Label* done_label() { return &done_label_; }
2620 class LForInPrepareMap FINAL : public LTemplateInstruction<1, 2, 0> {
2622 LForInPrepareMap(LOperand* context, LOperand* object) {
2623 inputs_[0] = context;
2624 inputs_[1] = object;
2627 LOperand* context() { return inputs_[0]; }
2628 LOperand* object() { return inputs_[1]; }
2630 DECLARE_CONCRETE_INSTRUCTION(ForInPrepareMap, "for-in-prepare-map")
2634 class LForInCacheArray FINAL : public LTemplateInstruction<1, 1, 0> {
2636 explicit LForInCacheArray(LOperand* map) {
2640 LOperand* map() { return inputs_[0]; }
2642 DECLARE_CONCRETE_INSTRUCTION(ForInCacheArray, "for-in-cache-array")
2645 return HForInCacheArray::cast(this->hydrogen_value())->idx();
2650 class LCheckMapValue FINAL : public LTemplateInstruction<0, 2, 0> {
2652 LCheckMapValue(LOperand* value, LOperand* map) {
2657 LOperand* value() { return inputs_[0]; }
2658 LOperand* map() { return inputs_[1]; }
2660 DECLARE_CONCRETE_INSTRUCTION(CheckMapValue, "check-map-value")
2664 class LLoadFieldByIndex FINAL : public LTemplateInstruction<1, 2, 0> {
2666 LLoadFieldByIndex(LOperand* object, LOperand* index) {
2667 inputs_[0] = object;
2671 LOperand* object() { return inputs_[0]; }
2672 LOperand* index() { return inputs_[1]; }
2674 DECLARE_CONCRETE_INSTRUCTION(LoadFieldByIndex, "load-field-by-index")
2678 class LStoreFrameContext: public LTemplateInstruction<0, 1, 0> {
2680 explicit LStoreFrameContext(LOperand* context) {
2681 inputs_[0] = context;
2684 LOperand* context() { return inputs_[0]; }
2686 DECLARE_CONCRETE_INSTRUCTION(StoreFrameContext, "store-frame-context")
2690 class LAllocateBlockContext: public LTemplateInstruction<1, 2, 0> {
2692 LAllocateBlockContext(LOperand* context, LOperand* function) {
2693 inputs_[0] = context;
2694 inputs_[1] = function;
2697 LOperand* context() { return inputs_[0]; }
2698 LOperand* function() { return inputs_[1]; }
2700 Handle<ScopeInfo> scope_info() { return hydrogen()->scope_info(); }
2702 DECLARE_CONCRETE_INSTRUCTION(AllocateBlockContext, "allocate-block-context")
2703 DECLARE_HYDROGEN_ACCESSOR(AllocateBlockContext)
2707 class LChunkBuilder;
2708 class LPlatformChunk FINAL : public LChunk {
2710 LPlatformChunk(CompilationInfo* info, HGraph* graph)
2711 : LChunk(info, graph),
2712 dehoisted_key_ids_(graph->GetMaximumValueID(), graph->zone()) { }
2714 int GetNextSpillIndex(RegisterKind kind);
2715 LOperand* GetNextSpillSlot(RegisterKind kind);
2716 BitVector* GetDehoistedKeyIds() { return &dehoisted_key_ids_; }
2717 bool IsDehoistedKey(HValue* value) {
2718 return dehoisted_key_ids_.Contains(value->id());
2722 BitVector dehoisted_key_ids_;
2726 class LChunkBuilder FINAL : public LChunkBuilderBase {
2728 LChunkBuilder(CompilationInfo* info, HGraph* graph, LAllocator* allocator)
2729 : LChunkBuilderBase(graph->zone()),
2734 current_instruction_(NULL),
2735 current_block_(NULL),
2737 allocator_(allocator) { }
2739 Isolate* isolate() const { return graph_->isolate(); }
2741 // Build the sequence for the graph.
2742 LPlatformChunk* Build();
2744 // Declare methods that deal with the individual node types.
2745 #define DECLARE_DO(type) LInstruction* Do##type(H##type* node);
2746 HYDROGEN_CONCRETE_INSTRUCTION_LIST(DECLARE_DO)
2749 LInstruction* DoMathFloor(HUnaryMathOperation* instr);
2750 LInstruction* DoMathRound(HUnaryMathOperation* instr);
2751 LInstruction* DoMathFround(HUnaryMathOperation* instr);
2752 LInstruction* DoMathAbs(HUnaryMathOperation* instr);
2753 LInstruction* DoMathLog(HUnaryMathOperation* instr);
2754 LInstruction* DoMathExp(HUnaryMathOperation* instr);
2755 LInstruction* DoMathSqrt(HUnaryMathOperation* instr);
2756 LInstruction* DoMathPowHalf(HUnaryMathOperation* instr);
2757 LInstruction* DoMathClz32(HUnaryMathOperation* instr);
2758 LInstruction* DoDivByPowerOf2I(HDiv* instr);
2759 LInstruction* DoDivByConstI(HDiv* instr);
2760 LInstruction* DoDivI(HDiv* instr);
2761 LInstruction* DoModByPowerOf2I(HMod* instr);
2762 LInstruction* DoModByConstI(HMod* instr);
2763 LInstruction* DoModI(HMod* instr);
2764 LInstruction* DoFlooringDivByPowerOf2I(HMathFloorOfDiv* instr);
2765 LInstruction* DoFlooringDivByConstI(HMathFloorOfDiv* instr);
2766 LInstruction* DoFlooringDivI(HMathFloorOfDiv* instr);
2776 LPlatformChunk* chunk() const { return chunk_; }
2777 CompilationInfo* info() const { return info_; }
2778 HGraph* graph() const { return graph_; }
2780 bool is_unused() const { return status_ == UNUSED; }
2781 bool is_building() const { return status_ == BUILDING; }
2782 bool is_done() const { return status_ == DONE; }
2783 bool is_aborted() const { return status_ == ABORTED; }
2785 void Abort(BailoutReason reason);
2787 // Methods for getting operands for Use / Define / Temp.
2788 LUnallocated* ToUnallocated(Register reg);
2789 LUnallocated* ToUnallocated(XMMRegister reg);
2791 // Methods for setting up define-use relationships.
2792 MUST_USE_RESULT LOperand* Use(HValue* value, LUnallocated* operand);
2793 MUST_USE_RESULT LOperand* UseFixed(HValue* value, Register fixed_register);
2794 MUST_USE_RESULT LOperand* UseFixedDouble(HValue* value,
2795 XMMRegister fixed_register);
2797 // A value that is guaranteed to be allocated to a register.
2798 // Operand created by UseRegister is guaranteed to be live until the end of
2799 // instruction. This means that register allocator will not reuse it's
2800 // register for any other operand inside instruction.
2801 // Operand created by UseRegisterAtStart is guaranteed to be live only at
2802 // instruction start. Register allocator is free to assign the same register
2803 // to some other operand used inside instruction (i.e. temporary or
2805 MUST_USE_RESULT LOperand* UseRegister(HValue* value);
2806 MUST_USE_RESULT LOperand* UseRegisterAtStart(HValue* value);
2808 // An input operand in a register that may be trashed.
2809 MUST_USE_RESULT LOperand* UseTempRegister(HValue* value);
2811 // An input operand in a register that may be trashed or a constant operand.
2812 MUST_USE_RESULT LOperand* UseTempRegisterOrConstant(HValue* value);
2814 // An input operand in a register or stack slot.
2815 MUST_USE_RESULT LOperand* Use(HValue* value);
2816 MUST_USE_RESULT LOperand* UseAtStart(HValue* value);
2818 // An input operand in a register, stack slot or a constant operand.
2819 MUST_USE_RESULT LOperand* UseOrConstant(HValue* value);
2820 MUST_USE_RESULT LOperand* UseOrConstantAtStart(HValue* value);
2822 // An input operand in a register or a constant operand.
2823 MUST_USE_RESULT LOperand* UseRegisterOrConstant(HValue* value);
2824 MUST_USE_RESULT LOperand* UseRegisterOrConstantAtStart(HValue* value);
2826 // An input operand in a constant operand.
2827 MUST_USE_RESULT LOperand* UseConstant(HValue* value);
2829 // An input operand in register, stack slot or a constant operand.
2830 // Will not be moved to a register even if one is freely available.
2831 virtual MUST_USE_RESULT LOperand* UseAny(HValue* value) OVERRIDE;
2833 // Temporary operand that must be in a register.
2834 MUST_USE_RESULT LUnallocated* TempRegister();
2835 MUST_USE_RESULT LOperand* FixedTemp(Register reg);
2836 MUST_USE_RESULT LOperand* FixedTemp(XMMRegister reg);
2838 // Methods for setting up define-use relationships.
2839 // Return the same instruction that they are passed.
2840 LInstruction* Define(LTemplateResultInstruction<1>* instr,
2841 LUnallocated* result);
2842 LInstruction* DefineAsRegister(LTemplateResultInstruction<1>* instr);
2843 LInstruction* DefineAsSpilled(LTemplateResultInstruction<1>* instr,
2845 LInstruction* DefineSameAsFirst(LTemplateResultInstruction<1>* instr);
2846 LInstruction* DefineFixed(LTemplateResultInstruction<1>* instr,
2848 LInstruction* DefineFixedDouble(LTemplateResultInstruction<1>* instr,
2850 // Assigns an environment to an instruction. An instruction which can
2851 // deoptimize must have an environment.
2852 LInstruction* AssignEnvironment(LInstruction* instr);
2853 // Assigns a pointer map to an instruction. An instruction which can
2854 // trigger a GC or a lazy deoptimization must have a pointer map.
2855 LInstruction* AssignPointerMap(LInstruction* instr);
2857 enum CanDeoptimize { CAN_DEOPTIMIZE_EAGERLY, CANNOT_DEOPTIMIZE_EAGERLY };
2859 // Marks a call for the register allocator. Assigns a pointer map to
2860 // support GC and lazy deoptimization. Assigns an environment to support
2861 // eager deoptimization if CAN_DEOPTIMIZE_EAGERLY.
2862 LInstruction* MarkAsCall(
2863 LInstruction* instr,
2864 HInstruction* hinstr,
2865 CanDeoptimize can_deoptimize = CANNOT_DEOPTIMIZE_EAGERLY);
2867 void VisitInstruction(HInstruction* current);
2868 void AddInstruction(LInstruction* instr, HInstruction* current);
2870 void DoBasicBlock(HBasicBlock* block, HBasicBlock* next_block);
2871 LInstruction* DoShift(Token::Value op, HBitwiseBinaryOperation* instr);
2872 LInstruction* DoArithmeticD(Token::Value op,
2873 HArithmeticBinaryOperation* instr);
2874 LInstruction* DoArithmeticT(Token::Value op,
2875 HBinaryOperation* instr);
2876 void FindDehoistedKeyDefinitions(HValue* candidate);
2878 LPlatformChunk* chunk_;
2879 CompilationInfo* info_;
2880 HGraph* const graph_;
2882 HInstruction* current_instruction_;
2883 HBasicBlock* current_block_;
2884 HBasicBlock* next_block_;
2885 LAllocator* allocator_;
2887 DISALLOW_COPY_AND_ASSIGN(LChunkBuilder);
2890 #undef DECLARE_HYDROGEN_ACCESSOR
2891 #undef DECLARE_CONCRETE_INSTRUCTION
2893 } } // namespace v8::int
2895 #endif // V8_X64_LITHIUM_X64_H_