Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8087341

C2 doesn't optimize redundant memory operations with G1

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Fixed
    • Icon: P4 P4
    • 9
    • None
    • hotspot
    • None
    • b110

      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.

            roland Roland Westrelin
            roland Roland Westrelin
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: