binary, cross compilation, etc • Zero dependency ◦ E.g. third party toolchains • Compile once, run everywhere • Sandbox environment ◦ Memory isolation ◦ Deny “system calls” by default
r.InstantiateModuleFromBinary(...) Linear memory // Instantiate a Rust Wasm binary. rust := r.InstantiateModuleFromBinary(...) Linear memory make([]byte, N) make([]byte, M)
r.InstantiateModuleFromBinary(...) Linear memory // Instantiate a Rust Wasm binary. rust := r.InstantiateModuleFromBinary(...) Linear memory make([]byte, N) make([]byte, M)
r.InstantiateModuleFromBinary(...) Linear memory // Instantiate a Rust Wasm binary. rust := r.InstantiateModuleFromBinary(...) Linear memory make([]byte, N) make([]byte, M)
◦ Wasm == Virtualization ◦ Depends on runtime implementation • Needs to compile your FFI to Wasm ◦ Premature ecosystem ◦ Refactor in a Wasm-friendly way
◦ Wasm == Virtualization ◦ Depends on runtime implementation • Needs to compile your FFI to Wasm ◦ Premature ecosystem ◦ Refactor in a Wasm-friendly way
◦ Wasm == Virtualization ◦ Depends on runtime implementation • Needs to compile your FFI to Wasm ◦ Premature ecosystem ◦ Refactor in a Wasm-friendly way
• Slow startup time ◦ AOT = compile Wasm binary into native machine code before execution • Fast execution (10x+ faster than interpreter) wazero.NewRuntimeConfigCompiler()
(e.g. “call” instruction) • Do not access Goroutine-stack allocated variable from machine code • Debugging is extremely difficult • Single pass compiler: optimizations are TODOs
(e.g. “call” instruction) • Do not access Goroutine-stack allocated variable from machine code • Debugging is extremely difficult • Single pass compiler: optimizations are TODOs
…. Function calls Wasm Linear memory []byte{...} allocated by Go runtime Module Information, etc A struct allocated by Go runtime Wasm stack []byte{...} allocated by Go runtime Goroutine stack 1 Goroutine stack N …. Generated machine codes
(e.g. “call” instruction) • Do not access Goroutine-stack allocated variable from machine code • Debugging is extremely difficult • Naive single pass compiler: optimizations are TODOs