RFR(S): 8087341: C2 doesn't optimize redundant memory operations with G1
Roland Westrelin
roland.westrelin at oracle.com
Thu Jan 28 12:49:38 UTC 2016
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.
Roland.
More information about the hotspot-compiler-dev
mailing list