Tuesday, August 21, 2018

JIT Compiler & Its Types

JIT Compiler

In the .NET Framework, all the Microsoft .NET languages use a Common Language Runtime. The language compiler will convert code into MSIL. Before the MSIL can be executed, it must be converted to native code. Native code is CPU specific code which runs on the same machine. JIT compiler converts the MSIL code to CPU native code as it is needed during code execution. It is called just-in-time since it converts the MSIL code to CPU native code; when it is required within code execution otherwise it will not do nothing with that MSIL code.

Role of the JIT compiler:-

The JIT compiler loads MSIL on target machines for execution. The MSIL is stored in .NET assemblies after the developer has compiled the code written in any .NET-compliant programming language, such as Visual Basic and C#. JIT compiler translates the MSIL code of an assembly and uses the CPU architecture of the target machine to execute a .NET application. It also stores the resulting native code so that it is accessible for subsequent calls. If a code executing on a target machine calls a non-native method, the JIT compiler converts the MSIL of that method into native code. JIT compiler also enforces type-safety in runtime environment of .NET Framework. It checks for the values that are passed to parameters of any method.

Types of JIT Compiler:


Pre JIT:

PRE JIT Compiler compiles complete source code into native code in a single compilation cycle. It will convert the compiled .NET code from the platform-independent intermediate state to a platform specific stage. This is done at the time of deployment of the application. The advantage of PRE JIT Compiler is that you don't have the initial compilation delay that the compiler can introduce when an assembly or type is loaded for the first time in code.


Econo JIT: 

Econo JIT Compiler compiles only those methods that are called at runtime. These compiled methods are removed when they are not required. The idea of Econo JIT is to spend less time compiling so that startup latency (the delay before a transfer of data begins following an instruction for its transfer) is lower for interactive applications.



Normal JIT: 

This complies only those methods that are called at runtime. These methods are compiled only first time when they are called, and then they are stored in memory cache. This memory cache is commonly called as JITTED. When the same methods are called again, the complied code from cache is used for execution.




7 comments: