Abstract
In order to simplify the compilation process, many compilers for higher-order languages use the continuation-passing style (CPS) transformation in a first phase to generate an intermediate representation of the source program. The salient aspect of this intermediate form is that all procedures take an argument that represents the rest of the computation (the “continuation”). Since the nai¨ve CPS transformation considerably increases the size of programs, CPS compilers perform reductions to produce a more compact intermediate representation. Although often implemented as a part of the CPS transformation, this step is conceptually a second phase. Finally, code generators for typical CPS compilers treat continuations specially in order to optimize the interpretation of continuation parameters.
A thorough analysis of the abstract machine for CPS terms show that the actions of the code generator invert the nai¨ve CPS translation step. Put differently, the combined effect of the three phases is equivalent to a source-to-source transformation that simulates the compaction phase. Thus, fully developed CPS compilers do not need to employ the CPS transformation but can achieve the same results with a simple source-level transformation.
References
- 1 AHO, A., SETHI, R., AND ULLMAN, J. Compilers--Pmnciples, Techniques, and Tools. Addison-Wesley, Reading, Mass., 1985. Google Scholar
Digital Library
- 2 APPEL, A. Compiling with Continuations. Cambridge University Press, 1992. Google Scholar
Digital Library
- 3 BARENDREGT, H. The Lambda Calculus: Its $yntaz and Semantics, revised ed. Studies in Logic and the Foundations of Mathematics 103. North- Holland, 1984.Google Scholar
- 4 BOEHM, H.-J., AND DC~MERS, A. Implementing Russel. In Proceedzngs of the A CM SIG- PLAN 1986 Symposzum on Compiler Constructzon (1986), vol. 21(7), Sigplan Notices, pp. 186-195. Google Scholar
Digital Library
- 5 BONDOaF, A. Improving binding times without explicit CPS-conversion. in Proceedings of the 1992 A CM Conference on L~sp and Functional Programm2ng (1992), pp. 1-10. Google Scholar
Digital Library
- 6 CLINGEa, W. The Scheme 311 compiler: An exercise in denotational semantics. In Proceedings of the 198J A CM Conference on L~sp and Functional Programmzng (1984), pp. 356-364. Google Scholar
Digital Library
- 7 DANVY, O. Back to direct style. In Proceedings of the Jth European Symposium on Programming (Rennes, 1992), Lecture Notes in Computer Science, 582, Springer Verlag, pp. 130-150. Google Scholar
Digital Library
- 8 DANVY, O. Three steps for the CPS transformation. Tech. l~ep. CIS-92-2, Kansas State University, 1992.Google Scholar
- 9 DANVY, O., AND FILiNSKI, A. Representing control: A study of the CPS transformation. Mathematical Structures in Computer Science, 4 (1992), 361-391.Google Scholar
Cross Ref
- 10 FELLE~SEN, M., AND FRIEDMAN, D. Control operators, the SECD-machine, and the A-calculus. In Formal Description of Programming Concepts III (Amsterdam, 1986), M. Wirsing, Ed., Elsevier Science Publishers B.V. (North-Holland), pp. 193- 217.Google Scholar
- 11 FESSENDEN, C., CLINGER, W., FRIEDMAN, D. P., AND HAYNES, C. T. Scheme 311 version 4 reference manual. Computer Science Technical Report 137, indiana University, Bloomington, Indiana, Feb. 1983.Google Scholar
- 12 FISCHER, M. Lambda calculus schemata. In Proceedings of the A CM Conference on Proving Assertions About Programs (1972), vol. 7(1), Sigplan Notices, pp. 104-109. Google Scholar
Digital Library
- 13 KELSEY, R., AND HUDAK, P. Realistic compilation by program transformation. In Conference Record of the 16th Annual ACM Symposium on Principles of Programming Languages (Austin, TX, Jan. 1989), pp. 281-292. Google Scholar
Digital Library
- 14 KaANZ, D., KELSEY, R., REES, J., HUDAK, P., PmLnIr~, J., ^rqD ADAMS, N. Orbit: An optimizing compiler for Scheme. In Proceedings of the A CM $IGPLAN 1986 Symposium on Compiler Construction (1986), vol. 21(7), Sigplan Notices, pp. 219-233. Google Scholar
Digital Library
- 15 LEROY, X. The Zinc experiment: An economical implementation of the ML language. Tech. Rep. 117, INRIA, 1990.Google Scholar
- 16 PLOTKIN, G. Call-by-name, call-by-value, and the A-calculus. Theoretical Computer Science i (1975), 125-159.Google Scholar
- 17 SABRY, A., AND FELLEISEN, M. Reasoning about programs in continuation-passing style. In Proceed~ngs of the 1992 A CM Conference on Lisp and Functional Programming (1992), pp. 288-298. Technical Report 92-180, Rice University. Google Scholar
Digital Library
- 18 SHIVEr. S, O. Control-Flow Analysis of Higher- Order Languages or Tamzng Lambda. PhD thesis, Carnegie-Mellon University, 1991. Google Scholar
Digital Library
- 19 STEELE, G. L. RABBIT: A compiler for Scheme. MIT AI Memo 474, Massachusetts Institute of Technology, Cambridge, Mass., May 1978. Google Scholar
Digital Library
- 20 WAND, M. Correctness of procedure representations in higher-order assembly language. In Proceedings of the 1991 Conference on the Mathematical Foundations of Programing Semantics (1992), S. Brookes, Ed., vol. 598 of Lecture Notes ,n Computer Science, Springer Verlag, pp. 294-311. Google Scholar
Digital Library
- 21 WE~SE, D. Advanced compiling techniques. Course Notes at Stanford University, 1990.Google Scholar
Index Terms
The essence of compiling with continuations






Comments