Commit f78265ea authored by rtoy's avatar rtoy
Browse files

Merge changes from snapshot-2008-07.

parent 2c35ac88
Loading
Loading
Loading
Loading
+460 −4

File changed.

Preview size limit exceeded, changes collapsed.

+4 −3
Original line number Diff line number Diff line
@@ -6,7 +6,7 @@
;;; placed in the Public domain, and is provided 'as is'.
;;;
(ext:file-comment
  "$Header: /Volumes/share2/src/cmucl/cvs2git/cvsroot/src/code/rand-mt19937.lisp,v 1.15 2007/08/02 18:18:19 rtoy Exp $")
  "$Header: /Volumes/share2/src/cmucl/cvs2git/cvsroot/src/code/rand-mt19937.lisp,v 1.15.4.1 2008/06/27 17:24:13 rtoy Exp $")
;;;
;;; **********************************************************************
;;;
@@ -443,8 +443,9 @@
  (declare (inline %random-single-float %random-double-float
		   #+long-float %long-float))
  (cond
    ((and (fixnump arg) (<= arg random-fixnum-max) (> arg 0))
     (rem (random-chunk state) arg))
    ((typep arg '(integer 1 #x100000000))
     ;; Let the compiler deftransform take care of this case.
     (random arg state))
    ((and (typep arg 'single-float) (> arg 0.0F0))
     (%random-single-float arg state))
    ((and (typep arg 'double-float) (> arg 0.0D0))
+15 −15
Original line number Diff line number Diff line
@@ -5,7 +5,7 @@
;;; Carnegie Mellon University, and has been placed in the public domain.
;;;
(ext:file-comment
  "$Header: /Volumes/share2/src/cmucl/cvs2git/cvsroot/src/compiler/float-tran.lisp,v 1.119 2008/04/08 14:15:35 rtoy Exp $")
  "$Header: /Volumes/share2/src/cmucl/cvs2git/cvsroot/src/compiler/float-tran.lisp,v 1.119.2.1 2008/06/27 17:24:14 rtoy Exp $")
;;;
;;; **********************************************************************
;;;
@@ -248,29 +248,29 @@
				  :key #'numeric-type-high))
			 (t
			  (give-up)))))
    ;; Rather than doing (rem (random-chunk) num-high), we do,
    ;; essentially, (rem (* num-high (random-chunk)) #x100000000).  I
    ;; (rtoy) believe this approach doesn't have the bias issue with
    ;; doing rem.  This method works by treating (random-chunk) as if
    ;; it were a 32-bit fraction between 0 and 1, exclusive.  Multiply
    ;; this by num-high to get a random number between 0 and num-high,
    ;; This should have no bias.
    (cond ((constant-continuation-p num)
	   ;; Check the worst case sum abs error for the random number
	   ;; expectations.
	   (let ((rem (rem (expt 2 32) num-high)))
	     (unless (< (/ (* 2 rem (- num-high rem)) num-high (expt 2 32))
			(expt 2 (- kernel::random-integer-extra-bits)))
	       (give-up "The random number expectations are inaccurate."))
	   (if (= num-high (expt 2 32))
	       '(random-chunk (or state *random-state*))
		 #-x86 '(rem (random-chunk (or state *random-state*)) num)
		 #+x86
		 ;; Use multiplication which is faster.
	       '(values (bignum::%multiply 
			 (random-chunk (or state *random-state*))
			   num)))))
	  ((> num-high random-fixnum-max)
	   (give-up "The range is too large to assure an accurate result."))
	  #+x86
			 num))))
	  ((< num-high (expt 2 32))
	   '(values (bignum::%multiply (random-chunk (or state *random-state*))
		     num)))
	  ((= num-high (expt 2 32))
	   '(if (= num (expt 2 32))
		(random-chunk (or state *random-state*))
		(values (bignum::%multiply (random-chunk (or state *random-state*))
					   num))))
	  (t
	   '(rem (random-chunk (or state *random-state*)) num)))))
	   (error "Shouldn't happen")))))


