On Mon, 8 Dec 2025 18:45:04 GMT, Aleksey Shipilev <[email protected]> wrote:

> 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

This pull request has now been integrated.

Changeset: 88c8a55a
Author:    Aleksey Shipilev <[email protected]>
URL:       
https://git.openjdk.org/jdk/commit/88c8a55a4337a857ac17ffff068f730f67cf5763
Stats:     99 lines in 15 files changed: 35 ins; 25 del; 39 mod

8373266: Strengthen constant CardTable base accesses

Reviewed-by: tschatzl, xpeng

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

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

Reply via email to