lithium-x64.h 79.2 KB
Newer Older
1
// Copyright 2012 the V8 project authors. All rights reserved.
2 3
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
4 5 6 7

#ifndef V8_X64_LITHIUM_X64_H_
#define V8_X64_LITHIUM_X64_H_

8 9
#include "src/hydrogen.h"
#include "src/lithium.h"
10
#include "src/lithium-allocator.h"
11 12
#include "src/safepoint-table.h"
#include "src/utils.h"
13 14 15 16 17 18 19

namespace v8 {
namespace internal {

// Forward declarations.
class LCodeGen;

20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151
#define LITHIUM_CONCRETE_INSTRUCTION_LIST(V) \
  V(AccessArgumentsAt)                       \
  V(AddI)                                    \
  V(Allocate)                                \
  V(AllocateBlockContext)                    \
  V(ApplyArguments)                          \
  V(ArgumentsElements)                       \
  V(ArgumentsLength)                         \
  V(ArithmeticD)                             \
  V(ArithmeticT)                             \
  V(BitI)                                    \
  V(BoundsCheck)                             \
  V(Branch)                                  \
  V(CallJSFunction)                          \
  V(CallWithDescriptor)                      \
  V(CallFunction)                            \
  V(CallNew)                                 \
  V(CallNewArray)                            \
  V(CallRuntime)                             \
  V(CallStub)                                \
  V(CheckInstanceType)                       \
  V(CheckMaps)                               \
  V(CheckMapValue)                           \
  V(CheckNonSmi)                             \
  V(CheckSmi)                                \
  V(CheckValue)                              \
  V(ClampDToUint8)                           \
  V(ClampIToUint8)                           \
  V(ClampTToUint8)                           \
  V(ClassOfTestAndBranch)                    \
  V(CompareMinusZeroAndBranch)               \
  V(CompareNumericAndBranch)                 \
  V(CmpObjectEqAndBranch)                    \
  V(CmpHoleAndBranch)                        \
  V(CmpMapAndBranch)                         \
  V(CmpT)                                    \
  V(ConstantD)                               \
  V(ConstantE)                               \
  V(ConstantI)                               \
  V(ConstantS)                               \
  V(ConstantT)                               \
  V(ConstructDouble)                         \
  V(Context)                                 \
  V(DateField)                               \
  V(DebugBreak)                              \
  V(DeclareGlobals)                          \
  V(Deoptimize)                              \
  V(DivByConstI)                             \
  V(DivByPowerOf2I)                          \
  V(DivI)                                    \
  V(DoubleBits)                              \
  V(DoubleToI)                               \
  V(DoubleToSmi)                             \
  V(Drop)                                    \
  V(DummyUse)                                \
  V(Dummy)                                   \
  V(FlooringDivByConstI)                     \
  V(FlooringDivByPowerOf2I)                  \
  V(FlooringDivI)                            \
  V(ForInCacheArray)                         \
  V(ForInPrepareMap)                         \
  V(FunctionLiteral)                         \
  V(GetCachedArrayIndex)                     \
  V(Goto)                                    \
  V(HasCachedArrayIndexAndBranch)            \
  V(HasInstanceTypeAndBranch)                \
  V(InnerAllocatedObject)                    \
  V(InstanceOf)                              \
  V(InstanceOfKnownGlobal)                   \
  V(InstructionGap)                          \
  V(Integer32ToDouble)                       \
  V(InvokeFunction)                          \
  V(IsConstructCallAndBranch)                \
  V(IsObjectAndBranch)                       \
  V(IsStringAndBranch)                       \
  V(IsSmiAndBranch)                          \
  V(IsUndetectableAndBranch)                 \
  V(Label)                                   \
  V(LazyBailout)                             \
  V(LoadContextSlot)                         \
  V(LoadRoot)                                \
  V(LoadFieldByIndex)                        \
  V(LoadFunctionPrototype)                   \
  V(LoadGlobalGeneric)                       \
  V(LoadKeyed)                               \
  V(LoadKeyedGeneric)                        \
  V(LoadNamedField)                          \
  V(LoadNamedGeneric)                        \
  V(MapEnumLength)                           \
  V(MathAbs)                                 \
  V(MathClz32)                               \
  V(MathExp)                                 \
  V(MathFloor)                               \
  V(MathFround)                              \
  V(MathLog)                                 \
  V(MathMinMax)                              \
  V(MathPowHalf)                             \
  V(MathRound)                               \
  V(MathSqrt)                                \
  V(ModByConstI)                             \
  V(ModByPowerOf2I)                          \
  V(ModI)                                    \
  V(MulI)                                    \
  V(NumberTagD)                              \
  V(NumberTagI)                              \
  V(NumberTagU)                              \
  V(NumberUntagD)                            \
  V(OsrEntry)                                \
  V(Parameter)                               \
  V(Power)                                   \
  V(PushArgument)                            \
  V(RegExpLiteral)                           \
  V(Return)                                  \
  V(SeqStringGetChar)                        \
  V(SeqStringSetChar)                        \
  V(ShiftI)                                  \
  V(SmiTag)                                  \
  V(SmiUntag)                                \
  V(StackCheck)                              \
  V(StoreCodeEntry)                          \
  V(StoreContextSlot)                        \
  V(StoreFrameContext)                       \
  V(StoreKeyed)                              \
  V(StoreKeyedGeneric)                       \
  V(StoreNamedField)                         \
  V(StoreNamedGeneric)                       \
  V(StringAdd)                               \
  V(StringCharCodeAt)                        \
  V(StringCharFromCode)                      \
  V(StringCompareAndBranch)                  \
  V(SubI)                                    \
  V(TaggedToI)                               \
152
  V(TailCallThroughMegamorphicCache)         \
153 154 155 156 157 158 159 160
  V(ThisFunction)                            \
  V(ToFastProperties)                        \
  V(TransitionElementsKind)                  \
  V(TrapAllocationMemento)                   \
  V(Typeof)                                  \
  V(TypeofIsAndBranch)                       \
  V(Uint32ToDouble)                          \
  V(UnknownOSRValue)                         \
yangguo@chromium.org's avatar
yangguo@chromium.org committed
161
  V(WrapReceiver)
162 163


164 165 166 167 168 169 170
#define DECLARE_CONCRETE_INSTRUCTION(type, mnemonic)            \
  Opcode opcode() const FINAL { return LInstruction::k##type; } \
  void CompileToNative(LCodeGen* generator) FINAL;              \
  const char* Mnemonic() const FINAL { return mnemonic; }       \
  static L##type* cast(LInstruction* instr) {                   \
    DCHECK(instr->Is##type());                                  \
    return reinterpret_cast<L##type*>(instr);                   \
171 172 173 174 175 176 177 178 179
  }


#define DECLARE_HYDROGEN_ACCESSOR(type)     \
  H##type* hydrogen() const {               \
    return H##type::cast(hydrogen_value()); \
  }


180
class LInstruction : public ZoneObject {
181
 public:
182
  LInstruction()
183 184 185 186
      : environment_(NULL),
        hydrogen_value_(NULL),
        bit_field_(IsCallBits::encode(false)) {
  }
187

188
  virtual ~LInstruction() {}
189

190 191
  virtual void CompileToNative(LCodeGen* generator) = 0;
  virtual const char* Mnemonic() const = 0;
192
  virtual void PrintTo(StringStream* stream);
193 194
  virtual void PrintDataTo(StringStream* stream);
  virtual void PrintOutputOperandTo(StringStream* stream);
195

196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214
  enum Opcode {
    // Declare a unique enum value for each instruction.
#define DECLARE_OPCODE(type) k##type,
    LITHIUM_CONCRETE_INSTRUCTION_LIST(DECLARE_OPCODE)
    kNumberOfInstructions
#undef DECLARE_OPCODE
  };

  virtual Opcode opcode() const = 0;

  // Declare non-virtual type testers for all leaf IR classes.
#define DECLARE_PREDICATE(type) \
  bool Is##type() const { return opcode() == k##type; }
  LITHIUM_CONCRETE_INSTRUCTION_LIST(DECLARE_PREDICATE)
#undef DECLARE_PREDICATE

  // Declare virtual predicates for instructions that don't have
  // an opcode.
  virtual bool IsGap() const { return false; }
215

216 217
  virtual bool IsControl() const { return false; }

218 219 220
  // Try deleting this instruction if possible.
  virtual bool TryDelete() { return false; }

221 222 223
  void set_environment(LEnvironment* env) { environment_ = env; }
  LEnvironment* environment() const { return environment_; }
  bool HasEnvironment() const { return environment_ != NULL; }
224

225 226 227
  void set_pointer_map(LPointerMap* p) { pointer_map_.set(p); }
  LPointerMap* pointer_map() const { return pointer_map_.get(); }
  bool HasPointerMap() const { return pointer_map_.is_set(); }
228

229 230 231
  void set_hydrogen_value(HValue* value) { hydrogen_value_ = value; }
  HValue* hydrogen_value() const { return hydrogen_value_; }

232 233
  void MarkAsCall() { bit_field_ = IsCallBits::update(bit_field_, true); }
  bool IsCall() const { return IsCallBits::decode(bit_field_); }
234

235
  // Interface to the register allocator and iterators.
236 237
  bool ClobbersTemps() const { return IsCall(); }
  bool ClobbersRegisters() const { return IsCall(); }
238
  virtual bool ClobbersDoubleRegisters(Isolate* isolate) const {
239 240
    return IsCall();
  }
241

242
  virtual void SetDeferredLazyDeoptimizationEnvironment(LEnvironment* env) { }
243 244

  // Interface to the register allocator and iterators.
245
  bool IsMarkedAsCall() const { return IsCall(); }
246 247

  virtual bool HasResult() const = 0;
248
  virtual LOperand* result() const = 0;
249 250 251 252

  LOperand* FirstInput() { return InputAt(0); }
  LOperand* Output() { return HasResult() ? result() : NULL; }

253 254
  virtual bool HasInterestingComment(LCodeGen* gen) const { return true; }

255 256 257 258
  virtual bool MustSignExtendResult(LPlatformChunk* chunk) const {
    return false;
  }

259 260 261 262
#ifdef DEBUG
  void VerifyCall();
#endif

263 264 265
  virtual int InputCount() = 0;
  virtual LOperand* InputAt(int i) = 0;

266
 private:
267 268 269
  // Iterator support.
  friend class InputIterator;

270 271 272 273
  friend class TempIterator;
  virtual int TempCount() = 0;
  virtual LOperand* TempAt(int i) = 0;

274 275
  class IsCallBits: public BitField<bool, 0, 1> {};

276
  LEnvironment* environment_;
277 278
  SetOncePointer<LPointerMap> pointer_map_;
  HValue* hydrogen_value_;
279
  int bit_field_;
280 281 282
};


283
// R = number of result operands (0 or 1).
284 285
template<int R>
class LTemplateResultInstruction : public LInstruction {
286
 public:
287 288
  // Allow 0 or 1 output operands.
  STATIC_ASSERT(R == 0 || R == 1);
289
  bool HasResult() const FINAL { return R != 0 && result() != NULL; }
290
  void set_result(LOperand* operand) { results_[0] = operand; }
291
  LOperand* result() const OVERRIDE { return results_[0]; }
292

293
  bool MustSignExtendResult(LPlatformChunk* chunk) const FINAL;
294

295
 protected:
296
  EmbeddedContainer<LOperand*, R> results_;
297 298 299 300 301 302 303 304 305
};


// R = number of result operands (0 or 1).
// I = number of input operands.
// T = number of temporary operands.
template<int R, int I, int T>
class LTemplateInstruction : public LTemplateResultInstruction<R> {
 protected:
306 307
  EmbeddedContainer<LOperand*, I> inputs_;
  EmbeddedContainer<LOperand*, T> temps_;
308 309

 private:
310
  // Iterator support.
311 312
  int InputCount() FINAL { return I; }
  LOperand* InputAt(int i) FINAL { return inputs_[i]; }
313

314 315
  int TempCount() FINAL { return T; }
  LOperand* TempAt(int i) FINAL { return temps_[i]; }
316 317 318
};


319
class LGap : public LTemplateInstruction<0, 0, 0> {
320
 public:
321 322 323 324 325 326
  explicit LGap(HBasicBlock* block)
      : block_(block) {
    parallel_moves_[BEFORE] = NULL;
    parallel_moves_[START] = NULL;
    parallel_moves_[END] = NULL;
    parallel_moves_[AFTER] = NULL;
327 328
  }

329
  // Can't use the DECLARE-macro here because of sub-classes.
330 331
  bool IsGap() const FINAL { return true; }
  void PrintDataTo(StringStream* stream) OVERRIDE;
332
  static LGap* cast(LInstruction* instr) {
333
    DCHECK(instr->IsGap());
334 335
    return reinterpret_cast<LGap*>(instr);
  }
336

337
  bool IsRedundant() const;
338

339
  HBasicBlock* block() const { return block_; }
340 341 342 343 344 345 346 347 348 349

  enum InnerPosition {
    BEFORE,
    START,
    END,
    AFTER,
    FIRST_INNER_POSITION = BEFORE,
    LAST_INNER_POSITION = AFTER
  };

350 351 352 353 354
  LParallelMove* GetOrCreateParallelMove(InnerPosition pos,
                                         Zone* zone)  {
    if (parallel_moves_[pos] == NULL) {
      parallel_moves_[pos] = new(zone) LParallelMove(zone);
    }
355
    return parallel_moves_[pos];
356 357 358
  }

  LParallelMove* GetParallelMove(InnerPosition pos)  {
359
    return parallel_moves_[pos];
360
  }
361 362 363 364

 private:
  LParallelMove* parallel_moves_[LAST_INNER_POSITION + 1];
  HBasicBlock* block_;
365 366 367
};


368
class LInstructionGap FINAL : public LGap {
369 370 371
 public:
  explicit LInstructionGap(HBasicBlock* block) : LGap(block) { }

372
  bool HasInterestingComment(LCodeGen* gen) const OVERRIDE {
373 374 375
    return !IsRedundant();
  }

376 377 378 379
  DECLARE_CONCRETE_INSTRUCTION(InstructionGap, "gap")
};


380
class LGoto FINAL : public LTemplateInstruction<0, 0, 0> {
381
 public:
382
  explicit LGoto(HBasicBlock* block) : block_(block) { }
383

384
  bool HasInterestingComment(LCodeGen* gen) const OVERRIDE;
385
  DECLARE_CONCRETE_INSTRUCTION(Goto, "goto")
386 387
  void PrintDataTo(StringStream* stream) OVERRIDE;
  bool IsControl() const OVERRIDE { return true; }
388

389
  int block_id() const { return block_->block_id(); }
390 391

