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

C2: anti dependence missed because store hidden by membar

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P2
    • Resolution: Fixed
    • Affects Version/s: 9
    • Fix Version/s: 9
    • Component/s: hotspot
    • Labels:
    • Subcomponent:
    • Resolved In Build:
      b156
    • Verification:
      Not verified

      Backports

        Description

        C2 compiler has generated incorrect code on PPC64 for the following method:
        java/awt/Component.setBackground(Ljava/awt/Color;)V

        It starts with the following accesses:
         Color oldColor = background; // oop load from field "background"
         ComponentPeer peer = this.peer; // volatile load from other field
         background = c; // oop store to field "background"

        Note that we use support_IRIW_for_not_multiple_copy_atomic_cpu = true on PPC64 which has the effect, that the volatile load is preceded by a MemBarVolatile.
        That's why the mach graph looks like this after matching (simplified, only showing memory dependencies):

        1: MachProj Memory

        2: loadN2P_unscaled(1) // oldColor = background

        3: membar_volatile(1)
        4: MachProj(3)
        5: loadN_ac(4) // peer = this.peer
        6: unnecessary_membar_acquire(4)
        7: MachProj(6)

        8: storeN(7) // background = c

        PhaseCFG::insert_anti_dependences must find an anti-dependence between 8 and 2 in order to schedule the load correctly.
        Because insert_anti_dependences does not follow memory edges behind membars, this does not happen and the load gets executed after the store and hence returns the already overwritten value.

        The code contains a comment "Wide MemBar's are anti-dependent on everything (except immutable memories).", but a check for this case is missing.
        The membar's adr_type is NULL so can_alias returns false and reordering is not prevented.

          Attachments

            Issue Links

              Activity

                People

                • Assignee:
                  mdoerr Martin Doerr
                  Reporter:
                  mdoerr Martin Doerr
                • Votes:
                  0 Vote for this issue
                  Watchers:
                  2 Start watching this issue

                  Dates

                  • Created:
                    Updated:
                    Resolved: