lithium-x87.h 70.1 KB
Newer Older
danno@chromium.org's avatar
danno@chromium.org committed
1 2 3 4
// Copyright 2012 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

5 6
#ifndef V8_CRANKSHAFT_X87_LITHIUM_X87_H_
#define V8_CRANKSHAFT_X87_LITHIUM_X87_H_
danno@chromium.org's avatar
danno@chromium.org committed
7

8 9 10
#include "src/crankshaft/hydrogen.h"
#include "src/crankshaft/lithium.h"
#include "src/crankshaft/lithium-allocator.h"
11 12
#include "src/safepoint-table.h"
#include "src/utils.h"
danno@chromium.org's avatar
danno@chromium.org committed
13 14 15 16

namespace v8 {
namespace internal {

17 18 19 20
namespace compiler {
class RCodeVisualizer;
}

danno@chromium.org's avatar
danno@chromium.org committed
21 22 23
// Forward declarations.
class LCodeGen;

24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
#define LITHIUM_CONCRETE_INSTRUCTION_LIST(V) \
  V(AccessArgumentsAt)                       \
  V(AddI)                                    \
  V(Allocate)                                \
  V(ApplyArguments)                          \
  V(ArgumentsElements)                       \
  V(ArgumentsLength)                         \
  V(ArithmeticD)                             \
  V(ArithmeticT)                             \
  V(BitI)                                    \
  V(BoundsCheck)                             \
  V(Branch)                                  \
  V(CallWithDescriptor)                      \
  V(CallNewArray)                            \
  V(CallRuntime)                             \
39
  V(CheckArrayBufferNotNeutered)             \
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
  V(CheckInstanceType)                       \
  V(CheckMaps)                               \
  V(CheckMapValue)                           \
  V(CheckNonSmi)                             \
  V(CheckSmi)                                \
  V(CheckValue)                              \
  V(ClampDToUint8)                           \
  V(ClampIToUint8)                           \
  V(ClampTToUint8NoSSE2)                     \
  V(ClassOfTestAndBranch)                    \
  V(ClobberDoubles)                          \
  V(CompareNumericAndBranch)                 \
  V(CmpObjectEqAndBranch)                    \
  V(CmpHoleAndBranch)                        \
  V(CmpMapAndBranch)                         \
  V(CmpT)                                    \
  V(ConstantD)                               \
  V(ConstantE)                               \
  V(ConstantI)                               \
  V(ConstantS)                               \
  V(ConstantT)                               \
  V(Context)                                 \
  V(DebugBreak)                              \
  V(DeclareGlobals)                          \
  V(Deoptimize)                              \
  V(DivByConstI)                             \
  V(DivByPowerOf2I)                          \
  V(DivI)                                    \
  V(DoubleToI)                               \
  V(DoubleToSmi)                             \
  V(Drop)                                    \
  V(Dummy)                                   \
  V(DummyUse)                                \
73
  V(FastAllocate)                            \
74 75 76 77 78 79
  V(FlooringDivByConstI)                     \
  V(FlooringDivByPowerOf2I)                  \
  V(FlooringDivI)                            \
  V(ForInCacheArray)                         \
  V(ForInPrepareMap)                         \
  V(Goto)                                    \
80
  V(HasInPrototypeChainAndBranch)            \
81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98
  V(HasInstanceTypeAndBranch)                \
  V(InnerAllocatedObject)                    \
  V(InstructionGap)                          \
  V(Integer32ToDouble)                       \
  V(InvokeFunction)                          \
  V(IsStringAndBranch)                       \
  V(IsSmiAndBranch)                          \
  V(IsUndetectableAndBranch)                 \
  V(Label)                                   \
  V(LazyBailout)                             \
  V(LoadContextSlot)                         \
  V(LoadFieldByIndex)                        \
  V(LoadFunctionPrototype)                   \
  V(LoadKeyed)                               \
  V(LoadNamedField)                          \
  V(LoadRoot)                                \
  V(MathAbs)                                 \
  V(MathClz32)                               \
99
  V(MathCos)                                 \
100 101 102 103 104 105 106 107
  V(MathExp)                                 \
  V(MathFloor)                               \
  V(MathFround)                              \
  V(MathLog)                                 \
  V(MathMinMax)                              \
  V(MathPowHalf)                             \
  V(MathRound)                               \
  V(MathSqrt)                                \
108
  V(MaybeGrowElements)                       \
109
  V(MathSin)                                 \
110 111 112 113 114 115 116 117 118 119 120
  V(ModByConstI)                             \
  V(ModByPowerOf2I)                          \
  V(ModI)                                    \
  V(MulI)                                    \
  V(NumberTagD)                              \
  V(NumberTagI)                              \
  V(NumberTagU)                              \
  V(NumberUntagD)                            \
  V(OsrEntry)                                \
  V(Parameter)                               \
  V(Power)                                   \
121
  V(Prologue)                                \
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
  V(PushArgument)                            \
  V(Return)                                  \
  V(SeqStringGetChar)                        \
  V(SeqStringSetChar)                        \
  V(ShiftI)                                  \
  V(SmiTag)                                  \
  V(SmiUntag)                                \
  V(StackCheck)                              \
  V(StoreCodeEntry)                          \
  V(StoreContextSlot)                        \
  V(StoreKeyed)                              \
  V(StoreNamedField)                         \
  V(StringAdd)                               \
  V(StringCharCodeAt)                        \
  V(StringCharFromCode)                      \
  V(StringCompareAndBranch)                  \
  V(SubI)                                    \
  V(TaggedToI)                               \
  V(ThisFunction)                            \
  V(TransitionElementsKind)                  \
  V(TrapAllocationMemento)                   \
  V(Typeof)                                  \
  V(TypeofIsAndBranch)                       \
  V(Uint32ToDouble)                          \
  V(UnknownOSRValue)                         \
danno@chromium.org's avatar
danno@chromium.org committed
147 148
  V(WrapReceiver)

149
#define DECLARE_CONCRETE_INSTRUCTION(type, mnemonic)            \
150 151 152
  Opcode opcode() const final { return LInstruction::k##type; } \
  void CompileToNative(LCodeGen* generator) final;              \
  const char* Mnemonic() const final { return mnemonic; }       \
153 154 155
  static L##type* cast(LInstruction* instr) {                   \
    DCHECK(instr->Is##type());                                  \
    return reinterpret_cast<L##type*>(instr);                   \
danno@chromium.org's avatar
danno@chromium.org committed
156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183
  }


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


class LInstruction : public ZoneObject {
 public:
  LInstruction()
      : environment_(NULL),
        hydrogen_value_(NULL),
        bit_field_(IsCallBits::encode(false)) {
  }

  virtual ~LInstruction() {}

  virtual void CompileToNative(LCodeGen* generator) = 0;
  virtual const char* Mnemonic() const = 0;
  virtual void PrintTo(StringStream* stream);
  virtual void PrintDataTo(StringStream* stream);
  virtual void PrintOutputOperandTo(StringStream* stream);

  enum Opcode {
    // Declare a unique enum value for each instruction.
#define DECLARE_OPCODE(type) k##type,
184
    LITHIUM_CONCRETE_INSTRUCTION_LIST(DECLARE_OPCODE) kAdapter,
danno@chromium.org's avatar
danno@chromium.org committed
185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202
    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; }

  virtual bool IsControl() const { return false; }

203 204 205
  // Try deleting this instruction if possible.
  virtual bool TryDelete() { return false; }

danno@chromium.org's avatar
danno@chromium.org committed
206 207 208 209 210 211 212 213 214 215 216 217 218 219
  void set_environment(LEnvironment* env) { environment_ = env; }
  LEnvironment* environment() const { return environment_; }
  bool HasEnvironment() const { return environment_ != NULL; }

  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(); }

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

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

220 221 222 223 224 225 226
  void MarkAsSyntacticTailCall() {
    bit_field_ = IsSyntacticTailCallBits::update(bit_field_, true);
  }
  bool IsSyntacticTailCall() const {
    return IsSyntacticTailCallBits::decode(bit_field_);
  }

danno@chromium.org's avatar
danno@chromium.org committed
227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252
  // Interface to the register allocator and iterators.
  bool ClobbersTemps() const { return IsCall(); }
  bool ClobbersRegisters() const { return IsCall(); }
  virtual bool ClobbersDoubleRegisters(Isolate* isolate) const {
    return IsCall() ||
           // We only have rudimentary X87Stack tracking, thus in general
           // cannot handle phi-nodes.
        (IsControl());
  }

  virtual bool HasResult() const = 0;
  virtual LOperand* result() const = 0;

  bool HasDoubleRegisterResult();
  bool HasDoubleRegisterInput();
  bool IsDoubleInput(X87Register reg, LCodeGen* cgen);

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

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

#ifdef DEBUG
  void VerifyCall();
#endif

253 254 255
  virtual int InputCount() = 0;
  virtual LOperand* InputAt(int i) = 0;

danno@chromium.org's avatar
danno@chromium.org committed
256 257 258 259 260 261 262 263 264
 private:
  // Iterator support.
  friend class InputIterator;

  friend class TempIterator;
  virtual int TempCount() = 0;
  virtual LOperand* TempAt(int i) = 0;

  class IsCallBits: public BitField<bool, 0, 1> {};
265 266
  class IsSyntacticTailCallBits : public BitField<bool, IsCallBits::kNext, 1> {
  };
danno@chromium.org's avatar
danno@chromium.org committed
267 268 269 270 271 272 273 274 275 276 277 278 279 280

  LEnvironment* environment_;
  SetOncePointer<LPointerMap> pointer_map_;
  HValue* hydrogen_value_;
  int bit_field_;
};


// R = number of result operands (0 or 1).
template<int R>
class LTemplateResultInstruction : public LInstruction {
 public:
  // Allow 0 or 1 output operands.
  STATIC_ASSERT(R == 0 || R == 1);
281
  bool HasResult() const final { return R != 0 && result() != NULL; }
danno@chromium.org's avatar
danno@chromium.org committed
282
  void set_result(LOperand* operand) { results_[0] = operand; }
283
  LOperand* result() const override { return results_[0]; }
danno@chromium.org's avatar
danno@chromium.org committed
284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300

 protected:
  EmbeddedContainer<LOperand*, R> results_;
};


// 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:
  EmbeddedContainer<LOperand*, I> inputs_;
  EmbeddedContainer<LOperand*, T> temps_;

