RFR: 8256106: Bypass intrinsic/barrier when calling Reference.get() from Finalizer [v2]

Erik Österlund eosterlund at openjdk.java.net
Wed Nov 11 17:20:59 UTC 2020

On Wed, 11 Nov 2020 15:23:12 GMT, Roman Kennke <rkennke at openjdk.org> wrote:

>> Finalizer calls Reference.get() from the Finalizer to acquire the finalizee. Concurrent reference processing GCs like Shenandoah and ZGC would return NULL for unreachable referents, and thus would not call finalize() on them.
>> ZGC works around this by fixing the referent before enqueuing, so that the barrier would take the fast-path, but Shenandoah cannot do this.
>> It is ok to bypass the barrier altogether in this place, because the FinalReference is inactive and marking and reference-discovery treat inactive FinalReferences like strong references.
>> Testing:
>>  - [x] hotspot_gc_shenandoah
>>  - [x] tier1 +UseShenandoahGC +ShenandoahVerify
>>  - [x] tier2 +UseShenandoahGC +ShenandoahVerify
>>  - [x] tier1
>>  - [x] tier2
> Roman Kennke has updated the pull request with a new target base due to a merge or a rebase. The incremental webrev excludes the unrelated changes brought in by the merge/rebase. The pull request contains two additional commits since the last revision:
>  - Merge branch 'master' into JDK-8256106
>  - 8256106: Bypass intrinsic/barrier when calling Reference.get() from Finalizer

I would prefer if we could make this look like less of a hack. We use the "raw" postfix usually to describe an access that will not have GC barriers applied. This is not true here. What it does, is rather to apply strong load barriers, which is not a raw access. So I think the name should suggest that this is treated like a strong access. Strong loads are semantically okay when the Reference is inactive, because then the referent switches over to strong semantics instead. So perhaps we could call it something that better captures this. Either something like getAsStrong() or getInactive(). I think I might prefer the latter. And new comments to describe what I just said. Oh and the comments should maybe be in java doc format like all the other comments in this file.


Changes requested by eosterlund (Reviewer).

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

More information about the hotspot-gc-dev mailing list