CIL

From OSDev.wiki
Revision as of 08:45, 3 July 2008 by osdev>Virtlink (first attempt)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search
This page is a stub.
You can help the wiki by accurately adding more contents to it.

The Common Intermediate Language (CIL, formerly MSIL) is a byte code intermediate language used in the .NET Framework. It is 'managed code' created by any CLI compatible compiler (such as the C# Compiler, and executed by the Virtual Execution System (VES). It is CPU and platform independent.

Most of the time, developers will not be programming directly in CIL but use a higher level language such as C#, C++/CLI, Visual Basic .NET and J#. However, CIL has it's own assembly language which can be assembled by ILAsm (ilasm.exe). To display the byte code in assembly language, the CIL disassembler ILDAsm (ildasm.exe) is used. However, some specialized tools such as .Net Reflector can represent the byte code as any of the supported higher level languages, such as C#, including the classes, methods and other metadata.

Managed code

The CIL byte code is so called managed code, which means that the execution system knows where all the data is, all the time. Therefore it is not possible to use pointers in managed code. Thanks to this property, the most common security and stability problems are eliminated, such as buffer overflows and dangling pointers. A garbage collector is employed to use the memory as efficient as possible.

Metadata

The CIL byte code is only half of an .NET assembly. The other half is metadata, which is used by the VES to find which method needs to be called. This makes it possible to inherit or extend classes and override methods while the correct overridden method will be called at run-time without recompiling the calling assembly.