JDK-8320052 : Zero: Use __atomic built-ins for atomic RMW operations
  • Type: Bug
  • Component: hotspot
  • Sub-Component: runtime
  • Affected Version: 17,21,22
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2023-11-14
  • Updated: 2024-02-03
  • Resolved: 2023-11-20
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 21 JDK 22
21.0.3Fixed 22 b25Fixed
Related Reports
Blocks :  
Blocks :  
Duplicate :  
Relates :  
Description
GCC defines __sync* built-ins as legacy implementations of atomic support routines, and recommends using __atomic* built-ins in new code:
https://gcc.gnu.org/onlinedocs/gcc/_005f_005fatomic-Builtins.html

The crucial difference between these two families of built-ins is that __atomic* 64-bit CAS is guaranteed to be supported ("The ‘__atomic’ builtins can be used with any integral scalar or pointer type that is 1, 2, 4, or 8 bytes in length"), whereas __sync* 64-bit CAS can be unimplemented. This is important for making sure JDK-8316961 works on all platforms, and allows JDK-8318776 to proceed.

Upstream reports suggest PPC32 is one of the platforms that does not have __sync_val_compare_and_swap_8 implemented. My own testing shows these platforms have the __sync_val_compare_and_swap_8 unimplemented:
    zero-fastdebug-mipsel-linux-gnu-10
    zero-fastdebug-m68k-linux-gnu-10
    zero-fastdebug-powerpc-linux-gnu-10
    zero-fastdebug-sh4-linux-gnu-10

Comments
A pull request was submitted for review. URL: https://git.openjdk.org/jdk21u-dev/pull/227 Date: 2024-01-30 10:13:31 +0000
30-01-2024

[jdk21u-fix-request] Approval Request from Aleksey Shipilëv Clean backport to improve Atomic support in JDK 21, and prepare for JDK-8316961 backport.
30-01-2024

Changeset: 020c9007 Author: Aleksey Shipilev <shade@openjdk.org> Date: 2023-11-20 19:01:20 +0000 URL: https://git.openjdk.org/jdk/commit/020c9007f8e9cc4b46a58d7955284f43a6ac913b
20-11-2023

A pull request was submitted for review. URL: https://git.openjdk.org/jdk/pull/16654 Date: 2023-11-14 10:52:21 +0000
14-11-2023