[go: up one dir, main page]
More Web Proxy on the site http://driver.im/ skip to main content
article
Free access

The essence of compiling with continuations

Published: 01 June 1993 Publication 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]
AHO, A., SETHI, R., AND ULLMAN, J. Compilers--Pmnciples, Techniques, and Tools. Addison-Wesley, Reading, Mass., 1985.
[2]
APPEL, A. Compiling with Continuations. Cambridge University Press, 1992.
[3]
BARENDREGT, H. The Lambda Calculus: Its $yntaz and Semantics, revised ed. Studies in Logic and the Foundations of Mathematics 103. North- Holland, 1984.
[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.
[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.
[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.
[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.
[8]
DANVY, O. Three steps for the CPS transformation. Tech. l~ep. CIS-92-2, Kansas State University, 1992.
[9]
DANVY, O., AND FILiNSKI, A. Representing control: A study of the CPS transformation. Mathematical Structures in Computer Science, 4 (1992), 361-391.
[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.
[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.
[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.
[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.
[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.
[15]
LEROY, X. The Zinc experiment: An economical implementation of the ML language. Tech. Rep. 117, INRIA, 1990.
[16]
PLOTKIN, G. Call-by-name, call-by-value, and the A-calculus. Theoretical Computer Science i (1975), 125-159.
[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.
[18]
SHIVEr. S, O. Control-Flow Analysis of Higher- Order Languages or Tamzng Lambda. PhD thesis, Carnegie-Mellon University, 1991.
[19]
STEELE, G. L. RABBIT: A compiler for Scheme. MIT AI Memo 474, Massachusetts Institute of Technology, Cambridge, Mass., May 1978.
[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.
[21]
WE~SE, D. Advanced compiling techniques. Course Notes at Stanford University, 1990.

Cited By

View all
  • (2024)GPU Coroutines for Flexible Splitting and Scheduling of Rendering TasksACM Transactions on Graphics10.1145/368776643:6(1-24)Online publication date: 19-Dec-2024
  • (2024)Taypsi: Static Enforcement of Privacy Policies for Policy-Agnostic Oblivious ComputationProceedings of the ACM on Programming Languages10.1145/36498618:OOPSLA1(1407-1436)Online publication date: 29-Apr-2024
  • (2023)Focusing on Refinement TypingACM Transactions on Programming Languages and Systems10.1145/3610408Online publication date: 17-Oct-2023
  • Show More Cited By

Recommendations

Comments

Please enable JavaScript to view thecomments powered by Disqus.

Information & Contributors

Information

Published In

cover image ACM SIGPLAN Notices
ACM SIGPLAN Notices  Volume 28, Issue 6
June 1993
313 pages
ISSN:0362-1340
EISSN:1558-1160
DOI:10.1145/173262
Issue’s Table of Contents
  • 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
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: 01 June 1993
Published in SIGPLAN Volume 28, Issue 6

Check for updates

Qualifiers

  • Article

Contributors

Other Metrics

Bibliometrics & Citations

Bibliometrics

Article Metrics

  • Downloads (Last 12 months)15,409
  • Downloads (Last 6 weeks)858
Reflects downloads up to 15 Jan 2025

Other Metrics

Citations

Cited By

View all
  • (2024)GPU Coroutines for Flexible Splitting and Scheduling of Rendering TasksACM Transactions on Graphics10.1145/368776643:6(1-24)Online publication date: 19-Dec-2024
  • (2024)Taypsi: Static Enforcement of Privacy Policies for Policy-Agnostic Oblivious ComputationProceedings of the ACM on Programming Languages10.1145/36498618:OOPSLA1(1407-1436)Online publication date: 29-Apr-2024
  • (2023)Focusing on Refinement TypingACM Transactions on Programming Languages and Systems10.1145/3610408Online publication date: 17-Oct-2023
  • (2023)Taype: A Policy-Agnostic Language for Oblivious ComputationProceedings of the ACM on Programming Languages10.1145/35912617:PLDI(1001-1025)Online publication date: 6-Jun-2023
  • (2023)m-CFA Exhibits Perfect Stack PrecisionProgramming Languages and Systems10.1007/978-981-99-8311-7_14(290-309)Online publication date: 26-Nov-2023
  • (2023)Automatic Alignment in Higher-Order Probabilistic Programming LanguagesProgramming Languages and Systems10.1007/978-3-031-30044-8_20(535-563)Online publication date: 22-Apr-2023
  • (2023)RICE: An Optimizing Curry CompilerPractical Aspects of Declarative Languages10.1007/978-3-031-24841-2_1(3-19)Online publication date: 8-Jan-2023
  • (2022)Generating circuits with generatorsProceedings of the ACM on Programming Languages10.1145/35498216:ICFP(52-79)Online publication date: 31-Aug-2022
  • (2022)A formal foundation for symbolic evaluation with mergingProceedings of the ACM on Programming Languages10.1145/34987096:POPL(1-28)Online publication date: 12-Jan-2022
  • (2022)Compiling Universal Probabilistic Programming Languages with Efficient Parallel Sequential Monte Carlo InferenceProgramming Languages and Systems10.1007/978-3-030-99336-8_2(29-56)Online publication date: 29-Mar-2022
  • Show More Cited By

View Options

View options

PDF

View or Download as a PDF file.

PDF

eReader

View online with eReader.

eReader

Login options

Media

Figures

Other

Tables

Share

Share

Share this Publication link

Share on social media