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

Andrew Haley aph at redhat.com
Tue Jul 12 10:22:35 UTC 2016


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?  And where foes the spec say that VarHandle.{get,set}Opaque is
atomic?

Andrew.



More information about the jmm-dev mailing list