 private:
392
  HBasicBlock* block_;
393 394 395
};


396
class LLazyBailout FINAL : public LTemplateInstruction<0, 0, 0> {
397 398 399 400 401 402 403 404 405 406 407 408 409 410 411
 public:
  LLazyBailout() : gap_instructions_size_(0) { }

  DECLARE_CONCRETE_INSTRUCTION(LazyBailout, "lazy-bailout")

  void set_gap_instructions_size(int gap_instructions_size) {
    gap_instructions_size_ = gap_instructions_size;
  }
  int gap_instructions_size() { return gap_instructions_size_; }

 private:
  int gap_instructions_size_;
};


412
class LDummy FINAL : public LTemplateInstruction<1, 0, 0> {
413
 public:
414
  LDummy() {}
415 416 417 418
  DECLARE_CONCRETE_INSTRUCTION(Dummy, "dummy")
};


419
class LDummyUse FINAL : public LTemplateInstruction<1, 1, 0> {
420 421 422 423 424 425 426 427
 public:
  explicit LDummyUse(LOperand* value) {
    inputs_[0] = value;
  }
  DECLARE_CONCRETE_INSTRUCTION(DummyUse, "dummy-use")
};


428
class LDeoptimize FINAL : public LTemplateInstruction<0, 0, 0> {
429
 public:
430
  bool IsControl() const OVERRIDE { return true; }
431
  DECLARE_CONCRETE_INSTRUCTION(Deoptimize, "deoptimize")
432
  DECLARE_HYDROGEN_ACCESSOR(Deoptimize)
433 434 435
};


436
class LLabel FINAL : public LGap {
437
 public:
438
  explicit LLabel(HBasicBlock* block)
fschneider@chromium.org's avatar
fschneider@chromium.org committed
439
      : LGap(block), replacement_(NULL) { }
440

441
  bool HasInterestingComment(LCodeGen* gen) const OVERRIDE { return false; }
442 443
  DECLARE_CONCRETE_INSTRUCTION(Label, "label")

444
  void PrintDataTo(StringStream* stream) OVERRIDE;
445

fschneider@chromium.org's avatar
fschneider@chromium.org committed
446 447
  int block_id() const { return block()->block_id(); }
  bool is_loop_header() const { return block()->IsLoopHeader(); }
448
  bool is_osr_entry() const { return block()->is_osr_entry(); }
449 450 451 452
  Label* label() { return &label_; }
  LLabel* replacement() const { return replacement_; }
  void set_replacement(LLabel* label) { replacement_ = label; }
  bool HasReplacement() const { return replacement_ != NULL; }
453 454 455 456

 private:
  Label label_;
  LLabel* replacement_;
457 458 459
};


460
class LParameter FINAL : public LTemplateInstruction<1, 0, 0> {
461
 public:
462
  bool HasInterestingComment(LCodeGen* gen) const OVERRIDE { return false; }
463 464
  DECLARE_CONCRETE_INSTRUCTION(Parameter, "parameter")
};
465

466

467
class LCallStub FINAL : public LTemplateInstruction<1, 1, 0> {
468
 public:
469 470 471 472 473 474
  explicit LCallStub(LOperand* context) {
    inputs_[0] = context;
  }

  LOperand* context() { return inputs_[0]; }

475 476
  DECLARE_CONCRETE_INSTRUCTION(CallStub, "call-stub")
  DECLARE_HYDROGEN_ACCESSOR(CallStub)
477 478 479
};


480
class LTailCallThroughMegamorphicCache FINAL
481
    : public LTemplateInstruction<0, 5, 0> {
482 483
 public:
  explicit LTailCallThroughMegamorphicCache(LOperand* context,
484 485
                                            LOperand* receiver, LOperand* name,
                                            LOperand* slot, LOperand* vector) {
486 487 488
    inputs_[0] = context;
    inputs_[1] = receiver;
    inputs_[2] = name;
489 490
    inputs_[3] = slot;
    inputs_[4] = vector;
491 492 493 494 495
  }

  LOperand* context() { return inputs_[0]; }
  LOperand* receiver() { return inputs_[1]; }
  LOperand* name() { return inputs_[2]; }
496 497
  LOperand* slot() { return inputs_[3]; }
  LOperand* vector() { return inputs_[4]; }
498 499 500 501 502 503 504

  DECLARE_CONCRETE_INSTRUCTION(TailCallThroughMegamorphicCache,
                               "tail-call-through-megamorphic-cache")
  DECLARE_HYDROGEN_ACCESSOR(TailCallThroughMegamorphicCache)
};


505
class LUnknownOSRValue FINAL : public LTemplateInstruction<1, 0, 0> {
506
 public:
507
  bool HasInterestingComment(LCodeGen* gen) const OVERRIDE { return false; }
508 509
  DECLARE_CONCRETE_INSTRUCTION(UnknownOSRValue, "unknown-osr-value")
};
510

511

512
template<int I, int T>
513
class LControlInstruction : public LTemplateInstruction<0, I, T> {
514
 public:
515 516
  LControlInstruction() : false_label_(NULL), true_label_(NULL) { }

517
  bool IsControl() const FINAL { return true; }
518

519 520
  int SuccessorCount() { return hydrogen()->SuccessorCount(); }
  HBasicBlock* SuccessorAt(int i) { return hydrogen()->SuccessorAt(i); }
521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544

  int TrueDestination(LChunk* chunk) {
    return chunk->LookupDestination(true_block_id());
  }
  int FalseDestination(LChunk* chunk) {
    return chunk->LookupDestination(false_block_id());
  }

  Label* TrueLabel(LChunk* chunk) {
    if (true_label_ == NULL) {
      true_label_ = chunk->GetAssemblyLabel(TrueDestination(chunk));
    }
    return true_label_;
  }
  Label* FalseLabel(LChunk* chunk) {
    if (false_label_ == NULL) {
      false_label_ = chunk->GetAssemblyLabel(FalseDestination(chunk));
    }
    return false_label_;
  }

 protected:
  int true_block_id() { return SuccessorAt(0)->block_id(); }
  int false_block_id() { return SuccessorAt(1)->block_id(); }
545

546
 private:
547 548 549
  HControlInstruction* hydrogen() {
    return HControlInstruction::cast(this->hydrogen_value());
  }
550 551 552

  Label* false_label_;
  Label* true_label_;
553 554 555
};


556
class LWrapReceiver FINAL : public LTemplateInstruction<1, 2, 0> {
557 558 559 560 561 562 563 564
 public:
  LWrapReceiver(LOperand* receiver, LOperand* function) {
    inputs_[0] = receiver;
    inputs_[1] = function;
  }

  LOperand* receiver() { return inputs_[0]; }
  LOperand* function() { return inputs_[1]; }
565 566

  DECLARE_CONCRETE_INSTRUCTION(WrapReceiver, "wrap-receiver")
567
  DECLARE_HYDROGEN_ACCESSOR(WrapReceiver)
568 569 570
};


571
class LApplyArguments FINAL : public LTemplateInstruction<1, 4, 0> {
572 573 574 575 576
 public:
  LApplyArguments(LOperand* function,
                  LOperand* receiver,
                  LOperand* length,
                  LOperand* elements) {
577 578 579 580
    inputs_[0] = function;
    inputs_[1] = receiver;
    inputs_[2] = length;
    inputs_[3] = elements;
581 582
  }

583 584 585 586
  LOperand* function() { return inputs_[0]; }
  LOperand* receiver() { return inputs_[1]; }
  LOperand* length() { return inputs_[2]; }
  LOperand* elements() { return inputs_[3]; }
587 588

  DECLARE_CONCRETE_INSTRUCTION(ApplyArguments, "apply-arguments")
589 590 591
};


592
class LAccessArgumentsAt FINAL : public LTemplateInstruction<1, 3, 0> {
593 594
 public:
  LAccessArgumentsAt(LOperand* arguments, LOperand* length, LOperand* index) {
595 596 597
    inputs_[0] = arguments;
    inputs_[1] = length;
    inputs_[2] = index;
598 599
  }

600 601 602
  LOperand* arguments() { return inputs_[0]; }
  LOperand* length() { return inputs_[1]; }
  LOperand* index() { return inputs_[2]; }
603

604 605
  DECLARE_CONCRETE_INSTRUCTION(AccessArgumentsAt, "access-arguments-at")

606
  void PrintDataTo(StringStream* stream) OVERRIDE;
607 608 609
};


610
class LArgumentsLength FINAL : public LTemplateInstruction<1, 1, 0> {
611
 public:
612 613 614
  explicit LArgumentsLength(LOperand* elements) {
    inputs_[0] = elements;
  }
615

616 617
  LOperand* elements() { return inputs_[0]; }

618 619 620 621
  DECLARE_CONCRETE_INSTRUCTION(ArgumentsLength, "arguments-length")
};


622
class LArgumentsElements FINAL : public LTemplateInstruction<1, 0, 0> {
623 624
 public:
  DECLARE_CONCRETE_INSTRUCTION(ArgumentsElements, "arguments-elements")
625
  DECLARE_HYDROGEN_ACCESSOR(ArgumentsElements)
626 627 628
};


629
class LModByPowerOf2I FINAL : public LTemplateInstruction<1, 1, 0> {
630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646
 public:
  LModByPowerOf2I(LOperand* dividend, int32_t divisor) {
    inputs_[0] = dividend;
    divisor_ = divisor;
  }

  LOperand* dividend() { return inputs_[0]; }
  int32_t divisor() const { return divisor_; }

  DECLARE_CONCRETE_INSTRUCTION(ModByPowerOf2I, "mod-by-power-of-2-i")
  DECLARE_HYDROGEN_ACCESSOR(Mod)

 private:
  int32_t divisor_;
};


647
class LModByConstI FINAL : public LTemplateInstruction<1, 1, 2> {
648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671
 public:
  LModByConstI(LOperand* dividend,
               int32_t divisor,
               LOperand* temp1,
               LOperand* temp2) {
    inputs_[0] = dividend;
    divisor_ = divisor;
    temps_[0] = temp1;
    temps_[1] = temp2;
  }

  LOperand* dividend() { return inputs_[0]; }
  int32_t divisor() const { return divisor_; }
  LOperand* temp1() { return temps_[0]; }
  LOperand* temp2() { return temps_[1]; }

  DECLARE_CONCRETE_INSTRUCTION(ModByConstI, "mod-by-const-i")
  DECLARE_HYDROGEN_ACCESSOR(Mod)

 private:
  int32_t divisor_;
};


672
class LModI FINAL : public LTemplateInstruction<1, 2, 1> {
673
 public:
674 675 676 677 678
  LModI(LOperand* left, LOperand* right, LOperand* temp) {
    inputs_[0] = left;
    inputs_[1] = right;
    temps_[0] = temp;
  }
679

680 681 682 683
  LOperand* left() { return inputs_[0]; }
  LOperand* right() { return inputs_[1]; }
  LOperand* temp() { return temps_[0]; }

684 685 686 687 688
  DECLARE_CONCRETE_INSTRUCTION(ModI, "mod-i")
  DECLARE_HYDROGEN_ACCESSOR(Mod)
};


689
class LDivByPowerOf2I FINAL : public LTemplateInstruction<1, 1, 0> {
690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706
 public:
  LDivByPowerOf2I(LOperand* dividend, int32_t divisor) {
    inputs_[0] = dividend;
    divisor_ = divisor;
  }

  LOperand* dividend() { return inputs_[0]; }
  int32_t divisor() const { return divisor_; }

  DECLARE_CONCRETE_INSTRUCTION(DivByPowerOf2I, "div-by-power-of-2-i")
  DECLARE_HYDROGEN_ACCESSOR(Div)

 private:
  int32_t divisor_;
};


707
class LDivByConstI FINAL : public LTemplateInstruction<1, 1, 2> {
708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731
 public:
  LDivByConstI(LOperand* dividend,
               int32_t divisor,
               LOperand* temp1,
               LOperand* temp2) {
    inputs_[0] = dividend;
    divisor_ = divisor;
    temps_[0] = temp1;
    temps_[1] = temp2;
  }

  LOperand* dividend() { return inputs_[0]; }
  int32_t divisor() const { return divisor_; }
  LOperand* temp1() { return temps_[0]; }
  LOperand* temp2() { return temps_[1]; }

  DECLARE_CONCRETE_INSTRUCTION(DivByConstI, "div-by-const-i")
  DECLARE_HYDROGEN_ACCESSOR(Div)

 private:
  int32_t divisor_;
};


732
class LDivI FINAL : public LTemplateInstruction<1, 2, 1> {
733
 public:
734 735 736
  LDivI(LOperand* dividend, LOperand* divisor, LOperand* temp) {
    inputs_[0] = dividend;
    inputs_[1] = divisor;
737 738
    temps_[0] = temp;
  }
739

740 741
  LOperand* dividend() { return inputs_[0]; }
  LOperand* divisor() { return inputs_[1]; }
742 743
  LOperand* temp() { return temps_[0]; }

744
  DECLARE_CONCRETE_INSTRUCTION(DivI, "div-i")
745
  DECLARE_HYDROGEN_ACCESSOR(BinaryOperation)
746 747 748
};


749
class LFlooringDivByPowerOf2I FINAL : public LTemplateInstruction<1, 1, 0> {
750
 public:
751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767
  LFlooringDivByPowerOf2I(LOperand* dividend, int32_t divisor) {
    inputs_[0] = dividend;
    divisor_ = divisor;
  }

  LOperand* dividend() { return inputs_[0]; }
  int32_t divisor() const { return divisor_; }

  DECLARE_CONCRETE_INSTRUCTION(FlooringDivByPowerOf2I,
                               "flooring-div-by-power-of-2-i")
  DECLARE_HYDROGEN_ACCESSOR(MathFloorOfDiv)

