.NET类型内部构件-从Microsoft CLR角度 [英] .NET Type Internals - From a Microsoft CLR Perspective
本文介绍了.NET类型内部构件-从Microsoft CLR角度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有两个类Class1和Program a,如下所示:
I have two classes Class1 and Program a shown below:
class Class1
{
public void xx()
{
}
}
class Program : Class1
{
static void Main(string[] args)
{
}
}
这是SOS调试器的输出...
Here is the output from SOS debugger......
!dumpmt -md 00153898
EEClass: 00151474
Module: 00152ea4
Name: ConsoleApplication24.Program
mdToken: b1d44c0002000003
File: E:\c#\ConsoleApplication24\ConsoleApplication24\bin\Debug\ConsoleApplication24.exe
BaseSize: 0xc
ComponentSize: 0x0
Slots in VTable: 6
Number of IFaces in IFaceMap: 0
--------------------------------------
MethodDesc Table
Entry MethodDesc JIT Name
530ba790 52e94cd8 PreJIT System.Object.ToString()
530be290 52e94ce0 PreJIT System.Object.Equals(System.Object)
530be1a0 52e94d00 PreJIT System.Object.GetHashCode()
531417b0 52e94d14 PreJIT System.Object.Finalize()
0015c038 0015388c NONE ConsoleApplication24.Program..ctor()
0015c030 0015387c JIT ConsoleApplication24.Program.Main(System.String[])
但是,为什么在这里我没有在程序类"中看到继承的函数(即Class1的xx())????
因为当我创建Program类的实例并访问方法xx()时,它如何找到
方法????
But why here i not seen the inherited functions ( ie xx() from Class1 )in "Program class"??????
Because when i create instance of Program class and access method xx() then how it finds the
method????
推荐答案
编译器已经知道它是非虚拟的,因此它直接生成对Class1.xx()的调用.使用ildasm.exe查看生成的IL.
这里是clr烧写Class1方法表中方法xx()的地址并发出调用.这里clr不需要引用class1方法表的对象....... clr做到这一点自动....
The compiler already knows it is non-virtual so it directly generates a call to Class1.xx(). Use ildasm.exe to look at the generated IL.
here the address of the method xx() from Class1''s method table is burn by clr and emits call to it.Here clr not required the object reference to class1''s method table.......clr does it automatically....
这篇关于.NET类型内部构件-从Microsoft CLR角度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文