提交 7df075be 编写于 作者: S shade

8152698: Remove obsolete Unsafe.putOrdered{X} methods, usages, runtime and compiler support

Reviewed-by: kvn, psandoz, dl
上级 d9d15d59
......@@ -480,7 +480,7 @@ public class CompletableFuture<T> implements Future<T>, CompletionStage<T> {
}
static void lazySetNext(Completion c, Completion next) {
U.putOrderedObject(c, NEXT, next);
U.putObjectRelease(c, NEXT, next);
}
/**
......
......@@ -309,7 +309,7 @@ public class ConcurrentLinkedDeque<E>
}
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 @@ public class ConcurrentLinkedDeque<E>
}
void lazySetPrev(Node<E> val) {
U.putOrderedObject(this, PREV, val);
U.putObjectRelease(this, PREV, val);
}
boolean casPrev(Node<E> cmp, Node<E> val) {
......
......@@ -198,7 +198,7 @@ public class ConcurrentLinkedQueue<E> extends AbstractQueue<E>
}
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) {
......
......@@ -239,7 +239,7 @@ public class Exchanger<V> {
* 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<V> {
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<V> {
break;
}
}
U.putOrderedObject(p, MATCH, null);
U.putObjectRelease(p, MATCH, null);
p.item = null;
p.hash = h;
return v;
......
......@@ -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;
}
......
......@@ -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);
......
......@@ -174,7 +174,7 @@ public class FutureTask<V> implements RunnableFuture<V> {
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<V> implements RunnableFuture<V> {
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<V> implements RunnableFuture<V> {
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();
}
}
......
......@@ -1496,7 +1496,7 @@ public class SubmissionPublisher<T> implements Flow.Publisher<T>,
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);
......
......@@ -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));
}
/**
......
......@@ -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);
}
/**
......
......@@ -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);
}
/**
......
......@@ -475,7 +475,7 @@ public abstract class AtomicIntegerFieldUpdater<T> {
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) {
......
......@@ -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);
}
/**
......
......@@ -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);
}
/**
......
......@@ -457,7 +457,7 @@ public abstract class AtomicLongFieldUpdater<T> {
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) {
......
......@@ -103,7 +103,7 @@ public class AtomicReference<V> implements java.io.Serializable {
* @since 1.6
*/
public final void lazySet(V newValue) {
U.putOrderedObject(this, VALUE, newValue);
U.putObjectRelease(this, VALUE, newValue);
}
/**
......
......@@ -147,7 +147,7 @@ public class AtomicReferenceArray<E> 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);
}
/**
......
......@@ -426,7 +426,7 @@ public abstract class AtomicReferenceFieldUpdater<T,V> {
public final void lazySet(T obj, V newValue) {
accessCheck(obj);
valueCheck(newValue);
U.putOrderedObject(obj, offset, newValue);
U.putObjectRelease(obj, offset, newValue);
}
@SuppressWarnings("unchecked")
......
......@@ -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
......
......@@ -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) {
......
......@@ -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);
}
/**
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册