@@ -1452,27 +1452,23 @@ void ShenandoahHeap::print_heap_regions_on(outputStream* st) const {
14521452 }
14531453}
14541454
1455- size_t ShenandoahHeap::trash_humongous_region_at (ShenandoahHeapRegion* start) {
1455+ size_t ShenandoahHeap::trash_humongous_region_at (ShenandoahHeapRegion* start) const {
14561456 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-
14631457 assert (!start->has_live (), " liveness must be zero" );
14641458
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" );
14711465 assert (!region->is_cset (), " Humongous region should not be in collection set" );
1472-
14731466 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 ();
14761472}
14771473
14781474class ShenandoahCheckCleanGCLABClosure : public ThreadClosure {
0 commit comments