I wrote a C virtual machine that has a call table populated with pointers to functions that provide functionality to VM opcodes. When the virtual machine is started, it first interprets the program, creating an array of indexes corresponding to the corresponding function in the call table for the provided operation code. Then it goes through the array, calling each function until it reaches the end.
Each instruction is extremely small, usually one line. Ideal for embedding. The problem is that the compiler does not know when any of the instructions of the virtual machine will be called, as was accepted at run time, so it cannot embed them. Overhead function calls and passing arguments kill the performance of my virtual machine. Any ideas on how to get around this?
source share