106
107 // Find a contiguous set of empty or uncommitted regions of length num and return
108 // the index of the first region or G1_NO_HRM_INDEX if the search was unsuccessful.
109 // If only_empty is true, only empty regions are considered.
110 // Searches from bottom to top of the heap, doing a first-fit.
111 uint find_contiguous(size_t num, bool only_empty);
112 // Finds the next sequence of unavailable regions starting from start_idx. Returns the
113 // length of the sequence found. If this result is zero, no such sequence could be found,
114 // otherwise res_idx indicates the start index of these regions.
115 uint find_unavailable_from_idx(uint start_idx, uint* res_idx) const;
116 // Finds the next sequence of empty regions starting from start_idx, going backwards in
117 // the heap. Returns the length of the sequence found. If this value is zero, no
118 // sequence could be found, otherwise res_idx contains the start index of this range.
119 uint find_empty_from_idx_reverse(uint start_idx, uint* res_idx) const;
120 // Allocate a new HeapRegion for the given index.
121 HeapRegion* new_heap_region(uint hrm_index);
122 #ifdef ASSERT
123 public:
124 bool is_free(HeapRegion* hr) const;
125 #endif
126 // Returns whether the given region is available for allocation.
127 bool is_available(uint region) const;
128
129 public:
130 // Empty constructor, we'll initialize it with the initialize() method.
131 HeapRegionManager();
132
133 void initialize(G1RegionToSpaceMapper* heap_storage,
134 G1RegionToSpaceMapper* prev_bitmap,
135 G1RegionToSpaceMapper* next_bitmap,
136 G1RegionToSpaceMapper* bot,
137 G1RegionToSpaceMapper* cardtable,
138 G1RegionToSpaceMapper* card_counts);
139
140 // Return the "dummy" region used for G1AllocRegion. This is currently a hardwired
141 // new HeapRegion that owns HeapRegion at index 0. Since at the moment we commit
142 // the heap from the lowest address, this region (and its associated data
143 // structures) are available and we do not need to check further.
144 HeapRegion* get_dummy_region() { return new_heap_region(0); }
145
146 // Return the HeapRegion at the given index. Assume that the index
147 // is valid.
148 inline HeapRegion* at(uint index) const;
149
150 // Return the next region (by index) that is part of the same
151 // humongous object that hr is part of.
152 inline HeapRegion* next_region_in_humongous(HeapRegion* hr) const;
153
154 // If addr is within the committed space return its corresponding
155 // HeapRegion, otherwise return NULL.
156 inline HeapRegion* addr_to_region(HeapWord* addr) const;
157
158 // Insert the given region into the free region list.
159 inline void insert_into_free_list(HeapRegion* hr);
160
161 // Insert the given region list into the global free region list.
162 void insert_list_into_free_list(FreeRegionList* list) {
163 _free_list.add_ordered(list);
164 }
165
166 HeapRegion* allocate_free_region(bool is_old) {
167 HeapRegion* hr = _free_list.remove_region(is_old);
168
|
106
107 // Find a contiguous set of empty or uncommitted regions of length num and return
108 // the index of the first region or G1_NO_HRM_INDEX if the search was unsuccessful.
109 // If only_empty is true, only empty regions are considered.
110 // Searches from bottom to top of the heap, doing a first-fit.
111 uint find_contiguous(size_t num, bool only_empty);
112 // Finds the next sequence of unavailable regions starting from start_idx. Returns the
113 // length of the sequence found. If this result is zero, no such sequence could be found,
114 // otherwise res_idx indicates the start index of these regions.
115 uint find_unavailable_from_idx(uint start_idx, uint* res_idx) const;
116 // Finds the next sequence of empty regions starting from start_idx, going backwards in
117 // the heap. Returns the length of the sequence found. If this value is zero, no
118 // sequence could be found, otherwise res_idx contains the start index of this range.
119 uint find_empty_from_idx_reverse(uint start_idx, uint* res_idx) const;
120 // Allocate a new HeapRegion for the given index.
121 HeapRegion* new_heap_region(uint hrm_index);
122 #ifdef ASSERT
123 public:
124 bool is_free(HeapRegion* hr) const;
125 #endif
126 public:
127 // Returns whether the given region is available for allocation.
128 bool is_available(uint region) const;
129
130 // Empty constructor, we'll initialize it with the initialize() method.
131 HeapRegionManager();
132
133 void initialize(G1RegionToSpaceMapper* heap_storage,
134 G1RegionToSpaceMapper* prev_bitmap,
135 G1RegionToSpaceMapper* next_bitmap,
136 G1RegionToSpaceMapper* bot,
137 G1RegionToSpaceMapper* cardtable,
138 G1RegionToSpaceMapper* card_counts);
139
140 // Return the "dummy" region used for G1AllocRegion. This is currently a hardwired
141 // new HeapRegion that owns HeapRegion at index 0. Since at the moment we commit
142 // the heap from the lowest address, this region (and its associated data
143 // structures) are available and we do not need to check further.
144 HeapRegion* get_dummy_region() { return new_heap_region(0); }
145
146 // Return the HeapRegion at the given index. Assume that the index
147 // is valid.
148 inline HeapRegion* at(uint index) const;
149
150 // Return the HeapRegion at the given index, NULL if the index
151 // is for an unavailable region.
152 inline HeapRegion* at_or_null(uint index) const;
153
154 // Return the next region (by index) that is part of the same
155 // humongous object that hr is part of.
156 inline HeapRegion* next_region_in_humongous(HeapRegion* hr) const;
157
158 // If addr is within the committed space return its corresponding
159 // HeapRegion, otherwise return NULL.
160 inline HeapRegion* addr_to_region(HeapWord* addr) const;
161
162 // Insert the given region into the free region list.
163 inline void insert_into_free_list(HeapRegion* hr);
164
165 // Insert the given region list into the global free region list.
166 void insert_list_into_free_list(FreeRegionList* list) {
167 _free_list.add_ordered(list);
168 }
169
170 HeapRegion* allocate_free_region(bool is_old) {
171 HeapRegion* hr = _free_list.remove_region(is_old);
172
|