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

consing



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
much.

--mark

(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))

#+:CCL
(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)))
                    $pagesize
                    (%ilogand2 #xfff fp))))))