RFR: 8357267: ZGC: Handle APX EGPRs spilling in ZRuntimeCallSpill

Jatin Bhateja jbhateja at openjdk.org
Mon May 26 12:03:56 UTC 2025


On Fri, 23 May 2025 13:53:23 GMT, Roberto Castañeda Lozano <rcastanedalo at openjdk.org> wrote:

> > > > Patch has been verified using Intel SDE all test under test/hotspot/jtreg/compiler/gcbarriers are green.
> > > 
> > > 
> > > Have you checked that these tests exercise `ZRuntimeCallSpill` significantly? Most tests in that directory seem to exercise C2's generated ZGC barriers, which use other spilling/restoring logic across runtime calls (`SaveLiveRegisters`). Also, I expect the register pressure in these test cases to be minimal, so it could be good to randomize register assignment to improve the testing effectiveness. Finally, `ZRuntimeCallSpill` is typically used in slow paths, which are rarely exercised in short-lived test cases. Have you considered altering the users of `ZRuntimeCallSpill` so that they are forced to always, or at least more often, enter the slow path, for testing purposes? [This PR](https://github.com/openjdk/jdk/pull/18967) did something similar in the context of C2 ZGC barriers.
> > 
> > 
> > Intel SDE allows us to collect execution traces with _-itrace_execute_emulate_ and we found quite a lot of register save/ restorations around native method, there is already an existing test point for it https://github.com/openjdk/jdk/blob/master/test/hotspot/jtreg/compiler/gcbarriers/UnsafeIntrinsicsTest.java
> 
> OK, thanks for checking Jatin!
> 
> Have you also checked whether, at least in some of the cases, some of the APX EGPRs are live across the runtime call (i.e. are defined before the call and used after the call), and whether the called runtime routine typically clobbers these registers? Knowing that this case is exercised in the test runs would be good to be confident about the correctness of the patch.

Hi @robcasloz, 
The patch uses new push2/pop2 instructions, which reduces dynamic instruction count needed to save and restore all the caller-saved registers.  New instruction sequence based on push2/pop2 not only saves EGPRs but also existing GPRs with shorter JIT sequence. We verified our fix using the following standalone gtest with the Intel Software Development Emulator.

[test_ZRuntimeCallSpill_cpp.txt](https://github.com/user-attachments/files/20440415/test_ZRuntimeCallSpill_cpp.txt)

Given that gtests is a build-time validation and the JVM itself is built with with minimum feature set, hence am hesitant to add this along with the patch.  BTW, ZRuntimeCallSpill is called as part of the slow path barrier for native methods, which can modify EGPRs.

Let me know if you think it's good to land in.

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

PR Comment: https://git.openjdk.org/jdk/pull/25351#issuecomment-2909487712


More information about the hotspot-dev mailing list