CacheIR: The Benefits of a Structured Representation for Inline Caches

In less than a week (😱) myself and my colleague Iain Ireland will be in Portugal, presenting our paper on CacheIR at MPLR, co-located with SPLASH 2023. Here’s our preprint (edit: and official ACM DL link), and here’s the abstract:

Inline Caching is an important technique used to accelerate operations in dynamically typed language implementations by creating fast paths based on observed program behaviour. Most software stacks that support inline caching use low-level, often ad-hoc, Inline-Cache (ICs) data structures for code generation. This work presents CacheIR, a design for inline caching built entirely around an intermediate representation (IR) which: (i) simplifies the development of ICs by raising the abstraction level; and (ii) enables reusing compiled native code through IR matching techniques. Moreover, this work describes WarpBuilder, a novel design for a Just-In-Time (JIT) compiler front-end that directly generates type-specialized code by lowering the CacheIR contained in ICs; and Trial Inlining, an extension to the inline-caching system that allows for context-sensitive inlining of context-sensitive ICs. The combination of CacheIR and WarpBuilder have been powerful performance tools for the SpiderMonkey team, and have been key in providing improved performance with less security risk.

This paper is the paper on CacheIR that I have wanted to exist for years, at least since I wrote this blog post in 2018. Since then, we’ve taken inline caching and pushed it even further with the addition of WarpBuilder, and so we cover even more of the power that CacheIR unlocks. I think this is a really fascinating design point which provides large amounts of software engineering leverage when building your system, and so I’m very happy to see that we’ve managed to publish a paper on this. We didn’t even cover everything about CacheIR in this paper — for example, we didn’t talk about tooling such as the CacheIR Analyzer or CacheIR health tool.

It’s my hope that we’ll seed conversations with this paper and find more academic collaborations and inspire more designs with high leverage. I’d be glad to answer questions or hear comments!

Thanks to our co-authors! Jan (who deserves the credit of having come up with CacheIR), Nathan (who did a bunch of work on the paper) and Nelson, always a happy guide to academia.