What does a just-in-time (JIT) compiler do?
JIT-Just in time the word itself says when it's needed (on demand)
Typical scenario:
The source code is completely converted into machine code
JIT scenario:
The source code will be converted into assembly language like structure [for ex IL (intermediate language) for C#, ByteCode for java].
The intermediate code is converted into machine language only when the application needs that is required codes are only converted to machine code.
JIT vs Non-JIT comparison:
In JIT not all the code is converted into machine code first a part of the code that is necessary will be converted into machine code then if a method or functionality called is not in machine then that will be turned into machine code... it reduces burden on the CPU.
As the machine code will be generated on run time....the JIT compiler will produce machine code that is optimised for running machine's CPU architecture.
JIT Examples:
- In Java JIT is in JVM (Java Virtual Machine)
- In C# it is in CLR (Common Language Runtime)
- In Android it is in DVM (Dalvik Virtual Machine), or ART (Android RunTime) in newer versions.