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