C # compiler knowledge

C # code is compiled into MSIL code.

  When compiling a .NET user program, the compiler source code is translated into a set can be efficiently converted to native code and independent of CPU instructions. When these instructions are executed in real time ( the JIT ) compiler converting them to CPU specific code. Due to the common language runtime support for multiple real-time compiler, so the same piece of code can be different msil-time compiler compiler and run on different structures. In theory, MSIL will eliminate disputes between different languages in the industry for many years. May happen in the following part of the world's .NET EFFIL code may be implemented using another portion of the code C # or VB.NET completed, but the last of these codes will be converted into an intermediate language. This gives programmers a great deal of flexibility, programmers can choose their own familiar language, and no longer have to continue to introduce new language to learn to worry.

 

  MSIL comprising means for loading, storing and initialize the object and instructions to call a method on the object, further comprising means for arithmetic and logical operations, flow control, direct memory access, instruction exception handling and other operations. To make the code run, MSIL must first be converted to CPU-specific code, which is usually done by real-time (JIT) compiler. Due to the common language runtime for each computer architecture it supports provides one or more JIT compiler, so the same set of MSIL can be JIT compiled and run on any structural supports.
  When the compiler generates MSIL, it also generates metadata . Metadata describes the type of code, including the definition of each type, the signature of the members of each type, other data and code references a member of the runtime used in the execution. MSIL and metadata is contained in a portable executable (PE) file, this file is based on and expand Microsoft PE and Common Object File Format (COFF) for the past executable content published. This file format contains MSIL or native code and metadata, so that the operating system can recognize the common language runtime image. Metadata file and the code to enable the presence of MSIL describe itself, which means that no type library or interface definition language (IDL). Runtime need to find and extract metadata from the implementation process according to the document.

Guess you like

Origin www.cnblogs.com/Tpf386/p/11751338.html