dl at cs.oswego.edu
Mon Oct 15 08:22:37 EDT 2012
On 10/15/12 05:38, Romain Colle wrote:
> Out of curiosity, do you mean that a call to Unsafe.getXXVolatile() does also
> issue a LoadLoad barrier before its read?
> Are there any reasons why this is the case, in addition to the post-read fence
> of a regular volatile read?
First, I'll echo Aleksey's plea for others to please not use this.
The effects rely on an undocumented property of an internal JVM
method that cannot even be formally spec'ed under the current JMM.
We hope to have a better solution by JDK8 release.
But for the curious: Because Unsafe.getXXVolatile does not know if
its argument is even declared as a volatile, in the absence
of magically powerful global analyses, it must conservatively
prevent reorderings in either direction. And at least in
OpenJDK hotspot, the implementation is aware of this fact and
More information about the Concurrency-interest