Four Approaches to Debugging Server-side WebAssembly
Step-debugging server-side WebAssembly can be done four ways: compiling to a native target and using LLDB/GDB, running the Wasm under Wasmtime inside LLDB, using a Wasm-specific debugger like Wasminspect, or using browser DevTools via Chrome's DWARF extension or source maps. Native compilation gives the best variable rendering and familiar tooling, and is the only option for interpreted languages, but may require stubbing imported functions and cannot reproduce Wasm-specific behavior. The other approaches suffer from lower-fidelity variable rendering, missing features, or harness setup. The recommendation is to debug natively by default and fall back to Wasmtime+LLDB or browser tools when bugs only reproduce in a Wasm engine.
Related posts
- Bringing Javascript to WebAssembly for Shopify Functions
Shopify Engineering mediumAdeptShopify runs JavaScript in Shopify Functions by compiling the QuickJS interpreter to WebAssembly/WASI via Javy. JIT engines like V8 can't run inside Wasm, so QuickJS fills the gap. Embedding the engine with the user's bytecode produced modules of 800KB or more, well over the 256KB limit. Shopify got around this with an ad-hoc dynamic linking scheme built on Wasmtime's linker: a shared "javy_quickjs_provider_v1" library exposes realloc and eval_bytecode, so each function shrinks to a roughly 220-byte stub plus its bytecode, and the engine can be precompiled and patched centrally. The minimal Javy runtime adds POSIX-like stdin/stdout APIs on a Javy global and a Rust-implemented UTF-8 TextEncoder/TextDecoder, but does not yet enable the event loop.
- Extensible Language Support in Zed - Part 1
Zed mediumAdeptZed loads third-party Tree-sitter grammars as WebAssembly modules using a hybrid design. Native code consumes the parser's static parse tables after they are copied out of wasm linear memory, while only the lexing functions, including hand-written external scanners, run inside Wasmtime. This avoids depending on the user's C compiler and keeps buggy scanners from crashing the editor. It also avoids copying large syntax trees out of wasm memory on every keystroke. A new `WasmStore` API lets wasm-loaded languages behave identically to native ones, and a bundled mini-libc with a bump allocator that is reset each parse makes scanner memory leaks impossible.
- Introducing Ruvy
Shopify Engineering mediumAdeptRuvy is an open-source toolchain built on ruby.wasm that compiles Ruby scripts into WebAssembly modules, pre-initializing the Ruby VM and preloaded Ruby files at build time instead of at startup. Compared with ruby.wasm plus wasi-vfs, Ruvy modules instantiate and run about 20% faster (roughly 44 ms vs 56 ms in Wasmtime) and compile to native code with Cranelift about 70% faster (about 0.45 s vs 1.65 s). Because the script is embedded, Ruvy modules need no WASI arguments at runtime, which suits edge platforms that can't pass them. Ruvy is currently built from source, and contributions are invited, including Shopify Functions compatibility work.
- Bringing Goodnotes to the web with Swift and WebAssembly
Swift.org mediumAdeptGoodnotes runs the same Swift code behind its iPad app in browsers by compiling it to WebAssembly with SwiftWasm, sharing 1.47M lines (66% of the 2.2M-line web codebase) including a rendering engine that targets Metal on iOS and WebGL on the web. The port required replacing libdispatch with Swift Concurrency, fixing code that assumed a 64-bit Int on wasm32, and abstracting I/O through dependency injection. WASI threads with Web Workers and SharedArrayBuffer, plus custom actor executors (SE-0392) that pin actors to specific workers, more than doubled INP but require cross-origin isolation. The roughly 50 MB binary (12 MB with Brotli) is cached with Service Workers, and Chrome DevTools debugging and a custom wasm-memprof heap profiler make the tooling workable. The WebAssembly support is upstreamed as of Swift 6.2.
- Contributing support for a Wasm instruction to Winch
Shopify Engineering hardMasterAdding a WebAssembly instruction to Winch, Wasmtime's baseline non-optimizing compiler, touches several layers: the wasmparser VisitOperator visitor, the CodeGenContext that manages the value stack, register allocation and spilling, an ISA-independent MacroAssembler, and an x86_64 assembler built on Cranelift's ISLE-generated instruction definitions. The i32.clz example shows how the MacroAssembler emits lzcnt when the CPU supports it and otherwise falls back to a bsr/setne sequence. Changes are tested in two ways: filetests check the emitted machine code without running it, so they work on AArch64 Macs, and differential fuzzing on x86_64 hardware compares Winch's results against another Wasm engine.