X-Git-Url: http://repo.macrolet.net/gitweb/?a=blobdiff_plain;f=src%2Fcode%2Fgc.lisp;h=2389750c02cc62a31c51ef7fac13e766308eb954;hb=d61775ee52828f379eb6acedca421d5a55bfa2bd;hp=523f347bf147e729f601cfc125f71c16f0c0d911;hpb=550e5afc7ad95ff1e1bbfe932bf8dd81b0c4dce6;p=sbcl.git diff --git a/src/code/gc.lisp b/src/code/gc.lisp index 523f347..2389750 100644 --- a/src/code/gc.lisp +++ b/src/code/gc.lisp @@ -33,9 +33,9 @@ #!-sb-fluid (declaim (inline dynamic-usage)) ; to reduce PROFILEd call overhead -#!+(or cgc gencgc) +#!+gencgc (def-c-var-frob dynamic-usage "bytes_allocated") -#!-(or cgc gencgc) +#!-gencgc (defun dynamic-usage () (the (unsigned-byte 32) (- (sb!sys:sap-int (sb!c::dynamic-space-free-pointer)) @@ -70,7 +70,7 @@ (format t "Control stack usage is: ~10:D bytes.~%" (control-stack-usage)) (format t "Binding stack usage is: ~10:D bytes.~%" (binding-stack-usage)) (format t "Garbage collection is currently ~:[enabled~;DISABLED~].~%" - *gc-inhibit*)) + (> *gc-inhibit* 0))) (defun room-intermediate-info () (room-minimal-info) @@ -223,7 +223,7 @@ and submit it as a patch." (declaim (type (or index null) *gc-trigger*)) (defvar *gc-trigger* nil) -;;; When non-NIL, inhibits garbage collection. +;;; When >0, inhibits garbage collection. (defvar *gc-inhibit*) ; initialized in cold init ;;; This flag is used to prevent recursive entry into the garbage @@ -244,7 +244,7 @@ and submit it as a patch." (finish-output notify-stream)) (defparameter *gc-notify-before* #'default-gc-notify-before #!+sb-doc - "This function bound to this variable is invoked before GC'ing (unless + "The function bound to this variable is invoked before GC'ing (unless *GC-NOTIFY-STREAM* is NIL) with the value of *GC-NOTIFY-STREAM* and current amount of dynamic usage (in bytes). It should notify the user that the system is going to GC.") @@ -273,7 +273,7 @@ function should notify the user that the system has finished GC'ing.") ;;;; internal GC (sb!alien:define-alien-routine collect-garbage sb!alien:int - #!+gencgc (last-gen sb!alien:int)) + (#!+gencgc last-gen #!-gencgc ignore sb!alien:int)) (sb!alien:define-alien-routine set-auto-gc-trigger sb!alien:void (dynamic-usage sb!alien:unsigned-long)) @@ -300,6 +300,13 @@ function should notify the user that the system has finished GC'ing.") ;;; is not greater than *GC-TRIGGER*. ;;; ;;; For GENCGC all generations < GEN will be GC'ed. + +;;; XXX need (1) some kind of locking to ensure that only one thread +;;; at a time is trying to GC, (2) to look at all these specials and +;;; work out how much of this "do we really need to GC now?" stuff is +;;; actually necessary: I think we actually end up GCing every time we +;;; hit this code + (defun sub-gc (&key force-p (gen 0)) (/show0 "entering SUB-GC") (unless *already-maybe-gcing* @@ -323,7 +330,7 @@ function should notify the user that the system has finished GC'ing.") (when (and *gc-trigger* (> pre-gc-dynamic-usage *gc-trigger*)) (setf *need-to-collect-garbage* t)) (when (or force-p - (and *need-to-collect-garbage* (not *gc-inhibit*))) + (and *need-to-collect-garbage* (zerop *gc-inhibit*))) ;; KLUDGE: Wow, we really mask interrupts all the time we're ;; collecting garbage? That seems like a long time.. -- WHN 19991129 (without-interrupts @@ -349,17 +356,7 @@ function should notify the user that the system has finished GC'ing.") ;; triggered GC could've done a fair amount of ;; consing.) (pre-internal-gc-dynamic-usage (dynamic-usage)) - (ignore-me - #!-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. We should probably just - ;; straighten out the interface so that all *INTERNAL-GC* - ;; functions accept a GEN argument (and then the - ;; non-generational ones just ignore it). - #!+gencgc (if (eq *internal-gc* #'collect-garbage) - (funcall *internal-gc* gen) - (funcall *internal-gc*))) + (ignore-me (funcall *internal-gc* gen)) (post-gc-dynamic-usage (dynamic-usage)) (n-bytes-freed (- pre-internal-gc-dynamic-usage post-gc-dynamic-usage)) @@ -462,7 +459,7 @@ function should notify the user that the system has finished GC'ing.") (defun gc-on () #!+sb-doc "Enable the garbage collector." - (setq *gc-inhibit* nil) + (setq *gc-inhibit* 0) (when *need-to-collect-garbage* (sub-gc)) nil) @@ -470,7 +467,7 @@ function should notify the user that the system has finished GC'ing.") (defun gc-off () #!+sb-doc "Disable the garbage collector." - (setq *gc-inhibit* t) + (setq *gc-inhibit* 1) nil) ;;;; initialization stuff