Bytecode disassembler
Brian T. Rice
water at tunes.org
Fri Aug 13 09:49:39 PDT 2004
Pavel Holejsovsky wrote:
> Hi Slaters,
>
> I wrote attached bytecode disassembling stream, mainly for educational
> purposes. I'd be glad for any comments about this code - both for
> implementation and style of interface (Disassembler is ReadStream clone,
> working over CompiledMethod, providing strings with single disassembled
> instructions).
Cool! Thank you. This is definitely a nice start. I'm not sure if it
helps to make it a stream type, although it's obviously true that the
code must be traversed in-order to build up the instruction sequence.
The only things I really noticed were that it resembled StreamProcessor
but doesn't (and probably shouldn't) have the same interface, and that
value:typed: is kind of an awkward message name, although I'm not sure
what a better one would be. Perhaps printNameOf:type: or something.
> 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 have some questions:
> - I'm not sure if I understood doc/bytecode.txt properly. Especially
> extended value decoding might be completely broken (see
> valueFromOpcode:). Also, jump-type offset decoding
> (d@(DisassemblerStream traits) value: _ typed: _@#jumpType) assumes
> little-endian, but is real encoding image-endianness dependent?
That's an interesting question. You might have to check both images to
verify this. We're supposed to be able to perform endianness-swaps on
load so we won't have to deal with the platforms separately; perhaps
this would be an issue. (Lee, any comments?)
> - How can I get block of existing slate methods (to see them
> disassembled)? I mean, if I want to see disassembly of method #next for
> argument {Disassembler traits}, I need some protocol which answers block
> (closure) according to method name and array of parameters. Is it there
> something like this?
Sure. #selector findOn: {arguments} will return a method found by lookup
on the arguments or Nil. There's also a findOn:after: for simulating
resends. Probably from this there could be an easy definition of
findAllMethodsOn:.
> thanks
> pavouk
-------------- next part --------------
A non-text attachment was scrubbed...
Name: water.vcf
Type: text/x-vcard
Size: 208 bytes
Desc: not available
Url : /archives/slate/attachments/20040813/25f4259e/water.vcf
More information about the Slate
mailing list