JDK-8172145 : C2: anti dependence missed because store hidden by membar
  • Type: Bug
  • Component: hotspot
  • Sub-Component: compiler
  • Affected Version: 9
  • Priority: P2
  • Status: Closed
  • Resolution: Fixed
  • Submitted: 2016-12-30
  • Updated: 2017-11-29
  • Resolved: 2017-01-03
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 10 JDK 8 JDK 9
10Fixed 8u152Fixed 9 b156Fixed
Related Reports
Relates :  
C2 compiler has generated incorrect code on PPC64 for the following method:

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.

Regression test: Run api/javax_swing/plaf/basic JCK tests with -Xcomp on PPC64.