 private:
  // Iterator support.
301 302
  int InputCount() final { return I; }
  LOperand* InputAt(int i) final { return inputs_[i]; }
danno@chromium.org's avatar
danno@chromium.org committed
303

304 305
  int TempCount() final { return T; }
  LOperand* TempAt(int i) final { return temps_[i]; }
danno@chromium.org's avatar
danno@chromium.org committed
306 307 308 309 310 311 312 313 314 315 316 317 318
};


class LGap : public LTemplateInstruction<0, 0, 0> {
 public:
  explicit LGap(HBasicBlock* block) : block_(block) {
    parallel_moves_[BEFORE] = NULL;
    parallel_moves_[START] = NULL;
    parallel_moves_[END] = NULL;
    parallel_moves_[AFTER] = NULL;
  }

  // Can't use the DECLARE-macro here because of sub-classes.
319 320
  bool IsGap() const final { return true; }
  void PrintDataTo(StringStream* stream) override;
danno@chromium.org's avatar
danno@chromium.org committed
321
  static LGap* cast(LInstruction* instr) {
322
    DCHECK(instr->IsGap());
danno@chromium.org's avatar
danno@chromium.org committed
323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355
    return reinterpret_cast<LGap*>(instr);
  }

  bool IsRedundant() const;

  HBasicBlock* block() const { return block_; }

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

  LParallelMove* GetOrCreateParallelMove(InnerPosition pos, Zone* zone)  {
    if (parallel_moves_[pos] == NULL) {
      parallel_moves_[pos] = new(zone) LParallelMove(zone);
    }
    return parallel_moves_[pos];
  }

  LParallelMove* GetParallelMove(InnerPosition pos)  {
    return parallel_moves_[pos];
  }

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


356
class LInstructionGap final : public LGap {
danno@chromium.org's avatar
danno@chromium.org committed
357 358 359
 public:
  explicit LInstructionGap(HBasicBlock* block) : LGap(block) { }

360
  bool HasInterestingComment(LCodeGen* gen) const override {
danno@chromium.org's avatar
danno@chromium.org committed
361 362 363 364 365 366 367
    return !IsRedundant();
  }

  DECLARE_CONCRETE_INSTRUCTION(InstructionGap, "gap")
};


368
class LClobberDoubles final : public LTemplateInstruction<0, 0, 0> {
danno@chromium.org's avatar
danno@chromium.org committed
369 370 371
 public:
  explicit LClobberDoubles(Isolate* isolate) { }

372
  bool ClobbersDoubleRegisters(Isolate* isolate) const override { return true; }
danno@chromium.org's avatar
danno@chromium.org committed
373 374 375 376 377

  DECLARE_CONCRETE_INSTRUCTION(ClobberDoubles, "clobber-d")
};


378
class LGoto final : public LTemplateInstruction<0, 0, 0> {
danno@chromium.org's avatar
danno@chromium.org committed
379 380 381
 public:
  explicit LGoto(HBasicBlock* block) : block_(block) { }

382
  bool HasInterestingComment(LCodeGen* gen) const override;
danno@chromium.org's avatar
danno@chromium.org committed
383
  DECLARE_CONCRETE_INSTRUCTION(Goto, "goto")
384 385
  void PrintDataTo(StringStream* stream) override;
  bool IsControl() const override { return true; }
danno@chromium.org's avatar
danno@chromium.org committed
386 387

  int block_id() const { return block_->block_id(); }
388
  bool ClobbersDoubleRegisters(Isolate* isolate) const override {
danno@chromium.org's avatar
danno@chromium.org committed
389 390 391 392
    return false;
  }

  bool jumps_to_join() const { return block_->predecessors()->length() > 1; }
393
  HBasicBlock* block() const { return block_; }
danno@chromium.org's avatar
danno@chromium.org committed
394 395 396 397 398 399

 private:
  HBasicBlock* block_;
};


400 401 402 403 404 405
class LPrologue final : public LTemplateInstruction<0, 0, 0> {
 public:
  DECLARE_CONCRETE_INSTRUCTION(Prologue, "prologue")
};


406
class LLazyBailout final : public LTemplateInstruction<0, 0, 0> {
danno@chromium.org's avatar
danno@chromium.org committed
407 408 409 410 411
 public:
  DECLARE_CONCRETE_INSTRUCTION(LazyBailout, "lazy-bailout")
};


412
class LDummy final : public LTemplateInstruction<1, 0, 0> {
danno@chromium.org's avatar
danno@chromium.org committed
413
 public:
414
  LDummy() {}
danno@chromium.org's avatar
danno@chromium.org committed
415 416 417 418
  DECLARE_CONCRETE_INSTRUCTION(Dummy, "dummy")
};


419
class LDummyUse final : public LTemplateInstruction<1, 1, 0> {
danno@chromium.org's avatar
danno@chromium.org committed
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> {
danno@chromium.org's avatar
danno@chromium.org committed
429
 public:
430
  bool IsControl() const override { return true; }
danno@chromium.org's avatar
danno@chromium.org committed
431 432 433 434 435
  DECLARE_CONCRETE_INSTRUCTION(Deoptimize, "deoptimize")
  DECLARE_HYDROGEN_ACCESSOR(Deoptimize)
};


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

441
  bool HasInterestingComment(LCodeGen* gen) const override { return false; }
danno@chromium.org's avatar
danno@chromium.org committed
442 443
  DECLARE_CONCRETE_INSTRUCTION(Label, "label")

444
  void PrintDataTo(StringStream* stream) override;
danno@chromium.org's avatar
danno@chromium.org committed
445 446 447 448 449 450 451 452 453 454 455 456 457 458 459

  int block_id() const { return block()->block_id(); }
  bool is_loop_header() const { return block()->IsLoopHeader(); }
  bool is_osr_entry() const { return block()->is_osr_entry(); }
  Label* label() { return &label_; }
  LLabel* replacement() const { return replacement_; }
  void set_replacement(LLabel* label) { replacement_ = label; }
  bool HasReplacement() const { return replacement_ != NULL; }

 private:
  Label label_;
  LLabel* replacement_;
};


460
class LParameter final : public LTemplateInstruction<1, 0, 0> {
danno@chromium.org's avatar
danno@chromium.org committed
461
 public:
462
  bool HasInterestingComment(LCodeGen* gen) const override { return false; }
danno@chromium.org's avatar
danno@chromium.org committed
463 464 465 466
  DECLARE_CONCRETE_INSTRUCTION(Parameter, "parameter")
};


467
class LUnknownOSRValue final : public LTemplateInstruction<1, 0, 0> {
danno@chromium.org's avatar
danno@chromium.org committed
468
 public:
469
  bool HasInterestingComment(LCodeGen* gen) const override { return false; }
danno@chromium.org's avatar
danno@chromium.org committed
470 471 472 473 474 475 476 477 478
  DECLARE_CONCRETE_INSTRUCTION(UnknownOSRValue, "unknown-osr-value")
};


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

479
  bool IsControl() const final { return true; }
danno@chromium.org's avatar
danno@chromium.org committed
480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517

  int SuccessorCount() { return hydrogen()->SuccessorCount(); }
  HBasicBlock* SuccessorAt(int i) { return hydrogen()->SuccessorAt(i); }

  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(); }

 private:
  HControlInstruction* hydrogen() {
    return HControlInstruction::cast(this->hydrogen_value());
  }

  Label* false_label_;
  Label* true_label_;
};


518
class LWrapReceiver final : public LTemplateInstruction<1, 2, 1> {
danno@chromium.org's avatar
danno@chromium.org committed
519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536
 public:
  LWrapReceiver(LOperand* receiver,
                LOperand* function,
                LOperand* temp) {
    inputs_[0] = receiver;
    inputs_[1] = function;
    temps_[0] = temp;
  }

  LOperand* receiver() { return inputs_[0]; }
  LOperand* function() { return inputs_[1]; }
  LOperand* temp() { return temps_[0]; }

  DECLARE_CONCRETE_INSTRUCTION(WrapReceiver, "wrap-receiver")
  DECLARE_HYDROGEN_ACCESSOR(WrapReceiver)
};


537
class LApplyArguments final : public LTemplateInstruction<1, 4, 0> {
danno@chromium.org's avatar
danno@chromium.org committed
538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554
 public:
  LApplyArguments(LOperand* function,
                  LOperand* receiver,
                  LOperand* length,
                  LOperand* elements) {
    inputs_[0] = function;
    inputs_[1] = receiver;
    inputs_[2] = length;
    inputs_[3] = elements;
  }

  LOperand* function() { return inputs_[0]; }
  LOperand* receiver() { return inputs_[1]; }
  LOperand* length() { return inputs_[2]; }
  LOperand* elements() { return inputs_[3]; }

  DECLARE_CONCRETE_INSTRUCTION(ApplyArguments, "apply-arguments")
555
  DECLARE_HYDROGEN_ACCESSOR(ApplyArguments)
danno@chromium.org's avatar
danno@chromium.org committed
556 557 558
};


559
class LAccessArgumentsAt final : public LTemplateInstruction<1, 3, 0> {
danno@chromium.org's avatar
danno@chromium.org committed
560 561 562 563 564 565 566 567 568 569 570 571 572
 public:
  LAccessArgumentsAt(LOperand* arguments, LOperand* length, LOperand* index) {
    inputs_[0] = arguments;
    inputs_[1] = length;
    inputs_[2] = index;
  }

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

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

573
  void PrintDataTo(StringStream* stream) override;
danno@chromium.org's avatar
danno@chromium.org committed
574 575 576
};


577
class LArgumentsLength final : public LTemplateInstruction<1, 1, 0> {
danno@chromium.org's avatar
danno@chromium.org committed
578 579 580 581 582 583 584 585 586 587 588
 public:
  explicit LArgumentsLength(LOperand* elements) {
    inputs_[0] = elements;
  }

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

  DECLARE_CONCRETE_INSTRUCTION(ArgumentsLength, "arguments-length")
};


589
class LArgumentsElements final : public LTemplateInstruction<1, 0, 0> {
danno@chromium.org's avatar
danno@chromium.org committed
590 591 592 593 594 595
 public:
  DECLARE_CONCRETE_INSTRUCTION(ArgumentsElements, "arguments-elements")
  DECLARE_HYDROGEN_ACCESSOR(ArgumentsElements)
};


