- (without-gcing
- ;; We need to rehash here so that a current key can be found if it
- ;; exists.
- (cond ((= (get-header-data (hash-table-table hash-table))
- sb!vm:vector-must-rehash-subtype)
- (rehash-without-growing hash-table))
- ((not (zerop (hash-table-needing-rehash hash-table)))
- (flush-needing-rehash hash-table)))
-
- ;; Search for key in the hash table.
- (multiple-value-bind (hashing eq-based)
- (funcall (hash-table-hash-fun hash-table) key)
- (declare (type hash hashing))
- (let* ((index-vector (hash-table-index-vector hash-table))
- (length (length index-vector))
- (index (rem hashing length))
- (next (aref index-vector index))
- (table (hash-table-table hash-table))
- (next-vector (hash-table-next-vector hash-table))
- (hash-vector (hash-table-hash-vector hash-table))
- (test-fun (hash-table-test-fun hash-table)))
- (declare (type index index next))
- (flet ((clear-slot (chain-vector prior-slot-location slot-location)
- ;; Mark slot as empty.
- (setf (aref table (* 2 slot-location)) +empty-ht-slot+
- (aref table (1+ (* 2 slot-location))) +empty-ht-slot+)
- ;; Update the prior pointer in the chain to skip this.
- (setf (aref chain-vector prior-slot-location)
- (aref next-vector slot-location))
- ;; Push KV slot onto free chain.
- (setf (aref next-vector slot-location)
- (hash-table-next-free-kv hash-table))
- (setf (hash-table-next-free-kv hash-table) slot-location)
- (when hash-vector
- (setf (aref hash-vector slot-location) +magic-hash-vector-value+))
- (decf (hash-table-number-entries hash-table))
- t))
- (cond ((zerop next)
- nil)
- ((if (or eq-based (not hash-vector))
- (eq key (aref table (* 2 next)))
- (and (= hashing (aref hash-vector next))
- (funcall test-fun key (aref table (* 2 next)))))
- (clear-slot index-vector index next))
- ;; Search next-vector chain for a matching key.
- ((or eq-based (not hash-vector))
- ;; EQ based
- (do ((prior next next)
- (next (aref next-vector next) (aref next-vector next)))
- ((zerop next) nil)
- (declare (type index next))
- (when (eq key (aref table (* 2 next)))
- (return-from remhash (clear-slot next-vector prior next)))))
- (t
- ;; not EQ based
- (do ((prior next next)
- (next (aref next-vector next) (aref next-vector next)))
- ((zerop next) nil)
- (declare (type index next))
- (when (and (= hashing (aref hash-vector next))
- (funcall test-fun key (aref table (* 2 next))))
- (return-from remhash (clear-slot next-vector prior next)))))))))))
+ (with-spinlock-and-without-gcing ((hash-table-spinlock hash-table))
+ remhash
+ ;; We need to rehash here so that a current key can be found if it
+ ;; exists.
+ (cond ((= (get-header-data (hash-table-table hash-table))
+ sb!vm:vector-must-rehash-subtype)
+ (rehash-without-growing hash-table))
+ ((not (zerop (hash-table-needing-rehash hash-table)))
+ (flush-needing-rehash hash-table)))
+
+ ;; For now, just clear the cache
+ (setf (hash-table-cache hash-table) nil)
+
+ ;; Search for key in the hash table.
+ (multiple-value-bind (hashing eq-based)
+ (funcall (hash-table-hash-fun hash-table) key)
+ (declare (type hash hashing))
+ (let* ((index-vector (hash-table-index-vector hash-table))
+ (length (length index-vector))
+ (index (rem hashing length))
+ (next (aref index-vector index))
+ (table (hash-table-table hash-table))
+ (next-vector (hash-table-next-vector hash-table))
+ (hash-vector (hash-table-hash-vector hash-table))
+ (test-fun (hash-table-test-fun hash-table)))
+ (declare (type index index)
+ (type index/2 next))
+ (flet ((clear-slot (chain-vector prior-slot-location slot-location)
+ (declare (type index/2 slot-location))
+ ;; Mark slot as empty.
+ (setf (aref table (* 2 slot-location)) +empty-ht-slot+
+ (aref table (1+ (* 2 slot-location))) +empty-ht-slot+)
+ ;; Update the prior pointer in the chain to skip this.
+ (setf (aref chain-vector prior-slot-location)
+ (aref next-vector slot-location))
+ ;; Push KV slot onto free chain.
+ (setf (aref next-vector slot-location)
+ (hash-table-next-free-kv hash-table))
+ (setf (hash-table-next-free-kv hash-table) slot-location)
+ (when hash-vector
+ (setf (aref hash-vector slot-location)
+ +magic-hash-vector-value+))
+ (decf (hash-table-number-entries hash-table))
+ t))
+ (cond ((zerop next)
+ nil)
+ ((if (or eq-based (not hash-vector))
+ (eq key (aref table (* 2 next)))
+ (and (= hashing (aref hash-vector next))
+ (funcall test-fun key (aref table (* 2 next)))))
+ (clear-slot index-vector index next))
+ ;; Search next-vector chain for a matching key.
+ ((or eq-based (not hash-vector))
+ ;; EQ based
+ (do ((prior next next)
+ (next (aref next-vector next) (aref next-vector next)))
+ ((zerop next) nil)
+ (declare (type index next))
+ (when (eq key (aref table (* 2 next)))
+ (return-from remhash (clear-slot next-vector prior next)))))
+ (t
+ ;; not EQ based
+ (do ((prior next next)
+ (next (aref next-vector next) (aref next-vector next)))
+ ((zerop next) nil)
+ (declare (type index/2 next))
+ (when (and (= hashing (aref hash-vector next))
+ (funcall test-fun key (aref table (* 2 next))))
+ (return-from remhash
+ (clear-slot next-vector prior next)))))))))))