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

Cesar Soares Lucas cslucas at openjdk.org
Mon Feb 9 22:01:53 UTC 2026


On Mon, 9 Feb 2026 12:46:25 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 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 requested by cslucas (Committer).

src/hotspot/share/gc/shenandoah/c2/shenandoahBarrierSetC2.cpp line 834:

> 832:       worklist.push(u);
> 833:     } else if (is_barrier_traversal_node(u->Opcode())) {
> 834:       enqueue_dependent_gc_barriers_helper(worklist, visited, u);

I'd prefer if you used a Stack instead of recursion here.

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

PR Review: https://git.openjdk.org/jdk/pull/29491#pullrequestreview-3765575700
PR Review Comment: https://git.openjdk.org/jdk/pull/29491#discussion_r2776422119


More information about the shenandoah-dev mailing list