encyclopegia.org

Inline caching

Inline caching is an optimization technique employed by some language runtimes, and first developed for Smalltalk. The goal of inline caching is to speed up runtime method binding by remembering the results of a previous method lookup directly at the call site. Inline caching is especially useful for dynamically typed languages where most if not all method binding happens at runtime and where virtual method tables often cannot be used.

Inline caching is an optimization technique employed by some language runtimes, and first developed for Smalltalk. The goal of inline caching is to speed up runtime method binding by remembering the results of a previous method lookup directly at the call site. Inline caching is especially useful for dynamically typed languages where most if not all method binding happens at runtime and where virtual method tables often cannot be used. function dump(obj) { document.write(obj.toString()); } Since the type of the object is not specified and because of potential method overloading, it is impossible to decide ahead of time which concrete implementation of the toString-method is going to be invoked. Instead, a dynamic lookup has to be performed at runtime. In language runtimes that do not employ some form of caching, this lookup is performed every time a method is invoked. Because methods may be defined several steps down the inheritance chain, a dynamic lookup can be an expensive operation. To achieve better performance, many language runtimes employ some form of non-inline caching where the results of a limited number of method lookups are stored in an associative data structure. This can greatly increase performance, provided that the programs executed are "cache friendly" (i.e., there is a limited set of methods that are invoked frequently). This data structure is typically called the first-level method lookup cache. var values = [1, "a", 2, "b", 3, "c", 4, "d"]; for (var i in values) { document.write(values[i].toString()); } Again, the method toString is invoked on an object whose type is not known in advance. More importantly though, the type of the object changes with every iteration of the surrounding loop. A naive implementation of monomorphic inline caching would therefore constantly cycle through the "uninitialized" and "monomorphic" states. In order to prevent this from happening, most implementations of monomorphic inline caching support a third state often referred to as the "megamorphic" state. This state is entered when a particular call site has seen a predetermined number of different types. Once a call site has entered the "megamorphic" state, it will behave just as it did in the "uninitialized" state with the exception that it will not enter the "monomorphic" state ever again (some implementations of monomorphic inline caching will change "megamorphic" call sites back to being "uninitialized" after a certain amount of time has passed or once a full garbage collection cycle is performed). ==See also== Memoization

References

No reference rows published for this article.

Cite this article

MLA

"Inline caching." encyclopegia.org, 2025, https://encyclopegia.org/wiki/inline-caching. Accessed 24 November 2026.

Chicago

"Inline caching." encyclopegia.org. Accessed November 24, 2026. https://encyclopegia.org/wiki/inline-caching.

APA

encyclopegia.org. (2025). Inline caching. Retrieved November 24, 2026, from https://encyclopegia.org/wiki/inline-caching

Accessed November 24, 2026 · CC BY-SA 4.0 · citation page · JSON

Related articles

Iqaluit-Tasiluk

stub · references available

in-band signaling

stub · references available

list of doping cases in sport (Y)

stub · references available

music of Minnesota

stub · references available

Bihar State Road Transport Corporation

stub · references available

Japanese adult adoption

stub · references available

Zoombinis

stub · references available

J. Hallett and Son

stub · references available

Jalanan

stub · references available

Dowry system in India

stub · references available
CC BY-SA 4.0 · tier1-factual · https://en.wikipedia.org/w/index.php?oldid=1313975464 · 0.55 · snapshot inline-caching-1854342-3bfba93d40759665 · QID Q17082756

Cite · JSON · Search

Related services and records

Services

  • Estate — measured countries, lanes and facts
  • Intel — live corroborated events
  • Legal — statutes, cases and citations
  • Encyclopedia — articles with inline sources
  • Space — launches, satellites and orbits
  • Search — federated search and reports
  • Pass — passport account and SSO
  • Corpora — read-only corpus origins
  • e01 — self-hosted corpora and tools

Text and metadata only; each target carries its own sources. Missing data is published as no-data, never estimated.