RFR: 8366117: Shenandoah: Notify barrier nodes when transitive inputs change during IGVN [v2]
Kerem Kat
krk at openjdk.org
Mon Feb 9 22:01:50 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 three additional commits since the last revision:
- 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/6c7460e2..3b6cb3bf
Webrevs:
- full: https://webrevs.openjdk.org/?repo=jdk&pr=29491&range=01
- incr: https://webrevs.openjdk.org/?repo=jdk&pr=29491&range=00-01
Stats: 56525 lines in 897 files changed: 27425 ins; 17282 del; 11818 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