On Mar 25, 2004, at 4:47 PM, David Holmes wrote:
> Bill Pugh wrote:
>> "Roach motel semantics" are only an approximation to the semantics of
>> synchronization and volatiles.
>> Roach motel semantics guarantee that you can
>> * move non-volatile memory accesses into a synchronized block,
>> * reorder a non-volatile memory access and a following volatile read
>> * reorder a volatile write and a following non-volatile access
>> Roach motel semantics do _not_ say you may never reorder:
>> * a non-volatile memory access out of a synchronized block
>> * reorder a non-volatile memory access and a following volatile write
>> * reorder a volatile read and a following non-volatile access
> Roach motel was always expressed as "you can move in but you can't move
> out". You've now stated that you can move out. That makes no sense to
> me as
> essentially you are now allowing the accesses being synchronized to be
> out of the code that causes the synchronization! That would be broken.
> The reason you couldn't move out was because of the happens before
> that the synchronization actions established.
> Well you've now totally lost me. ???
> David Holmes
Remember the golden rule of compiler optimizations:
If you can't be caught, it isn't illegal.
For example, you are allowed to reorder memory accesses and accesses to
a thread local volatile. Similarly, if an object is thread local,
on that object is a no-op and reads and writes can be freely moved out
of the synchronization block (or you can just remove the
There are not transformations that are explicitly allowed by the memory
Rather, you can use the memory model to show that they are not
that they do not allow any additional behaviors.
JavaMemoryModel mailing list - http://www.cs.umd.edu/~pugh/java/memoryModel
This archive was generated by hypermail 2b29 : Thu Oct 13 2005 - 07:01:01 EDT