[V8] Introduce a QML compilation mode
[profile/ivi/qtjsbackend.git] / src / 3rdparty / v8 / src / ia32 / lithium-ia32.h
1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are
4 // met:
5 //
6 //     * Redistributions of source code must retain the above copyright
7 //       notice, this list of conditions and the following disclaimer.
8 //     * Redistributions in binary form must reproduce the above
9 //       copyright notice, this list of conditions and the following
10 //       disclaimer in the documentation and/or other materials provided
11 //       with the distribution.
12 //     * Neither the name of Google Inc. nor the names of its
13 //       contributors may be used to endorse or promote products derived
14 //       from this software without specific prior written permission.
15 //
16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
28 #ifndef V8_IA32_LITHIUM_IA32_H_
29 #define V8_IA32_LITHIUM_IA32_H_
30
31 #include "hydrogen.h"
32 #include "lithium-allocator.h"
33 #include "lithium.h"
34 #include "safepoint-table.h"
35 #include "utils.h"
36
37 namespace v8 {
38 namespace internal {
39
40 // Forward declarations.
41 class LCodeGen;
42
43 #define LITHIUM_CONCRETE_INSTRUCTION_LIST(V)    \
44   V(AccessArgumentsAt)                          \
45   V(AddI)                                       \
46   V(AllocateObject)                             \
47   V(ApplyArguments)                             \
48   V(ArgumentsElements)                          \
49   V(ArgumentsLength)                            \
50   V(ArithmeticD)                                \
51   V(ArithmeticT)                                \
52   V(ArrayLiteral)                               \
53   V(BitI)                                       \
54   V(BitNotI)                                    \
55   V(BoundsCheck)                                \
56   V(Branch)                                     \
57   V(CallConstantFunction)                       \
58   V(CallFunction)                               \
59   V(CallGlobal)                                 \
60   V(CallKeyed)                                  \
61   V(CallKnownGlobal)                            \
62   V(CallNamed)                                  \
63   V(CallNew)                                    \
64   V(CallRuntime)                                \
65   V(CallStub)                                   \
66   V(CheckFunction)                              \
67   V(CheckInstanceType)                          \
68   V(CheckMaps)                                  \
69   V(CheckNonSmi)                                \
70   V(CheckPrototypeMaps)                         \
71   V(CheckSmi)                                   \
72   V(ClampDToUint8)                              \
73   V(ClampIToUint8)                              \
74   V(ClampTToUint8)                              \
75   V(ClassOfTestAndBranch)                       \
76   V(CmpIDAndBranch)                             \
77   V(CmpObjectEqAndBranch)                       \
78   V(CmpMapAndBranch)                            \
79   V(CmpT)                                       \
80   V(CmpConstantEqAndBranch)                     \
81   V(ConstantD)                                  \
82   V(ConstantI)                                  \
83   V(ConstantT)                                  \
84   V(Context)                                    \
85   V(DeclareGlobals)                             \
86   V(DeleteProperty)                             \
87   V(Deoptimize)                                 \
88   V(DivI)                                       \
89   V(DoubleToI)                                  \
90   V(ElementsKind)                               \
91   V(FastLiteral)                                \
92   V(FixedArrayBaseLength)                       \
93   V(FunctionLiteral)                            \
94   V(GetCachedArrayIndex)                        \
95   V(GlobalObject)                               \
96   V(GlobalReceiver)                             \
97   V(Goto)                                       \
98   V(HasCachedArrayIndexAndBranch)               \
99   V(HasInstanceTypeAndBranch)                   \
100   V(In)                                         \
101   V(InstanceOf)                                 \
102   V(InstanceOfKnownGlobal)                      \
103   V(InstructionGap)                             \
104   V(Integer32ToDouble)                          \
105   V(InvokeFunction)                             \
106   V(IsConstructCallAndBranch)                   \
107   V(IsNilAndBranch)                             \
108   V(IsObjectAndBranch)                          \
109   V(IsStringAndBranch)                          \
110   V(IsSmiAndBranch)                             \
111   V(IsUndetectableAndBranch)                    \
112   V(StringCompareAndBranch)                     \
113   V(JSArrayLength)                              \
114   V(Label)                                      \
115   V(LazyBailout)                                \
116   V(LoadContextSlot)                            \
117   V(LoadElements)                               \
118   V(LoadExternalArrayPointer)                   \
119   V(LoadFunctionPrototype)                      \
120   V(LoadGlobalCell)                             \
121   V(LoadGlobalGeneric)                          \
122   V(LoadKeyedFastElement)                       \
123   V(LoadKeyedFastDoubleElement)                 \
124   V(LoadKeyedGeneric)                           \
125   V(LoadKeyedSpecializedArrayElement)           \
126   V(LoadNamedField)                             \
127   V(LoadNamedFieldPolymorphic)                  \
128   V(LoadNamedGeneric)                           \
129   V(MathPowHalf)                                \
130   V(ModI)                                       \
131   V(MulI)                                       \
132   V(NumberTagD)                                 \
133   V(NumberTagI)                                 \
134   V(NumberUntagD)                               \
135   V(ObjectLiteral)                              \
136   V(OsrEntry)                                   \
137   V(OuterContext)                               \
138   V(Parameter)                                  \
139   V(Power)                                      \
140   V(Random)                                     \
141   V(PushArgument)                               \
142   V(RegExpLiteral)                              \
143   V(Return)                                     \
144   V(ShiftI)                                     \
145   V(SmiTag)                                     \
146   V(SmiUntag)                                   \
147   V(StackCheck)                                 \
148   V(StoreContextSlot)                           \
149   V(StoreGlobalCell)                            \
150   V(StoreGlobalGeneric)                         \
151   V(StoreKeyedFastDoubleElement)                \
152   V(StoreKeyedFastElement)                      \
153   V(StoreKeyedGeneric)                          \
154   V(StoreKeyedSpecializedArrayElement)          \
155   V(StoreNamedField)                            \
156   V(StoreNamedGeneric)                          \
157   V(StringAdd)                                  \
158   V(StringCharCodeAt)                           \
159   V(StringCharFromCode)                         \
160   V(StringLength)                               \
161   V(SubI)                                       \
162   V(TaggedToI)                                  \
163   V(ThisFunction)                               \
164   V(Throw)                                      \
165   V(ToFastProperties)                           \
166   V(TransitionElementsKind)                     \
167   V(Typeof)                                     \
168   V(TypeofIsAndBranch)                          \
169   V(UnaryMathOperation)                         \
170   V(UnknownOSRValue)                            \
171   V(ValueOf)                                    \
172   V(ForInPrepareMap)                            \
173   V(ForInCacheArray)                            \
174   V(CheckMapValue)                              \
175   V(LoadFieldByIndex)                           \
176   V(DateField)                                  \
177   V(WrapReceiver)                               \
178   V(Drop)
179
180
181 #define DECLARE_CONCRETE_INSTRUCTION(type, mnemonic)              \
182   virtual Opcode opcode() const { return LInstruction::k##type; } \
183   virtual void CompileToNative(LCodeGen* generator);              \
184   virtual const char* Mnemonic() const { return mnemonic; }       \
185   static L##type* cast(LInstruction* instr) {                     \
186     ASSERT(instr->Is##type());                                    \
187     return reinterpret_cast<L##type*>(instr);                     \
188   }
189
190
191 #define DECLARE_HYDROGEN_ACCESSOR(type)     \
192   H##type* hydrogen() const {               \
193     return H##type::cast(hydrogen_value()); \
194   }
195
196
197 class LInstruction: public ZoneObject {
198  public:
199   LInstruction()
200       : environment_(NULL),
201         hydrogen_value_(NULL),
202         is_call_(false) { }
203   virtual ~LInstruction() { }
204
205   virtual void CompileToNative(LCodeGen* generator) = 0;
206   virtual const char* Mnemonic() const = 0;
207   virtual void PrintTo(StringStream* stream);
208   virtual void PrintDataTo(StringStream* stream);
209   virtual void PrintOutputOperandTo(StringStream* stream);
210
211   enum Opcode {
212     // Declare a unique enum value for each instruction.
213 #define DECLARE_OPCODE(type) k##type,
214     LITHIUM_CONCRETE_INSTRUCTION_LIST(DECLARE_OPCODE)
215     kNumberOfInstructions
216 #undef DECLARE_OPCODE
217   };
218
219   virtual Opcode opcode() const = 0;
220
221   // Declare non-virtual type testers for all leaf IR classes.
222 #define DECLARE_PREDICATE(type) \
223   bool Is##type() const { return opcode() == k##type; }
224   LITHIUM_CONCRETE_INSTRUCTION_LIST(DECLARE_PREDICATE)
225 #undef DECLARE_PREDICATE
226
227   // Declare virtual predicates for instructions that don't have
228   // an opcode.
229   virtual bool IsGap() const { return false; }
230
231   virtual bool IsControl() const { return false; }
232
233   void set_environment(LEnvironment* env) { environment_ = env; }
234   LEnvironment* environment() const { return environment_; }
235   bool HasEnvironment() const { return environment_ != NULL; }
236
237   void set_pointer_map(LPointerMap* p) { pointer_map_.set(p); }
238   LPointerMap* pointer_map() const { return pointer_map_.get(); }
239   bool HasPointerMap() const { return pointer_map_.is_set(); }
240
241
242   void set_hydrogen_value(HValue* value) { hydrogen_value_ = value; }
243   HValue* hydrogen_value() const { return hydrogen_value_; }
244
245   virtual void SetDeferredLazyDeoptimizationEnvironment(LEnvironment* env) { }
246
247   void MarkAsCall() { is_call_ = true; }
248
249   // Interface to the register allocator and iterators.
250   bool IsMarkedAsCall() const { return is_call_; }
251
252   virtual bool HasResult() const = 0;
253   virtual LOperand* result() = 0;
254
255   virtual int InputCount() = 0;
256   virtual LOperand* InputAt(int i) = 0;
257   virtual int TempCount() = 0;
258   virtual LOperand* TempAt(int i) = 0;
259
260   LOperand* FirstInput() { return InputAt(0); }
261   LOperand* Output() { return HasResult() ? result() : NULL; }
262
263 #ifdef DEBUG
264   void VerifyCall();
265 #endif
266
267  private:
268   LEnvironment* environment_;
269   SetOncePointer<LPointerMap> pointer_map_;
270   HValue* hydrogen_value_;
271   bool is_call_;
272 };
273
274
275 // R = number of result operands (0 or 1).
276 // I = number of input operands.
277 // T = number of temporary operands.
278 template<int R, int I, int T>
279 class LTemplateInstruction: public LInstruction {
280  public:
281   // Allow 0 or 1 output operands.
282   STATIC_ASSERT(R == 0 || R == 1);
283   virtual bool HasResult() const { return R != 0; }
284   void set_result(LOperand* operand) { results_[0] = operand; }
285   LOperand* result() { return results_[0]; }
286
287   int InputCount() { return I; }
288   LOperand* InputAt(int i) { return inputs_[i]; }
289
290   int TempCount() { return T; }
291   LOperand* TempAt(int i) { return temps_[i]; }
292
293  protected:
294   EmbeddedContainer<LOperand*, R> results_;
295   EmbeddedContainer<LOperand*, I> inputs_;
296   EmbeddedContainer<LOperand*, T> temps_;
297 };
298
299
300 class LGap: public LTemplateInstruction<0, 0, 0> {
301  public:
302   explicit LGap(HBasicBlock* block) : block_(block) {
303     parallel_moves_[BEFORE] = NULL;
304     parallel_moves_[START] = NULL;
305     parallel_moves_[END] = NULL;
306     parallel_moves_[AFTER] = NULL;
307   }
308
309   // Can't use the DECLARE-macro here because of sub-classes.
310   virtual bool IsGap() const { return true; }
311   virtual void PrintDataTo(StringStream* stream);
312   static LGap* cast(LInstruction* instr) {
313     ASSERT(instr->IsGap());
314     return reinterpret_cast<LGap*>(instr);
315   }
316
317   bool IsRedundant() const;
318
319   HBasicBlock* block() const { return block_; }
320
321   enum InnerPosition {
322     BEFORE,
323     START,
324     END,
325     AFTER,
326     FIRST_INNER_POSITION = BEFORE,
327     LAST_INNER_POSITION = AFTER
328   };
329
330   LParallelMove* GetOrCreateParallelMove(InnerPosition pos)  {
331     if (parallel_moves_[pos] == NULL) parallel_moves_[pos] = new LParallelMove;
332     return parallel_moves_[pos];
333   }
334
335   LParallelMove* GetParallelMove(InnerPosition pos)  {
336     return parallel_moves_[pos];
337   }
338
339  private:
340   LParallelMove* parallel_moves_[LAST_INNER_POSITION + 1];
341   HBasicBlock* block_;
342 };
343
344
345 class LInstructionGap: public LGap {
346  public:
347   explicit LInstructionGap(HBasicBlock* block) : LGap(block) { }
348
349   DECLARE_CONCRETE_INSTRUCTION(InstructionGap, "gap")
350 };
351
352
353 class LGoto: public LTemplateInstruction<0, 0, 0> {
354  public:
355   explicit LGoto(int block_id) : block_id_(block_id) { }
356
357   DECLARE_CONCRETE_INSTRUCTION(Goto, "goto")
358   virtual void PrintDataTo(StringStream* stream);
359   virtual bool IsControl() const { return true; }
360
361   int block_id() const { return block_id_; }
362
363  private:
364   int block_id_;
365 };
366
367
368 class LLazyBailout: public LTemplateInstruction<0, 0, 0> {
369  public:
370   DECLARE_CONCRETE_INSTRUCTION(LazyBailout, "lazy-bailout")
371 };
372
373
374 class LDeoptimize: public LTemplateInstruction<0, 0, 0> {
375  public:
376   DECLARE_CONCRETE_INSTRUCTION(Deoptimize, "deoptimize")
377 };
378
379
380 class LLabel: public LGap {
381  public:
382   explicit LLabel(HBasicBlock* block)
383       : LGap(block), replacement_(NULL) { }
384
385   DECLARE_CONCRETE_INSTRUCTION(Label, "label")
386
387   virtual void PrintDataTo(StringStream* stream);
388
389   int block_id() const { return block()->block_id(); }
390   bool is_loop_header() const { return block()->IsLoopHeader(); }
391   Label* label() { return &label_; }
392   LLabel* replacement() const { return replacement_; }
393   void set_replacement(LLabel* label) { replacement_ = label; }
394   bool HasReplacement() const { return replacement_ != NULL; }
395
396  private:
397   Label label_;
398   LLabel* replacement_;
399 };
400
401
402 class LParameter: public LTemplateInstruction<1, 0, 0> {
403  public:
404   DECLARE_CONCRETE_INSTRUCTION(Parameter, "parameter")
405 };
406
407
408 class LCallStub: public LTemplateInstruction<1, 1, 0> {
409  public:
410   explicit LCallStub(LOperand* context) {
411     inputs_[0] = context;
412   }
413
414   DECLARE_CONCRETE_INSTRUCTION(CallStub, "call-stub")
415   DECLARE_HYDROGEN_ACCESSOR(CallStub)
416
417   LOperand* context() { return inputs_[0]; }
418
419   TranscendentalCache::Type transcendental_type() {
420     return hydrogen()->transcendental_type();
421   }
422 };
423
424
425 class LUnknownOSRValue: public LTemplateInstruction<1, 0, 0> {
426  public:
427   DECLARE_CONCRETE_INSTRUCTION(UnknownOSRValue, "unknown-osr-value")
428 };
429
430
431 template<int I, int T>
432 class LControlInstruction: public LTemplateInstruction<0, I, T> {
433  public:
434   virtual bool IsControl() const { return true; }
435
436   int SuccessorCount() { return hydrogen()->SuccessorCount(); }
437   HBasicBlock* SuccessorAt(int i) { return hydrogen()->SuccessorAt(i); }
438   int true_block_id() { return hydrogen()->SuccessorAt(0)->block_id(); }
439   int false_block_id() { return hydrogen()->SuccessorAt(1)->block_id(); }
440
441  private:
442   HControlInstruction* hydrogen() {
443     return HControlInstruction::cast(this->hydrogen_value());
444   }
445 };
446
447
448 class LWrapReceiver: public LTemplateInstruction<1, 2, 1> {
449  public:
450   LWrapReceiver(LOperand* receiver,
451                 LOperand* function,
452                 LOperand* temp) {
453     inputs_[0] = receiver;
454     inputs_[1] = function;
455     temps_[0] = temp;
456   }
457
458   DECLARE_CONCRETE_INSTRUCTION(WrapReceiver, "wrap-receiver")
459
460   LOperand* receiver() { return inputs_[0]; }
461   LOperand* function() { return inputs_[1]; }
462 };
463
464
465 class LApplyArguments: public LTemplateInstruction<1, 4, 0> {
466  public:
467   LApplyArguments(LOperand* function,
468                   LOperand* receiver,
469                   LOperand* length,
470                   LOperand* elements) {
471     inputs_[0] = function;
472     inputs_[1] = receiver;
473     inputs_[2] = length;
474     inputs_[3] = elements;
475   }
476
477   DECLARE_CONCRETE_INSTRUCTION(ApplyArguments, "apply-arguments")
478
479   LOperand* function() { return inputs_[0]; }
480   LOperand* receiver() { return inputs_[1]; }
481   LOperand* length() { return inputs_[2]; }
482   LOperand* elements() { return inputs_[3]; }
483 };
484
485
486 class LAccessArgumentsAt: public LTemplateInstruction<1, 3, 0> {
487  public:
488   LAccessArgumentsAt(LOperand* arguments, LOperand* length, LOperand* index) {
489     inputs_[0] = arguments;
490     inputs_[1] = length;
491     inputs_[2] = index;
492   }
493
494   DECLARE_CONCRETE_INSTRUCTION(AccessArgumentsAt, "access-arguments-at")
495
496   LOperand* arguments() { return inputs_[0]; }
497   LOperand* length() { return inputs_[1]; }
498   LOperand* index() { return inputs_[2]; }
499
500   virtual void PrintDataTo(StringStream* stream);
501 };
502
503
504 class LArgumentsLength: public LTemplateInstruction<1, 1, 0> {
505  public:
506   explicit LArgumentsLength(LOperand* elements) {
507     inputs_[0] = elements;
508   }
509
510   DECLARE_CONCRETE_INSTRUCTION(ArgumentsLength, "arguments-length")
511 };
512
513
514 class LArgumentsElements: public LTemplateInstruction<1, 0, 0> {
515  public:
516   DECLARE_CONCRETE_INSTRUCTION(ArgumentsElements, "arguments-elements")
517   DECLARE_HYDROGEN_ACCESSOR(ArgumentsElements)
518 };
519
520
521 class LModI: public LTemplateInstruction<1, 2, 1> {
522  public:
523   LModI(LOperand* left, LOperand* right, LOperand* temp) {
524     inputs_[0] = left;
525     inputs_[1] = right;
526     temps_[0] = temp;
527   }
528
529   DECLARE_CONCRETE_INSTRUCTION(ModI, "mod-i")
530   DECLARE_HYDROGEN_ACCESSOR(Mod)
531 };
532
533
534 class LDivI: public LTemplateInstruction<1, 2, 1> {
535  public:
536   LDivI(LOperand* left, LOperand* right, LOperand* temp) {
537     inputs_[0] = left;
538     inputs_[1] = right;
539     temps_[0] = temp;
540   }
541
542   DECLARE_CONCRETE_INSTRUCTION(DivI, "div-i")
543   DECLARE_HYDROGEN_ACCESSOR(Div)
544 };
545
546
547 class LMulI: public LTemplateInstruction<1, 2, 1> {
548  public:
549   LMulI(LOperand* left, LOperand* right, LOperand* temp) {
550     inputs_[0] = left;
551     inputs_[1] = right;
552     temps_[0] = temp;
553   }
554
555   DECLARE_CONCRETE_INSTRUCTION(MulI, "mul-i")
556   DECLARE_HYDROGEN_ACCESSOR(Mul)
557 };
558
559
560 class LCmpIDAndBranch: public LControlInstruction<2, 0> {
561  public:
562   LCmpIDAndBranch(LOperand* left, LOperand* right) {
563     inputs_[0] = left;
564     inputs_[1] = right;
565   }
566
567   DECLARE_CONCRETE_INSTRUCTION(CmpIDAndBranch, "cmp-id-and-branch")
568   DECLARE_HYDROGEN_ACCESSOR(CompareIDAndBranch)
569
570   Token::Value op() const { return hydrogen()->token(); }
571   bool is_double() const {
572     return hydrogen()->GetInputRepresentation().IsDouble();
573   }
574
575   virtual void PrintDataTo(StringStream* stream);
576 };
577
578
579 class LUnaryMathOperation: public LTemplateInstruction<1, 2, 0> {
580  public:
581   LUnaryMathOperation(LOperand* context, LOperand* value) {
582     inputs_[1] = context;
583     inputs_[0] = value;
584   }
585
586   LOperand* context() { return inputs_[1]; }
587   LOperand* value() { return inputs_[0]; }
588
589   DECLARE_CONCRETE_INSTRUCTION(UnaryMathOperation, "unary-math-operation")
590   DECLARE_HYDROGEN_ACCESSOR(UnaryMathOperation)
591
592   virtual void PrintDataTo(StringStream* stream);
593   BuiltinFunctionId op() const { return hydrogen()->op(); }
594 };
595
596
597 class LMathPowHalf: public LTemplateInstruction<1, 2, 1> {
598  public:
599   LMathPowHalf(LOperand* context, LOperand* value, LOperand* temp) {
600     inputs_[1] = context;
601     inputs_[0] = value;
602     temps_[0] = temp;
603   }
604
605   LOperand* context() { return inputs_[1]; }
606   LOperand* value() { return inputs_[0]; }
607   LOperand* temp() { return temps_[0]; }
608
609   DECLARE_CONCRETE_INSTRUCTION(MathPowHalf, "math-pow-half")
610
611   virtual void PrintDataTo(StringStream* stream);
612 };
613
614
615 class LCmpObjectEqAndBranch: public LControlInstruction<2, 0> {
616  public:
617   LCmpObjectEqAndBranch(LOperand* left, LOperand* right) {
618     inputs_[0] = left;
619     inputs_[1] = right;
620   }
621
622   DECLARE_CONCRETE_INSTRUCTION(CmpObjectEqAndBranch,
623                                "cmp-object-eq-and-branch")
624 };
625
626
627 class LCmpConstantEqAndBranch: public LControlInstruction<1, 0> {
628  public:
629   explicit LCmpConstantEqAndBranch(LOperand* left) {
630     inputs_[0] = left;
631   }
632
633   DECLARE_CONCRETE_INSTRUCTION(CmpConstantEqAndBranch,
634                                "cmp-constant-eq-and-branch")
635   DECLARE_HYDROGEN_ACCESSOR(CompareConstantEqAndBranch)
636 };
637
638
639 class LIsNilAndBranch: public LControlInstruction<1, 1> {
640  public:
641   LIsNilAndBranch(LOperand* value, LOperand* temp) {
642     inputs_[0] = value;
643     temps_[0] = temp;
644   }
645
646   DECLARE_CONCRETE_INSTRUCTION(IsNilAndBranch, "is-nil-and-branch")
647   DECLARE_HYDROGEN_ACCESSOR(IsNilAndBranch)
648
649   EqualityKind kind() const { return hydrogen()->kind(); }
650   NilValue nil() const { return hydrogen()->nil(); }
651
652   virtual void PrintDataTo(StringStream* stream);
653 };
654
655
656 class LIsObjectAndBranch: public LControlInstruction<1, 1> {
657  public:
658   LIsObjectAndBranch(LOperand* value, LOperand* temp) {
659     inputs_[0] = value;
660     temps_[0] = temp;
661   }
662
663   DECLARE_CONCRETE_INSTRUCTION(IsObjectAndBranch, "is-object-and-branch")
664
665   virtual void PrintDataTo(StringStream* stream);
666 };
667
668
669 class LIsStringAndBranch: public LControlInstruction<1, 1> {
670  public:
671   LIsStringAndBranch(LOperand* value, LOperand* temp) {
672     inputs_[0] = value;
673     temps_[0] = temp;
674   }
675
676   DECLARE_CONCRETE_INSTRUCTION(IsStringAndBranch, "is-string-and-branch")
677
678   virtual void PrintDataTo(StringStream* stream);
679 };
680
681
682 class LIsSmiAndBranch: public LControlInstruction<1, 0> {
683  public:
684   explicit LIsSmiAndBranch(LOperand* value) {
685     inputs_[0] = value;
686   }
687
688   DECLARE_CONCRETE_INSTRUCTION(IsSmiAndBranch, "is-smi-and-branch")
689   DECLARE_HYDROGEN_ACCESSOR(IsSmiAndBranch)
690
691   virtual void PrintDataTo(StringStream* stream);
692 };
693
694
695 class LIsUndetectableAndBranch: public LControlInstruction<1, 1> {
696  public:
697   LIsUndetectableAndBranch(LOperand* value, LOperand* temp) {
698     inputs_[0] = value;
699     temps_[0] = temp;
700   }
701
702   DECLARE_CONCRETE_INSTRUCTION(IsUndetectableAndBranch,
703                                "is-undetectable-and-branch")
704
705   virtual void PrintDataTo(StringStream* stream);
706 };
707
708
709 class LStringCompareAndBranch: public LControlInstruction<3, 0> {
710  public:
711   LStringCompareAndBranch(LOperand* context, LOperand* left, LOperand* right) {
712     inputs_[0] = context;
713     inputs_[1] = left;
714     inputs_[2] = right;
715   }
716
717   DECLARE_CONCRETE_INSTRUCTION(StringCompareAndBranch,
718                                "string-compare-and-branch")
719   DECLARE_HYDROGEN_ACCESSOR(StringCompareAndBranch)
720
721   virtual void PrintDataTo(StringStream* stream);
722
723   Token::Value op() const { return hydrogen()->token(); }
724 };
725
726
727 class LHasInstanceTypeAndBranch: public LControlInstruction<1, 1> {
728  public:
729   LHasInstanceTypeAndBranch(LOperand* value, LOperand* temp) {
730     inputs_[0] = value;
731     temps_[0] = temp;
732   }
733
734   DECLARE_CONCRETE_INSTRUCTION(HasInstanceTypeAndBranch,
735                                "has-instance-type-and-branch")
736   DECLARE_HYDROGEN_ACCESSOR(HasInstanceTypeAndBranch)
737
738   virtual void PrintDataTo(StringStream* stream);
739 };
740
741
742 class LGetCachedArrayIndex: public LTemplateInstruction<1, 1, 0> {
743  public:
744   explicit LGetCachedArrayIndex(LOperand* value) {
745     inputs_[0] = value;
746   }
747
748   DECLARE_CONCRETE_INSTRUCTION(GetCachedArrayIndex, "get-cached-array-index")
749   DECLARE_HYDROGEN_ACCESSOR(GetCachedArrayIndex)
750 };
751
752
753 class LHasCachedArrayIndexAndBranch: public LControlInstruction<1, 0> {
754  public:
755   explicit LHasCachedArrayIndexAndBranch(LOperand* value) {
756     inputs_[0] = value;
757   }
758
759   DECLARE_CONCRETE_INSTRUCTION(HasCachedArrayIndexAndBranch,
760                                "has-cached-array-index-and-branch")
761   virtual void PrintDataTo(StringStream* stream);
762 };
763
764
765 class LIsConstructCallAndBranch: public LControlInstruction<0, 1> {
766  public:
767   explicit LIsConstructCallAndBranch(LOperand* temp) {
768     temps_[0] = temp;
769   }
770
771   DECLARE_CONCRETE_INSTRUCTION(IsConstructCallAndBranch,
772                                "is-construct-call-and-branch")
773 };
774
775
776 class LClassOfTestAndBranch: public LControlInstruction<1, 2> {
777  public:
778   LClassOfTestAndBranch(LOperand* value, LOperand* temp, LOperand* temp2) {
779     inputs_[0] = value;
780     temps_[0] = temp;
781     temps_[1] = temp2;
782   }
783
784   DECLARE_CONCRETE_INSTRUCTION(ClassOfTestAndBranch,
785                                "class-of-test-and-branch")
786   DECLARE_HYDROGEN_ACCESSOR(ClassOfTestAndBranch)
787
788   virtual void PrintDataTo(StringStream* stream);
789 };
790
791
792 class LCmpT: public LTemplateInstruction<1, 3, 0> {
793  public:
794   LCmpT(LOperand* context, LOperand* left, LOperand* right) {
795     inputs_[0] = context;
796     inputs_[1] = left;
797     inputs_[2] = right;
798   }
799
800   DECLARE_CONCRETE_INSTRUCTION(CmpT, "cmp-t")
801   DECLARE_HYDROGEN_ACCESSOR(CompareGeneric)
802
803   Token::Value op() const { return hydrogen()->token(); }
804 };
805
806
807 class LInstanceOf: public LTemplateInstruction<1, 3, 0> {
808  public:
809   LInstanceOf(LOperand* context, LOperand* left, LOperand* right) {
810     inputs_[0] = context;
811     inputs_[1] = left;
812     inputs_[2] = right;
813   }
814
815   DECLARE_CONCRETE_INSTRUCTION(InstanceOf, "instance-of")
816
817   LOperand* context() { return inputs_[0]; }
818 };
819
820
821 class LInstanceOfKnownGlobal: public LTemplateInstruction<1, 2, 1> {
822  public:
823   LInstanceOfKnownGlobal(LOperand* context, LOperand* value, LOperand* temp) {
824     inputs_[0] = context;
825     inputs_[1] = value;
826     temps_[0] = temp;
827   }
828
829   DECLARE_CONCRETE_INSTRUCTION(InstanceOfKnownGlobal,
830                                "instance-of-known-global")
831   DECLARE_HYDROGEN_ACCESSOR(InstanceOfKnownGlobal)
832
833   Handle<JSFunction> function() const { return hydrogen()->function(); }
834   LEnvironment* GetDeferredLazyDeoptimizationEnvironment() {
835     return lazy_deopt_env_;
836   }
837   virtual void SetDeferredLazyDeoptimizationEnvironment(LEnvironment* env) {
838     lazy_deopt_env_ = env;
839   }
840
841  private:
842   LEnvironment* lazy_deopt_env_;
843 };
844
845
846 class LBoundsCheck: public LTemplateInstruction<0, 2, 0> {
847  public:
848   LBoundsCheck(LOperand* index, LOperand* length) {
849     inputs_[0] = index;
850     inputs_[1] = length;
851   }
852
853   LOperand* index() { return inputs_[0]; }
854   LOperand* length() { return inputs_[1]; }
855
856   DECLARE_CONCRETE_INSTRUCTION(BoundsCheck, "bounds-check")
857 };
858
859
860 class LBitI: public LTemplateInstruction<1, 2, 0> {
861  public:
862   LBitI(LOperand* left, LOperand* right) {
863     inputs_[0] = left;
864     inputs_[1] = right;
865   }
866
867   Token::Value op() const { return hydrogen()->op(); }
868
869   DECLARE_CONCRETE_INSTRUCTION(BitI, "bit-i")
870   DECLARE_HYDROGEN_ACCESSOR(Bitwise)
871 };
872
873
874 class LShiftI: public LTemplateInstruction<1, 2, 0> {
875  public:
876   LShiftI(Token::Value op, LOperand* left, LOperand* right, bool can_deopt)
877       : op_(op), can_deopt_(can_deopt) {
878     inputs_[0] = left;
879     inputs_[1] = right;
880   }
881
882   Token::Value op() const { return op_; }
883
884   bool can_deopt() const { return can_deopt_; }
885
886   DECLARE_CONCRETE_INSTRUCTION(ShiftI, "shift-i")
887
888  private:
889   Token::Value op_;
890   bool can_deopt_;
891 };
892
893
894 class LSubI: public LTemplateInstruction<1, 2, 0> {
895  public:
896   LSubI(LOperand* left, LOperand* right) {
897     inputs_[0] = left;
898     inputs_[1] = right;
899   }
900
901   DECLARE_CONCRETE_INSTRUCTION(SubI, "sub-i")
902   DECLARE_HYDROGEN_ACCESSOR(Sub)
903 };
904
905
906 class LConstantI: public LTemplateInstruction<1, 0, 0> {
907  public:
908   DECLARE_CONCRETE_INSTRUCTION(ConstantI, "constant-i")
909   DECLARE_HYDROGEN_ACCESSOR(Constant)
910
911   int32_t value() const { return hydrogen()->Integer32Value(); }
912 };
913
914
915 class LConstantD: public LTemplateInstruction<1, 0, 1> {
916  public:
917   explicit LConstantD(LOperand* temp) {
918     temps_[0] = temp;
919   }
920
921   DECLARE_CONCRETE_INSTRUCTION(ConstantD, "constant-d")
922   DECLARE_HYDROGEN_ACCESSOR(Constant)
923
924   double value() const { return hydrogen()->DoubleValue(); }
925 };
926
927
928 class LConstantT: public LTemplateInstruction<1, 0, 0> {
929  public:
930   DECLARE_CONCRETE_INSTRUCTION(ConstantT, "constant-t")
931   DECLARE_HYDROGEN_ACCESSOR(Constant)
932
933   Handle<Object> value() const { return hydrogen()->handle(); }
934 };
935
936
937 class LBranch: public LControlInstruction<1, 1> {
938  public:
939   explicit LBranch(LOperand* value, LOperand* temp) {
940     inputs_[0] = value;
941     temps_[0] = temp;
942   }
943
944   DECLARE_CONCRETE_INSTRUCTION(Branch, "branch")
945   DECLARE_HYDROGEN_ACCESSOR(Branch)
946
947   virtual void PrintDataTo(StringStream* stream);
948 };
949
950
951 class LCmpMapAndBranch: public LTemplateInstruction<0, 1, 0> {
952  public:
953   explicit LCmpMapAndBranch(LOperand* value) {
954     inputs_[0] = value;
955   }
956
957   DECLARE_CONCRETE_INSTRUCTION(CmpMapAndBranch, "cmp-map-and-branch")
958   DECLARE_HYDROGEN_ACCESSOR(CompareMap)
959
960   virtual bool IsControl() const { return true; }
961
962   Handle<Map> map() const { return hydrogen()->map(); }
963   int true_block_id() const {
964     return hydrogen()->FirstSuccessor()->block_id();
965   }
966   int false_block_id() const {
967     return hydrogen()->SecondSuccessor()->block_id();
968   }
969 };
970
971
972 class LJSArrayLength: public LTemplateInstruction<1, 1, 0> {
973  public:
974   explicit LJSArrayLength(LOperand* value) {
975     inputs_[0] = value;
976   }
977
978   DECLARE_CONCRETE_INSTRUCTION(JSArrayLength, "js-array-length")
979   DECLARE_HYDROGEN_ACCESSOR(JSArrayLength)
980 };
981
982
983 class LFixedArrayBaseLength: public LTemplateInstruction<1, 1, 0> {
984  public:
985   explicit LFixedArrayBaseLength(LOperand* value) {
986     inputs_[0] = value;
987   }
988
989   DECLARE_CONCRETE_INSTRUCTION(FixedArrayBaseLength,
990                                "fixed-array-base-length")
991   DECLARE_HYDROGEN_ACCESSOR(FixedArrayBaseLength)
992 };
993
994
995 class LElementsKind: public LTemplateInstruction<1, 1, 0> {
996  public:
997   explicit LElementsKind(LOperand* value) {
998     inputs_[0] = value;
999   }
1000
1001   DECLARE_CONCRETE_INSTRUCTION(ElementsKind, "elements-kind")
1002   DECLARE_HYDROGEN_ACCESSOR(ElementsKind)
1003 };
1004
1005
1006 class LValueOf: public LTemplateInstruction<1, 1, 1> {
1007  public:
1008   LValueOf(LOperand* value, LOperand* temp) {
1009     inputs_[0] = value;
1010     temps_[0] = temp;
1011   }
1012
1013   DECLARE_CONCRETE_INSTRUCTION(ValueOf, "value-of")
1014   DECLARE_HYDROGEN_ACCESSOR(ValueOf)
1015 };
1016
1017
1018 class LDateField: public LTemplateInstruction<1, 1, 1> {
1019  public:
1020   LDateField(LOperand* date, LOperand* temp, Smi* index)
1021       : index_(index) {
1022     inputs_[0] = date;
1023     temps_[0] = temp;
1024   }
1025
1026   DECLARE_CONCRETE_INSTRUCTION(DateField, "date-field")
1027   DECLARE_HYDROGEN_ACCESSOR(DateField)
1028
1029   Smi* index() const { return index_; }
1030
1031  private:
1032   Smi* index_;
1033 };
1034
1035
1036 class LThrow: public LTemplateInstruction<0, 2, 0> {
1037  public:
1038   LThrow(LOperand* context, LOperand* value) {
1039     inputs_[0] = context;
1040     inputs_[1] = value;
1041   }
1042
1043   LOperand* context() { return inputs_[0]; }
1044   LOperand* value() { return inputs_[1]; }
1045
1046   DECLARE_CONCRETE_INSTRUCTION(Throw, "throw")
1047 };
1048
1049
1050 class LBitNotI: public LTemplateInstruction<1, 1, 0> {
1051  public:
1052   explicit LBitNotI(LOperand* value) {
1053     inputs_[0] = value;
1054   }
1055
1056   DECLARE_CONCRETE_INSTRUCTION(BitNotI, "bit-not-i")
1057 };
1058
1059
1060 class LAddI: public LTemplateInstruction<1, 2, 0> {
1061  public:
1062   LAddI(LOperand* left, LOperand* right) {
1063     inputs_[0] = left;
1064     inputs_[1] = right;
1065   }
1066
1067   DECLARE_CONCRETE_INSTRUCTION(AddI, "add-i")
1068   DECLARE_HYDROGEN_ACCESSOR(Add)
1069 };
1070
1071
1072 class LPower: public LTemplateInstruction<1, 2, 0> {
1073  public:
1074   LPower(LOperand* left, LOperand* right) {
1075     inputs_[0] = left;
1076     inputs_[1] = right;
1077   }
1078
1079   DECLARE_CONCRETE_INSTRUCTION(Power, "power")
1080   DECLARE_HYDROGEN_ACCESSOR(Power)
1081 };
1082
1083
1084 class LRandom: public LTemplateInstruction<1, 1, 0> {
1085  public:
1086   explicit LRandom(LOperand* global_object) {
1087     inputs_[0] = global_object;
1088   }
1089
1090   DECLARE_CONCRETE_INSTRUCTION(Random, "random")
1091   DECLARE_HYDROGEN_ACCESSOR(Random)
1092 };
1093
1094
1095 class LArithmeticD: public LTemplateInstruction<1, 2, 0> {
1096  public:
1097   LArithmeticD(Token::Value op, LOperand* left, LOperand* right)
1098       : op_(op) {
1099     inputs_[0] = left;
1100     inputs_[1] = right;
1101   }
1102
1103   Token::Value op() const { return op_; }
1104
1105   virtual Opcode opcode() const { return LInstruction::kArithmeticD; }
1106   virtual void CompileToNative(LCodeGen* generator);
1107   virtual const char* Mnemonic() const;
1108
1109  private:
1110   Token::Value op_;
1111 };
1112
1113
1114 class LArithmeticT: public LTemplateInstruction<1, 3, 0> {
1115  public:
1116   LArithmeticT(Token::Value op,
1117                LOperand* context,
1118                LOperand* left,
1119                LOperand* right)
1120       : op_(op) {
1121     inputs_[0] = context;
1122     inputs_[1] = left;
1123     inputs_[2] = right;
1124   }
1125
1126   virtual Opcode opcode() const { return LInstruction::kArithmeticT; }
1127   virtual void CompileToNative(LCodeGen* generator);
1128   virtual const char* Mnemonic() const;
1129
1130   Token::Value op() const { return op_; }
1131   LOperand* context() { return inputs_[0]; }
1132   LOperand* left() { return inputs_[1]; }
1133   LOperand* right() { return inputs_[2]; }
1134
1135  private:
1136   Token::Value op_;
1137 };
1138
1139
1140 class LReturn: public LTemplateInstruction<0, 1, 0> {
1141  public:
1142   explicit LReturn(LOperand* value) {
1143     inputs_[0] = value;
1144   }
1145
1146   DECLARE_CONCRETE_INSTRUCTION(Return, "return")
1147 };
1148
1149
1150 class LLoadNamedField: public LTemplateInstruction<1, 1, 0> {
1151  public:
1152   explicit LLoadNamedField(LOperand* object) {
1153     inputs_[0] = object;
1154   }
1155
1156   DECLARE_CONCRETE_INSTRUCTION(LoadNamedField, "load-named-field")
1157   DECLARE_HYDROGEN_ACCESSOR(LoadNamedField)
1158
1159   LOperand* object() { return inputs_[0]; }
1160 };
1161
1162
1163 class LLoadNamedFieldPolymorphic: public LTemplateInstruction<1, 2, 0> {
1164  public:
1165   LLoadNamedFieldPolymorphic(LOperand* context, LOperand* object) {
1166     inputs_[0] = context;
1167     inputs_[1] = object;
1168   }
1169
1170   DECLARE_CONCRETE_INSTRUCTION(LoadNamedField, "load-named-field-polymorphic")
1171   DECLARE_HYDROGEN_ACCESSOR(LoadNamedFieldPolymorphic)
1172
1173   LOperand* context() { return inputs_[0]; }
1174   LOperand* object() { return inputs_[1]; }
1175 };
1176
1177
1178 class LLoadNamedGeneric: public LTemplateInstruction<1, 2, 0> {
1179  public:
1180   LLoadNamedGeneric(LOperand* context, LOperand* object) {
1181     inputs_[0] = context;
1182     inputs_[1] = object;
1183   }
1184
1185   DECLARE_CONCRETE_INSTRUCTION(LoadNamedGeneric, "load-named-generic")
1186   DECLARE_HYDROGEN_ACCESSOR(LoadNamedGeneric)
1187
1188   LOperand* context() { return inputs_[0]; }
1189   LOperand* object() { return inputs_[1]; }
1190   Handle<Object> name() const { return hydrogen()->name(); }
1191 };
1192
1193
1194 class LLoadFunctionPrototype: public LTemplateInstruction<1, 1, 1> {
1195  public:
1196   LLoadFunctionPrototype(LOperand* function, LOperand* temp) {
1197     inputs_[0] = function;
1198     temps_[0] = temp;
1199   }
1200
1201   DECLARE_CONCRETE_INSTRUCTION(LoadFunctionPrototype, "load-function-prototype")
1202   DECLARE_HYDROGEN_ACCESSOR(LoadFunctionPrototype)
1203
1204   LOperand* function() { return inputs_[0]; }
1205 };
1206
1207
1208 class LLoadElements: public LTemplateInstruction<1, 1, 0> {
1209  public:
1210   explicit LLoadElements(LOperand* object) {
1211     inputs_[0] = object;
1212   }
1213
1214   DECLARE_CONCRETE_INSTRUCTION(LoadElements, "load-elements")
1215 };
1216
1217
1218 class LLoadExternalArrayPointer: public LTemplateInstruction<1, 1, 0> {
1219  public:
1220   explicit LLoadExternalArrayPointer(LOperand* object) {
1221     inputs_[0] = object;
1222   }
1223
1224   DECLARE_CONCRETE_INSTRUCTION(LoadExternalArrayPointer,
1225                                "load-external-array-pointer")
1226 };
1227
1228
1229 class LLoadKeyedFastElement: public LTemplateInstruction<1, 2, 0> {
1230  public:
1231   LLoadKeyedFastElement(LOperand* elements, LOperand* key) {
1232     inputs_[0] = elements;
1233     inputs_[1] = key;
1234   }
1235
1236   DECLARE_CONCRETE_INSTRUCTION(LoadKeyedFastElement, "load-keyed-fast-element")
1237   DECLARE_HYDROGEN_ACCESSOR(LoadKeyedFastElement)
1238
1239   LOperand* elements() { return inputs_[0]; }
1240   LOperand* key() { return inputs_[1]; }
1241   uint32_t additional_index() const { return hydrogen()->index_offset(); }
1242 };
1243
1244
1245 class LLoadKeyedFastDoubleElement: public LTemplateInstruction<1, 2, 0> {
1246  public:
1247   LLoadKeyedFastDoubleElement(LOperand* elements, LOperand* key) {
1248     inputs_[0] = elements;
1249     inputs_[1] = key;
1250   }
1251
1252   DECLARE_CONCRETE_INSTRUCTION(LoadKeyedFastDoubleElement,
1253                                "load-keyed-fast-double-element")
1254   DECLARE_HYDROGEN_ACCESSOR(LoadKeyedFastDoubleElement)
1255
1256   LOperand* elements() { return inputs_[0]; }
1257   LOperand* key() { return inputs_[1]; }
1258   uint32_t additional_index() const { return hydrogen()->index_offset(); }
1259 };
1260
1261
1262 class LLoadKeyedSpecializedArrayElement: public LTemplateInstruction<1, 2, 0> {
1263  public:
1264   LLoadKeyedSpecializedArrayElement(LOperand* external_pointer, LOperand* key) {
1265     inputs_[0] = external_pointer;
1266     inputs_[1] = key;
1267   }
1268
1269   DECLARE_CONCRETE_INSTRUCTION(LoadKeyedSpecializedArrayElement,
1270                                "load-keyed-specialized-array-element")
1271   DECLARE_HYDROGEN_ACCESSOR(LoadKeyedSpecializedArrayElement)
1272
1273   LOperand* external_pointer() { return inputs_[0]; }
1274   LOperand* key() { return inputs_[1]; }
1275   ElementsKind elements_kind() const {
1276     return hydrogen()->elements_kind();
1277   }
1278   uint32_t additional_index() const { return hydrogen()->index_offset(); }
1279 };
1280
1281
1282 class LLoadKeyedGeneric: public LTemplateInstruction<1, 3, 0> {
1283  public:
1284   LLoadKeyedGeneric(LOperand* context, LOperand* obj, LOperand* key) {
1285     inputs_[0] = context;
1286     inputs_[1] = obj;
1287     inputs_[2] = key;
1288   }
1289
1290   DECLARE_CONCRETE_INSTRUCTION(LoadKeyedGeneric, "load-keyed-generic")
1291
1292   LOperand* context() { return inputs_[0]; }
1293   LOperand* object() { return inputs_[1]; }
1294   LOperand* key() { return inputs_[2]; }
1295 };
1296
1297
1298 class LLoadGlobalCell: public LTemplateInstruction<1, 0, 0> {
1299  public:
1300   DECLARE_CONCRETE_INSTRUCTION(LoadGlobalCell, "load-global-cell")
1301   DECLARE_HYDROGEN_ACCESSOR(LoadGlobalCell)
1302 };
1303
1304
1305 class LLoadGlobalGeneric: public LTemplateInstruction<1, 2, 0> {
1306  public:
1307   LLoadGlobalGeneric(LOperand* context, LOperand* global_object) {
1308     inputs_[0] = context;
1309     inputs_[1] = global_object;
1310   }
1311
1312   DECLARE_CONCRETE_INSTRUCTION(LoadGlobalGeneric, "load-global-generic")
1313   DECLARE_HYDROGEN_ACCESSOR(LoadGlobalGeneric)
1314
1315   LOperand* context() { return inputs_[0]; }
1316   LOperand* global_object() { return inputs_[1]; }
1317   Handle<Object> name() const { return hydrogen()->name(); }
1318   bool for_typeof() const { return hydrogen()->for_typeof(); }
1319 };
1320
1321
1322 class LStoreGlobalCell: public LTemplateInstruction<0, 1, 0> {
1323  public:
1324   explicit LStoreGlobalCell(LOperand* value) {
1325     inputs_[0] = value;
1326   }
1327
1328   DECLARE_CONCRETE_INSTRUCTION(StoreGlobalCell, "store-global-cell")
1329   DECLARE_HYDROGEN_ACCESSOR(StoreGlobalCell)
1330
1331   LOperand* value() { return inputs_[0]; }
1332 };
1333
1334
1335 class LStoreGlobalGeneric: public LTemplateInstruction<0, 3, 0> {
1336  public:
1337   LStoreGlobalGeneric(LOperand* context,
1338                       LOperand* global_object,
1339                       LOperand* value) {
1340     inputs_[0] = context;
1341     inputs_[1] = global_object;
1342     inputs_[2] = value;
1343   }
1344
1345   DECLARE_CONCRETE_INSTRUCTION(StoreGlobalGeneric, "store-global-generic")
1346   DECLARE_HYDROGEN_ACCESSOR(StoreGlobalGeneric)
1347
1348   LOperand* context() { return InputAt(0); }
1349   LOperand* global_object() { return InputAt(1); }
1350   Handle<Object> name() const { return hydrogen()->name(); }
1351   LOperand* value() { return InputAt(2); }
1352   StrictModeFlag strict_mode_flag() { return hydrogen()->strict_mode_flag(); }
1353 };
1354
1355
1356 class LLoadContextSlot: public LTemplateInstruction<1, 1, 0> {
1357  public:
1358   explicit LLoadContextSlot(LOperand* context) {
1359     inputs_[0] = context;
1360   }
1361
1362   DECLARE_CONCRETE_INSTRUCTION(LoadContextSlot, "load-context-slot")
1363   DECLARE_HYDROGEN_ACCESSOR(LoadContextSlot)
1364
1365   LOperand* context() { return InputAt(0); }
1366   int slot_index() { return hydrogen()->slot_index(); }
1367
1368   virtual void PrintDataTo(StringStream* stream);
1369 };
1370
1371
1372 class LStoreContextSlot: public LTemplateInstruction<0, 2, 1> {
1373  public:
1374   LStoreContextSlot(LOperand* context, LOperand* value, LOperand* temp) {
1375     inputs_[0] = context;
1376     inputs_[1] = value;
1377     temps_[0] = temp;
1378   }
1379
1380   DECLARE_CONCRETE_INSTRUCTION(StoreContextSlot, "store-context-slot")
1381   DECLARE_HYDROGEN_ACCESSOR(StoreContextSlot)
1382
1383   LOperand* context() { return InputAt(0); }
1384   LOperand* value() { return InputAt(1); }
1385   int slot_index() { return hydrogen()->slot_index(); }
1386
1387   virtual void PrintDataTo(StringStream* stream);
1388 };
1389
1390
1391 class LPushArgument: public LTemplateInstruction<0, 1, 0> {
1392  public:
1393   explicit LPushArgument(LOperand* value) {
1394     inputs_[0] = value;
1395   }
1396
1397   DECLARE_CONCRETE_INSTRUCTION(PushArgument, "push-argument")
1398 };
1399
1400
1401 class LDrop: public LTemplateInstruction<0, 0, 0> {
1402  public:
1403   explicit LDrop(int count) : count_(count) { }
1404
1405   int count() const { return count_; }
1406
1407   DECLARE_CONCRETE_INSTRUCTION(Drop, "drop")
1408
1409  private:
1410   int count_;
1411 };
1412
1413
1414 class LThisFunction: public LTemplateInstruction<1, 0, 0> {
1415  public:
1416   DECLARE_CONCRETE_INSTRUCTION(ThisFunction, "this-function")
1417   DECLARE_HYDROGEN_ACCESSOR(ThisFunction)
1418 };
1419
1420
1421 class LContext: public LTemplateInstruction<1, 0, 0> {
1422  public:
1423   DECLARE_CONCRETE_INSTRUCTION(Context, "context")
1424 };
1425
1426
1427 class LOuterContext: public LTemplateInstruction<1, 1, 0> {
1428  public:
1429   explicit LOuterContext(LOperand* context) {
1430     inputs_[0] = context;
1431   }
1432
1433   DECLARE_CONCRETE_INSTRUCTION(OuterContext, "outer-context")
1434
1435   LOperand* context() { return InputAt(0); }
1436 };
1437
1438
1439 class LDeclareGlobals: public LTemplateInstruction<0, 1, 0> {
1440  public:
1441   explicit LDeclareGlobals(LOperand* context) {
1442     inputs_[0] = context;
1443   }
1444
1445   DECLARE_CONCRETE_INSTRUCTION(DeclareGlobals, "declare-globals")
1446   DECLARE_HYDROGEN_ACCESSOR(DeclareGlobals)
1447 };
1448
1449
1450 class LGlobalObject: public LTemplateInstruction<1, 1, 0> {
1451  public:
1452   explicit LGlobalObject(LOperand* context, bool qml_global) {
1453     inputs_[0] = context;
1454     qml_global_ = qml_global;
1455   }
1456
1457   DECLARE_CONCRETE_INSTRUCTION(GlobalObject, "global-object")
1458
1459   LOperand* context() { return InputAt(0); }
1460   bool qml_global() { return qml_global_; }
1461  private:
1462   bool qml_global_;
1463 };
1464
1465
1466 class LGlobalReceiver: public LTemplateInstruction<1, 1, 0> {
1467  public:
1468   explicit LGlobalReceiver(LOperand* global_object) {
1469     inputs_[0] = global_object;
1470   }
1471
1472   DECLARE_CONCRETE_INSTRUCTION(GlobalReceiver, "global-receiver")
1473
1474   LOperand* global() { return InputAt(0); }
1475 };
1476
1477
1478 class LCallConstantFunction: public LTemplateInstruction<1, 0, 0> {
1479  public:
1480   DECLARE_CONCRETE_INSTRUCTION(CallConstantFunction, "call-constant-function")
1481   DECLARE_HYDROGEN_ACCESSOR(CallConstantFunction)
1482
1483   virtual void PrintDataTo(StringStream* stream);
1484
1485   Handle<JSFunction> function() { return hydrogen()->function(); }
1486   int arity() const { return hydrogen()->argument_count() - 1; }
1487 };
1488
1489
1490 class LInvokeFunction: public LTemplateInstruction<1, 2, 0> {
1491  public:
1492   LInvokeFunction(LOperand* context, LOperand* function) {
1493     inputs_[0] = context;
1494     inputs_[1] = function;
1495   }
1496
1497   DECLARE_CONCRETE_INSTRUCTION(InvokeFunction, "invoke-function")
1498   DECLARE_HYDROGEN_ACCESSOR(InvokeFunction)
1499
1500   LOperand* context() { return inputs_[0]; }
1501   LOperand* function() { return inputs_[1]; }
1502
1503   virtual void PrintDataTo(StringStream* stream);
1504
1505   int arity() const { return hydrogen()->argument_count() - 1; }
1506   Handle<JSFunction> known_function() { return hydrogen()->known_function(); }
1507 };
1508
1509
1510 class LCallKeyed: public LTemplateInstruction<1, 2, 0> {
1511  public:
1512   LCallKeyed(LOperand* context, LOperand* key) {
1513     inputs_[0] = context;
1514     inputs_[1] = key;
1515   }
1516
1517   DECLARE_CONCRETE_INSTRUCTION(CallKeyed, "call-keyed")
1518   DECLARE_HYDROGEN_ACCESSOR(CallKeyed)
1519
1520   LOperand* context() { return inputs_[0]; }
1521   LOperand* key() { return inputs_[1]; }
1522
1523   virtual void PrintDataTo(StringStream* stream);
1524
1525   int arity() const { return hydrogen()->argument_count() - 1; }
1526 };
1527
1528
1529 class LCallNamed: public LTemplateInstruction<1, 1, 0> {
1530  public:
1531   explicit LCallNamed(LOperand* context) {
1532     inputs_[0] = context;
1533   }
1534
1535   DECLARE_CONCRETE_INSTRUCTION(CallNamed, "call-named")
1536   DECLARE_HYDROGEN_ACCESSOR(CallNamed)
1537
1538   virtual void PrintDataTo(StringStream* stream);
1539
1540   LOperand* context() { return inputs_[0]; }
1541   Handle<String> name() const { return hydrogen()->name(); }
1542   int arity() const { return hydrogen()->argument_count() - 1; }
1543 };
1544
1545
1546 class LCallFunction: public LTemplateInstruction<1, 2, 0> {
1547  public:
1548   explicit LCallFunction(LOperand* context, LOperand* function) {
1549     inputs_[0] = context;
1550     inputs_[1] = function;
1551   }
1552
1553   DECLARE_CONCRETE_INSTRUCTION(CallFunction, "call-function")
1554   DECLARE_HYDROGEN_ACCESSOR(CallFunction)
1555
1556   LOperand* context() { return inputs_[0]; }
1557   LOperand* function() { return inputs_[1]; }
1558   int arity() const { return hydrogen()->argument_count() - 1; }
1559 };
1560
1561
1562 class LCallGlobal: public LTemplateInstruction<1, 1, 0> {
1563  public:
1564   explicit LCallGlobal(LOperand* context, bool qml_global) : qml_global_(qml_global) {
1565     inputs_[0] = context;
1566   }
1567
1568   DECLARE_CONCRETE_INSTRUCTION(CallGlobal, "call-global")
1569   DECLARE_HYDROGEN_ACCESSOR(CallGlobal)
1570
1571   virtual void PrintDataTo(StringStream* stream);
1572
1573   LOperand* context() { return inputs_[0]; }
1574   Handle<String> name() const {return hydrogen()->name(); }
1575   int arity() const { return hydrogen()->argument_count() - 1; }
1576
1577   bool qml_global() { return qml_global_; }
1578  private:
1579   bool qml_global_;
1580 };
1581
1582
1583 class LCallKnownGlobal: public LTemplateInstruction<1, 0, 0> {
1584  public:
1585   DECLARE_CONCRETE_INSTRUCTION(CallKnownGlobal, "call-known-global")
1586   DECLARE_HYDROGEN_ACCESSOR(CallKnownGlobal)
1587
1588   virtual void PrintDataTo(StringStream* stream);
1589
1590   Handle<JSFunction> target() const { return hydrogen()->target();  }
1591   int arity() const { return hydrogen()->argument_count() - 1;  }
1592 };
1593
1594
1595 class LCallNew: public LTemplateInstruction<1, 2, 0> {
1596  public:
1597   LCallNew(LOperand* context, LOperand* constructor) {
1598     inputs_[0] = context;
1599     inputs_[1] = constructor;
1600   }
1601
1602   DECLARE_CONCRETE_INSTRUCTION(CallNew, "call-new")
1603   DECLARE_HYDROGEN_ACCESSOR(CallNew)
1604
1605   virtual void PrintDataTo(StringStream* stream);
1606
1607   LOperand* context() { return inputs_[0]; }
1608   LOperand* constructor() { return inputs_[1]; }
1609   int arity() const { return hydrogen()->argument_count() - 1; }
1610 };
1611
1612
1613 class LCallRuntime: public LTemplateInstruction<1, 1, 0> {
1614  public:
1615   explicit LCallRuntime(LOperand* context) {
1616     inputs_[0] = context;
1617   }
1618   DECLARE_CONCRETE_INSTRUCTION(CallRuntime, "call-runtime")
1619   DECLARE_HYDROGEN_ACCESSOR(CallRuntime)
1620
1621   LOperand* context() { return inputs_[0]; }
1622   const Runtime::Function* function() const { return hydrogen()->function(); }
1623   int arity() const { return hydrogen()->argument_count(); }
1624 };
1625
1626
1627 class LInteger32ToDouble: public LTemplateInstruction<1, 1, 0> {
1628  public:
1629   explicit LInteger32ToDouble(LOperand* value) {
1630     inputs_[0] = value;
1631   }
1632
1633   DECLARE_CONCRETE_INSTRUCTION(Integer32ToDouble, "int32-to-double")
1634 };
1635
1636
1637 class LNumberTagI: public LTemplateInstruction<1, 1, 0> {
1638  public:
1639   explicit LNumberTagI(LOperand* value) {
1640     inputs_[0] = value;
1641   }
1642
1643   DECLARE_CONCRETE_INSTRUCTION(NumberTagI, "number-tag-i")
1644 };
1645
1646
1647 class LNumberTagD: public LTemplateInstruction<1, 1, 1> {
1648  public:
1649   LNumberTagD(LOperand* value, LOperand* temp) {
1650     inputs_[0] = value;
1651     temps_[0] = temp;
1652   }
1653
1654   DECLARE_CONCRETE_INSTRUCTION(NumberTagD, "number-tag-d")
1655 };
1656
1657
1658 // Sometimes truncating conversion from a tagged value to an int32.
1659 class LDoubleToI: public LTemplateInstruction<1, 1, 1> {
1660  public:
1661   LDoubleToI(LOperand* value, LOperand* temp) {
1662     inputs_[0] = value;
1663     temps_[0] = temp;
1664   }
1665
1666   DECLARE_CONCRETE_INSTRUCTION(DoubleToI, "double-to-i")
1667   DECLARE_HYDROGEN_ACCESSOR(UnaryOperation)
1668
1669   bool truncating() { return hydrogen()->CanTruncateToInt32(); }
1670 };
1671
1672
1673 // Truncating conversion from a tagged value to an int32.
1674 class LTaggedToI: public LTemplateInstruction<1, 1, 1> {
1675  public:
1676   LTaggedToI(LOperand* value, LOperand* temp) {
1677     inputs_[0] = value;
1678     temps_[0] = temp;
1679   }
1680
1681   DECLARE_CONCRETE_INSTRUCTION(TaggedToI, "tagged-to-i")
1682   DECLARE_HYDROGEN_ACCESSOR(UnaryOperation)
1683
1684   bool truncating() { return hydrogen()->CanTruncateToInt32(); }
1685 };
1686
1687
1688 class LSmiTag: public LTemplateInstruction<1, 1, 0> {
1689  public:
1690   explicit LSmiTag(LOperand* value) {
1691     inputs_[0] = value;
1692   }
1693
1694   DECLARE_CONCRETE_INSTRUCTION(SmiTag, "smi-tag")
1695 };
1696
1697
1698 class LNumberUntagD: public LTemplateInstruction<1, 1, 1> {
1699  public:
1700   explicit LNumberUntagD(LOperand* value, LOperand* temp) {
1701     inputs_[0] = value;
1702     temps_[0] = temp;
1703   }
1704
1705   DECLARE_CONCRETE_INSTRUCTION(NumberUntagD, "double-untag")
1706   DECLARE_HYDROGEN_ACCESSOR(Change);
1707 };
1708
1709
1710 class LSmiUntag: public LTemplateInstruction<1, 1, 0> {
1711  public:
1712   LSmiUntag(LOperand* value, bool needs_check)
1713       : needs_check_(needs_check) {
1714     inputs_[0] = value;
1715   }
1716
1717   DECLARE_CONCRETE_INSTRUCTION(SmiUntag, "smi-untag")
1718
1719   bool needs_check() const { return needs_check_; }
1720
1721  private:
1722   bool needs_check_;
1723 };
1724
1725
1726 class LStoreNamedField: public LTemplateInstruction<0, 2, 1> {
1727  public:
1728   LStoreNamedField(LOperand* obj, LOperand* val, LOperand* temp) {
1729     inputs_[0] = obj;
1730     inputs_[1] = val;
1731     temps_[0] = temp;
1732   }
1733
1734   DECLARE_CONCRETE_INSTRUCTION(StoreNamedField, "store-named-field")
1735   DECLARE_HYDROGEN_ACCESSOR(StoreNamedField)
1736
1737   virtual void PrintDataTo(StringStream* stream);
1738
1739   LOperand* object() { return inputs_[0]; }
1740   LOperand* value() { return inputs_[1]; }
1741
1742   Handle<Object> name() const { return hydrogen()->name(); }
1743   bool is_in_object() { return hydrogen()->is_in_object(); }
1744   int offset() { return hydrogen()->offset(); }
1745   Handle<Map> transition() const { return hydrogen()->transition(); }
1746 };
1747
1748
1749 class LStoreNamedGeneric: public LTemplateInstruction<0, 3, 0> {
1750  public:
1751   LStoreNamedGeneric(LOperand* context, LOperand* object, LOperand* value) {
1752     inputs_[0] = context;
1753     inputs_[1] = object;
1754     inputs_[2] = value;
1755   }
1756
1757   DECLARE_CONCRETE_INSTRUCTION(StoreNamedGeneric, "store-named-generic")
1758   DECLARE_HYDROGEN_ACCESSOR(StoreNamedGeneric)
1759
1760   virtual void PrintDataTo(StringStream* stream);
1761
1762   LOperand* context() { return inputs_[0]; }
1763   LOperand* object() { return inputs_[1]; }
1764   LOperand* value() { return inputs_[2]; }
1765   Handle<Object> name() const { return hydrogen()->name(); }
1766   StrictModeFlag strict_mode_flag() { return hydrogen()->strict_mode_flag(); }
1767 };
1768
1769
1770 class LStoreKeyedFastElement: public LTemplateInstruction<0, 3, 0> {
1771  public:
1772   LStoreKeyedFastElement(LOperand* obj, LOperand* key, LOperand* val) {
1773     inputs_[0] = obj;
1774     inputs_[1] = key;
1775     inputs_[2] = val;
1776   }
1777
1778   DECLARE_CONCRETE_INSTRUCTION(StoreKeyedFastElement,
1779                                "store-keyed-fast-element")
1780   DECLARE_HYDROGEN_ACCESSOR(StoreKeyedFastElement)
1781
1782   virtual void PrintDataTo(StringStream* stream);
1783
1784   LOperand* object() { return inputs_[0]; }
1785   LOperand* key() { return inputs_[1]; }
1786   LOperand* value() { return inputs_[2]; }
1787   uint32_t additional_index() const { return hydrogen()->index_offset(); }
1788 };
1789
1790
1791 class LStoreKeyedFastDoubleElement: public LTemplateInstruction<0, 3, 0> {
1792  public:
1793   LStoreKeyedFastDoubleElement(LOperand* elements,
1794                                LOperand* key,
1795                                LOperand* val) {
1796     inputs_[0] = elements;
1797     inputs_[1] = key;
1798     inputs_[2] = val;
1799   }
1800
1801   DECLARE_CONCRETE_INSTRUCTION(StoreKeyedFastDoubleElement,
1802                                "store-keyed-fast-double-element")
1803   DECLARE_HYDROGEN_ACCESSOR(StoreKeyedFastDoubleElement)
1804
1805   virtual void PrintDataTo(StringStream* stream);
1806
1807   LOperand* elements() { return inputs_[0]; }
1808   LOperand* key() { return inputs_[1]; }
1809   LOperand* value() { return inputs_[2]; }
1810   uint32_t additional_index() const { return hydrogen()->index_offset(); }
1811
1812   bool NeedsCanonicalization() { return hydrogen()->NeedsCanonicalization(); }
1813 };
1814
1815
1816 class LStoreKeyedSpecializedArrayElement: public LTemplateInstruction<0, 3, 0> {
1817  public:
1818   LStoreKeyedSpecializedArrayElement(LOperand* external_pointer,
1819                                      LOperand* key,
1820                                      LOperand* val) {
1821     inputs_[0] = external_pointer;
1822     inputs_[1] = key;
1823     inputs_[2] = val;
1824   }
1825
1826   DECLARE_CONCRETE_INSTRUCTION(StoreKeyedSpecializedArrayElement,
1827                                "store-keyed-specialized-array-element")
1828   DECLARE_HYDROGEN_ACCESSOR(StoreKeyedSpecializedArrayElement)
1829
1830   LOperand* external_pointer() { return inputs_[0]; }
1831   LOperand* key() { return inputs_[1]; }
1832   LOperand* value() { return inputs_[2]; }
1833   ElementsKind elements_kind() const {
1834     return hydrogen()->elements_kind();
1835   }
1836   uint32_t additional_index() const { return hydrogen()->index_offset(); }
1837 };
1838
1839
1840 class LStoreKeyedGeneric: public LTemplateInstruction<0, 4, 0> {
1841  public:
1842   LStoreKeyedGeneric(LOperand* context,
1843                      LOperand* object,
1844                      LOperand* key,
1845                      LOperand* value) {
1846     inputs_[0] = context;
1847     inputs_[1] = object;
1848     inputs_[2] = key;
1849     inputs_[3] = value;
1850   }
1851
1852   DECLARE_CONCRETE_INSTRUCTION(StoreKeyedGeneric, "store-keyed-generic")
1853   DECLARE_HYDROGEN_ACCESSOR(StoreKeyedGeneric)
1854
1855   virtual void PrintDataTo(StringStream* stream);
1856
1857   LOperand* context() { return inputs_[0]; }
1858   LOperand* object() { return inputs_[1]; }
1859   LOperand* key() { return inputs_[2]; }
1860   LOperand* value() { return inputs_[3]; }
1861   StrictModeFlag strict_mode_flag() { return hydrogen()->strict_mode_flag(); }
1862 };
1863
1864
1865 class LTransitionElementsKind: public LTemplateInstruction<1, 1, 2> {
1866  public:
1867   LTransitionElementsKind(LOperand* object,
1868                           LOperand* new_map_temp,
1869                           LOperand* temp_reg) {
1870     inputs_[0] = object;
1871     temps_[0] = new_map_temp;
1872     temps_[1] = temp_reg;
1873   }
1874
1875   DECLARE_CONCRETE_INSTRUCTION(TransitionElementsKind,
1876                                "transition-elements-kind")
1877   DECLARE_HYDROGEN_ACCESSOR(TransitionElementsKind)
1878
1879   virtual void PrintDataTo(StringStream* stream);
1880
1881   LOperand* object() { return inputs_[0]; }
1882   LOperand* new_map_reg() { return temps_[0]; }
1883   LOperand* temp_reg() { return temps_[1]; }
1884   Handle<Map> original_map() { return hydrogen()->original_map(); }
1885   Handle<Map> transitioned_map() { return hydrogen()->transitioned_map(); }
1886 };
1887
1888
1889 class LStringAdd: public LTemplateInstruction<1, 3, 0> {
1890  public:
1891   LStringAdd(LOperand* context, LOperand* left, LOperand* right) {
1892     inputs_[0] = context;
1893     inputs_[1] = left;
1894     inputs_[2] = right;
1895   }
1896
1897   DECLARE_CONCRETE_INSTRUCTION(StringAdd, "string-add")
1898   DECLARE_HYDROGEN_ACCESSOR(StringAdd)
1899
1900   LOperand* context() { return inputs_[0]; }
1901   LOperand* left() { return inputs_[1]; }
1902   LOperand* right() { return inputs_[2]; }
1903 };
1904
1905
1906 class LStringCharCodeAt: public LTemplateInstruction<1, 3, 0> {
1907  public:
1908   LStringCharCodeAt(LOperand* context, LOperand* string, LOperand* index) {
1909     inputs_[0] = context;
1910     inputs_[1] = string;
1911     inputs_[2] = index;
1912   }
1913
1914   DECLARE_CONCRETE_INSTRUCTION(StringCharCodeAt, "string-char-code-at")
1915   DECLARE_HYDROGEN_ACCESSOR(StringCharCodeAt)
1916
1917   LOperand* context() { return inputs_[0]; }
1918   LOperand* string() { return inputs_[1]; }
1919   LOperand* index() { return inputs_[2]; }
1920 };
1921
1922
1923 class LStringCharFromCode: public LTemplateInstruction<1, 2, 0> {
1924  public:
1925   LStringCharFromCode(LOperand* context, LOperand* char_code) {
1926     inputs_[0] = context;
1927     inputs_[1] = char_code;
1928   }
1929
1930   DECLARE_CONCRETE_INSTRUCTION(StringCharFromCode, "string-char-from-code")
1931   DECLARE_HYDROGEN_ACCESSOR(StringCharFromCode)
1932
1933   LOperand* context() { return inputs_[0]; }
1934   LOperand* char_code() { return inputs_[1]; }
1935 };
1936
1937
1938 class LStringLength: public LTemplateInstruction<1, 1, 0> {
1939  public:
1940   explicit LStringLength(LOperand* string) {
1941     inputs_[0] = string;
1942   }
1943
1944   DECLARE_CONCRETE_INSTRUCTION(StringLength, "string-length")
1945   DECLARE_HYDROGEN_ACCESSOR(StringLength)
1946
1947   LOperand* string() { return inputs_[0]; }
1948 };
1949
1950
1951 class LCheckFunction: public LTemplateInstruction<0, 1, 0> {
1952  public:
1953   explicit LCheckFunction(LOperand* value) {
1954     inputs_[0] = value;
1955   }
1956
1957   LOperand* value() { return inputs_[0]; }
1958
1959   DECLARE_CONCRETE_INSTRUCTION(CheckFunction, "check-function")
1960   DECLARE_HYDROGEN_ACCESSOR(CheckFunction)
1961 };
1962
1963
1964 class LCheckInstanceType: public LTemplateInstruction<0, 1, 1> {
1965  public:
1966   LCheckInstanceType(LOperand* value, LOperand* temp) {
1967     inputs_[0] = value;
1968     temps_[0] = temp;
1969   }
1970
1971   DECLARE_CONCRETE_INSTRUCTION(CheckInstanceType, "check-instance-type")
1972   DECLARE_HYDROGEN_ACCESSOR(CheckInstanceType)
1973 };
1974
1975
1976 class LCheckMaps: public LTemplateInstruction<0, 1, 0> {
1977  public:
1978   explicit LCheckMaps(LOperand* value) {
1979     inputs_[0] = value;
1980   }
1981
1982   DECLARE_CONCRETE_INSTRUCTION(CheckMaps, "check-maps")
1983   DECLARE_HYDROGEN_ACCESSOR(CheckMaps)
1984 };
1985
1986
1987 class LCheckPrototypeMaps: public LTemplateInstruction<0, 0, 1> {
1988  public:
1989   explicit LCheckPrototypeMaps(LOperand* temp)  {
1990     temps_[0] = temp;
1991   }
1992
1993   DECLARE_CONCRETE_INSTRUCTION(CheckPrototypeMaps, "check-prototype-maps")
1994   DECLARE_HYDROGEN_ACCESSOR(CheckPrototypeMaps)
1995
1996   Handle<JSObject> prototype() const { return hydrogen()->prototype(); }
1997   Handle<JSObject> holder() const { return hydrogen()->holder(); }
1998 };
1999
2000
2001 class LCheckSmi: public LTemplateInstruction<0, 1, 0> {
2002  public:
2003   explicit LCheckSmi(LOperand* value) {
2004     inputs_[0] = value;
2005   }
2006
2007   DECLARE_CONCRETE_INSTRUCTION(CheckSmi, "check-smi")
2008 };
2009
2010
2011 class LClampDToUint8: public LTemplateInstruction<1, 1, 0> {
2012  public:
2013   explicit LClampDToUint8(LOperand* value) {
2014     inputs_[0] = value;
2015   }
2016
2017   LOperand* unclamped() { return inputs_[0]; }
2018
2019   DECLARE_CONCRETE_INSTRUCTION(ClampDToUint8, "clamp-d-to-uint8")
2020 };
2021
2022
2023 class LClampIToUint8: public LTemplateInstruction<1, 1, 0> {
2024  public:
2025   explicit LClampIToUint8(LOperand* value) {
2026     inputs_[0] = value;
2027   }
2028
2029   LOperand* unclamped() { return inputs_[0]; }
2030
2031   DECLARE_CONCRETE_INSTRUCTION(ClampIToUint8, "clamp-i-to-uint8")
2032 };
2033
2034
2035 class LClampTToUint8: public LTemplateInstruction<1, 1, 1> {
2036  public:
2037   LClampTToUint8(LOperand* value, LOperand* temp) {
2038     inputs_[0] = value;
2039     temps_[0] = temp;
2040   }
2041
2042   LOperand* unclamped() { return inputs_[0]; }
2043
2044   DECLARE_CONCRETE_INSTRUCTION(ClampTToUint8, "clamp-t-to-uint8")
2045 };
2046
2047
2048 class LCheckNonSmi: public LTemplateInstruction<0, 1, 0> {
2049  public:
2050   explicit LCheckNonSmi(LOperand* value) {
2051     inputs_[0] = value;
2052   }
2053
2054   DECLARE_CONCRETE_INSTRUCTION(CheckNonSmi, "check-non-smi")
2055 };
2056
2057
2058 class LAllocateObject: public LTemplateInstruction<1, 1, 1> {
2059  public:
2060   LAllocateObject(LOperand* context, LOperand* temp) {
2061     inputs_[0] = context;
2062     temps_[0] = temp;
2063   }
2064
2065   DECLARE_CONCRETE_INSTRUCTION(AllocateObject, "allocate-object")
2066   DECLARE_HYDROGEN_ACCESSOR(AllocateObject)
2067
2068   LOperand* context() { return inputs_[0]; }
2069 };
2070
2071
2072 class LFastLiteral: public LTemplateInstruction<1, 1, 0> {
2073  public:
2074   explicit LFastLiteral(LOperand* context) {
2075     inputs_[0] = context;
2076   }
2077
2078   LOperand* context() { return inputs_[0]; }
2079
2080   DECLARE_CONCRETE_INSTRUCTION(FastLiteral, "fast-literal")
2081   DECLARE_HYDROGEN_ACCESSOR(FastLiteral)
2082 };
2083
2084
2085 class LArrayLiteral: public LTemplateInstruction<1, 1, 0> {
2086  public:
2087   explicit LArrayLiteral(LOperand* context) {
2088     inputs_[0] = context;
2089   }
2090
2091   LOperand* context() { return inputs_[0]; }
2092
2093   DECLARE_CONCRETE_INSTRUCTION(ArrayLiteral, "array-literal")
2094   DECLARE_HYDROGEN_ACCESSOR(ArrayLiteral)
2095 };
2096
2097
2098 class LObjectLiteral: public LTemplateInstruction<1, 1, 0> {
2099  public:
2100   explicit LObjectLiteral(LOperand* context) {
2101     inputs_[0] = context;
2102   }
2103
2104   LOperand* context() { return inputs_[0]; }
2105
2106   DECLARE_CONCRETE_INSTRUCTION(ObjectLiteral, "object-literal")
2107   DECLARE_HYDROGEN_ACCESSOR(ObjectLiteral)
2108 };
2109
2110
2111 class LRegExpLiteral: public LTemplateInstruction<1, 1, 0> {
2112  public:
2113   explicit LRegExpLiteral(LOperand* context) {
2114     inputs_[0] = context;
2115   }
2116
2117   LOperand* context() { return inputs_[0]; }
2118
2119   DECLARE_CONCRETE_INSTRUCTION(RegExpLiteral, "regexp-literal")
2120   DECLARE_HYDROGEN_ACCESSOR(RegExpLiteral)
2121 };
2122
2123
2124 class LFunctionLiteral: public LTemplateInstruction<1, 1, 0> {
2125  public:
2126   explicit LFunctionLiteral(LOperand* context) {
2127     inputs_[0] = context;
2128   }
2129
2130   LOperand* context() { return inputs_[0]; }
2131
2132   DECLARE_CONCRETE_INSTRUCTION(FunctionLiteral, "function-literal")
2133   DECLARE_HYDROGEN_ACCESSOR(FunctionLiteral)
2134
2135   Handle<SharedFunctionInfo> shared_info() { return hydrogen()->shared_info(); }
2136 };
2137
2138
2139 class LToFastProperties: public LTemplateInstruction<1, 1, 0> {
2140  public:
2141   explicit LToFastProperties(LOperand* value) {
2142     inputs_[0] = value;
2143   }
2144
2145   DECLARE_CONCRETE_INSTRUCTION(ToFastProperties, "to-fast-properties")
2146   DECLARE_HYDROGEN_ACCESSOR(ToFastProperties)
2147 };
2148
2149
2150 class LTypeof: public LTemplateInstruction<1, 2, 0> {
2151  public:
2152   LTypeof(LOperand* context, LOperand* value) {
2153     inputs_[0] = context;
2154     inputs_[1] = value;
2155   }
2156
2157   DECLARE_CONCRETE_INSTRUCTION(Typeof, "typeof")
2158 };
2159
2160
2161 class LTypeofIsAndBranch: public LControlInstruction<1, 0> {
2162  public:
2163   explicit LTypeofIsAndBranch(LOperand* value) {
2164     inputs_[0] = value;
2165   }
2166
2167   DECLARE_CONCRETE_INSTRUCTION(TypeofIsAndBranch, "typeof-is-and-branch")
2168   DECLARE_HYDROGEN_ACCESSOR(TypeofIsAndBranch)
2169
2170   Handle<String> type_literal() { return hydrogen()->type_literal(); }
2171
2172   virtual void PrintDataTo(StringStream* stream);
2173 };
2174
2175
2176 class LDeleteProperty: public LTemplateInstruction<1, 3, 0> {
2177  public:
2178   LDeleteProperty(LOperand* context, LOperand* obj, LOperand* key) {
2179     inputs_[0] = context;
2180     inputs_[1] = obj;
2181     inputs_[2] = key;
2182   }
2183
2184   DECLARE_CONCRETE_INSTRUCTION(DeleteProperty, "delete-property")
2185
2186   LOperand* context() { return inputs_[0]; }
2187   LOperand* object() { return inputs_[1]; }
2188   LOperand* key() { return inputs_[2]; }
2189 };
2190
2191
2192 class LOsrEntry: public LTemplateInstruction<0, 0, 0> {
2193  public:
2194   LOsrEntry();
2195
2196   DECLARE_CONCRETE_INSTRUCTION(OsrEntry, "osr-entry")
2197
2198   LOperand** SpilledRegisterArray() { return register_spills_; }
2199   LOperand** SpilledDoubleRegisterArray() { return double_register_spills_; }
2200
2201   void MarkSpilledRegister(int allocation_index, LOperand* spill_operand);
2202   void MarkSpilledDoubleRegister(int allocation_index,
2203                                  LOperand* spill_operand);
2204
2205  private:
2206   // Arrays of spill slot operands for registers with an assigned spill
2207   // slot, i.e., that must also be restored to the spill slot on OSR entry.
2208   // NULL if the register has no assigned spill slot.  Indexed by allocation
2209   // index.
2210   LOperand* register_spills_[Register::kNumAllocatableRegisters];
2211   LOperand* double_register_spills_[DoubleRegister::kNumAllocatableRegisters];
2212 };
2213
2214
2215 class LStackCheck: public LTemplateInstruction<0, 1, 0> {
2216  public:
2217   explicit LStackCheck(LOperand* context) {
2218     inputs_[0] = context;
2219   }
2220
2221   LOperand* context() { return inputs_[0]; }
2222
2223   DECLARE_CONCRETE_INSTRUCTION(StackCheck, "stack-check")
2224   DECLARE_HYDROGEN_ACCESSOR(StackCheck)
2225
2226   Label* done_label() { return &done_label_; }
2227
2228  private:
2229   Label done_label_;
2230 };
2231
2232
2233 class LIn: public LTemplateInstruction<1, 3, 0> {
2234  public:
2235   LIn(LOperand* context, LOperand* key, LOperand* object) {
2236     inputs_[0] = context;
2237     inputs_[1] = key;
2238     inputs_[2] = object;
2239   }
2240
2241   LOperand* context() { return inputs_[0]; }
2242   LOperand* key() { return inputs_[1]; }
2243   LOperand* object() { return inputs_[2]; }
2244
2245   DECLARE_CONCRETE_INSTRUCTION(In, "in")
2246 };
2247
2248
2249 class LForInPrepareMap: public LTemplateInstruction<1, 2, 0> {
2250  public:
2251   LForInPrepareMap(LOperand* context, LOperand* object) {
2252     inputs_[0] = context;
2253     inputs_[1] = object;
2254   }
2255
2256   LOperand* context() { return inputs_[0]; }
2257   LOperand* object() { return inputs_[1]; }
2258
2259   DECLARE_CONCRETE_INSTRUCTION(ForInPrepareMap, "for-in-prepare-map")
2260 };
2261
2262
2263 class LForInCacheArray: public LTemplateInstruction<1, 1, 0> {
2264  public:
2265   explicit LForInCacheArray(LOperand* map) {
2266     inputs_[0] = map;
2267   }
2268
2269   LOperand* map() { return inputs_[0]; }
2270
2271   DECLARE_CONCRETE_INSTRUCTION(ForInCacheArray, "for-in-cache-array")
2272
2273   int idx() {
2274     return HForInCacheArray::cast(this->hydrogen_value())->idx();
2275   }
2276 };
2277
2278
2279 class LCheckMapValue: public LTemplateInstruction<0, 2, 0> {
2280  public:
2281   LCheckMapValue(LOperand* value, LOperand* map) {
2282     inputs_[0] = value;
2283     inputs_[1] = map;
2284   }
2285
2286   LOperand* value() { return inputs_[0]; }
2287   LOperand* map() { return inputs_[1]; }
2288
2289   DECLARE_CONCRETE_INSTRUCTION(CheckMapValue, "check-map-value")
2290 };
2291
2292
2293 class LLoadFieldByIndex: public LTemplateInstruction<1, 2, 0> {
2294  public:
2295   LLoadFieldByIndex(LOperand* object, LOperand* index) {
2296     inputs_[0] = object;
2297     inputs_[1] = index;
2298   }
2299
2300   LOperand* object() { return inputs_[0]; }
2301   LOperand* index() { return inputs_[1]; }
2302
2303   DECLARE_CONCRETE_INSTRUCTION(LoadFieldByIndex, "load-field-by-index")
2304 };
2305
2306
2307 class LChunkBuilder;
2308 class LChunk: public ZoneObject {
2309  public:
2310   LChunk(CompilationInfo* info, HGraph* graph)
2311     : spill_slot_count_(0),
2312       info_(info),
2313       graph_(graph),
2314       instructions_(32),
2315       pointer_maps_(8),
2316       inlined_closures_(1) { }
2317
2318   void AddInstruction(LInstruction* instruction, HBasicBlock* block);
2319   LConstantOperand* DefineConstantOperand(HConstant* constant);
2320   Handle<Object> LookupLiteral(LConstantOperand* operand) const;
2321   Representation LookupLiteralRepresentation(LConstantOperand* operand) const;
2322
2323   int GetNextSpillIndex(bool is_double);
2324   LOperand* GetNextSpillSlot(bool is_double);
2325
2326   int ParameterAt(int index);
2327   int GetParameterStackSlot(int index) const;
2328   int spill_slot_count() const { return spill_slot_count_; }
2329   CompilationInfo* info() const { return info_; }
2330   HGraph* graph() const { return graph_; }
2331   const ZoneList<LInstruction*>* instructions() const { return &instructions_; }
2332   void AddGapMove(int index, LOperand* from, LOperand* to);
2333   LGap* GetGapAt(int index) const;
2334   bool IsGapAt(int index) const;
2335   int NearestGapPos(int index) const;
2336   void MarkEmptyBlocks();
2337   const ZoneList<LPointerMap*>* pointer_maps() const { return &pointer_maps_; }
2338   LLabel* GetLabel(int block_id) const {
2339     HBasicBlock* block = graph_->blocks()->at(block_id);
2340     int first_instruction = block->first_instruction_index();
2341     return LLabel::cast(instructions_[first_instruction]);
2342   }
2343   int LookupDestination(int block_id) const {
2344     LLabel* cur = GetLabel(block_id);
2345     while (cur->replacement() != NULL) {
2346       cur = cur->replacement();
2347     }
2348     return cur->block_id();
2349   }
2350   Label* GetAssemblyLabel(int block_id) const {
2351     LLabel* label = GetLabel(block_id);
2352     ASSERT(!label->HasReplacement());
2353     return label->label();
2354   }
2355
2356   const ZoneList<Handle<JSFunction> >* inlined_closures() const {
2357     return &inlined_closures_;
2358   }
2359
2360   void AddInlinedClosure(Handle<JSFunction> closure) {
2361     inlined_closures_.Add(closure);
2362   }
2363
2364  private:
2365   int spill_slot_count_;
2366   CompilationInfo* info_;
2367   HGraph* const graph_;
2368   ZoneList<LInstruction*> instructions_;
2369   ZoneList<LPointerMap*> pointer_maps_;
2370   ZoneList<Handle<JSFunction> > inlined_closures_;
2371 };
2372
2373
2374 class LChunkBuilder BASE_EMBEDDED {
2375  public:
2376   LChunkBuilder(CompilationInfo* info, HGraph* graph, LAllocator* allocator)
2377       : chunk_(NULL),
2378         info_(info),
2379         graph_(graph),
2380         zone_(graph->isolate()->zone()),
2381         status_(UNUSED),
2382         current_instruction_(NULL),
2383         current_block_(NULL),
2384         next_block_(NULL),
2385         argument_count_(0),
2386         allocator_(allocator),
2387         position_(RelocInfo::kNoPosition),
2388         instruction_pending_deoptimization_environment_(NULL),
2389         pending_deoptimization_ast_id_(AstNode::kNoNumber) { }
2390
2391   // Build the sequence for the graph.
2392   LChunk* Build();
2393
2394   // Declare methods that deal with the individual node types.
2395 #define DECLARE_DO(type) LInstruction* Do##type(H##type* node);
2396   HYDROGEN_CONCRETE_INSTRUCTION_LIST(DECLARE_DO)
2397 #undef DECLARE_DO
2398
2399  private:
2400   enum Status {
2401     UNUSED,
2402     BUILDING,
2403     DONE,
2404     ABORTED
2405   };
2406
2407   LChunk* chunk() const { return chunk_; }
2408   CompilationInfo* info() const { return info_; }
2409   HGraph* graph() const { return graph_; }
2410   Zone* zone() { return zone_; }
2411
2412   bool is_unused() const { return status_ == UNUSED; }
2413   bool is_building() const { return status_ == BUILDING; }
2414   bool is_done() const { return status_ == DONE; }
2415   bool is_aborted() const { return status_ == ABORTED; }
2416
2417   void Abort(const char* format, ...);
2418
2419   // Methods for getting operands for Use / Define / Temp.
2420   LUnallocated* ToUnallocated(Register reg);
2421   LUnallocated* ToUnallocated(XMMRegister reg);
2422
2423   // Methods for setting up define-use relationships.
2424   MUST_USE_RESULT LOperand* Use(HValue* value, LUnallocated* operand);
2425   MUST_USE_RESULT LOperand* UseFixed(HValue* value, Register fixed_register);
2426   MUST_USE_RESULT LOperand* UseFixedDouble(HValue* value,
2427                                            XMMRegister fixed_register);
2428
2429   // A value that is guaranteed to be allocated to a register.
2430   // Operand created by UseRegister is guaranteed to be live until the end of
2431   // instruction. This means that register allocator will not reuse it's
2432   // register for any other operand inside instruction.
2433   // Operand created by UseRegisterAtStart is guaranteed to be live only at
2434   // instruction start. Register allocator is free to assign the same register
2435   // to some other operand used inside instruction (i.e. temporary or
2436   // output).
2437   MUST_USE_RESULT LOperand* UseRegister(HValue* value);
2438   MUST_USE_RESULT LOperand* UseRegisterAtStart(HValue* value);
2439
2440   // An input operand in a register that may be trashed.
2441   MUST_USE_RESULT LOperand* UseTempRegister(HValue* value);
2442
2443   // An input operand in a register or stack slot.
2444   MUST_USE_RESULT LOperand* Use(HValue* value);
2445   MUST_USE_RESULT LOperand* UseAtStart(HValue* value);
2446
2447   // An input operand in a register, stack slot or a constant operand.
2448   MUST_USE_RESULT LOperand* UseOrConstant(HValue* value);
2449   MUST_USE_RESULT LOperand* UseOrConstantAtStart(HValue* value);
2450
2451   // An input operand in a register or a constant operand.
2452   MUST_USE_RESULT LOperand* UseRegisterOrConstant(HValue* value);
2453   MUST_USE_RESULT LOperand* UseRegisterOrConstantAtStart(HValue* value);
2454
2455   // An input operand in register, stack slot or a constant operand.
2456   // Will not be moved to a register even if one is freely available.
2457   MUST_USE_RESULT LOperand* UseAny(HValue* value);
2458
2459   // Temporary operand that must be in a register.
2460   MUST_USE_RESULT LUnallocated* TempRegister();
2461   MUST_USE_RESULT LOperand* FixedTemp(Register reg);
2462   MUST_USE_RESULT LOperand* FixedTemp(XMMRegister reg);
2463
2464   // Methods for setting up define-use relationships.
2465   // Return the same instruction that they are passed.
2466   template<int I, int T>
2467       LInstruction* Define(LTemplateInstruction<1, I, T>* instr,
2468                            LUnallocated* result);
2469   template<int I, int T>
2470       LInstruction* DefineAsRegister(LTemplateInstruction<1, I, T>* instr);
2471   template<int I, int T>
2472       LInstruction* DefineAsSpilled(LTemplateInstruction<1, I, T>* instr,
2473                                     int index);
2474   template<int I, int T>
2475       LInstruction* DefineSameAsFirst(LTemplateInstruction<1, I, T>* instr);
2476   template<int I, int T>
2477       LInstruction* DefineFixed(LTemplateInstruction<1, I, T>* instr,
2478                                 Register reg);
2479   template<int I, int T>
2480       LInstruction* DefineFixedDouble(LTemplateInstruction<1, I, T>* instr,
2481                                       XMMRegister reg);
2482   // Assigns an environment to an instruction.  An instruction which can
2483   // deoptimize must have an environment.
2484   LInstruction* AssignEnvironment(LInstruction* instr);
2485   // Assigns a pointer map to an instruction.  An instruction which can
2486   // trigger a GC or a lazy deoptimization must have a pointer map.
2487   LInstruction* AssignPointerMap(LInstruction* instr);
2488
2489   enum CanDeoptimize { CAN_DEOPTIMIZE_EAGERLY, CANNOT_DEOPTIMIZE_EAGERLY };
2490
2491   // Marks a call for the register allocator.  Assigns a pointer map to
2492   // support GC and lazy deoptimization.  Assigns an environment to support
2493   // eager deoptimization if CAN_DEOPTIMIZE_EAGERLY.
2494   LInstruction* MarkAsCall(
2495       LInstruction* instr,
2496       HInstruction* hinstr,
2497       CanDeoptimize can_deoptimize = CANNOT_DEOPTIMIZE_EAGERLY);
2498
2499   LEnvironment* CreateEnvironment(HEnvironment* hydrogen_env,
2500                                   int* argument_index_accumulator);
2501
2502   void VisitInstruction(HInstruction* current);
2503
2504   void DoBasicBlock(HBasicBlock* block, HBasicBlock* next_block);
2505   LInstruction* DoShift(Token::Value op, HBitwiseBinaryOperation* instr);
2506   LInstruction* DoArithmeticD(Token::Value op,
2507                               HArithmeticBinaryOperation* instr);
2508   LInstruction* DoArithmeticT(Token::Value op,
2509                               HArithmeticBinaryOperation* instr);
2510
2511   LChunk* chunk_;
2512   CompilationInfo* info_;
2513   HGraph* const graph_;
2514   Zone* zone_;
2515   Status status_;
2516   HInstruction* current_instruction_;
2517   HBasicBlock* current_block_;
2518   HBasicBlock* next_block_;
2519   int argument_count_;
2520   LAllocator* allocator_;
2521   int position_;
2522   LInstruction* instruction_pending_deoptimization_environment_;
2523   int pending_deoptimization_ast_id_;
2524
2525   DISALLOW_COPY_AND_ASSIGN(LChunkBuilder);
2526 };
2527
2528 #undef DECLARE_HYDROGEN_ACCESSOR
2529 #undef DECLARE_CONCRETE_INSTRUCTION
2530
2531 } }  // namespace v8::internal
2532
2533 #endif  // V8_IA32_LITHIUM_IA32_H_