RFR: 8315131: Clarify VarHandle set/get access on 32-bit platforms [v3]
Chen Liang
liach at openjdk.org
Wed Jul 16 03:47:47 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"
I think @mcimadamore and @JornVernee still disagree with this - they think "atomic" can mean a CAS operation as a whole is atomic, or an individual memory access (read, write) in the CAS is. This atomicity here is lacking for the individual memory access, which is the weaker form of atomicity.
On another look, I think another way to address this problem could be to move this "potential lack of atomicity in memory access" to "get" and "set" themselves - which also applies to unaligned access and other var handles. Then, for aligned access through VH, the VH just specify it implements all access modes and upholds all atomicity guarantees of those modes (with respect to other threads)
-------------
PR Comment: https://git.openjdk.org/jdk/pull/26258#issuecomment-3076627776
More information about the core-libs-dev
mailing list