On Mon, 5 May 2025 13:41:22 GMT, Per Minborg <pminb...@openjdk.org> wrote:

> This sketch shows how "Stable Updaters" can be used to create stable 
> computations of `@Stable` fields. Only one updater is needed per class, 
> similar to `AtomicIntegerFieldUpdater`.

src/java.base/share/classes/jdk/internal/lang/stable/StableFieldUpdater.java 
line 214:

> 212:             }
> 213:             Objects.requireNonNull(underlying);
> 214:             return new StableLongFieldUpdater<>(holderType, offset, 
> underlying, zeroReplacement);

This should probably construct `TearingStableLongFieldUpdater` on 32‑bit 
platforms:
Suggestion:

            if (Architecture.is64bit()) {
                // We are also relying on the fact that the VM will not place 
64-bit
                // instance fields that can cross cache lines.
                return new StableLongFieldUpdater<>(holderType, offset, 
underlying, zeroReplacement);
            } else {
                return new TearingStableLongFieldUpdater<>(holderType, offset, 
underlying, zeroReplacement);
            }

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

PR Review Comment: https://git.openjdk.org/jdk/pull/25040#discussion_r2075572314

Reply via email to