X-Git-Url: http://repo.macrolet.net/gitweb/?a=blobdiff_plain;f=src%2Fcode%2Fgc.lisp;h=973799df2f8c9045ca5920567bd858db3dbf6ef7;hb=c9e11f1e55e5e19f35c931af8180a2cd075ab5f5;hp=3aa11b4064c021d464a41644ab6d365925732b96;hpb=a530bbe337109d898d5b4a001fc8f1afa3b5dc39;p=sbcl.git diff --git a/src/code/gc.lisp b/src/code/gc.lisp index 3aa11b4..973799d 100644 --- a/src/code/gc.lisp +++ b/src/code/gc.lisp @@ -10,14 +10,11 @@ ;;;; files for more information. (in-package "SB!KERNEL") - -(file-comment - "$Header$") ;;;; DYNAMIC-USAGE and friends -(declaim (special *read-only-space-free-pointer* - *static-space-free-pointer*)) +(declaim (special sb!vm:*read-only-space-free-pointer* + sb!vm:*static-space-free-pointer*)) (eval-when (:compile-toplevel :execute) (sb!xc:defmacro def-c-var-frob (lisp-fun c-var-name) @@ -26,59 +23,35 @@ (defun ,lisp-fun () (sb!alien:extern-alien ,c-var-name (sb!alien:unsigned 32)))))) -(def-c-var-frob read-only-space-start "read_only_space") -(def-c-var-frob static-space-start "static_space") -(def-c-var-frob dynamic-0-space-start "dynamic_0_space") -(def-c-var-frob dynamic-1-space-start "dynamic_1_space") -(def-c-var-frob control-stack-start "control_stack") -#!+x86 (def-c-var-frob control-stack-end "control_stack_end") -(def-c-var-frob binding-stack-start "binding_stack") -(def-c-var-frob current-dynamic-space-start "current_dynamic_space") - #!-sb-fluid (declaim (inline dynamic-usage)) -#!-(or cgc gencgc) -(defun dynamic-usage () - (the (unsigned-byte 32) - (- (sb!sys:sap-int (sb!c::dynamic-space-free-pointer)) - (current-dynamic-space-start)))) -#!+(or cgc gencgc) (def-c-var-frob dynamic-usage "bytes_allocated") (defun static-space-usage () - (- (* sb!impl::*static-space-free-pointer* sb!vm:word-bytes) - (static-space-start))) + (- (* sb!vm:*static-space-free-pointer* sb!vm:word-bytes) + sb!vm:static-space-start)) (defun read-only-space-usage () - (- (* sb!impl::*read-only-space-free-pointer* sb!vm:word-bytes) - (read-only-space-start))) + (- (* sb!vm::*read-only-space-free-pointer* sb!vm:word-bytes) + sb!vm:read-only-space-start)) (defun control-stack-usage () #!-x86 (- (sb!sys:sap-int (sb!c::control-stack-pointer-sap)) - (control-stack-start)) - #!+x86 (- (control-stack-end) + sb!vm:control-stack-start) + #!+x86 (- sb!vm:control-stack-end (sb!sys:sap-int (sb!c::control-stack-pointer-sap)))) (defun binding-stack-usage () - (- (sb!sys:sap-int (sb!c::binding-stack-pointer-sap)) (binding-stack-start))) - -(defun current-dynamic-space () - (let ((start (current-dynamic-space-start))) - (cond ((= start (dynamic-0-space-start)) - 0) - ((= start (dynamic-1-space-start)) - 1) - (t - (error "Oh no! The current dynamic space is missing!"))))) + (- (sb!sys:sap-int (sb!c::binding-stack-pointer-sap)) + sb!vm:binding-stack-start)) ;;;; ROOM (defun room-minimal-info () - (format t "Dynamic Space Usage: ~10:D bytes.~%" (dynamic-usage)) - (format t "Read-Only Space Usage: ~10:D bytes.~%" (read-only-space-usage)) - (format t "Static Space Usage: ~10:D bytes.~%" (static-space-usage)) - (format t "Control Stack Usage: ~10:D bytes.~%" (control-stack-usage)) - (format t "Binding Stack Usage: ~10:D bytes.~%" (binding-stack-usage)) - (format t "The current dynamic space is ~D.~%" (current-dynamic-space)) + (format t "Dynamic space usage is: ~10:D bytes.~%" (dynamic-usage)) + (format t "Read-only space usage is: ~10:D bytes.~%" (read-only-space-usage)) + (format t "Static space usage is: ~10:D bytes.~%" (static-space-usage)) + (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*)) @@ -267,25 +240,11 @@ (sb!alien:def-alien-routine collect-garbage sb!c-call:int #!+gencgc (last-gen sb!c-call:int)) -#!-ibmrt (sb!alien:def-alien-routine set-auto-gc-trigger sb!c-call:void (dynamic-usage sb!c-call:unsigned-long)) -#!+ibmrt -(defun set-auto-gc-trigger (bytes) - (let ((words (ash (+ (current-dynamic-space-start) bytes) -2))) - (unless (and (fixnump words) (plusp words)) - (clear-auto-gc-trigger) - (warn "attempt to set GC trigger to something bogus: ~S" bytes)) - (setf %rt::*internal-gc-trigger* words))) - -#!-ibmrt (sb!alien:def-alien-routine clear-auto-gc-trigger sb!c-call:void) -#!+ibmrt -(defun clear-auto-gc-trigger () - (setf %rt::*internal-gc-trigger* -1)) - ;;; This variable contains the function that does the real GC. This is ;;; for low-level GC experimentation. Do not touch it if you do not ;;; know what you are doing. @@ -393,11 +352,11 @@ (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. + ;; 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") @@ -415,7 +374,7 @@ (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") + (/show0 "returning from tail of SUB-GC") nil) ;;; This routine is called by the allocation miscops to decide whether