 private:
  int32_t divisor_;
};


768
class LFlooringDivByConstI FINAL : public LTemplateInstruction<1, 1, 3> {
769
 public:
770 771 772
  LFlooringDivByConstI(LOperand* dividend,
                       int32_t divisor,
                       LOperand* temp1,
773 774
                       LOperand* temp2,
                       LOperand* temp3) {
775 776
    inputs_[0] = dividend;
    divisor_ = divisor;
777 778
    temps_[0] = temp1;
    temps_[1] = temp2;
779
    temps_[2] = temp3;
780 781
  }

782 783
  LOperand* dividend() { return inputs_[0]; }
  int32_t divisor() const { return divisor_; }
784
  LOperand* temp1() { return temps_[0]; }
785 786
  LOperand* temp2() { return temps_[1]; }
  LOperand* temp3() { return temps_[2]; }
787

788
  DECLARE_CONCRETE_INSTRUCTION(FlooringDivByConstI, "flooring-div-by-const-i")
789
  DECLARE_HYDROGEN_ACCESSOR(MathFloorOfDiv)
790 791 792

 private:
  int32_t divisor_;
793 794 795
};


796
class LFlooringDivI FINAL : public LTemplateInstruction<1, 2, 1> {
797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812
 public:
  LFlooringDivI(LOperand* dividend, LOperand* divisor, LOperand* temp) {
    inputs_[0] = dividend;
    inputs_[1] = divisor;
    temps_[0] = temp;
  }

  LOperand* dividend() { return inputs_[0]; }
  LOperand* divisor() { return inputs_[1]; }
  LOperand* temp() { return temps_[0]; }

  DECLARE_CONCRETE_INSTRUCTION(FlooringDivI, "flooring-div-i")
  DECLARE_HYDROGEN_ACCESSOR(MathFloorOfDiv)
};


813
class LMulI FINAL : public LTemplateInstruction<1, 2, 0> {
814
 public:
815
  LMulI(LOperand* left, LOperand* right) {
816 817 818
    inputs_[0] = left;
    inputs_[1] = right;
  }
819

820 821 822
  LOperand* left() { return inputs_[0]; }
  LOperand* right() { return inputs_[1]; }

823 824 825 826 827
  DECLARE_CONCRETE_INSTRUCTION(MulI, "mul-i")
  DECLARE_HYDROGEN_ACCESSOR(Mul)
};


828
class LCompareNumericAndBranch FINAL : public LControlInstruction<2, 0> {
829
 public:
830
  LCompareNumericAndBranch(LOperand* left, LOperand* right) {
831 832 833
    inputs_[0] = left;
    inputs_[1] = right;
  }
834

835 836 837
  LOperand* left() { return inputs_[0]; }
  LOperand* right() { return inputs_[1]; }

838 839 840
  DECLARE_CONCRETE_INSTRUCTION(CompareNumericAndBranch,
                               "compare-numeric-and-branch")
  DECLARE_HYDROGEN_ACCESSOR(CompareNumericAndBranch)
841

842 843
  Token::Value op() const { return hydrogen()->token(); }
  bool is_double() const {
844
    return hydrogen()->representation().IsDouble();
845
  }
846

847
  void PrintDataTo(StringStream* stream) OVERRIDE;
848 849 850
};


851
class LMathFloor FINAL : public LTemplateInstruction<1, 1, 0> {
852
 public:
853
  explicit LMathFloor(LOperand* value) {
854 855
    inputs_[0] = value;
  }
856

857 858
  LOperand* value() { return inputs_[0]; }

859
  DECLARE_CONCRETE_INSTRUCTION(MathFloor, "math-floor")
860
  DECLARE_HYDROGEN_ACCESSOR(UnaryMathOperation)
861
};
862

863

864
class LMathRound FINAL : public LTemplateInstruction<1, 1, 1> {
865
 public:
866
  LMathRound(LOperand* value, LOperand* temp) {
867
    inputs_[0] = value;
868
    temps_[0] = temp;
869 870 871
  }

  LOperand* value() { return inputs_[0]; }
872
  LOperand* temp() { return temps_[0]; }
873 874 875 876 877 878

  DECLARE_CONCRETE_INSTRUCTION(MathRound, "math-round")
  DECLARE_HYDROGEN_ACCESSOR(UnaryMathOperation)
};


879
class LMathFround FINAL : public LTemplateInstruction<1, 1, 0> {
880 881 882 883 884
 public:
  explicit LMathFround(LOperand* value) { inputs_[0] = value; }

  LOperand* value() { return inputs_[0]; }

885
  DECLARE_CONCRETE_INSTRUCTION(MathFround, "math-fround")
886 887 888
};


889
class LMathAbs FINAL : public LTemplateInstruction<1, 2, 0> {
890
 public:
891 892
  explicit LMathAbs(LOperand* context, LOperand* value) {
    inputs_[1] = context;
893 894 895
    inputs_[0] = value;
  }

896
  LOperand* context() { return inputs_[1]; }
897 898 899 900 901 902 903
  LOperand* value() { return inputs_[0]; }

  DECLARE_CONCRETE_INSTRUCTION(MathAbs, "math-abs")
  DECLARE_HYDROGEN_ACCESSOR(UnaryMathOperation)
};


904
class LMathLog FINAL : public LTemplateInstruction<1, 1, 0> {
905 906 907 908 909 910 911 912 913 914 915
 public:
  explicit LMathLog(LOperand* value) {
    inputs_[0] = value;
  }

  LOperand* value() { return inputs_[0]; }

  DECLARE_CONCRETE_INSTRUCTION(MathLog, "math-log")
};


916
class LMathClz32 FINAL : public LTemplateInstruction<1, 1, 0> {
917 918 919 920 921 922 923 924 925 926 927
 public:
  explicit LMathClz32(LOperand* value) {
    inputs_[0] = value;
  }

  LOperand* value() { return inputs_[0]; }

  DECLARE_CONCRETE_INSTRUCTION(MathClz32, "math-clz32")
};


928
class LMathExp FINAL : public LTemplateInstruction<1, 1, 2> {
929 930 931 932 933 934 935 936 937 938 939 940 941
 public:
  LMathExp(LOperand* value, LOperand* temp1, LOperand* temp2) {
    inputs_[0] = value;
    temps_[0] = temp1;
    temps_[1] = temp2;
    ExternalReference::InitializeMathExpData();
  }

  LOperand* value() { return inputs_[0]; }
  LOperand* temp1() { return temps_[0]; }
  LOperand* temp2() { return temps_[1]; }

  DECLARE_CONCRETE_INSTRUCTION(MathExp, "math-exp")
942
};
943

944

945
class LMathSqrt FINAL : public LTemplateInstruction<1, 1, 0> {
946 947 948 949 950 951 952 953 954 955 956
 public:
  explicit LMathSqrt(LOperand* value) {
    inputs_[0] = value;
  }

  LOperand* value() { return inputs_[0]; }

  DECLARE_CONCRETE_INSTRUCTION(MathSqrt, "math-sqrt")
};


957
class LMathPowHalf FINAL : public LTemplateInstruction<1, 1, 0> {
958 959 960 961 962 963 964 965
 public:
  explicit LMathPowHalf(LOperand* value) {
    inputs_[0] = value;
  }

  LOperand* value() { return inputs_[0]; }

  DECLARE_CONCRETE_INSTRUCTION(MathPowHalf, "math-pow-half")
966 967 968
};


969
class LCmpObjectEqAndBranch FINAL : public LControlInstruction<2, 0> {
970
 public:
971
  LCmpObjectEqAndBranch(LOperand* left, LOperand* right) {
972 973 974
    inputs_[0] = left;
    inputs_[1] = right;
  }
975

976 977 978
  LOperand* left() { return inputs_[0]; }
  LOperand* right() { return inputs_[1]; }

979 980 981 982
  DECLARE_CONCRETE_INSTRUCTION(CmpObjectEqAndBranch, "cmp-object-eq-and-branch")
};


983
class LCmpHoleAndBranch FINAL : public LControlInstruction<1, 0> {
984 985 986 987 988 989 990 991 992
 public:
  explicit LCmpHoleAndBranch(LOperand* object) {
    inputs_[0] = object;
  }

  LOperand* object() { return inputs_[0]; }

  DECLARE_CONCRETE_INSTRUCTION(CmpHoleAndBranch, "cmp-hole-and-branch")
  DECLARE_HYDROGEN_ACCESSOR(CompareHoleAndBranch)
993 994 995
};


996
class LCompareMinusZeroAndBranch FINAL : public LControlInstruction<1, 0> {
997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010
 public:
  explicit LCompareMinusZeroAndBranch(LOperand* value) {
    inputs_[0] = value;
  }

  LOperand* value() { return inputs_[0]; }

  DECLARE_CONCRETE_INSTRUCTION(CompareMinusZeroAndBranch,
                               "cmp-minus-zero-and-branch")
  DECLARE_HYDROGEN_ACCESSOR(CompareMinusZeroAndBranch)
};



1011
class LIsObjectAndBranch FINAL : public LControlInstruction<1, 0> {
1012
 public:
1013
  explicit LIsObjectAndBranch(LOperand* value) {
1014 1015
    inputs_[0] = value;
  }
1016

1017 1018
  LOperand* value() { return inputs_[0]; }

1019
  DECLARE_CONCRETE_INSTRUCTION(IsObjectAndBranch, "is-object-and-branch")
1020
  DECLARE_HYDROGEN_ACCESSOR(IsObjectAndBranch)
1021

1022
  void PrintDataTo(StringStream* stream) OVERRIDE;
1023 1024 1025
};


1026
class LIsStringAndBranch FINAL : public LControlInstruction<1, 1> {
1027 1028 1029 1030 1031 1032
 public:
  explicit LIsStringAndBranch(LOperand* value, LOperand* temp) {
    inputs_[0] = value;
    temps_[0] = temp;
  }

1033 1034 1035
  LOperand* value() { return inputs_[0]; }
  LOperand* temp() { return temps_[0]; }

1036 1037 1038
  DECLARE_CONCRETE_INSTRUCTION(IsStringAndBranch, "is-string-and-branch")
  DECLARE_HYDROGEN_ACCESSOR(IsStringAndBranch)

1039
  void PrintDataTo(StringStream* stream) OVERRIDE;
1040 1041 1042
};


1043
class LIsSmiAndBranch FINAL : public LControlInstruction<1, 0> {
1044
 public:
1045 1046 1047
  explicit LIsSmiAndBranch(LOperand* value) {
    inputs_[0] = value;
  }
1048

1049 1050
  LOperand* value() { return inputs_[0]; }

1051
  DECLARE_CONCRETE_INSTRUCTION(IsSmiAndBranch, "is-smi-and-branch")
1052
  DECLARE_HYDROGEN_ACCESSOR(IsSmiAndBranch)
1053

1054
  void PrintDataTo(StringStream* stream) OVERRIDE;
1055 1056 1057
};


1058
class LIsUndetectableAndBranch FINAL : public LControlInstruction<1, 1> {
1059 1060 1061 1062 1063 1064
 public:
  explicit LIsUndetectableAndBranch(LOperand* value, LOperand* temp) {
    inputs_[0] = value;
    temps_[0] = temp;
  }

1065 1066 1067
  LOperand* value() { return inputs_[0]; }
  LOperand* temp() { return temps_[0]; }

1068 1069
  DECLARE_CONCRETE_INSTRUCTION(IsUndetectableAndBranch,
                               "is-undetectable-and-branch")
1070
  DECLARE_HYDROGEN_ACCESSOR(IsUndetectableAndBranch)
1071

1072
  void PrintDataTo(StringStream* stream) OVERRIDE;
1073 1074 1075
};


1076
class LStringCompareAndBranch FINAL : public LControlInstruction<3, 0> {
1077
 public:
1078 1079 1080 1081 1082 1083
  explicit LStringCompareAndBranch(LOperand* context,
                                   LOperand* left,
                                   LOperand* right) {
    inputs_[0] = context;
    inputs_[1] = left;
    inputs_[2] = right;
1084 1085
  }

1086 1087 1088
  LOperand* context() { return inputs_[0]; }
  LOperand* left() { return inputs_[1]; }
  LOperand* right() { return inputs_[2]; }
1089

1090 1091 1092 1093
  DECLARE_CONCRETE_INSTRUCTION(StringCompareAndBranch,
                               "string-compare-and-branch")
  DECLARE_HYDROGEN_ACCESSOR(StringCompareAndBranch)

1094
  void PrintDataTo(StringStream* stream) OVERRIDE;
1095 1096 1097 1098 1099

  Token::Value op() const { return hydrogen()->token(); }
};


1100
class LHasInstanceTypeAndBranch FINAL : public LControlInstruction<1, 0> {
1101
 public:
1102
  explicit LHasInstanceTypeAndBranch(LOperand* value) {
1103 1104
    inputs_[0] = value;
  }
1105

1106 1107
  LOperand* value() { return inputs_[0]; }

1108 1109
  DECLARE_CONCRETE_INSTRUCTION(HasInstanceTypeAndBranch,
                               "has-instance-type-and-branch")
1110
  DECLARE_HYDROGEN_ACCESSOR(HasInstanceTypeAndBranch)
1111

1112
  void PrintDataTo(StringStream* stream) OVERRIDE;
1113 1114 1115
};


1116
class LGetCachedArrayIndex FINAL : public LTemplateInstruction<1, 1, 0> {
1117 1118 1119 1120 1121
 public:
  explicit LGetCachedArrayIndex(LOperand* value) {
    inputs_[0] = value;
  }

1122 1123
  LOperand* value() { return inputs_[0]; }

1124 1125 1126 1127 1128
  DECLARE_CONCRETE_INSTRUCTION(GetCachedArrayIndex, "get-cached-array-index")
  DECLARE_HYDROGEN_ACCESSOR(GetCachedArrayIndex)
};


1129
class LHasCachedArrayIndexAndBranch FINAL
1130
    : public LControlInstruction<1, 0> {
1131
 public:
1132 1133 1134
  explicit LHasCachedArrayIndexAndBranch(LOperand* value) {
    inputs_[0] = value;
  }
1135

1136 1137
  LOperand* value() { return inputs_[0]; }

1138 1139
  DECLARE_CONCRETE_INSTRUCTION(HasCachedArrayIndexAndBranch,
                               "has-cached-array-index-and-branch")
1140
  DECLARE_HYDROGEN_ACCESSOR(HasCachedArrayIndexAndBranch)
1141

1142
  void PrintDataTo(StringStream* stream) OVERRIDE;
1143 1144 1145
};


1146
class LClassOfTestAndBranch FINAL : public LControlInstruction<1, 2> {
1147
 public:
1148
  LClassOfTestAndBranch(LOperand* value, LOperand* temp, LOperand* temp2) {
1149 1150
    inputs_[0] = value;
    temps_[0] = temp;
1151
    temps_[1] = temp2;
1152
  }
1153

1154 1155 1156 1157
  LOperand* value() { return inputs_[0]; }
  LOperand* temp() { return temps_[0]; }
  LOperand* temp2() { return temps_[1]; }

1158 1159
  DECLARE_CONCRETE_INSTRUCTION(ClassOfTestAndBranch,
                               "class-of-test-and-branch")
1160
  DECLARE_HYDROGEN_ACCESSOR(ClassOfTestAndBranch)
1161

1162
  void PrintDataTo(StringStream* stream) OVERRIDE;
1163 1164 1165
};


1166
class LCmpT FINAL : public LTemplateInstruction<1, 3, 0> {
1167
 public:
1168 1169 1170 1171
  LCmpT(LOperand* context, LOperand* left, LOperand* right) {
    inputs_[0] = context;
    inputs_[1] = left;
    inputs_[2] = right;
1172
  }
1173

1174 1175 1176
  LOperand* context() { return inputs_[0]; }
  LOperand* left() { return inputs_[1]; }
  LOperand* right() { return inputs_[2]; }
1177

1178 1179
  DECLARE_CONCRETE_INSTRUCTION(CmpT, "cmp-t")
  DECLARE_HYDROGEN_ACCESSOR(CompareGeneric)
1180 1181 1182 1183 1184

  Token::Value op() const { return hydrogen()->token(); }
};


1185
class LInstanceOf FINAL : public LTemplateInstruction<1, 3, 0> {
1186
 public:
1187 1188 1189 1190
  LInstanceOf(LOperand* context, LOperand* left, LOperand* right) {
    inputs_[0] = context;
    inputs_[1] = left;
    inputs_[2] = right;
1191
  }
1192

1193 1194 1195
  LOperand* context() { return inputs_[0]; }
  LOperand* left() { return inputs_[1]; }
  LOperand* right() { return inputs_[2]; }
1196

1197 1198 1199 1200
  DECLARE_CONCRETE_INSTRUCTION(InstanceOf, "instance-of")
};


1201
class LInstanceOfKnownGlobal FINAL : public LTemplateInstruction<1, 2, 1> {
1202
 public:
1203 1204 1205
  LInstanceOfKnownGlobal(LOperand* context, LOperand* value, LOperand* temp) {
    inputs_[0] = context;
    inputs_[1] = value;
1206
    temps_[0] = temp;
1207
  }
1208

1209 1210
  LOperand* context() { return inputs_[0]; }
  LOperand* value() { return inputs_[1]; }
1211 1212
  LOperand* temp() { return temps_[0]; }

1213 1214 1215 1216 1217
  DECLARE_CONCRETE_INSTRUCTION(InstanceOfKnownGlobal,
                               "instance-of-known-global")
  DECLARE_HYDROGEN_ACCESSOR(InstanceOfKnownGlobal)

  Handle<JSFunction> function() const { return hydrogen()->function(); }
1218 1219 1220
  LEnvironment* GetDeferredLazyDeoptimizationEnvironment() {
    return lazy_deopt_env_;
  }
1221
  virtual void SetDeferredLazyDeoptimizationEnvironment(
1222
      LEnvironment* env) OVERRIDE {
1223 1224 1225 1226 1227
    lazy_deopt_env_ = env;
  }

 private:
  LEnvironment* lazy_deopt_env_;
1228 1229 1230
};


1231
class LBoundsCheck FINAL : public LTemplateInstruction<0, 2, 0> {
1232
 public:
1233 1234 1235 1236
  LBoundsCheck(LOperand* index, LOperand* length) {
    inputs_[0] = index;
    inputs_[1] = length;
  }
1237

1238 1239
  LOperand* index() { return inputs_[0]; }
  LOperand* length() { return inputs_[1]; }
1240 1241

  DECLARE_CONCRETE_INSTRUCTION(BoundsCheck, "bounds-check")
1242
  DECLARE_HYDROGEN_ACCESSOR(BoundsCheck)
1243 1244 1245
};


1246
class LBitI FINAL : public LTemplateInstruction<1, 2, 0> {
1247
 public:
1248
  LBitI(LOperand* left, LOperand* right) {
1249 1250 1251
    inputs_[0] = left;
    inputs_[1] = right;
  }
1252

1253 1254 1255
  LOperand* left() { return inputs_[0]; }
  LOperand* right() { return inputs_[1]; }

1256
  Token::Value op() const { return hydrogen()->op(); }
1257 1258 1259
  bool IsInteger32() const {
    return hydrogen()->representation().IsInteger32();
  }
1260 1261

  DECLARE_CONCRETE_INSTRUCTION(BitI, "bit-i")
1262
  DECLARE_HYDROGEN_ACCESSOR(Bitwise)
1263 1264 1265
};


1266
class LShiftI FINAL : public LTemplateInstruction<1, 2, 0> {
1267 1268
 public:
  LShiftI(Token::Value op, LOperand* left, LOperand* right, bool can_deopt)
1269 1270 1271 1272
      : op_(op), can_deopt_(can_deopt) {
    inputs_[0] = left;
    inputs_[1] = right;
  }
1273 1274

  Token::Value op() const { return op_; }
1275 1276
  LOperand* left() { return inputs_[0]; }
  LOperand* right() { return inputs_[1]; }
1277 1278 1279 1280 1281 1282 1283 1284 1285 1286
  bool can_deopt() const { return can_deopt_; }

  DECLARE_CONCRETE_INSTRUCTION(ShiftI, "shift-i")

 private:
  Token::Value op_;
  bool can_deopt_;
};


1287
class LSubI FINAL : public LTemplateInstruction<1, 2, 0> {
1288
 public:
1289 1290 1291 1292
  LSubI(LOperand* left, LOperand* right) {
    inputs_[0] = left;
    inputs_[1] = right;
  }
1293

1294 1295 1296
  LOperand* left() { return inputs_[0]; }
  LOperand* right() { return inputs_[1]; }

1297 1298 1299 1300 1301
  DECLARE_CONCRETE_INSTRUCTION(SubI, "sub-i")
  DECLARE_HYDROGEN_ACCESSOR(Sub)
};


1302
class LConstantI FINAL : public LTemplateInstruction<1, 0, 0> {
1303 1304
 public:
  DECLARE_CONCRETE_INSTRUCTION(ConstantI, "constant-i")
1305
  DECLARE_HYDROGEN_ACCESSOR(Constant)
1306

1307
  int32_t value() const { return hydrogen()->Integer32Value(); }
1308 1309 1310
};


1311
class LConstantS FINAL : public LTemplateInstruction<1, 0, 0> {
1312 1313 1314 1315 1316 1317 1318 1319
 public:
  DECLARE_CONCRETE_INSTRUCTION(ConstantS, "constant-s")
  DECLARE_HYDROGEN_ACCESSOR(Constant)

  Smi* value() const { return Smi::FromInt(hydrogen()->Integer32Value()); }
};


1320
class LConstantD FINAL : public LTemplateInstruction<1, 0, 0> {
1321 1322
 public:
  DECLARE_CONCRETE_INSTRUCTION(ConstantD, "constant-d")
1323
  DECLARE_HYDROGEN_ACCESSOR(Constant)
1324

1325
  uint64_t bits() const { return hydrogen()->DoubleValueAsBits(); }
1326 1327 1328
};


1329
class LConstantE FINAL : public LTemplateInstruction<1, 0, 0> {
1330 1331 1332 1333 1334 1335 1336 1337 1338 1339
 public:
  DECLARE_CONCRETE_INSTRUCTION(ConstantE, "constant-e")
  DECLARE_HYDROGEN_ACCESSOR(Constant)

  ExternalReference value() const {
    return hydrogen()->ExternalReferenceValue();
  }
};


1340
class LConstantT FINAL : public LTemplateInstruction<1, 0, 0> {
1341 1342
 public:
  DECLARE_CONCRETE_INSTRUCTION(ConstantT, "constant-t")
1343
  DECLARE_HYDROGEN_ACCESSOR(Constant)
1344

1345 1346 1347
  Handle<Object> value(Isolate* isolate) const {
    return hydrogen()->handle(isolate);
  }
1348 1349 1350
};


1351
class LBranch FINAL : public LControlInstruction<1, 0> {
1352
 public:
1353 1354 1355
  explicit LBranch(LOperand* value) {
    inputs_[0] = value;
  }
1356

1357 1358
  LOperand* value() { return inputs_[0]; }

1359
  DECLARE_CONCRETE_INSTRUCTION(Branch, "branch")
1360
  DECLARE_HYDROGEN_ACCESSOR(Branch)
1361

1362
  void PrintDataTo(StringStream* stream) OVERRIDE;
1363 1364 1365
};


1366
class LDebugBreak FINAL : public LTemplateInstruction<0, 0, 0> {
1367 1368 1369 1370 1371
 public:
  DECLARE_CONCRETE_INSTRUCTION(DebugBreak, "break")
};


1372
class LCmpMapAndBranch FINAL : public LControlInstruction<1, 0> {
1373
 public:
1374 1375 1376
  explicit LCmpMapAndBranch(LOperand* value) {
    inputs_[0] = value;
  }
1377

1378 1379
  LOperand* value() { return inputs_[0]; }

1380
  DECLARE_CONCRETE_INSTRUCTION(CmpMapAndBranch, "cmp-map-and-branch")
1381
  DECLARE_HYDROGEN_ACCESSOR(CompareMap)
1382

1383
  Handle<Map> map() const { return hydrogen()->map().handle(); }
1384 1385 1386
};


1387
class LMapEnumLength FINAL : public LTemplateInstruction<1, 1, 0> {
1388 1389 1390 1391 1392
 public:
  explicit LMapEnumLength(LOperand* value) {
    inputs_[0] = value;
  }

1393 1394
  LOperand* value() { return inputs_[0]; }

1395 1396 1397 1398
  DECLARE_CONCRETE_INSTRUCTION(MapEnumLength, "map-enum-length")
};


1399
class LDateField FINAL : public LTemplateInstruction<1, 1, 0> {
1400
 public:
1401
  LDateField(LOperand* date, Smi* index) : index_(index) {
1402 1403 1404
    inputs_[0] = date;
  }

1405 1406 1407
  LOperand* date() { return inputs_[0]; }
  Smi* index() const { return index_; }

haitao.feng@intel.com's avatar
haitao.feng@intel.com committed
1408 1409
  DECLARE_CONCRETE_INSTRUCTION(DateField, "date-field")
  DECLARE_HYDROGEN_ACCESSOR(DateField)
1410 1411

 private:
1412
  Smi* index_;
1413 1414 1415
};


1416
class LSeqStringGetChar FINAL : public LTemplateInstruction<1, 2, 0> {
1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430
 public:
  LSeqStringGetChar(LOperand* string, LOperand* index) {
    inputs_[0] = string;
    inputs_[1] = index;
  }

  LOperand* string() const { return inputs_[0]; }
  LOperand* index() const { return inputs_[1]; }

  DECLARE_CONCRETE_INSTRUCTION(SeqStringGetChar, "seq-string-get-char")
  DECLARE_HYDROGEN_ACCESSOR(SeqStringGetChar)
};


1431
class LSeqStringSetChar FINAL : public LTemplateInstruction<1, 4, 0> {
1432
 public:
1433 1434
  LSeqStringSetChar(LOperand* context,
                    LOperand* string,
1435
                    LOperand* index,
1436
                    LOperand* value) {
1437 1438 1439 1440
    inputs_[0] = context;
    inputs_[1] = string;
    inputs_[2] = index;
    inputs_[3] = value;
1441 1442
  }

1443 1444 1445
  LOperand* string() { return inputs_[1]; }
  LOperand* index() { return inputs_[2]; }
  LOperand* value() { return inputs_[3]; }
1446 1447 1448 1449 1450 1451

  DECLARE_CONCRETE_INSTRUCTION(SeqStringSetChar, "seq-string-set-char")
  DECLARE_HYDROGEN_ACCESSOR(SeqStringSetChar)
};


1452
class LAddI FINAL : public LTemplateInstruction<1, 2, 0> {
1453
 public:
1454 1455 1456 1457
  LAddI(LOperand* left, LOperand* right) {
    inputs_[0] = left;
    inputs_[1] = right;
  }
1458

1459 1460 1461
  LOperand* left() { return inputs_[0]; }
  LOperand* right() { return inputs_[1]; }

1462 1463 1464 1465 1466
  static bool UseLea(HAdd* add) {
    return !add->CheckFlag(HValue::kCanOverflow) &&
        add->BetterLeftOperand()->UseCount() > 1;
  }

1467 1468 1469 1470 1471
  DECLARE_CONCRETE_INSTRUCTION(AddI, "add-i")
  DECLARE_HYDROGEN_ACCESSOR(Add)
};


1472
class LMathMinMax FINAL : public LTemplateInstruction<1, 2, 0> {
1473 1474 1475 1476 1477 1478
 public:
  LMathMinMax(LOperand* left, LOperand* right) {
    inputs_[0] = left;
    inputs_[1] = right;
  }

1479 1480 1481
  LOperand* left() { return inputs_[0]; }
  LOperand* right() { return inputs_[1]; }

1482
  DECLARE_CONCRETE_INSTRUCTION(MathMinMax, "math-min-max")
1483 1484 1485 1486
  DECLARE_HYDROGEN_ACCESSOR(MathMinMax)
};


1487
class LPower FINAL : public LTemplateInstruction<1, 2, 0> {
1488
 public:
1489 1490 1491 1492
  LPower(LOperand* left, LOperand* right) {
    inputs_[0] = left;
    inputs_[1] = right;
  }
1493

1494 1495 1496
  LOperand* left() { return inputs_[0]; }
  LOperand* right() { return inputs_[1]; }

1497 1498 1499 1500 1501
  DECLARE_CONCRETE_INSTRUCTION(Power, "power")
  DECLARE_HYDROGEN_ACCESSOR(Power)
};


1502
class LArithmeticD FINAL : public LTemplateInstruction<1, 2, 0> {
1503 1504
 public:
  LArithmeticD(Token::Value op, LOperand* left, LOperand* right)
1505 1506 1507 1508
      : op_(op) {
    inputs_[0] = left;
    inputs_[1] = right;
  }
1509 1510

