Read Summary (1) how the source code of the DOTNET platform generates applications

Source: Internet
Author: User

CLR (Common Language Runtime) is the core content in the. NET Framework framework. The so-called CLR execution model is simply explained on the. NET platform.CodeIs how to compile and run. An image is summarized as follows:

The following is the work of each stage.

1. SetSource codeCompile into a managed Module

Microsoft has created a compiler for each language. during compilation, the compiler analyzes the source code and checks the code syntax. If there is no problem, the compiler can pass the compilation smoothly, finally, a managed module is generated, which consists of four parts, as shown in.

1> pe32 file header: If the pe32 format is used, it indicates that the file runs in both the 32-bit and 64-bit Windows versions. If the pe32 + format is used, indicates that the file can only run in the 64-bit version of Windows. The pe32 File Header identifies the file type and file generation time.
2> CLR header: contains the required CLR version, some flags, and methoddef metadata tag (token) of the managed module entry method (main method.
3> il code: the intermediate language code, which is generated when the compiler compiles the source code. During runtime, CLR (JIT compiler) compiles the Il code at a cost (or local CPU command ).
4> metadata: it is actually a set of tables. A type of table describes the classes and Members defined in the source code, and a type of table describes the classes and members referenced by the source code.

2. Merge the managed modulesProgramSet

CLR does not actually work with the hosting module, but with the Assembly. An assembly is a logical combination of one or more managed modules and resource files (slice and HTML static pages. Explains how managed modules are merged into an assembly.

Note: a manifest configuration file is a table set composed of metadata tables. These tables describe all the files that constitute the assembly and the resources or data files associated with the Assembly.

3. Run the assembly code.

To execute the assembly code, the clr jit compiler will first compile the Il code at a cost. Explains how the JIT compiler compiles and executes the Il code at a cost.

Note: A method performs il code verification and compilation into local code only when it is called for the first time. The second call does not require il code verification and compilation, directly execute the local code in the memory block. However, once the application stops running the application again or starts two instances of the application simultaneously (using two different operating system processes), the JIT compiler must verify and compile the Il code again, because the local code stored in the memory has been lost.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.