Changeset 6428
 Timestamp:
 May 5, 2007, 11:24:20 PM (15 years ago)
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

trunk/ccl/level0/l0hash.lisp
r6015 r6428 766 766 (withoutinterrupts 767 767 (block protected 768 (lockhashtable hash) 769 (%lockgclock) 770 (when (%needsrehashingp hash) 771 (%rehash hash)) 772 (do* ((iterator (nhash.iterator hash) (hti.previterator iterator))) 773 ((null iterator)) 774 (let* ((vector (hti.vector iterator)) 775 (index (index>vectorindex (hti.index iterator))) 776 (test (hashtabletest hash))) 777 (declare (fixnum index)) 778 (when (and (< index (the fixnum (uvsize vector))) 779 (not (funcall test (%svref vector index) key))) 780 (unlockhashtable hash) 781 (%unlockgclock) 782 (error "Can't add key ~s during iteration on hashtable ~s" 783 key hash)))) 784 (let ((vector (nhash.vector hash))) 785 (when (eq key (nhash.vector.cachekey vector)) 786 (let* ((idx (nhash.vector.cacheidx vector))) 787 (declare (fixnum idx)) 788 (setf (%svref vector (the fixnum (1+ (the fixnum (index>vectorindex idx))))) 789 value) 790 (setf (nhash.vector.cachevalue vector) value) 791 (returnfrom protected))) 792 (let* ((vectorindex (funcall (nhash.findnew hash) hash key)) 793 (oldvalue (%svref vector vectorindex))) 794 (declare (fixnum vectorindex)) 795 796 (cond ((eq oldvalue deletedhashkeymarker) 797 (%sethashtablevectorkey vector vectorindex key) 798 (setf (%svref vector (the fixnum (1+ vectorindex))) value) 799 (setf (nhash.count hash) (the fixnum (1+ (the fixnum (nhash.count hash))))) 800 ;; Adjust deletedcount 801 (when (> 0 (the fixnum 802 (decf (the fixnum 803 (nhash.vector.deletedcount vector))))) 804 (let ((weakdeletions (nhash.vector.weakdeletionscount vector))) 805 (declare (fixnum weakdeletions)) 806 (setf (nhash.vector.weakdeletionscount vector) 0) 807 (incf (the fixnum (nhash.vector.deletedcount vector)) weakdeletions) 808 (decf (the fixnum (nhash.count hash)) weakdeletions)))) 809 ((eq oldvalue freehashkeymarker) 810 (when (eql 0 (nhash.growthreshold hash)) 811 (growhashtable hash) 812 (returnfrom protected (puthash key hash value))) 813 (%sethashtablevectorkey vector vectorindex key) 814 (setf (%svref vector (the fixnum (1+ vectorindex))) value) 815 (decf (the fixnum (nhash.growthreshold hash))) 816 (incf (the fixnum (nhash.count hash)))) 817 (t 818 ;; Key was already there, update value. 819 (setf (%svref vector (the fixnum (1+ vectorindex))) value))) 820 (setf (nhash.vector.cacheidx vector) (vectorindex>index vectorindex) 821 (nhash.vector.cachekey vector) key 822 (nhash.vector.cachevalue vector) value)))) 768 (tagbody 769 (lockhashtable hash) 770 AGAIN 771 (%lockgclock) 772 (when (%needsrehashingp hash) 773 (%rehash hash)) 774 (do* ((iterator (nhash.iterator hash) (hti.previterator iterator))) 775 ((null iterator)) 776 (let* ((vector (hti.vector iterator)) 777 (index (index>vectorindex (hti.index iterator))) 778 (test (hashtabletest hash))) 779 (declare (fixnum index)) 780 (when (and (< index (the fixnum (uvsize vector))) 781 (not (funcall test (%svref vector index) key))) 782 (unlockhashtable hash) 783 (%unlockgclock) 784 (error "Can't add key ~s during iteration on hashtable ~s" 785 key hash)))) 786 (let ((vector (nhash.vector hash))) 787 (when (eq key (nhash.vector.cachekey vector)) 788 (let* ((idx (nhash.vector.cacheidx vector))) 789 (declare (fixnum idx)) 790 (setf (%svref vector (the fixnum (1+ (the fixnum (index>vectorindex idx))))) 791 value) 792 (setf (nhash.vector.cachevalue vector) value) 793 (returnfrom protected))) 794 (let* ((vectorindex (funcall (nhash.findnew hash) hash key)) 795 (oldvalue (%svref vector vectorindex))) 796 (declare (fixnum vectorindex)) 797 798 (cond ((eq oldvalue deletedhashkeymarker) 799 (%sethashtablevectorkey vector vectorindex key) 800 (setf (%svref vector (the fixnum (1+ vectorindex))) value) 801 (setf (nhash.count hash) (the fixnum (1+ (the fixnum (nhash.count hash))))) 802 ;; Adjust deletedcount 803 (when (> 0 (the fixnum 804 (decf (the fixnum 805 (nhash.vector.deletedcount vector))))) 806 (let ((weakdeletions (nhash.vector.weakdeletionscount vector))) 807 (declare (fixnum weakdeletions)) 808 (setf (nhash.vector.weakdeletionscount vector) 0) 809 (incf (the fixnum (nhash.vector.deletedcount vector)) weakdeletions) 810 (decf (the fixnum (nhash.count hash)) weakdeletions)))) 811 ((eq oldvalue freehashkeymarker) 812 (when (eql 0 (nhash.growthreshold hash)) 813 (%unlockgclock) 814 (growhashtable hash) 815 (go AGAIN)) 816 (%sethashtablevectorkey vector vectorindex key) 817 (setf (%svref vector (the fixnum (1+ vectorindex))) value) 818 (decf (the fixnum (nhash.growthreshold hash))) 819 (incf (the fixnum (nhash.count hash)))) 820 (t 821 ;; Key was already there, update value. 822 (setf (%svref vector (the fixnum (1+ vectorindex))) value))) 823 (setf (nhash.vector.cacheidx vector) (vectorindex>index vectorindex) 824 (nhash.vector.cachekey vector) key 825 (nhash.vector.cachevalue vector) value))))) 823 826 (%unlockgclock) 824 827 (unlockhashtable hash))
Note: See TracChangeset
for help on using the changeset viewer.