# Core Wasm Proposals and Wasmtime
Nick Fitzgerald and Luke Wagner
2024-01-31
<!-- Put the link to this slide here so people can follow -->
slides: https://hackmd.io/p/yL4xCgBBT1KcblBKHG1P_A
---
# GC
https://github.com/WebAssembly/gc
Adds user-defined, garbage-collected types to Wasm
---
## GC: Status in Wasmtime
### done:
* [x] `wasmparser`
* [x] `wat/wast`
* [x] `wasm-encoder`
* [x] `wasm-smith`
---
## GC: Status in Wasmtime
impl owner: fitzgen
### todo:
* [ ] "null" GC in wasmtime
* [ ] spec tests passing in wasmtime
* [ ] embedder API changes
* [ ] `wasmtime_runtime::GcInterface`
* [ ] the real GC
* [ ] component model canonical ABI GC variant?
---
# Exception Handling
https://github.com/WebAssembly/exception-handling
Adds throw/catch-style unwinding to Wasm
---
## Exception Handling: Status in Wasmtime
### done:
* [x] `wasmparser`
* [x] `wat/wast`
* [x] `wasm-smith`
* [x] `wasm-encoder`
---
## Exception Handling: Status in Wasmtime
impl owner: needed!
### todo:
* [ ] bjorn3 has WIP support in Cranelift, maybe?
* Unclear if upstreamable
* [ ] Design and implement unwinding in Wasmtime and Cranelift
* RFC?
---
## Exception Handling Impl Options
* Zero-overhead, unwind info tables approach
* Swift-style calling convention approach
---
# Shared Everything Threads
https://github.com/WebAssembly/shared-everything-threads
Adds fine-grained sharing of Wasm state (functions, tables, globals, GC objects, etc...)
No core `thread.spawn` instruction.
`thread.spawn` component model builtin.
---
## Shared-Everything Threads in Wasmtime
Challenges:
* `vmctx` representation for thread vs instance
* is there even a difference?
* embedder API
* how to represent a thread?
* `wasmtime::SharedFunc` and `wasmtime::Func`?
* or is `wasmtime::Func` sendable to new stores/instances/what-have-you that represent a thread?
* testing? tsan in ci?
---
# Stack Switching
https://github.com/WebAssembly/stack-switching/
* Add fibers to core wasm (stacks, not threads)
* Status
* One concrete proposal:
* ["algebraic effects"](https://wasmfx.dev) aka "WasmFX"
* Implemented in a Wasmtime fork
* One less-concrete alternative:
* ["bag of stacks"](https://gist.github.com/fgmccabe/afe8bdfdf2ffdc94d69252683f376d15)
* More work needed
---
## Stack Switching: in parallel
* Adding fibers outside core wasm:
* Browser: [JavaScript Promise Integration](https://github.com/WebAssembly/js-promise-integration/blob/main/proposals/js-promise-integration/Overview.md)
* Component Model: Preview 3 / native async
* Not *dependent* on core stack-switching
* But watching to make sure it integrates
* Entails much of the "hard work" for runtimes
* Useful first steps toward stack-switching
---
# Thanks!
{"title":"Core Wasm Proposals in Wasmtime","breaks":true,"description":"View the slide with \"Slide Mode\".","contributors":"[{\"id\":\"86fa8590-380f-4ee1-8d72-ef8d8b271765\",\"add\":2080,\"del\":2395},{\"id\":\"6a5cd211-2ddf-44ea-a066-ff54b14e1151\",\"add\":1063,\"del\":202}]"}