Changeset 9999
 Timestamp:
 Jul 10, 2008, 11:12:28 AM (11 years ago)
 Location:
 trunk/source
 Files:

 3 edited
Legend:
 Unmodified
 Added
 Removed

trunk/source/level0/X86/x86hash.lisp
r4415 r9999 37 37 (singlevaluereturn)) 38 38 39 40 ;; Faster mod based on Bruce Hoult's Dylan version, modified to use a branchfree max. 41 (defx86lapfunction fastmod3 ((number arg_x) (divisor arg_y) (recip arg_z)) 42 (mov (% number) (% imm0)) 43 (shrq ($ target::fixnumshift) (% imm0)) 44 (mov (% recip) (% imm1)) 45 (mul (% imm1)) ;; > hi word in imm1 (unboxed) 46 (mov (% divisor) (% imm0)) 47 (mul (% imm1)) ;; > lo word in imm0 (boxed) 48 (subq (% imm0) (% number)) 49 (subq (% divisor) (% number)) 50 (mov (% number) (% arg_z)) 51 (mov (% number) (% imm0)) 52 (sar ($ (1 target::nbitsinword)) (% imm0)) 53 (andq (% imm0) (% divisor)) 54 (addq (% divisor) (% arg_z)) 55 (singlevaluereturn)) 39 56 40 57 (defx86lapfunction %dfloathash ((key arg_z)) 
trunk/source/level0/l0hash.lisp
r9912 r9999 213 213 214 214 (defun nhash.vectorsize (vector) 215 (ash (the fixnum ( (the fixnum (uvsize vector)) $nhash.vector_overhead)) 1)) 215 (nhash.vector.size vector)) 216 217 (evalwhen (:compiletoplevel :execute) (declaim (inline hashmod))) 218 (defun hashmod (hash entries vector) 219 (fastmod3 hash entries (nhash.vector.sizereciprocal vector))) 216 220 217 221 ;;; Is KEY something which can be EQL to something it's not EQ to ? … … 430 434 (setq flags (bitset $nhash_component_address_bit flags)))) 431 435 (setf (nhash.vector.flags vector) flags)))) 432 (let* ((length ( (the fixnum (uvsize vector)) $nhash.vector_overhead)) 433 (entries (ash length 1))) 434 (declare (fixnum length entries)) 436 (let* ((entries (nhash.vectorsize vector))) 437 (declare (fixnum entries)) 435 438 (values primary 436 ( fastmod primary entries)439 (hashmod primary entries vector) 437 440 entries)))) 438 441 … … 1091 1094 (%hashsymbol key) 1092 1095 (mixuphashcode (striptagtofixnum key))))))) 1093 (length (uvsize vector)) 1094 (count ( length $nhash.vector_overhead)) 1095 (entries (ash count 1)) 1096 (vectorindex (index>vectorindex (fastmod hashcode entries))) 1096 (entries (nhash.vectorsize vector)) 1097 (vectorindex (index>vectorindex (hashmod hashcode entries vector))) 1097 1098 (tablekey (%svref vector vectorindex))) 1098 (declare (fixnum hashcode entries vectorindex count length))1099 (declare (fixnum hashcode entries vectorindex)) 1099 1100 (if (or (eq key tablekey) 1100 1101 (eq tablekey freehashkeymarker)) … … 1104 1105 (initialindex vectorindex) 1105 1106 (firstdeletedindex (if (eq tablekey deletedhashkeymarker) 1106 vectorindex))) 1107 (declare (fixnum secondaryhash initialindex)) 1107 vectorindex)) 1108 (count (+ entries entries)) 1109 (length (+ count $nhash.vector_overhead))) 1110 (declare (fixnum secondaryhash initialindex count length)) 1108 1111 (loop 1109 1112 (incf vectorindex secondaryhash) … … 1145 1148 (logior $nhashtrackkeysmask flags)))) 1146 1149 (mixuphashcode (striptagtofixnum key)))))))) 1147 (length (uvsize vector)) 1148 (count ( length $nhash.vector_overhead)) 1149 (vectorindex (index>vectorindex (fastmod hashcode (ash count 1)))) 1150 (entries (nhash.vectorsize vector)) 1151 (vectorindex (index>vectorindex (hashmod hashcode entries vector))) 1150 1152 (tablekey (%svref vector vectorindex))) 1151 (declare (fixnum hashcode length countvectorindex))1153 (declare (fixnum hashcode vectorindex)) 1152 1154 (if (or (eq key tablekey) 1153 1155 (eq tablekey freehashkeymarker)) … … 1157 1159 (initialindex vectorindex) 1158 1160 (firstdeletedindex (if (eq tablekey deletedhashkeymarker) 1159 vectorindex))) 1160 (declare (fixnum secondaryhash initialindex)) 1161 vectorindex)) 1162 (count (+ entries entries)) 1163 (length (+ count $nhash.vector_overhead))) 1164 (declare (fixnum secondaryhash initialindex count length)) 1161 1165 (loop 1162 1166 (incf vectorindex secondaryhash) … … 1179 1183 (let* ((vector (nhash.vector hash)) 1180 1184 (hashcode (%%eqlhashinternal key)) 1181 (length (uvsize vector)) 1182 (count ( length $nhash.vector_overhead)) 1183 (entries (ash count 1)) 1184 (vectorindex (index>vectorindex (fastmod hashcode entries))) 1185 (entries (nhash.vectorsize vector)) 1186 (vectorindex (index>vectorindex (hashmod hashcode entries vector))) 1185 1187 (tablekey (%svref vector vectorindex))) 1186 (declare (fixnum hashcode length entries countvectorindex))1188 (declare (fixnum hashcode entries vectorindex)) 1187 1189 (if (or (eql key tablekey) 1188 1190 (eq tablekey freehashkeymarker)) … … 1192 1194 (initialindex vectorindex) 1193 1195 (firstdeletedindex (if (eq tablekey deletedhashkeymarker) 1194 vectorindex))) 1195 (declare (fixnum secondaryhash initialindex)) 1196 vectorindex)) 1197 (count (+ entries entries)) 1198 (length (+ count $nhash.vector_overhead))) 1199 (declare (fixnum secondaryhash initialindex count length)) 1196 1200 (loop 1197 1201 (incf vectorindex secondaryhash) … … 1215 1219 (let* ((vector (nhash.vector hash)) 1216 1220 (hashcode (%%eqlhashinternal key)) 1217 (length (uvsize vector)) 1218 (count ( length $nhash.vector_overhead)) 1219 (entries (ash count 1)) 1220 (vectorindex (index>vectorindex (fastmod hashcode entries))) 1221 (entries (nhash.vectorsize vector)) 1222 (vectorindex (index>vectorindex (hashmod hashcode entries vector))) 1221 1223 (tablekey (%svref vector vectorindex))) 1222 (declare (fixnum hashcode lengthentries vectorindex))1224 (declare (fixnum hashcode entries vectorindex)) 1223 1225 (if (or (eql key tablekey) 1224 1226 (eq tablekey freehashkeymarker)) … … 1228 1230 (initialindex vectorindex) 1229 1231 (firstdeletedindex (if (eq tablekey deletedhashkeymarker) 1230 vectorindex))) 1231 (declare (fixnum secondaryhash initialindex)) 1232 vectorindex)) 1233 (count (+ entries entries)) 1234 (length (+ count $nhash.vector_overhead))) 1235 (declare (fixnum secondaryhash initialindex count length)) 1232 1236 (loop 1233 1237 (incf vectorindex secondaryhash) … … 1684 1688 (nhash.vector.cachekey vector) (%unboundmarker) 1685 1689 (nhash.vector.cachevalue vector) nil 1686 (nhash.vector.cacheidx vector) nil) 1690 (nhash.vector.cacheidx vector) nil 1691 (nhash.vector.size vector) size 1692 (nhash.vector.sizereciprocal vector) (floor (ash 1 ( target::nbitsinword target::fixnumshift)) size)) 1687 1693 vector)) 1688 1694 
trunk/source/xdump/hashenv.lisp
r7959 r9999 32 32 (defconstant $nhash.locknotwhilerehashing #x20001) 33 33 34 ; The hash.vector cell contains a vector with 8longwords of overhead34 ; The hash.vector cell contains a vector with some longwords of overhead 35 35 ; followed by alternating keys and values. 36 36 ; A key of $undefined denotes an empty or deleted value … … 47 47 nhash.vector.cachekey ; cached key 48 48 nhash.vector.cachevalue ; cached value 49 nhash.vector.size ; number of entries in table 50 nhash.vector.sizereciprocal ; shifted reciprocal of nhash.vector.size 49 51 ) 52 50 53 51 54 ; number of longwords of overhead in nhash.vector. 52 55 ; Must be a multiple of 2 or INDEX parameters in LAP code will not be tagged as fixnums. 53 (defconstant $nhash.vector_overhead 1 0)56 (defconstant $nhash.vector_overhead 12) 54 57 55 58 (defconstant $nhash_weak_bit 12) ; weak hash table
Note: See TracChangeset
for help on using the changeset viewer.