RFR: 8376531: Genshen: Missing volatile modifier on multiple fields of ShenandoahOldGeneration

William Kemper wkemper at openjdk.org
Tue Jan 27 23:38:05 UTC 2026


On Tue, 27 Jan 2026 22:19:15 GMT, Xiaolong Peng <xpeng at openjdk.org> wrote:

> Came across the source code of ShenandoahOldGeneration, and noticed that we use AtomicAccess to read/write to fields `_promoted_expended`, `_promotion_failure_count`, `_promotion_failure_words` but non of them is declared with volatile modifier.
> 
> Given that OpenJDK has introduced `Atomic<T>` to replace the idiom of volatile var plus AtomicAccess:: operations(see details [here](https://bugs.openjdk.org/browse/JDK-8367013), I decided to convert these fields to `Atomic<T>` instead of adding `volatile`.
> 
> ### Test
> - [x] hotshpot_gc_shenandoah
> - [ ] GHA

Changes requested by wkemper (Reviewer).

src/hotspot/share/gc/shenandoah/shenandoahOldGeneration.cpp line 585:

> 583: 
> 584: void ShenandoahOldGeneration::handle_failed_promotion(Thread* thread, size_t size) {
> 585:   _promotion_failure_count.add_then_fetch(static_cast<size_t>(1));

Can this be `1UL` instead of `static_cast<size_t>(1)`?

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

PR Review: https://git.openjdk.org/jdk/pull/29456#pullrequestreview-3713954434
PR Review Comment: https://git.openjdk.org/jdk/pull/29456#discussion_r2734254725


More information about the hotspot-gc-dev mailing list