-;;;
-;;; FIXME: The VERBOSE-P stuff is no longer used.
-(defun sub-gc (&key (verbose-p *gc-verbose*) force-p #!+gencgc (gen 0))
- (/show0 "entering SUB-GC")
- (unless *already-maybe-gcing*
- (/show0 "not *ALREADY-MAYBE-GCING*")
- (let* ((*already-maybe-gcing* t)
- (start-time (get-internal-run-time))
- (pre-gc-dyn-usage (dynamic-usage)))
- (unless (integerp (symbol-value '*bytes-consed-between-gcs*))
- ;; The noise w/ symbol-value above is to keep the compiler
- ;; from optimizing the test away because of the type declaim
- ;; for *bytes-consed-between-gcs*.
- ;;
- ;; FIXME: I'm inclined either to get rid of the DECLAIM or to
- ;; trust it, instead of doing this weird hack. It's not
- ;; particularly trustable, since (SETF
- ;; *BYTES-CONSED-BETWEEN-GCS* 'SEVEN) works. But it's also not
- ;; very nice to have the type of the variable specified in two
- ;; places which can (and in CMU CL 2.4.8 did, INTEGER vs.
- ;; INDEX) drift apart. So perhaps we should just add a note to
- ;; the variable documentation for *BYTES-CONSED-BETWEEN-GCS*
- ;; that it must be an INDEX, and remove the DECLAIM. Or we
- ;; could make a SETFable (BYTES-CONSED-BETWEEN-GCS) function
- ;; and enforce the typing that way. And in fact the SETFable
- ;; function already exists, so all we need do is make the
- ;; variable private, and then we can trust the DECLAIM.
- (warn "The value of *BYTES-CONSED-BETWEEN-GCS*, ~S, is not an ~
- integer. Resetting it to ~D."
- *bytes-consed-between-gcs*
- default-bytes-consed-between-gcs)
- (setf *bytes-consed-between-gcs* default-bytes-consed-between-gcs))
- (when (and *gc-trigger* (> pre-gc-dyn-usage *gc-trigger*))
- (/show0 "setting *NEED-TO-COLLECT-GARBAGE* to T")
- (setf *need-to-collect-garbage* t))
- (when (or force-p
- (and *need-to-collect-garbage* (not *gc-inhibit*)))
- (/show0 "Evidently we ought to collect garbage..")
- (when (and (not force-p)
- *gc-inhibit-hook*
- (carefully-funcall *gc-inhibit-hook* pre-gc-dyn-usage))
- (/show0 "..but we're inhibited.")
- (setf *gc-inhibit* t)
- (return-from sub-gc nil))
- ;; KLUDGE: Wow, we really mask interrupts all the time we're
- ;; collecting garbage? That seems like a long time.. -- WHN 19991129
- (without-interrupts
- ;; FIXME: We probably shouldn't do this evil thing to
- ;; *STANDARD-OUTPUT* in a binding which is wrapped around
- ;; calls to user-settable GC hook functions.
- (let ((*standard-output* *terminal-io*))
- (when *gc-notify-stream*
- (/show0 "doing the *GC-NOTIFY-BEFORE* thing")
- (if (streamp *gc-notify-stream*)
- (carefully-funcall *gc-notify-before*
- *gc-notify-stream*
- pre-gc-dyn-usage)
- (warn
- "*GC-NOTIFY-STREAM* is set, but not a STREAM -- ignored.")))
- (dolist (hook *before-gc-hooks*)
- (/show0 "doing a hook from *BEFORE-GC-HOOKS*")
- (carefully-funcall hook))
- (when *gc-trigger*
- (clear-auto-gc-trigger))
- (/show0 "FUNCALLing *INTERNAL-GC*, one way or another")
- #!-gencgc (funcall *internal-gc*)
- ;; FIXME: This EQ test is pretty gross. Among its other
- ;; nastinesses, it looks as though it could break if we
- ;; recompile COLLECT-GARBAGE.
- #!+gencgc (if (eq *internal-gc* #'collect-garbage)
- (funcall *internal-gc* gen)
- (funcall *internal-gc*))
- (/show0 "back from FUNCALL to *INTERNAL-GC*")
- (let* ((post-gc-dyn-usage (dynamic-usage))
- (bytes-freed (- pre-gc-dyn-usage post-gc-dyn-usage)))
- (when *last-bytes-in-use*
- (incf *total-bytes-consed*
- (- pre-gc-dyn-usage *last-bytes-in-use*))
- (setq *last-bytes-in-use* post-gc-dyn-usage))
- (setf *need-to-collect-garbage* nil)
- (let ((new-gc-trigger (+ post-gc-dyn-usage
- *bytes-consed-between-gcs*)))
- (setf *gc-trigger* new-gc-trigger))
- (set-auto-gc-trigger *gc-trigger*)
- (dolist (hook *after-gc-hooks*)
- (/show0 "doing a hook from *AFTER-GC--HOOKS*")
- ;; FIXME: This hook should be called with the
- ;; same kind of information as *GC-NOTIFY-AFTER*.
- ;; In particular, it would be nice for the
- ;; hook function to be able to adjust *GC-TRIGGER*
- ;; intelligently to e.g. 108% of total memory usage.
- (carefully-funcall hook))
- (when *gc-notify-stream*
- (/show0 "doing the *GC-NOTIFY-AFTER* thing")
- (if (streamp *gc-notify-stream*)
- (carefully-funcall *gc-notify-after*
- *gc-notify-stream*
- post-gc-dyn-usage
- bytes-freed
- *gc-trigger*)
- (warn
- "*GC-NOTIFY-STREAM* is set, but not a stream -- ignored.")))))
- (/show0 "scrubbing control stack")
- (scrub-control-stack)))
- (/show0 "updating *GC-RUN-TIME*")
- (incf *gc-run-time* (- (get-internal-run-time)
- start-time))))
- ;; FIXME: should probably return (VALUES), here and in RETURN-FROM
- (/show "returning from tail of SUB-GC")
- nil)