;;;; Float accessors:
+35 −1
Original line number Diff line number Diff line
@@ -5,7 +5,7 @@
;;; Carnegie Mellon University, and has been placed in the public domain.
;;;
(ext:file-comment
  "$Header: /Volumes/share2/src/cmucl/cvs2git/cvsroot/src/compiler/sparc/float.lisp,v 1.56 2008/04/22 20:18:01 rtoy Exp $")
  "$Header: /Volumes/share2/src/cmucl/cvs2git/cvsroot/src/compiler/sparc/float.lisp,v 1.56.2.1 2008/06/27 17:24:14 rtoy Exp $")
;;;
;;; **********************************************************************
;;;
@@ -1045,6 +1045,40 @@
  #+long-float
  (frob %long-float/signed %long-float fitoq long-reg long-float))

;; Sparc doesn't have an instruction to convert a 32-bit unsigned
;; integer to a float, but does have one for a 32-bit signed integer.
;; What we do here is break up the 32-bit number into 2 smaller
;; pieces.  Each of these are converted to a float, and the higher
;; order piece is scaled appropriately, and finally everything is
;; summed together.  The pieces are done in a way such that no
;; roundoff occurs.  The scaling should not produce any roundoff
;; either, since the scale factor is an exact power of two.  The final
;; sum will produce the correct rounded result.  (I think,)
;;
;; But need to be careful because we still want to call the VOP for
;; the small pieces, so we need the transform to give up if it's known
;; that the argument is smaller than a 32-bit unsigned integer.
(macrolet ((frob (name limit unit)
	     `(deftransform ,name ((n) ((unsigned-byte 32)))
		;; Should this be extended to a (unsigned-byte 53)?  We could.  Just
		;; take the low 31 bits, and the rest, and float them and combine
		;; them as before.
		(when (csubtypep (c::continuation-type n)
				 (c::specifier-type '(unsigned-byte 31)))
		  ;; We want to give-up if we know the number can't have the
		  ;; MSB set.  The signed 32-bit vop can handle that.
		  (c::give-up))
		`(+ (,',name (ldb (byte ,',limit 0) n))
		    (* (,',name (ldb (byte ,',(- 32 limit) ,',limit) n))
		       (scale-float ,',unit ,',limit))))))
  ;; If we break up the numbers into the low 12 bits and the high 20
  ;; bits, we can use a single AND instruction to get the low 12 bits.
  ;; This is a microoptimization for Sparc.  Otherwise, the only
  ;; constraint is that the pieces must be small enough to fit in the
  ;; desired float format without rounding.
  (frob %single-float 12 1f0)
  (frob %double-float 12 1f0))

(macrolet ((frob (name translate inst from-sc from-type to-sc to-type)
	     `(define-vop (,name)
		(:args (x :scs (,from-sc)))
+10 −0
Original line number Diff line number Diff line
@@ -20,6 +20,7 @@ New in this release:


  * Feature enhancements:
    - ~R supports many more cardinal names.
 
  * ANSI compliance fixes:
    - Fix bug in backquote printer.  If the variable is @foo, we want
@@ -61,12 +62,21 @@ New in this release:
      arglist contains items that can't be printed readably.
    - DIRECTORY is now faster for directories with a large number of
      files.  
    - RANDOM is now much faster on all platforms for numbers upto
      #xffffffff.  This is an incompatible change from previous
      releases because the numbers produced may be different from
      before.  
    - The small bias in RANDOM for integer args up to 32 bits long
      should now be gone.

  * Trac Tickets:
    - #16: Read-time hash-table issue
      Fixed.

  * Other changes:
    - IS1, IS2, IS3, and IS4 are recognized character names for the
      ASCII control codes US, RS, GS, FS, respectively.
    - Added OPEN-NETWORK-STREAM and ACCEPT-NETWORK-STREAM functions.

  * Improvements to the PCL implementation of CLOS:
    - The compiler and interpreter should handle SLOT-VALUE the same