diff --git a/jdk/src/java.base/share/classes/java/util/concurrent/CompletableFuture.java b/jdk/src/java.base/share/classes/java/util/concurrent/CompletableFuture.java index b3fb80dcd37..31b6924cb63 100644 --- a/jdk/src/java.base/share/classes/java/util/concurrent/CompletableFuture.java +++ b/jdk/src/java.base/share/classes/java/util/concurrent/CompletableFuture.java @@ -480,7 +480,7 @@ public class CompletableFuture implements Future, CompletionStage { } static void lazySetNext(Completion c, Completion next) { - U.putOrderedObject(c, NEXT, next); + U.putObjectRelease(c, NEXT, next); } /** diff --git a/jdk/src/java.base/share/classes/java/util/concurrent/ConcurrentLinkedDeque.java b/jdk/src/java.base/share/classes/java/util/concurrent/ConcurrentLinkedDeque.java index 4f8fdd92c49..9b23efa6157 100644 --- a/jdk/src/java.base/share/classes/java/util/concurrent/ConcurrentLinkedDeque.java +++ b/jdk/src/java.base/share/classes/java/util/concurrent/ConcurrentLinkedDeque.java @@ -309,7 +309,7 @@ public class ConcurrentLinkedDeque } void lazySetNext(Node val) { - U.putOrderedObject(this, NEXT, val); + U.putObjectRelease(this, NEXT, val); } boolean casNext(Node cmp, Node val) { @@ -317,7 +317,7 @@ public class ConcurrentLinkedDeque } void lazySetPrev(Node val) { - U.putOrderedObject(this, PREV, val); + U.putObjectRelease(this, PREV, val); } boolean casPrev(Node cmp, Node val) { diff --git a/jdk/src/java.base/share/classes/java/util/concurrent/ConcurrentLinkedQueue.java b/jdk/src/java.base/share/classes/java/util/concurrent/ConcurrentLinkedQueue.java index d302b6f55b8..ba4ee87f335 100644 --- a/jdk/src/java.base/share/classes/java/util/concurrent/ConcurrentLinkedQueue.java +++ b/jdk/src/java.base/share/classes/java/util/concurrent/ConcurrentLinkedQueue.java @@ -198,7 +198,7 @@ public class ConcurrentLinkedQueue extends AbstractQueue } static void lazySetNext(Node node, Node val) { - U.putOrderedObject(node, NEXT, val); + U.putObjectRelease(node, NEXT, val); } static boolean casNext(Node node, Node cmp, Node val) { diff --git a/jdk/src/java.base/share/classes/java/util/concurrent/Exchanger.java b/jdk/src/java.base/share/classes/java/util/concurrent/Exchanger.java index 3f5ce5e371d..069d6e0f871 100644 --- a/jdk/src/java.base/share/classes/java/util/concurrent/Exchanger.java +++ b/jdk/src/java.base/share/classes/java/util/concurrent/Exchanger.java @@ -239,7 +239,7 @@ public class Exchanger { * not to be as readily inlined by dynamic compilers when they are * hidden behind other methods that would more nicely name and * encapsulate the intended effects). This includes the use of - * putOrderedX to clear fields of the per-thread Nodes between + * putXRelease to clear fields of the per-thread Nodes between * uses. Note that field Node.item is not declared as volatile * even though it is read by releasing threads, because they only * do so after CAS operations that must precede access, and all @@ -376,7 +376,7 @@ public class Exchanger { for (int h = p.hash, spins = SPINS;;) { Object v = p.match; if (v != null) { - U.putOrderedObject(p, MATCH, null); + U.putObjectRelease(p, MATCH, null); p.item = null; // clear for next use p.hash = h; return v; @@ -507,7 +507,7 @@ public class Exchanger { break; } } - U.putOrderedObject(p, MATCH, null); + U.putObjectRelease(p, MATCH, null); p.item = null; p.hash = h; return v; diff --git a/jdk/src/java.base/share/classes/java/util/concurrent/ForkJoinPool.java b/jdk/src/java.base/share/classes/java/util/concurrent/ForkJoinPool.java index 3a7c0ab4eb8..bcb6d59fcad 100644 --- a/jdk/src/java.base/share/classes/java/util/concurrent/ForkJoinPool.java +++ b/jdk/src/java.base/share/classes/java/util/concurrent/ForkJoinPool.java @@ -289,7 +289,7 @@ public class ForkJoinPool extends AbstractExecutorService { * on to try or create other queues -- they block only when * creating and registering new queues. Because it is used only as * a spinlock, unlocking requires only a "releasing" store (using - * putOrderedInt). The qlock is also used during termination + * putIntRelease). The qlock is also used during termination * detection, in which case it is forced to a negative * non-lockable value. * @@ -1071,7 +1071,7 @@ public class ForkJoinPool extends AbstractExecutorService { popped = true; top = s; } - U.putOrderedInt(this, QLOCK, 0); + U.putIntRelease(this, QLOCK, 0); } } return popped; @@ -1261,7 +1261,7 @@ public class ForkJoinPool extends AbstractExecutorService { popped = true; top = s - 1; } - U.putOrderedInt(this, QLOCK, 0); + U.putIntRelease(this, QLOCK, 0); if (popped) return t; } diff --git a/jdk/src/java.base/share/classes/java/util/concurrent/ForkJoinWorkerThread.java b/jdk/src/java.base/share/classes/java/util/concurrent/ForkJoinWorkerThread.java index 54d8931de4f..9629e83bd3b 100644 --- a/jdk/src/java.base/share/classes/java/util/concurrent/ForkJoinWorkerThread.java +++ b/jdk/src/java.base/share/classes/java/util/concurrent/ForkJoinWorkerThread.java @@ -92,7 +92,7 @@ public class ForkJoinWorkerThread extends Thread { ForkJoinWorkerThread(ForkJoinPool pool, ThreadGroup threadGroup, AccessControlContext acc) { super(threadGroup, null, "aForkJoinWorkerThread"); - U.putOrderedObject(this, INHERITEDACCESSCONTROLCONTEXT, acc); + U.putObjectRelease(this, INHERITEDACCESSCONTROLCONTEXT, acc); eraseThreadLocals(); // clear before registering this.pool = pool; this.workQueue = pool.registerWorker(this); diff --git a/jdk/src/java.base/share/classes/java/util/concurrent/FutureTask.java b/jdk/src/java.base/share/classes/java/util/concurrent/FutureTask.java index 27943fd7cb6..aade083ffe3 100644 --- a/jdk/src/java.base/share/classes/java/util/concurrent/FutureTask.java +++ b/jdk/src/java.base/share/classes/java/util/concurrent/FutureTask.java @@ -174,7 +174,7 @@ public class FutureTask implements RunnableFuture { if (t != null) t.interrupt(); } finally { // final state - U.putOrderedInt(this, STATE, INTERRUPTED); + U.putIntRelease(this, STATE, INTERRUPTED); } } } finally { @@ -230,7 +230,7 @@ public class FutureTask implements RunnableFuture { protected void set(V v) { if (U.compareAndSwapInt(this, STATE, NEW, COMPLETING)) { outcome = v; - U.putOrderedInt(this, STATE, NORMAL); // final state + U.putIntRelease(this, STATE, NORMAL); // final state finishCompletion(); } } @@ -248,7 +248,7 @@ public class FutureTask implements RunnableFuture { protected void setException(Throwable t) { if (U.compareAndSwapInt(this, STATE, NEW, COMPLETING)) { outcome = t; - U.putOrderedInt(this, STATE, EXCEPTIONAL); // final state + U.putIntRelease(this, STATE, EXCEPTIONAL); // final state finishCompletion(); } } diff --git a/jdk/src/java.base/share/classes/java/util/concurrent/SubmissionPublisher.java b/jdk/src/java.base/share/classes/java/util/concurrent/SubmissionPublisher.java index d3c4518a3b6..0e84bf4e050 100644 --- a/jdk/src/java.base/share/classes/java/util/concurrent/SubmissionPublisher.java +++ b/jdk/src/java.base/share/classes/java/util/concurrent/SubmissionPublisher.java @@ -1496,7 +1496,7 @@ public class SubmissionPublisher implements Flow.Publisher, else if (((c & CONSUME) != 0 || U.compareAndSwapInt(this, CTL, c, c | CONSUME)) && U.compareAndSwapObject(a, i, x, null)) { - U.putOrderedInt(this, HEAD, ++h); + U.putIntRelease(this, HEAD, ++h); U.getAndAddLong(this, DEMAND, -1L); if ((w = waiter) != null) signalWaiter(w); diff --git a/jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicBoolean.java b/jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicBoolean.java index 01fc1c2c0d7..5241392ed92 100644 --- a/jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicBoolean.java +++ b/jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicBoolean.java @@ -136,7 +136,7 @@ public class AtomicBoolean implements java.io.Serializable { * @since 1.6 */ public final void lazySet(boolean newValue) { - U.putOrderedInt(this, VALUE, (newValue ? 1 : 0)); + U.putIntRelease(this, VALUE, (newValue ? 1 : 0)); } /** diff --git a/jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicInteger.java b/jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicInteger.java index 96e13f60ed8..920b45bd5ab 100644 --- a/jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicInteger.java +++ b/jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicInteger.java @@ -108,7 +108,7 @@ public class AtomicInteger extends Number implements java.io.Serializable { * @since 1.6 */ public final void lazySet(int newValue) { - U.putOrderedInt(this, VALUE, newValue); + U.putIntRelease(this, VALUE, newValue); } /** diff --git a/jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicIntegerArray.java b/jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicIntegerArray.java index f3a262b65b4..001a35008d9 100644 --- a/jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicIntegerArray.java +++ b/jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicIntegerArray.java @@ -136,7 +136,7 @@ public class AtomicIntegerArray implements java.io.Serializable { * @since 1.6 */ public final void lazySet(int i, int newValue) { - U.putOrderedInt(array, checkedByteOffset(i), newValue); + U.putIntRelease(array, checkedByteOffset(i), newValue); } /** diff --git a/jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicIntegerFieldUpdater.java b/jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicIntegerFieldUpdater.java index d14454228f8..09b372dc822 100644 --- a/jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicIntegerFieldUpdater.java +++ b/jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicIntegerFieldUpdater.java @@ -475,7 +475,7 @@ public abstract class AtomicIntegerFieldUpdater { public final void lazySet(T obj, int newValue) { accessCheck(obj); - U.putOrderedInt(obj, offset, newValue); + U.putIntRelease(obj, offset, newValue); } public final int get(T obj) { diff --git a/jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicLong.java b/jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicLong.java index 2af5d1dd07f..85ff9030da3 100644 --- a/jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicLong.java +++ b/jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicLong.java @@ -124,7 +124,7 @@ public class AtomicLong extends Number implements java.io.Serializable { * @since 1.6 */ public final void lazySet(long newValue) { - U.putOrderedLong(this, VALUE, newValue); + U.putLongRelease(this, VALUE, newValue); } /** diff --git a/jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicLongArray.java b/jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicLongArray.java index 58aa1875b19..041e561b2a7 100644 --- a/jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicLongArray.java +++ b/jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicLongArray.java @@ -135,7 +135,7 @@ public class AtomicLongArray implements java.io.Serializable { * @since 1.6 */ public final void lazySet(int i, long newValue) { - U.putOrderedLong(array, checkedByteOffset(i), newValue); + U.putLongRelease(array, checkedByteOffset(i), newValue); } /** diff --git a/jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicLongFieldUpdater.java b/jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicLongFieldUpdater.java index dccca9e15b2..8770b2d962a 100644 --- a/jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicLongFieldUpdater.java +++ b/jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicLongFieldUpdater.java @@ -457,7 +457,7 @@ public abstract class AtomicLongFieldUpdater { public final void lazySet(T obj, long newValue) { accessCheck(obj); - U.putOrderedLong(obj, offset, newValue); + U.putLongRelease(obj, offset, newValue); } public final long get(T obj) { diff --git a/jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicReference.java b/jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicReference.java index 9d4d2a385c7..d0a0b0a90cf 100644 --- a/jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicReference.java +++ b/jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicReference.java @@ -103,7 +103,7 @@ public class AtomicReference implements java.io.Serializable { * @since 1.6 */ public final void lazySet(V newValue) { - U.putOrderedObject(this, VALUE, newValue); + U.putObjectRelease(this, VALUE, newValue); } /** diff --git a/jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicReferenceArray.java b/jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicReferenceArray.java index 03f950d43e0..a2e8b2b7805 100644 --- a/jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicReferenceArray.java +++ b/jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicReferenceArray.java @@ -147,7 +147,7 @@ public class AtomicReferenceArray implements java.io.Serializable { * @since 1.6 */ public final void lazySet(int i, E newValue) { - U.putOrderedObject(array, checkedByteOffset(i), newValue); + U.putObjectRelease(array, checkedByteOffset(i), newValue); } /** diff --git a/jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicReferenceFieldUpdater.java b/jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicReferenceFieldUpdater.java index f9e4989cbbe..b30341f73f9 100644 --- a/jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicReferenceFieldUpdater.java +++ b/jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicReferenceFieldUpdater.java @@ -426,7 +426,7 @@ public abstract class AtomicReferenceFieldUpdater { public final void lazySet(T obj, V newValue) { accessCheck(obj); valueCheck(newValue); - U.putOrderedObject(obj, offset, newValue); + U.putObjectRelease(obj, offset, newValue); } @SuppressWarnings("unchecked") diff --git a/jdk/src/java.base/share/classes/jdk/internal/misc/InnocuousThread.java b/jdk/src/java.base/share/classes/jdk/internal/misc/InnocuousThread.java index 0891f2a125f..a50bc613bd9 100644 --- a/jdk/src/java.base/share/classes/jdk/internal/misc/InnocuousThread.java +++ b/jdk/src/java.base/share/classes/jdk/internal/misc/InnocuousThread.java @@ -57,8 +57,8 @@ public final class InnocuousThread extends Thread { public InnocuousThread(ThreadGroup group, Runnable target, String name) { super(group, target, name, 0L, false); - UNSAFE.putOrderedObject(this, INHERITEDACCESSCONTROLCONTEXT, ACC); - UNSAFE.putOrderedObject(this, CONTEXTCLASSLOADER, ClassLoader.getSystemClassLoader()); + UNSAFE.putObjectRelease(this, INHERITEDACCESSCONTROLCONTEXT, ACC); + UNSAFE.putObjectRelease(this, CONTEXTCLASSLOADER, ClassLoader.getSystemClassLoader()); } @Override diff --git a/jdk/src/java.base/share/classes/jdk/internal/misc/Unsafe.java b/jdk/src/java.base/share/classes/jdk/internal/misc/Unsafe.java index 8b8a0ff9531..beb64fd5155 100644 --- a/jdk/src/java.base/share/classes/jdk/internal/misc/Unsafe.java +++ b/jdk/src/java.base/share/classes/jdk/internal/misc/Unsafe.java @@ -1457,25 +1457,7 @@ public final class Unsafe { @HotSpotIntrinsicCandidate public native void putDoubleVolatile(Object o, long offset, double x); - /** - * Version of {@link #putObjectVolatile(Object, long, Object)} - * that does not guarantee immediate visibility of the store to - * other threads. This method is generally only useful if the - * underlying field is a Java volatile (or if an array cell, one - * that is otherwise only accessed using volatile accesses). - * - * Corresponds to C11 atomic_store_explicit(..., memory_order_release). - */ - @HotSpotIntrinsicCandidate - public native void putOrderedObject(Object o, long offset, Object x); - /** Ordered/Lazy version of {@link #putIntVolatile(Object, long, int)} */ - @HotSpotIntrinsicCandidate - public native void putOrderedInt(Object o, long offset, int x); - - /** Ordered/Lazy version of {@link #putLongVolatile(Object, long, long)} */ - @HotSpotIntrinsicCandidate - public native void putOrderedLong(Object o, long offset, long x); /** Acquire version of {@link #getObjectVolatile(Object, long)} */ @HotSpotIntrinsicCandidate @@ -1531,6 +1513,16 @@ public final class Unsafe { return getDoubleVolatile(o, offset); } + /* + * Versions of {@link #putObjectVolatile(Object, long, Object)} + * that do not guarantee immediate visibility of the store to + * other threads. This method is generally only useful if the + * underlying field is a Java volatile (or if an array cell, one + * that is otherwise only accessed using volatile accesses). + * + * Corresponds to C11 atomic_store_explicit(..., memory_order_release). + */ + /** Release version of {@link #putObjectVolatile(Object, long, Object)} */ @HotSpotIntrinsicCandidate public final void putObjectRelease(Object o, long offset, Object x) { diff --git a/jdk/src/java.base/share/classes/sun/misc/Unsafe.java b/jdk/src/java.base/share/classes/sun/misc/Unsafe.java index 15ba929c32f..c69b66020ab 100644 --- a/jdk/src/java.base/share/classes/sun/misc/Unsafe.java +++ b/jdk/src/java.base/share/classes/sun/misc/Unsafe.java @@ -1068,19 +1068,19 @@ public final class Unsafe { */ @ForceInline public void putOrderedObject(Object o, long offset, Object x) { - theInternalUnsafe.putOrderedObject(o, offset, x); + theInternalUnsafe.putObjectRelease(o, offset, x); } /** Ordered/Lazy version of {@link #putIntVolatile(Object, long, int)} */ @ForceInline public void putOrderedInt(Object o, long offset, int x) { - theInternalUnsafe.putOrderedInt(o, offset, x); + theInternalUnsafe.putIntRelease(o, offset, x); } /** Ordered/Lazy version of {@link #putLongVolatile(Object, long, long)} */ @ForceInline public void putOrderedLong(Object o, long offset, long x) { - theInternalUnsafe.putOrderedLong(o, offset, x); + theInternalUnsafe.putLongRelease(o, offset, x); } /**