Lumen - Bringing the BEAM to WebAssembly and Beyond
summary
A new ahead-of-time compiler and runtime to run Erlang/Elixir on WebAssembly and x86_64 produces native objects via Rust + LLVM + wasm-bindgen, removes hot code loading so it can do dead-code elimination, and implements a continuation-based scheduler to preserve tail calls and cooperative scheduling inside wasm’s restrictions. A browser interpreter is already runnable for testing, the codegen backend is nearly finished, and the pipeline uses a Thorin-based IR with LLVM backend to generate wasm or native executables.
AI-written summary · about
chapters (17)
- 0:00Intro
- 1:01A new compiler/runtime for Erlang/Elixir Brings these languages to WebAssembly, with support for other targets as well Provides a path for building things in these languages that are not necessarily well supported by the BEAM
- 3:10Client-side ecosystem is in constant flux Why split investment and expertise across two ecosystems when one will do?
- 5:44Better cross-pollination Take advantage of the powerful tools provided by Erlang/OTP on both server and client Actors are an excellent pattern for building Uls
- 9:25An instruction set + binary and textual formats Designed for a stack-based virtual machine Portable, embeddable Memory-safe, sandboxed
- 11:18Harvard Architecture (separate code/data) Structured control flow vs arbitrary CFG Only permits passing integers to/from JS
- 13:19Code Size Load Time Concurrency Model
- 16:30Code Size Performance
- 19:04Shipping BEAM bytecode is expensive Weak dead-code elimination
- 21:46Impose some restrictions Ahead-of-Time vs VM Take advantage of existing tools
- 23:00Only pay for what you use No interpretation overhead Enables a wide variety of optimizations Including target specific optimizations
- 26:36Non-local returns/exceptions Green threads/preemptive scheduling WebAssembly-specific limitations
- 29:09Abstract machine is stack-based Requires structured control flow No direct access to the stack
- 31:17BEST SOLUTION? CONTINUATIONS!
- 31:33All continuations are in tail position Continuations never return Can represent all control flow constructs
- 39:32There is an interpreter that can be used for experimentation Codegen backend is basically complete Next release is waiting on a few PRs
- 40:48Better type information Auto-generated JS/DOM bindings In-browser debugging Support for a wider array of targets
related talks
19mLumen
31mLumen and Eir
43mLivecoding a WebAssembly interpreter
35mWebAssembly: now web is a new compiler target architecture
44mWebAssembly: the browser is now a real virtual machine
42mWebAssembly: A New Compilation Target for the Web
16mWhy WebAssembly
46mA State Of WebAssembly - The Browser is now a real VM
