X-Git-Url: http://repo.macrolet.net/gitweb/?a=blobdiff_plain;ds=inline;f=src%2Fcode%2Fpcounter.lisp;h=aee1cad2631214ae7ce0ab97eebc4aae612426b1;hb=3cb38bad21763eb16bd89d89a5fac9a186ac625b;hp=c250ecdcb713988ccdff71c3c8754f3881b76e3d;hpb=b4dcc81361b084a1ed9e3212ae4abbb174720780;p=sbcl.git diff --git a/src/code/pcounter.lisp b/src/code/pcounter.lisp index c250ecd..aee1cad 100644 --- a/src/code/pcounter.lisp +++ b/src/code/pcounter.lisp @@ -3,7 +3,7 @@ ;;;; a PCOUNTER is used to represent an unsigned integer quantity which ;;;; can grow bigger than a fixnum, but typically does so, if at all, ;;;; in many small steps, where we don't want to cons on every step. -;;;; Such quantities typically arise in profiling, e.g. +;;;; Such quantities typically arise in profiling, e.g. ;;;; total system consing, time spent in a profiled function, and ;;;; bytes consed in a profiled function are all examples of such ;;;; quantities. The name is an abbreviation for "Profiling COUNTER". @@ -18,26 +18,20 @@ ;;;; basic PCOUNTER stuff -(/show0 "pcounter.lisp 16") - -(defstruct (pcounter (:copier nil)) - (integer 0 :type unsigned-byte) - (fixnum 0 :type (and fixnum unsigned-byte))) - -(/show0 "pcounter.lisp 22") +(/show0 "pcounter.lisp 21") (declaim (maybe-inline incf-pcounter)) (defun incf-pcounter (pcounter delta) (aver (typep delta 'unsigned-byte)) (let ((sum (+ (pcounter-fixnum pcounter) delta))) (cond ((typep sum 'fixnum) - (setf (pcounter-fixnum pcounter) sum)) - (t - (incf (pcounter-integer pcounter) sum) - (setf (pcounter-fixnum pcounter) 0)))) + (setf (pcounter-fixnum pcounter) sum)) + (t + (incf (pcounter-integer pcounter) sum) + (setf (pcounter-fixnum pcounter) 0)))) pcounter) -(/show0 "pcounter.lisp 36") +(/show0 "pcounter.lisp 34") ;;;(declaim (inline pcounter->integer)) ; FIXME: maybe inline when more stable (defun pcounter->integer (pcounter) @@ -50,7 +44,7 @@ ;;;; start with a FIXNUM counter and only create a PCOUNTER if the ;;;; FIXNUM overflows. -(/show0 "pcounter.lisp 50") +(/show0 "pcounter.lisp 47") (declaim (inline %incf-pcounter-or-fixnum)) (defun %incf-pcounter-or-fixnum (x delta) @@ -58,14 +52,14 @@ (fixnum (let ((sum (+ x delta))) (if (typep sum 'fixnum) - sum - (make-pcounter :integer sum)))) + sum + (make-pcounter :integer sum)))) (pcounter (incf-pcounter x delta)))) - + (define-modify-macro incf-pcounter-or-fixnum (delta) %incf-pcounter-or-fixnum) -(/show0 "pcounter.lisp 64") +(/show0 "pcounter.lisp 62") ;;; Trade off space for execution time by handling the common fast ;;; (TYPEP DELTA 'FIXNUM) case inline and only calling generic @@ -76,10 +70,10 @@ (aver (typep ,delta-sym 'unsigned-byte)) ;;(declare (type unsigned-byte ,delta-sym)) (if (typep ,delta-sym 'fixnum) - (incf-pcounter-or-fixnum ,x ,delta) - (incf-pcounter-or-fixnum ,x ,delta))))) + (incf-pcounter-or-fixnum ,x ,delta) + (incf-pcounter-or-fixnum ,x ,delta))))) -(/show0 "pcounter.lisp 80") +(/show0 "pcounter.lisp 76") (declaim (maybe-inline pcounter-or-fixnum->integer)) (defun pcounter-or-fixnum->integer (x)