Changeset 6918 for trunk/ccl/level-0
- Timestamp:
- Jul 21, 2007, 10:13:54 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/ccl/level-0/l0-hash.lisp
r6534 r6918 245 245 (setf (nhash.vector.flags vector) (logior (ash 1 $nhash_key_moved_bit) flags))))) 246 246 247 #+32-bit-target 247 248 (defun mixup-hash-code (fixnum) 248 249 (declare (fixnum fixnum)) … … 250 251 (+ fixnum 251 252 (the fixnum (%ilsl (- 32 8) 253 (logand (1- (ash 1 (- 8 3))) fixnum)))))) 254 255 #+64-bit-target 256 (defun mixup-hash-code (fixnum) 257 (declare (fixnum fixnum)) 258 (the fixnum 259 (+ fixnum 260 (the fixnum (%ilsl 50 252 261 (logand (1- (ash 1 (- 8 3))) fixnum)))))) 253 262 … … 290 299 291 300 301 #+32-bit-target 292 302 (defun swap (num) 293 303 (declare (fixnum num)) 294 304 (the fixnum (+ (the fixnum (%ilsl 16 num))(the fixnum (%ilsr 13 num))))) 305 306 #+64-bit-target 307 (defun swap (num) 308 (declare (fixnum num)) 309 (the fixnum (+ (the fixnum (%ilsl 32 num))(the fixnum (%ilsr 29 num))))) 295 310 296 311 ;;; teeny bit faster when nothing to do … … 658 673 (report-bad-arg hash 'hash-table)) 659 674 (let* ((value nil) 675 (vector-key nil) 676 (gc-locked nil) 660 677 (foundp nil)) 661 678 (without-interrupts 662 (block protected 663 (lock-hash-table hash) 664 (%lock-gc-lock) 665 (when (%needs-rehashing-p hash) 666 (%rehash hash)) 667 (let* ((vector (nhash.vector hash))) 668 (if (eq key (nhash.vector.cache-key vector)) 669 (setq foundp t 670 value (nhash.vector.cache-value vector)) 671 (let* ((vector-index (funcall (nhash.find hash) hash key)) 672 (vector-key (%svref vector vector-index))) 673 (declare (fixnum vector-index)) 674 (if (setq foundp (and (not (eq vector-key free-hash-key-marker)) 675 (not (eq vector-key deleted-hash-key-marker)))) 676 (setf value (%svref vector (the fixnum (1+ vector-index))) 677 (nhash.vector.cache-key vector) vector-key 678 (nhash.vector.cache-value vector) value 679 (nhash.vector.cache-idx vector) (vector-index->index 680 vector-index))))))) 681 (%unlock-gc-lock) 682 (unlock-hash-table hash)) 679 (lock-hash-table hash) 680 (let* ((vector (nhash.vector hash))) 681 (if (and (eq key (nhash.vector.cache-key vector)) 682 ;; Check twice: the GC might nuke the cached key/value pair 683 (progn (setq value (nhash.vector.cache-value vector)) 684 (eq key (nhash.vector.cache-key vector)))) 685 (setq foundp t) 686 (loop 687 (let* ((vector-index (funcall (nhash.find hash) hash key))) 688 (declare (fixnum vector-index)) 689 ;; Referencing both key and value here - and referencing 690 ;; value first - is an attempt to compensate for the 691 ;; possibility that the GC deletes a weak-on-key pair. 692 (setq value (%svref vector (the fixnum (1+ vector-index))) 693 vector-key (%svref vector vector-index)) 694 (cond ((setq foundp (and (not (eq vector-key free-hash-key-marker)) 695 (not (eq vector-key deleted-hash-key-marker)))) 696 (setf (nhash.vector.cache-key vector) vector-key 697 (nhash.vector.cache-value vector) value 698 (nhash.vector.cache-idx vector) (vector-index->index 699 vector-index)) 700 (return)) 701 ((%needs-rehashing-p hash) 702 (setq gc-locked t) 703 (%lock-gc-lock) 704 (%rehash hash)) 705 (t (return))))))) 706 (when gc-locked (%unlock-gc-lock)) 707 (unlock-hash-table hash)) 683 708 (if foundp 684 709 (values value t) … … 846 871 847 872 848 ;;; Grow the hash table, then add the given (key value) pair.849 873 (defun grow-hash-table (hash) 850 874 (unless (hash-table-p hash)
Note: See TracChangeset
for help on using the changeset viewer.