(defun ,lisp-fun ()
(sb!alien:extern-alien ,c-var-name (sb!alien:unsigned 32))))))
-#!+(or cgc gencgc) (progn
-#!-sb-fluid (declaim (inline dynamic-usage))
-(def-c-var-frob dynamic-usage "bytes_allocated"))
-
+#!-gencgc
+(progn
+ ;; This is called once per PROFILEd function call, so it's worth a
+ ;; little possible space cost to reduce its time cost.
+ #!-sb-fluid
+ (declaim (inline current-dynamic-space-start))
+ (def-c-var-frob current-dynamic-space-start "current_dynamic_space"))
+
+#!-sb-fluid
+(declaim (inline dynamic-usage)) ; to reduce PROFILEd call overhead
+#!+(or cgc gencgc)
+(def-c-var-frob dynamic-usage "bytes_allocated")
#!-(or cgc gencgc)
(defun dynamic-usage ()
(the (unsigned-byte 32)
(- (sb!sys:sap-int (sb!c::dynamic-space-free-pointer))
(current-dynamic-space-start))))
-#!-gencgc (progn
-#!-sb-fluid (declaim (inline current-dynamic-space-start))
-(def-c-var-frob current-dynamic-space-start "current_dynamic_space"))
-
(defun static-space-usage ()
(- (* sb!vm:*static-space-free-pointer* sb!vm:word-bytes)
sb!vm:static-space-start))
(declaim (type index *gc-run-time*))
;;; a limit to help catch programs which allocate too much memory,
-;;; since a hard heap overflow is so hard to recover from.
+;;; since a hard heap overflow is so hard to recover from
(declaim (type (or unsigned-byte null) *soft-heap-limit*))
(defvar *soft-heap-limit* nil)
-;;; Internal trigger. When the dynamic usage increases beyond this
-;;; amount, the system notes that a garbage collection needs to occur by
-;;; setting *NEED-TO-COLLECT-GARBAGE* to T. It starts out as NIL meaning
+;;; When the dynamic usage increases beyond this amount, the system
+;;; notes that a garbage collection needs to occur by setting
+;;; *NEED-TO-COLLECT-GARBAGE* to T. It starts out as NIL meaning
;;; nobody has figured out what it should be yet.
(defvar *gc-trigger* nil)
(defun default-gc-notify-before (notify-stream bytes-in-use)
(declare (type stream notify-stream))
(format notify-stream
- "~&; GC is beginning with ~:D bytes in use.~%"
- bytes-in-use)
+ "~&; GC is beginning with ~:D bytes in use at internal runtime ~:D.~%"
+ bytes-in-use
+ (get-internal-run-time))
(finish-output notify-stream))
(defparameter *gc-notify-before* #'default-gc-notify-before
#!+sb-doc
new-trigger)
(declare (type stream notify-stream))
(format notify-stream
- "~&; GC has finished with ~:D bytes in use (~:D bytes freed).~%"
+ "~&; GC has finished with ~:D bytes in use (~:D bytes freed)~@
+ ; at internal runtime ~:D. The new GC trigger is ~:D bytes.~%"
bytes-retained
- bytes-freed)
- (format notify-stream
- "~&; The new GC trigger is ~:D bytes.~%"
+ bytes-freed
+ (get-internal-run-time)
new-trigger)
(finish-output notify-stream))
(defparameter *gc-notify-after* #'default-gc-notify-after
(sb!alien:def-alien-routine collect-garbage sb!c-call:int
#!+gencgc (last-gen sb!c-call:int))
-
(sb!alien:def-alien-routine set-auto-gc-trigger sb!c-call:void
(dynamic-usage sb!c-call:unsigned-long))
;;; is not greater than *GC-TRIGGER*.
;;;
;;; For GENCGC all generations < GEN will be GC'ed.
-(defun sub-gc (&key force-p (gen 0))
+(defun sub-gc (&key force-p (gen 0))
(/show0 "entering SUB-GC")
(unless *already-maybe-gcing*
(let* ((*already-maybe-gcing* t)
object)
;;; This is the user-advertised garbage collection function.
-
(defun gc (&key (gen 0) (full nil) &allow-other-keys)
#!+(and sb-doc gencgc)
"Initiate a garbage collection. GEN controls the number of generations
to garbage collect."
#!+(and sb-doc (not gencgc))
- "Initiate a garbage collection. GEN may be provided for compatibility, but
- is ignored."
+ "Initiate a garbage collection. GEN may be provided for compatibility with
+ generational garbage collectors, but is ignored in this implementation."
(sub-gc :force-p t :gen (if full 6 gen)))
\f