RFR(M): 8209420: Track membars for volatile accesses so they can be properly optimized
Andrew Dinn
adinn at redhat.com
Mon Aug 13 16:20:16 UTC 2018
Hi Roland,
On 13/08/18 15:38, Roland Westrelin wrote:
> http://cr.openjdk.java.net/~roland/8209420/webrev.00/
In general, this looks good, far clearer and much less fragile than the
deleted AArch64 code.
However, I'm rather confused by the logic of the changes in
StoreNode::Identify in memnode.cpp.
The trailing and leading membars are removed along with their associated
store when:
1) the store saves a value that was just loaded from the same address
2) the store repeats a directly preceding store to the same address
3) the store writes zero to a newly allocated (hence zero) object
(and ReduceFieldZeroing is set)
4) the store rewrites zero write to the same address as a still visible
prior store
(and ReduceFieldZeroing is set)
This looks fine when dealing with stores to non-volatile fields but I
don't follow how it works when writing to volatile fields.
I can see that removal would be fine on the assumption that both stores
are volatile -- after removing the later store and its barriers the
earlier one should still be bracketed by memory barriers. However, I am
not sure the code detects that situation correctly. If the earlier store
was also a volatile store then would there not be a membar between it
and the later store in the memory chain? Well, actually two membars, the
trailing (volatile) membar of the earlier store and the leading
(release) membar of the subsequent store.
On the other hand if there is no intervening membar then would that not
mean that both the earlier and later stores are not a volatile store?
If we somehow had a case where the earlier store had no membars and the
later one did then removing the membars would mean that the relevant
release semantics would not be guaranteed? Only, I don't think this case
will happen either because the leading membar for this store ought to
precede it in the memory ordering.
What am I missing here?
regards,
Andrew Dinn
-----------
Senior Principal Software Engineer
Red Hat UK Ltd
Registered in England and Wales under Company Registration No. 03798903
Directors: Michael Cunningham, Michael ("Mike") O'Neill, Eric Shander
More information about the hotspot-compiler-dev
mailing list