A single Microsoft Windows process that has the CLR loaded into it

来源:互联网 发布:转基因好处数据 编辑:程序博客网 时间:2024/06/08 12:00

A singleMicrosoft Windows process that has the CLR loaded into it

 

In this processthere may be many threads.

When athread is created, it is allocated a 1-MB stack.

This stackspace is used for passing arguments to a method and for local variables defined

within amethod. In Figure 4-2, the memory for one thread’sstack is shown (on the right).

Stacks buildfrom high-memory addresses to low-memory addresses.

When the M1 methodstarts to execute, its prologue code allocates memory for the local namevariable

from the thread’s stack (see Figure 4-3).

Then, M1calls the M2 method, passing in the namelocal variable as an argument.

Inside the M2method, the stack location will be identified usingthe parameter variable named s.

Also, when amethod is called, the address

indicatingwhere the called method should return to in the calling method is pushed on the

stack (also shown in Figure4-4).

When the M2method starts to execute, its prologue codeallocates memory for the local

length and tallyvariables from the thread’sstack (see Figure 4-5). Then the code inside

method M2executes. Eventually, M2gets to its return statement, which causes the CPU’s

instructionpointer to be set to the return address in the stack, and M2’s stack frame is unwound

so that itlooks the way it did in Figure 4-3. At this point, M1is continuing to execute

its codethat immediately follows the call to M2, and its stack frame accurately reflects the

state needed by M1.

 

Our Windowsprocess has started, the CLR is loaded into it, the managed heap isinitialized,

and a thread has been created(along with its 1 MB of stack space).

At thistime, the CLR ensures that the assemblies that definethese types are loaded. Then, using the assembly’smetadata, the CLR extracts

informationabout these types and creates some data structures to represent the types

themselves.

0 0
原创粉丝点击