RFR: 8315131: Clarify VarHandle set/get access on 32-bit platforms [v3]
Raffaello Giulietti
rgiulietti at openjdk.org
Wed Jul 16 09:31:41 UTC 2025
On Fri, 11 Jul 2025 19:02:31 GMT, Chen Liang <liach at openjdk.org> wrote:
>> On 32 bit platforms, when an access to long/double is aligned, it is supported but not atomic. The original wording in `MethodHandles::byteBufferViewVarHandle` sounds as if it is not supported at all. We can fix that by borrowing the improved specification from `MemoryLayout::varHandle`.
>>
>> Note: This doc is copied from https://github.com/openjdk/jdk/blob/ee0d309bbd33302d8c6f35155e975db77aaea785/src/java.base/share/classes/java/lang/foreign/MemoryLayout.java#L279-L282 with slight adjustments. See the rendering at https://docs.oracle.com/en/java/javase/24/docs/api/java.base/java/lang/foreign/MemoryLayout.html#access-mode-restrictions
>
> Chen Liang has updated the pull request incrementally with one additional commit since the last revision:
>
> "may be non-atomic"
src/java.base/share/classes/java/lang/foreign/MemoryLayout.java line 281:
> 279: * <li>read write access modes for all {@code T}. On 32-bit platforms, access modes
> 280: * {@code get} and {@code set} for {@code long}, {@code double} and {@code MemorySegment}
> 281: * are supported but may be non-atomic, as described in Section {@jls 17.7}
Suggestion:
* are supported but may be non-atomic in the sense of Section {@jls 17.7}
A useful taxonomy has atomic _read-modify-write_ operations (atomic updates, numeric atomic updates, bitwise atomic updates, like CASes, etc.), and atomic _access_ operations, that is, atomic loads and stores (atomic reads and writes).
But the reference to the JLS section here should clarify what is meant in this specific context, namely access operation, not read-modify-write operations.
src/java.base/share/classes/java/lang/invoke/MethodHandles.java line 4310:
> 4308: * <li>read write access modes for all {@code T}. On 32-bit platforms,
> 4309: * access modes {@code get} and {@code set} for {@code long}, {@code
> 4310: * double} are supported but may be non-atomic, as described in Section
Suggestion:
* double} are supported but may be non-atomic in the sense of Section
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/26258#discussion_r2209793287
PR Review Comment: https://git.openjdk.org/jdk/pull/26258#discussion_r2209793415
More information about the core-libs-dev
mailing list