Upgrade to Pro — share decks privately, control downloads, hide ads and more …

.NETプログラム (のランタイムを実装する) 入門なのです

Mayuki Sawatari
September 16, 2015

.NETプログラム (のランタイムを実装する) 入門なのです

Mayuki Sawatari

September 16, 2015
Tweet

More Decks by Mayuki Sawatari

Other Decks in Technology

Transcript

  1. MethodTable MethodTable NumVirtuals EEClass EEClass ParentMethodTable Interfaces MethodSlots StaticFields MethodSlots

    Slot MethodDesc 0 MethodA(0x1) 1 MethodB(0x2) 2 MethodA(0x1) 3 MethodB(0x2) 4 MethodC(0x2)
  2. System.Object Slot MethodDesc 0 ToString (virtual) 1 Equals (virtual) 2

    GetHashCode (virtual) A Slot MethodDesc 0 A.ToString (override) 1 Equals 2 GetHashCode 3 VirtualMethod (virtual) B Slot MethodDesc 0 A.ToString 1 Equals 2 GetHashCode 3 B.VirtualMethod (override) 4 B.VirtualMethod2
  3. CLR ? 0:006> !name2ee *!ConsoleApplication3.B Module: 73281000 Assembly: mscorlib.dll --------------------------------------

    Module: 02dd3fbc Assembly: ConsoleApplication3.exe Token: 02000004 MethodTable: 02dd4dcc EEClass: 02dd1858 Name: ConsoleApplication3.B 0:006> !dumpmt -md 02dd4dcc EEClass: 02dd1858 Module: 02dd3fbc Name: ConsoleApplication3.B mdToken: 02000004 File: C:\Users\Tomoyo\Documents\visual studio 2015\Projects\ConsoleApplication3\ConsoleApplication3\bin\Debug\ConsoleApplication3.exe BaseSize: 0xc ComponentSize: 0x0 Slots in VTable: 7 Number of IFaces in IFaceMap: 0 -------------------------------------- MethodDesc Table Entry MethodDe JIT Name 02e20055 02dd4d44 NONE ConsoleApplication3.A.ToString() 735f5600 7328835c PreJIT System.Object.Equals(System.Object) 735c19b0 7328837c PreJIT System.Object.GetHashCode() 735c16e8 73288390 PreJIT System.Object.Finalize() 02e20075 02dd4db4 NONE ConsoleApplication3.B.VirtualMethod() 02e20079 02dd4dbc NONE ConsoleApplication3.B.VirtualMethod2() 02e204a8 02dd4dc4 JIT ConsoleApplication3.B..ctor() 0:006> !name2ee *!ConsoleApplication3.A Module: 73281000 Assembly: mscorlib.dll -------------------------------------- Module: 02dd3fbc Assembly: ConsoleApplication3.exe Token: 02000003 MethodTable: 02dd4d5c EEClass: 02dd1804 Name: ConsoleApplication3.A 0:006> !dumpmt -md 02dd4d5c EEClass: 02dd1804 Module: 02dd3fbc Name: ConsoleApplication3.A mdToken: 02000003 File: C:\Users\Tomoyo\Documents\visual studio 2015\Projects\ConsoleApplication3\ConsoleApplication3\bin\Debug\ConsoleApplication3.exe BaseSize: 0xc ComponentSize: 0x0 Slots in VTable: 6 Number of IFaces in IFaceMap: 0 -------------------------------------- MethodDesc Table Entry MethodDe JIT Name 02e20055 02dd4d44 NONE ConsoleApplication3.A.ToString() 735f5600 7328835c PreJIT System.Object.Equals(System.Object) 735c19b0 7328837c PreJIT System.Object.GetHashCode() 735c16e8 73288390 PreJIT System.Object.Finalize() 02e20059 02dd4d4c NONE ConsoleApplication3.A.VirtualMethod() 02e204e0 02dd4d54 JIT ConsoleApplication3.A..ctor()
  4. MethodTable MethodTable Slot MethodDesc 0 MethodA(0x1) 1 MethodB(0x2) 2 MethodA(0x1)

    3 MethodB(0x2) 4 MethodC(0x2) interface IA { void MethodA(); void MethodB(); } interface IB { void MethodA(); void MethodB(); } class C : IA, IB { public void MethodA() { } public void MethodB() { } public void MethodC() { } } InterfaceVTableMap Interface MTSlot IA 0 IB 2
  5. Book of the Runtime ( BotR) https://github.com/dotnet/coreclr/tree/master/Documentation#book-of-the-runtime SOS & WinDbg

    & ildasm The Root of .NET Framework OpCodes https://msdn.microsoft.com/ja-jp/library/System.Reflection.Emit.OpCodes.aspx