Just-In-Time (JIT) Compiler is a part of .NET Framework. This component makes the execution of a .NET program more efficient by translating those parts of code which are absolutely necessary. Hence, JIT doesn’t translate the whole of the MSIL code.
Overview of JIT Compiler
Just-In-Time (JIT) Compiler is a component of Common Language Runtime (CLR). Basically, the JIT compiler converts the MSIL code into native code. However, it does so as needed at that moment. By all means, the Just-In-Time (JIT) Compiler tries to improve the performance of code execution. In fact, JIT maintains a cache of translated machine code in order to speed up the execution process. Depending upon which of the code should be compiled, we can categories the JIT compilers as follows.
Types of Just-In-Time (JIT) Compiler
Pre-JIT Compiler makes the compilation process faster by translating the complete code at once in a single stretch. It is most suitable when the assembly is initially loaded. Native Image Generator (Ngen.exe) makes use of the Pre-JIT compiler.
The Native Image Generator (Ngen.exe)
.NET provides a tool called Native Image Generator which helps in speeding up the process of code execution on local computers. This tool creates native images. Native images are the files which contain system-specific native code. Ngen.exe installs this compiled native code on the cache of the system.
When the JIT compiler translates those methods into machine code, which it encounters the first time, it is called the Normal-JIT compiler. However, after that, it places this translated machine code in the memory cache. All the subsequent calls to those methods utilize the code from cache for faster execution.
This type of JIT compiler also compiles only those methods which are being called by the runtime. However, it doesn’t keep those methods after their use and removes them from the cache also.