paperbot · PL 论文追踪

全部论文 待读 收藏

P2 Finitary polymorphism for optimizing type-directed compilation

用于优化类型导向编译的有限多态
ICFP 2(ICFP)2018匹配度 1/10 · 该论文研究多态类型系统的编译优化与类型传递抽象消除,属于类型论/编译器方向,与用户的 PL↔AI、Agentic 程序分析、浮点程序分析、贝叶斯程序分析等核心方向没有直接交集。引用 0 inbox
Atsushi Ohori, Katsuhiro Ueno, Hisayuki Mima
crossref: 2026-09-10

AI 速览

一句话:提出有限多态演算与类型宇宙重构,消除多态编译中的类型传递抽象并加速代码。

针对多态语言中类型导向编译常需传递类型信息、带来运行时开销的问题,本文提出一种有限多态的类型论方法。作者定义带有限类型宇宙的谓词式二阶 lambda 演算,将类型抽象约束到有限实例类型集合,并相对类型传递操作语义证明类型可靠性。为将标准二阶 lambda 演算项转化为该演算,提出宇宙重构算法,可判定并构造对应项。基于此给出多态函数的类型优化方法,在 SML# 编译器中针对原生无标签数据表示和记录多态实现。基准测试表明,83.79% 的类型传递抽象被消除,编译代码平均加速 15.28%。

问题
多态语言的类型导向编译常因运行时类型传递而产生开销,核心问题是如何从类型层面消除不必要的类型抽象。
方法
定义带有限类型宇宙的谓词式二阶 lambda 演算并证明类型可靠性,设计宇宙重构算法将标准二阶项转成有限多态项,据此优化多态函数。
评估
在 SML# 编译器中实现针对无标签数据表示和记录多态的优化,并在基准测试上测量类型传递消除率与运行加速。
原文摘要(Abstract)

We develop a type-theoretical method for optimizing type directed compilation of polymorphic languages, implement the method in SML#, which is a full-scale compiler of Standard ML extended with several advanced features that require type-passing operational semantics, and report its effectiveness through performance evaluation. For this purpose, we first define a predicative second-order lambda calculus with finitary polymorphism, where each type abstraction is explicitly constrained to a finite type universe, and establishes the type soundness with respect to a type-passing operational semantics. Different from a calculus with stratified type universes, type universes of the calculus are terms that represent a finite set of instance types. We then develop a universe reconstruction algorithm that takes a term of the standard second-order lambda calculus, checks if the term is typable with finitary polymorphism, and, if typable, constructs a term in the calculus of finitary polymorphism. Based on these results, we present a type-based optimization method for polymorphic functions. Since our formalism is based on the second-order lambda calculus, it can be used to optimize various polymorphic languages. We implement the optimization method for native (tag-free) data representation and record polymorphism, and evaluate its effectiveness through benchmarks. The evaluation shows that 83.79% of type passing abstractions are eliminated, and achieves the average of 15.28% speed-up of compiled code.

链接与引用

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

BibTeX
@article{paperbot268,
  title = {Finitary polymorphism for optimizing type-directed compilation},
  author = {Atsushi Ohori and Katsuhiro Ueno and Hisayuki Mima},
  journal = {Proceedings of the ACM on Programming Languages},
  volume = {2},
  number = {ICFP},
  year = {2018},
  doi = {10.1145/3236776}
}