596
class LDebugBreak final : public LTemplateInstruction<0, 0, 0> {
danno@chromium.org's avatar
danno@chromium.org committed
597 598 599 600 601
 public:
  DECLARE_CONCRETE_INSTRUCTION(DebugBreak, "break")
};


602
class LModByPowerOf2I final : public LTemplateInstruction<1, 1, 0> {
danno@chromium.org's avatar
danno@chromium.org committed
603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619
 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_;
};


620
class LModByConstI final : public LTemplateInstruction<1, 1, 2> {
danno@chromium.org's avatar
danno@chromium.org committed
621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644
 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_;
};


645
class LModI final : public LTemplateInstruction<1, 2, 1> {
danno@chromium.org's avatar
danno@chromium.org committed
646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661
 public:
  LModI(LOperand* left, LOperand* right, LOperand* temp) {
    inputs_[0] = left;
    inputs_[1] = right;
    temps_[0] = temp;
  }

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

  DECLARE_CONCRETE_INSTRUCTION(ModI, "mod-i")
  DECLARE_HYDROGEN_ACCESSOR(Mod)
};


662
class LDivByPowerOf2I final : public LTemplateInstruction<1, 1, 0> {
danno@chromium.org's avatar
danno@chromium.org committed
663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679
 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_;
};


680
class LDivByConstI final : public LTemplateInstruction<1, 1, 2> {
danno@chromium.org's avatar
danno@chromium.org committed
681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704
 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_;
};


705
class LDivI final : public LTemplateInstruction<1, 2, 1> {
danno@chromium.org's avatar
danno@chromium.org committed
706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721
 public:
  LDivI(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(DivI, "div-i")
  DECLARE_HYDROGEN_ACCESSOR(BinaryOperation)
};


722
class LFlooringDivByPowerOf2I final : public LTemplateInstruction<1, 1, 0> {
danno@chromium.org's avatar
danno@chromium.org committed
723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740
 public:
  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_;
};


741
class LFlooringDivByConstI final : public LTemplateInstruction<1, 1, 3> {
danno@chromium.org's avatar
danno@chromium.org committed
742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768
 public:
  LFlooringDivByConstI(LOperand* dividend,
                       int32_t divisor,
                       LOperand* temp1,
                       LOperand* temp2,
                       LOperand* temp3) {
    inputs_[0] = dividend;
    divisor_ = divisor;
    temps_[0] = temp1;
    temps_[1] = temp2;
    temps_[2] = temp3;
  }

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

  DECLARE_CONCRETE_INSTRUCTION(FlooringDivByConstI, "flooring-div-by-const-i")
  DECLARE_HYDROGEN_ACCESSOR(MathFloorOfDiv)

 private:
  int32_t divisor_;
};


769
class LFlooringDivI final : public LTemplateInstruction<1, 2, 1> {
danno@chromium.org's avatar
danno@chromium.org committed
770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785
 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)
};


786
class LMulI final : public LTemplateInstruction<1, 2, 1> {
danno@chromium.org's avatar
danno@chromium.org committed
787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802
 public:
  LMulI(LOperand* left, LOperand* right, LOperand* temp) {
    inputs_[0] = left;
    inputs_[1] = right;
    temps_[0] = temp;
  }

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

  DECLARE_CONCRETE_INSTRUCTION(MulI, "mul-i")
  DECLARE_HYDROGEN_ACCESSOR(Mul)
};


803
class LCompareNumericAndBranch final : public LControlInstruction<2, 0> {
danno@chromium.org's avatar
danno@chromium.org committed
804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821
 public:
  LCompareNumericAndBranch(LOperand* left, LOperand* right) {
    inputs_[0] = left;
    inputs_[1] = right;
  }

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

  DECLARE_CONCRETE_INSTRUCTION(CompareNumericAndBranch,
                               "compare-numeric-and-branch")
  DECLARE_HYDROGEN_ACCESSOR(CompareNumericAndBranch)

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

822
  void PrintDataTo(StringStream* stream) override;
danno@chromium.org's avatar
danno@chromium.org committed
823 824 825
};


826
class LMathFloor final : public LTemplateInstruction<1, 1, 0> {
danno@chromium.org's avatar
danno@chromium.org committed
827 828 829 830 831 832 833 834 835 836 837 838
 public:
  explicit LMathFloor(LOperand* value) {
    inputs_[0] = value;
  }

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

  DECLARE_CONCRETE_INSTRUCTION(MathFloor, "math-floor")
  DECLARE_HYDROGEN_ACCESSOR(UnaryMathOperation)
};


839
class LMathRound final : public LTemplateInstruction<1, 1, 0> {
danno@chromium.org's avatar
danno@chromium.org committed
840 841 842 843 844 845 846 847 848 849 850 851
 public:
  explicit LMathRound(LOperand* value) {
    inputs_[0] = value;
  }

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

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


852
class LMathFround final : public LTemplateInstruction<1, 1, 0> {
853 854 855 856 857 858 859 860 861
 public:
  explicit LMathFround(LOperand* value) { inputs_[0] = value; }

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

  DECLARE_CONCRETE_INSTRUCTION(MathFround, "math-fround")
};


862
class LMathAbs final : public LTemplateInstruction<1, 2, 0> {
danno@chromium.org's avatar
danno@chromium.org committed
863 864 865 866 867 868 869 870 871 872 873 874 875 876
 public:
  LMathAbs(LOperand* context, LOperand* value) {
    inputs_[1] = context;
    inputs_[0] = value;
  }

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

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


877
class LMathLog final : public LTemplateInstruction<1, 1, 0> {
danno@chromium.org's avatar
danno@chromium.org committed
878 879 880 881 882 883 884 885 886 887 888
 public:
  explicit LMathLog(LOperand* value) {
    inputs_[0] = value;
  }

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

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


889
class LMathClz32 final : public LTemplateInstruction<1, 1, 0> {
danno@chromium.org's avatar
danno@chromium.org committed
890 891 892 893 894 895 896 897 898 899
 public:
  explicit LMathClz32(LOperand* value) {
    inputs_[0] = value;
  }

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

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

900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917
class LMathCos final : public LTemplateInstruction<1, 1, 0> {
 public:
  explicit LMathCos(LOperand* value) { inputs_[0] = value; }

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

  DECLARE_CONCRETE_INSTRUCTION(MathCos, "math-cos")
};

class LMathSin final : public LTemplateInstruction<1, 1, 0> {
 public:
  explicit LMathSin(LOperand* value) { inputs_[0] = value; }

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

  DECLARE_CONCRETE_INSTRUCTION(MathSin, "math-sin")
};

918
class LMathExp final : public LTemplateInstruction<1, 1, 0> {
danno@chromium.org's avatar
danno@chromium.org committed
919
 public:
920
  explicit LMathExp(LOperand* value) { inputs_[0] = value; }
danno@chromium.org's avatar
danno@chromium.org committed
921 922 923 924 925 926 927

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

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


928
class LMathSqrt final : public LTemplateInstruction<1, 1, 2> {
danno@chromium.org's avatar
danno@chromium.org committed
929
 public:
930 931 932
  explicit LMathSqrt(LOperand* value,
                     LOperand* temp1,
                     LOperand* temp2) {
danno@chromium.org's avatar
danno@chromium.org committed
933
    inputs_[0] = value;
934 935
    temps_[0] = temp1;
    temps_[1] = temp2;
danno@chromium.org's avatar
danno@chromium.org committed
936 937 938
  }

  LOperand* value() { return inputs_[0]; }
939 940
  LOperand* temp1() { return temps_[0]; }
  LOperand* temp2() { return temps_[1]; }
danno@chromium.org's avatar
danno@chromium.org committed
941 942 943 944 945

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


946
class LMathPowHalf final : public LTemplateInstruction<1, 1, 0> {
danno@chromium.org's avatar
danno@chromium.org committed
947
 public:
948
  explicit LMathPowHalf(LOperand* value) { inputs_[0] = value; }
danno@chromium.org's avatar
danno@chromium.org committed
949 950 951 952 953 954 955

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

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


956
class LCmpObjectEqAndBranch final : public LControlInstruction<2, 0> {
danno@chromium.org's avatar
danno@chromium.org committed
957 958 959 960 961 962 963 964 965 966 967 968 969
 public:
  LCmpObjectEqAndBranch(LOperand* left, LOperand* right) {
    inputs_[0] = left;
    inputs_[1] = right;
  }

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

  DECLARE_CONCRETE_INSTRUCTION(CmpObjectEqAndBranch, "cmp-object-eq-and-branch")
};


970
class LCmpHoleAndBranch final : public LControlInstruction<1, 0> {
danno@chromium.org's avatar
danno@chromium.org committed
971 972 973 974 975 976 977 978 979 980 981 982
 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)
};


983
class LIsStringAndBranch final : public LControlInstruction<1, 1> {
danno@chromium.org's avatar
danno@chromium.org committed
984 985 986 987 988 989 990 991 992 993 994 995
 public:
  LIsStringAndBranch(LOperand* value, LOperand* temp) {
    inputs_[0] = value;
    temps_[0] = temp;
  }

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

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

996
  void PrintDataTo(StringStream* stream) override;
danno@chromium.org's avatar
danno@chromium.org committed
997 998 999
};


1000
class LIsSmiAndBranch final : public LControlInstruction<1, 0> {
danno@chromium.org's avatar
danno@chromium.org committed
1001 1002 1003 1004 1005 1006 1007 1008 1009 1010
 public:
  explicit LIsSmiAndBranch(LOperand* value) {
    inputs_[0] = value;
  }

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

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

1011
  void PrintDataTo(StringStream* stream) override;
danno@chromium.org's avatar
danno@chromium.org committed
1012 1013 1014
};


1015
class LIsUndetectableAndBranch final : public LControlInstruction<1, 1> {
danno@chromium.org's avatar
danno@chromium.org committed
1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028
 public:
  LIsUndetectableAndBranch(LOperand* value, LOperand* temp) {
    inputs_[0] = value;
    temps_[0] = temp;
  }

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

