changeset 14077:39ddc2279d51

8152698: Remove obsolete Unsafe.putOrdered{X} methods, usages, runtime and compiler support Reviewed-by: kvn, psandoz, dl
author shade
date Fri, 25 Mar 2016 15:35:43 +0300
parents bf47af65820f
children b49e66e98def
files src/java.base/share/classes/java/util/concurrent/CompletableFuture.java src/java.base/share/classes/java/util/concurrent/ConcurrentLinkedDeque.java src/java.base/share/classes/java/util/concurrent/ConcurrentLinkedQueue.java src/java.base/share/classes/java/util/concurrent/Exchanger.java src/java.base/share/classes/java/util/concurrent/ForkJoinPool.java src/java.base/share/classes/java/util/concurrent/ForkJoinWorkerThread.java src/java.base/share/classes/java/util/concurrent/FutureTask.java src/java.base/share/classes/java/util/concurrent/SubmissionPublisher.java src/java.base/share/classes/java/util/concurrent/atomic/AtomicBoolean.java src/java.base/share/classes/java/util/concurrent/atomic/AtomicInteger.java src/java.base/share/classes/java/util/concurrent/atomic/AtomicIntegerArray.java src/java.base/share/classes/java/util/concurrent/atomic/AtomicIntegerFieldUpdater.java src/java.base/share/classes/java/util/concurrent/atomic/AtomicLong.java src/java.base/share/classes/java/util/concurrent/atomic/AtomicLongArray.java src/java.base/share/classes/java/util/concurrent/atomic/AtomicLongFieldUpdater.java src/java.base/share/classes/java/util/concurrent/atomic/AtomicReference.java src/java.base/share/classes/java/util/concurrent/atomic/AtomicReferenceArray.java src/java.base/share/classes/java/util/concurrent/atomic/AtomicReferenceFieldUpdater.java src/java.base/share/classes/jdk/internal/misc/InnocuousThread.java src/java.base/share/classes/jdk/internal/misc/Unsafe.java src/java.base/share/classes/sun/misc/Unsafe.java
diffstat 21 files changed, 40 insertions(+), 48 deletions(-) [+]
line wrap: on
line diff
--- a/src/java.base/share/classes/java/util/concurrent/CompletableFuture.java	Thu Mar 24 16:21:19 2016 +0100
+++ b/src/java.base/share/classes/java/util/concurrent/CompletableFuture.java	Fri Mar 25 15:35:43 2016 +0300
@@ -480,7 +480,7 @@
     }
 
     static void lazySetNext(Completion c, Completion next) {
-        U.putOrderedObject(c, NEXT, next);
+        U.putObjectRelease(c, NEXT, next);
     }
 
     /**
--- a/src/java.base/share/classes/java/util/concurrent/ConcurrentLinkedDeque.java	Thu Mar 24 16:21:19 2016 +0100
+++ b/src/java.base/share/classes/java/util/concurrent/ConcurrentLinkedDeque.java	Fri Mar 25 15:35:43 2016 +0300
@@ -309,7 +309,7 @@
         }
 
         void lazySetNext(Node<E> val) {
-            U.putOrderedObject(this, NEXT, val);
+            U.putObjectRelease(this, NEXT, val);
         }
 
         boolean casNext(Node<E> cmp, Node<E> val) {
@@ -317,7 +317,7 @@
         }
 
         void lazySetPrev(Node<E> val) {
-            U.putOrderedObject(this, PREV, val);
+            U.putObjectRelease(this, PREV, val);
         }
 
         boolean casPrev(Node<E> cmp, Node<E> val) {
--- a/src/java.base/share/classes/java/util/concurrent/ConcurrentLinkedQueue.java	Thu Mar 24 16:21:19 2016 +0100
+++ b/src/java.base/share/classes/java/util/concurrent/ConcurrentLinkedQueue.java	Fri Mar 25 15:35:43 2016 +0300
@@ -198,7 +198,7 @@
     }
 
     static <E> void lazySetNext(Node<E> node, Node<E> val) {
-        U.putOrderedObject(node, NEXT, val);
+        U.putObjectRelease(node, NEXT, val);
     }
 
     static <E> boolean casNext(Node<E> node, Node<E> cmp, Node<E> val) {
--- a/src/java.base/share/classes/java/util/concurrent/Exchanger.java	Thu Mar 24 16:21:19 2016 +0100
+++ b/src/java.base/share/classes/java/util/concurrent/Exchanger.java	Fri Mar 25 15:35:43 2016 +0300
@@ -239,7 +239,7 @@
      * 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 @@
                     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 @@
                 break;
             }
         }
-        U.putOrderedObject(p, MATCH, null);
+        U.putObjectRelease(p, MATCH, null);
         p.item = null;
         p.hash = h;
         return v;
--- a/src/java.base/share/classes/java/util/concurrent/ForkJoinPool.java	Thu Mar 24 16:21:19 2016 +0100
+++ b/src/java.base/share/classes/java/util/concurrent/ForkJoinPool.java	Fri Mar 25 15:35:43 2016 +0300
@@ -289,7 +289,7 @@
      * 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 @@
                         popped = true;
                         top = s;
                     }
-                    U.putOrderedInt(this, QLOCK, 0);
+                    U.putIntRelease(this, QLOCK, 0);
                 }
             }
             return popped;
@@ -1261,7 +1261,7 @@
                                         popped = true;
                                         top = s - 1;
                                     }
-                                    U.putOrderedInt(this, QLOCK, 0);
+                                    U.putIntRelease(this, QLOCK, 0);
                                     if (popped)
                                         return t;
                                 }
--- a/src/java.base/share/classes/java/util/concurrent/ForkJoinWorkerThread.java	Thu Mar 24 16:21:19 2016 +0100
+++ b/src/java.base/share/classes/java/util/concurrent/ForkJoinWorkerThread.java	Fri Mar 25 15:35:43 2016 +0300
@@ -92,7 +92,7 @@
     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);
--- a/src/java.base/share/classes/java/util/concurrent/FutureTask.java	Thu Mar 24 16:21:19 2016 +0100
+++ b/src/java.base/share/classes/java/util/concurrent/FutureTask.java	Fri Mar 25 15:35:43 2016 +0300
@@ -174,7 +174,7 @@
                     if (t != null)
                         t.interrupt();
                 } finally { // final state
-                    U.putOrderedInt(this, STATE, INTERRUPTED);
+                    U.putIntRelease(this, STATE, INTERRUPTED);
                 }
             }
         } finally {
@@ -230,7 +230,7 @@
     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 @@
     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();
         }
     }
--- a/src/java.base/share/classes/java/util/concurrent/SubmissionPublisher.java	Thu Mar 24 16:21:19 2016 +0100
+++ b/src/java.base/share/classes/java/util/concurrent/SubmissionPublisher.java	Fri Mar 25 15:35:43 2016 +0300
@@ -1496,7 +1496,7 @@
                     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);
--- a/src/java.base/share/classes/java/util/concurrent/atomic/AtomicBoolean.java	Thu Mar 24 16:21:19 2016 +0100
+++ b/src/java.base/share/classes/java/util/concurrent/atomic/AtomicBoolean.java	Fri Mar 25 15:35:43 2016 +0300
@@ -136,7 +136,7 @@
      * @since 1.6
      */
     public final void lazySet(boolean newValue) {
-        U.putOrderedInt(this, VALUE, (newValue ? 1 : 0));
+        U.putIntRelease(this, VALUE, (newValue ? 1 : 0));
     }
 
     /**
--- a/src/java.base/share/classes/java/util/concurrent/atomic/AtomicInteger.java	Thu Mar 24 16:21:19 2016 +0100
+++ b/src/java.base/share/classes/java/util/concurrent/atomic/AtomicInteger.java	Fri Mar 25 15:35:43 2016 +0300
@@ -108,7 +108,7 @@
      * @since 1.6
      */
     public final void lazySet(int newValue) {
-        U.putOrderedInt(this, VALUE, newValue);
+        U.putIntRelease(this, VALUE, newValue);
     }
 
     /**
--- a/src/java.base/share/classes/java/util/concurrent/atomic/AtomicIntegerArray.java	Thu Mar 24 16:21:19 2016 +0100
+++ b/src/java.base/share/classes/java/util/concurrent/atomic/AtomicIntegerArray.java	Fri Mar 25 15:35:43 2016 +0300
@@ -136,7 +136,7 @@
      * @since 1.6
      */
     public final void lazySet(int i, int newValue) {
-        U.putOrderedInt(array, checkedByteOffset(i), newValue);
+        U.putIntRelease(array, checkedByteOffset(i), newValue);
     }
 
     /**
--- a/src/java.base/share/classes/java/util/concurrent/atomic/AtomicIntegerFieldUpdater.java	Thu Mar 24 16:21:19 2016 +0100
+++ b/src/java.base/share/classes/java/util/concurrent/atomic/AtomicIntegerFieldUpdater.java	Fri Mar 25 15:35:43 2016 +0300
@@ -475,7 +475,7 @@
 
         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) {
--- a/src/java.base/share/classes/java/util/concurrent/atomic/AtomicLong.java	Thu Mar 24 16:21:19 2016 +0100
+++ b/src/java.base/share/classes/java/util/concurrent/atomic/AtomicLong.java	Fri Mar 25 15:35:43 2016 +0300
@@ -124,7 +124,7 @@
      * @since 1.6
      */
     public final void lazySet(long newValue) {
-        U.putOrderedLong(this, VALUE, newValue);
+        U.putLongRelease(this, VALUE, newValue);
     }
 
     /**
--- a/src/java.base/share/classes/java/util/concurrent/atomic/AtomicLongArray.java	Thu Mar 24 16:21:19 2016 +0100
+++ b/src/java.base/share/classes/java/util/concurrent/atomic/AtomicLongArray.java	Fri Mar 25 15:35:43 2016 +0300
@@ -135,7 +135,7 @@
      * @since 1.6
      */
     public final void lazySet(int i, long newValue) {
-        U.putOrderedLong(array, checkedByteOffset(i), newValue);
+        U.putLongRelease(array, checkedByteOffset(i), newValue);
     }
 
     /**
--- a/src/java.base/share/classes/java/util/concurrent/atomic/AtomicLongFieldUpdater.java	Thu Mar 24 16:21:19 2016 +0100
+++ b/src/java.base/share/classes/java/util/concurrent/atomic/AtomicLongFieldUpdater.java	Fri Mar 25 15:35:43 2016 +0300
@@ -457,7 +457,7 @@
 
         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) {
--- a/src/java.base/share/classes/java/util/concurrent/atomic/AtomicReference.java	Thu Mar 24 16:21:19 2016 +0100
+++ b/src/java.base/share/classes/java/util/concurrent/atomic/AtomicReference.java	Fri Mar 25 15:35:43 2016 +0300
@@ -103,7 +103,7 @@
      * @since 1.6
      */
     public final void lazySet(V newValue) {
-        U.putOrderedObject(this, VALUE, newValue);
+        U.putObjectRelease(this, VALUE, newValue);
     }
 
     /**
--- a/src/java.base/share/classes/java/util/concurrent/atomic/AtomicReferenceArray.java	Thu Mar 24 16:21:19 2016 +0100
+++ b/src/java.base/share/classes/java/util/concurrent/atomic/AtomicReferenceArray.java	Fri Mar 25 15:35:43 2016 +0300
@@ -147,7 +147,7 @@
      * @since 1.6
      */
     public final void lazySet(int i, E newValue) {
-        U.putOrderedObject(array, checkedByteOffset(i), newValue);
+        U.putObjectRelease(array, checkedByteOffset(i), newValue);
     }
 
     /**
--- a/src/java.base/share/classes/java/util/concurrent/atomic/AtomicReferenceFieldUpdater.java	Thu Mar 24 16:21:19 2016 +0100
+++ b/src/java.base/share/classes/java/util/concurrent/atomic/AtomicReferenceFieldUpdater.java	Fri Mar 25 15:35:43 2016 +0300
@@ -426,7 +426,7 @@
         public final void lazySet(T obj, V newValue) {
             accessCheck(obj);
             valueCheck(newValue);
-            U.putOrderedObject(obj, offset, newValue);
+            U.putObjectRelease(obj, offset, newValue);
         }
 
         @SuppressWarnings("unchecked")
--- a/src/java.base/share/classes/jdk/internal/misc/InnocuousThread.java	Thu Mar 24 16:21:19 2016 +0100
+++ b/src/java.base/share/classes/jdk/internal/misc/InnocuousThread.java	Fri Mar 25 15:35:43 2016 +0300
@@ -57,8 +57,8 @@
 
     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
--- a/src/java.base/share/classes/jdk/internal/misc/Unsafe.java	Thu Mar 24 16:21:19 2016 +0100
+++ b/src/java.base/share/classes/jdk/internal/misc/Unsafe.java	Fri Mar 25 15:35:43 2016 +0300
@@ -1457,25 +1457,7 @@
     @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 @@
         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) {
--- a/src/java.base/share/classes/sun/misc/Unsafe.java	Thu Mar 24 16:21:19 2016 +0100
+++ b/src/java.base/share/classes/sun/misc/Unsafe.java	Fri Mar 25 15:35:43 2016 +0300
@@ -1068,19 +1068,19 @@
      */
     @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);
     }
 
     /**