X-Git-Url: http://repo.macrolet.net/gitweb/?a=blobdiff_plain;f=src%2Fpcl%2Fcache.lisp;h=bb60a0306f5419467dfa29e024bf87b2653cd8ad;hb=3fa2feb10ab827fc6cc2a85287e78b6e66b7bf4d;hp=e7f60e4d6502f28b7319652849c274c9c99cc9f4;hpb=db770d287bb64a58967d08fdd8225c02cdd4d45a;p=sbcl.git diff --git a/src/pcl/cache.lisp b/src/pcl/cache.lisp index e7f60e4..bb60a03 100644 --- a/src/pcl/cache.lisp +++ b/src/pcl/cache.lisp @@ -104,11 +104,6 @@ ;; bits at the low end. (logand (1- vector-length) (- line-size))) -;;; The smallest power of two that is equal to or greater then X. -(declaim (inline power-of-two-ceiling)) -(defun power-of-two-ceiling (x) - (ash 1 (integer-length (1- x)))) - (defun cache-statistics (cache) (let* ((vector (cache-vector cache)) (size (length vector)) @@ -322,8 +317,6 @@ ;; Make a smaller one, then (make-cache :key-count key-count :value value :size (ceiling size 2))))) -(defconstant n-fixnum-bits #.(integer-length most-positive-fixnum)) - ;;;; Copies and expands the cache, dropping any invalidated or ;;;; incomplete lines. (defun copy-and-expand-cache (cache layouts value) @@ -362,18 +355,8 @@ ;; _Experimentally_ 50% seems to perform the ;; best, but it would be nice to have a proper ;; analysis... - (flet ((random-fixnum () - (random (1+ most-positive-fixnum)))) - (let ((drops (random-fixnum)) - (drop-pos n-fixnum-bits)) - (declare (fixnum drops) - (type (integer 0 #.n-fixnum-bits) drop-pos)) - (lambda (layouts value) - (when (logbitp (the unsigned-byte (decf drop-pos)) drops) - (try-update-cache copy layouts value)) - (when (zerop drop-pos) - (setf drops (random-fixnum) - drop-pos n-fixnum-bits))))) + (randomly-punting-lambda (layouts value) + (try-update-cache copy layouts value)) (lambda (layouts value) (unless (try-update-cache copy layouts value) ;; Didn't fit -- expand the cache, or drop