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