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

Tobias Hartmann thartmann at openjdk.org
Fri Dec 19 09:44:53 UTC 2025


On Fri, 19 Dec 2025 07:56:27 GMT, Marc Chevalier <mchevalier at openjdk.org> wrote:

> That's the x86 counterpart of [JDK-8371993](https://bugs.openjdk.org/browse/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:
> 
> https://github.com/openjdk/valhalla/blob/3c41c2aa442076827cb4480373a1d481e481cdf1/src/hotspot/cpu/x86/frame_x86.hpp#L61-L62
> 
> 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	0x00000...

Nice comments! The changes look good to me.

-------------

Marked as reviewed by thartmann (Committer).

PR Review: https://git.openjdk.org/valhalla/pull/1839#pullrequestreview-3597794053


More information about the valhalla-dev mailing list