RFR: 8377048: Shenandoah: shenandoahLock related improvments

Xiaolong Peng xpeng at openjdk.org
Tue Feb 3 16:59:49 UTC 2026


While I was working on https://bugs.openjdk.org/browse/JDK-8373371, I made these changes to the shenandoahLock, but I feel it make sense peel off these changes into a separate PR as they are not really related to JDK-8373371. 

Major thing in this PR is to use template for ShenandoahReentrantLock and ShenandoahLocker so we could get rid of duplicate code, along with some other changes where the locks are used e.g. use type alias for ShenandoahNMethodLock and ShenandoahNMethodLocker, use ShenandoahReentrantLock for ShenandoahRebuildLock.

Another improvement is to strengthen assert in SheandnoahHeapLocker to avoid potential dead lock(this was also discussed in previous PR [here](https://github.com/openjdk/jdk/pull/27612#discussion_r2479898169) and our internal channel

### Test
- [x] MacOS aach64, server fastdebug: hotspot_gc_shenandoah
- [x] GHA

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

Commit messages:
 - Merge branch 'openjdk:master' into shenandoah-heap-lock-asserts
 - Def type ShenandoahRebuildLock as ShenandoahReentrantLock<ShenandoahLock>
 - Revert name change of ShenandoahRebuildLock for the PR(it will be in next pr after this)
 - Rename ShenandoahRebuildLock to ShenandoahHeapUsageAccountingLock
 - Use ShenandoahReentrantLock<ShenandoahLock> as ShenandoahRebuildLock to simplify code
 - ShenandoahHeapLocker should assert if current thread is holding free-set rebuild lock
 - Use template to impl ShenandoahReentrantLock and ShenandoahLocker

Changes: https://git.openjdk.org/jdk/pull/29543/files
  Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=29543&range=00
  Issue: https://bugs.openjdk.org/browse/JDK-8377048
  Stats: 136 lines in 15 files changed: 38 ins; 34 del; 64 mod
  Patch: https://git.openjdk.org/jdk/pull/29543.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/29543/head:pull/29543

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


More information about the shenandoah-dev mailing list