Sunday, December 19, 2004

Introduction

My name is Petrény Zsolt and I am working as a software developer. I am mostly interested in .NET and especially in understanding it. That's why a few months ago I started write a program to better understand how MSIL (Microsoft Intermediate Language) works. My job is not directly related to IL (we're developing an ASP.NET application) thus I can work on this project only in my spare time.

A little bit about IL... As it's quite well known, when a code is compiled, the resulting assembly will contain IL instructions and metadata information (and a few other things like resources). The IL code will become real x86 machine instruction when the assembly is executed (let's talk about ngen later...).
The first time when a method is called, it will point to another method called PreStubWorker and this method will compile the IL instructions into x86 code. After this JIT (Just-In-Time) compilation the original method will contain a jmp instruction which points to the compiled x86 code. Thus the compilation will occur only once, at the first access of the method.
There are lots of good tools which help you to understand IL. The first and most important is ILDASM (IL Disassembler) which is part of the .NET Framework SDK.
Another disassembler program is Lutz Roeder's Reflector. I think this is the most popular (and best...) as it's not only able to show the IL code but it can also decompile the instructions into other languages like C#, VB.NET or Delphi. And there are also lots of useful add-ins for it.

I think this will be enough for an introduction. Unfortunately lately I can't spend as much time on my project as I would like to, but hopefully I'll be able to make a few entries every month in this blog.
If you have any question or correction (as I said I'm learning MSIL and not perfectly understand it yet ;-)) please leave a comment.