567 |
|
static final int SEED_INCREMENT = 0x61c88647; |
568 |
|
|
569 |
|
/** |
570 |
< |
* Per-thread counter hash codes. Shared across all instances |
570 |
> |
* Per-thread counter hash codes. Shared across all instances. |
571 |
|
*/ |
572 |
|
static final ThreadLocal<CounterHashCode> threadCounterHashCode = |
573 |
|
new ThreadLocal<CounterHashCode>(); |
4577 |
|
/** |
4578 |
|
* Base class for views. |
4579 |
|
*/ |
4580 |
< |
static abstract class CHMView<K, V> { |
4580 |
> |
abstract static class CHMView<K, V> { |
4581 |
|
final ConcurrentHashMapV8<K, V> map; |
4582 |
|
CHMView(ConcurrentHashMapV8<K, V> map) { this.map = map; } |
4583 |
|
|
4593 |
|
public final void clear() { map.clear(); } |
4594 |
|
|
4595 |
|
// implementations below rely on concrete classes supplying these |
4596 |
< |
abstract public Iterator<?> iterator(); |
4597 |
< |
abstract public boolean contains(Object o); |
4598 |
< |
abstract public boolean remove(Object o); |
4596 |
> |
public abstract Iterator<?> iterator(); |
4597 |
> |
public abstract boolean contains(Object o); |
4598 |
> |
public abstract boolean remove(Object o); |
4599 |
|
|
4600 |
|
private static final String oomeMsg = "Required array size too large"; |
4601 |
|
|
6804 |
|
private static final int ASHIFT; |
6805 |
|
|
6806 |
|
static { |
6807 |
– |
int ss; |
6807 |
|
try { |
6808 |
|
U = getUnsafe(); |
6809 |
|
Class<?> k = ConcurrentHashMapV8.class; |
6822 |
|
(ck.getDeclaredField("value")); |
6823 |
|
Class<?> sc = Node[].class; |
6824 |
|
ABASE = U.arrayBaseOffset(sc); |
6825 |
< |
ss = U.arrayIndexScale(sc); |
6826 |
< |
ASHIFT = 31 - Integer.numberOfLeadingZeros(ss); |
6825 |
> |
int scale = U.arrayIndexScale(sc); |
6826 |
> |
if ((scale & (scale - 1)) != 0) |
6827 |
> |
throw new Error("data type scale not a power of two"); |
6828 |
> |
ASHIFT = 31 - Integer.numberOfLeadingZeros(scale); |
6829 |
|
} catch (Exception e) { |
6830 |
|
throw new Error(e); |
6831 |
|
} |
6831 |
– |
if ((ss & (ss-1)) != 0) |
6832 |
– |
throw new Error("data type scale not a power of two"); |
6832 |
|
} |
6833 |
|
|
6834 |
|
/** |
6841 |
|
private static sun.misc.Unsafe getUnsafe() { |
6842 |
|
try { |
6843 |
|
return sun.misc.Unsafe.getUnsafe(); |
6844 |
< |
} catch (SecurityException se) { |
6845 |
< |
try { |
6846 |
< |
return java.security.AccessController.doPrivileged |
6847 |
< |
(new java.security |
6848 |
< |
.PrivilegedExceptionAction<sun.misc.Unsafe>() { |
6849 |
< |
public sun.misc.Unsafe run() throws Exception { |
6850 |
< |
java.lang.reflect.Field f = sun.misc |
6851 |
< |
.Unsafe.class.getDeclaredField("theUnsafe"); |
6852 |
< |
f.setAccessible(true); |
6853 |
< |
return (sun.misc.Unsafe) f.get(null); |
6854 |
< |
}}); |
6855 |
< |
} catch (java.security.PrivilegedActionException e) { |
6856 |
< |
throw new RuntimeException("Could not initialize intrinsics", |
6857 |
< |
e.getCause()); |
6858 |
< |
} |
6844 |
> |
} catch (SecurityException tryReflectionInstead) {} |
6845 |
> |
try { |
6846 |
> |
return java.security.AccessController.doPrivileged |
6847 |
> |
(new java.security.PrivilegedExceptionAction<sun.misc.Unsafe>() { |
6848 |
> |
public sun.misc.Unsafe run() throws Exception { |
6849 |
> |
Class<sun.misc.Unsafe> k = sun.misc.Unsafe.class; |
6850 |
> |
for (java.lang.reflect.Field f : k.getDeclaredFields()) { |
6851 |
> |
f.setAccessible(true); |
6852 |
> |
Object x = f.get(null); |
6853 |
> |
if (k.isInstance(x)) |
6854 |
> |
return k.cast(x); |
6855 |
> |
} |
6856 |
> |
throw new NoSuchFieldError("the Unsafe"); |
6857 |
> |
}}); |
6858 |
> |
} catch (java.security.PrivilegedActionException e) { |
6859 |
> |
throw new RuntimeException("Could not initialize intrinsics", |
6860 |
> |
e.getCause()); |
6861 |
|
} |
6862 |
|
} |
6863 |
|
} |