Common Intermediate Language
Common Intermediate Language ( CIL ; sometimes just Intermediate Language , IL ) is an intermediate language into which all programs of the Common Language Infrastructure are translated. CIL is an object-oriented assembly language and is completely stack-based . On the target computer, the CIL is translated into native program code by a runtime system ( Virtual Execution System ) in order to be able to execute programs in the CIL.
CIL was called Microsoft Intermediate Language ( MSIL ) in the early development phases of .NET, but this name has been discarded with the standardization of the Common Language Infrastructure .
Basic functionality
When compiling source code from .NET languages, the system's own program code is not generated directly, but rather CIL code as a first step. In CIL, the program commands are specified as a sequence of byte values (sometimes more than one byte ). This code is translated to native machine code (so-called JIT compilation) and executed on the execution computer in a runtime system (the common language runtime ) .
During the translation, the security and correctness of the code (manipulation) are also checked.
NGEN (Native Image Generation) compilation
As an alternative to JIT compilation, it is also possible to compile a program before it is executed. The Native Image Generator (NGEN) program offers this possibility in the .NET framework. This makes it unnecessary to compile the program during runtime, so that the program start can be accelerated. However, the pre-generated program code cannot be transferred to other platforms . A recompilation with NGEN is necessary here or the fallback to the JIT compiler.
Even a natively compiled program always requires the runtime environment, since essential metadata are not part of the native program image. This only makes the JIT compilation superfluous.
CIL as a language
It is possible to represent the CIL intermediate code using assembler-like commands and thus to program programs directly in CIL.
See the hello world example in CIL .