25
loading...
This website collects cookies to deliver better user experience
You write code, compile it, and the next step in the process is the responsibility of CLR - it compiles MSIL (DLL or EXE) and creates an environment in which your code can be executed.
Depending on CPU type in the computer Windows loads x86, x64 or ARM version of MSCorEE.dll
JIT compilation takes into account the possibility that some code might never be called during execution. Instead of using time and memory to convert all the MSIL in a PE file to native code, it converts the MSIL as needed during execution and stores the resulting native code in memory so that it is accessible for subsequent calls in the context of that process.
Main
method of Program.exe
is called, and WriteLine
is set to be executed next, the JITCompiler
function searches assembly's (Console.dll
) metadata for the called method's (WriteLine
) MSIL. JITCompiler
next verifies and compiles the MSIL into native code and saves it in a dynamically allocated block of memory.WriteLine
) with an address of the block in memory containing the native code it previously compiled.WriteLine(string)
method) in the memory block, executes it and returns to Main
from where it continues execution as normal.WriteLine
is executed, code for the WriteLine
method has already been verified and compiled, meaning the call goes directly to the block of memory where native code is stored. Subsequent calls to the JIT-compiled method go directly to the native code.