Elamur Research

Optimizing Dynamically-Typed Object-Oriented Languages With Polymorphic Inline Caches

Paper · 1991 · Urs Hölzle, Craig Chambers and David Ungar

Summary

Dynamically-typed object-oriented languages such as SELF and Smalltalk spend much of their time on dynamically-bound message sends, and their compilers usually lack the receiver-type information needed to optimize those sends away. Conventional inline caching stores one lookup result at each call site. This works well when a site always sees the same receiver type, but it fails at polymorphic sites, where repeated misses can make execution slower than no cache at all.

The authors propose polymorphic inline caches (PICs). On a cache miss, the runtime builds a small stub that grows over time. The stub compares the receiver against every type seen so far at that site and jumps directly to the matching method body. Sites that exceed a size limit are treated as megamorphic. On medium-sized object-oriented SELF benchmarks, PICs give a median 11% speedup.

PICs also record the receiver types actually seen at each site. An experimental compiler uses this record when recompiling methods to inline more sends, reaching a median 27% speedup. This motivates adaptive compilation: compile quickly first, then reoptimize hot code using the collected type feedback.

Key points

  • In the SELF system, roughly 25% of the Richards benchmark's execution time went to dealing with misses in the inline cache. With PICs, Richards runs 52% faster.
  • Call-site polymorphism follows a trimodal pattern: monomorphic, polymorphic (usually fewer than ten types) or megamorphic. PICs stop growing past a fixed number of cases.
  • Recompiling with PIC-collected type information gives a median 27% speedup and cuts the number of non-inlined message sends roughly in half.
  • PICs add little code: 0.8% to 6.9% of compiled code size for Richards, Parser, PrimMaker and PathCache.
  • The benchmarks were Richards, Parser, PrimMaker, UI, PathCache and PolyTest. On the synthetic PolyTest benchmark, execution time fell from 20.48 s to 3.76 s with PICs.

Our summary of the paper, in our own words — not its text. The work belongs to its authors; read it at the links above.

 Fields, topics and concepts

 Shelf 1The field of science this work belongs to (OpenAlex fields).Computer Science · 19,503 works

Cite

Cite as Urs Hölzle, Craig Chambers and David Ungar. 1991. Optimizing Dynamically-Typed Object-Oriented Languages With Polymorphic Inline Caches. ECOOP 1991.

The paper itself, not this page. BibTeX from the library's record of the work.

@inproceedings{holzle1991optimizing,
  title = {{Optimizing Dynamically-Typed Object-Oriented Languages With Polymorphic Inline Caches}},
  author = {Urs Hölzle, Craig Chambers and David Ungar},
  booktitle = {ECOOP 1991},
  year = {1991},
  url = {https://bibliography.selflanguage.org/_static/pics.pdf}
}

References

3 references, 0 of them with a card of ours. Each entry links to our card when we hold the work, else to OpenAlex and Google Scholar searches for it.

  1. A. H. Borning and D. H. H. Ingalls, “A Type Declaration and Inference System for Smalltalk.” In Conference Record of the Ninth Annual Symposium on Foundations of Computer Science, pp. 133-139, 1982. Craig Chambers, The Design and Implementation of the S ELF Compiler, an Optimizing Compiler for Objec… OpenAlex ↗ · Scholar ↗
  2. MIPS Computer Systems, MIPS Language Programmer’s Guide. MIPS Computer Systems, Sunnyvale, CA, 1986. J. G. Mitchell, Design and Construction of Flexible and Efficient Interactive Programming Systems. Ph.D. Thesis, Carnegie-Mellon University, 1970. William Pugh and Grant Weddell, “Two-Directional Rec… OpenAlex ↗ · Scholar ↗
  3. . David Ungar and David Patterson, “What Price Smalltalk?” In IEEE Computer 20(1), January, 1987. Paul R. Wilson and Thomas G. Mohler, “Design of the Opportunistic Garbage Collector.” In OOPSLA ’89 Conference Proceedings, pp. 23-35, New Orleans, LA, October, 1989. Published as SIGPLAN Notices 24(10)… OpenAlex ↗ · Scholar ↗

This page in Markdown https://md.research.elamur.ai/free/en/papers/holzle-1991-optimizing-dynamically-typed-object-oriented/