  Token::Value op() const { return op_; }
1511 1512
  LOperand* left() { return inputs_[0]; }
  LOperand* right() { return inputs_[1]; }
1513

1514 1515 1516
  Opcode opcode() const OVERRIDE { return LInstruction::kArithmeticD; }
  void CompileToNative(LCodeGen* generator) OVERRIDE;
  const char* Mnemonic() const OVERRIDE;
1517 1518 1519 1520 1521 1522

 private:
  Token::Value op_;
};


1523
class LArithmeticT FINAL : public LTemplateInstruction<1, 3, 0> {
1524
 public:
1525 1526 1527 1528
  LArithmeticT(Token::Value op,
               LOperand* context,
               LOperand* left,
               LOperand* right)
1529
      : op_(op) {
1530 1531 1532
    inputs_[0] = context;
    inputs_[1] = left;
    inputs_[2] = right;
1533
  }
1534

1535
  Token::Value op() const { return op_; }
1536 1537 1538
  LOperand* context() { return inputs_[0]; }
  LOperand* left() { return inputs_[1]; }
  LOperand* right() { return inputs_[2]; }
1539

1540 1541 1542
  Opcode opcode() const OVERRIDE { return LInstruction::kArithmeticT; }
  void CompileToNative(LCodeGen* generator) OVERRIDE;
  const char* Mnemonic() const OVERRIDE;
1543 1544 1545 1546 1547 1548

 private:
  Token::Value op_;
};


1549
class LReturn FINAL : public LTemplateInstruction<0, 3, 0> {
1550
 public:
1551 1552 1553
  explicit LReturn(LOperand* value,
                   LOperand* context,
                   LOperand* parameter_count) {
1554
    inputs_[0] = value;
1555 1556
    inputs_[1] = context;
    inputs_[2] = parameter_count;
1557
  }
1558

1559
  LOperand* value() { return inputs_[0]; }
1560
  LOperand* context() { return inputs_[1]; }
1561

1562 1563 1564 1565
  bool has_constant_parameter_count() {
    return parameter_count()->IsConstantOperand();
  }
  LConstantOperand* constant_parameter_count() {
1566
    DCHECK(has_constant_parameter_count());
1567 1568
    return LConstantOperand::cast(parameter_count());
  }
1569
  LOperand* parameter_count() { return inputs_[2]; }
1570

1571
  DECLARE_CONCRETE_INSTRUCTION(Return, "return")
1572
  DECLARE_HYDROGEN_ACCESSOR(Return)
1573 1574 1575
};


1576
class LLoadNamedField FINAL : public LTemplateInstruction<1, 1, 0> {
1577
 public:
1578
  explicit LLoadNamedField(LOperand* object) {
1579 1580
    inputs_[0] = object;
  }
1581

1582 1583
  LOperand* object() { return inputs_[0]; }

1584 1585 1586 1587 1588
  DECLARE_CONCRETE_INSTRUCTION(LoadNamedField, "load-named-field")
  DECLARE_HYDROGEN_ACCESSOR(LoadNamedField)
};


1589
class LLoadNamedGeneric FINAL : public LTemplateInstruction<1, 2, 1> {
1590
 public:
1591 1592
  explicit LLoadNamedGeneric(LOperand* context, LOperand* object,
                             LOperand* vector) {
1593 1594
    inputs_[0] = context;
    inputs_[1] = object;
1595
    temps_[0] = vector;
1596
  }
1597 1598 1599 1600

  DECLARE_CONCRETE_INSTRUCTION(LoadNamedGeneric, "load-named-generic")
  DECLARE_HYDROGEN_ACCESSOR(LoadNamedGeneric)

1601 1602
  LOperand* context() { return inputs_[0]; }
  LOperand* object() { return inputs_[1]; }
1603 1604
  LOperand* temp_vector() { return temps_[0]; }

1605 1606 1607 1608
  Handle<Object> name() const { return hydrogen()->name(); }
};


1609
class LLoadFunctionPrototype FINAL : public LTemplateInstruction<1, 1, 0> {
1610
 public:
1611
  explicit LLoadFunctionPrototype(LOperand* function) {
1612 1613
    inputs_[0] = function;
  }
1614 1615 1616 1617

  DECLARE_CONCRETE_INSTRUCTION(LoadFunctionPrototype, "load-function-prototype")
  DECLARE_HYDROGEN_ACCESSOR(LoadFunctionPrototype)

1618
  LOperand* function() { return inputs_[0]; }
1619 1620 1621
};


1622
class LLoadRoot FINAL : public LTemplateInstruction<1, 0, 0> {
1623 1624 1625 1626 1627 1628 1629 1630
 public:
  DECLARE_CONCRETE_INSTRUCTION(LoadRoot, "load-root")
  DECLARE_HYDROGEN_ACCESSOR(LoadRoot)

  Heap::RootListIndex index() const { return hydrogen()->index(); }
};


1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646
inline static bool ExternalArrayOpRequiresTemp(
    Representation key_representation,
    ElementsKind elements_kind) {
  // Operations that require the key to be divided by two to be converted into
  // an index cannot fold the scale operation into a load and need an extra
  // temp register to do the work.
  return SmiValuesAre31Bits() && key_representation.IsSmi() &&
      (elements_kind == EXTERNAL_INT8_ELEMENTS ||
       elements_kind == EXTERNAL_UINT8_ELEMENTS ||
       elements_kind == EXTERNAL_UINT8_CLAMPED_ELEMENTS ||
       elements_kind == UINT8_ELEMENTS ||
       elements_kind == INT8_ELEMENTS ||
       elements_kind == UINT8_CLAMPED_ELEMENTS);
}


1647
class LLoadKeyed FINAL : public LTemplateInstruction<1, 2, 0> {
1648
 public:
1649
  LLoadKeyed(LOperand* elements, LOperand* key) {
1650 1651 1652
    inputs_[0] = elements;
    inputs_[1] = key;
  }
1653

1654 1655
  DECLARE_CONCRETE_INSTRUCTION(LoadKeyed, "load-keyed")
  DECLARE_HYDROGEN_ACCESSOR(LoadKeyed)
1656

1657 1658
  bool is_external() const {
    return hydrogen()->is_external();
1659
  }
1660 1661 1662 1663 1664 1665
  bool is_fixed_typed_array() const {
    return hydrogen()->is_fixed_typed_array();
  }
  bool is_typed_elements() const {
    return is_external() || is_fixed_typed_array();
  }
1666 1667
  LOperand* elements() { return inputs_[0]; }
  LOperand* key() { return inputs_[1]; }
1668
  void PrintDataTo(StringStream* stream) OVERRIDE;
1669
  uint32_t base_offset() const { return hydrogen()->base_offset(); }
1670
  ElementsKind elements_kind() const {
1671
    return hydrogen()->elements_kind();
1672
  }
1673 1674 1675
};


1676
class LLoadKeyedGeneric FINAL : public LTemplateInstruction<1, 3, 1> {
1677
 public:
1678 1679
  LLoadKeyedGeneric(LOperand* context, LOperand* obj, LOperand* key,
                    LOperand* vector) {
1680 1681 1682
    inputs_[0] = context;
    inputs_[1] = obj;
    inputs_[2] = key;
1683
    temps_[0] = vector;
1684
  }
1685 1686

  DECLARE_CONCRETE_INSTRUCTION(LoadKeyedGeneric, "load-keyed-generic")
1687
  DECLARE_HYDROGEN_ACCESSOR(LoadKeyedGeneric)
1688

1689 1690 1691
  LOperand* context() { return inputs_[0]; }
  LOperand* object() { return inputs_[1]; }
  LOperand* key() { return inputs_[2]; }
1692
  LOperand* temp_vector() { return temps_[0]; }
1693 1694 1695
};


1696
class LLoadGlobalGeneric FINAL : public LTemplateInstruction<1, 2, 1> {
1697
 public:
1698 1699
  explicit LLoadGlobalGeneric(LOperand* context, LOperand* global_object,
                              LOperand* vector) {
1700 1701
    inputs_[0] = context;
    inputs_[1] = global_object;
1702
    temps_[0] = vector;
1703 1704 1705 1706 1707
  }

  DECLARE_CONCRETE_INSTRUCTION(LoadGlobalGeneric, "load-global-generic")
  DECLARE_HYDROGEN_ACCESSOR(LoadGlobalGeneric)

1708 1709
  LOperand* context() { return inputs_[0]; }
  LOperand* global_object() { return inputs_[1]; }
1710 1711
  LOperand* temp_vector() { return temps_[0]; }

1712 1713
  Handle<Object> name() const { return hydrogen()->name(); }
  bool for_typeof() const { return hydrogen()->for_typeof(); }
1714 1715 1716
};


1717
class LLoadContextSlot FINAL : public LTemplateInstruction<1, 1, 0> {
1718
 public:
whesse@chromium.org's avatar
whesse@chromium.org committed
1719 1720
  explicit LLoadContextSlot(LOperand* context) {
    inputs_[0] = context;
1721 1722
  }

1723 1724
  LOperand* context() { return inputs_[0]; }

1725 1726 1727
  DECLARE_CONCRETE_INSTRUCTION(LoadContextSlot, "load-context-slot")
  DECLARE_HYDROGEN_ACCESSOR(LoadContextSlot)

1728
  int slot_index() { return hydrogen()->slot_index(); }
1729

1730
  void PrintDataTo(StringStream* stream) OVERRIDE;
1731 1732 1733
};


1734
class LStoreContextSlot FINAL : public LTemplateInstruction<0, 2, 1> {
1735
 public:
1736
  LStoreContextSlot(LOperand* context, LOperand* value, LOperand* temp) {
whesse@chromium.org's avatar
whesse@chromium.org committed
1737 1738
    inputs_[0] = context;
    inputs_[1] = value;
1739
    temps_[0] = temp;
1740 1741
  }

1742 1743 1744 1745
  LOperand* context() { return inputs_[0]; }
  LOperand* value() { return inputs_[1]; }
  LOperand* temp() { return temps_[0]; }

1746 1747 1748 1749 1750
  DECLARE_CONCRETE_INSTRUCTION(StoreContextSlot, "store-context-slot")
  DECLARE_HYDROGEN_ACCESSOR(StoreContextSlot)

  int slot_index() { return hydrogen()->slot_index(); }

1751
  void PrintDataTo(StringStream* stream) OVERRIDE;
1752 1753 1754
};


1755
class LPushArgument FINAL : public LTemplateInstruction<0, 1, 0> {
1756
 public:
1757 1758 1759
  explicit LPushArgument(LOperand* value) {
    inputs_[0] = value;
  }
1760

1761 1762
  LOperand* value() { return inputs_[0]; }

1763 1764 1765 1766
  DECLARE_CONCRETE_INSTRUCTION(PushArgument, "push-argument")
};


1767
class LDrop FINAL : public LTemplateInstruction<0, 0, 0> {
1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779
 public:
  explicit LDrop(int count) : count_(count) { }

  int count() const { return count_; }

  DECLARE_CONCRETE_INSTRUCTION(Drop, "drop")

 private:
  int count_;
};


1780
class LStoreCodeEntry FINAL: public LTemplateInstruction<0, 2, 0> {
1781 1782 1783
 public:
  LStoreCodeEntry(LOperand* function, LOperand* code_object) {
    inputs_[0] = function;
1784
    inputs_[1] = code_object;
1785 1786 1787
  }

  LOperand* function() { return inputs_[0]; }
1788
  LOperand* code_object() { return inputs_[1]; }
1789

1790
  void PrintDataTo(StringStream* stream) OVERRIDE;
1791 1792 1793 1794 1795 1796

  DECLARE_CONCRETE_INSTRUCTION(StoreCodeEntry, "store-code-entry")
  DECLARE_HYDROGEN_ACCESSOR(StoreCodeEntry)
};


1797
class LInnerAllocatedObject FINAL: public LTemplateInstruction<1, 2, 0> {
1798
 public:
1799
  LInnerAllocatedObject(LOperand* base_object, LOperand* offset) {
1800
    inputs_[0] = base_object;
1801
    inputs_[1] = offset;
1802 1803
  }

1804 1805
  LOperand* base_object() const { return inputs_[0]; }
  LOperand* offset() const { return inputs_[1]; }
1806

1807
  void PrintDataTo(StringStream* stream) OVERRIDE;
1808

1809
  DECLARE_CONCRETE_INSTRUCTION(InnerAllocatedObject, "inner-allocated-object")
1810 1811 1812
};


1813
class LThisFunction FINAL : public LTemplateInstruction<1, 0, 0> {
1814
 public:
1815
  DECLARE_CONCRETE_INSTRUCTION(ThisFunction, "this-function")
1816
  DECLARE_HYDROGEN_ACCESSOR(ThisFunction)
1817 1818 1819
};


1820
class LContext FINAL : public LTemplateInstruction<1, 0, 0> {
1821 1822
 public:
  DECLARE_CONCRETE_INSTRUCTION(Context, "context")
1823
  DECLARE_HYDROGEN_ACCESSOR(Context)
1824 1825 1826
};


1827
class LDeclareGlobals FINAL : public LTemplateInstruction<0, 1, 0> {
1828
 public:
1829 1830 1831 1832 1833 1834
  explicit LDeclareGlobals(LOperand* context) {
    inputs_[0] = context;
  }

  LOperand* context() { return inputs_[0]; }

1835 1836 1837 1838 1839
  DECLARE_CONCRETE_INSTRUCTION(DeclareGlobals, "declare-globals")
  DECLARE_HYDROGEN_ACCESSOR(DeclareGlobals)
};


1840
class LCallJSFunction FINAL : public LTemplateInstruction<1, 1, 0> {
1841
 public:
1842 1843 1844
  explicit LCallJSFunction(LOperand* function) {
    inputs_[0] = function;
  }
1845

1846 1847 1848 1849 1850
  LOperand* function() { return inputs_[0]; }

