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