Continuing WebAssembly with Effect Handlers

Author:

Phipps-Costin Luna1ORCID,Rossberg Andreas2ORCID,Guha Arjun3ORCID,Leijen Daan4ORCID,Hillerström Daniel5ORCID,Sivaramakrishnan KC6ORCID,Pretnar Matija7ORCID,Lindley Sam8ORCID

Affiliation:

1. Northeastern University, Boston, USA

2. Independent, Munich, Germany

3. Northeastern University, Boston, USA / Roblox, Boston, USA

4. Microsoft Research, Redmond, USA

5. Huawei Zurich Research Center, Zurich, Switzerland

6. Tarides, Chennai, India / IIT Madras, Chennai, India

7. University of Ljubljana, Ljubljana, Slovenia / Institute of Mathematics, Physics & Mechanics, Ljubljana, Slovenia

8. The University of Edinburgh, Edinburgh, United Kingdom

Abstract

WebAssembly (Wasm) is a low-level portable code format offering near native performance. It is intended as a compilation target for a wide variety of source languages. However, Wasm provides no direct support for non-local control flow features such as async/await, generators/iterators, lightweight threads, first-class continuations, etc. This means that compilers for source languages with such features must ceremoniously transform whole source programs in order to target Wasm. We present WasmFX an extension to Wasm which provides a universal target for non-local control features via effect handlers, enabling compilers to translate such features directly into Wasm. Our extension is minimal and only adds three main instructions for creating, suspending, and resuming continuations. Moreover, our primitive instructions are type-safe providing typed continuations which are well-aligned with the design principles of Wasm whose stacks are typed. We present a formal specification of WasmFX and show that the extension is sound. We have implemented WasmFX as an extension to the Wasm reference interpreter and also built a prototype WasmFX extension for Wasmtime, a production-grade Wasm engine, piggybacking on Wasmtime's existing fibers API. The preliminary performance results for our prototype are encouraging, and we outline future plans to realise a native implementation.

Funder

NSF

UKRI

Publisher

Association for Computing Machinery (ACM)

Reference37 articles.

1. Heejin Ahn. 2022. Exception Handling Proposal for WebAssembly. https://webassembly.github.io/exception-handling/ Accessed 2022-10-27 Heejin Ahn. 2022. Exception Handling Proposal for WebAssembly. https://webassembly.github.io/exception-handling/ Accessed 2022-10-27

2. Joe Armstrong , Robert Virding , Claes Wikström , and Mike Williams . 1996. Concurrent Programming in Erlang , Second Edition. Prentice Hall International , Hertfordshire, UK . Joe Armstrong, Robert Virding, Claes Wikström, and Mike Williams. 1996. Concurrent Programming in Erlang, Second Edition. Prentice Hall International, Hertfordshire, UK.

3. Alan Bateman and Ron Pressler. 2021. JEP 428: Structured Concurrency (Incubator). https://openjdk.org/jeps/428 Accessed 2023-04-14 Alan Bateman and Ron Pressler. 2021. JEP 428: Structured Concurrency (Incubator). https://openjdk.org/jeps/428 Accessed 2023-04-14

4. Exceptional syntax

5. Gavin M. Bierman , Claudio V. Russo , Geoffrey Mainland , Erik Meijer , and Mads Torgersen . 2012 . Pause ’n’ Play: Formalizing Asynchronous C# . In ECOOP (Lecture Notes in Computer Science , Vol. 7313). Springer, 233– 257 . Gavin M. Bierman, Claudio V. Russo, Geoffrey Mainland, Erik Meijer, and Mads Torgersen. 2012. Pause ’n’ Play: Formalizing Asynchronous C#. In ECOOP (Lecture Notes in Computer Science, Vol. 7313). Springer, 233–257.

Cited by 9 articles. 订阅此论文施引文献 订阅此论文施引文献,注册后可以免费订阅5篇论文的施引文献,订阅后可以查看论文全部施引文献

1. Optimize Effect Handling for Tail-resumption with Stack Unwinding;Proceedings of the 18th ACM SIGPLAN International Conference on Software Language Engineering;2025-06-12

2. Handling the Selection Monad;Proceedings of the ACM on Programming Languages;2025-06-10

3. Modal Effect Types;Proceedings of the ACM on Programming Languages;2025-04-09

4. Lexical Effect Handlers, Directly;Proceedings of the ACM on Programming Languages;2024-10-08

5. Effect Handlers for C via Coroutines;Proceedings of the ACM on Programming Languages;2024-10-08

同舟云学术

1.学者识别学者识别

2.学术分析学术分析

3.人才评估人才评估

"同舟云学术"是以全球学者为主线,采集、加工和组织学术论文而形成的新型学术文献查询和分析系统,可以对全球学者进行文献检索和人才价值评估。用户可以通过关注某些学科领域的顶尖人物而持续追踪该领域的学科进展和研究前沿。经过近期的数据扩容,当前同舟云学术共收录了国内外主流学术期刊6万余种,收集的期刊论文及会议论文总量共计约1.7亿篇,并以每天添加12000余篇中外论文的速度递增。我们也可以为用户提供个性化、定制化的学者数据。欢迎来电咨询!咨询电话:010-8811{复制后删除}0370

www.globalauthorid.com

TOP

Copyright © 2019-2025 北京同舟云网络信息技术有限公司
京公网安备11010802033243号  京ICP备18003416号-3