1. Introduction to JIT
JIT is the abbreviation of just in time, which is just in time compiler.
Using just-in-time compiler technology can accelerate the execution speed of Java programs.
Two, the problem
- Usually the program source code is compiled by javac and converted into java bytecode.
- JVM interprets bytecodes into corresponding machine instructions, reads in one by one, and interprets and translates one by one.
Obviously, after interpretation and execution, its execution speed will inevitably be much slower than executable binary bytecode programs.
Three, the solution
In order to improve the execution speed, JIT technology is introduced.
- At runtime, JIT will save the translated machine code for future use.
Therefore, in theory, using this JIT technology can approach the previous pure compilation technology.
Four, JIT compilation process
When JIT compilation is enabled (it is enabled by default), JVM reads the .class file for interpretation and sends it to the JIT compiler.
The JIT compiler compiles bytecode into native machine code.