Skip to content

Commit 4020ed5

Browse files
committed
8293210: G1: Remove redundant check in G1FreeHumongousRegionClosure
Reviewed-by: tschatzl, kbarrett
1 parent 8ff2c26 commit 4020ed5

File tree

2 files changed

+14
-17
lines changed

2 files changed

+14
-17
lines changed

src/hotspot/share/gc/g1/g1CollectedHeap.inline.hpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,6 @@ inline bool G1CollectedHeap::is_obj_dead_full(const oop obj) const {
238238
}
239239

240240
inline bool G1CollectedHeap::is_humongous_reclaim_candidate(uint region) {
241-
assert(_hrm.at(region)->is_starts_humongous(), "Must start a humongous object");
242241
return _region_attr.is_humongous_candidate(region);
243242
}
244243

src/hotspot/share/gc/g1/g1YoungGCPostEvacuateTasks.cpp

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -137,10 +137,11 @@ G1PostEvacuateCollectionSetCleanupTask1::G1PostEvacuateCollectionSetCleanupTask1
137137
}
138138
}
139139

140-
class G1FreeHumongousRegionClosure : public HeapRegionClosure {
140+
class G1FreeHumongousRegionClosure : public HeapRegionIndexClosure {
141141
uint _humongous_objects_reclaimed;
142142
uint _humongous_regions_reclaimed;
143143
size_t _freed_bytes;
144+
G1CollectedHeap* _g1h;
144145

145146
// Returns whether the given humongous object defined by the start region index
146147
// is reclaimable.
@@ -181,45 +182,42 @@ class G1FreeHumongousRegionClosure : public HeapRegionClosure {
181182
G1FreeHumongousRegionClosure() :
182183
_humongous_objects_reclaimed(0),
183184
_humongous_regions_reclaimed(0),
184-
_freed_bytes(0) {
185-
}
185+
_freed_bytes(0),
186+
_g1h(G1CollectedHeap::heap())
187+
{}
186188

187-
virtual bool do_heap_region(HeapRegion* r) {
188-
if (!r->is_starts_humongous()) {
189+
bool do_heap_region_index(uint region_index) override {
190+
if (!is_reclaimable(region_index)) {
189191
return false;
190192
}
191193

192-
uint region_idx = r->hrm_index();
193-
if (!is_reclaimable(region_idx)) {
194-
return false;
195-
}
194+
HeapRegion* r = _g1h->region_at(region_index);
196195

197196
oop obj = cast_to_oop(r->bottom());
198197
guarantee(obj->is_typeArray(),
199198
"Only eagerly reclaiming type arrays is supported, but the object "
200199
PTR_FORMAT " is not.", p2i(r->bottom()));
201200

202201
log_debug(gc, humongous)("Reclaimed humongous region %u (object size " SIZE_FORMAT " @ " PTR_FORMAT ")",
203-
region_idx,
202+
region_index,
204203
obj->size() * HeapWordSize,
205204
p2i(r->bottom())
206205
);
207206

208-
G1CollectedHeap* g1h = G1CollectedHeap::heap();
209-
G1ConcurrentMark* const cm = g1h->concurrent_mark();
207+
G1ConcurrentMark* const cm = _g1h->concurrent_mark();
210208
cm->humongous_object_eagerly_reclaimed(r);
211209
assert(!cm->is_marked_in_bitmap(obj),
212210
"Eagerly reclaimed humongous region %u should not be marked at all but is in bitmap %s",
213-
region_idx,
211+
region_index,
214212
BOOL_TO_STR(cm->is_marked_in_bitmap(obj)));
215213
_humongous_objects_reclaimed++;
216214
do {
217-
HeapRegion* next = g1h->next_region_in_humongous(r);
215+
HeapRegion* next = _g1h->next_region_in_humongous(r);
218216
_freed_bytes += r->used();
219217
r->set_containing_set(nullptr);
220218
_humongous_regions_reclaimed++;
221-
g1h->free_humongous_region(r, nullptr);
222-
g1h->hr_printer()->cleanup(r);
219+
_g1h->free_humongous_region(r, nullptr);
220+
_g1h->hr_printer()->cleanup(r);
223221
r = next;
224222
} while (r != nullptr);
225223

0 commit comments

Comments
 (0)