Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(funcall (java:jfield org.armedbear.lisp.Function FUNCTION_CLASS_BYTE… #437

Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 19 additions & 1 deletion src/org/armedbear/lisp/disassemble.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,20 @@
(in-package :system)
(require :clos)

(eval-when (:load-toplevel)
(defvar *available-disassemblers*
(let ((files
(directory (merge-pathnames
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One cannot assume the presences of a the ABCL-INTROSPECT in the core implementation. Additionally, the presence of the function in a file does not necessarily mean the assembler is available, as it might have unsatisfied Maven load dependencies.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If there aren't any disassemblers then available-disassemblers will be nil. It's a directory probe which simply fails. The require loads the appropriate system, which resolves the maven dependencies.

"abcl-introspect/*.lisp"
sys::*abcl-contrib*))))
(loop for f in files
append
(with-open-file (s f :direction :input)
(loop for line = (read-line s nil :eof)
until (eq line :eof)
when (search "disassemble-class-bytes" line)
do (return (list (intern (string-upcase (pathname-name f)) :keyword)))))))))

(defvar *disassembler-function* nil
"The currently used function for CL:DISASSEMBLE.

Expand Down Expand Up @@ -63,6 +77,8 @@ SYS:*DISASSEMBLERS*."
(flet ((sane-disassembler-p (disassembler)
(and disassembler
(fboundp disassembler))))
(when (member name *available-disassemblers*)
(require name))
(setf *disassembler-function*
(if name
(let ((disassembler (cdr (assoc name *disassemblers*))))
Expand Down Expand Up @@ -149,7 +165,9 @@ SYS:*DISASSEMBLERS*."
(if (or (java:jinstance-of-p classloader "org.armedbear.lisp.MemoryClassLoader")
(java:jinstance-of-p classloader "org.armedbear.lisp.FaslClassLoader"))
(disassemble-bytes
(java:jcall "getFunctionClassBytes" classloader class))
(funcall (java:jfield "org.armedbear.lisp.Function" "FUNCTION_CLASS_BYTES") function)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why this better than calling getFunctionClassBytes on the classloader? Perhaps it is an additional strategy, rather than a strict replacement?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

getFunctionClassBytes didn't work sometimes and I couldn't figure out why, but this works. Should be tracked down. By someone else ;-)

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So, we should modify by adding the strategy to an (or (ignore-errors [CASE A]) (ignore-errors … clause as it will break even less often…

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's fine with me.

;(java:jcall "getFunctionClassBytes" classloader class)
)
(disassemble-bytes
(read-byte-array-from-stream
(java:jcall-raw
Expand Down