In a nutshell, here’s a proposal for value type atomicity:

- Define a contextual keyword “alwaysatomic" (working title “__AlwaysAtomic”).
- It can only occur with “inline” in class declaration.
- All instances of the given inline class are protected against races.
- Protection is “as if” each field were volatile, “and the same” for array 
elements.
- In the class file the ACC_VOLATILE bit is used (0x0040) to record the keyword.
- This bit does not necessarily disable flattening; if the JVM can get away 
with flattening it should.
- The JVM can get away with flattening such values on stack, in registers, and 
perhaps in final heap variables.
- The JVM can get away with flattening such values if they are “naturally 
atomic”, meaning they can be wholly loaded or stored in one (atomic) hardware 
instruction.

More details to follow.  Here’s a backgrounder I wrote a while ago:

http://cr.openjdk.java.net/~jrose/oblog/value-tearing.html

— John

Reply via email to