[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]


The following code, grafted from some MACL examples, defines a GET-CONSING
function for MACL that returns the total number of conses used. While this
is usable for my code, I really need a function which returns the total
number of conses used since the beginning of time (i.e., it shouldn't
reset after a GC). Also, it would be nice if the function didn't cons so


(in-package :ccl)

(eval-when (eval compile)
  #+:CCL(defconstant $pagesize 4096)
  #+:CCL(defconstant $lstFP #x-a42)
  #+:CCL(defconstant $currentA5 #x904)
  #+:CCL(defconstant $pagecounts #x-18e)
  #+:CCL(defconstant $consfirstob 64))

(defun get-consing (&aux pages fp)
  ;; Returns the number of conses used. (8 bytes each)
  (let* ((a5 (%get-ptr $currentA5))
         (ptr (%inc-ptr a5 $pagecounts)))
    (%ilsr 3 (%i+ (%i- (%ilsl 12 (%i- (setq pages (%get-word ptr 0)) 1)) 
                       (%i* pages $consfirstob))
                  (if (eq 0 (setq fp (%get-long a5 $lstFP)))
                    (%ilogand2 #xfff fp))))))