src/java.base/share/classes/java/util/concurrent/ConcurrentHashMap.java

Print this page
rev 12972 : 8140606: Update library code to use internal Unsafe
Reviewed-by: duke

*** 295,305 **** * first insertion. Each bin in the table normally contains a * list of Nodes (most often, the list has only zero or one Node). * Table accesses require volatile/atomic reads, writes, and * CASes. Because there is no other way to arrange this without * adding further indirections, we use intrinsics ! * (sun.misc.Unsafe) operations. * * We use the top (sign) bit of Node hash fields for control * purposes -- it is available anyway because of addressing * constraints. Nodes with negative hash fields are specially * handled or ignored in map methods. --- 295,305 ---- * first insertion. Each bin in the table normally contains a * list of Nodes (most often, the list has only zero or one Node). * Table accesses require volatile/atomic reads, writes, and * CASes. Because there is no other way to arrange this without * adding further indirections, we use intrinsics ! * (jdk.internal.misc.Unsafe) operations. * * We use the top (sign) bit of Node hash fields for control * purposes -- it is available anyway because of addressing * constraints. Nodes with negative hash fields are specially * handled or ignored in map methods.
*** 3285,3295 **** if (tr != null && !checkInvariants(tr)) return false; return true; } ! private static final sun.misc.Unsafe U = sun.misc.Unsafe.getUnsafe(); private static final long LOCKSTATE; static { try { LOCKSTATE = U.objectFieldOffset (TreeBin.class.getDeclaredField("lockState")); --- 3285,3295 ---- if (tr != null && !checkInvariants(tr)) return false; return true; } ! private static final jdk.internal.misc.Unsafe U = jdk.internal.misc.Unsafe.getUnsafe(); private static final long LOCKSTATE; static { try { LOCKSTATE = U.objectFieldOffset (TreeBin.class.getDeclaredField("lockState"));
*** 6328,6338 **** } } } // Unsafe mechanics ! private static final sun.misc.Unsafe U = sun.misc.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; --- 6328,6338 ---- } } } // Unsafe mechanics ! private static final jdk.internal.misc.Unsafe U = jdk.internal.misc.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;