DCE: delete :optional functionals.
[sbcl.git] / src / code / target-sxhash.lisp
blobe1da32288f10379bfdb769e4e2910c34a65cf5f2
1 ;;;; hashing functions
3 ;;;; This software is part of the SBCL system. See the README file for
4 ;;;; more information.
5 ;;;;
6 ;;;; This software is derived from the CMU CL system, which was
7 ;;;; written at Carnegie Mellon University and released into the
8 ;;;; public domain. The software is in the public domain and is
9 ;;;; provided with absolutely no warranty. See the COPYING and CREDITS
10 ;;;; files for more information.
12 (in-package "SB!IMPL")
14 (defun pointer-hash (key)
15 (pointer-hash key))
17 ;;; the depthoid explored when calculating hash values
18 ;;;
19 ;;; "Depthoid" here is a sort of mixture of what Common Lisp ordinarily calls
20 ;;; depth and what Common Lisp ordinarily calls length; it's incremented either
21 ;;; when we descend into a compound object or when we step through elements of
22 ;;; a compound object.
23 (defconstant +max-hash-depthoid+ 4)
25 ;;;; mixing hash values
27 ;;; a function for mixing hash values
28 ;;;
29 ;;; desiderata:
30 ;;; * Non-commutativity keeps us from hashing e.g. #(1 5) to the
31 ;;; same value as #(5 1), and ending up in real trouble in some
32 ;;; special cases like bit vectors the way that CMUCL 18b SXHASH
33 ;;; does. (Under CMUCL 18b, SXHASH of any bit vector is 1..)
34 ;;; * We'd like to scatter our hash values over the entire possible range
35 ;;; of values instead of hashing small or common key values (like
36 ;;; 2 and NIL and #\a) to small FIXNUMs the way that the CMUCL 18b
37 ;;; SXHASH function does, again helping to avoid pathologies like
38 ;;; hashing all bit vectors to 1.
39 ;;; * We'd like this to be simple and fast, too.
40 (declaim (ftype (sfunction ((and fixnum unsigned-byte)
41 (and fixnum unsigned-byte))
42 (and fixnum unsigned-byte))
43 mix))
44 (declaim (inline mix))
45 (defun mix (x y)
46 (declare (optimize (speed 3)))
47 (declare (type (and fixnum unsigned-byte) x y))
48 ;; the ideas here:
49 ;; * Bits diffuse in both directions (shifted arbitrarily left by
50 ;; the multiplication in the calculation of XY, and shifted
51 ;; right by up to 5 places by the ASH).
52 ;; * The #'+ and #'LOGXOR operations don't commute with each other,
53 ;; so different bit patterns are mixed together as they shift
54 ;; past each other.
55 ;; * The arbitrary constant XOR used in the LOGXOR expression is
56 ;; intended to help break up any weird anomalies we might
57 ;; otherwise get when hashing highly regular patterns.
58 ;; (These are vaguely like the ideas used in many cryptographic
59 ;; algorithms, but we're not pushing them hard enough here for them
60 ;; to be cryptographically strong.)
62 ;; note: 3622009729038463111 is a 62-bit prime such that its low 61
63 ;; bits, low 60 bits and low 29 bits are all also primes, thus
64 ;; giving decent distributions no matter which of the possible
65 ;; values of most-positive-fixnum we have. It is derived by simple
66 ;; search starting from 2^60*pi. The multiplication should be
67 ;; efficient no matter what the platform thanks to modular
68 ;; arithmetic.
69 (let* ((mul (logand 3622009729038463111 sb!xc:most-positive-fixnum))
70 (xor (logand 608948948376289905 sb!xc:most-positive-fixnum))
71 (xy (logand (+ (* x mul) y) sb!xc:most-positive-fixnum)))
72 (logand (logxor xor xy (ash xy -5)) sb!xc:most-positive-fixnum)))
74 ;; Return a number that increments by 1 for each word-pair allocation,
75 ;; barring complications such as exhaustion of the current page.
76 ;; The result is guaranteed to be a positive fixnum.
77 (declaim (inline address-based-counter-val))
78 (defun address-based-counter-val ()
79 #!+(and (not sb-thread) cheneygc)
80 (ash (sap-int (dynamic-space-free-pointer)) (- (1+ sb!vm:word-shift)))
81 ;; dynamic-space-free-pointer increments only when a page is full.
82 ;; Using boxed_region directly is finer-grained.
83 #!+(and (not sb-thread) gencgc)
84 (ash (extern-alien "gc_alloc_region" unsigned-long)
85 (- (1+ sb!vm:word-shift)))
86 ;; threads imply gencgc. use the per-thread alloc region pointer
87 #!+sb-thread
88 (ash (sap-int (sb!vm::current-thread-offset-sap
89 sb!vm::thread-alloc-region-slot))
90 (- (1+ sb!vm:word-shift))))
92 ;; Return some bits that are dependent on the next address that will be
93 ;; allocated, mixed with the previous state (in case addresses get recycled).
94 ;; This algorithm, used for stuffing a hash-code into instances of CTYPE
95 ;; subtypes, is simpler than RANDOM, and a test of randomness won't
96 ;; measure up as well, but for the intended use, it doesn't matter.
97 ;; CLOS hashes could probably be made to use this.
98 (defun quasi-random-address-based-hash (state mask)
99 (declare (type (simple-array (and fixnum unsigned-byte) (1)) state))
100 ;; Ok with multiple threads - No harm, no foul.
101 (logand (setf (aref state 0) (mix (address-based-counter-val) (aref state 0)))
102 mask))
105 ;;;; hashing strings
106 ;;;;
107 ;;;; Note that this operation is used in compiler symbol table
108 ;;;; lookups, so we'd like it to be fast.
109 ;;;;
110 ;;;; As of 2004-03-10, we implement the one-at-a-time algorithm
111 ;;;; designed by Bob Jenkins (see
112 ;;;; <http://burtleburtle.net/bob/hash/doobs.html> for some more
113 ;;;; information).
115 (declaim (inline %sxhash-substring))
116 (defun %sxhash-substring (string &optional (count (length string)))
117 ;; FIXME: As in MIX above, we wouldn't need (SAFETY 0) here if the
118 ;; cross-compiler were smarter about ASH, but we need it for
119 ;; sbcl-0.5.0m. (probably no longer true? We might need SAFETY 0
120 ;; to elide some type checks, but then again if this is inlined in
121 ;; all the critical places, we might not -- CSR, 2004-03-10)
122 (declare (optimize (speed 3) (safety 0)))
123 (declare (type string string))
124 (declare (type index count))
125 (macrolet ((set-result (form)
126 `(setf result (ldb (byte #.sb!vm:n-word-bits 0) ,form))))
127 (let ((result 0))
128 (declare (type (unsigned-byte #.sb!vm:n-word-bits) result))
129 (unless (typep string '(vector nil))
130 (dotimes (i count)
131 (declare (type index i))
132 (set-result (+ result (char-code (aref string i))))
133 (set-result (+ result (ash result 10)))
134 (set-result (logxor result (ash result -6)))))
135 (set-result (+ result (ash result 3)))
136 (set-result (logxor result (ash result -11)))
137 (set-result (logxor result (ash result 15)))
138 (logand result most-positive-fixnum))))
139 ;;; test:
140 ;;; (let ((ht (make-hash-table :test 'equal)))
141 ;;; (do-all-symbols (symbol)
142 ;;; (let* ((string (symbol-name symbol))
143 ;;; (hash (%sxhash-substring string)))
144 ;;; (if (gethash hash ht)
145 ;;; (unless (string= (gethash hash ht) string)
146 ;;; (format t "collision: ~S ~S~%" string (gethash hash ht)))
147 ;;; (setf (gethash hash ht) string))))
148 ;;; (format t "final count=~W~%" (hash-table-count ht)))
150 (defun %sxhash-simple-string (x)
151 (declare (optimize speed))
152 (declare (type simple-string x))
153 ;; KLUDGE: this FLET is a workaround (suggested by APD) for presence
154 ;; of let conversion in the cross compiler, which otherwise causes
155 ;; strongly suboptimal register allocation.
156 (flet ((trick (x)
157 (%sxhash-substring x)))
158 (declare (notinline trick))
159 (trick x)))
161 (defun %sxhash-simple-substring (x count)
162 (declare (optimize speed))
163 (declare (type simple-string x))
164 (declare (type index count))
165 ;; see comment in %SXHASH-SIMPLE-STRING
166 (flet ((trick (x count)
167 (%sxhash-substring x count)))
168 (declare (notinline trick))
169 (trick x count)))
171 ;;;; the SXHASH function
173 ;; simple cases
174 (declaim (ftype (sfunction (integer) hash) sxhash-bignum))
176 (defun new-instance-hash-code ()
177 ;; ANSI SXHASH wants us to make a good-faith effort to produce
178 ;; hash-codes that are well distributed within the range of
179 ;; non-negative fixnums, and this address-based operation does that.
180 ;; This is faster than calling RANDOM, and is random enough.
181 (loop
182 (let ((answer
183 (truly-the fixnum
184 (quasi-random-address-based-hash
185 (load-time-value (make-array 1 :element-type '(and fixnum unsigned-byte))
187 most-positive-fixnum))))
188 (when (plusp answer)
189 ;; Make sure we never return 0 (almost no chance of that anyway).
190 (return answer)))))
193 #!+(and compact-instance-header x86-64)
194 (progn
195 (declaim (inline %std-instance-hash))
196 (defun %std-instance-hash (slots) ; return or compute the 32-bit hash
197 (let ((stored-hash (sb!vm::get-header-data-high slots)))
198 (if (eql stored-hash 0)
199 (let ((new (logand (new-instance-hash-code) #xFFFFFFFF)))
200 (let ((old (sb!vm::cas-header-data-high slots 0 new)))
201 (if (eql old 0) new old)))
202 stored-hash))))
204 (defun std-instance-hash (instance)
205 #!+(and compact-instance-header x86-64)
206 ;; The one logical slot (excluding layout) in the primitive object is index 0.
207 ;; That holds a vector of the clos slots, and its header holds the hash.
208 (let* ((slots (%instance-ref instance 0))
209 (hash (%std-instance-hash slots)))
210 ;; Simulate N-POSITIVE-FIXNUM-BITS of output for backward-compatibility,
211 ;; in case people use the high order bits.
212 ;; (There are only 32 bits of actual randomness, if even that)
213 (logxor (ash hash (- sb!vm:n-positive-fixnum-bits 32)) hash))
214 #!-(and compact-instance-header x86-64)
215 (let ((hash (%instance-ref instance sb!pcl::std-instance-hash-slot-index)))
216 (if (not (eql hash 0))
217 hash
218 (let ((new (new-instance-hash-code)))
219 ;; At most one thread will compute a random hash.
220 ;; %INSTANCE-CAS is a full call if there is no vop for it.
221 (let ((old (%instance-cas instance sb!pcl::std-instance-hash-slot-index
222 0 new)))
223 (if (eql old 0) new old))))))
225 ;; These are also random numbers, but not lazily computed.
226 (declaim (inline fsc-instance-hash))
227 (defun fsc-instance-hash (fin)
228 #!+compact-instance-header
229 (sb!vm::get-header-data-high (%funcallable-instance-info fin 0))
230 #!-compact-instance-header
231 (%funcallable-instance-info fin sb!pcl::fsc-instance-hash-slot-index))
233 (defun sxhash (x)
234 ;; profiling SXHASH is hard, but we might as well try to make it go
235 ;; fast, in case it is the bottleneck somewhere. -- CSR, 2003-03-14
236 (declare (optimize speed))
237 (labels ((sxhash-number (x)
238 (macrolet ((hash-complex-float ()
239 `(let ((result 535698211))
240 (declare (type fixnum result))
241 (mixf result (sxhash (realpart x)))
242 (mixf result (sxhash (imagpart x)))
243 result)))
244 (etypecase x
245 (fixnum (sxhash x)) ; through DEFTRANSFORM
246 (integer (sb!bignum:sxhash-bignum x))
247 (single-float (sxhash x)) ; through DEFTRANSFORM
248 (double-float (sxhash x)) ; through DEFTRANSFORM
249 #!+long-float (long-float (error "stub: no LONG-FLOAT"))
250 (ratio (let ((result 127810327))
251 (declare (type fixnum result))
252 (mixf result (sxhash-number (numerator x)))
253 (mixf result (sxhash-number (denominator x)))
254 result))
255 #!+long-float
256 ((complex long-float)
257 (hash-complex-float))
258 ((complex double-float)
259 (hash-complex-float))
260 ((complex single-float)
261 (hash-complex-float))
262 ((complex rational)
263 (let ((result 535698211)
264 (realpart (realpart x))
265 (imagpart (imagpart x)))
266 (declare (type fixnum result))
267 (mixf result (if (fixnump imagpart)
268 (sxhash imagpart)
269 (sxhash-number imagpart)))
270 (mixf result (if (fixnump realpart)
271 (sxhash realpart)
272 (sxhash-number realpart)))
273 result)))))
274 (sxhash-recurse (x depthoid)
275 (declare (type index depthoid))
276 (typecase x
277 ;; we test for LIST here, rather than CONS, because the
278 ;; type test for CONS is in fact the test for
279 ;; LIST-POINTER-LOWTAG followed by a negated test for
280 ;; NIL. If we're going to have to test for NIL anyway,
281 ;; we might as well do it explicitly and pick off the
282 ;; answer. -- CSR, 2004-07-14
283 (list
284 (if (null x)
285 (sxhash x) ; through DEFTRANSFORM
286 (if (plusp depthoid)
287 (mix (sxhash-recurse (car x) (1- depthoid))
288 (sxhash-recurse (cdr x) (1- depthoid)))
289 261835505)))
290 (instance
291 (typecase x
292 (pathname
293 ;; Pathnames are EQUAL if all the components are EQUAL, so
294 ;; we hash all of the components of a pathname together.
295 (let ((hash (sxhash-recurse (pathname-host x) depthoid)))
296 (mixf hash (sxhash-recurse (pathname-device x) depthoid))
297 (mixf hash (%pathname-dir-hash x))
298 (mixf hash (%pathname-stem-hash x))
299 ;; Hash :NEWEST the same as NIL because EQUAL for
300 ;; pathnames assumes that :newest and nil are equal.
301 (let ((version (%pathname-version x)))
302 (mixf hash (sxhash-recurse (if (eq version :newest)
304 version)
305 depthoid)))))
306 (layout
307 ;; LAYOUTs have an easily-accesible hash value: we
308 ;; might as well use it. It's not actually uniform
309 ;; over the space of hash values (it excludes 0 and
310 ;; some of the larger numbers) but it's better than
311 ;; simply returning the same value for all LAYOUT
312 ;; objects, as the next branch would do.
313 (layout-clos-hash x))
314 (structure-object
315 (logxor 422371266
316 ;; FIXME: why not (LAYOUT-CLOS-HASH ...) ?
317 (sxhash ; through DEFTRANSFORM
318 (classoid-name
319 (layout-classoid (%instance-layout x))))))
320 (condition (sb!kernel::condition-hash x))
321 (t (std-instance-hash x))))
322 (symbol (sxhash x)) ; through DEFTRANSFORM
323 (array
324 (typecase x
325 (simple-string (sxhash x)) ; through DEFTRANSFORM
326 (string (%sxhash-substring x))
327 (simple-bit-vector (sxhash x)) ; through DEFTRANSFORM
328 (bit-vector
329 ;; FIXME: It must surely be possible to do better
330 ;; than this. The problem is that a non-SIMPLE
331 ;; BIT-VECTOR could be displaced to another, with a
332 ;; non-zero offset -- so that significantly more
333 ;; work needs to be done using the %VECTOR-RAW-BITS
334 ;; approach. This will probably do for now.
335 (sxhash-recurse (copy-seq x) depthoid))
336 (t (logxor 191020317 (sxhash (array-rank x))))))
337 (character
338 (logxor 72185131
339 (sxhash (char-code x)))) ; through DEFTRANSFORM
340 ;; general, inefficient case of NUMBER
341 (number (sxhash-number x))
342 (funcallable-instance
343 (typecase x
344 #!+sb-fasteval
345 (sb!interpreter:interpreted-function
346 9550684)
347 #!+sb-eval
348 (sb!eval:interpreted-function
349 9550684)
351 (fsc-instance-hash x))))
352 (t 42))))
353 (sxhash-recurse x +max-hash-depthoid+)))
355 ;;;; the PSXHASH function
357 ;;;; FIXME: This code does a lot of unnecessary full calls. It could be made
358 ;;;; more efficient (in both time and space) by rewriting it along the lines
359 ;;;; of the SXHASH code above.
361 ;;; like SXHASH, but for EQUALP hashing instead of EQUAL hashing
362 (defun psxhash (key &optional (depthoid +max-hash-depthoid+))
363 (declare (optimize speed))
364 (declare (type (integer 0 #.+max-hash-depthoid+) depthoid))
365 ;; Note: You might think it would be cleaner to use the ordering given in the
366 ;; table from Figure 5-13 in the EQUALP section of the ANSI specification
367 ;; here. So did I, but that is a snare for the unwary! Nothing in the ANSI
368 ;; spec says that HASH-TABLE can't be a STRUCTURE-OBJECT, and in fact our
369 ;; HASH-TABLEs *are* STRUCTURE-OBJECTs, so we need to pick off the special
370 ;; HASH-TABLE behavior before we fall through to the generic STRUCTURE-OBJECT
371 ;; comparison behavior.
372 (typecase key
373 (array (array-psxhash key depthoid))
374 (hash-table (hash-table-psxhash key))
375 (pathname (sxhash key))
376 (structure-object (structure-object-psxhash key depthoid))
377 (cons (list-psxhash key depthoid))
378 (number (number-psxhash key))
379 (character (char-code (char-upcase key)))
380 (t (sxhash key))))
382 (defun array-psxhash (key depthoid)
383 (declare (optimize speed))
384 (declare (type array key))
385 (declare (type (integer 0 #.+max-hash-depthoid+) depthoid))
386 (typecase key
387 ;; VECTORs have to be treated specially because ANSI specifies
388 ;; that we must respect fill pointers.
389 (vector
390 (macrolet ((frob ()
391 `(let ((result 572539))
392 (declare (type fixnum result))
393 (mixf result (length key))
394 (when (plusp depthoid)
395 (decf depthoid)
396 (dotimes (i (length key))
397 (declare (type fixnum i))
398 (mixf result
399 (psxhash (aref key i) depthoid))))
400 result))
401 (make-dispatch (types)
402 `(typecase key
403 ,@(loop for type in types
404 collect `(,type
405 (frob))))))
406 (make-dispatch (simple-base-string
407 (simple-array character (*))
408 simple-vector
409 (simple-array (unsigned-byte 8) (*))
410 (simple-array fixnum (*))
411 t))))
412 ;; Any other array can be hashed by working with its underlying
413 ;; one-dimensional physical representation.
415 (let ((result 60828))
416 (declare (type fixnum result))
417 (dotimes (i (array-rank key))
418 (mixf result (%array-dimension key i)))
419 (when (plusp depthoid)
420 (decf depthoid)
421 (with-array-data ((key key) (start) (end))
422 (let ((getter (truly-the function (svref %%data-vector-reffers%%
423 (%other-pointer-widetag key)))))
424 (loop for i from start below end
425 do (mixf result
426 (psxhash (funcall getter key i) depthoid))))))
427 result))))
429 (defun structure-object-psxhash (key depthoid)
430 (declare (optimize speed))
431 (declare (type structure-object key))
432 (declare (type (integer 0 #.+max-hash-depthoid+) depthoid))
433 (let* ((layout (%instance-layout key))
434 (result (layout-clos-hash layout)))
435 (declare (type fixnum result))
436 (when (plusp depthoid)
437 (let ((max-iterations depthoid)
438 (depthoid (1- depthoid)))
439 ;; We don't mix in LAYOUT here because it was already done above.
440 (do-instance-tagged-slot (i key :layout layout :pad nil)
441 (mixf result (psxhash (%instance-ref key i) depthoid))
442 (if (zerop (decf max-iterations)) (return)))))
443 ;; [The following comment blurs some issues: indeed it would take
444 ;; a second loop in the non-interleaved-slots code; that loop might
445 ;; never execute because depthoid "cuts off", although that's an arbitrary
446 ;; choice and could be decided otherwise; and efficiency would likely
447 ;; demand that we store some additional metadata in the LAYOUT indicating
448 ;; how to mix the bits in, because floating-point +/-zeros have to
449 ;; be considered EQUALP]
450 ;; KLUDGE: Should hash untagged slots, too. (Although +max-hash-depthoid+
451 ;; is pretty low currently, so they might not make it into the hash
452 ;; value anyway.)
453 result))
455 (defun list-psxhash (key depthoid)
456 (declare (optimize speed))
457 (declare (type list key))
458 (declare (type (integer 0 #.+max-hash-depthoid+) depthoid))
459 (cond ((null key)
460 (the fixnum 480929))
461 ((zerop depthoid)
462 (the fixnum 779578))
464 (mix (psxhash (car key) (1- depthoid))
465 (psxhash (cdr key) (1- depthoid))))))
467 (defun hash-table-psxhash (key)
468 (declare (optimize speed))
469 (declare (type hash-table key))
470 (let ((result 103924836))
471 (declare (type fixnum result))
472 (mixf result (hash-table-count key))
473 (mixf result (sxhash (hash-table-test key)))
474 result))
476 (defun number-psxhash (key)
477 (declare (type number key)
478 (muffle-conditions compiler-note)
479 (optimize speed))
480 (flet ((sxhash-double-float (val)
481 (declare (type double-float val))
482 ;; FIXME: Check to make sure that the DEFTRANSFORM kicks in and the
483 ;; resulting code works without consing. (In Debian cmucl 2.4.17,
484 ;; it didn't.)
485 (sxhash val)))
486 (macrolet ((hash-float (type key)
487 (let ((lo (coerce sb!xc:most-negative-fixnum type))
488 (hi (coerce sb!xc:most-positive-fixnum type)))
489 `(let ((key ,key))
490 (cond ( ;; This clause allows FIXNUM-sized integer
491 ;; values to be handled without consing.
492 (<= ,lo key ,hi)
493 (multiple-value-bind (q r)
494 (floor (the (,type ,lo ,hi) key))
495 (if (zerop (the ,type r))
496 (sxhash q)
497 (sxhash-double-float
498 (coerce key 'double-float)))))
499 ((float-infinity-p key)
500 ;; {single,double}-float infinities are EQUALP
501 (if (minusp key)
502 (load-time-value
503 (sxhash (symbol-value 'sb!ext:single-float-negative-infinity))
505 (load-time-value
506 (sxhash (symbol-value 'sb!ext:single-float-positive-infinity))
507 t)))
509 (multiple-value-bind (q r) (floor key)
510 (if (zerop (the ,type r))
511 (sxhash q)
512 (sxhash-double-float
513 (coerce key 'double-float)))))))))
514 (hash-complex (&optional (hasher '(number-psxhash)))
515 `(if (zerop (imagpart key))
516 (,@hasher (realpart key))
517 (let ((result 330231))
518 (declare (type fixnum result))
519 (mixf result (,@hasher (realpart key)))
520 (mixf result (,@hasher (imagpart key)))
521 result))))
522 (etypecase key
523 (integer (sxhash key))
524 (float (macrolet ()
525 (etypecase key
526 (single-float (hash-float single-float key))
527 (double-float (hash-float double-float key))
528 #!+long-float
529 (long-float (error "LONG-FLOAT not currently supported")))))
530 (rational (if (and (<= most-negative-double-float
532 most-positive-double-float)
533 (= (coerce key 'double-float) key))
534 (sxhash-double-float (coerce key 'double-float))
535 (sxhash key)))
536 ((complex double-float)
537 (hash-complex (hash-float double-float)))
538 ((complex single-float)
539 (hash-complex (hash-float single-float)))
540 ((complex rational)
541 (hash-complex))))))
543 ;;; Semantic equivalent of SXHASH, but better-behaved for function names.
544 ;;; It performs more work by not cutting off as soon in the CDR direction.
545 ;;; More work here equates to less work in the global hashtable.
546 ;;; To wit: (eq (sxhash '(foo a b c bar)) (sxhash '(foo a b c d))) => T
547 ;;; but the corresponding globaldb-sxhashoids differ.
548 (defun globaldb-sxhashoid (name)
549 (locally
550 (declare (optimize (safety 0))) ; after the argc check
551 ;; TRAVERSE will walk across more cons cells than RECURSE will descend.
552 ;; That's why this isn't just one self-recursive function.
553 (labels ((traverse (accumulator x length-limit)
554 (declare (fixnum length-limit))
555 (cond ((atom x) (mix (sxhash x) accumulator))
556 ((zerop length-limit) accumulator)
557 (t (traverse (mix (recurse (car x) 4) accumulator)
558 (cdr x) (1- length-limit)))))
559 (recurse (x depthoid) ; depthoid = a blend of level and length
560 (declare (fixnum depthoid))
561 (cond ((atom x) (sxhash x))
562 ((zerop depthoid)
563 #.(logand sb!xc:most-positive-fixnum #36Rglobaldbsxhashoid))
564 (t (mix (recurse (car x) (1- depthoid))
565 (recurse (cdr x) (1- depthoid)))))))
566 (traverse 0 name 10))))