@@ -1039,26 +1039,23 @@ void ShenandoahHeap::print_heap_regions_on(outputStream* st) const {
10391039 }
10401040}
10411041
1042- void ShenandoahHeap::trash_humongous_region_at (ShenandoahHeapRegion* start) {
1042+ size_t ShenandoahHeap::trash_humongous_region_at (ShenandoahHeapRegion* start) const {
10431043 assert (start->is_humongous_start (), " reclaim regions starting with the first one" );
1044-
1045- oop humongous_obj = cast_to_oop (start->bottom ());
1046- size_t size = humongous_obj->size ();
1047- size_t required_regions = ShenandoahHeapRegion::required_regions (size * HeapWordSize);
1048- size_t index = start->index () + required_regions - 1 ;
1049-
10501044 assert (!start->has_live (), " liveness must be zero" );
10511045
1052- for ( size_t i = 0 ; i < required_regions; i++) {
1053- // Reclaim from tail. Otherwise, assertion fails when printing region to trace log,
1054- // as it expects that every region belongs to a humongous region starting with a humongous start region.
1055- ShenandoahHeapRegion* region = get_region (index -- );
1056-
1057- assert (region->is_humongous (), " expect correct humongous start or continuation" );
1046+ // Do not try to get the size of this humongous object. STW collections will
1047+ // have already unloaded classes, so an unmarked object may have a bad klass pointer.
1048+ ShenandoahHeapRegion* region = start;
1049+ size_t index = region-> index ( );
1050+ do {
1051+ assert (region->is_humongous (), " Expect correct humongous start or continuation" );
10581052 assert (!region->is_cset (), " Humongous region should not be in collection set" );
1059-
10601053 region->make_trash_immediate ();
1061- }
1054+ region = get_region (++index);
1055+ } while (region != nullptr && region->is_humongous_continuation ());
1056+
1057+ // Return number of regions trashed
1058+ return index - start->index ();
10621059}
10631060
10641061class ShenandoahCheckCleanGCLABClosure : public ThreadClosure {
0 commit comments