Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
skip to main content
10.1145/1291151.1291179acmconferencesArticle/Chapter ViewAbstractPublication PagesicfpConference Proceedingsconference-collections
Article

Compiling with continuations, continued

Published: 01 October 2007 Publication History
  • Get Citation Alerts
  • Abstract

    We present a series of CPS-based intermediate languages suitable for functional language compilation, arguing that they have practical benefits over direct-style languages based on A-normal form (ANF) or monads. Inlining of functions demonstrates the benefits most clearly: in ANF-based languages, inlining involves a re-normalization step that rearranges let expressions and possibly introduces a new 'join point' function, and in monadic languages, commuting conversions must be applied; in contrast, inlining in our CPS language is a simple substitution of variables for variables.
    We present a contification transformation implemented by simple rewrites on the intermediate language. Exceptions are modelled using so-called 'double-barrelled' CPS. Subtyping on exception constructors then gives a very straightforward effect analysis for exceptions. We also show how a graph-based representation of CPS terms can be implemented extremely efficiently, with linear-time term simplification.

    References

    [1]
    Andrew W. Appel. Compiling with Continuations. Cambridge University Press, 1992.
    [2]
    Andrew W. Appel. SSA is functional programming. SIGPLAN Notices, 33 (4): 17--20, 1998.
    [3]
    Andrew W. Appel and Trevor Jim. Shrinking lambda expressions in linear time. Journal of Functional Programming, 7 (5): 515--540, 1997.
    [4]
    Franz Baader and Tobias Nipkow. Term Rewriting and All That. Cambridge University Press, 1998.
    [5]
    Nick Benton and Peter Buchlovsky. Semantics of an effect analysis for exceptions. In ACM SIGPLAN International Workshop on Types in Language Design and Implementation (TLDI), pages 15--26, 2007.
    [6]
    Nick Benton and Andrew Kennedy. Exceptional syntax. Journal of Functional Programming, 11 (4): 395--410, 2001.
    [7]
    Nick Benton, Andrew Kennedy, and George Russell. Compiling Standard ML to Java bytecodes. In 3rd ACM SIGPLAN International Conference on Functional Programming. ACM Press, September 1998.
    [8]
    Nick Benton, Andrew Kennedy, Sam Lindley, and Claudio Russo. Shrinking reductions in SML.NET. In 16th International Workshop on Implementation and Application of Functional Languages (IFL), 2004.
    [9]
    Nick Benton, Andrew Kennedy, and Claudio Russo. Adventures in interoperability: The SML.NET experience. In 6th International Conference on Principles and Practice of Declarative Programming (PPDP), 2004.
    [10]
    Thomas Cormen, Charles Leiserson, Ronald Rivest, and Clifford Stein. Introduction to Algorithms. MIT Press, second edition, 2001.
    [11]
    Olivier Danvy. A new one-pass transformation into monadic normal form. In 12th International Conference on Compiler Construction (CC'03), 2003.
    [12]
    Olivier Danvy and Andrzej Filinski. Representing control: A study of the CPS transformation. Mathematical Structures in Computer Science, 2 (4): 361--391, 1992.
    [13]
    Olivier Danvy and Lasse R. Nielsen. A first-order one-pass CPS transformation. Theor. Comput. Sci., 308 (1-3): 239--257, 2003.
    [14]
    Cormac Flanagan, Amr Sabry, Bruce F. Duba, and Matthias Felleisen. The essence of compiling with continuations (with retrospective). In McKinley (2004), pages 502--514.
    [15]
    Matthew Fluet and Stephen Weeks. Contification using dominators. In ICFP'01: Proceedings of the Sixth ACM SIGPLAN International Conference on Functional Programming, pages 2--13. ACM Press, September 2001.
    [16]
    John Hatcliff and Olivier Danvy. A generic account of continuation-passing styles. In Principles of Programming Languages (POPL), pages 458--471, 1994.
    [17]
    Haim Kaplan, Nira Shafrir, and Robert E. Tarjan. Union-find with deletions. In SODA '02: Proceedings of the thirteenth annual ACM-SIAM symposium on Discrete algorithms, pages 19--28, Philadelphia, PA, USA, 2002. Society for Industrial and Applied Mathematics. ISBN 0-89871-513-X.
    [18]
    Richard Kelsey. A correspondence between continuation passing style and static single assignment form. In Intermediate Representations Workshop, pages 13--23, 1995.
    [19]
    Richard A. Kelsey and Paul Hudak. Realistic compilation by program transformation. In Principles of Programming Languages (POPL). ACM, January 1989.
    [20]
    Jung-taek Kim, Kwangkeun Yi, and Olivier Danvy. Assessing the overhead of ML exceptions by selective CPS transformation. In ACM SIGPLAN Workshop on ML, pages 112--119, 1998. Also appears as BRICS technical report RS-98-15.
    [21]
    David A. Kranz, Richard A. Kelsey, Jonathan A. Rees, Paul Hudak, and James Philbin. ORBIT: an optimizing compiler for scheme. In Proceedings of the ACM SIGPLAN symposium on Compiler Construction, pages 219--233, June 1986.
    [22]
    Sam Lindley. Normalisation by evaluation in the compilation of typed functional programming languages. PhD thesis, University of Edinburgh, 2005.
    [23]
    Kathryn S. McKinley, editor. 20 Years of the ACM SIGPLAN Conference on Programming Language Design and Implementation 1979--1999, A Selection, 2004. ACM.
    [24]
    Eugenio Moggi. Notions of computation and monads. Information and Computation, 93: 55--92, 1991.
    [25]
    A. M. Pitts. Typed operational reasoning. In B. C. Pierce, editor, Advanced Topics in Types and Programming Languages, chapter 7, pages 245--289. The MIT Press, 2005.
    [26]
    Amr Sabry and Philip Wadler. A reflection on call-by-value. ACM Transactions on Programming Languages and Systems (TOPLAS), 19 (6): 916--941, November 1997. ISSN 0164-0925.
    [27]
    Zhong Shao and Andrew W. Appel. A type-based compiler for Standard ML. In Proc. 1995 ACM SIGPLAN Conference on Programming Language Design and Implementation (PLDI), pages 116--129, La Jolla, CA, Jun 1995.
    [28]
    Olin Shivers. Higher-order control-flow analysis in retrospect: lessons learned, lessons abandoned (with retrospective). In McKinley (2004), pages 257--269.
    [29]
    Olin Shivers and Mitchell Wand. Bottom-up β-reduction: Uplinks and λ-DAGs. In European Symposium on Programming (ESOP), pages 217--232, 2005.
    [30]
    Guy L. Steele. RABBIT: A compiler for SCHEME. Technical Report AI-TR-474, MIT, May 1978.
    [31]
    Hayo Thielecke. Comparing control constructs by double-barrelled CPS. Higher-Order and Symbolic Computation, 15 (2/3): 141--160, 2002.
    [32]
    Andrew P. Tolmach and Dino Oliva. From ML to Ada: Strongly-typed language interoperability via source translation. Journal of Functional Programming, 8 (4): 367--412, 1998.
    [33]
    Philip Wadler and Peter Thiemann. The marriage of effects and monads. In ACM SIGPLAN International Conference on Functional Programming (ICFP), 1998.

    Cited By

    View all
    • (2024)Call-by-Unboxed-ValueProceedings of the ACM on Programming Languages10.1145/36746548:ICFP(845-879)Online publication date: 15-Aug-2024
    • (2024)On the Operational Theory of the CPS-Calculus: Towards a Theoretical Foundation for IRsProceedings of the ACM on Programming Languages10.1145/36746308:ICFP(147-176)Online publication date: 15-Aug-2024
    • (2024)Hardware Implementation of OCaml Using a Synchronous Functional LanguagePractical Aspects of Declarative Languages10.1007/978-3-031-52038-9_10(151-168)Online publication date: 15-Jan-2024
    • Show More Cited By

    Index Terms

    1. Compiling with continuations, continued

      Recommendations

      Comments

      Information & Contributors

      Information

      Published In

      cover image ACM Conferences
      ICFP '07: Proceedings of the 12th ACM SIGPLAN international conference on Functional programming
      October 2007
      346 pages
      ISBN:9781595938152
      DOI:10.1145/1291151
      • cover image ACM SIGPLAN Notices
        ACM SIGPLAN Notices  Volume 42, Issue 9
        Proceedings of the ICFP '07 conference
        September 2007
        331 pages
        ISSN:0362-1340
        EISSN:1558-1160
        DOI:10.1145/1291220
        Issue’s Table of Contents
      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]

      Sponsors

      Publisher

      Association for Computing Machinery

      New York, NY, United States

      Publication History

      Published: 01 October 2007

      Permissions

      Request permissions for this article.

      Check for updates

      Author Tags

      1. continuation passing style
      2. continuations
      3. functional programming languages
      4. monads
      5. optimizing compilation

      Qualifiers

      • Article

      Conference

      ICFP07
      Sponsor:

      Acceptance Rates

      Overall Acceptance Rate 333 of 1,064 submissions, 31%

      Upcoming Conference

      ICFP '24

      Contributors

      Other Metrics

      Bibliometrics & Citations

      Bibliometrics

      Article Metrics

      • Downloads (Last 12 months)69
      • Downloads (Last 6 weeks)5
      Reflects downloads up to 11 Aug 2024

      Other Metrics

      Citations

      Cited By

      View all
      • (2024)Call-by-Unboxed-ValueProceedings of the ACM on Programming Languages10.1145/36746548:ICFP(845-879)Online publication date: 15-Aug-2024
      • (2024)On the Operational Theory of the CPS-Calculus: Towards a Theoretical Foundation for IRsProceedings of the ACM on Programming Languages10.1145/36746308:ICFP(147-176)Online publication date: 15-Aug-2024
      • (2024)Hardware Implementation of OCaml Using a Synchronous Functional LanguagePractical Aspects of Declarative Languages10.1007/978-3-031-52038-9_10(151-168)Online publication date: 15-Jan-2024
      • (2023) Prisma : A Tierless Language for Enforcing Contract-client Protocols in Decentralized ApplicationsACM Transactions on Programming Languages and Systems10.1145/360462945:3(1-41)Online publication date: 23-Sep-2023
      • (2023)Back to Direct Style: Typed and TightProceedings of the ACM on Programming Languages10.1145/35860567:OOPSLA1(848-875)Online publication date: 6-Apr-2023
      • (2023)Compiling Parallel Symbolic Execution with Continuations2023 IEEE/ACM 45th International Conference on Software Engineering (ICSE)10.1109/ICSE48619.2023.00116(1316-1328)Online publication date: May-2023
      • (2023)Accelerating OCaml Programs on FPGAInternational Journal of Parallel Programming10.1007/s10766-022-00748-z51:2-3(186-207)Online publication date: 24-Jan-2023
      • (2023)Verified Transformation of Continuation-Passing Style into Static Single Assignment FormTheoretical Aspects of Software Engineering10.1007/978-3-031-35257-7_2(20-37)Online publication date: 27-Jun-2023
      • (2022)Analyzing binding extent in 3CPSProceedings of the ACM on Programming Languages10.1145/35476456:ICFP(650-678)Online publication date: 31-Aug-2022
      • (2022)Lightweight Shape Analysis Based on Physical TypesVerification, Model Checking, and Abstract Interpretation10.1007/978-3-030-94583-1_11(219-241)Online publication date: 14-Jan-2022
      • Show More Cited By

      View Options

      Get Access

      Login options

      View options

      PDF

      View or Download as a PDF file.

      PDF

      eReader

      View online with eReader.

      eReader

      Media

      Figures

      Other

      Tables

      Share

      Share

      Share this Publication link

      Share on social media