More fun with VMs

Jecel Assumpcao Jr jecel at merlintec.com
Wed Mar 22 18:59:35 UTC 2006


Dan Ingalls wrote on Wed, 22 Mar 2006 07:32:19 -0800
> > > Lazy Activation
> 
> Completely.  Yes, it's in interesting case in which the dynamic solution,
> by virtue of more information, can do somewhat better.

When you have a method with something like

...
... ifTrue: [ .... "need to allocate context" coll message .... ].
...
... myArg ...

In the dynamic system the exact same bytecode for "myArg" can do
different things depending on the execution of the conditional
expression. The static compiler can only select one of two alternative
bytecode sequences for "myArg". The solutions are to either move the
context allocation to before the #ifTrue: so it will always happen even
when not needed or to do a Craig Chambers style "code splitting" and
generate two separate versions for the rest of the method after the
#ifTrue:. The first option will perform worse than the dynamic system
while the second option, when applied to enough methods, will make the
memory footprint of having two (or four, or eight!) interpreters tiny in
comparison. 

> >> Cloned Activation

I forgot to mention a future "Smalltalk in hardware" project I have (or
will have, actually) that is an extreme example of this:

http://www.merlintec.com:8080/hardware/19

Here code is represented by trees of message templates rather than
bytecodes. When you are going to execute an expression, you first clone
the whole tree. Each individual node waits until all its elements are
constants (rather than subtrees) and then it turns itself into a message
and flows around the machine. When it meets the receiver object and
finds it is associated with some code, then that new tree is cloned with
the root pointing to the message (now context). The same object has
three different roles through its lifetime, so this is a very eager
allocation of contexts.

> Yes.  I've been talking with Dave about Self recently , and if may be that this was tickling my brain cells at the time.

I envy you both and hope great stuff comes from these discussions!

-- Jecel



More information about the Squeak-dev mailing list