ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/jsr166/jsr166/src/jsr166e/ConcurrentHashMapV8.java
(Generate patch)

Comparing jsr166/src/jsr166e/ConcurrentHashMapV8.java (file contents):
Revision 1.108 by jsr166, Mon Jul 1 19:19:31 2013 UTC vs.
Revision 1.109 by dl, Wed Jul 3 18:16:31 2013 UTC

# Line 568 | Line 568 | public class ConcurrentHashMapV8<K,V>
568      /*
569       * Encodings for Node hash fields. See above for explanation.
570       */
571 <    static final int MOVED     = 0x8fffffff; // (-1) hash for forwarding nodes
572 <    static final int TREEBIN   = 0x80000000; // hash for roots of trees
573 <    static final int RESERVED  = 0x80000001; // hash for transient reservations
571 >    static final int MOVED     = -1; // hash for forwarding nodes
572 >    static final int TREEBIN   = -2; // hash for roots of trees
573 >    static final int RESERVED  = -3; // hash for transient reservations
574      static final int HASH_BITS = 0x7fffffff; // usable bits of normal node hash
575  
576      /** Number of CPUS, to place bounds on some sizings */
# Line 597 | Line 597 | public class ConcurrentHashMapV8<K,V>
597          final int hash;
598          final K key;
599          volatile V val;
600 <        Node<K,V> next;
600 >        volatile Node<K,V> next;
601  
602          Node(int hash, K key, V val, Node<K,V> next) {
603              this.hash = hash;
# Line 722 | Line 722 | public class ConcurrentHashMapV8<K,V>
722       * errors by users, these checks must operate on local variables,
723       * which accounts for some odd-looking inline assignments below.
724       * Note that calls to setTabAt always occur within locked regions,
725 <     * and so do not need full volatile semantics, but still require
726 <     * ordering to maintain concurrent readability.
725 >     * and so in principle require only release ordering, not need
726 >     * full volatile semantics, but are currently coded as volatile
727 >     * writes to be conservative.
728       */
729  
730      @SuppressWarnings("unchecked")
# Line 737 | Line 738 | public class ConcurrentHashMapV8<K,V>
738      }
739  
740      static final <K,V> void setTabAt(Node<K,V>[] tab, int i, Node<K,V> v) {
741 <        U.putOrderedObject(tab, ((long)i << ASHIFT) + ABASE, v);
741 >        U.putObjectVolatile(tab, ((long)i << ASHIFT) + ABASE, v);
742      }
743  
744      /* ---------------- Fields -------------- */
# Line 2395 | Line 2396 | public class ConcurrentHashMapV8<K,V>
2396                                  else
2397                                      hn = new Node<K,V>(ph, pk, pv, hn);
2398                              }
2399 +                            setTabAt(nextTab, i, ln);
2400 +                            setTabAt(nextTab, i + n, hn);
2401 +                            setTabAt(tab, i, fwd);
2402 +                            advance = true;
2403                          }
2404                          else if (f instanceof TreeBin) {
2405                              TreeBin<K,V> t = (TreeBin<K,V>)f;
# Line 2426 | Line 2431 | public class ConcurrentHashMapV8<K,V>
2431                                  (hc != 0) ? new TreeBin<K,V>(lo) : t;
2432                              hn = (hc <= UNTREEIFY_THRESHOLD) ? untreeify(hi) :
2433                                  (lc != 0) ? new TreeBin<K,V>(hi) : t;
2434 +                            setTabAt(nextTab, i, ln);
2435 +                            setTabAt(nextTab, i + n, hn);
2436 +                            setTabAt(tab, i, fwd);
2437 +                            advance = true;
2438                          }
2430                        else
2431                            ln = hn = null;
2432                        setTabAt(nextTab, i, ln);
2433                        setTabAt(nextTab, i + n, hn);
2434                        setTabAt(tab, i, fwd);
2435                        advance = true;
2439                      }
2440                  }
2441              }
# Line 2453 | Line 2456 | public class ConcurrentHashMapV8<K,V>
2456                      U.compareAndSwapInt(this, SIZECTL, sc, -2))
2457                      transfer(tab, null);
2458              }
2459 <            else if ((b = tabAt(tab, index)) != null) {
2459 >            else if ((b = tabAt(tab, index)) != null && b.hash >= 0) {
2460                  synchronized (b) {
2461                      if (tabAt(tab, index) == b) {
2462                          TreeNode<K,V> hd = null, tl = null;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines