RFR(S): 8087341: C2 doesn't optimize redundant memory operations with G1

Andrew Haley aph at redhat.com
Tue Feb 2 17:03:43 UTC 2016


On 02/02/2016 02:55 PM, Mikael Gerdin wrote:
> The barrier can only be removed if the object is never allocated.
> If the object is allocated and the field store is performed then the 
> barrier must be preserved, even if the compiler can prove that no 
> application thread can see the objects, a concurrent gc thread may still 
> see these objects.

This reminds me of the discussion at http://mail.openjdk.java.net/pipermail/hotspot-compiler-dev/2015-December/020345.html

It removes the memory barrier after object creation if the object does
not escape.  I guess this is not safe, then, because a concurrent GC
will see a partially-constructed object: the fields may not have been
zeroed and the  header may not have been initialized.

I'd like your opinion on this.

Thanks,

Andrew.


More information about the hotspot-compiler-dev mailing list