  DECLARE_CONCRETE_INSTRUCTION(IsUndetectableAndBranch,
                               "is-undetectable-and-branch")
  DECLARE_HYDROGEN_ACCESSOR(IsUndetectableAndBranch)

1029
  void PrintDataTo(StringStream* stream) override;
danno@chromium.org's avatar
danno@chromium.org committed
1030 1031 1032
};


1033
class LStringCompareAndBranch final : public LControlInstruction<3, 0> {
danno@chromium.org's avatar
danno@chromium.org committed
1034 1035 1036 1037 1038 1039 1040
 public:
  LStringCompareAndBranch(LOperand* context, LOperand* left, LOperand* right) {
    inputs_[0] = context;
    inputs_[1] = left;
    inputs_[2] = right;
  }

1041
  LOperand* context() { return inputs_[0]; }
danno@chromium.org's avatar
danno@chromium.org committed
1042 1043 1044 1045 1046 1047 1048
  LOperand* left() { return inputs_[1]; }
  LOperand* right() { return inputs_[2]; }

  DECLARE_CONCRETE_INSTRUCTION(StringCompareAndBranch,
                               "string-compare-and-branch")
  DECLARE_HYDROGEN_ACCESSOR(StringCompareAndBranch)

1049
  void PrintDataTo(StringStream* stream) override;
danno@chromium.org's avatar
danno@chromium.org committed
1050 1051 1052 1053 1054

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


1055
class LHasInstanceTypeAndBranch final : public LControlInstruction<1, 1> {
danno@chromium.org's avatar
danno@chromium.org committed
1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068
 public:
  LHasInstanceTypeAndBranch(LOperand* value, LOperand* temp) {
    inputs_[0] = value;
    temps_[0] = temp;
  }

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

  DECLARE_CONCRETE_INSTRUCTION(HasInstanceTypeAndBranch,
                               "has-instance-type-and-branch")
  DECLARE_HYDROGEN_ACCESSOR(HasInstanceTypeAndBranch)

1069
  void PrintDataTo(StringStream* stream) override;
danno@chromium.org's avatar
danno@chromium.org committed
1070 1071
};

1072
class LClassOfTestAndBranch final : public LControlInstruction<1, 2> {
danno@chromium.org's avatar
danno@chromium.org committed
1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087
 public:
  LClassOfTestAndBranch(LOperand* value, LOperand* temp, LOperand* temp2) {
    inputs_[0] = value;
    temps_[0] = temp;
    temps_[1] = temp2;
  }

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

  DECLARE_CONCRETE_INSTRUCTION(ClassOfTestAndBranch,
                               "class-of-test-and-branch")
  DECLARE_HYDROGEN_ACCESSOR(ClassOfTestAndBranch)

1088
  void PrintDataTo(StringStream* stream) override;
danno@chromium.org's avatar
danno@chromium.org committed
1089 1090 1091
};


1092
class LCmpT final : public LTemplateInstruction<1, 3, 0> {
danno@chromium.org's avatar
danno@chromium.org committed
1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107
 public:
  LCmpT(LOperand* context, LOperand* left, LOperand* right) {
    inputs_[0] = context;
    inputs_[1] = left;
    inputs_[2] = right;
  }

  DECLARE_CONCRETE_INSTRUCTION(CmpT, "cmp-t")
  DECLARE_HYDROGEN_ACCESSOR(CompareGeneric)

  LOperand* context() { return inputs_[0]; }
  Token::Value op() const { return hydrogen()->token(); }
};


1108
class LHasInPrototypeChainAndBranch final : public LControlInstruction<2, 1> {
danno@chromium.org's avatar
danno@chromium.org committed
1109
 public:
1110 1111 1112 1113 1114
  LHasInPrototypeChainAndBranch(LOperand* object, LOperand* prototype,
                                LOperand* scratch) {
    inputs_[0] = object;
    inputs_[1] = prototype;
    temps_[0] = scratch;
danno@chromium.org's avatar
danno@chromium.org committed
1115 1116
  }

1117 1118 1119
  LOperand* object() const { return inputs_[0]; }
  LOperand* prototype() const { return inputs_[1]; }
  LOperand* scratch() const { return temps_[0]; }
danno@chromium.org's avatar
danno@chromium.org committed
1120

1121 1122 1123
  DECLARE_CONCRETE_INSTRUCTION(HasInPrototypeChainAndBranch,
                               "has-in-prototype-chain-and-branch")
  DECLARE_HYDROGEN_ACCESSOR(HasInPrototypeChainAndBranch)
danno@chromium.org's avatar
danno@chromium.org committed
1124 1125 1126
};


1127
class LBoundsCheck final : public LTemplateInstruction<0, 2, 0> {
danno@chromium.org's avatar
danno@chromium.org committed
1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141
 public:
  LBoundsCheck(LOperand* index, LOperand* length) {
    inputs_[0] = index;
    inputs_[1] = length;
  }

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

  DECLARE_CONCRETE_INSTRUCTION(BoundsCheck, "bounds-check")
  DECLARE_HYDROGEN_ACCESSOR(BoundsCheck)
};


1142
class LBitI final : public LTemplateInstruction<1, 2, 0> {
danno@chromium.org's avatar
danno@chromium.org committed
1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158
 public:
  LBitI(LOperand* left, LOperand* right) {
    inputs_[0] = left;
    inputs_[1] = right;
  }

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

  DECLARE_CONCRETE_INSTRUCTION(BitI, "bit-i")
  DECLARE_HYDROGEN_ACCESSOR(Bitwise)

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


1159
class LShiftI final : public LTemplateInstruction<1, 2, 0> {
danno@chromium.org's avatar
danno@chromium.org committed
1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180
 public:
  LShiftI(Token::Value op, LOperand* left, LOperand* right, bool can_deopt)
      : op_(op), can_deopt_(can_deopt) {
    inputs_[0] = left;
    inputs_[1] = right;
  }

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

  DECLARE_CONCRETE_INSTRUCTION(ShiftI, "shift-i")

  Token::Value op() const { return op_; }
  bool can_deopt() const { return can_deopt_; }

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


1181
class LSubI final : public LTemplateInstruction<1, 2, 0> {
danno@chromium.org's avatar
danno@chromium.org committed
1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195
 public:
  LSubI(LOperand* left, LOperand* right) {
    inputs_[0] = left;
    inputs_[1] = right;
  }

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

  DECLARE_CONCRETE_INSTRUCTION(SubI, "sub-i")
  DECLARE_HYDROGEN_ACCESSOR(Sub)
};


1196
class LConstantI final : public LTemplateInstruction<1, 0, 0> {
danno@chromium.org's avatar
danno@chromium.org committed
1197 1198 1199 1200 1201 1202 1203 1204
 public:
  DECLARE_CONCRETE_INSTRUCTION(ConstantI, "constant-i")
  DECLARE_HYDROGEN_ACCESSOR(Constant)

  int32_t value() const { return hydrogen()->Integer32Value(); }
};


1205
class LConstantS final : public LTemplateInstruction<1, 0, 0> {
danno@chromium.org's avatar
danno@chromium.org committed
1206 1207 1208 1209 1210 1211 1212 1213
 public:
  DECLARE_CONCRETE_INSTRUCTION(ConstantS, "constant-s")
  DECLARE_HYDROGEN_ACCESSOR(Constant)

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


1214
class LConstantD final : public LTemplateInstruction<1, 0, 1> {
danno@chromium.org's avatar
danno@chromium.org committed
1215 1216 1217 1218
 public:
  DECLARE_CONCRETE_INSTRUCTION(ConstantD, "constant-d")
  DECLARE_HYDROGEN_ACCESSOR(Constant)

1219
  uint64_t bits() const { return hydrogen()->DoubleValueAsBits(); }
danno@chromium.org's avatar
danno@chromium.org committed
1220 1221 1222
};


1223
class LConstantE final : public LTemplateInstruction<1, 0, 0> {
danno@chromium.org's avatar
danno@chromium.org committed
1224 1225 1226 1227 1228 1229 1230 1231 1232 1233
 public:
  DECLARE_CONCRETE_INSTRUCTION(ConstantE, "constant-e")
  DECLARE_HYDROGEN_ACCESSOR(Constant)

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


1234
class LConstantT final : public LTemplateInstruction<1, 0, 0> {
danno@chromium.org's avatar
danno@chromium.org committed
1235 1236 1237 1238 1239 1240 1241 1242 1243 1244
 public:
  DECLARE_CONCRETE_INSTRUCTION(ConstantT, "constant-t")
  DECLARE_HYDROGEN_ACCESSOR(Constant)

  Handle<Object> value(Isolate* isolate) const {
    return hydrogen()->handle(isolate);
  }
};


1245
class LBranch final : public LControlInstruction<1, 1> {
danno@chromium.org's avatar
danno@chromium.org committed
1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257
 public:
  LBranch(LOperand* value, LOperand* temp) {
    inputs_[0] = value;
    temps_[0] = temp;
  }

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

  DECLARE_CONCRETE_INSTRUCTION(Branch, "branch")
  DECLARE_HYDROGEN_ACCESSOR(Branch)

1258
  void PrintDataTo(StringStream* stream) override;
danno@chromium.org's avatar
danno@chromium.org committed
1259 1260 1261
};


1262
class LCmpMapAndBranch final : public LControlInstruction<1, 0> {
danno@chromium.org's avatar
danno@chromium.org committed
1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276
 public:
  explicit LCmpMapAndBranch(LOperand* value) {
    inputs_[0] = value;
  }

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

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

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


1277
class LSeqStringGetChar final : public LTemplateInstruction<1, 2, 0> {
danno@chromium.org's avatar
danno@chromium.org committed
1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291
 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)
};


1292
class LSeqStringSetChar final : public LTemplateInstruction<1, 4, 0> {
danno@chromium.org's avatar
danno@chromium.org committed
1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312
 public:
  LSeqStringSetChar(LOperand* context,
                    LOperand* string,
                    LOperand* index,
                    LOperand* value) {
    inputs_[0] = context;
    inputs_[1] = string;
    inputs_[2] = index;
    inputs_[3] = value;
  }

  LOperand* string() { return inputs_[1]; }
  LOperand* index() { return inputs_[2]; }
  LOperand* value() { return inputs_[3]; }

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


1313
class LAddI final : public LTemplateInstruction<1, 2, 0> {
danno@chromium.org's avatar
danno@chromium.org committed
1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332
 public:
  LAddI(LOperand* left, LOperand* right) {
    inputs_[0] = left;
    inputs_[1] = right;
  }

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

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

