[Vm-dev] Copy Down to avoid Looking Up
ken.dickey at whidbey.com
ken.dickey at whidbey.com
Wed Mar 17 15:13:13 UTC 2021
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.
Why not?
Thanks much for insights!
-KenD
More information about the Vm-dev
mailing list