What did Net compile?

zhaozj2021-02-17  49

There is a lot of questions about the design compilation of a .NET program (CPU-Specific Binary or Pseudo-code) in the list of newsgroups and email.

Here is a simple answer: When you compile a C # application or any CLS (CommnLanguage Specification) compatible language, it will first be compiled into a pseudo code called IL (Intermediate Language) (pseudo-code) . This IL code will be compiled into a machine code when this application is running. That is to say, from the source code to the operation result, two compilations were carried out. In fact, only those functional code that are truly used will be compiled for the second time. The details that are hidden during the development process are revealed:

1) You use C # Development Some Programs 2) Compile to an EXE3 with a C # compiler or CLS compatible compiler to add generated IL code and additional information (manifest) to the Win32 executable with a standard PE header Reading part. 4) The compiler is imported (import) a function called _corexemain when you create this executable. This function is the entry function of the .NET EE (Execution Engine) -. Net runtime engine. 5) When this WIN32 executable is executed, the operating system will call the _corexemain function in MSCoree.dll because it is mainly DLL's PE file. 6) The operating system calls Mscoree.dll through the entry point in the PE file. And guarantees that there are many programs that can be run simultaneously in Windows. 7) Because the operating system cannot execute .NET IL code, the entry point in EXE is just a simple intermediary, which will indicate the operating system call _corexemain function. 8) Then the _corexemain function begins to explain the IL code located in the PE file. 9) Because IL is not directly executed, .NET EE uses an instant compiler called Jitter (Just In Time Compiler) to compile IL code cost CPU machine code for execution. This instant compilation process is only performed at the first time.

转载请注明原文地址:https://www.9cbs.com/read-29178.html

New Post(0)