logo       

CVS: sbcl/src/code sxhash.lisp,1.7,1.8 target-sxhash.lisp,1.17,1.18: msg#00139

Subject: CVS: sbcl/src/code sxhash.lisp,1.7,1.8 target-sxhash.lisp,1.17,1.18
Update of /cvsroot/sbcl/sbcl/src/code
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3717/src/code

Modified Files:
        sxhash.lisp target-sxhash.lisp 
Log Message:
0.8.10.46:
        * On X86 remove compiler notes for SXHASH:
        ... add type declarations for SXHASH-{BIGNUM,INSTANCE};
        ... for {SINGLE,DOUBLE}-FLOAT and FIXNUM transforms of SXHASH,
            coerce signed words to unsigned, so that the compiler can
            use unsigned modular arithmetic.


Index: sxhash.lisp
===================================================================
RCS file: /cvsroot/sbcl/sbcl/src/code/sxhash.lisp,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- sxhash.lisp 21 May 2004 12:17:48 -0000      1.7
+++ sxhash.lisp 22 May 2004 14:50:04 -0000      1.8
@@ -18,7 +18,7 @@
 ;;; order to avoid boxing.
 (deftransform sxhash ((x) (single-float))
   '(let* ((val (+ 0.0f0 x))
-         (bits (single-float-bits val)))
+         (bits (logand (single-float-bits val) #.(1- (ash 1 32)))))
      (logxor 66194023
             (sxhash (the fixnum
                          (logand most-positive-fixnum
@@ -26,7 +26,7 @@
                                          (ash bits -7))))))))
 (deftransform sxhash ((x) (double-float))
   '(let* ((val (+ 0.0d0 x))
-         (hi (double-float-high-bits val))
+         (hi (logand (double-float-high-bits val) #.(1- (ash 1 32))))
          (lo (double-float-low-bits val))
          (hilo (logxor hi lo)))
      (logxor 475038542
@@ -39,8 +39,8 @@
 ;;; simple.
 (deftransform sxhash ((x) (fixnum))
   '(logand most-positive-fixnum
-          (logxor (ash (logand x (ash most-positive-fixnum -4)) 4) 
-                  (ash x -1) ; to get sign bit into hash
+          (logxor (ash (logand x (ash most-positive-fixnum -4)) 4)
+                  (logand (ash x -1) most-positive-fixnum) ; to get sign bit 
into hash
                   361475658)))
 
 ;;; SXHASH of SIMPLE-BIT-VECTOR values is defined as a DEFTRANSFORM
@@ -68,7 +68,6 @@
                                '(- sb!vm:n-word-bits
                                    (mod length sb!vm:n-word-bits)))))
                       (%raw-bits x i))))
-                (declare (type (unsigned-byte 32) num))
                 (mix result ,(ecase sb!c:*backend-byte-order*
                                (:little-endian
                                 '(logand num most-positive-fixnum))
@@ -76,7 +75,6 @@
                                 '(ash num (- sb!vm:n-lowtag-bits)))))))
           (declare (type index i end-1))
           (let ((num (%raw-bits x i)))
-            (declare (type (unsigned-byte 32) num))
             (mixf result ,(ecase sb!c:*backend-byte-order*
                             (:little-endian
                              '(logand num most-positive-fixnum))
@@ -113,7 +111,7 @@
        ;; (which contains NIL itself) is a negative fixnum.
        (if (= 0 result)
            (let ((sxhash (%sxhash-simple-string (symbol-name x))))
-             ;; We could do a (logor sxhash #x10000000) to ensure
+             ;; We could do a (logior sxhash #x10000000) to ensure
              ;; that we never store a 0 in the slot. However, it's
              ;; such an unlikely event (1/5e8?) that it makes more
              ;; sense to optimize for the common case...

Index: target-sxhash.lisp
===================================================================
RCS file: /cvsroot/sbcl/sbcl/src/code/target-sxhash.lisp,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -d -r1.17 -r1.18
--- target-sxhash.lisp  10 Mar 2004 16:10:18 -0000      1.17
+++ target-sxhash.lisp  22 May 2004 14:50:04 -0000      1.18
@@ -36,9 +36,10 @@
 ;;;   * We'd like this to be simple and fast, too.
 ;;;
 ;;; FIXME: Should this be INLINE?
-(declaim (ftype (function ((and fixnum unsigned-byte)
-                          (and fixnum unsigned-byte))
-                         (and fixnum unsigned-byte)) mix))
+(declaim (ftype (sfunction ((and fixnum unsigned-byte)
+                            (and fixnum unsigned-byte))
+                           (and fixnum unsigned-byte))
+                mix))
 (defun mix (x y)
   ;; FIXME: We wouldn't need the nasty (SAFETY 0) here if the compiler
   ;; were smarter about optimizing ASH. (Without the THE FIXNUM below,
@@ -89,7 +90,7 @@
   (declare (type string string))
   (declare (type index count))
   (let ((result 0))
-    (declare (type (unsigned-byte 32) result))    
+    (declare (type (unsigned-byte 32) result))
     (unless (typep string '(vector nil))
       (dotimes (i count)
        (declare (type index i))
@@ -144,6 +145,12 @@
 
 ;;;; the SXHASH function
 
+;; simple cases
+(declaim (ftype (sfunction (integer) (integer 0 #.sb!xc:most-positive-fixnum))
+                sxhash-bignum))
+(declaim (ftype (sfunction (t) (integer 0 #.sb!xc:most-positive-fixnum))
+                sxhash-instance))
+
 (defun sxhash (x)
   ;; profiling SXHASH is hard, but we might as well try to make it go
   ;; fast, in case it is the bottleneck somwhere.  -- CSR, 2003-03-14



-------------------------------------------------------
This SF.Net email is sponsored by: Oracle 10g
Get certified on the hottest thing ever to hit the market... Oracle 10g. 
Take an Oracle 10g class now, and we'll give you the exam FREE.
http://ads.osdn.com/?ad_id=3149&alloc_id=8166&op=click


<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

Recently Viewed:
linux.arklinux....    user-groups.lin...    kde.usability/2...    ietf.ipp/2002-0...    mail.spam.spamc...    os.netbsd.devel...    audio.cd-record...    text.unicode.de...    php.documentati...    games.fps.halfl...    window-managers...    suse.oracle.gen...    bug-tracking.gn...    video.dvdrip.us...    xfree86.cvs/200...    java.netbeans.m...    network.argus/2...    culture.sf.kill...    debian.ports.al...    freebsd.questio...    qplus.devel/200...    handhelds.palm....   
Home | blog view | USPTO Patent Archive | advertise | OSDir is an inevitable website. super tiny logo

Free Magazines

Cisco News
Receive a free quarterly e-newsletter with exclusive articles on how Cisco IT uses its own products and solutions to enable the business.
subscribe

Systems Management News, the newspaper for IT systems administration and data center managers! Each issue of Systems Management News is chock-full of news and analysis to help you understand what's happening in your field.
subscribe

The Enterprise Newsweekly eWeek is the essential technology information source for builders of e-business.
subscribe

Oracle Magazine Oracle Magazine contains technology strategy articles, sample code, tips, Oracle and partner news, how to articles for developers and DBAs, and more. Oracle (NASDAQ: ORCL) is the world's largest enterprise software company.
subscribe

Total Telecom Total Telecom is "The Economist of the communications industry".
subscribe