  DECLARE_CONCRETE_INSTRUCTION(AddI, "add-i")
  DECLARE_HYDROGEN_ACCESSOR(Add)
};


1333
class LMathMinMax final : public LTemplateInstruction<1, 2, 1> {
danno@chromium.org's avatar
danno@chromium.org committed
1334
 public:
1335
  LMathMinMax(LOperand* left, LOperand* right, LOperand* temp) {
danno@chromium.org's avatar
danno@chromium.org committed
1336 1337
    inputs_[0] = left;
    inputs_[1] = right;
1338
    temps_[0] = temp;
danno@chromium.org's avatar
danno@chromium.org committed
1339 1340 1341 1342
  }

  LOperand* left() { return inputs_[0]; }
  LOperand* right() { return inputs_[1]; }
1343
  LOperand* temp() { return temps_[0]; }
danno@chromium.org's avatar
danno@chromium.org committed
1344 1345 1346 1347 1348 1349

  DECLARE_CONCRETE_INSTRUCTION(MathMinMax, "math-min-max")
  DECLARE_HYDROGEN_ACCESSOR(MathMinMax)
};


1350
class LPower final : public LTemplateInstruction<1, 2, 0> {
danno@chromium.org's avatar
danno@chromium.org committed
1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364
 public:
  LPower(LOperand* left, LOperand* right) {
    inputs_[0] = left;
    inputs_[1] = right;
  }

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

  DECLARE_CONCRETE_INSTRUCTION(Power, "power")
  DECLARE_HYDROGEN_ACCESSOR(Power)
};


1365
class LArithmeticD final : public LTemplateInstruction<1, 2, 0> {
danno@chromium.org's avatar
danno@chromium.org committed
1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377
 public:
  LArithmeticD(Token::Value op, LOperand* left, LOperand* right)
      : op_(op) {
    inputs_[0] = left;
    inputs_[1] = right;
  }

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

  Token::Value op() const { return op_; }

1378 1379 1380
  Opcode opcode() const override { return LInstruction::kArithmeticD; }
  void CompileToNative(LCodeGen* generator) override;
  const char* Mnemonic() const override;
danno@chromium.org's avatar
danno@chromium.org committed
1381 1382 1383 1384 1385 1386

 private:
  Token::Value op_;
};


1387
class LArithmeticT final : public LTemplateInstruction<1, 3, 0> {
danno@chromium.org's avatar
danno@chromium.org committed
1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401
 public:
  LArithmeticT(Token::Value op,
               LOperand* context,
               LOperand* left,
               LOperand* right)
      : op_(op) {
    inputs_[0] = context;
    inputs_[1] = left;
    inputs_[2] = right;
  }

  LOperand* context() { return inputs_[0]; }
  LOperand* left() { return inputs_[1]; }
  LOperand* right() { return inputs_[2]; }
conradw's avatar
conradw committed
1402
  Token::Value op() const { return op_; }
danno@chromium.org's avatar
danno@chromium.org committed
1403

1404 1405 1406
  Opcode opcode() const override { return LInstruction::kArithmeticT; }
  void CompileToNative(LCodeGen* generator) override;
  const char* Mnemonic() const override;
danno@chromium.org's avatar
danno@chromium.org committed
1407

conradw's avatar
conradw committed
1408 1409
  DECLARE_HYDROGEN_ACCESSOR(BinaryOperation)

danno@chromium.org's avatar
danno@chromium.org committed
1410 1411 1412 1413 1414
 private:
  Token::Value op_;
};


1415
class LReturn final : public LTemplateInstruction<0, 3, 0> {
danno@chromium.org's avatar
danno@chromium.org committed
1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428
 public:
  explicit LReturn(LOperand* value,
                   LOperand* context,
                   LOperand* parameter_count) {
    inputs_[0] = value;
    inputs_[1] = context;
    inputs_[2] = parameter_count;
  }

  bool has_constant_parameter_count() {
    return parameter_count()->IsConstantOperand();
  }
  LConstantOperand* constant_parameter_count() {
1429
    DCHECK(has_constant_parameter_count());
danno@chromium.org's avatar
danno@chromium.org committed
1430 1431 1432 1433 1434 1435 1436 1437 1438
    return LConstantOperand::cast(parameter_count());
  }
  LOperand* parameter_count() { return inputs_[2]; }

  DECLARE_CONCRETE_INSTRUCTION(Return, "return")
  DECLARE_HYDROGEN_ACCESSOR(Return)
};


1439
class LLoadNamedField final : public LTemplateInstruction<1, 1, 0> {
danno@chromium.org's avatar
danno@chromium.org committed
1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451
 public:
  explicit LLoadNamedField(LOperand* object) {
    inputs_[0] = object;
  }

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

  DECLARE_CONCRETE_INSTRUCTION(LoadNamedField, "load-named-field")
  DECLARE_HYDROGEN_ACCESSOR(LoadNamedField)
};


1452
class LLoadFunctionPrototype final : public LTemplateInstruction<1, 1, 1> {
danno@chromium.org's avatar
danno@chromium.org committed
1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466
 public:
  LLoadFunctionPrototype(LOperand* function, LOperand* temp) {
    inputs_[0] = function;
    temps_[0] = temp;
  }

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

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


1467
class LLoadRoot final : public LTemplateInstruction<1, 0, 0> {
danno@chromium.org's avatar
danno@chromium.org committed
1468 1469 1470 1471 1472 1473 1474 1475
 public:
  DECLARE_CONCRETE_INSTRUCTION(LoadRoot, "load-root")
  DECLARE_HYDROGEN_ACCESSOR(LoadRoot)

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


1476
class LLoadKeyed final : public LTemplateInstruction<1, 3, 0> {
danno@chromium.org's avatar
danno@chromium.org committed
1477
 public:
1478
  LLoadKeyed(LOperand* elements, LOperand* key, LOperand* backing_store_owner) {
danno@chromium.org's avatar
danno@chromium.org committed
1479 1480
    inputs_[0] = elements;
    inputs_[1] = key;
1481
    inputs_[2] = backing_store_owner;
danno@chromium.org's avatar
danno@chromium.org committed
1482 1483 1484
  }
  LOperand* elements() { return inputs_[0]; }
  LOperand* key() { return inputs_[1]; }
1485
  LOperand* backing_store_owner() { return inputs_[2]; }
danno@chromium.org's avatar
danno@chromium.org committed
1486 1487 1488 1489 1490 1491 1492 1493 1494 1495
  ElementsKind elements_kind() const {
    return hydrogen()->elements_kind();
  }
  bool is_fixed_typed_array() const {
    return hydrogen()->is_fixed_typed_array();
  }

  DECLARE_CONCRETE_INSTRUCTION(LoadKeyed, "load-keyed")
  DECLARE_HYDROGEN_ACCESSOR(LoadKeyed)

1496
  void PrintDataTo(StringStream* stream) override;
danno@chromium.org's avatar
danno@chromium.org committed
1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510
  uint32_t base_offset() const { return hydrogen()->base_offset(); }
  bool key_is_smi() {
    return hydrogen()->key()->representation().IsTagged();
  }
};


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 key_representation.IsSmi() &&
1511 1512
         (elements_kind == UINT8_ELEMENTS || elements_kind == INT8_ELEMENTS ||
          elements_kind == UINT8_CLAMPED_ELEMENTS);
danno@chromium.org's avatar
danno@chromium.org committed
1513 1514 1515
}


1516
class LLoadContextSlot final : public LTemplateInstruction<1, 1, 0> {
danno@chromium.org's avatar
danno@chromium.org committed
1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528
 public:
  explicit LLoadContextSlot(LOperand* context) {
    inputs_[0] = context;
  }

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

  DECLARE_CONCRETE_INSTRUCTION(LoadContextSlot, "load-context-slot")
  DECLARE_HYDROGEN_ACCESSOR(LoadContextSlot)

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

1529
  void PrintDataTo(StringStream* stream) override;
danno@chromium.org's avatar
danno@chromium.org committed
1530 1531 1532
};


1533
class LStoreContextSlot final : public LTemplateInstruction<0, 2, 1> {
danno@chromium.org's avatar
danno@chromium.org committed
1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549
 public:
  LStoreContextSlot(LOperand* context, LOperand* value, LOperand* temp) {
    inputs_[0] = context;
    inputs_[1] = value;
    temps_[0] = temp;
  }

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

  DECLARE_CONCRETE_INSTRUCTION(StoreContextSlot, "store-context-slot")
  DECLARE_HYDROGEN_ACCESSOR(StoreContextSlot)

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

1550
  void PrintDataTo(StringStream* stream) override;
danno@chromium.org's avatar
danno@chromium.org committed
1551 1552 1553
};


1554
class LPushArgument final : public LTemplateInstruction<0, 1, 0> {
danno@chromium.org's avatar
danno@chromium.org committed
1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565
 public:
  explicit LPushArgument(LOperand* value) {
    inputs_[0] = value;
  }

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

  DECLARE_CONCRETE_INSTRUCTION(PushArgument, "push-argument")
};


1566
class LDrop final : public LTemplateInstruction<0, 0, 0> {
danno@chromium.org's avatar
danno@chromium.org committed
1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578
 public:
  explicit LDrop(int count) : count_(count) { }

  int count() const { return count_; }

  DECLARE_CONCRETE_INSTRUCTION(Drop, "drop")

 private:
  int count_;
};


1579
class LStoreCodeEntry final : public LTemplateInstruction<0, 2, 0> {
danno@chromium.org's avatar
danno@chromium.org committed
1580 1581 1582
 public:
  LStoreCodeEntry(LOperand* function, LOperand* code_object) {
    inputs_[0] = function;
1583
    inputs_[1] = code_object;
danno@chromium.org's avatar
danno@chromium.org committed
1584 1585 1586
  }

  LOperand* function() { return inputs_[0]; }
1587
  LOperand* code_object() { return inputs_[1]; }
danno@chromium.org's avatar
danno@chromium.org committed
1588

1589
  void PrintDataTo(StringStream* stream) override;
danno@chromium.org's avatar
danno@chromium.org committed
1590 1591 1592 1593 1594 1595

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


1596
class LInnerAllocatedObject final : public LTemplateInstruction<1, 2, 0> {
danno@chromium.org's avatar
danno@chromium.org committed
1597 1598 1599 1600 1601 1602 1603 1604 1605
 public:
  LInnerAllocatedObject(LOperand* base_object, LOperand* offset) {
    inputs_[0] = base_object;
    inputs_[1] = offset;
  }

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

1606
  void PrintDataTo(StringStream* stream) override;
danno@chromium.org's avatar
danno@chromium.org committed
1607 1608 1609 1610 1611

