RFR: JDK-8265259: G1: Fix HeapRegion::block_is_obj for unloading class in full gc

Hamlin Li mli at openjdk.java.net
Fri Apr 16 04:00:34 UTC 2021


On Thu, 15 Apr 2021 17:11:32 GMT, Stefan Johansson <sjohanss at openjdk.org> wrote:

>> In JDK-8262068, we have introduced an enhancement to skip compacting some heap regions.
>> But the objs in these regions might have been dead, and their classes might have been unloaded, at this situation, we need following change to make sure we don't get into trouble when calls HeapRegion::block_is_obj(const HeapWord* p) and subsequent calls e.g. to get obj size.
>
> src/hotspot/share/gc/g1/heapRegion.inline.hpp line 148:
> 
>> 146:   // they're not marked in the full gc.
>> 147:   // So, only when ClassUnloading is false, it's safe to tell an obj is indeed an obj when
>> 148:   // it's under the top of the region, otherwise we have to go to the slow path below.
> 
> This now only talks about the Full GC case and previously we only needed this when unloading during a concurrent cycle. I would like this case to be mentioned as well. Maybe something like:
> Suggestion:
> 
>   // When class unloading is enabled it is not safe to only consider top() to conclude if the 
>   // given pointer is a valid object. The situation can occur both for class unloading in a 
>   // Full GC and during a concurrent cycle. 
>   // During a Full GC regions can be excluded from compaction due to high live ration, and
>   // because of this there can be stale objects for unloaded classes left in these regions.
>   // During a concurrent cycle class unloading is done after marking is complete and objects
>   // for the unloaded classes will be stale until the regions are collected.
> 
> 
> Feel free to change the wording.

Thanks for refining the comments.

-------------

PR: https://git.openjdk.java.net/jdk/pull/3514



More information about the hotspot-gc-dev mailing list