This java code:
object.field = other_object;
object.field = other_object;
should be optimized by c2 as:
object.field = other_object;
but it's not with G1 enabled because GraphKit::g1_write_barrier_post() has:
// Use Op_MemBarVolatile to achieve the effect of a StoreLoad barrier.
insert_mem_bar(Op_MemBarVolatile, oop_store);
which confuses StoreNode::Ideal()
With the membar above commented out, the redundant store is optimized out but it seems we leave the pre/post barrier for the second store in.
The membar seems too coarse grain as all is required is that store load between the write to a field and the load from the card table.
object.field = other_object;
object.field = other_object;
should be optimized by c2 as:
object.field = other_object;
but it's not with G1 enabled because GraphKit::g1_write_barrier_post() has:
// Use Op_MemBarVolatile to achieve the effect of a StoreLoad barrier.
insert_mem_bar(Op_MemBarVolatile, oop_store);
which confuses StoreNode::Ideal()
With the membar above commented out, the redundant store is optimized out but it seems we leave the pre/post barrier for the second store in.
The membar seems too coarse grain as all is required is that store load between the write to a field and the load from the card table.
- relates to
-
JDK-8173195 [BACKOUT] 8087341: C2 doesn't optimize redundant memory operations with G1
-
- Closed
-
-
JDK-8173196 [REDO] C2 does not optimize redundant memory operations with G1
-
- Resolved
-
-
JDK-8172850 Anti-dependency on membar causes crash in register allocator due to invalid instruction scheduling
-
- Closed
-