1 ;;;; that part of SXHASH logic which runs not only in the target Lisp but
2 ;;;; in the cross-compilation host Lisp
4 ;;;; This software is part of the SBCL system. See the README file for
7 ;;;; This software is derived from the CMU CL system, which was
8 ;;;; written at Carnegie Mellon University and released into the
9 ;;;; public domain. The software is in the public domain and is
10 ;;;; provided with absolutely no warranty. See the COPYING and CREDITS
11 ;;;; files for more information.
15 (sb!xc:define-modify-macro mixf (y) mix)
17 ;;; SXHASH of FLOAT values is defined directly in terms of DEFTRANSFORM in
18 ;;; order to avoid boxing.
19 (deftransform sxhash ((x) (single-float))
20 '(let ((bits (single-float-bits x)))
23 (logand most-positive-fixnum
26 (deftransform sxhash ((x) (double-float))
28 (hi (double-float-high-bits val))
29 (lo (double-float-low-bits val))
30 (hilo (logxor hi lo)))
33 (logand most-positive-fixnum
37 ;;; SXHASH of FIXNUM values is defined as a DEFTRANSFORM because it's so
39 (deftransform sxhash ((x) (fixnum))
40 '(logand most-positive-fixnum
42 (ash x -3) ; to get sign bit into hash
45 ;;; Some other common SXHASH cases are defined as DEFTRANSFORMs in
46 ;;; order to avoid having to do TYPECASE at runtime.
48 ;;; We also take the opportunity to handle the cases of constant
49 ;;; strings, and of symbols whose names are known at compile time;
50 ;;; except that since SXHASH on the cross-compilation host is not in
51 ;;; general compatible with SXHASH on the target SBCL, we can't so
52 ;;; easily do this optimization in the cross-compiler, and SBCL itself
53 ;;; doesn't seem to need this optimization, so we don't try.
54 (deftransform sxhash ((x) (simple-string))
55 (if #+sb-xc-host nil #-sb-xc-host (constant-continuation-p x)
56 (sxhash (continuation-value x))
57 '(%sxhash-simple-string x)))
58 (deftransform sxhash ((x) (symbol))
59 (if #+sb-xc-host nil #-sb-xc-host (constant-continuation-p x)
60 (sxhash (continuation-value x))
61 '(%sxhash-simple-string (symbol-name x))))