Continuing WebAssembly with Effect Handlers

Continuing WebAssembly with Effect Handlers
复制标题

使用效果处理程序继续 WebAssembly

DOI:
10.1145/3622814
复制
发表时间:
2023
影响因子:
--
通讯作者:
Lindley, Sam
Lindley, Sam
中科院分区:
--
文献类型:
--
作者:
Phipps-Costin, Luna;Rossberg, Andreas;Guha, Arjun;Leijen, Daan;Hillerström, Daniel;Sivaramakrishnan, KC;Pretnar, Matija;Lindley, Sam

文献摘要

相似文献

WebAssembly(Wasm)是一种低级别的可移植代码格式, 原生性能它旨在作为广泛的 多种源语言。但是,Wasm不提供直接支持 对于非本地控制流特征(例如UART/AWAIT), 生成器/迭代器,轻量级线程,第一类延续, 这意味着具有这些功能的源语言编译器 必须隆重地转换整个源程序,以便针对 Wasm.我们提出WasmFX扩展Wasm提供了一个通用的 通过效果处理程序为非本地控件功能设定目标, 编译器将这些功能直接转换为Wasm。我们 扩展是最小的,只增加了三个主要指令, 创建、挂起和恢复延续。而且我们 基元指令是类型安全的, 这与WASM的设计原则非常一致, 都是打字的我们提出了WasmFX的正式规范,并表明, 扩展是健全的。我们已经实现了WasmFX作为一个扩展, Wasm参考解释器,并构建了一个原型WasmFX Wasmtime的扩展,一个生产级的Wasm引擎,搭载 Wasmtime现有的光纤API。初步业绩 我们原型的结果令人鼓舞,我们概述了未来的计划 来实现原生的实现。
WebAssembly (Wasm) is a low-level portable code format offering near native performance. It is intended as a compilation target for a wide variety of source languages. However, Wasm provides no direct support for non-local control flow features such as async/await, generators/iterators, lightweight threads, first-class continuations, etc. This means that compilers for source languages with such features must ceremoniously transform whole source programs in order to target Wasm.We present WasmFX an extension to Wasm which provides a universal target for non-local control features via effect handlers, enabling compilers to translate such features directly into Wasm. Our extension is minimal and only adds three main instructions for creating, suspending, and resuming continuations. Moreover, our primitive instructions are type-safe providing typed continuations which are well-aligned with the design principles of Wasm whose stacks are typed. We present a formal specification of WasmFX and show that the extension is sound. We have implemented WasmFX as an extension to the Wasm reference interpreter and also built a prototype WasmFX extension for Wasmtime, a production-grade Wasm engine, piggybacking on Wasmtime's existing fibers API. The preliminary performance results for our prototype are encouraging, and we outline future plans to realise a native implementation.