Update of /cvsroot/sbcl/sbcl/src/code
In directory sc8-pr-cvs1:/tmp/cvs-serv20011/src/code
Modified Files:
cold-init.lisp gc.lisp sysmacs.lisp
Log Message:
0.pre8.4
Change *gc-inhibit* into a counter which increments every time
without-gcing is called. Now we can call without-gcing
recursively or from >1 thread without bad things happening
Index: cold-init.lisp
===================================================================
RCS file: /cvsroot/sbcl/sbcl/src/code/cold-init.lisp,v
retrieving revision 1.36
retrieving revision 1.37
diff -u -d -r1.36 -r1.37
--- cold-init.lisp 5 Sep 2002 13:15:50 -0000 1.36
+++ cold-init.lisp 25 Mar 2003 01:49:36 -0000 1.37
@@ -96,7 +96,7 @@
*before-gc-hooks* nil
*after-gc-hooks* nil
*already-maybe-gcing* t
- *gc-inhibit* t
+ *gc-inhibit* 1
*need-to-collect-garbage* nil
sb!unix::*interrupts-enabled* t
sb!unix::*interrupt-pending* nil
Index: gc.lisp
===================================================================
RCS file: /cvsroot/sbcl/sbcl/src/code/gc.lisp,v
retrieving revision 1.40
retrieving revision 1.41
diff -u -d -r1.40 -r1.41
--- gc.lisp 28 Feb 2003 19:26:22 -0000 1.40
+++ gc.lisp 25 Mar 2003 01:49:36 -0000 1.41
@@ -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 @@
(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
@@ -300,6 +300,13 @@
;;; 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 @@
(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
@@ -452,7 +459,7 @@
(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)
@@ -460,7 +467,7 @@
(defun gc-off ()
#!+sb-doc
"Disable the garbage collector."
- (setq *gc-inhibit* t)
+ (setq *gc-inhibit* 1)
nil)
;;;; initialization stuff
Index: sysmacs.lisp
===================================================================
RCS file: /cvsroot/sbcl/sbcl/src/code/sysmacs.lisp,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -d -r1.11 -r1.12
--- sysmacs.lisp 31 Oct 2001 19:42:57 -0000 1.11
+++ sysmacs.lisp 25 Mar 2003 01:49:36 -0000 1.12
@@ -11,14 +11,26 @@
(in-package "SB!IMPL")
+
+#!-sb-thread
+(defmacro atomic-incf (symbol-name &optional (delta 1))
+ `(incf ,symbol-name ,delta))
+
+(defmacro atomic-decf (place &optional (delta 1))
+ `(atomic-incf ,place ,(- delta)))
+
+
(defmacro without-gcing (&rest body)
#!+sb-doc
"Executes the forms in the body without doing a garbage collection."
`(unwind-protect
- (let ((*gc-inhibit* t))
- ,@body)
- (when (and *need-to-collect-garbage* (not *gc-inhibit*))
- (maybe-gc nil))))
+ (progn
+ (atomic-incf *gc-inhibit*)
+ ,@body)
+ (atomic-decf *gc-inhibit*)
+ (when (and *need-to-collect-garbage* (zerop *gc-inhibit*))
+ (maybe-gc nil))))
+
;;; EOF-OR-LOSE is a useful macro that handles EOF.
(defmacro eof-or-lose (stream eof-error-p eof-value)
-------------------------------------------------------
This SF.net email is sponsored by:
The Definitive IT and Networking Event. Be There!
NetWorld+Interop Las Vegas 2003 -- Register today!
http://ads.sourceforge.net/cgi-bin/redirect.pl?keyn0001en
|