Re: JavaMemoryModel: correct synchronization

From: Jeremy Manson (jmanson@cs.umd.edu)
Date: Mon Feb 23 2004 - 00:32:21 EST


> I wrote:
> > > AFAIK code motion across sync blocks is prohibited.
>
> Jeremy Manson replied:
> > We don't make such general statements about code motion because they have
> > holes in them. So, you can, for example, move code across thread-local
> > synchronization blocks.
>
> Jeremy: given that thread-local sync is by definition a no-op and hence can
> be removed, I would hope that this is the *only* case where this can occur.
> In which case I for one, would really like to see this property (albeit a
> derived one) of the JMM clearly stated. If not please give another example.

We aim to please: it is stated on p19 of the public review draft, in
Section 6.6. :)

I should point out that it is only by definition a no-op because the spec
defines it that way.

Nevertheless, a couple of other examples spring to mind, depending on how
broadly you define "thread-local" and "code motion". Reentrant locks can
be eliminated. You can also merge adjacent lock regions. I believe (not
sure) that we mention both of these things as well.

                                        Jeremy

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



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