Ensuring atomicity of long values

- liangchenblue at gmail.com
Sat Oct 21 06:37:19 UTC 2023


Hello valhalla community,
While looking at the new non-atomic model that allows flattening in the
heap, I wonder if we can represent null-restricted 64-bit atomic data where
the most and the least significant bits shouldn't tear.

An example would be a modifier collection, where some modifier bits are
dependent on others, while 0 (the default) is a valid value. One such
dependency present in JDK itself is that ABSTRACT modifier must be set if
INTERFACE modifier is, and at most one of PUBLIC, PRIVATE, or PROTECTED
modifiers can be set. Such constraints can happen across the 32-bit
boundary, and thus primitive long is not a suitable choice for
its non-atomicity.

How should I declare a value class that ensures atomicity of the
null-restricted long value it contains? And how can a correct declaration
consistently benefit from the 64-bit atomic operations offered on modern
architectures?

Truly curious,
Chen Liang
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/valhalla-dev/attachments/20231021/b8bf3233/attachment.htm>


More information about the valhalla-dev mailing list