The JIT compiler in C# converts MSIL code to native code for execution, ensuring type safety. Types of JIT compilation include Pre-JIT, Econo-JIT, and Normal-JIT. Pre-JIT compiles all code at deployment, Econo-JIT compiles methods at runtime and removes them after execution, and Normal-JIT caches compiled methods.
The JIT compiler translates the MSIL code of an assembly to native code 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.
The JIT compiler also enforces type safety in the runtime environment of the .NET Framework.
It checks for the values that are passed to the parameters of any method.
The following are the various types of JIT compilation in .NET:
Pre - JIT.
Econo - JIT.
Normal - JIT.
Pre - JIT
In Pre-JIT compilation, complete source code is converted into native code in a single cycle (i.e. compiles the entire code into native code in one stretch)
This is done at the time of application deployment.
In .Net it is called "Ngen.exe"
Econo - JIT
In Econo-JIT compilation, the compiler compiles only those methods that are called at run time.
After the execution of this method, the compiled methods are removed from memory.
Normal - JIT
In Normal-JIT compilation, the compiler compiles only those methods that are called at run time.
After executing this method, compiled methods are stored in a memory cache.
No further calls to compiled methods will execute the methods from the memory cache.
2 comments
2 Comments
Join the conversation! Your thoughts help the community grow.
Join to leave a comment
Members earn 10 SHARP for a comment, 10 SHARP for a reaction, and 1,000 SHARP for every article they publish.
Thanks Mahesh to share this article.
I have few doubts. hope you will be help me to clear my doubts.
There are 3 types of JIT compilation in .Net:
1. How can decide which one will be compiling the code?
2. Who is responsible to call appropriate JIT Compiler?
3. All three compilation use or uses one among these three?
4. How can identify that which compilation is used to compiled code?
Thanks
haneef shikPosted Sep 24, 2019, 8:50 PM EDT
Thanks, for brief about this compiler
Sandeep Singh ShekhawatPosted Apr 3, 2013, 8:55 AM EDT
Thanks Mahesh to share this article. I have few doubts. hope you will be help me to clear my doubts. There are 3 types of JIT compilation in .Net: 1. How can decide which one will be compiling the code? 2. Who is responsible to call appropriate JIT Compiler? 3. All three compilation use or uses one among these three? 4. How can identify that which compilation is used to compiled code? Thanks