Integrated: 8330685: ZGC: share barrier spilling logic

Roberto Castañeda Lozano rcastanedalo at openjdk.org
Mon Apr 29 08:45:15 UTC 2024


On Fri, 26 Apr 2024 08:12:46 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!

This pull request has now been integrated.

Changeset: 549bc6a0
Author:    Roberto Castañeda Lozano <rcastanedalo at openjdk.org>
URL:       https://git.openjdk.org/jdk/commit/549bc6a0398906df3cc08679c751eb0c633ef0be
Stats:     1915 lines in 26 files changed: 1061 ins; 838 del; 16 mod

8330685: ZGC: share barrier spilling logic

Reviewed-by: eosterlund, mdoerr, fyang, aboldtch

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

PR: https://git.openjdk.org/jdk/pull/18967


More information about the hotspot-compiler-dev mailing list