How do polymorphic inline caches work with mutable types?
Posted
by kingkilr
on Stack Overflow
See other posts from Stack Overflow
or by kingkilr
Published on 2009-06-27T15:57:23Z
Indexed on
2010/04/05
18:33 UTC
Read the original article
Hit count: 251
A polymorphic inline cache works by caching the actual method by the type of the object, in order to avoid the expensive lookup procedures (usually a hashtable lookup). How does one handle the type comparison if the type objects are mutable (i.e. the method might be monkey patched into something different at run time). The one idea I've come up with would be a "class counter" that gets incremented each time a method is adjusted, however this seems like it would be exceptionally expensive in a heavily monkey patched environ since it would kill all the PICs for that class, even if the methods for them weren't altered. I'm sure there must be a good solution to this, as this issue is directly applicable to Javascript and AFAIK all 3 of the big JS VMs have PICs (wow acronym ahoy).
© Stack Overflow or respective owner