[strong] Disallow implicit conversions for comparison
[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   LanguageMode language_mode() { return hydrogen()->language_mode(); }
1178
1179   Token::Value op() const { return hydrogen()->token(); }
1180 };
1181
1182
1183 class LInstanceOf final : public LTemplateInstruction<1, 3, 0> {
1184  public:
1185   LInstanceOf(LOperand* context, LOperand* left, LOperand* right) {
1186     inputs_[0] = context;
1187     inputs_[1] = left;
1188     inputs_[2] = right;
1189   }
1190
1191   LOperand* context() { return inputs_[0]; }
1192   LOperand* left() { return inputs_[1]; }
1193   LOperand* right() { return inputs_[2]; }
1194
1195   DECLARE_CONCRETE_INSTRUCTION(InstanceOf, "instance-of")
1196 };
1197
1198
1199 class LInstanceOfKnownGlobal final : public LTemplateInstruction<1, 2, 1> {
1200  public:
1201   LInstanceOfKnownGlobal(LOperand* context, LOperand* value, LOperand* temp) {
1202     inputs_[0] = context;
1203     inputs_[1] = value;
1204     temps_[0] = temp;
1205   }
1206
1207   LOperand* context() { return inputs_[0]; }
1208   LOperand* value() { return inputs_[1]; }
1209   LOperand* temp() { return temps_[0]; }
1210
1211   DECLARE_CONCRETE_INSTRUCTION(InstanceOfKnownGlobal,
1212                                "instance-of-known-global")
1213   DECLARE_HYDROGEN_ACCESSOR(InstanceOfKnownGlobal)
1214
1215   Handle<JSFunction> function() const { return hydrogen()->function(); }
1216   LEnvironment* GetDeferredLazyDeoptimizationEnvironment() {
1217     return lazy_deopt_env_;
1218   }
1219   virtual void SetDeferredLazyDeoptimizationEnvironment(
1220       LEnvironment* env) override {
1221     lazy_deopt_env_ = env;
1222   }
1223
1224  private:
1225   LEnvironment* lazy_deopt_env_;
1226 };
1227
1228
1229 class LBoundsCheck final : public LTemplateInstruction<0, 2, 0> {
1230  public:
1231   LBoundsCheck(LOperand* index, LOperand* length) {
1232     inputs_[0] = index;
1233     inputs_[1] = length;
1234   }
1235
1236   LOperand* index() { return inputs_[0]; }
1237   LOperand* length() { return inputs_[1]; }
1238
1239   DECLARE_CONCRETE_INSTRUCTION(BoundsCheck, "bounds-check")
1240   DECLARE_HYDROGEN_ACCESSOR(BoundsCheck)
1241 };
1242
1243
1244 class LBitI final : public LTemplateInstruction<1, 2, 0> {
1245  public:
1246   LBitI(LOperand* left, LOperand* right) {
1247     inputs_[0] = left;
1248     inputs_[1] = right;
1249   }
1250
1251   LOperand* left() { return inputs_[0]; }
1252   LOperand* right() { return inputs_[1]; }
1253
1254   Token::Value op() const { return hydrogen()->op(); }
1255   bool IsInteger32() const {
1256     return hydrogen()->representation().IsInteger32();
1257   }
1258
1259   DECLARE_CONCRETE_INSTRUCTION(BitI, "bit-i")
1260   DECLARE_HYDROGEN_ACCESSOR(Bitwise)
1261 };
1262
1263
1264 class LShiftI final : public LTemplateInstruction<1, 2, 0> {
1265  public:
1266   LShiftI(Token::Value op, LOperand* left, LOperand* right, bool can_deopt)
1267       : op_(op), can_deopt_(can_deopt) {
1268     inputs_[0] = left;
1269     inputs_[1] = right;
1270   }
1271
1272   Token::Value op() const { return op_; }
1273   LOperand* left() { return inputs_[0]; }
1274   LOperand* right() { return inputs_[1]; }
1275   bool can_deopt() const { return can_deopt_; }
1276
1277   DECLARE_CONCRETE_INSTRUCTION(ShiftI, "shift-i")
1278
1279  private:
1280   Token::Value op_;
1281   bool can_deopt_;
1282 };
1283
1284
1285 class LSubI final : public LTemplateInstruction<1, 2, 0> {
1286  public:
1287   LSubI(LOperand* left, LOperand* right) {
1288     inputs_[0] = left;
1289     inputs_[1] = right;
1290   }
1291
1292   LOperand* left() { return inputs_[0]; }
1293   LOperand* right() { return inputs_[1]; }
1294
1295   DECLARE_CONCRETE_INSTRUCTION(SubI, "sub-i")
1296   DECLARE_HYDROGEN_ACCESSOR(Sub)
1297 };
1298
1299
1300 class LConstantI final : public LTemplateInstruction<1, 0, 0> {
1301  public:
1302   DECLARE_CONCRETE_INSTRUCTION(ConstantI, "constant-i")
1303   DECLARE_HYDROGEN_ACCESSOR(Constant)
1304
1305   int32_t value() const { return hydrogen()->Integer32Value(); }
1306 };
1307
1308
1309 class LConstantS final : public LTemplateInstruction<1, 0, 0> {
1310  public:
1311   DECLARE_CONCRETE_INSTRUCTION(ConstantS, "constant-s")
1312   DECLARE_HYDROGEN_ACCESSOR(Constant)
1313
1314   Smi* value() const { return Smi::FromInt(hydrogen()->Integer32Value()); }
1315 };
1316
1317
1318 class LConstantD final : public LTemplateInstruction<1, 0, 0> {
1319  public:
1320   DECLARE_CONCRETE_INSTRUCTION(ConstantD, "constant-d")
1321   DECLARE_HYDROGEN_ACCESSOR(Constant)
1322
1323   uint64_t bits() const { return hydrogen()->DoubleValueAsBits(); }
1324 };
1325
1326
1327 class LConstantE final : public LTemplateInstruction<1, 0, 0> {
1328  public:
1329   DECLARE_CONCRETE_INSTRUCTION(ConstantE, "constant-e")
1330   DECLARE_HYDROGEN_ACCESSOR(Constant)
1331
1332   ExternalReference value() const {
1333     return hydrogen()->ExternalReferenceValue();
1334   }
1335 };
1336
1337
1338 class LConstantT final : public LTemplateInstruction<1, 0, 0> {
1339  public:
1340   DECLARE_CONCRETE_INSTRUCTION(ConstantT, "constant-t")
1341   DECLARE_HYDROGEN_ACCESSOR(Constant)
1342
1343   Handle<Object> value(Isolate* isolate) const {
1344     return hydrogen()->handle(isolate);
1345   }
1346 };
1347
1348
1349 class LBranch final : public LControlInstruction<1, 0> {
1350  public:
1351   explicit LBranch(LOperand* value) {
1352     inputs_[0] = value;
1353   }
1354
1355   LOperand* value() { return inputs_[0]; }
1356
1357   DECLARE_CONCRETE_INSTRUCTION(Branch, "branch")
1358   DECLARE_HYDROGEN_ACCESSOR(Branch)
1359
1360   void PrintDataTo(StringStream* stream) override;
1361 };
1362
1363
1364 class LDebugBreak final : public LTemplateInstruction<0, 0, 0> {
1365  public:
1366   DECLARE_CONCRETE_INSTRUCTION(DebugBreak, "break")
1367 };
1368
1369
1370 class LCmpMapAndBranch final : public LControlInstruction<1, 0> {
1371  public:
1372   explicit LCmpMapAndBranch(LOperand* value) {
1373     inputs_[0] = value;
1374   }
1375
1376   LOperand* value() { return inputs_[0]; }
1377
1378   DECLARE_CONCRETE_INSTRUCTION(CmpMapAndBranch, "cmp-map-and-branch")
1379   DECLARE_HYDROGEN_ACCESSOR(CompareMap)
1380
1381   Handle<Map> map() const { return hydrogen()->map().handle(); }
1382 };
1383
1384
1385 class LMapEnumLength final : public LTemplateInstruction<1, 1, 0> {
1386  public:
1387   explicit LMapEnumLength(LOperand* value) {
1388     inputs_[0] = value;
1389   }
1390
1391   LOperand* value() { return inputs_[0]; }
1392
1393   DECLARE_CONCRETE_INSTRUCTION(MapEnumLength, "map-enum-length")
1394 };
1395
1396
1397 class LDateField final : public LTemplateInstruction<1, 1, 0> {
1398  public:
1399   LDateField(LOperand* date, Smi* index) : index_(index) {
1400     inputs_[0] = date;
1401   }
1402
1403   LOperand* date() { return inputs_[0]; }
1404   Smi* index() const { return index_; }
1405
1406   DECLARE_CONCRETE_INSTRUCTION(DateField, "date-field")
1407   DECLARE_HYDROGEN_ACCESSOR(DateField)
1408
1409  private:
1410   Smi* index_;
1411 };
1412
1413
1414 class LSeqStringGetChar final : public LTemplateInstruction<1, 2, 0> {
1415  public:
1416   LSeqStringGetChar(LOperand* string, LOperand* index) {
1417     inputs_[0] = string;
1418     inputs_[1] = index;
1419   }
1420
1421   LOperand* string() const { return inputs_[0]; }
1422   LOperand* index() const { return inputs_[1]; }
1423
1424   DECLARE_CONCRETE_INSTRUCTION(SeqStringGetChar, "seq-string-get-char")
1425   DECLARE_HYDROGEN_ACCESSOR(SeqStringGetChar)
1426 };
1427
1428
1429 class LSeqStringSetChar final : public LTemplateInstruction<1, 4, 0> {
1430  public:
1431   LSeqStringSetChar(LOperand* context,
1432                     LOperand* string,
1433                     LOperand* index,
1434                     LOperand* value) {
1435     inputs_[0] = context;
1436     inputs_[1] = string;
1437     inputs_[2] = index;
1438     inputs_[3] = value;
1439   }
1440
1441   LOperand* string() { return inputs_[1]; }
1442   LOperand* index() { return inputs_[2]; }
1443   LOperand* value() { return inputs_[3]; }
1444
1445   DECLARE_CONCRETE_INSTRUCTION(SeqStringSetChar, "seq-string-set-char")
1446   DECLARE_HYDROGEN_ACCESSOR(SeqStringSetChar)
1447 };
1448
1449
1450 class LAddI final : public LTemplateInstruction<1, 2, 0> {
1451  public:
1452   LAddI(LOperand* left, LOperand* right) {
1453     inputs_[0] = left;
1454     inputs_[1] = right;
1455   }
1456
1457   LOperand* left() { return inputs_[0]; }
1458   LOperand* right() { return inputs_[1]; }
1459
1460   static bool UseLea(HAdd* add) {
1461     return !add->CheckFlag(HValue::kCanOverflow) &&
1462         add->BetterLeftOperand()->UseCount() > 1;
1463   }
1464
1465   DECLARE_CONCRETE_INSTRUCTION(AddI, "add-i")
1466   DECLARE_HYDROGEN_ACCESSOR(Add)
1467 };
1468
1469
1470 class LMathMinMax final : public LTemplateInstruction<1, 2, 0> {
1471  public:
1472   LMathMinMax(LOperand* left, LOperand* right) {
1473     inputs_[0] = left;
1474     inputs_[1] = right;
1475   }
1476
1477   LOperand* left() { return inputs_[0]; }
1478   LOperand* right() { return inputs_[1]; }
1479
1480   DECLARE_CONCRETE_INSTRUCTION(MathMinMax, "math-min-max")
1481   DECLARE_HYDROGEN_ACCESSOR(MathMinMax)
1482 };
1483
1484
1485 class LPower final : public LTemplateInstruction<1, 2, 0> {
1486  public:
1487   LPower(LOperand* left, LOperand* right) {
1488     inputs_[0] = left;
1489     inputs_[1] = right;
1490   }
1491
1492   LOperand* left() { return inputs_[0]; }
1493   LOperand* right() { return inputs_[1]; }
1494
1495   DECLARE_CONCRETE_INSTRUCTION(Power, "power")
1496   DECLARE_HYDROGEN_ACCESSOR(Power)
1497 };
1498
1499
1500 class LArithmeticD final : public LTemplateInstruction<1, 2, 0> {
1501  public:
1502   LArithmeticD(Token::Value op, LOperand* left, LOperand* right)
1503       : op_(op) {
1504     inputs_[0] = left;
1505     inputs_[1] = right;
1506   }
1507
1508   Token::Value op() const { return op_; }
1509   LOperand* left() { return inputs_[0]; }
1510   LOperand* right() { return inputs_[1]; }
1511
1512   Opcode opcode() const override { return LInstruction::kArithmeticD; }
1513   void CompileToNative(LCodeGen* generator) override;
1514   const char* Mnemonic() const override;
1515
1516  private:
1517   Token::Value op_;
1518 };
1519
1520
1521 class LArithmeticT final : public LTemplateInstruction<1, 3, 0> {
1522  public:
1523   LArithmeticT(Token::Value op,
1524                LOperand* context,
1525                LOperand* left,
1526                LOperand* right)
1527       : op_(op) {
1528     inputs_[0] = context;
1529     inputs_[1] = left;
1530     inputs_[2] = right;
1531   }
1532
1533   Token::Value op() const { return op_; }
1534   LOperand* context() { return inputs_[0]; }
1535   LOperand* left() { return inputs_[1]; }
1536   LOperand* right() { return inputs_[2]; }
1537
1538   Opcode opcode() const override { return LInstruction::kArithmeticT; }
1539   void CompileToNative(LCodeGen* generator) override;
1540   const char* Mnemonic() const override;
1541
1542   DECLARE_HYDROGEN_ACCESSOR(BinaryOperation)
1543
1544   LanguageMode language_mode() { return hydrogen()->language_mode(); }
1545
1546  private:
1547   Token::Value op_;
1548 };
1549
1550
1551 class LReturn final : public LTemplateInstruction<0, 3, 0> {
1552  public:
1553   explicit LReturn(LOperand* value,
1554                    LOperand* context,
1555                    LOperand* parameter_count) {
1556     inputs_[0] = value;
1557     inputs_[1] = context;
1558     inputs_[2] = parameter_count;
1559   }
1560
1561   LOperand* value() { return inputs_[0]; }
1562   LOperand* context() { return inputs_[1]; }
1563
1564   bool has_constant_parameter_count() {
1565     return parameter_count()->IsConstantOperand();
1566   }
1567   LConstantOperand* constant_parameter_count() {
1568     DCHECK(has_constant_parameter_count());
1569     return LConstantOperand::cast(parameter_count());
1570   }
1571   LOperand* parameter_count() { return inputs_[2]; }
1572
1573   DECLARE_CONCRETE_INSTRUCTION(Return, "return")
1574   DECLARE_HYDROGEN_ACCESSOR(Return)
1575 };
1576
1577
1578 class LLoadNamedField final : public LTemplateInstruction<1, 1, 0> {
1579  public:
1580   explicit LLoadNamedField(LOperand* object) {
1581     inputs_[0] = object;
1582   }
1583
1584   LOperand* object() { return inputs_[0]; }
1585
1586   DECLARE_CONCRETE_INSTRUCTION(LoadNamedField, "load-named-field")
1587   DECLARE_HYDROGEN_ACCESSOR(LoadNamedField)
1588 };
1589
1590
1591 class LLoadNamedGeneric final : public LTemplateInstruction<1, 2, 1> {
1592  public:
1593   explicit LLoadNamedGeneric(LOperand* context, LOperand* object,
1594                              LOperand* vector) {
1595     inputs_[0] = context;
1596     inputs_[1] = object;
1597     temps_[0] = vector;
1598   }
1599
1600   DECLARE_CONCRETE_INSTRUCTION(LoadNamedGeneric, "load-named-generic")
1601   DECLARE_HYDROGEN_ACCESSOR(LoadNamedGeneric)
1602
1603   LOperand* context() { return inputs_[0]; }
1604   LOperand* object() { return inputs_[1]; }
1605   LOperand* temp_vector() { return temps_[0]; }
1606
1607   Handle<Object> name() const { return hydrogen()->name(); }
1608 };
1609
1610
1611 class LLoadFunctionPrototype final : public LTemplateInstruction<1, 1, 0> {
1612  public:
1613   explicit LLoadFunctionPrototype(LOperand* function) {
1614     inputs_[0] = function;
1615   }
1616
1617   DECLARE_CONCRETE_INSTRUCTION(LoadFunctionPrototype, "load-function-prototype")
1618   DECLARE_HYDROGEN_ACCESSOR(LoadFunctionPrototype)
1619
1620   LOperand* function() { return inputs_[0]; }
1621 };
1622
1623
1624 class LLoadRoot final : public LTemplateInstruction<1, 0, 0> {
1625  public:
1626   DECLARE_CONCRETE_INSTRUCTION(LoadRoot, "load-root")
1627   DECLARE_HYDROGEN_ACCESSOR(LoadRoot)
1628
1629   Heap::RootListIndex index() const { return hydrogen()->index(); }
1630 };
1631
1632
1633 inline static bool ExternalArrayOpRequiresTemp(
1634     Representation key_representation,
1635     ElementsKind elements_kind) {
1636   // Operations that require the key to be divided by two to be converted into
1637   // an index cannot fold the scale operation into a load and need an extra
1638   // temp register to do the work.
1639   return SmiValuesAre31Bits() && key_representation.IsSmi() &&
1640       (elements_kind == EXTERNAL_INT8_ELEMENTS ||
1641        elements_kind == EXTERNAL_UINT8_ELEMENTS ||
1642        elements_kind == EXTERNAL_UINT8_CLAMPED_ELEMENTS ||
1643        elements_kind == UINT8_ELEMENTS ||
1644        elements_kind == INT8_ELEMENTS ||
1645        elements_kind == UINT8_CLAMPED_ELEMENTS);
1646 }
1647
1648
1649 class LLoadKeyed final : public LTemplateInstruction<1, 2, 0> {
1650  public:
1651   LLoadKeyed(LOperand* elements, LOperand* key) {
1652     inputs_[0] = elements;
1653     inputs_[1] = key;
1654   }
1655
1656   DECLARE_CONCRETE_INSTRUCTION(LoadKeyed, "load-keyed")
1657   DECLARE_HYDROGEN_ACCESSOR(LoadKeyed)
1658
1659   bool is_external() const {
1660     return hydrogen()->is_external();
1661   }
1662   bool is_fixed_typed_array() const {
1663     return hydrogen()->is_fixed_typed_array();
1664   }
1665   bool is_typed_elements() const {
1666     return is_external() || is_fixed_typed_array();
1667   }
1668   LOperand* elements() { return inputs_[0]; }
1669   LOperand* key() { return inputs_[1]; }
1670   void PrintDataTo(StringStream* stream) override;
1671   uint32_t base_offset() const { return hydrogen()->base_offset(); }
1672   ElementsKind elements_kind() const {
1673     return hydrogen()->elements_kind();
1674   }
1675 };
1676
1677
1678 class LLoadKeyedGeneric final : public LTemplateInstruction<1, 3, 1> {
1679  public:
1680   LLoadKeyedGeneric(LOperand* context, LOperand* obj, LOperand* key,
1681                     LOperand* vector) {
1682     inputs_[0] = context;
1683     inputs_[1] = obj;
1684     inputs_[2] = key;
1685     temps_[0] = vector;
1686   }
1687
1688   DECLARE_CONCRETE_INSTRUCTION(LoadKeyedGeneric, "load-keyed-generic")
1689   DECLARE_HYDROGEN_ACCESSOR(LoadKeyedGeneric)
1690
1691   LOperand* context() { return inputs_[0]; }
1692   LOperand* object() { return inputs_[1]; }
1693   LOperand* key() { return inputs_[2]; }
1694   LOperand* temp_vector() { return temps_[0]; }
1695 };
1696
1697
1698 class LLoadGlobalGeneric final : public LTemplateInstruction<1, 2, 1> {
1699  public:
1700   explicit LLoadGlobalGeneric(LOperand* context, LOperand* global_object,
1701                               LOperand* vector) {
1702     inputs_[0] = context;
1703     inputs_[1] = global_object;
1704     temps_[0] = vector;
1705   }
1706
1707   DECLARE_CONCRETE_INSTRUCTION(LoadGlobalGeneric, "load-global-generic")
1708   DECLARE_HYDROGEN_ACCESSOR(LoadGlobalGeneric)
1709
1710   LOperand* context() { return inputs_[0]; }
1711   LOperand* global_object() { return inputs_[1]; }
1712   LOperand* temp_vector() { return temps_[0]; }
1713
1714   Handle<Object> name() const { return hydrogen()->name(); }
1715   bool for_typeof() const { return hydrogen()->for_typeof(); }
1716 };
1717
1718
1719 class LLoadContextSlot final : public LTemplateInstruction<1, 1, 0> {
1720  public:
1721   explicit LLoadContextSlot(LOperand* context) {
1722     inputs_[0] = context;
1723   }
1724
1725   LOperand* context() { return inputs_[0]; }
1726
1727   DECLARE_CONCRETE_INSTRUCTION(LoadContextSlot, "load-context-slot")
1728   DECLARE_HYDROGEN_ACCESSOR(LoadContextSlot)
1729
1730   int slot_index() { return hydrogen()->slot_index(); }
1731
1732   void PrintDataTo(StringStream* stream) override;
1733 };
1734
1735
1736 class LStoreContextSlot final : public LTemplateInstruction<0, 2, 1> {
1737  public:
1738   LStoreContextSlot(LOperand* context, LOperand* value, LOperand* temp) {
1739     inputs_[0] = context;
1740     inputs_[1] = value;
1741     temps_[0] = temp;
1742   }
1743
1744   LOperand* context() { return inputs_[0]; }
1745   LOperand* value() { return inputs_[1]; }
1746   LOperand* temp() { return temps_[0]; }
1747
1748   DECLARE_CONCRETE_INSTRUCTION(StoreContextSlot, "store-context-slot")
1749   DECLARE_HYDROGEN_ACCESSOR(StoreContextSlot)
1750
1751   int slot_index() { return hydrogen()->slot_index(); }
1752
1753   void PrintDataTo(StringStream* stream) override;
1754 };
1755
1756
1757 class LPushArgument final : public LTemplateInstruction<0, 1, 0> {
1758  public:
1759   explicit LPushArgument(LOperand* value) {
1760     inputs_[0] = value;
1761   }
1762
1763   LOperand* value() { return inputs_[0]; }
1764
1765   DECLARE_CONCRETE_INSTRUCTION(PushArgument, "push-argument")
1766 };
1767
1768
1769 class LDrop final : public LTemplateInstruction<0, 0, 0> {
1770  public:
1771   explicit LDrop(int count) : count_(count) { }
1772
1773   int count() const { return count_; }
1774
1775   DECLARE_CONCRETE_INSTRUCTION(Drop, "drop")
1776
1777  private:
1778   int count_;
1779 };
1780
1781
1782 class LStoreCodeEntry final : public LTemplateInstruction<0, 2, 0> {
1783  public:
1784   LStoreCodeEntry(LOperand* function, LOperand* code_object) {
1785     inputs_[0] = function;
1786     inputs_[1] = code_object;
1787   }
1788
1789   LOperand* function() { return inputs_[0]; }
1790   LOperand* code_object() { return inputs_[1]; }
1791
1792   void PrintDataTo(StringStream* stream) override;
1793
1794   DECLARE_CONCRETE_INSTRUCTION(StoreCodeEntry, "store-code-entry")
1795   DECLARE_HYDROGEN_ACCESSOR(StoreCodeEntry)
1796 };
1797
1798
1799 class LInnerAllocatedObject final : public LTemplateInstruction<1, 2, 0> {
1800  public:
1801   LInnerAllocatedObject(LOperand* base_object, LOperand* offset) {
1802     inputs_[0] = base_object;
1803     inputs_[1] = offset;
1804   }
1805
1806   LOperand* base_object() const { return inputs_[0]; }
1807   LOperand* offset() const { return inputs_[1]; }
1808
1809   void PrintDataTo(StringStream* stream) override;
1810
1811   DECLARE_CONCRETE_INSTRUCTION(InnerAllocatedObject, "inner-allocated-object")
1812 };
1813
1814
1815 class LThisFunction final : public LTemplateInstruction<1, 0, 0> {
1816  public:
1817   DECLARE_CONCRETE_INSTRUCTION(ThisFunction, "this-function")
1818   DECLARE_HYDROGEN_ACCESSOR(ThisFunction)
1819 };
1820
1821
1822 class LContext final : public LTemplateInstruction<1, 0, 0> {
1823  public:
1824   DECLARE_CONCRETE_INSTRUCTION(Context, "context")
1825   DECLARE_HYDROGEN_ACCESSOR(Context)
1826 };
1827
1828
1829 class LDeclareGlobals final : public LTemplateInstruction<0, 1, 0> {
1830  public:
1831   explicit LDeclareGlobals(LOperand* context) {
1832     inputs_[0] = context;
1833   }
1834
1835   LOperand* context() { return inputs_[0]; }
1836
1837   DECLARE_CONCRETE_INSTRUCTION(DeclareGlobals, "declare-globals")
1838   DECLARE_HYDROGEN_ACCESSOR(DeclareGlobals)
1839 };
1840
1841
1842 class LCallJSFunction final : public LTemplateInstruction<1, 1, 0> {
1843  public:
1844   explicit LCallJSFunction(LOperand* function) {
1845     inputs_[0] = function;
1846   }
1847
1848   LOperand* function() { return inputs_[0]; }
1849
1850   DECLARE_CONCRETE_INSTRUCTION(CallJSFunction, "call-js-function")
1851   DECLARE_HYDROGEN_ACCESSOR(CallJSFunction)
1852
1853   void PrintDataTo(StringStream* stream) override;
1854
1855   int arity() const { return hydrogen()->argument_count() - 1; }
1856 };
1857
1858
1859 class LCallWithDescriptor final : public LTemplateResultInstruction<1> {
1860  public:
1861   LCallWithDescriptor(CallInterfaceDescriptor descriptor,
1862                       const ZoneList<LOperand*>& operands, Zone* zone)
1863       : inputs_(descriptor.GetRegisterParameterCount() + 1, zone) {
1864     DCHECK(descriptor.GetRegisterParameterCount() + 1 == operands.length());
1865     inputs_.AddAll(operands, zone);
1866   }
1867
1868   LOperand* target() const { return inputs_[0]; }
1869
1870   DECLARE_HYDROGEN_ACCESSOR(CallWithDescriptor)
1871
1872  private:
1873   DECLARE_CONCRETE_INSTRUCTION(CallWithDescriptor, "call-with-descriptor")
1874
1875   void PrintDataTo(StringStream* stream) override;
1876
1877   int arity() const { return hydrogen()->argument_count() - 1; }
1878
1879   ZoneList<LOperand*> inputs_;
1880
1881   // Iterator support.
1882   int InputCount() final { return inputs_.length(); }
1883   LOperand* InputAt(int i) final { return inputs_[i]; }
1884
1885   int TempCount() final { return 0; }
1886   LOperand* TempAt(int i) final { return NULL; }
1887 };
1888
1889
1890 class LInvokeFunction final : public LTemplateInstruction<1, 2, 0> {
1891  public:
1892   LInvokeFunction(LOperand* context, LOperand* function) {
1893     inputs_[0] = context;
1894     inputs_[1] = function;
1895   }
1896
1897   LOperand* context() { return inputs_[0]; }
1898   LOperand* function() { return inputs_[1]; }
1899
1900   DECLARE_CONCRETE_INSTRUCTION(InvokeFunction, "invoke-function")
1901   DECLARE_HYDROGEN_ACCESSOR(InvokeFunction)
1902
1903   void PrintDataTo(StringStream* stream) override;
1904
1905   int arity() const { return hydrogen()->argument_count() - 1; }
1906 };
1907
1908
1909 class LCallFunction final : public LTemplateInstruction<1, 2, 2> {
1910  public:
1911   LCallFunction(LOperand* context, LOperand* function, LOperand* slot,
1912                 LOperand* vector) {
1913     inputs_[0] = context;
1914     inputs_[1] = function;
1915     temps_[0] = slot;
1916     temps_[1] = vector;
1917   }
1918
1919   DECLARE_CONCRETE_INSTRUCTION(CallFunction, "call-function")
1920   DECLARE_HYDROGEN_ACCESSOR(CallFunction)
1921
1922   LOperand* context() { return inputs_[0]; }
1923   LOperand* function() { return inputs_[1]; }
1924   LOperand* temp_slot() { return temps_[0]; }
1925   LOperand* temp_vector() { return temps_[1]; }
1926   int arity() const { return hydrogen()->argument_count() - 1; }
1927
1928   void PrintDataTo(StringStream* stream) override;
1929 };
1930
1931
1932 class LCallNew final : public LTemplateInstruction<1, 2, 0> {
1933  public:
1934   LCallNew(LOperand* context, LOperand* constructor) {
1935     inputs_[0] = context;
1936     inputs_[1] = constructor;
1937   }
1938
1939   LOperand* context() { return inputs_[0]; }
1940   LOperand* constructor() { return inputs_[1]; }
1941
1942   DECLARE_CONCRETE_INSTRUCTION(CallNew, "call-new")
1943   DECLARE_HYDROGEN_ACCESSOR(CallNew)
1944
1945   void PrintDataTo(StringStream* stream) override;
1946
1947   int arity() const { return hydrogen()->argument_count() - 1; }
1948 };
1949
1950
1951 class LCallNewArray final : public LTemplateInstruction<1, 2, 0> {
1952  public:
1953   LCallNewArray(LOperand* context, LOperand* constructor) {
1954     inputs_[0] = context;
1955     inputs_[1] = constructor;
1956   }
1957
1958   LOperand* context() { return inputs_[0]; }
1959   LOperand* constructor() { return inputs_[1]; }
1960
1961   DECLARE_CONCRETE_INSTRUCTION(CallNewArray, "call-new-array")
1962   DECLARE_HYDROGEN_ACCESSOR(CallNewArray)
1963
1964   void PrintDataTo(StringStream* stream) override;
1965
1966   int arity() const { return hydrogen()->argument_count() - 1; }
1967 };
1968
1969
1970 class LCallRuntime final : public LTemplateInstruction<1, 1, 0> {
1971  public:
1972   explicit LCallRuntime(LOperand* context) {
1973     inputs_[0] = context;
1974   }
1975
1976   LOperand* context() { return inputs_[0]; }
1977
1978   DECLARE_CONCRETE_INSTRUCTION(CallRuntime, "call-runtime")
1979   DECLARE_HYDROGEN_ACCESSOR(CallRuntime)
1980
1981   bool ClobbersDoubleRegisters(Isolate* isolate) const override {
1982     return save_doubles() == kDontSaveFPRegs;
1983   }
1984
1985   const Runtime::Function* function() const { return hydrogen()->function(); }
1986   int arity() const { return hydrogen()->argument_count(); }
1987   SaveFPRegsMode save_doubles() const { return hydrogen()->save_doubles(); }
1988 };
1989
1990
1991 class LInteger32ToDouble final : public LTemplateInstruction<1, 1, 0> {
1992  public:
1993   explicit LInteger32ToDouble(LOperand* value) {
1994     inputs_[0] = value;
1995   }
1996
1997   LOperand* value() { return inputs_[0]; }
1998
1999   DECLARE_CONCRETE_INSTRUCTION(Integer32ToDouble, "int32-to-double")
2000 };
2001
2002
2003 class LUint32ToDouble final : public LTemplateInstruction<1, 1, 0> {
2004  public:
2005   explicit LUint32ToDouble(LOperand* value) {
2006     inputs_[0] = value;
2007   }
2008
2009   LOperand* value() { return inputs_[0]; }
2010
2011   DECLARE_CONCRETE_INSTRUCTION(Uint32ToDouble, "uint32-to-double")
2012 };
2013
2014
2015 class LNumberTagI final : public LTemplateInstruction<1, 1, 2> {
2016  public:
2017   LNumberTagI(LOperand* value, LOperand* temp1, LOperand* temp2) {
2018     inputs_[0] = value;
2019     temps_[0] = temp1;
2020     temps_[1] = temp2;
2021   }
2022
2023   LOperand* value() { return inputs_[0]; }
2024   LOperand* temp1() { return temps_[0]; }
2025   LOperand* temp2() { return temps_[1]; }
2026
2027   DECLARE_CONCRETE_INSTRUCTION(NumberTagI, "number-tag-i")
2028 };
2029
2030
2031 class LNumberTagU final : public LTemplateInstruction<1, 1, 2> {
2032  public:
2033   LNumberTagU(LOperand* value, LOperand* temp1, LOperand* temp2) {
2034     inputs_[0] = value;
2035     temps_[0] = temp1;
2036     temps_[1] = temp2;
2037   }
2038
2039   LOperand* value() { return inputs_[0]; }
2040   LOperand* temp1() { return temps_[0]; }
2041   LOperand* temp2() { return temps_[1]; }
2042
2043   DECLARE_CONCRETE_INSTRUCTION(NumberTagU, "number-tag-u")
2044 };
2045
2046
2047 class LNumberTagD final : public LTemplateInstruction<1, 1, 1> {
2048  public:
2049   explicit LNumberTagD(LOperand* value, LOperand* temp) {
2050     inputs_[0] = value;
2051     temps_[0] = temp;
2052   }
2053
2054   LOperand* value() { return inputs_[0]; }
2055   LOperand* temp() { return temps_[0]; }
2056
2057   DECLARE_CONCRETE_INSTRUCTION(NumberTagD, "number-tag-d")
2058   DECLARE_HYDROGEN_ACCESSOR(Change)
2059 };
2060
2061
2062 // Sometimes truncating conversion from a tagged value to an int32.
2063 class LDoubleToI final : public LTemplateInstruction<1, 1, 0> {
2064  public:
2065   explicit LDoubleToI(LOperand* value) {
2066     inputs_[0] = value;
2067   }
2068
2069   LOperand* value() { return inputs_[0]; }
2070
2071   DECLARE_CONCRETE_INSTRUCTION(DoubleToI, "double-to-i")
2072   DECLARE_HYDROGEN_ACCESSOR(UnaryOperation)
2073
2074   bool truncating() { return hydrogen()->CanTruncateToInt32(); }
2075 };
2076
2077
2078 class LDoubleToSmi final : public LTemplateInstruction<1, 1, 0> {
2079  public:
2080   explicit LDoubleToSmi(LOperand* value) {
2081     inputs_[0] = value;
2082   }
2083
2084   LOperand* value() { return inputs_[0]; }
2085
2086   DECLARE_CONCRETE_INSTRUCTION(DoubleToSmi, "double-to-smi")
2087   DECLARE_HYDROGEN_ACCESSOR(UnaryOperation)
2088 };
2089
2090
2091 // Truncating conversion from a tagged value to an int32.
2092 class LTaggedToI final : public LTemplateInstruction<1, 1, 1> {
2093  public:
2094   LTaggedToI(LOperand* value, LOperand* temp) {
2095     inputs_[0] = value;
2096     temps_[0] = temp;
2097   }
2098
2099   LOperand* value() { return inputs_[0]; }
2100   LOperand* temp() { return temps_[0]; }
2101
2102   DECLARE_CONCRETE_INSTRUCTION(TaggedToI, "tagged-to-i")
2103   DECLARE_HYDROGEN_ACCESSOR(Change)
2104
2105   bool truncating() { return hydrogen()->CanTruncateToInt32(); }
2106 };
2107
2108
2109 class LSmiTag final : public LTemplateInstruction<1, 1, 0> {
2110  public:
2111   explicit LSmiTag(LOperand* value) {
2112     inputs_[0] = value;
2113   }
2114
2115   LOperand* value() { return inputs_[0]; }
2116
2117   DECLARE_CONCRETE_INSTRUCTION(SmiTag, "smi-tag")
2118   DECLARE_HYDROGEN_ACCESSOR(Change)
2119 };
2120
2121
2122 class LNumberUntagD final : public LTemplateInstruction<1, 1, 0> {
2123  public:
2124   explicit LNumberUntagD(LOperand* value) {
2125     inputs_[0] = value;
2126   }
2127
2128   LOperand* value() { return inputs_[0]; }
2129
2130   DECLARE_CONCRETE_INSTRUCTION(NumberUntagD, "double-untag")
2131   DECLARE_HYDROGEN_ACCESSOR(Change);
2132 };
2133
2134
2135 class LSmiUntag final : public LTemplateInstruction<1, 1, 0> {
2136  public:
2137   LSmiUntag(LOperand* value, bool needs_check)
2138       : needs_check_(needs_check) {
2139     inputs_[0] = value;
2140   }
2141
2142   LOperand* value() { return inputs_[0]; }
2143   bool needs_check() const { return needs_check_; }
2144
2145   DECLARE_CONCRETE_INSTRUCTION(SmiUntag, "smi-untag")
2146
2147  private:
2148   bool needs_check_;
2149 };
2150
2151
2152 class LStoreNamedField final : public LTemplateInstruction<0, 2, 1> {
2153  public:
2154   LStoreNamedField(LOperand* object, LOperand* value, LOperand* temp) {
2155     inputs_[0] = object;
2156     inputs_[1] = value;
2157     temps_[0] = temp;
2158   }
2159
2160   LOperand* object() { return inputs_[0]; }
2161   LOperand* value() { return inputs_[1]; }
2162   LOperand* temp() { return temps_[0]; }
2163
2164   DECLARE_CONCRETE_INSTRUCTION(StoreNamedField, "store-named-field")
2165   DECLARE_HYDROGEN_ACCESSOR(StoreNamedField)
2166
2167   void PrintDataTo(StringStream* stream) override;
2168
2169   Representation representation() const {
2170     return hydrogen()->field_representation();
2171   }
2172 };
2173
2174
2175 class LStoreNamedGeneric final : public LTemplateInstruction<0, 3, 0> {
2176  public:
2177   LStoreNamedGeneric(LOperand* context, LOperand* object, LOperand* value) {
2178     inputs_[0] = context;
2179     inputs_[1] = object;
2180     inputs_[2] = value;
2181   }
2182
2183   LOperand* context() { return inputs_[0]; }
2184   LOperand* object() { return inputs_[1]; }
2185   LOperand* value() { return inputs_[2]; }
2186
2187   DECLARE_CONCRETE_INSTRUCTION(StoreNamedGeneric, "store-named-generic")
2188   DECLARE_HYDROGEN_ACCESSOR(StoreNamedGeneric)
2189
2190   void PrintDataTo(StringStream* stream) override;
2191
2192   Handle<Object> name() const { return hydrogen()->name(); }
2193   LanguageMode language_mode() { return hydrogen()->language_mode(); }
2194 };
2195
2196
2197 class LStoreKeyed final : public LTemplateInstruction<0, 3, 0> {
2198  public:
2199   LStoreKeyed(LOperand* object, LOperand* key, LOperand* value) {
2200     inputs_[0] = object;
2201     inputs_[1] = key;
2202     inputs_[2] = value;
2203   }
2204
2205   bool is_external() const { return hydrogen()->is_external(); }
2206   bool is_fixed_typed_array() const {
2207     return hydrogen()->is_fixed_typed_array();
2208   }
2209   bool is_typed_elements() const {
2210     return is_external() || is_fixed_typed_array();
2211   }
2212   LOperand* elements() { return inputs_[0]; }
2213   LOperand* key() { return inputs_[1]; }
2214   LOperand* value() { return inputs_[2]; }
2215   ElementsKind elements_kind() const { return hydrogen()->elements_kind(); }
2216
2217   DECLARE_CONCRETE_INSTRUCTION(StoreKeyed, "store-keyed")
2218   DECLARE_HYDROGEN_ACCESSOR(StoreKeyed)
2219
2220   void PrintDataTo(StringStream* stream) override;
2221   bool NeedsCanonicalization() { return hydrogen()->NeedsCanonicalization(); }
2222   uint32_t base_offset() const { return hydrogen()->base_offset(); }
2223 };
2224
2225
2226 class LStoreKeyedGeneric final : public LTemplateInstruction<0, 4, 0> {
2227  public:
2228   LStoreKeyedGeneric(LOperand* context,
2229                      LOperand* object,
2230                      LOperand* key,
2231                      LOperand* value) {
2232     inputs_[0] = context;
2233     inputs_[1] = object;
2234     inputs_[2] = key;
2235     inputs_[3] = value;
2236   }
2237
2238   LOperand* context() { return inputs_[0]; }
2239   LOperand* object() { return inputs_[1]; }
2240   LOperand* key() { return inputs_[2]; }
2241   LOperand* value() { return inputs_[3]; }
2242
2243   DECLARE_CONCRETE_INSTRUCTION(StoreKeyedGeneric, "store-keyed-generic")
2244   DECLARE_HYDROGEN_ACCESSOR(StoreKeyedGeneric)
2245
2246   void PrintDataTo(StringStream* stream) override;
2247
2248   LanguageMode language_mode() { return hydrogen()->language_mode(); }
2249 };
2250
2251
2252 class LTransitionElementsKind final : public LTemplateInstruction<0, 2, 2> {
2253  public:
2254   LTransitionElementsKind(LOperand* object,
2255                           LOperand* context,
2256                           LOperand* new_map_temp,
2257                           LOperand* temp) {
2258     inputs_[0] = object;
2259     inputs_[1] = context;
2260     temps_[0] = new_map_temp;
2261     temps_[1] = temp;
2262   }
2263
2264   LOperand* object() { return inputs_[0]; }
2265   LOperand* context() { return inputs_[1]; }
2266   LOperand* new_map_temp() { return temps_[0]; }
2267   LOperand* temp() { return temps_[1]; }
2268
2269   DECLARE_CONCRETE_INSTRUCTION(TransitionElementsKind,
2270                                "transition-elements-kind")
2271   DECLARE_HYDROGEN_ACCESSOR(TransitionElementsKind)
2272
2273   void PrintDataTo(StringStream* stream) override;
2274
2275   Handle<Map> original_map() { return hydrogen()->original_map().handle(); }
2276   Handle<Map> transitioned_map() {
2277     return hydrogen()->transitioned_map().handle();
2278   }
2279   ElementsKind from_kind() { return hydrogen()->from_kind(); }
2280   ElementsKind to_kind() { return hydrogen()->to_kind(); }
2281 };
2282
2283
2284 class LTrapAllocationMemento final : public LTemplateInstruction<0, 1, 1> {
2285  public:
2286   LTrapAllocationMemento(LOperand* object,
2287                          LOperand* temp) {
2288     inputs_[0] = object;
2289     temps_[0] = temp;
2290   }
2291
2292   LOperand* object() { return inputs_[0]; }
2293   LOperand* temp() { return temps_[0]; }
2294
2295   DECLARE_CONCRETE_INSTRUCTION(TrapAllocationMemento,
2296                                "trap-allocation-memento")
2297 };
2298
2299
2300 class LMaybeGrowElements final : public LTemplateInstruction<1, 5, 0> {
2301  public:
2302   LMaybeGrowElements(LOperand* context, LOperand* object, LOperand* elements,
2303                      LOperand* key, LOperand* current_capacity) {
2304     inputs_[0] = context;
2305     inputs_[1] = object;
2306     inputs_[2] = elements;
2307     inputs_[3] = key;
2308     inputs_[4] = current_capacity;
2309   }
2310
2311   LOperand* context() { return inputs_[0]; }
2312   LOperand* object() { return inputs_[1]; }
2313   LOperand* elements() { return inputs_[2]; }
2314   LOperand* key() { return inputs_[3]; }
2315   LOperand* current_capacity() { return inputs_[4]; }
2316
2317   DECLARE_HYDROGEN_ACCESSOR(MaybeGrowElements)
2318   DECLARE_CONCRETE_INSTRUCTION(MaybeGrowElements, "maybe-grow-elements")
2319 };
2320
2321
2322 class LStringAdd final : public LTemplateInstruction<1, 3, 0> {
2323  public:
2324   LStringAdd(LOperand* context, LOperand* left, LOperand* right) {
2325     inputs_[0] = context;
2326     inputs_[1] = left;
2327     inputs_[2] = right;
2328   }
2329
2330   LOperand* context() { return inputs_[0]; }
2331   LOperand* left() { return inputs_[1]; }
2332   LOperand* right() { return inputs_[2]; }
2333
2334   DECLARE_CONCRETE_INSTRUCTION(StringAdd, "string-add")
2335   DECLARE_HYDROGEN_ACCESSOR(StringAdd)
2336 };
2337
2338
2339 class LStringCharCodeAt final : public LTemplateInstruction<1, 3, 0> {
2340  public:
2341   LStringCharCodeAt(LOperand* context, LOperand* string, LOperand* index) {
2342     inputs_[0] = context;
2343     inputs_[1] = string;
2344     inputs_[2] = index;
2345   }
2346
2347   LOperand* context() { return inputs_[0]; }
2348   LOperand* string() { return inputs_[1]; }
2349   LOperand* index() { return inputs_[2]; }
2350
2351   DECLARE_CONCRETE_INSTRUCTION(StringCharCodeAt, "string-char-code-at")
2352   DECLARE_HYDROGEN_ACCESSOR(StringCharCodeAt)
2353 };
2354
2355
2356 class LStringCharFromCode final : public LTemplateInstruction<1, 2, 0> {
2357  public:
2358   explicit LStringCharFromCode(LOperand* context, LOperand* char_code) {
2359     inputs_[0] = context;
2360     inputs_[1] = char_code;
2361   }
2362
2363   LOperand* context() { return inputs_[0]; }
2364   LOperand* char_code() { return inputs_[1]; }
2365
2366   DECLARE_CONCRETE_INSTRUCTION(StringCharFromCode, "string-char-from-code")
2367   DECLARE_HYDROGEN_ACCESSOR(StringCharFromCode)
2368 };
2369
2370
2371 class LCheckValue final : public LTemplateInstruction<0, 1, 0> {
2372  public:
2373   explicit LCheckValue(LOperand* value) {
2374     inputs_[0] = value;
2375   }
2376
2377   LOperand* value() { return inputs_[0]; }
2378
2379   DECLARE_CONCRETE_INSTRUCTION(CheckValue, "check-value")
2380   DECLARE_HYDROGEN_ACCESSOR(CheckValue)
2381 };
2382
2383
2384 class LCheckArrayBufferNotNeutered final
2385     : public LTemplateInstruction<0, 1, 0> {
2386  public:
2387   explicit LCheckArrayBufferNotNeutered(LOperand* view) { inputs_[0] = view; }
2388
2389   LOperand* view() { return inputs_[0]; }
2390
2391   DECLARE_CONCRETE_INSTRUCTION(CheckArrayBufferNotNeutered,
2392                                "check-array-buffer-not-neutered")
2393   DECLARE_HYDROGEN_ACCESSOR(CheckArrayBufferNotNeutered)
2394 };
2395
2396
2397 class LCheckInstanceType final : public LTemplateInstruction<0, 1, 0> {
2398  public:
2399   explicit LCheckInstanceType(LOperand* value) {
2400     inputs_[0] = value;
2401   }
2402
2403   LOperand* value() { return inputs_[0]; }
2404
2405   DECLARE_CONCRETE_INSTRUCTION(CheckInstanceType, "check-instance-type")
2406   DECLARE_HYDROGEN_ACCESSOR(CheckInstanceType)
2407 };
2408
2409
2410 class LCheckMaps final : public LTemplateInstruction<0, 1, 0> {
2411  public:
2412   explicit LCheckMaps(LOperand* value = NULL) {
2413     inputs_[0] = value;
2414   }
2415
2416   LOperand* value() { return inputs_[0]; }
2417
2418   DECLARE_CONCRETE_INSTRUCTION(CheckMaps, "check-maps")
2419   DECLARE_HYDROGEN_ACCESSOR(CheckMaps)
2420 };
2421
2422
2423 class LCheckSmi final : public LTemplateInstruction<1, 1, 0> {
2424  public:
2425   explicit LCheckSmi(LOperand* value) {
2426     inputs_[0] = value;
2427   }
2428
2429   LOperand* value() { return inputs_[0]; }
2430
2431   DECLARE_CONCRETE_INSTRUCTION(CheckSmi, "check-smi")
2432 };
2433
2434
2435 class LClampDToUint8 final : public LTemplateInstruction<1, 1, 0> {
2436  public:
2437   explicit LClampDToUint8(LOperand* unclamped) {
2438     inputs_[0] = unclamped;
2439   }
2440
2441   LOperand* unclamped() { return inputs_[0]; }
2442
2443   DECLARE_CONCRETE_INSTRUCTION(ClampDToUint8, "clamp-d-to-uint8")
2444 };
2445
2446
2447 class LClampIToUint8 final : public LTemplateInstruction<1, 1, 0> {
2448  public:
2449   explicit LClampIToUint8(LOperand* unclamped) {
2450     inputs_[0] = unclamped;
2451   }
2452
2453   LOperand* unclamped() { return inputs_[0]; }
2454
2455   DECLARE_CONCRETE_INSTRUCTION(ClampIToUint8, "clamp-i-to-uint8")
2456 };
2457
2458
2459 class LClampTToUint8 final : public LTemplateInstruction<1, 1, 1> {
2460  public:
2461   LClampTToUint8(LOperand* unclamped,
2462                  LOperand* temp_xmm) {
2463     inputs_[0] = unclamped;
2464     temps_[0] = temp_xmm;
2465   }
2466
2467   LOperand* unclamped() { return inputs_[0]; }
2468   LOperand* temp_xmm() { return temps_[0]; }
2469
2470   DECLARE_CONCRETE_INSTRUCTION(ClampTToUint8, "clamp-t-to-uint8")
2471 };
2472
2473
2474 class LCheckNonSmi final : public LTemplateInstruction<0, 1, 0> {
2475  public:
2476   explicit LCheckNonSmi(LOperand* value) {
2477     inputs_[0] = value;
2478   }
2479
2480   LOperand* value() { return inputs_[0]; }
2481
2482   DECLARE_CONCRETE_INSTRUCTION(CheckNonSmi, "check-non-smi")
2483   DECLARE_HYDROGEN_ACCESSOR(CheckHeapObject)
2484 };
2485
2486
2487 class LDoubleBits final : public LTemplateInstruction<1, 1, 0> {
2488  public:
2489   explicit LDoubleBits(LOperand* value) {
2490     inputs_[0] = value;
2491   }
2492
2493   LOperand* value() { return inputs_[0]; }
2494
2495   DECLARE_CONCRETE_INSTRUCTION(DoubleBits, "double-bits")
2496   DECLARE_HYDROGEN_ACCESSOR(DoubleBits)
2497 };
2498
2499
2500 class LConstructDouble final : public LTemplateInstruction<1, 2, 0> {
2501  public:
2502   LConstructDouble(LOperand* hi, LOperand* lo) {
2503     inputs_[0] = hi;
2504     inputs_[1] = lo;
2505   }
2506
2507   LOperand* hi() { return inputs_[0]; }
2508   LOperand* lo() { return inputs_[1]; }
2509
2510   DECLARE_CONCRETE_INSTRUCTION(ConstructDouble, "construct-double")
2511 };
2512
2513
2514 class LAllocate final : public LTemplateInstruction<1, 2, 1> {
2515  public:
2516   LAllocate(LOperand* context, LOperand* size, LOperand* temp) {
2517     inputs_[0] = context;
2518     inputs_[1] = size;
2519     temps_[0] = temp;
2520   }
2521
2522   LOperand* context() { return inputs_[0]; }
2523   LOperand* size() { return inputs_[1]; }
2524   LOperand* temp() { return temps_[0]; }
2525
2526   DECLARE_CONCRETE_INSTRUCTION(Allocate, "allocate")
2527   DECLARE_HYDROGEN_ACCESSOR(Allocate)
2528 };
2529
2530
2531 class LRegExpLiteral final : public LTemplateInstruction<1, 1, 0> {
2532  public:
2533   explicit LRegExpLiteral(LOperand* context) {
2534     inputs_[0] = context;
2535   }
2536
2537   LOperand* context() { return inputs_[0]; }
2538
2539   DECLARE_CONCRETE_INSTRUCTION(RegExpLiteral, "regexp-literal")
2540   DECLARE_HYDROGEN_ACCESSOR(RegExpLiteral)
2541 };
2542
2543
2544 class LFunctionLiteral final : public LTemplateInstruction<1, 1, 0> {
2545  public:
2546   explicit LFunctionLiteral(LOperand* context) {
2547     inputs_[0] = context;
2548   }
2549
2550   LOperand* context() { return inputs_[0]; }
2551
2552   DECLARE_CONCRETE_INSTRUCTION(FunctionLiteral, "function-literal")
2553   DECLARE_HYDROGEN_ACCESSOR(FunctionLiteral)
2554 };
2555
2556
2557 class LToFastProperties final : public LTemplateInstruction<1, 1, 0> {
2558  public:
2559   explicit LToFastProperties(LOperand* value) {
2560     inputs_[0] = value;
2561   }
2562
2563   LOperand* value() { return inputs_[0]; }
2564
2565   DECLARE_CONCRETE_INSTRUCTION(ToFastProperties, "to-fast-properties")
2566   DECLARE_HYDROGEN_ACCESSOR(ToFastProperties)
2567 };
2568
2569
2570 class LTypeof final : public LTemplateInstruction<1, 2, 0> {
2571  public:
2572   LTypeof(LOperand* context, LOperand* value) {
2573     inputs_[0] = context;
2574     inputs_[1] = value;
2575   }
2576
2577   LOperand* context() { return inputs_[0]; }
2578   LOperand* value() { return inputs_[1]; }
2579
2580   DECLARE_CONCRETE_INSTRUCTION(Typeof, "typeof")
2581 };
2582
2583
2584 class LTypeofIsAndBranch final : public LControlInstruction<1, 0> {
2585  public:
2586   explicit LTypeofIsAndBranch(LOperand* value) {
2587     inputs_[0] = value;
2588   }
2589
2590   LOperand* value() { return inputs_[0]; }
2591
2592   DECLARE_CONCRETE_INSTRUCTION(TypeofIsAndBranch, "typeof-is-and-branch")
2593   DECLARE_HYDROGEN_ACCESSOR(TypeofIsAndBranch)
2594
2595   Handle<String> type_literal() { return hydrogen()->type_literal(); }
2596
2597   void PrintDataTo(StringStream* stream) override;
2598 };
2599
2600
2601 class LIsConstructCallAndBranch final : public LControlInstruction<0, 1> {
2602  public:
2603   explicit LIsConstructCallAndBranch(LOperand* temp) {
2604     temps_[0] = temp;
2605   }
2606
2607   LOperand* temp() { return temps_[0]; }
2608
2609   DECLARE_CONCRETE_INSTRUCTION(IsConstructCallAndBranch,
2610                                "is-construct-call-and-branch")
2611   DECLARE_HYDROGEN_ACCESSOR(IsConstructCallAndBranch)
2612 };
2613
2614
2615 class LOsrEntry final : public LTemplateInstruction<0, 0, 0> {
2616  public:
2617   LOsrEntry() {}
2618
2619   bool HasInterestingComment(LCodeGen* gen) const override { return false; }
2620   DECLARE_CONCRETE_INSTRUCTION(OsrEntry, "osr-entry")
2621 };
2622
2623
2624 class LStackCheck final : public LTemplateInstruction<0, 1, 0> {
2625  public:
2626   explicit LStackCheck(LOperand* context) {
2627     inputs_[0] = context;
2628   }
2629
2630   LOperand* context() { return inputs_[0]; }
2631
2632   DECLARE_CONCRETE_INSTRUCTION(StackCheck, "stack-check")
2633   DECLARE_HYDROGEN_ACCESSOR(StackCheck)
2634
2635   Label* done_label() { return &done_label_; }
2636
2637  private:
2638   Label done_label_;
2639 };
2640
2641
2642 class LForInPrepareMap final : public LTemplateInstruction<1, 2, 0> {
2643  public:
2644   LForInPrepareMap(LOperand* context, LOperand* object) {
2645     inputs_[0] = context;
2646     inputs_[1] = object;
2647   }
2648
2649   LOperand* context() { return inputs_[0]; }
2650   LOperand* object() { return inputs_[1]; }
2651
2652   DECLARE_CONCRETE_INSTRUCTION(ForInPrepareMap, "for-in-prepare-map")
2653 };
2654
2655
2656 class LForInCacheArray final : public LTemplateInstruction<1, 1, 0> {
2657  public:
2658   explicit LForInCacheArray(LOperand* map) {
2659     inputs_[0] = map;
2660   }
2661
2662   LOperand* map() { return inputs_[0]; }
2663
2664   DECLARE_CONCRETE_INSTRUCTION(ForInCacheArray, "for-in-cache-array")
2665
2666   int idx() {
2667     return HForInCacheArray::cast(this->hydrogen_value())->idx();
2668   }
2669 };
2670
2671
2672 class LCheckMapValue final : public LTemplateInstruction<0, 2, 0> {
2673  public:
2674   LCheckMapValue(LOperand* value, LOperand* map) {
2675     inputs_[0] = value;
2676     inputs_[1] = map;
2677   }
2678
2679   LOperand* value() { return inputs_[0]; }
2680   LOperand* map() { return inputs_[1]; }
2681
2682   DECLARE_CONCRETE_INSTRUCTION(CheckMapValue, "check-map-value")
2683 };
2684
2685
2686 class LLoadFieldByIndex final : public LTemplateInstruction<1, 2, 0> {
2687  public:
2688   LLoadFieldByIndex(LOperand* object, LOperand* index) {
2689     inputs_[0] = object;
2690     inputs_[1] = index;
2691   }
2692
2693   LOperand* object() { return inputs_[0]; }
2694   LOperand* index() { return inputs_[1]; }
2695
2696   DECLARE_CONCRETE_INSTRUCTION(LoadFieldByIndex, "load-field-by-index")
2697 };
2698
2699
2700 class LStoreFrameContext: public LTemplateInstruction<0, 1, 0> {
2701  public:
2702   explicit LStoreFrameContext(LOperand* context) {
2703     inputs_[0] = context;
2704   }
2705
2706   LOperand* context() { return inputs_[0]; }
2707
2708   DECLARE_CONCRETE_INSTRUCTION(StoreFrameContext, "store-frame-context")
2709 };
2710
2711
2712 class LAllocateBlockContext: public LTemplateInstruction<1, 2, 0> {
2713  public:
2714   LAllocateBlockContext(LOperand* context, LOperand* function) {
2715     inputs_[0] = context;
2716     inputs_[1] = function;
2717   }
2718
2719   LOperand* context() { return inputs_[0]; }
2720   LOperand* function() { return inputs_[1]; }
2721
2722   Handle<ScopeInfo> scope_info() { return hydrogen()->scope_info(); }
2723
2724   DECLARE_CONCRETE_INSTRUCTION(AllocateBlockContext, "allocate-block-context")
2725   DECLARE_HYDROGEN_ACCESSOR(AllocateBlockContext)
2726 };
2727
2728
2729 class LChunkBuilder;
2730 class LPlatformChunk final : public LChunk {
2731  public:
2732   LPlatformChunk(CompilationInfo* info, HGraph* graph)
2733       : LChunk(info, graph),
2734         dehoisted_key_ids_(graph->GetMaximumValueID(), graph->zone()) { }
2735
2736   int GetNextSpillIndex(RegisterKind kind);
2737   LOperand* GetNextSpillSlot(RegisterKind kind);
2738   BitVector* GetDehoistedKeyIds() { return &dehoisted_key_ids_; }
2739   bool IsDehoistedKey(HValue* value) {
2740     return dehoisted_key_ids_.Contains(value->id());
2741   }
2742
2743  private:
2744   BitVector dehoisted_key_ids_;
2745 };
2746
2747
2748 class LChunkBuilder final : public LChunkBuilderBase {
2749  public:
2750   LChunkBuilder(CompilationInfo* info, HGraph* graph, LAllocator* allocator)
2751       : LChunkBuilderBase(info, graph),
2752         current_instruction_(NULL),
2753         current_block_(NULL),
2754         next_block_(NULL),
2755         allocator_(allocator) {}
2756
2757   // Build the sequence for the graph.
2758   LPlatformChunk* Build();
2759
2760   // Declare methods that deal with the individual node types.
2761 #define DECLARE_DO(type) LInstruction* Do##type(H##type* node);
2762   HYDROGEN_CONCRETE_INSTRUCTION_LIST(DECLARE_DO)
2763 #undef DECLARE_DO
2764
2765   LInstruction* DoMathFloor(HUnaryMathOperation* instr);
2766   LInstruction* DoMathRound(HUnaryMathOperation* instr);
2767   LInstruction* DoMathFround(HUnaryMathOperation* instr);
2768   LInstruction* DoMathAbs(HUnaryMathOperation* instr);
2769   LInstruction* DoMathLog(HUnaryMathOperation* instr);
2770   LInstruction* DoMathExp(HUnaryMathOperation* instr);
2771   LInstruction* DoMathSqrt(HUnaryMathOperation* instr);
2772   LInstruction* DoMathPowHalf(HUnaryMathOperation* instr);
2773   LInstruction* DoMathClz32(HUnaryMathOperation* instr);
2774   LInstruction* DoDivByPowerOf2I(HDiv* instr);
2775   LInstruction* DoDivByConstI(HDiv* instr);
2776   LInstruction* DoDivI(HDiv* instr);
2777   LInstruction* DoModByPowerOf2I(HMod* instr);
2778   LInstruction* DoModByConstI(HMod* instr);
2779   LInstruction* DoModI(HMod* instr);
2780   LInstruction* DoFlooringDivByPowerOf2I(HMathFloorOfDiv* instr);
2781   LInstruction* DoFlooringDivByConstI(HMathFloorOfDiv* instr);
2782   LInstruction* DoFlooringDivI(HMathFloorOfDiv* instr);
2783
2784  private:
2785   // Methods for getting operands for Use / Define / Temp.
2786   LUnallocated* ToUnallocated(Register reg);
2787   LUnallocated* ToUnallocated(XMMRegister reg);
2788
2789   // Methods for setting up define-use relationships.
2790   MUST_USE_RESULT LOperand* Use(HValue* value, LUnallocated* operand);
2791   MUST_USE_RESULT LOperand* UseFixed(HValue* value, Register fixed_register);
2792   MUST_USE_RESULT LOperand* UseFixedDouble(HValue* value,
2793                                            XMMRegister fixed_register);
2794
2795   // A value that is guaranteed to be allocated to a register.
2796   // Operand created by UseRegister is guaranteed to be live until the end of
2797   // instruction. This means that register allocator will not reuse it's
2798   // register for any other operand inside instruction.
2799   // Operand created by UseRegisterAtStart is guaranteed to be live only at
2800   // instruction start. Register allocator is free to assign the same register
2801   // to some other operand used inside instruction (i.e. temporary or
2802   // output).
2803   MUST_USE_RESULT LOperand* UseRegister(HValue* value);
2804   MUST_USE_RESULT LOperand* UseRegisterAtStart(HValue* value);
2805
2806   // An input operand in a register that may be trashed.
2807   MUST_USE_RESULT LOperand* UseTempRegister(HValue* value);
2808
2809   // An input operand in a register that may be trashed or a constant operand.
2810   MUST_USE_RESULT LOperand* UseTempRegisterOrConstant(HValue* value);
2811
2812   // An input operand in a register or stack slot.
2813   MUST_USE_RESULT LOperand* Use(HValue* value);
2814   MUST_USE_RESULT LOperand* UseAtStart(HValue* value);
2815
2816   // An input operand in a register, stack slot or a constant operand.
2817   MUST_USE_RESULT LOperand* UseOrConstant(HValue* value);
2818   MUST_USE_RESULT LOperand* UseOrConstantAtStart(HValue* value);
2819
2820   // An input operand in a register or a constant operand.
2821   MUST_USE_RESULT LOperand* UseRegisterOrConstant(HValue* value);
2822   MUST_USE_RESULT LOperand* UseRegisterOrConstantAtStart(HValue* value);
2823
2824   // An input operand in a constant operand.
2825   MUST_USE_RESULT LOperand* UseConstant(HValue* value);
2826
2827   // An input operand in register, stack slot or a constant operand.
2828   // Will not be moved to a register even if one is freely available.
2829   MUST_USE_RESULT LOperand* UseAny(HValue* value) override;
2830
2831   // Temporary operand that must be in a register.
2832   MUST_USE_RESULT LUnallocated* TempRegister();
2833   MUST_USE_RESULT LOperand* FixedTemp(Register reg);
2834   MUST_USE_RESULT LOperand* FixedTemp(XMMRegister reg);
2835
2836   // Methods for setting up define-use relationships.
2837   // Return the same instruction that they are passed.
2838   LInstruction* Define(LTemplateResultInstruction<1>* instr,
2839                        LUnallocated* result);
2840   LInstruction* DefineAsRegister(LTemplateResultInstruction<1>* instr);
2841   LInstruction* DefineAsSpilled(LTemplateResultInstruction<1>* instr,
2842                                 int index);
2843   LInstruction* DefineSameAsFirst(LTemplateResultInstruction<1>* instr);
2844   LInstruction* DefineFixed(LTemplateResultInstruction<1>* instr,
2845                             Register reg);
2846   LInstruction* DefineFixedDouble(LTemplateResultInstruction<1>* instr,
2847                                   XMMRegister reg);
2848   // Assigns an environment to an instruction.  An instruction which can
2849   // deoptimize must have an environment.
2850   LInstruction* AssignEnvironment(LInstruction* instr);
2851   // Assigns a pointer map to an instruction.  An instruction which can
2852   // trigger a GC or a lazy deoptimization must have a pointer map.
2853   LInstruction* AssignPointerMap(LInstruction* instr);
2854
2855   enum CanDeoptimize { CAN_DEOPTIMIZE_EAGERLY, CANNOT_DEOPTIMIZE_EAGERLY };
2856
2857   // Marks a call for the register allocator.  Assigns a pointer map to
2858   // support GC and lazy deoptimization.  Assigns an environment to support
2859   // eager deoptimization if CAN_DEOPTIMIZE_EAGERLY.
2860   LInstruction* MarkAsCall(
2861       LInstruction* instr,
2862       HInstruction* hinstr,
2863       CanDeoptimize can_deoptimize = CANNOT_DEOPTIMIZE_EAGERLY);
2864
2865   void VisitInstruction(HInstruction* current);
2866   void AddInstruction(LInstruction* instr, HInstruction* current);
2867
2868   void DoBasicBlock(HBasicBlock* block, HBasicBlock* next_block);
2869   LInstruction* DoShift(Token::Value op, HBitwiseBinaryOperation* instr);
2870   LInstruction* DoArithmeticD(Token::Value op,
2871                               HArithmeticBinaryOperation* instr);
2872   LInstruction* DoArithmeticT(Token::Value op,
2873                               HBinaryOperation* instr);
2874   void FindDehoistedKeyDefinitions(HValue* candidate);
2875
2876   HInstruction* current_instruction_;
2877   HBasicBlock* current_block_;
2878   HBasicBlock* next_block_;
2879   LAllocator* allocator_;
2880
2881   DISALLOW_COPY_AND_ASSIGN(LChunkBuilder);
2882 };
2883
2884 #undef DECLARE_HYDROGEN_ACCESSOR
2885 #undef DECLARE_CONCRETE_INSTRUCTION
2886
2887 } }  // namespace v8::int
2888
2889 #endif  // V8_X64_LITHIUM_X64_H_