Skip to content

Conversation

chadrako
Copy link
Contributor

@chadrako chadrako commented Feb 11, 2025

This PR introduces a new function to replace nmethods, addressing JDK-8316694. It enables the creation of new nmethods from existing ones, allowing method relocation in the code heap and supporting JDK-8328186.

When an nmethod is replaced, a deep copy is performed. The corresponding Java method is updated to reference the new nmethod, while the old one is marked as unused. The garbage collector handles final cleanup and deallocation.

This does not modify existing code paths and therefore does not benefit much from existing tests. New tests were created to test the new functionality

Additional Testing:

  • Linux x64 fastdebug tier 1/2/3/4
  • Linux aarch64 fastdebug tier 1/2/3/4

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-8316694: Implement relocation of nmethod within CodeCache (Enhancement - P4)

Reviewers

Reviewing

Using git

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

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

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 23573

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

Using diff file

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

Using Webrev

Link to Webrev Comment

@bridgekeeper
Copy link

bridgekeeper bot commented Feb 11, 2025

👋 Welcome back chadrako! 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 Feb 11, 2025

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

8316694: Implement relocation of nmethod within CodeCache

Reviewed-by: kvn, eosterlund, never, eastigeevich, bulasevich

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 2 new commits pushed to the master branch:

  • e6868c6: 8369138: New test compiler/loopstripmining/MissingStoreAfterOuterStripMinedLoop.java fails
  • 837f634: 8369128: ProblemList jdk/jfr/event/profiling/TestCPUTimeSampleQueueAutoSizes.java in Xcomp configs

Please see this link for an up-to-date comparison between the source branch of this pull request and 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.

As you do not have Committer status in this project an existing Committer must agree to sponsor your change. Possible candidates are the reviewers of this PR (@vnkozlov, @fisk, @tkrodriguez, @eastig, @bulasevich) but any other Committer may sponsor as well.

➡️ To flag this PR as ready for integration with the above commit message, type /integrate in a new comment. (Afterwards, your sponsor types /sponsor in a new comment to perform the integration).

@openjdk
Copy link

openjdk bot commented Feb 11, 2025

@chadrako The following label will be automatically applied to this pull request:

  • hotspot

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

@chadrako chadrako changed the title 8316694: Implement creation of nmethods from nmethods 8316694: Implement relocation of nmethod within CodeCache Feb 25, 2025
Copy link
Member

@eastig eastig left a comment

Choose a reason for hiding this comment

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

lgtm

@vnkozlov
Copy link
Contributor

@vnkozlov Can you take a look at the change when you have a chance. Thanks :)

I will look on it this week and do new testing.

@vnkozlov
Copy link
Contributor

vnkozlov commented Oct 2, 2025

Update looks good. I submitted new testing.

Copy link
Contributor

@vnkozlov vnkozlov left a comment

Choose a reason for hiding this comment

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

My testing for v46 passed.

@openjdk openjdk bot added the merge-conflict Pull request has merge conflict with target branch label Oct 2, 2025
@openjdk openjdk bot removed the merge-conflict Pull request has merge conflict with target branch label Oct 3, 2025
@chadrako
Copy link
Contributor Author

chadrako commented Oct 3, 2025

@vnkozlov There was a minor merge conflict due to JDK-8366461 if you could re-review (hopefully for the last time)

Copy link
Contributor

@vnkozlov vnkozlov left a comment

Choose a reason for hiding this comment

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

Re-approved.

@openjdk openjdk bot added the ready Pull request is ready to be integrated label Oct 3, 2025
@chadrako
Copy link
Contributor Author

chadrako commented Oct 3, 2025

/integrate

@openjdk openjdk bot added the sponsor Pull request is ready to be sponsored label Oct 3, 2025
@openjdk
Copy link

openjdk bot commented Oct 3, 2025

@chadrako
Your change (at version 104661c) is now ready to be sponsored by a Committer.

@eastig
Copy link
Member

eastig commented Oct 4, 2025

/sponsor

@openjdk
Copy link

openjdk bot commented Oct 4, 2025

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

openjdk bot commented Oct 4, 2025

@eastig @chadrako Pushed as commit f740cd2.

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

@vnkozlov
Copy link
Contributor

vnkozlov commented Oct 5, 2025

@chadrako we hit failures in tier 3 testing. I will file bug.

@vnkozlov
Copy link
Contributor

vnkozlov commented Oct 5, 2025

@vnkozlov
Copy link
Contributor

vnkozlov commented Oct 5, 2025

@vnkozlov
Copy link
Contributor

vnkozlov commented Oct 5, 2025

@vnkozlov
Copy link
Contributor

vnkozlov commented Oct 5, 2025

Looks like when I tested changes I did not include new tests (forgot git add for them)

@vnkozlov
Copy link
Contributor

vnkozlov commented Oct 5, 2025

@vnkozlov
Copy link
Contributor

vnkozlov commented Oct 5, 2025

I problem listing new tests which fail: #27634

@TheRealMDoerr
Copy link
Contributor

We also see assertions on PPC64 in the new test DeoptimizeRelocatedNMethod:

#  Internal Error (jdk/src/hotspot/cpu/ppc/nativeInst_ppc.cpp:405)
#  assert(!decode(i1, i2)) failed: already patched

Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)
V  [libjvm.so+0x1701784]  NativePostCallNop::patch(int, int)+0xf4  (nativeInst_ppc.cpp:405)
V  [libjvm.so+0x1718414]  nmethod::finalize_relocations()+0x6f4  (nmethod.cpp:2059)
V  [libjvm.so+0x171891c]  nmethod::post_init()+0x5c  (nmethod.cpp:1252)
V  [libjvm.so+0x171a8dc]  nmethod::relocate(CodeBlobType)+0x1ec  (nmethod.cpp:1515)
V  [libjvm.so+0x200b598]  WB_RelocateNMethodFromMethod+0x388  (whitebox.cpp:1653)
j  jdk.test.whitebox.WhiteBox.relocateNMethodFromMethod0(Ljava/lang/reflect/Executable;I)V+0
j  jdk.test.whitebox.WhiteBox.relocateNMethodFromMethod(Ljava/lang/reflect/Executable;I)V+8
j  compiler.whitebox.DeoptimizeRelocatedNMethod.main([Ljava/lang/String;)V+50

@reinrich: I assume this assertion is no longer valid.

@reinrich
Copy link
Member

reinrich commented Oct 6, 2025

We also see assertions on PPC64 in the new test DeoptimizeRelocatedNMethod:

#  Internal Error (jdk/src/hotspot/cpu/ppc/nativeInst_ppc.cpp:405)
#  assert(!decode(i1, i2)) failed: already patched

Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)
V  [libjvm.so+0x1701784]  NativePostCallNop::patch(int, int)+0xf4  (nativeInst_ppc.cpp:405)
V  [libjvm.so+0x1718414]  nmethod::finalize_relocations()+0x6f4  (nmethod.cpp:2059)
V  [libjvm.so+0x171891c]  nmethod::post_init()+0x5c  (nmethod.cpp:1252)
V  [libjvm.so+0x171a8dc]  nmethod::relocate(CodeBlobType)+0x1ec  (nmethod.cpp:1515)
V  [libjvm.so+0x200b598]  WB_RelocateNMethodFromMethod+0x388  (whitebox.cpp:1653)
j  jdk.test.whitebox.WhiteBox.relocateNMethodFromMethod0(Ljava/lang/reflect/Executable;I)V+0
j  jdk.test.whitebox.WhiteBox.relocateNMethodFromMethod(Ljava/lang/reflect/Executable;I)V+8
j  compiler.whitebox.DeoptimizeRelocatedNMethod.main([Ljava/lang/String;)V+50

@reinrich: I assume this assertion is no longer valid.

Yeah, I reckon it needs to be adapted/removed. Would be nice, though, if we could keep it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
hotspot-compiler [email protected] integrated Pull request has been integrated
Development

Successfully merging this pull request may close these issues.