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