anchor.diff:           (entry-sp nil)
            (fundamental-function (mezzano.disassemble::peel-function function))
            (call-counts (make-hash-table :synchronized nil))
  -         (execution-counts (make-hash-table :synchronized nil)))
  +         (execution-counts (make-hash-table :synchronized nil))
  +         (callers (make-hash-table :synchronized nil))
  +         (callees (make-hash-table :synchronized nil)))
       (mezzano.supervisor::stop-thread thread)
       (setf stopped t)
       (unwind-protect
  
positive.code:                  call-counts)
          (setf counts (sort counts #'< :key #'cdr))
          (loop for (fn . count) in counts do (format t "~S: ~D~%" fn count)))
        (format t "Instruction counts:~%")
        (let ((counts '()))
          (maphash (lambda (fn count)
                     (push (cons fn count) counts))
                   execution-counts)
          (setf counts (sort counts #'< :key #'cdr))
          (loop for (fn . count) in counts do (format t "~S: ~D ~D%~%" fn count (* (/ count instructions-stepped) 100.0)))))))
  
  (defun profile-execution (function &key (sample-interval 1/100))
    (check-type function function)
  
negative.code:                                                       fn))
                                                 call-counts
                                                 0))
                                  (let ((tbl (gethash fn callers)))
                                    (when (not tbl)
                                      (setf tbl (make-hash-table :synchronized nil)
                                            (gethash fn callers) tbl))
                                    (incf (gethash prev-fn tbl 0)))
                                  (let ((tbl (gethash prev-fn callees)))
                                    (when (not tbl)
                                      (setf tbl (make-hash-table :synchronized nil)
                                            (gethash prev-fn callees) tbl))
                                    (incf (gethash fn tbl 0)))
                                  (cond (trace-call-mode
                                         (write-char #\>)
                                         (write-char #\Space)
  