JDK-8217368 : AArch64: C2 recursive stack locking optimisation not triggered
  • Type: Bug
  • Component: hotspot
  • Sub-Component: compiler
  • Affected Version: 8-aarch64,11,12,13
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • CPU: aarch64
  • Submitted: 2019-01-18
  • Updated: 2021-02-01
  • Resolved: 2019-01-24
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 13 Other
11.0.5Fixed 13 b06Fixed openjdk8u292Fixed
Related Reports
Relates :  
Relates :  
Description
While I was cleaning up the patch for 8216350 I noticed an issue in the implementation of recursive locking in aarch64_enc_fast_lock:

First we load the markOop of the object we want to lock and OR it with markOopDesc::unlocked_value (1). Then we do a CAS to exchange the address of the box on our thread's stack with the object's header word iff it's equal to the (markOop | 1) we just computed. If this fails, then we should check for a recursive lock by comparing 

  (~(page size - 1) | 3) & (markOop - SP) == 0

Where "markOop" is the current object header word loaded by the failed CAS. This checks that the lock bits are zero (locked) and the stack address of the displaced header is within one page of the current SP. But on AArch64 we actually do this:

  (~(page size - 1) | 3) & ((old markOop | 1) - SP) == 0

Where "old markOop | 1" is the compare-to value used for the CAS. This is always false as the result has at least bit #0 set. This only affects C2, the c1_MacroAssembler version has the correct test.
Comments
Fix Request What: Backported to JDK11u as two patches. Why: An important optimization is missing without this patch Review Thread: https://mail.openjdk.java.net/pipermail/jdk-updates-dev/2019-August/001734.html Tetsing: tier1 tests pass as before
25-08-2019