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