| OLD | NEW |
| 1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef V8_REGISTER_ALLOCATOR_H_ | 5 #ifndef V8_REGISTER_ALLOCATOR_H_ |
| 6 #define V8_REGISTER_ALLOCATOR_H_ | 6 #define V8_REGISTER_ALLOCATOR_H_ |
| 7 | 7 |
| 8 #include "src/compiler/instruction.h" | 8 #include "src/compiler/instruction.h" |
| 9 #include "src/zone-containers.h" | 9 #include "src/zone-containers.h" |
| 10 | 10 |
| (...skipping 359 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 370 }; | 370 }; |
| 371 | 371 |
| 372 | 372 |
| 373 class RegisterAllocator FINAL : public ZoneObject { | 373 class RegisterAllocator FINAL : public ZoneObject { |
| 374 public: | 374 public: |
| 375 explicit RegisterAllocator(const RegisterConfiguration* config, | 375 explicit RegisterAllocator(const RegisterConfiguration* config, |
| 376 Zone* local_zone, Frame* frame, | 376 Zone* local_zone, Frame* frame, |
| 377 InstructionSequence* code, | 377 InstructionSequence* code, |
| 378 const char* debug_name = nullptr); | 378 const char* debug_name = nullptr); |
| 379 | 379 |
| 380 bool AllocationOk() { return allocation_ok_; } | |
| 381 | |
| 382 const ZoneVector<LiveRange*>& live_ranges() const { return live_ranges_; } | 380 const ZoneVector<LiveRange*>& live_ranges() const { return live_ranges_; } |
| 383 const ZoneVector<LiveRange*>& fixed_live_ranges() const { | 381 const ZoneVector<LiveRange*>& fixed_live_ranges() const { |
| 384 return fixed_live_ranges_; | 382 return fixed_live_ranges_; |
| 385 } | 383 } |
| 386 const ZoneVector<LiveRange*>& fixed_double_live_ranges() const { | 384 const ZoneVector<LiveRange*>& fixed_double_live_ranges() const { |
| 387 return fixed_double_live_ranges_; | 385 return fixed_double_live_ranges_; |
| 388 } | 386 } |
| 389 InstructionSequence* code() const { return code_; } | 387 InstructionSequence* code() const { return code_; } |
| 390 // This zone is for datastructures only needed during register allocation. | 388 // This zone is for datastructures only needed during register allocation. |
| 391 Zone* local_zone() const { return local_zone_; } | 389 Zone* local_zone() const { return local_zone_; } |
| (...skipping 22 matching lines...) Expand all Loading... |
| 414 // Phase 7: compute values for pointer maps. | 412 // Phase 7: compute values for pointer maps. |
| 415 void PopulatePointerMaps(); // TODO(titzer): rename to PopulateReferenceMaps. | 413 void PopulatePointerMaps(); // TODO(titzer): rename to PopulateReferenceMaps. |
| 416 | 414 |
| 417 // Phase 8: reconnect split ranges with moves. | 415 // Phase 8: reconnect split ranges with moves. |
| 418 void ConnectRanges(); | 416 void ConnectRanges(); |
| 419 | 417 |
| 420 // Phase 9: insert moves to connect ranges across basic blocks. | 418 // Phase 9: insert moves to connect ranges across basic blocks. |
| 421 void ResolveControlFlow(); | 419 void ResolveControlFlow(); |
| 422 | 420 |
| 423 private: | 421 private: |
| 424 int GetVirtualRegister() { | 422 int GetVirtualRegister() { return code()->NextVirtualRegister(); } |
| 425 int vreg = code()->NextVirtualRegister(); | |
| 426 if (vreg >= UnallocatedOperand::kMaxVirtualRegisters) { | |
| 427 allocation_ok_ = false; | |
| 428 // Maintain the invariant that we return something below the maximum. | |
| 429 return 0; | |
| 430 } | |
| 431 return vreg; | |
| 432 } | |
| 433 | 423 |
| 434 // Checks whether the value of a given virtual register is a reference. | 424 // Checks whether the value of a given virtual register is a reference. |
| 435 // TODO(titzer): rename this to IsReference. | 425 // TODO(titzer): rename this to IsReference. |
| 436 bool HasTaggedValue(int virtual_register) const; | 426 bool HasTaggedValue(int virtual_register) const; |
| 437 | 427 |
| 438 // Returns the register kind required by the given virtual register. | 428 // Returns the register kind required by the given virtual register. |
| 439 RegisterKind RequiredRegisterKind(int virtual_register) const; | 429 RegisterKind RequiredRegisterKind(int virtual_register) const; |
| 440 | 430 |
| 441 // This zone is for InstructionOperands and moves that live beyond register | 431 // This zone is for InstructionOperands and moves that live beyond register |
| 442 // allocation. | 432 // allocation. |
| (...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 618 ZoneVector<LiveRange*> inactive_live_ranges_; | 608 ZoneVector<LiveRange*> inactive_live_ranges_; |
| 619 ZoneVector<LiveRange*> reusable_slots_; | 609 ZoneVector<LiveRange*> reusable_slots_; |
| 620 ZoneVector<SpillRange*> spill_ranges_; | 610 ZoneVector<SpillRange*> spill_ranges_; |
| 621 | 611 |
| 622 RegisterKind mode_; | 612 RegisterKind mode_; |
| 623 int num_registers_; | 613 int num_registers_; |
| 624 | 614 |
| 625 BitVector* assigned_registers_; | 615 BitVector* assigned_registers_; |
| 626 BitVector* assigned_double_registers_; | 616 BitVector* assigned_double_registers_; |
| 627 | 617 |
| 628 // Indicates success or failure during register allocation. | |
| 629 bool allocation_ok_; | |
| 630 | |
| 631 #ifdef DEBUG | 618 #ifdef DEBUG |
| 632 LifetimePosition allocation_finger_; | 619 LifetimePosition allocation_finger_; |
| 633 #endif | 620 #endif |
| 634 | 621 |
| 635 DISALLOW_COPY_AND_ASSIGN(RegisterAllocator); | 622 DISALLOW_COPY_AND_ASSIGN(RegisterAllocator); |
| 636 }; | 623 }; |
| 637 | 624 |
| 638 } // namespace compiler | 625 } // namespace compiler |
| 639 } // namespace internal | 626 } // namespace internal |
| 640 } // namespace v8 | 627 } // namespace v8 |
| 641 | 628 |
| 642 #endif // V8_REGISTER_ALLOCATOR_H_ | 629 #endif // V8_REGISTER_ALLOCATOR_H_ |
| OLD | NEW |