[Vm-dev] Copy Down to avoid Looking Up

Vanessa Freudenberg vanessa at codefrau.net
Thu Mar 18 21:01:38 UTC 2021


On Thu, Mar 18, 2021 at 1:11 PM Eliot Miranda <eliot.miranda at gmail.com>
wrote:

>
> Hi Ken,
>
> On Wed, Mar 17, 2021 at 8:13 AM <ken.dickey at whidbey.com> wrote:
>
>>
>> You can help me out.
>>
>> I keep getting this wacky idea which does not seem to go away.  You can
>> tell me what is wrong with it.
>>
>> OK.  Here it is:
>>
>> To get rid of PICs and dynamic method lookups, each Class knows
>> selectors of methods it defines.  Each successful method definition is
>> added not only to the method dictionary of the class, but copied down
>> transitively to all subclasses, and their sub-subclasses, who have not
>> defined a method with the same selector.
>>
>> At #DeepRehash time, _each_ method dictionary knows all of its selectors
>> and creates a "perfect hash" function, or something close to it.
>>
>> So lookup is just into the specific method dictionary of the instance's
>> class which yields the proper method (backstop method is DNU).  Never a
>> miss.  No class hierarchy search for inherited methods.
>>
>> Memory is cheap these days, but selectors and compiled methods are
>> mostly shared and the memory cost of method dictionaries is probably
>> balanced out by elimination of PICS at the call sites.
>>
>> The UI tools need to keep some simple rules (e,g, transitively deleting
>> methods from subclass method dictionaries), but these should be simple
>> and obvious.
>>
>> The above seems simple enough, but nobody seems to be doing it.
>>
>
> I don't think no one is doing this.  I expect for example that the
> SqueakJS effort would explore this.
>

Nah. SqueakJS is supposed to be compatible with existing images, I'm not
interested in changing the image to suit the VM. So this copy-down would
have to happen at image load time or dynamically, *and* it would have to be
hidden from the image. I think inline caches are the safer bet, polymorphic
or not.

Plus, if you squint at them in the right way, PICs *are* equivalent to
copy-down. They "copy" the right method into the cache. That's a
late-bound version of copy-down, whereas actual copy-down would be
early-bound and require all tools to change to maintain the invariants.
Sure it can be done, but it also makes certain use cases a lot more
expensive: adding a method to Object is not a big deal today, but with
copy-down, you would have to copy it to every single class in the whole
system, making it extremely expensive. This sounds more like a deployment
mechanism to me, not like something I would use for live coding.

- Vanessa -
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.squeakfoundation.org/pipermail/vm-dev/attachments/20210318/e00d9827/attachment-0001.html>


More information about the Vm-dev mailing list