Semantics of CollectedHeap::requires_barriers()
Ron Pressler
ron.pressler at oracle.com
Mon Feb 8 10:02:54 UTC 2021
Hi Roman.
It means that oops in the object do not require barriers. For G1, that’s equivalent to whether or not the object
is in the young generation; for ZGC it means whether the object is in an allocating region.
It is used in the following way: continuation stacks are stored in special objects, known to the GCs, of type
StackChunk (see instanceStackChunkKlass.xxx). As long as that object does not require barriers, frames
can be copied into it (frozen) without parsing them and walking the oops. Once such an object starts requiring
barriers, frames can only be copied out of it (thawed), and freezing will allocate a new chunk.
This allows us to quickly freeze stack portions without parsing them and without changing the shape (location
of oops) when the object is in a region that requires barriers, so that the GC can assume that oop locations
are stable.
— Ron
> On 5 Feb 2021, at 19:17, Roman Kennke <rkennke at redhat.com> wrote:
>
> Hello Loom devs,
>
> I am currently trying to befriend Loom and Shenandoah GC. It's falling over this assert here:
>
> https://github.com/openjdk/loom/blob/e8aeb3d34d9dee2f1f5c1ddc71a41adc991b5808/src/hotspot/share/runtime/continuation.cpp#L2650
>
> And thus I'm trying to figure out what requires_barriers() means in this context, what is the expected semantics of it.
>
> In other GCs it seems to return false when the object is in a heap region that is not used for allocations:
>
> E.g.:
> https://github.com/openjdk/loom/blob/e8aeb3d34d9dee2f1f5c1ddc71a41adc991b5808/src/hotspot/share/gc/g1/g1CollectedHeap.cpp#L2222
>
> or:
>
> https://github.com/openjdk/loom/blob/e8aeb3d34d9dee2f1f5c1ddc71a41adc991b5808/src/hotspot/share/gc/z/zCollectedHeap.cpp#L124
>
> However, the declaration here says something different, that it should return false when HeapAccess are equivalent to RawAccess:
>
> https://github.com/openjdk/loom/blob/e8aeb3d34d9dee2f1f5c1ddc71a41adc991b5808/src/hotspot/share/gc/shared/collectedHeap.hpp#L360
>
> In most GCs this would be the case when GC is not active. But that is not how it's implemented in other GCs.
>
> Can you please shed some light what is the intention behind requires_barriers() and how it is used?
>
> Thanks a lot!
> Roman
>
More information about the loom-dev
mailing list