|Version 1 (modified by chromatic, 3 years ago)|
Look in the Object PMC's generated C code. See all of the calls to Parrot_oo_find_vtable_override()? Isn't that ridiculous?
Some ~6% of all of the time spent running Rakudo, if not more, goes to checking if an object's class has a VTABLE override written in PIR. Most don't. Very few do. Yet these get checked on *every* invocation of each of those VTABLE entries.
We can fix this:
- create a dummy VTABLE, where each entry automatically, irrevocably delegates to an overridden PIR VTABLE
- add code to the NameSpace PMC (or wherever's most appropriate) to duplicate the current class VTABLE and swap in the appropriate override pointer when something adds a VTABLE override
- only duplicate that VTABLE once
- make sure to free that duplicate VTABLE when appropriate, lest we leak memory at the end of the program
We may run a small risk of not being able to add overrides when we've already instantiated objects of the given class, but I think that's a low risk (and we can test for that anyway). We already forbid modifications to the class if we've instantiated objects.
This is a fairly simple task which will have positive performance implications for not too much work. Takers welcome.