I recently took part in a discussion of Java performance. When I listened, many of the arguments against Java were that the interpretation was โextremely time-consuming,โ and because of this, even simple Java programs run slower than similar ones compiled directly into machine code.
The answer to this question was that Java code is often compiled directly into machine code, if the JVM computes it, the program does it faster than if it were interpreted in a standard way.
My questions are: when does the JVM actually "decide" to execute the compilation "just in time"? What are the criteria that make JIT more efficient than standard bytecode interpretation? I mean, that compilation takes some time, and, as I understand it, all this should happen when the program is already running?
source share