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

Wasm/k:WebAssembly的分隔延续

Wasm/k: Delimited Continuations for WebAssembly

Donald Pinckney, Arjun Guha, Yuriy Brun

摘要:

WebAssembly被设计成JavaScript的替代品,它是各种语言的安全,可移植和高效的编译目标。高级语言的性能不仅取决于WebAssembly的底层性能,还取决于生成的WebAssembly代码的质量。在本文中,我们确定了高级语言的几个功能,目前的方法只能通过生成复杂和低效的代码编译为WebAssembly。我们认为,这些问题可以解决,如果WebAssembly原生支持一流的延续。然后,我们介绍Wasm/k,它扩展了WebAssembly,带有分隔的延续。Wasm/k没有引入新的值类型,因此不需要对WebAssembly类型系统(验证)进行重大更改。Wasm/k是安全的,即使存在外部函数调用(例如,和来自JavaScript)。最后,Wasm/k可以有效地实现:我们将Wasm/k实现为Wasmtime的本地更改,Wasmtime是现有的WebAssembly JIT。我们通过实现C/k来评估Wasm/k,它将分隔的延续添加到C/C++。C/k使用Emscripten,它的实现可以作为如何在面向WebAssembly的编译器中使用Wasm/k的案例研究。我们提出了几个使用C/k的案例研究,并表明,在实现绿色线程,它可以优于最先进的方法Asyncify的性能提高了18%,代码大小提高了30%。

英文摘要:

WebAssembly is designed to be an alternative to JavaScript that is a safe, portable, and efficient compilation target for a variety of languages. The performance of high-level languages depends not only on the underlying performance of WebAssembly, but also on the quality of the generated WebAssembly code. In this paper, we identify several features of high-level languages that current approaches can only compile to WebAssembly by generating complex and inefficient code. We argue that these problems could be addressed if WebAssembly natively supported first-class continuations. We then present Wasm/k, which extends WebAssembly with delimited continuations. Wasm/k introduces no new value types, and thus does not require significant changes to the WebAssembly type system (validation). Wasm/k is safe, even in the presence of foreign function calls (e.g., to and from JavaScript). Finally, Wasm/k is amenable to efficient implementation: we implement Wasm/k as a local change to Wasmtime, an existing WebAssembly JIT. We evaluate Wasm/k by implementing C/k, which adds delimited continuations to C/C++. C/k uses Emscripten and its implementation serves as a case study on how to use Wasm/k in a compiler that targets WebAssembly. We present several case studies using C/k, and show that on implementing green threads, it can outperform the state-of-the-art approach Asyncify with an 18% improvement in performance and a 30% improvement in code size.

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

↑