I was thinking that JIT compilers will eventually beat AOT compilers in terms of the performance of the compiled code, due to the inherent advantage of JIT (can use information available only at runtime). One argument is that AOT compilers can spend more time compiling code, but a server VM could spend a lot of time, too.
I do understand that JIT does seem to beat AOT compilers in some cases, but they still seem to lag behind in most cases.
So my question is, what are the specific, tough problems that is preventing JIT compilers to beat AOT compilers?
EDIT:
Some common arguments:
- AOT compilers can spend more time doing advanced optimizations -> If you are running a server VM for days, you can spend the same amount of time, if not longer.
- Byte code interpretation has cost -> Most JIT compilers cache native machine instructions anyways these days.
Yet another edit:
For a specific example, see this article: Improving Swing Performance: JIT vs AOT Compilation. From what I can gather from this article, the authors are basically saying that when there are no hotspots, the advantage of having runtime information decreases and thus AOT without the overhead of JIT, wins. But by 40%?? That doesn't seem to make a lot of sense. Is it simply that the JIT compiler that was compared wasn't tuned for this situation? Or is it something more fundamental?