paperbot · PL 论文追踪

全部论文 待读 收藏

P2 Let It Be Optimized: Building Multi-stage Evaluators with Let-Insertion and Optimizations in Small Pieces (Functional Pearl)

Let It Be Optimized:用 let 插入与优化以小步构建多阶段求值器(函数式 Pearl)
ICFP 10(ICFP)2026匹配度 2/10 · 该论文属于函数式编程与多阶段求值/编译器优化的形式语义研究,虽然涉及程序分析与优化技术,但并未涉及用户核心关注的 LLM/Agentic 程序、LLM 辅助静态分析/形式化验证、浮点程序分析或贝叶斯程序分析等交叉方向。其形式化与模块化优化展示有一定 PL 理论价值,但与用户当前研究画像的交叉点很少。引用 1 inbox
Guannan Wei, Jun Tan, Dinghong Zhong
crossref: 2026-09-10

AI 速览

一句话:用扩展 CPS 定义解释器,为库式多阶段求值中的自动 let 插入与优化建立操作语义,并模块化展示多种优化。

多阶段编程让元程序生成高效代码。库式 staging 系统常将分阶段求值、自动 let 插入与残差代码优化结合,但缺乏语义刻画,难以推理正确性或与其他 staging 范式比较。本文针对核心两阶段语言,用函数式编程技术构建一组定义式解释器,以扩展 CPS 简洁描述分阶段求值,其中两个 continuation 自然处理 let 插入。通过小幅重构,作者把常量传播/折叠、公共子表达式消除、死代码消除、beta-inlining、部分静态数据、代码移动等优化模块化地接入求值过程。每种优化都是小而独立的扩展,无需元程序员额外工作,也无需复杂的事后编译器基础设施。

问题
库式多阶段编程系统将分阶段求值、自动 let 插入与残差代码优化结合使用,但该组合缺少语义处理,难以推理正确性或与其他 staging 范式系统比较。
方法
针对核心两阶段语言,采用扩展 continuation-passing style 编写一系列定义式解释器,用两个 continuation 自然刻画 let 插入,并把各类优化作为小型模块化扩展集成到分阶段求值中。
评估
以常量传播/折叠、公共子表达式消除、死代码消除、beta-inlining、部分静态数据和代码移动为例,展示每种优化均可模块化加入,无需元程序员额外工作或复杂的事后编译器基础设施。
原文摘要(Abstract)

Multi-stage programming lets programmers write meta-programs that generate efficient code. Staging is typically realized either as a language primitive with quotations and splices (e.g., MetaML and its descendants), or as a library embedded in a host language (e.g., Lightweight Modular Staging). Unlike quotation-based approaches, practical library-based systems combine staged evaluation with automatic let-insertion to preserve evaluation order, along with optimizations that improve residual code. Despite their popularity and practical importance, this combination has received little semantic treatment, making it difficult to reason about correctness or to compare systematically with other staging paradigms. Using functional programming techniques, this pearl illuminates the operational aspects of staged evaluation with automatic let-insertion and optimizations as found in library-based staging systems. For a core two-stage language, we develop a series of definitional interpreters that concisely describe staged evaluation generating optimized, let-inserted residual programs. The interpreters are written in the extended continuation-passing style, where two continuations naturally account for let-insertion. With minor refactoring, we showcase a suite of optimizations, ranging from simple constant propagation/folding, common subexpression elimination, and dead-code elimination to more involved optimizations such as beta-inlining, partially-static data, and code motion. Each optimization is presented as a small, modular extension integrated into staged evaluation, requiring neither additional effort from the meta-programmer, nor complex post-hoc compiler infrastructure.

链接与引用

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

BibTeX
@article{WeiTZ26,
  title = {Let It Be Optimized: Building Multi-stage Evaluators with Let-Insertion and Optimizations in Small Pieces (Functional Pearl)},
  author = {Guannan Wei and Jun Tan and Dinghong Zhong},
  journal = {Proceedings of the ACM on Programming Languages},
  volume = {10},
  number = {ICFP},
  year = {2026},
  doi = {10.1145/3828676}
}