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

Kerem Kat krk at openjdk.org
Tue Feb 17 18:01:03 UTC 2026


> `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

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

Changes:
  - all: https://git.openjdk.org/jdk/pull/29491/files
  - new: https://git.openjdk.org/jdk/pull/29491/files/3b6cb3bf..63606a00

Webrevs:
 - full: https://webrevs.openjdk.org/?repo=jdk&pr=29491&range=02
 - incr: https://webrevs.openjdk.org/?repo=jdk&pr=29491&range=01-02

  Stats: 27801 lines in 595 files changed: 13577 ins; 3686 del; 10538 mod
  Patch: https://git.openjdk.org/jdk/pull/29491.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/29491/head:pull/29491

PR: https://git.openjdk.org/jdk/pull/29491


More information about the shenandoah-dev mailing list