4 ms·
WASM is a stack-machine, so the input code needs to be validated to make sure that the same types gets pop'ed as has previously been push'ed. But that can be do
by Findecanor 3y ago
WASM is a stack-machine, so the input code needs to be validated to make sure that the same types gets pop'ed as has previously been push'ed. But that can be done ahead of execution.
You'd need to validate function types during runtime though, which is something that a CPU emulator does not need to.
- klodolph 3y agoWASM is kind of a stack machine, yes, but there are a lot of constraints on the stack machine that are designed to make it easy to translate to registers. If you squint and look sideways, you can think of it as a flattened tree, rather than a stack machine.
- snvzz 3y agoIn contrast, RISC-V would be considered a register-based VM here.