* Use VOP translation instead of %PRIMITIVE.
* On x86 and x86-64 improve the pointer-hash slightly: use the whole
address, but none of the tag bits in the hash.
* Fix type in INDEX-FOR-HASHING: the first argument is a HASH, not an
INDEX. Given the better quality of low bits on x86oids (and
hopefully soon on others as well), adjust the mixing a bit.
when SB-DEBUG:*SHOW-ENTRY-POINT-DETAILS* is NIL.
* unreadably printed representation of hash-tables now includes
weakness if any.
+ * bug fix: on x86 and x86-64 pointer based EQ-hashing now uses the
+ full address of the object, and none of the tag bits.
* bug fix: readably printing hash-tables now respects other printer
control variables. (reported by Cedric St-Jean)
* bug fix: compiler gave a bogus STYLE-WARNING for the :SYNCHRONIZED
"LAMBDA-WITH-LEXENV" "LEXENV-FIND"
"LOCATION=" "LTN-ANNOTATE"
"MAKE-ALIAS-TN" "MAKE-CATCH-BLOCK"
- "MAKE-CLOSURE" "MAKE-CONSTANT-TN" "MAKE-FIXNUM"
+ "MAKE-CLOSURE" "MAKE-CONSTANT-TN"
"MAKE-FIXUP-NOTE"
"MAKE-LOAD-TIME-CONSTANT-TN" "MAKE-N-TNS" "MAKE-NORMAL-TN"
"MAKE-OTHER-IMMEDIATE-TYPE" "MAKE-RANDOM-TN"
"PACKAGE-INTERNAL-SYMBOLS" "PACKAGE-EXTERNAL-SYMBOLS"
"PARSE-DEFMACRO" "PARSE-UNKNOWN-TYPE"
"PARSE-UNKNOWN-TYPE-SPECIFIER" "PATHNAME-DESIGNATOR"
+ "POINTER-HASH"
#!+(or x86 x86-64) "*PSEUDO-ATOMIC-BITS*"
"PUNT-PRINT-IF-TOO-LONG"
"RAW-INSTANCE-SLOTS-EQUALP"
\f
;;;; utilities
-(eval-when (:compile-toplevel :load-toplevel :execute)
- (defconstant max-hash sb!xc:most-positive-fixnum))
-
;;; Code for detecting concurrent accesses to the same table from
;;; multiple threads. Only compiled in when the :SB-HASH-TABLE-DEBUG
;;; feature is enabled. The main reason for the existence of this code
(setf (,thread-slot-accessor ,hash-table) nil)))
(body-fun)))))))
-(deftype hash ()
- `(integer 0 ,max-hash))
-
-;;; FIXME: Does this always make a nonnegative FIXNUM? If so, then
-;;; explain why. If not (or if the reason it always makes a
-;;; nonnegative FIXNUM is only the accident that pointers in supported
-;;; architectures happen to be in the lower half of the address
-;;; space), then fix it.
-#!-sb-fluid (declaim (inline pointer-hash))
-(defun pointer-hash (key)
- (declare (values hash))
- (truly-the hash (%primitive sb!c:make-fixnum key)))
-
#!-sb-fluid (declaim (inline eq-hash))
(defun eq-hash (key)
(declare (values hash (member t nil)))
(ash 1 (integer-length num)))
(declaim (inline index-for-hashing))
-(defun index-for-hashing (index length)
- (declare (type index index length))
+(defun index-for-hashing (hash length)
+ (declare (type hash hash length))
;; We're using power of two tables which obviously are very
;; sensitive to the exact values of the low bits in the hash
;; value. Do a little shuffling of the value to mix the high bits in
;; there too.
- (logand (1- length)
- (+ (logxor #b11100101010001011010100111
- index)
- (ash index -6)
- (ash index -15)
- (ash index -23))))
+ (truly-the index
+ (logand (1- length)
+ (+ (logxor #b11100101010001011010100111
+ hash)
+ (ash hash -3)
+ (ash hash -12)
+ (ash hash -20)))))
\f
;;;; user-defined hash table tests
(in-package "SB!IMPL")
+(eval-when (:compile-toplevel :load-toplevel :execute)
+ (defconstant max-hash sb!xc:most-positive-fixnum))
+
+(deftype hash ()
+ `(integer 0 ,max-hash))
+
+(defun pointer-hash (key)
+ (pointer-hash key))
+
;;; the depthoid explored when calculating hash values
;;;
;;; "Depthoid" here is a sort of mixture of what Common Lisp ordinarily calls
(storew t1 x 0 other-pointer-lowtag)
(move x res)))
-(define-vop (make-fixnum)
+(define-vop (pointer-hash)
+ (:translate pointer-hash)
(:args (ptr :scs (any-reg descriptor-reg)))
(:results (res :scs (any-reg descriptor-reg)))
+ (:policy :fast-safe)
(:generator 1
- ;;
- ;; Some code (the hash table code) depends on this returning a
- ;; positive number so make sure it does.
+ ;; FIXME: It would be better if this would mask the lowtag,
+ ;; and shift the result into a positive fixnum like on x86.
(inst sll ptr 35 res)
(inst srl res 33 res)))
\f
;;;; miscellaneous "sub-primitives"
+(defknown pointer-hash (t) hash (flushable))
+
(defknown %sp-string-compare
(simple-string index index simple-string index index)
(or index null)
:element-type 'compact-info-entry))
(sorted (sort (names)
#+sb-xc-host #'<
- ;; (This MAKE-FIXNUM hack implements
- ;; pointer comparison, as explained above.)
+ ;; POINTER-HASH hack implements pointer
+ ;; comparison, as explained above.
#-sb-xc-host (lambda (x y)
- (< (%primitive make-fixnum x)
- (%primitive make-fixnum y))))))
+ (< (pointer-hash x)
+ (pointer-hash y))))))
(/show0 "done making/sorting vectors in COMPACT-INFO-ENVIRONMENT")
(let ((entries-idx 0))
(dolist (types sorted)
(storew temp x 0 other-pointer-lowtag)
(move x res)))
-(define-vop (make-fixnum)
+(define-vop (pointer-hash)
+ (:translate pointer-hash)
(:args (ptr :scs (any-reg descriptor-reg)))
(:results (res :scs (any-reg descriptor-reg)))
+ (:policy :fast-safe)
(:generator 1
- ;;
- ;; Some code (the hash table code) depends on this returning a
- ;; positive number so make sure it does.
+ ;; FIXME: It would be better if this would mask the lowtag,
+ ;; and shift the result into a positive fixnum like on x86.
(inst zdep ptr 29 29 res)))
(define-vop (make-other-immediate-type)
(storew t1 x 0 other-pointer-lowtag)
(move res x)))
-(define-vop (make-fixnum)
+(define-vop (pointer-hash)
+ (:translate pointer-hash)
(:args (ptr :scs (any-reg descriptor-reg)))
(:results (res :scs (any-reg descriptor-reg)))
+ (:policy :fast-safe)
(:generator 1
- ;;
- ;; Some code (the hash table code) depends on this returning a
- ;; positive number so make sure it does.
+ ;; FIXME: It would be better if this would mask the lowtag,
+ ;; and shift the result into a positive fixnum like on x86.
(inst sll res ptr 3)
(inst srl res res 1)))
(move res x)))
-(define-vop (make-fixnum)
+(define-vop (pointer-hash)
+ (:translate pointer-hash)
(:args (ptr :scs (any-reg descriptor-reg)))
(:results (res :scs (any-reg descriptor-reg)))
+ (:policy :fast-safe)
(:generator 1
- ;;
- ;; Some code (the hash table code) depends on this returning a
- ;; positive number so make sure it does.
+ ;; FIXME: It would be better if this would mask the lowtag,
+ ;; and shift the result into a positive fixnum like on x86.
(inst rlwinm res ptr n-fixnum-tag-bits 1 n-positive-fixnum-bits)))
(define-vop (make-other-immediate-type)
(move res x)))
-(define-vop (make-fixnum)
+(define-vop (pointer-hash)
+ (:translate pointer-hash)
(:args (ptr :scs (any-reg descriptor-reg)))
(:results (res :scs (any-reg descriptor-reg)))
+ (:policy :fast-safe)
(:generator 1
- ;; FIXME: CMUCL comment:
- ;; Some code (the hash table code) depends on this returning a
- ;; positive number so make sure it does.
+ ;; FIXME: It would be better if this would mask the lowtag,
+ ;; and shift the result into a positive fixnum like on x86.
(inst sll res ptr 3)
(inst srl res res 1)))
(storew eax x 0 other-pointer-lowtag)
(move res x)))
\f
-(define-vop (make-fixnum)
+(define-vop (pointer-hash)
+ (:translate pointer-hash)
(:args (ptr :scs (any-reg descriptor-reg) :target res))
(:results (res :scs (any-reg descriptor-reg)))
+ (:policy :fast-safe)
(:generator 1
- ;; Some code (the hash table code) depends on this returning a
- ;; positive number so make sure it does.
(move res ptr)
- (inst shl res 4)
+ ;; Mask the lowtag, and shift the whole address into a positive
+ ;; fixnum.
+ (inst and res (lognot lowtag-mask))
(inst shr res 1)))
(define-vop (make-other-immediate-type)
(storew eax x 0 other-pointer-lowtag)
(move res x)))
\f
-(define-vop (make-fixnum)
+(define-vop (pointer-hash)
+ (:translate pointer-hash)
(:args (ptr :scs (any-reg descriptor-reg) :target res))
(:results (res :scs (any-reg descriptor-reg)))
+ (:policy :fast-safe)
(:generator 1
- ;; Some code (the hash table code) depends on this returning a
- ;; positive number so make sure it does.
(move res ptr)
- (inst shl res 3)
+ ;; Mask the lowtag, and shift the whole address into a positive
+ ;; fixnum.
+ (inst and res (lognot lowtag-mask))
(inst shr res 1)))
(define-vop (make-other-immediate-type)
;;; checkins which aren't released. (And occasionally for internal
;;; versions, especially for internal versions off the main CVS
;;; branch, it gets hairier, e.g. "0.pre7.14.flaky4.13".)
-"1.0.14.26"
+"1.0.14.27"