[go: up one dir, main page]
More Web Proxy on the site http://driver.im/ skip to main content
10.1145/3426422.3426978acmconferencesArticle/Chapter ViewAbstractPublication PagessplashConference Proceedingsconference-collections
research-article

Wasm/k: delimited continuations for WebAssembly

Published: 15 November 2020 Publication History

Abstract

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.

Supplementary Material

Auxiliary Presentation Video (dls20main-p5-p-video.mp4)
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 is safe, even in the presence of foreign function calls (e.g., to and from JavaScript), and is amenable to efficient implementation in a JIT runtime. We evaluate Wasm/k by implementing C/k, an extension to C/C++ adding delimited continuations and compied to Wasm/k, and several case studies embedded in C/k.
MP4 File (3426422.3426978.mp4)
Presentation Video

References

[1]
2020. C-Ray. htps://github.com/vkoskiv/c-ray. Accessed Jul 4 2020.
[2]
2020. Electron. htps://www.electronjs.org. Accessed July 5, 2020.
[3]
2020. Exception handling. htps://github.com/WebAssembly/ exception-handling/blob/master/proposals/Exceptions.md. Accessed Jul 4 2020.
[4]
2020. generator.rkt. htps://github.com/racket/racket/blob/ ac4ae9ebba653c76edb2bb1f08ec1007427e5333/racket/collects/ racket/generator.rkt#L30. Accessed July 5, 2020.
[5]
2020. misc/Wasm: long tasks with Go WebAssembly. htps://github. com/golang/go/issues/39620. Accessed July 5, 2020.
[6]
2020. runtime: fatal error: self deadlock WebAssembly. htps://github. com/golang/go/issues/35256. Accessed July 5, 2020.
[7]
2020. syscall/js: performance considerations. htps://github.com/ golang/go/issues/32591. Accessed July 5, 2020.
[8]
2020. Threading proposal for WebAssembly. htps://github.com/ WebAssembly/threads/blob/master/proposals/threads/Overview.md. Accessed Jul 4 2020.
[9]
2020. Wasm: 3x performance overhead of using WebAssembly in Node 8. htps://github.com/golang/go/issues/26277. Accessed July 5, 2020.
[10]
2020. wasm_lua. htps://github.com/vvanders/wasm_lua. Accessed Sept 6, 2020.
[11]
2020. WebAssembly Specification. htps://webassembly.github.io/ spec/core/. Accessed Jul 6 2020.
[12]
Samuel Baxter, Rachit Nigam, Joe Gibbs Politz, Shriram Krishnamurthi, and Arjun Guha. 2018. Putting in All the Stops: Execution Control for JavaScript (PLDI'18).
[13]
Olivier Danvy and Andrzej Filinski. 1990. Abstracting Control (LFP'90). 151ś160.
[14]
Kavon Farvardin and John Reppy. 2020. From Folklore to Fact: Comparing Implementations of Stacks and Continuations (PLDI'20).
[15]
Mattias Felleisen. 1988. The Theory and Practice of First-Class Prompts (POPL'88). 180ś190.
[16]
Matthew Flatt, Gang Yu, Robert Bruce Findler, and Matthias Felleisen. 2007. Adding Delimited and Composable Control to a Production Programming Environment (ICFP'07).
[17]
Robbert Gurdeep Singh and Christophe Scholliers. 2019. WARDuino: A Dynamic WebAssembly Virtual Machine for Programming Microcontrollers (MPLR' 2019 ).
[18]
Andreas Haas, Andreas Rossberg, Derek L. Schuf, Ben L. Titzer, Michael Holman, Dan Gohman, Luke Wagner, Alon Zakai, and JF Bastien. 2017. Bringing the Web Up to Speed with WebAssembly (PLDI'17).
[19]
Xuan Huang. 2020. A Mechanized Formalization of the WebAssembly Specification in Coq. htps://www.cs.rit.edu/~mtf/student-resources/ 20191_huang_mscourse.pdf. Accessed Jul 7 2020.
[20]
Abhinav Jangda, Bobby Powers, Emery Berger, and Arjun Guha. 2019. Not So Fast: Analyzing the Performance of WebAssembly vs. Native Code (ATC'19).
[21]
Brooks Paige and Frank Wood. 2014. A Compilation Target for Probabilistic Programming Languages (ICML'14).
[22]
Greg Pettyjohn, John Clements, Joe Marshall, Shriram Krishnamurthi, and Matthias Felleisen. 2005. Continuations from generalized stack inspection (ICFP'05).
[23]
Donald Pinckney, Arjun Guha, and Yuriy Brun. 2020. Wasm/k: Delimited Continuations for WebAssembly. htps://arxiv.org/abs/ 2010.01723
[24]
Andreas Rossberg, Daan Leijen, Daniel Hillerström, KC Sivaramakrishnan, Matija Pretnar, Sam Lindley, and Stephen Dolan. 2019. Stacks and Continuations for Wasm Ð Idea Sketch. htps://github.com/WebAssembly/meetings/blob/master/main/ 2020/presentations/2020-02-rossberg-continuations. pdf. Accessed Jul 4 2020.
[25]
Dorai Sitaram and Matthias Felleisen. 1990. Control Delimiters and Their Hierarchies. LISP and Symbolic Computation 3, 1 (May 1990 ), 67ś99.
[26]
Conrad Watt. 2018. Mechanising and Verifying the WebAssembly Specification (CPP'18).
[27]
Conrad Watt, Andreas Rossberg, and Jean Pichon-Pharabod. 2019. Weakening WebAssembly (OOPSLA'19).
[28]
Alon Zakai. 2019. Pause and Resume WebAssembly with Binaryen's Asyncify. htps://kripken.github.io/blog/wasm/2019/07/16/asyncify. html. Accessed Jul 4 2020.

Cited By

View all
  • (2024)Whose Baseline Compiler Is It Anyway?Proceedings of the 2024 IEEE/ACM International Symposium on Code Generation and Optimization10.1109/CGO57630.2024.10444855(207-220)Online publication date: 2-Mar-2024
  • (2024)Os noise mitigations for benchmarking web browser execution environment performanceDiscover Computing10.1007/s10791-024-09471-427:1Online publication date: 29-Oct-2024
  • (2023)Continuing WebAssembly with Effect HandlersProceedings of the ACM on Programming Languages10.1145/36228147:OOPSLA2(460-485)Online publication date: 16-Oct-2023
  • Show More Cited By

Recommendations

Comments

Please enable JavaScript to view thecomments powered by Disqus.

Information & Contributors

Information

Published In

cover image ACM Conferences
DLS 2020: Proceedings of the 16th ACM SIGPLAN International Symposium on Dynamic Languages
November 2020
125 pages
ISBN:9781450381758
DOI:10.1145/3426422
Permission to make digital or hard copies of all or part of this work for personal or classroom use is granted without fee provided that copies are not made or distributed for profit or commercial advantage and that copies bear this notice and the full citation on the first page. Copyrights for components of this work owned by others than the author(s) must be honored. Abstracting with credit is permitted. To copy otherwise, or republish, to post on servers or to redistribute to lists, requires prior specific permission and/or a fee. Request permissions from [email protected].

Publisher

Association for Computing Machinery

New York, NY, United States

Publication History

Published: 15 November 2020

Permissions

Request permissions for this article.

Check for updates

Author Tags

  1. first-class continuations
  2. formal language semantics
  3. virtual machines

Qualifiers

  • Research-article

Funding Sources

Conference

SPLASH '20

Acceptance Rates

Overall Acceptance Rate 32 of 77 submissions, 42%

Upcoming Conference

Contributors

Other Metrics

Bibliometrics & Citations

Bibliometrics

Article Metrics

  • Downloads (Last 12 months)23
  • Downloads (Last 6 weeks)4
Reflects downloads up to 12 Dec 2024

Other Metrics

Citations

Cited By

View all
  • (2024)Whose Baseline Compiler Is It Anyway?Proceedings of the 2024 IEEE/ACM International Symposium on Code Generation and Optimization10.1109/CGO57630.2024.10444855(207-220)Online publication date: 2-Mar-2024
  • (2024)Os noise mitigations for benchmarking web browser execution environment performanceDiscover Computing10.1007/s10791-024-09471-427:1Online publication date: 29-Oct-2024
  • (2023)Continuing WebAssembly with Effect HandlersProceedings of the ACM on Programming Languages10.1145/36228147:OOPSLA2(460-485)Online publication date: 16-Oct-2023
  • (2023)Dynamic Slicing of WebAssembly Binaries2023 IEEE International Conference on Software Maintenance and Evolution (ICSME)10.1109/ICSME58846.2023.00020(84-96)Online publication date: 1-Oct-2023
  • (2022)Static stack-preserving intra-procedural slicing of webassembly binariesProceedings of the 44th International Conference on Software Engineering10.1145/3510003.3510070(2031-2042)Online publication date: 21-May-2022

View Options

Login options

View options

PDF

View or Download as a PDF file.

PDF

eReader

View online with eReader.

eReader

Media

Figures

Other

Tables

Share

Share

Share this Publication link

Share on social media