| 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/base/compiler-specific.h" | 8 #include "src/base/compiler-specific.h" |
| 9 #include "src/compiler/instruction.h" | 9 #include "src/compiler/instruction.h" |
| 10 #include "src/globals.h" | 10 #include "src/globals.h" |
| (...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 350 UsePosition* NextRegisterPosition(LifetimePosition start) const; | 350 UsePosition* NextRegisterPosition(LifetimePosition start) const; |
| 351 | 351 |
| 352 // Returns the first use position requiring stack slot, or nullptr. | 352 // Returns the first use position requiring stack slot, or nullptr. |
| 353 UsePosition* NextSlotPosition(LifetimePosition start) const; | 353 UsePosition* NextSlotPosition(LifetimePosition start) const; |
| 354 | 354 |
| 355 // Returns use position for which register is beneficial in this live | 355 // Returns use position for which register is beneficial in this live |
| 356 // range and which follows both start and last processed use position | 356 // range and which follows both start and last processed use position |
| 357 UsePosition* NextUsePositionRegisterIsBeneficial( | 357 UsePosition* NextUsePositionRegisterIsBeneficial( |
| 358 LifetimePosition start) const; | 358 LifetimePosition start) const; |
| 359 | 359 |
| 360 // Returns lifetime position for which register is beneficial in this live |
| 361 // range and which follows both start and last processed use position. |
| 362 LifetimePosition NextLifetimePositionRegisterIsBeneficial( |
| 363 const LifetimePosition& start) const; |
| 364 |
| 360 // Returns use position for which register is beneficial in this live | 365 // Returns use position for which register is beneficial in this live |
| 361 // range and which precedes start. | 366 // range and which precedes start. |
| 362 UsePosition* PreviousUsePositionRegisterIsBeneficial( | 367 UsePosition* PreviousUsePositionRegisterIsBeneficial( |
| 363 LifetimePosition start) const; | 368 LifetimePosition start) const; |
| 364 | 369 |
| 365 // Can this live range be spilled at this position. | 370 // Can this live range be spilled at this position. |
| 366 bool CanBeSpilled(LifetimePosition pos) const; | 371 bool CanBeSpilled(LifetimePosition pos) const; |
| 367 | 372 |
| 368 // Splitting primitive used by both splitting and splintering members. | 373 // Splitting primitive used by both splitting and splintering members. |
| 369 // Performs the split, but does not link the resulting ranges. | 374 // Performs the split, but does not link the resulting ranges. |
| (...skipping 396 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 766 const ZoneVector<TopLevelLiveRange*>& live_ranges() const { | 771 const ZoneVector<TopLevelLiveRange*>& live_ranges() const { |
| 767 return live_ranges_; | 772 return live_ranges_; |
| 768 } | 773 } |
| 769 ZoneVector<TopLevelLiveRange*>& live_ranges() { return live_ranges_; } | 774 ZoneVector<TopLevelLiveRange*>& live_ranges() { return live_ranges_; } |
| 770 const ZoneVector<TopLevelLiveRange*>& fixed_live_ranges() const { | 775 const ZoneVector<TopLevelLiveRange*>& fixed_live_ranges() const { |
| 771 return fixed_live_ranges_; | 776 return fixed_live_ranges_; |
| 772 } | 777 } |
| 773 ZoneVector<TopLevelLiveRange*>& fixed_live_ranges() { | 778 ZoneVector<TopLevelLiveRange*>& fixed_live_ranges() { |
| 774 return fixed_live_ranges_; | 779 return fixed_live_ranges_; |
| 775 } | 780 } |
| 781 ZoneVector<TopLevelLiveRange*>& fixed_float_live_ranges() { |
| 782 return fixed_float_live_ranges_; |
| 783 } |
| 784 const ZoneVector<TopLevelLiveRange*>& fixed_float_live_ranges() const { |
| 785 return fixed_float_live_ranges_; |
| 786 } |
| 776 ZoneVector<TopLevelLiveRange*>& fixed_double_live_ranges() { | 787 ZoneVector<TopLevelLiveRange*>& fixed_double_live_ranges() { |
| 777 return fixed_double_live_ranges_; | 788 return fixed_double_live_ranges_; |
| 778 } | 789 } |
| 779 const ZoneVector<TopLevelLiveRange*>& fixed_double_live_ranges() const { | 790 const ZoneVector<TopLevelLiveRange*>& fixed_double_live_ranges() const { |
| 780 return fixed_double_live_ranges_; | 791 return fixed_double_live_ranges_; |
| 781 } | 792 } |
| 793 ZoneVector<TopLevelLiveRange*>& fixed_simd128_live_ranges() { |
| 794 return fixed_simd128_live_ranges_; |
| 795 } |
| 796 const ZoneVector<TopLevelLiveRange*>& fixed_simd128_live_ranges() const { |
| 797 return fixed_simd128_live_ranges_; |
| 798 } |
| 782 ZoneVector<BitVector*>& live_in_sets() { return live_in_sets_; } | 799 ZoneVector<BitVector*>& live_in_sets() { return live_in_sets_; } |
| 783 ZoneVector<BitVector*>& live_out_sets() { return live_out_sets_; } | 800 ZoneVector<BitVector*>& live_out_sets() { return live_out_sets_; } |
| 784 ZoneVector<SpillRange*>& spill_ranges() { return spill_ranges_; } | 801 ZoneVector<SpillRange*>& spill_ranges() { return spill_ranges_; } |
| 785 DelayedReferences& delayed_references() { return delayed_references_; } | 802 DelayedReferences& delayed_references() { return delayed_references_; } |
| 786 InstructionSequence* code() const { return code_; } | 803 InstructionSequence* code() const { return code_; } |
| 787 // This zone is for data structures only needed during register allocation | 804 // This zone is for data structures only needed during register allocation |
| 788 // phases. | 805 // phases. |
| 789 Zone* allocation_zone() const { return allocation_zone_; } | 806 Zone* allocation_zone() const { return allocation_zone_; } |
| 790 // This zone is for InstructionOperands and moves that live beyond register | 807 // This zone is for InstructionOperands and moves that live beyond register |
| 791 // allocation. | 808 // allocation. |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 833 Zone* const allocation_zone_; | 850 Zone* const allocation_zone_; |
| 834 Frame* const frame_; | 851 Frame* const frame_; |
| 835 InstructionSequence* const code_; | 852 InstructionSequence* const code_; |
| 836 const char* const debug_name_; | 853 const char* const debug_name_; |
| 837 const RegisterConfiguration* const config_; | 854 const RegisterConfiguration* const config_; |
| 838 PhiMap phi_map_; | 855 PhiMap phi_map_; |
| 839 ZoneVector<BitVector*> live_in_sets_; | 856 ZoneVector<BitVector*> live_in_sets_; |
| 840 ZoneVector<BitVector*> live_out_sets_; | 857 ZoneVector<BitVector*> live_out_sets_; |
| 841 ZoneVector<TopLevelLiveRange*> live_ranges_; | 858 ZoneVector<TopLevelLiveRange*> live_ranges_; |
| 842 ZoneVector<TopLevelLiveRange*> fixed_live_ranges_; | 859 ZoneVector<TopLevelLiveRange*> fixed_live_ranges_; |
| 860 ZoneVector<TopLevelLiveRange*> fixed_float_live_ranges_; |
| 843 ZoneVector<TopLevelLiveRange*> fixed_double_live_ranges_; | 861 ZoneVector<TopLevelLiveRange*> fixed_double_live_ranges_; |
| 862 ZoneVector<TopLevelLiveRange*> fixed_simd128_live_ranges_; |
| 844 ZoneVector<SpillRange*> spill_ranges_; | 863 ZoneVector<SpillRange*> spill_ranges_; |
| 845 DelayedReferences delayed_references_; | 864 DelayedReferences delayed_references_; |
| 846 BitVector* assigned_registers_; | 865 BitVector* assigned_registers_; |
| 847 BitVector* assigned_double_registers_; | 866 BitVector* assigned_double_registers_; |
| 848 int virtual_register_count_; | 867 int virtual_register_count_; |
| 849 RangesWithPreassignedSlots preassigned_slot_ranges_; | 868 RangesWithPreassignedSlots preassigned_slot_ranges_; |
| 850 | 869 |
| 851 DISALLOW_COPY_AND_ASSIGN(RegisterAllocationData); | 870 DISALLOW_COPY_AND_ASSIGN(RegisterAllocationData); |
| 852 }; | 871 }; |
| 853 | 872 |
| (...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1051 void ActiveToInactive(LiveRange* range); | 1070 void ActiveToInactive(LiveRange* range); |
| 1052 void InactiveToHandled(LiveRange* range); | 1071 void InactiveToHandled(LiveRange* range); |
| 1053 void InactiveToActive(LiveRange* range); | 1072 void InactiveToActive(LiveRange* range); |
| 1054 | 1073 |
| 1055 // Helper methods for allocating registers. | 1074 // Helper methods for allocating registers. |
| 1056 bool TryReuseSpillForPhi(TopLevelLiveRange* range); | 1075 bool TryReuseSpillForPhi(TopLevelLiveRange* range); |
| 1057 bool TryAllocateFreeReg(LiveRange* range, | 1076 bool TryAllocateFreeReg(LiveRange* range, |
| 1058 const Vector<LifetimePosition>& free_until_pos); | 1077 const Vector<LifetimePosition>& free_until_pos); |
| 1059 bool TryAllocatePreferredReg(LiveRange* range, | 1078 bool TryAllocatePreferredReg(LiveRange* range, |
| 1060 const Vector<LifetimePosition>& free_until_pos); | 1079 const Vector<LifetimePosition>& free_until_pos); |
| 1080 void GetFPRegisterSet(MachineRepresentation rep, int* num_regs, |
| 1081 int* num_codes, const int** codes) const; |
| 1061 void FindFreeRegistersForRange(LiveRange* range, | 1082 void FindFreeRegistersForRange(LiveRange* range, |
| 1062 Vector<LifetimePosition> free_until_pos); | 1083 Vector<LifetimePosition> free_until_pos); |
| 1063 void ProcessCurrentRange(LiveRange* current); | 1084 void ProcessCurrentRange(LiveRange* current); |
| 1064 void AllocateBlockedReg(LiveRange* range); | 1085 void AllocateBlockedReg(LiveRange* range); |
| 1065 bool TrySplitAndSpillSplinter(LiveRange* range); | 1086 bool TrySplitAndSpillSplinter(LiveRange* range); |
| 1066 | 1087 |
| 1067 // Spill the given life range after position pos. | 1088 // Spill the given life range after position pos. |
| 1068 void SpillAfter(LiveRange* range, LifetimePosition pos); | 1089 void SpillAfter(LiveRange* range, LifetimePosition pos); |
| 1069 | 1090 |
| 1070 // Spill the given life range after position [start] and up to position [end]. | 1091 // Spill the given life range after position [start] and up to position [end]. |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1182 RegisterAllocationData* const data_; | 1203 RegisterAllocationData* const data_; |
| 1183 | 1204 |
| 1184 DISALLOW_COPY_AND_ASSIGN(LiveRangeConnector); | 1205 DISALLOW_COPY_AND_ASSIGN(LiveRangeConnector); |
| 1185 }; | 1206 }; |
| 1186 | 1207 |
| 1187 } // namespace compiler | 1208 } // namespace compiler |
| 1188 } // namespace internal | 1209 } // namespace internal |
| 1189 } // namespace v8 | 1210 } // namespace v8 |
| 1190 | 1211 |
| 1191 #endif // V8_REGISTER_ALLOCATOR_H_ | 1212 #endif // V8_REGISTER_ALLOCATOR_H_ |
| OLD | NEW |