We present the design of a dynamic compilation system for C. Directed
by a few declarative user annotations specifying where and on what dyn
amic compilation is to take place, a binding time analysis computes th
e set of run-time constants at each program point in each annotated pr
ocedure's control flow graph; the analysis supports program-point-spec
ific polyvariant division and specialization. The analysis results gui
de the construction of a specialized run-time specializer for each dyn
amically compiled region; the specializer supports various caching str
ategies for managing dynamically generated code and supports mixes of
speculative and demand-driven specialization of dynamic branch success
ors. Most of the key cost/benefit trade-offs in the binding time analy
sis and the run-time specializer are open to user control through decl
arative policy annotations. Our design is being implemented in the con
text of an existing optimizing compiler.