Demystifying "most Smalltalk's don't directly support multiple inheritance"

Klaus D. Witzel klaus.witzel at cobss.com
Sun Jun 25 19:45:03 UTC 2006


Hi Alex,

on Sun, 25 Jun 2006 17:14:45 +0200, you wrote:
> Hi Klaus!
>
> I tried and I guess I understand how you did it.
> Tricky, you use the literal for the super class reference to tell the VM  
> to start the lookup in another class.
>
> I think you might have problems with recursive calls (i.e., 'super foo'  
> that is called twice by two different objects) and concurrency.

You're right and as many times before I appreciate your expertise! There  
is indeed a gap between the time of setting the super class reference  
(bytecode i-1) and when the VM starts using it (bytecode i+0). But from  
there on, method lookup and method activation is atomic.

It would be much better to keep the super class reference static  
(compile-time). Which is not hard to achieve, since every method has its  
own superclass field (either settable explicitly or traitified images have  
it anyways). Then a self send is looked up in one superclass hierarchy and  
a super send is looked up in another superclass hierarchy. Since an n-ary  
branch is reducible to a couple of 2-ary branches, we so have MI (as  
specified by the Blue Book :) and can forget expensive doesNotUnderstand:  
handling. We can discuss this further and deeper in offline mode if you  
like.

>> The third example employs the existing method cache of the VM (the  
>> original Squeak VM) for multiple inheritance message sends and thus  
>> minimizes the overhead to less than 5% (and the demo is written in .st  
>> code :-)
>
> Your implementation relies on a doesNotUnderstand:. I am interested in  
> knowing how can you have just a 5% overhead.

This demo runs in the documented setting and doesNotUnderstand: handling  
is accounted for by standard message tally with 5% (the reason is the VM  
method lookup cache which has one miss and from then on only hits. Let me  
know if something here remains unclear). Of course, more switches between  
more parents would incur more overhead.

> Cheers,
> Alexandre
>

/Klaus

Oops, I just did alt-s in Opera under WinXP and it DID NOT WORK :(




More information about the Squeak-dev mailing list