bytebox icon indicating copy to clipboard operation
bytebox copied to clipboard

Optimization: transform stack-based bytecode to a custom register-based bytecode

Open rdunnington opened this issue 2 years ago • 0 comments

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:

  1. Translate WASM bytecode into a sea-of-nodes IR format.
  2. Run optimization passes eliding unnecessary get/set.
  3. Lower the IR to a register-based bytecode.
  4. 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.

rdunnington avatar May 15 '23 17:05 rdunnington