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) \
133 V(SeqStringGetChar) \
134 V(SeqStringSetChar) \
140 V(StoreContextSlot) \
141 V(StoreFrameContext) \
144 V(StoreKeyedGeneric) \
146 V(StoreNamedGeneric) \
148 V(StringCharCodeAt) \
149 V(StringCharFromCode) \
150 V(StringCompareAndBranch) \
154 V(ToFastProperties) \
155 V(TransitionElementsKind) \
156 V(TrapAllocationMemento) \
158 V(TypeofIsAndBranch) \
164 #define DECLARE_CONCRETE_INSTRUCTION(type, mnemonic) \
165 virtual Opcode opcode() const V8_FINAL V8_OVERRIDE { \
166 return LInstruction::k##type; \
168 virtual void CompileToNative(LCodeGen* generator) V8_FINAL V8_OVERRIDE; \
169 virtual const char* Mnemonic() const V8_FINAL V8_OVERRIDE { \
172 static L##type* cast(LInstruction* instr) { \
173 ASSERT(instr->Is##type()); \
174 return reinterpret_cast<L##type*>(instr); \
178 #define DECLARE_HYDROGEN_ACCESSOR(type) \
179 H##type* hydrogen() const { \
180 return H##type::cast(hydrogen_value()); \
184 class LInstruction : public ZoneObject {
187 : environment_(NULL),
188 hydrogen_value_(NULL),
189 bit_field_(IsCallBits::encode(false)) {
192 virtual ~LInstruction() {}
194 virtual void CompileToNative(LCodeGen* generator) = 0;
195 virtual const char* Mnemonic() const = 0;
196 virtual void PrintTo(StringStream* stream);
197 virtual void PrintDataTo(StringStream* stream);
198 virtual void PrintOutputOperandTo(StringStream* stream);
201 // Declare a unique enum value for each instruction.
202 #define DECLARE_OPCODE(type) k##type,
203 LITHIUM_CONCRETE_INSTRUCTION_LIST(DECLARE_OPCODE)
204 kNumberOfInstructions
205 #undef DECLARE_OPCODE
208 virtual Opcode opcode() const = 0;
210 // Declare non-virtual type testers for all leaf IR classes.
211 #define DECLARE_PREDICATE(type) \
212 bool Is##type() const { return opcode() == k##type; }
213 LITHIUM_CONCRETE_INSTRUCTION_LIST(DECLARE_PREDICATE)
214 #undef DECLARE_PREDICATE
216 // Declare virtual predicates for instructions that don't have
218 virtual bool IsGap() const { return false; }
220 virtual bool IsControl() const { return false; }
222 void set_environment(LEnvironment* env) { environment_ = env; }
223 LEnvironment* environment() const { return environment_; }
224 bool HasEnvironment() const { return environment_ != NULL; }
226 void set_pointer_map(LPointerMap* p) { pointer_map_.set(p); }
227 LPointerMap* pointer_map() const { return pointer_map_.get(); }
228 bool HasPointerMap() const { return pointer_map_.is_set(); }
230 void set_hydrogen_value(HValue* value) { hydrogen_value_ = value; }
231 HValue* hydrogen_value() const { return hydrogen_value_; }
233 void MarkAsCall() { bit_field_ = IsCallBits::update(bit_field_, true); }
234 bool IsCall() const { return IsCallBits::decode(bit_field_); }
236 // Interface to the register allocator and iterators.
237 bool ClobbersTemps() const { return IsCall(); }
238 bool ClobbersRegisters() const { return IsCall(); }
239 virtual bool ClobbersDoubleRegisters(Isolate* isolate) const {
243 virtual void SetDeferredLazyDeoptimizationEnvironment(LEnvironment* env) { }
245 // Interface to the register allocator and iterators.
246 bool IsMarkedAsCall() const { return IsCall(); }
248 virtual bool HasResult() const = 0;
249 virtual LOperand* result() const = 0;
251 LOperand* FirstInput() { return InputAt(0); }
252 LOperand* Output() { return HasResult() ? result() : NULL; }
254 virtual bool HasInterestingComment(LCodeGen* gen) const { return true; }
256 virtual bool MustSignExtendResult(LPlatformChunk* chunk) const {
266 friend class InputIterator;
267 virtual int InputCount() = 0;
268 virtual LOperand* InputAt(int i) = 0;
270 friend class TempIterator;
271 virtual int TempCount() = 0;
272 virtual LOperand* TempAt(int i) = 0;
274 class IsCallBits: public BitField<bool, 0, 1> {};
276 LEnvironment* environment_;
277 SetOncePointer<LPointerMap> pointer_map_;
278 HValue* hydrogen_value_;
283 // R = number of result operands (0 or 1).
285 class LTemplateResultInstruction : public LInstruction {
287 // Allow 0 or 1 output operands.
288 STATIC_ASSERT(R == 0 || R == 1);
289 virtual bool HasResult() const V8_FINAL V8_OVERRIDE {
290 return R != 0 && result() != NULL;
292 void set_result(LOperand* operand) { results_[0] = operand; }
293 LOperand* result() const { return results_[0]; }
295 virtual bool MustSignExtendResult(
296 LPlatformChunk* chunk) const V8_FINAL V8_OVERRIDE;
299 EmbeddedContainer<LOperand*, R> results_;
303 // R = number of result operands (0 or 1).
304 // I = number of input operands.
305 // T = number of temporary operands.
306 template<int R, int I, int T>
307 class LTemplateInstruction : public LTemplateResultInstruction<R> {
309 EmbeddedContainer<LOperand*, I> inputs_;
310 EmbeddedContainer<LOperand*, T> temps_;
314 virtual int InputCount() V8_FINAL V8_OVERRIDE { return I; }
315 virtual LOperand* InputAt(int i) V8_FINAL V8_OVERRIDE { return inputs_[i]; }
317 virtual int TempCount() V8_FINAL V8_OVERRIDE { return T; }
318 virtual LOperand* TempAt(int i) V8_FINAL V8_OVERRIDE { return temps_[i]; }
322 class LGap : public LTemplateInstruction<0, 0, 0> {
324 explicit LGap(HBasicBlock* block)
326 parallel_moves_[BEFORE] = NULL;
327 parallel_moves_[START] = NULL;
328 parallel_moves_[END] = NULL;
329 parallel_moves_[AFTER] = NULL;
332 // Can't use the DECLARE-macro here because of sub-classes.
333 virtual bool IsGap() const V8_FINAL V8_OVERRIDE { return true; }
334 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
335 static LGap* cast(LInstruction* instr) {
336 ASSERT(instr->IsGap());
337 return reinterpret_cast<LGap*>(instr);
340 bool IsRedundant() const;
342 HBasicBlock* block() const { return block_; }
349 FIRST_INNER_POSITION = BEFORE,
350 LAST_INNER_POSITION = AFTER
353 LParallelMove* GetOrCreateParallelMove(InnerPosition pos,
355 if (parallel_moves_[pos] == NULL) {
356 parallel_moves_[pos] = new(zone) LParallelMove(zone);
358 return parallel_moves_[pos];
361 LParallelMove* GetParallelMove(InnerPosition pos) {
362 return parallel_moves_[pos];
366 LParallelMove* parallel_moves_[LAST_INNER_POSITION + 1];
371 class LInstructionGap V8_FINAL : public LGap {
373 explicit LInstructionGap(HBasicBlock* block) : LGap(block) { }
375 virtual bool HasInterestingComment(LCodeGen* gen) const V8_OVERRIDE {
376 return !IsRedundant();
379 DECLARE_CONCRETE_INSTRUCTION(InstructionGap, "gap")
383 class LGoto V8_FINAL : public LTemplateInstruction<0, 0, 0> {
385 explicit LGoto(HBasicBlock* block) : block_(block) { }
387 virtual bool HasInterestingComment(LCodeGen* gen) const V8_OVERRIDE;
388 DECLARE_CONCRETE_INSTRUCTION(Goto, "goto")
389 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
390 virtual bool IsControl() const V8_OVERRIDE { return true; }
392 int block_id() const { return block_->block_id(); }
399 class LLazyBailout V8_FINAL : public LTemplateInstruction<0, 0, 0> {
401 LLazyBailout() : gap_instructions_size_(0) { }
403 DECLARE_CONCRETE_INSTRUCTION(LazyBailout, "lazy-bailout")
405 void set_gap_instructions_size(int gap_instructions_size) {
406 gap_instructions_size_ = gap_instructions_size;
408 int gap_instructions_size() { return gap_instructions_size_; }
411 int gap_instructions_size_;
415 class LDummy V8_FINAL : public LTemplateInstruction<1, 0, 0> {
417 explicit LDummy() { }
418 DECLARE_CONCRETE_INSTRUCTION(Dummy, "dummy")
422 class LDummyUse V8_FINAL : public LTemplateInstruction<1, 1, 0> {
424 explicit LDummyUse(LOperand* value) {
427 DECLARE_CONCRETE_INSTRUCTION(DummyUse, "dummy-use")
431 class LDeoptimize V8_FINAL : public LTemplateInstruction<0, 0, 0> {
433 virtual bool IsControl() const V8_OVERRIDE { return true; }
434 DECLARE_CONCRETE_INSTRUCTION(Deoptimize, "deoptimize")
435 DECLARE_HYDROGEN_ACCESSOR(Deoptimize)
439 class LLabel V8_FINAL : public LGap {
441 explicit LLabel(HBasicBlock* block)
442 : LGap(block), replacement_(NULL) { }
444 virtual bool HasInterestingComment(LCodeGen* gen) const V8_OVERRIDE {
447 DECLARE_CONCRETE_INSTRUCTION(Label, "label")
449 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
451 int block_id() const { return block()->block_id(); }
452 bool is_loop_header() const { return block()->IsLoopHeader(); }
453 bool is_osr_entry() const { return block()->is_osr_entry(); }
454 Label* label() { return &label_; }
455 LLabel* replacement() const { return replacement_; }
456 void set_replacement(LLabel* label) { replacement_ = label; }
457 bool HasReplacement() const { return replacement_ != NULL; }
461 LLabel* replacement_;
465 class LParameter V8_FINAL : public LTemplateInstruction<1, 0, 0> {
467 virtual bool HasInterestingComment(LCodeGen* gen) const V8_OVERRIDE {
470 DECLARE_CONCRETE_INSTRUCTION(Parameter, "parameter")
474 class LCallStub V8_FINAL : public LTemplateInstruction<1, 1, 0> {
476 explicit LCallStub(LOperand* context) {
477 inputs_[0] = context;
480 LOperand* context() { return inputs_[0]; }
482 DECLARE_CONCRETE_INSTRUCTION(CallStub, "call-stub")
483 DECLARE_HYDROGEN_ACCESSOR(CallStub)
487 class LUnknownOSRValue V8_FINAL : public LTemplateInstruction<1, 0, 0> {
489 virtual bool HasInterestingComment(LCodeGen* gen) const V8_OVERRIDE {
492 DECLARE_CONCRETE_INSTRUCTION(UnknownOSRValue, "unknown-osr-value")
496 template<int I, int T>
497 class LControlInstruction : public LTemplateInstruction<0, I, T> {
499 LControlInstruction() : false_label_(NULL), true_label_(NULL) { }
501 virtual bool IsControl() const V8_FINAL V8_OVERRIDE { return true; }
503 int SuccessorCount() { return hydrogen()->SuccessorCount(); }
504 HBasicBlock* SuccessorAt(int i) { return hydrogen()->SuccessorAt(i); }
506 int TrueDestination(LChunk* chunk) {
507 return chunk->LookupDestination(true_block_id());
509 int FalseDestination(LChunk* chunk) {
510 return chunk->LookupDestination(false_block_id());
513 Label* TrueLabel(LChunk* chunk) {
514 if (true_label_ == NULL) {
515 true_label_ = chunk->GetAssemblyLabel(TrueDestination(chunk));
519 Label* FalseLabel(LChunk* chunk) {
520 if (false_label_ == NULL) {
521 false_label_ = chunk->GetAssemblyLabel(FalseDestination(chunk));
527 int true_block_id() { return SuccessorAt(0)->block_id(); }
528 int false_block_id() { return SuccessorAt(1)->block_id(); }
531 HControlInstruction* hydrogen() {
532 return HControlInstruction::cast(this->hydrogen_value());
540 class LWrapReceiver V8_FINAL : public LTemplateInstruction<1, 2, 0> {
542 LWrapReceiver(LOperand* receiver, LOperand* function) {
543 inputs_[0] = receiver;
544 inputs_[1] = function;
547 LOperand* receiver() { return inputs_[0]; }
548 LOperand* function() { return inputs_[1]; }
550 DECLARE_CONCRETE_INSTRUCTION(WrapReceiver, "wrap-receiver")
551 DECLARE_HYDROGEN_ACCESSOR(WrapReceiver)
555 class LApplyArguments V8_FINAL : public LTemplateInstruction<1, 4, 0> {
557 LApplyArguments(LOperand* function,
560 LOperand* elements) {
561 inputs_[0] = function;
562 inputs_[1] = receiver;
564 inputs_[3] = elements;
567 LOperand* function() { return inputs_[0]; }
568 LOperand* receiver() { return inputs_[1]; }
569 LOperand* length() { return inputs_[2]; }
570 LOperand* elements() { return inputs_[3]; }
572 DECLARE_CONCRETE_INSTRUCTION(ApplyArguments, "apply-arguments")
576 class LAccessArgumentsAt V8_FINAL : public LTemplateInstruction<1, 3, 0> {
578 LAccessArgumentsAt(LOperand* arguments, LOperand* length, LOperand* index) {
579 inputs_[0] = arguments;
584 LOperand* arguments() { return inputs_[0]; }
585 LOperand* length() { return inputs_[1]; }
586 LOperand* index() { return inputs_[2]; }
588 DECLARE_CONCRETE_INSTRUCTION(AccessArgumentsAt, "access-arguments-at")
590 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
594 class LArgumentsLength V8_FINAL : public LTemplateInstruction<1, 1, 0> {
596 explicit LArgumentsLength(LOperand* elements) {
597 inputs_[0] = elements;
600 LOperand* elements() { return inputs_[0]; }
602 DECLARE_CONCRETE_INSTRUCTION(ArgumentsLength, "arguments-length")
606 class LArgumentsElements V8_FINAL : public LTemplateInstruction<1, 0, 0> {
608 DECLARE_CONCRETE_INSTRUCTION(ArgumentsElements, "arguments-elements")
609 DECLARE_HYDROGEN_ACCESSOR(ArgumentsElements)
613 class LModByPowerOf2I V8_FINAL : public LTemplateInstruction<1, 1, 0> {
615 LModByPowerOf2I(LOperand* dividend, int32_t divisor) {
616 inputs_[0] = dividend;
620 LOperand* dividend() { return inputs_[0]; }
621 int32_t divisor() const { return divisor_; }
623 DECLARE_CONCRETE_INSTRUCTION(ModByPowerOf2I, "mod-by-power-of-2-i")
624 DECLARE_HYDROGEN_ACCESSOR(Mod)
631 class LModByConstI V8_FINAL : public LTemplateInstruction<1, 1, 2> {
633 LModByConstI(LOperand* dividend,
637 inputs_[0] = dividend;
643 LOperand* dividend() { return inputs_[0]; }
644 int32_t divisor() const { return divisor_; }
645 LOperand* temp1() { return temps_[0]; }
646 LOperand* temp2() { return temps_[1]; }
648 DECLARE_CONCRETE_INSTRUCTION(ModByConstI, "mod-by-const-i")
649 DECLARE_HYDROGEN_ACCESSOR(Mod)
656 class LModI V8_FINAL : public LTemplateInstruction<1, 2, 1> {
658 LModI(LOperand* left, LOperand* right, LOperand* temp) {
664 LOperand* left() { return inputs_[0]; }
665 LOperand* right() { return inputs_[1]; }
666 LOperand* temp() { return temps_[0]; }
668 DECLARE_CONCRETE_INSTRUCTION(ModI, "mod-i")
669 DECLARE_HYDROGEN_ACCESSOR(Mod)
673 class LDivByPowerOf2I V8_FINAL : public LTemplateInstruction<1, 1, 0> {
675 LDivByPowerOf2I(LOperand* dividend, int32_t divisor) {
676 inputs_[0] = dividend;
680 LOperand* dividend() { return inputs_[0]; }
681 int32_t divisor() const { return divisor_; }
683 DECLARE_CONCRETE_INSTRUCTION(DivByPowerOf2I, "div-by-power-of-2-i")
684 DECLARE_HYDROGEN_ACCESSOR(Div)
691 class LDivByConstI V8_FINAL : public LTemplateInstruction<1, 1, 2> {
693 LDivByConstI(LOperand* dividend,
697 inputs_[0] = dividend;
703 LOperand* dividend() { return inputs_[0]; }
704 int32_t divisor() const { return divisor_; }
705 LOperand* temp1() { return temps_[0]; }
706 LOperand* temp2() { return temps_[1]; }
708 DECLARE_CONCRETE_INSTRUCTION(DivByConstI, "div-by-const-i")
709 DECLARE_HYDROGEN_ACCESSOR(Div)
716 class LDivI V8_FINAL : public LTemplateInstruction<1, 2, 1> {
718 LDivI(LOperand* dividend, LOperand* divisor, LOperand* temp) {
719 inputs_[0] = dividend;
720 inputs_[1] = divisor;
724 LOperand* dividend() { return inputs_[0]; }
725 LOperand* divisor() { return inputs_[1]; }
726 LOperand* temp() { return temps_[0]; }
728 DECLARE_CONCRETE_INSTRUCTION(DivI, "div-i")
729 DECLARE_HYDROGEN_ACCESSOR(BinaryOperation)
733 class LFlooringDivByPowerOf2I V8_FINAL : public LTemplateInstruction<1, 1, 0> {
735 LFlooringDivByPowerOf2I(LOperand* dividend, int32_t divisor) {
736 inputs_[0] = dividend;
740 LOperand* dividend() { return inputs_[0]; }
741 int32_t divisor() const { return divisor_; }
743 DECLARE_CONCRETE_INSTRUCTION(FlooringDivByPowerOf2I,
744 "flooring-div-by-power-of-2-i")
745 DECLARE_HYDROGEN_ACCESSOR(MathFloorOfDiv)
752 class LFlooringDivByConstI V8_FINAL : public LTemplateInstruction<1, 1, 3> {
754 LFlooringDivByConstI(LOperand* dividend,
759 inputs_[0] = dividend;
766 LOperand* dividend() { return inputs_[0]; }
767 int32_t divisor() const { return divisor_; }
768 LOperand* temp1() { return temps_[0]; }
769 LOperand* temp2() { return temps_[1]; }
770 LOperand* temp3() { return temps_[2]; }
772 DECLARE_CONCRETE_INSTRUCTION(FlooringDivByConstI, "flooring-div-by-const-i")
773 DECLARE_HYDROGEN_ACCESSOR(MathFloorOfDiv)
780 class LFlooringDivI V8_FINAL : public LTemplateInstruction<1, 2, 1> {
782 LFlooringDivI(LOperand* dividend, LOperand* divisor, LOperand* temp) {
783 inputs_[0] = dividend;
784 inputs_[1] = divisor;
788 LOperand* dividend() { return inputs_[0]; }
789 LOperand* divisor() { return inputs_[1]; }
790 LOperand* temp() { return temps_[0]; }
792 DECLARE_CONCRETE_INSTRUCTION(FlooringDivI, "flooring-div-i")
793 DECLARE_HYDROGEN_ACCESSOR(MathFloorOfDiv)
797 class LMulI V8_FINAL : public LTemplateInstruction<1, 2, 0> {
799 LMulI(LOperand* left, LOperand* right) {
804 LOperand* left() { return inputs_[0]; }
805 LOperand* right() { return inputs_[1]; }
807 DECLARE_CONCRETE_INSTRUCTION(MulI, "mul-i")
808 DECLARE_HYDROGEN_ACCESSOR(Mul)
812 class LCompareNumericAndBranch V8_FINAL : public LControlInstruction<2, 0> {
814 LCompareNumericAndBranch(LOperand* left, LOperand* right) {
819 LOperand* left() { return inputs_[0]; }
820 LOperand* right() { return inputs_[1]; }
822 DECLARE_CONCRETE_INSTRUCTION(CompareNumericAndBranch,
823 "compare-numeric-and-branch")
824 DECLARE_HYDROGEN_ACCESSOR(CompareNumericAndBranch)
826 Token::Value op() const { return hydrogen()->token(); }
827 bool is_double() const {
828 return hydrogen()->representation().IsDouble();
831 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
835 class LMathFloor V8_FINAL : public LTemplateInstruction<1, 1, 0> {
837 explicit LMathFloor(LOperand* value) {
841 LOperand* value() { return inputs_[0]; }
843 DECLARE_CONCRETE_INSTRUCTION(MathFloor, "math-floor")
844 DECLARE_HYDROGEN_ACCESSOR(UnaryMathOperation)
848 class LMathRound V8_FINAL : public LTemplateInstruction<1, 1, 1> {
850 explicit LMathRound(LOperand* value, LOperand* temp) {
855 LOperand* value() { return inputs_[0]; }
856 LOperand* temp() { return temps_[0]; }
858 DECLARE_CONCRETE_INSTRUCTION(MathRound, "math-round")
859 DECLARE_HYDROGEN_ACCESSOR(UnaryMathOperation)
863 class LMathAbs V8_FINAL : public LTemplateInstruction<1, 2, 0> {
865 explicit LMathAbs(LOperand* context, LOperand* value) {
866 inputs_[1] = context;
870 LOperand* context() { return inputs_[1]; }
871 LOperand* value() { return inputs_[0]; }
873 DECLARE_CONCRETE_INSTRUCTION(MathAbs, "math-abs")
874 DECLARE_HYDROGEN_ACCESSOR(UnaryMathOperation)
878 class LMathLog V8_FINAL : public LTemplateInstruction<1, 1, 0> {
880 explicit LMathLog(LOperand* value) {
884 LOperand* value() { return inputs_[0]; }
886 DECLARE_CONCRETE_INSTRUCTION(MathLog, "math-log")
890 class LMathClz32 V8_FINAL : public LTemplateInstruction<1, 1, 0> {
892 explicit LMathClz32(LOperand* value) {
896 LOperand* value() { return inputs_[0]; }
898 DECLARE_CONCRETE_INSTRUCTION(MathClz32, "math-clz32")
902 class LMathExp V8_FINAL : public LTemplateInstruction<1, 1, 2> {
904 LMathExp(LOperand* value, LOperand* temp1, LOperand* temp2) {
908 ExternalReference::InitializeMathExpData();
911 LOperand* value() { return inputs_[0]; }
912 LOperand* temp1() { return temps_[0]; }
913 LOperand* temp2() { return temps_[1]; }
915 DECLARE_CONCRETE_INSTRUCTION(MathExp, "math-exp")
919 class LMathSqrt V8_FINAL : public LTemplateInstruction<1, 1, 0> {
921 explicit LMathSqrt(LOperand* value) {
925 LOperand* value() { return inputs_[0]; }
927 DECLARE_CONCRETE_INSTRUCTION(MathSqrt, "math-sqrt")
931 class LMathPowHalf V8_FINAL : public LTemplateInstruction<1, 1, 0> {
933 explicit LMathPowHalf(LOperand* value) {
937 LOperand* value() { return inputs_[0]; }
939 DECLARE_CONCRETE_INSTRUCTION(MathPowHalf, "math-pow-half")
943 class LCmpObjectEqAndBranch V8_FINAL : public LControlInstruction<2, 0> {
945 LCmpObjectEqAndBranch(LOperand* left, LOperand* right) {
950 LOperand* left() { return inputs_[0]; }
951 LOperand* right() { return inputs_[1]; }
953 DECLARE_CONCRETE_INSTRUCTION(CmpObjectEqAndBranch, "cmp-object-eq-and-branch")
957 class LCmpHoleAndBranch V8_FINAL : public LControlInstruction<1, 0> {
959 explicit LCmpHoleAndBranch(LOperand* object) {
963 LOperand* object() { return inputs_[0]; }
965 DECLARE_CONCRETE_INSTRUCTION(CmpHoleAndBranch, "cmp-hole-and-branch")
966 DECLARE_HYDROGEN_ACCESSOR(CompareHoleAndBranch)
970 class LCompareMinusZeroAndBranch V8_FINAL : public LControlInstruction<1, 0> {
972 explicit LCompareMinusZeroAndBranch(LOperand* value) {
976 LOperand* value() { return inputs_[0]; }
978 DECLARE_CONCRETE_INSTRUCTION(CompareMinusZeroAndBranch,
979 "cmp-minus-zero-and-branch")
980 DECLARE_HYDROGEN_ACCESSOR(CompareMinusZeroAndBranch)
985 class LIsObjectAndBranch V8_FINAL : public LControlInstruction<1, 0> {
987 explicit LIsObjectAndBranch(LOperand* value) {
991 LOperand* value() { return inputs_[0]; }
993 DECLARE_CONCRETE_INSTRUCTION(IsObjectAndBranch, "is-object-and-branch")
994 DECLARE_HYDROGEN_ACCESSOR(IsObjectAndBranch)
996 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1000 class LIsStringAndBranch V8_FINAL : public LControlInstruction<1, 1> {
1002 explicit LIsStringAndBranch(LOperand* value, LOperand* temp) {
1007 LOperand* value() { return inputs_[0]; }
1008 LOperand* temp() { return temps_[0]; }
1010 DECLARE_CONCRETE_INSTRUCTION(IsStringAndBranch, "is-string-and-branch")
1011 DECLARE_HYDROGEN_ACCESSOR(IsStringAndBranch)
1013 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1017 class LIsSmiAndBranch V8_FINAL : public LControlInstruction<1, 0> {
1019 explicit LIsSmiAndBranch(LOperand* value) {
1023 LOperand* value() { return inputs_[0]; }
1025 DECLARE_CONCRETE_INSTRUCTION(IsSmiAndBranch, "is-smi-and-branch")
1026 DECLARE_HYDROGEN_ACCESSOR(IsSmiAndBranch)
1028 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1032 class LIsUndetectableAndBranch V8_FINAL : public LControlInstruction<1, 1> {
1034 explicit LIsUndetectableAndBranch(LOperand* value, LOperand* temp) {
1039 LOperand* value() { return inputs_[0]; }
1040 LOperand* temp() { return temps_[0]; }
1042 DECLARE_CONCRETE_INSTRUCTION(IsUndetectableAndBranch,
1043 "is-undetectable-and-branch")
1044 DECLARE_HYDROGEN_ACCESSOR(IsUndetectableAndBranch)
1046 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1050 class LStringCompareAndBranch V8_FINAL : public LControlInstruction<3, 0> {
1052 explicit LStringCompareAndBranch(LOperand* context,
1055 inputs_[0] = context;
1060 LOperand* context() { return inputs_[0]; }
1061 LOperand* left() { return inputs_[1]; }
1062 LOperand* right() { return inputs_[2]; }
1064 DECLARE_CONCRETE_INSTRUCTION(StringCompareAndBranch,
1065 "string-compare-and-branch")
1066 DECLARE_HYDROGEN_ACCESSOR(StringCompareAndBranch)
1068 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1070 Token::Value op() const { return hydrogen()->token(); }
1074 class LHasInstanceTypeAndBranch V8_FINAL : public LControlInstruction<1, 0> {
1076 explicit LHasInstanceTypeAndBranch(LOperand* value) {
1080 LOperand* value() { return inputs_[0]; }
1082 DECLARE_CONCRETE_INSTRUCTION(HasInstanceTypeAndBranch,
1083 "has-instance-type-and-branch")
1084 DECLARE_HYDROGEN_ACCESSOR(HasInstanceTypeAndBranch)
1086 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1090 class LGetCachedArrayIndex V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1092 explicit LGetCachedArrayIndex(LOperand* value) {
1096 LOperand* value() { return inputs_[0]; }
1098 DECLARE_CONCRETE_INSTRUCTION(GetCachedArrayIndex, "get-cached-array-index")
1099 DECLARE_HYDROGEN_ACCESSOR(GetCachedArrayIndex)
1103 class LHasCachedArrayIndexAndBranch V8_FINAL
1104 : public LControlInstruction<1, 0> {
1106 explicit LHasCachedArrayIndexAndBranch(LOperand* value) {
1110 LOperand* value() { return inputs_[0]; }
1112 DECLARE_CONCRETE_INSTRUCTION(HasCachedArrayIndexAndBranch,
1113 "has-cached-array-index-and-branch")
1114 DECLARE_HYDROGEN_ACCESSOR(HasCachedArrayIndexAndBranch)
1116 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1120 class LClassOfTestAndBranch V8_FINAL : public LControlInstruction<1, 2> {
1122 LClassOfTestAndBranch(LOperand* value, LOperand* temp, LOperand* temp2) {
1128 LOperand* value() { return inputs_[0]; }
1129 LOperand* temp() { return temps_[0]; }
1130 LOperand* temp2() { return temps_[1]; }
1132 DECLARE_CONCRETE_INSTRUCTION(ClassOfTestAndBranch,
1133 "class-of-test-and-branch")
1134 DECLARE_HYDROGEN_ACCESSOR(ClassOfTestAndBranch)
1136 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1140 class LCmpT V8_FINAL : public LTemplateInstruction<1, 3, 0> {
1142 LCmpT(LOperand* context, LOperand* left, LOperand* right) {
1143 inputs_[0] = context;
1148 LOperand* context() { return inputs_[0]; }
1149 LOperand* left() { return inputs_[1]; }
1150 LOperand* right() { return inputs_[2]; }
1152 DECLARE_CONCRETE_INSTRUCTION(CmpT, "cmp-t")
1153 DECLARE_HYDROGEN_ACCESSOR(CompareGeneric)
1155 Token::Value op() const { return hydrogen()->token(); }
1159 class LInstanceOf V8_FINAL : public LTemplateInstruction<1, 3, 0> {
1161 LInstanceOf(LOperand* context, LOperand* left, LOperand* right) {
1162 inputs_[0] = context;
1167 LOperand* context() { return inputs_[0]; }
1168 LOperand* left() { return inputs_[1]; }
1169 LOperand* right() { return inputs_[2]; }
1171 DECLARE_CONCRETE_INSTRUCTION(InstanceOf, "instance-of")
1175 class LInstanceOfKnownGlobal V8_FINAL : public LTemplateInstruction<1, 2, 1> {
1177 LInstanceOfKnownGlobal(LOperand* context, LOperand* value, LOperand* temp) {
1178 inputs_[0] = context;
1183 LOperand* context() { return inputs_[0]; }
1184 LOperand* value() { return inputs_[1]; }
1185 LOperand* temp() { return temps_[0]; }
1187 DECLARE_CONCRETE_INSTRUCTION(InstanceOfKnownGlobal,
1188 "instance-of-known-global")
1189 DECLARE_HYDROGEN_ACCESSOR(InstanceOfKnownGlobal)
1191 Handle<JSFunction> function() const { return hydrogen()->function(); }
1192 LEnvironment* GetDeferredLazyDeoptimizationEnvironment() {
1193 return lazy_deopt_env_;
1195 virtual void SetDeferredLazyDeoptimizationEnvironment(
1196 LEnvironment* env) V8_OVERRIDE {
1197 lazy_deopt_env_ = env;
1201 LEnvironment* lazy_deopt_env_;
1205 class LBoundsCheck V8_FINAL : public LTemplateInstruction<0, 2, 0> {
1207 LBoundsCheck(LOperand* index, LOperand* length) {
1209 inputs_[1] = length;
1212 LOperand* index() { return inputs_[0]; }
1213 LOperand* length() { return inputs_[1]; }
1215 DECLARE_CONCRETE_INSTRUCTION(BoundsCheck, "bounds-check")
1216 DECLARE_HYDROGEN_ACCESSOR(BoundsCheck)
1220 class LBitI V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1222 LBitI(LOperand* left, LOperand* right) {
1227 LOperand* left() { return inputs_[0]; }
1228 LOperand* right() { return inputs_[1]; }
1230 Token::Value op() const { return hydrogen()->op(); }
1231 bool IsInteger32() const {
1232 return hydrogen()->representation().IsInteger32();
1235 DECLARE_CONCRETE_INSTRUCTION(BitI, "bit-i")
1236 DECLARE_HYDROGEN_ACCESSOR(Bitwise)
1240 class LShiftI V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1242 LShiftI(Token::Value op, LOperand* left, LOperand* right, bool can_deopt)
1243 : op_(op), can_deopt_(can_deopt) {
1248 Token::Value op() const { return op_; }
1249 LOperand* left() { return inputs_[0]; }
1250 LOperand* right() { return inputs_[1]; }
1251 bool can_deopt() const { return can_deopt_; }
1253 DECLARE_CONCRETE_INSTRUCTION(ShiftI, "shift-i")
1261 class LSubI V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1263 LSubI(LOperand* left, LOperand* right) {
1268 LOperand* left() { return inputs_[0]; }
1269 LOperand* right() { return inputs_[1]; }
1271 DECLARE_CONCRETE_INSTRUCTION(SubI, "sub-i")
1272 DECLARE_HYDROGEN_ACCESSOR(Sub)
1276 class LConstantI V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1278 DECLARE_CONCRETE_INSTRUCTION(ConstantI, "constant-i")
1279 DECLARE_HYDROGEN_ACCESSOR(Constant)
1281 int32_t value() const { return hydrogen()->Integer32Value(); }
1285 class LConstantS V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1287 DECLARE_CONCRETE_INSTRUCTION(ConstantS, "constant-s")
1288 DECLARE_HYDROGEN_ACCESSOR(Constant)
1290 Smi* value() const { return Smi::FromInt(hydrogen()->Integer32Value()); }
1294 class LConstantD V8_FINAL : public LTemplateInstruction<1, 0, 1> {
1296 explicit LConstantD(LOperand* temp) {
1300 LOperand* temp() { return temps_[0]; }
1302 DECLARE_CONCRETE_INSTRUCTION(ConstantD, "constant-d")
1303 DECLARE_HYDROGEN_ACCESSOR(Constant)
1305 double value() const { return hydrogen()->DoubleValue(); }
1309 class LConstantE V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1311 DECLARE_CONCRETE_INSTRUCTION(ConstantE, "constant-e")
1312 DECLARE_HYDROGEN_ACCESSOR(Constant)
1314 ExternalReference value() const {
1315 return hydrogen()->ExternalReferenceValue();
1320 class LConstantT V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1322 DECLARE_CONCRETE_INSTRUCTION(ConstantT, "constant-t")
1323 DECLARE_HYDROGEN_ACCESSOR(Constant)
1325 Handle<Object> value(Isolate* isolate) const {
1326 return hydrogen()->handle(isolate);
1331 class LBranch V8_FINAL : public LControlInstruction<1, 0> {
1333 explicit LBranch(LOperand* value) {
1337 LOperand* value() { return inputs_[0]; }
1339 DECLARE_CONCRETE_INSTRUCTION(Branch, "branch")
1340 DECLARE_HYDROGEN_ACCESSOR(Branch)
1342 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1346 class LDebugBreak V8_FINAL : public LTemplateInstruction<0, 0, 0> {
1348 DECLARE_CONCRETE_INSTRUCTION(DebugBreak, "break")
1352 class LCmpMapAndBranch V8_FINAL : public LControlInstruction<1, 0> {
1354 explicit LCmpMapAndBranch(LOperand* value) {
1358 LOperand* value() { return inputs_[0]; }
1360 DECLARE_CONCRETE_INSTRUCTION(CmpMapAndBranch, "cmp-map-and-branch")
1361 DECLARE_HYDROGEN_ACCESSOR(CompareMap)
1363 Handle<Map> map() const { return hydrogen()->map().handle(); }
1367 class LMapEnumLength V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1369 explicit LMapEnumLength(LOperand* value) {
1373 LOperand* value() { return inputs_[0]; }
1375 DECLARE_CONCRETE_INSTRUCTION(MapEnumLength, "map-enum-length")
1379 class LDateField V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1381 LDateField(LOperand* date, Smi* index) : index_(index) {
1385 LOperand* date() { return inputs_[0]; }
1386 Smi* index() const { return index_; }
1388 DECLARE_CONCRETE_INSTRUCTION(DateField, "date-field")
1389 DECLARE_HYDROGEN_ACCESSOR(DateField)
1396 class LSeqStringGetChar V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1398 LSeqStringGetChar(LOperand* string, LOperand* index) {
1399 inputs_[0] = string;
1403 LOperand* string() const { return inputs_[0]; }
1404 LOperand* index() const { return inputs_[1]; }
1406 DECLARE_CONCRETE_INSTRUCTION(SeqStringGetChar, "seq-string-get-char")
1407 DECLARE_HYDROGEN_ACCESSOR(SeqStringGetChar)
1411 class LSeqStringSetChar V8_FINAL : public LTemplateInstruction<1, 4, 0> {
1413 LSeqStringSetChar(LOperand* context,
1417 inputs_[0] = context;
1418 inputs_[1] = string;
1423 LOperand* string() { return inputs_[1]; }
1424 LOperand* index() { return inputs_[2]; }
1425 LOperand* value() { return inputs_[3]; }
1427 DECLARE_CONCRETE_INSTRUCTION(SeqStringSetChar, "seq-string-set-char")
1428 DECLARE_HYDROGEN_ACCESSOR(SeqStringSetChar)
1432 class LAddI V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1434 LAddI(LOperand* left, LOperand* right) {
1439 LOperand* left() { return inputs_[0]; }
1440 LOperand* right() { return inputs_[1]; }
1442 static bool UseLea(HAdd* add) {
1443 return !add->CheckFlag(HValue::kCanOverflow) &&
1444 add->BetterLeftOperand()->UseCount() > 1;
1447 DECLARE_CONCRETE_INSTRUCTION(AddI, "add-i")
1448 DECLARE_HYDROGEN_ACCESSOR(Add)
1452 class LMathMinMax V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1454 LMathMinMax(LOperand* left, LOperand* right) {
1459 LOperand* left() { return inputs_[0]; }
1460 LOperand* right() { return inputs_[1]; }
1462 DECLARE_CONCRETE_INSTRUCTION(MathMinMax, "math-min-max")
1463 DECLARE_HYDROGEN_ACCESSOR(MathMinMax)
1467 class LPower V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1469 LPower(LOperand* left, LOperand* right) {
1474 LOperand* left() { return inputs_[0]; }
1475 LOperand* right() { return inputs_[1]; }
1477 DECLARE_CONCRETE_INSTRUCTION(Power, "power")
1478 DECLARE_HYDROGEN_ACCESSOR(Power)
1482 class LArithmeticD V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1484 LArithmeticD(Token::Value op, LOperand* left, LOperand* right)
1490 Token::Value op() const { return op_; }
1491 LOperand* left() { return inputs_[0]; }
1492 LOperand* right() { return inputs_[1]; }
1494 virtual Opcode opcode() const V8_OVERRIDE {
1495 return LInstruction::kArithmeticD;
1497 virtual void CompileToNative(LCodeGen* generator) V8_OVERRIDE;
1498 virtual const char* Mnemonic() const V8_OVERRIDE;
1505 class LArithmeticT V8_FINAL : public LTemplateInstruction<1, 3, 0> {
1507 LArithmeticT(Token::Value op,
1512 inputs_[0] = context;
1517 Token::Value op() const { return op_; }
1518 LOperand* context() { return inputs_[0]; }
1519 LOperand* left() { return inputs_[1]; }
1520 LOperand* right() { return inputs_[2]; }
1522 virtual Opcode opcode() const V8_OVERRIDE {
1523 return LInstruction::kArithmeticT;
1525 virtual void CompileToNative(LCodeGen* generator) V8_OVERRIDE;
1526 virtual const char* Mnemonic() const V8_OVERRIDE;
1533 class LReturn V8_FINAL : public LTemplateInstruction<0, 3, 0> {
1535 explicit LReturn(LOperand* value,
1537 LOperand* parameter_count) {
1539 inputs_[1] = context;
1540 inputs_[2] = parameter_count;
1543 LOperand* value() { return inputs_[0]; }
1544 LOperand* context() { return inputs_[1]; }
1546 bool has_constant_parameter_count() {
1547 return parameter_count()->IsConstantOperand();
1549 LConstantOperand* constant_parameter_count() {
1550 ASSERT(has_constant_parameter_count());
1551 return LConstantOperand::cast(parameter_count());
1553 LOperand* parameter_count() { return inputs_[2]; }
1555 DECLARE_CONCRETE_INSTRUCTION(Return, "return")
1556 DECLARE_HYDROGEN_ACCESSOR(Return)
1560 class LLoadNamedField V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1562 explicit LLoadNamedField(LOperand* object) {
1563 inputs_[0] = object;
1566 LOperand* object() { return inputs_[0]; }
1568 DECLARE_CONCRETE_INSTRUCTION(LoadNamedField, "load-named-field")
1569 DECLARE_HYDROGEN_ACCESSOR(LoadNamedField)
1573 class LLoadNamedGeneric V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1575 explicit LLoadNamedGeneric(LOperand* context, LOperand* object) {
1576 inputs_[0] = context;
1577 inputs_[1] = object;
1580 DECLARE_CONCRETE_INSTRUCTION(LoadNamedGeneric, "load-named-generic")
1581 DECLARE_HYDROGEN_ACCESSOR(LoadNamedGeneric)
1583 LOperand* context() { return inputs_[0]; }
1584 LOperand* object() { return inputs_[1]; }
1585 Handle<Object> name() const { return hydrogen()->name(); }
1589 class LLoadFunctionPrototype V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1591 explicit LLoadFunctionPrototype(LOperand* function) {
1592 inputs_[0] = function;
1595 DECLARE_CONCRETE_INSTRUCTION(LoadFunctionPrototype, "load-function-prototype")
1596 DECLARE_HYDROGEN_ACCESSOR(LoadFunctionPrototype)
1598 LOperand* function() { return inputs_[0]; }
1602 class LLoadRoot V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1604 DECLARE_CONCRETE_INSTRUCTION(LoadRoot, "load-root")
1605 DECLARE_HYDROGEN_ACCESSOR(LoadRoot)
1607 Heap::RootListIndex index() const { return hydrogen()->index(); }
1611 inline static bool ExternalArrayOpRequiresTemp(
1612 Representation key_representation,
1613 ElementsKind elements_kind) {
1614 // Operations that require the key to be divided by two to be converted into
1615 // an index cannot fold the scale operation into a load and need an extra
1616 // temp register to do the work.
1617 return SmiValuesAre31Bits() && key_representation.IsSmi() &&
1618 (elements_kind == EXTERNAL_INT8_ELEMENTS ||
1619 elements_kind == EXTERNAL_UINT8_ELEMENTS ||
1620 elements_kind == EXTERNAL_UINT8_CLAMPED_ELEMENTS ||
1621 elements_kind == UINT8_ELEMENTS ||
1622 elements_kind == INT8_ELEMENTS ||
1623 elements_kind == UINT8_CLAMPED_ELEMENTS);
1627 class LLoadKeyed V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1629 LLoadKeyed(LOperand* elements, LOperand* key) {
1630 inputs_[0] = elements;
1634 DECLARE_CONCRETE_INSTRUCTION(LoadKeyed, "load-keyed")
1635 DECLARE_HYDROGEN_ACCESSOR(LoadKeyed)
1637 bool is_external() const {
1638 return hydrogen()->is_external();
1640 bool is_fixed_typed_array() const {
1641 return hydrogen()->is_fixed_typed_array();
1643 bool is_typed_elements() const {
1644 return is_external() || is_fixed_typed_array();
1646 LOperand* elements() { return inputs_[0]; }
1647 LOperand* key() { return inputs_[1]; }
1648 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1649 uint32_t base_offset() const { return hydrogen()->base_offset(); }
1650 ElementsKind elements_kind() const {
1651 return hydrogen()->elements_kind();
1656 class LLoadKeyedGeneric V8_FINAL : public LTemplateInstruction<1, 3, 0> {
1658 LLoadKeyedGeneric(LOperand* context, LOperand* obj, LOperand* key) {
1659 inputs_[0] = context;
1664 DECLARE_CONCRETE_INSTRUCTION(LoadKeyedGeneric, "load-keyed-generic")
1666 LOperand* context() { return inputs_[0]; }
1667 LOperand* object() { return inputs_[1]; }
1668 LOperand* key() { return inputs_[2]; }
1672 class LLoadGlobalCell V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1674 DECLARE_CONCRETE_INSTRUCTION(LoadGlobalCell, "load-global-cell")
1675 DECLARE_HYDROGEN_ACCESSOR(LoadGlobalCell)
1679 class LLoadGlobalGeneric V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1681 explicit LLoadGlobalGeneric(LOperand* context, LOperand* global_object) {
1682 inputs_[0] = context;
1683 inputs_[1] = global_object;
1686 DECLARE_CONCRETE_INSTRUCTION(LoadGlobalGeneric, "load-global-generic")
1687 DECLARE_HYDROGEN_ACCESSOR(LoadGlobalGeneric)
1689 LOperand* context() { return inputs_[0]; }
1690 LOperand* global_object() { return inputs_[1]; }
1691 Handle<Object> name() const { return hydrogen()->name(); }
1692 bool for_typeof() const { return hydrogen()->for_typeof(); }
1696 class LStoreGlobalCell V8_FINAL : public LTemplateInstruction<0, 1, 1> {
1698 explicit LStoreGlobalCell(LOperand* value, LOperand* temp) {
1703 LOperand* value() { return inputs_[0]; }
1704 LOperand* temp() { return temps_[0]; }
1706 DECLARE_CONCRETE_INSTRUCTION(StoreGlobalCell, "store-global-cell")
1707 DECLARE_HYDROGEN_ACCESSOR(StoreGlobalCell)
1711 class LLoadContextSlot V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1713 explicit LLoadContextSlot(LOperand* context) {
1714 inputs_[0] = context;
1717 LOperand* context() { return inputs_[0]; }
1719 DECLARE_CONCRETE_INSTRUCTION(LoadContextSlot, "load-context-slot")
1720 DECLARE_HYDROGEN_ACCESSOR(LoadContextSlot)
1722 int slot_index() { return hydrogen()->slot_index(); }
1724 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1728 class LStoreContextSlot V8_FINAL : public LTemplateInstruction<0, 2, 1> {
1730 LStoreContextSlot(LOperand* context, LOperand* value, LOperand* temp) {
1731 inputs_[0] = context;
1736 LOperand* context() { return inputs_[0]; }
1737 LOperand* value() { return inputs_[1]; }
1738 LOperand* temp() { return temps_[0]; }
1740 DECLARE_CONCRETE_INSTRUCTION(StoreContextSlot, "store-context-slot")
1741 DECLARE_HYDROGEN_ACCESSOR(StoreContextSlot)
1743 int slot_index() { return hydrogen()->slot_index(); }
1745 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1749 class LPushArgument V8_FINAL : public LTemplateInstruction<0, 1, 0> {
1751 explicit LPushArgument(LOperand* value) {
1755 LOperand* value() { return inputs_[0]; }
1757 DECLARE_CONCRETE_INSTRUCTION(PushArgument, "push-argument")
1761 class LDrop V8_FINAL : public LTemplateInstruction<0, 0, 0> {
1763 explicit LDrop(int count) : count_(count) { }
1765 int count() const { return count_; }
1767 DECLARE_CONCRETE_INSTRUCTION(Drop, "drop")
1774 class LStoreCodeEntry V8_FINAL: public LTemplateInstruction<0, 2, 0> {
1776 LStoreCodeEntry(LOperand* function, LOperand* code_object) {
1777 inputs_[0] = function;
1778 inputs_[1] = code_object;
1781 LOperand* function() { return inputs_[0]; }
1782 LOperand* code_object() { return inputs_[1]; }
1784 virtual void PrintDataTo(StringStream* stream);
1786 DECLARE_CONCRETE_INSTRUCTION(StoreCodeEntry, "store-code-entry")
1787 DECLARE_HYDROGEN_ACCESSOR(StoreCodeEntry)
1791 class LInnerAllocatedObject V8_FINAL: public LTemplateInstruction<1, 2, 0> {
1793 LInnerAllocatedObject(LOperand* base_object, LOperand* offset) {
1794 inputs_[0] = base_object;
1795 inputs_[1] = offset;
1798 LOperand* base_object() const { return inputs_[0]; }
1799 LOperand* offset() const { return inputs_[1]; }
1801 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1803 DECLARE_CONCRETE_INSTRUCTION(InnerAllocatedObject, "inner-allocated-object")
1807 class LThisFunction V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1809 DECLARE_CONCRETE_INSTRUCTION(ThisFunction, "this-function")
1810 DECLARE_HYDROGEN_ACCESSOR(ThisFunction)
1814 class LContext V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1816 DECLARE_CONCRETE_INSTRUCTION(Context, "context")
1817 DECLARE_HYDROGEN_ACCESSOR(Context)
1821 class LDeclareGlobals V8_FINAL : public LTemplateInstruction<0, 1, 0> {
1823 explicit LDeclareGlobals(LOperand* context) {
1824 inputs_[0] = context;
1827 LOperand* context() { return inputs_[0]; }
1829 DECLARE_CONCRETE_INSTRUCTION(DeclareGlobals, "declare-globals")
1830 DECLARE_HYDROGEN_ACCESSOR(DeclareGlobals)
1834 class LCallJSFunction V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1836 explicit LCallJSFunction(LOperand* function) {
1837 inputs_[0] = function;
1840 LOperand* function() { return inputs_[0]; }
1842 DECLARE_CONCRETE_INSTRUCTION(CallJSFunction, "call-js-function")
1843 DECLARE_HYDROGEN_ACCESSOR(CallJSFunction)
1845 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1847 int arity() const { return hydrogen()->argument_count() - 1; }
1851 class LCallWithDescriptor V8_FINAL : public LTemplateResultInstruction<1> {
1853 LCallWithDescriptor(const CallInterfaceDescriptor* descriptor,
1854 const ZoneList<LOperand*>& operands,
1856 : inputs_(descriptor->environment_length() + 1, zone) {
1857 ASSERT(descriptor->environment_length() + 1 == operands.length());
1858 inputs_.AddAll(operands, zone);
1861 LOperand* target() const { return inputs_[0]; }
1864 DECLARE_CONCRETE_INSTRUCTION(CallWithDescriptor, "call-with-descriptor")
1865 DECLARE_HYDROGEN_ACCESSOR(CallWithDescriptor)
1867 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1869 int arity() const { return hydrogen()->argument_count() - 1; }
1871 ZoneList<LOperand*> inputs_;
1873 // Iterator support.
1874 virtual int InputCount() V8_FINAL V8_OVERRIDE { return inputs_.length(); }
1875 virtual LOperand* InputAt(int i) V8_FINAL V8_OVERRIDE { return inputs_[i]; }
1877 virtual int TempCount() V8_FINAL V8_OVERRIDE { return 0; }
1878 virtual LOperand* TempAt(int i) V8_FINAL V8_OVERRIDE { return NULL; }
1882 class LInvokeFunction V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1884 LInvokeFunction(LOperand* context, LOperand* function) {
1885 inputs_[0] = context;
1886 inputs_[1] = function;
1889 LOperand* context() { return inputs_[0]; }
1890 LOperand* function() { return inputs_[1]; }
1892 DECLARE_CONCRETE_INSTRUCTION(InvokeFunction, "invoke-function")
1893 DECLARE_HYDROGEN_ACCESSOR(InvokeFunction)
1895 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1897 int arity() const { return hydrogen()->argument_count() - 1; }
1901 class LCallFunction V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1903 LCallFunction(LOperand* context, LOperand* function) {
1904 inputs_[0] = context;
1905 inputs_[1] = function;
1908 DECLARE_CONCRETE_INSTRUCTION(CallFunction, "call-function")
1909 DECLARE_HYDROGEN_ACCESSOR(CallFunction)
1911 LOperand* context() { return inputs_[0]; }
1912 LOperand* function() { return inputs_[1]; }
1913 int arity() const { return hydrogen()->argument_count() - 1; }
1917 class LCallNew V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1919 LCallNew(LOperand* context, LOperand* constructor) {
1920 inputs_[0] = context;
1921 inputs_[1] = constructor;
1924 LOperand* context() { return inputs_[0]; }
1925 LOperand* constructor() { return inputs_[1]; }
1927 DECLARE_CONCRETE_INSTRUCTION(CallNew, "call-new")
1928 DECLARE_HYDROGEN_ACCESSOR(CallNew)
1930 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1932 int arity() const { return hydrogen()->argument_count() - 1; }
1936 class LCallNewArray V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1938 LCallNewArray(LOperand* context, LOperand* constructor) {
1939 inputs_[0] = context;
1940 inputs_[1] = constructor;
1943 LOperand* context() { return inputs_[0]; }
1944 LOperand* constructor() { return inputs_[1]; }
1946 DECLARE_CONCRETE_INSTRUCTION(CallNewArray, "call-new-array")
1947 DECLARE_HYDROGEN_ACCESSOR(CallNewArray)
1949 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1951 int arity() const { return hydrogen()->argument_count() - 1; }
1955 class LCallRuntime V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1957 explicit LCallRuntime(LOperand* context) {
1958 inputs_[0] = context;
1961 LOperand* context() { return inputs_[0]; }
1963 DECLARE_CONCRETE_INSTRUCTION(CallRuntime, "call-runtime")
1964 DECLARE_HYDROGEN_ACCESSOR(CallRuntime)
1966 virtual bool ClobbersDoubleRegisters(Isolate* isolate) const V8_OVERRIDE {
1967 return save_doubles() == kDontSaveFPRegs;
1970 const Runtime::Function* function() const { return hydrogen()->function(); }
1971 int arity() const { return hydrogen()->argument_count(); }
1972 SaveFPRegsMode save_doubles() const { return hydrogen()->save_doubles(); }
1976 class LInteger32ToDouble V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1978 explicit LInteger32ToDouble(LOperand* value) {
1982 LOperand* value() { return inputs_[0]; }
1984 DECLARE_CONCRETE_INSTRUCTION(Integer32ToDouble, "int32-to-double")
1988 class LUint32ToDouble V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1990 explicit LUint32ToDouble(LOperand* value) {
1994 LOperand* value() { return inputs_[0]; }
1996 DECLARE_CONCRETE_INSTRUCTION(Uint32ToDouble, "uint32-to-double")
2000 class LNumberTagI V8_FINAL : public LTemplateInstruction<1, 1, 2> {
2002 LNumberTagI(LOperand* value, LOperand* temp1, LOperand* temp2) {
2008 LOperand* value() { return inputs_[0]; }
2009 LOperand* temp1() { return temps_[0]; }
2010 LOperand* temp2() { return temps_[1]; }
2012 DECLARE_CONCRETE_INSTRUCTION(NumberTagI, "number-tag-i")
2016 class LNumberTagU V8_FINAL : public LTemplateInstruction<1, 1, 2> {
2018 LNumberTagU(LOperand* value, LOperand* temp1, LOperand* temp2) {
2024 LOperand* value() { return inputs_[0]; }
2025 LOperand* temp1() { return temps_[0]; }
2026 LOperand* temp2() { return temps_[1]; }
2028 DECLARE_CONCRETE_INSTRUCTION(NumberTagU, "number-tag-u")
2032 class LNumberTagD V8_FINAL : public LTemplateInstruction<1, 1, 1> {
2034 explicit LNumberTagD(LOperand* value, LOperand* temp) {
2039 LOperand* value() { return inputs_[0]; }
2040 LOperand* temp() { return temps_[0]; }
2042 DECLARE_CONCRETE_INSTRUCTION(NumberTagD, "number-tag-d")
2043 DECLARE_HYDROGEN_ACCESSOR(Change)
2047 // Sometimes truncating conversion from a tagged value to an int32.
2048 class LDoubleToI V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2050 explicit LDoubleToI(LOperand* value) {
2054 LOperand* value() { return inputs_[0]; }
2056 DECLARE_CONCRETE_INSTRUCTION(DoubleToI, "double-to-i")
2057 DECLARE_HYDROGEN_ACCESSOR(UnaryOperation)
2059 bool truncating() { return hydrogen()->CanTruncateToInt32(); }
2063 class LDoubleToSmi V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2065 explicit LDoubleToSmi(LOperand* value) {
2069 LOperand* value() { return inputs_[0]; }
2071 DECLARE_CONCRETE_INSTRUCTION(DoubleToSmi, "double-to-smi")
2072 DECLARE_HYDROGEN_ACCESSOR(UnaryOperation)
2076 // Truncating conversion from a tagged value to an int32.
2077 class LTaggedToI V8_FINAL : public LTemplateInstruction<1, 1, 1> {
2079 LTaggedToI(LOperand* value, LOperand* temp) {
2084 LOperand* value() { return inputs_[0]; }
2085 LOperand* temp() { return temps_[0]; }
2087 DECLARE_CONCRETE_INSTRUCTION(TaggedToI, "tagged-to-i")
2088 DECLARE_HYDROGEN_ACCESSOR(Change)
2090 bool truncating() { return hydrogen()->CanTruncateToInt32(); }
2094 class LSmiTag V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2096 explicit LSmiTag(LOperand* value) {
2100 LOperand* value() { return inputs_[0]; }
2102 DECLARE_CONCRETE_INSTRUCTION(SmiTag, "smi-tag")
2103 DECLARE_HYDROGEN_ACCESSOR(Change)
2107 class LNumberUntagD V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2109 explicit LNumberUntagD(LOperand* value) {
2113 LOperand* value() { return inputs_[0]; }
2115 DECLARE_CONCRETE_INSTRUCTION(NumberUntagD, "double-untag")
2116 DECLARE_HYDROGEN_ACCESSOR(Change);
2120 class LSmiUntag V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2122 LSmiUntag(LOperand* value, bool needs_check)
2123 : needs_check_(needs_check) {
2127 LOperand* value() { return inputs_[0]; }
2128 bool needs_check() const { return needs_check_; }
2130 DECLARE_CONCRETE_INSTRUCTION(SmiUntag, "smi-untag")
2137 class LStoreNamedField V8_FINAL : public LTemplateInstruction<0, 2, 1> {
2139 LStoreNamedField(LOperand* object, LOperand* value, LOperand* temp) {
2140 inputs_[0] = object;
2145 LOperand* object() { return inputs_[0]; }
2146 LOperand* value() { return inputs_[1]; }
2147 LOperand* temp() { return temps_[0]; }
2149 DECLARE_CONCRETE_INSTRUCTION(StoreNamedField, "store-named-field")
2150 DECLARE_HYDROGEN_ACCESSOR(StoreNamedField)
2152 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
2154 Representation representation() const {
2155 return hydrogen()->field_representation();
2160 class LStoreNamedGeneric V8_FINAL : public LTemplateInstruction<0, 3, 0> {
2162 LStoreNamedGeneric(LOperand* context, LOperand* object, LOperand* value) {
2163 inputs_[0] = context;
2164 inputs_[1] = object;
2168 LOperand* context() { return inputs_[0]; }
2169 LOperand* object() { return inputs_[1]; }
2170 LOperand* value() { return inputs_[2]; }
2172 DECLARE_CONCRETE_INSTRUCTION(StoreNamedGeneric, "store-named-generic")
2173 DECLARE_HYDROGEN_ACCESSOR(StoreNamedGeneric)
2175 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
2177 Handle<Object> name() const { return hydrogen()->name(); }
2178 StrictMode strict_mode() { return hydrogen()->strict_mode(); }
2182 class LStoreKeyed V8_FINAL : public LTemplateInstruction<0, 3, 0> {
2184 LStoreKeyed(LOperand* object, LOperand* key, LOperand* value) {
2185 inputs_[0] = object;
2190 bool is_external() const { return hydrogen()->is_external(); }
2191 bool is_fixed_typed_array() const {
2192 return hydrogen()->is_fixed_typed_array();
2194 bool is_typed_elements() const {
2195 return is_external() || is_fixed_typed_array();
2197 LOperand* elements() { return inputs_[0]; }
2198 LOperand* key() { return inputs_[1]; }
2199 LOperand* value() { return inputs_[2]; }
2200 ElementsKind elements_kind() const { return hydrogen()->elements_kind(); }
2202 DECLARE_CONCRETE_INSTRUCTION(StoreKeyed, "store-keyed")
2203 DECLARE_HYDROGEN_ACCESSOR(StoreKeyed)
2205 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
2206 bool NeedsCanonicalization() { return hydrogen()->NeedsCanonicalization(); }
2207 uint32_t base_offset() const { return hydrogen()->base_offset(); }
2211 class LStoreKeyedGeneric V8_FINAL : public LTemplateInstruction<0, 4, 0> {
2213 LStoreKeyedGeneric(LOperand* context,
2217 inputs_[0] = context;
2218 inputs_[1] = object;
2223 LOperand* context() { return inputs_[0]; }
2224 LOperand* object() { return inputs_[1]; }
2225 LOperand* key() { return inputs_[2]; }
2226 LOperand* value() { return inputs_[3]; }
2228 DECLARE_CONCRETE_INSTRUCTION(StoreKeyedGeneric, "store-keyed-generic")
2229 DECLARE_HYDROGEN_ACCESSOR(StoreKeyedGeneric)
2231 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
2233 StrictMode strict_mode() { return hydrogen()->strict_mode(); }
2237 class LTransitionElementsKind V8_FINAL : public LTemplateInstruction<0, 2, 2> {
2239 LTransitionElementsKind(LOperand* object,
2241 LOperand* new_map_temp,
2243 inputs_[0] = object;
2244 inputs_[1] = context;
2245 temps_[0] = new_map_temp;
2249 LOperand* object() { return inputs_[0]; }
2250 LOperand* context() { return inputs_[1]; }
2251 LOperand* new_map_temp() { return temps_[0]; }
2252 LOperand* temp() { return temps_[1]; }
2254 DECLARE_CONCRETE_INSTRUCTION(TransitionElementsKind,
2255 "transition-elements-kind")
2256 DECLARE_HYDROGEN_ACCESSOR(TransitionElementsKind)
2258 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
2260 Handle<Map> original_map() { return hydrogen()->original_map().handle(); }
2261 Handle<Map> transitioned_map() {
2262 return hydrogen()->transitioned_map().handle();
2264 ElementsKind from_kind() { return hydrogen()->from_kind(); }
2265 ElementsKind to_kind() { return hydrogen()->to_kind(); }
2269 class LTrapAllocationMemento V8_FINAL : public LTemplateInstruction<0, 1, 1> {
2271 LTrapAllocationMemento(LOperand* object,
2273 inputs_[0] = object;
2277 LOperand* object() { return inputs_[0]; }
2278 LOperand* temp() { return temps_[0]; }
2280 DECLARE_CONCRETE_INSTRUCTION(TrapAllocationMemento,
2281 "trap-allocation-memento")
2285 class LStringAdd V8_FINAL : public LTemplateInstruction<1, 3, 0> {
2287 LStringAdd(LOperand* context, LOperand* left, LOperand* right) {
2288 inputs_[0] = context;
2293 LOperand* context() { return inputs_[0]; }
2294 LOperand* left() { return inputs_[1]; }
2295 LOperand* right() { return inputs_[2]; }
2297 DECLARE_CONCRETE_INSTRUCTION(StringAdd, "string-add")
2298 DECLARE_HYDROGEN_ACCESSOR(StringAdd)
2302 class LStringCharCodeAt V8_FINAL : public LTemplateInstruction<1, 3, 0> {
2304 LStringCharCodeAt(LOperand* context, LOperand* string, LOperand* index) {
2305 inputs_[0] = context;
2306 inputs_[1] = string;
2310 LOperand* context() { return inputs_[0]; }
2311 LOperand* string() { return inputs_[1]; }
2312 LOperand* index() { return inputs_[2]; }
2314 DECLARE_CONCRETE_INSTRUCTION(StringCharCodeAt, "string-char-code-at")
2315 DECLARE_HYDROGEN_ACCESSOR(StringCharCodeAt)
2319 class LStringCharFromCode V8_FINAL : public LTemplateInstruction<1, 2, 0> {
2321 explicit LStringCharFromCode(LOperand* context, LOperand* char_code) {
2322 inputs_[0] = context;
2323 inputs_[1] = char_code;
2326 LOperand* context() { return inputs_[0]; }
2327 LOperand* char_code() { return inputs_[1]; }
2329 DECLARE_CONCRETE_INSTRUCTION(StringCharFromCode, "string-char-from-code")
2330 DECLARE_HYDROGEN_ACCESSOR(StringCharFromCode)
2334 class LCheckValue V8_FINAL : public LTemplateInstruction<0, 1, 0> {
2336 explicit LCheckValue(LOperand* value) {
2340 LOperand* value() { return inputs_[0]; }
2342 DECLARE_CONCRETE_INSTRUCTION(CheckValue, "check-value")
2343 DECLARE_HYDROGEN_ACCESSOR(CheckValue)
2347 class LCheckInstanceType V8_FINAL : public LTemplateInstruction<0, 1, 0> {
2349 explicit LCheckInstanceType(LOperand* value) {
2353 LOperand* value() { return inputs_[0]; }
2355 DECLARE_CONCRETE_INSTRUCTION(CheckInstanceType, "check-instance-type")
2356 DECLARE_HYDROGEN_ACCESSOR(CheckInstanceType)
2360 class LCheckMaps V8_FINAL : public LTemplateInstruction<0, 1, 0> {
2362 explicit LCheckMaps(LOperand* value = NULL) {
2366 LOperand* value() { return inputs_[0]; }
2368 DECLARE_CONCRETE_INSTRUCTION(CheckMaps, "check-maps")
2369 DECLARE_HYDROGEN_ACCESSOR(CheckMaps)
2373 class LCheckSmi V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2375 explicit LCheckSmi(LOperand* value) {
2379 LOperand* value() { return inputs_[0]; }
2381 DECLARE_CONCRETE_INSTRUCTION(CheckSmi, "check-smi")
2385 class LClampDToUint8 V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2387 explicit LClampDToUint8(LOperand* unclamped) {
2388 inputs_[0] = unclamped;
2391 LOperand* unclamped() { return inputs_[0]; }
2393 DECLARE_CONCRETE_INSTRUCTION(ClampDToUint8, "clamp-d-to-uint8")
2397 class LClampIToUint8 V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2399 explicit LClampIToUint8(LOperand* unclamped) {
2400 inputs_[0] = unclamped;
2403 LOperand* unclamped() { return inputs_[0]; }
2405 DECLARE_CONCRETE_INSTRUCTION(ClampIToUint8, "clamp-i-to-uint8")
2409 class LClampTToUint8 V8_FINAL : public LTemplateInstruction<1, 1, 1> {
2411 LClampTToUint8(LOperand* unclamped,
2412 LOperand* temp_xmm) {
2413 inputs_[0] = unclamped;
2414 temps_[0] = temp_xmm;
2417 LOperand* unclamped() { return inputs_[0]; }
2418 LOperand* temp_xmm() { return temps_[0]; }
2420 DECLARE_CONCRETE_INSTRUCTION(ClampTToUint8, "clamp-t-to-uint8")
2424 class LCheckNonSmi V8_FINAL : public LTemplateInstruction<0, 1, 0> {
2426 explicit LCheckNonSmi(LOperand* value) {
2430 LOperand* value() { return inputs_[0]; }
2432 DECLARE_CONCRETE_INSTRUCTION(CheckNonSmi, "check-non-smi")
2433 DECLARE_HYDROGEN_ACCESSOR(CheckHeapObject)
2437 class LDoubleBits V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2439 explicit LDoubleBits(LOperand* value) {
2443 LOperand* value() { return inputs_[0]; }
2445 DECLARE_CONCRETE_INSTRUCTION(DoubleBits, "double-bits")
2446 DECLARE_HYDROGEN_ACCESSOR(DoubleBits)
2450 class LConstructDouble V8_FINAL : public LTemplateInstruction<1, 2, 0> {
2452 LConstructDouble(LOperand* hi, LOperand* lo) {
2457 LOperand* hi() { return inputs_[0]; }
2458 LOperand* lo() { return inputs_[1]; }
2460 DECLARE_CONCRETE_INSTRUCTION(ConstructDouble, "construct-double")
2464 class LAllocate V8_FINAL : public LTemplateInstruction<1, 2, 1> {
2466 LAllocate(LOperand* context, LOperand* size, LOperand* temp) {
2467 inputs_[0] = context;
2472 LOperand* context() { return inputs_[0]; }
2473 LOperand* size() { return inputs_[1]; }
2474 LOperand* temp() { return temps_[0]; }
2476 DECLARE_CONCRETE_INSTRUCTION(Allocate, "allocate")
2477 DECLARE_HYDROGEN_ACCESSOR(Allocate)
2481 class LRegExpLiteral V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2483 explicit LRegExpLiteral(LOperand* context) {
2484 inputs_[0] = context;
2487 LOperand* context() { return inputs_[0]; }
2489 DECLARE_CONCRETE_INSTRUCTION(RegExpLiteral, "regexp-literal")
2490 DECLARE_HYDROGEN_ACCESSOR(RegExpLiteral)
2494 class LFunctionLiteral V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2496 explicit LFunctionLiteral(LOperand* context) {
2497 inputs_[0] = context;
2500 LOperand* context() { return inputs_[0]; }
2502 DECLARE_CONCRETE_INSTRUCTION(FunctionLiteral, "function-literal")
2503 DECLARE_HYDROGEN_ACCESSOR(FunctionLiteral)
2507 class LToFastProperties V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2509 explicit LToFastProperties(LOperand* value) {
2513 LOperand* value() { return inputs_[0]; }
2515 DECLARE_CONCRETE_INSTRUCTION(ToFastProperties, "to-fast-properties")
2516 DECLARE_HYDROGEN_ACCESSOR(ToFastProperties)
2520 class LTypeof V8_FINAL : public LTemplateInstruction<1, 2, 0> {
2522 LTypeof(LOperand* context, LOperand* value) {
2523 inputs_[0] = context;
2527 LOperand* context() { return inputs_[0]; }
2528 LOperand* value() { return inputs_[1]; }
2530 DECLARE_CONCRETE_INSTRUCTION(Typeof, "typeof")
2534 class LTypeofIsAndBranch V8_FINAL : public LControlInstruction<1, 0> {
2536 explicit LTypeofIsAndBranch(LOperand* value) {
2540 LOperand* value() { return inputs_[0]; }
2542 DECLARE_CONCRETE_INSTRUCTION(TypeofIsAndBranch, "typeof-is-and-branch")
2543 DECLARE_HYDROGEN_ACCESSOR(TypeofIsAndBranch)
2545 Handle<String> type_literal() { return hydrogen()->type_literal(); }
2547 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
2551 class LIsConstructCallAndBranch V8_FINAL : public LControlInstruction<0, 1> {
2553 explicit LIsConstructCallAndBranch(LOperand* temp) {
2557 LOperand* temp() { return temps_[0]; }
2559 DECLARE_CONCRETE_INSTRUCTION(IsConstructCallAndBranch,
2560 "is-construct-call-and-branch")
2561 DECLARE_HYDROGEN_ACCESSOR(IsConstructCallAndBranch)
2565 class LOsrEntry V8_FINAL : public LTemplateInstruction<0, 0, 0> {
2569 virtual bool HasInterestingComment(LCodeGen* gen) const V8_OVERRIDE {
2572 DECLARE_CONCRETE_INSTRUCTION(OsrEntry, "osr-entry")
2576 class LStackCheck V8_FINAL : public LTemplateInstruction<0, 1, 0> {
2578 explicit LStackCheck(LOperand* context) {
2579 inputs_[0] = context;
2582 LOperand* context() { return inputs_[0]; }
2584 DECLARE_CONCRETE_INSTRUCTION(StackCheck, "stack-check")
2585 DECLARE_HYDROGEN_ACCESSOR(StackCheck)
2587 Label* done_label() { return &done_label_; }
2594 class LForInPrepareMap V8_FINAL : public LTemplateInstruction<1, 2, 0> {
2596 LForInPrepareMap(LOperand* context, LOperand* object) {
2597 inputs_[0] = context;
2598 inputs_[1] = object;
2601 LOperand* context() { return inputs_[0]; }
2602 LOperand* object() { return inputs_[1]; }
2604 DECLARE_CONCRETE_INSTRUCTION(ForInPrepareMap, "for-in-prepare-map")
2608 class LForInCacheArray V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2610 explicit LForInCacheArray(LOperand* map) {
2614 LOperand* map() { return inputs_[0]; }
2616 DECLARE_CONCRETE_INSTRUCTION(ForInCacheArray, "for-in-cache-array")
2619 return HForInCacheArray::cast(this->hydrogen_value())->idx();
2624 class LCheckMapValue V8_FINAL : public LTemplateInstruction<0, 2, 0> {
2626 LCheckMapValue(LOperand* value, LOperand* map) {
2631 LOperand* value() { return inputs_[0]; }
2632 LOperand* map() { return inputs_[1]; }
2634 DECLARE_CONCRETE_INSTRUCTION(CheckMapValue, "check-map-value")
2638 class LLoadFieldByIndex V8_FINAL : public LTemplateInstruction<1, 2, 0> {
2640 LLoadFieldByIndex(LOperand* object, LOperand* index) {
2641 inputs_[0] = object;
2645 LOperand* object() { return inputs_[0]; }
2646 LOperand* index() { return inputs_[1]; }
2648 DECLARE_CONCRETE_INSTRUCTION(LoadFieldByIndex, "load-field-by-index")
2652 class LStoreFrameContext: public LTemplateInstruction<0, 1, 0> {
2654 explicit LStoreFrameContext(LOperand* context) {
2655 inputs_[0] = context;
2658 LOperand* context() { return inputs_[0]; }
2660 DECLARE_CONCRETE_INSTRUCTION(StoreFrameContext, "store-frame-context")
2664 class LAllocateBlockContext: public LTemplateInstruction<1, 2, 0> {
2666 LAllocateBlockContext(LOperand* context, LOperand* function) {
2667 inputs_[0] = context;
2668 inputs_[1] = function;
2671 LOperand* context() { return inputs_[0]; }
2672 LOperand* function() { return inputs_[1]; }
2674 Handle<ScopeInfo> scope_info() { return hydrogen()->scope_info(); }
2676 DECLARE_CONCRETE_INSTRUCTION(AllocateBlockContext, "allocate-block-context")
2677 DECLARE_HYDROGEN_ACCESSOR(AllocateBlockContext)
2681 class LChunkBuilder;
2682 class LPlatformChunk V8_FINAL : public LChunk {
2684 LPlatformChunk(CompilationInfo* info, HGraph* graph)
2685 : LChunk(info, graph),
2686 dehoisted_key_ids_(graph->GetMaximumValueID(), graph->zone()) { }
2688 int GetNextSpillIndex(RegisterKind kind);
2689 LOperand* GetNextSpillSlot(RegisterKind kind);
2690 BitVector* GetDehoistedKeyIds() { return &dehoisted_key_ids_; }
2691 bool IsDehoistedKey(HValue* value) {
2692 return dehoisted_key_ids_.Contains(value->id());
2696 BitVector dehoisted_key_ids_;
2700 class LChunkBuilder V8_FINAL : public LChunkBuilderBase {
2702 LChunkBuilder(CompilationInfo* info, HGraph* graph, LAllocator* allocator)
2703 : LChunkBuilderBase(graph->zone()),
2708 current_instruction_(NULL),
2709 current_block_(NULL),
2711 allocator_(allocator) { }
2713 Isolate* isolate() const { return graph_->isolate(); }
2715 // Build the sequence for the graph.
2716 LPlatformChunk* Build();
2718 // Declare methods that deal with the individual node types.
2719 #define DECLARE_DO(type) LInstruction* Do##type(H##type* node);
2720 HYDROGEN_CONCRETE_INSTRUCTION_LIST(DECLARE_DO)
2723 LInstruction* DoMathFloor(HUnaryMathOperation* instr);
2724 LInstruction* DoMathRound(HUnaryMathOperation* instr);
2725 LInstruction* DoMathAbs(HUnaryMathOperation* instr);
2726 LInstruction* DoMathLog(HUnaryMathOperation* instr);
2727 LInstruction* DoMathExp(HUnaryMathOperation* instr);
2728 LInstruction* DoMathSqrt(HUnaryMathOperation* instr);
2729 LInstruction* DoMathPowHalf(HUnaryMathOperation* instr);
2730 LInstruction* DoMathClz32(HUnaryMathOperation* instr);
2731 LInstruction* DoDivByPowerOf2I(HDiv* instr);
2732 LInstruction* DoDivByConstI(HDiv* instr);
2733 LInstruction* DoDivI(HDiv* instr);
2734 LInstruction* DoModByPowerOf2I(HMod* instr);
2735 LInstruction* DoModByConstI(HMod* instr);
2736 LInstruction* DoModI(HMod* instr);
2737 LInstruction* DoFlooringDivByPowerOf2I(HMathFloorOfDiv* instr);
2738 LInstruction* DoFlooringDivByConstI(HMathFloorOfDiv* instr);
2739 LInstruction* DoFlooringDivI(HMathFloorOfDiv* instr);
2749 LPlatformChunk* chunk() const { return chunk_; }
2750 CompilationInfo* info() const { return info_; }
2751 HGraph* graph() const { return graph_; }
2753 bool is_unused() const { return status_ == UNUSED; }
2754 bool is_building() const { return status_ == BUILDING; }
2755 bool is_done() const { return status_ == DONE; }
2756 bool is_aborted() const { return status_ == ABORTED; }
2758 void Abort(BailoutReason reason);
2760 // Methods for getting operands for Use / Define / Temp.
2761 LUnallocated* ToUnallocated(Register reg);
2762 LUnallocated* ToUnallocated(XMMRegister reg);
2764 // Methods for setting up define-use relationships.
2765 MUST_USE_RESULT LOperand* Use(HValue* value, LUnallocated* operand);
2766 MUST_USE_RESULT LOperand* UseFixed(HValue* value, Register fixed_register);
2767 MUST_USE_RESULT LOperand* UseFixedDouble(HValue* value,
2768 XMMRegister fixed_register);
2770 // A value that is guaranteed to be allocated to a register.
2771 // Operand created by UseRegister is guaranteed to be live until the end of
2772 // instruction. This means that register allocator will not reuse it's
2773 // register for any other operand inside instruction.
2774 // Operand created by UseRegisterAtStart is guaranteed to be live only at
2775 // instruction start. Register allocator is free to assign the same register
2776 // to some other operand used inside instruction (i.e. temporary or
2778 MUST_USE_RESULT LOperand* UseRegister(HValue* value);
2779 MUST_USE_RESULT LOperand* UseRegisterAtStart(HValue* value);
2781 // An input operand in a register that may be trashed.
2782 MUST_USE_RESULT LOperand* UseTempRegister(HValue* value);
2784 // An input operand in a register that may be trashed or a constant operand.
2785 MUST_USE_RESULT LOperand* UseTempRegisterOrConstant(HValue* value);
2787 // An input operand in a register or stack slot.
2788 MUST_USE_RESULT LOperand* Use(HValue* value);
2789 MUST_USE_RESULT LOperand* UseAtStart(HValue* value);
2791 // An input operand in a register, stack slot or a constant operand.
2792 MUST_USE_RESULT LOperand* UseOrConstant(HValue* value);
2793 MUST_USE_RESULT LOperand* UseOrConstantAtStart(HValue* value);
2795 // An input operand in a register or a constant operand.
2796 MUST_USE_RESULT LOperand* UseRegisterOrConstant(HValue* value);
2797 MUST_USE_RESULT LOperand* UseRegisterOrConstantAtStart(HValue* value);
2799 // An input operand in a constant operand.
2800 MUST_USE_RESULT LOperand* UseConstant(HValue* value);
2802 // An input operand in register, stack slot or a constant operand.
2803 // Will not be moved to a register even if one is freely available.
2804 virtual MUST_USE_RESULT LOperand* UseAny(HValue* value) V8_OVERRIDE;
2806 // Temporary operand that must be in a register.
2807 MUST_USE_RESULT LUnallocated* TempRegister();
2808 MUST_USE_RESULT LOperand* FixedTemp(Register reg);
2809 MUST_USE_RESULT LOperand* FixedTemp(XMMRegister reg);
2811 // Methods for setting up define-use relationships.
2812 // Return the same instruction that they are passed.
2813 LInstruction* Define(LTemplateResultInstruction<1>* instr,
2814 LUnallocated* result);
2815 LInstruction* DefineAsRegister(LTemplateResultInstruction<1>* instr);
2816 LInstruction* DefineAsSpilled(LTemplateResultInstruction<1>* instr,
2818 LInstruction* DefineSameAsFirst(LTemplateResultInstruction<1>* instr);
2819 LInstruction* DefineFixed(LTemplateResultInstruction<1>* instr,
2821 LInstruction* DefineFixedDouble(LTemplateResultInstruction<1>* instr,
2823 // Assigns an environment to an instruction. An instruction which can
2824 // deoptimize must have an environment.
2825 LInstruction* AssignEnvironment(LInstruction* instr);
2826 // Assigns a pointer map to an instruction. An instruction which can
2827 // trigger a GC or a lazy deoptimization must have a pointer map.
2828 LInstruction* AssignPointerMap(LInstruction* instr);
2830 enum CanDeoptimize { CAN_DEOPTIMIZE_EAGERLY, CANNOT_DEOPTIMIZE_EAGERLY };
2832 // Marks a call for the register allocator. Assigns a pointer map to
2833 // support GC and lazy deoptimization. Assigns an environment to support
2834 // eager deoptimization if CAN_DEOPTIMIZE_EAGERLY.
2835 LInstruction* MarkAsCall(
2836 LInstruction* instr,
2837 HInstruction* hinstr,
2838 CanDeoptimize can_deoptimize = CANNOT_DEOPTIMIZE_EAGERLY);
2840 void VisitInstruction(HInstruction* current);
2841 void AddInstruction(LInstruction* instr, HInstruction* current);
2843 void DoBasicBlock(HBasicBlock* block, HBasicBlock* next_block);
2844 LInstruction* DoShift(Token::Value op, HBitwiseBinaryOperation* instr);
2845 LInstruction* DoArithmeticD(Token::Value op,
2846 HArithmeticBinaryOperation* instr);
2847 LInstruction* DoArithmeticT(Token::Value op,
2848 HBinaryOperation* instr);
2849 void FindDehoistedKeyDefinitions(HValue* candidate);
2851 LPlatformChunk* chunk_;
2852 CompilationInfo* info_;
2853 HGraph* const graph_;
2855 HInstruction* current_instruction_;
2856 HBasicBlock* current_block_;
2857 HBasicBlock* next_block_;
2858 LAllocator* allocator_;
2860 DISALLOW_COPY_AND_ASSIGN(LChunkBuilder);
2863 #undef DECLARE_HYDROGEN_ACCESSOR
2864 #undef DECLARE_CONCRETE_INSTRUCTION
2866 } } // namespace v8::int
2868 #endif // V8_X64_LITHIUM_X64_H_