Skip to content

Commit

Permalink
1.0.22.5: teach DISASSEMBLE about %METHOD-FUNCTIONs
Browse files Browse the repository at this point in the history
 * Disassemble both the %METHOD-FUNCTION object itself, and the
   associated fast-function.

 * Clarify the disassembler output slightly by prepending it with
   ; disassembly for <function name>.
  • Loading branch information
nikodemus committed Oct 31, 2008
1 parent cee152f commit 5045e82
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 13 deletions.
2 changes: 2 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
;;;; -*- coding: utf-8; -*-
changes in sbcl-1.0.23 relative to 1.0.22:
* enhancement: when disassembling method functions, disassembly
for the associated fast function is also produced.
* optimization: printing with *PRINT-PRETTY* true is now more
efficient as long as the object being printed doesn't require
special handling by the pretty printer.
Expand Down
33 changes: 21 additions & 12 deletions src/compiler/target-disassem.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -1498,26 +1498,30 @@
(error "can't compile a lexical closure"))
(compile nil lambda)))

(defun valid-extended-function-designator-for-disassemble-p (thing)
(defun valid-extended-function-designators-for-disassemble-p (thing)
(cond ((legal-fun-name-p thing)
(compiled-fun-or-lose (fdefinition thing) thing))
(compiled-funs-or-lose (fdefinition thing) thing))
#!+sb-eval
((sb!eval:interpreted-function-p thing)
(compile nil thing))
((typep thing 'sb!pcl::%method-function)
;; in a %METHOD-FUNCTION, the user code is in the fast function, so
;; we to disassemble both.
(list thing (sb!pcl::%method-function-fast-function thing)))
((functionp thing)
thing)
((and (listp thing)
(eq (car thing) 'lambda))
(compile nil thing))
(t nil)))

(defun compiled-fun-or-lose (thing &optional (name thing))
(let ((fun (valid-extended-function-designator-for-disassemble-p thing)))
(if fun
fun
(defun compiled-funs-or-lose (thing &optional (name thing))
(let ((funs (valid-extended-function-designators-for-disassemble-p thing)))
(if funs
funs
(error 'simple-type-error
:datum thing
:expected-type '(satisfies valid-extended-function-designator-for-disassemble-p)
:expected-type '(satisfies valid-extended-function-designators-for-disassemble-p)
:format-control "can't make a compiled function from ~S"
:format-arguments (list name)))))

Expand All @@ -1532,11 +1536,16 @@
(declare (type (or function symbol cons) object)
(type (or (member t) stream) stream)
(type (member t nil) use-labels))
(pprint-logical-block (*standard-output* nil :per-line-prefix "; ")
(disassemble-fun (compiled-fun-or-lose object)
:stream stream
:use-labels use-labels)
nil))
(flet ((disassemble1 (fun)
(format stream "~&; disassembly for ~S" (sb!kernel:%fun-name fun))
(disassemble-fun fun
:stream stream
:use-labels use-labels)))
(let ((funs (compiled-funs-or-lose object)))
(if (listp funs)
(dolist (fun funs) (disassemble1 fun))
(disassemble1 funs))))
nil)

;;; Disassembles the given area of memory starting at ADDRESS and
;;; LENGTH long. Note that if CODE-COMPONENT is NIL and this memory
Expand Down
2 changes: 1 addition & 1 deletion version.lisp-expr
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@
;;; checkins which aren't released. (And occasionally for internal
;;; versions, especially for internal versions off the main CVS
;;; branch, it gets hairier, e.g. "0.pre7.14.flaky4.13".)
"1.0.22.4"
"1.0.22.5"

0 comments on commit 5045e82

Please sign in to comment.