-----------------------------------------------------------

New Message on MumbaiUserGroup

-----------------------------------------------------------
From: Swapnil_B1
Message 1 in Discussion

  
Just In Time Compiler - Part 2  
The MSIL code rests in the executable file until we execute this file. At the 
time when the CLR receives control, the MSIL code is converted into the native 
code. This conversion is performed by the special compiler, called the 
Just-In-Time compiler. In theory, this JIT compiler should be the only 
platform-dependent component of .NET, but in real life, the majority of the 
.NET Framework class library and some of the other components are tied to the 
Windows platform. Here is a partial list:  
·         mscorlib;  
·         System;  
·         System.Design;  
·         System.Drawing;  
·         System.Windows.Forms.  
The Just-In-Time compiler compiles MSIL down to native code on a per-method 
basis. Here are the main steps in this process.  
1.      1)  Program is loaded and a function table is initialized with pointers 
referencing the MSIL code.  
2.       2) The Main method is JIT-compiled into native code and this code is 
executed. Calls to functions get compiled into indirect calls via the function 
table.  
3.       3) When another method is called, the CLR looks at the function table 
to see if it points into JIT-compiled code. If it does, the control flow 
continues. If not, the method is JIT-compiled and the table is updated.  
4.       4) As they are called, more and more methods are compiled into native 
code and more entries in the function table point into native code.  
5.       5) As the program continues to run, the JIT is called less and less 
often until everything is compiled.  
6.       6) A method is not compiled until it is called and it is never 
compiled again during the execution of the program.  
The Just-in-Time compiler is fast and generates good, optimized code. Here is a 
list of some of the optimizations performed by the JIT.  
·         constant folding Calculates constant values at compile time.  
·         constant and copy propagation Substitutes backwards to free variables 
earlier on.  
·         method inlining Replaces arguments with values passed at calltime and 
eliminates the call – currently only small methods (MSIL code size under 32 
bytes) are inlined.  
·         code hoisting and dominators Removes code from inside loops if it is 
duplicated outside.  
·         loop unrolling The overhead of incrementing counters and performing 
the test can be removed and the code of the loop can be repeated.  
·         common sub-expression elimination If a live variable still contains 
the information being recalculated, it uses that instead.  
·         enregistration Possible use of registers to store local variables 
instead of placing them on the stack.  
To avoid the delay caused by JIT compilation at runtime, we can precompile our 
applications using the special tool NGEN – CLR Native Image Generator, which 
runs the JIT compiler over the whole program once and saves the native code 
result on disk.  
Swapnil (Swaps)  
http://swapsnet.spaces.live.com/

-----------------------------------------------------------

To stop getting this e-mail, or change how often it arrives, go to your E-mail 
Settings.
http://groups.msn.com/MumbaiUserGroup/_emailsettings.msnw

Need help? If you've forgotten your password, please go to Passport Member 
Services.
http://groups.msn.com/_passportredir.msnw?ppmprop=help

For other questions or feedback, go to our Contact Us page.
http://groups.msn.com/contact

If you do not want to receive future e-mail from this MSN group, or if you 
received this message by mistake, please click the "Remove" link below. On the 
pre-addressed e-mail message that opens, simply click "Send". Your e-mail 
address will be deleted from this group's mailing list.
mailto:[EMAIL PROTECTED]

Reply via email to