Nicholas Clark wrote:
On Fri, Oct 29, 2004 at 05:19:35PM +0200, Leopold Toetsch wrote:


The method_lookup doesn't have a vtable indirection. And having a direct
array lookup doesn't really scale. So the actual code is a bit more
complicated (and in no way optimized).


Something that just struck me reading this whole thread - can we take
advantage of the lazy approach the prederef cores use? Prime all the slots
in the vtable array with pointers to the same function that actually does
the real work of the method lookup. So we take the lookup hit only when
we call the method.

First, while Paolo named the thing vtable, that term collides with pmc->table. So let's call the thing method_table. Second, I've to revise my above sentence, method lookup *is* a vtable call. We have:


  method_pmc = object->vtable->find_method(... "the_method_str")

The find_method calls the method lookup, which is a hash lookup in the objects class, and likely some more hash lookups in the classes parents.

So back to your idea. We'd need a list of the top N methods of all objects and generate a sparse array of index <-> method_str mappings per object primed with the actual lookup function. For all top N methods, we'd replace the keyed find_method with an indexed find_method.

Then after a successful lookup, we could replace the lookup-function with a function that returns the real method. Sounds doable, yes.

leo



Reply via email to