{"id":253094,"date":"2015-03-15T17:37:02","date_gmt":"2015-03-15T13:37:02","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=253094"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=253094","title":{"rendered":"Age of JIT compiling. Part II. CLR is watching you"},"content":{"rendered":"<p>     \t\u041f\u0440\u043e\u0434\u043e\u043b\u0436\u0430\u044f <a href=\"http:\/\/habrahabr.ru\/post\/248775\/\">\u0442\u0435\u043c\u0443 JIT-\u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u0438<\/a> .NET&#8217;a, \u0441\u0435\u0433\u043e\u0434\u043d\u044f \u043c\u044b \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0434\u0438\u0441\u043f\u0435\u0442\u0447\u0435\u0440\u0438\u0437\u0430\u0446\u0438\u044e \u043c\u0435\u0442\u043e\u0434\u043e\u0432 \u0443 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u043e\u0432, generics (\u043a\u0430\u043a \u043a\u043b\u0430\u0441\u0441\u043e\u0432, \u0442\u0430\u043a \u0438 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0445 \u043c\u0435\u0442\u043e\u0434\u043e\u0432 \u0432\u043c\u0435\u0441\u0442\u0435 \u0441 \u0440\u0435\u0430\u043b\u044c\u043d\u044b\u043c\u0438 \u0441\u0438\u0433\u043d\u0430\u0442\u0443\u0440\u0430\u043c\u0438); \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u044c \u043e\u0442\u043b\u0430\u0434\u043a\u0443 \u0440\u0435\u043b\u0438\u0437\u043d\u044b\u0445 \u0441\u0431\u043e\u0440\u043e\u043a \u0441 \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u044f\u043c\u0438; \u0440\u0430\u0437\u0431\u0435\u0440\u0435\u043c\u0441\u044f \u0441 \u0438\u0441\u0442\u0438\u043d\u043d\u044b\u043c \u043f\u0440\u0435\u0434\u043d\u0430\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435\u043c \u0442\u0438\u043f\u0430 System.__Canon (\u044d\u0442\u043e \u043d\u0435 \u0442\u043e, \u0447\u0442\u043e \u0412\u044b \u043f\u043e\u0434\u0443\u043c\u0430\u043b\u0438).<br \/>  <a name=\"habracut\"><\/a>  <\/p>\n<h3><font color=\"#2E74B5\">\u041d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 \u0441\u0440\u0435\u0434\u044b<\/font><\/h3>\n<p>  \u041f\u0440\u0435\u0436\u0434\u0435 \u0447\u0435\u043c \u0434\u0432\u0438\u0433\u0430\u0442\u044c\u0441\u044f \u0434\u0430\u043b\u044c\u0448\u0435, \u043d\u0430\u043c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u0438\u0442\u044c Visual Studio \u0434\u043b\u044f \u043e\u0442\u043b\u0430\u0434\u043a\u0438 \u0440\u0435\u043b\u0438\u0437\u043d\u044b\u0445 \u0441\u0431\u043e\u0440\u043e\u043a.<\/p>\n<p>  \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0431\u0443\u0434\u0435\u043c VS 2013, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0434\u043b\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f SOS.dll \u043f\u0440\u0438\u0434\u0435\u0442\u0441\u044f \u0432\u043a\u043b\u044e\u0447\u0438\u0442\u044c compatibility mode:  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">Tools -&gt; Options -&gt; Debugging -&gt; General<\/b><\/p>\n<div class=\"spoiler_text\"><img decoding=\"async\" src=\"\/\/habrastorage.org\/files\/8a3\/9e4\/0fe\/8a39e40fe4104fe7845bc2707fa2f89c.png\"\/>  <\/div>\n<\/div>\n<p>  \u0414\u0430\u043b\u0435\u0435 <u>\u0441\u043d\u0438\u043c\u0435\u043c<\/u> \u0433\u0430\u043b\u043e\u0447\u043a\u0438 \u0437\u0434\u0435\u0441\u044c \u0436\u0435 \u0441:  <\/p>\n<ul>\n<li>Suppress JIT optimization on module load<\/li>\n<li>Enable Just My Code<\/li>\n<\/ul>\n<p>  \u0422\u0430\u043a\u0436\u0435 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0432\u043a\u043b\u044e\u0447\u0438\u0442\u044c \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0443 Native Debugging:<br \/>  <code>Project Settings -&gt; Debug -&gt; Enable native code debugging<\/code><br \/>  \u0422\u0435\u043f\u0435\u0440\u044c \u043f\u0440\u0438\u0441\u0442\u0443\u043f\u0438\u043c \u043a \u043d\u0430\u0448\u0438\u043c \u0438\u0441\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u044f\u043c.<\/p>\n<h3><font color=\"#2E74B5\">Interface dispatch stubs (Virtual Stub Dispatch)<\/font><\/h3>\n<p>  CLR \u043f\u043e\u0441\u0442\u043e\u044f\u043d\u043d\u043e \u043f\u0440\u043e\u0432\u043e\u0434\u0438\u0442 \u043c\u043e\u043d\u0438\u0442\u043e\u0440\u0438\u043d\u0433 \u0432\u0441\u0435\u0445 \u0443\u0447\u0430\u0441\u0442\u043a\u043e\u0432 \u043a\u043e\u0434\u0430. \u0418\u043c\u0435\u0435\u0442 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0441\u0442\u0440\u0430\u0442\u0435\u0433\u0438\u0439 \u043f\u043e \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u044e \u043d\u0430\u0442\u0438\u0432\u043d\u043e\u0433\u043e \u043a\u043e\u0434\u0430 \u043c\u0435\u0442\u043e\u0434\u043e\u0432. \u0418\u043c\u0435\u043d\u043d\u043e \u0442\u0430\u043a \u2013 \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e HotSpot \u0432 Java \u0438\u043c\u0435\u0435\u0442 \u0442\u0430\u043a\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b, \u0438\u043b\u0438 \u0436\u0435 \u0441\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 JS-\u0434\u0432\u0438\u0436\u043a\u0438.<\/p>\n<p>  \u0422\u0430\u043a\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b \u043f\u043e\u044f\u0432\u0438\u043b\u0441\u044f \u0432 CLR 2.0 \u0435\u0449\u0435 \u0432 2006 \u0433\u043e\u0434\u0443. \u0418\u2026\u043e\u0441\u0442\u0430\u043b\u0441\u044f \u0432\u043e \u043c\u043d\u043e\u0433\u043e\u043c \u0432 \u0442\u0430\u043a\u043e\u043c \u0436\u0435 \u0432\u0438\u0434\u0435 + \u043d\u043e\u0432\u044b\u0435 \u044d\u0432\u0440\u0438\u0441\u0442\u0438\u043a\u0438.<\/p>\n<p>  \u041e\u0441\u043e\u0431\u0435\u043d\u043d\u043e \u201c\u0431\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u201d \u0441\u0440\u0435\u0434\u0430 \u0441\u043b\u0435\u0434\u0438\u0442 \u0437\u0430 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0430\u043c\u0438.<br \/>  \u041d\u0430\u0434\u0435\u044e\u0441\u044c, \u0412\u044b \u0443\u0436\u0435 \u043d\u0430\u0441\u0442\u0440\u043e\u0438\u043b\u0438 \u0441\u0442\u0443\u0434\u0438\u044e \u0434\u043b\u044f \u0434\u0435\u0431\u0430\u0433\u0430 \u0440\u0435\u043b\u0438\u0437\u043d\u043e\u0433\u043e \u043a\u043e\u0434\u0430.  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0420\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043f\u0440\u0438\u043c\u0435\u0440:<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"cs\">class Program {     static void Main(string[] args)     {         ICallable target = new FirstCallableImpl();         CallInterface(target);          ICallable target2 = new SecondCallableImpl();         CallInterface(target2);     }      [MethodImpl(MethodImplOptions.NoInlining)]     private static void CallInterface(ICallable callable)     {         for (int i = 0; i &lt; 1000000; i++)         {             callable.DoSomething(); \/\/ place breakpoint         }     } }  interface ICallable {     void DoSomething(); }  class FirstCallableImpl : ICallable {     public void DoSomething()     {      } }  class SecondCallableImpl : ICallable {     public void DoSomething()     {      } } <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  \u0417\u0430\u043f\u0443\u0441\u0442\u0438\u043c \u043e\u0442\u043b\u0430\u0434\u043a\u0443. \u0414\u0430\u043b\u0435\u0435 \u043e\u0442\u043a\u0440\u043e\u0435\u043c \u043e\u043a\u043d\u043e Disassembly (Debug -&gt; Windows -&gt; Disassembly).<br \/>  <img decoding=\"async\" src=\"\/\/habrastorage.org\/files\/1e2\/bec\/ef1\/1e2becef17d344e68688e5d7fdba4ab0.png\"\/><\/p>\n<p>  \u0420\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u044e <code>call        dword ptr ds:[00450010h]<\/code>.<br \/>  \u0427\u0442\u043e\u0431\u044b \u0443\u0437\u043d\u0430\u0442\u044c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043f\u043e \u0430\u0434\u0440\u0435\u0441\u0443 0x00450010 \u043e\u0442\u043a\u0440\u043e\u0435\u043c \u043e\u043a\u043d\u043e \u043f\u0430\u043c\u044f\u0442\u0438 (Debug -&gt; Windows-&gt; Memory-&gt; Memory1).<br \/>  <img decoding=\"async\" src=\"\/\/habrastorage.org\/files\/329\/c79\/81d\/329c7981d3384160b03acdd61036dbb7.png\"\/><\/p>\n<p>  \u041d\u0430 \u0434\u0430\u043d\u043d\u043e\u043c \u044d\u0442\u0430\u043f\u0435 JIT \u0435\u0449\u0435 \u043d\u0435 \u0441\u043e\u0437\u0434\u0430\u043b \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0439 \u0443\u0437\u0435\u043b \u0432\u044b\u0437\u043e\u0432\u0430, \u043f\u043e\u043a\u0430 \u0447\u0442\u043e \u0441\u0440\u0435\u0434\u0430 \u0441\u0430\u043c\u0430 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442 \u00ab\u0438\u043d\u0442\u0435\u0440\u043f\u0440\u0435\u0442\u0430\u0446\u0438\u044e\u00bb \u0432\u044b\u0437\u043e\u0432\u0430 \u043c\u0435\u0442\u043e\u0434\u0430 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0430 (\u044d\u0442\u043e \u0437\u043d\u0430\u0447\u0438\u0442, \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u043b\u0438\u043d\u0435\u0439\u043d\u044b\u0439 \u043f\u043e\u0438\u0441\u043a \u0442\u0440\u0435\u0431\u0443\u0435\u043c\u043e\u0433\u043e \u043c\u0435\u0442\u043e\u0434\u0430 \u0432 \u0440\u0430\u043d\u0442\u0430\u0439\u043c\u0435).<\/p>\n<p>  \u041e\u0434\u043d\u0430\u043a\u043e \u043f\u043e\u0437\u0432\u043e\u043b\u0438\u043c \u0435\u0449\u0435 2 \u0440\u0430\u0437\u0430 \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u044c\u0441\u044f \u044d\u0442\u043e\u043c\u0443 \u043a\u043e\u0434\u0443 \u0438 \u0443\u0432\u0438\u0434\u0438\u043c, \u0447\u0442\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0430\u0434\u0440\u0435\u0441\u0430 <u>0x0450010<\/u> \u0438\u0437\u043c\u0435\u043d\u0438\u043b\u043e\u0441\u044c:<br \/>  <img decoding=\"async\" src=\"\/\/habrastorage.org\/files\/2a2\/997\/8f7\/2a29978f70ab4b66a92bf9adfe4ccf47.png\"\/><\/p>\n<p>  \u0414\u043b\u044f \u0438\u043d\u0441\u043f\u0435\u043a\u0446\u0438\u0438 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f 00457012 \u0437\u0430\u0433\u0440\u0443\u0437\u0438\u043c SOS.dll:<br \/>  <code>Immediate window -&gt; .load sos<\/code>  <\/p>\n<pre><code class=\"markdown\">!u 00457012 Unmanaged code 00457012 813908314400     cmp         dword ptr [ecx],443108h 00457018 0F85F32F0000     jne         0045A011 0045701E E9BD901D00       jmp         006300E0 <\/code><\/pre>\n<p>  \u0418\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u044f <code>jmp         006300E0<\/code> \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0441\u043e\u0431\u043e\u0439 \u0432\u044b\u0437\u043e\u0432 \u0442\u0440\u0435\u0431\u0443\u0435\u043c\u043e\u0433\u043e \u043c\u0435\u0442\u043e\u0434\u0430 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0430. \u041f\u0440\u043e\u0432\u0435\u0440\u0438\u043c:  <\/p>\n<pre><code class=\"markdown\">!u 006300E0 Normal JIT generated code ConsoleApplication1.FirstCallableImpl.DoSomething() Begin 006300e0, size 1 &gt;&gt;&gt; 006300E0 C3               ret <\/code><\/pre>\n<p>  \u0422\u0430\u043a\u2026 \u0421 \u043c\u0435\u0442\u043e\u0434\u043e\u043c \u043f\u043e\u043d\u044f\u0442\u043d\u043e, \u043d\u043e \u0447\u0442\u043e \u0436\u0435 \u0437\u0430 \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0435 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0432 \u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0438 <code>cmp         dword ptr [ecx],443108h<\/code>?  <\/p>\n<pre><code class=\"markdown\">!DumpMT 443108 EEClass: 00441378 Module: 00442c5c Name: ConsoleApplication1.FirstCallableImpl mdToken: 02000004  (C:\\*path to project*\\InterfaceStubsTest.exe) BaseSize: 0xc ComponentSize: 0x0 Number of IFaces in IFaceMap: 1 Slots in VTable: 6 <\/code><\/pre>\n<p>  \u0410\u0433\u0430! \u0421\u0440\u0430\u0432\u043d\u0438\u0432\u0430\u0435\u043c <b>this<\/b> \u043d\u0430 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0438\u0435 \u0442\u0438\u043f\u0443 <i>FirstCallableImpl<\/i>(\u0442.\u0435. MethodTable) \u0438 \u043f\u0440\u0438 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0438 <b>true<\/b> \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u043c \u043c\u0435\u0442\u043e\u0434 <i>FirstCallableImpl.DoSomething<\/i>().<br \/>  \u0418\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u044f <code>jne         0045A011<\/code> \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0441\u043e\u0431\u043e\u0439 fallback \u043d\u0430 \u043b\u0438\u043d\u0435\u0439\u043d\u044b\u0439 \u043f\u043e\u0438\u0441\u043a, \u043a\u0430\u043a \u0438 \u0431\u044b\u043b\u043e \u0434\u043e \u043a\u044d\u0448\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f.<\/p>\n<p>  \u041a\u043e\u0433\u0434\u0430 \u0434\u0435\u043b\u043e \u0434\u043e\u0439\u0434\u0435\u0442 \u0434\u043e \u0432\u044b\u0437\u043e\u0432\u0430 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0433\u043e \u0442\u0438\u043f\u0430 \u2014 <i>SecondCallableImpl<\/i>, \u0442\u043e \u0432\u0441\u0435 \u0442\u0430\u043a \u0436\u0435 \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0442\u044c\u0441\u044f \u0432 \u0443\u0437\u043b\u0435 \u0432\u044b\u0437\u043e\u0432\u0430 \u0438\u043c\u0435\u043d\u043d\u043e FirstCallableImpl, \u0430 \u043d\u0435 SecondCallableImpl. <\/p>\n<p>  \u041d\u043e \u044d\u0442\u043e \u0436\u0435 \u043d\u0435\u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u043e! \u0418\u043c\u0435\u043d\u043d\u043e \u043f\u043e\u044d\u0442\u043e\u043c\u0443, \u043f\u043e \u0434\u043e\u0441\u0442\u0438\u0436\u0435\u043d\u0438\u044e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u043e\u0433\u043e \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0430 \u0438\u0442\u0435\u0440\u0430\u0446\u0438\u0439 \u0432\u044b\u0437\u043e\u0432\u0430 \u043a\u043e\u0434\u0430, \u0441\u0440\u0435\u0434\u0430 \u043f\u0440\u043e\u0441\u0442\u043e \u0437\u0430\u043c\u0435\u043d\u0438\u0442 \u0434\u0430\u043d\u043d\u044b\u0439 \u0443\u0437\u0435\u043b \u0432\u044b\u0437\u043e\u0432\u0430 \u0441 \u043a\u044d\u0448\u0435\u043c \u043d\u0430 (\u043a\u0430\u043a \u0412\u044b \u0443\u0436\u0435 \u0434\u043e\u0433\u0430\u0434\u0430\u043b\u0438\u0441\u044c) \u043b\u0438\u043d\u0435\u0439\u043d\u044b\u0439 \u043f\u043e\u0438\u0441\u043a.  <\/p>\n<blockquote><p>\u041a\u044d\u0448\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0432\u0435\u0441\u044c\u043c\u0430 \u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u043e, \u0435\u0441\u043b\u0438 \u043c\u044b \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u043c \u043c\u0435\u0442\u043e\u0434\u044b \u0443 \u043a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u0439, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440.<\/p><\/blockquote>\n<p>  <\/p>\n<h3><font color=\"#2E74B5\">Generic types stubs<\/font><\/h3>\n<p>  \u0412\u044b\u0445\u043e\u0434 CLR 2.0 \u0432\u043c\u0435\u0441\u0442\u0435 \u0441 generics \u043e\u0437\u043d\u0430\u043c\u0435\u043d\u043e\u0432\u0430\u043b \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0435 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0432 \u0441\u0440\u0435\u0434\u0435 \u0438\u0441\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f. \u0415\u0441\u043b\u0438 \u0434\u043e \u044d\u0442\u043e\u0433\u043e \u0434\u043b\u044f \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u044f \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e\u0433\u043e \u0442\u0438\u043f\u0430 \u201c\u0445\u0432\u0430\u0442\u0430\u043b\u043e\u201d \u043b\u0438\u0448\u044c \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b <b>EEClass<\/b>, \u0442\u043e \u0442\u0435\u043f\u0435\u0440\u044c \u0441\u0432\u044f\u0437\u043a\u0430 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 <b>EEClass+MethodTable<\/b> \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0441\u043e\u0431\u043e\u0439 \u0442\u0435\u043a\u0443\u0449\u0438\u0439 \u0442\u0438\u043f.<\/p>\n<p>  \u0411\u043e\u043b\u0435\u0435 \u0442\u043e\u0433\u043e, \u0434\u043b\u044f List&#038;ltstring&#038;gt \u0438 List&#038;ltint&#038;gt \u0440\u0430\u0437\u043d\u044b\u043c\u0438 \u0431\u0443\u0434\u0443\u0442 \u0434\u0430\u0436\u0435 EEClass (\u043f\u0440\u043e code-sharing \u0431\u0443\u0434\u0435\u0442 \u0447\u0443\u0442\u044c \u043d\u0438\u0436\u0435).  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0420\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043f\u0440\u0438\u043c\u0435\u0440:<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"cs\">class Program {     static void Main(string[] args)     {         var refTypeHolder = new HolderOf&lt;object&gt;(null);         var intTypeHolder = new HolderOf&lt;int&gt;(0);          \/\/ call JIT         refTypeHolder.GetPointer();         intTypeHolder.GetPointer();          Console.Read(); \/\/ place breakpoint     } }  class HolderOf&lt;T&gt; {     private readonly T _pointer;      public HolderOf(T pointer)     {         _pointer = pointer;     }      public T GetPointer()     {         return _pointer;     } } <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  \u0414\u043b\u044f \u0438\u043d\u0441\u043f\u0435\u043a\u0446\u0438\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u043a\u043e\u043c\u0430\u043d\u0434\u0443 <code>!dumpheap<\/code>:  <\/p>\n<pre><code class=\"markdown\">.load sos.dll  !dumpheap -type HolderOf PDB symbol for mscorwks.dll not loaded  Address       MT     Size 02d332c8 00f531e0       12      02d332d4 00f53268       12      total 2 objects Statistics:       MT    Count    TotalSize Class Name 00f53268        1           12 ConsoleApplication1.HolderOf`1[[System.Int32, mscorlib]] 00f531e0        1           12 ConsoleApplication1.HolderOf`1[[System.Object, mscorlib]] Total 2 objects <\/code><\/pre>\n<p>  \u041a\u0430\u043a \u043c\u044b \u0432\u0438\u0434\u0438\u043c, \u0441\u0440\u0435\u0434\u0430 \u0441\u043e\u0437\u0434\u0430\u043b\u0430 \u0434\u0432\u0435 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0435 \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043a\u043b\u0430\u0441\u0441\u0430 <code>HolderOf&lt;T&gt;<\/code>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">!dumpmt -md 00f53268 (HolderOf&lt;int&gt;)<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"markdown\">!dumpmt -md 00f53268 EEClass: 00f514cc Module: 00f52c5c Name: ConsoleApplication1.HolderOf`1[[System.Int32, mscorlib]] mdToken: 02000006  (C:\\*path to samples*\\InterfaceStubsTest.exe) BaseSize: 0xc ComponentSize: 0x0 Number of IFaces in IFaceMap: 0 Slots in VTable: 6 -------------------------------------- MethodDesc Table    Entry MethodDesc      JIT Name 66ae6a30   66964968   PreJIT System.Object.ToString() 66ae6a50   66964970   PreJIT System.Object.Equals(System.Object) 66ae6ac0   669649a0   PreJIT System.Object.GetHashCode() 66b57940   669649c4   PreJIT System.Object.Finalize() 00f5c088   00f53250      JIT ConsoleApplication1.HolderOf`1[[System.Int32, mscorlib]]..ctor(Int32) 00f5c090   00f5325c     NONE ConsoleApplication1.HolderOf`1[[System.Int32, mscorlib]].GetPointer() <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">!dumpmt -md 00f531e0 (HolderOf&lt;object&gt;)<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"markdown\">!dumpmt -md 00f531e0 EEClass: 00f51438 Module: 00f52c5c Name: ConsoleApplication1.HolderOf`1[[System.Object, mscorlib]] mdToken: 02000006  (C:\\*path to samples*\\InterfaceStubsTest.exe) BaseSize: 0xc ComponentSize: 0x0 Number of IFaces in IFaceMap: 0 Slots in VTable: 6 -------------------------------------- MethodDesc Table    Entry MethodDesc      JIT Name 66ae6a30   66964968   PreJIT System.Object.ToString() 66ae6a50   66964970   PreJIT System.Object.Equals(System.Object) 66ae6ac0   669649a0   PreJIT System.Object.GetHashCode() 66b57940   669649c4   PreJIT System.Object.Finalize() 00f5c068   00f53154      JIT ConsoleApplication1.HolderOf`1[[System.__Canon, mscorlib]]..ctor(System.__Canon) 00f5c070   00f53160     NONE ConsoleApplication1.HolderOf`1[[System.__Canon, mscorlib]].GetPointer() <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  \u0412 \u0432\u044b\u0448\u0435\u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u043d\u043e\u043c \u0434\u0430\u043c\u043f\u0435, \u043d\u0430\u0441 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u0443\u0435\u0442 <b><code>HolderOf&lt;T&gt;.GetPointer()<\/code><\/b>. \u0420\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c:  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">!dumpmd 00f5325c (HolderOf&lt;int&gt;.GetPointer())<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"markdown\">!dumpmd 00f5325c Method Name: ConsoleApplication1.HolderOf`1[[System.Int32, mscorlib]].GetPointer() Class: 00f514cc MethodTable: 00f53268 mdToken: 0600000b Module: 00f52c5c IsJitted: yes CodeAddr: 01090318 <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">!dumpmd 00f53160 (HolderOf&lt;object&gt;.GetPointer())<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"markdown\">!dumpmd 00f53160 Method Name: ConsoleApplication1.HolderOf`1[[System.__Canon, mscorlib]].GetPointer() Class: 00f51438 MethodTable: 00f53178 mdToken: 0600000b Module: 00f52c5c IsJitted: yes CodeAddr: 010902b8 <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  <\/p>\n<table>\n<tr>\n<th><\/th>\n<th>HolderOf&#038;ltobject&#038;gt<\/th>\n<th>HolderOf&#038;ltint&#038;gt<\/th>\n<\/tr>\n<tr>\n<td>MethodDesc<\/td>\n<td>00f53160<\/td>\n<td>00f5325c<\/td>\n<\/tr>\n<tr>\n<td>CodeAddr<\/td>\n<td>01090318<\/td>\n<td>010902b8<\/td>\n<\/tr>\n<tr>\n<td>Initiation type<\/td>\n<td>HolderOf`1[[System.__Canon, mscorlib]]<\/td>\n<td>HolderOf`1[[System.Int32, mscorlib]]<\/td>\n<\/tr>\n<\/table>\n<p>  \u0418\u0442\u0430\u043a, \u043c\u044b \u0432\u0438\u0434\u0438\u043c, \u0447\u0442\u043e \u043e\u0442\u043b\u0438\u0447\u0430\u044e\u0442\u0441\u044f \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e Methodtable, \u043d\u043e \u0438 \u043d\u0430\u0442\u0438\u0432\u043d\u044b\u0439 \u043a\u043e\u0434 (CodeAddr).<\/p>\n<p>  \u0410 \u0442\u0435\u043f\u0435\u0440\u044c \u0441\u0430\u043c\u043e\u0435 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e\u0435 \u2013 \u043a\u0443\u0434\u0430 \u0434\u0435\u043b\u0441\u044f <b>System.Object<\/b> \u0434\u043b\u044f Holderof&#038;ltobject&#038;gt ?! \u0427\u0442\u043e \u0437\u0430 <b>System.__Canon<\/b>?<br \/>  \u0417\u043d\u0430\u043a\u043e\u043c\u044c\u0442\u0435\u0441\u044c:  <\/p>\n<pre><code class=\"cs\">[Serializable()] [ClassInterface(ClassInterfaceType.AutoDual)] [ComVisible(true)] internal class __Canon { } <\/code><\/pre>\n<p>  <\/p>\n<blockquote><p>\u0415\u0441\u043b\u0438 \u043a\u0440\u0430\u0442\u043a\u043e, \u0442\u043e \u043e\u0431\u044b\u0447\u043d\u043e \u0433\u043e\u0432\u043e\u0440\u044f\u0442, \u0447\u0442\u043e \u0434\u043b\u044f \u0441\u0441\u044b\u043b\u043e\u0447\u043d\u044b\u0445 \u0442\u0438\u043f\u043e\u0432 \u0441\u0440\u0435\u0434\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u0442\u0438\u043f System.__Canon \u0434\u043b\u044f \u0448\u0430\u0440\u0438\u043d\u0433\u0430 \u043a\u043e\u0434\u0430.<br \/>  <b><u>\u041d\u043e \u043d\u0435 \u0432 \u044d\u0442\u043e\u043c \u0434\u0435\u043b\u043e. \u0421\u0435\u0440\u044c\u0435\u0437\u043d\u043e.<\/u><\/b><\/p><\/blockquote>\n<p>  \u0414\u0435\u043b\u043e \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e generic-\u0442\u0438\u043f\u044b \u043c\u043e\u0433\u0443\u0442 \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442\u044c \u0446\u0438\u043a\u043b\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u0434\u0440\u0443\u0433\u0438\u0445 \u0442\u0438\u043f\u043e\u0432, \u0447\u0442\u043e \u0447\u0440\u0435\u0432\u0430\u0442\u043e \u0431\u0435\u0441\u043a\u043e\u043d\u0435\u0447\u043d\u044b\u043c \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435\u043c \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0439 \u0434\u043b\u044f \u043a\u043e\u0434\u0430. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440:  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">Generics cyclomatic dependencies<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"cs\">class GenericClassOne&lt;T&gt; {     private T field; }  class GenericClassTwo&lt;U&gt; {     private GenericClassThree&lt;GenericClassOne&lt;U&gt;&gt; field }  class GenericClassThree&lt;S&gt; {     private GenericClassTwo&lt;GenericClassOne&lt;S&gt;&gt; field } class Program {     static void Main(string[] args)     {         Console.WriteLine((new GenericClassTwo&lt;object&gt;()).ToString());         Console.Read();     } } <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  \u041e\u0434\u043d\u0430\u043a\u043e \u044d\u0442\u043e\u0442 \u043a\u043e\u0434 \u043d\u0435 \u0443\u043f\u0430\u0434\u0435\u0442 \u0438 \u0432\u044b\u0432\u0435\u0434\u0435\u0442 <b>GenericClassTwo`1[System.Object]<\/b>.<\/p>\n<p>  <i> \u2014 \u0422\u0430\u043a \u0438 \u0447\u0442\u043e \u0442\u0430\u043c \u043f\u0440\u043e \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u0431\u044b\u043b\u043e? (\u043f\u0440\u0438\u043c\u0435\u0447\u0430\u043d\u0438\u0435: \u043c\u044b\u0441\u043b\u0438 \u0432\u0441\u043b\u0443\u0445).<\/i><\/p>\n<p>  <b>Type loader<\/b> (\u043e\u043d \u0436\u0435 \u0437\u0430\u0433\u0440\u0443\u0437\u0447\u0438\u043a \u0442\u0438\u043f\u043e\u0432) \u0441\u043a\u0430\u043d\u0438\u0440\u0443\u0435\u0442 \u043a\u0430\u0436\u0434\u044b\u0439 generic-\u0442\u0438\u043f \u043d\u0430 \u043d\u0430\u043b\u0438\u0447\u0438\u0435 \u0446\u0438\u043a\u043b\u0438\u0447\u0435\u0441\u043a\u043e\u0439 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u0438 \u043f\u0440\u0438\u0441\u0432\u0430\u0438\u0432\u0430\u0435\u0442 \u043e\u0447\u0435\u0440\u0435\u0434\u043d\u043e\u0441\u0442\u044c (\u0442.\u043d. LoadLevel \u0434\u043b\u044f \u043a\u043b\u0430\u0441\u0441\u0430). \u0425\u043e\u0442\u044f \u0432\u0441\u0435 \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0434\u043b\u044f ref-types \u0438\u043c\u0435\u044e\u0442 System.__Canon \u043a\u0430\u043a \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442 \u0442\u0438\u043f\u0430 \u2014 \u044d\u0442\u043e \u0441\u043b\u0435\u0434\u0441\u0442\u0432\u0438\u0435, \u0430 \u043d\u0435 \u043f\u0440\u0438\u0447\u0438\u043d\u0430.<\/p>\n<p>  \u0424\u0430\u0437\u044b \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438 (\u043e\u043d\u0438 \u0436\u0435 ClassLoadLevel):  <\/p>\n<pre><code class=\"cpp\">enum ClassLoadLevel {     CLASS_LOAD_BEGIN,     CLASS_LOAD_UNRESTOREDTYPEKEY,     CLASS_LOAD_UNRESTORED,       CLASS_LOAD_APPROXPARENTS,     CLASS_LOAD_EXACTPARENTS,     CLASS_DEPENDENCIES_LOADED,     CLASS_LOADED,     CLASS_LOAD_LEVEL_FINAL = CLASS_LOADED, }; <\/code><\/pre>\n<p>  \u0414\u043b\u044f SSLCI (Rotor) \u043a\u043e\u0434, \u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0439 \u0437\u0430 \u0441\u043a\u0430\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0432 \u0444\u0430\u0439\u043b\u0435 <code>sscli20\/clr\/src\/vm\/Generics.cpp<\/code>:  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">Generics.cpp<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"cpp\">BOOL Generics::CheckInstantiationForRecursion(const unsigned int nGenericClassArgs, const TypeHandle pGenericArgs[]) {     CONTRACTL     {         NOTHROW;         GC_NOTRIGGER;     }     CONTRACTL_END;          if (nGenericClassArgs == 0)         return TRUE;       _ASSERTE(pGenericArgs);       struct PerIterationData {         const TypeHandle * genArgs;         int index;         int numGenArgs;     };          PerIterationData stack[MAX_GENERIC_INSTANTIATION_DEPTH];     stack[0].genArgs = pGenericArgs;     stack[0].numGenArgs = nGenericClassArgs;     stack[0].index = 0;     int curDepth = 0;       \/\/ Walk over each instantiation, doing a depth-first search looking for any     \/\/ instantiation with a depth of over 100, in an attempt at flagging      \/\/ recursive type definitions.  We're doing this to help avoid a stack      \/\/ overflow in the loader.       \/\/ Avoid recursion here, to avoid a stack overflow.  Also, this code     \/\/ doesn't allocate memory.     while(curDepth &gt;= 0) {         PerIterationData * cur = &stack[curDepth];         if (cur-&gt;index == cur-&gt;numGenArgs) {             \/\/ Pop             curDepth--;             if (curDepth &gt;= 0)                 stack[curDepth].index++;             continue;         }         if (cur-&gt;genArgs[cur-&gt;index].HasInstantiation()) {             \/\/ Push             curDepth++;             if (curDepth &gt;= MAX_GENERIC_INSTANTIATION_DEPTH)                 return FALSE;             stack[curDepth].genArgs = cur-&gt;genArgs[cur-&gt;index].GetInstantiation();             stack[curDepth].numGenArgs = cur-&gt;genArgs[cur-&gt;index].GetNumGenericArgs();             stack[curDepth].index = 0;             continue;         }                  \/\/ Continue to the next item         cur-&gt;index++;     }     return TRUE; } <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  \u0414\u043b\u044f CoreCLR \u043a\u043e\u0434 <a href=\"https:\/\/github.com\/dotnet\/coreclr\/blob\/master\/src\/vm\/generics.cpp\">\u0438\u0437\u043c\u0435\u043d\u0438\u043b\u0441\u044f<\/a> \u0432 \u0441\u0442\u043e\u0440\u043e\u043d\u0443 \u041e\u041e\u041f \ud83d\ude42<\/p>\n<p>  \u0418\u0442\u0430\u043a, \u0440\u0430\u0437\u043e\u0431\u0440\u0430\u043b\u0438\u0441\u044c: \u0441\u0441\u044b\u043b\u043e\u0447\u043d\u044b\u0435 \u0442\u0438\u043f\u044b \u0438\u043c\u0435\u044e\u0442 \u0448\u0430\u0440\u0438\u043d\u0433 \u043a\u043e\u0434\u0430, \u0437\u043d\u0430\u0447\u0438\u043c\u044b\u0435 \u2013 \u043d\u0435\u0442\u2026 \u0410 \u043f\u043e\u0447\u0435\u043c\u0443? <br \/>  \u0415\u0441\u043b\u0438 \u0432\u0441\u0435 \u0441\u0432\u043e\u0434\u0438\u0442\u0441\u044f \u043a \u0440\u0430\u0437\u043c\u0435\u0440\u0443 \u0442\u0438\u043f\u0430 (ref \u2013 \u0440\u0430\u0437\u043c\u0435\u0440 \u0441\u043b\u043e\u0432\u0430; In32 \u2013 4 \u0431\u0430\u0439\u0442\u0430, double \u2013 8 \u0431\u0430\u0439\u0442 \u0438 \u0442.\u0434.), \u0442\u043e\u0433\u0434\u0430 \u043c\u043e\u0436\u043d\u043e \u0434\u043b\u044f DateTime \u0438 long \u0440\u0430\u0441\u0448\u0430\u0440\u0438\u0442\u044c. <\/p>\n<p>  \u0412\u043e-\u043f\u0435\u0440\u0432\u044b\u0445, \u044d\u0442\u043e \u043d\u0435\u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e \u0441 \u0442\u043e\u0447\u043a\u0438 \u0437\u0440\u0435\u043d\u0438\u044f \u0441\u0435\u043c\u0430\u043d\u0442\u0438\u043a\u0438. \u0412\u043e-\u0432\u0442\u043e\u0440\u044b\u0445, \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0438 CLR \u0440\u0435\u0448\u0438\u043b\u0438 \u044d\u0442\u043e\u0433\u043e \u043d\u0435 \u0434\u0435\u043b\u0430\u0442\u044c.<\/p>\n<h3><font color=\"#2E74B5\">Generic method stubs<\/font><\/h3>\n<p>  \u041c\u044b \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0435\u043b\u0438 \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e \u043a\u043e\u0434\u0430 \u0434\u043b\u044f generic-\u0442\u0438\u043f\u043e\u0432, \u0430 \u043a\u0430\u043a \u043d\u0430\u0441\u0447\u0435\u0442 \u043c\u0435\u0442\u043e\u0434\u043e\u0432? \u041a\u0430\u043a \u043d\u0430\u0439\u0442\u0438 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0435 \u043c\u0435\u0442\u043e\u0434\u044b \u0432\u043d\u0435 \u043a\u043b\u0430\u0441\u0441\u0430?<br \/>  \u0420\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043f\u0440\u0438\u043c\u0435\u0440:  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">Generic methods<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"cs\">class Program {     static void Main(string[] args)     {         var refTypeHolder = new HolderOf();                  Test(refTypeHolder);         Test2(refTypeHolder);         Console.Read();     }      [MethodImpl(MethodImplOptions.NoInlining)]     static void Test(HolderOf typeHolder)     {         for (int i = 0; i &lt; 10; i++)         {             typeHolder.GetPointer&lt;Program&gt;();         }     } \/\/ place breakpoint      [MethodImpl(MethodImplOptions.NoInlining)]     static void Test2(HolderOf typeHolder)     {         for (int i = 0; i &lt; 10; i++)         {             typeHolder.GetPointer&lt;object&gt;();         }     } \/\/ place breakpoint }  class HolderOf {     [MethodImpl(MethodImplOptions.NoInlining)]     public void GetPointer&lt;T&gt;()     {         Console.WriteLine(typeof(T));     } } <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  \u0412 \u0442\u043e\u0447\u043a\u0435 \u043e\u0441\u0442\u0430\u043d\u043e\u0432\u0430 \u0432 \u043e\u043a\u043d\u0435 Disassembly \u0434\u043b\u044f \u043c\u0435\u0442\u043e\u0434\u0430 Test() \u043c\u043e\u0436\u043d\u043e \u0443\u0432\u0438\u0434\u0435\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0435:  <\/p>\n<pre><code class=\"markdown\">00000045  mov         ecx,dword ptr [ebp-3Ch]  00000048  mov         edx,10031B8h  0000004d  cmp         dword ptr [ecx],ecx  0000004f  call        FFE8BF40  <\/code><\/pre>\n<p>  \u0410 \u0434\u043b\u044f Test2() \u2014 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0435:  <\/p>\n<pre><code class=\"markdown\">00000045  mov         ecx,dword ptr [ebp-3Ch]  00000048  mov         edx,1003574h  0000004d  cmp         dword ptr [ecx],ecx  0000004f  call        FFE8BE40  <\/code><\/pre>\n<p>  <\/p>\n<blockquote><p>\u0420\u0435\u0433\u0438\u0441\u0442\u0440 <b>ECX<\/b> \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044c \u043d\u0430 this (calling convention \u2014 FastCall), \u043d\u043e \u0432\u0435\u0434\u044c GetPointer() \u0438\u043c\u0435\u0435\u0442 \u043d\u043e\u043b\u044c \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u043e\u0432, \u0447\u0442\u043e \u0436\u0435 \u0442\u043e\u0433\u0434\u0430 \u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0432 <b>EDX<\/b>?!<\/p><\/blockquote>\n<p>  \u0418\u0441\u0441\u043b\u0435\u0434\u0443\u0435\u043c:  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">!dumpmd 10031B8 (from Test())<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"markdown\">Method Name: ConsoleApplication1.HolderOf.GetPointer[[ConsoleApplication1.Program, InterfaceStubsTest]]() Class: 01001444 MethodTable: 01003118 mdToken: 0600000e Module: 01002c5c IsJitted: no CodeAddr: ffffffffffffffff <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">!dumpmd 1003574 (from Test2())<\/b><\/p>\n<div class=\"spoiler_text\">!dumpmd 1003574<br \/>  Method Name: ConsoleApplication1.HolderOf.GetPointer[[System.Object, mscorlib]]()<br \/>  Class: 01001444<br \/>  MethodTable: 01003118<br \/>  mdToken: 0600000e<br \/>  Module: 01002c5c<br \/>  IsJitted: no<br \/>  CodeAddr: ffffffffffffffff  <\/div>\n<\/div>\n<p>  \u0410\u0433\u0430! \u043f\u0435\u0440\u0435\u0434\u0430\u0435\u0442\u0441\u044f \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 <b>MethodDesc<\/b>, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0432 \u0441\u0435\u0431\u0435 \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044c \u043d\u0430 MethodTable (\u0445\u043e\u0447\u0443 \u0437\u0430\u043c\u0435\u0442\u0438\u0442\u044c \u2014 \u043e\u0431\u0430 \u0434\u0435\u0441\u043a\u0440\u0438\u043f\u0442\u043e\u0440\u0430 \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u044e\u0442 \u043d\u0430 \u043e\u0434\u0438\u043d \u0438 \u0442\u043e\u0442 \u0436\u0435 MethodTable <u>0x01003118<\/u>) \u0438 \u0441\u043b\u0443\u0436\u0438\u0442 \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a\u043e\u043c \u043c\u0435\u0442\u0430\u0434\u0430\u043d\u043d\u044b\u0445.<\/p>\n<p>  \u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u043f\u0440\u0438 \u0432\u044b\u0437\u043e\u0432\u0435 generic-\u043c\u0435\u0442\u043e\u0434\u043e\u0432, \u043f\u0435\u0440\u0435\u0434\u0430\u0435\u0442\u0441\u044f \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 \u0441 MethodDesc.<br \/>  \u0421\u0430\u043c\u0438 \u0430\u0434\u0440\u0435\u0441\u0430 <u>FFE8BF40<\/u> \u0438 <u>FFE8BE40<\/u> \u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u0442\u0440\u0430\u043c\u043f\u043b\u0438\u043d\u043e\u043c, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043e\u0442\u0434\u0430\u0435\u0442 (forward) \u0440\u0435\u0430\u043b\u044c\u043d\u044b\u0439 \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 (\u0434\u043b\u044f int, object \u0438 \u0442.\u0434.) \u043d\u0430\u0442\u0438\u0432\u043d\u044b\u0439 \u043a\u043e\u0434.<\/p>\n<p>  \u0422.\u043a. \u0441\u0430\u043c \u0434\u0435\u0441\u043a\u0440\u0438\u043f\u0442\u043e\u0440 \u0442\u0430\u043a\u0436\u0435 \u0445\u0440\u0430\u043d\u0438\u0442 \u0432 \u0441\u0435\u0431\u0435 generic-\u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b, \u0442\u043e \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442\u0441\u044f \u0435\u0449\u0435 \u0438 \u044d\u043a\u043e\u043d\u043e\u043c\u0438\u044f \u043d\u0430 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0435 \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0435\u043c\u044b\u0445 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u043e\u0432 \u0432 \u0441\u043b\u0443\u0447\u0430\u0435, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u0445 generic-\u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432 <u>Some&#038;ltT, TU, TResult&#038;gt()<\/u>.<\/p>\n<div class=\"clear\"><\/div>\n<p> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"http:\/\/habrahabr.ru\/post\/253105\/\"> http:\/\/habrahabr.ru\/post\/253105\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>     \t\u041f\u0440\u043e\u0434\u043e\u043b\u0436\u0430\u044f <a href=\"http:\/\/habrahabr.ru\/post\/248775\/\">\u0442\u0435\u043c\u0443 JIT-\u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u0438<\/a> .NET&#8217;a, \u0441\u0435\u0433\u043e\u0434\u043d\u044f \u043c\u044b \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0434\u0438\u0441\u043f\u0435\u0442\u0447\u0435\u0440\u0438\u0437\u0430\u0446\u0438\u044e \u043c\u0435\u0442\u043e\u0434\u043e\u0432 \u0443 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u043e\u0432, generics (\u043a\u0430\u043a \u043a\u043b\u0430\u0441\u0441\u043e\u0432, \u0442\u0430\u043a \u0438 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0445 \u043c\u0435\u0442\u043e\u0434\u043e\u0432 \u0432\u043c\u0435\u0441\u0442\u0435 \u0441 \u0440\u0435\u0430\u043b\u044c\u043d\u044b\u043c\u0438 \u0441\u0438\u0433\u043d\u0430\u0442\u0443\u0440\u0430\u043c\u0438); \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u044c \u043e\u0442\u043b\u0430\u0434\u043a\u0443 \u0440\u0435\u043b\u0438\u0437\u043d\u044b\u0445 \u0441\u0431\u043e\u0440\u043e\u043a \u0441 \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u044f\u043c\u0438; \u0440\u0430\u0437\u0431\u0435\u0440\u0435\u043c\u0441\u044f \u0441 \u0438\u0441\u0442\u0438\u043d\u043d\u044b\u043c \u043f\u0440\u0435\u0434\u043d\u0430\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435\u043c \u0442\u0438\u043f\u0430 System.__Canon (\u044d\u0442\u043e \u043d\u0435 \u0442\u043e, \u0447\u0442\u043e \u0412\u044b \u043f\u043e\u0434\u0443\u043c\u0430\u043b\u0438).  <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-253094","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/253094","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=253094"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/253094\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=253094"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=253094"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=253094"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}