JIT stands for Just-in-Time. It is part of Java Run time Environment (JRE). It optimizes the performance of Java Application, by compiling byte codes to native machine code at run time.
JIT compiler enabled by default. Whenever a particular method is called, the JIT compiler compiles the byte code related to that method to native machine code.
JIT compilation threshold
Usually not every method code is compiled by JIT. JVM increases method call count for each method whenever a particular method is called. If the call count reaches to particular threshold, then JIT compiles and apply optimization's to the code. Until method count reaches to threshold, JVM interprets the byte code of the method whenever it is called.
What happens after JIT performs Compilation
Once JIT performs compilation, then method call count is reset to zero. Any calls to the method uses the compiled code(It won't interpret again and again) and method call count starts incrementing on sub sequent calls. Once method count reaches to thresh hold again, the code is recompiled by JIT and applies some more optimizations. This process repeats until the maximum optimization level is reached.
To do optimization JIT uses various techniques like Register usage optimization, Loop reduction and inversion, switch Analysis, GC and memory allocation optimizations etc.,a
No comments:
Post a Comment