In Smalltalk, looking up a method at run time can involve a large number of steps, since the method dictionary of a subclass does not contain methods in its superclass, and a pointer-chase is required to find the method. A optimization would be for each subclass to store all superclass methods in its method dictionary.
Question: How could this be done?
An obvious drawback is the space cost, but I'm just wondering how this can be done in Smalltalk? This is different from making a separate cache for recently invoked methods.
There are so many ways to cache the results of a lookup. Just read some basic VMimplementation papers - start with the Green Book. You can even find t for free online - http://stephane.ducasse.free.fr/FreeBooks.html and look near the bottom for 'Bits of History, Words of Advice'. Plain interpreters can use a simple hash keyed cache. Translating VMs can get into inline caches, polymorphic inline caches, adaptive caching... no need whatsoever to d something as painful as C++ vtables which is pretty much what you were suggesting. We've had this covered for decades. It's solved.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With