  DECLARE_CONCRETE_INSTRUCTION(CallJSFunction, "call-js-function")
  DECLARE_HYDROGEN_ACCESSOR(CallJSFunction)

1851
  void PrintDataTo(StringStream* stream) OVERRIDE;
1852 1853 1854 1855 1856

  int arity() const { return hydrogen()->argument_count() - 1; }
};


1857
class LCallWithDescriptor FINAL : public LTemplateResultInstruction<1> {
1858
 public:
1859
  LCallWithDescriptor(CallInterfaceDescriptor descriptor,
1860
                      const ZoneList<LOperand*>& operands, Zone* zone)
1861 1862
      : inputs_(descriptor.GetRegisterParameterCount() + 1, zone) {
    DCHECK(descriptor.GetRegisterParameterCount() + 1 == operands.length());
1863
    inputs_.AddAll(operands, zone);
1864 1865
  }

1866
  LOperand* target() const { return inputs_[0]; }
1867

1868 1869
  DECLARE_HYDROGEN_ACCESSOR(CallWithDescriptor)

1870 1871
 private:
  DECLARE_CONCRETE_INSTRUCTION(CallWithDescriptor, "call-with-descriptor")
1872

1873
  void PrintDataTo(StringStream* stream) OVERRIDE;
1874 1875 1876

  int arity() const { return hydrogen()->argument_count() - 1; }

1877
  ZoneList<LOperand*> inputs_;
1878

1879
  // Iterator support.
1880 1881
  int InputCount() FINAL { return inputs_.length(); }
  LOperand* InputAt(int i) FINAL { return inputs_[i]; }
1882

1883 1884
  int TempCount() FINAL { return 0; }
  LOperand* TempAt(int i) FINAL { return NULL; }
1885 1886 1887
};


1888
class LInvokeFunction FINAL : public LTemplateInstruction<1, 2, 0> {
1889
 public:
1890
  LInvokeFunction(LOperand* context, LOperand* function) {
1891
    inputs_[0] = context;
1892
    inputs_[1] = function;
1893 1894 1895
  }

  LOperand* context() { return inputs_[0]; }
1896
  LOperand* function() { return inputs_[1]; }
1897

1898 1899
  DECLARE_CONCRETE_INSTRUCTION(InvokeFunction, "invoke-function")
  DECLARE_HYDROGEN_ACCESSOR(InvokeFunction)
1900

1901
  void PrintDataTo(StringStream* stream) OVERRIDE;
1902 1903 1904 1905 1906

  int arity() const { return hydrogen()->argument_count() - 1; }
};


1907
class LCallFunction FINAL : public LTemplateInstruction<1, 2, 2> {
1908
 public:
1909 1910
  LCallFunction(LOperand* context, LOperand* function, LOperand* slot,
                LOperand* vector) {
1911 1912
    inputs_[0] = context;
    inputs_[1] = function;
1913 1914
    temps_[0] = slot;
    temps_[1] = vector;
1915
  }
1916

1917 1918 1919
  DECLARE_CONCRETE_INSTRUCTION(CallFunction, "call-function")
  DECLARE_HYDROGEN_ACCESSOR(CallFunction)

1920 1921
  LOperand* context() { return inputs_[0]; }
  LOperand* function() { return inputs_[1]; }
1922 1923
  LOperand* temp_slot() { return temps_[0]; }
  LOperand* temp_vector() { return temps_[1]; }
1924
  int arity() const { return hydrogen()->argument_count() - 1; }
1925 1926

  void PrintDataTo(StringStream* stream) OVERRIDE;
1927 1928 1929
};


1930
class LCallNew FINAL : public LTemplateInstruction<1, 2, 0> {
1931
 public:
1932 1933 1934
  LCallNew(LOperand* context, LOperand* constructor) {
    inputs_[0] = context;
    inputs_[1] = constructor;
1935
  }
1936

1937 1938
  LOperand* context() { return inputs_[0]; }
  LOperand* constructor() { return inputs_[1]; }
1939

1940 1941 1942
  DECLARE_CONCRETE_INSTRUCTION(CallNew, "call-new")
  DECLARE_HYDROGEN_ACCESSOR(CallNew)

1943
  void PrintDataTo(StringStream* stream) OVERRIDE;
1944 1945 1946 1947 1948

  int arity() const { return hydrogen()->argument_count() - 1; }
};


1949
class LCallNewArray FINAL : public LTemplateInstruction<1, 2, 0> {
1950
 public:
1951 1952 1953
  LCallNewArray(LOperand* context, LOperand* constructor) {
    inputs_[0] = context;
    inputs_[1] = constructor;
1954 1955
  }

1956 1957
  LOperand* context() { return inputs_[0]; }
  LOperand* constructor() { return inputs_[1]; }
1958 1959 1960 1961

  DECLARE_CONCRETE_INSTRUCTION(CallNewArray, "call-new-array")
  DECLARE_HYDROGEN_ACCESSOR(CallNewArray)

1962
  void PrintDataTo(StringStream* stream) OVERRIDE;
1963 1964 1965 1966 1967

  int arity() const { return hydrogen()->argument_count() - 1; }
};


1968
class LCallRuntime FINAL : public LTemplateInstruction<1, 1, 0> {
1969
 public:
1970 1971 1972 1973 1974 1975
  explicit LCallRuntime(LOperand* context) {
    inputs_[0] = context;
  }

  LOperand* context() { return inputs_[0]; }

1976 1977 1978
  DECLARE_CONCRETE_INSTRUCTION(CallRuntime, "call-runtime")
  DECLARE_HYDROGEN_ACCESSOR(CallRuntime)

1979
  bool ClobbersDoubleRegisters(Isolate* isolate) const OVERRIDE {
1980 1981 1982
    return save_doubles() == kDontSaveFPRegs;
  }

1983
  const Runtime::Function* function() const { return hydrogen()->function(); }
1984
  int arity() const { return hydrogen()->argument_count(); }
1985
  SaveFPRegsMode save_doubles() const { return hydrogen()->save_doubles(); }
1986 1987 1988
};


1989
class LInteger32ToDouble FINAL : public LTemplateInstruction<1, 1, 0> {
1990
 public:
1991 1992 1993
  explicit LInteger32ToDouble(LOperand* value) {
    inputs_[0] = value;
  }
1994

1995 1996
  LOperand* value() { return inputs_[0]; }

1997 1998 1999 2000
  DECLARE_CONCRETE_INSTRUCTION(Integer32ToDouble, "int32-to-double")
};


2001
class LUint32ToDouble FINAL : public LTemplateInstruction<1, 1, 0> {
2002
 public:
2003
  explicit LUint32ToDouble(LOperand* value) {
2004 2005 2006
    inputs_[0] = value;
  }

2007 2008
  LOperand* value() { return inputs_[0]; }

2009 2010 2011 2012
  DECLARE_CONCRETE_INSTRUCTION(Uint32ToDouble, "uint32-to-double")
};


2013
class LNumberTagI FINAL : public LTemplateInstruction<1, 1, 2> {
2014
 public:
2015
  LNumberTagI(LOperand* value, LOperand* temp1, LOperand* temp2) {
2016
    inputs_[0] = value;
2017 2018
    temps_[0] = temp1;
    temps_[1] = temp2;
2019
  }
2020

2021
  LOperand* value() { return inputs_[0]; }
2022 2023
  LOperand* temp1() { return temps_[0]; }
  LOperand* temp2() { return temps_[1]; }
2024

2025 2026 2027 2028
  DECLARE_CONCRETE_INSTRUCTION(NumberTagI, "number-tag-i")
};


2029
class LNumberTagU FINAL : public LTemplateInstruction<1, 1, 2> {
2030
 public:
2031
  LNumberTagU(LOperand* value, LOperand* temp1, LOperand* temp2) {
2032
    inputs_[0] = value;
2033 2034
    temps_[0] = temp1;
    temps_[1] = temp2;
2035 2036
  }

2037
  LOperand* value() { return inputs_[0]; }
2038 2039
  LOperand* temp1() { return temps_[0]; }
  LOperand* temp2() { return temps_[1]; }
2040

2041 2042 2043 2044
  DECLARE_CONCRETE_INSTRUCTION(NumberTagU, "number-tag-u")
};


2045
class LNumberTagD FINAL : public LTemplateInstruction<1, 1, 1> {
2046
 public:
2047 2048 2049 2050
  explicit LNumberTagD(LOperand* value, LOperand* temp) {
    inputs_[0] = value;
    temps_[0] = temp;
  }
2051

2052 2053 2054
  LOperand* value() { return inputs_[0]; }
  LOperand* temp() { return temps_[0]; }

2055
  DECLARE_CONCRETE_INSTRUCTION(NumberTagD, "number-tag-d")
2056
  DECLARE_HYDROGEN_ACCESSOR(Change)
2057 2058 2059 2060
};


// Sometimes truncating conversion from a tagged value to an int32.
2061
class LDoubleToI FINAL : public LTemplateInstruction<1, 1, 0> {
2062
 public:
2063
  explicit LDoubleToI(LOperand* value) {
2064 2065
    inputs_[0] = value;
  }
2066

2067 2068
  LOperand* value() { return inputs_[0]; }

2069
  DECLARE_CONCRETE_INSTRUCTION(DoubleToI, "double-to-i")
2070
  DECLARE_HYDROGEN_ACCESSOR(UnaryOperation)
2071 2072 2073 2074 2075

  bool truncating() { return hydrogen()->CanTruncateToInt32(); }
};


2076
class LDoubleToSmi FINAL : public LTemplateInstruction<1, 1, 0> {
2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088
 public:
  explicit LDoubleToSmi(LOperand* value) {
    inputs_[0] = value;
  }

  LOperand* value() { return inputs_[0]; }

  DECLARE_CONCRETE_INSTRUCTION(DoubleToSmi, "double-to-smi")
  DECLARE_HYDROGEN_ACCESSOR(UnaryOperation)
};


2089
// Truncating conversion from a tagged value to an int32.
2090
class LTaggedToI FINAL : public LTemplateInstruction<1, 1, 1> {
2091
 public:
2092 2093 2094 2095
  LTaggedToI(LOperand* value, LOperand* temp) {
    inputs_[0] = value;
    temps_[0] = temp;
  }
2096

2097 2098 2099
  LOperand* value() { return inputs_[0]; }
  LOperand* temp() { return temps_[0]; }

2100
  DECLARE_CONCRETE_INSTRUCTION(TaggedToI, "tagged-to-i")
2101
  DECLARE_HYDROGEN_ACCESSOR(Change)
2102 2103 2104 2105 2106

  bool truncating() { return hydrogen()->CanTruncateToInt32(); }
};


2107
class LSmiTag FINAL : public LTemplateInstruction<1, 1, 0> {
2108
 public:
2109 2110 2111
  explicit LSmiTag(LOperand* value) {
    inputs_[0] = value;
  }
2112

2113 2114
  LOperand* value() { return inputs_[0]; }

2115
  DECLARE_CONCRETE_INSTRUCTION(SmiTag, "smi-tag")
2116
  DECLARE_HYDROGEN_ACCESSOR(Change)
2117 2118 2119
};


2120
class LNumberUntagD FINAL : public LTemplateInstruction<1, 1, 0> {
2121
 public:
2122 2123 2124
  explicit LNumberUntagD(LOperand* value) {
    inputs_[0] = value;
  }
2125

2126 2127
  LOperand* value() { return inputs_[0]; }

2128
  DECLARE_CONCRETE_INSTRUCTION(NumberUntagD, "double-untag")
2129
  DECLARE_HYDROGEN_ACCESSOR(Change);
2130 2131 2132
};


2133
class LSmiUntag FINAL : public LTemplateInstruction<1, 1, 0> {
2134
 public:
2135 2136 2137 2138
  LSmiUntag(LOperand* value, bool needs_check)
      : needs_check_(needs_check) {
    inputs_[0] = value;
  }
2139

2140
  LOperand* value() { return inputs_[0]; }
2141 2142
  bool needs_check() const { return needs_check_; }

2143 2144
  DECLARE_CONCRETE_INSTRUCTION(SmiUntag, "smi-untag")

2145 2146 2147 2148 2149
 private:
  bool needs_check_;
};


2150
class LStoreNamedField FINAL : public LTemplateInstruction<0, 2, 1> {
2151
 public:
2152
  LStoreNamedField(LOperand* object, LOperand* value, LOperand* temp) {
2153 2154
    inputs_[0] = object;
    inputs_[1] = value;
2155
    temps_[0] = temp;
2156 2157
  }

2158 2159 2160 2161
  LOperand* object() { return inputs_[0]; }
  LOperand* value() { return inputs_[1]; }
  LOperand* temp() { return temps_[0]; }

2162 2163
  DECLARE_CONCRETE_INSTRUCTION(StoreNamedField, "store-named-field")
  DECLARE_HYDROGEN_ACCESSOR(StoreNamedField)
2164

2165
  void PrintDataTo(StringStream* stream) OVERRIDE;
2166

2167 2168 2169
  Representation representation() const {
    return hydrogen()->field_representation();
  }
2170 2171 2172
};


2173
class LStoreNamedGeneric FINAL : public LTemplateInstruction<0, 3, 0> {
2174
 public:
2175 2176 2177 2178
  LStoreNamedGeneric(LOperand* context, LOperand* object, LOperand* value) {
    inputs_[0] = context;
    inputs_[1] = object;
    inputs_[2] = value;
2179
  }
2180

2181 2182 2183
  LOperand* context() { return inputs_[0]; }
  LOperand* object() { return inputs_[1]; }
  LOperand* value() { return inputs_[2]; }
2184

2185 2186
  DECLARE_CONCRETE_INSTRUCTION(StoreNamedGeneric, "store-named-generic")
  DECLARE_HYDROGEN_ACCESSOR(StoreNamedGeneric)
2187

2188
  void PrintDataTo(StringStream* stream) OVERRIDE;
2189 2190

