RE: JavaMemoryModel: Another litmus test for strong vs. weak volatiles

From: David Holmes (dholmes@dltech.com.au)
Date: Fri Mar 26 2004 - 19:45:31 EST


Bill Pugh wrote:
> 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,
> synchronization
> 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
> synchronization block).
>
> There are not transformations that are explicitly allowed by the memory
> model.Rather, you can use the memory model to show that they are not
> detectable, in that they do not allow any additional behaviors.

Okay. I'll leave the formalities to others, but informally, once we allow
for the removal of thread-local volatiles and thread-local sync then the
"roach motel" rules are exact/complete. ie if my code contains no
thread-local volatiles or thread-local sync then I CAN explain the behaviour
in terms of the "barriers" (memory AND code-motion) inherent in the "roach
motel" rules. Right?

David Holmes

-------------------------------
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