[armedbear-devel] patch: do not call compile for every call of eql-specialized generic functions
Anton Vodonosov
avodonosov at gmail.com
Mon Jul 13 21:54:46 UTC 2009
2009/7/13 Mark Evenson <evenson at panix.com>:
> I'm not totally convinced as to what would happen to the eql-specialization
> cache in the face of subsequent redefinitions, but can't really come up with
> a good counter-example.
More precisely it's not only eql-specialized method cache, but cache
for all the (effective) methods.
When generic function is called, correct code must be executed,
according to the passed arguments, taking into account all the methods
defined, class precedence lists for argument classes, method
combination of the generic function.
Calculation of the correct code is expensive, therefore a cache is
used. When we call (FN X Y) first time, effective method is calculated
based on X and Y, and stored in cache of the generic function FN.
This mechanism was already in place, but it wasn't used for
eql-specialized methods. Instead full clos dispatch was performed
every time for every generic function having at least one
eql-specialized method. Full CLOS dispatch in ABCL includes generation
some lisp code at runtime, and compiling it.
My fix just extends the chaching mechanism to handle eql-specialized
methods too.
Redefinitions are handled as before: function
FINALIZE-GENERIC-FUNCTION just clears the cache. This function is
called every time when new method is added to a generic function (but
it seems not to be called when class hierarchy changes, probably
that's what was referred by the old ABCL home: "ABCL's CLOS is slow
and does not handle on-the-fly redefinition of classes correctly").
Christophe Rhodes in sbcl-help once pointed me to "Efficient Method
Dispatch in PCL" by Kiczales and Rodriguez. Maybe you'll find it
useful (I personally still haven't worked through this 15 pages doc;
but the quick glance i made at that time gave me understanding that
CLOS dispatch is optimized by caching and therefore helped to
understand the ABCL code now).
Best regards,
- Anton
More information about the armedbear-devel
mailing list