[Vm-dev] Howto invoke plugin primitive from Interpreter?
Marcus Denker
denker at iam.unibe.ch
Thu Jun 14 13:07:12 UTC 2007
On 14.06.2007, at 14:31, André Wendt wrote:
>
> Hi Bert,
>
> I'm trying to write a logging facility for send (sample work for Prof.
> Hirschfeld, actually): Each time a message is sent, the target class,
> message and a couple of other properties should be logged.
>
> That means I have to open a file upon initialization and write the
> file
> at each send. There's no other way than to do that in the Interpreter,
> as far as I can see.
>
Hacking the interpreter is one solution... but you can do it from inside
the image, with no VM changes, too. It might be a bit slower, though.
(and maybe not what you need at all, nevertheless, it is good to now
all the options).
One way to achieve this with no VM change is to manipulate the
bytecode of the methods.
So for logging sends, you would add bytecode in front of each send
that does the logging. This bytecode can access all sorts of
information,
e.g. the sender or the arguments of the sends.
We did a library that makes this kind of manipulation relatively easy to
do:
http://www.iam.unibe.ch/~scg/Research/ByteSurgeon/
The ByteSurgeon framework has been used for a "Log everything" Back-
in-Time
Debugger.
We now have an even better system (called "Reflectivity") for this
kind of meta
programming things (not based on bytecode manipulation).
If you decide to play with logging sends from "inside" the image,
this should
be quite interesting. The resulting code is faster then doing
bytecode manipulation,
and it allows for far better control (it implements the model of
Partial Behavioral
Reflection found in Reflex for Java).
This is not yet released, but if you want to play with it, please
send me a mail (I am
happy about any users ;-)).
Marcus
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 3947 bytes
Desc: not available
Url : http://lists.squeakfoundation.org/pipermail/vm-dev/attachments/20070614/b7762680/smime.bin
More information about the Vm-dev
mailing list