391 |
|
final Node[] resizeTable(CustomConcurrentHashMap cchm) { |
392 |
|
Node[] oldTable = table; |
393 |
|
if (oldTable == null) |
394 |
< |
return table = (Node[]) |
395 |
< |
new Node[cchm.initialSegmentCapacity]; |
394 |
> |
return table = new Node[cchm.initialSegmentCapacity]; |
395 |
|
|
396 |
|
int oldCapacity = oldTable.length; |
397 |
|
if (oldCapacity >= MAX_SEGMENT_CAPACITY) |
398 |
|
return oldTable; |
399 |
< |
Node[] newTable = |
401 |
< |
(Node[])new Node[oldCapacity<<1]; |
399 |
> |
Node[] newTable = new Node[oldCapacity<<1]; |
400 |
|
int sizeMask = newTable.length - 1; |
401 |
|
NodeFactory fac = cchm.factory; |
402 |
|
for (int i = 0; i < oldCapacity ; i++) { |
538 |
|
capacity = MAX_SEGMENT_CAPACITY; |
539 |
|
this.initialSegmentCapacity = capacity; |
540 |
|
} |
541 |
< |
this.segments = (Segment[])new Segment[NSEGMENTS]; |
541 |
> |
this.segments = new Segment[NSEGMENTS]; |
542 |
|
} |
543 |
|
|
544 |
|
/** |
1574 |
|
private void readObject(java.io.ObjectInputStream s) |
1575 |
|
throws IOException, ClassNotFoundException { |
1576 |
|
s.defaultReadObject(); |
1577 |
< |
this.segments = (Segment[])(new Segment[NSEGMENTS]); |
1577 |
> |
this.segments = new Segment[NSEGMENTS]; |
1578 |
|
for (;;) { |
1579 |
|
K key = (K) s.readObject(); |
1580 |
|
V value = (V) s.readObject(); |
1791 |
|
|
1792 |
|
// Strong Keys |
1793 |
|
|
1794 |
< |
static abstract class StrongKeyNode implements Node { |
1794 |
> |
abstract static class StrongKeyNode implements Node { |
1795 |
|
final Object key; |
1796 |
|
final int locator; |
1797 |
|
StrongKeyNode(int locator, Object key) { |
1803 |
|
} |
1804 |
|
|
1805 |
|
|
1806 |
< |
static abstract class StrongKeySelfValueNode |
1806 |
> |
abstract static class StrongKeySelfValueNode |
1807 |
|
extends StrongKeyNode { |
1808 |
|
StrongKeySelfValueNode(int locator, Object key) { |
1809 |
|
super(locator, key); |
1850 |
|
} |
1851 |
|
} |
1852 |
|
|
1853 |
< |
static abstract class StrongKeyStrongValueNode |
1853 |
> |
abstract static class StrongKeyStrongValueNode |
1854 |
|
extends StrongKeyNode { |
1855 |
|
volatile Object value; |
1856 |
|
StrongKeyStrongValueNode(int locator, Object key, Object value) { |
1903 |
|
|
1904 |
|
// ... |
1905 |
|
|
1906 |
< |
static abstract class StrongKeyIntValueNode |
1906 |
> |
abstract static class StrongKeyIntValueNode |
1907 |
|
extends StrongKeyNode { |
1908 |
|
volatile int value; |
1909 |
|
StrongKeyIntValueNode(int locator, Object key, Object value) { |
1958 |
|
|
1959 |
|
// ... |
1960 |
|
|
1961 |
< |
static abstract class StrongKeyWeakValueNode |
1961 |
> |
abstract static class StrongKeyWeakValueNode |
1962 |
|
extends StrongKeyNode { |
1963 |
|
volatile EmbeddedWeakReference valueRef; |
1964 |
|
final CustomConcurrentHashMap cchm; |
2026 |
|
} |
2027 |
|
|
2028 |
|
|
2029 |
< |
static abstract class StrongKeySoftValueNode |
2029 |
> |
abstract static class StrongKeySoftValueNode |
2030 |
|
extends StrongKeyNode { |
2031 |
|
volatile EmbeddedSoftReference valueRef; |
2032 |
|
final CustomConcurrentHashMap cchm; |
2095 |
|
|
2096 |
|
// Weak keys |
2097 |
|
|
2098 |
< |
static abstract class WeakKeyNode extends WeakReference |
2098 |
> |
abstract static class WeakKeyNode extends WeakReference |
2099 |
|
implements Node { |
2100 |
|
final int locator; |
2101 |
|
final CustomConcurrentHashMap cchm; |
2111 |
|
} |
2112 |
|
} |
2113 |
|
|
2114 |
< |
static abstract class WeakKeySelfValueNode |
2114 |
> |
abstract static class WeakKeySelfValueNode |
2115 |
|
extends WeakKeyNode { |
2116 |
|
WeakKeySelfValueNode(int locator, Object key, |
2117 |
|
CustomConcurrentHashMap cchm) { |
2161 |
|
} |
2162 |
|
|
2163 |
|
|
2164 |
< |
static abstract class WeakKeyStrongValueNode |
2164 |
> |
abstract static class WeakKeyStrongValueNode |
2165 |
|
extends WeakKeyNode { |
2166 |
|
volatile Object value; |
2167 |
|
WeakKeyStrongValueNode(int locator, Object key, Object value, |
2214 |
|
} |
2215 |
|
} |
2216 |
|
|
2217 |
< |
static abstract class WeakKeyIntValueNode |
2217 |
> |
abstract static class WeakKeyIntValueNode |
2218 |
|
extends WeakKeyNode { |
2219 |
|
volatile int value; |
2220 |
|
WeakKeyIntValueNode(int locator, Object key, Object value, |
2269 |
|
} |
2270 |
|
} |
2271 |
|
|
2272 |
< |
static abstract class WeakKeyWeakValueNode |
2272 |
> |
abstract static class WeakKeyWeakValueNode |
2273 |
|
extends WeakKeyNode { |
2274 |
|
volatile EmbeddedWeakReference valueRef; |
2275 |
|
WeakKeyWeakValueNode(int locator, Object key, Object value, |
2332 |
|
} |
2333 |
|
|
2334 |
|
|
2335 |
< |
static abstract class WeakKeySoftValueNode |
2335 |
> |
abstract static class WeakKeySoftValueNode |
2336 |
|
extends WeakKeyNode { |
2337 |
|
volatile EmbeddedSoftReference valueRef; |
2338 |
|
WeakKeySoftValueNode(int locator, Object key, Object value, |
2396 |
|
|
2397 |
|
// Soft keys |
2398 |
|
|
2399 |
< |
static abstract class SoftKeyNode extends SoftReference |
2399 |
> |
abstract static class SoftKeyNode extends SoftReference |
2400 |
|
implements Node { |
2401 |
|
final int locator; |
2402 |
|
final CustomConcurrentHashMap cchm; |
2412 |
|
} |
2413 |
|
} |
2414 |
|
|
2415 |
< |
static abstract class SoftKeySelfValueNode |
2415 |
> |
abstract static class SoftKeySelfValueNode |
2416 |
|
extends SoftKeyNode { |
2417 |
|
SoftKeySelfValueNode(int locator, Object key, |
2418 |
|
CustomConcurrentHashMap cchm) { |
2462 |
|
} |
2463 |
|
|
2464 |
|
|
2465 |
< |
static abstract class SoftKeyStrongValueNode |
2465 |
> |
abstract static class SoftKeyStrongValueNode |
2466 |
|
extends SoftKeyNode { |
2467 |
|
volatile Object value; |
2468 |
|
SoftKeyStrongValueNode(int locator, Object key, Object value, |
2515 |
|
} |
2516 |
|
} |
2517 |
|
|
2518 |
< |
static abstract class SoftKeyIntValueNode |
2518 |
> |
abstract static class SoftKeyIntValueNode |
2519 |
|
extends SoftKeyNode { |
2520 |
|
volatile int value; |
2521 |
|
SoftKeyIntValueNode(int locator, Object key, Object value, |
2570 |
|
} |
2571 |
|
} |
2572 |
|
|
2573 |
< |
static abstract class SoftKeyWeakValueNode |
2573 |
> |
abstract static class SoftKeyWeakValueNode |
2574 |
|
extends SoftKeyNode { |
2575 |
|
volatile EmbeddedWeakReference valueRef; |
2576 |
|
SoftKeyWeakValueNode(int locator, Object key, Object value, |
2633 |
|
} |
2634 |
|
|
2635 |
|
|
2636 |
< |
static abstract class SoftKeySoftValueNode |
2636 |
> |
abstract static class SoftKeySoftValueNode |
2637 |
|
extends SoftKeyNode { |
2638 |
|
volatile EmbeddedSoftReference valueRef; |
2639 |
|
SoftKeySoftValueNode(int locator, Object key, Object value, |
2695 |
|
} |
2696 |
|
} |
2697 |
|
|
2698 |
< |
static abstract class IntKeyNode implements Node { |
2698 |
> |
abstract static class IntKeyNode implements Node { |
2699 |
|
final int key; |
2700 |
|
IntKeyNode(int locator, Object key) { |
2701 |
|
this.key = ((Integer)key).intValue(); |
2705 |
|
} |
2706 |
|
|
2707 |
|
|
2708 |
< |
static abstract class IntKeySelfValueNode |
2708 |
> |
abstract static class IntKeySelfValueNode |
2709 |
|
extends IntKeyNode { |
2710 |
|
IntKeySelfValueNode(int locator, Object key) { |
2711 |
|
super(locator, key); |
2752 |
|
} |
2753 |
|
} |
2754 |
|
|
2755 |
< |
static abstract class IntKeyStrongValueNode |
2755 |
> |
abstract static class IntKeyStrongValueNode |
2756 |
|
extends IntKeyNode { |
2757 |
|
volatile Object value; |
2758 |
|
IntKeyStrongValueNode(int locator, Object key, Object value) { |
2803 |
|
} |
2804 |
|
} |
2805 |
|
|
2806 |
< |
static abstract class IntKeyIntValueNode |
2806 |
> |
abstract static class IntKeyIntValueNode |
2807 |
|
extends IntKeyNode { |
2808 |
|
volatile int value; |
2809 |
|
IntKeyIntValueNode(int locator, Object key, Object value) { |
2856 |
|
} |
2857 |
|
} |
2858 |
|
|
2859 |
< |
static abstract class IntKeyWeakValueNode |
2859 |
> |
abstract static class IntKeyWeakValueNode |
2860 |
|
extends IntKeyNode { |
2861 |
|
volatile EmbeddedWeakReference valueRef; |
2862 |
|
final CustomConcurrentHashMap cchm; |
2924 |
|
} |
2925 |
|
|
2926 |
|
|
2927 |
< |
static abstract class IntKeySoftValueNode |
2927 |
> |
abstract static class IntKeySoftValueNode |
2928 |
|
extends IntKeyNode { |
2929 |
|
volatile EmbeddedSoftReference valueRef; |
2930 |
|
final CustomConcurrentHashMap cchm; |
3005 |
|
try { |
3006 |
|
UNSAFE = getUnsafe(); |
3007 |
|
tableBase = UNSAFE.arrayBaseOffset(Node[].class); |
3008 |
< |
int s = UNSAFE.arrayIndexScale(Node[].class); |
3009 |
< |
if ((s & (s-1)) != 0) |
3008 |
> |
int scale = UNSAFE.arrayIndexScale(Node[].class); |
3009 |
> |
if ((scale & (scale - 1)) != 0) |
3010 |
|
throw new Error("data type scale not a power of two"); |
3011 |
< |
tableShift = 31 - Integer.numberOfLeadingZeros(s); |
3011 |
> |
tableShift = 31 - Integer.numberOfLeadingZeros(scale); |
3012 |
|
segmentsBase = UNSAFE.arrayBaseOffset(Segment[].class); |
3013 |
< |
s = UNSAFE.arrayIndexScale(Segment[].class); |
3014 |
< |
if ((s & (s-1)) != 0) |
3013 |
> |
scale = UNSAFE.arrayIndexScale(Segment[].class); |
3014 |
> |
if ((scale & (scale - 1)) != 0) |
3015 |
|
throw new Error("data type scale not a power of two"); |
3016 |
< |
segmentsShift = 31 - Integer.numberOfLeadingZeros(s); |
3016 |
> |
segmentsShift = 31 - Integer.numberOfLeadingZeros(scale); |
3017 |
|
} catch (Throwable e) { |
3018 |
|
throw new RuntimeException("Could not initialize intrinsics", e); |
3019 |
|
} |