private boolean copy_slot( NonBlockingHashMap topmap, int idx, Object[] oldkvs, Object[] newkvs ) {
      // Blindly set the key slot from null to TOMBSTONE, to eagerly stop
      // fresh put's from inserting new values in the old table when the old
      // table is mid-resize.  We don't need to act on the results here,
      // because our correctness stems from box'ing the Value field.  Slamming
      // the Key field is a minor speed optimization.
      Object key;
      while( (key=key(oldkvs,idx)) == null )
        CAS_key(oldkvs,idx, null, TOMBSTONE);

      // ---
      // Prevent new values from appearing in the old table.
      // Box what we see in the old table, to prevent further updates.
      Object oldval = val(oldkvs,idx); // Read OLD table
      while( !(oldval instanceof Prime) ) {
        final Prime box = (oldval == null || oldval == TOMBSTONE) ? TOMBPRIME : new Prime(oldval);
        if( CAS_val(oldkvs,idx,oldval,box) ) { // CAS down a box'd version of oldval
          // If we made the Value slot hold a TOMBPRIME, then we both
          // prevented further updates here but also the (absent)
          // oldval is vacuously available in the new table.  We
          // return with true here: any thread looking for a value for
          // this key can correctly go straight to the new table and
          // skip looking in the old table.
          if( box == TOMBPRIME )
            return true;
          // Otherwise we boxed something, but it still needs to be
          // copied into the new table.
          oldval = box;         // Record updated oldval
          break;                // Break loop; oldval is now boxed by us
        }
        oldval = val(oldkvs,idx); // Else try, try again
      }
      if( oldval == TOMBPRIME ) return false; // Copy already complete here!

      // ---
      // Copy the value into the new table, but only if we overwrite a null.
      // If another value is already in the new table, then somebody else
      // wrote something there and that write is happens-after any value that
      // appears in the old table.
      Object old_unboxed = ((Prime)oldval)._V;
      assert old_unboxed != TOMBSTONE;
      putIfMatch0(topmap, newkvs, key, old_unboxed, null);

      // ---
      // Finally, now that any old value is exposed in the new table, we can
      // forever hide the old-table value by slapping a TOMBPRIME down.  This
      // will stop other threads from uselessly attempting to copy this slot
      // (i.e., it's a speed optimization not a correctness issue).
      while( oldval != TOMBPRIME && !CAS_val(oldkvs,idx,oldval,TOMBPRIME) )
        oldval = val(oldkvs,idx);

      return oldval != TOMBPRIME; // True if we slammed the TOMBPRIME down
    }
Put, Remove, PutIfAbsent, etc.  Return the old value.  If the returned value is equal to expVal (or expVal is
{@link #NO_MATCH_OLD}) then the put can be assumed to work (although might have been immediately overwritten).
Only the path through copy_slot passes in an expected value of null, and putIfMatch only returns a null if passed
in an expected null.

@param topmap the map to act on
@param kvs the KV table snapshot we act on
@param key not null (will result in {@link NullPointerException})
@param putval the new value to use. Not null. {@link #TOMBSTONE} will result in deleting the entry.
@param expVal expected old value. Can be null. {@link #NO_MATCH_OLD} for an unconditional put/remove.
             {@link #TOMBSTONE} if we expect old entry to not exist(null/{@link #TOMBSTONE} value).
             {@link #MATCH_ANY} will ignore the current value, but only if an entry exists. A null expVal is used
              internally to perform a strict insert-if-never-been-seen-before operation.
@return {@link #TOMBSTONE} if key does not exist or match has failed. null if expVal is
null AND old value was null. Otherwise the old entry value (not null).
jctools-core/src/main/java/org/jctools/maps/NonBlockingHashMap.java