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

Andrew Dinn adinn at redhat.com
Thu Jan 28 14:30:35 UTC 2016


Hi Roland,

On 28/01/16 12:49, Roland Westrelin wrote:
> http://cr.openjdk.java.net/~roland/8087341/webrev.00/
> 
> C2 currently doesn’t optimize the field load in the following code:
> 
> static Object field;
> 
> static Object m(Object o) { field = o; return field; }
> 
> It should return o but instead loads the value back from memory. The
> reason it misses such simple optimization is that the G1 post barrier
> has a memory barrier with a wide effect on the memory state. C2
> doesn’t optimize this either:
> 
>     object.field = other_object;
>     object.field = other_object;
> 
> Same applies to -XX:+UseConcMarkSweepGC -XX:+UseCondCardMark
> 
> That memory barrier was added to have a memory barrier instruction
> and doesn’t have to have a wide memory effect.

I think this looks ok -- not sure until I try it out. However, I /am/
fairly sure it is going to cause a problem for the AArch64 code which
optimizes volatile loads and stores. That's because it change the
characteristic shape of the subgraph searched for by the predicates
which decide whether to i) generate loads + membars or ii) plant stlr or
ladr instructions.

I'll look into this asap.

regards,


Andrew Dinn
-----------
Senior Principal Software Engineer
Red Hat UK Ltd
Registered in UK and Wales under Company Registration No. 3798903
Directors: Michael Cunningham (US), Michael O'Neill (Ireland), Paul
Argiry (US)


More information about the hotspot-compiler-dev mailing list