| 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 491 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 502 void ResolvePhis(const InstructionBlock* block); | 502 void ResolvePhis(const InstructionBlock* block); |
| 503 | 503 |
| 504 // Helper methods for building intervals. | 504 // Helper methods for building intervals. |
| 505 InstructionOperand* AllocateFixed(UnallocatedOperand* operand, int pos, | 505 InstructionOperand* AllocateFixed(UnallocatedOperand* operand, int pos, |
| 506 bool is_tagged); | 506 bool is_tagged); |
| 507 LiveRange* LiveRangeFor(InstructionOperand* operand); | 507 LiveRange* LiveRangeFor(InstructionOperand* operand); |
| 508 void Define(LifetimePosition position, InstructionOperand* operand, | 508 void Define(LifetimePosition position, InstructionOperand* operand, |
| 509 InstructionOperand* hint); | 509 InstructionOperand* hint); |
| 510 void Use(LifetimePosition block_start, LifetimePosition position, | 510 void Use(LifetimePosition block_start, LifetimePosition position, |
| 511 InstructionOperand* operand, InstructionOperand* hint); | 511 InstructionOperand* operand, InstructionOperand* hint); |
| 512 void AddGapMove(int index, Instruction::GapPosition position, | 512 MoveOperands* AddGapMove(int index, Instruction::GapPosition position, |
| 513 InstructionOperand* from, InstructionOperand* to); | 513 const InstructionOperand& from, |
| 514 const InstructionOperand& to); |
| 514 | 515 |
| 515 // Helper methods for updating the life range lists. | 516 // Helper methods for updating the life range lists. |
| 516 void AddToActive(LiveRange* range); | 517 void AddToActive(LiveRange* range); |
| 517 void AddToInactive(LiveRange* range); | 518 void AddToInactive(LiveRange* range); |
| 518 void AddToUnhandledSorted(LiveRange* range); | 519 void AddToUnhandledSorted(LiveRange* range); |
| 519 void AddToUnhandledUnsorted(LiveRange* range); | 520 void AddToUnhandledUnsorted(LiveRange* range); |
| 520 void SortUnhandled(); | 521 void SortUnhandled(); |
| 521 bool UnhandledIsSorted(); | 522 bool UnhandledIsSorted(); |
| 522 void ActiveToHandled(LiveRange* range); | 523 void ActiveToHandled(LiveRange* range); |
| 523 void ActiveToInactive(LiveRange* range); | 524 void ActiveToInactive(LiveRange* range); |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 567 // If we are trying to spill a range inside the loop try to | 568 // If we are trying to spill a range inside the loop try to |
| 568 // hoist spill position out to the point just before the loop. | 569 // hoist spill position out to the point just before the loop. |
| 569 LifetimePosition FindOptimalSpillingPos(LiveRange* range, | 570 LifetimePosition FindOptimalSpillingPos(LiveRange* range, |
| 570 LifetimePosition pos); | 571 LifetimePosition pos); |
| 571 | 572 |
| 572 void Spill(LiveRange* range); | 573 void Spill(LiveRange* range); |
| 573 bool IsBlockBoundary(LifetimePosition pos); | 574 bool IsBlockBoundary(LifetimePosition pos); |
| 574 | 575 |
| 575 // Helper methods for resolving control flow. | 576 // Helper methods for resolving control flow. |
| 576 void ResolveControlFlow(const InstructionBlock* block, | 577 void ResolveControlFlow(const InstructionBlock* block, |
| 577 InstructionOperand* cur_op, | 578 const InstructionOperand& cur_op, |
| 578 const InstructionBlock* pred, | 579 const InstructionBlock* pred, |
| 579 InstructionOperand* pred_op); | 580 const InstructionOperand& pred_op); |
| 580 | 581 |
| 581 void SetLiveRangeAssignedRegister(LiveRange* range, int reg); | 582 void SetLiveRangeAssignedRegister(LiveRange* range, int reg); |
| 582 | 583 |
| 583 // Return the block which contains give lifetime position. | 584 // Return the block which contains give lifetime position. |
| 584 const InstructionBlock* GetInstructionBlock(LifetimePosition pos); | 585 const InstructionBlock* GetInstructionBlock(LifetimePosition pos); |
| 585 | 586 |
| 586 // Helper methods for the fixed registers. | 587 // Helper methods for the fixed registers. |
| 587 int RegisterCount() const; | 588 int RegisterCount() const; |
| 588 static int FixedLiveRangeID(int index) { return -index - 1; } | 589 static int FixedLiveRangeID(int index) { return -index - 1; } |
| 589 int FixedDoubleLiveRangeID(int index); | 590 int FixedDoubleLiveRangeID(int index); |
| 590 LiveRange* FixedLiveRangeFor(int index); | 591 LiveRange* FixedLiveRangeFor(int index); |
| 591 LiveRange* FixedDoubleLiveRangeFor(int index); | 592 LiveRange* FixedDoubleLiveRangeFor(int index); |
| 592 LiveRange* LiveRangeFor(int index); | 593 LiveRange* LiveRangeFor(int index); |
| 593 Instruction* GetLastInstruction(const InstructionBlock* block); | 594 Instruction* GetLastInstruction(const InstructionBlock* block); |
| 594 | 595 |
| 595 const char* RegisterName(int allocation_index); | 596 const char* RegisterName(int allocation_index); |
| 596 | 597 |
| 597 Instruction* InstructionAt(int index) { return code()->InstructionAt(index); } | 598 Instruction* InstructionAt(int index) { return code()->InstructionAt(index); } |
| 599 void AssignPhiInput(LiveRange* range, const InstructionOperand& assignment); |
| 598 | 600 |
| 599 Frame* frame() const { return frame_; } | 601 Frame* frame() const { return frame_; } |
| 600 const char* debug_name() const { return debug_name_; } | 602 const char* debug_name() const { return debug_name_; } |
| 601 const RegisterConfiguration* config() const { return config_; } | 603 const RegisterConfiguration* config() const { return config_; } |
| 602 ZoneVector<LiveRange*>& live_ranges() { return live_ranges_; } | 604 ZoneVector<LiveRange*>& live_ranges() { return live_ranges_; } |
| 603 ZoneVector<LiveRange*>& fixed_live_ranges() { return fixed_live_ranges_; } | 605 ZoneVector<LiveRange*>& fixed_live_ranges() { return fixed_live_ranges_; } |
| 604 ZoneVector<LiveRange*>& fixed_double_live_ranges() { | 606 ZoneVector<LiveRange*>& fixed_double_live_ranges() { |
| 605 return fixed_double_live_ranges_; | 607 return fixed_double_live_ranges_; |
| 606 } | 608 } |
| 607 ZoneVector<LiveRange*>& unhandled_live_ranges() { | 609 ZoneVector<LiveRange*>& unhandled_live_ranges() { |
| 608 return unhandled_live_ranges_; | 610 return unhandled_live_ranges_; |
| 609 } | 611 } |
| 610 ZoneVector<LiveRange*>& active_live_ranges() { return active_live_ranges_; } | 612 ZoneVector<LiveRange*>& active_live_ranges() { return active_live_ranges_; } |
| 611 ZoneVector<LiveRange*>& inactive_live_ranges() { | 613 ZoneVector<LiveRange*>& inactive_live_ranges() { |
| 612 return inactive_live_ranges_; | 614 return inactive_live_ranges_; |
| 613 } | 615 } |
| 614 ZoneVector<SpillRange*>& spill_ranges() { return spill_ranges_; } | 616 ZoneVector<SpillRange*>& spill_ranges() { return spill_ranges_; } |
| 615 | 617 |
| 616 struct PhiMapValue { | 618 class PhiMapValue : public ZoneObject { |
| 617 PhiMapValue(PhiInstruction* phi, const InstructionBlock* block) | 619 public: |
| 618 : phi(phi), block(block) {} | 620 PhiMapValue(PhiInstruction* phi, const InstructionBlock* block, Zone* zone) |
| 621 : phi(phi), block(block), incoming_moves(zone) { |
| 622 incoming_moves.reserve(phi->operands().size()); |
| 623 } |
| 619 PhiInstruction* const phi; | 624 PhiInstruction* const phi; |
| 620 const InstructionBlock* const block; | 625 const InstructionBlock* const block; |
| 626 ZoneVector<MoveOperands*> incoming_moves; |
| 621 }; | 627 }; |
| 622 typedef ZoneMap<int, PhiMapValue> PhiMap; | 628 typedef ZoneMap<int, PhiMapValue*> PhiMap; |
| 623 | 629 |
| 624 Zone* const local_zone_; | 630 Zone* const local_zone_; |
| 625 Frame* const frame_; | 631 Frame* const frame_; |
| 626 InstructionSequence* const code_; | 632 InstructionSequence* const code_; |
| 627 const char* const debug_name_; | 633 const char* const debug_name_; |
| 628 | 634 |
| 629 const RegisterConfiguration* config_; | 635 const RegisterConfiguration* config_; |
| 630 PhiMap phi_map_; | 636 PhiMap phi_map_; |
| 631 | 637 |
| 632 // During liveness analysis keep a mapping from block id to live_in sets | 638 // During liveness analysis keep a mapping from block id to live_in sets |
| (...skipping 22 matching lines...) Expand all Loading... |
| 655 #endif | 661 #endif |
| 656 | 662 |
| 657 DISALLOW_COPY_AND_ASSIGN(RegisterAllocator); | 663 DISALLOW_COPY_AND_ASSIGN(RegisterAllocator); |
| 658 }; | 664 }; |
| 659 | 665 |
| 660 } // namespace compiler | 666 } // namespace compiler |
| 661 } // namespace internal | 667 } // namespace internal |
| 662 } // namespace v8 | 668 } // namespace v8 |
| 663 | 669 |
| 664 #endif // V8_REGISTER_ALLOCATOR_H_ | 670 #endif // V8_REGISTER_ALLOCATOR_H_ |
| OLD | NEW |