RFR: 8330685: ZGC: share barrier spilling logic [v2]

Roberto Castañeda Lozano rcastanedalo at openjdk.org
Fri Apr 26 13:34:20 UTC 2024


> 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

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

Changes:
  - all: https://git.openjdk.org/jdk/pull/18967/files
  - new: https://git.openjdk.org/jdk/pull/18967/files/17fc99df..7132780f

Webrevs:
 - full: https://webrevs.openjdk.org/?repo=jdk&pr=18967&range=01
 - incr: https://webrevs.openjdk.org/?repo=jdk&pr=18967&range=00-01

  Stats: 45 lines in 2 files changed: 21 ins; 22 del; 2 mod
  Patch: https://git.openjdk.org/jdk/pull/18967.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/18967/head:pull/18967

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


More information about the hotspot-compiler-dev mailing list