Reconstructing Continuation-Passing Semantics for WebAssembly
摘要
WebAssembly is a popular low-level intermediate representation (IR) and compilation target. The official specification of WebAssembly provides a small-step reduction semantics. Unlike other common low-level IRs, WebAssembly provides structured control-flow constructs, whose reduction rules are complicated by additional administrative instructions in the reference semantics. This paper develops an alternative semantics in continuation-passing style (CPS), which can be implemented as a concise, compositional, and tail-recursive interpreter or CPS transformer. Using continuations from the meta-language eliminates the need for administrative instructions. We further demonstrate that the CPS semantics can be extended to support other forms of control abstractions, such as effect handlers.