From: Pascal Bourguignon
Subject: Re: disassemble in clisp
Date: 
Message-ID: <87br7gefxm.fsf@thalassa.informatimago.com>
Allan Adler <···@nestle.csail.mit.edu> writes:

> Pascal Bourguignon <···@informatimago.com> writes:
>
>>Well I guess the OP had in mind rather something like:
>>(defun assemble (code)
> [snip]
>
> I entered clisp in an emacs shell and ran the defun'd function assemble
> and got this error message:
> ** - Continuable Error
> INTERN("MAKE-ANODE"): #<PACKAGE SYSTEM> is locked
> If you continue (by typing 'continue'): Ignore the lock and proceed
> 1. Break [2]>
>
> I have no idea what it is complaining about. Since Pascal got as far as
>
>>(defun testasm () (print :hello))
>>(disassemble 'testasm)
>
> I guess his clisp doesn't complain about the definition of testasm. I think
> I'm running clisp-2.30.

Well, as you can see, there are a lot of :: in this example, so of
course, it cannot work if you don't have the exact same version as me
(CVS 2.33.83).

>>Disassembly of function TESTASM
>>(CONST 0) = :A
>>0 required arguments
>>0 optional arguments
>>No rest parameter
>>No keyword parameters
>>4 byte-code instructions:
>>0     (CONST&PUSH 0)                      ; :A
>>1     (PUSH-UNBOUND 1)
>>3     (CALLS1 132)                        ; PRINT
>>5     (SKIP&RET 1)
>>NIL
>
> So, it seems that the disassembly doesn't save the information about
> the string that one is supposed to print. I'm just speculating wildly,
> but maybe that means that when it tries to carry out the print routine,
> it tries to read a location (whatever that really is) of the virtual machine
> for which nothing has been allocated, causing the segmentation fault
> reported below:

There's no string. The function testasm, prints the symbol :a, and :a
is in the generated code as (const 0).


>>[70]> (funcall (assemble 
>>                  `((compiler::const ,(compiler::make-const :value :a))
>>                    (compiler::push) 
>>                    (compiler::push-unbound 1)
>>                    (compiler::funcall 132)
>>                    (compiler::ret)))))
>>
>>Process inferior-lisp segmentation fault
>
> Regarding the post-mortem:
>
>>Of course, I'd need to understand what I'm doing to have it work, but
>>at least one can see from compiler::traverse-anode that the 2nd pass
>>doesn't accept the full documented byte-code, but a somewhat higher
>>level, undocumented, "assembler".
>
> What is compiler::traverse-anode and how does one look at it?

It's in the sources of the compiler, in:
          /usr/local/srcclisp-cvs/clisp/src/compiler.lisp


-- 
__Pascal Bourguignon__                     http://www.informatimago.com/
In deep sleep hear sound,
Cat vomit hairball somewhere.
Will find in morning.