A Typed Intermediate Representation for Dynamic Languages
Open Access
- 5 June 2026
- journal article
- Published by Association for Computing Machinery (ACM) in ACM Transactions on Programming Languages and Systems
- Vol. 48 (2) , 1-33
Abstract
Dynamic programming languages pose significant challenges for optimizing compilers due to features such as dynamic typing, late binding, reflection, copy-on-write, and delayed evaluation. To generate efficient code, compilers must speculate on which dynamic features will be exercised and produce specialized code based on these assumptions. This article presents the design of a statically typed, high-level intermediate representation (IR) that makes dynamic behaviors explicit and amenable to static analysis. Our IR combines gradual typing with ownership tracking, and explicitly represents promises, multiple function versions, and contextual dispatch. Together, these features directly support optimizations such as specialization, inlining, scope elision, and copy elimination. We formalize a core calculus, called FIŘ, that captures the essential features required for these optimizations. We provide an operational semantics, a type system, and flow and reflection analyses, and we prove the soundness of the type system.Keywords
Funding Information
- Ministerstvo Školství, Mládeže a Tělovýchovy (LL2325)
- Grantová Agentura České Republiky (23-07580X)
This publication has 18 references indexed in Scilit:
- Correctness of speculative optimizations with dynamic deoptimizationProceedings of the ACM on Programming Languages, 2017
- Self-optimizing AST interpreters2012
- HappyJIT2011
- Integrating typed and untyped code in a scripting language2010
- Gradual Typing for Objects2007
- A Type System for the Java Bytecode Language and VerifierJournal of Automated Reasoning, 2003
- From system F to typed assembly languageACM Transactions on Programming Languages and Systems, 1999
- Flexible alias protection1998
- The revised report on the syntactic theories of sequential control and stateTheoretical Computer Science, 1992
- An efficient implementation of SELF, a dynamically-typed object-oriented language based on prototypesHigher-Order and Symbolic Computation, 1991