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

Vladimir Kozlov vladimir.kozlov at oracle.com
Thu Jan 28 23:45:12 UTC 2016


G1 barrier was added by Mikael Gerdin from GC. He should also look on this change.

https://bugs.openjdk.java.net/browse/JDK-8014555

Also we have specialized insert_mem_bar_volatile() if we don't want wide memory affect. Why not use it?
And we need to keep precedent edge link to oop store in case EA eliminates related allocation.

Thanks,
Vladimir

On 1/28/16 4:49 AM, 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.
>
> Roland.
>



More information about the hotspot-gc-dev mailing list