Skip to content

8379706: Cleanup and clarify BarrierSetAssembler::try_resolve_weak_handle_in_c2 - #30816

Closed
xmas92 wants to merge 4 commits into
openjdk:masterfrom
xmas92:JDK-8379706
Closed

8379706: Cleanup and clarify BarrierSetAssembler::try_resolve_weak_handle_in_c2#30816
xmas92 wants to merge 4 commits into
openjdk:masterfrom
xmas92:JDK-8379706

Conversation

@xmas92

@xmas92 xmas92 commented Apr 20, 2026

Copy link
Copy Markdown
Member

This patch is a simple refactor which does a few things:

  • Rename try_resolve_weak_handle_in_c2/try_resolve_weak_handle on all platforms to try_peek_weak_handle_in_nmethod to better encapsulate its contract
  • Remove its existence depending on C2's existence. It is now a shared API across all platforms
  • Create two distinct registers parameters for the weak_handle input and the obj maybe output. These may alias, and do in all current uses.

I did not add reg != noreg preconditions, but did augment the assert_different_registers with it.

I was wondering if try_peek_weak_handle_in_nmethod would be better named try_peek_weak_handle_from_nmethod, as the weak handle is not in the nmethod, but the peek is. Not sure what preposition is less ambiguous. Not that I think the name in the patch will cause problems for developers. But I'd like some input here.

Testing:

  • Tier1-3 on Oracle Supported platforms
  • GHA
  • gc/shenandoah on Linux x64
  • Compiled linux x64 without C2
  • Cross compiled aarch64, ppc64le and s390x with and without C2


Progress

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

Issue

  • JDK-8379706: Cleanup and clarify BarrierSetAssembler::try_resolve_weak_handle_in_c2 (Enhancement - P4)

Reviewers

Reviewing

Using git

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

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

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 30816

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

Using diff file

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

Using Webrev

Link to Webrev Comment

@bridgekeeper

bridgekeeper Bot commented Apr 20, 2026

Copy link
Copy Markdown

👋 Welcome back aboldtch! 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

openjdk Bot commented Apr 20, 2026

Copy link
Copy Markdown

@xmas92 This change now passes all automated pre-integration checks.

ℹ️ This project also has non-automated pre-integration requirements. Please see the file CONTRIBUTING.md for details.

After integration, the commit message for the final commit will be:

8379706: Cleanup and clarify BarrierSetAssembler::try_resolve_weak_handle_in_c2

Reviewed-by: mdoerr, fyang, amitkumar

You can use pull request commands such as /summary, /contributor and /issue to adjust it as needed.

At the time when this comment was updated there had been 182 new commits pushed to the master branch:

As there are no conflicts, your changes will automatically be rebased on top of these commits when integrating. If you prefer to avoid this automatic rebasing, please check the documentation for the /integrate command for further details.

➡️ To integrate this PR with the above commit message to the master branch, type /integrate in a new comment.

@openjdk openjdk Bot added hotspot hotspot-dev@openjdk.org shenandoah shenandoah-dev@openjdk.org labels Apr 20, 2026
@openjdk

openjdk Bot commented Apr 20, 2026

Copy link
Copy Markdown

@xmas92 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 commented Apr 20, 2026

Copy link
Copy Markdown

The total number of required reviews for this PR has been set to 2 based on the presence of this label: hotspot. This can be overridden with the /reviewers command.

@openjdk openjdk Bot added the rfr Pull request is ready for review label Apr 20, 2026
@mlbridge

mlbridge Bot commented Apr 20, 2026

Copy link
Copy Markdown

Webrevs

@TheRealMDoerr TheRealMDoerr left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks for improving this! I think an additional comment would be helpful to make sure potential users clearly understand what "peek" means. The peeked object is only valid until we hit the next safepoint.
We'll run tests.

void ZBarrierSetAssembler::try_resolve_weak_handle_in_c2(MacroAssembler* masm, Register obj, Register tmp, Label& slow_path) {
// Resolve weak handle using the standard implementation.
BarrierSetAssembler::try_resolve_weak_handle_in_c2(masm, obj, tmp, slow_path);
#undef __

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think the following lines above should also be removed:

#define __ masm->

#undef __

@TheRealMDoerr

Copy link
Copy Markdown
Contributor

Test results look good on our side. Thanks!

@TheRealMDoerr TheRealMDoerr left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Excellent! Thanks!

@fbredber

Copy link
Copy Markdown
Contributor

@RealFYang, @offamitkumar
You might want to look at this, and take it for a spin, since it changes code in your platforms.

@RealFYang RealFYang left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The RISC-V part seems fine to me. My local hs:tier1 - hs:tier3 test on linux-riscv64 using fastdebug build is good.

@openjdk openjdk Bot added the ready Pull request is ready to be integrated label Apr 30, 2026

@offamitkumar offamitkumar left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

s390 looks good, hotspot:tier1 test passed on s390x with fastdebug-vm.

@xmas92

xmas92 commented May 4, 2026

Copy link
Copy Markdown
Member Author

Thanks for the reviews.
/integrate

@openjdk

openjdk Bot commented May 4, 2026

Copy link
Copy Markdown

Going to push as commit 0588209.
Since your change was applied there have been 205 commits pushed to the master branch:

Your commit was automatically rebased without conflicts.

@openjdk openjdk Bot added the integrated Pull request has been integrated label May 4, 2026
@openjdk openjdk Bot closed this May 4, 2026
@openjdk openjdk Bot removed ready Pull request is ready to be integrated rfr Pull request is ready for review labels May 4, 2026
@openjdk

openjdk Bot commented May 4, 2026

Copy link
Copy Markdown

@xmas92 Pushed as commit 0588209.

💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored.

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

Labels

hotspot hotspot-dev@openjdk.org integrated Pull request has been integrated shenandoah shenandoah-dev@openjdk.org

Development

Successfully merging this pull request may close these issues.

5 participants