paperbot · PL 论文追踪

全部论文 待读 收藏

P2 Compiling with continuations, or without? whatever.

用续延编译,还是不用?随便。
ICFP 3(ICFP)2019匹配度 1/10 · 该论文研究函数式语言编译器的中间表示与 CPS/续延优化,属于编译原理方向;它与用户画像中的静态分析、LLM/Agent、浮点程序分析和贝叶斯程序分析均无直接关联。引用 18 inbox
Youyou Cong, Leo Osvald, Grégory M. Essertel, Tiark Rompf
crossref: 2026-09-10

AI 速览

一句话:提出一种可按需选择 CPS 的新编译器 IR,在直接风格与完全 CPS 间灵活优化续延。

函数式语言编译中长期争论 CPS:建模跳转需显式续延,但续延应作为第二类值并与普通函数分离,以保证代码生成效率。PLDI 2017 提出带显式 join point 的直接风格 IR,join point 即不返回、不逃逸的局部续延;该设计在 GHC 中有效,但优化时续延处理仍有改进空间。本文提出新 IR:用类似 Felleisen C 的控制算子消除冗余重写;分开处理续延的“不返回”与“不逃逸”性质,以高效编译良好行为函数;并定义选择性 CPS 翻译,在保持程序含义与类型的同时擦除控制算子。由此可在直接风格、完全 CPS 及中间风格中优化,把“是否 CPS”变为“何时需要多少 CPS”。

问题
如何在函数式语言编译器 IR 中处理续延:既要显式建模跳转,又要避免 CPS 带来的低效与优化冗余,并在直接风格与 CPS 之间取得灵活权衡。
方法
提出带 Felleisen C 式控制算子的新 IR,区分续延的不返回与不逃逸性质,并定义可擦除控制算子的选择性 CPS 翻译,保持程序含义与类型。
评估
摘要未报告具体实验,评估以在直接风格、完全 CPS 和选择性暴露续延的中间风格中支持优化为论证;此前 GHC join point 实践作为动机与对比。
原文摘要(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”.

链接与引用

DOI 原文 · PDF(开放获取) ·

BibTeX
@article{paperbot605,
  title = {Compiling with continuations, or without? whatever.},
  author = {Youyou Cong and Leo Osvald and Grégory M. Essertel and Tiark Rompf},
  journal = {Proceedings of the ACM on Programming Languages},
  volume = {3},
  number = {ICFP},
  year = {2019},
  doi = {10.1145/3341643}
}