  DECLARE_CONCRETE_INSTRUCTION(InnerAllocatedObject, "inner-allocated-object")
};


1612
class LThisFunction final : public LTemplateInstruction<1, 0, 0> {
danno@chromium.org's avatar
danno@chromium.org committed
1613 1614 1615 1616 1617 1618
 public:
  DECLARE_CONCRETE_INSTRUCTION(ThisFunction, "this-function")
  DECLARE_HYDROGEN_ACCESSOR(ThisFunction)
};


1619
class LContext final : public LTemplateInstruction<1, 0, 0> {
danno@chromium.org's avatar
danno@chromium.org committed
1620 1621 1622 1623 1624 1625
 public:
  DECLARE_CONCRETE_INSTRUCTION(Context, "context")
  DECLARE_HYDROGEN_ACCESSOR(Context)
};


1626
class LDeclareGlobals final : public LTemplateInstruction<0, 1, 0> {
danno@chromium.org's avatar
danno@chromium.org committed
1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638
 public:
  explicit LDeclareGlobals(LOperand* context) {
    inputs_[0] = context;
  }

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

  DECLARE_CONCRETE_INSTRUCTION(DeclareGlobals, "declare-globals")
  DECLARE_HYDROGEN_ACCESSOR(DeclareGlobals)
};


1639
class LCallWithDescriptor final : public LTemplateResultInstruction<1> {
danno@chromium.org's avatar
danno@chromium.org committed
1640
 public:
1641
  LCallWithDescriptor(CallInterfaceDescriptor descriptor,
1642
                      const ZoneList<LOperand*>& operands, Zone* zone)
1643 1644 1645 1646 1647 1648
      : inputs_(descriptor.GetRegisterParameterCount() +
                    kImplicitRegisterParameterCount,
                zone) {
    DCHECK(descriptor.GetRegisterParameterCount() +
               kImplicitRegisterParameterCount ==
           operands.length());
danno@chromium.org's avatar
danno@chromium.org committed
1649 1650 1651 1652 1653
    inputs_.AddAll(operands, zone);
  }

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

1654 1655
  DECLARE_HYDROGEN_ACCESSOR(CallWithDescriptor)

1656 1657 1658 1659
  // The target and context are passed as implicit parameters that are not
  // explicitly listed in the descriptor.
  static const int kImplicitRegisterParameterCount = 2;

danno@chromium.org's avatar
danno@chromium.org committed
1660 1661 1662
 private:
  DECLARE_CONCRETE_INSTRUCTION(CallWithDescriptor, "call-with-descriptor")

1663
  void PrintDataTo(StringStream* stream) override;
danno@chromium.org's avatar
danno@chromium.org committed
1664 1665 1666 1667 1668 1669

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

  ZoneList<LOperand*> inputs_;

  // Iterator support.
1670 1671
  int InputCount() final { return inputs_.length(); }
  LOperand* InputAt(int i) final { return inputs_[i]; }
danno@chromium.org's avatar
danno@chromium.org committed
1672

1673 1674
  int TempCount() final { return 0; }
  LOperand* TempAt(int i) final { return NULL; }
danno@chromium.org's avatar
danno@chromium.org committed
1675 1676 1677
};


1678
class LInvokeFunction final : public LTemplateInstruction<1, 2, 0> {
danno@chromium.org's avatar
danno@chromium.org committed
1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690
 public:
  LInvokeFunction(LOperand* context, LOperand* function) {
    inputs_[0] = context;
    inputs_[1] = function;
  }

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

  DECLARE_CONCRETE_INSTRUCTION(InvokeFunction, "invoke-function")
  DECLARE_HYDROGEN_ACCESSOR(InvokeFunction)

1691
  void PrintDataTo(StringStream* stream) override;
danno@chromium.org's avatar
danno@chromium.org committed
1692 1693 1694 1695 1696

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


1697
class LCallNewArray final : public LTemplateInstruction<1, 2, 0> {
danno@chromium.org's avatar
danno@chromium.org committed
1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709
 public:
  LCallNewArray(LOperand* context, LOperand* constructor) {
    inputs_[0] = context;
    inputs_[1] = constructor;
  }

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

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

1710
  void PrintDataTo(StringStream* stream) override;
danno@chromium.org's avatar
danno@chromium.org committed
1711 1712 1713 1714 1715

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


1716
class LCallRuntime final : public LTemplateInstruction<1, 1, 0> {
danno@chromium.org's avatar
danno@chromium.org committed
1717 1718 1719 1720 1721 1722 1723 1724 1725 1726
 public:
  explicit LCallRuntime(LOperand* context) {
    inputs_[0] = context;
  }

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

  DECLARE_CONCRETE_INSTRUCTION(CallRuntime, "call-runtime")
  DECLARE_HYDROGEN_ACCESSOR(CallRuntime)

1727
  bool ClobbersDoubleRegisters(Isolate* isolate) const override {
1728
    return save_doubles() == kDontSaveFPRegs;
danno@chromium.org's avatar
danno@chromium.org committed
1729 1730 1731 1732
  }

  const Runtime::Function* function() const { return hydrogen()->function(); }
  int arity() const { return hydrogen()->argument_count(); }
1733
  SaveFPRegsMode save_doubles() const { return hydrogen()->save_doubles(); }
danno@chromium.org's avatar
danno@chromium.org committed
1734 1735 1736
};


1737
class LInteger32ToDouble final : public LTemplateInstruction<1, 1, 0> {
danno@chromium.org's avatar
danno@chromium.org committed
1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748
 public:
  explicit LInteger32ToDouble(LOperand* value) {
    inputs_[0] = value;
  }

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

  DECLARE_CONCRETE_INSTRUCTION(Integer32ToDouble, "int32-to-double")
};


1749
class LUint32ToDouble final : public LTemplateInstruction<1, 1, 1> {
danno@chromium.org's avatar
danno@chromium.org committed
1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760
 public:
  explicit LUint32ToDouble(LOperand* value) {
    inputs_[0] = value;
  }

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

  DECLARE_CONCRETE_INSTRUCTION(Uint32ToDouble, "uint32-to-double")
};


1761
class LNumberTagI final : public LTemplateInstruction<1, 1, 1> {
danno@chromium.org's avatar
danno@chromium.org committed
1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774
 public:
  LNumberTagI(LOperand* value, LOperand* temp) {
    inputs_[0] = value;
    temps_[0] = temp;
  }

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

  DECLARE_CONCRETE_INSTRUCTION(NumberTagI, "number-tag-i")
};


1775
class LNumberTagU final : public LTemplateInstruction<1, 1, 1> {
danno@chromium.org's avatar
danno@chromium.org committed
1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788
 public:
  LNumberTagU(LOperand* value, LOperand* temp) {
    inputs_[0] = value;
    temps_[0] = temp;
  }

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

  DECLARE_CONCRETE_INSTRUCTION(NumberTagU, "number-tag-u")
};


1789
class LNumberTagD final : public LTemplateInstruction<1, 1, 1> {
danno@chromium.org's avatar
danno@chromium.org committed
1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804
 public:
  LNumberTagD(LOperand* value, LOperand* temp) {
    inputs_[0] = value;
    temps_[0] = temp;
  }

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

  DECLARE_CONCRETE_INSTRUCTION(NumberTagD, "number-tag-d")
  DECLARE_HYDROGEN_ACCESSOR(Change)
};


// Sometimes truncating conversion from a tagged value to an int32.
1805
class LDoubleToI final : public LTemplateInstruction<1, 1, 0> {
danno@chromium.org's avatar
danno@chromium.org committed
1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819
 public:
  explicit LDoubleToI(LOperand* value) {
    inputs_[0] = value;
  }

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

  DECLARE_CONCRETE_INSTRUCTION(DoubleToI, "double-to-i")
  DECLARE_HYDROGEN_ACCESSOR(UnaryOperation)

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


1820
class LDoubleToSmi final : public LTemplateInstruction<1, 1, 0> {
danno@chromium.org's avatar
danno@chromium.org committed
1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833
 public:
  explicit LDoubleToSmi(LOperand* value) {
    inputs_[0] = value;
  }

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

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


// Truncating conversion from a tagged value to an int32.
1834
class LTaggedToI final : public LTemplateInstruction<1, 1, 0> {
danno@chromium.org's avatar
danno@chromium.org committed
1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848
 public:
  explicit LTaggedToI(LOperand* value) {
    inputs_[0] = value;
  }

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

  DECLARE_CONCRETE_INSTRUCTION(TaggedToI, "tagged-to-i")
  DECLARE_HYDROGEN_ACCESSOR(Change)

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


1849
class LSmiTag final : public LTemplateInstruction<1, 1, 0> {
danno@chromium.org's avatar
danno@chromium.org committed
1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861
 public:
  explicit LSmiTag(LOperand* value) {
    inputs_[0] = value;
  }

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

  DECLARE_CONCRETE_INSTRUCTION(SmiTag, "smi-tag")
  DECLARE_HYDROGEN_ACCESSOR(Change)
};


1862
class LNumberUntagD final : public LTemplateInstruction<1, 1, 1> {
danno@chromium.org's avatar
danno@chromium.org committed
1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876
 public:
  explicit LNumberUntagD(LOperand* value, LOperand* temp) {
    inputs_[0] = value;
    temps_[0] = temp;
  }

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

  DECLARE_CONCRETE_INSTRUCTION(NumberUntagD, "double-untag")
  DECLARE_HYDROGEN_ACCESSOR(Change);
};


1877
class LSmiUntag final : public LTemplateInstruction<1, 1, 0> {
danno@chromium.org's avatar
danno@chromium.org committed
1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894
 public:
  LSmiUntag(LOperand* value, bool needs_check)
      : needs_check_(needs_check) {
    inputs_[0] = value;
  }

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

  DECLARE_CONCRETE_INSTRUCTION(SmiUntag, "smi-untag")

  bool needs_check() const { return needs_check_; }

