IT lexicon › Programming › Inline caching

Inline caching

Programming På svenska → Updated: 2026-11-05

A JIT technique in which each call site remembers the type it saw last and where the call went, turning the next lookup into one comparison and a jump.

In a dynamic language, obj.foo() in principle means searching the object's class for foo every single time. Peter Deutsch and Allan Schiffman noticed in 1984, while building their Smalltalk-80 implementation, that a given call site almost always sees the same class. So they patched the answer straight into the machine code: check the class, jump to the remembered method, and fall back to the full lookup only when the check fails.

Urs Hölzle, Craig Chambers and David Ungar extended this in 1991 for Self with polymorphic inline caches that hold a handful of types. Sites that see too many are called megamorphic and give up. More important than the raw speed was the side effect: the cache is a free type profile, and that is what lets V8 and HotSpot inline and devirtualize speculatively — with deoptimization as the safety net.

← Back to the lexicon