8293920: G1: Add index based heap region iteration
Reviewed-by: tschatzl, kbarrett
This commit is contained in:
parent
36c9034ff1
commit
a93cf92635
@ -2285,6 +2285,10 @@ void G1CollectedHeap::heap_region_iterate(HeapRegionClosure* cl) const {
|
||||
_hrm.iterate(cl);
|
||||
}
|
||||
|
||||
void G1CollectedHeap::heap_region_iterate(HeapRegionIndexClosure* cl) const {
|
||||
_hrm.iterate(cl);
|
||||
}
|
||||
|
||||
void G1CollectedHeap::heap_region_par_iterate_from_worker_offset(HeapRegionClosure* cl,
|
||||
HeapRegionClaimer *hrclaimer,
|
||||
uint worker_id) const {
|
||||
|
@ -1080,6 +1080,7 @@ public:
|
||||
// Iterate over heap regions, in address order, terminating the
|
||||
// iteration early if the "do_heap_region" method returns "true".
|
||||
void heap_region_iterate(HeapRegionClosure* blk) const;
|
||||
void heap_region_iterate(HeapRegionIndexClosure* blk) const;
|
||||
|
||||
// Return the region with the given index. It assumes the index is valid.
|
||||
inline HeapRegion* region_at(uint index) const;
|
||||
|
@ -609,4 +609,23 @@ public:
|
||||
bool is_complete() { return _is_complete; }
|
||||
};
|
||||
|
||||
class HeapRegionIndexClosure : public StackObj {
|
||||
friend class HeapRegionManager;
|
||||
friend class G1CollectionSet;
|
||||
friend class G1CollectionSetCandidates;
|
||||
|
||||
bool _is_complete;
|
||||
void set_incomplete() { _is_complete = false; }
|
||||
|
||||
public:
|
||||
HeapRegionIndexClosure(): _is_complete(true) {}
|
||||
|
||||
// Typically called on each region until it returns true.
|
||||
virtual bool do_heap_region_index(uint region_index) = 0;
|
||||
|
||||
// True after iteration if the closure was applied to all heap regions
|
||||
// and returned "false" in all cases.
|
||||
bool is_complete() { return _is_complete; }
|
||||
};
|
||||
|
||||
#endif // SHARE_GC_G1_HEAPREGION_HPP
|
||||
|
@ -526,6 +526,21 @@ void HeapRegionManager::iterate(HeapRegionClosure* blk) const {
|
||||
}
|
||||
}
|
||||
|
||||
void HeapRegionManager::iterate(HeapRegionIndexClosure* blk) const {
|
||||
uint len = reserved_length();
|
||||
|
||||
for (uint i = 0; i < len; i++) {
|
||||
if (!is_available(i)) {
|
||||
continue;
|
||||
}
|
||||
bool res = blk->do_heap_region_index(i);
|
||||
if (res) {
|
||||
blk->set_incomplete();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
uint HeapRegionManager::find_highest_free(bool* expanded) {
|
||||
// Loop downwards from the highest region index, looking for an
|
||||
// entry which is either free or not yet committed. If not yet
|
||||
|
@ -271,6 +271,7 @@ public:
|
||||
// Apply blk->do_heap_region() on all committed regions in address order,
|
||||
// terminating the iteration early if do_heap_region() returns true.
|
||||
void iterate(HeapRegionClosure* blk) const;
|
||||
void iterate(HeapRegionIndexClosure* blk) const;
|
||||
|
||||
void par_iterate(HeapRegionClosure* blk, HeapRegionClaimer* hrclaimer, const uint start_index) const;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user