 private:
  bool needs_check_;
};


1895
class LStoreNamedField final : public LTemplateInstruction<0, 2, 2> {
danno@chromium.org's avatar
danno@chromium.org committed
1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914
 public:
  LStoreNamedField(LOperand* obj,
                   LOperand* val,
                   LOperand* temp,
                   LOperand* temp_map) {
    inputs_[0] = obj;
    inputs_[1] = val;
    temps_[0] = temp;
    temps_[1] = temp_map;
  }

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

  DECLARE_CONCRETE_INSTRUCTION(StoreNamedField, "store-named-field")
  DECLARE_HYDROGEN_ACCESSOR(StoreNamedField)

1915
  void PrintDataTo(StringStream* stream) override;
danno@chromium.org's avatar
danno@chromium.org committed
1916 1917 1918
};


1919
class LStoreKeyed final : public LTemplateInstruction<0, 4, 0> {
danno@chromium.org's avatar
danno@chromium.org committed
1920
 public:
1921 1922
  LStoreKeyed(LOperand* obj, LOperand* key, LOperand* val,
              LOperand* backing_store_owner) {
danno@chromium.org's avatar
danno@chromium.org committed
1923 1924 1925
    inputs_[0] = obj;
    inputs_[1] = key;
    inputs_[2] = val;
1926
    inputs_[3] = backing_store_owner;
danno@chromium.org's avatar
danno@chromium.org committed
1927 1928 1929 1930 1931 1932 1933 1934
  }

  bool is_fixed_typed_array() const {
    return hydrogen()->is_fixed_typed_array();
  }
  LOperand* elements() { return inputs_[0]; }
  LOperand* key() { return inputs_[1]; }
  LOperand* value() { return inputs_[2]; }
1935
  LOperand* backing_store_owner() { return inputs_[3]; }
danno@chromium.org's avatar
danno@chromium.org committed
1936 1937 1938 1939 1940 1941 1942
  ElementsKind elements_kind() const {
    return hydrogen()->elements_kind();
  }

  DECLARE_CONCRETE_INSTRUCTION(StoreKeyed, "store-keyed")
  DECLARE_HYDROGEN_ACCESSOR(StoreKeyed)

1943
  void PrintDataTo(StringStream* stream) override;
danno@chromium.org's avatar
danno@chromium.org committed
1944 1945 1946 1947 1948
  uint32_t base_offset() const { return hydrogen()->base_offset(); }
  bool NeedsCanonicalization() { return hydrogen()->NeedsCanonicalization(); }
};


1949
class LTransitionElementsKind final : public LTemplateInstruction<0, 2, 2> {
danno@chromium.org's avatar
danno@chromium.org committed
1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969
 public:
  LTransitionElementsKind(LOperand* object,
                          LOperand* context,
                          LOperand* new_map_temp,
                          LOperand* temp) {
    inputs_[0] = object;
    inputs_[1] = context;
    temps_[0] = new_map_temp;
    temps_[1] = temp;
  }

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

  DECLARE_CONCRETE_INSTRUCTION(TransitionElementsKind,
                               "transition-elements-kind")
  DECLARE_HYDROGEN_ACCESSOR(TransitionElementsKind)

1970
  void PrintDataTo(StringStream* stream) override;
danno@chromium.org's avatar
danno@chromium.org committed
1971 1972 1973 1974 1975 1976 1977 1978 1979 1980

  Handle<Map> original_map() { return hydrogen()->original_map().handle(); }
  Handle<Map> transitioned_map() {
    return hydrogen()->transitioned_map().handle();
  }
  ElementsKind from_kind() { return hydrogen()->from_kind(); }
  ElementsKind to_kind() { return hydrogen()->to_kind(); }
};


1981
class LTrapAllocationMemento final : public LTemplateInstruction<0, 1, 1> {
danno@chromium.org's avatar
danno@chromium.org committed
1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996
 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")
};


1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013
class LMaybeGrowElements final : public LTemplateInstruction<1, 5, 0> {
 public:
  LMaybeGrowElements(LOperand* context, LOperand* object, LOperand* elements,
                     LOperand* key, LOperand* current_capacity) {
    inputs_[0] = context;
    inputs_[1] = object;
    inputs_[2] = elements;
    inputs_[3] = key;
    inputs_[4] = current_capacity;
  }

  LOperand* context() { return inputs_[0]; }
  LOperand* object() { return inputs_[1]; }
  LOperand* elements() { return inputs_[2]; }
  LOperand* key() { return inputs_[3]; }
  LOperand* current_capacity() { return inputs_[4]; }

2014 2015
  bool ClobbersDoubleRegisters(Isolate* isolate) const override { return true; }

2016 2017 2018 2019 2020
  DECLARE_HYDROGEN_ACCESSOR(MaybeGrowElements)
  DECLARE_CONCRETE_INSTRUCTION(MaybeGrowElements, "maybe-grow-elements")
};


2021
class LStringAdd final : public LTemplateInstruction<1, 3, 0> {
danno@chromium.org's avatar
danno@chromium.org committed
2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037
 public:
  LStringAdd(LOperand* context, LOperand* left, LOperand* right) {
    inputs_[0] = context;
    inputs_[1] = left;
    inputs_[2] = right;
  }

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

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


2038
class LStringCharCodeAt final : public LTemplateInstruction<1, 3, 0> {
danno@chromium.org's avatar
danno@chromium.org committed
2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054
 public:
  LStringCharCodeAt(LOperand* context, LOperand* string, LOperand* index) {
    inputs_[0] = context;
    inputs_[1] = string;
    inputs_[2] = index;
  }

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

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


2055
class LStringCharFromCode final : public LTemplateInstruction<1, 2, 0> {
danno@chromium.org's avatar
danno@chromium.org committed
2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069
 public:
  LStringCharFromCode(LOperand* context, LOperand* char_code) {
    inputs_[0] = context;
    inputs_[1] = char_code;
  }

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

  DECLARE_CONCRETE_INSTRUCTION(StringCharFromCode, "string-char-from-code")
  DECLARE_HYDROGEN_ACCESSOR(StringCharFromCode)
};


2070
class LCheckValue final : public LTemplateInstruction<0, 1, 0> {
danno@chromium.org's avatar
danno@chromium.org committed
2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082
 public:
  explicit LCheckValue(LOperand* value) {
    inputs_[0] = value;
  }

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

  DECLARE_CONCRETE_INSTRUCTION(CheckValue, "check-value")
  DECLARE_HYDROGEN_ACCESSOR(CheckValue)
};


2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099
class LCheckArrayBufferNotNeutered final
    : public LTemplateInstruction<0, 1, 1> {
 public:
  explicit LCheckArrayBufferNotNeutered(LOperand* view, LOperand* scratch) {
    inputs_[0] = view;
    temps_[0] = scratch;
  }

  LOperand* view() { return inputs_[0]; }
  LOperand* scratch() { return temps_[0]; }

  DECLARE_CONCRETE_INSTRUCTION(CheckArrayBufferNotNeutered,
                               "check-array-buffer-not-neutered")
  DECLARE_HYDROGEN_ACCESSOR(CheckArrayBufferNotNeutered)
};


2100
class LCheckInstanceType final : public LTemplateInstruction<0, 1, 1> {
danno@chromium.org's avatar
danno@chromium.org committed
2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114
 public:
  LCheckInstanceType(LOperand* value, LOperand* temp) {
    inputs_[0] = value;
    temps_[0] = temp;
  }

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

  DECLARE_CONCRETE_INSTRUCTION(CheckInstanceType, "check-instance-type")
  DECLARE_HYDROGEN_ACCESSOR(CheckInstanceType)
};


2115
class LCheckMaps final : public LTemplateInstruction<0, 1, 0> {
danno@chromium.org's avatar
danno@chromium.org committed
2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127
 public:
  explicit LCheckMaps(LOperand* value = NULL) {
    inputs_[0] = value;
  }

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

  DECLARE_CONCRETE_INSTRUCTION(CheckMaps, "check-maps")
  DECLARE_HYDROGEN_ACCESSOR(CheckMaps)
};


2128
class LCheckSmi final : public LTemplateInstruction<1, 1, 0> {
danno@chromium.org's avatar
danno@chromium.org committed
2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139
 public:
  explicit LCheckSmi(LOperand* value) {
    inputs_[0] = value;
  }

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

  DECLARE_CONCRETE_INSTRUCTION(CheckSmi, "check-smi")
};


2140
class LClampDToUint8 final : public LTemplateInstruction<1, 1, 0> {
danno@chromium.org's avatar
danno@chromium.org committed
2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151
 public:
  explicit LClampDToUint8(LOperand* value) {
    inputs_[0] = value;
  }

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

  DECLARE_CONCRETE_INSTRUCTION(ClampDToUint8, "clamp-d-to-uint8")
};


2152
class LClampIToUint8 final : public LTemplateInstruction<1, 1, 0> {
danno@chromium.org's avatar
danno@chromium.org committed
2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164
 public:
  explicit LClampIToUint8(LOperand* value) {
    inputs_[0] = value;
  }

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

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


// Truncating conversion from a tagged value to an int32.
2165
class LClampTToUint8NoSSE2 final : public LTemplateInstruction<1, 1, 3> {
danno@chromium.org's avatar
danno@chromium.org committed
2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187
 public:
  LClampTToUint8NoSSE2(LOperand* unclamped,
                       LOperand* temp1,
                       LOperand* temp2,
                       LOperand* temp3) {
    inputs_[0] = unclamped;
    temps_[0] = temp1;
    temps_[1] = temp2;
    temps_[2] = temp3;
  }

  LOperand* unclamped() { return inputs_[0]; }
  LOperand* scratch() { return temps_[0]; }
  LOperand* scratch2() { return temps_[1]; }
  LOperand* scratch3() { return temps_[2]; }

  DECLARE_CONCRETE_INSTRUCTION(ClampTToUint8NoSSE2,
                               "clamp-t-to-uint8-nosse2")
  DECLARE_HYDROGEN_ACCESSOR(UnaryOperation)
};


2188
class LCheckNonSmi final : public LTemplateInstruction<0, 1, 0> {
danno@chromium.org's avatar
danno@chromium.org committed
2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200
 public:
  explicit LCheckNonSmi(LOperand* value) {
    inputs_[0] = value;
  }

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

