379 public:
380 G1FreeHumongousRegionClosure() :
381 _humongous_objects_reclaimed(0),
382 _humongous_regions_reclaimed(0),
383 _freed_bytes(0),
384 _g1h(G1CollectedHeap::heap())
385 {}
386
387 bool do_heap_region_index(uint region_index) override {
388 if (!is_reclaimable(region_index)) {
389 return false;
390 }
391
392 G1HeapRegion* r = _g1h->region_at(region_index);
393
394 oop obj = cast_to_oop(r->bottom());
395 {
396 ResourceMark rm;
397 bool allocated_after_mark_start = r->bottom() == _g1h->concurrent_mark()->top_at_mark_start(r);
398 bool mark_in_progress = _g1h->collector_state()->is_in_marking();
399 guarantee(obj->is_typeArray() || (allocated_after_mark_start || !mark_in_progress),
400 "Only eagerly reclaiming primitive arrays is supported, other humongous objects only if allocated after mark start, but the object "
401 PTR_FORMAT " (%s) is not (mark %d allocated after mark: %d).",
402 p2i(r->bottom()), obj->klass()->name()->as_C_string(), mark_in_progress, allocated_after_mark_start);
403 }
404 log_debug(gc, humongous)("Reclaimed humongous region %u (object size %zu @ " PTR_FORMAT ")",
405 region_index,
406 obj->size() * HeapWordSize,
407 p2i(r->bottom())
408 );
409
410 G1ConcurrentMark* const cm = _g1h->concurrent_mark();
411 cm->humongous_object_eagerly_reclaimed(r);
412 assert(!cm->is_marked_in_bitmap(obj),
413 "Eagerly reclaimed humongous region %u should not be marked at all but is in bitmap %s",
414 region_index,
415 BOOL_TO_STR(cm->is_marked_in_bitmap(obj)));
416 _humongous_objects_reclaimed++;
417
418 auto free_humongous_region = [&] (G1HeapRegion* r) {
419 _freed_bytes += r->used();
420 r->set_containing_set(nullptr);
421 _humongous_regions_reclaimed++;
422 G1HeapRegionPrinter::eager_reclaim(r);
|
379 public:
380 G1FreeHumongousRegionClosure() :
381 _humongous_objects_reclaimed(0),
382 _humongous_regions_reclaimed(0),
383 _freed_bytes(0),
384 _g1h(G1CollectedHeap::heap())
385 {}
386
387 bool do_heap_region_index(uint region_index) override {
388 if (!is_reclaimable(region_index)) {
389 return false;
390 }
391
392 G1HeapRegion* r = _g1h->region_at(region_index);
393
394 oop obj = cast_to_oop(r->bottom());
395 {
396 ResourceMark rm;
397 bool allocated_after_mark_start = r->bottom() == _g1h->concurrent_mark()->top_at_mark_start(r);
398 bool mark_in_progress = _g1h->collector_state()->is_in_marking();
399 guarantee(_g1h->can_be_marked_through_immediately(obj) || (allocated_after_mark_start || !mark_in_progress),
400 "Only eagerly reclaiming arrays without oops is always supported, other humongous objects only if allocated after mark start, but the object "
401 PTR_FORMAT " (%s) is not (allocated after mark: %d mark in progress %d marked immediately %d is_array %d array_with_oops %d).",
402 p2i(r->bottom()), obj->klass()->name()->as_C_string(), allocated_after_mark_start, mark_in_progress, _g1h->can_be_marked_through_immediately(obj), obj->is_array(), obj->is_array_with_oops());
403 }
404 log_debug(gc, humongous)("Reclaimed humongous region %u (object size %zu @ " PTR_FORMAT ")",
405 region_index,
406 obj->size() * HeapWordSize,
407 p2i(r->bottom())
408 );
409
410 G1ConcurrentMark* const cm = _g1h->concurrent_mark();
411 cm->humongous_object_eagerly_reclaimed(r);
412 assert(!cm->is_marked_in_bitmap(obj),
413 "Eagerly reclaimed humongous region %u should not be marked at all but is in bitmap %s",
414 region_index,
415 BOOL_TO_STR(cm->is_marked_in_bitmap(obj)));
416 _humongous_objects_reclaimed++;
417
418 auto free_humongous_region = [&] (G1HeapRegion* r) {
419 _freed_bytes += r->used();
420 r->set_containing_set(nullptr);
421 _humongous_regions_reclaimed++;
422 G1HeapRegionPrinter::eager_reclaim(r);
|