  Handle<Object> name() const { return hydrogen()->name(); }
2191
  LanguageMode language_mode() { return hydrogen()->language_mode(); }
2192 2193 2194
};


2195
class LStoreKeyed FINAL : public LTemplateInstruction<0, 3, 0> {
2196
 public:
2197
  LStoreKeyed(LOperand* object, LOperand* key, LOperand* value) {
2198
    inputs_[0] = object;
2199
    inputs_[1] = key;
2200
    inputs_[2] = value;
2201 2202
  }

2203
  bool is_external() const { return hydrogen()->is_external(); }
2204 2205 2206 2207 2208 2209
  bool is_fixed_typed_array() const {
    return hydrogen()->is_fixed_typed_array();
  }
  bool is_typed_elements() const {
    return is_external() || is_fixed_typed_array();
  }
2210 2211 2212
  LOperand* elements() { return inputs_[0]; }
  LOperand* key() { return inputs_[1]; }
  LOperand* value() { return inputs_[2]; }
2213
  ElementsKind elements_kind() const { return hydrogen()->elements_kind(); }
2214

2215 2216
  DECLARE_CONCRETE_INSTRUCTION(StoreKeyed, "store-keyed")
  DECLARE_HYDROGEN_ACCESSOR(StoreKeyed)
2217

2218
  void PrintDataTo(StringStream* stream) OVERRIDE;
2219
  bool NeedsCanonicalization() { return hydrogen()->NeedsCanonicalization(); }
2220
  uint32_t base_offset() const { return hydrogen()->base_offset(); }
2221 2222 2223
};


2224
class LStoreKeyedGeneric FINAL : public LTemplateInstruction<0, 4, 0> {
2225
 public:
2226 2227 2228 2229 2230 2231 2232 2233
  LStoreKeyedGeneric(LOperand* context,
                     LOperand* object,
                     LOperand* key,
                     LOperand* value) {
    inputs_[0] = context;
    inputs_[1] = object;
    inputs_[2] = key;
    inputs_[3] = value;
2234
  }
2235

2236 2237 2238 2239
  LOperand* context() { return inputs_[0]; }
  LOperand* object() { return inputs_[1]; }
  LOperand* key() { return inputs_[2]; }
  LOperand* value() { return inputs_[3]; }
2240

2241
  DECLARE_CONCRETE_INSTRUCTION(StoreKeyedGeneric, "store-keyed-generic")
mmaly@chromium.org's avatar
mmaly@chromium.org committed
2242
  DECLARE_HYDROGEN_ACCESSOR(StoreKeyedGeneric)
2243

2244
  void PrintDataTo(StringStream* stream) OVERRIDE;
2245

2246
  LanguageMode language_mode() { return hydrogen()->language_mode(); }
2247 2248 2249
};


2250
class LTransitionElementsKind FINAL : public LTemplateInstruction<0, 2, 2> {
2251 2252
 public:
  LTransitionElementsKind(LOperand* object,
2253
                          LOperand* context,
2254
                          LOperand* new_map_temp,
2255
                          LOperand* temp) {
2256
    inputs_[0] = object;
2257
    inputs_[1] = context;
2258
    temps_[0] = new_map_temp;
2259
    temps_[1] = temp;
2260 2261
  }

2262
  LOperand* object() { return inputs_[0]; }
2263
  LOperand* context() { return inputs_[1]; }
2264 2265 2266
  LOperand* new_map_temp() { return temps_[0]; }
  LOperand* temp() { return temps_[1]; }

2267 2268 2269 2270
  DECLARE_CONCRETE_INSTRUCTION(TransitionElementsKind,
                               "transition-elements-kind")
  DECLARE_HYDROGEN_ACCESSOR(TransitionElementsKind)

2271
  void PrintDataTo(StringStream* stream) OVERRIDE;
2272

2273 2274 2275 2276
  Handle<Map> original_map() { return hydrogen()->original_map().handle(); }
  Handle<Map> transitioned_map() {
    return hydrogen()->transitioned_map().handle();
  }
2277 2278
  ElementsKind from_kind() { return hydrogen()->from_kind(); }
  ElementsKind to_kind() { return hydrogen()->to_kind(); }
2279 2280 2281
};


2282
class LTrapAllocationMemento FINAL : public LTemplateInstruction<0, 1, 1> {
2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297
 public:
  LTrapAllocationMemento(LOperand* object,
                         LOperand* temp) {
    inputs_[0] = object;
    temps_[0] = temp;
  }

  LOperand* object() { return inputs_[0]; }
  LOperand* temp() { return temps_[0]; }

  DECLARE_CONCRETE_INSTRUCTION(TrapAllocationMemento,
                               "trap-allocation-memento")
};


2298
class LStringAdd FINAL : public LTemplateInstruction<1, 3, 0> {
2299
 public:
2300 2301 2302 2303
  LStringAdd(LOperand* context, LOperand* left, LOperand* right) {
    inputs_[0] = context;
    inputs_[1] = left;
    inputs_[2] = right;
2304 2305
  }

2306 2307 2308
  LOperand* context() { return inputs_[0]; }
  LOperand* left() { return inputs_[1]; }
  LOperand* right() { return inputs_[2]; }
2309 2310 2311

  DECLARE_CONCRETE_INSTRUCTION(StringAdd, "string-add")
  DECLARE_HYDROGEN_ACCESSOR(StringAdd)
2312 2313 2314
};


2315
class LStringCharCodeAt FINAL : public LTemplateInstruction<1, 3, 0> {
2316
 public:
2317 2318 2319 2320
  LStringCharCodeAt(LOperand* context, LOperand* string, LOperand* index) {
    inputs_[0] = context;
    inputs_[1] = string;
    inputs_[2] = index;
2321 2322
  }

2323 2324 2325
  LOperand* context() { return inputs_[0]; }
  LOperand* string() { return inputs_[1]; }
  LOperand* index() { return inputs_[2]; }
2326 2327 2328

  DECLARE_CONCRETE_INSTRUCTION(StringCharCodeAt, "string-char-code-at")
  DECLARE_HYDROGEN_ACCESSOR(StringCharCodeAt)
2329 2330 2331
};


2332
class LStringCharFromCode FINAL : public LTemplateInstruction<1, 2, 0> {
2333
 public:
2334 2335 2336
  explicit LStringCharFromCode(LOperand* context, LOperand* char_code) {
    inputs_[0] = context;
    inputs_[1] = char_code;
2337 2338
  }

2339 2340
  LOperand* context() { return inputs_[0]; }
  LOperand* char_code() { return inputs_[1]; }
2341

2342 2343 2344 2345 2346
  DECLARE_CONCRETE_INSTRUCTION(StringCharFromCode, "string-char-from-code")
  DECLARE_HYDROGEN_ACCESSOR(StringCharFromCode)
};


2347
class LCheckValue FINAL : public LTemplateInstruction<0, 1, 0> {
2348
 public:
2349
  explicit LCheckValue(LOperand* value) {
2350 2351
    inputs_[0] = value;
  }
2352

2353
  LOperand* value() { return inputs_[0]; }
2354

2355 2356
  DECLARE_CONCRETE_INSTRUCTION(CheckValue, "check-value")
  DECLARE_HYDROGEN_ACCESSOR(CheckValue)
2357 2358 2359
};


2360
class LCheckInstanceType FINAL : public LTemplateInstruction<0, 1, 0> {
2361
 public:
2362
  explicit LCheckInstanceType(LOperand* value) {
2363 2364
    inputs_[0] = value;
  }
2365

2366 2367
  LOperand* value() { return inputs_[0]; }

2368 2369 2370 2371 2372
  DECLARE_CONCRETE_INSTRUCTION(CheckInstanceType, "check-instance-type")
  DECLARE_HYDROGEN_ACCESSOR(CheckInstanceType)
};


2373
class LCheckMaps FINAL : public LTemplateInstruction<0, 1, 0> {
2374
 public:
2375
  explicit LCheckMaps(LOperand* value = NULL) {
2376 2377
    inputs_[0] = value;
  }
2378

2379 2380
  LOperand* value() { return inputs_[0]; }

2381 2382
  DECLARE_CONCRETE_INSTRUCTION(CheckMaps, "check-maps")
  DECLARE_HYDROGEN_ACCESSOR(CheckMaps)
2383 2384 2385
};


2386
class LCheckSmi FINAL : public LTemplateInstruction<1, 1, 0> {
2387
 public:
2388
  explicit LCheckSmi(LOperand* value) {
2389 2390
    inputs_[0] = value;
  }
2391

2392 2393
  LOperand* value() { return inputs_[0]; }

2394 2395
  DECLARE_CONCRETE_INSTRUCTION(CheckSmi, "check-smi")
};
2396

2397

2398
class LClampDToUint8 FINAL : public LTemplateInstruction<1, 1, 0> {
2399
 public:
2400
  explicit LClampDToUint8(LOperand* unclamped) {
2401
    inputs_[0] = unclamped;
2402 2403 2404 2405
  }

  LOperand* unclamped() { return inputs_[0]; }

2406
  DECLARE_CONCRETE_INSTRUCTION(ClampDToUint8, "clamp-d-to-uint8")
2407 2408 2409
};


2410
class LClampIToUint8 FINAL : public LTemplateInstruction<1, 1, 0> {
2411
 public:
2412 2413
  explicit LClampIToUint8(LOperand* unclamped) {
    inputs_[0] = unclamped;
2414 2415 2416 2417 2418 2419 2420 2421
  }

  LOperand* unclamped() { return inputs_[0]; }

  DECLARE_CONCRETE_INSTRUCTION(ClampIToUint8, "clamp-i-to-uint8")
};


2422
class LClampTToUint8 FINAL : public LTemplateInstruction<1, 1, 1> {
2423
 public:
2424
  LClampTToUint8(LOperand* unclamped,
2425
                 LOperand* temp_xmm) {
2426
    inputs_[0] = unclamped;
2427
    temps_[0] = temp_xmm;
2428 2429 2430
  }

  LOperand* unclamped() { return inputs_[0]; }
2431
  LOperand* temp_xmm() { return temps_[0]; }
2432

2433
  DECLARE_CONCRETE_INSTRUCTION(ClampTToUint8, "clamp-t-to-uint8")
2434 2435 2436
};


2437
class LCheckNonSmi FINAL : public LTemplateInstruction<0, 1, 0> {
2438 2439 2440
 public:
  explicit LCheckNonSmi(LOperand* value) {
    inputs_[0] = value;
2441 2442
  }

2443 2444
  LOperand* value() { return inputs_[0]; }

2445
  DECLARE_CONCRETE_INSTRUCTION(CheckNonSmi, "check-non-smi")
2446
  DECLARE_HYDROGEN_ACCESSOR(CheckHeapObject)
2447 2448 2449
};


2450
class LDoubleBits FINAL : public LTemplateInstruction<1, 1, 0> {
2451 2452 2453 2454 2455 2456 2457 2458 2459 2460 2461 2462
 public:
  explicit LDoubleBits(LOperand* value) {
    inputs_[0] = value;
  }

  LOperand* value() { return inputs_[0]; }

  DECLARE_CONCRETE_INSTRUCTION(DoubleBits, "double-bits")
  DECLARE_HYDROGEN_ACCESSOR(DoubleBits)
};


2463
class LConstructDouble FINAL : public LTemplateInstruction<1, 2, 0> {
2464 2465 2466 2467 2468 2469 2470 2471 2472 2473 2474 2475 2476
 public:
  LConstructDouble(LOperand* hi, LOperand* lo) {
    inputs_[0] = hi;
    inputs_[1] = lo;
  }

  LOperand* hi() { return inputs_[0]; }
  LOperand* lo() { return inputs_[1]; }

  DECLARE_CONCRETE_INSTRUCTION(ConstructDouble, "construct-double")
};


2477
class LAllocate FINAL : public LTemplateInstruction<1, 2, 1> {
2478
 public:
2479 2480 2481
  LAllocate(LOperand* context, LOperand* size, LOperand* temp) {
    inputs_[0] = context;
    inputs_[1] = size;
2482 2483 2484
    temps_[0] = temp;
  }

2485 2486
  LOperand* context() { return inputs_[0]; }
  LOperand* size() { return inputs_[1]; }
2487 2488 2489 2490 2491 2492 2493
  LOperand* temp() { return temps_[0]; }

  DECLARE_CONCRETE_INSTRUCTION(Allocate, "allocate")
  DECLARE_HYDROGEN_ACCESSOR(Allocate)
};


2494
class LRegExpLiteral FINAL : public LTemplateInstruction<1, 1, 0> {
2495
 public:
2496 2497 2498 2499 2500 2501
  explicit LRegExpLiteral(LOperand* context) {
    inputs_[0] = context;
  }

  LOperand* context() { return inputs_[0]; }

2502 2503 2504 2505 2506
  DECLARE_CONCRETE_INSTRUCTION(RegExpLiteral, "regexp-literal")
  DECLARE_HYDROGEN_ACCESSOR(RegExpLiteral)
};


2507
class LFunctionLiteral FINAL : public LTemplateInstruction<1, 1, 0> {
2508
 public:
2509 2510 2511 2512 2513 2514
  explicit LFunctionLiteral(LOperand* context) {
    inputs_[0] = context;
  }

