An exploration of whether WebAssembly qualifies as a true stack machine, arguing the debate is largely semantic. WASM uses a stack as its primary interaction model but augments it with named locals (acting as registers), which improves readability compared to pure stack languages like Forth. A concrete example compares equivalent Forth and WASM code, showing WASM's named locals eliminate the need for stack manipulation operations like dup and swap. The post also examines how wasmtime compiles WASM to native x86-64, demonstrating that the compiler efficiently handles redundant local reads through standard optimization techniques like redundant load elimination.
Sort: