Skip to content

Conversation

@marc-chevalier
Copy link
Member

@marc-chevalier marc-chevalier commented Dec 19, 2025

That's the x86 counterpart of JDK-8371993.

I've added some comments, using the offsets given in frame_x86.hpp to make sure to put the frame start at the right place. In particular, the frame start is 2 pointer sizes under the sender's sp:

// non-interpreter frames
sender_sp_offset = 2,

Unlike aarch64, with x64 we have only one copy of rbp. As with aarch64, I had to get rid of an assert that can't be checked anymore. A small price to pay.

Now, in debug, instead of

pop    r13
sub    rsp,0x20
push   r13

we have

pop    r13
sub    rsp,0x20
mov    DWORD PTR [rsp-0x4],0xdeadda7a
mov    DWORD PTR [rsp-0x8],0xdeadda7a
sub    rsp,0x8

I've kept the pop r13 to limit the difference of behavior between debug and product builds: both will overwrite r13 with the return address, whether it's a good idea or not.

And at runtime, on my favorite compiler/valhalla/inlinetypes/CorrectlyRestoreRfp.java example, instead of the stack:

0x7fd7345fe660:	0x000000042724f5d0	0x00007fd7345fe750  <-- rsp
0x7fd7345fe670:	0xffffffffffffffff	0x00007fd740acc0f7
0x7fd7345fe680:	0x00007fd700000000	0x000000042724f5d0
0x7fd7345fe690:	0x000000056f517f28	0x00007fd7390002a6
0x7fd7345fe6a0:	0x00007fd72c90c8b3	0x0000000000000078  <--             #                | sp_inc
0x7fd7345fe6b0:	0x00007fd7345fe750	0x00007fd740541306  <-- rsp - 0x50  #            rbp | return address
0x7fd7345fe6c0:	0x000000056f49f4e0	0x000000042724f5d0  <--             #  String (arg2) | Object (arg3)
0x7fd7345fe6d0:	0x0000000000000000	0x00007fd740541306  <-- rsp - 0x70  # boolean (arg4) | return address
0x7fd7345fe6e0:	0x00007fd740541306	0x0000000000000000
0x7fd7345fe6f0:	0x000000042724f5d0	0x000000056f49f4e0

we have

0x7f93cfdfe660:	0x000000042724f5d0	0x00007f93cfdfe750  <-- rsp
0x7f93cfdfe670:	0xffffffffffffffff	0x00007f93e4acc107
0x7f93cfdfe680:	0x00007f9300000000	0x000000042724f5d0
0x7f93cfdfe690:	0x000000056f517fb0	0x00007f93dd0002a6
0x7f93cfdfe6a0:	0x00007f93d090c8b3	0x0000000000000078  <--             #                | sp_inc
0x7f93cfdfe6b0:	0x00007f93cfdfe750	0xdeadda7adeadda7a  <-- rsp - 0x50  #            rbp | >>>> bad word <<<<
0x7f93cfdfe6c0:	0x000000056f49f540	0x000000042724f5d0  <--             #  String (arg2) | Object (arg3)
0x7f93cfdfe6d0:	0x0000000000000000	0x00007f93e4541306  <-- rsp - 0x70  # boolean (arg4) | return address
0x7f93cfdfe6e0:	0x00007f93e4541306	0x0000000000000000
0x7f93cfdfe6f0:	0x000000042724f5d0	0x000000056f49f540

I had to problem list some virtual thread tests, in the same fashion as for aarch64, as it used the wrong return address. The assert I had to remove was a sign that only one of the return address is updated in case of deopt, so only one of them is reliable. To help with that, I've added frame::compiled_frame_details like for aarch64, that makes sure to do all the fixing internally.

Thanks,
Marc


Progress

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

Issue

  • JDK-8372806: [lworld] x64: save bad values instead of rfp and lr above the extension space (Enhancement - P4)

Reviewers

Reviewing

Using git

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

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

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 1839

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

Using diff file

Download this PR as a diff file:
https://git.openjdk.org/valhalla/pull/1839.diff

Using Webrev

Link to Webrev Comment

@bridgekeeper
Copy link

bridgekeeper bot commented Dec 19, 2025

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

@marc-chevalier marc-chevalier marked this pull request as ready for review December 19, 2025 07:59
@openjdk
Copy link

openjdk bot commented Dec 19, 2025

@marc-chevalier 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:

8372806: [lworld] x64: save bad values instead of rfp and lr above the extension space

Reviewed-by: thartmann

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 84 new commits pushed to the lworld 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 lworld branch, type /integrate in a new comment.

@openjdk openjdk bot added the rfr Pull request is ready for review label Dec 19, 2025
@mlbridge
Copy link

mlbridge bot commented Dec 19, 2025

Webrevs

Copy link
Member

@TobiHartmann TobiHartmann left a comment

Choose a reason for hiding this comment

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

Nice comments! The changes look good to me.

@openjdk openjdk bot added the ready Pull request is ready to be integrated label Dec 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready Pull request is ready to be integrated rfr Pull request is ready for review

Development

Successfully merging this pull request may close these issues.

2 participants