  LOperand* context() { return inputs_[0]; }

2515 2516 2517 2518 2519
  DECLARE_CONCRETE_INSTRUCTION(FunctionLiteral, "function-literal")
  DECLARE_HYDROGEN_ACCESSOR(FunctionLiteral)
};


2520
class LToFastProperties FINAL : public LTemplateInstruction<1, 1, 0> {
2521 2522 2523 2524 2525
 public:
  explicit LToFastProperties(LOperand* value) {
    inputs_[0] = value;
  }

2526 2527
  LOperand* value() { return inputs_[0]; }

2528 2529 2530 2531 2532
  DECLARE_CONCRETE_INSTRUCTION(ToFastProperties, "to-fast-properties")
  DECLARE_HYDROGEN_ACCESSOR(ToFastProperties)
};


2533
class LTypeof FINAL : public LTemplateInstruction<1, 2, 0> {
2534
 public:
2535 2536 2537
  LTypeof(LOperand* context, LOperand* value) {
    inputs_[0] = context;
    inputs_[1] = value;
2538
  }
2539

2540 2541
  LOperand* context() { return inputs_[0]; }
  LOperand* value() { return inputs_[1]; }
2542

2543 2544 2545 2546
  DECLARE_CONCRETE_INSTRUCTION(Typeof, "typeof")
};


2547
class LTypeofIsAndBranch FINAL : public LControlInstruction<1, 0> {
2548
 public:
2549 2550 2551
  explicit LTypeofIsAndBranch(LOperand* value) {
    inputs_[0] = value;
  }
2552

2553 2554
  LOperand* value() { return inputs_[0]; }

2555
  DECLARE_CONCRETE_INSTRUCTION(TypeofIsAndBranch, "typeof-is-and-branch")
2556
  DECLARE_HYDROGEN_ACCESSOR(TypeofIsAndBranch)
2557

2558
  Handle<String> type_literal() { return hydrogen()->type_literal(); }
2559

2560
  void PrintDataTo(StringStream* stream) OVERRIDE;
2561 2562 2563
};


2564
class LIsConstructCallAndBranch FINAL : public LControlInstruction<0, 1> {
2565 2566 2567 2568 2569
 public:
  explicit LIsConstructCallAndBranch(LOperand* temp) {
    temps_[0] = temp;
  }

2570 2571
  LOperand* temp() { return temps_[0]; }

2572 2573
  DECLARE_CONCRETE_INSTRUCTION(IsConstructCallAndBranch,
                               "is-construct-call-and-branch")
2574
  DECLARE_HYDROGEN_ACCESSOR(IsConstructCallAndBranch)
2575 2576 2577
};


2578
class LOsrEntry FINAL : public LTemplateInstruction<0, 0, 0> {
2579
 public:
2580
  LOsrEntry() {}
2581

2582
  bool HasInterestingComment(LCodeGen* gen) const OVERRIDE { return false; }
2583 2584 2585 2586
  DECLARE_CONCRETE_INSTRUCTION(OsrEntry, "osr-entry")
};


2587
class LStackCheck FINAL : public LTemplateInstruction<0, 1, 0> {
2588
 public:
2589 2590 2591 2592 2593 2594
  explicit LStackCheck(LOperand* context) {
    inputs_[0] = context;
  }

  LOperand* context() { return inputs_[0]; }

2595
  DECLARE_CONCRETE_INSTRUCTION(StackCheck, "stack-check")
2596 2597 2598 2599 2600 2601
  DECLARE_HYDROGEN_ACCESSOR(StackCheck)

  Label* done_label() { return &done_label_; }

 private:
  Label done_label_;
2602 2603 2604
};


2605
class LForInPrepareMap FINAL : public LTemplateInstruction<1, 2, 0> {
2606
 public:
2607 2608 2609
  LForInPrepareMap(LOperand* context, LOperand* object) {
    inputs_[0] = context;
    inputs_[1] = object;
2610 2611
  }

2612 2613
  LOperand* context() { return inputs_[0]; }
  LOperand* object() { return inputs_[1]; }
2614 2615 2616 2617 2618

  DECLARE_CONCRETE_INSTRUCTION(ForInPrepareMap, "for-in-prepare-map")
};


2619
class LForInCacheArray FINAL : public LTemplateInstruction<1, 1, 0> {
2620 2621 2622 2623 2624 2625 2626 2627 2628 2629 2630 2631 2632 2633 2634
 public:
  explicit LForInCacheArray(LOperand* map) {
    inputs_[0] = map;
  }

  LOperand* map() { return inputs_[0]; }

  DECLARE_CONCRETE_INSTRUCTION(ForInCacheArray, "for-in-cache-array")

  int idx() {
    return HForInCacheArray::cast(this->hydrogen_value())->idx();
  }
};


2635
class LCheckMapValue FINAL : public LTemplateInstruction<0, 2, 0> {
2636 2637 2638 2639 2640 2641 2642 2643 2644 2645 2646 2647 2648
 public:
  LCheckMapValue(LOperand* value, LOperand* map) {
    inputs_[0] = value;
    inputs_[1] = map;
  }

  LOperand* value() { return inputs_[0]; }
  LOperand* map() { return inputs_[1]; }

  DECLARE_CONCRETE_INSTRUCTION(CheckMapValue, "check-map-value")
};


2649
class LLoadFieldByIndex FINAL : public LTemplateInstruction<1, 2, 0> {
2650 2651 2652 2653 2654 2655 2656 2657 2658 2659 2660 2661 2662
 public:
  LLoadFieldByIndex(LOperand* object, LOperand* index) {
    inputs_[0] = object;
    inputs_[1] = index;
  }

  LOperand* object() { return inputs_[0]; }
  LOperand* index() { return inputs_[1]; }

  DECLARE_CONCRETE_INSTRUCTION(LoadFieldByIndex, "load-field-by-index")
};


2663 2664 2665 2666 2667 2668 2669 2670 2671 2672 2673 2674 2675 2676 2677 2678 2679 2680 2681 2682 2683 2684 2685 2686 2687 2688 2689 2690 2691
class LStoreFrameContext: public LTemplateInstruction<0, 1, 0> {
 public:
  explicit LStoreFrameContext(LOperand* context) {
    inputs_[0] = context;
  }

  LOperand* context() { return inputs_[0]; }

  DECLARE_CONCRETE_INSTRUCTION(StoreFrameContext, "store-frame-context")
};


class LAllocateBlockContext: public LTemplateInstruction<1, 2, 0> {
 public:
  LAllocateBlockContext(LOperand* context, LOperand* function) {
    inputs_[0] = context;
    inputs_[1] = function;
  }

  LOperand* context() { return inputs_[0]; }
  LOperand* function() { return inputs_[1]; }

  Handle<ScopeInfo> scope_info() { return hydrogen()->scope_info(); }

  DECLARE_CONCRETE_INSTRUCTION(AllocateBlockContext, "allocate-block-context")
  DECLARE_HYDROGEN_ACCESSOR(AllocateBlockContext)
};


2692
class LChunkBuilder;
2693
class LPlatformChunk FINAL : public LChunk {
2694
 public:
2695
  LPlatformChunk(CompilationInfo* info, HGraph* graph)
2696 2697
      : LChunk(info, graph),
        dehoisted_key_ids_(graph->GetMaximumValueID(), graph->zone()) { }
2698

2699 2700
  int GetNextSpillIndex(RegisterKind kind);
  LOperand* GetNextSpillSlot(RegisterKind kind);
2701 2702 2703 2704 2705 2706 2707
  BitVector* GetDehoistedKeyIds() { return &dehoisted_key_ids_; }
  bool IsDehoistedKey(HValue* value) {
    return dehoisted_key_ids_.Contains(value->id());
  }

 private:
  BitVector dehoisted_key_ids_;
2708 2709 2710
};


2711
class LChunkBuilder FINAL : public LChunkBuilderBase {
2712
 public:
2713
  LChunkBuilder(CompilationInfo* info, HGraph* graph, LAllocator* allocator)
2714
      : LChunkBuilderBase(info, graph),
2715 2716 2717
        current_instruction_(NULL),
        current_block_(NULL),
        next_block_(NULL),
2718
        allocator_(allocator) {}
2719

2720
  // Build the sequence for the graph.
2721
  LPlatformChunk* Build();
2722 2723 2724 2725 2726 2727

  // Declare methods that deal with the individual node types.
#define DECLARE_DO(type) LInstruction* Do##type(H##type* node);
  HYDROGEN_CONCRETE_INSTRUCTION_LIST(DECLARE_DO)
#undef DECLARE_DO

2728 2729
  LInstruction* DoMathFloor(HUnaryMathOperation* instr);
  LInstruction* DoMathRound(HUnaryMathOperation* instr);
2730
  LInstruction* DoMathFround(HUnaryMathOperation* instr);
2731 2732 2733 2734 2735
  LInstruction* DoMathAbs(HUnaryMathOperation* instr);
  LInstruction* DoMathLog(HUnaryMathOperation* instr);
  LInstruction* DoMathExp(HUnaryMathOperation* instr);
  LInstruction* DoMathSqrt(HUnaryMathOperation* instr);
  LInstruction* DoMathPowHalf(HUnaryMathOperation* instr);
2736
  LInstruction* DoMathClz32(HUnaryMathOperation* instr);
2737
  LInstruction* DoDivByPowerOf2I(HDiv* instr);
2738
  LInstruction* DoDivByConstI(HDiv* instr);
2739
  LInstruction* DoDivI(HDiv* instr);
2740
  LInstruction* DoModByPowerOf2I(HMod* instr);
2741
  LInstruction* DoModByConstI(HMod* instr);
2742 2743 2744
  LInstruction* DoModI(HMod* instr);
  LInstruction* DoFlooringDivByPowerOf2I(HMathFloorOfDiv* instr);
  LInstruction* DoFlooringDivByConstI(HMathFloorOfDiv* instr);
2745
  LInstruction* DoFlooringDivI(HMathFloorOfDiv* instr);
2746

2747 2748 2749 2750 2751 2752
 private:
  // Methods for getting operands for Use / Define / Temp.
  LUnallocated* ToUnallocated(Register reg);
  LUnallocated* ToUnallocated(XMMRegister reg);

  // Methods for setting up define-use relationships.
2753 2754 2755 2756
  MUST_USE_RESULT LOperand* Use(HValue* value, LUnallocated* operand);
  MUST_USE_RESULT LOperand* UseFixed(HValue* value, Register fixed_register);
  MUST_USE_RESULT LOperand* UseFixedDouble(HValue* value,
                                           XMMRegister fixed_register);
2757 2758 2759 2760 2761 2762 2763 2764 2765

  // A value that is guaranteed to be allocated to a register.
  // Operand created by UseRegister is guaranteed to be live until the end of
  // instruction. This means that register allocator will not reuse it's
  // register for any other operand inside instruction.
  // Operand created by UseRegisterAtStart is guaranteed to be live only at
  // instruction start. Register allocator is free to assign the same register
  // to some other operand used inside instruction (i.e. temporary or
  // output).
2766 2767
  MUST_USE_RESULT LOperand* UseRegister(HValue* value);
  MUST_USE_RESULT LOperand* UseRegisterAtStart(HValue* value);
2768

2769
  // An input operand in a register that may be trashed.
2770
  MUST_USE_RESULT LOperand* UseTempRegister(HValue* value);
2771

2772 2773 2774
  // An input operand in a register that may be trashed or a constant operand.
  MUST_USE_RESULT LOperand* UseTempRegisterOrConstant(HValue* value);

2775
  // An input operand in a register or stack slot.
2776 2777
  MUST_USE_RESULT LOperand* Use(HValue* value);
  MUST_USE_RESULT LOperand* UseAtStart(HValue* value);
2778

2779
  // An input operand in a register, stack slot or a constant operand.
2780 2781
  MUST_USE_RESULT LOperand* UseOrConstant(HValue* value);
  MUST_USE_RESULT LOperand* UseOrConstantAtStart(HValue* value);
2782

2783
  // An input operand in a register or a constant operand.
2784 2785 2786
  MUST_USE_RESULT LOperand* UseRegisterOrConstant(HValue* value);
  MUST_USE_RESULT LOperand* UseRegisterOrConstantAtStart(HValue* value);

2787 2788 2789
  // An input operand in a constant operand.
  MUST_USE_RESULT LOperand* UseConstant(HValue* value);

2790 2791
  // An input operand in register, stack slot or a constant operand.
  // Will not be moved to a register even if one is freely available.
2792
  MUST_USE_RESULT LOperand* UseAny(HValue* value) OVERRIDE;
2793

2794 2795 2796 2797
  // Temporary operand that must be in a register.
  MUST_USE_RESULT LUnallocated* TempRegister();
  MUST_USE_RESULT LOperand* FixedTemp(Register reg);
  MUST_USE_RESULT LOperand* FixedTemp(XMMRegister reg);
2798 2799 2800

  // Methods for setting up define-use relationships.
  // Return the same instruction that they are passed.
2801 2802 2803 2804 2805 2806 2807 2808 2809 2810
  LInstruction* Define(LTemplateResultInstruction<1>* instr,
                       LUnallocated* result);
  LInstruction* DefineAsRegister(LTemplateResultInstruction<1>* instr);
  LInstruction* DefineAsSpilled(LTemplateResultInstruction<1>* instr,
                                int index);
  LInstruction* DefineSameAsFirst(LTemplateResultInstruction<1>* instr);
  LInstruction* DefineFixed(LTemplateResultInstruction<1>* instr,
                            Register reg);
  LInstruction* DefineFixedDouble(LTemplateResultInstruction<1>* instr,
                                  XMMRegister reg);
2811 2812
  // Assigns an environment to an instruction.  An instruction which can
  // deoptimize must have an environment.
2813
  LInstruction* AssignEnvironment(LInstruction* instr);
2814 2815
  // Assigns a pointer map to an instruction.  An instruction which can
  // trigger a GC or a lazy deoptimization must have a pointer map.
2816 2817 2818 2819
  LInstruction* AssignPointerMap(LInstruction* instr);

  enum CanDeoptimize { CAN_DEOPTIMIZE_EAGERLY, CANNOT_DEOPTIMIZE_EAGERLY };

2820 2821 2822
  // Marks a call for the register allocator.  Assigns a pointer map to
  // support GC and lazy deoptimization.  Assigns an environment to support
  // eager deoptimization if CAN_DEOPTIMIZE_EAGERLY.
2823 2824 2825 2826 2827 2828
  LInstruction* MarkAsCall(
      LInstruction* instr,
      HInstruction* hinstr,
      CanDeoptimize can_deoptimize = CANNOT_DEOPTIMIZE_EAGERLY);

  void VisitInstruction(HInstruction* current);
2829
  void AddInstruction(LInstruction* instr, HInstruction* current);
2830 2831

  void DoBasicBlock(HBasicBlock* block, HBasicBlock* next_block);
2832 2833 2834 2835
  LInstruction* DoShift(Token::Value op, HBitwiseBinaryOperation* instr);
  LInstruction* DoArithmeticD(Token::Value op,
                              HArithmeticBinaryOperation* instr);
  LInstruction* DoArithmeticT(Token::Value op,
2836
                              HBinaryOperation* instr);
2837
  void FindDehoistedKeyDefinitions(HValue* candidate);
2838 2839 2840 2841 2842 2843

  HInstruction* current_instruction_;
  HBasicBlock* current_block_;
  HBasicBlock* next_block_;
  LAllocator* allocator_;

2844 2845 2846
  DISALLOW_COPY_AND_ASSIGN(LChunkBuilder);
};

2847 2848
#undef DECLARE_HYDROGEN_ACCESSOR
#undef DECLARE_CONCRETE_INSTRUCTION
2849

2850
} }  // namespace v8::int
2851 2852

#endif  // V8_X64_LITHIUM_X64_H_