Inline Caching

Inline Caching is a mechanism for optimizing the dispatch of messages in JIT-compiled, dynamic ObjectOriented languages, such as SmalltalkLanguage (see JustInTimeCompilation).

The optimization results from the empirical observation that most code that sends a message to an object always sends messages to objects of the same class. Therefore the message send can be compiled to a direct call to the appropriate method of that class. That is, the class of the object that receives a message is cached inline in the code that sends the message.

However, this doesn't work for message sends that are meant to be polymorphic. To handle these cases, the compiler compiles the message send into code that checks that the receiving object is of the correct class. If it is, the method is called as per normal. If it is not, the message is dispatched polymorphically, using a slower method lookup mechanism.

Note: this works very well in most cases, but slows down code that is actually polymorphic. To alleviate this problem, JIT compiled languages now use PolymorphicInlineCaches.


CategoryOptimization, CategorySmalltalk


EditText of this page (last edited March 14, 2006) or FindPage with title or text search