<div dir="ltr"><div dir="ltr">On Thu, Mar 18, 2021 at 1:11 PM Eliot Miranda <<a href="mailto:eliot.miranda@gmail.com">eliot.miranda@gmail.com</a>> wrote:<br></div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"> <div dir="ltr"><div dir="ltr"><div dir="ltr"><div style="font-size:small">Hi Ken,</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, Mar 17, 2021 at 8:13 AM <<a href="mailto:ken.dickey@whidbey.com" target="_blank">ken.dickey@whidbey.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"> <br>
You can help me out.<br>
<br>
I keep getting this wacky idea which does not seem to go away.  You can <br>
tell me what is wrong with it.<br>
<br>
OK.  Here it is:<br>
<br>
To get rid of PICs and dynamic method lookups, each Class knows <br>
selectors of methods it defines.  Each successful method definition is <br>
added not only to the method dictionary of the class, but copied down <br>
transitively to all subclasses, and their sub-subclasses, who have not <br>
defined a method with the same selector.<br>
<br>
At #DeepRehash time, _each_ method dictionary knows all of its selectors <br>
and creates a "perfect hash" function, or something close to it.<br>
<br>
So lookup is just into the specific method dictionary of the instance's <br>
class which yields the proper method (backstop method is DNU).  Never a <br>
miss.  No class hierarchy search for inherited methods.<br>
<br>
Memory is cheap these days, but selectors and compiled methods are <br>
mostly shared and the memory cost of method dictionaries is probably <br>
balanced out by elimination of PICS at the call sites.<br>
<br>
The UI tools need to keep some simple rules (e,g, transitively deleting <br>
methods from subclass method dictionaries), but these should be simple <br>
and obvious.<br>
<br>
The above seems simple enough, but nobody seems to be doing it.<br></blockquote><div><br></div><div style="font-size:small">I don't think no one is doing this.  I expect for example that the SqueakJS effort would explore this.</div></div></div></div></blockquote><div><br></div><div>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, <i>and</i> it would have to be hidden from the image. I think inline caches are the safer bet, polymorphic or not.</div><div><br></div><div>Plus, if you squint at them in the right way, PICs <i>are</i> 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.</div><div><br></div><div>- Vanessa -</div></div></div>