Value types and access atomicity

Aleksey Shipilev shade at
Wed May 26 08:45:19 UTC 2021

On 5/25/21 7:27 PM, Aleksey Shipilev wrote:
> On 5/25/21 6:14 PM, Paul Sandoz wrote:
>> What you observe is the proposed default behavior, with the following to enable atomicity: - mark
>> the field as volatile (dunno if the implementation currently supports this); and
> Right. Adding "volatile" indeed restores the access atomicity, like it should for longs/doules.
>> VHs will require some spec/impl adjustment. Atomic VH access to a plain field of non-atomic
>> primitive class is gonna be problematic (fail? or global lock, yuck!).
> Yes. I would expect that doing VH.getOpaque over primitive-class-typed field gives me atomicity
> back. It would be sad to sacrifice nearly the only guarantee that opaque mode actually provides...

Seems like VH.{get|set}Opaque over (long,long) primitive class already "works" to regain access 
atomicity, but only because Unsafe.{get|set}ValueVolatile does the global lock. Yuck.


More information about the valhalla-dev mailing list