Compiling with continuations, or without? Whatever.

15Citations
Citations of this article
23Readers
Mendeley users who have this article in their library.

Abstract

What makes a good compiler IR? In the context of functional languages, there has been an extensive debate on the advantages and disadvantages of continuation-passing-style (CPS). The consensus seems to be that some form of explicit continuations is necessary to model jumps in a functional style, but that they should have a 2nd-class status, separate from regular functions, to ensure efficient code generation. Building on this observation, a recent study from PLDI 2017 proposed a direct-style IR with explicit join points, which essentially represent local continuations, i.e., functions that do not return or escape. While this IR can work well in practice, as evidenced by the implementation of join points in the Glasgow Haskell Compiler (GHC), there still seems to be room for improvement, especially with regard to the way continuations are handled in the course of optimization. In this paper, we contribute to the CPS debate by developing a novel IR with the following features. First, we integrate a control operator that resembles Felleisen's C, eliminating certain redundant rewrites observed in the previous study. Second, we treat the non-returning and non-escaping aspects of continuations separately, allowing efficient compilation of well-behaved functions defined by the user. Third, we define a selective CPS translation of our IR, which erases control operators while preserving the meaning and typing of programs. These features enable optimizations in both direct style and full CPS, as well as in any intermediate style with selectively exposed continuations. Thus, we change the spectrum of available options from łCPS yes or nož to łas much or as little CPS as you want, when you want itž.

References Powered by Scopus

A syntactic approach to type soundness

744Citations
N/AReaders
Get full text

Lightweight modular staging: A pragmatic approach to runtime code generation and compiled DSLs

202Citations
N/AReaders
Get full text

Representing control: A study of the cps transformation

202Citations
N/AReaders
Get full text

Cited by Powered by Scopus

Compiling effect handlers in capability-passing style

19Citations
N/AReaders
Get full text

Kotlin coroutines: Design and implementation

13Citations
N/AReaders
Get full text

Reachability types: Tracking aliasing and separation in higher-order functional programs

12Citations
N/AReaders
Get full text

Register to see more suggestions

Mendeley helps you to discover research relevant for your work.

Already have an account?

Cite

CITATION STYLE

APA

Cong, Y., Osvald, L., Essertel, G. M., & Rompf, T. (2019). Compiling with continuations, or without? Whatever. Proceedings of the ACM on Programming Languages, 3(ICFP). https://doi.org/10.1145/3341643

Readers' Seniority

Tooltip

PhD / Post grad / Masters / Doc 8

73%

Researcher 3

27%

Readers' Discipline

Tooltip

Computer Science 18

90%

Nursing and Health Professions 1

5%

Engineering 1

5%

Save time finding and organizing research with Mendeley

Sign up for free