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