@@ -137,10 +137,11 @@ G1PostEvacuateCollectionSetCleanupTask1::G1PostEvacuateCollectionSetCleanupTask1
137
137
}
138
138
}
139
139
140
- class G1FreeHumongousRegionClosure : public HeapRegionClosure {
140
+ class G1FreeHumongousRegionClosure : public HeapRegionIndexClosure {
141
141
uint _humongous_objects_reclaimed;
142
142
uint _humongous_regions_reclaimed;
143
143
size_t _freed_bytes;
144
+ G1CollectedHeap* _g1h;
144
145
145
146
// Returns whether the given humongous object defined by the start region index
146
147
// is reclaimable.
@@ -181,45 +182,42 @@ class G1FreeHumongousRegionClosure : public HeapRegionClosure {
181
182
G1FreeHumongousRegionClosure () :
182
183
_humongous_objects_reclaimed (0 ),
183
184
_humongous_regions_reclaimed (0 ),
184
- _freed_bytes (0 ) {
185
- }
185
+ _freed_bytes (0 ),
186
+ _g1h (G1CollectedHeap::heap())
187
+ {}
186
188
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 )) {
189
191
return false ;
190
192
}
191
193
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);
196
195
197
196
oop obj = cast_to_oop (r->bottom ());
198
197
guarantee (obj->is_typeArray (),
199
198
" Only eagerly reclaiming type arrays is supported, but the object "
200
199
PTR_FORMAT " is not." , p2i (r->bottom ()));
201
200
202
201
log_debug (gc, humongous)(" Reclaimed humongous region %u (object size " SIZE_FORMAT " @ " PTR_FORMAT " )" ,
203
- region_idx ,
202
+ region_index ,
204
203
obj->size () * HeapWordSize,
205
204
p2i (r->bottom ())
206
205
);
207
206
208
- G1CollectedHeap* g1h = G1CollectedHeap::heap ();
209
- G1ConcurrentMark* const cm = g1h->concurrent_mark ();
207
+ G1ConcurrentMark* const cm = _g1h->concurrent_mark ();
210
208
cm->humongous_object_eagerly_reclaimed (r);
211
209
assert (!cm->is_marked_in_bitmap (obj),
212
210
" Eagerly reclaimed humongous region %u should not be marked at all but is in bitmap %s" ,
213
- region_idx ,
211
+ region_index ,
214
212
BOOL_TO_STR (cm->is_marked_in_bitmap (obj)));
215
213
_humongous_objects_reclaimed++;
216
214
do {
217
- HeapRegion* next = g1h ->next_region_in_humongous (r);
215
+ HeapRegion* next = _g1h ->next_region_in_humongous (r);
218
216
_freed_bytes += r->used ();
219
217
r->set_containing_set (nullptr );
220
218
_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);
223
221
r = next;
224
222
} while (r != nullptr );
225
223
0 commit comments