3 ms·
Nice. Copying (concatenating) the opcode implementations into an executable memory buffer is well-known. There are variants but it seems to generally be called
by versteegen 4y ago
Nice. Copying (concatenating) the opcode implementations into an executable memory buffer is well-known. There are variants but it seems to generally be called inline threading or dynamic superinstructions or the memcpy method [1]. If you can manage to do that in C (probably with the GCC computed-goto extension?) without asm or editing machine code I think it's a very good complexity-performance tradeoff, but unfortunately it doesn't seem to be too popular. It's faster than direct-threaded VMs but only eliminates one part of the instruction dispatch overhead compared to a real JIT (e.g. LuaJIT 2 vs LuaJIT 1) which loads operands directly or inlines them and does register allocation. But once you do inline threading, you have opportunities to eliminate more of the interpretation overhead, and the payoff becomes even greater e.g. [2].
[1] Markku Rossi, Kengatharan Sivalingam, 1996, A Survey of Instruction Dispatch Techniques for Byte-Code Interpreters, https://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.53.9849 https://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.53....
[2] M. Anton Ertl, David Gregg, 2004, Combining Stack Caching with Dynamic Superinstructions https://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.90.4604&rep=rep1&type=pdf https://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.90...