[jmm-dev] The JSR-133 Cookbook and final fields

Hans Boehm boehm at acm.org
Tue Nov 22 05:21:16 UTC 2016

I think in general the intent is that ordering constraints associated with
operations on thread-local objects should be safe to eliminate. Clearly
explicit fences do not have the same property. I think that it is be OK to
remove constructor fences associated with objects whose final fields are
not accessed by another thread. Clearly an explicit fence in a constructor
is entirely different. Just as fences that would otherwise be associated
with thread-local volatiles or monitors can be removed, but explicit fences
can at best be combined, as Doug suggests.

On Mon, Nov 21, 2016 at 7:50 AM, Doug Lea <dl at cs.oswego.edu> wrote:

> On 11/21/2016 10:32 AM, Andrew Haley wrote:
> We're working on this right now in Graal.  If an object does not
>> escape, is it legitimate to remove the StoreStore fence as well?  I
> See the cookbook section "Removing barriers" that covers
> some of these cases. (http://gee.cs.oswego.edu/dl/jmm/cookbook.html)
> In general, don't just "remove" fences, instead move-and-merge them:
> move them until they hit another that absorbs them (the same or
> stronger).  In many but not all cases, this does have the same effect
> as just removing them.
> -Doug

More information about the jmm-dev mailing list