arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2104.00250cs.PL
收藏

在OCaml上改进效果处理器

Retrofitting Effect Handlers onto OCaml

KC Sivaramakrishnan, Stephen Dolan, Leo White, Tom Kelly, Sadiq Jaffer, Anil Madhavapeddy

摘要:

效果处理程序作为一种具有用户自定义效果的模块化编程机制,已经获得了越来越多的发展势头。效果处理程序允许非本地控制流机制,如生成器,可组合地表达的GMAC/await,轻量级线程和协程。我们提出了一个设计和评估一个成熟的有效实现的效果处理程序OCaml,工业实力的多范式程序设计语言。我们的实现努力维护现有OCaml代码的向后兼容性和性能配置文件。将效果处理程序改造到OCaml上具有挑战性,因为OCaml目前除了异常之外没有任何非本地控制流机制。我们的OCaml效果处理程序的实现:(i)对不使用效果处理程序的综合宏基准测试套件施加平均1%的开销;(ii)与检查堆栈的程序分析工具保持兼容;(iii)对于使用效果处理程序的新代码是有效的。

英文摘要:

Effect handlers have been gathering momentum as a mechanism for modular programming with user-defined effects. Effect handlers allow for non-local control flow mechanisms such as generators, async/await, lightweight threads and coroutines to be composably expressed. We present a design and evaluate a full-fledged efficient implementation of effect handlers for OCaml, an industrial-strength multi-paradigm programming language. Our implementation strives to maintain the backwards compatibility and performance profile of existing OCaml code. Retrofitting effect handlers onto OCaml is challenging since OCaml does not currently have any non-local control flow mechanisms other than exceptions. Our implementation of effect handlers for OCaml: (i) imposes a mean 1% overhead on a comprehensive macro benchmark suite that does not use effect handlers; (ii) remains compatible with program analysis tools that inspect the stack; and (iii) is efficient for new code that makes use of effect handlers.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