New VM in progress

Rob Withers rwithers12 at mediaone.net
Mon Dec 17 13:33:44 UTC 2001


At 02:38 PM 12/13/2001, Tim Rowledge wrote:
>"Stephen Pair" <spair at advantive.com> is widely believed to have written:
>
> > > > * Instance based prototyping patches                Yes? No?
> > > Hmm. Not a fan of instance based, but Rob Withers and I got a
> > > simple demo hack for something like this working at oopsla
> > > this year. Well, delegation, anyway. Or something. Rob? Stop
> > > me before  gibber too much...
> >
> > What did you guys do on this?  I think instance based stuff is important
> > for non-developer types...most people don't look at the world in terms
> > of a class hierarchy.  Have you seen http://spair.swiki.net/delegation
> > ...it's got some useful stuff regarding mirrors and reflection (along
> > with primitives to support such).
>I have to admit I really can't remember what it was for anymore! We
>managed to do some dreadful hack that (ab)used the facility already in
>the VM to handle missing method dictionaries or something of that sort.
>Hmm, that doesn't actually sound much like instance based stuff, does
>it? Oh, maybe - it does make it possible to intercept the method lookup
>and do whatever you want in the image. Senility is a wonderful thing...

There is no question about it, what we were doing was a hack.  As you both 
said, it wasn't delegation or instance-based inheritence.   I want an 
object which intercepts *all* message sends to it and redirect them to a 
manager object.  This would be a very useful capability to have.  I also 
wanted to experience hacking the VM, and that I have certainly 
received!  Just knowing what (((self baseHeader: oop) >> 12) bitAnd: 16r1F) 
does is a bit scary to me.

At Oopsla, we used the nil dictionary mechanism to send a #cannotInterpret: 
message to a superclass implementation of the object.  This was quite 
horrendous, as it required a 2 layer hierarchy of classes (Object -> 
Redirector -> ConcreteRedirector).  Add a 
Redirector>>cannotInterpret:  method and nil out the MethodDictionary of 
the ConcreteRedirector.  This works for every method except for #class and 
#==.  However, a change the shape of either class would cause a shape 
recompile of the hierarchy and reinstall the MethodDictionary.

Anthony gave me an idea about using compact classes, which I have almost 
implemented.  I am still using the nil Dictionary detection, in 
lookupMethodInClass:, but I verify that my instance is a Redirector compact 
class, and directly send the lookup method to the Manager 
(#redirectMessage:forHandle:).   I have placed this class detection in 
bytecodePrimClass and bytecodePrimEquivalent, and send a normalSend if it 
matches.  It is much slower than a #doesNotUnderstand: proxy  (no proxy 
sending  3 microseconds, DNU 6 microseconds, redirect 32 microseconds), but 
it picks up all messages.

Let me point out that I am also setting a handle in each Proxy, and this 
gets resolved to an object in the Manager.   This requires either explicit 
deregister, of the Proxy from the manager, or finalization to do this.   It 
gives us some reference opacity which is another useful feature.

Rob





More information about the Squeak-dev mailing list