Interprocedural Specialization of Higher-Order Dynamic Languages Without Static Analysis
Function duplication is widely used by JIT compilers to efficiently implement dynamic languages. When the source language supports higher order functions, the called function’s identity is not generally known when compiling a call site, thus limiting the use of function duplication. This paper presents a JIT compilation technique enabling function duplication in the presence of higher order functions. Unlike existing techniques, our approach uses dynamic dispatch at call sites instead of trying to discover function identity. We have implemented the technique in a Scheme JIT compiler. Experiments show that it allows removing all the run time type checks for several benchmarks, and 47% on average, allowing the compiler to generate code up to 30% faster and 12.3% on average. We show that the technique can be use to duplicate functions using other run time information opening up new applications such as register allocation based duplication and aggressive inlining.