  DECLARE_CONCRETE_INSTRUCTION(CheckNonSmi, "check-non-smi")
  DECLARE_HYDROGEN_ACCESSOR(CheckHeapObject)
};


2201
class LAllocate final : public LTemplateInstruction<1, 2, 1> {
danno@chromium.org's avatar
danno@chromium.org committed
2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216
 public:
  LAllocate(LOperand* context, LOperand* size, LOperand* temp) {
    inputs_[0] = context;
    inputs_[1] = size;
    temps_[0] = temp;
  }

  LOperand* context() { return inputs_[0]; }
  LOperand* size() { return inputs_[1]; }
  LOperand* temp() { return temps_[0]; }

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

2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229
class LFastAllocate final : public LTemplateInstruction<1, 1, 1> {
 public:
  LFastAllocate(LOperand* size, LOperand* temp) {
    inputs_[0] = size;
    temps_[0] = temp;
  }

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

  DECLARE_CONCRETE_INSTRUCTION(FastAllocate, "fast-allocate")
  DECLARE_HYDROGEN_ACCESSOR(Allocate)
};
danno@chromium.org's avatar
danno@chromium.org committed
2230

2231
class LTypeof final : public LTemplateInstruction<1, 2, 0> {
danno@chromium.org's avatar
danno@chromium.org committed
2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244
 public:
  LTypeof(LOperand* context, LOperand* value) {
    inputs_[0] = context;
    inputs_[1] = value;
  }

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

  DECLARE_CONCRETE_INSTRUCTION(Typeof, "typeof")
};


2245
class LTypeofIsAndBranch final : public LControlInstruction<1, 0> {
danno@chromium.org's avatar
danno@chromium.org committed
2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257
 public:
  explicit LTypeofIsAndBranch(LOperand* value) {
    inputs_[0] = value;
  }

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

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

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

2258
  void PrintDataTo(StringStream* stream) override;
danno@chromium.org's avatar
danno@chromium.org committed
2259 2260 2261
};


2262
class LOsrEntry final : public LTemplateInstruction<0, 0, 0> {
danno@chromium.org's avatar
danno@chromium.org committed
2263
 public:
2264
  bool HasInterestingComment(LCodeGen* gen) const override { return false; }
danno@chromium.org's avatar
danno@chromium.org committed
2265 2266 2267 2268
  DECLARE_CONCRETE_INSTRUCTION(OsrEntry, "osr-entry")
};


2269
class LStackCheck final : public LTemplateInstruction<0, 1, 0> {
danno@chromium.org's avatar
danno@chromium.org committed
2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286
 public:
  explicit LStackCheck(LOperand* context) {
    inputs_[0] = context;
  }

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

  DECLARE_CONCRETE_INSTRUCTION(StackCheck, "stack-check")
  DECLARE_HYDROGEN_ACCESSOR(StackCheck)

  Label* done_label() { return &done_label_; }

 private:
  Label done_label_;
};


2287
class LForInPrepareMap final : public LTemplateInstruction<1, 2, 0> {
danno@chromium.org's avatar
danno@chromium.org committed
2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300
 public:
  LForInPrepareMap(LOperand* context, LOperand* object) {
    inputs_[0] = context;
    inputs_[1] = object;
  }

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

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


2301
class LForInCacheArray final : public LTemplateInstruction<1, 1, 0> {
danno@chromium.org's avatar
danno@chromium.org committed
2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316
 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();
  }
};


2317
class LCheckMapValue final : public LTemplateInstruction<0, 2, 0> {
danno@chromium.org's avatar
danno@chromium.org committed
2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330
 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")
};


2331
class LLoadFieldByIndex final : public LTemplateInstruction<1, 2, 0> {
danno@chromium.org's avatar
danno@chromium.org committed
2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345
 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")
};


class LChunkBuilder;
2346
class LPlatformChunk final : public LChunk {
danno@chromium.org's avatar
danno@chromium.org committed
2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361
 public:
  LPlatformChunk(CompilationInfo* info, HGraph* graph)
      : LChunk(info, graph),
        num_double_slots_(0) { }

  int GetNextSpillIndex(RegisterKind kind);
  LOperand* GetNextSpillSlot(RegisterKind kind);

  int num_double_slots() const { return num_double_slots_; }

 private:
  int num_double_slots_;
};


2362
class LChunkBuilder final : public LChunkBuilderBase {
danno@chromium.org's avatar
danno@chromium.org committed
2363 2364
 public:
  LChunkBuilder(CompilationInfo* info, HGraph* graph, LAllocator* allocator)
2365
      : LChunkBuilderBase(info, graph),
danno@chromium.org's avatar
danno@chromium.org committed
2366 2367 2368
        current_instruction_(NULL),
        current_block_(NULL),
        next_block_(NULL),
2369
        allocator_(allocator) {}
danno@chromium.org's avatar
danno@chromium.org committed
2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380

  // Build the sequence for the graph.
  LPlatformChunk* Build();

  // 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

  LInstruction* DoMathFloor(HUnaryMathOperation* instr);
  LInstruction* DoMathRound(HUnaryMathOperation* instr);
2381
  LInstruction* DoMathFround(HUnaryMathOperation* instr);
danno@chromium.org's avatar
danno@chromium.org committed
2382 2383
  LInstruction* DoMathAbs(HUnaryMathOperation* instr);
  LInstruction* DoMathLog(HUnaryMathOperation* instr);
2384 2385
  LInstruction* DoMathCos(HUnaryMathOperation* instr);
  LInstruction* DoMathSin(HUnaryMathOperation* instr);
danno@chromium.org's avatar
danno@chromium.org committed
2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 2415 2416 2417 2418 2419 2420 2421 2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432 2433 2434 2435 2436 2437 2438 2439 2440 2441 2442 2443
  LInstruction* DoMathExp(HUnaryMathOperation* instr);
  LInstruction* DoMathSqrt(HUnaryMathOperation* instr);
  LInstruction* DoMathPowHalf(HUnaryMathOperation* instr);
  LInstruction* DoMathClz32(HUnaryMathOperation* instr);
  LInstruction* DoDivByPowerOf2I(HDiv* instr);
  LInstruction* DoDivByConstI(HDiv* instr);
  LInstruction* DoDivI(HDiv* instr);
  LInstruction* DoModByPowerOf2I(HMod* instr);
  LInstruction* DoModByConstI(HMod* instr);
  LInstruction* DoModI(HMod* instr);
  LInstruction* DoFlooringDivByPowerOf2I(HMathFloorOfDiv* instr);
  LInstruction* DoFlooringDivByConstI(HMathFloorOfDiv* instr);
  LInstruction* DoFlooringDivI(HMathFloorOfDiv* instr);

 private:
  // Methods for getting operands for Use / Define / Temp.
  LUnallocated* ToUnallocated(Register reg);
  LUnallocated* ToUnallocated(X87Register reg);

  // Methods for setting up define-use relationships.
  MUST_USE_RESULT LOperand* Use(HValue* value, LUnallocated* operand);
  MUST_USE_RESULT LOperand* UseFixed(HValue* value, Register fixed_register);

  // 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).
  MUST_USE_RESULT LOperand* UseRegister(HValue* value);
  MUST_USE_RESULT LOperand* UseRegisterAtStart(HValue* value);

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

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

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

  // An input operand in a fixed register or a constant operand.
  MUST_USE_RESULT LOperand* UseFixedOrConstant(HValue* value,
                                               Register fixed_register);

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

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

  // An input operand in register, stack slot or a constant operand.
  // Will not be moved to a register even if one is freely available.
2444
  MUST_USE_RESULT LOperand* UseAny(HValue* value) override;
danno@chromium.org's avatar
danno@chromium.org committed
2445 2446 2447 2448 2449 2450 2451 2452 2453 2454 2455 2456 2457 2458 2459

  // Temporary operand that must be in a register.
  MUST_USE_RESULT LUnallocated* TempRegister();
  MUST_USE_RESULT LOperand* FixedTemp(Register reg);

  // Methods for setting up define-use relationships.
  // Return the same instruction that they are passed.
  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);
2460 2461
  LInstruction* DefineFixed(LTemplateResultInstruction<1>* instr,
                            X87Register reg);
danno@chromium.org's avatar
danno@chromium.org committed
2462 2463 2464 2465 2466 2467 2468 2469 2470 2471 2472 2473 2474 2475 2476 2477 2478 2479 2480 2481 2482 2483 2484 2485 2486 2487 2488 2489 2490 2491 2492 2493 2494 2495 2496 2497 2498 2499 2500 2501 2502 2503 2504
  LInstruction* DefineX87TOS(LTemplateResultInstruction<1>* instr);
  // Assigns an environment to an instruction.  An instruction which can
  // deoptimize must have an environment.
  LInstruction* AssignEnvironment(LInstruction* instr);
  // Assigns a pointer map to an instruction.  An instruction which can
  // trigger a GC or a lazy deoptimization must have a pointer map.
  LInstruction* AssignPointerMap(LInstruction* instr);

  enum CanDeoptimize { CAN_DEOPTIMIZE_EAGERLY, CANNOT_DEOPTIMIZE_EAGERLY };

  LOperand* GetSeqStringSetCharOperand(HSeqStringSetChar* instr);

  // 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.
  LInstruction* MarkAsCall(
      LInstruction* instr,
      HInstruction* hinstr,
      CanDeoptimize can_deoptimize = CANNOT_DEOPTIMIZE_EAGERLY);

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

  void DoBasicBlock(HBasicBlock* block, HBasicBlock* next_block);
  LInstruction* DoShift(Token::Value op, HBitwiseBinaryOperation* instr);
  LInstruction* DoArithmeticD(Token::Value op,
                              HArithmeticBinaryOperation* instr);
  LInstruction* DoArithmeticT(Token::Value op,
                              HBinaryOperation* instr);

  LOperand* GetStoreKeyedValueOperand(HStoreKeyed* instr);

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

  DISALLOW_COPY_AND_ASSIGN(LChunkBuilder);
};

#undef DECLARE_HYDROGEN_ACCESSOR
#undef DECLARE_CONCRETE_INSTRUCTION

2505 2506
}  // namespace internal
}  // namespace v8
danno@chromium.org's avatar
danno@chromium.org committed
2507

2508
#endif  // V8_CRANKSHAFT_X87_LITHIUM_X87_H_