Need a clear explanation of CLR,MSIL and JIT?

  • Thread starter Thread starter James dean
  • Start date Start date
J

James dean

My understanding is the MSIL runs on the CLR and the CLR is basically
the JIT compiler plus Garbage collection. This part "MSIL runs on the
CLR" is a bit vague to me can anyone give me a clearer definition and
explain how these 3 work together.
 
MSIL = ms intermediate language
CLR = common language runtime
JIT = Just in time compiler

MSIL is the "machine code like" language that the C# compiles your code
into.
The CLR is the "machine" that the MSIL runs on.
When runinng the MSIL the CLR converts your code into *real* machine code
using the JIT.
In this context just in time stands for that only the MSIL needed for the
moment is beeing compiled into machine code.
The real machine code is run on yor computers actual CPU.

Hope this helps.
mortb
 
mortb said:
MSIL = ms intermediate language
CLR = common language runtime
JIT = Just in time compiler

And as a sidenote:

ECMA (and later) ISO never bought using MSIL when .NET was formally made
into a standard.
Hence, MSIL was swiftly renamed into CIL.

CIL = Common Intermediate Language.

Happy Coding
- Michael S
 
When you compile a .NET language it generates an assembly. This assembly contains the IL instructions. When you run a .NET program, the win32 loader loads the CLR and hands off control to it. The CLR loads the assembly and locates the entrypoint (Main). The processor can't execute IL so the CLR invokes the JIT compiler to compile the method to machine code - all methods called from Main are stubbed out. The machine code is now executed by the processor. When the code path takes it into one of the stub functions, the JIT compiler is re-invoked to compile the new method (and it's called methods are stubbed out).

During the execution of the code, objects are created causing memory allocation. This memory is allocate on an area of memory called the managed heap. Because this block of memory is not infinite, eventually an allocation will cause a threshold to be breached where the CLR decides memory must be reclaimed. The Garbage Collector is invoked and it walks through the objects that are still potentially in use in the application and marks them as still in use. The memory for every object not marked as in use can then be reclaimed (the GC process is much more involved than this but this is broadly the approach).

Regards

Richard Blewett - DevelopMentor
http://www.dotnetconsult.co.uk/weblog
http://www.dotnetconsult.co.uk

My understanding is the MSIL runs on the CLR and the CLR is basically
the JIT compiler plus Garbage collection. This part "MSIL runs on the
CLR" is a bit vague to me can anyone give me a clearer definition and
explain how these 3 work together.
 
Back
Top