Re: JavaMemoryModel: Question about the semantics of volatile

From: Bill Pugh (pugh@cs.umd.edu)
Date: Wed Mar 17 2004 - 15:44:30 EST


On Mar 17, 2004, at 3:31 PM, Evan Ireland wrote:

> Bill,
>
> Perhaps I am missing something, but the weak interpretation doesn't
> look
> safe.
>
> If under the weak interpretation the compiler can eliminate the
> volatile
> reads, what constraint prevents applying that optimization to the
> extreme
> that each thread could keep a cache of all volatiles it has written to,
> (i.e.
> mapping from addresses to values written) such that upon encountering a
> volatile read the previously written value could be looked up in the
> cache?
>

A compiler could only eliminate a volatile read if it could prove that
the previous sync action (e.g., volatile access, synchronization) in
that
thread was a write to that volatile variable.

Bill

-------------------------------
JavaMemoryModel mailing list - http://www.cs.umd.edu/~pugh/java/memoryModel



This archive was generated by hypermail 2b29 : Thu Oct 13 2005 - 07:01:00 EDT