▲ | o11c 2 days ago | |
You have to ensure that virtual instructions map to distinct hardware instructions. Computed-goto-after-each-instruction is well known, and copying fragments of machine code is obvious. Less known is "make an entire copy of your interpreter for each state" - though I'm only aware of this as a depessimization for stack machines. https://dl.acm.org/doi/pdf/10.1145/223428.207165 But the main problem, which none of these solve, is that most VM languages are designed to be impossible (or very difficult) to optimize, due to aggressive use of dynamic typing. Nothing will save you from dynamic types. |