Is it always faster during compilation?

Greetings to all compiler developers here at Stack Overflow.

I am currently working on a project that focuses on developing a new scripting language for use with high-performance computing. The source code is first compiled into a representation of the byte code. Then, the byte code is loaded by the runtime, which runs on it aggressive (and possibly time) optimizers (which go much further than what most compilers do “in front”, after all, that is the whole point in the project). Keep in mind that the result of this process is still byte code.

Then the bytecode is run in the virtual machine. This virtual machine is currently implemented using a direct jump table and a message pump. The virtual machine is started by bytecode using the pointer, loads the instruction under the pointer, looks for the instruction handler in the jump table and goes into it. The instruction handler takes the appropriate action and finally returns control to the message outline. The virtual machine instruction pointer is incremented and the whole process starts again. The performance that I can achieve with this approach is actually quite amazing. Of course, the code of the actual handlers is manually configured again.

Currently, most “professional” runtimes (such as Java, .NET, etc.) use Just-in-Time compilation to translate byte code into native code before execution. A JIT virtual machine typically has much better performance than a byte code interpreter. Now the question is that basically the interpreter loads the instruction and looks for the transition goal in the jump table (remember that the instruction handler itself is statically compiled into the interpreter, therefore it is already an internal code), will use Just-in-Time Compilation leads to increase productivity or lead to lower productivity? I can’t imagine the transition table of the interpreter to degrade performance,to significantly reduce the time taken to compile this code using JITer. I understand that JITER can perform additional code optimization, but in my case, very aggressive optimization is already performed before the bytecode is executed. Do you think I could get more speed by replacing the interpreter with the JIT compiler? If so, why?

, , , , , .

.

+3
3

. , , . , , , . , , . , , , , . , , ( , ) C ++.

+3

, ; ( ). 2 - 3 , IIRC; , JIT. , , , , , PIC; JIT.

, , IMHO.

+2

JIT , ( ). , , , , , et.c.

I'm sure your jumptable approach is fine, but I still think it will work pretty poorly compared to direct C code, right?

+1
source

Source: https://habr.com/ru/post/1785570/