Skip to content

Conversation

@dougxc
Copy link
Member

@dougxc dougxc commented May 28, 2025

The point of the phantom_ref parameter (introduced by JDK-8234359) of JVMCINMethodData::get_nmethod_mirror is to avoid the special resurrection semantics of a phantom read when reading the field during GC, which is when JVMCINMethodData::invalidate_nmethod_mirror can be called.
This case can be handled directly in JVMCINMethodData::invalidate_nmethod_mirror and so the phantom_ref parameter can be removed.


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-8357619: [JVMCI] Revisit phantom_ref parameter in JVMCINMethodData::get_nmethod_mirror (Enhancement - P4)

Reviewers

Reviewing

Using git

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

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

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 25488

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

Using diff file

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

Using Webrev

Link to Webrev Comment

@bridgekeeper
Copy link

bridgekeeper bot commented May 28, 2025

👋 Welcome back dnsimon! 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 May 28, 2025

@dougxc 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:

8357619: [JVMCI] Revisit phantom_ref parameter in JVMCINMethodData::get_nmethod_mirror

Reviewed-by: eosterlund, never

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 103 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
Copy link

openjdk bot commented May 28, 2025

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

  • graal
  • hotspot-compiler

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 graal graal-dev@openjdk.org hotspot-compiler hotspot-compiler-dev@openjdk.org labels May 28, 2025
@dougxc dougxc changed the title 8357619: [JVMCI] Improve documentation of phantom_ref parameter in JVMCINMethodData::get_nmethod_mirror 8357619: [JVMCI] Clarify phantom_ref parameter in JVMCINMethodData::get_nmethod_mirror May 28, 2025
@dougxc dougxc changed the title 8357619: [JVMCI] Clarify phantom_ref parameter in JVMCINMethodData::get_nmethod_mirror 8357619: [JVMCI] Revisit phantom_ref parameter in JVMCINMethodData::get_nmethod_mirror May 28, 2025
// Only the mirror in the HotSpot heap is accessible
// through JVMCINMethodData
oop nmethod_mirror = data->get_nmethod_mirror(nm, /* phantom_ref */ true);
oop nmethod_mirror = data->get_nmethod_mirror(nm);
Copy link
Contributor

Choose a reason for hiding this comment

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

Is the nmethod guaranteed to be on-stack here? If not it gotta be phantom.

Copy link
Member Author

Choose a reason for hiding this comment

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

Is the use of JVMCINMethodHandle equivalent to nm being on-stack?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes. Great, so that should be fine then.

@dougxc dougxc marked this pull request as ready for review May 29, 2025 13:00
@openjdk openjdk bot added the rfr Pull request is ready for review label May 29, 2025
@mlbridge
Copy link

mlbridge bot commented May 29, 2025

Webrevs

Copy link
Contributor

@fisk fisk left a comment

Choose a reason for hiding this comment

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

Looks good.

@openjdk openjdk bot added the ready Pull request is ready to be integrated label May 30, 2025
void JVMCINMethodData::invalidate_nmethod_mirror(nmethod* nm) {
oop nmethod_mirror = get_nmethod_mirror(nm, /* phantom_ref */ false);
if (nmethod_mirror == nullptr) {
if (_nmethod_mirror_index == -1) {
Copy link
Contributor

Choose a reason for hiding this comment

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

This part is actually wrong as that's the first part of get_nmethod_mirror and we must always check that get_nmethod_mirror doesn't return nullptr. I'd assumed that the mirror was always non-null if _nmethod_mirror_index != -1 but that's not true. The slot is reserved for all non-default nmethods and must stay around so that translate can work.

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed: 7456988

@openjdk openjdk bot removed the ready Pull request is ready to be integrated label Jun 2, 2025
oop nmethod_mirror = get_nmethod_mirror(nm, /* phantom_ref */ false);
oop nmethod_mirror = get_nmethod_mirror(nm);
if (nmethod_mirror == nullptr) {
return;
Copy link
Contributor

Choose a reason for hiding this comment

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

minor typo

@openjdk openjdk bot added the ready Pull request is ready to be integrated label Jun 2, 2025
@openjdk openjdk bot removed the ready Pull request is ready to be integrated label Jun 2, 2025
@openjdk openjdk bot added the ready Pull request is ready to be integrated label Jun 2, 2025
@dougxc
Copy link
Member Author

dougxc commented Jun 3, 2025

Thanks for the reviews.

/integrate

@openjdk
Copy link

openjdk bot commented Jun 3, 2025

Going to push as commit 6cfd405.
Since your change was applied there have been 114 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 Jun 3, 2025
@openjdk openjdk bot closed this Jun 3, 2025
@openjdk openjdk bot removed ready Pull request is ready to be integrated rfr Pull request is ready for review labels Jun 3, 2025
@openjdk
Copy link

openjdk bot commented Jun 3, 2025

@dougxc Pushed as commit 6cfd405.

💡 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

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

Development

Successfully merging this pull request may close these issues.

3 participants