JDK-8209835 : Aarch64: elide barriers on all volatile operations
  • Type: Enhancement
  • Component: hotspot
  • Sub-Component: compiler
  • Affected Version: 11,12
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • CPU: aarch64
  • Submitted: 2018-08-22
  • Updated: 2021-02-01
  • Resolved: 2018-11-05
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 11 JDK 12 Other
11.0.6Fixed 12 b19Fixed openjdk8u292Fixed
Related Reports
Relates :  
Description
Andrew Haley said:

I notice that this works for simple volatile access, but it does not
 work for read-modify write operations such as, say,
 VarHandle.getAndAdd(), where the barrier instructions are not elided:

  ;; membar_release
   0x000003ffa8b049b8: dmb	ish
   0x000003ffa8b049bc: add	x10, x19, #0xc
   0x000003ffa8b049c0: ldxr	wscratch2, [x10]
   0x000003ffa8b049c4: add	wscratch1, wscratch2, #0x1
   0x000003ffa8b049c8: stxr	wscratch2, wscratch1, [x10]
   0x000003ffa8b049cc: cbnz	wscratch2, 0x000003ffa8b049c0
   0x000003ffa8b049d0: sub	w10, wscratch1, #0x1
  ;; membar_acquire
   0x000003ffa8b049d4: dmb	ishld                       ;*invokevirtual getAndAddInt {reexecute=0 rethrow=0 return_oop=0}
                                                             ; - java.lang.invoke.VarHandleInts$FieldInstanceReadWrite::getAndAdd@19 (line 206)
                                                             ; - java.lang.invoke.VarHandleGuards::guard_LI_I@33 (line 129)
                                                             ; - Sync::run@42 (line 35)

 I think we need to be consistent about how we handle these operations.
Comments
Fix Request 11u What: Original patch does not apply to jdk11u cleanly, tweaks needed for three newly added tests. (Review thread: https://mail.openjdk.java.net/pipermail/jdk-updates-dev/2019-August/001740.html) Why: Currently, we used ldar & stlr pair for CompareAndSwap operations on aarch64 C2. This is not the case for read-modify write operations such as GetAndSet operations, for which normal ld/st + dmb instruction are used. This difference may manifest itself as runtime bugs on aarch64 weakly ordered platforms. We need to be consistent for read-modify write operations. Testing: Passed tier1 on aarch64. Newly added JTreg tests succeed with aarch64 fastdebug build. Passed jcstress test with aarch64 release build. Risk: Low
23-08-2019