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