mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-28 15:24:43 +02:00
8225490: Miscellaneous changes imported from jsr166 CVS 2019-09
Reviewed-by: martin, alanb
This commit is contained in:
parent
9275097a02
commit
eb1eadb69f
46 changed files with 622 additions and 640 deletions
|
@ -385,7 +385,7 @@ public class ConcurrentHashMap<K,V> extends AbstractMap<K,V>
|
|||
* cases where old nodes can be reused because their next fields
|
||||
* won't change. On average, only about one-sixth of them need
|
||||
* cloning when a table doubles. The nodes they replace will be
|
||||
* garbage collectable as soon as they are no longer referenced by
|
||||
* garbage collectible as soon as they are no longer referenced by
|
||||
* any reader thread that may be in the midst of concurrently
|
||||
* traversing table. Upon transfer, the old table bin contains
|
||||
* only a special forwarding node (with hash field "MOVED") that
|
||||
|
@ -3286,9 +3286,8 @@ public class ConcurrentHashMap<K,V> extends AbstractMap<K,V>
|
|||
return true;
|
||||
}
|
||||
|
||||
private static final Unsafe U = Unsafe.getUnsafe();
|
||||
private static final long LOCKSTATE
|
||||
= U.objectFieldOffset(TreeBin.class, "lockState");
|
||||
= U.objectFieldOffset(TreeBin.class, "lockState");
|
||||
}
|
||||
|
||||
/* ----------------Table Traversal -------------- */
|
||||
|
@ -6345,28 +6344,20 @@ public class ConcurrentHashMap<K,V> extends AbstractMap<K,V>
|
|||
|
||||
// Unsafe mechanics
|
||||
private static final Unsafe U = Unsafe.getUnsafe();
|
||||
private static final long SIZECTL;
|
||||
private static final long TRANSFERINDEX;
|
||||
private static final long BASECOUNT;
|
||||
private static final long CELLSBUSY;
|
||||
private static final long CELLVALUE;
|
||||
private static final int ABASE;
|
||||
private static final long SIZECTL
|
||||
= U.objectFieldOffset(ConcurrentHashMap.class, "sizeCtl");
|
||||
private static final long TRANSFERINDEX
|
||||
= U.objectFieldOffset(ConcurrentHashMap.class, "transferIndex");
|
||||
private static final long BASECOUNT
|
||||
= U.objectFieldOffset(ConcurrentHashMap.class, "baseCount");
|
||||
private static final long CELLSBUSY
|
||||
= U.objectFieldOffset(ConcurrentHashMap.class, "cellsBusy");
|
||||
private static final long CELLVALUE
|
||||
= U.objectFieldOffset(CounterCell.class, "value");
|
||||
private static final int ABASE = U.arrayBaseOffset(Node[].class);
|
||||
private static final int ASHIFT;
|
||||
|
||||
static {
|
||||
SIZECTL = U.objectFieldOffset
|
||||
(ConcurrentHashMap.class, "sizeCtl");
|
||||
TRANSFERINDEX = U.objectFieldOffset
|
||||
(ConcurrentHashMap.class, "transferIndex");
|
||||
BASECOUNT = U.objectFieldOffset
|
||||
(ConcurrentHashMap.class, "baseCount");
|
||||
CELLSBUSY = U.objectFieldOffset
|
||||
(ConcurrentHashMap.class, "cellsBusy");
|
||||
|
||||
CELLVALUE = U.objectFieldOffset
|
||||
(CounterCell.class, "value");
|
||||
|
||||
ABASE = U.arrayBaseOffset(Node[].class);
|
||||
int scale = U.arrayIndexScale(Node[].class);
|
||||
if ((scale & (scale - 1)) != 0)
|
||||
throw new ExceptionInInitializerError("array index scale not a power of two");
|
||||
|
|
|
@ -97,7 +97,7 @@ import java.util.concurrent.locks.LockSupport;
|
|||
* associated recovery within handlers of those exceptions,
|
||||
* often after invoking {@code forceTermination}. Phasers may
|
||||
* also be used by tasks executing in a {@link ForkJoinPool}.
|
||||
* Progress is ensured if the pool's parallelismLevel can
|
||||
* Progress is ensured if the pool's parallelism level can
|
||||
* accommodate the maximum number of simultaneously blocked
|
||||
* parties.
|
||||
*
|
||||
|
|
|
@ -1053,18 +1053,18 @@ public class ThreadLocalRandom extends Random {
|
|||
|
||||
// Unsafe mechanics
|
||||
private static final Unsafe U = Unsafe.getUnsafe();
|
||||
private static final long SEED = U.objectFieldOffset
|
||||
(Thread.class, "threadLocalRandomSeed");
|
||||
private static final long PROBE = U.objectFieldOffset
|
||||
(Thread.class, "threadLocalRandomProbe");
|
||||
private static final long SECONDARY = U.objectFieldOffset
|
||||
(Thread.class, "threadLocalRandomSecondarySeed");
|
||||
private static final long THREADLOCALS = U.objectFieldOffset
|
||||
(Thread.class, "threadLocals");
|
||||
private static final long INHERITABLETHREADLOCALS = U.objectFieldOffset
|
||||
(Thread.class, "inheritableThreadLocals");
|
||||
private static final long INHERITEDACCESSCONTROLCONTEXT = U.objectFieldOffset
|
||||
(Thread.class, "inheritedAccessControlContext");
|
||||
private static final long SEED
|
||||
= U.objectFieldOffset(Thread.class, "threadLocalRandomSeed");
|
||||
private static final long PROBE
|
||||
= U.objectFieldOffset(Thread.class, "threadLocalRandomProbe");
|
||||
private static final long SECONDARY
|
||||
= U.objectFieldOffset(Thread.class, "threadLocalRandomSecondarySeed");
|
||||
private static final long THREADLOCALS
|
||||
= U.objectFieldOffset(Thread.class, "threadLocals");
|
||||
private static final long INHERITABLETHREADLOCALS
|
||||
= U.objectFieldOffset(Thread.class, "inheritableThreadLocals");
|
||||
private static final long INHERITEDACCESSCONTROLCONTEXT
|
||||
= U.objectFieldOffset(Thread.class, "inheritedAccessControlContext");
|
||||
|
||||
/** Rarely-used holder for the second of a pair of Gaussians */
|
||||
private static final ThreadLocal<Double> nextLocalGaussian =
|
||||
|
|
|
@ -38,6 +38,7 @@ package java.util.concurrent.atomic;
|
|||
import java.lang.invoke.VarHandle;
|
||||
import java.util.function.IntBinaryOperator;
|
||||
import java.util.function.IntUnaryOperator;
|
||||
import jdk.internal.misc.Unsafe;
|
||||
|
||||
/**
|
||||
* An {@code int} value that may be updated atomically. See the
|
||||
|
@ -58,8 +59,9 @@ public class AtomicInteger extends Number implements java.io.Serializable {
|
|||
* This class intended to be implemented using VarHandles, but there
|
||||
* are unresolved cyclic startup dependencies.
|
||||
*/
|
||||
private static final jdk.internal.misc.Unsafe U = jdk.internal.misc.Unsafe.getUnsafe();
|
||||
private static final long VALUE = U.objectFieldOffset(AtomicInteger.class, "value");
|
||||
private static final Unsafe U = Unsafe.getUnsafe();
|
||||
private static final long VALUE
|
||||
= U.objectFieldOffset(AtomicInteger.class, "value");
|
||||
|
||||
private volatile int value;
|
||||
|
||||
|
|
|
@ -38,6 +38,7 @@ package java.util.concurrent.atomic;
|
|||
import java.lang.invoke.VarHandle;
|
||||
import java.util.function.LongBinaryOperator;
|
||||
import java.util.function.LongUnaryOperator;
|
||||
import jdk.internal.misc.Unsafe;
|
||||
|
||||
/**
|
||||
* A {@code long} value that may be updated atomically. See the
|
||||
|
@ -72,8 +73,9 @@ public class AtomicLong extends Number implements java.io.Serializable {
|
|||
* This class intended to be implemented using VarHandles, but there
|
||||
* are unresolved cyclic startup dependencies.
|
||||
*/
|
||||
private static final jdk.internal.misc.Unsafe U = jdk.internal.misc.Unsafe.getUnsafe();
|
||||
private static final long VALUE = U.objectFieldOffset(AtomicLong.class, "value");
|
||||
private static final Unsafe U = Unsafe.getUnsafe();
|
||||
private static final long VALUE
|
||||
= U.objectFieldOffset(AtomicLong.class, "value");
|
||||
|
||||
private volatile long value;
|
||||
|
||||
|
|
|
@ -226,9 +226,8 @@
|
|||
*
|
||||
* <h2 id="MemoryVisibility">Memory Consistency Properties</h2>
|
||||
*
|
||||
* <a href="https://docs.oracle.com/javase/specs/jls/se11/html/jls-17.html#jls-17.4.5">
|
||||
* Chapter 17 of
|
||||
* <cite>The Java™ Language Specification</cite></a> defines the
|
||||
* <cite>The Java™ Language Specification</cite> defines the
|
||||
* <i>happens-before</i> relation on memory operations such as reads and
|
||||
* writes of shared variables. The results of a write by one thread are
|
||||
* guaranteed to be visible to a read by another thread only if the write
|
||||
|
@ -302,6 +301,8 @@
|
|||
*
|
||||
* </ul>
|
||||
*
|
||||
* @jls 17.4.5 Happens-before Order
|
||||
*
|
||||
* @since 1.5
|
||||
*/
|
||||
package java.util.concurrent;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue