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

C2: anti dependence missed because store hidden by membar

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P2 P2
    • 9
    • 9
    • hotspot
    • b156
    • Not verified

        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.

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

                Created:
                Updated:
                Resolved: