23 */ |
23 */ |
24 |
24 |
25 #ifndef SHARE_GC_G1_HEAPREGIONSET_INLINE_HPP |
25 #ifndef SHARE_GC_G1_HEAPREGIONSET_INLINE_HPP |
26 #define SHARE_GC_G1_HEAPREGIONSET_INLINE_HPP |
26 #define SHARE_GC_G1_HEAPREGIONSET_INLINE_HPP |
27 |
27 |
|
28 #include "gc/g1/g1NUMA.hpp" |
28 #include "gc/g1/heapRegionSet.hpp" |
29 #include "gc/g1/heapRegionSet.hpp" |
29 |
30 |
30 inline void HeapRegionSetBase::add(HeapRegion* hr) { |
31 inline void HeapRegionSetBase::add(HeapRegion* hr) { |
31 check_mt_safety(); |
32 check_mt_safety(); |
32 assert_heap_region_set(hr->containing_set() == NULL, "should not already have a containing set"); |
33 assert_heap_region_set(hr->containing_set() == NULL, "should not already have a containing set"); |
145 // remove() will verify the region and check mt safety. |
146 // remove() will verify the region and check mt safety. |
146 remove(hr); |
147 remove(hr); |
147 return hr; |
148 return hr; |
148 } |
149 } |
149 |
150 |
|
151 inline HeapRegion* FreeRegionList::remove_region_with_node_index(bool from_head, |
|
152 const uint requested_node_index, |
|
153 uint* allocated_node_index) { |
|
154 assert(UseNUMA, "Invariant"); |
|
155 |
|
156 const uint max_search_depth = G1NUMA::numa()->max_search_depth(); |
|
157 HeapRegion* cur; |
|
158 |
|
159 // Find the region to use, searching from _head or _tail as requested. |
|
160 size_t cur_depth = 0; |
|
161 if (from_head) { |
|
162 for (cur = _head; |
|
163 cur != NULL && cur_depth < max_search_depth; |
|
164 cur = cur->next(), ++cur_depth) { |
|
165 if (requested_node_index == cur->node_index()) { |
|
166 break; |
|
167 } |
|
168 } |
|
169 } else { |
|
170 for (cur = _tail; |
|
171 cur != NULL && cur_depth < max_search_depth; |
|
172 cur = cur->prev(), ++cur_depth) { |
|
173 if (requested_node_index == cur->node_index()) { |
|
174 break; |
|
175 } |
|
176 } |
|
177 } |
|
178 |
|
179 // Didn't find a region to use. |
|
180 if (cur == NULL || cur_depth >= max_search_depth) { |
|
181 return NULL; |
|
182 } |
|
183 |
|
184 // Splice the region out of the list. |
|
185 HeapRegion* prev = cur->prev(); |
|
186 HeapRegion* next = cur->next(); |
|
187 if (prev == NULL) { |
|
188 _head = next; |
|
189 } else { |
|
190 prev->set_next(next); |
|
191 } |
|
192 if (next == NULL) { |
|
193 _tail = prev; |
|
194 } else { |
|
195 next->set_prev(prev); |
|
196 } |
|
197 cur->set_prev(NULL); |
|
198 cur->set_next(NULL); |
|
199 |
|
200 if (_last == cur) { |
|
201 _last = NULL; |
|
202 } |
|
203 |
|
204 remove(cur); |
|
205 if (allocated_node_index != NULL) { |
|
206 *allocated_node_index = cur->node_index(); |
|
207 } |
|
208 |
|
209 return cur; |
|
210 } |
|
211 |
150 #endif // SHARE_GC_G1_HEAPREGIONSET_INLINE_HPP |
212 #endif // SHARE_GC_G1_HEAPREGIONSET_INLINE_HPP |