A bare metal physical implementation of WASM. That's right, a WebAssembly CPU (2018)
A stack-based WASM CPU for stack-based WASM bytecode will be slower than a traditional register based CPU for reasons that have been known at least since the 1970s-1980s, when stack-based CPUs for Smalltalk, Lisp, and C were tried.<p>This didn&#x27;t stop Sun from trying again in the 1990s to make stack based CPUs for the JVM (picoJava, UltraJava, ...).<p>TL;DR: A WASM CPU will need a complicated stack cache to map stack positions to registers. This will involve more transistors, power, and latency than just letting compiler writers use the registers directly.<p>One of the earliest important papers is from 1982: &quot;Register Allocation for Free: The C Machine Stack Cache.&quot;[1]<p>Lispers sometimes lament that current processors are &#x27;C machines ill-suited to Lisp like the Symbolics Lisp processors of yore&#x27;, but in reality, C is very much a stack language, too. A C compiler is soooooo much easier to write if you don&#x27;t have to worry about register allocation, a hard problem.<p>I like that WASM is stack-based because it makes compilers for WASM much easier to write. But it makes the WASM JIT compiler much more complicated to write. But it&#x27;s better that top talent at Google, Mozilla, etc. does the WASM JIT compiler so that the rest of us can focus on solving other problems.<p>The Lisp Machines of yore had instructions for tagged arithmetic, which can speed up, say, adding two dynamically typed variables. No need for a compiler to infer and enforce the datatypes of simple variables in advance, the processor checks the datatypes while it is executing the code and signals a type error if you try to add a float to a character. But modern JIT strategies, which can infer the datatypes of loop variables and emit native instructions lightning fast, might ultimately be better.<p>[1] <a href="https:&#x2F;&#x2F;www.eecg.utoronto.ca&#x2F;~jzhu&#x2F;csc467&#x2F;readings&#x2F;ra-for-free.pdf" rel="nofollow">https:&#x2F;&#x2F;www.eecg.utoronto.ca&#x2F;~jzhu&#x2F;csc467&#x2F;readings&#x2F;ra-for-fr...</a>