skip to main content
10.1145/155090.155113acmconferencesArticle/Chapter ViewAbstractPublication PagespldiConference Proceedingsconference-collections
Article
Free Access

The essence of compiling with continuations

Published:01 June 1993Publication History

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. 1.AHO, A., SETHI, R., AND ULLMAN, J. Compilers--Pmnciples, Techniques, and Tools. Addison-Wesley, Reading, Mass., 1985. Google ScholarGoogle ScholarDigital LibraryDigital Library
  2. 2.APPEL, A. Compiling with Continuations. Cambridge University Press, 1992. Google ScholarGoogle ScholarDigital LibraryDigital Library
  3. 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 ScholarGoogle Scholar
  4. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  5. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  6. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  7. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  8. 8.DANVY, O. Three steps for the CPS transformation. Tech. l~ep. CIS-92-2, Kansas State University, 1992.Google ScholarGoogle Scholar
  9. 9.DANVY, O., AND FILiNSKI, A. Representing control: A study of the CPS transformation. Mathematical Structures in Computer Science, 4 (1992), 361-391.Google ScholarGoogle ScholarCross RefCross Ref
  10. 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 ScholarGoogle Scholar
  11. 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 ScholarGoogle Scholar
  12. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  13. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  14. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  15. 15.LEROY, X. The Zinc experiment: An economical implementation of the ML language. Tech. Rep. 117, INRIA, 1990.Google ScholarGoogle Scholar
  16. 16.PLOTKIN, G. Call-by-name, call-by-value, and the A-calculus. Theoretical Computer Science i (1975), 125-159.Google ScholarGoogle Scholar
  17. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  18. 18.SHIVEr. S, O. Control-Flow Analysis of Higher- Order Languages or Tamzng Lambda. PhD thesis, Carnegie-Mellon University, 1991. Google ScholarGoogle ScholarDigital LibraryDigital Library
  19. 19.STEELE, G. L. RABBIT: A compiler for Scheme. MIT AI Memo 474, Massachusetts Institute of Technology, Cambridge, Mass., May 1978. Google ScholarGoogle ScholarDigital LibraryDigital Library
  20. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  21. 21.WE~SE, D. Advanced compiling techniques. Course Notes at Stanford University, 1990.Google ScholarGoogle Scholar

Index Terms

  1. The essence of compiling with continuations

        Recommendations

        Comments

        Login options

        Check if you have access through your login credentials or your institution to get full access on this article.

        Sign in
        • Published in

          cover image ACM Conferences
          PLDI '93: Proceedings of the ACM SIGPLAN 1993 conference on Programming language design and implementation
          August 1993
          313 pages
          ISBN:0897915984
          DOI:10.1145/155090

          Copyright © 1993 ACM

          Permission to make digital or hard copies of all or part of this work for personal or classroom use is granted without fee provided that copies are not made or distributed for profit or commercial advantage and that copies bear this notice and the full citation on the first page. Copyrights for components of this work owned by others than ACM must be honored. Abstracting with credit is permitted. To copy otherwise, or republish, to post on servers or to redistribute to lists, requires prior specific permission and/or a fee. Request permissions from [email protected]

          Publisher

          Association for Computing Machinery

          New York, NY, United States

          Publication History

          • Published: 1 June 1993

          Permissions

          Request permissions about this article.

          Request Permissions

          Check for updates

          Qualifiers

          • Article

          Acceptance Rates

          Overall Acceptance Rate406of2,067submissions,20%

          Upcoming Conference

          PLDI '24

        PDF Format

        View or Download as a PDF file.

        PDF

        eReader

        View online with eReader.

        eReader