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