@@ -1452,27 +1452,23 @@ void ShenandoahHeap::print_heap_regions_on(outputStream* st) const {
1452
1452
}
1453
1453
}
1454
1454
1455
- size_t ShenandoahHeap::trash_humongous_region_at (ShenandoahHeapRegion* start) {
1455
+ size_t ShenandoahHeap::trash_humongous_region_at (ShenandoahHeapRegion* start) const {
1456
1456
assert (start->is_humongous_start (), " reclaim regions starting with the first one" );
1457
-
1458
- oop humongous_obj = cast_to_oop (start->bottom ());
1459
- size_t size = humongous_obj->size ();
1460
- size_t required_regions = ShenandoahHeapRegion::required_regions (size * HeapWordSize);
1461
- size_t index = start->index () + required_regions - 1 ;
1462
-
1463
1457
assert (!start->has_live (), " liveness must be zero" );
1464
1458
1465
- for ( size_t i = 0 ; i < required_regions; i++) {
1466
- // Reclaim from tail. Otherwise, assertion fails when printing region to trace log,
1467
- // as it expects that every region belongs to a humongous region starting with a humongous start region.
1468
- ShenandoahHeapRegion* region = get_region (index -- );
1469
-
1470
- assert (region->is_humongous (), " expect correct humongous start or continuation" );
1459
+ // Do not try to get the size of this humongous object. STW collections will
1460
+ // have already unloaded classes, so an unmarked object may have a bad klass pointer.
1461
+ ShenandoahHeapRegion* region = start;
1462
+ size_t index = region-> index ( );
1463
+ do {
1464
+ assert (region->is_humongous (), " Expect correct humongous start or continuation" );
1471
1465
assert (!region->is_cset (), " Humongous region should not be in collection set" );
1472
-
1473
1466
region->make_trash_immediate ();
1474
- }
1475
- return required_regions;
1467
+ region = get_region (++index);
1468
+ } while (region != nullptr && region->is_humongous_continuation ());
1469
+
1470
+ // Return number of regions trashed
1471
+ return index - start->index ();
1476
1472
}
1477
1473
1478
1474
class ShenandoahCheckCleanGCLABClosure : public ThreadClosure {
0 commit comments