RFR: 8145680: Remove unnecessary explicit initialization of volatile variables in java.base

Aleksey Shipilev aleksey.shipilev at oracle.com
Mon Dec 21 13:33:01 UTC 2015


On 12/19/2015 04:07 PM, Claes Redestad wrote:
> When meticulously going through and checking each usage for odd pattern
> like this I accidentally did a bit of extra cleanup, mostly addressing a
> number of cases where the volatile field was being read twice. Sorry!
> 
> Bug: https://bugs.openjdk.java.net/browse/JDK-8145680
> 
> Webrev: http://cr.openjdk.java.net/~redestad/8145680/webrev.01/

Looks good.

> Note: when the parent bug was filed back in 2008 there was some
> internal discussion about improving javac and/or the compiler to
> elide these stores. That apparently led nowhere due to difficulty in
> detecting various corner cases, and then the actual cleanup was
> forgotten. Let's not go there this time, shall we?

I agree with this sentiment; but we should also try to not to penalize
assigning default values, if done for code clarity reasons. I'll submit
a few HotSpot compiler RFEs for that.


Thanks,
-Aleksey




More information about the core-libs-dev mailing list