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(); |
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 |
|
} |