Wasm/k: Delimited Continuations for WebAssembly

10/05/2020
by   Donald Pinckney, et al.
0

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 size.

READ FULL TEXT

page 1

page 2

page 3

page 4

research
02/26/2022

Semantic Soundness for Language Interoperability

Programs are rarely implemented in a single language, and thus questions...
research
09/26/2020

Applying Type Oriented Programming to the PGAS Memory Model

The Partitioned Global Address Space memory model has been popularised b...
research
09/02/2022

Performance of the Vipera framework for DSLs on micro-core architectures

Vipera provides a compiler and runtime framework for implementing dynami...
research
11/01/2022

Expression Acceleration: Seamless Parallelization of Typed High-Level Languages

Efficient parallelization of algorithms on general-purpose GPUs is today...
research
06/07/2019

Software Ethology: An Accurate and Resilient Semantic Binary Analysis Framework

When reverse engineering a binary, the analyst must first understand the...
research
05/25/2023

Implementing backjumping by means of exception handling

We discuss how to implement backjumping (or intelligent backtracking) in...
research
02/22/2020

Modeling the Invariance of Virtual Pointers in LLVM

Devirtualization is a compiler optimization that replaces indirect (virt...

Please sign up or login with your details

Forgot password? Click here to reset