356 |
|
* cases where old nodes can be reused because their next fields |
357 |
|
* won't change. On average, only about one-sixth of them need |
358 |
|
* cloning when a table doubles. The nodes they replace will be |
359 |
< |
* garbage collectable as soon as they are no longer referenced by |
359 |
> |
* garbage collectible as soon as they are no longer referenced by |
360 |
|
* any reader thread that may be in the midst of concurrently |
361 |
|
* traversing table. Upon transfer, the old table bin contains |
362 |
|
* only a special forwarding node (with hash field "MOVED") that |
3258 |
|
} |
3259 |
|
|
3260 |
|
private static final Unsafe U = Unsafe.getUnsafe(); |
3261 |
< |
private static final long LOCKSTATE; |
3262 |
< |
static { |
3263 |
< |
try { |
3264 |
< |
LOCKSTATE = U.objectFieldOffset |
3265 |
< |
(TreeBin.class.getDeclaredField("lockState")); |
3266 |
< |
} catch (ReflectiveOperationException e) { |
3267 |
< |
throw new ExceptionInInitializerError(e); |
3268 |
< |
} |
3269 |
< |
} |
3261 |
> |
private static final long LOCKSTATE |
3262 |
> |
= U.objectFieldOffset(TreeBin.class, "lockState"); |
3263 |
|
} |
3264 |
|
|
3265 |
|
/* ----------------Table Traversal -------------- */ |
6325 |
|
private static final int ASHIFT; |
6326 |
|
|
6327 |
|
static { |
6328 |
< |
try { |
6329 |
< |
SIZECTL = U.objectFieldOffset |
6330 |
< |
(ConcurrentHashMap.class.getDeclaredField("sizeCtl")); |
6331 |
< |
TRANSFERINDEX = U.objectFieldOffset |
6332 |
< |
(ConcurrentHashMap.class.getDeclaredField("transferIndex")); |
6333 |
< |
BASECOUNT = U.objectFieldOffset |
6334 |
< |
(ConcurrentHashMap.class.getDeclaredField("baseCount")); |
6335 |
< |
CELLSBUSY = U.objectFieldOffset |
6336 |
< |
(ConcurrentHashMap.class.getDeclaredField("cellsBusy")); |
6337 |
< |
|
6338 |
< |
CELLVALUE = U.objectFieldOffset |
6339 |
< |
(CounterCell.class.getDeclaredField("value")); |
6340 |
< |
|
6341 |
< |
ABASE = U.arrayBaseOffset(Node[].class); |
6342 |
< |
int scale = U.arrayIndexScale(Node[].class); |
6343 |
< |
if ((scale & (scale - 1)) != 0) |
6344 |
< |
throw new ExceptionInInitializerError("array index scale not a power of two"); |
6352 |
< |
ASHIFT = 31 - Integer.numberOfLeadingZeros(scale); |
6353 |
< |
} catch (ReflectiveOperationException e) { |
6354 |
< |
throw new ExceptionInInitializerError(e); |
6355 |
< |
} |
6328 |
> |
SIZECTL = U.objectFieldOffset |
6329 |
> |
(ConcurrentHashMap.class, "sizeCtl"); |
6330 |
> |
TRANSFERINDEX = U.objectFieldOffset |
6331 |
> |
(ConcurrentHashMap.class, "transferIndex"); |
6332 |
> |
BASECOUNT = U.objectFieldOffset |
6333 |
> |
(ConcurrentHashMap.class, "baseCount"); |
6334 |
> |
CELLSBUSY = U.objectFieldOffset |
6335 |
> |
(ConcurrentHashMap.class, "cellsBusy"); |
6336 |
> |
|
6337 |
> |
CELLVALUE = U.objectFieldOffset |
6338 |
> |
(CounterCell.class, "value"); |
6339 |
> |
|
6340 |
> |
ABASE = U.arrayBaseOffset(Node[].class); |
6341 |
> |
int scale = U.arrayIndexScale(Node[].class); |
6342 |
> |
if ((scale & (scale - 1)) != 0) |
6343 |
> |
throw new ExceptionInInitializerError("array index scale not a power of two"); |
6344 |
> |
ASHIFT = 31 - Integer.numberOfLeadingZeros(scale); |
6345 |
|
|
6346 |
|
// Reduce the risk of rare disastrous classloading in first call to |
6347 |
|
// LockSupport.park: https://bugs.openjdk.java.net/browse/JDK-8074773 |