JUST IN TIME (JIT)

Today in Engineer's World, we are discussing a very important topic of .NET Framework in very easy way. Posted By- +Manish Kumar Gautam +LIVE VIAR +ASP.NET SOLUTIONS

Click imagination hunt to see latest Blogs


What is the proper Definition of JIT?

Definition: JIT is Just In Time Compiler. A compiler which convert the IL code to machine specific code i.e., into Machine code. JIT is a tool provided by the CLR which give a way to the Source Code so that it can perform on the Machine efficiently.

How JIT work?
 
Working of Just-In-Time

Working: Firstly, the source code is compiled into its CIL code. Then the CIL code is taken by the CLR. Read the complete working of CLR and IL code in my previous blog ".NET FRAMEWORK".
The CLR then transfer the managed code to JIT. JIT at run-time convert the code into user machine specific code. And when we double click on the IL Code the JIT convert it into machine which is actually getting executed according to the client machine configuration.


How does it compile code?

Compilation: 

JIT compilation converts MSIL to native code on demand at application run time, when the contents of an assembly are loaded and executed. Because the common language runtime supplies a JIT compiler for each supported CPU architecture, developers can build a set of MSIL assemblies that can be JIT-compiled and run on different computers with different machine architectures. However, your managed code will run only on a specific operating system if it calls platform-specific native APIs, or a platform-specific class library.
The compilation of code can be done in three ways: 
 
Code compilation by JIT

o   Per File: It takes the complete C# File and compiles it to a machine language.
o   Per Method/Function:  It will take some methods or functions and compile that method and function and save that compile code into memory. 
o   Per Fragment: In Code Fragment where he probably takes 3 or 4 lines of codes and compile that code into machine language.

Does JIT also have types?
  
The answer is yes.

Types: 3 Types of JIT are available in .Net.
[NOTE]: These JIT may be categorized on the way they compile and the way they do caching.
 
Just-In-Time Types

o   Normal JIT: Compilation done on demand basis. Suppose there is Method 1. So, only Method 1 is compiled in case if it is needed. And once the Method 1 is compiled, the code is stored into RAM.
o   Econo JIT: Econo-JIT is same as Normal JIT, here also compilation is done on demand basis, but the code is not stored in cache into RAM. In case when you have low memory or you don't have lot of RAM. For example- Look at mobile phones memory. Then Econo-JIT is better thing to be used.
o   Pre JIT: In Pre-JIT there is no Dynamic compilation, instead there is full compilation. This compilation is done by ngen.exe. And this ngen.exe will compile your full .Net code into full machine language at that moment itself. This is full compilation rather than half compilation.





For any query, comment us below.

Click imagination hunt to see latest Blogs

Keep learning and sharing...

Comments

Popular posts from this blog

SSC CGL 2016 Tier-1 Marks / Result

DATA TYPES IN C#

Pattern printing program

IS STRING MUTABLE OR IMMUTABLE IN .NET?

Top Mutual Funds

SSC CGL 2017 TIER 2 RESULT OUT

Can we have multiple Main methods in one class

TOP 15 VISUAL STUDIO SHORTCUT KEYS

Top 10 Interview Tips and Questions