On Mon, 31 Mar 2025 14:22:16 GMT, Maurizio Cimadamore <[email protected]>
wrote:
>> Per Minborg has updated the pull request incrementally with one additional
>> commit since the last revision:
>>
>> Finish and clean up benchmarks
>
> src/java.base/share/classes/jdk/internal/lang/stable/StableValueImpl.java
> line 161:
>
>> 159:
>> 160: static String renderWrapped(Object t) {
>> 161: return (t == null) ? UNSET_LABEL : Objects.toString(unwrap(t));
>
> If I read correctly, this implementation is similar to what described here:
>
> https://preshing.com/20130930/double-checked-locking-is-fixed-in-cpp11/
>
> (see section `Using C++11 Acquire and Release Fences`).
>
> We don't need the "relaxed" loads in Java because a reference load in Java
> can never tear. Correct?
@mcimadamore That atomic load under the lock is unnecessary because the load
will never be concurrent with any store. I believe `relaxed` has to be used
because C++ lacks the ability to perform atomic operations and non-atomic
operations on the same object until C++ 20 with `std::atomic_ref`.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/23972#discussion_r2021289826