At 8:24 AM +1000 5/26/00, David Holmes wrote:
> > This does not work. According to both the existing specification, and
>> proposed new specifications, the write to singletons[i] can be moved
>> inside the synchronized block.
>It can? I am surprised in the sense that I view memory barriers as implicit
>code motion barriers and so, unless the compiler/JIT can be 100% certain
>that what it is doing is correct it should not move code across
Under the existing semantics, monitorenter and monitorexit act only
as one-way barriers, not full memory barriers. This is, in fact, the
In particular, it is legal to reorder a load/store and a following
monitorenter, and it is legal to reorder a monitorexit and a
following load/store. (In other words, you can move stuff from
outside a synchronized block inside the block, but you can't move
stuff from inside to outside.
Changing the semantics to allow for removal of "useless"
synchronization will make it even weaker than that.
JavaMemoryModel mailing list - http://www.cs.umd.edu/~pugh/java/memoryModel
This archive was generated by hypermail 2b29 : Thu Oct 13 2005 - 07:00:25 EDT