The Just-In-Time (JIT) compiler is a component of the Java Runtime Environment (JRE) that is responsible for performance optimization of Java-based applications during runtime. It compiles bytecode into native machine code at runtime, which the hardware can execute directly, as compared to having the JVM interpret the same sequence of bytecode repeatedly and incurring overhead for the translation process. The JIT compiler interacts with the Java Virtual Machine (JVM) at runtime and compiles suitable bytecode sequences into native machine code.
The JIT compiler is able to perform certain simple optimizations while compiling a series of bytecode to native machine language. Some of these optimizations performed by JIT compilers are data analysis, reduction of memory accesses by register allocation, translation from stack operations to register operations, elimination of common sub-expressions, etc. . The greater the degree of optimization done, the more time a JIT compiler spends in the execution stage. However, it cannot afford to do all the optimizations that a static compiler is capable of, because of the extra overhead added to the execution time and moreover its view of the program is also restricted.
The JIT compiler is a combination of the two traditional approaches to translation to machine code: ahead-of-time compilation (AOT) and interpretation. It combines some advantages and drawbacks of both. Roughly, JIT compilation combines the speed of compiled code with the flexibility of interpretation, with the overhead of an interpreter and the additional overhead of compiling and linking (not just interpreting) .
In summary, the JIT compiler is a component of the JRE that compiles bytecode into native machine code at runtime, which improves the performance of Java-based applications. It interacts with the JVM at runtime and performs certain simple optimizations while compiling a series of bytecode to native machine language. The JIT compiler is a combination of the two traditional approaches to translation to machine code: ahead-of-time compilation (AOT) and interpretation.