Skip to content

Commit

Permalink
8293210: G1: Remove redundant check in G1FreeHumongousRegionClosure
Browse files Browse the repository at this point in the history
Reviewed-by: tschatzl, kbarrett
  • Loading branch information
albertnetymk committed Sep 19, 2022
1 parent 8ff2c26 commit 4020ed5
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 17 deletions.
1 change: 0 additions & 1 deletion src/hotspot/share/gc/g1/g1CollectedHeap.inline.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
30 changes: 14 additions & 16 deletions src/hotspot/share/gc/g1/g1YoungGCPostEvacuateTasks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -181,45 +182,42 @@ class G1FreeHumongousRegionClosure : public HeapRegionClosure {
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(),
"Only eagerly reclaiming type arrays is supported, but the object "
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);

Expand Down

1 comment on commit 4020ed5

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.