I've been thinking about this recently, and it seems to me that most of the benefits provided by JIT compilation should be more or less related to the intermediate format instead, and that jitting alone is not a very good way to generate code.
So these are the main pro-JIT compilation arguments that I usually hear:
- Just-in-time compilation provides greater portability. Does this apply to the intermediate format? I mean, nothing prevents you from compiling your virtual bytecode into your own bytecode as soon as you receive it on your machine. Portability is a problem in the “distribution” phase, and not during the “launch” phase.
- OK, then what about generating code at runtime? Well, the same thing. Nothing prevents you from integrating the just-in-time compiler for a real urgent need in your own program.
- But the runtime compiles it into its own code only once in any case and saves the resulting executable file in some cache somewhere on your hard drive. Yes of course. But he optimized your program for time limits, and this did not improve it. See the next paragraph.
It does not seem that compiling ahead had any advantages. Compilation has time limits: you cannot keep the end user waiting while your program starts, so it has a trade-off that can be made somewhere. Most of the time they simply optimize less. My friend had profiling evidence that the built-in functions and manual cycle sweeps (obfuscating the source code in the process) had a positive impact on performance in his C # crunch-number program; doing the same on my side, with my C program filling in the same task that did not produce any positive results, and I believe that this is due to the extensive transformations that my compiler allowed to do.
And yet we are surrounded by jitt programs. C # and Java , Python scripts can compile into some kind of bytecode, and I'm sure a whole bunch of other programming languages do the same. There must be a good reason why I am missing. So, what makes compiling just in time so superior to compiling ahead ?
EDIT To eliminate some confusion, it might be important to indicate that I am all for the intermediate representation of executables. This has many advantages (and indeed, most arguments for compilation on time are actually arguments for an intermediate view). My question is how to compile them into native code.
Most runtimes (or compilers, for that matter) prefer either to compile them accurately or on time. Since compiling up front looks like the best alternative to me, because the compiler has more time to do the optimization, I wonder why Microsoft, Sun and everyone else goes the other way around. I have little doubt about optimizing profiling, since my experience with just-in-time compiled programs reflected weak basic optimizations.
I used the C code example only because I need a compilation example ahead of the timeline . The fact that the C code was not passed to the intermediate representation is not relevant, since I just needed to show that compiling ahead could give better immediate results.
compilation jit
zneak Jan 21 2018-10-21T00: 00-01
source share