-
Enhancement
-
Resolution: Fixed
-
P4
-
17, 21, 22
-
b21
Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-8325389 | 21.0.3 | Aleksey Shipilev | P4 | Resolved | Fixed | b03 |
64-bit Atomic::cmpxchg is implemented on almost all platforms, though, which means we can write the fallback implementations for 64-bit add and xchg using 64-bit cmpxchg. When 64-bit cmpchg is not available, we can do what Access API does: take a lock.
This would simplify future development.
The caveat with such delegation would be giving up on wait-freedom that hardware implementations for xadd/xchg implicitly have. Implementing xadd/xchg with CAS loops makes them lock-free, but not wait-free. Implementing them with locks makes them not lock-free. This might not be a problem in practice.
Existing code in this area:
1. Fallback implementations for e.g. Unsafe::getAndAdd and Unsafe::getAndSet already do fallback CAS loops: https://github.com/openjdk/jdk/blob/1f7dfda7059f9dc14bff61b3c77d769ade85557d/src/java.base/share/classes/jdk/internal/misc/Unsafe.java#L2471-L2507
2. Access API takes a lock: https://github.com/openjdk/jdk/blob/1f7dfda7059f9dc14bff61b3c77d769ade85557d/src/hotspot/share/oops/accessBackend.inline.hpp#L217-L253
A draft version for Atomic::add and CAS loops looks like this:
https://github.com/openjdk/jdk/compare/master...shipilev:wip-32bit-add
- backported by
-
JDK-8325389 Fallback implementations for 64-bit Atomic::{add,xchg} on 32-bit platforms
- Resolved
- is blocked by
-
JDK-8320052 Zero: Use __atomic built-ins for atomic RMW operations
- Resolved
- relates to
-
JDK-8320052 Zero: Use __atomic built-ins for atomic RMW operations
- Resolved
-
JDK-8320050 Zero: Build failures due to duplicate definition of __sync_val_compare_and_swap_8
- Closed
-
JDK-8318776 Require supports_cx8 to always be true
- Resolved
- links to
-
Commit openjdk/jdk21u-dev/4d62dfa3
-
Commit openjdk/jdk/ba7d08b8
-
Review openjdk/jdk21u-dev/233
-
Review openjdk/jdk/16252