X-Git-Url: http://repo.macrolet.net/gitweb/?a=blobdiff_plain;f=src%2Fpcl%2Fcache.lisp;h=5eb5930fb0ef19e877629e873e7e41ff168c58b1;hb=ebc0f0ebf9efd39519ab86ba28c33abdb25443e0;hp=9a65defcc9ea0f147269591e0d359806f70e56e0;hpb=1a405defbd26ca767e71494b67127fcc00a8af12;p=sbcl.git diff --git a/src/pcl/cache.lisp b/src/pcl/cache.lisp index 9a65def..5eb5930 100644 --- a/src/pcl/cache.lisp +++ b/src/pcl/cache.lisp @@ -25,6 +25,13 @@ (in-package "SB-PCL") +;;; Ye olde CMUCL comment follows, but it seems likely that the paper +;;; that would be inserted would resemble Kiczales and Rodruigez, +;;; Efficient Method Dispatch in PCL, ACM 1990. Some of the details +;;; changed between that paper and "May Day PCL" of 1992; some other +;;; details have changed since, but reading that paper gives the broad +;;; idea. +;;; ;;; The caching algorithm implemented: ;;; ;;; << put a paper here >> @@ -936,7 +943,7 @@ (defun fill-cache (cache wrappers value) ;; FILL-CACHE won't return if WRAPPERS is nil, might as well check.. - (assert wrappers) + (aver wrappers) (or (fill-cache-p nil cache wrappers value) (and (< (ceiling (* (cache-count cache) *cache-expand-threshold*)) @@ -975,10 +982,7 @@ (defun probe-cache (cache wrappers &optional default limit-fn) ;;(declare (values value)) - (unless wrappers - ;; FIXME: This and another earlier test on a WRAPPERS arg can - ;; be compact assertoids. - (error "WRAPPERS arg is NIL!")) + (aver wrappers) (with-local-cache-functions (cache) (let* ((location (compute-primary-cache-location (field) (mask) wrappers)) (limit (funcall (or limit-fn (limit-fn)) (nlines)))) @@ -1034,6 +1038,13 @@ (let* ((location (compute-primary-cache-location (field) (mask) wrappers)) (primary (location-line location))) (declare (fixnum location primary)) + ;; FIXME: I tried (aver (> location 0)) and (aver (not + ;; (location-reserved-p location))) here, on the basis that + ;; particularly passing a LOCATION of 0 for a cache with more + ;; than one key would cause PRIMARY to be -1. However, the + ;; AVERs triggered during the bootstrap, and removing them + ;; didn't cause anything to break, so I've left them removed. + ;; I'm still confused as to what is right. -- CSR, 2006-04-20 (multiple-value-bind (free emptyp) (find-free-cache-line primary cache wrappers) (when (or forcep emptyp) @@ -1149,6 +1160,8 @@ (do-one-fill wrappers value)) (maybe-check-cache ncache))))) +(defvar *pcl-misc-random-state* (make-random-state)) + ;;; This is the heart of the cache filling mechanism. It implements ;;; the decisions about where entries are placed. ;;; @@ -1185,7 +1198,8 @@ (when (>= osep limit) (return-from find-free-cache-line (values primary nil))) (when (cond ((= nsep limit) t) - ((= nsep osep) (zerop (random 2))) + ((= nsep osep) + (zerop (random 2 *pcl-misc-random-state*))) ((> nsep osep) t) (t nil)) ;; See whether we can displace what is in this line so that we @@ -1224,4 +1238,3 @@ ((8 16) 4) (otherwise 6))) -(defvar *empty-cache* (make-cache)) ; for defstruct slot initial value forms