Skip to content

8366117: Shenandoah: Notify barrier nodes when transitive inputs change during IGVN#29491

Open
krk wants to merge 6 commits intoopenjdk:masterfrom
krk:shenbarrier-optmore-8366117
Open

8366117: Shenandoah: Notify barrier nodes when transitive inputs change during IGVN#29491
krk wants to merge 6 commits intoopenjdk:masterfrom
krk:shenbarrier-optmore-8366117

Conversation

@krk
Copy link

@krk krk commented Jan 29, 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.


Progress

  • Change must be properly reviewed (1 review required, with at least 1 Reviewer)
  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue

Issue

  • JDK-8366117: Shenandoah: Notify barrier nodes when transitive inputs change during IGVN (Bug - P4)

Reviewers

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/29491/head:pull/29491
$ git checkout pull/29491

Update a local copy of the PR:
$ git checkout pull/29491
$ git pull https://git.openjdk.org/jdk.git pull/29491/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 29491

View PR using the GUI difftool:
$ git pr show -t 29491

Using diff file

Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/29491.diff

Using Webrev

Link to Webrev Comment

@bridgekeeper
Copy link

bridgekeeper bot commented Jan 29, 2026

👋 Welcome back krk! A progress list of the required criteria for merging this PR into master will be added to the body of your pull request. There are additional pull request commands available for use with this pull request.

@openjdk
Copy link

openjdk bot commented Jan 29, 2026

❗ This change is not yet ready to be integrated.
See the Progress checklist in the description for automated requirements.

@openjdk openjdk bot added hotspot hotspot-dev@openjdk.org shenandoah shenandoah-dev@openjdk.org labels Jan 29, 2026
@openjdk
Copy link

openjdk bot commented Jan 29, 2026

@krk The following labels will be automatically applied to this pull request:

  • hotspot
  • shenandoah

When this pull request is ready to be reviewed, an "RFR" email will be sent to the corresponding mailing lists. If you would like to change these labels, use the /label pull request command.

@openjdk openjdk bot added the rfr Pull request is ready for review label Jan 29, 2026
@mlbridge
Copy link

mlbridge bot commented Jan 29, 2026

Webrevs

if (u->Opcode() == Op_ShenandoahLoadReferenceBarrier) {
worklist.push(u);
} else if (is_barrier_traversal_node(u->Opcode())) {
enqueue_dependent_gc_barriers_helper(worklist, visited, u);
Copy link
Contributor

@JohnTortugo JohnTortugo Feb 6, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Contributor

@JohnTortugo JohnTortugo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@krk
Copy link
Author

krk commented Mar 2, 2026

Hi! Could I get a review on this one?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

hotspot hotspot-dev@openjdk.org rfr Pull request is ready for review shenandoah shenandoah-dev@openjdk.org

Development

Successfully merging this pull request may close these issues.

2 participants