From ff78d8030b41c04530bc34511e805552daa2989d Mon Sep 17 00:00:00 2001 From: jgarcia Date: Sat, 9 Feb 2008 08:37:25 +0000 Subject: [PATCH] Finished porting the profiler --- contrib/profile/profile.lisp | 27 +++++++++++---------------- src/lsp/config.lsp.in | 2 +- 2 files changed, 12 insertions(+), 17 deletions(-) diff --git a/contrib/profile/profile.lisp b/contrib/profile/profile.lisp index c89b847e3..916717745 100644 --- a/contrib/profile/profile.lisp +++ b/contrib/profile/profile.lisp @@ -37,22 +37,17 @@ ) (ffi:clines " -static size_t old_bytes_consed = 0; ") -(defun get-bytes-consed () - (ffi:c-inline () () :object " -size_t bytes_consed = GC_get_total_bytes(); -size_t delta; -if (bytes_consed < old_bytes_consed) { - delta = ~((size_t)0) - old_bytes_consed; - delta += bytes_consed; -} else { - delta = bytes_consed - old_bytes_consed; -} -old_bytes_consed = bytes_consed; -@(return) = ecl_make_unsigned_integer(delta); -")) +(defconstant +wrap+ (ffi:c-inline () () :object "ecl_make_unsigned_integer(~((size_t)0))" + :one-liner t)) + +(defun get-bytes-consed (orig) + (let ((bytes (ffi:c-inline () () :object "ecl_make_unsigned_integer(GC_get_total_bytes())" + :one-liner t))) + (if (< bytes orig) + (+ (- +wrap+ orig) bytes) + (- bytes orig)))) (deftype counter () '(integer 0 *)) @@ -194,7 +189,7 @@ old_bytes_consed = bytes_consed; (old-enclosed-consing *enclosed-consing*) (old-enclosed-profiles *enclosed-profiles*) (start-ticks (get-internal-ticks)) - (start-consed (get-bytes-consed))) + (start-consed (get-bytes-consed 0))) (unwind-protect (progn (setf *enclosed-ticks* 0 @@ -202,7 +197,7 @@ old_bytes_consed = bytes_consed; *enclosed-consing* 0) (apply encapsulated-fun args)) (setf dticks (- (get-internal-ticks) start-ticks)) - (setf dconsing (- (get-bytes-consed) start-consed)) + (setf dconsing (get-bytes-consed start-consed)) (setf inner-enclosed-profiles *enclosed-profiles*) (let ((net-dticks (- dticks *enclosed-ticks*))) (incf ticks net-dticks)) diff --git a/src/lsp/config.lsp.in b/src/lsp/config.lsp.in index 142fbb378..8b14c8630 100644 --- a/src/lsp/config.lsp.in +++ b/src/lsp/config.lsp.in @@ -24,7 +24,7 @@ Returns, as a string, the location of the machine on which ECL runs." (defun lisp-implementation-version () "Args:() Returns the version of your ECL as a string." - "@PACKAGE_VERSION@ (CVS 2008-02-09 00:53)") + "@PACKAGE_VERSION@ (CVS 2008-02-09 09:37)") (defun machine-type () "Args: ()