RFR: 8330685: ZGC: share barrier spilling logic [v2]
Fei Yang
fyang at openjdk.org
Mon Apr 29 02:10:12 UTC 2024
On Fri, 26 Apr 2024 13:34:20 GMT, Roberto Castañeda Lozano <rcastanedalo at openjdk.org> wrote:
>> This changeset generalizes the logic to detect, represent, spill, and restore live registers around runtime calls in ZGC C2 barriers so that it can be shared by different collectors (including G1 in the near future, see [JEP 475](https://openjdk.org/jeps/475)).
>>
>> The main changes are:
>>
>> - Create GC-agnostic `BarrierStubC2` and `BarrierSetC2State` classes from which `ZBarrierStubC2` and `ZBarrierSetC2State` derive. In order to make `BarrierSetC2State` GC-agnostic, define a virtual function `bool BarrierSetC2State::needs_liveness_data(const MachNode* mach)` that every derived class can instantiate to specify whether liveness data should be computed for a given C2 node (`mach`).
>>
>> - Move the late register liveness computation function `void ZBarrierSetC2::compute_liveness_at_stubs()` to its parent class `BarrierSetC2`.
>>
>> - For platforms that support ZGC (x64, aarch64, riscv, ppc), make ZGC's spill and restore logic (`ZSaveLiveRegisters` class and supporting functions in `ZBarrierSetAssembler`) GC-agnostic by moving it into the corresponding `BarrierSetAssembler` file (e.g. from `src/hotspot/cpu/aarch64/gc/z/zBarrierSetAssembler_aarch64.cpp` to `src/hotspot/cpu/aarch64/gc/shared/barrierSetAssembler_aarch64.(h|c)pp`), and replacing all references to `ZBarrierStubC2` with its parent class `BarrierStubC2`.
>>
>> - For platforms that do not support ZGC (x86, arm, s390), define a minimal, unimplemented `BarrierSetAssembler::refine_register` function. This definition is expected by the GC-agnostic `BarrierSetC2::compute_liveness_at_stubs()` function, but it is currently never executed by these platforms since they do not support any late barrier expansion collector yet.
>>
>> #### Testing
>>
>> - tier1-5 (windows-x64, linux-x64, linux-aarch64, macosx-x64, macosx-aarch64; release and debug mode).
>> - tier1-7 (windows-x64, linux-x64, linux-aarch64, macosx-x64, macosx-aarch64; release and debug mode; ZGC tests only) with [an additional patch](https://github.com/openjdk/jdk/commit/68b924be2b84c7cb96e55a870b47952464ad96f3) that exercises the spilling and restoring logic by forcing ZGC read barriers to always take the slow path and clearing all general-purpose save-on-call registers upon the slow path's runtime call.
>> - build with `make hotspot` (linux-riscv64-debug, linux-ppc64le-debug, linux-x86-debug, linux-arm32-debug, linux-s390x-debug). @RealFYang, @TheRealMDoerr: could you please test the changeset on riscv and ppc? Thanks!
>
> Roberto Castañeda Lozano has updated the pull request incrementally with one additional commit since the last revision:
>
> Put back ZGC-specific trampoline stub state into ZBarrierSetC2State
Test good on linux-riscv64 platform too. LGTM. Thanks.
-------------
Marked as reviewed by fyang (Reviewer).
PR Review: https://git.openjdk.org/jdk/pull/18967#pullrequestreview-2027479205
More information about the hotspot-compiler-dev
mailing list