一句话:提出基于高阶流分析的安全空间闭包转换器,优化变量元组共享与寄存器展开,提升 SML/NJ 生成代码性能。
高阶函数式语言中,一等函数值的表示依赖闭包转换;嵌套函数构造闭包时常需从外层闭包复制数据,而链接表示虽避免复制却导致变量访问慢和空间泄漏。Shao 和 Appel 的闭包转换器虽减少复制并保证安全空间,但基于弱的一阶分析。本文提出使用高阶流分析指导闭包表示决策的安全空间闭包转换器,并将分析信息用于改进堆分配变量元组的共享以及将变量展开到参数寄存器。作者在 Standard ML of New Jersey 中实现该转换器,实验表明其生成代码平均优于 Shao-Appel 转换器,部分基准获得显著性能提升。
One of the key implementation challenges for higher-order functional languages is managing the representation of first-class function values. The standard approach to this problem is closure conversion , which is a compiler transformation that introduces an explicit data structure to represent the environment of a function value. Constructing the closure for a nested function usually involves copying data from the enclosing function’s closure. To avoid this copying, one might use linked representations, but that choice makes variable access slow and can introduce space leaks. Shao and Appel developed an effective closure converter that reduces copying and is safe-for-space, but their converter is based on a weak, first-order analysis. In this paper, we present a new safe-for-space closure converter that uses a higher-order flow analysis to inform closure-representation decisions. We describe how this information can be used to improve two aspects of closure optimization: sharing heap-allocated tuples of variables and spreading variables into argument registers. We have implemented our converter in the Standard ML of New Jersey system and demonstrated that it produces better code on average than the Shao and Appel converter, with significant performance gains for some benchmarks.
@article{ReppySZ26,
title = {Flow-Analysis-Based Closure Optimization},
author = {John Reppy and Olin Shivers and Byron Zhong},
journal = {Proceedings of the ACM on Programming Languages},
volume = {10},
number = {PLDI},
year = {2026},
doi = {10.1145/3808262}
}