0.6.11.45:
[sbcl.git] / src / code / profile.lisp
index 4bb691c..57b3a5e 100644 (file)
 ;;; will minimize profiling overhead.)
 (defun profile-encapsulation-lambdas (encapsulated-fun)
   (declare (type function encapsulated-fun))
-  (declare (optimize speed safety))
   (let* ((count 0)
         (ticks 0)
         (consing 0)
     (values
      ;; ENCAPSULATION-FUN
      (lambda (sb-c:&more arg-context arg-count)
-       #+nil (declare (optimize (speed 3) (safety 0))) ; FIXME: remove #+NIL?
+       (declare (optimize speed safety))
+       ;; FIXME: Probably when this is stable, we should optimize (SAFETY 0).
        (fastbig-incf-pcounter-or-fixnum count 1)
        (let ((dticks 0)
             (dconsing 0)
 ;;; Profile the named function, which should exist and not be profiled
 ;;; already.
 (defun profile-1-unprofiled-function (name)
+  (declare #.*optimize-byte-compilation*)
   (let ((encapsulated-fun (fdefinition name)))
     (multiple-value-bind (encapsulation-fun read-stats-fun clear-stats-fun)
        (profile-encapsulation-lambdas encapsulated-fun)
 
 ;;; Profile the named function. If already profiled, unprofile first.
 (defun profile-1-function (name)
+  (declare #.*optimize-byte-compilation*)
   (cond ((fboundp name)
         (when (gethash name *profiled-function-name->info*)
           (warn "~S is already profiled, so unprofiling it first." name)
 
 ;;; Unprofile the named function, if it is profiled.
 (defun unprofile-1-function (name)
+  (declare #.*optimize-byte-compilation*)
   (let ((pinfo (gethash name *profiled-function-name->info*)))
     (cond (pinfo
           (remhash name *profiled-function-name->info*)
    reprofile (useful to notice function redefinition.)  If a name is
    undefined, then we give a warning and ignore it. See also
    UNPROFILE, REPORT and RESET."
+  (declare #.*optimize-byte-compilation*)
   (if (null names)
       `(loop for k being each hash-key in *profiled-function-name->info*
             collecting k)
   a function. A string names all the functions named by symbols in the
   named package. NAMES defaults to the list of names of all currently 
   profiled functions."
+  (declare #.*optimize-byte-compilation*)
   (if names
       `(mapc-on-named-functions #'unprofile-1-function ',names)
       `(unprofile-all)))
 
 (defun unprofile-all ()
+  (declare #.*optimize-byte-compilation*)
   (dohash (name profile-info *profiled-function-name->info*)
     (declare (ignore profile-info))
     (unprofile-1-function name)))
@@ -399,7 +405,7 @@ approximately adjusted for profiling overhead, but when RAW is true
 the unadjusted results are reported. The compensation may be somewhat
 inaccurate when bignums are involved in runtime calculation, as in
 a very-long-running Lisp process."
-  (declare (optimize (speed 0)))
+  (declare #.*optimize-external-despite-byte-compilation*)
   (unless (boundp '*overhead*)
     (setf *overhead*
          (compute-overhead)))