RFR: 8373266: Strengthen constant CardTable base accesses [v3]

Aleksey Shipilev shade at openjdk.org
Wed Jan 21 16:41:35 UTC 2026


> Shenandoah and G1 are using CardTable for most of its infrastructure, but flip the card tables as they go, and maintain the actual card table reference in TLS. As such, accessing card table base from assembler and compilers runs into risk of accidentally encoding the wrong card table base in generated code. 
> 
> Most of the current code avoids this trouble by carefully implementing their GC barriers to avoid touching shared parts where card table base constness is assumed. _Except_ for JVMCI, that reads the card table base for G1 barrier set, and that is wrong. The JVMCI users would need to rectify this downstream.
> 
> Shenandoah added a few asserts to catch these errors:
>  SHENANDOAHGC_ONLY(assert(!UseShenandoahGC, "Shenandoah byte_map_base is not constant.");)
> 
> ...but G1 would also benefit from the similar safety mechanism.
> 
> This PR strengthens the code to prevent future accidents.
> 
> Additional testing:
>  - [x] Linux x86_64 server fastdebug, `hotspot_gc`
>  - [x] Linux x86_64 server fastdebug, `all` with Serial, Parallel, G1, Shenandoah, Z
>  - [x] Linux AArch64 server fastdebug, `all` with Serial, Parallel, G1, Shenandoah, Z
>  - [x] GHA, cross-compilation only

Aleksey Shipilev has updated the pull request with a new target base due to a merge or a rebase. The incremental webrev excludes the unrelated changes brought in by the merge/rebase. The pull request contains 223 additional commits since the last revision:

 - Merge branch 'master' into JDK-8373266-cardtable-asserts
 - Some polishing
 - 8375544: JfrSet::clear should not use memset
   
   Reviewed-by: mgronlun
 - 8374998: Failing os::write - remove bad file
   
   Reviewed-by: mdoerr, lucy
 - 8375498: [VectorAPI] Dump primary vector IR details with -XX:+TraceNewVectors
   
   Reviewed-by: epeter
 - 8375717: Outdated link in jdk.jfr.internal.JVM javadoc
   
   Reviewed-by: egahlin
 - 8238686: G1 may waste lots of space or fail to uncommit when observing MinHeapFreeRatio during sizing after full gc
   
   Reviewed-by: tschatzl, sjohanss
 - 8375622: G1: Convert G1CodeRootSet to use Atomic<T>
   
   Reviewed-by: shade, sjohanss
 - 8375787: compiler/vectorapi/TestCastShapeBadOpc.java fails with release VMs
   
   Reviewed-by: syan, lmesnik, fyang, epeter
 - 8375738: Fix -Wzero-as-null-pointer-constant warnings in MacOSX/bsd code
   
   Reviewed-by: erikj, dholmes
 - ... and 213 more: https://git.openjdk.org/jdk/compare/98c1f2a9...79dca36a

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

Changes:
  - all: https://git.openjdk.org/jdk/pull/28703/files
  - new: https://git.openjdk.org/jdk/pull/28703/files/040a84d7..79dca36a

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

  Stats: 65746 lines in 1352 files changed: 34023 ins; 12037 del; 19686 mod
  Patch: https://git.openjdk.org/jdk/pull/28703.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/28703/head:pull/28703

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


More information about the hotspot-dev mailing list