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