JIT and Debugging
The standard PE header comes at the beginning of the file. Inside the file is the CLR
header, followed by the data required to load the code into its process space--referred to
as metadata. It describes to the execution engine how the module should be loaded, what
additional files it needs, how to load those additional files, and how to interact with COM
and the .NET runtime.
Metadata also describes the methods, interfaces, and classes contained in the module or
assembly. The information the metadata provides allows the JIT compiler to compile and
run the module. The metadata section exposes much of your application's internals and
eases the transition from disassembled IL to useful code.
3.3 JIT (Justin-Time Compiler) & Debugging
The .NET Runtime ships with a Just-In-Time (JIT or JITter) compiler, which will convert
the MSIL code in to the native code (CPU Specific executable code). So whatever code
we write will be complied in to MSIL format and the JIT takes over when you run it.
The .NET runtime/Common Language Runtime (CLR) ships three different classes of
JITters. The Main JIT compiler converts the MSIL code it to native code with out any
optimizations. The JIT compiler takes the MSIL code and optimizes it. So this compiler
requires lot of resources like, time to compile, larger memory footprint, etc. The PreJIT
is based on the Main JIT and it works like the traditional compilers (compiles MSIL to
native code during compilation time rather than runtime). This compiler is usually used at
the time of installation.
No matter whatever language we used to develop the HelloWorld program, it's a known
fact that compiler's are going to generate a MSIL format, once our code has been
converted in to MSIL format, from MSIL format all the code that we write will be
converted to native code in the same way whether if it is a VB.NET source or C# source.
Intermediate Language (IL)
To support our discussion let us examine the IL code of HelloWorld program written
using VB.NET and C#. To visualize the IL code Microsoft provides a disassembler tool
through which you can easily see the IL code
To use the tool, choose command prompt and type ILDASM->ILDASM dialog is shown-
> choose file open dialog and select the assembly
(make sure you set your path variable to point to the place where your ILDASM is
available)