(defvar *enclosed-profiles* 0)
(declaim (type (or pcounter fixnum) *enclosed-profiles*))
+;;; the encapsulated function we're currently computing profiling data
+;;; for, recorded so that we can detect the problem of
+;;; PROFILE-computing machinery calling a function which has itself
+;;; been PROFILEd
+(defvar *computing-profiling-data-for*)
+
;;; the components of profiling overhead
(defstruct (overhead (:copier nil))
;; the number of ticks a bare function call takes. This is
;; ENCAPSULATION-FUN
(lambda (sb-c:&more arg-context arg-count)
(declare (optimize speed safety))
+ ;; Make sure that we're not recursing infinitely.
+ (when (boundp '*computing-profiling-data-for*)
+ (unprofile-all) ; to avoid further recursion
+ (error "~@<When computing profiling data for ~S, the profiled function ~S was called. To get out of this infinite recursion, all functions have been unprofiled. (Since the profiling system evidently uses ~S in its computations, it looks as though it's a bad idea to profile it.)~:@>"
+ *computing-profiling-data-for*
+ encapsulated-fun
+ encapsulated-fun))
;; FIXME: Probably when this is stable, we should optimize (SAFETY 0).
(fastbig-incf-pcounter-or-fixnum count 1)
(let ((dticks 0)
(sb-c:%more-arg-values arg-context
0
arg-count))
- (setf dticks (fastbig- (get-internal-ticks) start-ticks)
- dconsing (fastbig- (the unsigned-byte
- (get-bytes-consed))
- start-consing))
- (setf inner-enclosed-profiles
- (pcounter-or-fixnum->integer *enclosed-profiles*))
- (when (minusp dticks) ; REMOVEME
- (error "huh? (GET-INTERNAL-TICKS)=~S START-TICKS=~S"
- (get-internal-ticks) start-ticks))
- (aver (not (minusp dconsing))) ; REMOVEME
- (aver (not (minusp inner-enclosed-profiles))) ; REMOVEME
- (let ((net-dticks (fastbig- dticks *enclosed-ticks*)))
- (when (minusp net-dticks) ; REMOVEME
- (error "huh? DTICKS=~S, *ENCLOSED-TICKS*=~S"
- dticks *enclosed-ticks*))
- (fastbig-incf-pcounter-or-fixnum ticks net-dticks))
- (let ((net-dconsing (fastbig- dconsing *enclosed-consing*)))
- (when (minusp net-dconsing) ; REMOVEME
- (error "huh? DCONSING=~S, *ENCLOSED-CONSING*=~S"
- dticks *enclosed-ticks*))
- (fastbig-incf-pcounter-or-fixnum consing net-dconsing))
- (fastbig-incf-pcounter-or-fixnum profiles
- inner-enclosed-profiles)))
+ (let ((*computing-profiling-data-for* encapsulated-fun))
+ (setf dticks (fastbig- (get-internal-ticks) start-ticks)
+ dconsing (fastbig- (the unsigned-byte
+ (get-bytes-consed))
+ start-consing))
+ (setf inner-enclosed-profiles
+ (pcounter-or-fixnum->integer *enclosed-profiles*))
+ (when (minusp dticks) ; REMOVEME
+ (unprofile-all)
+ (error "huh? (GET-INTERNAL-TICKS)=~S START-TICKS=~S"
+ (get-internal-ticks) start-ticks))
+ (aver (not (minusp dconsing))) ; REMOVEME
+ (aver (not (minusp inner-enclosed-profiles))) ; REMOVEME
+ (let ((net-dticks (fastbig- dticks *enclosed-ticks*)))
+ (when (minusp net-dticks) ; REMOVEME
+ (unprofile-all)
+ (error "huh? DTICKS=~S, *ENCLOSED-TICKS*=~S"
+ dticks *enclosed-ticks*))
+ (fastbig-incf-pcounter-or-fixnum ticks net-dticks))
+ (let ((net-dconsing (fastbig- dconsing *enclosed-consing*)))
+ (when (minusp net-dconsing) ; REMOVEME
+ (unprofile-all)
+ (error "huh? DCONSING=~S, *ENCLOSED-CONSING*=~S"
+ dticks *enclosed-ticks*))
+ (fastbig-incf-pcounter-or-fixnum consing net-dconsing))
+ (fastbig-incf-pcounter-or-fixnum profiles
+ inner-enclosed-profiles))))
(fastbig-incf-pcounter-or-fixnum *enclosed-ticks* dticks)
(fastbig-incf-pcounter-or-fixnum *enclosed-consing* dconsing)
(fastbig-incf-pcounter-or-fixnum *enclosed-profiles*
inner-enclosed-profiles)))))
;; READ-STATS-FUN
(lambda ()
- (format t "/entering READ-STATS-FUN ~S ~S ~S ~S~%"
- count ticks consing profiles) ; REMOVEME (and M-V-PROG1 below)
- (multiple-value-prog1
- (values (pcounter-or-fixnum->integer count)
- (pcounter-or-fixnum->integer ticks)
- (pcounter-or-fixnum->integer consing)
- (pcounter-or-fixnum->integer profiles))
- (print "/returning from READ-STATS-FUN")))
+ (values (pcounter-or-fixnum->integer count)
+ (pcounter-or-fixnum->integer ticks)
+ (pcounter-or-fixnum->integer consing)
+ (pcounter-or-fixnum->integer profiles)))
;; CLEAR-STATS-FUN
(lambda ()
(setf count 0
;;;; overhead estimation
;;; We average the timing overhead over this many iterations.
-(defconstant +timer-overhead-iterations+ 50000)
+(defconstant +timer-overhead-iterations+
+ 50 ; REMOVEME
+ ;;50000
+ )
;;; a dummy function that we profile to find profiling overhead
(declaim (notinline compute-overhead-aux))
(assert (= (exercise-valuesify 1.25) 2.25))
;;; Don Geddis reported this test case 25 December 1999 on a CMU CL
-;;; mailing list: dumping circular lists caused an infinite loop.
-;;; Douglas Crosher reported a patch 27 Dec 1999. The patch was tested
-;;; on SBCL by Martin Atzmueller 2 Nov 2000, and merged in
-;;; sbcl-0.6.8.11.
+;;; mailing list: dumping circular lists caused the compiler to enter
+;;; an infinite loop. Douglas Crosher reported a patch 27 Dec 1999.
+;;; The patch was tested on SBCL by Martin Atzmueller 2 Nov 2000, and
+;;; merged in sbcl-0.6.8.11.
(defun q-dg1999-1 () (dolist (x '#1=("A" "B" . #1#)) x))
(defun q-dg1999-2 () (dolist (x '#1=("C" "D" . #1#)) x))
(defun q-dg1999-3 () (dolist (x '#1=("E" "F" . #1#)) x))
(declaim (ftype function i-am-just-a-function))
(defun i-am-just-a-function (x y) (+ x y 1))
+;;; Stig E SandPHI (where PHI is some phi-like character not
+;;; representable in ASCII) reported in cclan-Bugs-431263 that SBCL
+;;; couldn't compile this. sbcl-0.6.12.26 died in CIRCULAR-LIST-P with
+;;; "The value \"EST\" is not of type LIST." Dan Barlow fixed it.
+(defvar +time-zones+
+ '((5 "EDT" . "EST") (6 "CDT" . "CST") (7 "MDT" .
+"MST") (8 "PDT" . "PST")
+ (0 "GMT" . "GDT") (-2 "MET" . "MET DST"))
+ "*The string representations of the time zones.")
+
(sb-ext:quit :unix-status 104) ; success