RFR 8158039 VarHandle float/double field/array access should support CAS/set/add atomics

Martin Buchholz martinrb at google.com
Thu Jun 2 17:56:12 UTC 2016


I don't see any way that AtomicDouble could get into trouble with
floating point weirdness.
Users cannot provide arbitrary long bit patterns; they have to provide
an actual java double.
It encapsulates the existing advice of transforming double to long.

I suppose someone could do

atomicDouble.CAS(NaN, 1)
and fail because we're storing a DIFFERENT NaN, but we have little sympathy.
It's possible to collapse all the NaNs into the One True NaN on input,
but I don't recommend it.


On Thu, Jun 2, 2016 at 8:29 AM, Paul Sandoz <paul.sandoz at oracle.com> wrote:
>
>> On 2 Jun 2016, at 14:41, Martin Buchholz <martinrb at google.com> wrote:
>>
>> You can find an AtomicDouble in jsr166 CVS
>> http://gee.cs.oswego.edu/cgi-bin/viewcvs.cgi/jsr166/src/jsr166e/extra/AtomicDouble.java?view=markup
>> and in guava
>> https://github.com/google/guava/blob/master/guava/src/com/google/common/util/concurrent/AtomicDouble.java
>>
>> I'm still in favor of putting it in openjdk.
>>
>
> Thanks, that is helpful.
>
> What pushed me over the edge in favour was the support for sub-word CAS. The float/double types are lonely and want to join the club as fully signed up members :-)
>
> I will produce another patch with fixes and better docs.
>
> Thanks,
> Paul.


More information about the jdk9-dev mailing list