8293210: G1: Remove redundant check in G1FreeHumongousRegionClosure

Reviewed-by: tschatzl, kbarrett
This commit is contained in:
Albert Mingkun Yang 2022-09-19 18:05:28 +00:00
parent 8ff2c2639e
commit 4020ed53dd
2 changed files with 14 additions and 17 deletions

View File

@ -238,7 +238,6 @@ inline bool G1CollectedHeap::is_obj_dead_full(const oop obj) const {
}
inline bool G1CollectedHeap::is_humongous_reclaim_candidate(uint region) {
assert(_hrm.at(region)->is_starts_humongous(), "Must start a humongous object");
return _region_attr.is_humongous_candidate(region);
}

View File

@ -137,10 +137,11 @@ G1PostEvacuateCollectionSetCleanupTask1::G1PostEvacuateCollectionSetCleanupTask1
}
}
class G1FreeHumongousRegionClosure : public HeapRegionClosure {
class G1FreeHumongousRegionClosure : public HeapRegionIndexClosure {
uint _humongous_objects_reclaimed;
uint _humongous_regions_reclaimed;
size_t _freed_bytes;
G1CollectedHeap* _g1h;
// Returns whether the given humongous object defined by the start region index
// is reclaimable.
@ -181,18 +182,16 @@ public:
G1FreeHumongousRegionClosure() :
_humongous_objects_reclaimed(0),
_humongous_regions_reclaimed(0),
_freed_bytes(0) {
}
_freed_bytes(0),
_g1h(G1CollectedHeap::heap())
{}
virtual bool do_heap_region(HeapRegion* r) {
if (!r->is_starts_humongous()) {
bool do_heap_region_index(uint region_index) override {
if (!is_reclaimable(region_index)) {
return false;
}
uint region_idx = r->hrm_index();
if (!is_reclaimable(region_idx)) {
return false;
}
HeapRegion* r = _g1h->region_at(region_index);
oop obj = cast_to_oop(r->bottom());
guarantee(obj->is_typeArray(),
@ -200,26 +199,25 @@ public:
PTR_FORMAT " is not.", p2i(r->bottom()));
log_debug(gc, humongous)("Reclaimed humongous region %u (object size " SIZE_FORMAT " @ " PTR_FORMAT ")",
region_idx,
region_index,
obj->size() * HeapWordSize,
p2i(r->bottom())
);
G1CollectedHeap* g1h = G1CollectedHeap::heap();
G1ConcurrentMark* const cm = g1h->concurrent_mark();
G1ConcurrentMark* const cm = _g1h->concurrent_mark();
cm->humongous_object_eagerly_reclaimed(r);
assert(!cm->is_marked_in_bitmap(obj),
"Eagerly reclaimed humongous region %u should not be marked at all but is in bitmap %s",
region_idx,
region_index,
BOOL_TO_STR(cm->is_marked_in_bitmap(obj)));
_humongous_objects_reclaimed++;
do {
HeapRegion* next = g1h->next_region_in_humongous(r);
HeapRegion* next = _g1h->next_region_in_humongous(r);
_freed_bytes += r->used();
r->set_containing_set(nullptr);
_humongous_regions_reclaimed++;
g1h->free_humongous_region(r, nullptr);
g1h->hr_printer()->cleanup(r);
_g1h->free_humongous_region(r, nullptr);
_g1h->hr_printer()->cleanup(r);
r = next;
} while (r != nullptr);