Run-time Code Generation and Modal-ML
CARNEGIE-MELLON UNIV PITTSBURGH PA SCHOOL OF COMPUTER SCIENCE
Pagination or Media Count:
This paper presents early experience with a typed programming language and compiler for runtime code generation. The language is an extension of the SML language with modal operators, based on the lambdasquare 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 runtime 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 runtime 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 runtime 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 lambdasquare programs into CCAM code. Finally, the results of some experiments are shown, to demonstrate the benefits of this style of runtime code generation for some applications.
- Computer Programming and Software