Bytecode disassembler

Pavel Holejsovsky pavel.holejsovsky at upek.com
Tue Aug 17 01:48:47 PDT 2004


>>> Sample usage:
>>> [] disassembler upToEnd.
>>> [|:a b| b: a - 1. (b < 0) ifTrue: a neg ifFalse: a ] disassembler do:
>>>   [| :instr | Console ; instr ; '\n' ].
>>>
>>> or 'hackish' REPL-friendly interface:
>>> disass: [ 1 + 1 ].
> 
> 
> I thought more about the contents of the results as strings, and it's 
> not an easy thing to work on. One thing I have toyed with in my thoughts 
> is the idea of having subjective code-sequences to represent / simulate 
> bytecodes, so you could have (for your long example):
> 
> (
> loadSelector: #-.
> loadVariable: #i0.
> loadLiteral: 1.
> sendMessageWithArgs: 2.
> storeVariable: #l0.
> pop: 1.
> loadSelector: #<.
> ...
> ).
> 
> And each of these would be subjectively layered on the context so that 
> an Interpreter would execute these messages in a way that simulated the 
> state of the executable VM without being entangled too much in the 
> run-time characteristics. Now that I think of it, a specific Interpreter 
> must be chosen, so maybe macros are needed or something.
> 
> This is a slow solution, but kind of instructive.

Sounds pretty interesting and much more slate-like. Thanks for the idea, 
although I must say that I don't entirely get it at first glance.  Will 
think about it and probably ask some more questions.  The immediate 
problem I can see with this representation is how to express jump 
targets - some kind of label would be needed, will have to think about this.

> Anyway, maybe you'll get some ideas based on it. We will be better off 
> with a useful disassembler than without one, of course, so I'd like to 
> refine this and add it in to the repository.

Cool, thanks! Feel free to do whatever you like with this code.

pavouk




More information about the Slate mailing list