jdk icon indicating copy to clipboard operation
jdk copied to clipboard

8373266: Strengthen constant CardTable base accesses

Open shipilev opened this issue 1 month ago • 5 comments

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

Progress

  • [ ] Change must be properly reviewed (1 review required, with at least 1 Reviewer)
  • [x] Change must not contain extraneous whitespace
  • [x] Commit message must refer to an issue

Issue

  • JDK-8373266: Strengthen constant CardTable base accesses (Enhancement - P4)

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/28703/head:pull/28703
$ git checkout pull/28703

Update a local copy of the PR:
$ git checkout pull/28703
$ git pull https://git.openjdk.org/jdk.git pull/28703/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 28703

View PR using the GUI difftool:
$ git pr show -t 28703

Using diff file

Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/28703.diff

Using Webrev

Link to Webrev Comment

shipilev avatar Dec 08 '25 18:12 shipilev

:wave: Welcome back shade! A progress list of the required criteria for merging this PR into master will be added to the body of your pull request. There are additional pull request commands available for use with this pull request.

bridgekeeper[bot] avatar Dec 08 '25 18:12 bridgekeeper[bot]

❗ This change is not yet ready to be integrated. See the Progress checklist in the description for automated requirements.

openjdk[bot] avatar Dec 08 '25 18:12 openjdk[bot]

@shipilev The following labels will be automatically applied to this pull request:

  • hotspot
  • shenandoah

When this pull request is ready to be reviewed, an "RFR" email will be sent to the corresponding mailing lists. If you would like to change these labels, use the /label pull request command.

openjdk[bot] avatar Dec 08 '25 18:12 openjdk[bot]

Webrevs

mlbridge[bot] avatar Dec 10 '25 19:12 mlbridge[bot]

all tests are passing with various GC combinations as well. Ready for review.

shipilev avatar Dec 15 '25 10:12 shipilev