论文标题

WASM/K:WebAssembly的界定连续性

Wasm/k: Delimited Continuations for WebAssembly

论文作者

Pinckney, Donald, Guha, Arjun, Brun, Yuriy

论文摘要

WebAssembly旨在替代JavaScript,它是各种语言的安全,便携式和有效的编译目标。高级语言的性能不仅取决于WebAssembly的基础性能,还取决于生成的WebAssembly代码的质量。在本文中,我们确定了当前方法只能通过生成复杂且效率低下的代码来编译到WebAssembly的高级语言的几个功能。我们认为,如果WebAssembly在本地支持的一流延续中,可以解决这些问题。然后,我们提出WASM/K,该WebAssembly扩展了划界的连续性。 WASM/K不引入新的价值类型,因此不需要对WebAssembly类型系统(验证)进行重大更改。 WASM/K也是安全的,即使在存在外国功能呼叫的情况下(例如,从JavaScript)也是安全的。最后,WASM/K适合有效的实施:我们实现WASM/K作为现有WebSembly JIT WASMTIME的本地更改。我们通过实施C/K来评估WASM/K,从而将划界连续性添加到C/C ++。 C/K使用Emscripten,其实施是关于如何在针对WebAssembly的编译器中使用WASM/K的案例研究。我们使用C/K介绍了几项案例研究,并表明,在实施绿色线程时,它可以优于最先进的方法,而性能提高了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.

扫码加入交流群

加入微信交流群

微信交流群二维码

扫码加入学术交流群,获取更多资源