dl at cs.oswego.edu
Tue Oct 16 16:27:31 EDT 2012
On 10/15/12 23:21, Boehm, Hans wrote:
>> 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.
> I still don't understand the reasoning here. Do you have an example where it
> matters whether the argument is declared as volatile? I'm assuming the
> writing side must still use a corresponding (or volatile) access?
Yes, but a compiler could otherwise lose track of compiler reordering
constraints. Imagine the read inside a loop, so that non-volatile
reordering might mean moving out/up. The only reasonable path is to
treat it as non-reorderable all the way through. In any case
(reasonable or not :-) this is what they do.
More information about the Concurrency-interest