[jmm-dev] Make load/store of 64-bit long and double atomic

Aleksey Shipilev aleksey.shipilev at oracle.com
Tue Jul 12 11:30:51 UTC 2016


On 07/12/2016 01:22 PM, Andrew Haley wrote:
> On 12/07/16 11:19, Aleksey Shipilev wrote:
>> On 07/12/2016 01:13 PM, Andrew Haley wrote:
>>> I wonder if a better solution to this might be to make
>>> VarHandle.{get,set}Opaque atomic on all primitive types.  This gives
>>> us a way to get atomic operations on 32-bit machines without the
>>> overhead of volatile accesses.  Being able to read a 64-bit counter
>>> atomically is very useful.
>>
>> VarHandle.{get,set}Opaque is single-copy atomic for all primitive types.
>> Pretty much like C++ std::atomic(..., mem_ord_relaxed).
> 
> So what does
> 
> Unless stated otherwise in the documentation of a factory method, the
> access modes get and set (if supported) provide atomic access for
> reference types and all primitives types, with the exception of long
> and double on 32-bit platforms.
> 
> refer to? 

That's for VarHandle.{get|set}, not for VarHandle.{get|set}Opaque.
Access mode "get" is different from access mode "getOpaque".

> And where foes the spec say that VarHandle.{get,set}Opaque is
> atomic?

Nowhere yet. I tried to capture atomicity in Javadoc like this:
 http://mail.openjdk.java.net/pipermail/jmm-dev/2016-June/000282.html

...but it's not yet there.

Thanks,
-Aleksey





More information about the jmm-dev mailing list