Upstream version 7.36.149.0
[platform/framework/web/crosswalk.git] / src / v8 / src / arm / lithium-arm.h
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.
4
5 #ifndef V8_ARM_LITHIUM_ARM_H_
6 #define V8_ARM_LITHIUM_ARM_H_
7
8 #include "hydrogen.h"
9 #include "lithium-allocator.h"
10 #include "lithium.h"
11 #include "safepoint-table.h"
12 #include "utils.h"
13
14 namespace v8 {
15 namespace internal {
16
17 // Forward declarations.
18 class LCodeGen;
19
20 #define LITHIUM_CONCRETE_INSTRUCTION_LIST(V)    \
21   V(AccessArgumentsAt)                          \
22   V(AddI)                                       \
23   V(Allocate)                                   \
24   V(ApplyArguments)                             \
25   V(ArgumentsElements)                          \
26   V(ArgumentsLength)                            \
27   V(ArithmeticD)                                \
28   V(ArithmeticT)                                \
29   V(BitI)                                       \
30   V(BoundsCheck)                                \
31   V(Branch)                                     \
32   V(CallJSFunction)                             \
33   V(CallWithDescriptor)                         \
34   V(CallFunction)                               \
35   V(CallNew)                                    \
36   V(CallNewArray)                               \
37   V(CallRuntime)                                \
38   V(CallStub)                                   \
39   V(CheckInstanceType)                          \
40   V(CheckNonSmi)                                \
41   V(CheckMaps)                                  \
42   V(CheckMapValue)                              \
43   V(CheckSmi)                                   \
44   V(CheckValue)                                 \
45   V(ClampDToUint8)                              \
46   V(ClampIToUint8)                              \
47   V(ClampTToUint8)                              \
48   V(ClassOfTestAndBranch)                       \
49   V(CompareMinusZeroAndBranch)                  \
50   V(CompareNumericAndBranch)                    \
51   V(CmpObjectEqAndBranch)                       \
52   V(CmpHoleAndBranch)                           \
53   V(CmpMapAndBranch)                            \
54   V(CmpT)                                       \
55   V(ConstantD)                                  \
56   V(ConstantE)                                  \
57   V(ConstantI)                                  \
58   V(ConstantS)                                  \
59   V(ConstantT)                                  \
60   V(ConstructDouble)                            \
61   V(Context)                                    \
62   V(DateField)                                  \
63   V(DebugBreak)                                 \
64   V(DeclareGlobals)                             \
65   V(Deoptimize)                                 \
66   V(DivByConstI)                                \
67   V(DivByPowerOf2I)                             \
68   V(DivI)                                       \
69   V(DoubleBits)                                 \
70   V(DoubleToI)                                  \
71   V(DoubleToSmi)                                \
72   V(Drop)                                       \
73   V(Dummy)                                      \
74   V(DummyUse)                                   \
75   V(FlooringDivByConstI)                        \
76   V(FlooringDivByPowerOf2I)                     \
77   V(FlooringDivI)                               \
78   V(ForInCacheArray)                            \
79   V(ForInPrepareMap)                            \
80   V(FunctionLiteral)                            \
81   V(GetCachedArrayIndex)                        \
82   V(Goto)                                       \
83   V(HasCachedArrayIndexAndBranch)               \
84   V(HasInstanceTypeAndBranch)                   \
85   V(InnerAllocatedObject)                       \
86   V(InstanceOf)                                 \
87   V(InstanceOfKnownGlobal)                      \
88   V(InstructionGap)                             \
89   V(Integer32ToDouble)                          \
90   V(InvokeFunction)                             \
91   V(IsConstructCallAndBranch)                   \
92   V(IsObjectAndBranch)                          \
93   V(IsStringAndBranch)                          \
94   V(IsSmiAndBranch)                             \
95   V(IsUndetectableAndBranch)                    \
96   V(Label)                                      \
97   V(LazyBailout)                                \
98   V(LoadContextSlot)                            \
99   V(LoadRoot)                                   \
100   V(LoadFieldByIndex)                           \
101   V(LoadFunctionPrototype)                      \
102   V(LoadGlobalCell)                             \
103   V(LoadGlobalGeneric)                          \
104   V(LoadKeyed)                                  \
105   V(LoadKeyedGeneric)                           \
106   V(LoadNamedField)                             \
107   V(LoadNamedGeneric)                           \
108   V(MapEnumLength)                              \
109   V(MathAbs)                                    \
110   V(MathClz32)                                  \
111   V(MathExp)                                    \
112   V(MathFloor)                                  \
113   V(MathLog)                                    \
114   V(MathMinMax)                                 \
115   V(MathPowHalf)                                \
116   V(MathRound)                                  \
117   V(MathSqrt)                                   \
118   V(ModByConstI)                                \
119   V(ModByPowerOf2I)                             \
120   V(ModI)                                       \
121   V(MulI)                                       \
122   V(MultiplyAddD)                               \
123   V(MultiplySubD)                               \
124   V(NumberTagD)                                 \
125   V(NumberTagI)                                 \
126   V(NumberTagU)                                 \
127   V(NumberUntagD)                               \
128   V(OsrEntry)                                   \
129   V(Parameter)                                  \
130   V(Power)                                      \
131   V(PushArgument)                               \
132   V(RegExpLiteral)                              \
133   V(Return)                                     \
134   V(SeqStringGetChar)                           \
135   V(SeqStringSetChar)                           \
136   V(ShiftI)                                     \
137   V(SmiTag)                                     \
138   V(SmiUntag)                                   \
139   V(StackCheck)                                 \
140   V(StoreCodeEntry)                             \
141   V(StoreContextSlot)                           \
142   V(StoreGlobalCell)                            \
143   V(StoreKeyed)                                 \
144   V(StoreKeyedGeneric)                          \
145   V(StoreNamedField)                            \
146   V(StoreNamedGeneric)                          \
147   V(StringAdd)                                  \
148   V(StringCharCodeAt)                           \
149   V(StringCharFromCode)                         \
150   V(StringCompareAndBranch)                     \
151   V(SubI)                                       \
152   V(RSubI)                                      \
153   V(TaggedToI)                                  \
154   V(ThisFunction)                               \
155   V(ToFastProperties)                           \
156   V(TransitionElementsKind)                     \
157   V(TrapAllocationMemento)                      \
158   V(Typeof)                                     \
159   V(TypeofIsAndBranch)                          \
160   V(Uint32ToDouble)                             \
161   V(UnknownOSRValue)                            \
162   V(WrapReceiver)
163
164
165 #define DECLARE_CONCRETE_INSTRUCTION(type, mnemonic)                        \
166   virtual Opcode opcode() const V8_FINAL V8_OVERRIDE {                      \
167     return LInstruction::k##type;                                           \
168   }                                                                         \
169   virtual void CompileToNative(LCodeGen* generator) V8_FINAL V8_OVERRIDE;   \
170   virtual const char* Mnemonic() const V8_FINAL V8_OVERRIDE {               \
171     return mnemonic;                                                        \
172   }                                                                         \
173   static L##type* cast(LInstruction* instr) {                               \
174     ASSERT(instr->Is##type());                                              \
175     return reinterpret_cast<L##type*>(instr);                               \
176   }
177
178
179 #define DECLARE_HYDROGEN_ACCESSOR(type)     \
180   H##type* hydrogen() const {               \
181     return H##type::cast(hydrogen_value()); \
182   }
183
184
185 class LInstruction : public ZoneObject {
186  public:
187   LInstruction()
188       : environment_(NULL),
189         hydrogen_value_(NULL),
190         bit_field_(IsCallBits::encode(false)) {
191   }
192
193   virtual ~LInstruction() {}
194
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);
200
201   enum Opcode {
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
207   };
208
209   virtual Opcode opcode() const = 0;
210
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
216
217   // Declare virtual predicates for instructions that don't have
218   // an opcode.
219   virtual bool IsGap() const { return false; }
220
221   virtual bool IsControl() const { return false; }
222
223   void set_environment(LEnvironment* env) { environment_ = env; }
224   LEnvironment* environment() const { return environment_; }
225   bool HasEnvironment() const { return environment_ != NULL; }
226
227   void set_pointer_map(LPointerMap* p) { pointer_map_.set(p); }
228   LPointerMap* pointer_map() const { return pointer_map_.get(); }
229   bool HasPointerMap() const { return pointer_map_.is_set(); }
230
231   void set_hydrogen_value(HValue* value) { hydrogen_value_ = value; }
232   HValue* hydrogen_value() const { return hydrogen_value_; }
233
234   virtual void SetDeferredLazyDeoptimizationEnvironment(LEnvironment* env) { }
235
236   void MarkAsCall() { bit_field_ = IsCallBits::update(bit_field_, true); }
237   bool IsCall() const { return IsCallBits::decode(bit_field_); }
238
239   // Interface to the register allocator and iterators.
240   bool ClobbersTemps() const { return IsCall(); }
241   bool ClobbersRegisters() const { return IsCall(); }
242   virtual bool ClobbersDoubleRegisters(Isolate* isolate) const {
243     return IsCall();
244   }
245
246   // Interface to the register allocator and iterators.
247   bool IsMarkedAsCall() const { return IsCall(); }
248
249   virtual bool HasResult() const = 0;
250   virtual LOperand* result() const = 0;
251
252   LOperand* FirstInput() { return InputAt(0); }
253   LOperand* Output() { return HasResult() ? result() : NULL; }
254
255   virtual bool HasInterestingComment(LCodeGen* gen) const { return true; }
256
257 #ifdef DEBUG
258   void VerifyCall();
259 #endif
260
261  private:
262   // Iterator support.
263   friend class InputIterator;
264   virtual int InputCount() = 0;
265   virtual LOperand* InputAt(int i) = 0;
266
267   friend class TempIterator;
268   virtual int TempCount() = 0;
269   virtual LOperand* TempAt(int i) = 0;
270
271   class IsCallBits: public BitField<bool, 0, 1> {};
272
273   LEnvironment* environment_;
274   SetOncePointer<LPointerMap> pointer_map_;
275   HValue* hydrogen_value_;
276   int bit_field_;
277 };
278
279
280 // R = number of result operands (0 or 1).
281 template<int R>
282 class LTemplateResultInstruction : public LInstruction {
283  public:
284   // Allow 0 or 1 output operands.
285   STATIC_ASSERT(R == 0 || R == 1);
286   virtual bool HasResult() const V8_FINAL V8_OVERRIDE {
287     return R != 0 && result() != NULL;
288   }
289   void set_result(LOperand* operand) { results_[0] = operand; }
290   LOperand* result() const { return results_[0]; }
291
292  protected:
293   EmbeddedContainer<LOperand*, R> results_;
294 };
295
296
297 // R = number of result operands (0 or 1).
298 // I = number of input operands.
299 // T = number of temporary operands.
300 template<int R, int I, int T>
301 class LTemplateInstruction : public LTemplateResultInstruction<R> {
302  protected:
303   EmbeddedContainer<LOperand*, I> inputs_;
304   EmbeddedContainer<LOperand*, T> temps_;
305
306  private:
307   // Iterator support.
308   virtual int InputCount() V8_FINAL V8_OVERRIDE { return I; }
309   virtual LOperand* InputAt(int i) V8_FINAL V8_OVERRIDE { return inputs_[i]; }
310
311   virtual int TempCount() V8_FINAL V8_OVERRIDE { return T; }
312   virtual LOperand* TempAt(int i) V8_FINAL V8_OVERRIDE { return temps_[i]; }
313 };
314
315
316 class LGap : public LTemplateInstruction<0, 0, 0> {
317  public:
318   explicit LGap(HBasicBlock* block)
319       : block_(block) {
320     parallel_moves_[BEFORE] = NULL;
321     parallel_moves_[START] = NULL;
322     parallel_moves_[END] = NULL;
323     parallel_moves_[AFTER] = NULL;
324   }
325
326   // Can't use the DECLARE-macro here because of sub-classes.
327   virtual bool IsGap() const V8_OVERRIDE { return true; }
328   virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
329   static LGap* cast(LInstruction* instr) {
330     ASSERT(instr->IsGap());
331     return reinterpret_cast<LGap*>(instr);
332   }
333
334   bool IsRedundant() const;
335
336   HBasicBlock* block() const { return block_; }
337
338   enum InnerPosition {
339     BEFORE,
340     START,
341     END,
342     AFTER,
343     FIRST_INNER_POSITION = BEFORE,
344     LAST_INNER_POSITION = AFTER
345   };
346
347   LParallelMove* GetOrCreateParallelMove(InnerPosition pos, Zone* zone)  {
348     if (parallel_moves_[pos] == NULL) {
349       parallel_moves_[pos] = new(zone) LParallelMove(zone);
350     }
351     return parallel_moves_[pos];
352   }
353
354   LParallelMove* GetParallelMove(InnerPosition pos)  {
355     return parallel_moves_[pos];
356   }
357
358  private:
359   LParallelMove* parallel_moves_[LAST_INNER_POSITION + 1];
360   HBasicBlock* block_;
361 };
362
363
364 class LInstructionGap V8_FINAL : public LGap {
365  public:
366   explicit LInstructionGap(HBasicBlock* block) : LGap(block) { }
367
368   virtual bool HasInterestingComment(LCodeGen* gen) const V8_OVERRIDE {
369     return !IsRedundant();
370   }
371
372   DECLARE_CONCRETE_INSTRUCTION(InstructionGap, "gap")
373 };
374
375
376 class LGoto V8_FINAL : public LTemplateInstruction<0, 0, 0> {
377  public:
378   explicit LGoto(HBasicBlock* block) : block_(block) { }
379
380   virtual bool HasInterestingComment(LCodeGen* gen) const V8_OVERRIDE;
381   DECLARE_CONCRETE_INSTRUCTION(Goto, "goto")
382   virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
383   virtual bool IsControl() const V8_OVERRIDE { return true; }
384
385   int block_id() const { return block_->block_id(); }
386
387  private:
388   HBasicBlock* block_;
389 };
390
391
392 class LLazyBailout V8_FINAL : public LTemplateInstruction<0, 0, 0> {
393  public:
394   LLazyBailout() : gap_instructions_size_(0) { }
395
396   DECLARE_CONCRETE_INSTRUCTION(LazyBailout, "lazy-bailout")
397
398   void set_gap_instructions_size(int gap_instructions_size) {
399     gap_instructions_size_ = gap_instructions_size;
400   }
401   int gap_instructions_size() { return gap_instructions_size_; }
402
403  private:
404   int gap_instructions_size_;
405 };
406
407
408 class LDummy V8_FINAL : public LTemplateInstruction<1, 0, 0> {
409  public:
410   explicit LDummy() { }
411   DECLARE_CONCRETE_INSTRUCTION(Dummy, "dummy")
412 };
413
414
415 class LDummyUse V8_FINAL : public LTemplateInstruction<1, 1, 0> {
416  public:
417   explicit LDummyUse(LOperand* value) {
418     inputs_[0] = value;
419   }
420   DECLARE_CONCRETE_INSTRUCTION(DummyUse, "dummy-use")
421 };
422
423
424 class LDeoptimize V8_FINAL : public LTemplateInstruction<0, 0, 0> {
425  public:
426   DECLARE_CONCRETE_INSTRUCTION(Deoptimize, "deoptimize")
427   DECLARE_HYDROGEN_ACCESSOR(Deoptimize)
428 };
429
430
431 class LLabel V8_FINAL : public LGap {
432  public:
433   explicit LLabel(HBasicBlock* block)
434       : LGap(block), replacement_(NULL) { }
435
436   virtual bool HasInterestingComment(LCodeGen* gen) const V8_OVERRIDE {
437     return false;
438   }
439   DECLARE_CONCRETE_INSTRUCTION(Label, "label")
440
441   virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
442
443   int block_id() const { return block()->block_id(); }
444   bool is_loop_header() const { return block()->IsLoopHeader(); }
445   bool is_osr_entry() const { return block()->is_osr_entry(); }
446   Label* label() { return &label_; }
447   LLabel* replacement() const { return replacement_; }
448   void set_replacement(LLabel* label) { replacement_ = label; }
449   bool HasReplacement() const { return replacement_ != NULL; }
450
451  private:
452   Label label_;
453   LLabel* replacement_;
454 };
455
456
457 class LParameter V8_FINAL : public LTemplateInstruction<1, 0, 0> {
458  public:
459   virtual bool HasInterestingComment(LCodeGen* gen) const { return false; }
460   DECLARE_CONCRETE_INSTRUCTION(Parameter, "parameter")
461 };
462
463
464 class LCallStub V8_FINAL : public LTemplateInstruction<1, 1, 0> {
465  public:
466   explicit LCallStub(LOperand* context) {
467     inputs_[0] = context;
468   }
469
470   LOperand* context() { return inputs_[0]; }
471
472   DECLARE_CONCRETE_INSTRUCTION(CallStub, "call-stub")
473   DECLARE_HYDROGEN_ACCESSOR(CallStub)
474 };
475
476
477 class LUnknownOSRValue V8_FINAL : public LTemplateInstruction<1, 0, 0> {
478  public:
479   virtual bool HasInterestingComment(LCodeGen* gen) const V8_OVERRIDE {
480     return false;
481   }
482   DECLARE_CONCRETE_INSTRUCTION(UnknownOSRValue, "unknown-osr-value")
483 };
484
485
486 template<int I, int T>
487 class LControlInstruction : public LTemplateInstruction<0, I, T> {
488  public:
489   LControlInstruction() : false_label_(NULL), true_label_(NULL) { }
490
491   virtual bool IsControl() const V8_FINAL V8_OVERRIDE { return true; }
492
493   int SuccessorCount() { return hydrogen()->SuccessorCount(); }
494   HBasicBlock* SuccessorAt(int i) { return hydrogen()->SuccessorAt(i); }
495
496   int TrueDestination(LChunk* chunk) {
497     return chunk->LookupDestination(true_block_id());
498   }
499   int FalseDestination(LChunk* chunk) {
500     return chunk->LookupDestination(false_block_id());
501   }
502
503   Label* TrueLabel(LChunk* chunk) {
504     if (true_label_ == NULL) {
505       true_label_ = chunk->GetAssemblyLabel(TrueDestination(chunk));
506     }
507     return true_label_;
508   }
509   Label* FalseLabel(LChunk* chunk) {
510     if (false_label_ == NULL) {
511       false_label_ = chunk->GetAssemblyLabel(FalseDestination(chunk));
512     }
513     return false_label_;
514   }
515
516  protected:
517   int true_block_id() { return SuccessorAt(0)->block_id(); }
518   int false_block_id() { return SuccessorAt(1)->block_id(); }
519
520  private:
521   HControlInstruction* hydrogen() {
522     return HControlInstruction::cast(this->hydrogen_value());
523   }
524
525   Label* false_label_;
526   Label* true_label_;
527 };
528
529
530 class LWrapReceiver V8_FINAL : public LTemplateInstruction<1, 2, 0> {
531  public:
532   LWrapReceiver(LOperand* receiver, LOperand* function) {
533     inputs_[0] = receiver;
534     inputs_[1] = function;
535   }
536
537   DECLARE_CONCRETE_INSTRUCTION(WrapReceiver, "wrap-receiver")
538   DECLARE_HYDROGEN_ACCESSOR(WrapReceiver)
539
540   LOperand* receiver() { return inputs_[0]; }
541   LOperand* function() { return inputs_[1]; }
542 };
543
544
545 class LApplyArguments V8_FINAL : public LTemplateInstruction<1, 4, 0> {
546  public:
547   LApplyArguments(LOperand* function,
548                   LOperand* receiver,
549                   LOperand* length,
550                   LOperand* elements) {
551     inputs_[0] = function;
552     inputs_[1] = receiver;
553     inputs_[2] = length;
554     inputs_[3] = elements;
555   }
556
557   DECLARE_CONCRETE_INSTRUCTION(ApplyArguments, "apply-arguments")
558
559   LOperand* function() { return inputs_[0]; }
560   LOperand* receiver() { return inputs_[1]; }
561   LOperand* length() { return inputs_[2]; }
562   LOperand* elements() { return inputs_[3]; }
563 };
564
565
566 class LAccessArgumentsAt V8_FINAL : public LTemplateInstruction<1, 3, 0> {
567  public:
568   LAccessArgumentsAt(LOperand* arguments, LOperand* length, LOperand* index) {
569     inputs_[0] = arguments;
570     inputs_[1] = length;
571     inputs_[2] = index;
572   }
573
574   DECLARE_CONCRETE_INSTRUCTION(AccessArgumentsAt, "access-arguments-at")
575
576   LOperand* arguments() { return inputs_[0]; }
577   LOperand* length() { return inputs_[1]; }
578   LOperand* index() { return inputs_[2]; }
579
580   virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
581 };
582
583
584 class LArgumentsLength V8_FINAL : public LTemplateInstruction<1, 1, 0> {
585  public:
586   explicit LArgumentsLength(LOperand* elements) {
587     inputs_[0] = elements;
588   }
589
590   LOperand* elements() { return inputs_[0]; }
591
592   DECLARE_CONCRETE_INSTRUCTION(ArgumentsLength, "arguments-length")
593 };
594
595
596 class LArgumentsElements V8_FINAL : public LTemplateInstruction<1, 0, 0> {
597  public:
598   DECLARE_CONCRETE_INSTRUCTION(ArgumentsElements, "arguments-elements")
599   DECLARE_HYDROGEN_ACCESSOR(ArgumentsElements)
600 };
601
602
603 class LModByPowerOf2I V8_FINAL : public LTemplateInstruction<1, 1, 0> {
604  public:
605   LModByPowerOf2I(LOperand* dividend, int32_t divisor) {
606     inputs_[0] = dividend;
607     divisor_ = divisor;
608   }
609
610   LOperand* dividend() { return inputs_[0]; }
611   int32_t divisor() const { return divisor_; }
612
613   DECLARE_CONCRETE_INSTRUCTION(ModByPowerOf2I, "mod-by-power-of-2-i")
614   DECLARE_HYDROGEN_ACCESSOR(Mod)
615
616  private:
617   int32_t divisor_;
618 };
619
620
621 class LModByConstI V8_FINAL : public LTemplateInstruction<1, 1, 0> {
622  public:
623   LModByConstI(LOperand* dividend, int32_t divisor) {
624     inputs_[0] = dividend;
625     divisor_ = divisor;
626   }
627
628   LOperand* dividend() { return inputs_[0]; }
629   int32_t divisor() const { return divisor_; }
630
631   DECLARE_CONCRETE_INSTRUCTION(ModByConstI, "mod-by-const-i")
632   DECLARE_HYDROGEN_ACCESSOR(Mod)
633
634  private:
635   int32_t divisor_;
636 };
637
638
639 class LModI V8_FINAL : public LTemplateInstruction<1, 2, 2> {
640  public:
641   LModI(LOperand* left, LOperand* right, LOperand* temp, LOperand* temp2) {
642     inputs_[0] = left;
643     inputs_[1] = right;
644     temps_[0] = temp;
645     temps_[1] = temp2;
646   }
647
648   LOperand* left() { return inputs_[0]; }
649   LOperand* right() { return inputs_[1]; }
650   LOperand* temp() { return temps_[0]; }
651   LOperand* temp2() { return temps_[1]; }
652
653   DECLARE_CONCRETE_INSTRUCTION(ModI, "mod-i")
654   DECLARE_HYDROGEN_ACCESSOR(Mod)
655 };
656
657
658 class LDivByPowerOf2I V8_FINAL : public LTemplateInstruction<1, 1, 0> {
659  public:
660   LDivByPowerOf2I(LOperand* dividend, int32_t divisor) {
661     inputs_[0] = dividend;
662     divisor_ = divisor;
663   }
664
665   LOperand* dividend() { return inputs_[0]; }
666   int32_t divisor() const { return divisor_; }
667
668   DECLARE_CONCRETE_INSTRUCTION(DivByPowerOf2I, "div-by-power-of-2-i")
669   DECLARE_HYDROGEN_ACCESSOR(Div)
670
671  private:
672   int32_t divisor_;
673 };
674
675
676 class LDivByConstI V8_FINAL : public LTemplateInstruction<1, 1, 0> {
677  public:
678   LDivByConstI(LOperand* dividend, int32_t divisor) {
679     inputs_[0] = dividend;
680     divisor_ = divisor;
681   }
682
683   LOperand* dividend() { return inputs_[0]; }
684   int32_t divisor() const { return divisor_; }
685
686   DECLARE_CONCRETE_INSTRUCTION(DivByConstI, "div-by-const-i")
687   DECLARE_HYDROGEN_ACCESSOR(Div)
688
689  private:
690   int32_t divisor_;
691 };
692
693
694 class LDivI V8_FINAL : public LTemplateInstruction<1, 2, 1> {
695  public:
696   LDivI(LOperand* dividend, LOperand* divisor, LOperand* temp) {
697     inputs_[0] = dividend;
698     inputs_[1] = divisor;
699     temps_[0] = temp;
700   }
701
702   LOperand* dividend() { return inputs_[0]; }
703   LOperand* divisor() { return inputs_[1]; }
704   LOperand* temp() { return temps_[0]; }
705
706   DECLARE_CONCRETE_INSTRUCTION(DivI, "div-i")
707   DECLARE_HYDROGEN_ACCESSOR(BinaryOperation)
708 };
709
710
711 class LFlooringDivByPowerOf2I V8_FINAL : public LTemplateInstruction<1, 1, 0> {
712  public:
713   LFlooringDivByPowerOf2I(LOperand* dividend, int32_t divisor) {
714     inputs_[0] = dividend;
715     divisor_ = divisor;
716   }
717
718   LOperand* dividend() { return inputs_[0]; }
719   int32_t divisor() { return divisor_; }
720
721   DECLARE_CONCRETE_INSTRUCTION(FlooringDivByPowerOf2I,
722                                "flooring-div-by-power-of-2-i")
723   DECLARE_HYDROGEN_ACCESSOR(MathFloorOfDiv)
724
725  private:
726   int32_t divisor_;
727 };
728
729
730 class LFlooringDivByConstI V8_FINAL : public LTemplateInstruction<1, 1, 2> {
731  public:
732   LFlooringDivByConstI(LOperand* dividend, int32_t divisor, LOperand* temp) {
733     inputs_[0] = dividend;
734     divisor_ = divisor;
735     temps_[0] = temp;
736   }
737
738   LOperand* dividend() { return inputs_[0]; }
739   int32_t divisor() const { return divisor_; }
740   LOperand* temp() { return temps_[0]; }
741
742   DECLARE_CONCRETE_INSTRUCTION(FlooringDivByConstI, "flooring-div-by-const-i")
743   DECLARE_HYDROGEN_ACCESSOR(MathFloorOfDiv)
744
745  private:
746   int32_t divisor_;
747 };
748
749
750 class LFlooringDivI V8_FINAL : public LTemplateInstruction<1, 2, 1> {
751  public:
752   LFlooringDivI(LOperand* dividend, LOperand* divisor, LOperand* temp) {
753     inputs_[0] = dividend;
754     inputs_[1] = divisor;
755     temps_[0] = temp;
756   }
757
758   LOperand* dividend() { return inputs_[0]; }
759   LOperand* divisor() { return inputs_[1]; }
760   LOperand* temp() { return temps_[0]; }
761
762   DECLARE_CONCRETE_INSTRUCTION(FlooringDivI, "flooring-div-i")
763   DECLARE_HYDROGEN_ACCESSOR(MathFloorOfDiv)
764 };
765
766
767 class LMulI V8_FINAL : public LTemplateInstruction<1, 2, 0> {
768  public:
769   LMulI(LOperand* left, LOperand* right) {
770     inputs_[0] = left;
771     inputs_[1] = right;
772   }
773
774   LOperand* left() { return inputs_[0]; }
775   LOperand* right() { return inputs_[1]; }
776
777   DECLARE_CONCRETE_INSTRUCTION(MulI, "mul-i")
778   DECLARE_HYDROGEN_ACCESSOR(Mul)
779 };
780
781
782 // Instruction for computing multiplier * multiplicand + addend.
783 class LMultiplyAddD V8_FINAL : public LTemplateInstruction<1, 3, 0> {
784  public:
785   LMultiplyAddD(LOperand* addend, LOperand* multiplier,
786                 LOperand* multiplicand) {
787     inputs_[0] = addend;
788     inputs_[1] = multiplier;
789     inputs_[2] = multiplicand;
790   }
791
792   LOperand* addend() { return inputs_[0]; }
793   LOperand* multiplier() { return inputs_[1]; }
794   LOperand* multiplicand() { return inputs_[2]; }
795
796   DECLARE_CONCRETE_INSTRUCTION(MultiplyAddD, "multiply-add-d")
797 };
798
799
800 // Instruction for computing minuend - multiplier * multiplicand.
801 class LMultiplySubD V8_FINAL : public LTemplateInstruction<1, 3, 0> {
802  public:
803   LMultiplySubD(LOperand* minuend, LOperand* multiplier,
804                 LOperand* multiplicand) {
805     inputs_[0] = minuend;
806     inputs_[1] = multiplier;
807     inputs_[2] = multiplicand;
808   }
809
810   LOperand* minuend() { return inputs_[0]; }
811   LOperand* multiplier() { return inputs_[1]; }
812   LOperand* multiplicand() { return inputs_[2]; }
813
814   DECLARE_CONCRETE_INSTRUCTION(MultiplySubD, "multiply-sub-d")
815 };
816
817
818 class LDebugBreak V8_FINAL : public LTemplateInstruction<0, 0, 0> {
819  public:
820   DECLARE_CONCRETE_INSTRUCTION(DebugBreak, "break")
821 };
822
823
824 class LCompareNumericAndBranch V8_FINAL : public LControlInstruction<2, 0> {
825  public:
826   LCompareNumericAndBranch(LOperand* left, LOperand* right) {
827     inputs_[0] = left;
828     inputs_[1] = right;
829   }
830
831   LOperand* left() { return inputs_[0]; }
832   LOperand* right() { return inputs_[1]; }
833
834   DECLARE_CONCRETE_INSTRUCTION(CompareNumericAndBranch,
835                                "compare-numeric-and-branch")
836   DECLARE_HYDROGEN_ACCESSOR(CompareNumericAndBranch)
837
838   Token::Value op() const { return hydrogen()->token(); }
839   bool is_double() const {
840     return hydrogen()->representation().IsDouble();
841   }
842
843   virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
844 };
845
846
847 class LMathFloor V8_FINAL : public LTemplateInstruction<1, 1, 0> {
848  public:
849   explicit LMathFloor(LOperand* value) {
850     inputs_[0] = value;
851   }
852
853   LOperand* value() { return inputs_[0]; }
854
855   DECLARE_CONCRETE_INSTRUCTION(MathFloor, "math-floor")
856   DECLARE_HYDROGEN_ACCESSOR(UnaryMathOperation)
857 };
858
859
860 class LMathRound V8_FINAL : public LTemplateInstruction<1, 1, 1> {
861  public:
862   LMathRound(LOperand* value, LOperand* temp) {
863     inputs_[0] = value;
864     temps_[0] = temp;
865   }
866
867   LOperand* value() { return inputs_[0]; }
868   LOperand* temp() { return temps_[0]; }
869
870   DECLARE_CONCRETE_INSTRUCTION(MathRound, "math-round")
871   DECLARE_HYDROGEN_ACCESSOR(UnaryMathOperation)
872 };
873
874
875 class LMathAbs V8_FINAL : public LTemplateInstruction<1, 2, 0> {
876  public:
877   LMathAbs(LOperand* context, LOperand* value) {
878     inputs_[1] = context;
879     inputs_[0] = value;
880   }
881
882   LOperand* context() { return inputs_[1]; }
883   LOperand* value() { return inputs_[0]; }
884
885   DECLARE_CONCRETE_INSTRUCTION(MathAbs, "math-abs")
886   DECLARE_HYDROGEN_ACCESSOR(UnaryMathOperation)
887 };
888
889
890 class LMathLog V8_FINAL : public LTemplateInstruction<1, 1, 0> {
891  public:
892   explicit LMathLog(LOperand* value) {
893     inputs_[0] = value;
894   }
895
896   LOperand* value() { return inputs_[0]; }
897
898   DECLARE_CONCRETE_INSTRUCTION(MathLog, "math-log")
899 };
900
901
902 class LMathClz32 V8_FINAL : public LTemplateInstruction<1, 1, 0> {
903  public:
904   explicit LMathClz32(LOperand* value) {
905     inputs_[0] = value;
906   }
907
908   LOperand* value() { return inputs_[0]; }
909
910   DECLARE_CONCRETE_INSTRUCTION(MathClz32, "math-clz32")
911 };
912
913
914 class LMathExp V8_FINAL : public LTemplateInstruction<1, 1, 3> {
915  public:
916   LMathExp(LOperand* value,
917            LOperand* double_temp,
918            LOperand* temp1,
919            LOperand* temp2) {
920     inputs_[0] = value;
921     temps_[0] = temp1;
922     temps_[1] = temp2;
923     temps_[2] = double_temp;
924     ExternalReference::InitializeMathExpData();
925   }
926
927   LOperand* value() { return inputs_[0]; }
928   LOperand* temp1() { return temps_[0]; }
929   LOperand* temp2() { return temps_[1]; }
930   LOperand* double_temp() { return temps_[2]; }
931
932   DECLARE_CONCRETE_INSTRUCTION(MathExp, "math-exp")
933 };
934
935
936 class LMathSqrt V8_FINAL : public LTemplateInstruction<1, 1, 0> {
937  public:
938   explicit LMathSqrt(LOperand* value) {
939     inputs_[0] = value;
940   }
941
942   LOperand* value() { return inputs_[0]; }
943
944   DECLARE_CONCRETE_INSTRUCTION(MathSqrt, "math-sqrt")
945 };
946
947
948 class LMathPowHalf V8_FINAL : public LTemplateInstruction<1, 1, 0> {
949  public:
950   explicit LMathPowHalf(LOperand* value) {
951     inputs_[0] = value;
952   }
953
954   LOperand* value() { return inputs_[0]; }
955
956   DECLARE_CONCRETE_INSTRUCTION(MathPowHalf, "math-pow-half")
957 };
958
959
960 class LCmpObjectEqAndBranch V8_FINAL : public LControlInstruction<2, 0> {
961  public:
962   LCmpObjectEqAndBranch(LOperand* left, LOperand* right) {
963     inputs_[0] = left;
964     inputs_[1] = right;
965   }
966
967   LOperand* left() { return inputs_[0]; }
968   LOperand* right() { return inputs_[1]; }
969
970   DECLARE_CONCRETE_INSTRUCTION(CmpObjectEqAndBranch, "cmp-object-eq-and-branch")
971   DECLARE_HYDROGEN_ACCESSOR(CompareObjectEqAndBranch)
972 };
973
974
975 class LCmpHoleAndBranch V8_FINAL : public LControlInstruction<1, 0> {
976  public:
977   explicit LCmpHoleAndBranch(LOperand* object) {
978     inputs_[0] = object;
979   }
980
981   LOperand* object() { return inputs_[0]; }
982
983   DECLARE_CONCRETE_INSTRUCTION(CmpHoleAndBranch, "cmp-hole-and-branch")
984   DECLARE_HYDROGEN_ACCESSOR(CompareHoleAndBranch)
985 };
986
987
988 class LCompareMinusZeroAndBranch V8_FINAL : public LControlInstruction<1, 1> {
989  public:
990   LCompareMinusZeroAndBranch(LOperand* value, LOperand* temp) {
991     inputs_[0] = value;
992     temps_[0] = temp;
993   }
994
995   LOperand* value() { return inputs_[0]; }
996   LOperand* temp() { return temps_[0]; }
997
998   DECLARE_CONCRETE_INSTRUCTION(CompareMinusZeroAndBranch,
999                                "cmp-minus-zero-and-branch")
1000   DECLARE_HYDROGEN_ACCESSOR(CompareMinusZeroAndBranch)
1001 };
1002
1003
1004 class LIsObjectAndBranch V8_FINAL : public LControlInstruction<1, 1> {
1005  public:
1006   LIsObjectAndBranch(LOperand* value, LOperand* temp) {
1007     inputs_[0] = value;
1008     temps_[0] = temp;
1009   }
1010
1011   LOperand* value() { return inputs_[0]; }
1012   LOperand* temp() { return temps_[0]; }
1013
1014   DECLARE_CONCRETE_INSTRUCTION(IsObjectAndBranch, "is-object-and-branch")
1015   DECLARE_HYDROGEN_ACCESSOR(IsObjectAndBranch)
1016
1017   virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1018 };
1019
1020
1021 class LIsStringAndBranch V8_FINAL : public LControlInstruction<1, 1> {
1022  public:
1023   LIsStringAndBranch(LOperand* value, LOperand* temp) {
1024     inputs_[0] = value;
1025     temps_[0] = temp;
1026   }
1027
1028   LOperand* value() { return inputs_[0]; }
1029   LOperand* temp() { return temps_[0]; }
1030
1031   DECLARE_CONCRETE_INSTRUCTION(IsStringAndBranch, "is-string-and-branch")
1032   DECLARE_HYDROGEN_ACCESSOR(IsStringAndBranch)
1033
1034   virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1035 };
1036
1037
1038 class LIsSmiAndBranch V8_FINAL : public LControlInstruction<1, 0> {
1039  public:
1040   explicit LIsSmiAndBranch(LOperand* value) {
1041     inputs_[0] = value;
1042   }
1043
1044   LOperand* value() { return inputs_[0]; }
1045
1046   DECLARE_CONCRETE_INSTRUCTION(IsSmiAndBranch, "is-smi-and-branch")
1047   DECLARE_HYDROGEN_ACCESSOR(IsSmiAndBranch)
1048
1049   virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1050 };
1051
1052
1053 class LIsUndetectableAndBranch V8_FINAL : public LControlInstruction<1, 1> {
1054  public:
1055   explicit LIsUndetectableAndBranch(LOperand* value, LOperand* temp) {
1056     inputs_[0] = value;
1057     temps_[0] = temp;
1058   }
1059
1060   LOperand* value() { return inputs_[0]; }
1061   LOperand* temp() { return temps_[0]; }
1062
1063   DECLARE_CONCRETE_INSTRUCTION(IsUndetectableAndBranch,
1064                                "is-undetectable-and-branch")
1065   DECLARE_HYDROGEN_ACCESSOR(IsUndetectableAndBranch)
1066
1067   virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1068 };
1069
1070
1071 class LStringCompareAndBranch V8_FINAL : public LControlInstruction<3, 0> {
1072  public:
1073   LStringCompareAndBranch(LOperand* context, LOperand* left, LOperand* right) {
1074     inputs_[0] = context;
1075     inputs_[1] = left;
1076     inputs_[2] = right;
1077   }
1078
1079   LOperand* context() { return inputs_[0]; }
1080   LOperand* left() { return inputs_[1]; }
1081   LOperand* right() { return inputs_[2]; }
1082
1083   DECLARE_CONCRETE_INSTRUCTION(StringCompareAndBranch,
1084                                "string-compare-and-branch")
1085   DECLARE_HYDROGEN_ACCESSOR(StringCompareAndBranch)
1086
1087   Token::Value op() const { return hydrogen()->token(); }
1088
1089   virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1090 };
1091
1092
1093 class LHasInstanceTypeAndBranch V8_FINAL : public LControlInstruction<1, 0> {
1094  public:
1095   explicit LHasInstanceTypeAndBranch(LOperand* value) {
1096     inputs_[0] = value;
1097   }
1098
1099   LOperand* value() { return inputs_[0]; }
1100
1101   DECLARE_CONCRETE_INSTRUCTION(HasInstanceTypeAndBranch,
1102                                "has-instance-type-and-branch")
1103   DECLARE_HYDROGEN_ACCESSOR(HasInstanceTypeAndBranch)
1104
1105   virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1106 };
1107
1108
1109 class LGetCachedArrayIndex V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1110  public:
1111   explicit LGetCachedArrayIndex(LOperand* value) {
1112     inputs_[0] = value;
1113   }
1114
1115   LOperand* value() { return inputs_[0]; }
1116
1117   DECLARE_CONCRETE_INSTRUCTION(GetCachedArrayIndex, "get-cached-array-index")
1118   DECLARE_HYDROGEN_ACCESSOR(GetCachedArrayIndex)
1119 };
1120
1121
1122 class LHasCachedArrayIndexAndBranch V8_FINAL
1123     : public LControlInstruction<1, 0> {
1124  public:
1125   explicit LHasCachedArrayIndexAndBranch(LOperand* value) {
1126     inputs_[0] = value;
1127   }
1128
1129   LOperand* value() { return inputs_[0]; }
1130
1131   DECLARE_CONCRETE_INSTRUCTION(HasCachedArrayIndexAndBranch,
1132                                "has-cached-array-index-and-branch")
1133   DECLARE_HYDROGEN_ACCESSOR(HasCachedArrayIndexAndBranch)
1134
1135   virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1136 };
1137
1138
1139 class LClassOfTestAndBranch V8_FINAL : public LControlInstruction<1, 1> {
1140  public:
1141   LClassOfTestAndBranch(LOperand* value, LOperand* temp) {
1142     inputs_[0] = value;
1143     temps_[0] = temp;
1144   }
1145
1146   LOperand* value() { return inputs_[0]; }
1147   LOperand* temp() { return temps_[0]; }
1148
1149   DECLARE_CONCRETE_INSTRUCTION(ClassOfTestAndBranch,
1150                                "class-of-test-and-branch")
1151   DECLARE_HYDROGEN_ACCESSOR(ClassOfTestAndBranch)
1152
1153   virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1154 };
1155
1156
1157 class LCmpT V8_FINAL : public LTemplateInstruction<1, 3, 0> {
1158  public:
1159   LCmpT(LOperand* context, LOperand* left, LOperand* right) {
1160     inputs_[0] = context;
1161     inputs_[1] = left;
1162     inputs_[2] = right;
1163   }
1164
1165   LOperand* context() { return inputs_[0]; }
1166   LOperand* left() { return inputs_[1]; }
1167   LOperand* right() { return inputs_[2]; }
1168
1169   DECLARE_CONCRETE_INSTRUCTION(CmpT, "cmp-t")
1170   DECLARE_HYDROGEN_ACCESSOR(CompareGeneric)
1171
1172   Token::Value op() const { return hydrogen()->token(); }
1173 };
1174
1175
1176 class LInstanceOf V8_FINAL : public LTemplateInstruction<1, 3, 0> {
1177  public:
1178   LInstanceOf(LOperand* context, LOperand* left, LOperand* right) {
1179     inputs_[0] = context;
1180     inputs_[1] = left;
1181     inputs_[2] = right;
1182   }
1183
1184   LOperand* context() { return inputs_[0]; }
1185   LOperand* left() { return inputs_[1]; }
1186   LOperand* right() { return inputs_[2]; }
1187
1188   DECLARE_CONCRETE_INSTRUCTION(InstanceOf, "instance-of")
1189 };
1190
1191
1192 class LInstanceOfKnownGlobal V8_FINAL : public LTemplateInstruction<1, 2, 1> {
1193  public:
1194   LInstanceOfKnownGlobal(LOperand* context, LOperand* value, LOperand* temp) {
1195     inputs_[0] = context;
1196     inputs_[1] = value;
1197     temps_[0] = temp;
1198   }
1199
1200   LOperand* context() { return inputs_[0]; }
1201   LOperand* value() { return inputs_[1]; }
1202   LOperand* temp() { return temps_[0]; }
1203
1204   DECLARE_CONCRETE_INSTRUCTION(InstanceOfKnownGlobal,
1205                                "instance-of-known-global")
1206   DECLARE_HYDROGEN_ACCESSOR(InstanceOfKnownGlobal)
1207
1208   Handle<JSFunction> function() const { return hydrogen()->function(); }
1209   LEnvironment* GetDeferredLazyDeoptimizationEnvironment() {
1210     return lazy_deopt_env_;
1211   }
1212   virtual void SetDeferredLazyDeoptimizationEnvironment(
1213       LEnvironment* env) V8_OVERRIDE {
1214     lazy_deopt_env_ = env;
1215   }
1216
1217  private:
1218   LEnvironment* lazy_deopt_env_;
1219 };
1220
1221
1222 class LBoundsCheck V8_FINAL : public LTemplateInstruction<0, 2, 0> {
1223  public:
1224   LBoundsCheck(LOperand* index, LOperand* length) {
1225     inputs_[0] = index;
1226     inputs_[1] = length;
1227   }
1228
1229   LOperand* index() { return inputs_[0]; }
1230   LOperand* length() { return inputs_[1]; }
1231
1232   DECLARE_CONCRETE_INSTRUCTION(BoundsCheck, "bounds-check")
1233   DECLARE_HYDROGEN_ACCESSOR(BoundsCheck)
1234 };
1235
1236
1237 class LBitI V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1238  public:
1239   LBitI(LOperand* left, LOperand* right) {
1240     inputs_[0] = left;
1241     inputs_[1] = right;
1242   }
1243
1244   LOperand* left() { return inputs_[0]; }
1245   LOperand* right() { return inputs_[1]; }
1246
1247   Token::Value op() const { return hydrogen()->op(); }
1248
1249   DECLARE_CONCRETE_INSTRUCTION(BitI, "bit-i")
1250   DECLARE_HYDROGEN_ACCESSOR(Bitwise)
1251 };
1252
1253
1254 class LShiftI V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1255  public:
1256   LShiftI(Token::Value op, LOperand* left, LOperand* right, bool can_deopt)
1257       : op_(op), can_deopt_(can_deopt) {
1258     inputs_[0] = left;
1259     inputs_[1] = right;
1260   }
1261
1262   Token::Value op() const { return op_; }
1263   LOperand* left() { return inputs_[0]; }
1264   LOperand* right() { return inputs_[1]; }
1265   bool can_deopt() const { return can_deopt_; }
1266
1267   DECLARE_CONCRETE_INSTRUCTION(ShiftI, "shift-i")
1268
1269  private:
1270   Token::Value op_;
1271   bool can_deopt_;
1272 };
1273
1274
1275 class LSubI V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1276  public:
1277   LSubI(LOperand* left, LOperand* right) {
1278     inputs_[0] = left;
1279     inputs_[1] = right;
1280   }
1281
1282   LOperand* left() { return inputs_[0]; }
1283   LOperand* right() { return inputs_[1]; }
1284
1285   DECLARE_CONCRETE_INSTRUCTION(SubI, "sub-i")
1286   DECLARE_HYDROGEN_ACCESSOR(Sub)
1287 };
1288
1289
1290 class LRSubI V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1291  public:
1292   LRSubI(LOperand* left, LOperand* right) {
1293     inputs_[0] = left;
1294     inputs_[1] = right;
1295   }
1296
1297   LOperand* left() { return inputs_[0]; }
1298   LOperand* right() { return inputs_[1]; }
1299
1300   DECLARE_CONCRETE_INSTRUCTION(RSubI, "rsub-i")
1301   DECLARE_HYDROGEN_ACCESSOR(Sub)
1302 };
1303
1304
1305 class LConstantI V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1306  public:
1307   DECLARE_CONCRETE_INSTRUCTION(ConstantI, "constant-i")
1308   DECLARE_HYDROGEN_ACCESSOR(Constant)
1309
1310   int32_t value() const { return hydrogen()->Integer32Value(); }
1311 };
1312
1313
1314 class LConstantS V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1315  public:
1316   DECLARE_CONCRETE_INSTRUCTION(ConstantS, "constant-s")
1317   DECLARE_HYDROGEN_ACCESSOR(Constant)
1318
1319   Smi* value() const { return Smi::FromInt(hydrogen()->Integer32Value()); }
1320 };
1321
1322
1323 class LConstantD V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1324  public:
1325   DECLARE_CONCRETE_INSTRUCTION(ConstantD, "constant-d")
1326   DECLARE_HYDROGEN_ACCESSOR(Constant)
1327
1328   double value() const { return hydrogen()->DoubleValue(); }
1329 };
1330
1331
1332 class LConstantE V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1333  public:
1334   DECLARE_CONCRETE_INSTRUCTION(ConstantE, "constant-e")
1335   DECLARE_HYDROGEN_ACCESSOR(Constant)
1336
1337   ExternalReference value() const {
1338     return hydrogen()->ExternalReferenceValue();
1339   }
1340 };
1341
1342
1343 class LConstantT V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1344  public:
1345   DECLARE_CONCRETE_INSTRUCTION(ConstantT, "constant-t")
1346   DECLARE_HYDROGEN_ACCESSOR(Constant)
1347
1348   Handle<Object> value(Isolate* isolate) const {
1349     return hydrogen()->handle(isolate);
1350   }
1351 };
1352
1353
1354 class LBranch V8_FINAL : public LControlInstruction<1, 0> {
1355  public:
1356   explicit LBranch(LOperand* value) {
1357     inputs_[0] = value;
1358   }
1359
1360   LOperand* value() { return inputs_[0]; }
1361
1362   DECLARE_CONCRETE_INSTRUCTION(Branch, "branch")
1363   DECLARE_HYDROGEN_ACCESSOR(Branch)
1364
1365   virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1366 };
1367
1368
1369 class LCmpMapAndBranch V8_FINAL : public LControlInstruction<1, 1> {
1370  public:
1371   LCmpMapAndBranch(LOperand* value, LOperand* temp) {
1372     inputs_[0] = value;
1373     temps_[0] = temp;
1374   }
1375
1376   LOperand* value() { return inputs_[0]; }
1377   LOperand* temp() { return temps_[0]; }
1378
1379   DECLARE_CONCRETE_INSTRUCTION(CmpMapAndBranch, "cmp-map-and-branch")
1380   DECLARE_HYDROGEN_ACCESSOR(CompareMap)
1381
1382   Handle<Map> map() const { return hydrogen()->map().handle(); }
1383 };
1384
1385
1386 class LMapEnumLength V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1387  public:
1388   explicit LMapEnumLength(LOperand* value) {
1389     inputs_[0] = value;
1390   }
1391
1392   LOperand* value() { return inputs_[0]; }
1393
1394   DECLARE_CONCRETE_INSTRUCTION(MapEnumLength, "map-enum-length")
1395 };
1396
1397
1398 class LDateField V8_FINAL : public LTemplateInstruction<1, 1, 1> {
1399  public:
1400   LDateField(LOperand* date, LOperand* temp, Smi* index) : index_(index) {
1401     inputs_[0] = date;
1402     temps_[0] = temp;
1403   }
1404
1405   LOperand* date() { return inputs_[0]; }
1406   LOperand* temp() { return temps_[0]; }
1407   Smi* index() const { return index_; }
1408
1409   DECLARE_CONCRETE_INSTRUCTION(DateField, "date-field")
1410   DECLARE_HYDROGEN_ACCESSOR(DateField)
1411
1412  private:
1413   Smi* index_;
1414 };
1415
1416
1417 class LSeqStringGetChar V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1418  public:
1419   LSeqStringGetChar(LOperand* string, LOperand* index) {
1420     inputs_[0] = string;
1421     inputs_[1] = index;
1422   }
1423
1424   LOperand* string() const { return inputs_[0]; }
1425   LOperand* index() const { return inputs_[1]; }
1426
1427   DECLARE_CONCRETE_INSTRUCTION(SeqStringGetChar, "seq-string-get-char")
1428   DECLARE_HYDROGEN_ACCESSOR(SeqStringGetChar)
1429 };
1430
1431
1432 class LSeqStringSetChar V8_FINAL : public LTemplateInstruction<1, 4, 0> {
1433  public:
1434   LSeqStringSetChar(LOperand* context,
1435                     LOperand* string,
1436                     LOperand* index,
1437                     LOperand* value) {
1438     inputs_[0] = context;
1439     inputs_[1] = string;
1440     inputs_[2] = index;
1441     inputs_[3] = value;
1442   }
1443
1444   LOperand* string() { return inputs_[1]; }
1445   LOperand* index() { return inputs_[2]; }
1446   LOperand* value() { return inputs_[3]; }
1447
1448   DECLARE_CONCRETE_INSTRUCTION(SeqStringSetChar, "seq-string-set-char")
1449   DECLARE_HYDROGEN_ACCESSOR(SeqStringSetChar)
1450 };
1451
1452
1453 class LAddI V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1454  public:
1455   LAddI(LOperand* left, LOperand* right) {
1456     inputs_[0] = left;
1457     inputs_[1] = right;
1458   }
1459
1460   LOperand* left() { return inputs_[0]; }
1461   LOperand* right() { return inputs_[1]; }
1462
1463   DECLARE_CONCRETE_INSTRUCTION(AddI, "add-i")
1464   DECLARE_HYDROGEN_ACCESSOR(Add)
1465 };
1466
1467
1468 class LMathMinMax V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1469  public:
1470   LMathMinMax(LOperand* left, LOperand* right) {
1471     inputs_[0] = left;
1472     inputs_[1] = right;
1473   }
1474
1475   LOperand* left() { return inputs_[0]; }
1476   LOperand* right() { return inputs_[1]; }
1477
1478   DECLARE_CONCRETE_INSTRUCTION(MathMinMax, "math-min-max")
1479   DECLARE_HYDROGEN_ACCESSOR(MathMinMax)
1480 };
1481
1482
1483 class LPower V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1484  public:
1485   LPower(LOperand* left, LOperand* right) {
1486     inputs_[0] = left;
1487     inputs_[1] = right;
1488   }
1489
1490   LOperand* left() { return inputs_[0]; }
1491   LOperand* right() { return inputs_[1]; }
1492
1493   DECLARE_CONCRETE_INSTRUCTION(Power, "power")
1494   DECLARE_HYDROGEN_ACCESSOR(Power)
1495 };
1496
1497
1498 class LArithmeticD V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1499  public:
1500   LArithmeticD(Token::Value op, LOperand* left, LOperand* right)
1501       : op_(op) {
1502     inputs_[0] = left;
1503     inputs_[1] = right;
1504   }
1505
1506   Token::Value op() const { return op_; }
1507   LOperand* left() { return inputs_[0]; }
1508   LOperand* right() { return inputs_[1]; }
1509
1510   virtual Opcode opcode() const V8_OVERRIDE {
1511     return LInstruction::kArithmeticD;
1512   }
1513   virtual void CompileToNative(LCodeGen* generator) V8_OVERRIDE;
1514   virtual const char* Mnemonic() const V8_OVERRIDE;
1515
1516  private:
1517   Token::Value op_;
1518 };
1519
1520
1521 class LArithmeticT V8_FINAL : public LTemplateInstruction<1, 3, 0> {
1522  public:
1523   LArithmeticT(Token::Value op,
1524                LOperand* context,
1525                LOperand* left,
1526                LOperand* right)
1527       : op_(op) {
1528     inputs_[0] = context;
1529     inputs_[1] = left;
1530     inputs_[2] = right;
1531   }
1532
1533   LOperand* context() { return inputs_[0]; }
1534   LOperand* left() { return inputs_[1]; }
1535   LOperand* right() { return inputs_[2]; }
1536   Token::Value op() const { return op_; }
1537
1538   virtual Opcode opcode() const V8_OVERRIDE {
1539     return LInstruction::kArithmeticT;
1540   }
1541   virtual void CompileToNative(LCodeGen* generator) V8_OVERRIDE;
1542   virtual const char* Mnemonic() const V8_OVERRIDE;
1543
1544  private:
1545   Token::Value op_;
1546 };
1547
1548
1549 class LReturn V8_FINAL : public LTemplateInstruction<0, 3, 0> {
1550  public:
1551   LReturn(LOperand* value, LOperand* context, LOperand* parameter_count) {
1552     inputs_[0] = value;
1553     inputs_[1] = context;
1554     inputs_[2] = parameter_count;
1555   }
1556
1557   LOperand* value() { return inputs_[0]; }
1558
1559   bool has_constant_parameter_count() {
1560     return parameter_count()->IsConstantOperand();
1561   }
1562   LConstantOperand* constant_parameter_count() {
1563     ASSERT(has_constant_parameter_count());
1564     return LConstantOperand::cast(parameter_count());
1565   }
1566   LOperand* parameter_count() { return inputs_[2]; }
1567
1568   DECLARE_CONCRETE_INSTRUCTION(Return, "return")
1569 };
1570
1571
1572 class LLoadNamedField V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1573  public:
1574   explicit LLoadNamedField(LOperand* object) {
1575     inputs_[0] = object;
1576   }
1577
1578   LOperand* object() { return inputs_[0]; }
1579
1580   DECLARE_CONCRETE_INSTRUCTION(LoadNamedField, "load-named-field")
1581   DECLARE_HYDROGEN_ACCESSOR(LoadNamedField)
1582 };
1583
1584
1585 class LLoadNamedGeneric V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1586  public:
1587   LLoadNamedGeneric(LOperand* context, LOperand* object) {
1588     inputs_[0] = context;
1589     inputs_[1] = object;
1590   }
1591
1592   LOperand* context() { return inputs_[0]; }
1593   LOperand* object() { return inputs_[1]; }
1594
1595   DECLARE_CONCRETE_INSTRUCTION(LoadNamedGeneric, "load-named-generic")
1596   DECLARE_HYDROGEN_ACCESSOR(LoadNamedGeneric)
1597
1598   Handle<Object> name() const { return hydrogen()->name(); }
1599 };
1600
1601
1602 class LLoadFunctionPrototype V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1603  public:
1604   explicit LLoadFunctionPrototype(LOperand* function) {
1605     inputs_[0] = function;
1606   }
1607
1608   LOperand* function() { return inputs_[0]; }
1609
1610   DECLARE_CONCRETE_INSTRUCTION(LoadFunctionPrototype, "load-function-prototype")
1611   DECLARE_HYDROGEN_ACCESSOR(LoadFunctionPrototype)
1612 };
1613
1614
1615 class LLoadRoot V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1616  public:
1617   DECLARE_CONCRETE_INSTRUCTION(LoadRoot, "load-root")
1618   DECLARE_HYDROGEN_ACCESSOR(LoadRoot)
1619
1620   Heap::RootListIndex index() const { return hydrogen()->index(); }
1621 };
1622
1623
1624 class LLoadKeyed V8_FINAL : public LTemplateInstruction<1, 2, 2> {
1625  public:
1626   LLoadKeyed(LOperand* elements, LOperand* key,
1627              LOperand* temp, LOperand* temp2) {
1628     inputs_[0] = elements;
1629     inputs_[1] = key;
1630     temps_[0] = temp;
1631     temps_[1] = temp2;
1632   }
1633
1634   LOperand* elements() { return inputs_[0]; }
1635   LOperand* key() { return inputs_[1]; }
1636   LOperand* temp() { return temps_[0]; }
1637   LOperand* temp2() { return temps_[1]; }
1638   ElementsKind elements_kind() const {
1639     return hydrogen()->elements_kind();
1640   }
1641   bool is_external() const {
1642     return hydrogen()->is_external();
1643   }
1644   bool is_fixed_typed_array() const {
1645     return hydrogen()->is_fixed_typed_array();
1646   }
1647   bool is_typed_elements() const {
1648     return is_external() || is_fixed_typed_array();
1649   }
1650
1651   DECLARE_CONCRETE_INSTRUCTION(LoadKeyed, "load-keyed")
1652   DECLARE_HYDROGEN_ACCESSOR(LoadKeyed)
1653
1654   virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1655   uint32_t additional_index() const { return hydrogen()->index_offset(); }
1656 };
1657
1658
1659 class LLoadKeyedGeneric V8_FINAL : public LTemplateInstruction<1, 3, 0> {
1660  public:
1661   LLoadKeyedGeneric(LOperand* context, LOperand* object, LOperand* key) {
1662     inputs_[0] = context;
1663     inputs_[1] = object;
1664     inputs_[2] = key;
1665   }
1666
1667   LOperand* context() { return inputs_[0]; }
1668   LOperand* object() { return inputs_[1]; }
1669   LOperand* key() { return inputs_[2]; }
1670
1671   DECLARE_CONCRETE_INSTRUCTION(LoadKeyedGeneric, "load-keyed-generic")
1672 };
1673
1674
1675 class LLoadGlobalCell V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1676  public:
1677   DECLARE_CONCRETE_INSTRUCTION(LoadGlobalCell, "load-global-cell")
1678   DECLARE_HYDROGEN_ACCESSOR(LoadGlobalCell)
1679 };
1680
1681
1682 class LLoadGlobalGeneric V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1683  public:
1684   LLoadGlobalGeneric(LOperand* context, LOperand* global_object) {
1685     inputs_[0] = context;
1686     inputs_[1] = global_object;
1687   }
1688
1689   LOperand* context() { return inputs_[0]; }
1690   LOperand* global_object() { return inputs_[1]; }
1691
1692   DECLARE_CONCRETE_INSTRUCTION(LoadGlobalGeneric, "load-global-generic")
1693   DECLARE_HYDROGEN_ACCESSOR(LoadGlobalGeneric)
1694
1695   Handle<Object> name() const { return hydrogen()->name(); }
1696   bool for_typeof() const { return hydrogen()->for_typeof(); }
1697 };
1698
1699
1700 class LStoreGlobalCell V8_FINAL : public LTemplateInstruction<0, 1, 1> {
1701  public:
1702   LStoreGlobalCell(LOperand* value, LOperand* temp) {
1703     inputs_[0] = value;
1704     temps_[0] = temp;
1705   }
1706
1707   LOperand* value() { return inputs_[0]; }
1708   LOperand* temp() { return temps_[0]; }
1709
1710   DECLARE_CONCRETE_INSTRUCTION(StoreGlobalCell, "store-global-cell")
1711   DECLARE_HYDROGEN_ACCESSOR(StoreGlobalCell)
1712 };
1713
1714
1715 class LLoadContextSlot V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1716  public:
1717   explicit LLoadContextSlot(LOperand* context) {
1718     inputs_[0] = context;
1719   }
1720
1721   LOperand* context() { return inputs_[0]; }
1722
1723   DECLARE_CONCRETE_INSTRUCTION(LoadContextSlot, "load-context-slot")
1724   DECLARE_HYDROGEN_ACCESSOR(LoadContextSlot)
1725
1726   int slot_index() { return hydrogen()->slot_index(); }
1727
1728   virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1729 };
1730
1731
1732 class LStoreContextSlot V8_FINAL : public LTemplateInstruction<0, 2, 0> {
1733  public:
1734   LStoreContextSlot(LOperand* context, LOperand* value) {
1735     inputs_[0] = context;
1736     inputs_[1] = value;
1737   }
1738
1739   LOperand* context() { return inputs_[0]; }
1740   LOperand* value() { return inputs_[1]; }
1741
1742   DECLARE_CONCRETE_INSTRUCTION(StoreContextSlot, "store-context-slot")
1743   DECLARE_HYDROGEN_ACCESSOR(StoreContextSlot)
1744
1745   int slot_index() { return hydrogen()->slot_index(); }
1746
1747   virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1748 };
1749
1750
1751 class LPushArgument V8_FINAL : public LTemplateInstruction<0, 1, 0> {
1752  public:
1753   explicit LPushArgument(LOperand* value) {
1754     inputs_[0] = value;
1755   }
1756
1757   LOperand* value() { return inputs_[0]; }
1758
1759   DECLARE_CONCRETE_INSTRUCTION(PushArgument, "push-argument")
1760 };
1761
1762
1763 class LDrop V8_FINAL : public LTemplateInstruction<0, 0, 0> {
1764  public:
1765   explicit LDrop(int count) : count_(count) { }
1766
1767   int count() const { return count_; }
1768
1769   DECLARE_CONCRETE_INSTRUCTION(Drop, "drop")
1770
1771  private:
1772   int count_;
1773 };
1774
1775
1776 class LStoreCodeEntry V8_FINAL: public LTemplateInstruction<0, 1, 1> {
1777  public:
1778   LStoreCodeEntry(LOperand* function, LOperand* code_object) {
1779     inputs_[0] = function;
1780     temps_[0] = code_object;
1781   }
1782
1783   LOperand* function() { return inputs_[0]; }
1784   LOperand* code_object() { return temps_[0]; }
1785
1786   virtual void PrintDataTo(StringStream* stream);
1787
1788   DECLARE_CONCRETE_INSTRUCTION(StoreCodeEntry, "store-code-entry")
1789   DECLARE_HYDROGEN_ACCESSOR(StoreCodeEntry)
1790 };
1791
1792
1793 class LInnerAllocatedObject V8_FINAL: public LTemplateInstruction<1, 2, 0> {
1794  public:
1795   LInnerAllocatedObject(LOperand* base_object, LOperand* offset) {
1796     inputs_[0] = base_object;
1797     inputs_[1] = offset;
1798   }
1799
1800   LOperand* base_object() const { return inputs_[0]; }
1801   LOperand* offset() const { return inputs_[1]; }
1802
1803   virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1804
1805   DECLARE_CONCRETE_INSTRUCTION(InnerAllocatedObject, "inner-allocated-object")
1806 };
1807
1808
1809 class LThisFunction V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1810  public:
1811   DECLARE_CONCRETE_INSTRUCTION(ThisFunction, "this-function")
1812   DECLARE_HYDROGEN_ACCESSOR(ThisFunction)
1813 };
1814
1815
1816 class LContext V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1817  public:
1818   DECLARE_CONCRETE_INSTRUCTION(Context, "context")
1819   DECLARE_HYDROGEN_ACCESSOR(Context)
1820 };
1821
1822
1823 class LDeclareGlobals V8_FINAL : public LTemplateInstruction<0, 1, 0> {
1824  public:
1825   explicit LDeclareGlobals(LOperand* context) {
1826     inputs_[0] = context;
1827   }
1828
1829   LOperand* context() { return inputs_[0]; }
1830
1831   DECLARE_CONCRETE_INSTRUCTION(DeclareGlobals, "declare-globals")
1832   DECLARE_HYDROGEN_ACCESSOR(DeclareGlobals)
1833 };
1834
1835
1836 class LCallJSFunction V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1837  public:
1838   explicit LCallJSFunction(LOperand* function) {
1839     inputs_[0] = function;
1840   }
1841
1842   LOperand* function() { return inputs_[0]; }
1843
1844   DECLARE_CONCRETE_INSTRUCTION(CallJSFunction, "call-js-function")
1845   DECLARE_HYDROGEN_ACCESSOR(CallJSFunction)
1846
1847   virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1848
1849   int arity() const { return hydrogen()->argument_count() - 1; }
1850 };
1851
1852
1853 class LCallWithDescriptor V8_FINAL : public LTemplateResultInstruction<1> {
1854  public:
1855   LCallWithDescriptor(const CallInterfaceDescriptor* descriptor,
1856                       ZoneList<LOperand*>& operands,
1857                       Zone* zone)
1858     : descriptor_(descriptor),
1859       inputs_(descriptor->environment_length() + 1, zone) {
1860     ASSERT(descriptor->environment_length() + 1 == operands.length());
1861     inputs_.AddAll(operands, zone);
1862   }
1863
1864   LOperand* target() const { return inputs_[0]; }
1865
1866   const CallInterfaceDescriptor* descriptor() { return descriptor_; }
1867
1868  private:
1869   DECLARE_CONCRETE_INSTRUCTION(CallWithDescriptor, "call-with-descriptor")
1870   DECLARE_HYDROGEN_ACCESSOR(CallWithDescriptor)
1871
1872   virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1873
1874   int arity() const { return hydrogen()->argument_count() - 1; }
1875
1876   const CallInterfaceDescriptor* descriptor_;
1877   ZoneList<LOperand*> inputs_;
1878
1879   // Iterator support.
1880   virtual int InputCount() V8_FINAL V8_OVERRIDE { return inputs_.length(); }
1881   virtual LOperand* InputAt(int i) V8_FINAL V8_OVERRIDE { return inputs_[i]; }
1882
1883   virtual int TempCount() V8_FINAL V8_OVERRIDE { return 0; }
1884   virtual LOperand* TempAt(int i) V8_FINAL V8_OVERRIDE { return NULL; }
1885 };
1886
1887
1888 class LInvokeFunction V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1889  public:
1890   LInvokeFunction(LOperand* context, LOperand* function) {
1891     inputs_[0] = context;
1892     inputs_[1] = function;
1893   }
1894
1895   LOperand* context() { return inputs_[0]; }
1896   LOperand* function() { return inputs_[1]; }
1897
1898   DECLARE_CONCRETE_INSTRUCTION(InvokeFunction, "invoke-function")
1899   DECLARE_HYDROGEN_ACCESSOR(InvokeFunction)
1900
1901   virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1902
1903   int arity() const { return hydrogen()->argument_count() - 1; }
1904 };
1905
1906
1907 class LCallFunction V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1908  public:
1909   LCallFunction(LOperand* context, LOperand* function) {
1910     inputs_[0] = context;
1911     inputs_[1] = function;
1912   }
1913
1914   LOperand* context() { return inputs_[0]; }
1915   LOperand* function() { return inputs_[1]; }
1916
1917   DECLARE_CONCRETE_INSTRUCTION(CallFunction, "call-function")
1918   DECLARE_HYDROGEN_ACCESSOR(CallFunction)
1919
1920   int arity() const { return hydrogen()->argument_count() - 1; }
1921 };
1922
1923
1924 class LCallNew V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1925  public:
1926   LCallNew(LOperand* context, LOperand* constructor) {
1927     inputs_[0] = context;
1928     inputs_[1] = constructor;
1929   }
1930
1931   LOperand* context() { return inputs_[0]; }
1932   LOperand* constructor() { return inputs_[1]; }
1933
1934   DECLARE_CONCRETE_INSTRUCTION(CallNew, "call-new")
1935   DECLARE_HYDROGEN_ACCESSOR(CallNew)
1936
1937   virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1938
1939   int arity() const { return hydrogen()->argument_count() - 1; }
1940 };
1941
1942
1943 class LCallNewArray V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1944  public:
1945   LCallNewArray(LOperand* context, LOperand* constructor) {
1946     inputs_[0] = context;
1947     inputs_[1] = constructor;
1948   }
1949
1950   LOperand* context() { return inputs_[0]; }
1951   LOperand* constructor() { return inputs_[1]; }
1952
1953   DECLARE_CONCRETE_INSTRUCTION(CallNewArray, "call-new-array")
1954   DECLARE_HYDROGEN_ACCESSOR(CallNewArray)
1955
1956   virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1957
1958   int arity() const { return hydrogen()->argument_count() - 1; }
1959 };
1960
1961
1962 class LCallRuntime V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1963  public:
1964   explicit LCallRuntime(LOperand* context) {
1965     inputs_[0] = context;
1966   }
1967
1968   LOperand* context() { return inputs_[0]; }
1969
1970   DECLARE_CONCRETE_INSTRUCTION(CallRuntime, "call-runtime")
1971   DECLARE_HYDROGEN_ACCESSOR(CallRuntime)
1972
1973   virtual bool ClobbersDoubleRegisters(Isolate* isolate) const V8_OVERRIDE {
1974     return save_doubles() == kDontSaveFPRegs;
1975   }
1976
1977   const Runtime::Function* function() const { return hydrogen()->function(); }
1978   int arity() const { return hydrogen()->argument_count(); }
1979   SaveFPRegsMode save_doubles() const { return hydrogen()->save_doubles(); }
1980 };
1981
1982
1983 class LInteger32ToDouble V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1984  public:
1985   explicit LInteger32ToDouble(LOperand* value) {
1986     inputs_[0] = value;
1987   }
1988
1989   LOperand* value() { return inputs_[0]; }
1990
1991   DECLARE_CONCRETE_INSTRUCTION(Integer32ToDouble, "int32-to-double")
1992 };
1993
1994
1995 class LUint32ToDouble V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1996  public:
1997   explicit LUint32ToDouble(LOperand* value) {
1998     inputs_[0] = value;
1999   }
2000
2001   LOperand* value() { return inputs_[0]; }
2002
2003   DECLARE_CONCRETE_INSTRUCTION(Uint32ToDouble, "uint32-to-double")
2004 };
2005
2006
2007 class LNumberTagI V8_FINAL : public LTemplateInstruction<1, 1, 2> {
2008  public:
2009   LNumberTagI(LOperand* value, LOperand* temp1, LOperand* temp2) {
2010     inputs_[0] = value;
2011     temps_[0] = temp1;
2012     temps_[1] = temp2;
2013   }
2014
2015   LOperand* value() { return inputs_[0]; }
2016   LOperand* temp1() { return temps_[0]; }
2017   LOperand* temp2() { return temps_[1]; }
2018
2019   DECLARE_CONCRETE_INSTRUCTION(NumberTagI, "number-tag-i")
2020 };
2021
2022
2023 class LNumberTagU V8_FINAL : public LTemplateInstruction<1, 1, 2> {
2024  public:
2025   LNumberTagU(LOperand* value, LOperand* temp1, LOperand* temp2) {
2026     inputs_[0] = value;
2027     temps_[0] = temp1;
2028     temps_[1] = temp2;
2029   }
2030
2031   LOperand* value() { return inputs_[0]; }
2032   LOperand* temp1() { return temps_[0]; }
2033   LOperand* temp2() { return temps_[1]; }
2034
2035   DECLARE_CONCRETE_INSTRUCTION(NumberTagU, "number-tag-u")
2036 };
2037
2038
2039 class LNumberTagD V8_FINAL : public LTemplateInstruction<1, 1, 2> {
2040  public:
2041   LNumberTagD(LOperand* value, LOperand* temp, LOperand* temp2) {
2042     inputs_[0] = value;
2043     temps_[0] = temp;
2044     temps_[1] = temp2;
2045   }
2046
2047   LOperand* value() { return inputs_[0]; }
2048   LOperand* temp() { return temps_[0]; }
2049   LOperand* temp2() { return temps_[1]; }
2050
2051   DECLARE_CONCRETE_INSTRUCTION(NumberTagD, "number-tag-d")
2052   DECLARE_HYDROGEN_ACCESSOR(Change)
2053 };
2054
2055
2056 class LDoubleToSmi V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2057  public:
2058   explicit LDoubleToSmi(LOperand* value) {
2059     inputs_[0] = value;
2060   }
2061
2062   LOperand* value() { return inputs_[0]; }
2063
2064   DECLARE_CONCRETE_INSTRUCTION(DoubleToSmi, "double-to-smi")
2065   DECLARE_HYDROGEN_ACCESSOR(UnaryOperation)
2066
2067   bool truncating() { return hydrogen()->CanTruncateToInt32(); }
2068 };
2069
2070
2071 // Sometimes truncating conversion from a tagged value to an int32.
2072 class LDoubleToI V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2073  public:
2074   explicit LDoubleToI(LOperand* value) {
2075     inputs_[0] = value;
2076   }
2077
2078   LOperand* value() { return inputs_[0]; }
2079
2080   DECLARE_CONCRETE_INSTRUCTION(DoubleToI, "double-to-i")
2081   DECLARE_HYDROGEN_ACCESSOR(UnaryOperation)
2082
2083   bool truncating() { return hydrogen()->CanTruncateToInt32(); }
2084 };
2085
2086
2087 // Truncating conversion from a tagged value to an int32.
2088 class LTaggedToI V8_FINAL : public LTemplateInstruction<1, 1, 2> {
2089  public:
2090   LTaggedToI(LOperand* value,
2091              LOperand* temp,
2092              LOperand* temp2) {
2093     inputs_[0] = value;
2094     temps_[0] = temp;
2095     temps_[1] = temp2;
2096   }
2097
2098   LOperand* value() { return inputs_[0]; }
2099   LOperand* temp() { return temps_[0]; }
2100   LOperand* temp2() { return temps_[1]; }
2101
2102   DECLARE_CONCRETE_INSTRUCTION(TaggedToI, "tagged-to-i")
2103   DECLARE_HYDROGEN_ACCESSOR(Change)
2104
2105   bool truncating() { return hydrogen()->CanTruncateToInt32(); }
2106 };
2107
2108
2109 class LSmiTag V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2110  public:
2111   explicit LSmiTag(LOperand* value) {
2112     inputs_[0] = value;
2113   }
2114
2115   LOperand* value() { return inputs_[0]; }
2116
2117   DECLARE_CONCRETE_INSTRUCTION(SmiTag, "smi-tag")
2118   DECLARE_HYDROGEN_ACCESSOR(Change)
2119 };
2120
2121
2122 class LNumberUntagD V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2123  public:
2124   explicit LNumberUntagD(LOperand* value) {
2125     inputs_[0] = value;
2126   }
2127
2128   LOperand* value() { return inputs_[0]; }
2129
2130   DECLARE_CONCRETE_INSTRUCTION(NumberUntagD, "double-untag")
2131   DECLARE_HYDROGEN_ACCESSOR(Change)
2132 };
2133
2134
2135 class LSmiUntag V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2136  public:
2137   LSmiUntag(LOperand* value, bool needs_check)
2138       : needs_check_(needs_check) {
2139     inputs_[0] = value;
2140   }
2141
2142   LOperand* value() { return inputs_[0]; }
2143   bool needs_check() const { return needs_check_; }
2144
2145   DECLARE_CONCRETE_INSTRUCTION(SmiUntag, "smi-untag")
2146
2147  private:
2148   bool needs_check_;
2149 };
2150
2151
2152 class LStoreNamedField V8_FINAL : public LTemplateInstruction<0, 2, 1> {
2153  public:
2154   LStoreNamedField(LOperand* object, LOperand* value, LOperand* temp) {
2155     inputs_[0] = object;
2156     inputs_[1] = value;
2157     temps_[0] = temp;
2158   }
2159
2160   LOperand* object() { return inputs_[0]; }
2161   LOperand* value() { return inputs_[1]; }
2162   LOperand* temp() { return temps_[0]; }
2163
2164   DECLARE_CONCRETE_INSTRUCTION(StoreNamedField, "store-named-field")
2165   DECLARE_HYDROGEN_ACCESSOR(StoreNamedField)
2166
2167   virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
2168
2169   Representation representation() const {
2170     return hydrogen()->field_representation();
2171   }
2172 };
2173
2174
2175 class LStoreNamedGeneric V8_FINAL : public LTemplateInstruction<0, 3, 0> {
2176  public:
2177   LStoreNamedGeneric(LOperand* context, LOperand* object, LOperand* value) {
2178     inputs_[0] = context;
2179     inputs_[1] = object;
2180     inputs_[2] = value;
2181   }
2182
2183   LOperand* context() { return inputs_[0]; }
2184   LOperand* object() { return inputs_[1]; }
2185   LOperand* value() { return inputs_[2]; }
2186
2187   DECLARE_CONCRETE_INSTRUCTION(StoreNamedGeneric, "store-named-generic")
2188   DECLARE_HYDROGEN_ACCESSOR(StoreNamedGeneric)
2189
2190   virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
2191
2192   Handle<Object> name() const { return hydrogen()->name(); }
2193   StrictMode strict_mode() { return hydrogen()->strict_mode(); }
2194 };
2195
2196
2197 class LStoreKeyed V8_FINAL : public LTemplateInstruction<0, 3, 1> {
2198  public:
2199   LStoreKeyed(LOperand* object, LOperand* key, LOperand* value,
2200               LOperand* temp) {
2201     inputs_[0] = object;
2202     inputs_[1] = key;
2203     inputs_[2] = value;
2204     temps_[0] = temp;
2205   }
2206
2207   bool is_external() const { return hydrogen()->is_external(); }
2208   bool is_fixed_typed_array() const {
2209     return hydrogen()->is_fixed_typed_array();
2210   }
2211   bool is_typed_elements() const {
2212     return is_external() || is_fixed_typed_array();
2213   }
2214   LOperand* elements() { return inputs_[0]; }
2215   LOperand* key() { return inputs_[1]; }
2216   LOperand* value() { return inputs_[2]; }
2217   LOperand* temp() { return temps_[0]; }
2218   ElementsKind elements_kind() const {
2219     return hydrogen()->elements_kind();
2220   }
2221
2222   DECLARE_CONCRETE_INSTRUCTION(StoreKeyed, "store-keyed")
2223   DECLARE_HYDROGEN_ACCESSOR(StoreKeyed)
2224
2225   virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
2226   bool NeedsCanonicalization() {
2227     if (hydrogen()->value()->IsAdd() || hydrogen()->value()->IsSub() ||
2228         hydrogen()->value()->IsMul() || hydrogen()->value()->IsDiv()) {
2229       return false;
2230     }
2231     return hydrogen()->NeedsCanonicalization();
2232   }
2233   uint32_t additional_index() const { return hydrogen()->index_offset(); }
2234 };
2235
2236
2237 class LStoreKeyedGeneric V8_FINAL : public LTemplateInstruction<0, 4, 0> {
2238  public:
2239   LStoreKeyedGeneric(LOperand* context,
2240                      LOperand* obj,
2241                      LOperand* key,
2242                      LOperand* value) {
2243     inputs_[0] = context;
2244     inputs_[1] = obj;
2245     inputs_[2] = key;
2246     inputs_[3] = value;
2247   }
2248
2249   LOperand* context() { return inputs_[0]; }
2250   LOperand* object() { return inputs_[1]; }
2251   LOperand* key() { return inputs_[2]; }
2252   LOperand* value() { return inputs_[3]; }
2253
2254   DECLARE_CONCRETE_INSTRUCTION(StoreKeyedGeneric, "store-keyed-generic")
2255   DECLARE_HYDROGEN_ACCESSOR(StoreKeyedGeneric)
2256
2257   virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
2258
2259   StrictMode strict_mode() { return hydrogen()->strict_mode(); }
2260 };
2261
2262
2263 class LTransitionElementsKind V8_FINAL : public LTemplateInstruction<0, 2, 1> {
2264  public:
2265   LTransitionElementsKind(LOperand* object,
2266                           LOperand* context,
2267                           LOperand* new_map_temp) {
2268     inputs_[0] = object;
2269     inputs_[1] = context;
2270     temps_[0] = new_map_temp;
2271   }
2272
2273   LOperand* context() { return inputs_[1]; }
2274   LOperand* object() { return inputs_[0]; }
2275   LOperand* new_map_temp() { return temps_[0]; }
2276
2277   DECLARE_CONCRETE_INSTRUCTION(TransitionElementsKind,
2278                                "transition-elements-kind")
2279   DECLARE_HYDROGEN_ACCESSOR(TransitionElementsKind)
2280
2281   virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
2282
2283   Handle<Map> original_map() { return hydrogen()->original_map().handle(); }
2284   Handle<Map> transitioned_map() {
2285     return hydrogen()->transitioned_map().handle();
2286   }
2287   ElementsKind from_kind() { return hydrogen()->from_kind(); }
2288   ElementsKind to_kind() { return hydrogen()->to_kind(); }
2289 };
2290
2291
2292 class LTrapAllocationMemento V8_FINAL : public LTemplateInstruction<0, 1, 1> {
2293  public:
2294   LTrapAllocationMemento(LOperand* object,
2295                          LOperand* temp) {
2296     inputs_[0] = object;
2297     temps_[0] = temp;
2298   }
2299
2300   LOperand* object() { return inputs_[0]; }
2301   LOperand* temp() { return temps_[0]; }
2302
2303   DECLARE_CONCRETE_INSTRUCTION(TrapAllocationMemento,
2304                                "trap-allocation-memento")
2305 };
2306
2307
2308 class LStringAdd V8_FINAL : public LTemplateInstruction<1, 3, 0> {
2309  public:
2310   LStringAdd(LOperand* context, LOperand* left, LOperand* right) {
2311     inputs_[0] = context;
2312     inputs_[1] = left;
2313     inputs_[2] = right;
2314   }
2315
2316   LOperand* context() { return inputs_[0]; }
2317   LOperand* left() { return inputs_[1]; }
2318   LOperand* right() { return inputs_[2]; }
2319
2320   DECLARE_CONCRETE_INSTRUCTION(StringAdd, "string-add")
2321   DECLARE_HYDROGEN_ACCESSOR(StringAdd)
2322 };
2323
2324
2325
2326 class LStringCharCodeAt V8_FINAL : public LTemplateInstruction<1, 3, 0> {
2327  public:
2328   LStringCharCodeAt(LOperand* context, LOperand* string, LOperand* index) {
2329     inputs_[0] = context;
2330     inputs_[1] = string;
2331     inputs_[2] = index;
2332   }
2333
2334   LOperand* context() { return inputs_[0]; }
2335   LOperand* string() { return inputs_[1]; }
2336   LOperand* index() { return inputs_[2]; }
2337
2338   DECLARE_CONCRETE_INSTRUCTION(StringCharCodeAt, "string-char-code-at")
2339   DECLARE_HYDROGEN_ACCESSOR(StringCharCodeAt)
2340 };
2341
2342
2343 class LStringCharFromCode V8_FINAL : public LTemplateInstruction<1, 2, 0> {
2344  public:
2345   explicit LStringCharFromCode(LOperand* context, LOperand* char_code) {
2346     inputs_[0] = context;
2347     inputs_[1] = char_code;
2348   }
2349
2350   LOperand* context() { return inputs_[0]; }
2351   LOperand* char_code() { return inputs_[1]; }
2352
2353   DECLARE_CONCRETE_INSTRUCTION(StringCharFromCode, "string-char-from-code")
2354   DECLARE_HYDROGEN_ACCESSOR(StringCharFromCode)
2355 };
2356
2357
2358 class LCheckValue V8_FINAL : public LTemplateInstruction<0, 1, 0> {
2359  public:
2360   explicit LCheckValue(LOperand* value) {
2361     inputs_[0] = value;
2362   }
2363
2364   LOperand* value() { return inputs_[0]; }
2365
2366   DECLARE_CONCRETE_INSTRUCTION(CheckValue, "check-value")
2367   DECLARE_HYDROGEN_ACCESSOR(CheckValue)
2368 };
2369
2370
2371 class LCheckInstanceType V8_FINAL : public LTemplateInstruction<0, 1, 0> {
2372  public:
2373   explicit LCheckInstanceType(LOperand* value) {
2374     inputs_[0] = value;
2375   }
2376
2377   LOperand* value() { return inputs_[0]; }
2378
2379   DECLARE_CONCRETE_INSTRUCTION(CheckInstanceType, "check-instance-type")
2380   DECLARE_HYDROGEN_ACCESSOR(CheckInstanceType)
2381 };
2382
2383
2384 class LCheckMaps V8_FINAL : public LTemplateInstruction<0, 1, 0> {
2385  public:
2386   explicit LCheckMaps(LOperand* value = NULL) {
2387     inputs_[0] = value;
2388   }
2389
2390   LOperand* value() { return inputs_[0]; }
2391
2392   DECLARE_CONCRETE_INSTRUCTION(CheckMaps, "check-maps")
2393   DECLARE_HYDROGEN_ACCESSOR(CheckMaps)
2394 };
2395
2396
2397 class LCheckSmi V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2398  public:
2399   explicit LCheckSmi(LOperand* value) {
2400     inputs_[0] = value;
2401   }
2402
2403   LOperand* value() { return inputs_[0]; }
2404
2405   DECLARE_CONCRETE_INSTRUCTION(CheckSmi, "check-smi")
2406 };
2407
2408
2409 class LCheckNonSmi V8_FINAL : public LTemplateInstruction<0, 1, 0> {
2410  public:
2411   explicit LCheckNonSmi(LOperand* value) {
2412     inputs_[0] = value;
2413   }
2414
2415   LOperand* value() { return inputs_[0]; }
2416
2417   DECLARE_CONCRETE_INSTRUCTION(CheckNonSmi, "check-non-smi")
2418   DECLARE_HYDROGEN_ACCESSOR(CheckHeapObject)
2419 };
2420
2421
2422 class LClampDToUint8 V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2423  public:
2424   explicit LClampDToUint8(LOperand* unclamped) {
2425     inputs_[0] = unclamped;
2426   }
2427
2428   LOperand* unclamped() { return inputs_[0]; }
2429
2430   DECLARE_CONCRETE_INSTRUCTION(ClampDToUint8, "clamp-d-to-uint8")
2431 };
2432
2433
2434 class LClampIToUint8 V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2435  public:
2436   explicit LClampIToUint8(LOperand* unclamped) {
2437     inputs_[0] = unclamped;
2438   }
2439
2440   LOperand* unclamped() { return inputs_[0]; }
2441
2442   DECLARE_CONCRETE_INSTRUCTION(ClampIToUint8, "clamp-i-to-uint8")
2443 };
2444
2445
2446 class LClampTToUint8 V8_FINAL : public LTemplateInstruction<1, 1, 1> {
2447  public:
2448   LClampTToUint8(LOperand* unclamped, LOperand* temp) {
2449     inputs_[0] = unclamped;
2450     temps_[0] = temp;
2451   }
2452
2453   LOperand* unclamped() { return inputs_[0]; }
2454   LOperand* temp() { return temps_[0]; }
2455
2456   DECLARE_CONCRETE_INSTRUCTION(ClampTToUint8, "clamp-t-to-uint8")
2457 };
2458
2459
2460 class LDoubleBits V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2461  public:
2462   explicit LDoubleBits(LOperand* value) {
2463     inputs_[0] = value;
2464   }
2465
2466   LOperand* value() { return inputs_[0]; }
2467
2468   DECLARE_CONCRETE_INSTRUCTION(DoubleBits, "double-bits")
2469   DECLARE_HYDROGEN_ACCESSOR(DoubleBits)
2470 };
2471
2472
2473 class LConstructDouble V8_FINAL : public LTemplateInstruction<1, 2, 0> {
2474  public:
2475   LConstructDouble(LOperand* hi, LOperand* lo) {
2476     inputs_[0] = hi;
2477     inputs_[1] = lo;
2478   }
2479
2480   LOperand* hi() { return inputs_[0]; }
2481   LOperand* lo() { return inputs_[1]; }
2482
2483   DECLARE_CONCRETE_INSTRUCTION(ConstructDouble, "construct-double")
2484 };
2485
2486
2487 class LAllocate V8_FINAL : public LTemplateInstruction<1, 2, 2> {
2488  public:
2489   LAllocate(LOperand* context,
2490             LOperand* size,
2491             LOperand* temp1,
2492             LOperand* temp2) {
2493     inputs_[0] = context;
2494     inputs_[1] = size;
2495     temps_[0] = temp1;
2496     temps_[1] = temp2;
2497   }
2498
2499   LOperand* context() { return inputs_[0]; }
2500   LOperand* size() { return inputs_[1]; }
2501   LOperand* temp1() { return temps_[0]; }
2502   LOperand* temp2() { return temps_[1]; }
2503
2504   DECLARE_CONCRETE_INSTRUCTION(Allocate, "allocate")
2505   DECLARE_HYDROGEN_ACCESSOR(Allocate)
2506 };
2507
2508
2509 class LRegExpLiteral V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2510  public:
2511   explicit LRegExpLiteral(LOperand* context) {
2512     inputs_[0] = context;
2513   }
2514
2515   LOperand* context() { return inputs_[0]; }
2516
2517   DECLARE_CONCRETE_INSTRUCTION(RegExpLiteral, "regexp-literal")
2518   DECLARE_HYDROGEN_ACCESSOR(RegExpLiteral)
2519 };
2520
2521
2522 class LFunctionLiteral V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2523  public:
2524   explicit LFunctionLiteral(LOperand* context) {
2525     inputs_[0] = context;
2526   }
2527
2528   LOperand* context() { return inputs_[0]; }
2529
2530   DECLARE_CONCRETE_INSTRUCTION(FunctionLiteral, "function-literal")
2531   DECLARE_HYDROGEN_ACCESSOR(FunctionLiteral)
2532 };
2533
2534
2535 class LToFastProperties V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2536  public:
2537   explicit LToFastProperties(LOperand* value) {
2538     inputs_[0] = value;
2539   }
2540
2541   LOperand* value() { return inputs_[0]; }
2542
2543   DECLARE_CONCRETE_INSTRUCTION(ToFastProperties, "to-fast-properties")
2544   DECLARE_HYDROGEN_ACCESSOR(ToFastProperties)
2545 };
2546
2547
2548 class LTypeof V8_FINAL : public LTemplateInstruction<1, 2, 0> {
2549  public:
2550   LTypeof(LOperand* context, LOperand* value) {
2551     inputs_[0] = context;
2552     inputs_[1] = value;
2553   }
2554
2555   LOperand* context() { return inputs_[0]; }
2556   LOperand* value() { return inputs_[1]; }
2557
2558   DECLARE_CONCRETE_INSTRUCTION(Typeof, "typeof")
2559 };
2560
2561
2562 class LTypeofIsAndBranch V8_FINAL : public LControlInstruction<1, 0> {
2563  public:
2564   explicit LTypeofIsAndBranch(LOperand* value) {
2565     inputs_[0] = value;
2566   }
2567
2568   LOperand* value() { return inputs_[0]; }
2569
2570   DECLARE_CONCRETE_INSTRUCTION(TypeofIsAndBranch, "typeof-is-and-branch")
2571   DECLARE_HYDROGEN_ACCESSOR(TypeofIsAndBranch)
2572
2573   Handle<String> type_literal() { return hydrogen()->type_literal(); }
2574
2575   virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
2576 };
2577
2578
2579 class LIsConstructCallAndBranch V8_FINAL : public LControlInstruction<0, 1> {
2580  public:
2581   explicit LIsConstructCallAndBranch(LOperand* temp) {
2582     temps_[0] = temp;
2583   }
2584
2585   LOperand* temp() { return temps_[0]; }
2586
2587   DECLARE_CONCRETE_INSTRUCTION(IsConstructCallAndBranch,
2588                                "is-construct-call-and-branch")
2589 };
2590
2591
2592 class LOsrEntry V8_FINAL : public LTemplateInstruction<0, 0, 0> {
2593  public:
2594   LOsrEntry() {}
2595
2596   virtual bool HasInterestingComment(LCodeGen* gen) const V8_OVERRIDE {
2597     return false;
2598   }
2599   DECLARE_CONCRETE_INSTRUCTION(OsrEntry, "osr-entry")
2600 };
2601
2602
2603 class LStackCheck V8_FINAL : public LTemplateInstruction<0, 1, 0> {
2604  public:
2605   explicit LStackCheck(LOperand* context) {
2606     inputs_[0] = context;
2607   }
2608
2609   LOperand* context() { return inputs_[0]; }
2610
2611   DECLARE_CONCRETE_INSTRUCTION(StackCheck, "stack-check")
2612   DECLARE_HYDROGEN_ACCESSOR(StackCheck)
2613
2614   Label* done_label() { return &done_label_; }
2615
2616  private:
2617   Label done_label_;
2618 };
2619
2620
2621 class LForInPrepareMap V8_FINAL : public LTemplateInstruction<1, 2, 0> {
2622  public:
2623   LForInPrepareMap(LOperand* context, LOperand* object) {
2624     inputs_[0] = context;
2625     inputs_[1] = object;
2626   }
2627
2628   LOperand* context() { return inputs_[0]; }
2629   LOperand* object() { return inputs_[1]; }
2630
2631   DECLARE_CONCRETE_INSTRUCTION(ForInPrepareMap, "for-in-prepare-map")
2632 };
2633
2634
2635 class LForInCacheArray V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2636  public:
2637   explicit LForInCacheArray(LOperand* map) {
2638     inputs_[0] = map;
2639   }
2640
2641   LOperand* map() { return inputs_[0]; }
2642
2643   DECLARE_CONCRETE_INSTRUCTION(ForInCacheArray, "for-in-cache-array")
2644
2645   int idx() {
2646     return HForInCacheArray::cast(this->hydrogen_value())->idx();
2647   }
2648 };
2649
2650
2651 class LCheckMapValue V8_FINAL : public LTemplateInstruction<0, 2, 0> {
2652  public:
2653   LCheckMapValue(LOperand* value, LOperand* map) {
2654     inputs_[0] = value;
2655     inputs_[1] = map;
2656   }
2657
2658   LOperand* value() { return inputs_[0]; }
2659   LOperand* map() { return inputs_[1]; }
2660
2661   DECLARE_CONCRETE_INSTRUCTION(CheckMapValue, "check-map-value")
2662 };
2663
2664
2665 class LLoadFieldByIndex V8_FINAL : public LTemplateInstruction<1, 2, 0> {
2666  public:
2667   LLoadFieldByIndex(LOperand* object, LOperand* index) {
2668     inputs_[0] = object;
2669     inputs_[1] = index;
2670   }
2671
2672   LOperand* object() { return inputs_[0]; }
2673   LOperand* index() { return inputs_[1]; }
2674
2675   DECLARE_CONCRETE_INSTRUCTION(LoadFieldByIndex, "load-field-by-index")
2676 };
2677
2678
2679 class LChunkBuilder;
2680 class LPlatformChunk V8_FINAL : public LChunk {
2681  public:
2682   LPlatformChunk(CompilationInfo* info, HGraph* graph)
2683       : LChunk(info, graph) { }
2684
2685   int GetNextSpillIndex(RegisterKind kind);
2686   LOperand* GetNextSpillSlot(RegisterKind kind);
2687 };
2688
2689
2690 class LChunkBuilder V8_FINAL : public LChunkBuilderBase {
2691  public:
2692   LChunkBuilder(CompilationInfo* info, HGraph* graph, LAllocator* allocator)
2693       : LChunkBuilderBase(graph->zone()),
2694         chunk_(NULL),
2695         info_(info),
2696         graph_(graph),
2697         status_(UNUSED),
2698         current_instruction_(NULL),
2699         current_block_(NULL),
2700         next_block_(NULL),
2701         allocator_(allocator) { }
2702
2703   Isolate* isolate() const { return graph_->isolate(); }
2704
2705   // Build the sequence for the graph.
2706   LPlatformChunk* Build();
2707
2708   LInstruction* CheckElideControlInstruction(HControlInstruction* instr);
2709
2710   // Declare methods that deal with the individual node types.
2711 #define DECLARE_DO(type) LInstruction* Do##type(H##type* node);
2712   HYDROGEN_CONCRETE_INSTRUCTION_LIST(DECLARE_DO)
2713 #undef DECLARE_DO
2714
2715   LInstruction* DoMultiplyAdd(HMul* mul, HValue* addend);
2716   LInstruction* DoMultiplySub(HValue* minuend, HMul* mul);
2717   LInstruction* DoRSub(HSub* instr);
2718
2719   static bool HasMagicNumberForDivisor(int32_t divisor);
2720
2721   LInstruction* DoMathFloor(HUnaryMathOperation* instr);
2722   LInstruction* DoMathRound(HUnaryMathOperation* instr);
2723   LInstruction* DoMathAbs(HUnaryMathOperation* instr);
2724   LInstruction* DoMathLog(HUnaryMathOperation* instr);
2725   LInstruction* DoMathExp(HUnaryMathOperation* instr);
2726   LInstruction* DoMathSqrt(HUnaryMathOperation* instr);
2727   LInstruction* DoMathPowHalf(HUnaryMathOperation* instr);
2728   LInstruction* DoMathClz32(HUnaryMathOperation* instr);
2729   LInstruction* DoDivByPowerOf2I(HDiv* instr);
2730   LInstruction* DoDivByConstI(HDiv* instr);
2731   LInstruction* DoDivI(HDiv* instr);
2732   LInstruction* DoModByPowerOf2I(HMod* instr);
2733   LInstruction* DoModByConstI(HMod* instr);
2734   LInstruction* DoModI(HMod* instr);
2735   LInstruction* DoFlooringDivByPowerOf2I(HMathFloorOfDiv* instr);
2736   LInstruction* DoFlooringDivByConstI(HMathFloorOfDiv* instr);
2737   LInstruction* DoFlooringDivI(HMathFloorOfDiv* instr);
2738
2739  private:
2740   enum Status {
2741     UNUSED,
2742     BUILDING,
2743     DONE,
2744     ABORTED
2745   };
2746
2747   LPlatformChunk* chunk() const { return chunk_; }
2748   CompilationInfo* info() const { return info_; }
2749   HGraph* graph() const { return graph_; }
2750
2751   bool is_unused() const { return status_ == UNUSED; }
2752   bool is_building() const { return status_ == BUILDING; }
2753   bool is_done() const { return status_ == DONE; }
2754   bool is_aborted() const { return status_ == ABORTED; }
2755
2756   void Abort(BailoutReason reason);
2757
2758   // Methods for getting operands for Use / Define / Temp.
2759   LUnallocated* ToUnallocated(Register reg);
2760   LUnallocated* ToUnallocated(DoubleRegister reg);
2761
2762   // Methods for setting up define-use relationships.
2763   MUST_USE_RESULT LOperand* Use(HValue* value, LUnallocated* operand);
2764   MUST_USE_RESULT LOperand* UseFixed(HValue* value, Register fixed_register);
2765   MUST_USE_RESULT LOperand* UseFixedDouble(HValue* value,
2766                                            DoubleRegister fixed_register);
2767
2768   // A value that is guaranteed to be allocated to a register.
2769   // Operand created by UseRegister is guaranteed to be live until the end of
2770   // instruction. This means that register allocator will not reuse it's
2771   // register for any other operand inside instruction.
2772   // Operand created by UseRegisterAtStart is guaranteed to be live only at
2773   // instruction start. Register allocator is free to assign the same register
2774   // to some other operand used inside instruction (i.e. temporary or
2775   // output).
2776   MUST_USE_RESULT LOperand* UseRegister(HValue* value);
2777   MUST_USE_RESULT LOperand* UseRegisterAtStart(HValue* value);
2778
2779   // An input operand in a register that may be trashed.
2780   MUST_USE_RESULT LOperand* UseTempRegister(HValue* value);
2781
2782   // An input operand in a register or stack slot.
2783   MUST_USE_RESULT LOperand* Use(HValue* value);
2784   MUST_USE_RESULT LOperand* UseAtStart(HValue* value);
2785
2786   // An input operand in a register, stack slot or a constant operand.
2787   MUST_USE_RESULT LOperand* UseOrConstant(HValue* value);
2788   MUST_USE_RESULT LOperand* UseOrConstantAtStart(HValue* value);
2789
2790   // An input operand in a register or a constant operand.
2791   MUST_USE_RESULT LOperand* UseRegisterOrConstant(HValue* value);
2792   MUST_USE_RESULT LOperand* UseRegisterOrConstantAtStart(HValue* value);
2793
2794   // An input operand in a constant operand.
2795   MUST_USE_RESULT LOperand* UseConstant(HValue* value);
2796
2797   // An input operand in register, stack slot or a constant operand.
2798   // Will not be moved to a register even if one is freely available.
2799   virtual MUST_USE_RESULT LOperand* UseAny(HValue* value) V8_OVERRIDE;
2800
2801   // Temporary operand that must be in a register.
2802   MUST_USE_RESULT LUnallocated* TempRegister();
2803   MUST_USE_RESULT LOperand* FixedTemp(Register reg);
2804   MUST_USE_RESULT LOperand* FixedTemp(DoubleRegister reg);
2805
2806   // Methods for setting up define-use relationships.
2807   // Return the same instruction that they are passed.
2808   LInstruction* Define(LTemplateResultInstruction<1>* instr,
2809                        LUnallocated* result);
2810   LInstruction* DefineAsRegister(LTemplateResultInstruction<1>* instr);
2811   LInstruction* DefineAsSpilled(LTemplateResultInstruction<1>* instr,
2812                                 int index);
2813   LInstruction* DefineSameAsFirst(LTemplateResultInstruction<1>* instr);
2814   LInstruction* DefineFixed(LTemplateResultInstruction<1>* instr,
2815                             Register reg);
2816   LInstruction* DefineFixedDouble(LTemplateResultInstruction<1>* instr,
2817                                   DoubleRegister reg);
2818   LInstruction* AssignEnvironment(LInstruction* instr);
2819   LInstruction* AssignPointerMap(LInstruction* instr);
2820
2821   enum CanDeoptimize { CAN_DEOPTIMIZE_EAGERLY, CANNOT_DEOPTIMIZE_EAGERLY };
2822
2823   // By default we assume that instruction sequences generated for calls
2824   // cannot deoptimize eagerly and we do not attach environment to this
2825   // instruction.
2826   LInstruction* MarkAsCall(
2827       LInstruction* instr,
2828       HInstruction* hinstr,
2829       CanDeoptimize can_deoptimize = CANNOT_DEOPTIMIZE_EAGERLY);
2830
2831   void VisitInstruction(HInstruction* current);
2832
2833   void DoBasicBlock(HBasicBlock* block, HBasicBlock* next_block);
2834   LInstruction* DoShift(Token::Value op, HBitwiseBinaryOperation* instr);
2835   LInstruction* DoArithmeticD(Token::Value op,
2836                               HArithmeticBinaryOperation* instr);
2837   LInstruction* DoArithmeticT(Token::Value op,
2838                               HBinaryOperation* instr);
2839
2840   LPlatformChunk* chunk_;
2841   CompilationInfo* info_;
2842   HGraph* const graph_;
2843   Status status_;
2844   HInstruction* current_instruction_;
2845   HBasicBlock* current_block_;
2846   HBasicBlock* next_block_;
2847   LAllocator* allocator_;
2848
2849   DISALLOW_COPY_AND_ASSIGN(LChunkBuilder);
2850 };
2851
2852 #undef DECLARE_HYDROGEN_ACCESSOR
2853 #undef DECLARE_CONCRETE_INSTRUCTION
2854
2855 } }  // namespace v8::internal
2856
2857 #endif  // V8_ARM_LITHIUM_ARM_H_