Run-time Code Generation and Modal-ML
Philip Wickline, Peter Lee, Frank Pfenning
January 1998

Also appears as CMU-CS-FOX-98-01

This paper presents early experience with a typed programming language and compiler for run-time code generation. The language is an extension of the SML language with modal operators, based on the @g[] language of Davies and Pfenning. It allows programmers to specify precisely, through types, the stages of computation in a program. The compiler generates target code that makes use of run-time code generation in order to exploit the staging information. The target machine is currently a version of the Categorial Abstract Machine, called the CCAM, which we have extended with facilities for run-time code generation. Using this approach, the programmer is able to express the staging that he wants to the compiler directly. It also provides a typed framework in which to verify the correctness of his staging intentions, and to discuss his staging decisions with other programmers. Finally, it supports in a natural way multiple stages of run-time specialization, so that dynamically generated code can be used to generate yet further specialized code. This paper presents an overview of the language, with several examples of programs that illustrate key concepts and programming techniques. Then, it discusses the CCAM and the compilation of @g[] programs into CCAM code. Finally, the results of some experiments are shown, to demonstrate the benefits of this style of run-time code generation for some applications.

Modal logic, run-time code generation, generating extensions, partial evaluation

17 pages

CS Technical Reports Collection Home Page
SCS Technical Reports Collection Home Page