Automatic staged compilation

Abstract:

The ability to optimize programs while they execute has become increasingly important in recent years. The primary challenge in such optimization is to keep the run-time overhead of optimization down while maximizing its effectiveness. The widely used solution of Just-In-Time (JIT) compilation keeps run-time overhead low, at considerable engineering cost, by sacrificing performance.The past few years have seen the emergence of staged optimization , which produces run-time optimizations that often have much lower run-time overhead than traditional optimizers, yet do not sacrifice any of their functionality. The key to the technique is a method, called staging, to transfer optimization overhead to static compile time from run time. Unfortunately, developing staged variants of individual optimizations has been highly specialized, labor-intensive work; staging pipelines of optimizations even more so.This dissertation presents a system called the Staged Compilation Framework (SCF), which automatically stages entire pipelines of compiler optimizations at arguably little additional engineering cost beyond building the slower traditional version of the pipeline. SCF harnesses two powerful but traditionally difficult-to-use techniques, partial evaluation and dead-store elimination, to achieve staging. An implementation of SCF shows that staged compilation can speed up pipelines of classical compiler optimizations by up to an order of magnitude, and more commonly by a factor of 4.5 to 5.