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