paperbot · PL 论文追踪

全部论文 待读 收藏

P2 Oxidizing OCaml with Modal Memory Management

用模态内存管理“氧化”OCaml
ICFP 8(ICFP)2024匹配度 2/10 · 论文属于 PL 类型系统与语言设计中的模态内存管理,虽与程序分析同属 PL 领域,但未涉及用户核心关注的静态分析、LLM/Agent、浮点程序分析或贝叶斯程序分析。引用 22 inbox
Anton Lorenzen, Leo White, Stephen Dolan, Richard A. Eisenberg, Sam Lindley
dblp: 2026-09-10crossref: 2026-09-10

AI 速览

一句话:以 affinity、uniqueness、locality 三条 mode 轴实现可完全推断、向后兼容的 OCaml 栈分配与原地更新,安全减少堆分配。

减少堆分配(栈分配或原地复用已有内存)通常能提升程序性能,但缺乏安全保证时极易引发 use-after-free,甚至破坏类型健全性。本文提出一套基于 mode(模态)的设计,让程序员能够安全地减少分配:在不可变结构上使用栈分配与原地更新。设计围绕三条 mode 轴展开——affinity、uniqueness 与 locality。这些 mode 与现有 OCaml 代码完全向后兼容,并且可以被完全推断,无需程序员手动标注。该工作使 OCaml 中的手动内存管理既安全又便捷,为把 Rust 的优势引入 OCaml 铺平了道路。摘要未报告具体的基准测试或量化评估结果。

问题
如何在不牺牲内存安全与类型健全性的前提下,通过栈分配和原地更新不可变结构来减少堆分配。
方法
提出基于 mode 的模态内存管理设计,围绕 affinity、uniqueness、locality 三条 mode 轴约束所有权与生命周期,并支持完全推断与对既有 OCaml 代码的向后兼容。
评估
摘要未给出量化实验,评估以设计与语言机制论证为主:所提 mode 可被完全推断,且与现有 OCaml 代码完全向后兼容。
原文摘要(Abstract)

Programmers can often improve the performance of their programs by reducing heap allocations: either by allocating on the stack or reusing existing memory in-place. However, without safety guarantees, these optimizations can easily lead to use-after-free errors and even type unsoundness. In this paper, we present a design based on modes which allows programmers to safely reduce allocations by using stack allocation and in-place updates of immutable structures. We focus on three mode axes: affinity, uniqueness and locality. Modes are fully backwards compatible with existing OCaml code and can be completely inferred. Our work makes manual memory management in OCaml safe and convenient and charts a path towards bringing the benefits of Rust to OCaml.

链接与引用

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

BibTeX
@article{LorenzenWDEL24,
  title = {Oxidizing OCaml with Modal Memory Management},
  author = {Anton Lorenzen and Leo White and Stephen Dolan and Richard A. Eisenberg and Sam Lindley},
  journal = {Proceedings of the ACM on Programming Languages},
  volume = {8},
  number = {ICFP},
  year = {2024},
  doi = {10.1145/3674642}
}