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