1.0.19.7: refactor stack allocation decisions
[sbcl.git] / src / code / profile.lisp
index e2f98f9..ddfd722 100644 (file)
 \f
 ;;;; reading internal run time with high resolution and low overhead
 
-;;; FIXME: It might make sense to replace this with something
-;;; with finer resolution, e.g. milliseconds or microseconds.
-;;; For that matter, maybe we should boost the internal clock
-;;; up to something faster, like milliseconds.
-
 (defconstant +ticks-per-second+ internal-time-units-per-second)
 
 (declaim (inline get-internal-ticks))
@@ -51,7 +46,8 @@
   (make-hash-table
    ;; EQL testing isn't good enough for generalized function names
    ;; like (SETF FOO).
-   :test 'equal))
+   :test 'equal
+   :synchronized t))
 (defstruct (profile-info (:copier nil))
   (name              (missing-arg) :read-only t)
   (encapsulated-fun  (missing-arg) :type function :read-only t)
 ;;;   (VALUES ENCAPSULATION-FUN READ-STATS-FUN CLEAR-STATS-FUN).
 ;;;
 ;;; ENCAPSULATION-FUN is a plug-in replacement for ENCAPSULATED-FUN,
-;;; which updates statistics whenver it's called.
+;;; which updates statistics whenever it's called.
 ;;;
 ;;; READ-STATS-FUN returns the statistics:
 ;;;   (VALUES COUNT TIME CONSING PROFILE).
        (let ((dticks 0)
              (dconsing 0)
              (inner-enclosed-profiles 0))
-         (declare (type unsigned-byte dticks dconsing))
-         (declare (type unsigned-byte inner-enclosed-profiles))
+         (declare (type unsigned-byte dticks dconsing inner-enclosed-profiles)
+                  (dynamic-extent dticks dconsing inner-enclosed-profiles))
          (aver (typep dticks 'unsigned-byte))
          (aver (typep dconsing 'unsigned-byte))
          (aver (typep inner-enclosed-profiles 'unsigned-byte))
       `(unprofile-all)))
 
 (defun unprofile-all ()
-  (dohash (name profile-info *profiled-fun-name->info*)
+  (dohash ((name profile-info) *profiled-fun-name->info*
+           :locked t)
     (declare (ignore profile-info))
     (unprofile-1-fun name)))
 
 (defun reset ()
   "Reset the counters for all profiled functions."
-  (dohash (name profile-info *profiled-fun-name->info*)
+  (dohash ((name profile-info) *profiled-fun-name->info* :locked t)
     (declare (ignore name))
     (funcall (profile-info-clear-stats-fun profile-info))))
 \f
@@ -363,7 +360,7 @@ Lisp process."
           (compute-overhead)))
   (let ((time-info-list ())
         (no-call-name-list ()))
-    (dohash (name pinfo *profiled-fun-name->info*)
+    (dohash ((name pinfo) *profiled-fun-name->info* :locked t)
       (unless (eq (fdefinition name)
                   (profile-info-encapsulation-fun pinfo))
         (warn "Function ~S has been redefined, so times may be inaccurate.~@