Abstract
Partial evaluation allows for specialization of program fragments. This can be realized by staging, where one fragment is executed earlier than its surrounding code. However, taking advantage of these capabilities is often a cumbersome endeavor. In this paper, we present a new metaprogramming concept using staging parameters that are first-class citizen entities and define the order of execution of the program. Staging parameters can be used to define MetaML-like quotations, but can also allow stages to be created and resolved dynamically. The programmer can write generic, polyvariant code which can be reused in the context of different stages. We demonstrate how our approach can be used to define and apply domain-specific optimizations. Our implementation of the proposed metaprogramming concept generates code which is on a par with templated C++ code in terms of execution time.
- A. W. Appel. Compiling with Continuations. Cambridge University Press, 1992. ISBN 0-521-41695-7. Google Scholar
Digital Library
- C. Calcagno, W. Taha, L. Huang, and X. Leroy. Implementing Multistage Languages using ASTs, Gensym, and Reflection. In Proceedings of the 2nd International Conference on Generative Programming and Component Engineering (GPCE), pages 57–76. Springer, Sept. 2003. Google Scholar
Digital Library
- J. W. Cooley and J. W. Tukey. An Algorithm for the Machine Calculation of Complex Fourier Series. Mathematics of Computation, 19(90):297–301, 1965.Google Scholar
Cross Ref
- Z. DeVito, J. Hegarty, A. Aiken, P. Hanrahan, and J. Vitek. Terra: A Multi-Stage Language for High-Performance Computing. In Proceedings of the 34th annual ACM SIGPLAN Conference on Programming Language Design and Implementation (PLDI), pages 105–116. ACM, June 2013. Google Scholar
Digital Library
- D. R. Engler, W. C. Hsieh, and M. F. Kaashoek. ‘C: A Language for High-level, Efficient, and Machine-independent Dynamic Code Generation. In Proceedings of the 23rd ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages (POPL), pages 131–144. ACM, 1996. Google Scholar
Digital Library
- C. Lattner and V. Adve. LLVM: A Compilation Framework for Lifelong Program Analysis & Transformation. In Proceedings of the 2004 International Symposium on Code Generation and Optimization (CGO), pages 75––86. IEEE, Mar. 2004. Google Scholar
Digital Library
- J. Levine, T. Mason, and D. Brown. Lex & Yacc. O’’Reilly & Associates, 1992. Google Scholar
Digital Library
- E. Moggi, W. Taha, Z.-E.-A. Benaissa, and T. Sheard. An Idealized MetaML: Simpler, and More Expressive. Lecture Notes in Computer Science, pages 193–207. Springer, 1999. Google Scholar
Digital Library
- B. C. Pierce. Types and Programming Languages. MIT Press, 2002. ISBN 0-262-16209-1. Google Scholar
Digital Library
- T. Rompf and M. Odersky. Lightweight Modular Staging: A Pragmatic Approach to Runtime Code Generation and Compiled DSLs. In Proceedings of the 9th International Conference on Generative Programming and Component Engineering (GPCE), pages 127–136. ACM, Oct. 2010. Google Scholar
Digital Library
- T. Sheard and S. P. Jones. Template Meta-programming for Haskell. In Proceedings of the 2002 ACM SIGPLAN Workshop on Haskell, pages 1–16. ACM, 2002. Google Scholar
Digital Library
- G. Sussman and G. Steele. Scheme: An Interpreter for Extended Lambda Calculus. Massachusetts Institute of Technology, Artificial Intelligence Laboratory, 1975.Google Scholar
- W. Taha and T. Sheard. Multi-Stage Programming with Explicit Annotations. ACM SIGPLAN Notices, 32(12):203–217, 1997. Google Scholar
Digital Library
- W. Taha and T. Sheard. MetaML and Multi-Stage Programming with Explicit Annotations. In Theoretical Computer Science, pages 203–217. ACM Press, 1999. Google Scholar
Digital Library
- A. M. Turing. On Computable Numbers, With an Application to the Entscheidungsproblem. Proceedings of the London Mathematical Society, 42(2):230–265, 1936.Google Scholar
Index Terms
Specialization through dynamic staging
Recommendations
Specialization through dynamic staging
GPCE 2014: Proceedings of the 2014 International Conference on Generative Programming: Concepts and ExperiencesPartial evaluation allows for specialization of program fragments. This can be realized by staging, where one fragment is executed earlier than its surrounding code. However, taking advantage of these capabilities is often a cumbersome endeavor. In ...
Static and Dynamic Program Compilation by Interpreter Specialization
Interpretation and run-time compilation techniques are increasingly important because they can support heterogeneous architectures, evolving programming languages, and dynamically-loaded code. Interpretation is simple to implement, but yields poor ...
A portable approach to dynamic optimization in run-time specialization
AbstractThis paper proposes arun-time bytecode specialization (BCS) technique that analyzes programs and generates specialized programs at run-time in an intermediate language. By using an intermediate language for code generation, a back-end system can...






Comments