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 434 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
445 | 445 |
446 #ifdef DEBUG | 446 #ifdef DEBUG |
447 void Verify() const; | 447 void Verify() const; |
448 #endif | 448 #endif |
449 | 449 |
450 void AllocateRegisters(); | 450 void AllocateRegisters(); |
451 bool CanEagerlyResolveControlFlow(const InstructionBlock* block) const; | 451 bool CanEagerlyResolveControlFlow(const InstructionBlock* block) const; |
452 bool SafePointsAreInOrder() const; | 452 bool SafePointsAreInOrder() const; |
453 | 453 |
454 // Liveness analysis support. | 454 // Liveness analysis support. |
455 void InitializeLivenessAnalysis(); | |
456 BitVector* ComputeLiveOut(const InstructionBlock* block); | 455 BitVector* ComputeLiveOut(const InstructionBlock* block); |
457 void AddInitialIntervals(const InstructionBlock* block, BitVector* live_out); | 456 void AddInitialIntervals(const InstructionBlock* block, BitVector* live_out); |
458 bool IsOutputRegisterOf(Instruction* instr, int index); | 457 bool IsOutputRegisterOf(Instruction* instr, int index); |
459 bool IsOutputDoubleRegisterOf(Instruction* instr, int index); | 458 bool IsOutputDoubleRegisterOf(Instruction* instr, int index); |
460 void ProcessInstructions(const InstructionBlock* block, BitVector* live); | 459 void ProcessInstructions(const InstructionBlock* block, BitVector* live); |
461 void MeetRegisterConstraints(const InstructionBlock* block); | 460 void MeetRegisterConstraints(const InstructionBlock* block); |
462 void MeetConstraintsBetween(Instruction* first, Instruction* second, | 461 void MeetConstraintsBetween(Instruction* first, Instruction* second, |
463 int gap_index); | 462 int gap_index); |
464 void MeetRegisterConstraintsForLastInstructionInBlock( | 463 void MeetRegisterConstraintsForLastInstructionInBlock( |
465 const InstructionBlock* block); | 464 const InstructionBlock* block); |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
562 LiveRange* LiveRangeFor(int index); | 561 LiveRange* LiveRangeFor(int index); |
563 GapInstruction* GetLastGap(const InstructionBlock* block); | 562 GapInstruction* GetLastGap(const InstructionBlock* block); |
564 | 563 |
565 const char* RegisterName(int allocation_index); | 564 const char* RegisterName(int allocation_index); |
566 | 565 |
567 Instruction* InstructionAt(int index) { return code()->InstructionAt(index); } | 566 Instruction* InstructionAt(int index) { return code()->InstructionAt(index); } |
568 | 567 |
569 Frame* frame() const { return frame_; } | 568 Frame* frame() const { return frame_; } |
570 const char* debug_name() const { return debug_name_; } | 569 const char* debug_name() const { return debug_name_; } |
571 const RegisterConfiguration* config() const { return config_; } | 570 const RegisterConfiguration* config() const { return config_; } |
| 571 ZoneVector<LiveRange*>& live_ranges() { return live_ranges_; } |
| 572 ZoneVector<LiveRange*>& fixed_live_ranges() { return fixed_live_ranges_; } |
| 573 ZoneVector<LiveRange*>& fixed_double_live_ranges() { |
| 574 return fixed_double_live_ranges_; |
| 575 } |
| 576 ZoneVector<LiveRange*>& unhandled_live_ranges() { |
| 577 return unhandled_live_ranges_; |
| 578 } |
| 579 ZoneVector<LiveRange*>& active_live_ranges() { return active_live_ranges_; } |
| 580 ZoneVector<LiveRange*>& inactive_live_ranges() { |
| 581 return inactive_live_ranges_; |
| 582 } |
| 583 ZoneVector<LiveRange*>& reusable_slots() { return reusable_slots_; } |
| 584 ZoneVector<SpillRange*>& spill_ranges() { return spill_ranges_; } |
572 | 585 |
573 struct PhiMapValue { | 586 struct PhiMapValue { |
574 PhiMapValue(PhiInstruction* phi, const InstructionBlock* block) | 587 PhiMapValue(PhiInstruction* phi, const InstructionBlock* block) |
575 : phi(phi), block(block) {} | 588 : phi(phi), block(block) {} |
576 PhiInstruction* const phi; | 589 PhiInstruction* const phi; |
577 const InstructionBlock* const block; | 590 const InstructionBlock* const block; |
578 }; | 591 }; |
579 typedef std::map<int, PhiMapValue, std::less<int>, | 592 typedef std::map<int, PhiMapValue, std::less<int>, |
580 zone_allocator<std::pair<int, PhiMapValue>>> PhiMap; | 593 zone_allocator<std::pair<int, PhiMapValue>>> PhiMap; |
581 | 594 |
582 Zone* const local_zone_; | 595 Zone* const local_zone_; |
583 Frame* const frame_; | 596 Frame* const frame_; |
584 InstructionSequence* const code_; | 597 InstructionSequence* const code_; |
585 const char* const debug_name_; | 598 const char* const debug_name_; |
586 | 599 |
587 const RegisterConfiguration* config_; | 600 const RegisterConfiguration* config_; |
588 | 601 |
589 PhiMap phi_map_; | 602 PhiMap phi_map_; |
590 | 603 |
591 // During liveness analysis keep a mapping from block id to live_in sets | 604 // During liveness analysis keep a mapping from block id to live_in sets |
592 // for blocks already analyzed. | 605 // for blocks already analyzed. |
593 ZoneVector<BitVector*> live_in_sets_; | 606 ZoneVector<BitVector*> live_in_sets_; |
594 | 607 |
595 // Liveness analysis results. | 608 // Liveness analysis results. |
596 ZoneVector<LiveRange*> live_ranges_; | 609 ZoneVector<LiveRange*> live_ranges_; |
597 | 610 |
598 // Lists of live ranges | 611 // Lists of live ranges |
599 ZoneVector<LiveRange*> fixed_live_ranges_; | 612 ZoneVector<LiveRange*> fixed_live_ranges_; |
600 ZoneVector<LiveRange*> fixed_double_live_ranges_; | 613 ZoneVector<LiveRange*> fixed_double_live_ranges_; |
601 ZoneList<LiveRange*> unhandled_live_ranges_; | 614 ZoneVector<LiveRange*> unhandled_live_ranges_; |
602 ZoneList<LiveRange*> active_live_ranges_; | 615 ZoneVector<LiveRange*> active_live_ranges_; |
603 ZoneList<LiveRange*> inactive_live_ranges_; | 616 ZoneVector<LiveRange*> inactive_live_ranges_; |
604 ZoneList<LiveRange*> reusable_slots_; | 617 ZoneVector<LiveRange*> reusable_slots_; |
605 ZoneList<SpillRange*> spill_ranges_; | 618 ZoneVector<SpillRange*> spill_ranges_; |
606 | 619 |
607 RegisterKind mode_; | 620 RegisterKind mode_; |
608 int num_registers_; | 621 int num_registers_; |
609 | 622 |
610 BitVector* assigned_registers_; | 623 BitVector* assigned_registers_; |
611 BitVector* assigned_double_registers_; | 624 BitVector* assigned_double_registers_; |
612 | 625 |
613 // Indicates success or failure during register allocation. | 626 // Indicates success or failure during register allocation. |
614 bool allocation_ok_; | 627 bool allocation_ok_; |
615 | 628 |
616 #ifdef DEBUG | 629 #ifdef DEBUG |
617 LifetimePosition allocation_finger_; | 630 LifetimePosition allocation_finger_; |
618 #endif | 631 #endif |
619 | 632 |
620 DISALLOW_COPY_AND_ASSIGN(RegisterAllocator); | 633 DISALLOW_COPY_AND_ASSIGN(RegisterAllocator); |
621 }; | 634 }; |
622 | 635 |
623 } // namespace compiler | 636 } // namespace compiler |
624 } // namespace internal | 637 } // namespace internal |
625 } // namespace v8 | 638 } // namespace v8 |
626 | 639 |
627 #endif // V8_REGISTER_ALLOCATOR_H_ | 640 #endif // V8_REGISTER_ALLOCATOR_H_ |
OLD | NEW |