RFR: 8366117: Shenandoah: Notify barrier nodes when transitive inputs change during IGVN [v3]

Cesar Soares Lucas cslucas at openjdk.org
Thu Feb 19 01:28:57 UTC 2026


On Tue, 17 Feb 2026 18:01:03 GMT, Kerem Kat <krk at openjdk.org> wrote:

>> `ShenandoahLoadReferenceBarrierNode::Identity()` determines if a barrier can be eliminated by traversing through intermediate nodes (`Phi`, `DecodeN`, `CastPP`, etc.) via `needs_barrier_impl()`. When these intermediate nodes change during IGVN, the barrier is not re-evaluated because IGVN only notifies direct users. This causes `TestVerifyIterativeGVN` to fail with Shenandoah, reporting missed optimization opportunities.
>> 
>> This fix adds a `BarrierSetC2::enqueue_dependent_gc_barriers()` virtual method that Shenandoah overrides to traverse outputs through the same node types and enqueue dependent barriers for re-evaluation.
>> 
>> There are more barrier eliminations enabled with this, e.g. in the arbitrarily chosen scrabble of renaissance benchmarks:
>> 
>> 
>> java -XX:+UseShenandoahGC -Xbatch -Xcomp -XX:-TieredCompilation -jar ~/.cache/stress/renaissance-gpl-0.16.1.jar scrabble -r 1 |& tee /dev/stderr | grep "optimize barrier" | sort | uniq -c | sort -rn
>> 
>> # with fix
>> 236 optimize barrier on call
>>      75 optimize barrier on alloc
>>      35 optimize barrier on barrier
>>      23 optimize barrier on parm
>>      15 optimize barrier on const
>>       1 optimize barrier on barrier
>>       1 optimize barrier on null
>> TOTAL = 386
>> 
>> # without fix
>> 193 optimize barrier on call
>>      72 optimize barrier on alloc
>>      32 optimize barrier on barrier
>>      23 optimize barrier on parm
>>       1 optimize barrier on barrier
>>       1 optimize barrier on null
>>       1 optimize barrier on const
>> TOTAL = 323
>> 
>> 
>> This requires uncommenting prints with `optimize barrier` in `c2/shenandoahSupport.cpp`.
>> 
>> Also tested with `make test CONF=linux-x86_64-server-fastdebug TEST=compiler/c2/TestVerifyIterativeGVN.java JTREG="VM_OPTIONS=-XX:+UseShenandoahGC -Xcomp -Xbatch -XX:-TieredCompilation"` which passes with the fix and fails without.
>
> Kerem Kat 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 four additional commits since the last revision:
> 
>  - Merge branch 'master' into shenbarrier-optmore-8366117
>  - Use a stack instead of recursion
>  - Merge branch 'master' into shenbarrier-optmore-8366117
>  - 8366117: Shenandoah: Notify barrier nodes when transitive inputs change during IGVN

LGTM. However, note that we are working on Shenandoah late-barrier expansion and once that happens we won't have these Shenandoah-specific IR nodes anymore.

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

Marked as reviewed by cslucas (Committer).

PR Review: https://git.openjdk.org/jdk/pull/29491#pullrequestreview-3823016091


More information about the shenandoah-dev mailing list