bytebox
bytebox copied to clipboard
Optimization: transform stack-based bytecode to a custom register-based bytecode
Stack-based VMs have inherent performance limitations that are not present in register-based VMs. To reach or surpass performance of other WASM interpreters, bytebox will need to implement a register-based VM. Additionally, observing that most non-trivial programs have an obscene amount of locals and gets/sets to get around the stack limitations, a huge optimization would be to recognize most of these gets/sets as noops once they have register storage. To do this, we will need to:
- Translate WASM bytecode into a sea-of-nodes IR format.
- Run optimization passes eliding unnecessary get/set.
- Lower the IR to a register-based bytecode.
- Write a new VM capable of interpreting the new bytecode format.
This approach will also pave the way for JITing the register ops into native at some future point.