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