Pushing RISC-V Emulation to Bare-Metal Speed
Pushing the limits of RISC-V emulation

This post explores how close a RISC-V program can get to bare-metal performance on a non-RISC-V machine. The key is an ahead-of-time recompiler that connects generated basic blocks with tail calls and uses Clang's `preserve_none` calling convention to keep hot guest state in host registers. Starting from a basic interpreter, the author progressively removes overhead—predecoding, computed goto, tail-call threading—before moving to a hand-written assembly backend and finally letting Clang compile each basic block as a separate function.
The fastest way to run a program is to get out of its way and let the hardware execute it directly.
- dmitrygr
At the end it is not emulation but static recompilation (which is, arguably, cooler)