<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.msdn.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>JIT, NGen, and other Managed Code Generation Stuff</title><link>http://blogs.msdn.com/b/clrcodegeneration/</link><description /><dc:language>en-US</dc:language><generator>Telligent Evolution Platform Developer Build (Build: 5.6.50428.7875)</generator><item><title>JIT ETW Tail Call Event Fail Reasons</title><link>http://blogs.msdn.com/b/clrcodegeneration/archive/2010/05/07/jit-etw-tail-call-event-fail-reasons.aspx</link><pubDate>Fri, 07 May 2010 21:48:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10009397</guid><dc:creator>Grant Richins</dc:creator><slash:comments>5</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.msdn.com/b/clrcodegeneration/rsscomments.aspx?WeblogPostID=10009397</wfw:commentRss><comments>http://blogs.msdn.com/b/clrcodegeneration/archive/2010/05/07/jit-etw-tail-call-event-fail-reasons.aspx#comments</comments><description>&lt;P&gt;This is a follow-up post&amp;nbsp; for &lt;A href="http://blogs.msdn.com/clrcodegeneration/archive/2009/05/11/jit-etw-tracing-in-net-framework-4.aspx" mce_href="http://blogs.msdn.com/clrcodegeneration/archive/2009/05/11/jit-etw-tracing-in-net-framework-4.aspx"&gt;JIT ETW tracing in .NET Framework 4&lt;/A&gt;.&amp;nbsp; These are some of the possible strings that might show up in the FailReason field of the MethodJitTailCallFailed event.&amp;nbsp; These are reasons that come from or are checked for by the VM (as compared to the JIT) and are listed in no particular order:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;"Caller is ComImport .cctor" - This means the caller is a static class constructor for a type which has a base type somewhere in the class hierarchy marked with the &lt;A href="http://msdn.microsoft.com/en-us/library/system.runtime.interopservices.comimportattribute(VS.100).aspx" mce_href="http://msdn.microsoft.com/en-us/library/system.runtime.interopservices.comimportattribute(VS.100).aspx"&gt;ComImportAttribute&lt;/A&gt;. This is caused by an implementation choice within the runtime for managed objects that effectively derive from native COM objects. You must remove the attribute if you want to perform a tail call.&lt;/LI&gt;
&lt;LI&gt;&lt;A title=declarative_security name=declarative_security&gt;&lt;/A&gt;"Caller has declarative security" - This means the caller has a &lt;A href="http://msdn.microsoft.com/en-us/library/kaacwy28.aspx" mce_href="http://msdn.microsoft.com/en-us/library/kaacwy28.aspx"&gt;declarative security&lt;/A&gt; attribute applied to it (usually an Assert or a Demand, but Deny and PermitOnly also prevent tail calls).&amp;nbsp; The current implementation relies on the caller remaining on the stack to enforce the security attribute.&amp;nbsp; You must remove the attribute from the caller, if you want to perform a tail call.&lt;/LI&gt;
&lt;LI&gt;"Different security" - The caller and callee have different permissions, and the one with the ‘lower' permissions must remain on the stack. Since comparing permissions is expensive, we simplify it to Full Trust and non-Full Trust. Full Trust code can do anything, including tail calls. One other special case is &lt;A href="http://msdn.microsoft.com/en-us/library/system.appdomain.ishomogenous.aspx" mce_href="http://msdn.microsoft.com/en-us/library/system.appdomain.ishomogenous.aspx"&gt;homogenous appdomains&lt;/A&gt;, where everything in the appdomain has the same permissions, so even if the callee is unknown (due to virtual or indirect calls), the callee must have the same permissions as the caller. If you want to do a tail call, use a homogenous appdomain, grant the caller Full Trust, or put the caller and the callee in the same assembly and make sure it is a direct call.&lt;/LI&gt;
&lt;LI&gt;"Caller is the entry point" - If there is no "tail." instruction prefix, the JIT is not allowed to generate a tail call from a method marked as the &lt;A href="http://msdn.microsoft.com/en-us/library/system.reflection.assembly.entrypoint.aspx" mce_href="http://msdn.microsoft.com/en-us/library/system.reflection.assembly.entrypoint.aspx"&gt;entrypoint&lt;/A&gt; for a module. The idea is that programers like to see their Main method at the bottom of the stack always. There is no way around this restriction.&lt;/LI&gt;
&lt;LI&gt;"Caller is marked as no inline" - If there is no "tail." instruction prefix and the caller is explicitly marked with &lt;A href="http://msdn.microsoft.com/en-us/library/system.runtime.compilerservices.methodimploptions.aspx" mce_href="http://msdn.microsoft.com/en-us/library/system.runtime.compilerservices.methodimploptions.aspx"&gt;MethodImplOptions.NoInlining&lt;/A&gt;, then the VM assumes the programmer really wants that method frame to remain on the stack and not get elided via inlining or tail calls, and so it prevents tail calls from that method. If you want to do a tail call, either explicitly add the "tail." prefix to the call or remove the NoInlining flag.&lt;/LI&gt;
&lt;LI&gt;"Callee might have a StackCrawlMark.LookForMyCaller" - certain methods in mscorlib rely on a stack walk to determine their caller. They are marked to prevent inlining and also to prevent direct tail calls. This will only happen if the callee is known, and is inside mscorlib. There is no way to generate tail calls directly to these methods.&lt;/LI&gt;
&lt;LI&gt;"Caller is a CER root" - See the &lt;A href="http://msdn.microsoft.com/en-us/library/ms228973(VS.100).aspx" mce_href="http://msdn.microsoft.com/en-us/library/ms228973(VS.100).aspx"&gt;Constrained Execution Regions&lt;/A&gt; topic on MSDN.&lt;/LI&gt;&lt;/UL&gt;
&lt;P&gt;From x86 JIT, we get this list of failure reasons (again in no particular order):&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;&lt;A title=Caller_is_synchronized name=Caller_is_synchronized&gt;&lt;/A&gt;"Caller is synchronized" - The caller is marked with &lt;A href="http://msdn.microsoft.com/en-us/library/system.runtime.compilerservices.methodimploptions(VS.100).aspx" mce_href="http://msdn.microsoft.com/en-us/library/system.runtime.compilerservices.methodimploptions(VS.100).aspx"&gt;MethodImplOptions.Synchronized&lt;/A&gt;.&amp;nbsp; The JIT needs to leave the caller's frame on the stack until after the callee finishes in order to know when to release the runtime-implemented locking.&lt;/LI&gt;
&lt;LI&gt;"Caller is varargs" - This is just an implementation limitation of the x86 JIT. For more information about varargs in C# (&lt;B&gt;not&lt;/B&gt; the params keyword), search for &lt;A href="http://www.bing.com/search?q=C%23+__arglist" mce_href="http://www.bing.com/search?q=C%23+__arglist"&gt;__arglist&lt;/A&gt;.&lt;/LI&gt;
&lt;LI&gt;&lt;A title=imperative_security name=imperative_security&gt;&lt;/A&gt;"Caller requires a security check." - The caller is marked with &lt;A href="http://msdn.microsoft.com/en-us/library/ms231030(VS.100).aspx" mce_href="http://msdn.microsoft.com/en-us/library/ms231030(VS.100).aspx"&gt;mdRequireSecObject&lt;/A&gt; for &lt;A href="http://msdn.microsoft.com/en-us/library/0xkh23z.aspx" mce_href="http://msdn.microsoft.com/en-us/library/0xkh23z.aspx"&gt;imperative security&lt;/A&gt;.&amp;nbsp; With our current implementation, such methods need their own call frame so the corresponding Assert or Deny will end at the return of the method.&amp;nbsp; If you want to do a tail call, remove the imperative security calls.&lt;/LI&gt;
&lt;LI&gt;"Needs security check" - Same as above.&lt;/LI&gt;
&lt;LI&gt;&lt;A title=native name=native&gt;&lt;/A&gt;"Callee is native" - We currently cannot tail call from managed code to native code.&lt;/LI&gt;
&lt;LI&gt;"PInvoke calli" - Same as above.&lt;/LI&gt;
&lt;LI&gt;&lt;A title=return_type name=return_type&gt;&lt;/A&gt;"Return types don't match" - The caller and callee must have the exact same return type.&amp;nbsp; If you want to do a tail call, change the return types to match.&lt;/LI&gt;
&lt;LI&gt;&lt;A title=localloc name=localloc&gt;&lt;/A&gt;"Localloc used" - This is just an implementation limitation of the x86 JIT. In C# if you use &lt;A href="http://msdn.microsoft.com/en-us/library/cx9s2sy4.aspx" mce_href="http://msdn.microsoft.com/en-us/library/cx9s2sy4.aspx"&gt;stackalloc&lt;/A&gt; then the JIT cannot be sure of the intended lifetime, and so it goes safe and prevents the tail call. If you want to do a tail call, remove the stackalloc.&lt;/LI&gt;
&lt;LI&gt;"Need to copy return buffer" - If the return value doesn't fit in a register, the caller needs to allocate a buffer. Normally the JIT reuses the caller's return buffer for the caller to avoid a copy, but sometimes it can't, and because it now has to do a copy after the callee returns, it can't do a tail call. If you want to do a tail call, use an out parameter rather than a return value.&lt;/LI&gt;
&lt;LI&gt;&lt;A title=handle name=handle&gt;&lt;/A&gt;"Changed into handle" - The C# expression ‘&lt;A href="http://msdn.microsoft.com/en-us/library/58918ffs.aspx" mce_href="http://msdn.microsoft.com/en-us/library/58918ffs.aspx"&gt;typeof(XXX)&lt;/A&gt;.&lt;A href="http://msdn.microsoft.com/en-us/library/system.type.typehandle.aspx" mce_href="http://msdn.microsoft.com/en-us/library/system.type.typehandle.aspx"&gt;TypeHandle&lt;/A&gt;' involves a call to the property method &lt;A href="http://msdn.microsoft.com/en-us/library/system.type.typehandle.aspx" mce_href="http://msdn.microsoft.com/en-us/library/system.type.typehandle.aspx"&gt;get_TypeHandle&lt;/A&gt;.&amp;nbsp; The JIT can turn that whole expression (including the call) into a simple embedded constant (the TypeHandle as provided by the VM).&amp;nbsp; We think that is faster and better than any tail call.&lt;/LI&gt;&lt;/UL&gt;
&lt;P&gt;From the 64-bit JIT, we get this list of failure reasons:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;"function has EH" - The IA64 JIT doesn't support tail calls from methods with try/catch/finally clauses, unless the call uses the "tail." instruction prefix. If you want to do a tail call remove the exception handling clauses or add a "tail." prefix.&lt;/LI&gt;
&lt;LI&gt;"found symbol with address taken" - if the call doesn't use the "tail." instruction prefix and the method takes the address of a local, the JIT doesn't do enough analysis to see if it is address-escaped (meaning the callee uses the address to access the caller's local) and so it just doesn't try to optimize a normal call into a tail call.&lt;/LI&gt;
&lt;LI&gt;"local address taken" - Same as above.&lt;/LI&gt;
&lt;LI&gt;"synchronized" - This is the same as the x86 JIT's &lt;A href="http://blogs.msdn.com/controlpanel/blogs/posteditor.aspx?SelectedNavItem=NewPost&amp;amp;sectionid=8926&amp;amp;bpt=1#Caller_is_synchronized" mce_href="http://blogs.msdn.com/controlpanel/blogs/posteditor.aspx?SelectedNavItem=NewPost&amp;amp;sectionid=8926&amp;amp;bpt=1#Caller_is_synchronized"&gt;"Caller is synchronized"&lt;/A&gt;.&lt;/LI&gt;
&lt;LI&gt;"caller's imperative security" - This is the same as the x86 JIT's &lt;A href="http://blogs.msdn.com/controlpanel/blogs/posteditor.aspx?SelectedNavItem=NewPost&amp;amp;sectionid=8926&amp;amp;bpt=1#imperative_security" mce_href="http://blogs.msdn.com/controlpanel/blogs/posteditor.aspx?SelectedNavItem=NewPost&amp;amp;sectionid=8926&amp;amp;bpt=1#imperative_security"&gt;"Caller requires a security check"&lt;/A&gt;.&lt;/LI&gt;
&lt;LI&gt;"caller's declarative security" - This is the same as the VM's &lt;A href="http://blogs.msdn.com/controlpanel/blogs/posteditor.aspx?SelectedNavItem=NewPost&amp;amp;sectionid=8926&amp;amp;bpt=1#declarative_security" mce_href="http://blogs.msdn.com/controlpanel/blogs/posteditor.aspx?SelectedNavItem=NewPost&amp;amp;sectionid=8926&amp;amp;bpt=1#declarative_security"&gt;"Caller has declarative security"&lt;/A&gt;.&lt;/LI&gt;
&lt;LI&gt;"not optimizing" - The JIT disabled all optimizations, and so it only performs a tail call if the "tail." prefix is present. If you want to do a tail call, either add the "tail." prefix or re-enable optimizations. Some of the reasons why JIT optimizations might be disabled include: using &lt;A href="http://msdn.microsoft.com/en-us/library/system.runtime.compilerservices.methodimploptions.aspx" mce_href="http://msdn.microsoft.com/en-us/library/system.runtime.compilerservices.methodimploptions.aspx"&gt;MethodImplOptions.NoOptimization&lt;/A&gt;, a method that is too big or too complex to optimize, running under a debugger, and certain compiler switches.&lt;/LI&gt;
&lt;LI&gt;"localloc" - This is the same as the x86 JIT's &lt;A href="http://blogs.msdn.com/controlpanel/blogs/posteditor.aspx?SelectedNavItem=NewPost&amp;amp;sectionid=8926&amp;amp;bpt=1#localloc" mce_href="http://blogs.msdn.com/controlpanel/blogs/posteditor.aspx?SelectedNavItem=NewPost&amp;amp;sectionid=8926&amp;amp;bpt=1#localloc"&gt;"Localloc used"&lt;/A&gt;, except the 64-bit JIT will do a tail call if the call explicitly uses the "tail." instruction prefix.&lt;/LI&gt;
&lt;LI&gt;"GS" - The method uses local buffers (unmanaged arrays) and the JIT adds extra code to detect buffer overruns before they can be exploited. These extra checks are incompatible with tail calls in our current implementation. The name comes from the &lt;A href="http://msdn.microsoft.com/en-us/library/8dbf701c.aspx" mce_href="http://msdn.microsoft.com/en-us/library/8dbf701c.aspx"&gt;C++ compiler's /GS command-line switch&lt;/A&gt;, and attempts to prevent many similar issues as they appear in unsafe managed code.&lt;/LI&gt;
&lt;LI&gt;"turned into intrinsic" - The 64-bit JIT cannot tail call certain methods that effectively turn into special code. This is similar to the x86 JIT's &lt;A href="http://blogs.msdn.com/controlpanel/blogs/posteditor.aspx?SelectedNavItem=NewPost&amp;amp;sectionid=8926&amp;amp;bpt=1#handle" mce_href="http://blogs.msdn.com/controlpanel/blogs/posteditor.aspx?SelectedNavItem=NewPost&amp;amp;sectionid=8926&amp;amp;bpt=1#handle"&gt;"Changed into handle"&lt;/A&gt;.&lt;/LI&gt;
&lt;LI&gt;"P/Invoke" - This is the same as the x86 JIT's &lt;A href="http://blogs.msdn.com/controlpanel/blogs/posteditor.aspx?SelectedNavItem=NewPost&amp;amp;sectionid=8926&amp;amp;bpt=1#native" mce_href="http://blogs.msdn.com/controlpanel/blogs/posteditor.aspx?SelectedNavItem=NewPost&amp;amp;sectionid=8926&amp;amp;bpt=1#native"&gt;"Callee is native"&lt;/A&gt;.&lt;/LI&gt;
&lt;LI&gt;"return type mismatch" - The caller and callee must have compatible return types (types that don't require any conversion at the hardware level). This is similar to the x86 JIT's &lt;A href="http://blogs.msdn.com/controlpanel/blogs/posteditor.aspx?SelectedNavItem=NewPost&amp;amp;sectionid=8926&amp;amp;bpt=1#return_type" mce_href="http://blogs.msdn.com/controlpanel/blogs/posteditor.aspx?SelectedNavItem=NewPost&amp;amp;sectionid=8926&amp;amp;bpt=1#return_type"&gt;"Return types don't match"&lt;/A&gt;, but the 64-bit JIT is slightly more permissive.&lt;/LI&gt;
&lt;LI&gt;"processor specific reasons" - The caller and callee's signature are different enough that the calling convention makes it hard (or impossible) to do a traditional optimized tail call. This is usually caused by the callee having more (or bigger) arguments than the caller. On x64 if the "tail." instruction prefix is used, the JIT will generate a HelperAssistedTailCall. &lt;/LI&gt;&lt;/UL&gt;
&lt;P&gt;It is worth noting that the 64-bit JIT tries to optimize almost all calls into tail calls.&amp;nbsp; The JIT also implies a certain amount of knowledge, intent and analysis when the "tail." IL prefix is used on a call.&amp;nbsp; A normal call (no prefix) is sort of like telling the JIT to make a call however it deems best.&amp;nbsp; The JIT then does some quick conservative checks to see if a tail call is possible and would be as good as or better than a normal call.&amp;nbsp; On the other hand a call with the "tail." prefix is sort of like telling the JIT to try as hard as possible to make a tail call, because the programmer or the compiler did some big analysis and proved that, despite what the JIT might think, the tail call is safe and will be better than a regular call.&amp;nbsp; Thus the only things the JIT has to check for are known problems (verification, security, and implementation limitations).&lt;/P&gt;
&lt;P&gt;The x86 JIT, on the other hand, currently only attempts to do a tail call when the IL explicitly uses the "tail." prefix.&amp;nbsp; Thus the x86 JIT only checks for correctness.&lt;/P&gt;
&lt;P&gt;It is my understanding that the C# and VB.NET compilers never emit the "tail." instruction prefix, but the C++ and F# compilers generate it automatically, so the programmer has very little control over this condition.&amp;nbsp; So unless you write in IL, or use some form of IL rewriter, your ability to add or remove the ".tail" prefix is limited at best.&lt;/P&gt;
&lt;P&gt;Lastly if you're still reading you have probably noticed that there is a lot of redundancy.&amp;nbsp; This is partly because the messages are generated by different components in the runtime - the VM, the x86 JIT, and the x64 JIT - which were developed, and have evolved, fairly independently.&amp;nbsp; There is also some amount of redundancy as a safety precaution.&lt;/P&gt;
&lt;P&gt;Grant RIchins&lt;BR&gt;CLR Codegen Team&lt;/P&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10009397" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/b/clrcodegeneration/archive/tags/JIT/">JIT</category><category domain="http://blogs.msdn.com/b/clrcodegeneration/archive/tags/performance/">performance</category><category domain="http://blogs.msdn.com/b/clrcodegeneration/archive/tags/-NET+Framework+4/">.NET Framework 4</category><category domain="http://blogs.msdn.com/b/clrcodegeneration/archive/tags/Visual+Studio+2010/">Visual Studio 2010</category><category domain="http://blogs.msdn.com/b/clrcodegeneration/archive/tags/Tail+calls/">Tail calls</category><category domain="http://blogs.msdn.com/b/clrcodegeneration/archive/tags/ETW/">ETW</category></item><item><title>NGen: Creating Setup Projects</title><link>http://blogs.msdn.com/b/clrcodegeneration/archive/2010/04/27/ngen-creating-setup-projects.aspx</link><pubDate>Tue, 27 Apr 2010 18:05:34 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10003354</guid><dc:creator>pracheeti</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.msdn.com/b/clrcodegeneration/rsscomments.aspx?WeblogPostID=10003354</wfw:commentRss><comments>http://blogs.msdn.com/b/clrcodegeneration/archive/2010/04/27/ngen-creating-setup-projects.aspx#comments</comments><description>&lt;p&gt;This is article 4 of 4 in the &lt;strong&gt;&lt;a href="http://blogs.msdn.com/clrcodegeneration/archive/2010/04/27/ngen-walk-through-series.aspx"&gt;NGen: Walk-through Series&lt;/a&gt;&lt;/strong&gt;.&lt;/p&gt; &lt;p&gt;The NGen technology is designed to be used during the installation phase of a managed application or library. This article will talk about the various installer technologies available, which one to choose, and how to invoke NGen given that installer technology. &lt;/p&gt; &lt;h5&gt;Installer Toolsets&lt;/h5&gt; &lt;p class="MsoNormal"&gt;The fundamental thing to know before we take a look at installers is that NGen is a tool that can be run only with administrator privileges. A non-admin user cannot invoke NGen.exe. This means that any installer technology that cannot run with administrator privileges cannot be used to invoke NGen easily. Non-admin installer technologies like ClickOnce sometimes use an MSI wrapper to invoke administrator-only actions like NGen. &lt;/p&gt; &lt;p class="MsoNormal"&gt;&amp;nbsp;&lt;/p&gt; &lt;p class="MsoNormal"&gt;There are several tools available to create a Windows Installer file (MSI file) – Visual Studio Setup and Deployment Projects, Install Shield 2010 Limited Edition, Windows Installer XML Toolset (WiX), etc. This MSDN article gives a breakdown of how these tools compare: &lt;a href="http://msdn.microsoft.com/en-us/library/ee721500(v=VS.100).aspx"&gt;http://msdn.microsoft.com/en-us/library/ee721500(v=VS.100).aspx&lt;/a&gt;. &lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&lt;/span&gt;For a simple project which just installs a few binaries, the Visual Studio Deployment Project is easy to ramp up on and can quickly produce a workable package. However, for production quality applications, WiX tends to be the installer toolset of choice. Among other benefits, WiX has MSBuild support (which implies you don’t need to install Visual Studio in order to create a setup package) and stores all data in XML files (which makes it easily editable). &lt;/p&gt; &lt;p class="MsoNormal"&gt;&amp;nbsp;&lt;/p&gt; &lt;p class="MsoNormal"&gt;The rest of this article will focus on using NGen via the WiX toolset. &lt;/p&gt; &lt;p class="MsoNormal"&gt;&amp;nbsp;&lt;/p&gt; &lt;p class="MsoNormal"&gt;&lt;u&gt;Further Reading&lt;/u&gt;&lt;/p&gt; &lt;p class="MsoListParagraph" style="text-indent: -0.25in; mso-list: l2 level1 lfo1"&gt;&lt;span style="mso-fareast-font-family: calibri; mso-fareast-theme-font: minor-latin; mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin"&gt;&lt;span style="mso-list: ignore"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span style="mso-fareast-font-family: calibri; mso-fareast-theme-font: minor-latin; mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin"&gt;&lt;span style="mso-list: ignore"&gt;1&amp;gt;&lt;span style="font: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;Using NGen Custom Action in Visual Studio Deployment Projects: &lt;a href="http://msdn.microsoft.com/en-us/library/3hwzzhyd.aspx"&gt;http://msdn.microsoft.com/en-us/library/3hwzzhyd.aspx&lt;/a&gt;&amp;nbsp;&lt;/p&gt; &lt;p class="MsoListParagraph" style="text-indent: -0.25in; mso-list: l2 level1 lfo1"&gt;&amp;nbsp;&lt;/p&gt; &lt;h5&gt;Getting Started with WiX&lt;/h5&gt; &lt;p class="MsoNormal"&gt;Assuming you have Visual Studio 2010 installed, the next step is to install WiX 3.5 from &lt;a href="http://wix.sourceforge.net/releases/3.5.1419.0"&gt;&lt;span style="mso-bidi-font-weight: bold"&gt;http://wix.sourceforge.net/releases/3.5.1419.0&lt;/span&gt;&lt;/a&gt;. &lt;/p&gt; &lt;p class="MsoNormal"&gt;&amp;nbsp;&lt;/p&gt; &lt;p class="MsoNormal"&gt;This version is officially the one used for Visual Studio 2010 RC, but it will work against Visual Studio 2010 RTM as well. The version of WiX that is supported on Visual Studio 2010 RTM is scheduled to release soon.&lt;/p&gt; &lt;p class="MsoNormal"&gt;&amp;nbsp;&lt;/p&gt; &lt;p class="MsoNormal"&gt;The walk through below assumes that a Visual Studio project for a basic Windows Forms application called &lt;i style="mso-bidi-font-style: normal"&gt;HelloWinForm&lt;/i&gt; exists already. To create the WiX project that will install this application, in your Visual Studio solution, in &lt;b style="mso-bidi-font-weight: normal"&gt;Solution Explorer&lt;/b&gt; right click on the solution, &lt;b style="mso-bidi-font-weight: normal"&gt;Add&lt;/b&gt; a &lt;b style="mso-bidi-font-weight: normal"&gt;New Project&lt;/b&gt; and under the &lt;b style="mso-bidi-font-weight: normal"&gt;Windows Installer XML &lt;/b&gt;template select the &lt;b style="mso-bidi-font-weight: normal"&gt;Setup Project&lt;/b&gt;. &lt;/p&gt; &lt;p class="MsoNormal"&gt;&amp;nbsp;&lt;/p&gt; &lt;p class="MsoNormal"&gt;&lt;span style="mso-no-proof: yes; mso-fareast-language: en-us"&gt;&lt;a href="http://blogs.msdn.com/blogfiles/clrcodegeneration/WindowsLiveWriter/NGenCreatingSetupProjects_10FCA/clip_image0024.jpg"&gt;&lt;img title="clip_image002" style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="176" alt="clip_image002" src="http://blogs.msdn.com/blogfiles/clrcodegeneration/WindowsLiveWriter/NGenCreatingSetupProjects_10FCA/clip_image0024_thumb.jpg" width="447" border="0" v:shapes="Picture_x0020_1"&gt;&lt;/a&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoSubtitle"&gt;&lt;span style="font-size: 11pt; line-height: 115%; font-family: 'Calibri','sans-serif'; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin"&gt;&lt;em&gt;&lt;font size="1"&gt;&lt;font face="Verdana"&gt;Screenshot 1: Selecting a Setup Project&lt;?xml:namespace prefix = o /&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/font&gt;&lt;/font&gt;&lt;/em&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal"&gt;Next, in Solution Explorer, under &lt;i style="mso-bidi-font-style: normal"&gt;WixProject1&lt;/i&gt; right click on the &lt;b style="mso-bidi-font-weight: normal"&gt;References &lt;/b&gt;node and choose &lt;b style="mso-bidi-font-weight: normal"&gt;Add Reference&lt;/b&gt;. In the &lt;b style="mso-bidi-font-weight: normal"&gt;Projects&lt;/b&gt; tab, select the project named &lt;i style="mso-bidi-font-style: normal"&gt;HelloWinForm&lt;/i&gt;. This will ensure that the &lt;i style="mso-bidi-font-style: normal"&gt;HelloWinForm &lt;/i&gt;project will build prior to the &lt;i style="mso-bidi-font-style: normal"&gt;WixProject1&lt;/i&gt;, and the input to &lt;i style="mso-bidi-font-style: normal"&gt;WixProject1&lt;/i&gt; is the output of the &lt;i style="mso-bidi-font-style: normal"&gt;HelloWinForm&lt;/i&gt; project. &lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal"&gt;&lt;i style="mso-bidi-font-style: normal"&gt;&lt;/i&gt;&amp;nbsp;&lt;/p&gt; &lt;p class="MsoNormal"&gt;&lt;i style="mso-bidi-font-style: normal"&gt;WixProject1 &lt;/i&gt;will now contain a default .WXS file which will need some modifications before you can build successfully. This XML file will have several TODOs that will need to be adjusted. Under the Component tag, add a File tag which looks like this – &lt;/p&gt; &lt;p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; mso-layout-grid-align: none"&gt;&lt;span style="font-size: 9.5pt; color: blue; font-family: consolas; mso-bidi-font-family: consolas"&gt;&amp;lt;&lt;/span&gt;&lt;span style="font-size: 9.5pt; color: #a31515; font-family: consolas; mso-bidi-font-family: consolas"&gt;File&lt;/span&gt;&lt;span style="font-size: 9.5pt; color: blue; font-family: consolas; mso-bidi-font-family: consolas"&gt; &lt;/span&gt;&lt;span style="font-size: 9.5pt; color: red; font-family: consolas; mso-bidi-font-family: consolas"&gt;Id&lt;/span&gt;&lt;span style="font-size: 9.5pt; color: blue; font-family: consolas; mso-bidi-font-family: consolas"&gt;=&lt;/span&gt;&lt;span style="font-size: 9.5pt; font-family: consolas; mso-bidi-font-family: consolas"&gt;"&lt;span style="color: blue"&gt;WindowsFormsApplication1File&lt;/span&gt;"&lt;span style="color: blue"&gt; &lt;/span&gt;&lt;span style="color: red"&gt;Name&lt;/span&gt;&lt;span style="color: blue"&gt;=&lt;/span&gt;"&lt;span style="color: blue"&gt;$(var.HelloWinform.TargetFileName)&lt;/span&gt;"&lt;span style="color: blue"&gt; &lt;/span&gt;&lt;span style="color: red"&gt;Source&lt;/span&gt;&lt;span style="color: blue"&gt;=&lt;/span&gt;"&lt;span style="color: blue"&gt;$(var.HelloWinform.TargetPath)&lt;/span&gt;"&lt;span style="color: blue"&gt; &lt;/span&gt;&lt;span style="color: red"&gt;DiskId&lt;/span&gt;&lt;span style="color: blue"&gt;=&lt;/span&gt;"&lt;span style="color: blue"&gt;1&lt;/span&gt;"&lt;span style="color: blue"&gt; &lt;/span&gt;&lt;span style="color: red"&gt;KeyPath&lt;/span&gt;&lt;span style="color: blue"&gt;=&lt;/span&gt;"&lt;span style="color: blue"&gt;yes&lt;/span&gt;"&lt;span style="color: blue"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 9.5pt; color: blue; font-family: consolas; mso-bidi-font-family: consolas"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal"&gt;&amp;nbsp;&lt;/p&gt; &lt;p class="MsoNormal"&gt;&lt;u&gt;Further Reading&lt;/u&gt;&lt;/p&gt; &lt;p class="MsoListParagraphCxSpFirst" style="text-indent: -0.25in; mso-list: l1 level1 lfo2"&gt;&lt;span style="mso-fareast-font-family: calibri; mso-fareast-theme-font: minor-latin; mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin"&gt;&lt;span style="mso-list: ignore"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span style="mso-fareast-font-family: calibri; mso-fareast-theme-font: minor-latin; mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin"&gt;&lt;span style="mso-list: ignore"&gt;1&amp;gt;&lt;span style="font: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;Getting the latest updates for WiX: &lt;a href="http://wix.sourceforge.net/"&gt;http://wix.sourceforge.net/&lt;/a&gt; &lt;/p&gt; &lt;p class="MsoListParagraphCxSpMiddle" style="text-indent: -0.25in; mso-list: l1 level1 lfo2"&gt;&lt;span style="mso-fareast-font-family: calibri; mso-fareast-theme-font: minor-latin; mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin"&gt;&lt;span style="mso-list: ignore"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span style="mso-fareast-font-family: calibri; mso-fareast-theme-font: minor-latin; mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin"&gt;&lt;span style="mso-list: ignore"&gt;2&amp;gt;&lt;span style="font: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;Using WiX in Visual Studio to create a basic setup package: All Programs -&amp;gt; Windows Installer XML Toolset 3.5 -&amp;gt; WiX Documentation. Go to Using WiX in Visual Studio -&amp;gt; Creating a Simple Setup.&lt;/p&gt; &lt;p class="MsoListParagraphCxSpMiddle" style="text-indent: -0.25in; mso-list: l1 level1 lfo2"&gt;&amp;nbsp;&lt;/p&gt; &lt;h5&gt;Adding NGen steps to the WiX Project&lt;/h5&gt; &lt;p class="MsoNormal"&gt;Now that we have a basic WiX project working without NGen, the next phase is to incorporate NGen into this project so we can NGen the binaries produced in the &lt;i style="mso-bidi-font-style: normal"&gt;HelloWinForm&lt;/i&gt; project. &lt;/p&gt; &lt;p class="MsoNormal"&gt;&amp;nbsp;&lt;/p&gt; &lt;p class="MsoNormal"&gt;In Solution Explorer, right click on the &lt;b style="mso-bidi-font-weight: normal"&gt;References&lt;/b&gt; node and choose &lt;b style="mso-bidi-font-weight: normal"&gt;Add Reference.&lt;/b&gt; In the &lt;b style="mso-bidi-font-weight: normal"&gt;Browse &lt;/b&gt;tab, find &lt;b style="mso-bidi-font-weight: normal"&gt;WixNetFxExtension.dll&lt;/b&gt; under the bin directory (the full path will likely be something like C:\Program Files\Windows Installer XML v3.5\bin\WixNetFxExtension.dll), and click &lt;b style="mso-bidi-font-weight: normal"&gt;Add.&lt;/b&gt; Add an XML namespace called netfx by changing the Wix tag in the WXS file as shown below.&lt;/p&gt; &lt;p class="MsoNormal"&gt;&lt;span style="mso-bidi-font-family: consolas"&gt;&lt;/span&gt;&amp;nbsp;&lt;/p&gt; &lt;p class="MsoNormal"&gt;&lt;span style="mso-bidi-font-family: consolas"&gt;Before:&lt;/span&gt;&lt;span style="font-size: 9.5pt; line-height: 115%; font-family: consolas; mso-bidi-font-family: consolas"&gt;&lt;span style="mso-tab-count: 2"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="color: blue"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;Wix&lt;/span&gt;&lt;span style="color: blue"&gt; &lt;/span&gt;&lt;span style="color: red"&gt;xmlns&lt;/span&gt;&lt;span style="color: blue"&gt;=&lt;/span&gt;"&lt;span style="color: blue"&gt;http://schemas.microsoft.com/wix/2006/wi&lt;/span&gt;"&lt;span style="color: blue"&gt; &amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal"&gt;&lt;span style="font-family: consolas; mso-bidi-font-family: consolas"&gt;&lt;/span&gt;&amp;nbsp;&lt;/p&gt; &lt;p class="MsoNormal"&gt;&lt;span style="font-family: consolas; mso-bidi-font-family: consolas"&gt;After:&lt;span style="mso-tab-count: 1"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 9.5pt; color: blue; line-height: 115%; font-family: consolas; mso-bidi-font-family: consolas"&gt;&amp;lt;&lt;/span&gt;&lt;span style="font-size: 9.5pt; color: #a31515; line-height: 115%; font-family: consolas; mso-bidi-font-family: consolas"&gt;Wix&lt;/span&gt;&lt;span style="font-size: 9.5pt; color: blue; line-height: 115%; font-family: consolas; mso-bidi-font-family: consolas"&gt; &lt;/span&gt;&lt;span style="font-size: 9.5pt; color: red; line-height: 115%; font-family: consolas; mso-bidi-font-family: consolas"&gt;xmlns&lt;/span&gt;&lt;span style="font-size: 9.5pt; color: blue; line-height: 115%; font-family: consolas; mso-bidi-font-family: consolas"&gt;=&lt;/span&gt;&lt;span style="font-size: 9.5pt; line-height: 115%; font-family: consolas; mso-bidi-font-family: consolas"&gt;"&lt;span style="color: blue"&gt;http://schemas.microsoft.com/wix/2006/wi&lt;/span&gt;"&lt;span style="color: blue"&gt; &lt;/span&gt;&lt;span style="color: red"&gt;xmlns:netfx&lt;/span&gt;&lt;span style="color: blue"&gt; =&lt;/span&gt;"&lt;span style="color: blue"&gt;http://schemas.microsoft.com/wix/NetFxExtension&lt;/span&gt;"&lt;span style="color: blue"&gt; &amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal"&gt;&amp;nbsp;&lt;/p&gt; &lt;p class="MsoNormal"&gt;This will enable intellisense for the netfx namespace. &lt;/p&gt; &lt;p class="MsoNormal"&gt;&amp;nbsp;&lt;/p&gt; &lt;p class="MsoNormal"&gt;The next step is to enable NGen installation for the binary that is built in the &lt;i style="mso-bidi-font-style: normal"&gt;HelloWinForm&lt;/i&gt; project. To do that, add the following line under the File element.&lt;/p&gt; &lt;p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; mso-layout-grid-align: none"&gt;&lt;span style="font-size: 9.5pt; color: blue; font-family: consolas; mso-bidi-font-family: consolas"&gt;&lt;/span&gt;&amp;nbsp;&lt;/p&gt; &lt;p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; mso-layout-grid-align: none"&gt;&lt;span style="font-size: 9.5pt; color: blue; font-family: consolas; mso-bidi-font-family: consolas"&gt;&amp;lt;&lt;/span&gt;&lt;span style="font-size: 9.5pt; color: #a31515; font-family: consolas; mso-bidi-font-family: consolas"&gt;netfx:NativeImage&lt;/span&gt;&lt;span style="font-size: 9.5pt; color: blue; font-family: consolas; mso-bidi-font-family: consolas"&gt; &lt;/span&gt;&lt;span style="font-size: 9.5pt; color: red; font-family: consolas; mso-bidi-font-family: consolas"&gt;Id&lt;/span&gt;&lt;span style="font-size: 9.5pt; color: blue; font-family: consolas; mso-bidi-font-family: consolas"&gt;=&lt;/span&gt;&lt;span style="font-size: 9.5pt; font-family: consolas; mso-bidi-font-family: consolas"&gt;"&lt;span style="color: blue"&gt;WindowsFormsApplication1File.exe&lt;/span&gt;"&lt;span style="color: blue"&gt; &lt;/span&gt;&lt;span style="color: red"&gt;Platform&lt;/span&gt;&lt;span style="color: blue"&gt;=&lt;/span&gt;"&lt;span style="color: blue"&gt;32bit&lt;/span&gt;"&lt;span style="color: blue"&gt; &lt;/span&gt;&lt;span style="color: red"&gt;Priority&lt;/span&gt;&lt;span style="color: blue"&gt;=&lt;/span&gt;"&lt;span style="color: blue"&gt;1&lt;/span&gt;"&lt;span style="color: blue"&gt; &lt;/span&gt;&lt;span style="color: red"&gt;Dependencies&lt;/span&gt;&lt;span style="color: blue"&gt;=&lt;/span&gt;"&lt;span style="color: blue"&gt;no&lt;/span&gt;"&lt;span style="color: blue"&gt; /&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/p&gt; &lt;p class="MsoNormal"&gt;Detailed documentation for the WiX schemas can be found via the Windows start menu, All Programs -&amp;gt; Windows Installer XML Toolset 3.5 -&amp;gt; WiX Documentation. Information about the NetFx namespace lives under Windows Installer XML (WiX) Help -&amp;gt; WiX Schema References -&amp;gt; Netfx Schema -&amp;gt; NativeImage Element (Netfx Extension).&lt;/p&gt; &lt;p class="MsoNormal"&gt;&amp;nbsp;&lt;/p&gt; &lt;p class="MsoNormal"&gt;The resulting WXS file will look as follows – &lt;/p&gt; &lt;p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; mso-layout-grid-align: none"&gt;&lt;span style="font-size: 9.5pt; color: blue; font-family: consolas; mso-bidi-font-family: consolas"&gt;&amp;lt;?&lt;/span&gt;&lt;span style="font-size: 9.5pt; color: #a31515; font-family: consolas; mso-bidi-font-family: consolas"&gt;xml&lt;/span&gt;&lt;span style="font-size: 9.5pt; color: blue; font-family: consolas; mso-bidi-font-family: consolas"&gt; &lt;/span&gt;&lt;span style="font-size: 9.5pt; color: red; font-family: consolas; mso-bidi-font-family: consolas"&gt;version&lt;/span&gt;&lt;span style="font-size: 9.5pt; color: blue; font-family: consolas; mso-bidi-font-family: consolas"&gt;=&lt;/span&gt;&lt;span style="font-size: 9.5pt; font-family: consolas; mso-bidi-font-family: consolas"&gt;"&lt;span style="color: blue"&gt;1.0&lt;/span&gt;"&lt;span style="color: blue"&gt; &lt;/span&gt;&lt;span style="color: red"&gt;encoding&lt;/span&gt;&lt;span style="color: blue"&gt;=&lt;/span&gt;"&lt;span style="color: blue"&gt;UTF-8&lt;/span&gt;"&lt;span style="color: blue"&gt;?&amp;gt;&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; mso-layout-grid-align: none"&gt;&lt;span style="font-size: 9.5pt; color: blue; font-family: consolas; mso-bidi-font-family: consolas"&gt;&amp;lt;&lt;/span&gt;&lt;span style="font-size: 9.5pt; color: #a31515; font-family: consolas; mso-bidi-font-family: consolas"&gt;Wix&lt;/span&gt;&lt;span style="font-size: 9.5pt; color: blue; font-family: consolas; mso-bidi-font-family: consolas"&gt; &lt;/span&gt;&lt;span style="font-size: 9.5pt; color: red; font-family: consolas; mso-bidi-font-family: consolas"&gt;xmlns&lt;/span&gt;&lt;span style="font-size: 9.5pt; color: blue; font-family: consolas; mso-bidi-font-family: consolas"&gt;=&lt;/span&gt;&lt;span style="font-size: 9.5pt; font-family: consolas; mso-bidi-font-family: consolas"&gt;"&lt;span style="color: blue"&gt;http://schemas.microsoft.com/wix/2006/wi&lt;/span&gt;"&lt;span style="color: blue"&gt; &lt;/span&gt;&lt;span style="color: red"&gt;xmlns:netfx&lt;/span&gt;&lt;span style="color: blue"&gt; =&lt;/span&gt;"&lt;span style="color: blue"&gt;http://schemas.microsoft.com/wix/NetFxExtension&lt;/span&gt;"&lt;span style="color: blue"&gt; &amp;gt;&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; mso-layout-grid-align: none"&gt;&lt;span style="font-size: 9.5pt; color: blue; font-family: consolas; mso-bidi-font-family: consolas"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/span&gt;&amp;lt;&lt;/span&gt;&lt;span style="font-size: 9.5pt; color: #a31515; font-family: consolas; mso-bidi-font-family: consolas"&gt;Product&lt;/span&gt;&lt;span style="font-size: 9.5pt; color: blue; font-family: consolas; mso-bidi-font-family: consolas"&gt; &lt;/span&gt;&lt;span style="font-size: 9.5pt; color: red; font-family: consolas; mso-bidi-font-family: consolas"&gt;Id&lt;/span&gt;&lt;span style="font-size: 9.5pt; color: blue; font-family: consolas; mso-bidi-font-family: consolas"&gt;=&lt;/span&gt;&lt;span style="font-size: 9.5pt; font-family: consolas; mso-bidi-font-family: consolas"&gt;"&lt;span style="color: blue"&gt;3645a635-5cb6-48da-8a2a-6d9bd9778aee&lt;/span&gt;"&lt;span style="color: blue"&gt; &lt;/span&gt;&lt;span style="color: red"&gt;Name&lt;/span&gt;&lt;span style="color: blue"&gt;=&lt;/span&gt;"&lt;span style="color: blue"&gt;Wix35Project1&lt;/span&gt;"&lt;span style="color: blue"&gt; &lt;/span&gt;&lt;span style="color: red"&gt;Language&lt;/span&gt;&lt;span style="color: blue"&gt;=&lt;/span&gt;"&lt;span style="color: blue"&gt;1033&lt;/span&gt;"&lt;span style="color: blue"&gt; &lt;/span&gt;&lt;span style="color: red"&gt;Version&lt;/span&gt;&lt;span style="color: blue"&gt;=&lt;/span&gt;"&lt;span style="color: blue"&gt;1.0.0.0&lt;/span&gt;"&lt;span style="color: blue"&gt; &lt;/span&gt;&lt;span style="color: red"&gt;Manufacturer&lt;/span&gt;&lt;span style="color: blue"&gt;=&lt;/span&gt;"&lt;span style="color: blue"&gt;Wix35Project1&lt;/span&gt;"&lt;span style="color: blue"&gt; &lt;/span&gt;&lt;span style="color: red"&gt;UpgradeCode&lt;/span&gt;&lt;span style="color: blue"&gt;=&lt;/span&gt;"&lt;span style="color: blue"&gt;2abe811c-b331-4ca3-94b1-2bfd652a280a&lt;/span&gt;"&lt;span style="color: blue"&gt;&amp;gt;&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; mso-layout-grid-align: none"&gt;&lt;span style="font-size: 9.5pt; color: blue; font-family: consolas; mso-bidi-font-family: consolas"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&amp;lt;&lt;/span&gt;&lt;span style="font-size: 9.5pt; color: #a31515; font-family: consolas; mso-bidi-font-family: consolas"&gt;Package&lt;/span&gt;&lt;span style="font-size: 9.5pt; color: blue; font-family: consolas; mso-bidi-font-family: consolas"&gt; &lt;/span&gt;&lt;span style="font-size: 9.5pt; color: red; font-family: consolas; mso-bidi-font-family: consolas"&gt;InstallerVersion&lt;/span&gt;&lt;span style="font-size: 9.5pt; color: blue; font-family: consolas; mso-bidi-font-family: consolas"&gt;=&lt;/span&gt;&lt;span style="font-size: 9.5pt; font-family: consolas; mso-bidi-font-family: consolas"&gt;"&lt;span style="color: blue"&gt;200&lt;/span&gt;"&lt;span style="color: blue"&gt; &lt;/span&gt;&lt;span style="color: red"&gt;Compressed&lt;/span&gt;&lt;span style="color: blue"&gt;=&lt;/span&gt;"&lt;span style="color: blue"&gt;yes&lt;/span&gt;"&lt;span style="color: blue"&gt; /&amp;gt;&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; mso-layout-grid-align: none"&gt;&lt;span style="font-size: 9.5pt; color: blue; font-family: consolas; mso-bidi-font-family: consolas"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&amp;lt;&lt;/span&gt;&lt;span style="font-size: 9.5pt; color: #a31515; font-family: consolas; mso-bidi-font-family: consolas"&gt;Media&lt;/span&gt;&lt;span style="font-size: 9.5pt; color: blue; font-family: consolas; mso-bidi-font-family: consolas"&gt; &lt;/span&gt;&lt;span style="font-size: 9.5pt; color: red; font-family: consolas; mso-bidi-font-family: consolas"&gt;Id&lt;/span&gt;&lt;span style="font-size: 9.5pt; color: blue; font-family: consolas; mso-bidi-font-family: consolas"&gt;=&lt;/span&gt;&lt;span style="font-size: 9.5pt; font-family: consolas; mso-bidi-font-family: consolas"&gt;"&lt;span style="color: blue"&gt;1&lt;/span&gt;"&lt;span style="color: blue"&gt; &lt;/span&gt;&lt;span style="color: red"&gt;Cabinet&lt;/span&gt;&lt;span style="color: blue"&gt;=&lt;/span&gt;"&lt;span style="color: blue"&gt;media1.cab&lt;/span&gt;"&lt;span style="color: blue"&gt; &lt;/span&gt;&lt;span style="color: red"&gt;EmbedCab&lt;/span&gt;&lt;span style="color: blue"&gt;=&lt;/span&gt;"&lt;span style="color: blue"&gt;yes&lt;/span&gt;"&lt;span style="color: blue"&gt; /&amp;gt;&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; mso-layout-grid-align: none"&gt;&lt;span style="font-size: 9.5pt; font-family: consolas; mso-bidi-font-family: consolas"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; mso-layout-grid-align: none"&gt;&lt;span style="font-size: 9.5pt; color: blue; font-family: consolas; mso-bidi-font-family: consolas"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&amp;lt;&lt;/span&gt;&lt;span style="font-size: 9.5pt; color: #a31515; font-family: consolas; mso-bidi-font-family: consolas"&gt;Directory&lt;/span&gt;&lt;span style="font-size: 9.5pt; color: blue; font-family: consolas; mso-bidi-font-family: consolas"&gt; &lt;/span&gt;&lt;span style="font-size: 9.5pt; color: red; font-family: consolas; mso-bidi-font-family: consolas"&gt;Id&lt;/span&gt;&lt;span style="font-size: 9.5pt; color: blue; font-family: consolas; mso-bidi-font-family: consolas"&gt;=&lt;/span&gt;&lt;span style="font-size: 9.5pt; font-family: consolas; mso-bidi-font-family: consolas"&gt;"&lt;span style="color: blue"&gt;TARGETDIR&lt;/span&gt;"&lt;span style="color: blue"&gt; &lt;/span&gt;&lt;span style="color: red"&gt;Name&lt;/span&gt;&lt;span style="color: blue"&gt;=&lt;/span&gt;"&lt;span style="color: blue"&gt;SourceDir&lt;/span&gt;"&lt;span style="color: blue"&gt;&amp;gt;&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; mso-layout-grid-align: none"&gt;&lt;span style="font-size: 9.5pt; color: blue; font-family: consolas; mso-bidi-font-family: consolas"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&amp;lt;&lt;/span&gt;&lt;span style="font-size: 9.5pt; color: #a31515; font-family: consolas; mso-bidi-font-family: consolas"&gt;Directory&lt;/span&gt;&lt;span style="font-size: 9.5pt; color: blue; font-family: consolas; mso-bidi-font-family: consolas"&gt; &lt;/span&gt;&lt;span style="font-size: 9.5pt; color: red; font-family: consolas; mso-bidi-font-family: consolas"&gt;Id&lt;/span&gt;&lt;span style="font-size: 9.5pt; color: blue; font-family: consolas; mso-bidi-font-family: consolas"&gt;=&lt;/span&gt;&lt;span style="font-size: 9.5pt; font-family: consolas; mso-bidi-font-family: consolas"&gt;"&lt;span style="color: blue"&gt;ProgramFilesFolder&lt;/span&gt;"&lt;span style="color: blue"&gt;&amp;gt;&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; mso-layout-grid-align: none"&gt;&lt;span style="font-size: 9.5pt; color: blue; font-family: consolas; mso-bidi-font-family: consolas"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&amp;lt;&lt;/span&gt;&lt;span style="font-size: 9.5pt; color: #a31515; font-family: consolas; mso-bidi-font-family: consolas"&gt;Directory&lt;/span&gt;&lt;span style="font-size: 9.5pt; color: blue; font-family: consolas; mso-bidi-font-family: consolas"&gt; &lt;/span&gt;&lt;span style="font-size: 9.5pt; color: red; font-family: consolas; mso-bidi-font-family: consolas"&gt;Id&lt;/span&gt;&lt;span style="font-size: 9.5pt; color: blue; font-family: consolas; mso-bidi-font-family: consolas"&gt;=&lt;/span&gt;&lt;span style="font-size: 9.5pt; font-family: consolas; mso-bidi-font-family: consolas"&gt;"&lt;span style="color: blue"&gt;INSTALLLOCATION&lt;/span&gt;"&lt;span style="color: blue"&gt; &lt;/span&gt;&lt;span style="color: red"&gt;Name&lt;/span&gt;&lt;span style="color: blue"&gt;=&lt;/span&gt;"&lt;span style="color: blue"&gt;Wix35Project1&lt;/span&gt;"&lt;span style="color: blue"&gt;&amp;gt;&lt;span style="mso-tab-count: 1"&gt; &lt;/span&gt;&lt;span style="mso-tab-count: 3"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; mso-layout-grid-align: none"&gt;&lt;span style="font-size: 9.5pt; color: blue; font-family: consolas; mso-bidi-font-family: consolas"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&amp;lt;&lt;/span&gt;&lt;span style="font-size: 9.5pt; color: #a31515; font-family: consolas; mso-bidi-font-family: consolas"&gt;Component&lt;/span&gt;&lt;span style="font-size: 9.5pt; color: blue; font-family: consolas; mso-bidi-font-family: consolas"&gt; &lt;/span&gt;&lt;span style="font-size: 9.5pt; color: red; font-family: consolas; mso-bidi-font-family: consolas"&gt;Id&lt;/span&gt;&lt;span style="font-size: 9.5pt; color: blue; font-family: consolas; mso-bidi-font-family: consolas"&gt;=&lt;/span&gt;&lt;span style="font-size: 9.5pt; font-family: consolas; mso-bidi-font-family: consolas"&gt;"&lt;span style="color: blue"&gt;ProductComponent&lt;/span&gt;"&lt;span style="color: blue"&gt; &lt;/span&gt;&lt;span style="color: red"&gt;Guid&lt;/span&gt;&lt;span style="color: blue"&gt;=&lt;/span&gt;"&lt;span style="color: blue"&gt;13b3ea27-e675-4e39-b225-62b67d2255d0&lt;/span&gt;"&lt;span style="color: blue"&gt;&amp;gt;&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; mso-layout-grid-align: none"&gt;&lt;span style="font-size: 9.5pt; color: blue; font-family: consolas; mso-bidi-font-family: consolas"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&amp;lt;&lt;/span&gt;&lt;span style="font-size: 9.5pt; color: #a31515; font-family: consolas; mso-bidi-font-family: consolas"&gt;File&lt;/span&gt;&lt;span style="font-size: 9.5pt; color: blue; font-family: consolas; mso-bidi-font-family: consolas"&gt; &lt;/span&gt;&lt;span style="font-size: 9.5pt; color: red; font-family: consolas; mso-bidi-font-family: consolas"&gt;Id&lt;/span&gt;&lt;span style="font-size: 9.5pt; color: blue; font-family: consolas; mso-bidi-font-family: consolas"&gt;=&lt;/span&gt;&lt;span style="font-size: 9.5pt; font-family: consolas; mso-bidi-font-family: consolas"&gt;"&lt;span style="color: blue"&gt;WindowsFormsApplication1File&lt;/span&gt;"&lt;span style="color: blue"&gt; &lt;/span&gt;&lt;span style="color: red"&gt;Name&lt;/span&gt;&lt;span style="color: blue"&gt;=&lt;/span&gt;"&lt;span style="color: blue"&gt;$(var.HelloWinform.TargetFileName)&lt;/span&gt;"&lt;span style="color: blue"&gt; &lt;/span&gt;&lt;span style="color: red"&gt;Source&lt;/span&gt;&lt;span style="color: blue"&gt;=&lt;/span&gt;"&lt;span style="color: blue"&gt;$(var.HelloWinform.TargetPath)&lt;/span&gt;"&lt;span style="color: blue"&gt; &lt;/span&gt;&lt;span style="color: red"&gt;DiskId&lt;/span&gt;&lt;span style="color: blue"&gt;=&lt;/span&gt;"&lt;span style="color: blue"&gt;1&lt;/span&gt;"&lt;span style="color: blue"&gt; &lt;/span&gt;&lt;span style="color: red"&gt;KeyPath&lt;/span&gt;&lt;span style="color: blue"&gt;=&lt;/span&gt;"&lt;span style="color: blue"&gt;yes&lt;/span&gt;"&lt;span style="color: blue"&gt;&amp;gt;&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; mso-layout-grid-align: none"&gt;&lt;span style="font-size: 9.5pt; color: blue; font-family: consolas; mso-bidi-font-family: consolas"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&amp;lt;&lt;/span&gt;&lt;span style="font-size: 9.5pt; color: #a31515; font-family: consolas; mso-bidi-font-family: consolas"&gt;netfx:NativeImage&lt;/span&gt;&lt;span style="font-size: 9.5pt; color: blue; font-family: consolas; mso-bidi-font-family: consolas"&gt; &lt;/span&gt;&lt;span style="font-size: 9.5pt; color: red; font-family: consolas; mso-bidi-font-family: consolas"&gt;Id&lt;/span&gt;&lt;span style="font-size: 9.5pt; color: blue; font-family: consolas; mso-bidi-font-family: consolas"&gt;=&lt;/span&gt;&lt;span style="font-size: 9.5pt; font-family: consolas; mso-bidi-font-family: consolas"&gt;"&lt;span style="color: blue"&gt;WindowsFormsApplication1File.exe&lt;/span&gt;"&lt;span style="color: blue"&gt; &lt;/span&gt;&lt;span style="color: red"&gt;Platform&lt;/span&gt;&lt;span style="color: blue"&gt;=&lt;/span&gt;"&lt;span style="color: blue"&gt;32bit&lt;/span&gt;"&lt;span style="color: blue"&gt; &lt;/span&gt;&lt;span style="color: red"&gt;Priority&lt;/span&gt;&lt;span style="color: blue"&gt;=&lt;/span&gt;"&lt;span style="color: blue"&gt;1&lt;/span&gt;"&lt;span style="color: blue"&gt; &lt;/span&gt;&lt;span style="color: red"&gt;Debug&lt;/span&gt;&lt;span style="color: blue"&gt;=&lt;/span&gt;"&lt;span style="color: blue"&gt;yes&lt;/span&gt;"&lt;span style="color: blue"&gt; &lt;/span&gt;&lt;span style="color: red"&gt;Dependencies&lt;/span&gt;&lt;span style="color: blue"&gt;=&lt;/span&gt;"&lt;span style="color: blue"&gt;no&lt;/span&gt;"&lt;span style="color: blue"&gt; /&amp;gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; mso-layout-grid-align: none"&gt;&lt;span style="font-size: 9.5pt; color: blue; font-family: consolas; mso-bidi-font-family: consolas"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&amp;lt;/&lt;/span&gt;&lt;span style="font-size: 9.5pt; color: #a31515; font-family: consolas; mso-bidi-font-family: consolas"&gt;File&lt;/span&gt;&lt;span style="font-size: 9.5pt; color: blue; font-family: consolas; mso-bidi-font-family: consolas"&gt;&amp;gt;&lt;/span&gt;&lt;span style="font-size: 9.5pt; font-family: consolas; mso-bidi-font-family: consolas"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; mso-layout-grid-align: none"&gt;&lt;span style="font-size: 9.5pt; color: blue; font-family: consolas; mso-bidi-font-family: consolas"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&amp;lt;/&lt;/span&gt;&lt;span style="font-size: 9.5pt; color: #a31515; font-family: consolas; mso-bidi-font-family: consolas"&gt;Component&lt;/span&gt;&lt;span style="font-size: 9.5pt; color: blue; font-family: consolas; mso-bidi-font-family: consolas"&gt;&amp;gt;&lt;/span&gt;&lt;span style="font-size: 9.5pt; font-family: consolas; mso-bidi-font-family: consolas"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; mso-layout-grid-align: none"&gt;&lt;span style="font-size: 9.5pt; color: blue; font-family: consolas; mso-bidi-font-family: consolas"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&amp;lt;/&lt;/span&gt;&lt;span style="font-size: 9.5pt; color: #a31515; font-family: consolas; mso-bidi-font-family: consolas"&gt;Directory&lt;/span&gt;&lt;span style="font-size: 9.5pt; color: blue; font-family: consolas; mso-bidi-font-family: consolas"&gt;&amp;gt;&lt;/span&gt;&lt;span style="font-size: 9.5pt; font-family: consolas; mso-bidi-font-family: consolas"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; mso-layout-grid-align: none"&gt;&lt;span style="font-size: 9.5pt; color: blue; font-family: consolas; mso-bidi-font-family: consolas"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&amp;lt;/&lt;/span&gt;&lt;span style="font-size: 9.5pt; color: #a31515; font-family: consolas; mso-bidi-font-family: consolas"&gt;Directory&lt;/span&gt;&lt;span style="font-size: 9.5pt; color: blue; font-family: consolas; mso-bidi-font-family: consolas"&gt;&amp;gt;&lt;/span&gt;&lt;span style="font-size: 9.5pt; font-family: consolas; mso-bidi-font-family: consolas"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; mso-layout-grid-align: none"&gt;&lt;span style="font-size: 9.5pt; color: blue; font-family: consolas; mso-bidi-font-family: consolas"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&amp;lt;/&lt;/span&gt;&lt;span style="font-size: 9.5pt; color: #a31515; font-family: consolas; mso-bidi-font-family: consolas"&gt;Directory&lt;/span&gt;&lt;span style="font-size: 9.5pt; color: blue; font-family: consolas; mso-bidi-font-family: consolas"&gt;&amp;gt;&lt;/span&gt;&lt;span style="font-size: 9.5pt; font-family: consolas; mso-bidi-font-family: consolas"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; mso-layout-grid-align: none"&gt;&lt;span style="font-size: 9.5pt; font-family: consolas; mso-bidi-font-family: consolas"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; mso-layout-grid-align: none"&gt;&lt;span style="font-size: 9.5pt; color: blue; font-family: consolas; mso-bidi-font-family: consolas"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&amp;lt;&lt;/span&gt;&lt;span style="font-size: 9.5pt; color: #a31515; font-family: consolas; mso-bidi-font-family: consolas"&gt;Feature&lt;/span&gt;&lt;span style="font-size: 9.5pt; color: blue; font-family: consolas; mso-bidi-font-family: consolas"&gt; &lt;/span&gt;&lt;span style="font-size: 9.5pt; color: red; font-family: consolas; mso-bidi-font-family: consolas"&gt;Id&lt;/span&gt;&lt;span style="font-size: 9.5pt; color: blue; font-family: consolas; mso-bidi-font-family: consolas"&gt;=&lt;/span&gt;&lt;span style="font-size: 9.5pt; font-family: consolas; mso-bidi-font-family: consolas"&gt;"&lt;span style="color: blue"&gt;ProductFeature&lt;/span&gt;"&lt;span style="color: blue"&gt; &lt;/span&gt;&lt;span style="color: red"&gt;Title&lt;/span&gt;&lt;span style="color: blue"&gt;=&lt;/span&gt;"&lt;span style="color: blue"&gt;Wix35Project1&lt;/span&gt;"&lt;span style="color: blue"&gt; &lt;/span&gt;&lt;span style="color: red"&gt;Level&lt;/span&gt;&lt;span style="color: blue"&gt;=&lt;/span&gt;"&lt;span style="color: blue"&gt;1&lt;/span&gt;"&lt;span style="color: blue"&gt;&amp;gt;&lt;span style="mso-tab-count: 3"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; mso-layout-grid-align: none"&gt;&lt;span style="font-size: 9.5pt; color: blue; font-family: consolas; mso-bidi-font-family: consolas"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&amp;lt;&lt;/span&gt;&lt;span style="font-size: 9.5pt; color: #a31515; font-family: consolas; mso-bidi-font-family: consolas"&gt;ComponentRef&lt;/span&gt;&lt;span style="font-size: 9.5pt; color: blue; font-family: consolas; mso-bidi-font-family: consolas"&gt; &lt;/span&gt;&lt;span style="font-size: 9.5pt; color: red; font-family: consolas; mso-bidi-font-family: consolas"&gt;Id&lt;/span&gt;&lt;span style="font-size: 9.5pt; color: blue; font-family: consolas; mso-bidi-font-family: consolas"&gt;=&lt;/span&gt;&lt;span style="font-size: 9.5pt; font-family: consolas; mso-bidi-font-family: consolas"&gt;"&lt;span style="color: blue"&gt;ProductComponent&lt;/span&gt;"&lt;span style="color: blue"&gt; /&amp;gt;&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; mso-layout-grid-align: none"&gt;&lt;span style="font-size: 9.5pt; color: blue; font-family: consolas; mso-bidi-font-family: consolas"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&amp;lt;/&lt;/span&gt;&lt;span style="font-size: 9.5pt; color: #a31515; font-family: consolas; mso-bidi-font-family: consolas"&gt;Feature&lt;/span&gt;&lt;span style="font-size: 9.5pt; color: blue; font-family: consolas; mso-bidi-font-family: consolas"&gt;&amp;gt;&lt;/span&gt;&lt;span style="font-size: 9.5pt; font-family: consolas; mso-bidi-font-family: consolas"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; mso-layout-grid-align: none"&gt;&lt;span style="font-size: 9.5pt; color: blue; font-family: consolas; mso-bidi-font-family: consolas"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/span&gt;&amp;lt;/&lt;/span&gt;&lt;span style="font-size: 9.5pt; color: #a31515; font-family: consolas; mso-bidi-font-family: consolas"&gt;Product&lt;/span&gt;&lt;span style="font-size: 9.5pt; color: blue; font-family: consolas; mso-bidi-font-family: consolas"&gt;&amp;gt;&lt;/span&gt;&lt;span style="font-size: 9.5pt; font-family: consolas; mso-bidi-font-family: consolas"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; mso-layout-grid-align: none"&gt;&lt;span style="font-size: 9.5pt; color: blue; font-family: consolas; mso-bidi-font-family: consolas"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="font-size: 9.5pt; color: #a31515; font-family: consolas; mso-bidi-font-family: consolas"&gt;Wix&lt;/span&gt;&lt;span style="font-size: 9.5pt; color: blue; font-family: consolas; mso-bidi-font-family: consolas"&gt;&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/p&gt; &lt;p class="MsoNormal"&gt;Specifying a priority of 0 ensures that the native image compilation will be done synchronously when the installer is running. Specifying a priority value of 1, 2 or 3 will make the compilation occur in the background. Priority 1 has the effect that assemblies are immediately compiled in the background, priority 2 means the assemblies will be compiled after the priority 1 assemblies are done, and priority 3 assemblies are compiled at machine idle time. If no priority value is specified, the priority will default to be 3. The WiX toolset will issue an “ngen install” or “ngen uninstall” action depending on whether the resulting MSI is being used to install the application or remove it from the machine. The toolset will always issue an “ngen update /queue” as the last command, in order to trigger the NGen service to recompile any native images that may be out of date. &lt;/p&gt; &lt;p class="MsoNormal"&gt;&amp;nbsp;&lt;/p&gt; &lt;p class="MsoNormal"&gt;&lt;u&gt;Further Reading&lt;/u&gt;&lt;/p&gt; &lt;p class="MsoListParagraphCxSpFirst" style="text-indent: -0.25in; mso-list: l0 level1 lfo3"&gt;&lt;span style="mso-fareast-font-family: calibri; mso-fareast-theme-font: minor-latin; mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin"&gt;&lt;span style="mso-list: ignore"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span style="mso-fareast-font-family: calibri; mso-fareast-theme-font: minor-latin; mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin"&gt;&lt;span style="mso-list: ignore"&gt;1&amp;gt;&lt;span style="font: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;How to NGen files in an MSI-based setup package using WiX: &lt;a href="https://blogs.msdn.com/astebner/archive/2007/03/03/how-to-ngen-files-in-an-msi-based-setup-package-using-wix.aspx"&gt;https://blogs.msdn.com/astebner/archive/2007/03/03/how-to-ngen-files-in-an-msi-based-setup-package-using-wix.aspx&lt;/a&gt; &lt;/p&gt; &lt;p class="MsoListParagraphCxSpMiddle" style="text-indent: -0.25in; mso-list: l0 level1 lfo3"&gt;&lt;span style="mso-fareast-font-family: calibri; mso-fareast-theme-font: minor-latin; mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin"&gt;&lt;span style="mso-list: ignore"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span style="mso-fareast-font-family: calibri; mso-fareast-theme-font: minor-latin; mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin"&gt;&lt;span style="mso-list: ignore"&gt;2&amp;gt;&lt;span style="font: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;Introducing NGen Support in WiX: &lt;a href="http://installing.blogspot.com/2006/06/ngen-support-in-wix.html"&gt;http://installing.blogspot.com/2006/06/ngen-support-in-wix.html&lt;/a&gt; &lt;/p&gt; &lt;p class="MsoListParagraphCxSpMiddle" style="text-indent: -0.25in; mso-list: l0 level1 lfo3"&gt;&lt;span style="mso-fareast-font-family: calibri; mso-fareast-theme-font: minor-latin; mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin"&gt;&lt;span style="mso-list: ignore"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span style="mso-fareast-font-family: calibri; mso-fareast-theme-font: minor-latin; mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin"&gt;&lt;span style="mso-list: ignore"&gt;3&amp;gt;&lt;span style="font: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;Synchronous versus Asynchronous Native Image compilation: &lt;a href="http://msdn.microsoft.com/en-us/library/ms165074(v=VS.80).aspx"&gt;http://msdn.microsoft.com/en-us/library/ms165074(v=VS.80).aspx&lt;/a&gt; &lt;/p&gt; &lt;p class="MsoListParagraphCxSpLast" style="text-indent: -0.25in; mso-list: l0 level1 lfo3"&gt;&lt;span style="mso-fareast-font-family: calibri; mso-fareast-theme-font: minor-latin; mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin"&gt;&lt;span style="mso-list: ignore"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 4&amp;gt;&lt;span style="font: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;Installing file into the GAC using WiX: &lt;a href="http://blogs.msdn.com/astebner/archive/2007/06/21/3450539.aspx"&gt;http://blogs.msdn.com/astebner/archive/2007/06/21/3450539.aspx&lt;/a&gt; &lt;/p&gt; &lt;p class="MsoListParagraphCxSpLast" style="text-indent: -0.25in; mso-list: l0 level1 lfo3"&gt;&amp;nbsp;&lt;/p&gt; &lt;h5&gt;Wrapping it up!&lt;/h5&gt; &lt;p class="MsoNormal"&gt;That summarizes the very basics of using the Windows Installer XML toolset to invoke NGen.exe in an installer for your application. This article hopefully articulates the various steps needed to get the environment setup, and points out nuances along the way. We’d love to hear what you think! Have you used WiX in the past to enable NGen in your installer? If not, what technology do you use? How was your experience? Please use the comments section below for any feedback and questions.&lt;/p&gt; &lt;p class="MsoNormal"&gt;&amp;nbsp;&lt;/p&gt; &lt;p class="MsoNormal"&gt;&lt;o:p&gt;&lt;/o:p&gt;&amp;nbsp;&lt;/p&gt; &lt;p class="MsoNormal"&gt;Janine Zhang, Pracheeti Nagarkar&lt;/p&gt; &lt;p class="MsoNormal"&gt;CLR Team &lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10003354" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/b/clrcodegeneration/archive/tags/NGen/">NGen</category><category domain="http://blogs.msdn.com/b/clrcodegeneration/archive/tags/Pracheeti+Nagarkar/">Pracheeti Nagarkar</category><category domain="http://blogs.msdn.com/b/clrcodegeneration/archive/tags/Janine+Zhang/">Janine Zhang</category><category domain="http://blogs.msdn.com/b/clrcodegeneration/archive/tags/WiX/">WiX</category><category domain="http://blogs.msdn.com/b/clrcodegeneration/archive/tags/Visual+Studio/">Visual Studio</category></item><item><title>NGen: Measuring Working Set with VMMap</title><link>http://blogs.msdn.com/b/clrcodegeneration/archive/2010/04/27/ngen-measuring-working-set-with-vmmap.aspx</link><pubDate>Tue, 27 Apr 2010 17:59:10 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10003350</guid><dc:creator>pracheeti</dc:creator><slash:comments>2</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.msdn.com/b/clrcodegeneration/rsscomments.aspx?WeblogPostID=10003350</wfw:commentRss><comments>http://blogs.msdn.com/b/clrcodegeneration/archive/2010/04/27/ngen-measuring-working-set-with-vmmap.aspx#comments</comments><description>&lt;p&gt;This is article 3 of 4 in the &lt;strong&gt;&lt;a href="http://blogs.msdn.com/clrcodegeneration/archive/2010/04/27/ngen-walk-through-series.aspx"&gt;NGen: Walk-through Series&lt;/a&gt;&lt;/strong&gt;.&lt;/p&gt; &lt;p&gt;This article is part of a series of blog posts intended to help managed code developers analyze if Native Image Generation (NGen) technology provides benefit to their application/library. NGen refers to the process of pre-compiling Microsoft® Intermediate Language (MSIL) executables into machine code prior to execution time. &lt;/p&gt; &lt;p class="MsoNormal"&gt;Working set is the amount of physical memory that has been assigned by the operating system to a given process. For managed applications, NGen helps to reduce the working set in 2 ways: the application will not need to load the JIT into the process (process specific benefit), and the native image for a library will be shared across multiple managed applications running at the same time (machine wide benefit). As with everything performance related, you can only decide whether using NGen benefits working set for your application by measuring it. This article will walk through how to perform such measurements and what to watch for. &lt;/p&gt; &lt;p class="MsoNormal"&gt;&amp;nbsp;&lt;/p&gt; &lt;p class="MsoNormal"&gt;This article contains the following sections: &lt;i style="mso-bidi-font-style: normal"&gt;Getting Started with VMMap, The Basics: Is the JIT getting loaded?, The Basics: Using the GAC, Impact of Base Address Collisions (Rebasing): Pre-Vista, Impact of Base Address Collisions (Rebasing): What about Vista?, Cross-Process Sharing of Native Images, Wrapping it up!&lt;/i&gt;&amp;nbsp;&lt;/p&gt; &lt;h5&gt;Getting Started with VMMap&lt;/h5&gt; &lt;p class="MsoNormal"&gt;Download: &lt;a href="http://technet.microsoft.com/en-us/sysinternals/dd535533.aspx"&gt;http://technet.microsoft.com/en-us/sysinternals/dd535533.aspx&lt;/a&gt; &lt;/p&gt; &lt;p class="MsoNormal"&gt;&amp;nbsp;&lt;/p&gt; &lt;p class="MsoNormal"&gt;VMMap is a handy tool that provides visualization for process memory usage. In order to easily launch it on a currently running process, use the command “vmmap.exe –p &amp;lt;name_of_process_exe&amp;gt;”. &lt;/p&gt; &lt;p class="MsoNormal"&gt;&amp;nbsp;&lt;/p&gt; &lt;p class="MsoNormal"&gt;&lt;a href="http://blogs.msdn.com/blogfiles/clrcodegeneration/WindowsLiveWriter/NGenMeasuringWorkingSetwithVMMap_10D1C/VMMap_Table1_2.jpg"&gt;&lt;img title="VMMap_Table1" style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="315" alt="VMMap_Table1" src="http://blogs.msdn.com/blogfiles/clrcodegeneration/WindowsLiveWriter/NGenMeasuringWorkingSetwithVMMap_10D1C/VMMap_Table1_thumb.jpg" width="498" border="0"&gt;&lt;/a&gt; &lt;/p&gt; &lt;p class="MsoNormal"&gt;&lt;span style="mso-no-proof: yes"&gt;&lt;?xml:namespace prefix = v /&gt;&lt;v:shapetype id="_x0000_t75" coordsize="21600,21600" o:spt="75" o:preferrelative="t" path="m@4@5l@4@11@9@11@9@5xe" filled="f" stroked="f"&gt;&lt;v:stroke joinstyle="miter"&gt;&lt;/v:stroke&gt;&lt;v:formulas&gt;&lt;v:f eqn="if lineDrawn pixelLineWidth 0"&gt;&lt;/v:f&gt;&lt;v:f eqn="sum @0 1 0"&gt;&lt;/v:f&gt;&lt;v:f eqn="sum 0 0 @1"&gt;&lt;/v:f&gt;&lt;v:f eqn="prod @2 1 2"&gt;&lt;/v:f&gt;&lt;v:f eqn="prod @3 21600 pixelWidth"&gt;&lt;/v:f&gt;&lt;v:f eqn="prod @3 21600 pixelHeight"&gt;&lt;/v:f&gt;&lt;v:f eqn="sum @0 0 1"&gt;&lt;/v:f&gt;&lt;v:f eqn="prod @6 1 2"&gt;&lt;/v:f&gt;&lt;v:f eqn="prod @7 21600 pixelWidth"&gt;&lt;/v:f&gt;&lt;v:f eqn="sum @8 21600 0"&gt;&lt;/v:f&gt;&lt;v:f eqn="prod @7 21600 pixelHeight"&gt;&lt;/v:f&gt;&lt;v:f eqn="sum @10 21600 0"&gt;&lt;/v:f&gt;&lt;/v:formulas&gt;&lt;v:path o:extrusionok="f" gradientshapeok="t" o:connecttype="rect"&gt;&lt;/v:path&gt;&lt;?xml:namespace prefix = o /&gt;&lt;o:lock v:ext="edit" aspectratio="t"&gt;&lt;/o:lock&gt;&lt;/v:shapetype&gt;&lt;v:shape id="Picture_x0020_1" style="visibility: visible; width: 680.45pt; height: 427.05pt; mso-wrap-style: square" o:spid="_x0000_i1030" type="#_x0000_t75" alt="VMMap_Table1.jpg"&gt;&lt;v:imagedata src="file:///C:\Users\pnag\AppData\Local\Temp\2\msohtmlclip1\01\clip_image001.jpg" o:title="VMMap_Table1"&gt;&lt;/v:imagedata&gt;&lt;/v:shape&gt;&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;em&gt;Screenshot 1: Overall View&lt;/em&gt;&lt;/p&gt; &lt;p class="MsoNormal"&gt;In Screenshot 1 above, observe the various memory types listed in the rows in the upper pane (Image, Private, Shareable etc.). For each memory type (for example, Private), there are several columns that detail how that memory type breaks down; how much is the Committed memory, Total Working Set, Private Working Set, Shareable Working Set etc. Note that the precise definition of each of these is available from the Help-&amp;gt;Quick Help menu in the UI. The Image memory type is easier to use for tracking purposes because it maps to the executable file that launched the current process being analyzed. It also enables a drill down into which other files were loaded into the process and how much of memory they consume. The goal here is to reduce the Total WS (benefits the application) and reduce the Private WS (could benefit the machine wide resource usage). &lt;/p&gt; &lt;p class="MsoNormal"&gt;&amp;nbsp;&lt;/p&gt; &lt;p class="MsoNormal"&gt;In order to see the detailed break-down of the Image memory type, in the upper pane, select the row named Image. The lower pane will now display the list of all files loaded into this process and the resource usage of each file. See Screenshot 2 below.&lt;/p&gt; &lt;p class="MsoNormal"&gt;&lt;span style="mso-no-proof: yes"&gt;&lt;v:shape id="Picture_x0020_2" style="visibility: visible; width: 802.6pt; height: 530.1pt; mso-wrap-style: square" o:spid="_x0000_i1029" type="#_x0000_t75" alt="Vmmap_Screenshot2.jpg"&gt;&lt;v:imagedata src="file:///C:\Users\pnag\AppData\Local\Temp\2\msohtmlclip1\01\clip_image002.jpg" o:title="Vmmap_Screenshot2" croptop="174f" cropleft="165f"&gt;&lt;/v:imagedata&gt;&lt;/v:shape&gt;&lt;/span&gt;&lt;/p&gt; &lt;h5&gt;&lt;a href="http://blogs.msdn.com/blogfiles/clrcodegeneration/WindowsLiveWriter/NGenMeasuringWorkingSetwithVMMap_10D1C/Vmmap_Screenshot2_2.jpg"&gt;&lt;img title="Vmmap_Screenshot2" style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="339" alt="Vmmap_Screenshot2" src="http://blogs.msdn.com/blogfiles/clrcodegeneration/WindowsLiveWriter/NGenMeasuringWorkingSetwithVMMap_10D1C/Vmmap_Screenshot2_thumb.jpg" width="514" border="0"&gt;&lt;/a&gt; &lt;/h5&gt; &lt;p&gt;&lt;em&gt;Screenshot 2: Image memory type view&lt;/em&gt;&lt;/p&gt; &lt;p class="MsoNormal"&gt;For each file (file name is visible in the right-most Details column, see Screenshot 2 above), the resource usage of the file is further broken down into Size, Committed, Total WS, Private WS, Shareable WS and Shared WS. We are interested in the working set columns (Total, Private, Shareable and Shared). &lt;/p&gt; &lt;p class="MsoNormal"&gt;&amp;nbsp;&lt;/p&gt; &lt;p class="MsoNormal"&gt;Let’s understand one of the rows shown above, for the file mscorlib.ni.dll. &lt;/p&gt; &lt;p class="MsoNormal"&gt;&amp;nbsp;&lt;/p&gt; &lt;p class="MsoNormal"&gt;Size = 13,936K. This refers to the size of the image which comes from the PE header of the file. For the curious, to see where this number comes from, do the following: From a Visual Studio SDK command prompt use “link.exe /dump /headers &amp;lt;PathToFile&amp;gt;”, and look under the Optional Header Values for “size of image” in hex. &lt;/p&gt; &lt;p class="MsoNormal"&gt;&amp;nbsp;&lt;/p&gt; &lt;p class="MsoNormal"&gt;Committed = 13,936K. This is the amount of allocation backed by virtual memory. &lt;/p&gt; &lt;p class="MsoNormal"&gt;&amp;nbsp;&lt;/p&gt; &lt;p class="MsoNormal"&gt;Total WS = 788K. This is the amount of physical memory that is assigned to this file. &lt;/p&gt; &lt;p class="MsoNormal"&gt;&amp;nbsp;&lt;/p&gt; &lt;p class="MsoNormal"&gt;Private WS = 64 K. Of the total physical memory assigned to this file, this amount cannot be shared with other simultaneously running processes that also need this file. &lt;/p&gt; &lt;p class="MsoNormal"&gt;&amp;nbsp;&lt;/p&gt; &lt;p class="MsoNormal"&gt;Shareable WS=724K. Of the total physical memory assigned to this file, this amount could be shared with other simultaneously running processes that also need this file. &lt;/p&gt; &lt;p class="MsoNormal"&gt;&amp;nbsp;&lt;/p&gt; &lt;p class="MsoNormal"&gt;Shared WS = 684K. Of the total Shareable working set, this is the amount that is currently being shared with another process that also needs this file. If there were no other process that needs this file, this number could be 0.&lt;/p&gt; &lt;p class="MsoNormal"&gt;&amp;nbsp;&lt;/p&gt; &lt;p class="MsoNormal"&gt;Supported Environments: Windows XP and newer Operating Systems. 32 bit and 64 bit. &lt;/p&gt; &lt;p class="MsoNormal"&gt;&amp;nbsp;&lt;/p&gt; &lt;p class="MsoNormal"&gt;&lt;u&gt;Further Reading&lt;/u&gt; &lt;/p&gt; &lt;p class="MsoListParagraph" style="text-indent: -0.25in; mso-list: l0 level1 lfo1"&gt;&lt;span style="mso-fareast-font-family: calibri; mso-fareast-theme-font: minor-latin; mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin"&gt;&lt;span style="mso-list: ignore"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1&amp;gt;&lt;span style="font: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;VMMap: &lt;a href="http://technet.microsoft.com/en-us/sysinternals/dd535533.aspx"&gt;http://technet.microsoft.com/en-us/sysinternals/dd535533.aspx&lt;/a&gt;&lt;/p&gt; &lt;p class="MsoListParagraph" style="text-indent: -0.25in; mso-list: l0 level1 lfo1"&gt;&amp;nbsp;&lt;/p&gt; &lt;h5&gt;The Basics: Is the JIT getting loaded?&lt;/h5&gt; &lt;p class="MsoNormal"&gt;One of the quickest ways to reduce the total working set of a managed application is to ensure that only essential modules get loaded into the process. &lt;/p&gt; &lt;p class="MsoNormal"&gt;&amp;nbsp;&lt;/p&gt; &lt;p class="MsoNormal"&gt;If the application and its entire closure of dependencies has been NGen’d, in the general case it is expected that the JIT will not get loaded. In the Details column in the lower pane of VMMap, check that clrjit.dll (.Net Framework v4.0) or mscorjit.dll (Pre-.Net Framework v4.0) has not been loaded. &lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&lt;/span&gt;If it has been loaded, it indicates that something within your application is getting JIT-ed. This may be an entire dependency that was not NGen’d or it may be a few methods within an assembly for which native code could not get generated. For the former case, Fusion Log Viewer can be used to determine the assembly for which a native image could not be found. For the latter case, the JIT Managed Debugging Assistant helps answer the question around which method the JIT is getting invoked for. See the links below in Further Reading for details on how these tools can be used. &lt;/p&gt; &lt;p class="MsoNormal"&gt;&amp;nbsp;&lt;/p&gt; &lt;p class="MsoNormal"&gt;Working Set Impact: When the JIT is loaded into the process, it contributes ~200K to the Total WS. This does not seem like a whole lot when looked at independently. However, in order to invoke the JIT, the CLR’s engine itself executes more code and as a result more pages from the engine’s DLL (called clr.dll in .Net Framework 4.0 or called mscorwks.dll in prior releases) are pulled into the Total WS. In the example I used, the Total WS of clr.dll went up by ~100K. That’s not all. Since a particular assembly say A.dll (or a part of it) needed to get JIT compiled, the IL for that assembly also needed to be loaded. Depending on the size of this assembly (or the size of the method that needed to be JIT compiled), the IL also contributes to the Total WS. Moreover, since the JIT compiled code cannot be shared across process boundaries, if A.dll was also needed subsequently by another process on the machine, that new process would need to incur its own Total WS cost to JIT compile the code. &lt;/p&gt; &lt;p class="MsoNormal"&gt;&amp;nbsp;&lt;/p&gt; &lt;p class="MsoNormal"&gt;Of course, if the size of the assembly (or method within the assembly) being JIT compiled is small, you may not care about this working set hit. Doing your own measurements will help you reach a decision. &lt;/p&gt; &lt;p class="MsoNormal"&gt;&amp;nbsp;&lt;/p&gt; &lt;p class="MsoNormal"&gt;&lt;u&gt;Further Reading&lt;/u&gt;&lt;/p&gt; &lt;p class="MsoListParagraphCxSpFirst" style="text-indent: -0.25in; mso-list: l1 level1 lfo2"&gt;&lt;span style="mso-fareast-font-family: calibri; mso-fareast-theme-font: minor-latin; mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin"&gt;&lt;span style="mso-list: ignore"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1&amp;gt;&lt;span style="font: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;Fusion Log Viewer: &lt;a href="http://msdn.microsoft.com/en-us/library/e74a18c4.aspx"&gt;http://msdn.microsoft.com/en-us/library/e74a18c4.aspx&lt;/a&gt; &lt;/p&gt; &lt;p class="MsoListParagraphCxSpLast" style="text-indent: -0.25in; mso-list: l1 level1 lfo2"&gt;&lt;span style="mso-fareast-font-family: calibri; mso-fareast-theme-font: minor-latin; mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin"&gt;&lt;span style="mso-list: ignore"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 2&amp;gt;&lt;span style="font: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;JitCompilationStart Managed Debugging Assistant (MDA): &lt;a href="http://msdn.microsoft.com/en-us/library/fw872k46(VS.80).aspx"&gt;http://msdn.microsoft.com/en-us/library/fw872k46(VS.80).aspx&lt;/a&gt;&amp;nbsp;&lt;/p&gt; &lt;p class="MsoListParagraphCxSpLast" style="text-indent: -0.25in; mso-list: l1 level1 lfo2"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/p&gt; &lt;h5&gt;The Basics: Using the GAC&lt;/h5&gt; &lt;p class="MsoNormal"&gt;In some cases, even when the JIT does not appear in the list of modules loaded in the process, it is possible that both the IL as well as the native image will get loaded for a particular assembly. Note that the application’s main executable will be listed twice in VMMap – the first listing corresponds to mapping the IL and the second corresponds to loading the native image. This is expected. See Screenshot 3 below. Note that when a native image is loaded for an assembly, the Details column will show a path of the type C:\Windows\assembly\NativeImages_*. &lt;/p&gt; &lt;p class="MsoNormal"&gt;&lt;span style="mso-no-proof: yes"&gt;&lt;v:shape id="Picture_x0020_3" style="visibility: visible; width: 794.8pt; height: 497.65pt; mso-wrap-style: square" o:spid="_x0000_i1028" type="#_x0000_t75" alt="Vmmap_Screenshot3.jpg"&gt;&lt;v:imagedata src="file:///C:\Users\pnag\AppData\Local\Temp\2\msohtmlclip1\01\clip_image003.jpg" o:title="Vmmap_Screenshot3"&gt;&lt;/v:imagedata&gt;&lt;/v:shape&gt;&lt;/span&gt;&lt;/p&gt; &lt;h5&gt;&lt;a href="http://blogs.msdn.com/blogfiles/clrcodegeneration/WindowsLiveWriter/NGenMeasuringWorkingSetwithVMMap_10D1C/Vmmap_Screenshot3_2.jpg"&gt;&lt;img title="Vmmap_Screenshot3" style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="349" alt="Vmmap_Screenshot3" src="http://blogs.msdn.com/blogfiles/clrcodegeneration/WindowsLiveWriter/NGenMeasuringWorkingSetwithVMMap_10D1C/Vmmap_Screenshot3_thumb.jpg" width="555" border="0"&gt;&lt;/a&gt; &lt;/h5&gt; &lt;p&gt;&lt;em&gt;&lt;u&gt;Screenshot 3: Example of both IL (foo.dll) and native image (foo.ni.dll) contributing to Total WS&lt;/u&gt; &lt;/em&gt;&lt;/p&gt; &lt;p class="MsoNormal"&gt;However, for any other managed assembly in the list of modules in the process, having both the IL and the native image contribute to Total WS may be preventable. A couple of the main reasons why both IL and native image may appear loaded are if the assembly is a mixed-mode assembly or if the assembly being loaded lives outside the GAC. For the former case, loading of both IL and Native Image for a mixed mode assembly is not preventable. In the latter case, installing the assembly into the GAC will stop the additional load of the IL. Again, it is important to keep in mind that the additional load of the IL assembly depends on the size of the assembly itself – it may not be large enough to make you want to install the assembly into the GAC. &lt;/p&gt; &lt;p class="MsoNormal"&gt;&amp;nbsp;&lt;/p&gt; &lt;p class="MsoNormal"&gt;Aside: Speaking of the GAC, prior to .Net Framework 3.5 SP1, it was strongly recommended that all strong name signed libraries used by an application be installed into the GAC. The reason was that the for strong name signed assemblies outside the GAC, the CLR would need to load the entire IL assembly and compute a hash over its contents and compare it with the assembly’s signature before permitting the load of the native image for security reasons. Starting with .Net Framework 3.5 SP1, a feature called strong name bypass eliminates the need to compute this hash for full trust cases. In Screenshot 3, the assembly foo.dll is strong name signed and outside the GAC. The IL still gets mapped and contributes to Total WS, but we do not incur an additional working set hit from clr.dll for computing the strong name hash. As an experiment, if the strong name bypass feature is disabled, the working set for clr.dll will be higher. &lt;/p&gt; &lt;p class="MsoNormal"&gt;&amp;nbsp;&lt;/p&gt; &lt;p class="MsoNormal"&gt;&lt;u&gt;Further Reading&lt;/u&gt; &lt;/p&gt; &lt;p class="MsoListParagraph" style="text-indent: -0.25in; mso-list: l2 level1 lfo3"&gt;&lt;span style="mso-fareast-font-family: calibri; mso-fareast-theme-font: minor-latin; mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin"&gt;&lt;span style="mso-list: ignore"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span style="mso-fareast-font-family: calibri; mso-fareast-theme-font: minor-latin; mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin"&gt;&lt;span style="mso-list: ignore"&gt;1&amp;gt;&lt;span style="font: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;Strong Name Bypass: &lt;a href="http://blogs.msdn.com/shawnfa/archive/2008/05/14/strong-name-bypass.aspx"&gt;http://blogs.msdn.com/shawnfa/archive/2008/05/14/strong-name-bypass.aspx&lt;/a&gt;&amp;nbsp;&lt;/p&gt; &lt;p class="MsoListParagraph" style="text-indent: -0.25in; mso-list: l2 level1 lfo3"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/p&gt; &lt;h5&gt;Impact of Base Address Collisions (Rebasing): Pre-Vista&lt;/h5&gt; &lt;p class="MsoNormal"&gt;When rebasing occurs, the Private WS increases and the Shareable WS decreases; this is not optimal for machine-wide memory usage. Let’s look at why rebasing affects working set. &lt;/p&gt; &lt;p class="MsoNormal"&gt;&amp;nbsp;&lt;/p&gt; &lt;p class="MsoNormal"&gt;Native Images typically get loaded at an address that is specified in its PE Header. From a Visual Studio Command Prompt, do a “link.exe /dump /headers &amp;lt;PathToNativeImageFile&amp;gt;”. Screenshot 4 below shows this.&lt;/p&gt; &lt;p class="MsoNormal"&gt;&amp;nbsp;&lt;/p&gt; &lt;p class="MsoNormal"&gt;&lt;a href="http://blogs.msdn.com/blogfiles/clrcodegeneration/WindowsLiveWriter/NGenMeasuringWorkingSetwithVMMap_10D1C/Link_ScreenShot4_2.jpg"&gt;&lt;img title="Link_ScreenShot4" style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="366" alt="Link_ScreenShot4" src="http://blogs.msdn.com/blogfiles/clrcodegeneration/WindowsLiveWriter/NGenMeasuringWorkingSetwithVMMap_10D1C/Link_ScreenShot4_thumb.jpg" width="506" border="0"&gt;&lt;/a&gt; &lt;/p&gt; &lt;p class="MsoNormal"&gt;&lt;span style="mso-no-proof: yes"&gt;&lt;v:shape id="Picture_x0020_4" style="visibility: visible; width: 356.45pt; height: 256.95pt; mso-wrap-style: square" o:spid="_x0000_i1027" type="#_x0000_t75" alt="Link_ScreenShot4.jpg"&gt;&lt;v:imagedata src="file:///C:\Users\pnag\AppData\Local\Temp\2\msohtmlclip1\01\clip_image004.jpg" o:title="Link_ScreenShot4"&gt;&lt;/v:imagedata&gt;&lt;/v:shape&gt;&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;em&gt;Screenshot 4: Preferred Base Address&lt;/em&gt;&lt;/p&gt; &lt;p class="MsoNormal"&gt;So who chooses the base address? Unless you specify a base address during compile time (for instance, via the /baseaddress option to csc.exe), the CLR will pick one! If a base address was not specified during compile time, the compiler assigns a default base address of 0x4000000. When creating a native image, the CLR translates this default address for an executable to 0x30000000 and for a DLL to 0x31000000. Screenshot 5 shows the DLL default above, as picked by the CLR. This address is the one used by the operating system to load the PE file at. VMMap shows which address was used in the very first column “Address” in the lower pane. &lt;/p&gt; &lt;p class="MsoNormal"&gt;&amp;nbsp;&lt;/p&gt; &lt;p class="MsoNormal"&gt;Naturally, if there are multiple managed DLLs loaded into the process with the same preferred base address assigned, not all can be loaded at the same address. The first DLL native image to be loaded will occupy 0x31000000 and all subsequent DLL native images will get loaded at other addresses; this is called rebasing. The SDK tool Fusion Log Viewer will log when a native image gets rebased. You should expect to see a message similar to the one shown in Screenshot 5 below, if rebasing occurred.&lt;/p&gt; &lt;p class="MsoNormal"&gt;&lt;span style="mso-no-proof: yes"&gt;&lt;v:shape id="Picture_x0020_0" style="visibility: visible; width: 658.6pt; height: 346.6pt; mso-wrap-style: square" o:spid="_x0000_i1026" type="#_x0000_t75" alt="Screenshot6_Fuslogvw.jpg"&gt;&lt;v:imagedata src="file:///C:\Users\pnag\AppData\Local\Temp\2\msohtmlclip1\01\clip_image005.jpg" o:title="Screenshot6_Fuslogvw"&gt;&lt;/v:imagedata&gt;&lt;/v:shape&gt;&lt;/span&gt;&lt;/p&gt; &lt;h5&gt;&lt;a href="http://blogs.msdn.com/blogfiles/clrcodegeneration/WindowsLiveWriter/NGenMeasuringWorkingSetwithVMMap_10D1C/Screenshot6_Fuslogvw_2.jpg"&gt;&lt;img title="Screenshot6_Fuslogvw" style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="261" alt="Screenshot6_Fuslogvw" src="http://blogs.msdn.com/blogfiles/clrcodegeneration/WindowsLiveWriter/NGenMeasuringWorkingSetwithVMMap_10D1C/Screenshot6_Fuslogvw_thumb.jpg" width="493" border="0"&gt;&lt;/a&gt; &lt;/h5&gt; &lt;p&gt;&lt;em&gt;Screenshot 5: Fusion Log Viewer indicating rebasing of a native image&lt;/em&gt;&lt;/p&gt; &lt;p class="MsoNormal"&gt;Let’s take a quick look at why rebasing is bad. Each native image contains absolute addresses that are references to items (like strings) within the native image itself. If the native image gets loaded at an address other than the preferred base address, the CLR needs to adjust those references (also known as performing fixups) – this is done by writing to the page that contains the reference, thereby creating private pages that cannot be shared with other processes that might also want to load the same native image. Using VMMap, when rebasing occurs, the Private WS number increases and the Shareable WS decreases. This is not optimal for total machine wide memory usage.&lt;/p&gt; &lt;p class="MsoNormal"&gt;&amp;nbsp;&lt;/p&gt; &lt;p class="MsoNormal"&gt;The use of hard binding further complicates this analysis. Note that if the managed application utilized hard binding for native images, when the application launches, the hard bound dependencies get loaded first before the application. In case any of the hard bound dependencies gets rebased, the dependency itself will need to have fix ups, creating private pages. However, the application’s native image that stores references to this dependency native image will need fixups as well. The application’s Private WS will increase for two reasons – once for the rebased dependency and once for the assembly that depends on this rebased dependency. &lt;/p&gt; &lt;p class="MsoNormal"&gt;&amp;nbsp;&lt;/p&gt; &lt;p class="MsoNormal"&gt;Remember when using VMMap: For Total WS and Private WS – lower is better. For Shareable WS – higher is better.&lt;/p&gt; &lt;p class="MsoNormal"&gt;&amp;nbsp;&lt;/p&gt; &lt;p class="MsoNormal"&gt;&lt;u&gt;Further Reading&lt;/u&gt; &lt;/p&gt; &lt;p class="MsoListParagraphCxSpFirst" style="text-indent: -0.25in; mso-list: l4 level1 lfo4"&gt;&lt;span style="mso-fareast-font-family: calibri; mso-fareast-theme-font: minor-latin; mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin"&gt;&lt;span style="mso-list: ignore"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span style="mso-fareast-font-family: calibri; mso-fareast-theme-font: minor-latin; mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin"&gt;&lt;span style="mso-list: ignore"&gt;1&amp;gt;&lt;span style="font: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;NGen and Rebasing: &lt;a href="http://msdn.microsoft.com/en-us/magazine/cc163610.aspx#S5"&gt;http://msdn.microsoft.com/en-us/magazine/cc163610.aspx#S5&lt;/a&gt; &lt;/p&gt; &lt;p class="MsoListParagraphCxSpLast" style="text-indent: -0.25in; mso-list: l4 level1 lfo4"&gt;&lt;span style="mso-fareast-font-family: calibri; mso-fareast-theme-font: minor-latin; mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin"&gt;&lt;span style="mso-list: ignore"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span style="mso-fareast-font-family: calibri; mso-fareast-theme-font: minor-latin; mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin"&gt;&lt;span style="mso-list: ignore"&gt;2&amp;gt;&lt;span style="font: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;Hard Binding of Native Images: &lt;a href="http://msdn.microsoft.com/en-us/magazine/cc163610.aspx#S7"&gt;http://msdn.microsoft.com/en-us/magazine/cc163610.aspx#S7&lt;/a&gt;&amp;nbsp;&lt;/p&gt; &lt;p class="MsoListParagraphCxSpLast" style="text-indent: -0.25in; mso-list: l4 level1 lfo4"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/p&gt; &lt;h5&gt;Impact of Base Address Collisions (Rebasing): What about Vista?&lt;/h5&gt; &lt;p class="MsoNormal"&gt;Starting with .Net Framework 3.5 SP1, on Vista machines (and newer Windows operating systems), native images are opted into an OS security feature called ASLR (Address Space Layout Randomization). Essentially, the Operating System ignores the preferred base address in the PE file header of a native image, and loads it at a random base address. As a result, it does not matter what preferred base address was assigned to a library, it will not be used. &lt;/p&gt; &lt;p class="MsoNormal"&gt;&amp;nbsp;&lt;/p&gt; &lt;p class="MsoNormal"&gt;As mentioned above, if your application’s distribution is restricted to Vista or newer operating systems, base address collisions is a class of problems that goes away. &lt;/p&gt; &lt;p class="MsoNormal"&gt;&amp;nbsp;&lt;/p&gt; &lt;p class="MsoNormal"&gt;&lt;u&gt;Further Reading&lt;/u&gt;&lt;/p&gt; &lt;p class="MsoListParagraph" style="text-indent: -0.25in; mso-list: l3 level1 lfo5"&gt;&lt;span style="mso-fareast-font-family: calibri; mso-fareast-theme-font: minor-latin; mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin"&gt;&lt;span style="mso-list: ignore"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1&amp;gt;&lt;span style="font: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;Address Space Layout Randomization: &lt;a href="http://technet.microsoft.com/en-us/magazine/2007.04.vistakernel.aspx"&gt;http://technet.microsoft.com/en-us/magazine/2007.04.vistakernel.aspx&lt;/a&gt; &lt;/p&gt; &lt;p class="MsoListParagraph" style="text-indent: -0.25in; mso-list: l3 level1 lfo5"&gt;&amp;nbsp;&lt;/p&gt; &lt;h5&gt;Cross-Process Sharing of Native Images&lt;/h5&gt; &lt;p class="MsoNormal"&gt;One of the benefits of having native images is that they can be shared across multiple managed processes on a machine. This is particularly helpful for server scenarios where there may be multiple managed applications running on the machine, that depend on a common set of managed libraries. If an application has already loaded a native image, and a second application is started that uses the same native images, the pages from the native image that are still marked shareable, will be shared. The second application will not incur a working set hit for those pages. &lt;/p&gt; &lt;p class="MsoNormal"&gt;&amp;nbsp;&lt;/p&gt; &lt;p class="MsoNormal"&gt;Let’s look at this using VMMap. &lt;/p&gt; &lt;p class="MsoNormal"&gt;&amp;nbsp;&lt;/p&gt; &lt;p class="MsoNormal"&gt;&lt;a href="http://blogs.msdn.com/blogfiles/clrcodegeneration/WindowsLiveWriter/NGenMeasuringWorkingSetwithVMMap_10D1C/Vmmap_Screenshot7_2.jpg"&gt;&lt;img title="Vmmap_Screenshot7" style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="332" alt="Vmmap_Screenshot7" src="http://blogs.msdn.com/blogfiles/clrcodegeneration/WindowsLiveWriter/NGenMeasuringWorkingSetwithVMMap_10D1C/Vmmap_Screenshot7_thumb.jpg" width="577" border="0"&gt;&lt;/a&gt; &lt;/p&gt; &lt;p class="MsoNormal"&gt;&lt;span style="mso-no-proof: yes"&gt;&lt;v:shape id="Picture_x0020_5" style="visibility: visible; width: 739.05pt; height: 420.7pt; mso-wrap-style: square" o:spid="_x0000_i1025" type="#_x0000_t75" alt="Vmmap_Screenshot6.jpg"&gt;&lt;v:imagedata src="file:///C:\Users\pnag\AppData\Local\Temp\2\msohtmlclip1\01\clip_image006.jpg" o:title="Vmmap_Screenshot6"&gt;&lt;/v:imagedata&gt;&lt;/v:shape&gt;&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;em&gt;Screenshot 6: Shareable WS becomes Shared WS with multiple managed applications&lt;/em&gt;&lt;/p&gt; &lt;p class="MsoNormal"&gt;Assume that Dep1.dll is our library that could potentially be shared. In VMMap, for the native image for foo.dll, the “Shareable WS” is listed as 8K, and the “Shared WS” is nothing. This indicates that an 8K chunk of memory in the native image for Dep1.dll is available for sharing, in case another process wanted to share it. When we launch a second application that also uses Dep1.dll, hit the Refresh option in VMMap to show the new working-set numbers. We’ll now see that the “Shared WS” number is 8K. This indicates that of the memory from Dep1.ni.dll that was available for sharing, we shared all of it.&lt;/p&gt; &lt;p class="MsoNormal"&gt;&amp;nbsp;&lt;/p&gt; &lt;h5&gt;Wrapping it up!&lt;/h5&gt; &lt;p class="MsoNormal"&gt;That summarizes the very basics of using VMMap to analyze the impact of NGen on the working set of a managed application. This article hopefully articulates how VMMap can be used and points out what to watch for during the measurements. We’d love to hear what you think! Have you used VMMap in the past to analyze the impact of NGen? If not, what do you use? How was your experience? Please use the comments section below for any feedback, questions and tips you’d like to share. &lt;/p&gt; &lt;p class="MsoNormal"&gt;&amp;nbsp;&lt;/p&gt; &lt;p class="MsoNormal"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/p&gt; &lt;p class="MsoNormal"&gt;Pracheeti Nagarkar&lt;/p&gt; &lt;p class="MsoNormal"&gt;CLR Codegen team &lt;/p&gt; &lt;p class="MsoNormal"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10003350" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/b/clrcodegeneration/archive/tags/NGen/">NGen</category><category domain="http://blogs.msdn.com/b/clrcodegeneration/archive/tags/Pracheeti+Nagarkar/">Pracheeti Nagarkar</category><category domain="http://blogs.msdn.com/b/clrcodegeneration/archive/tags/VMMap/">VMMap</category><category domain="http://blogs.msdn.com/b/clrcodegeneration/archive/tags/Working+Set/">Working Set</category></item><item><title>NGen: Measuring Warm Startup Performance with Xperf</title><link>http://blogs.msdn.com/b/clrcodegeneration/archive/2010/04/27/ngen-measuring-warm-startup-performance-with-xperf.aspx</link><pubDate>Tue, 27 Apr 2010 17:52:28 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10003344</guid><dc:creator>pracheeti</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.msdn.com/b/clrcodegeneration/rsscomments.aspx?WeblogPostID=10003344</wfw:commentRss><comments>http://blogs.msdn.com/b/clrcodegeneration/archive/2010/04/27/ngen-measuring-warm-startup-performance-with-xperf.aspx#comments</comments><description>&lt;p class="MsoNormal"&gt;&amp;nbsp;&lt;/p&gt; &lt;p class="MsoNormal"&gt;This is article 2 of 4 in the &lt;strong&gt;&lt;a href="http://blogs.msdn.com/clrcodegeneration/archive/2010/04/27/ngen-walk-through-series.aspx"&gt;NGen: Walkthrough Series&lt;/a&gt;&lt;/strong&gt;. &lt;/p&gt; &lt;p class="MsoNormal"&gt;&amp;nbsp;&lt;/p&gt; &lt;p class="MsoNormal"&gt;This article is part of a series of blog posts intended to help managed code developers analyze if Native Image Generation (NGen) technology provides benefit to their application/library. NGen refers to the process of pre-compiling Microsoft® Intermediate Language (MSIL) executables into machine code prior to execution time. &lt;/p&gt; &lt;p class="MsoNormal"&gt;&amp;nbsp;&lt;/p&gt; &lt;p class="MsoNormal"&gt;Startup time is defined as the time it takes for an application from launch to startup such that it is now responsive to user input. It is typically thought of as having two variants, cold startup and warm startup. The time it takes for an application to start up on a machine that has just been booted is typically referred to as cold startup time. The time it takes for the application to start up on its second launch is referred to as warm startup time. The difference between the two is that cold startup time is bound by the need to fetch pages used by the application from disk. In contrast, warm startup is typically only bound by the work the application (and underlying runtime layer) needs to do to start up, since the pages needed by the application under normal circumstances don’t need to be fetched from disk. &lt;/p&gt; &lt;p class="MsoNormal"&gt;&amp;nbsp;&lt;/p&gt; &lt;p class="MsoNormal"&gt;Using native images does not necessarily shorten cold startup time since the native image files are significantly larger than their corresponding IL files and may take longer to pull from the disk. We will not talk about cold startup time in this article although that may be a topic we address in a future post. Loading native images however, can help shorten application warm startup time since the CLR does not need to run the JIT compiler on the managed assemblies at application launch time. This article is a walk through to help developers use publicly available tools to evaluate how much warm startup benefit the application will see if NGen were to be used. &lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal"&gt;&amp;nbsp;&lt;/p&gt; &lt;p class="MsoNormal"&gt;We will look at two contrasting scenarios to measure warm startup time, the first will involve an application where most of the managed assemblies being loaded have native images and the second one will involve the same application where most of the managed assemblies will NOT have native images. &lt;/p&gt; &lt;p class="MsoNormal"&gt;&amp;nbsp;&lt;/p&gt; &lt;p class="MsoNormal"&gt;&lt;u&gt;Further Reading&lt;/u&gt;&lt;/p&gt; &lt;p class="MsoListParagraphCxSpFirst" style="text-indent: -0.25in; mso-list: l0 level1 lfo3"&gt;&lt;span style="mso-fareast-font-family: calibri; mso-fareast-theme-font: minor-latin; mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin"&gt;&lt;span style="mso-list: ignore"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1&amp;gt;&lt;span style="font: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;Performance Benefits of NGen: &lt;a href="http://msdn.microsoft.com/en-us/magazine/cc163610.aspx"&gt;http://msdn.microsoft.com/en-us/magazine/cc163610.aspx&lt;/a&gt; &lt;/p&gt; &lt;p class="MsoListParagraphCxSpLast" style="text-indent: -0.25in; mso-list: l0 level1 lfo3"&gt;&lt;span style="mso-fareast-font-family: calibri; mso-fareast-theme-font: minor-latin; mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin"&gt;&lt;span style="mso-list: ignore"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span style="mso-fareast-font-family: calibri; mso-fareast-theme-font: minor-latin; mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin"&gt;&lt;span style="mso-list: ignore"&gt;2&amp;gt;&lt;span style="font: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;A model for cold startup time: &lt;a href="http://blogs.msdn.com/vancem/archive/2007/04/09/a-model-for-cold-startup-time-of-an-application-on-windows.aspx"&gt;http://blogs.msdn.com/vancem/archive/2007/04/09/a-model-for-cold-startup-time-of-an-application-on-windows.aspx&lt;/a&gt;&lt;/p&gt; &lt;p class="MsoListParagraphCxSpLast" style="text-indent: -0.25in; mso-list: l0 level1 lfo3"&gt;&amp;nbsp;&lt;/p&gt; &lt;h5&gt;Getting Started with Xperf&lt;/h5&gt; &lt;p class="MsoNormal"&gt;Download Windows SDK: &lt;a href="http://msdn.microsoft.com/en-us/performance/cc825801.aspx"&gt;http://msdn.microsoft.com/en-us/performance/cc825801.aspx&lt;/a&gt; &lt;/p&gt; &lt;p class="MsoNormal"&gt;&amp;nbsp;&lt;/p&gt; &lt;p class="MsoNormal"&gt;Xperf is an ETW based performance measurement tool for Windows that is available publicly. This tool enables drill down analysis into how much machine-wide CPU time was spent in modules of an application. &lt;/p&gt; &lt;p class="MsoNormal"&gt;&amp;nbsp;&lt;/p&gt; &lt;p class="MsoNormal"&gt;After downloading Xperf, you can get access to the tool by launching All Programs -&amp;gt; Windows SDK -&amp;gt; Command Prompt. This will place Xperf on the path in the Command Prompt window. &lt;/p&gt; &lt;p class="MsoNormal"&gt;&amp;nbsp;&lt;/p&gt; &lt;p class="MsoNormal"&gt;&lt;u&gt;Further Reading&lt;/u&gt;&lt;/p&gt; &lt;p class="MsoListParagraphCxSpFirst" style="text-indent: -0.25in; mso-list: l2 level1 lfo2"&gt;&lt;span style="mso-fareast-font-family: calibri; mso-fareast-theme-font: minor-latin; mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin"&gt;&lt;span style="mso-list: ignore"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span style="mso-fareast-font-family: calibri; mso-fareast-theme-font: minor-latin; mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin"&gt;&lt;span style="mso-list: ignore"&gt;1&amp;gt;&lt;span style="font: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;Event Tracing for Windows (ETW): &lt;a href="http://msdn.microsoft.com/en-us/magazine/cc163437.aspx"&gt;http://msdn.microsoft.com/en-us/magazine/cc163437.aspx&lt;/a&gt; &lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoListParagraphCxSpLast" style="text-indent: -0.25in; mso-list: l2 level1 lfo2"&gt;&lt;span style="mso-fareast-font-family: calibri; mso-fareast-theme-font: minor-latin; mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin"&gt;&lt;span style="mso-list: ignore"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span style="mso-fareast-font-family: calibri; mso-fareast-theme-font: minor-latin; mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin"&gt;&lt;span style="mso-list: ignore"&gt;2&amp;gt;&lt;span style="font: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;Additional Information on Xperf: &lt;a href="http://blogs.msdn.com/pigscanfly/archive/2008/02/09/xperf-a-new-tool-in-the-windows-sdk.aspx"&gt;http://blogs.msdn.com/pigscanfly/archive/2008/02/09/xperf-a-new-tool-in-the-windows-sdk.aspx&lt;/a&gt;&amp;nbsp;&lt;/p&gt; &lt;p class="MsoListParagraphCxSpLast" style="text-indent: -0.25in; mso-list: l2 level1 lfo2"&gt;&amp;nbsp;&lt;/p&gt; &lt;h5&gt;Warm Startup Time with Native Images&lt;/h5&gt; &lt;p class="MsoNormal"&gt;In order to illustrate the analysis of startup performance, we will use a well known large application that has components written in managed code that have native images; Visual Studio 2010. The scenario will launch a basic HelloWorld WPF application in Visual Studio 2010, wait till the UI is responsive, and shutdown. In order to collect CPU time traces for later analysis, Xperf will be used to enable tracing before application launch, and tracing will be stopped after the scenario is run. &lt;/p&gt; &lt;p class="MsoNormal"&gt;&amp;nbsp;&lt;/p&gt; &lt;p class="MsoNormal"&gt;The steps below outline the sequence of actions needed.&lt;/p&gt; &lt;p class="MsoListParagraphCxSpFirst" style="text-indent: -0.25in; mso-list: l3 level1 lfo1"&gt;&lt;span style="mso-fareast-font-family: calibri; mso-fareast-theme-font: minor-latin; mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin"&gt;&lt;span style="mso-list: ignore"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span style="mso-fareast-font-family: calibri; mso-fareast-theme-font: minor-latin; mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin"&gt;&lt;span style="mso-list: ignore"&gt;1&amp;gt;&lt;span style="font: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;Enable ETW tracing using Xperf&lt;/p&gt; &lt;p class="MsoListParagraphCxSpMiddle" style="margin-left: 0in; text-indent: 0.5in; mso-add-space: auto"&gt;&lt;b style="mso-bidi-font-weight: normal"&gt;&lt;span style="font-size: 10pt; font-family: 'Courier New'"&gt;&lt;font size="1"&gt;xperf -on base+cswitch&lt;/font&gt;&lt;/span&gt;&lt;/b&gt;&lt;/p&gt; &lt;p class="MsoListParagraphCxSpMiddle" style="margin-left: 0in; text-indent: 0.5in; mso-add-space: auto"&gt;(Starts a trace with BASE Kernel Group and Context Switch Kernel Flag)&lt;/p&gt; &lt;p class="MsoListParagraphCxSpMiddle" style="text-indent: -0.25in; mso-list: l3 level1 lfo1"&gt;&lt;span style="mso-fareast-font-family: calibri; mso-fareast-theme-font: minor-latin; mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin"&gt;&lt;span style="mso-list: ignore"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span style="mso-fareast-font-family: calibri; mso-fareast-theme-font: minor-latin; mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin"&gt;&lt;span style="mso-list: ignore"&gt;2&amp;gt;&lt;span style="font: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;Run scenario of interest &lt;/p&gt; &lt;p class="MsoListParagraphCxSpMiddle" style="margin-left: 0in; text-indent: 0.5in; mso-add-space: auto"&gt;&lt;span style="font-size: 10pt; font-family: 'Courier New'"&gt;&lt;font size="1"&gt;“C:\Program Files\Microsoft Visual Studio 10.0\Common7\IDE\devenv.exe" "c:\users\xyz\documents\visual studio 2010\Projects\WpfApplication1\WpfApp1.sln"&lt;?xml:namespace prefix = o /&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoListParagraphCxSpMiddle" style="text-indent: -0.25in; mso-list: l3 level1 lfo1"&gt;&lt;span style="mso-fareast-font-family: calibri; mso-fareast-theme-font: minor-latin; mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin"&gt;&lt;span style="mso-list: ignore"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span style="mso-fareast-font-family: calibri; mso-fareast-theme-font: minor-latin; mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin"&gt;&lt;span style="mso-list: ignore"&gt;3&amp;gt;&lt;span style="font: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;Disable ETW tracing (data is saved to an ETL trace file) using Xperf&lt;/p&gt; &lt;p class="MsoListParagraphCxSpMiddle" style="margin-left: 0in; text-indent: 0.5in; mso-add-space: auto"&gt;&lt;span style="font-size: 10pt; font-family: 'Courier New'"&gt;&lt;font size="1"&gt;xperf -d trace4.etl&lt;/font&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoListParagraphCxSpMiddle" style="text-indent: -0.25in; mso-list: l3 level1 lfo1"&gt;&lt;span style="mso-fareast-font-family: calibri; mso-fareast-theme-font: minor-latin; mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin"&gt;&lt;span style="mso-list: ignore"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span style="mso-fareast-font-family: calibri; mso-fareast-theme-font: minor-latin; mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin"&gt;&lt;span style="mso-list: ignore"&gt;4&amp;gt;&lt;span style="font: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;View CPU time results using Xperfview&lt;/p&gt; &lt;p class="MsoListParagraphCxSpLast" style="margin-left: 0in; text-indent: 0.5in; mso-add-space: auto"&gt;&lt;span style="font-size: 10pt; font-family: 'Courier New'"&gt;&lt;font size="1"&gt;xperf trace4.etl&lt;o:p&gt;&lt;/o:p&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal"&gt;In the last step Xperf will forward the request to Performance Analyzer which will open and display a graphical view of the data in the file, similar to what is shown below. &lt;/p&gt; &lt;p class="MsoNormal"&gt;&amp;nbsp;&lt;/p&gt; &lt;p class="MsoNormal"&gt;&lt;span style="mso-no-proof: yes"&gt;&lt;a href="http://blogs.msdn.com/blogfiles/clrcodegeneration/WindowsLiveWriter/NGenMeasuringWarmStartupPerformancewithX_10CBE/clip_image002_2.jpg"&gt;&lt;img title="clip_image002" style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="313" alt="clip_image002" src="http://blogs.msdn.com/blogfiles/clrcodegeneration/WindowsLiveWriter/NGenMeasuringWarmStartupPerformancewithX_10CBE/clip_image002_thumb.jpg" width="545" border="0" v:shapes="Picture_x0020_3"&gt;&lt;/a&gt;&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;em&gt;Screenshot 1: Windows Performance Analyzer&lt;/em&gt;&lt;/p&gt; &lt;h5&gt;&lt;span style="mso-spacerun: yes"&gt;&lt;/span&gt;&lt;/h5&gt; &lt;p class="MsoNormal"&gt;Performance Analyzer has several rows of graphical data, the one of interest to us is the row titled &lt;b style="mso-bidi-font-weight: normal"&gt;CPU Sampling by CPU&lt;/b&gt;. Select the high activity region on the graph (assuming that devenv.exe was the only large application launched during this time-frame, the spikes seen in the CPU utilization should be easy to spot), right click in the region and select the &lt;b style="mso-bidi-font-weight: normal"&gt;Summary Table&lt;/b&gt; item. (Alternatively, you can also look at the &lt;b style="mso-bidi-font-weight: normal"&gt;CPU Sampling by Process&lt;/b&gt; row, and in the &lt;b style="mso-bidi-font-weight: normal"&gt;Processes &lt;/b&gt;drop down menu, you can select only &lt;b style="mso-bidi-font-weight: normal"&gt;devenv.exe&lt;/b&gt; to see the activity for that process.)&lt;/p&gt; &lt;p class="MsoNormal"&gt;&amp;nbsp;&lt;/p&gt; &lt;p class="MsoNormal"&gt;The &lt;b style="mso-bidi-font-weight: normal"&gt;Summary Table&lt;/b&gt; has tabular CPU utilization data for all the processes running on the machine in that time window; &lt;b style="mso-bidi-font-weight: normal"&gt;devenv.exe&lt;/b&gt; should be part of this list. Under the &lt;b style="mso-bidi-font-weight: normal"&gt;% Weight &lt;/b&gt;column you will see the time taken by devenv.exe on the machine as a &lt;b style="mso-bidi-font-weight: normal"&gt;percentage of the total CPU utilization on the machine&lt;/b&gt;. &lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal"&gt;&amp;nbsp;&lt;/p&gt; &lt;p class="MsoNormal"&gt;Expanding the devenv.exe process displays a view of the percentage of CPU time spent in each module loaded within this application. Notice in Screenshot 2 below that the bulk of the time was spent in clr.dll (20.96% total across the machine, which means that it was ~30% of the time spent within the process devenv.exe) and clrjit.dll (8.68% total across the machine, which means that it was ~12.6% within the process). Note that some time was spent in the JIT even though most of this scenario was running using native images. The use of native images can be seen in the fact that *.ni.dll files are listed in the module list (mscorlib.ni.dll, system.xaml.ni.dll etc).&lt;/p&gt; &lt;p class="MsoNormal"&gt;&amp;nbsp;&lt;/p&gt; &lt;p class="MsoNormal"&gt;&lt;span style="mso-no-proof: yes"&gt;&lt;a href="http://blogs.msdn.com/blogfiles/clrcodegeneration/WindowsLiveWriter/NGenMeasuringWarmStartupPerformancewithX_10CBE/clip_image004_2.jpg"&gt;&lt;img title="clip_image004" style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="375" alt="clip_image004" src="http://blogs.msdn.com/blogfiles/clrcodegeneration/WindowsLiveWriter/NGenMeasuringWarmStartupPerformancewithX_10CBE/clip_image004_thumb.jpg" width="426" border="0" v:shapes="Picture_x0020_10"&gt;&lt;/a&gt;&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;em&gt;Screenshot 2: Windows Performance Analyzer, CPU Utilization Summary Table drilldown with native images present&lt;/em&gt;&lt;/p&gt; &lt;p class="MsoNormal"&gt;&lt;u&gt;Further Reading&lt;/u&gt;&lt;/p&gt; &lt;p class="MsoListParagraph" style="margin-left: 0.75in; text-indent: -0.25in; mso-list: l1 level1 lfo4; mso-add-space: auto"&gt;&lt;span style="mso-fareast-font-family: calibri; mso-fareast-theme-font: minor-latin; mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin"&gt;&lt;span style="mso-list: ignore"&gt;1&amp;gt;&lt;span style="font: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;Detailed guidance on using Performance Analyzer: All Programs -&amp;gt; Windows Performance Toolkit -&amp;gt; Windows Performance Toolkit Help. Select Quick Start Guide: WPF Basics -&amp;gt; Detailed Walkthrough.&lt;/p&gt; &lt;h5&gt;Warm Startup Time without Native Images&lt;/h5&gt; &lt;p class="MsoNormal"&gt;Now let’s turn our attention to what the startup time characteristics look like when native images are not used in the Visual Studio 2010 application. Solely for purposes of this demo, the numbers below were generated by uninstalling all native images for Visual Studio and .Net Framework assemblies. It is NOT recommended that you uninstall native images in general. Executing the sequence of actions used previously, to generate traces again for this scenario, we get the graphs seen below. &lt;/p&gt; &lt;p class="MsoNormal"&gt;&amp;nbsp;&lt;/p&gt; &lt;p class="MsoNormal"&gt;The increase in the total CPU utilization by devenv.exe (49.34%) complicates the analysis a tad bit, but we can see that the time spent in clr.dll went up to 20.5% total, which means ~41.5% of the time spent in devenv.exe was spent in clr.dll. This is a large increase from the previous scenario where only 30% of the time spent in devenv.exe was in clr.dll. Furthermore, the time spent in clrjit.dll went up to 16.03% total, which means ~32.5% of the time spent in devenv.exe was spent in clrjit.dll. This is also an increase from the previous scenario where only 12.6% of the time was spent in clrjit.dll, almost a 3x increase! Also note that the list of modules loaded no longer shows modules that end with a .ni.dll file extension, indicating that native images were not loaded.&lt;/p&gt; &lt;p class="MsoNormal"&gt;&amp;nbsp;&lt;/p&gt; &lt;p class="MsoNormal"&gt;This large increase in time spent in clr.dll and clrjit.dll is to be expected when native images are not present. Since native code does not exist for many assemblies, the CLR needs to invoke the JIT to compile methods to native code at runtime, explaining the increase in time spent in clrjit.dll. Time spent in clr.dll also increases because the CLR needs to execute code to invoke the JIT, and it needs to create internal data structures that the native code will need. &lt;/p&gt; &lt;p class="MsoNormal"&gt;&amp;nbsp;&lt;/p&gt; &lt;p class="MsoNormal"&gt;&lt;span style="mso-no-proof: yes"&gt;&lt;a href="http://blogs.msdn.com/blogfiles/clrcodegeneration/WindowsLiveWriter/NGenMeasuringWarmStartupPerformancewithX_10CBE/clip_image006_2.jpg"&gt;&lt;img title="clip_image006" style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="300" alt="clip_image006" src="http://blogs.msdn.com/blogfiles/clrcodegeneration/WindowsLiveWriter/NGenMeasuringWarmStartupPerformancewithX_10CBE/clip_image006_thumb.jpg" width="475" border="0" v:shapes="Picture_x0020_1"&gt;&lt;/a&gt;&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;em&gt;Screenshot 3: Windows Performance Analyzer, CPU Utilization Summary Table drilldown without native images present&lt;/em&gt;&lt;/p&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;h5&gt;Wrapping it up! &lt;/h5&gt; &lt;p class="MsoNormal"&gt;This article demonstrated how to measure an application’s warm startup time using Xperf, and we saw the benefit of using native images for large applications. Hopefully, the information above will help you do a first round of evaluation of whether your managed application/library will benefit from the use of NGen. We’d love to hear what you think! Have you used Xperf before to do similar analysis? What were the pitfalls you ran into? Please use the comments section below for any feedback, questions and tips you’d like to share.&lt;/p&gt; &lt;p class="MsoNormal"&gt;&lt;o:p&gt;&lt;/o:p&gt;&amp;nbsp;&lt;/p&gt; &lt;p class="MsoNormal"&gt;&lt;o:p&gt;&lt;/o:p&gt;&amp;nbsp;&lt;/p&gt; &lt;p class="MsoNormal"&gt;Lakshan Fernando, Pracheeti Nagarkar&lt;/p&gt; &lt;p class="MsoNormal"&gt;CLR CodeGen team&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10003344" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/b/clrcodegeneration/archive/tags/NGen/">NGen</category><category domain="http://blogs.msdn.com/b/clrcodegeneration/archive/tags/Pracheeti+Nagarkar/">Pracheeti Nagarkar</category><category domain="http://blogs.msdn.com/b/clrcodegeneration/archive/tags/Warm+Startup/">Warm Startup</category><category domain="http://blogs.msdn.com/b/clrcodegeneration/archive/tags/Lakshan+Fernando/">Lakshan Fernando</category><category domain="http://blogs.msdn.com/b/clrcodegeneration/archive/tags/Xperf/">Xperf</category></item><item><title>NGen: Getting Started with NGen in Visual Studio</title><link>http://blogs.msdn.com/b/clrcodegeneration/archive/2010/04/27/ngen-getting-started-with-ngen-in-visual-studio.aspx</link><pubDate>Tue, 27 Apr 2010 17:39:20 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10003338</guid><dc:creator>pracheeti</dc:creator><slash:comments>3</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.msdn.com/b/clrcodegeneration/rsscomments.aspx?WeblogPostID=10003338</wfw:commentRss><comments>http://blogs.msdn.com/b/clrcodegeneration/archive/2010/04/27/ngen-getting-started-with-ngen-in-visual-studio.aspx#comments</comments><description>&lt;p&gt;This is article 1 of 4 in the &lt;strong&gt;&lt;a href="http://blogs.msdn.com/clrcodegeneration/archive/2010/04/27/ngen-walk-through-series.aspx"&gt;NGen: Walkthrough Series&lt;/a&gt;&lt;/strong&gt;.&lt;/p&gt; &lt;p class="MsoNormal"&gt;Hey there managed code developer. So you’d like to test drive the NGen technology in the .Net Framework? This article will walk you through how to use NGen for your existing solution in Visual Studio 2010. &lt;/p&gt; &lt;p class="MsoNormal"&gt;&amp;nbsp;&lt;/p&gt; &lt;p class="MsoNormal"&gt;To familiarize yourself with the concepts around NGen (how it works and for what style of application/library it makes sense to use), I strongly encourage you to first read through this excellent MSDN CLR Inside Out article around the Performance Benefits of NGen: &lt;a href="http://msdn.microsoft.com/en-us/magazine/cc163610.aspx"&gt;http://msdn.microsoft.com/en-us/magazine/cc163610.aspx&lt;/a&gt;. Now assuming you have some background on when to use NGen, let’s get started. I’m assuming you have identified that NGen will likely benefit your application (perhaps your application has been identified as having poor warm startup due to JIT-ing of method calls OR you are working with a library that gets loaded into several processes on a machine and you would like to reduce the library’s impact on the total working set of the machine.) &lt;/p&gt; &lt;p class="MsoNormal"&gt;&amp;nbsp;&lt;/p&gt; &lt;p class="MsoNormal"&gt;For the purposes of this walk-through, I assume you already have a Visual Studio solution for your application. This series of steps will provides guidance on how to invoke NGen for your application from within the Visual Studio solution. Using NGen via the set of steps outlined below will result in native images created only on the specific machine where the steps are run. Note also that this article does not provide instructions on how to invoke NGen in an installer package; a future article will talk about that scenario.&lt;/p&gt; &lt;p class="MsoNormal"&gt;&amp;nbsp;&lt;/p&gt; &lt;h5&gt;&lt;b style="mso-bidi-font-weight: normal"&gt;Adding a post-build event to run NGen.exe&lt;/b&gt;&lt;/h5&gt; &lt;p class="MsoNormal"&gt;Setting this up involves a fairly straightforward set of steps. &lt;/p&gt; &lt;p class="MsoNormal"&gt;&amp;nbsp;&lt;/p&gt; &lt;p class="MsoNormal"&gt;In your Visual Studio solution, under the &lt;b style="mso-bidi-font-weight: normal"&gt;Project&lt;/b&gt; menu, go to &lt;b style="mso-bidi-font-weight: normal"&gt;Properties&lt;/b&gt; and then go to the &lt;b style="mso-bidi-font-weight: normal"&gt;Build Events&lt;/b&gt; tab. Under the &lt;b style="mso-bidi-font-weight: normal"&gt;Post-build event command line&lt;/b&gt;, click on &lt;b style="mso-bidi-font-weight: normal"&gt;Edit Post-Build…&lt;/b&gt;&lt;/p&gt; &lt;p class="MsoNormal"&gt;&lt;strong&gt;&lt;/strong&gt;&amp;nbsp;&lt;/p&gt; &lt;p class="MsoNormal"&gt;Specify the command line as &lt;b style="mso-bidi-font-weight: normal"&gt;%WINDIR%\Microsoft.Net\Framework\v4.0.30319\ngen.exe install “$(TargetPath)”&lt;?xml:namespace prefix = o /&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/b&gt;&lt;/p&gt; &lt;p class="MsoNormal"&gt;&amp;nbsp;&lt;/p&gt; &lt;p class="MsoNormal"&gt;At the time of this writing, there is no Macro in Visual Studio that points to ngen.exe, so you will need to specify the path yourself. An easy way to locate the path to ngen.exe is to open up the Visual Studio Command Prompt (All Programs -&amp;gt; Microsoft Visual Studio 2010 -&amp;gt; Visual Studio Tools -&amp;gt; Visual Studio Command Prompt) and type “&lt;b style="mso-bidi-font-weight: normal"&gt;where ngen.exe”&lt;/b&gt;. &lt;/p&gt; &lt;p class="MsoNormal"&gt;&amp;nbsp;&lt;/p&gt; &lt;p class="MsoNormal"&gt;The NGen install command creates native images for the target specified along with any static dependencies that target may have. &lt;/p&gt; &lt;p class="MsoNormal"&gt;&amp;nbsp;&lt;/p&gt; &lt;p class="MsoNormal"&gt;Note that multiple post-build events can be specified in the &lt;b style="mso-bidi-font-weight: normal"&gt;Edit Post Build…&lt;/b&gt; window by specifying each command on a separate line.&lt;/p&gt; &lt;p class="MsoNormal"&gt;&amp;nbsp;&lt;/p&gt; &lt;p class="MsoNormal"&gt;Under the &lt;b style="mso-bidi-font-weight: normal"&gt;Project&lt;/b&gt; menu go to &lt;b style="mso-bidi-font-weight: normal"&gt;Properties&lt;/b&gt; and in the &lt;b style="mso-bidi-font-weight: normal"&gt;Debug&lt;/b&gt; tab, uncheck the box for &lt;b style="mso-bidi-font-weight: normal"&gt;Enable the Visual Studio Hosting Process&lt;/b&gt;. &lt;/p&gt; &lt;p class="MsoNormal"&gt;&amp;nbsp;&lt;/p&gt; &lt;p class="MsoNormal"&gt;Keep in mind that you need to be intentional about the bitness of NGen.exe that you use. If your development environment is on a 64 bit machine, the application in Visual Studio by default will be created as a 32 bit application, and you should use the 32 bit ngen.exe in the Post-Build Event. However, on 64 bit machines, outside the Visual Studio development environment, the application will run against the 64 bit runtime, and so you need to NGen using the 64 bit NGen.exe tool. &lt;/p&gt; &lt;p class="MsoNormal"&gt;&amp;nbsp;&lt;/p&gt; &lt;p class="MsoNormal"&gt;(On a related note, during build, if you choose to assign base addresses to the DLLs created in your Visual Studio Solution, the way to do that is under &lt;b style="mso-bidi-font-weight: normal"&gt;Project&lt;/b&gt; menu go to &lt;b style="mso-bidi-font-weight: normal"&gt;Properties&lt;/b&gt; and in the &lt;b style="mso-bidi-font-weight: normal"&gt;Build&lt;/b&gt; tab click on &lt;b style="mso-bidi-font-weight: normal"&gt;Advanced…&lt;/b&gt;&lt;/p&gt; &lt;p class="MsoNormal"&gt;&amp;nbsp;&lt;/p&gt; &lt;p class="MsoNormal"&gt;In the &lt;b style="mso-bidi-font-weight: normal"&gt;Advanced Build Settings&lt;/b&gt; window, under &lt;b style="mso-bidi-font-weight: normal"&gt;Output&lt;/b&gt;, the &lt;b style="mso-bidi-font-weight: normal"&gt;DLL Base Address&lt;/b&gt; field lets you specify the base address to assign to the DLL.)&lt;/p&gt; &lt;p class="MsoNormal"&gt;&amp;nbsp;&lt;/p&gt; &lt;p class="MsoNormal"&gt;&lt;u&gt;Further Reading&lt;/u&gt;&lt;/p&gt; &lt;p class="MsoListParagraphCxSpFirst" style="text-indent: -0.25in; mso-list: l3 level1 lfo5"&gt;&lt;span style="mso-fareast-font-family: calibri; mso-fareast-theme-font: minor-latin; mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin"&gt;&lt;span style="mso-list: ignore"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span style="mso-fareast-font-family: calibri; mso-fareast-theme-font: minor-latin; mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin"&gt;&lt;span style="mso-list: ignore"&gt;1&amp;gt;&lt;span style="font: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;How to: Specify Build Events: &lt;a href="http://msdn.microsoft.com/en-us/library/ke5z92ks(VS.80).aspx"&gt;http://msdn.microsoft.com/en-us/library/ke5z92ks(VS.80).aspx&lt;/a&gt;&amp;nbsp;&lt;/p&gt; &lt;p class="MsoListParagraphCxSpFirst" style="text-indent: -0.25in; mso-list: l3 level1 lfo5"&gt;&lt;span style="mso-fareast-font-family: calibri; mso-fareast-theme-font: minor-latin; mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin"&gt;&lt;span style="mso-list: ignore"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span style="mso-fareast-font-family: calibri; mso-fareast-theme-font: minor-latin; mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin"&gt;&lt;span style="mso-list: ignore"&gt;2&amp;gt;&lt;span style="font: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;How to install an assembly into the GAC: &lt;a href="http://support.microsoft.com/kb/815808"&gt;http://support.microsoft.com/kb/815808&lt;/a&gt; &lt;/p&gt; &lt;p class="MsoListParagraphCxSpFirst" style="text-indent: -0.25in; mso-list: l3 level1 lfo5"&gt;&amp;nbsp;&lt;/p&gt; &lt;h5&gt;&lt;b style="mso-bidi-font-weight: normal"&gt;Ensuring the post-build event worked&lt;/b&gt;&lt;/h5&gt; &lt;p class="MsoNormal"&gt;Now that you’ve added your post-build event to run NGen.exe on the built executables, it’s important to determine 2 things – &lt;/p&gt; &lt;p class="MsoListParagraphCxSpFirst" style="text-indent: -0.25in; mso-list: l2 level1 lfo1"&gt;&lt;span style="mso-fareast-font-family: calibri; mso-fareast-theme-font: minor-latin; mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin"&gt;&lt;span style="mso-list: ignore"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span style="mso-fareast-font-family: calibri; mso-fareast-theme-font: minor-latin; mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin"&gt;&lt;span style="mso-list: ignore"&gt;1&amp;gt;&lt;span style="font: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;Whether native images were generated successfully, AND&lt;/p&gt; &lt;p class="MsoListParagraphCxSpMiddle" style="text-indent: -0.25in; mso-list: l2 level1 lfo1"&gt;&lt;span style="mso-fareast-font-family: calibri; mso-fareast-theme-font: minor-latin; mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin"&gt;&lt;span style="mso-list: ignore"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span style="mso-fareast-font-family: calibri; mso-fareast-theme-font: minor-latin; mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin"&gt;&lt;span style="mso-list: ignore"&gt;2&amp;gt;&lt;span style="font: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;Whether native images got loaded during runtime&lt;/p&gt; &lt;p class="MsoListParagraphCxSpMiddle" style="text-indent: -0.25in; mso-list: l2 level1 lfo1"&gt;&amp;nbsp;&lt;/p&gt; &lt;h5&gt;&lt;b style="mso-bidi-font-weight: normal"&gt;Ensuring native images were generated successfully &lt;/b&gt;&lt;/h5&gt; &lt;p class="MsoNormal"&gt;After building the solution (F6), look at the Error List window to ensure there are no errors. If there are errors during build, look at the Output window to see where the error is coming from and if it is from the NGen.exe tool. &lt;/p&gt; &lt;p class="MsoNormal"&gt;Some common reasons why NGen.exe might have failed are – &lt;/p&gt; &lt;p class="MsoListParagraphCxSpFirst" style="text-indent: -0.25in; mso-list: l6 level1 lfo2"&gt;&lt;span style="mso-fareast-font-family: calibri; mso-fareast-theme-font: minor-latin; mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin"&gt;&lt;span style="mso-list: ignore"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span style="mso-fareast-font-family: calibri; mso-fareast-theme-font: minor-latin; mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin"&gt;&lt;span style="mso-list: ignore"&gt;1&amp;gt;&lt;span style="font: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;Visual Studio is not being run with Administrator credentials. NGen.exe is an Admin tool and the post-build step will fail with the following error if you run without the appropriate credentials – &lt;/p&gt; &lt;p class="MsoListParagraphCxSpMiddle" style="margin-bottom: 0pt; mso-layout-grid-align: none; mso-add-space: auto"&gt;&lt;span style="font-size: 9pt; font-family: consolas; mso-bidi-font-family: consolas"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoListParagraphCxSpMiddle" style="margin-bottom: 0pt; mso-layout-grid-align: none; mso-add-space: auto"&gt;&lt;span style="font-size: 9pt; font-family: consolas; mso-bidi-font-family: consolas"&gt;&lt;font size="1"&gt;&amp;nbsp; Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))&lt;/font&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoListParagraphCxSpMiddle" style="margin-bottom: 0pt; mso-layout-grid-align: none; mso-add-space: auto"&gt;&lt;span style="font-size: 9pt; font-family: consolas; mso-bidi-font-family: consolas"&gt;&lt;/span&gt;&lt;span style="font-size: 9pt; font-family: consolas; mso-bidi-font-family: consolas"&gt;&lt;font size="1"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/span&gt;Administrator permissions are needed to use the selected options.&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/span&gt;Use an administrator command prompt to complete these tasks.&lt;/font&gt;&lt;/span&gt;&lt;span style="font-size: 9pt; font-family: consolas; mso-bidi-font-family: consolas"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoListParagraph" style="text-indent: -0.25in; mso-list: l6 level1 lfo2"&gt;&lt;span style="mso-fareast-font-family: calibri; mso-fareast-theme-font: minor-latin; mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin"&gt;&lt;span style="mso-list: ignore"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span style="mso-fareast-font-family: calibri; mso-fareast-theme-font: minor-latin; mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin"&gt;&lt;span style="mso-list: ignore"&gt;2&amp;gt;&lt;span style="font: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;The post-build event command line contains the macro $(TargetPath), but this path contains spaces in it. Changing this to be “$(TargetPath)” should fix the problem. &lt;/p&gt; &lt;p class="MsoListParagraph" style="text-indent: -0.25in; mso-list: l6 level1 lfo2"&gt;&amp;nbsp;&lt;/p&gt; &lt;h5&gt;&lt;b style="mso-bidi-font-weight: normal"&gt;Ensuring native images got loaded during runtime&lt;/b&gt;&lt;/h5&gt; &lt;p class="MsoNormal"&gt;A native image file has a “.ni.dll” or “.ni.exe” file extension. Note that you do not need to do anything special to run a native image (like providing a path to the native image file). When you run hello.exe (the IL assembly), the Common Language Runtime’s assembly loader will check if a native image file exists for this IL assembly and will just load that instead of the IL. &lt;/p&gt; &lt;p class="MsoNormal"&gt;&amp;nbsp;&lt;/p&gt; &lt;p class="MsoNormal"&gt;The first thing to check for is that the native image files were loaded during runtime. The next thing to check for is whether the JIT got used to compile some methods in an assembly even though the native image for the assembly got loaded. &lt;/p&gt; &lt;p class="MsoNormal"&gt;&amp;nbsp;&lt;/p&gt; &lt;p class="MsoNormal"&gt;There are a couple different ways to validate that the native image files were loaded during runtime. &lt;/p&gt; &lt;p class="MsoListParagraphCxSpFirst" style="text-indent: -0.25in; mso-list: l4 level1 lfo4"&gt;&lt;span style="mso-fareast-font-family: calibri; mso-fareast-theme-font: minor-latin; mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin"&gt;&lt;span style="mso-list: ignore"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span style="mso-fareast-font-family: calibri; mso-fareast-theme-font: minor-latin; mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin"&gt;&lt;span style="mso-list: ignore"&gt;1&amp;gt;&lt;span style="font: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;Use the SDK tool Fusion Log Viewer: Easiest if running outside of Visual Studio&lt;/p&gt; &lt;p class="MsoListParagraphCxSpMiddle"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Launch the tool via the Visual Studio Command Prompt. Under &lt;b style="mso-bidi-font-weight: normal"&gt;Settings&lt;/b&gt;, enable &lt;b style="mso-bidi-font-weight: normal"&gt;Log All Binds to Disk&lt;/b&gt;. (You may also need to check &lt;b style="mso-bidi-font-weight: normal"&gt;Enable custom log path&lt;/b&gt; and provide a custom log path). &lt;/p&gt; &lt;p class="MsoListParagraphCxSpMiddle"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Run your application.&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/p&gt; &lt;p class="MsoListParagraphCxSpMiddle"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; In the &lt;b style="mso-bidi-font-weight: normal"&gt;Log Categories&lt;/b&gt; box, select &lt;b style="mso-bidi-font-weight: normal"&gt;Native Images&lt;/b&gt; and hit &lt;b style="mso-bidi-font-weight: normal"&gt;Refresh&lt;/b&gt;.&lt;/p&gt; &lt;p class="MsoListParagraphCxSpMiddle"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; The format of each entry in this log is such that Application column is the name of the executable and Description column contains the name of the assembly being loaded. &lt;/p&gt; &lt;p class="MsoListParagraphCxSpMiddle"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; If you open the log entry, at the bottom of the text will be a “WRN: No matching native image found.” If the native image for that assembly could not be loaded. &lt;/p&gt; &lt;p class="MsoListParagraphCxSpMiddle" style="text-indent: -0.25in; mso-list: l4 level1 lfo4"&gt;&lt;span style="mso-fareast-font-family: calibri; mso-fareast-theme-font: minor-latin; mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin"&gt;&lt;span style="mso-list: ignore"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span style="mso-fareast-font-family: calibri; mso-fareast-theme-font: minor-latin; mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin"&gt;&lt;span style="mso-list: ignore"&gt;2&amp;gt;&lt;span style="font: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;Inspect the list of loaded modules in Visual Studio: useful if running within Visual Studio&lt;/p&gt; &lt;p class="MsoListParagraphCxSpMiddle"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; The list of modules does not contain the native image files by default if your VS Solution was created for managed code. In order to work around this problem, from the &lt;b style="mso-bidi-font-weight: normal"&gt;Project&lt;/b&gt; menu go to &lt;b style="mso-bidi-font-weight: normal"&gt;Properties&lt;/b&gt; and in the &lt;b style="mso-bidi-font-weight: normal"&gt;Debug&lt;/b&gt; tab, mark the check box for &lt;b style="mso-bidi-font-weight: normal"&gt;Enable Unmanaged Code Debugging&lt;/b&gt;.&lt;/p&gt; &lt;p class="MsoListParagraphCxSpMiddle"&gt;&lt;u&gt;&lt;o:p&gt;&lt;span style="text-decoration: none"&gt;&lt;/span&gt;&lt;/o:p&gt;&lt;/u&gt;&lt;/p&gt; &lt;p class="MsoListParagraphCxSpMiddle"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;u&gt;While debugging&lt;/u&gt;, from the &lt;b style="mso-bidi-font-weight: normal"&gt;Debug&lt;/b&gt; menu go to &lt;b style="mso-bidi-font-weight: normal"&gt;Windows&lt;/b&gt; and &lt;b style="mso-bidi-font-weight: normal"&gt;Modules&lt;/b&gt;, to see a list of the modules loaded into the process. &lt;/p&gt; &lt;p class="MsoListParagraphCxSpLast"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="mso-no-proof: yes"&gt;&lt;a href="http://blogs.msdn.com/blogfiles/clrcodegeneration/WindowsLiveWriter/6feecb9e8f99_10BF1/clip_image002_2.jpg"&gt;&lt;img title="clip_image002" style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="135" alt="clip_image002" src="http://blogs.msdn.com/blogfiles/clrcodegeneration/WindowsLiveWriter/6feecb9e8f99_10BF1/clip_image002_thumb.jpg" width="244" border="0" v:shapes="Picture_x0020_2"&gt;&lt;/a&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal"&gt;&lt;u&gt;Further Reading&lt;/u&gt;&lt;/p&gt; &lt;p class="MsoListParagraphCxSpFirst" style="text-indent: -0.25in; mso-list: l1 level1 lfo7"&gt;&lt;span style="mso-fareast-font-family: calibri; mso-fareast-theme-font: minor-latin; mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin"&gt;&lt;span style="mso-list: ignore"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span style="mso-fareast-font-family: calibri; mso-fareast-theme-font: minor-latin; mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin"&gt;&lt;span style="mso-list: ignore"&gt;1&amp;gt;&lt;span style="font: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;Assembly Binding Log Viewer (fuslogvw.exe): &lt;a href="http://msdn.microsoft.com/en-us/library/e74a18c4.aspx"&gt;http://msdn.microsoft.com/en-us/library/e74a18c4.aspx&lt;/a&gt; &lt;/p&gt; &lt;p class="MsoListParagraphCxSpLast" style="text-indent: -0.25in; mso-list: l1 level1 lfo7"&gt;&lt;span style="mso-fareast-font-family: calibri; mso-fareast-theme-font: minor-latin; mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin"&gt;&lt;span style="mso-list: ignore"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span style="mso-fareast-font-family: calibri; mso-fareast-theme-font: minor-latin; mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin"&gt;&lt;span style="mso-list: ignore"&gt;2&amp;gt;&lt;span style="font: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;More tricks on how to tell if the NGen image got loaded: &lt;a href="http://blogs.msdn.com/jmstall/archive/2006/10/04/debugging_5F00_ngen_5F00_code.aspx"&gt;http://blogs.msdn.com/jmstall/archive/2006/10/04/debugging_5F00_ngen_5F00_code.aspx&lt;/a&gt; &lt;/p&gt; &lt;p class="MsoNormal"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/p&gt; &lt;h5&gt;&lt;b style="mso-bidi-font-weight: normal"&gt;Ensuring that the JIT did not get used during runtime&lt;/b&gt;&lt;/h5&gt; &lt;p class="MsoNormal"&gt;You might be wondering what the difference between the previous section “Ensuring native images got loaded during runtime” and this one is. If the native image file got loaded for an assembly, the JIT should not fire for it, right? Well, not quite. Sometimes, even though the native image might have been used for the bulk of the method in that assembly, the JIT does get loaded for some methods, or types of code within the assembly being executed; for example, some generic instantiations, dynamically generated code, multiple AppDomain scenarios etc. So, even though the native image file might have been loaded for an assembly and we may have used the native code from that assembly for most of our method execution needs, for some methods, we may have to fall back to JIT. It is important to know what those methods are for your application. &lt;/p&gt; &lt;p class="MsoNormal"&gt;&amp;nbsp;&lt;/p&gt; &lt;p class="MsoNormal"&gt;Moreover, if your application has several DLLs, it may not be a trivial amount of work to ensure that each DLL had a corresponding “.ni.dll” loaded for it, by inspecting either Fusion Log Viewer content or the Modules window content. Using the JitCompilationStart MDA will help in such scenarios as well. &lt;/p&gt; &lt;p class="MsoNormal"&gt;&amp;nbsp;&lt;/p&gt; &lt;p class="MsoNormal"&gt;As of this writing, the easiest way to determine this is by using the JitCompilationStart Managed Debugging Assistant. The 2 MSDN articles listed under “Further Reading” below give some excellent background information on what MDAs are, how to use them and how the JitCompilationStart MDA can be used.&lt;/p&gt; &lt;p class="MsoNormal"&gt;&amp;nbsp;&lt;/p&gt; &lt;p class="MsoNormal"&gt;Now let’s look at the practical steps for how to set up your Visual Studio configuration correctly so that the JitCompilationStart MDA will fire when it needs to.&lt;/p&gt; &lt;p class="MsoListParagraphCxSpFirst" style="text-indent: -0.25in; mso-list: l0 level1 lfo3"&gt;&lt;span style="mso-fareast-font-family: calibri; mso-fareast-theme-font: minor-latin; mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin"&gt;&lt;span style="mso-list: ignore"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1&amp;gt;&lt;span style="font: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;Disable the Visual Studio hosting process. See &lt;a href="http://msdn.microsoft.com/en-us/library/ms185330(VS.80).aspx"&gt;http://msdn.microsoft.com/en-us/library/ms185330(VS.80).aspx&lt;/a&gt; for instructions.&lt;/p&gt; &lt;p class="MsoListParagraphCxSpMiddle" style="text-indent: -0.25in; mso-list: l0 level1 lfo3"&gt;&lt;span style="mso-fareast-font-family: calibri; mso-fareast-theme-font: minor-latin; mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin"&gt;&lt;span style="mso-list: ignore"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 2&amp;gt;&lt;span style="font: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;If your application executable name is hello.exe, add a hello.exe.mda.config file to your solution with the contents below and in the &lt;b style="mso-bidi-font-weight: normal"&gt;Properties&lt;/b&gt; set &lt;b style="mso-bidi-font-weight: normal"&gt;Copy to Output Directory &lt;/b&gt;to&lt;b style="mso-bidi-font-weight: normal"&gt; Copy Always.&lt;/b&gt;&lt;/p&gt; &lt;p class="MsoListParagraphCxSpMiddle"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="font-size: 9pt; font-family: 'Courier New'"&gt;&amp;lt;mdaConfig&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoListParagraphCxSpMiddle"&gt;&lt;span style="font-size: 9pt; font-family: 'Courier New'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;assistants&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoListParagraphCxSpMiddle"&gt;&lt;span style="font-size: 9pt; font-family: 'Courier New'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;jitCompilationStart&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoListParagraphCxSpMiddle"&gt;&lt;span style="font-size: 9pt; font-family: 'Courier New'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;methods&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoListParagraphCxSpMiddle"&gt;&lt;span style="font-size: 9pt; font-family: 'Courier New'"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&amp;lt;match name="*" /&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoListParagraphCxSpMiddle"&gt;&lt;span style="font-size: 9pt; font-family: 'Courier New'"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&amp;lt;/methods&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoListParagraphCxSpMiddle"&gt;&lt;span style="font-size: 9pt; font-family: 'Courier New'"&gt;&lt;span style="font-size: 9pt; font-family: 'Courier New'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&amp;lt;/jitCompilationStart &amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoListParagraphCxSpMiddle"&gt;&lt;span style="font-size: 9pt; font-family: 'Courier New'"&gt;&lt;span style="font-size: 9pt; font-family: 'Courier New'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&amp;lt;/assistants&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoListParagraphCxSpMiddle"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="font-size: 9pt; font-family: 'Courier New'"&gt;&amp;lt;/mdaConfig&amp;gt;&lt;/span&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/p&gt; &lt;p class="MsoListParagraphCxSpMiddle" style="text-indent: -0.25in; mso-list: l0 level1 lfo3"&gt;&lt;span style="mso-fareast-font-family: calibri; mso-fareast-theme-font: minor-latin; mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin"&gt;&lt;span style="mso-list: ignore"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 3&amp;gt;&lt;span style="font: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;Under the menu &lt;b style="mso-bidi-font-weight: normal"&gt;Debug&lt;/b&gt; go to &lt;b style="mso-bidi-font-weight: normal"&gt;Exceptions&lt;/b&gt; and set &lt;b style="mso-bidi-font-weight: normal"&gt;Managed Debugging Assistants&lt;/b&gt; to &lt;b style="mso-bidi-font-weight: normal"&gt;Thrown.&lt;/b&gt;&lt;/p&gt; &lt;p class="MsoListParagraphCxSpMiddle" style="text-indent: -0.25in; mso-list: l0 level1 lfo3"&gt;&lt;span style="mso-fareast-font-family: calibri; mso-fareast-theme-font: minor-latin; mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin"&gt;&lt;span style="mso-list: ignore"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 4&amp;gt;&lt;span style="font: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;From the &lt;b style="mso-bidi-font-weight: normal"&gt;Project&lt;/b&gt; menu go to &lt;b style="mso-bidi-font-weight: normal"&gt;Properties&lt;/b&gt; and in the &lt;b style="mso-bidi-font-weight: normal"&gt;Debug&lt;/b&gt; tab, mark the check box for &lt;b style="mso-bidi-font-weight: normal"&gt;Enable Unmanaged Code Debugging&lt;/b&gt;.&lt;/p&gt; &lt;p class="MsoListParagraphCxSpLast" style="text-indent: -0.25in; mso-list: l0 level1 lfo3"&gt;&lt;span style="mso-fareast-font-family: calibri; mso-fareast-theme-font: minor-latin; mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin"&gt;&lt;span style="mso-list: ignore"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 5&amp;gt;&lt;span style="font: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;Finally, in order to enable the MDA infrastructure to look at the hello.exe.mda.config file you created in Step 2, you need to update the registry. Under HKLM\Software\Microsoft\.NetFramework, create a REG_SZ sub-key called “MDA” and set its value to “1”. &lt;/p&gt; &lt;p class="MsoNormal"&gt;Yes I understand this is an unnecessarily large set of steps to go through to enable this particular MDA, we hope to improve this experience in a future release of Visual Studio. &lt;/p&gt; &lt;p class="MsoNormal"&gt;&amp;nbsp;&lt;/p&gt; &lt;p class="MsoNormal"&gt;Now that the JitCompilationStart MDA is enabled, all you need to do is hit F5! If a method does get JIT-ed, an unhandled exception dialog box will be generated of the type below. &lt;/p&gt; &lt;p class="MsoNormal"&gt;&amp;nbsp;&lt;/p&gt; &lt;p class="MsoNormal"&gt;&lt;span style="mso-no-proof: yes"&gt;&lt;a href="http://blogs.msdn.com/blogfiles/clrcodegeneration/WindowsLiveWriter/6feecb9e8f99_10BF1/clip_image004_2.jpg"&gt;&lt;img title="clip_image004" style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="127" alt="clip_image004" src="http://blogs.msdn.com/blogfiles/clrcodegeneration/WindowsLiveWriter/6feecb9e8f99_10BF1/clip_image004_thumb.jpg" width="244" border="0" v:shapes="Picture_x0020_1"&gt;&lt;/a&gt;&lt;/span&gt;&lt;span style="background: yellow; mso-highlight: yellow"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal"&gt;&amp;nbsp;&lt;/p&gt; &lt;p class="MsoNormal"&gt;Select Break in the dialog box to see the line of disassembly for which the JIT got loaded. The Call Stack window will also show the unmanaged call stack at which the break point occurs. This will provide a clue as to what part of your code caused the JIT to load.&lt;/p&gt; &lt;p class="MsoNormal"&gt;&amp;nbsp;&lt;/p&gt; &lt;p class="MsoNormal"&gt;&lt;u&gt;Further Reading&lt;/u&gt;&lt;/p&gt; &lt;p class="MsoListParagraphCxSpFirst" style="text-indent: -0.25in; mso-list: l5 level1 lfo6"&gt;&lt;span style="mso-fareast-font-family: calibri; mso-fareast-theme-font: minor-latin; mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin"&gt;&lt;span style="mso-list: ignore"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1&amp;gt;&lt;span style="font: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;Diagnosing Errors with Managed Debugging Assistants: &lt;a href="http://msdn.microsoft.com/en-us/library/d21c150d(VS.80).aspx"&gt;http://msdn.microsoft.com/en-us/library/d21c150d(VS.80).aspx&lt;/a&gt; &lt;/p&gt; &lt;p class="MsoListParagraphCxSpMiddle" style="text-indent: -0.25in; mso-list: l5 level1 lfo6"&gt;&lt;span style="mso-fareast-font-family: calibri; mso-fareast-theme-font: minor-latin; mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin"&gt;&lt;span style="mso-list: ignore"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span style="mso-fareast-font-family: calibri; mso-fareast-theme-font: minor-latin; mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin"&gt;&lt;span style="mso-list: ignore"&gt;2&amp;gt;&lt;span style="font: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;JitCompilationStart: &lt;a href="http://msdn.microsoft.com/en-us/library/fw872k46(VS.80).aspx"&gt;http://msdn.microsoft.com/en-us/library/fw872k46(VS.80).aspx&lt;/a&gt; &lt;/p&gt; &lt;p class="MsoListParagraphCxSpLast" style="text-indent: -0.25in; mso-list: l5 level1 lfo6"&gt;&lt;span style="mso-fareast-font-family: calibri; mso-fareast-theme-font: minor-latin; mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin"&gt;&lt;span style="mso-list: ignore"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span style="mso-fareast-font-family: calibri; mso-fareast-theme-font: minor-latin; mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin"&gt;&lt;span style="mso-list: ignore"&gt;3&amp;gt;&lt;span style="font: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;Description for how JIT can get loaded for multiple AppDomain scenarios: &lt;a href="http://msdn.microsoft.com/en-us/magazine/cc163610.aspx#S6"&gt;http://msdn.microsoft.com/en-us/magazine/cc163610.aspx#S6&lt;/a&gt; &lt;/p&gt; &lt;p class="MsoListParagraphCxSpLast" style="text-indent: -0.25in; mso-list: l5 level1 lfo6"&gt;&amp;nbsp;&lt;/p&gt; &lt;h5&gt;&lt;b style="mso-bidi-font-weight: normal"&gt;Wrapping it up!&lt;/b&gt;&amp;nbsp;&lt;/h5&gt; &lt;p class="MsoNormal"&gt;That summarizes the very basics of using Visual Studio to run NGen.exe for your application. This article hopefully articulates all the various steps needed to get the environment right, and points out potential pitfalls along the way. We’d love to hear what you think! Have you used Visual Studio in the past to enable NGen for your application? If not, what do you use? How was your experience? Please use the comments section below for any feedback and questions.&lt;/p&gt; &lt;p class="MsoNormal"&gt;&lt;o:p&gt;&lt;/o:p&gt;&amp;nbsp;&lt;/p&gt; &lt;p class="MsoNormal"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/p&gt; &lt;p class="MsoNormal"&gt;Pracheeti Nagarkar&lt;/p&gt; &lt;p class="MsoNormal"&gt;CLR Codegen team &lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10003338" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/b/clrcodegeneration/archive/tags/NGen/">NGen</category><category domain="http://blogs.msdn.com/b/clrcodegeneration/archive/tags/Pracheeti+Nagarkar/">Pracheeti Nagarkar</category><category domain="http://blogs.msdn.com/b/clrcodegeneration/archive/tags/JIT+MDA/">JIT MDA</category><category domain="http://blogs.msdn.com/b/clrcodegeneration/archive/tags/Fuslogvw/">Fuslogvw</category><category domain="http://blogs.msdn.com/b/clrcodegeneration/archive/tags/Visual+Studio/">Visual Studio</category></item><item><title>NGen: Walk-through Series</title><link>http://blogs.msdn.com/b/clrcodegeneration/archive/2010/04/27/ngen-walk-through-series.aspx</link><pubDate>Tue, 27 Apr 2010 17:24:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10003330</guid><dc:creator>pracheeti</dc:creator><slash:comments>2</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.msdn.com/b/clrcodegeneration/rsscomments.aspx?WeblogPostID=10003330</wfw:commentRss><comments>http://blogs.msdn.com/b/clrcodegeneration/archive/2010/04/27/ngen-walk-through-series.aspx#comments</comments><description>&lt;P&gt;Now that &lt;A href="http://www.microsoft.com/visualstudio/en-us/" mce_href="http://www.microsoft.com/visualstudio/en-us/"&gt;Microsoft Visual Studio 2010&lt;/A&gt; has shipped, we thought it would be a good time to publish a series of articles focused on how to use the NGen technology and how to measure performance benefits from it. This series features hands-on style content, so get your copy of Visual Studio 2010 installed and you’ll be ready to follow along. &lt;/P&gt;
&lt;P class=MsoNormal&gt;The following topics will be covered in the 4 blog posts that make up this series.&lt;/P&gt;
&lt;P class=MsoListParagraphCxSpFirst style="TEXT-INDENT: -0.25in; mso-list: l0 level1 lfo1"&gt;&lt;SPAN style="mso-fareast-font-family: calibri; mso-fareast-theme-font: minor-latin; mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin"&gt;&lt;SPAN style="mso-list: ignore"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1.&lt;SPAN style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;A class="" href="http://blogs.msdn.com/clrcodegeneration/archive/2010/04/27/ngen-getting-started-with-ngen-in-visual-studio.aspx" mce_href="http://blogs.msdn.com/clrcodegeneration/archive/2010/04/27/ngen-getting-started-with-ngen-in-visual-studio.aspx"&gt;NGen: Getting Started with NGen in Visual Studio&lt;/A&gt;&lt;/P&gt;
&lt;P class=MsoListParagraphCxSpFirst style="TEXT-INDENT: -0.25in; mso-list: l0 level1 lfo1"&gt;&lt;SPAN style="mso-fareast-font-family: calibri; mso-fareast-theme-font: minor-latin; mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin"&gt;&lt;SPAN style="mso-list: ignore"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 2.&lt;SPAN style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;A class="" href="http://blogs.msdn.com/clrcodegeneration/archive/2010/04/27/ngen-measuring-warm-startup-performance-with-xperf.aspx" mce_href="http://blogs.msdn.com/clrcodegeneration/archive/2010/04/27/ngen-measuring-warm-startup-performance-with-xperf.aspx"&gt;NGen: Measuring Warm Startup Performance with Xperf&lt;/A&gt;&lt;/P&gt;
&lt;P class=MsoListParagraphCxSpMiddle style="TEXT-INDENT: -0.25in; mso-list: l0 level1 lfo1"&gt;&lt;SPAN style="mso-fareast-font-family: calibri; mso-fareast-theme-font: minor-latin; mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin"&gt;&lt;SPAN style="mso-list: ignore"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 3.&lt;SPAN style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;A class="" href="http://blogs.msdn.com/clrcodegeneration/archive/2010/04/27/ngen-measuring-working-set-with-vmmap.aspx" mce_href="http://blogs.msdn.com/clrcodegeneration/archive/2010/04/27/ngen-measuring-working-set-with-vmmap.aspx"&gt;NGen: Measuring Working Set with VMMap&lt;/A&gt;&lt;/P&gt;
&lt;P class=MsoListParagraphCxSpLast style="TEXT-INDENT: -0.25in; mso-list: l0 level1 lfo1"&gt;&lt;SPAN style="mso-fareast-font-family: calibri; mso-fareast-theme-font: minor-latin; mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin"&gt;&lt;SPAN style="mso-list: ignore"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 4.&lt;SPAN style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;A class="" href="http://blogs.msdn.com/clrcodegeneration/archive/2010/04/27/ngen-creating-setup-projects.aspx" mce_href="http://blogs.msdn.com/clrcodegeneration/archive/2010/04/27/ngen-creating-setup-projects.aspx"&gt;NGen: Creating Setup Projects&lt;/A&gt;&lt;/P&gt;
&lt;P class=MsoNormal&gt;Please use the comments section under each post to reach out to us, provide feedback and ask questions. &lt;/P&gt;
&lt;P class=MsoNormal mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P class=MsoNormal&gt;&lt;?xml:namespace prefix = o /&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/P&gt;
&lt;P class=MsoNormal&gt;Pracheeti Nagarkar&lt;/P&gt;
&lt;P class=MsoNormal&gt;CLR CodeGen Team&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10003330" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/b/clrcodegeneration/archive/tags/NGen/">NGen</category><category domain="http://blogs.msdn.com/b/clrcodegeneration/archive/tags/Pracheeti+Nagarkar/">Pracheeti Nagarkar</category></item><item><title>JIT ETW Inlining Event Fail Reasons</title><link>http://blogs.msdn.com/b/clrcodegeneration/archive/2009/10/21/jit-etw-inlining-event-fail-reasons.aspx</link><pubDate>Wed, 21 Oct 2009 22:01:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9910953</guid><dc:creator>Grant Richins</dc:creator><slash:comments>2</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.msdn.com/b/clrcodegeneration/rsscomments.aspx?WeblogPostID=9910953</wfw:commentRss><comments>http://blogs.msdn.com/b/clrcodegeneration/archive/2009/10/21/jit-etw-inlining-event-fail-reasons.aspx#comments</comments><description>&lt;P&gt;This is a follow-up post&amp;nbsp; for &lt;A href="http://blogs.msdn.com/clrcodegeneration/archive/2009/05/11/jit-etw-tracing-in-net-framework-4.aspx"&gt;JIT ETW tracing in .NET Framework 4&lt;/A&gt;.&amp;nbsp; These are some of the possible strings that might show up in FailReason field of the MethodJitInliningFailed event.&amp;nbsp; These are reasons that come from or are checked for by the VM (as compared to the JIT) and are listed in no particular order:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;"Inlinee is NoMetadata" - this means the inlinee is not normal managed code. The most common case is &lt;A href="http://msdn.microsoft.com/en-us/library/system.reflection.emit.dynamicmethod(VS.100).aspx"&gt;dynamic methods&lt;/A&gt;. Another possibility is one of the many kinds of stubs the CLR uses internally for things like PInvoke marshalling, delegates, remoting, etc.&lt;/LI&gt;
&lt;LI&gt;"Inlinee is debuggable" - the inlinee was compiled or loaded in such a way that it told the runtime not to optimize its code (C#'s /o- switch is one example).&lt;/LI&gt;
&lt;LI&gt;"Profiler disabled inlining globally" - a profiler passed &lt;A href="http://msdn.microsoft.com/en-us/library/ms231874(VS.100).aspx"&gt;COR_PRF_DISABLE_INLINING&lt;/A&gt;.&lt;/LI&gt;
&lt;LI&gt;"Profiler disabled inlining locally" - a profiler passed &lt;A href="http://msdn.microsoft.com/en-us/library/ms231874(VS.100).aspx"&gt;COR_PRF_MONITOR_JIT_COMPILATION&lt;/A&gt; and then set *pfShouldInline to FALSE in &lt;A href="http://msdn.microsoft.com/en-us/library/ms232601(VS.100).aspx"&gt;ICorProfilerCallback::JITInlining&lt;/A&gt;.&lt;/LI&gt;
&lt;LI&gt;"Inlinee is not verifiable" - the inlinee does not have &lt;A href="http://msdn.microsoft.com/en-us/library/system.security.permissions.securitypermissionattribute.skipverification(VS.100).aspx"&gt;SkipVerification&lt;/A&gt; permission and is not verifiable. This is done so that verification exceptions are easier to debug.&lt;/LI&gt;
&lt;LI&gt;"Inlinee is marked as no inline" - the inlinee is explicitly marked with &lt;A href="http://msdn.microsoft.com/en-us/library/system.runtime.compilerservices.methodimploptions(VS.100).aspx"&gt;MethodImplOptions.NoInlining&lt;/A&gt;, or the VM or JIT previously determined that the method would never be a good inline candidate and marked it as such to speed subsequent JITs that might try to inline the same inlinee.&lt;/LI&gt;
&lt;LI&gt;"Inlinee requires a security object (calls Demand/Assert/Deny)" - the inlinee is marked with &lt;A href="http://msdn.microsoft.com/en-us/library/ms231030(VS.100).aspx"&gt;mdRequireSecObject&lt;/A&gt;. With our current implementation, such methods need their own call frame so the corresponding Assert or Deny will end at the return of the method.&lt;/LI&gt;
&lt;LI&gt;"Inlinee is MethodImpl'd by another method within the same type" - an implementation limitation such that it can't find the right method to give to the JIT to inline (but don't worry, it still finds the right one to call). See &lt;A href="http://msdn.microsoft.com/en-us/library/ms231913(VS.100).aspx"&gt;IMetadataEmit::DefineMethodImpl&lt;/A&gt; for how this is done at the IL level. It is my understanding that the C# language does not allow this, but VB.NET does.&lt;/LI&gt;
&lt;LI&gt;"Targeted Patching - Method lacks &lt;A href="http://msdn.microsoft.com/en-us/library/system.runtime.targetedpatchingoptoutattribute(VS.100).aspx"&gt;TargetedPatchingOptOutAttribute&lt;/A&gt;" - this relates to a new feature in CLR 4 where NGEN images are more version resilient. In a nutshell, we hope to be able to apply a patch or fix to mscorlib.dll and &lt;B&gt;not&lt;/B&gt; have to recompile all the other native images on the machine that depend upon it. This should only apply to methods in the .NET framework class libraries because they are the only assemblies that can &lt;A href="http://msdn.microsoft.com/en-us/library/system.runtime.assemblytargetedpatchbandattribute(VS.100).aspx"&gt;opt into this feature&lt;/A&gt;. For more information, see this previous blog post: &lt;A href="http://blogs.msdn.com/clrcodegeneration/archive/2009/05/03/Improvements-to-NGen-in-.NET-Framework-4.aspx"&gt;Improvements to NGen in .NET Framework 4&lt;/A&gt;.&lt;/LI&gt;
&lt;LI&gt;"Inlinee has restrictions the JIT doesn't want" - although this is in the code, in our current implementation this will never happen. It indicates that the VM needs to place a restriction on the inlinee (i.e. the inlinee can only be inlined if certain conditions are met), but the JIT doesn't allow any restrictions, so the VM has to refuse the inlining.&lt;/LI&gt;&lt;/UL&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9910953" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/b/clrcodegeneration/archive/tags/JIT/">JIT</category><category domain="http://blogs.msdn.com/b/clrcodegeneration/archive/tags/performance/">performance</category><category domain="http://blogs.msdn.com/b/clrcodegeneration/archive/tags/-NET+Framework+4/">.NET Framework 4</category><category domain="http://blogs.msdn.com/b/clrcodegeneration/archive/tags/ETW/">ETW</category></item><item><title>Array Bounds Check Elimination in the CLR</title><link>http://blogs.msdn.com/b/clrcodegeneration/archive/2009/08/13/array-bounds-check-elimination-in-the-clr.aspx</link><pubDate>Thu, 13 Aug 2009 23:46:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9868799</guid><dc:creator>Dave Detlefs</dc:creator><slash:comments>4</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.msdn.com/b/clrcodegeneration/rsscomments.aspx?WeblogPostID=9868799</wfw:commentRss><comments>http://blogs.msdn.com/b/clrcodegeneration/archive/2009/08/13/array-bounds-check-elimination-in-the-clr.aspx#comments</comments><description>&lt;DIV style="BORDER-BOTTOM: #4f81bd 1pt solid; BORDER-LEFT: medium none; PADDING-BOTTOM: 4pt; PADDING-LEFT: 0in; PADDING-RIGHT: 0in; BORDER-TOP: medium none; BORDER-RIGHT: medium none; PADDING-TOP: 0in; mso-element: para-border-div; mso-border-bottom-themecolor: accent1"&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;H1 style="MARGIN: 24pt 0in 0pt"&gt;&lt;FONT size=5&gt;&lt;FONT color=#365f91&gt;&lt;FONT face=Cambria&gt;Introduction&lt;?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/H1&gt;
&lt;P style="MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;FONT face=Calibri&gt;&lt;FONT size=3&gt;One argument often made by those who dislike managed code is along the lines of “managed code can never be as fast as native code, because managed code has to do array bounds checks.”&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;Of course, this isn’t precisely true – it would be more accurate to say that “managed code must ensure that any indexing outside of an array’s bounds raises an appropriate exception.”&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;If a compiler can prove statically that an array index operation is safe, it doesn’t need to generate a dynamic test.&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;We’re not starting from scratch here.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;There’s been a lot of academic (and industrial) research on bounds check elimination, and various managed code systems have implemented some subset of these techniques.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;Putting “array bounds check elimination” into bing.com yielded a large number of relevant papers, many of which I’ve read and enjoyed; I’d imagine a competitor’s search site would do the same &lt;/FONT&gt;&lt;SPAN style="FONT-FAMILY: Wingdings; mso-ascii-font-family: Calibri; mso-ascii-theme-font: minor-latin; mso-hansi-font-family: Calibri; mso-hansi-theme-font: minor-latin; mso-char-type: symbol; mso-symbol-font-family: Wingdings"&gt;&lt;SPAN style="mso-char-type: symbol; mso-symbol-font-family: Wingdings"&gt;J&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;FONT face=Calibri&gt;.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;This &lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&lt;/SPAN&gt;blog post will explore what the CLR’s just-in-time compilers do and do not do in this area.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;I’ll of course highlight the good cases, but I’m also going to be brutally honest, and expose many examples where we could potentially eliminate a range check, but don’t.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&lt;/SPAN&gt;The reader (and, for that matter, the author, who didn’t implement this stuff himself) should keep in mind an important constraint: these are, in fact dynamic JIT compilers, so any extra optimization that slows the compiler down must be balanced against the gains of that optimization.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;Even when we run the JIT “offline”, via the NGEN tool, users are sensitive to compiler throughput.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;So there are many things we &lt;I style="mso-bidi-font-style: normal"&gt;could &lt;/I&gt;do, but all take CLR developer effort, and some of them use up our precious compilation time budget.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;That excuse being made, it’s up to us to be clever and figure out how to do some of these optimizations efficiently in the compiler, and we’ll certainly try to do more of that in the future.&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;The JIT compilers for x86 and x64 are currently quite different code bases, and I’ll describe the behavior of each here.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;The reader should note however, that we intend to unify them at some point in the not-too-distant future.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;The x86 JIT is faster in terms of compilation speed; the x64 JIT is slower, but does more interesting optimizations.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;Our plan is to extend the x86 codebase to generate x64 code, and incorporate some of the x64 JIT’s optimizations without unduly increasing compilation time.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;In any case, performance characteristics of JITted code on x64 platforms is likely to change significantly when this unification is achieved.&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;When I show examples where we don’t eliminate bounds checks, I will when possible give advice that will help you stay within boundary of idioms for which we can.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;I’ll discuss things we might be able to do in the future, but I’m not in a position to give any scheduling commitments on when these might be done.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;I can say that any reader feedback on prioritization will be taken into account.&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;H1 style="MARGIN: 24pt 0in 0pt"&gt;&lt;FONT size=5&gt;&lt;FONT color=#365f91&gt;&lt;FONT face=Cambria&gt;Code Gen for Range Checks&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/H1&gt;
&lt;P style="MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;Before we start considering when we eliminate range checks, let’s see what the code generated for a range check looks like.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;Here is bounds-check code generated by the CLR’s x86 JIT for an example array index expression a[i]:&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=Code&gt;&lt;STRONG&gt;&lt;FONT face="Courier New"&gt;IN0001: 000003&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;cmp&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;EDX, dword ptr [ECX+4]&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;// a in ECX, i in EDX&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=Code&gt;&lt;STRONG&gt;&lt;FONT face="Courier New"&gt;IN0002: 000006&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;jae&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;SHORT G_M60672_IG03&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;// unsigned comparison&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P style="TEXT-ALIGN: center; MARGIN: 0in 0in 0pt" class=Code align=center&gt;&lt;o:p&gt;&lt;STRONG&gt;&lt;FONT face="Courier New"&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/o:p&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;FONT size=3 face=Calibri&gt;In the first instruction, EDX contains the array index, and ECX + 4 is the address of the length field of the array.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;We compare these, and jump if the index is greater than or equal to the length.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;The jump target, not shown, raises a &lt;/FONT&gt;&lt;SPAN class=CodeChar&gt;&lt;SPAN style="LINE-HEIGHT: 115%; FONT-SIZE: 9pt; mso-bidi-font-size: 11.0pt"&gt;&lt;STRONG&gt;&lt;FONT face="Courier New"&gt;System.IndexOutOfRangeException&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;A sharp-eyed reader might wonder: the semantics require not only that the index value is less than the array length, but also that it is at least zero.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;Isn’t that two checks?&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;How did they get away with only one comparison and branch?&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;The answer is that we (like many other systems) take advantage of the wonders of unsigned arithmetic – the x86 “jae” instruction interprets its arguments as unsigned integers (it’s the unsigned equivalent of “jge”, if that’s more familiar to some readers).&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;The type of the length of an array, and an expression used to index into an array, is Int32, not UInt32.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;So the maximum value for either of these is 2&lt;SUP&gt;31&lt;/SUP&gt;-1.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;Further, we know that the array length will be non-negative.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;So if we convert the array length to a UInt32, it doesn’t affect its value.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;The index value, however, &lt;I style="mso-bidi-font-style: normal"&gt;might &lt;/I&gt;be negative.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;If it is, casting its bit pattern to UInt32 yields a value that is &lt;I style="mso-bidi-font-style: normal"&gt;at least &lt;/I&gt;2&lt;SUP&gt;31&lt;/SUP&gt;.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;So both cases, when the index value is negative, or when it is larger than the array length, are handled by the same test.&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;In an NGEN image, we try to separate out code we expect to never be executed (code that is so “cold” that it’s at absolute zero!), hoping to increase working set density, especially during startup.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;We expect bounds-check failures to be in this category, so we put the basic blocks for failure cases on cold pages.&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;H1 style="MARGIN: 24pt 0in 0pt"&gt;&lt;FONT size=5&gt;&lt;FONT color=#365f91&gt;&lt;FONT face=Cambria&gt;Bounds-check removal cases&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/H1&gt;
&lt;P style="MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;FONT face=Calibri&gt;&lt;FONT size=3&gt;Now we’ll examine some test cases, starting with some simple ones.&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;H3 style="MARGIN: 10pt 0in 0pt"&gt;&lt;FONT color=#4f81bd&gt;&lt;FONT face=Cambria&gt;&lt;FONT size=3&gt;Simple cases&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/H3&gt;
&lt;P style="MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;The good news is that we &lt;I style="mso-bidi-font-style: normal"&gt;do &lt;/I&gt;eliminate bounds checks for what we believe to be the most common form of array accesses: accesses that occur within a loop over all the indices of the loop.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;So, there is no dynamic range check for the array access in this program:&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=Code&gt;&lt;STRONG&gt;&lt;FONT face="Courier New"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;static void Test_SimpleAscend(int[] a) {&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=Code&gt;&lt;STRONG&gt;&lt;FONT face="Courier New"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;for (int i = 0; i &amp;lt; a.Length; i++)&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=Code&gt;&lt;STRONG&gt;&lt;FONT face="Courier New"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;a[i] = i;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;// We get this.&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=Code&gt;&lt;STRONG&gt;&lt;FONT face="Courier New"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=Code&gt;&lt;o:p&gt;&lt;STRONG&gt;&lt;FONT face="Courier New"&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/o:p&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;Unfortunately, we do not eliminate the range check for the descending version of this loop:&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=Code&gt;&lt;STRONG&gt;&lt;FONT face="Courier New"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;static void Test_SimpleDescend(int[] a) {&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=Code&gt;&lt;STRONG&gt;&lt;FONT face="Courier New"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;for (int i = a.Length - 1; i &amp;gt;= 0; i--)&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=Code&gt;&lt;STRONG&gt;&lt;FONT face="Courier New"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;a[i] = i;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;// We DO NOT get this.&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=Code&gt;&lt;STRONG&gt;&lt;FONT face="Courier New"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=Code&gt;&lt;o:p&gt;&lt;STRONG&gt;&lt;FONT face="Courier New"&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/o:p&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;FONT face=Calibri&gt;&lt;FONT size=3&gt;Some older programmers learned to write loops like this, because on some early architectures (&lt;I style="mso-bidi-font-style: normal"&gt;e.g., &lt;/I&gt;DEC PDP-8, if memory serves) there was a hardware addressing mode that did auto-decrement, but not auto-increment.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;They may have passed this habit down to middle-aged programmers (of which I am one), and so on.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;There’s also a somewhat more currently-valid argument that hardware generally supports a comparison to zero without requiring the value zero to be placed in a register.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;In any case, while the JIT compiler should arguably eliminate the bounds check for the descending form of the loop, we don’t today, and the cost of the bounds check probably outweighs any of the other advantages.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;So:&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="TEXT-INDENT: -0.25in; MARGIN: 0in 0in 10pt 0.5in; mso-list: l0 level1 lfo2" class=MsoListParagraph&gt;&lt;SPAN style="FONT-FAMILY: Symbol; mso-fareast-font-family: Symbol; mso-bidi-font-family: Symbol"&gt;&lt;SPAN style="mso-list: Ignore"&gt;&lt;FONT size=3&gt;·&lt;/FONT&gt;&lt;SPAN style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;&lt;B style="mso-bidi-font-weight: normal"&gt;Advice 1: &lt;/B&gt;if you have the choice between using an ascending or descending loop to access an array, choose ascending.&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=Code&gt;&lt;o:p&gt;&lt;STRONG&gt;&lt;FONT face="Courier New"&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/o:p&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;FONT face=Calibri&gt;&lt;FONT size=3&gt;I’ve put the array access on the left-hand side of an assignment in both these examples, but it works independently of the context in which the array index expression appears (as long as it’s within the loop, of course).&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;H3 style="MARGIN: 10pt 0in 0pt"&gt;&lt;FONT color=#4f81bd&gt;&lt;FONT face=Cambria&gt;&lt;FONT size=3&gt;Do we track equalities with the length of a newly allocated array?&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/H3&gt;
&lt;P style="MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;Here is a case in which the x86 JIT does not eliminate the bounds check:&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=Code&gt;&lt;STRONG&gt;&lt;FONT face="Courier New"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;static int[] Test_ArrayCopy1(int n) {&lt;SPAN style="FONT-WEIGHT: normal"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=Code&gt;&lt;STRONG&gt;&lt;FONT face="Courier New"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;int[] ia = new int[n];&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=Code&gt;&lt;STRONG&gt;&lt;FONT face="Courier New"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;for (int i = 0; i &amp;lt; n; i++)&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=Code&gt;&lt;STRONG&gt;&lt;FONT face="Courier New"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;ia[i] = i;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;// We do not get this one.&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=Code&gt;&lt;STRONG&gt;&lt;FONT face="Courier New"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;return ia;&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=Code&gt;&lt;STRONG&gt;&lt;FONT face="Courier New"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=Code&gt;&lt;o:p&gt;&lt;STRONG&gt;&lt;FONT face="Courier New"&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/o:p&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;FONT size=3 face=Calibri&gt;No excuses here: there’s no reason not to get this, the JIT compiler ought to know that &lt;/FONT&gt;&lt;SPAN class=CodeChar&gt;&lt;SPAN style="LINE-HEIGHT: 115%; FONT-SIZE: 9pt; mso-bidi-font-size: 11.0pt"&gt;&lt;STRONG&gt;&lt;FONT face="Courier New"&gt;n&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;FONT size=3 face=Calibri&gt; is the length of the newly allocated array in &lt;/FONT&gt;&lt;SPAN class=CodeChar&gt;&lt;SPAN style="LINE-HEIGHT: 115%; FONT-SIZE: 9pt; mso-bidi-font-size: 11.0pt"&gt;&lt;STRONG&gt;&lt;FONT face="Courier New"&gt;ia&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;FONT size=3 face=Calibri&gt;.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;In fact, the author of such code might think he was doing the JIT compiler a favor, since comparison with a local variable &lt;/FONT&gt;&lt;SPAN class=CodeChar&gt;&lt;SPAN style="LINE-HEIGHT: 115%; FONT-SIZE: 9pt; mso-bidi-font-size: 11.0pt"&gt;&lt;STRONG&gt;&lt;FONT face="Courier New"&gt;n&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;FONT size=3 face=Calibri&gt; might seem cheaper than comparison with &lt;/FONT&gt;&lt;SPAN class=CodeChar&gt;&lt;SPAN style="LINE-HEIGHT: 115%; FONT-SIZE: 9pt; mso-bidi-font-size: 11.0pt"&gt;&lt;STRONG&gt;&lt;FONT face="Courier New"&gt;ia.Length&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;FONT face=Calibri&gt;&lt;FONT size=3&gt; (though this isn’t really true on Intel machines).&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;But in our system, at least today, this sort of transformation is counterproductive for the x86 JIT, since it prevents the bounds check from being eliminated.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;We may well extend our compiler(s) to track this sort of value equivalence in the future.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;For now, though, you should follow this piece of practical advice:&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="TEXT-INDENT: -0.25in; MARGIN: 0in 0in 10pt 0.5in; mso-list: l1 level1 lfo1" class=MsoListParagraph&gt;&lt;SPAN style="FONT-FAMILY: Symbol; mso-fareast-font-family: Symbol; mso-bidi-font-family: Symbol"&gt;&lt;SPAN style="mso-list: Ignore"&gt;&lt;FONT size=3&gt;·&lt;/FONT&gt;&lt;SPAN style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;&lt;B style="mso-bidi-font-weight: normal"&gt;Advice 2: &lt;/B&gt;When possible, use “a.Length” to bound a loop whose index variable is used to index into “a”.&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;FONT size=3 face=Calibri&gt;The x64 JIT &lt;I style="mso-bidi-font-style: normal"&gt;does &lt;/I&gt;eliminate the range checks here, by hoisting a test outside the loop, comparing &lt;/FONT&gt;&lt;SPAN class=CodeChar&gt;&lt;SPAN style="LINE-HEIGHT: 115%; FONT-SIZE: 9pt; mso-bidi-font-size: 11.0pt"&gt;&lt;STRONG&gt;&lt;FONT face="Courier New"&gt;n&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;FONT size=3 face=Calibri&gt; with &lt;/FONT&gt;&lt;SPAN class=CodeChar&gt;&lt;SPAN style="LINE-HEIGHT: 115%; FONT-SIZE: 9pt; mso-bidi-font-size: 11.0pt"&gt;&lt;STRONG&gt;&lt;FONT face="Courier New"&gt;ia.Length&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;FONT size=3 face=Calibri&gt;.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;If this check fails, it throws an &lt;/FONT&gt;&lt;STRONG&gt;&lt;SPAN class=CodeChar&gt;&lt;SPAN style="LINE-HEIGHT: 115%; FONT-SIZE: 9pt; mso-bidi-font-size: 11.0pt"&gt;&lt;FONT face="Courier New"&gt;IndexOutOfRangeException.&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN class=CodeChar&gt;&lt;SPAN style="LINE-HEIGHT: 115%; FONT-FAMILY: 'Calibri','sans-serif'; FONT-SIZE: 9pt; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-bidi-font-size: 11.0pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;FONT size=3 face=Calibri&gt;This is somewhat problematic, since without this optimization the program would execute &lt;/FONT&gt;&lt;SPAN class=CodeChar&gt;&lt;SPAN style="LINE-HEIGHT: 115%; FONT-SIZE: 9pt; mso-bidi-font-size: 11.0pt"&gt;&lt;STRONG&gt;&lt;FONT face="Courier New"&gt;ia.Length&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;FONT size=3 face=Calibri&gt; iterations of the loop before throwing an exception, and strict language semantics would require those to be executed if they could possibly have a side-effect visible outside the method (which this example does not in fact have – though proving it requires your compiler to do enough escape analysis to know that the allocated array that is written to has not leaked outside the method).&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;This semantic ambiguity is the subject of some internal debate, and we’ll eventually reach consensus on how/when to incorporate such tests in a unified JIT,&lt;SPAN class=MsoFootnoteReference&gt; &lt;/SPAN&gt;or whether we need to ensure strict semantics, perhaps by generating multiple copies of loop bodies, as we’ll discuss below.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;(It’s interesting to note that the hoisted test and throw would be justified by assuming the &lt;/FONT&gt;&lt;SPAN style="LINE-HEIGHT: 115%; FONT-FAMILY: 'Courier New'; COLOR: #000081; FONT-SIZE: 8pt"&gt;CompilationRelaxationsAttribute &lt;/SPAN&gt;&lt;FONT face=Calibri&gt;&lt;FONT size=3&gt;defined in section I.12.6.4 of the ECMA CLI specification for bounds-check error exceptions everywhere – whereas the specification requires it to be given explicitly.)&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;In any case, we should emphasize that, as far as we know, this is a “theoretical” concern only – we don’t know of any actual customer code whose correctness is affected by this issue.&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;H3 style="MARGIN: 10pt 0in 0pt"&gt;&lt;FONT color=#4f81bd&gt;&lt;FONT face=Cambria&gt;&lt;FONT size=3&gt;Redundant array accesses&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/H3&gt;
&lt;P style="MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;OK, while we’re slightly embarrassed by the previous “multiple names for the length” case, let’s cheer ourselves up with something we do well.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;We’re pretty good at eliminating redundant bounds checks.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;In the method:&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=Code&gt;&lt;STRONG&gt;&lt;FONT face="Courier New"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;static void Test_SimpleRedundant(int[] a, int i) {&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=Code&gt;&lt;STRONG&gt;&lt;FONT face="Courier New"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;k = a[i];&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=Code&gt;&lt;STRONG&gt;&lt;FONT face="Courier New"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;k = k + a[i];&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=Code&gt;&lt;STRONG&gt;&lt;FONT face="Courier New"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=Code&gt;&lt;o:p&gt;&lt;STRONG&gt;&lt;FONT face="Courier New"&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/o:p&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;bounds-check code is generated for the first instance of “a[i]”, but not the second.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;In fact, the x86 JIT treats it as a common subexpression, and the first result is re-used.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;And this works not just within “basic blocks” – it can work across control flow, as demonstrated by:&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=Code&gt;&lt;STRONG&gt;&lt;FONT face="Courier New"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;static void Test_RedundantExBB(int[] a, int i, bool b) {&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=Code&gt;&lt;STRONG&gt;&lt;FONT face="Courier New"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;k = a[i];&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=Code&gt;&lt;STRONG&gt;&lt;FONT face="Courier New"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;if (b) {&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=Code&gt;&lt;STRONG&gt;&lt;FONT face="Courier New"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;k = k + a[i];&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=Code&gt;&lt;STRONG&gt;&lt;FONT face="Courier New"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;} else {&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=Code&gt;&lt;STRONG&gt;&lt;FONT face="Courier New"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;k = k - a[i];&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=Code&gt;&lt;STRONG&gt;&lt;FONT face="Courier New"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=Code&gt;&lt;STRONG&gt;&lt;FONT face="Courier New"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=Code&gt;&lt;o:p&gt;&lt;STRONG&gt;&lt;FONT face="Courier New"&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/o:p&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;As before, the first “a[i]” gets a bounds check, but the two subsequent occurrences of “a[i]” do not. &lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&lt;/SPAN&gt;The x86 JIT also treats the expression as a common subexpression, re-using the result from the first read of “a[i]”.&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;It is not the case that bounds check elimination &lt;I style="mso-bidi-font-style: normal"&gt;only &lt;/I&gt;works in the x86 JIT when the result is a common subexpression.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;Consider this variation of the first case:&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=Code&gt;&lt;STRONG&gt;&lt;FONT face="Courier New"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;static void Test_RedundantNotCse(int[] a, int i, int j) {&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=Code&gt;&lt;STRONG&gt;&lt;FONT face="Courier New"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;k = a[i];&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=Code&gt;&lt;STRONG&gt;&lt;FONT face="Courier New"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;a[j] = i;&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=Code&gt;&lt;STRONG&gt;&lt;FONT face="Courier New"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;k = k + a[i];&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=Code&gt;&lt;STRONG&gt;&lt;FONT face="Courier New"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=Code&gt;&lt;o:p&gt;&lt;STRONG&gt;&lt;FONT face="Courier New"&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/o:p&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;FONT face=Calibri&gt;&lt;FONT size=3&gt;The JIT compiler obviously can’t tell whether “i” and “j” will have the same value at runtime.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;But it can tell that they &lt;I style="mso-bidi-font-style: normal"&gt;might, &lt;/I&gt;and that if they do, the “a[i]” on the last line will return the value written there on the second line.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;So we cannot treat the “a[i]” expressions on the first and last lines of the body as common subexpressions.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;But the assignment on the second line can’t affect the &lt;I style="mso-bidi-font-style: normal"&gt;length&lt;/I&gt; of the array “a,” so in fact the bounds check for the first line “covers” the “a[i]” on the third line – the generated code accesses the array without a bounds check (in both JITs).&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;H3 style="MARGIN: 10pt 0in 0pt"&gt;&lt;FONT color=#4f81bd&gt;&lt;FONT face=Cambria&gt;&lt;FONT size=3&gt;Arrays as IEnumerable&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/H3&gt;
&lt;P style="MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;FONT size=3 face=Calibri&gt;Arrays implement the IEnumerable interface, which raises a reasonable question: if you enumerate over the elements of an array using C#’s &lt;/FONT&gt;&lt;SPAN class=CodeChar&gt;&lt;SPAN style="LINE-HEIGHT: 115%; FONT-SIZE: 9pt; mso-bidi-font-size: 11.0pt"&gt;&lt;STRONG&gt;&lt;FONT face="Courier New"&gt;foreach &lt;/FONT&gt;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;construct, do you get bounds checks?&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;For example:&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=Code&gt;&lt;STRONG&gt;&lt;FONT face="Courier New"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;static int Test_Foreach(int[] ia) {&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=Code&gt;&lt;STRONG&gt;&lt;FONT face="Courier New"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;int sum = 0;&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=Code&gt;&lt;STRONG&gt;&lt;FONT face="Courier New"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;foreach (int i in ia) {&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=Code&gt;&lt;STRONG&gt;&lt;FONT face="Courier New"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;sum += i;&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=Code&gt;&lt;STRONG&gt;&lt;FONT face="Courier New"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=Code&gt;&lt;STRONG&gt;&lt;FONT face="Courier New"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;return sum;&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=Code&gt;&lt;STRONG&gt;&lt;FONT face="Courier New"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=Code&gt;&lt;o:p&gt;&lt;STRONG&gt;&lt;FONT face="Courier New"&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/o:p&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;FONT face=Calibri&gt;&lt;FONT size=3&gt;Happily, we do eliminate the bounds checks in this case.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;However, there is a little quirk here: of the cases listed, this one is the only one that is sensitive to whether the original source program (C#, in this case) was compiled to IL with the /optimize flag.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;The default for csc, the C# compiler, is not to optimize, and in this mode it produces somewhat more verbose IL for the range check that doesn’t fit the pattern that the JIT compiler looks for.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;So:&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="TEXT-INDENT: -0.25in; MARGIN: 0in 0in 10pt 0.5in; mso-list: l1 level1 lfo1" class=MsoListParagraph&gt;&lt;SPAN style="FONT-FAMILY: Symbol; mso-fareast-font-family: Symbol; mso-bidi-font-family: Symbol"&gt;&lt;SPAN style="mso-list: Ignore"&gt;&lt;FONT size=3&gt;·&lt;/FONT&gt;&lt;SPAN style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;FONT face=Calibri&gt;&lt;FONT size=3&gt;&lt;B style="mso-bidi-font-weight: normal"&gt;Advice 3: &lt;/B&gt;if you’re worried about performance, and your compiler has an optimization flag, uh, use it!&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;H3 style="MARGIN: 10pt 0in 0pt"&gt;&lt;FONT color=#4f81bd&gt;&lt;FONT face=Cambria&gt;&lt;FONT size=3&gt;Arrays in global locations; concurrency&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/H3&gt;
&lt;P style="MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;Here’s a case where we don’t eliminate the bounds check, but where we aren’t too embarrassed by this failure:&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=Code&gt;&lt;STRONG&gt;&lt;FONT face="Courier New"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;static int[] v;&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=Code&gt;&lt;STRONG&gt;&lt;FONT face="Courier New"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;…&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=Code&gt;&lt;STRONG&gt;&lt;FONT face="Courier New"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;static void Test_ArrayInGlobal() {&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=Code&gt;&lt;STRONG&gt;&lt;FONT face="Courier New"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;for (int i = 0; i &amp;lt; v.Length; i++)&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=Code&gt;&lt;STRONG&gt;&lt;FONT face="Courier New"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;v[i] = i;&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=Code&gt;&lt;STRONG&gt;&lt;FONT face="Courier New"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=Code&gt;&lt;o:p&gt;&lt;STRONG&gt;&lt;FONT face="Courier New"&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/o:p&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;FONT face=Calibri&gt;&lt;FONT size=3&gt;At first glance, this seems exactly the same as our first, simplest example, Test_SimpleAscend.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;The difference is that Test_SimpleAscend took an array argument, whereas Test_ArrayInGlobal’s array is accessed via a static variable, accessible to other threads.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;This makes static elimination of the bounds check for “v[i]” at the very least dicey.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;Let’s say we did, and that “v” initially holds an array of length 100.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;On the iteration when “i” reaches (say) 80, we check “i &amp;lt; v.Length”, and it’s still true.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;Now another thread sets “v” to an array whose length is only 50.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;If we go ahead with the array store without a dynamic check, we’re writing off the end of the array – type-safety and security are lost, game over.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;(Obviously, the same reasoning would apply for an array held in any location accessible to multiple threads – an object field, element of another array, anything not local to the running thread.)&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;FONT face=Calibri&gt;&lt;FONT size=3&gt;So we don’t do this, for good and solid reasons.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;If we cared enough, there &lt;I style="mso-bidi-font-style: normal"&gt;is &lt;/I&gt;a technique that would allow us to eliminate these bounds checks.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;But it would require us to couple otherwise-unrelated optimizations.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;As it happens, the code for accessing a static variable in the presence of app domains can be moderately costly, so it’s good to treat those as common-subexpression candidates, and the x86 JIT does in this case (the x64 JIT does not).&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;So the optimizer in essence synthesizes a local variable to hold the array.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;If we do this, then we &lt;I style="mso-bidi-font-style: normal"&gt;are &lt;/I&gt;back in the Test_SimpleAscend situation, and the bounds-check elimination is legal.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;But doing the bounds-check elimination &lt;I style="mso-bidi-font-style: normal"&gt;requires &lt;/I&gt;that the static variable be read once into a local.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;So it’s at least a bit complicated.&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;H3 style="MARGIN: 10pt 0in 0pt"&gt;&lt;FONT color=#4f81bd&gt;&lt;FONT face=Cambria&gt;&lt;FONT size=3&gt;Parallel arrays&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/H3&gt;
&lt;P style="MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;Next we consider a case that involves what are sometimes called “parallel arrays” (in the sense of their structure, not in the sense that they will be used by multiple threads):&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=Code&gt;&lt;STRONG&gt;&lt;FONT face="Courier New"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;static int Test_TwoArrays(int[] ia1, int[] ia2) {&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=Code&gt;&lt;STRONG&gt;&lt;FONT face="Courier New"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;// The programmer knows a precondition: ia1.Length == ia2.Length&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=Code&gt;&lt;STRONG&gt;&lt;FONT face="Courier New"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;int sum = 0;&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=Code&gt;&lt;STRONG&gt;&lt;FONT face="Courier New"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;for (int i = 0; i &amp;lt; ia1.Length; i++) {&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=Code&gt;&lt;STRONG&gt;&lt;FONT face="Courier New"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;// Below we eliminate the ia1 check, but not the one for ia2.&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=Code&gt;&lt;STRONG&gt;&lt;FONT face="Courier New"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;sum += (ia1[i] + ia2[i]);&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=Code&gt;&lt;STRONG&gt;&lt;FONT face="Courier New"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=Code&gt;&lt;STRONG&gt;&lt;FONT face="Courier New"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;return sum;&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=Code&gt;&lt;STRONG&gt;&lt;FONT face="Courier New"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=Code&gt;&lt;o:p&gt;&lt;STRONG&gt;&lt;FONT face="Courier New"&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/o:p&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;FONT size=3 face=Calibri&gt;Much as with Test_ArrayCopy1, the x64 JIT hoists a test comparing &lt;/FONT&gt;&lt;SPAN class=CodeChar&gt;&lt;SPAN style="LINE-HEIGHT: 115%; FONT-SIZE: 9pt; mso-bidi-font-size: 11.0pt"&gt;&lt;STRONG&gt;&lt;FONT face="Courier New"&gt;ia2.Length&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;FONT size=3 face=Calibri&gt; and &lt;/FONT&gt;&lt;SPAN class=CodeChar&gt;&lt;SPAN style="LINE-HEIGHT: 115%; FONT-SIZE: 9pt; mso-bidi-font-size: 11.0pt"&gt;&lt;STRONG&gt;&lt;FONT face="Courier New"&gt;ia1.Length&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;FONT size=3 face=Calibri&gt;, immediately throwing the bounds-check exception if the test fails.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;If the test succeeds, range checks for both array accesses in the loop are eliminated.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;The same comments about the semantic issues with such a test apply.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;The x86 JIT takes a more “purist” approach: it does not hoist a test, so it only eliminates the bounds check for the access to the array &lt;/FONT&gt;&lt;SPAN class=CodeChar&gt;&lt;SPAN style="LINE-HEIGHT: 115%; FONT-SIZE: 9pt; mso-bidi-font-size: 11.0pt"&gt;&lt;STRONG&gt;&lt;FONT face="Courier New"&gt;ia1&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;FONT size=3 face=Calibri&gt; whose &lt;/FONT&gt;&lt;SPAN class=CodeChar&gt;&lt;SPAN style="LINE-HEIGHT: 115%; FONT-SIZE: 9pt; mso-bidi-font-size: 11.0pt"&gt;&lt;STRONG&gt;&lt;FONT face="Courier New"&gt;Length&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;FONT face=Calibri&gt;&lt;FONT size=3&gt; bounds the index variable.&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;FONT face=Calibri&gt;&lt;FONT size=3&gt;We could resolve the two approaches.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;The mechanisms proposed for this sort of problem in the research literature have the common property that they require, at least in some cases, generating code for the loop multiple times, under different assumptions, and synthesizing some sort of test to determine which version of the loop should be executed – this is essentially the test that the x64 JIT is already creating.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;Generally, bounds check exceptions are rare – if the programmer wrote the code above, he or she had some reason to believe that the index expression “ia2[i]” was safe.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;So we could synthesize a test on that basis.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;In our case above, if the compiler proved that neither argument variable “ia1” or “ia2” was modified in the loop, then a test “ia2.Length &amp;gt;= ia1.Length” (the one the x64 JIT generates) outside the loop would allow us to execute an optimized version of the loop, with no bounds checks for either array access.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;If this test failed, however, we’d need to execute an unoptimized version of the loop to be completely semantically correct.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;You’d have to evaluate this test carefully, since it’s code that doesn’t appear in the original program.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;In particular in this case, you’d have to worry about whether either of “ia1” or “ia2” were null.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;If they are, you want the null pointer exception to occur at the appropriate point in execution, not in some code the compiler made up.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;So the synthesized test would have to include null tests, and take the unoptimized path if either argument is null.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;FONT face=Calibri&gt;&lt;FONT size=3&gt;As we’ve discussed, the x64 JIT generates the test, but not the unoptimized version of the loop – it throws the exception “early” in that case.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;Under the “purist” viewpoint, this is incorrect because if the test fails, the semantics require the program to execute some number of loop iterations before throwing the exception, and those iterations might have side effects.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;In many cases, we might be able to prove that the loop body does &lt;I style="mso-bidi-font-style: normal"&gt;not &lt;/I&gt;have side effects, and therefore use the x64 JIT’s strategy with semantic blessing.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;For example, a loop that computed the sum of the loop elements into a local would side-effect only that local variable – if the exception causes control flow to leave the method, the value of that local becomes meaningless.&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;FONT face=Calibri&gt;&lt;FONT size=3&gt;Many other patterns are amenable to this sort of synthesized test.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;An alternative form of Test_TwoArrays might have passed the shared length of both arrays as a separate argument, and used that as the loop bound.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;We could do something similar, synthesizing a test of that loop bound vs. both array lengths.&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;H4 style="MARGIN: 10pt 0in 0pt"&gt;&lt;EM&gt;&lt;FONT color=#4f81bd&gt;&lt;FONT face=Cambria&gt;Explicit Assertions&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/EM&gt;&lt;/H4&gt;
&lt;P style="MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;FONT face=Calibri&gt;&lt;FONT size=3&gt;Another suggestion that has been made is to allow the programmer to provide the relevant test in the form of a contract assertion (of a flavor that would be executed in all execution modes, not just in a debug mode).&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;This would essentially provide semantic “permission” to fail immediately if the test is violated, avoiding the need to have an unoptimized version of the loop.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;There are many things to be said for this sort of proposal: they can allow bounds checks to be eliminated in situations more complicated than those for which the compiler could easily infer a test, and the invariants they express are often useful program documentation as well.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;Still, I also worry somewhat about such proposals.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;In many common cases, it’s easy enough to infer the test, so we should avoid &lt;I style="mso-bidi-font-style: normal"&gt;requiring &lt;/I&gt;the programmer to add assertions in the easy cases.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;More importantly, if the programmer adds an assertion expecting it to eliminate a bounds check, how does the tool chain indicate whether he or she has been successful?&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;And, if not, why not?&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;These sorts of issues merit some more thought.&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;FONT face=Calibri&gt;&lt;FONT size=3&gt;Still another path would be to have a custom annotation like [OptimizeForSpeedNotSpace], allowing the programmer to tell us that the performance of this method is important enough that we should apply optimizations that we wouldn’t generally apply because they increase code size – &lt;I style="mso-bidi-font-style: normal"&gt;i.e., &lt;/I&gt;especially aggressive inlining, loop unrolling, loop body replication/specialization for the reasons discussed here, or for other forms of specialization.&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;FONT face=Calibri&gt;&lt;FONT size=3&gt;The right strategy in this area is obviously a little muddled.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;Constructive feedback is welcome!&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;H3 style="MARGIN: 10pt 0in 0pt"&gt;&lt;FONT color=#4f81bd&gt;&lt;FONT face=Cambria&gt;&lt;FONT size=3&gt;Copy loop&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/H3&gt;
&lt;P style="MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;Here’s another example, somewhat similar to the Test_TwoArrays case:&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=Code&gt;&lt;STRONG&gt;&lt;FONT face="Courier New"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;static int[] Test_ArrayCopy2(int[] ia1) {&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=Code&gt;&lt;STRONG&gt;&lt;FONT face="Courier New"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;// An array copy loop operation.&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=Code&gt;&lt;STRONG&gt;&lt;FONT face="Courier New"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;int[] res = new int[ia1.Length];&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=Code&gt;&lt;STRONG&gt;&lt;FONT face="Courier New"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;for (int i = 0; i &amp;lt; res.Length; i++) {&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=Code&gt;&lt;STRONG&gt;&lt;FONT face="Courier New"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;res[i] = ia1[i];&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=Code&gt;&lt;STRONG&gt;&lt;FONT face="Courier New"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=Code&gt;&lt;STRONG&gt;&lt;FONT face="Courier New"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;return res;&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=Code&gt;&lt;STRONG&gt;&lt;FONT face="Courier New"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=Code&gt;&lt;o:p&gt;&lt;STRONG&gt;&lt;FONT face="Courier New"&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/o:p&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;FONT face=Calibri&gt;&lt;FONT size=3&gt;As you might expect from previous examples, since we use the length of “res” as the loop bound, we eliminate the bounds check for the access to “res”.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;But we do not eliminate the check for the access to “ia1”.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;As in Test_ArrayCopy1, to eliminate this we’d need to do a better job of tracking equivalences of array lengths with local variables or other array lengths.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;We don’t do this today, but it’s certainly a plausible enhancement we might do.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;The x86 JIT leaves the bounds check in for the access “ia1[i]”, while the x64 JIT hoists a bounds-check out of the loop, as discussed above (and with the same difficulties discussed above).&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;FONT face=Calibri&gt;&lt;FONT size=3&gt;While it would be nice for us to eliminate the bounds checks cases like this, if you’re copying arrays, there are many reasons to use the built-in Array.Copy routine rather than writing an explicit copy loop like those that appear in these examples:&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="TEXT-INDENT: -0.25in; MARGIN: 0in 0in 10pt 0.5in; mso-list: l1 level1 lfo1" class=MsoListParagraph&gt;&lt;SPAN style="FONT-FAMILY: Symbol; mso-fareast-font-family: Symbol; mso-bidi-font-family: Symbol"&gt;&lt;SPAN style="mso-list: Ignore"&gt;&lt;FONT size=3&gt;·&lt;/FONT&gt;&lt;SPAN style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;FONT face=Calibri&gt;&lt;FONT size=3&gt;&lt;B style="mso-bidi-font-weight: normal"&gt;Advice 4: &lt;/B&gt;when you’re copying medium-to-large arrays, use Array.Copy, rather than explicit copy loops.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;First, all your range checks will be “hoisted” to a single check outside the loop.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;If the arrays contain object references, you will also get efficient “hoisting” of two more expenses related to storing into arrays of object types: the per-element “store checks” related to array covariance can often be eliminated by a check on the dynamic types of the arrays, and garbage-collection-related write barriers will be aggregated and become much more efficient.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;Finally, we will able to use more efficient “memcpy”-style copy loops.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;(And in the coming multicore world, perhaps even employ parallelism if the arrays are big enough!)&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;H3 style="MARGIN: 10pt 0in 0pt"&gt;&lt;FONT color=#4f81bd&gt;&lt;FONT face=Cambria&gt;&lt;FONT size=3&gt;Multi-dimensional Arrays&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/H3&gt;
&lt;P style="MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&lt;/SPAN&gt;The CLR, and C#, support real multi-dimensional arrays – in contrast to C++ or Java, which (directly) support only one-dimensional arrays.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;To get two-dimensional arrays, you have to simulate them, either through classes that represent the 2-d array as a large 1-d array, and do the appropriate index arithmetic, or as an “array-of-arrays.”&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;In the latter case, even if they are allocated originally to form a “rectangular” 2-d array, it’s hard for a compiler to prove that the array &lt;I style="mso-bidi-font-style: normal"&gt;stays &lt;/I&gt;rectangular, so bounds check on accesses to the “inner” arrays are hard to prove.&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;With true multi-dimensional arrays, the array lengths in each dimension are immutable (just as the length of a regular 1-d array is).&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;This makes removing of bounds checks in each dimension more tractable.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;A related advantage is that indexing calculations become easier when the array is known to be “rectangular.”&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;(With a good optimizer and appropriately aggressive inlining, C++ template-class-based simulations of multidimensional arrays can get similar indexing calculation code.)&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;Unfortunately, we aren’t yet able to remove any range checks for accesses in multi-dimensional arrays, even in simple cases like this:&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=Code&gt;&lt;STRONG&gt;&lt;FONT face="Courier New"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;static int Test_2D(int[,] mat) {&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=Code&gt;&lt;STRONG&gt;&lt;FONT face="Courier New"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;int sum = 0;&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=Code&gt;&lt;STRONG&gt;&lt;FONT face="Courier New"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;for (int i = 0; i &amp;lt; mat.GetLength(0); i++) {&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=Code&gt;&lt;STRONG&gt;&lt;FONT face="Courier New"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;for (int j = 0; j &amp;lt; mat.GetLength(1); j++) {&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=Code&gt;&lt;STRONG&gt;&lt;FONT face="Courier New"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;sum += mat[i, j];&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=Code&gt;&lt;STRONG&gt;&lt;FONT face="Courier New"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=Code&gt;&lt;STRONG&gt;&lt;FONT face="Courier New"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=Code&gt;&lt;STRONG&gt;&lt;FONT face="Courier New"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;return sum;&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=Code&gt;&lt;STRONG&gt;&lt;FONT face="Courier New"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=Code&gt;&lt;o:p&gt;&lt;STRONG&gt;&lt;FONT face="Courier New"&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/o:p&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;FONT face=Calibri&gt;&lt;FONT size=3&gt;The “mat.GetLength(k)” method returns the length of “mat” in the k&lt;SUP&gt;th&lt;/SUP&gt; dimension.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;We’ll clearly need to eliminate bounds checks for multi-dimensional array accesses if we want to generate reasonable code for, say, a matrix multiplication.&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="TEXT-INDENT: -0.25in; MARGIN: 0in 0in 10pt 0.5in; mso-list: l1 level1 lfo1" class=MsoListParagraph&gt;&lt;SPAN style="FONT-FAMILY: Symbol; mso-fareast-font-family: Symbol; mso-bidi-font-family: Symbol"&gt;&lt;SPAN style="mso-list: Ignore"&gt;&lt;FONT size=3&gt;·&lt;/FONT&gt;&lt;SPAN style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;&lt;B style="mso-bidi-font-weight: normal"&gt;Advice 5: &lt;/B&gt;Until we get this right, I would suggest that .NET users do what many C++ numerical programmers do: write a class to implement your n-dimensional array.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;This would be represented as a 1-dimensional array, and the relevant accessors would convert n indices into 1 via appropriate multiplications.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;We almost certainly wouldn’t eliminate the bounds check into the 1-d array, but at least we’d only do one check!&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;H1 style="MARGIN: 24pt 0in 0pt"&gt;&lt;FONT size=5&gt;&lt;FONT color=#365f91&gt;&lt;FONT face=Cambria&gt;Conclusions&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/H1&gt;
&lt;P style="MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;First, let’s accentuate the positive: we do eliminate bounds checks in some very common cases, and the costs of bounds checks usually aren’t that great when we don’t eliminate them.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;And, as I mentioned at the beginning, we have to keep in mind that the compiler we’re talking about is a dynamic JIT compiler, so we must carefully balance adding extra optimization that slows the compiler against the gains of that optimization.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;Still, if we don’t eliminate a bounds check that we should have in a small, tight loop that’s important to the performance of your program, I doubt you’ll find these excuses very satisfying.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;I hope this blog post convinces you that we’re well aware of the problems.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;The future almost certainly holds some mechanism for applying extra compilation effort to methods whose performance matters a lot, either by doing the extra work in some form of offline build-lab compilation, or by using profile-directed feedback, user annotations of hot methods, or other heuristics.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;When we can do extra compiler work, bounds-check elimination will be one of the problems we address.&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;o:p&gt;&lt;FONT size=3 face=Calibri&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/P&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9868799" width="1" height="1"&gt;</description></item><item><title>Tail Call Improvements in .NET Framework 4</title><link>http://blogs.msdn.com/b/clrcodegeneration/archive/2009/05/11/tail-call-improvements-in-net-framework-4.aspx</link><pubDate>Mon, 11 May 2009 11:50:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9601188</guid><dc:creator>CLR Codegen Blogger</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.msdn.com/b/clrcodegeneration/rsscomments.aspx?WeblogPostID=9601188</wfw:commentRss><comments>http://blogs.msdn.com/b/clrcodegeneration/archive/2009/05/11/tail-call-improvements-in-net-framework-4.aspx#comments</comments><description>&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;SPAN style="FONT-SIZE: 12pt; mso-bidi-font-family: 'Times New Roman'; mso-fareast-font-family: 'Times New Roman'"&gt;&lt;FONT face=Calibri&gt;First a little background reading before going into tail call improvements in CLR 4 - David Broman did an excellent job at covering the basics in his post here: &lt;/FONT&gt;&lt;A href="http://blogs.msdn.com/davbr/archive/2007/06/20/enter-leave-tailcall-hooks-part-2-tall-tales-of-tail-calls.aspx" mce_href="http://blogs.msdn.com/davbr/archive/2007/06/20/enter-leave-tailcall-hooks-part-2-tall-tales-of-tail-calls.aspx"&gt;&lt;SPAN style="COLOR: blue; mso-fareast-font-family: 'Times New Roman'; mso-fareast-theme-font: major-fareast"&gt;&lt;FONT face=Calibri&gt;http://blogs.msdn.com/davbr/archive/2007/06/20/enter-leave-tailcall-hooks-part-2-tall-tales-of-tail-calls.aspx&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/A&gt;&lt;FONT face=Calibri&gt;.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;He also captured a mostly complete list of the restrictions as they stood for CLR 2 here: &lt;/FONT&gt;&lt;A href="http://blogs.msdn.com/davbr/pages/tail-call-jit-conditions.aspx" mce_href="http://blogs.msdn.com/davbr/pages/tail-call-jit-conditions.aspx"&gt;&lt;SPAN style="COLOR: blue; mso-fareast-font-family: 'Times New Roman'; mso-fareast-theme-font: major-fareast"&gt;&lt;FONT face=Calibri&gt;http://blogs.msdn.com/davbr/pages/tail-call-jit-conditions.aspx&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/A&gt;&lt;FONT face=Calibri&gt;.&lt;?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;SPAN style="FONT-SIZE: 12pt; mso-bidi-font-family: 'Times New Roman'; mso-fareast-font-family: 'Times New Roman'"&gt;&lt;o:p&gt;&lt;FONT face=Calibri&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;SPAN style="FONT-SIZE: 12pt; mso-bidi-font-family: 'Times New Roman'; mso-fareast-font-family: 'Times New Roman'"&gt;&lt;FONT face=Calibri&gt;The primary reason for a tail call as an optimization is to improve data locality, memory usage, and cache usage.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;By doing a tail call the callee will use the same stack space as the caller.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;This reduces memory pressure.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;It marginally improves the cache because the same memory is reused for subsequent callers and thus can stay in the cache, rather than evicting some older cache line to make room for a new cache line.&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;SPAN style="FONT-SIZE: 12pt; mso-bidi-font-family: 'Times New Roman'; mso-fareast-font-family: 'Times New Roman'"&gt;&lt;o:p&gt;&lt;FONT face=Calibri&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;SPAN style="FONT-SIZE: 12pt; mso-bidi-font-family: 'Times New Roman'; mso-fareast-font-family: 'Times New Roman'"&gt;&lt;FONT face=Calibri&gt;The other usage of tail calls are in recursive algorithms.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;We all know from our computer science theory classes that any recursive algorithm can be made into an iterative one.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;However, just because you can doesn’t mean you always want to.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;If the algorithm is naturally tail recursive, why not let the compiler do the work for you?&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;By using a tail call, the compiler effectively turns a tail recursive algorithm into a loop.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;This is such an important concept that the JIT has a special path just for turning functions that call themselves in a tail recursive manner into loops.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;This is a nice performance win because beyond the memory improvements mentioned previously, you also save several instructions by not executing the prolog or epilog multiple times.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;The compiler is also able to treat it like a loop and hoist out loop invariants so they are also only executed once instead of being executed on every iteration.&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;SPAN style="FONT-SIZE: 12pt; mso-bidi-font-family: 'Times New Roman'; mso-fareast-font-family: 'Times New Roman'"&gt;&lt;o:p&gt;&lt;FONT face=Calibri&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;SPAN style="FONT-SIZE: 12pt; mso-bidi-font-family: 'Times New Roman'; mso-fareast-font-family: 'Times New Roman'"&gt;&lt;FONT face=Calibri&gt;In CLR 2 the 64-bit JIT focused solely on the ‘easy’ cases.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;That meant that it generated code that did a tail call whenever it could because of the memory benefits.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;However, it also meant that sometimes when the IL requested a tail call using the “tail.” instruction prefix, the JIT would not generate a tail call because it wasn’t easy.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;The 32-bit JIT had a general purpose tail call mechanism that always worked, but wasn’t performant enough to consider it an optimization, so it was only used when the IL requested a tail call.&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;SPAN style="FONT-SIZE: 12pt; mso-bidi-font-family: 'Times New Roman'; mso-fareast-font-family: 'Times New Roman'"&gt;&lt;o:p&gt;&lt;FONT face=Calibri&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;SPAN style="FONT-SIZE: 12pt; mso-bidi-font-family: 'Times New Roman'; mso-fareast-font-family: 'Times New Roman'"&gt;&lt;FONT face=Calibri&gt;For CLR 4 the fact that the x64 JIT would sometimes not honor the “tail.” prefix prevented functional languages like F# from being viable.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;So we worked to improve the x64 JIT so that it could honor the “tail.” prefix all of the time and help make F# a success.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;Except where explicitly called out, x86 and IA64 remain unchanged between CLR 2 and CLR 4, and the remainder of this document refers solely to the x64 JIT.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;Also this is specific to CLR 4, all other versions of the runtime or JIT (including service packs, QFEs, etc.) might change this in any number of ways.&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;SPAN style="FONT-SIZE: 12pt; mso-bidi-font-family: 'Times New Roman'; mso-fareast-font-family: 'Times New Roman'"&gt;&lt;o:p&gt;&lt;FONT face=Calibri&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;SPAN style="FONT-SIZE: 12pt; mso-bidi-font-family: 'Times New Roman'; mso-fareast-font-family: 'Times New Roman'"&gt;&lt;FONT face=Calibri&gt;The 64-bit calling convention is basically a caller-pops convention.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;Thus the ‘easy’ cases basically boiled down to where the JIT could generate code that stored the outgoing tail call arguments in the caller’s incoming argument slots, execute the epilog, and then jump to the target rather than returning.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;The improvements for CLR 4 came in two categories: Fewer restrictions on the optimized/easy cases and a solution for the non-easy cases.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;The end result is that on x64 you should see shorter call stacks in optimized code because the JIT generated more tail calls (don’t worry this optimization is turned off for debug code), and functional programmers (or any other compiler or language that relies on tail calls and uses the “tail.” prefix) no longer need to worry about stack overflows.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;The down side of course is that if you have to debug or profile optimized code, be prepared to deal with call stacks that look like they’re missing a few frames.&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;SPAN style="FONT-SIZE: 10pt; mso-bidi-font-family: Arial; mso-fareast-font-family: 'Times New Roman'"&gt;&lt;o:p&gt;&lt;FONT face=Calibri&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;FONT face=Calibri&gt;&lt;I&gt;&lt;SPAN style="COLOR: #4f81bd; FONT-SIZE: 12pt; mso-bidi-font-family: Arial; mso-fareast-font-family: 'Times New Roman'"&gt;Reducing restrictions on the easy cases&lt;/SPAN&gt;&lt;/I&gt;&lt;I&gt;&lt;SPAN style="FONT-FAMILY: 'Times New Roman','serif'; COLOR: #4f81bd; FONT-SIZE: 12pt; mso-fareast-font-family: 'Times New Roman'"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/I&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;FONT face=Calibri&gt;&lt;SPAN style="FONT-SIZE: 12pt; mso-bidi-font-family: 'Times New Roman'; mso-fareast-font-family: 'Times New Roman'"&gt;The more often we can tail call, the more likely programs will benefit from the optimization.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;From the second link above you can see that there were a lot of restrictions on when the JIT could perform a tail call.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;We looked at each one of these and tried to see if we could reduce or eliminate them.&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Times New Roman','serif'; FONT-SIZE: 12pt; mso-fareast-font-family: 'Times New Roman'"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;UL type=disc&gt;
&lt;LI style="LINE-HEIGHT: normal; MARGIN: 0in 0in 10pt; mso-list: l2 level1 lfo1; mso-margin-top-alt: auto; mso-margin-bottom-alt: auto; tab-stops: list .5in" class=MsoNormal&gt;&lt;SPAN style="FONT-SIZE: 12pt; mso-bidi-font-family: Arial; mso-fareast-font-family: 'Times New Roman'"&gt;&lt;FONT face=Calibri&gt;The call/callvirt/calli is followed by something other than nop or ret IL instructions. &lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/LI&gt;&lt;/UL&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;SPAN style="FONT-SIZE: 12pt; mso-bidi-font-family: 'Times New Roman'; mso-fareast-font-family: 'Times New Roman'"&gt;&lt;FONT face=Calibri&gt;We reduced this restriction by also allowing a single pop opcode.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;This allowed the case where a method that returned void ended with a call to some other method that had a non-void return.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;The callee was obviously being invoked for its side-effect rather than its return value.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;In most cases the return value is just sitting in rax or xmm0, and does no harm by being left there, so in those cases, the tail call is legal and becomes an ‘easy’ case.&amp;nbsp; However, note that having an explicit tail call, with the tail. prefix is still unverifiable in this situation, so in most cases a compiler or code generator should omit the tail. prefix and just rely on the JIT optimizing the call into a tail call.&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;UL type=disc&gt;
&lt;LI style="LINE-HEIGHT: normal; MARGIN: 0in 0in 10pt; mso-list: l5 level1 lfo2; mso-margin-top-alt: auto; mso-margin-bottom-alt: auto; tab-stops: list .5in" class=MsoNormal&gt;&lt;SPAN style="FONT-SIZE: 12pt; mso-bidi-font-family: Arial; mso-fareast-font-family: 'Times New Roman'"&gt;&lt;FONT face=Calibri&gt;The caller or callee returns a value type. &lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/LI&gt;&lt;/UL&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;SPAN style="FONT-SIZE: 12pt; mso-bidi-font-family: 'Times New Roman'; mso-fareast-font-family: 'Times New Roman'"&gt;&lt;FONT face=Calibri&gt;We changed the JIT to recognize this case as well.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;Specifically the X64 calling convention dictates that for value types that don’t fit in a register (1,2,4, or 8 byte sized value types), that the caller should pass a ‘hidden’ argument called the return buffer.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;The CLR 2 JIT would pass a new return buffer to the callee, and then copy the data from the callee’s return buffer to the caller’s return buffer.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;The CLR 4 runtime now recognizes when it is safe to do so, and then just passes the caller’s return buffer into the callee as its return buffer.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;This means even when we don’t do a tail call, the code has at least one less copy, and it enables one more case to be ‘easy’!&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;UL type=disc&gt;
&lt;LI style="LINE-HEIGHT: normal; MARGIN: 0in 0in 10pt; mso-list: l4 level1 lfo3; mso-margin-top-alt: auto; mso-margin-bottom-alt: auto; tab-stops: list .5in" class=MsoNormal&gt;&lt;SPAN style="FONT-SIZE: 12pt; mso-bidi-font-family: Arial; mso-fareast-font-family: 'Times New Roman'"&gt;&lt;FONT face=Calibri&gt;The caller is a shared generic method. &lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/LI&gt;&lt;/UL&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;SPAN style="FONT-SIZE: 12pt; mso-bidi-font-family: 'Times New Roman'; mso-fareast-font-family: 'Times New Roman'"&gt;&lt;FONT face=Calibri&gt;The above&amp;nbsp;restriction is now removed!&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;UL type=disc&gt;
&lt;LI style="LINE-HEIGHT: normal; MARGIN: 0in 0in 10pt; mso-list: l0 level1 lfo4; mso-margin-top-alt: auto; mso-margin-bottom-alt: auto; tab-stops: list .5in" class=MsoNormal&gt;&lt;SPAN style="FONT-SIZE: 12pt; mso-bidi-font-family: Arial; mso-fareast-font-family: 'Times New Roman'"&gt;&lt;FONT face=Calibri&gt;The caller is varargs &lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/LI&gt;
&lt;LI style="LINE-HEIGHT: normal; MARGIN: 0in 0in 10pt; mso-list: l0 level1 lfo4; mso-margin-top-alt: auto; mso-margin-bottom-alt: auto; tab-stops: list .5in" class=MsoNormal&gt;&lt;SPAN style="FONT-SIZE: 12pt; mso-bidi-font-family: Arial; mso-fareast-font-family: 'Times New Roman'"&gt;&lt;FONT face=Calibri&gt;The callee is varargs. &lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/LI&gt;&lt;/UL&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;SPAN style="FONT-SIZE: 12pt; mso-bidi-font-family: 'Times New Roman'; mso-fareast-font-family: 'Times New Roman'"&gt;&lt;FONT face=Calibri&gt;These have been partially removed.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;Specifically, we treat the caller as only having its fixed arguments and the callee as having all of its arguments.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;Then we apply all of the other rules.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;It is also worth mentioning that the CLR deviates from the native X64 calling convention by adding another ‘hidden’ argument called the vararg cookie.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;It stores the GC properties of the actual call (important for the variadic part).&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;This hidden argument is also counted as part of the signature for the purposes of the other rules.&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;SPAN style="FONT-SIZE: 12pt; mso-bidi-font-family: 'Times New Roman'; mso-fareast-font-family: 'Times New Roman'"&gt;&lt;o:p&gt;&lt;FONT face=Calibri&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;UL type=disc&gt;
&lt;LI style="LINE-HEIGHT: normal; MARGIN: 0in 0in 10pt; mso-list: l6 level1 lfo5; mso-margin-top-alt: auto; mso-margin-bottom-alt: auto; tab-stops: list .5in" class=MsoNormal&gt;&lt;SPAN style="FONT-SIZE: 12pt; mso-bidi-font-family: Arial; mso-fareast-font-family: 'Times New Roman'"&gt;&lt;FONT face=Calibri&gt;The runtime forbids the JIT to tail call.&amp;nbsp;&amp;nbsp; (&lt;I&gt;There are various reasons the runtime may disallow tail calling, such as caller / callee being in different assemblies, the call going to the application's entrypoint, any conflicts with usage of security features, and other esoteric cases.&lt;/I&gt;) &lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/LI&gt;&lt;/UL&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;SPAN style="FONT-SIZE: 12pt; mso-bidi-font-family: 'Times New Roman'; mso-fareast-font-family: 'Times New Roman'"&gt;&lt;FONT face=Calibri&gt;This part applies to all platforms.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;We were able to reduce the number of cases where the runtime refused a tail call due to security constraints.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;Mainly the runtime stopped caring so much about the exact assembly and instead looked at the security properties.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;If performing the call as a tail call would not cause an important stack frame to disappear from the call stack, it is now allowed.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;Previous to this change tail calls across modules or to unknown destinations (due to calli or callvirt) were rare, now they are significantly more common.&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;UL type=disc&gt;
&lt;LI style="LINE-HEIGHT: normal; MARGIN: 0in 0in 10pt; mso-list: l3 level1 lfo6; mso-margin-top-alt: auto; mso-margin-bottom-alt: auto; tab-stops: list .5in" class=MsoNormal&gt;&lt;SPAN style="FONT-SIZE: 12pt; mso-bidi-font-family: Arial; mso-fareast-font-family: 'Times New Roman'"&gt;&lt;FONT face=Calibri&gt;The callee is invoked via stub dispatch (&lt;I&gt;i.e., via intermediate code that's generated at runtime to optimize certain types of calls&lt;/I&gt;). &lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/LI&gt;&lt;/UL&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;SPAN style="FONT-SIZE: 12pt; mso-bidi-font-family: 'Times New Roman'; mso-fareast-font-family: 'Times New Roman'"&gt;&lt;FONT face=Calibri&gt;The above&amp;nbsp;restriction is now removed!&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;UL type=disc&gt;
&lt;LI style="LINE-HEIGHT: normal; MARGIN: 0in 0in 10pt; mso-list: l1 level1 lfo7; mso-margin-top-alt: auto; mso-margin-bottom-alt: auto; tab-stops: list .5in" class=MsoNormal&gt;&lt;SPAN style="FONT-SIZE: 12pt; mso-bidi-font-family: Arial; mso-fareast-font-family: 'Times New Roman'"&gt;&lt;FONT face=Calibri&gt;For x64 we have these additional restrictions: &lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/LI&gt;
&lt;UL type=circle&gt;
&lt;LI style="LINE-HEIGHT: normal; MARGIN: 0in 0in 10pt; mso-list: l1 level2 lfo7; mso-margin-top-alt: auto; mso-margin-bottom-alt: auto; tab-stops: list 1.0in" class=MsoNormal&gt;&lt;SPAN style="FONT-SIZE: 12pt; mso-bidi-font-family: Arial; mso-fareast-font-family: 'Times New Roman'"&gt;&lt;FONT face=Calibri&gt;…&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/LI&gt;
&lt;LI style="LINE-HEIGHT: normal; MARGIN: 0in 0in 10pt; mso-list: l1 level2 lfo7; mso-margin-top-alt: auto; mso-margin-bottom-alt: auto; tab-stops: list 1.0in" class=MsoNormal&gt;&lt;SPAN style="FONT-SIZE: 12pt; mso-bidi-font-family: Arial; mso-fareast-font-family: 'Times New Roman'"&gt;&lt;FONT face=Calibri&gt;For all of the parameters passed on the stack the GC-ness must match between the caller and callee.&amp;nbsp; (&lt;I&gt;"GC-ness" means the state of being a pointer to the beginning of an object managed by the GC, or a pointer to the interior of an object managed by the GC (e.g., a byref field), or neither (e.g., an integer or struct).&lt;/I&gt;)&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;/UL&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;SPAN style="FONT-SIZE: 12pt; mso-bidi-font-family: 'Times New Roman'; mso-fareast-font-family: 'Times New Roman'"&gt;&lt;FONT face=Calibri&gt;The above&amp;nbsp;x64 restriction is now removed!&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;SPAN style="FONT-SIZE: 12pt; mso-bidi-font-family: 'Times New Roman'; mso-fareast-font-family: 'Times New Roman'"&gt;&lt;o:p&gt;&lt;FONT face=Calibri&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;FONT face=Calibri&gt;&lt;I&gt;&lt;SPAN style="COLOR: #4f81bd; FONT-SIZE: 12pt; mso-bidi-font-family: Arial; mso-fareast-font-family: 'Times New Roman'"&gt;A solution for the non-easy cases&lt;/SPAN&gt;&lt;/I&gt;&lt;I&gt;&lt;SPAN style="FONT-FAMILY: 'Times New Roman','serif'; COLOR: #4f81bd; FONT-SIZE: 12pt; mso-bidi-font-family: Arial; mso-fareast-font-family: 'Times New Roman'"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/I&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;FONT face=Calibri&gt;&lt;SPAN style="FONT-SIZE: 12pt; mso-bidi-font-family: 'Times New Roman'; mso-fareast-font-family: 'Times New Roman'"&gt;Previously even if the IL had the “tail.” prefix, if the call did not match the requirements to be one of the optimized easy tail calls cases, it was turned into a regular call.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;This is disastrous for recursive algorithms.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;In many cases this prevented F# programs from running to completion without getting stack overflows.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;So for CLR 4 we added an alternate code path that allowed tail call like properties for these specific scenarios, where it was needed, but it was not easy.&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Times New Roman','serif'; FONT-SIZE: 12pt; mso-fareast-font-family: 'Times New Roman'"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;SPAN style="FONT-SIZE: 12pt; mso-bidi-font-family: 'Times New Roman'; mso-fareast-font-family: 'Times New Roman'"&gt;&lt;o:p&gt;&lt;FONT face=Calibri&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;SPAN style="FONT-SIZE: 12pt; mso-bidi-font-family: 'Times New Roman'; mso-fareast-font-family: 'Times New Roman'"&gt;&lt;FONT face=Calibri&gt;The biggest problem to overcome is the x64 calling convention.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;Because of the calling convention if a tail call callee needs more argument space than the caller has, the code is wedged between a rock and a hard place.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;The solution involved a little stack trickery.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;The JIT generates a mostly normal call instead of a tail call.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;However instead of calling the target directly it calls through a special helper which works some magic on the stack.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;It logically unwinds the stack to be as if the caller has returned.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;Then it adds a fake method to the stack as if it had been called, and then jumps to the callee.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;This fake method is called the TailCallHelper.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;It takes no arguments, and as far as unwind data and the calling convention are concerned calls the callee with no outgoing arguments, but has a dynamically resizing locals area (think _alloca for C/C++ programmers, or stackalloc for C# programmers).&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;Thus this method is still caller-pops, but the tail call helper can dynamically change how much to pop based on a given callee.&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;SPAN style="FONT-SIZE: 12pt; mso-bidi-font-family: 'Times New Roman'; mso-fareast-font-family: 'Times New Roman'"&gt;&lt;o:p&gt;&lt;FONT face=Calibri&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;SPAN style="FONT-SIZE: 12pt; mso-bidi-font-family: 'Times New Roman'; mso-fareast-font-family: 'Times New Roman'"&gt;&lt;FONT face=Calibri&gt;This stack magic is not cheap.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;It is significantly slower than a normal call or a tail call.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;It also consumes a non-trivial amount of stack space.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;However the stack space is ‘recycled’ such that if you have a tail recursive algorithm, the first tail call that isn’t ‘easy’ will erect the TailCallHelper stack frame, and subsequent non-easy tail calls may need to grow that frame to accommodate all the arguments.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;Hopefully once the algorithm has gone through a full cycle of recursion the TailCallHelper stack frame has grown to the maximum sized needed by all the non-easy calls involved in the recursion, and then never grows, and thus prevents a stack overflow.&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;SPAN style="FONT-SIZE: 12pt; mso-bidi-font-family: 'Times New Roman'; mso-fareast-font-family: 'Times New Roman'"&gt;&lt;o:p&gt;&lt;FONT face=Calibri&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;SPAN style="FONT-SIZE: 12pt; mso-bidi-font-family: 'Times New Roman'; mso-fareast-font-family: 'Times New Roman'"&gt;&lt;FONT face=Calibri&gt;As you can see the way the non-easy case is handled is also not fast.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;Because of that, the JIT never uses the non-easy helper unless the IL requires it with the “tail.” prefix.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;This was also the driving force behind trying to reduce the number of restrictions on the ‘easy’ cases.&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;SPAN style="FONT-SIZE: 12pt; mso-bidi-font-family: 'Times New Roman'; mso-fareast-font-family: 'Times New Roman'"&gt;&lt;FONT face=Calibri&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&amp;nbsp;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;SPAN style="FONT-SIZE: 12pt; mso-bidi-font-family: 'Times New Roman'; mso-fareast-font-family: 'Times New Roman'"&gt;&lt;FONT face=Calibri&gt;Grant Richins&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;SPAN style="FONT-SIZE: 12pt; mso-bidi-font-family: 'Times New Roman'; mso-fareast-font-family: 'Times New Roman'"&gt;&lt;FONT face=Calibri&gt;CLR Codegen Team&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;SPAN style="FONT-SIZE: 12pt; mso-bidi-font-family: 'Times New Roman'; mso-fareast-font-family: 'Times New Roman'"&gt;&lt;FONT face=Calibri&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&amp;nbsp;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;SPAN style="FONT-SIZE: 12pt; mso-bidi-font-family: 'Times New Roman'; mso-fareast-font-family: 'Times New Roman'"&gt;&lt;FONT face=Calibri&gt;[Updated 6/25/2009 to make a few minor clarifications based on internal feedback]&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9601188" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/b/clrcodegeneration/archive/tags/x64/">x64</category><category domain="http://blogs.msdn.com/b/clrcodegeneration/archive/tags/-NET+Framework+4/">.NET Framework 4</category><category domain="http://blogs.msdn.com/b/clrcodegeneration/archive/tags/Visual+Studio+2010/">Visual Studio 2010</category><category domain="http://blogs.msdn.com/b/clrcodegeneration/archive/tags/Tail+calls/">Tail calls</category></item><item><title>JIT ETW tracing in .NET Framework 4</title><link>http://blogs.msdn.com/b/clrcodegeneration/archive/2009/05/11/jit-etw-tracing-in-net-framework-4.aspx</link><pubDate>Mon, 11 May 2009 08:56:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9601193</guid><dc:creator>CLR Codegen Blogger</dc:creator><slash:comments>2</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.msdn.com/b/clrcodegeneration/rsscomments.aspx?WeblogPostID=9601193</wfw:commentRss><comments>http://blogs.msdn.com/b/clrcodegeneration/archive/2009/05/11/jit-etw-tracing-in-net-framework-4.aspx#comments</comments><description>&lt;FONT size=3 face="Times New Roman"&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin"&gt;If you care about performance at a very low level, at one point you’ve asked yourself why the compiler, JIT, or runtime did or did not inline a certain method.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;Unless you worked on the compiler, JIT, or runtime, you really had no way of telling, other than trial and error (sort of like asking how a magic 8 ball comes up with its answers).&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;We, on the JIT team, decided to fix that in CLR 4.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;Now you the end-user or programmer can see why the JIT, and in some cases the runtime decided to disallow inlining or tail calls.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;We also tell you when the JIT succeeded in inlining or tail calling a certain method.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;All of this wonderful information is made available by &lt;A href="http://msdn.microsoft.com/en-us/library/bb968803(VS.85).aspx" mce_href="http://msdn.microsoft.com/en-us/library/bb968803(VS.85).aspx"&gt;&lt;I style="mso-bidi-font-style: normal"&gt;&lt;FONT color=#0000ff&gt;Event Tracing for Windows&lt;/FONT&gt;&lt;/I&gt;&lt;/A&gt;.&lt;?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin"&gt;First a disclaimer, I’m not an expert on ETW events, and this post isn’t about ETW events in general, it is only about a couple of new events exposed by the JIT to enable performance junkies to hurt themselves. &lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: Wingdings; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-ascii-font-family: Calibri; mso-hansi-font-family: Calibri; mso-char-type: symbol; mso-symbol-font-family: Wingdings"&gt;&lt;SPAN style="mso-char-type: symbol; mso-symbol-font-family: Wingdings"&gt;J&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin"&gt;For Windows XP, Widows Server 2003, Windows Vista and Windows 7, you already have everything you need on your machine.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;For Windows 2000, you’ll need to download the &lt;I style="mso-bidi-font-style: normal"&gt;Microsoft Windows 2000 Server Resource Kit&lt;/I&gt;.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;According to the gurus around here previous to Windows Vista registering an ETW provider was not cheap, so the runtime only does it when requested to.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;On Vista and newer OSes, it is cheap enough to do all the time, so you only need to request it on pre-Vista OSes.You request it by setting the following environment variable before running the application you are interested in:&lt;I style="mso-bidi-font-style: normal"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/I&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 6pt 0.25in" class=Code&gt;&lt;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; FONT-SIZE: 12pt; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin"&gt;SET COMPLUS_ETWENABLED=1&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin"&gt;To start logging ETW events do this:&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 6pt 0.25in" class=Code&gt;&lt;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; FONT-SIZE: 12pt; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin"&gt;&lt;A href="http://technet.microsoft.com/en-us/library/bb490956.aspx" target=_blank mce_href="http://technet.microsoft.com/en-us/library/bb490956.aspx"&gt;&lt;FONT color=#0000ff&gt;logman&lt;/FONT&gt;&lt;/A&gt; start clrevents -p {e13c0d23-ccbc-4e12-931b-d9cc2eee27e4} 0x1000 5 -ets&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin"&gt;There are lots more options to tweak here, but the important part is the GUID (the CLR ETW provider GUID), the mask 0x1000 (the &lt;/SPAN&gt;&lt;SPAN class=CodeChar&gt;&lt;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin"&gt;JitTracingKeyword&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin"&gt;), and the level 5 (everything).&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;More information about logman.exe can be found at &lt;A href="http://technet.microsoft.com/en-us/library/bb490956.aspx" mce_href="http://technet.microsoft.com/en-us/library/bb490956.aspx"&gt;&lt;FONT color=#0000ff&gt;http://technet.microsoft.com/en-us/library/bb490956.aspx&lt;/FONT&gt;&lt;/A&gt;.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;After you’ve started ETW, run your scenario, and then stop ETW as follows:&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 6pt 0.25in" class=Code&gt;&lt;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; FONT-SIZE: 12pt; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin"&gt;logman stop clrevents -ets&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin"&gt;This will create clrevents.etl.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin"&gt;&lt;/SPAN&gt;&amp;nbsp;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin"&gt;[Begin Edit 1/27/2010]&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin"&gt;Several people have reported that on Vista and Win7 (and their 2008 server counter parts), one additional step is needed so that the events can be properly decoded.&amp;nbsp; It is my understanding this only needs to be done once, but I am no expert here on ETW.&amp;nbsp; It is also my understanding that this needs to be run from an elevated command prompt.&amp;nbsp; I am merely placing this here to help others.&amp;nbsp; Also you will need to replace the path with the equivalent path on your machine/setup/configuration.&lt;/SPAN&gt;&lt;/P&gt;&lt;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin"&gt;
&lt;P style="MARGIN: 6pt 0.25in" class=Code&gt;&lt;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; FONT-SIZE: 12pt; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin"&gt;&lt;A href="http://technet.microsoft.com/en-us/library/cc732848(WS.10).aspx" target=_blank mce_href="http://technet.microsoft.com/en-us/library/cc732848(WS.10).aspx"&gt;wevtutil&lt;/A&gt; im c:\windows\microsoft.net\framework\v4.0.21006\clr-etw.man&lt;/SPAN&gt;&lt;/P&gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin"&gt;&lt;/SPAN&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin"&gt;[End Edit 1/27/2010]&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin"&gt;&lt;/SPAN&gt;&amp;nbsp;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin"&gt;To decode it further run this:&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 6pt 0.25in" class=Code&gt;&lt;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; FONT-SIZE: 12pt; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin"&gt;tracerpt clrevents.etl&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin"&gt;This will create 2 files: dumpfile.csv and summary.txt. The former has all the events, the latter gives a nice summary of the events. On Vista, &lt;/SPAN&gt;&lt;SPAN class=CodeChar&gt;&lt;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin"&gt;tracerpt&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin"&gt; will generate dumpfile.xml instead of dumpfile.csv.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;I ran this on a Vista machine so I’m going to deal with the XML format, but the csv format is similar.&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin"&gt;Here is a sample &lt;/SPAN&gt;&lt;SPAN class=CodeChar&gt;&lt;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin"&gt;MethodJitInliningSucceeded&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin"&gt; event:&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt 0.25in; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; COLOR: blue; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-bidi-font-family: 'Courier New'; mso-no-proof: yes"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt 0.25in; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; COLOR: blue; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-bidi-font-family: 'Courier New'; mso-no-proof: yes"&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; COLOR: #a31515; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-bidi-font-family: 'Courier New'; mso-no-proof: yes"&gt;Event&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; COLOR: blue; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-bidi-font-family: 'Courier New'; mso-no-proof: yes"&gt; &lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; COLOR: red; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-bidi-font-family: 'Courier New'; mso-no-proof: yes"&gt;xmlns&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; COLOR: blue; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-bidi-font-family: 'Courier New'; mso-no-proof: yes"&gt;=&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-bidi-font-family: 'Courier New'; mso-no-proof: yes"&gt;"&lt;SPAN style="COLOR: blue"&gt;http://schemas.microsoft.com/win/2004/08/events/event&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt;&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt 0.25in; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; COLOR: blue; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-bidi-font-family: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-tab-count: 1"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; COLOR: #a31515; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-bidi-font-family: 'Courier New'; mso-no-proof: yes"&gt;System&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; COLOR: blue; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-bidi-font-family: 'Courier New'; mso-no-proof: yes"&gt;&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt 0.25in; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; COLOR: blue; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-bidi-font-family: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-tab-count: 2"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; COLOR: #a31515; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-bidi-font-family: 'Courier New'; mso-no-proof: yes"&gt;Provider&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; COLOR: blue; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-bidi-font-family: 'Courier New'; mso-no-proof: yes"&gt; &lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; COLOR: red; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-bidi-font-family: 'Courier New'; mso-no-proof: yes"&gt;Name&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; COLOR: blue; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-bidi-font-family: 'Courier New'; mso-no-proof: yes"&gt;=&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-bidi-font-family: 'Courier New'; mso-no-proof: yes"&gt;"&lt;SPAN style="COLOR: blue"&gt;Microsoft-Windows-DotNETRuntime&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;Guid&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;=&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt;{e13c0d23-ccbc-4e12-931b-d9cc2eee27e4}&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt; /&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt 0.25in; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; COLOR: blue; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-bidi-font-family: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-tab-count: 2"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; COLOR: #a31515; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-bidi-font-family: 'Courier New'; mso-no-proof: yes"&gt;EventID&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; COLOR: blue; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-bidi-font-family: 'Courier New'; mso-no-proof: yes"&gt;&amp;gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-bidi-font-family: 'Courier New'; mso-no-proof: yes"&gt;185&lt;SPAN style="COLOR: blue"&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;EventID&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt 0.25in; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; COLOR: blue; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-bidi-font-family: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-tab-count: 2"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; COLOR: #a31515; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-bidi-font-family: 'Courier New'; mso-no-proof: yes"&gt;Version&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; COLOR: blue; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-bidi-font-family: 'Courier New'; mso-no-proof: yes"&gt;&amp;gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-bidi-font-family: 'Courier New'; mso-no-proof: yes"&gt;0&lt;SPAN style="COLOR: blue"&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;Version&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt 0.25in; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; COLOR: blue; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-bidi-font-family: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-tab-count: 2"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; COLOR: #a31515; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-bidi-font-family: 'Courier New'; mso-no-proof: yes"&gt;Level&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; COLOR: blue; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-bidi-font-family: 'Courier New'; mso-no-proof: yes"&gt;&amp;gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-bidi-font-family: 'Courier New'; mso-no-proof: yes"&gt;5&lt;SPAN style="COLOR: blue"&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;Level&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt 0.25in; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; COLOR: blue; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-bidi-font-family: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-tab-count: 2"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; COLOR: #a31515; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-bidi-font-family: 'Courier New'; mso-no-proof: yes"&gt;Task&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; COLOR: blue; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-bidi-font-family: 'Courier New'; mso-no-proof: yes"&gt;&amp;gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-bidi-font-family: 'Courier New'; mso-no-proof: yes"&gt;9&lt;SPAN style="COLOR: blue"&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;Task&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt 0.25in; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; COLOR: blue; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-bidi-font-family: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-tab-count: 2"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; COLOR: #a31515; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-bidi-font-family: 'Courier New'; mso-no-proof: yes"&gt;Opcode&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; COLOR: blue; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-bidi-font-family: 'Courier New'; mso-no-proof: yes"&gt;&amp;gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-bidi-font-family: 'Courier New'; mso-no-proof: yes"&gt;83&lt;SPAN style="COLOR: blue"&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;Opcode&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt 0.25in; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; COLOR: blue; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-bidi-font-family: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-tab-count: 2"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; COLOR: #a31515; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-bidi-font-family: 'Courier New'; mso-no-proof: yes"&gt;Keywords&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; COLOR: blue; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-bidi-font-family: 'Courier New'; mso-no-proof: yes"&gt;&amp;gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-bidi-font-family: 'Courier New'; mso-no-proof: yes"&gt;0x1000&lt;SPAN style="COLOR: blue"&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;Keywords&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt 0.25in; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; COLOR: blue; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-bidi-font-family: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-tab-count: 2"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; COLOR: #a31515; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-bidi-font-family: 'Courier New'; mso-no-proof: yes"&gt;TimeCreated&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; COLOR: blue; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-bidi-font-family: 'Courier New'; mso-no-proof: yes"&gt; &lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; COLOR: red; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-bidi-font-family: 'Courier New'; mso-no-proof: yes"&gt;SystemTime&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; COLOR: blue; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-bidi-font-family: 'Courier New'; mso-no-proof: yes"&gt;=&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-bidi-font-family: 'Courier New'; mso-no-proof: yes"&gt;"&lt;SPAN style="COLOR: blue"&gt;2009-04-14T14:31:52.168851900Z&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt; /&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt 0.25in; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; COLOR: blue; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-bidi-font-family: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-tab-count: 2"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; COLOR: #a31515; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-bidi-font-family: 'Courier New'; mso-no-proof: yes"&gt;Correlation&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; COLOR: blue; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-bidi-font-family: 'Courier New'; mso-no-proof: yes"&gt; &lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; COLOR: red; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-bidi-font-family: 'Courier New'; mso-no-proof: yes"&gt;ActivityID&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; COLOR: blue; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-bidi-font-family: 'Courier New'; mso-no-proof: yes"&gt;=&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-bidi-font-family: 'Courier New'; mso-no-proof: yes"&gt;"&lt;SPAN style="COLOR: blue"&gt;{00000000-0000-0000-0000-000000000000}&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt; /&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt 0.25in; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; COLOR: blue; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-bidi-font-family: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-tab-count: 2"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; COLOR: #a31515; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-bidi-font-family: 'Courier New'; mso-no-proof: yes"&gt;Execution&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; COLOR: blue; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-bidi-font-family: 'Courier New'; mso-no-proof: yes"&gt; &lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; COLOR: red; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-bidi-font-family: 'Courier New'; mso-no-proof: yes"&gt;ProcessID&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; COLOR: blue; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-bidi-font-family: 'Courier New'; mso-no-proof: yes"&gt;=&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-bidi-font-family: 'Courier New'; mso-no-proof: yes"&gt;"&lt;SPAN style="COLOR: blue"&gt;15476&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;ThreadID&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;=&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt;16936&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;ProcessorID&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;=&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt;3&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;KernelTime&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;=&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt;90&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;UserTime&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;=&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt;60&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt; /&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt 0.25in; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; COLOR: blue; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-bidi-font-family: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-tab-count: 2"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; COLOR: #a31515; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-bidi-font-family: 'Courier New'; mso-no-proof: yes"&gt;Channel&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; COLOR: blue; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-bidi-font-family: 'Courier New'; mso-no-proof: yes"&gt; /&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt 0.25in; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; COLOR: blue; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-bidi-font-family: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-tab-count: 2"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; COLOR: #a31515; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-bidi-font-family: 'Courier New'; mso-no-proof: yes"&gt;Computer&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; COLOR: blue; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-bidi-font-family: 'Courier New'; mso-no-proof: yes"&gt; /&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt 0.25in; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; COLOR: blue; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-bidi-font-family: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-tab-count: 1"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; COLOR: #a31515; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-bidi-font-family: 'Courier New'; mso-no-proof: yes"&gt;System&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; COLOR: blue; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-bidi-font-family: 'Courier New'; mso-no-proof: yes"&gt;&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt 0.25in; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; COLOR: blue; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-bidi-font-family: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-tab-count: 1"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; COLOR: #a31515; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-bidi-font-family: 'Courier New'; mso-no-proof: yes"&gt;UserData&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; COLOR: blue; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-bidi-font-family: 'Courier New'; mso-no-proof: yes"&gt;&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt 0.25in; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; COLOR: blue; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-bidi-font-family: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-tab-count: 2"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; COLOR: #a31515; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-bidi-font-family: 'Courier New'; mso-no-proof: yes"&gt;MethodJitInliningSucceeded&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; COLOR: blue; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-bidi-font-family: 'Courier New'; mso-no-proof: yes"&gt; &lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; COLOR: red; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-bidi-font-family: 'Courier New'; mso-no-proof: yes"&gt;xmlns&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; COLOR: blue; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-bidi-font-family: 'Courier New'; mso-no-proof: yes"&gt;=&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-bidi-font-family: 'Courier New'; mso-no-proof: yes"&gt;'&lt;SPAN style="COLOR: blue"&gt;myNs&lt;/SPAN&gt;'&lt;SPAN style="COLOR: blue"&gt;&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt 0.25in; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; COLOR: blue; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-bidi-font-family: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-tab-count: 2"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="mso-tab-count: 1"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; COLOR: #a31515; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-bidi-font-family: 'Courier New'; mso-no-proof: yes"&gt;MethodBeingCompiledNamespace&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; COLOR: blue; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-bidi-font-family: 'Courier New'; mso-no-proof: yes"&gt;&amp;gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-bidi-font-family: 'Courier New'; mso-no-proof: yes"&gt;Factorial&lt;SPAN style="COLOR: blue"&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;MethodBeingCompiledNamespace&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt 0.25in; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; COLOR: blue; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-bidi-font-family: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-tab-count: 2"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="mso-tab-count: 1"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; COLOR: #a31515; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-bidi-font-family: 'Courier New'; mso-no-proof: yes"&gt;MethodBeingCompiledName&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; COLOR: blue; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-bidi-font-family: 'Courier New'; mso-no-proof: yes"&gt;&amp;gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-bidi-font-family: 'Courier New'; mso-no-proof: yes"&gt;Main&lt;SPAN style="COLOR: blue"&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;MethodBeingCompiledName&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt 0.25in; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; COLOR: blue; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-bidi-font-family: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-tab-count: 3"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; COLOR: #a31515; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-bidi-font-family: 'Courier New'; mso-no-proof: yes"&gt;MethodBeingCompiledNameSignature&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; COLOR: blue; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-bidi-font-family: 'Courier New'; mso-no-proof: yes"&gt;&amp;gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-bidi-font-family: 'Courier New'; mso-no-proof: yes"&gt;void&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;(class System.String[])&lt;SPAN style="COLOR: blue"&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;MethodBeingCompiledNameSignature&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt 0.25in; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; COLOR: blue; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-bidi-font-family: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-tab-count: 3"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; COLOR: #a31515; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-bidi-font-family: 'Courier New'; mso-no-proof: yes"&gt;InlinerNamespace&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; COLOR: blue; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-bidi-font-family: 'Courier New'; mso-no-proof: yes"&gt;&amp;gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-bidi-font-family: 'Courier New'; mso-no-proof: yes"&gt;Factorial&lt;SPAN style="COLOR: blue"&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;InlinerNamespace&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt 0.25in; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; COLOR: blue; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-bidi-font-family: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-tab-count: 3"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; COLOR: #a31515; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-bidi-font-family: 'Courier New'; mso-no-proof: yes"&gt;InlinerName&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; COLOR: blue; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-bidi-font-family: 'Courier New'; mso-no-proof: yes"&gt;&amp;gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-bidi-font-family: 'Courier New'; mso-no-proof: yes"&gt;Main&lt;SPAN style="COLOR: blue"&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;InlinerName&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt 0.25in; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; COLOR: blue; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-bidi-font-family: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-tab-count: 3"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; COLOR: #a31515; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-bidi-font-family: 'Courier New'; mso-no-proof: yes"&gt;InlinerNameSignature&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; COLOR: blue; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-bidi-font-family: 'Courier New'; mso-no-proof: yes"&gt;&amp;gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-bidi-font-family: 'Courier New'; mso-no-proof: yes"&gt;void&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;(class System.String[])&lt;SPAN style="COLOR: blue"&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;InlinerNameSignature&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt 0.25in; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; COLOR: blue; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-bidi-font-family: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-tab-count: 3"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; COLOR: #a31515; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-bidi-font-family: 'Courier New'; mso-no-proof: yes"&gt;InlineeNamespace&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; COLOR: blue; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-bidi-font-family: 'Courier New'; mso-no-proof: yes"&gt;&amp;gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-bidi-font-family: 'Courier New'; mso-no-proof: yes"&gt;Factorial&lt;SPAN style="COLOR: blue"&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;InlineeNamespace&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt 0.25in; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; COLOR: blue; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-bidi-font-family: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-tab-count: 3"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; COLOR: #a31515; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-bidi-font-family: 'Courier New'; mso-no-proof: yes"&gt;InlineeName&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; COLOR: blue; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-bidi-font-family: 'Courier New'; mso-no-proof: yes"&gt;&amp;gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-bidi-font-family: 'Courier New'; mso-no-proof: yes"&gt;fact&lt;SPAN style="COLOR: blue"&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;InlineeName&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt 0.25in; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; COLOR: blue; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-bidi-font-family: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-tab-count: 3"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; COLOR: #a31515; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-bidi-font-family: 'Courier New'; mso-no-proof: yes"&gt;InlineeNameSignature&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; COLOR: blue; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-bidi-font-family: 'Courier New'; mso-no-proof: yes"&gt;&amp;gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-bidi-font-family: 'Courier New'; mso-no-proof: yes"&gt;unsigned int32&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;(unsigned int32)&lt;SPAN style="COLOR: blue"&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;InlineeNameSignature&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt 0.25in; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; COLOR: blue; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-bidi-font-family: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-tab-count: 3"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; COLOR: #a31515; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-bidi-font-family: 'Courier New'; mso-no-proof: yes"&gt;ClrInstanceID&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; COLOR: blue; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-bidi-font-family: 'Courier New'; mso-no-proof: yes"&gt;&amp;gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-bidi-font-family: 'Courier New'; mso-no-proof: yes"&gt;13&lt;SPAN style="COLOR: blue"&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;ClrInstanceID&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt 0.25in; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; COLOR: blue; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-bidi-font-family: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-tab-count: 2"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; COLOR: #a31515; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-bidi-font-family: 'Courier New'; mso-no-proof: yes"&gt;MethodJitInliningSucceeded&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; COLOR: blue; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-bidi-font-family: 'Courier New'; mso-no-proof: yes"&gt;&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt 0.25in; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; COLOR: blue; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-bidi-font-family: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-tab-count: 1"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; COLOR: #a31515; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-bidi-font-family: 'Courier New'; mso-no-proof: yes"&gt;UserData&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; COLOR: blue; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-bidi-font-family: 'Courier New'; mso-no-proof: yes"&gt;&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt 0.25in; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; COLOR: blue; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-bidi-font-family: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-tab-count: 1"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; COLOR: #a31515; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-bidi-font-family: 'Courier New'; mso-no-proof: yes"&gt;RenderingInfo&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; COLOR: blue; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-bidi-font-family: 'Courier New'; mso-no-proof: yes"&gt; &lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; COLOR: red; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-bidi-font-family: 'Courier New'; mso-no-proof: yes"&gt;Culture&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; COLOR: blue; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-bidi-font-family: 'Courier New'; mso-no-proof: yes"&gt;=&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-bidi-font-family: 'Courier New'; mso-no-proof: yes"&gt;"&lt;SPAN style="COLOR: blue"&gt;en-US&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt;&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt 0.25in; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; COLOR: blue; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-bidi-font-family: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-tab-count: 2"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; COLOR: #a31515; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-bidi-font-family: 'Courier New'; mso-no-proof: yes"&gt;Level&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; COLOR: blue; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-bidi-font-family: 'Courier New'; mso-no-proof: yes"&gt;&amp;gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-bidi-font-family: 'Courier New'; mso-no-proof: yes"&gt;Verbose &lt;SPAN style="COLOR: blue"&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;Level&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt 0.25in; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; COLOR: blue; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-bidi-font-family: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-tab-count: 2"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; COLOR: #a31515; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-bidi-font-family: 'Courier New'; mso-no-proof: yes"&gt;Opcode&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; COLOR: blue; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-bidi-font-family: 'Courier New'; mso-no-proof: yes"&gt;&amp;gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-bidi-font-family: 'Courier New'; mso-no-proof: yes"&gt;JitInliningSucceeded &lt;SPAN style="COLOR: blue"&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;Opcode&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt 0.25in; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; COLOR: blue; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-bidi-font-family: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-tab-count: 2"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; COLOR: #a31515; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-bidi-font-family: 'Courier New'; mso-no-proof: yes"&gt;Keywords&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; COLOR: blue; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-bidi-font-family: 'Courier New'; mso-no-proof: yes"&gt;&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt 0.25in; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; COLOR: blue; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-bidi-font-family: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-tab-count: 3"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; COLOR: #a31515; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-bidi-font-family: 'Courier New'; mso-no-proof: yes"&gt;Keyword&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; COLOR: blue; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-bidi-font-family: 'Courier New'; mso-no-proof: yes"&gt;&amp;gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-bidi-font-family: 'Courier New'; mso-no-proof: yes"&gt;JitTracingKeyword &lt;SPAN style="COLOR: blue"&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;Keyword&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt 0.25in; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; COLOR: blue; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-bidi-font-family: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-tab-count: 2"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; COLOR: #a31515; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-bidi-font-family: 'Courier New'; mso-no-proof: yes"&gt;Keywords&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; COLOR: blue; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-bidi-font-family: 'Courier New'; mso-no-proof: yes"&gt;&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt 0.25in; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; COLOR: blue; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-bidi-font-family: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-tab-count: 2"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; COLOR: #a31515; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-bidi-font-family: 'Courier New'; mso-no-proof: yes"&gt;Task&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; COLOR: blue; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-bidi-font-family: 'Courier New'; mso-no-proof: yes"&gt;&amp;gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-bidi-font-family: 'Courier New'; mso-no-proof: yes"&gt;CLR Method &lt;SPAN style="COLOR: blue"&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;Task&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt 0.25in; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; COLOR: blue; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-bidi-font-family: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-tab-count: 2"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; COLOR: #a31515; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-bidi-font-family: 'Courier New'; mso-no-proof: yes"&gt;Message&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; COLOR: blue; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-bidi-font-family: 'Courier New'; mso-no-proof: yes"&gt;&amp;gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-bidi-font-family: 'Courier New'; mso-no-proof: yes"&gt;MethodBeingCompiledNamespace=Factorial;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt 0.25in; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-bidi-font-family: 'Courier New'; mso-no-proof: yes"&gt;MethodBeingCompiledName=Main;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt 0.25in; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-bidi-font-family: 'Courier New'; mso-no-proof: yes"&gt;MethodBeingCompiledNameSignature=void&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;(class System.String[]);&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt 0.25in; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-bidi-font-family: 'Courier New'; mso-no-proof: yes"&gt;InlinerNamespace=Factorial;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt 0.25in; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-bidi-font-family: 'Courier New'; mso-no-proof: yes"&gt;InlinerName=Main;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt 0.25in; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-bidi-font-family: 'Courier New'; mso-no-proof: yes"&gt;InlinerNameSignature=void&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;(class System.String[]);&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt 0.25in; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-bidi-font-family: 'Courier New'; mso-no-proof: yes"&gt;InlineeNamespace=Factorial;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt 0.25in; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-bidi-font-family: 'Courier New'; mso-no-proof: yes"&gt;InlineeName=fact;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt 0.25in; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-bidi-font-family: 'Courier New'; mso-no-proof: yes"&gt;InlineeNameSignature=unsigned int32&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;(unsigned int32);&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt 0.25in; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-bidi-font-family: 'Courier New'; mso-no-proof: yes"&gt;ClrInstanceID=13 &lt;SPAN style="COLOR: blue"&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;Message&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt 0.25in; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; COLOR: blue; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-bidi-font-family: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-tab-count: 1"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; COLOR: #a31515; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-bidi-font-family: 'Courier New'; mso-no-proof: yes"&gt;RenderingInfo&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; COLOR: blue; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-bidi-font-family: 'Courier New'; mso-no-proof: yes"&gt;&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt 0.25in; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; COLOR: blue; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-bidi-font-family: 'Courier New'; mso-no-proof: yes"&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; COLOR: #a31515; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-bidi-font-family: 'Courier New'; mso-no-proof: yes"&gt;Event&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; COLOR: blue; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-bidi-font-family: 'Courier New'; mso-no-proof: yes"&gt;&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin"&gt;We’ll focus in on the &lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; COLOR: #a31515; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-bidi-font-family: 'Courier New'; mso-no-proof: yes"&gt;UserData&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin"&gt; element because it looks the prettiest.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;First you have 3 sets of triples: &lt;/SPAN&gt;&lt;SPAN class=XMLReference&gt;&lt;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-bidi-font-size: 12.0pt; mso-ansi-font-size: 12.0pt"&gt;&lt;FONT color=#a31515&gt;MethodBeingCompiled&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin"&gt;, &lt;/SPAN&gt;&lt;SPAN class=XMLReference&gt;&lt;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-bidi-font-size: 12.0pt; mso-ansi-font-size: 12.0pt"&gt;&lt;FONT color=#a31515&gt;Inliner&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin"&gt;, and &lt;/SPAN&gt;&lt;SPAN class=XMLReference&gt;&lt;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-bidi-font-size: 12.0pt; mso-ansi-font-size: 12.0pt"&gt;&lt;FONT color=#a31515&gt;Inlinee&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin"&gt; crossed with &lt;/SPAN&gt;&lt;SPAN class=XMLReference&gt;&lt;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-bidi-font-size: 12.0pt; mso-ansi-font-size: 12.0pt"&gt;&lt;FONT color=#a31515&gt;Namespace&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin"&gt;, &lt;/SPAN&gt;&lt;SPAN class=XMLReference&gt;&lt;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-bidi-font-size: 12.0pt; mso-ansi-font-size: 12.0pt"&gt;&lt;FONT color=#a31515&gt;Name&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin"&gt;, and &lt;/SPAN&gt;&lt;SPAN class=XMLReference&gt;&lt;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-bidi-font-size: 12.0pt; mso-ansi-font-size: 12.0pt"&gt;&lt;FONT color=#a31515&gt;Signature&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin"&gt;.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;I think the namespace, name and signature are fairly obvious, but the reason they are separate instead of pretty printed into a simple element is a matter of performance.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;ETW is supposed to be lightweight.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;Computing these strings is &lt;B style="mso-bidi-font-weight: normal"&gt;not&lt;/B&gt; lightweight, but we felt we made a nice trade-off (just enough information to be useful, but don’t spend time on making it prettier than it needs to be).&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN class=XMLReference&gt;&lt;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-bidi-font-size: 12.0pt; mso-ansi-font-size: 12.0pt"&gt;&lt;FONT color=#a31515&gt;MethodBeingCompiled&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin"&gt; is the method the VM asked the JIT to generate code for.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN class=XMLReference&gt;&lt;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-bidi-font-size: 12.0pt; mso-ansi-font-size: 12.0pt"&gt;&lt;FONT color=#a31515&gt;Inliner&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin"&gt; refers to the method that the JIT is trying to generate code for.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;If the &lt;/SPAN&gt;&lt;SPAN class=XMLReference&gt;&lt;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-bidi-font-size: 12.0pt; mso-ansi-font-size: 12.0pt"&gt;&lt;FONT color=#a31515&gt;Inliner&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin"&gt; is not the same as the &lt;/SPAN&gt;&lt;SPAN class=XMLReference&gt;&lt;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-bidi-font-size: 12.0pt; mso-ansi-font-size: 12.0pt"&gt;&lt;FONT color=#a31515&gt;MethodBeingCompiled&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin"&gt; it is because the JIT decided to &lt;B style="mso-bidi-font-weight: normal"&gt;try&lt;/B&gt; and inline the code for &lt;/SPAN&gt;&lt;SPAN class=XMLReference&gt;&lt;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-bidi-font-size: 12.0pt; mso-ansi-font-size: 12.0pt"&gt;&lt;FONT color=#a31515&gt;Inliner&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin"&gt; into the code for &lt;/SPAN&gt;&lt;SPAN class=XMLReference&gt;&lt;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-bidi-font-size: 12.0pt; mso-ansi-font-size: 12.0pt"&gt;&lt;FONT color=#a31515&gt;MethodBeingCompiled&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin"&gt; rather than generate a call to &lt;/SPAN&gt;&lt;SPAN class=XMLReference&gt;&lt;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-bidi-font-size: 12.0pt; mso-ansi-font-size: 12.0pt"&gt;&lt;FONT color=#a31515&gt;Inliner&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin"&gt;.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;However, just because you see a method showing up as the &lt;/SPAN&gt;&lt;SPAN class=XMLReference&gt;&lt;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-bidi-font-size: 12.0pt; mso-ansi-font-size: 12.0pt"&gt;&lt;FONT color=#a31515&gt;Inliner&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin"&gt;, it doesn’t mean the JIT has actually succeeded in inlining it.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;Finally the &lt;/SPAN&gt;&lt;SPAN class=XMLReference&gt;&lt;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-bidi-font-size: 12.0pt; mso-ansi-font-size: 12.0pt"&gt;&lt;FONT color=#a31515&gt;Inlinee&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin"&gt; refers to the method that the JIT is trying to inline (rather than generate a call to).&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin"&gt;If this was a &lt;/SPAN&gt;&lt;SPAN class=XMLReference&gt;&lt;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-bidi-font-size: 12.0pt; mso-ansi-font-size: 12.0pt"&gt;&lt;FONT color=#a31515&gt;MethodJitInliningFailed&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin"&gt; event it would have 2 additional elements: &lt;/SPAN&gt;&lt;SPAN class=XMLReference&gt;&lt;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-bidi-font-size: 12.0pt; mso-ansi-font-size: 12.0pt"&gt;&lt;FONT color=#a31515&gt;FailAlways&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin"&gt; and &lt;/SPAN&gt;&lt;SPAN class=XMLReference&gt;&lt;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-bidi-font-size: 12.0pt; mso-ansi-font-size: 12.0pt"&gt;&lt;FONT color=#a31515&gt;FailReason&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin"&gt;.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;If &lt;/SPAN&gt;&lt;SPAN class=XMLReference&gt;&lt;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-bidi-font-size: 12.0pt; mso-ansi-font-size: 12.0pt"&gt;&lt;FONT color=#a31515&gt;FailAlways&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin"&gt; is true, it is a hint back to the JIT and VM that inlining will always fail for the given &lt;/SPAN&gt;&lt;SPAN class=XMLReference&gt;&lt;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-bidi-font-size: 12.0pt; mso-ansi-font-size: 12.0pt"&gt;&lt;FONT color=#a31515&gt;Inlinee&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin"&gt;, regardless of the situation, and so subsequent compiles will be able to abort the inlining attempt faster (this is what &lt;/SPAN&gt;&lt;SPAN class=XMLReference&gt;&lt;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-bidi-font-size: 12.0pt; mso-ansi-font-size: 12.0pt"&gt;&lt;FONT color=#a31515&gt;FailReason&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin"&gt; of “&lt;/SPAN&gt;&lt;SPAN class=CodeChar&gt;&lt;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin"&gt;It is marked as &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin"&gt;'&lt;/SPAN&gt;&lt;SPAN class=CodeChar&gt;&lt;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin"&gt;INLINE_NEVER&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin"&gt;'” means).&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;The &lt;/SPAN&gt;&lt;SPAN class=XMLReference&gt;&lt;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-bidi-font-size: 12.0pt; mso-ansi-font-size: 12.0pt"&gt;&lt;FONT color=#a31515&gt;FailReason&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin"&gt; is a free-form text field.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;Originally this came from some internal code we had to help us in our debugging.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;The text is often cryptic, and is not localized.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;Part of the reason we did not localize it was performance.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;The other part is that these strings are often so cryptic many English speakers will have a hard time with them.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;For us we often end up treating them like a GUID: we search the sources for the places where that reason is returned to figure out why a particular inline failed.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;So if English is not your native language, don’t fret too much, you’re probably not missing much.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;That covers the 2 most common events: &lt;/SPAN&gt;&lt;SPAN class=XMLReference&gt;&lt;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-bidi-font-size: 12.0pt; mso-ansi-font-size: 12.0pt"&gt;&lt;FONT color=#a31515&gt;MethodJitInliningSucceeded&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin"&gt; and &lt;/SPAN&gt;&lt;SPAN class=XMLReference&gt;&lt;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-bidi-font-size: 12.0pt; mso-ansi-font-size: 12.0pt"&gt;&lt;FONT color=#a31515&gt;MethodJitInliningFailed&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin"&gt;.&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin"&gt;Now we move onto the only other 2 events for this keyword: &lt;/SPAN&gt;&lt;SPAN class=XMLReference&gt;&lt;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-bidi-font-size: 12.0pt; mso-ansi-font-size: 12.0pt"&gt;&lt;FONT color=#a31515&gt;MethodJitTailCallSucceeded&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin"&gt; and &lt;/SPAN&gt;&lt;SPAN class=XMLReference&gt;&lt;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-bidi-font-size: 12.0pt; mso-ansi-font-size: 12.0pt"&gt;&lt;FONT color=#a31515&gt;MethodJitTailCallFailed&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin"&gt;.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;The first 9 elements are the same (except replace &lt;/SPAN&gt;&lt;SPAN class=XMLReference&gt;&lt;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-bidi-font-size: 12.0pt; mso-ansi-font-size: 12.0pt"&gt;&lt;FONT color=#a31515&gt;Inliner&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin"&gt; with &lt;/SPAN&gt;&lt;SPAN class=XMLReference&gt;&lt;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-bidi-font-size: 12.0pt; mso-ansi-font-size: 12.0pt"&gt;&lt;FONT color=#a31515&gt;Caller&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin"&gt;, and &lt;/SPAN&gt;&lt;SPAN class=XMLReference&gt;&lt;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-bidi-font-size: 12.0pt; mso-ansi-font-size: 12.0pt"&gt;&lt;FONT color=#a31515&gt;Inlinee&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin"&gt; with &lt;/SPAN&gt;&lt;SPAN class=XMLReference&gt;&lt;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-bidi-font-size: 12.0pt; mso-ansi-font-size: 12.0pt"&gt;&lt;FONT color=#a31515&gt;Callee&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin"&gt;).&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;The next element is the &lt;/SPAN&gt;&lt;SPAN class=XMLReference&gt;&lt;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-bidi-font-size: 12.0pt; mso-ansi-font-size: 12.0pt"&gt;&lt;FONT color=#a31515&gt;TailPrefix&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin"&gt; element.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;This element tells whether the &lt;/SPAN&gt;&lt;SPAN class=CodeChar&gt;&lt;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin"&gt;tail.&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin"&gt; IL prefix was present.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;For x86 this currently will always be true because the x86 JIT does not generate tail calls as an optimization.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;See other blog posts for why tail calls are a good optimization that the x64 and IA64 JIT often performs even without the &lt;/SPAN&gt;&lt;SPAN class=CodeChar&gt;&lt;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin"&gt;tail.&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin"&gt; il prefix.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;We find this useful because, although some compilers emit the &lt;/SPAN&gt;&lt;SPAN class=CodeChar&gt;&lt;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin"&gt;tail.&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin"&gt; prefix in IL, they do not have any source syntax to expose it, so the programmer does not know looking only at the source what was in the IL.&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin"&gt;For &lt;/SPAN&gt;&lt;SPAN class=XMLReference&gt;&lt;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-bidi-font-size: 12.0pt; mso-ansi-font-size: 12.0pt"&gt;&lt;FONT color=#a31515&gt;MethodJitTailCallSucceded&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin"&gt;, you get a &lt;/SPAN&gt;&lt;SPAN class=XMLReference&gt;&lt;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-bidi-font-size: 12.0pt; mso-ansi-font-size: 12.0pt"&gt;&lt;FONT color=#a31515&gt;TailCallType&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin"&gt;.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;This is an enum, which has names that should be localized down in the &lt;/SPAN&gt;&lt;SPAN class=XMLReference&gt;&lt;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-bidi-font-size: 12.0pt; mso-ansi-font-size: 12.0pt"&gt;&lt;FONT color=#a31515&gt;Message&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin"&gt; element.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;Due to a bug in Beta 1 you will only get the numeric values.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;Also the pre-Vista versions of tracerpt do not do the translation from value to string.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;So on post Beta 1 builds with Vista or newer, you should the pretty names, otherwise expect the numbers.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;I will list both, especially because the number still appear in the &lt;/SPAN&gt;&lt;SPAN class=XMLReference&gt;&lt;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-bidi-font-size: 12.0pt; mso-ansi-font-size: 12.0pt"&gt;&lt;FONT color=#a31515&gt;UserData&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin"&gt; element.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN class=XMLReference&gt;&lt;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-bidi-font-size: 12.0pt; mso-ansi-font-size: 12.0pt"&gt;&lt;FONT color=#a31515&gt;OptimizedTailCall&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin"&gt;, 0, means a typical tail call, where the outgoing arguments are pushed into the incoming parameter slots, the epilog is executed but instead of returning, it ends with a jump to the new method.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN class=XMLReference&gt;&lt;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-bidi-font-size: 12.0pt; mso-ansi-font-size: 12.0pt"&gt;&lt;FONT color=#a31515&gt;RecursiveLoop&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin"&gt;, 1, means a recursive tail call, where the JIT sees that the method calls itself, and replaces the call with a jump back to the start of the method (thus skipping even the prolog and epilog). &lt;/SPAN&gt;&lt;SPAN class=XMLReference&gt;&lt;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-bidi-font-size: 12.0pt; mso-ansi-font-size: 12.0pt"&gt;&lt;FONT color=#a31515&gt;HelperAssistedTailCall&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin"&gt;, 2, means that the tail call cannot be accomplished directly and must go through a helper function call.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;These helper-assisted tail calls are slower than normal calls and only used as a last resort when the program needs to do a tail call in order to prevent stack overflows.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;Thus currently you should never see a &lt;/SPAN&gt;&lt;SPAN class=XMLReference&gt;&lt;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-bidi-font-size: 12.0pt; mso-ansi-font-size: 12.0pt"&gt;&lt;FONT color=#a31515&gt;HelperAssistedTailCall&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin"&gt; with &lt;/SPAN&gt;&lt;SPAN class=XMLReference&gt;&lt;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-bidi-font-size: 12.0pt; mso-ansi-font-size: 12.0pt"&gt;&lt;FONT color=#a31515&gt;TailPrefix&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN class=CodeChar&gt;&lt;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin"&gt;=false&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin"&gt;.&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin"&gt;For &lt;/SPAN&gt;&lt;SPAN class=XMLReference&gt;&lt;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-bidi-font-size: 12.0pt; mso-ansi-font-size: 12.0pt"&gt;&lt;FONT color=#a31515&gt;MethodJitTailCallFailed&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin"&gt;, you don’t get &lt;/SPAN&gt;&lt;SPAN class=XMLReference&gt;&lt;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-bidi-font-size: 12.0pt; mso-ansi-font-size: 12.0pt"&gt;&lt;FONT color=#a31515&gt;TailCallType&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin"&gt; element, but you do get &lt;/SPAN&gt;&lt;SPAN class=XMLReference&gt;&lt;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-bidi-font-size: 12.0pt; mso-ansi-font-size: 12.0pt"&gt;&lt;FONT color=#a31515&gt;FailReason&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin"&gt;, which is similar to &lt;/SPAN&gt;&lt;SPAN class=XMLReference&gt;&lt;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-bidi-font-size: 12.0pt; mso-ansi-font-size: 12.0pt"&gt;&lt;FONT color=#a31515&gt;MethodJitInliningFailed&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin"&gt;’s &lt;/SPAN&gt;&lt;SPAN class=XMLReference&gt;&lt;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-bidi-font-size: 12.0pt; mso-ansi-font-size: 12.0pt"&gt;&lt;FONT color=#a31515&gt;FailReason&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin"&gt;.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;It is also cryptic english-only text.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;In future posts we hope to explain some of the more common reasons.&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin"&gt;So for the few people that really need to squeeze out every last bit of performance from your code, you can now see a little bit further into how the JIT compiles your code.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;Occasionally this will enable you to refactor a method in such a way as to improve inlining or tail calls.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;If you do this remember though that &lt;B style="mso-bidi-font-weight: normal"&gt;every&lt;/B&gt; runtime has different heuristics and algorithms, and just because a methods was or wasn’t inlined in one version doesn’t mean the same will be true on a different version.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;If a method absolutely cannot be inlined, use &lt;A href="http://msdn.microsoft.com/en-us/library/system.runtime.compilerservices.methodimploptions(VS.95).aspxhttp:/msdn.microsoft.com/en-us/library/system.runtime.compilerservices.methodimploptions(VS.95).aspx" mce_href="http://msdn.microsoft.com/en-us/library/system.runtime.compilerservices.methodimploptions(VS.95).aspxhttp:/msdn.microsoft.com/en-us/library/system.runtime.compilerservices.methodimploptions(VS.95).aspx"&gt;&lt;SPAN style="mso-bidi-font-family: 'Courier New'"&gt;&lt;FONT color=#0000ff&gt;MethodImplOptions.NoInlining&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/A&gt;.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;If it absolutely must be inlined then inline it manually (i.e. copy and paste the code).&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;That recommendation should never change.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;If however you’re looking for some simple performance boosts, you can try these events and possibly learn something.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;One example we found internally is that moving a try/catch or try/finally up or down the call chain can often have a big performance impact because it might enable/disable inlining inside a very important loop.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin"&gt;&lt;/SPAN&gt;&amp;nbsp;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin"&gt;Grant Richins&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin"&gt;CLR Codegen Team&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;/FONT&gt;Update 10/8/2009 - replace em-dash in logman command line with a normal dash that you can paste into a command window and it will work.&lt;/P&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9601193" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/b/clrcodegeneration/archive/tags/JIT/">JIT</category><category domain="http://blogs.msdn.com/b/clrcodegeneration/archive/tags/performance/">performance</category><category domain="http://blogs.msdn.com/b/clrcodegeneration/archive/tags/-NET+Framework+4/">.NET Framework 4</category><category domain="http://blogs.msdn.com/b/clrcodegeneration/archive/tags/Visual+Studio+2010/">Visual Studio 2010</category><category domain="http://blogs.msdn.com/b/clrcodegeneration/archive/tags/ETW/">ETW</category></item><item><title>Improvements to NGen in .NET Framework 4</title><link>http://blogs.msdn.com/b/clrcodegeneration/archive/2009/05/03/improvements-to-ngen-in-.net-framework-4.aspx</link><pubDate>Sun, 03 May 2009 22:41:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9584872</guid><dc:creator>Surupa Biswas</dc:creator><slash:comments>5</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.msdn.com/b/clrcodegeneration/rsscomments.aspx?WeblogPostID=9584872</wfw:commentRss><comments>http://blogs.msdn.com/b/clrcodegeneration/archive/2009/05/03/improvements-to-ngen-in-.net-framework-4.aspx#comments</comments><description>&lt;SPAN style="FONT-SIZE: 12pt; mso-bidi-font-family: 'Times New Roman'; mso-fareast-font-family: 'Times New Roman'"&gt;&lt;FONT face=Calibri&gt;&lt;?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /&gt;&lt;o:p&gt;&lt;SPAN style="FONT-SIZE: 12pt; mso-bidi-font-family: 'Times New Roman'; mso-fareast-font-family: 'Times New Roman'"&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;SPAN style="mso-bidi-font-family: 'Times New Roman'; mso-fareast-font-family: 'Times New Roman'"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;SPAN style="mso-bidi-font-family: 'Times New Roman'; mso-fareast-font-family: 'Times New Roman'"&gt;.NET Framework 4 is our first release since we shipped FX 3.5 SP1 (FX 4 beta 1&amp;nbsp;is now available here: &lt;A href="http://msdn.microsoft.com/en-us/vstudio/dd582936.aspx" mce_href="http://msdn.microsoft.com/en-us/vstudio/dd582936.aspx"&gt;&lt;SPAN style="COLOR: blue"&gt;http://msdn.microsoft.com/en-us/vstudio/dd582936.aspx&lt;/SPAN&gt;&lt;/A&gt;). FX 3.5 SP1 contained major changes to NGen – features that improved startup performance, security, NGen time and compilation working set – described at length in this MSDN article: &lt;A href="http://msdn.microsoft.com/en-us/magazine/dd569747.aspx" mce_href="http://msdn.microsoft.com/en-us/magazine/dd569747.aspx"&gt;&lt;SPAN style="COLOR: blue"&gt;http://msdn.microsoft.com/en-us/magazine/dd569747.aspx&lt;/SPAN&gt;&lt;/A&gt;. &lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;SPAN style="mso-bidi-font-family: 'Times New Roman'; mso-fareast-font-family: 'Times New Roman'"&gt;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;SPAN style="mso-bidi-font-family: 'Times New Roman'; mso-fareast-font-family: 'Times New Roman'"&gt;In FX 4 we shifted our primary focus from startup performance to framework deployment. &lt;SPAN style="COLOR: black; mso-themecolor: text1"&gt;As many of you are aware, the performance win from pre-compiling your application using NGen comes at a cost – the time taken to generate the NGen images on the end-user machine.&amp;nbsp; In .NET 4 we’ve lowered that cost substantially in two ways.&amp;nbsp; First, we’ve made NGEN multiproc-aware.&amp;nbsp; In many cases, your assemblies (and ours) will now NGEN about twice as fast! &amp;nbsp;In addition, we’ve substantially reduced the number of situations in which we need to regenerate NGen images.&amp;nbsp; Our new Targeted Patching feature means that for many .NET Framework patches, we can now modify just the affected assemblies and not have to re-NGEN any other dependent assemblies.&amp;nbsp; Combined, these two features mean you and your users will spend a lot less time running NGEN.&amp;nbsp; Best of all, you don’t have to do anything to get these benefits – they’ll happen automatically when you use .NET 4.&amp;nbsp; &lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;SPAN style="COLOR: black; mso-bidi-font-family: 'Times New Roman'; mso-fareast-font-family: 'Times New Roman'; mso-themecolor: text1"&gt;We thought you may want to learn a little more about how these features work and the situations in which you’ll get these benefits.&amp;nbsp; In addition, since .NET 4 is a SxS release, there is a bit of complexity under the covers to make sure assemblies get NGen-ed against the matching runtime.&amp;nbsp; In general things will just work the way you would guess or expect them to, but below, I’ll go into some more detail about exactly what happens in various interesting cases.&amp;nbsp; &amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;SPAN style="mso-bidi-font-family: 'Times New Roman'; mso-fareast-font-family: 'Times New Roman'"&gt;If you have any comments or questions about any of these, we’d love to hear from you. Most of these features are available in the FX 4 beta 1 build.&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; TEXT-INDENT: -0.25in; MARGIN: 0in 0in 0pt 0.5in; mso-list: l0 level1 lfo1; mso-add-space: auto; mso-margin-top-alt: auto; mso-margin-bottom-alt: auto; tab-stops: list .5in" class=MsoListParagraphCxSpFirst&gt;&lt;SPAN style="FONT-FAMILY: Symbol; mso-bidi-font-family: Symbol; mso-fareast-font-family: Symbol"&gt;&lt;SPAN style="mso-list: Ignore"&gt;·&lt;SPAN style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;B style="mso-bidi-font-weight: normal"&gt;&lt;SPAN style="mso-bidi-font-family: Arial; mso-fareast-font-family: 'Times New Roman'"&gt;NGen SxS&lt;/SPAN&gt;&lt;/B&gt;&lt;SPAN style="mso-bidi-font-family: Arial; mso-fareast-font-family: 'Times New Roman'"&gt;: Making NGen work correctly when 2 major versions of the CLR are installed side-by-side&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; TEXT-INDENT: -0.25in; MARGIN: 0in 0in 0pt 0.5in; mso-list: l0 level1 lfo1; mso-add-space: auto; mso-margin-top-alt: auto; mso-margin-bottom-alt: auto; tab-stops: list .5in" class=MsoListParagraphCxSpMiddle&gt;&lt;SPAN style="FONT-FAMILY: Symbol; mso-bidi-font-family: Symbol; mso-fareast-font-family: Symbol"&gt;&lt;SPAN style="mso-list: Ignore"&gt;·&lt;SPAN style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;B style="mso-bidi-font-weight: normal"&gt;&lt;SPAN style="mso-bidi-font-family: Arial; mso-fareast-font-family: 'Times New Roman'"&gt;Multi-proc NGen&lt;/SPAN&gt;&lt;/B&gt;&lt;SPAN style="mso-bidi-font-family: Arial; mso-fareast-font-family: 'Times New Roman'"&gt;: Enabling use of multiple cores/processors during NGen to make it faster&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; TEXT-INDENT: -0.25in; MARGIN: 0in 0in 0pt 0.5in; mso-list: l0 level1 lfo1; mso-add-space: auto; mso-margin-top-alt: auto; mso-margin-bottom-alt: auto; tab-stops: list .5in" class=MsoListParagraphCxSpMiddle&gt;&lt;SPAN style="FONT-FAMILY: Symbol; mso-bidi-font-family: Symbol; mso-fareast-font-family: Symbol"&gt;&lt;SPAN style="mso-list: Ignore"&gt;·&lt;SPAN style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;B style="mso-bidi-font-weight: normal"&gt;&lt;SPAN style="mso-bidi-font-family: Arial; mso-fareast-font-family: 'Times New Roman'"&gt;Targeted Patching&lt;/SPAN&gt;&lt;/B&gt;&lt;SPAN style="mso-bidi-font-family: Arial; mso-fareast-font-family: 'Times New Roman'"&gt;: First step towards making NGen images less “fragile” – avoids having to recompile all managed assemblies when a FX dependency is patched&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; TEXT-INDENT: -0.25in; MARGIN: 0in 0in 10pt 0.5in; mso-list: l0 level1 lfo1; mso-add-space: auto; mso-margin-top-alt: auto; mso-margin-bottom-alt: auto; tab-stops: list .5in" class=MsoListParagraphCxSpLast&gt;&lt;SPAN style="FONT-FAMILY: Symbol; mso-bidi-font-family: Symbol; mso-fareast-font-family: Symbol"&gt;&lt;SPAN style="mso-list: Ignore"&gt;·&lt;SPAN style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;B style="mso-bidi-font-weight: normal"&gt;&lt;SPAN style="mso-bidi-font-family: Arial; mso-fareast-font-family: 'Times New Roman'"&gt;No NGen in partial trust&lt;/SPAN&gt;&lt;/B&gt;&lt;SPAN style="mso-bidi-font-family: Arial; mso-fareast-font-family: 'Times New Roman'"&gt;: Deprecated support for generating and loading NGen images in partial trust applications&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; TEXT-INDENT: -0.25in; MARGIN: auto auto auto 0.25in; mso-add-space: auto; mso-margin-top-alt: auto; mso-margin-bottom-alt: auto" class=MsoNormalCxSpFirst&gt;&lt;SPAN style="mso-bidi-font-family: Arial; mso-fareast-font-family: 'Times New Roman'"&gt;&lt;o:p&gt;&lt;FONT face="Times New Roman"&gt;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;B style="mso-bidi-font-weight: normal"&gt;&lt;SPAN style="mso-bidi-font-family: 'Times New Roman'; mso-fareast-font-family: 'Times New Roman'"&gt;NGen SxS&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/B&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;SPAN style="mso-bidi-font-family: 'Times New Roman'; mso-fareast-font-family: 'Times New Roman'"&gt;To a large extent FX 4 is the first SxS release for NGen (the NGen infrastructure in FX 1.0 and 1.1 was rudimentary). We’ve now architected NGen such that the 4.0 ngen.exe tool can be used to generate NGen images for both 2.0 and 4.0 MSIL assemblies without having to pass any special arguments. NGen uses the same logic that is used at application runtime (this logic resides in the shim) to determine the CLR version to load and run an application against. Thus,&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;B style="mso-bidi-font-weight: normal"&gt;&lt;SPAN style="COLOR: #1f497d; mso-bidi-font-family: 'Times New Roman'; mso-fareast-font-family: 'Times New Roman'; mso-themecolor: text2"&gt;%WINDIR%\Microsoft.NET\Framework\v4.0.xxxxx\ngen.exe install &amp;lt;4.0 assembly&amp;gt;&lt;/SPAN&gt;&lt;/B&gt;&lt;SPAN style="mso-bidi-font-family: 'Times New Roman'; mso-fareast-font-family: 'Times New Roman'"&gt; will generate an NGen image compiled against the 4.0 runtime.&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;B style="mso-bidi-font-weight: normal"&gt;&lt;SPAN style="COLOR: #1f497d; mso-bidi-font-family: 'Times New Roman'; mso-fareast-font-family: 'Times New Roman'; mso-themecolor: text2"&gt;%WINDIR%\Microsoft.NET\Framework\v4.0.xxxxx\ngen.exe install &amp;lt;2.0 assembly&amp;gt;&lt;/SPAN&gt;&lt;/B&gt;&lt;SPAN style="mso-bidi-font-family: 'Times New Roman'; mso-fareast-font-family: 'Times New Roman'"&gt; will generate an NGen image compiled against the 2.0 runtime (if .NET Framework 2.0/3.0/3.5 is installed on the machine. Note that applications built against .NET Framework 2.0 won’t run against .NET Framework 4.0 by default, and thus by default we don’t NGen 2.0 assemblies unless CLR 2 is installed). &lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;B style="mso-bidi-font-weight: normal"&gt;&lt;SPAN style="COLOR: #1f497d; mso-bidi-font-family: 'Times New Roman'; mso-fareast-font-family: 'Times New Roman'; mso-themecolor: text2"&gt;%WINDIR%\Microsoft.NET\Framework\v4.0.xxxxx\ngen.exe install &amp;lt;2.0 assembly&amp;gt; /ExeConfig:&amp;lt;Path to a 4.0 EXE&amp;gt;&lt;/SPAN&gt;&lt;/B&gt;&lt;SPAN style="mso-bidi-font-family: 'Times New Roman'; mso-fareast-font-family: 'Times New Roman'"&gt; will generate an NGen image compiled against the 4.0 runtime.&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;B style="mso-bidi-font-weight: normal"&gt;&lt;SPAN style="COLOR: #1f497d; mso-bidi-font-family: 'Times New Roman'; mso-fareast-font-family: 'Times New Roman'; mso-themecolor: text2"&gt;%WINDIR%\Microsoft.NET\Framework\v4.0.xxxxx\ngen.exe install &amp;lt;2.0 EXE with a config file that indicates 4.0 as the preferred runtime&amp;gt;&lt;/SPAN&gt;&lt;/B&gt;&lt;SPAN style="mso-bidi-font-family: 'Times New Roman'; mso-fareast-font-family: 'Times New Roman'"&gt; will generate an NGen image compiled against the 4.0 runtime.&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;B style="mso-bidi-font-weight: normal"&gt;&lt;SPAN style="COLOR: #1f497d; mso-bidi-font-family: 'Times New Roman'; mso-fareast-font-family: 'Times New Roman'; mso-themecolor: text2"&gt;%WINDIR%\Microsoft.NET\Framework\v4.0.xxxxx\ngen.exe install &amp;lt;2.0 assembly&amp;gt; /ExeConfig:&amp;lt;Path to a 2.0 EXE with a config file that indicates 4.0 as the preferred runtime&amp;gt; &lt;/SPAN&gt;&lt;/B&gt;&lt;SPAN style="mso-bidi-font-family: 'Times New Roman'; mso-fareast-font-family: 'Times New Roman'"&gt;will generate an NGen image compiled against the 4.0 runtime.&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;SPAN style="mso-bidi-font-family: 'Times New Roman'; mso-fareast-font-family: 'Times New Roman'"&gt;There was also work required to make the 2.0 NGen Service (clr_optimization_v2.0.50727_32|64) work SxS with the 4.0 NGen Service (clr_optimization_v4.0.xxxxx_32|64). Only one service (the latest) is active at any time – installing FX 4 disables the 2.0 service and it is re-enabled if/when FX 4 is uninstalled. &lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;B style="mso-bidi-font-weight: normal"&gt;&lt;SPAN style="mso-bidi-font-family: 'Times New Roman'; mso-fareast-font-family: 'Times New Roman'"&gt;Multiproc NGen&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/B&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;SPAN style="mso-bidi-font-family: 'Times New Roman'; mso-fareast-font-family: 'Times New Roman'"&gt;NGen is now aware of multiple processors/cores and can compile up to 6 assemblies in parallel (the parallelism is at the level of assemblies). To avoid impacting foreground activities, NGen only runs in this aggressive mode when assemblies are being compiled synchronously i.e. the NGen Service still runs on one processor. Synchronous NGen commands (such as ngen.exe install &amp;lt;assembly&amp;gt;, ngen.exe update, ngen.exe ExecuteQueuedItems) will now use multiple processors/cores whenever possible (we also factor in amount of RAM when determining how many cores/processors to use). Since the parallelism is at the level of assemblies, the most effective way to enable use of multiple processors for NGen is to do the following:&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;B style="mso-bidi-font-weight: normal"&gt;&lt;SPAN style="COLOR: #1f497d; mso-bidi-font-family: 'Times New Roman'; mso-fareast-font-family: 'Times New Roman'; mso-themecolor: text2"&gt;ngen.exe install /queue:1 &amp;lt;MyImportantAssembly#1&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/B&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;B style="mso-bidi-font-weight: normal"&gt;&lt;SPAN style="COLOR: #1f497d; mso-bidi-font-family: 'Times New Roman'; mso-fareast-font-family: 'Times New Roman'; mso-themecolor: text2"&gt;ngen.exe install /queue:1 &amp;lt;MyImportantAssembly#2&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/B&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;B style="mso-bidi-font-weight: normal"&gt;&lt;SPAN style="COLOR: #1f497d; mso-bidi-font-family: 'Times New Roman'; mso-fareast-font-family: 'Times New Roman'; mso-themecolor: text2"&gt;…&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/B&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;B style="mso-bidi-font-weight: normal"&gt;&lt;SPAN style="COLOR: #1f497d; mso-bidi-font-family: 'Times New Roman'; mso-fareast-font-family: 'Times New Roman'; mso-themecolor: text2"&gt;ngen.exe install /queue:1 &amp;lt;MyImportantAssembly#N&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/B&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;B style="mso-bidi-font-weight: normal"&gt;&lt;SPAN style="COLOR: #1f497d; mso-bidi-font-family: 'Times New Roman'; mso-fareast-font-family: 'Times New Roman'; mso-themecolor: text2"&gt;ngen.exe install /queue:3 &amp;lt;MyAssembly#N+1&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/B&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;B style="mso-bidi-font-weight: normal"&gt;&lt;SPAN style="COLOR: #1f497d; mso-bidi-font-family: 'Times New Roman'; mso-fareast-font-family: 'Times New Roman'; mso-themecolor: text2"&gt;….&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/B&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;B style="mso-bidi-font-weight: normal"&gt;&lt;SPAN style="COLOR: #1f497d; mso-bidi-font-family: 'Times New Roman'; mso-fareast-font-family: 'Times New Roman'; mso-themecolor: text2"&gt;ngen.exe install /queue:3 &amp;lt;MyAssembly#M&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/B&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;B style="mso-bidi-font-weight: normal"&gt;&lt;SPAN style="COLOR: #1f497d; mso-bidi-font-family: 'Times New Roman'; mso-fareast-font-family: 'Times New Roman'; mso-themecolor: text2"&gt;ngen.exe ExecuteQueuedItems 1 &lt;/SPAN&gt;&lt;/B&gt;&lt;SPAN style="mso-bidi-font-family: 'Times New Roman'; mso-fareast-font-family: 'Times New Roman'"&gt;//Synchronously compiles all important (priority 1) assemblies during set up using multiple cores whenever possible; other (priority 3) assemblies will be compiled in the background by the NGen Service at machine idle-time.&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 12pt" class=MsoNormal&gt;&lt;SPAN style="mso-bidi-font-family: 'Times New Roman'; mso-fareast-font-family: 'Times New Roman'"&gt;As part of this work we reworked FX 4 set up to use the NGen pattern above.&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;B style="mso-bidi-font-weight: normal"&gt;&lt;SPAN style="mso-bidi-font-family: 'Times New Roman'; mso-fareast-font-family: 'Times New Roman'"&gt;Targeted Patching&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/B&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;SPAN style="mso-bidi-font-family: 'Times New Roman'; mso-fareast-font-family: 'Times New Roman'"&gt;NGen images thus far have been nothing more than “cached JIT-compiled code and CLR data structures” – as a consequence they’re completely fragile; any change to the underlying CLR or to any managed dependency invalidates them and requires them to be regenerated. For example, any change to the CLR or to basic assemblies like mscorlib and System that all/most assemblies depend upon invalidates all NGen images installed on the machine. Since a machine could have several hundreds of NGen images, the cost of regenerating them after FX servicing events is high. In CLR 4 we took a first step towards making NGen images less fragile to avoid the cascaded cost associated with .NET Framework updates. In particular, FX updates that only involve fixes to bodies of existing methods (that aren’t generic, and aren’t inlined across NGen image boundaries) will no longer require recompiling dependent NGen images (the old NGen images can be used with the new serviced dependency). Although this may sound trivial (and beg the question why the system didn’t have this attribute to begin with &lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: Wingdings; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-ascii-font-family: Calibri; mso-hansi-font-family: Calibri; mso-char-type: symbol; mso-symbol-font-family: Wingdings; mso-bidi-font-family: 'Times New Roman'; mso-fareast-font-family: 'Times New Roman'"&gt;&lt;SPAN style="mso-char-type: symbol; mso-symbol-font-family: Wingdings"&gt;J&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN style="mso-bidi-font-family: 'Times New Roman'; mso-fareast-font-family: 'Times New Roman'"&gt;), since NGen images had never been architected to be anything but serialized JIT-ed code and CLR data, accomplishing this turned out to be major feat. From reworking &lt;A href="http://msdn.microsoft.com/en-us/magazine/cc163610.aspx#S7" mce_href="http://msdn.microsoft.com/en-us/magazine/cc163610.aspx#S7"&gt;&lt;SPAN style="COLOR: blue"&gt;hardbinding&lt;/SPAN&gt;&lt;/A&gt;, doing major performance work to recover the perf impact, to writing an IL post-processing tool that normalizes metadata tokens, detects Targeted Patching-compatible vs. incompatible changes, and flags compatible changes such that existing NGen images can rewired to the updated dependency, plugging that tool into our build system, and revising NGen cross-module inlining rules, this is a major effort that several of us have been working on for several months. &lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;SPAN style="mso-bidi-font-family: 'Times New Roman'; mso-fareast-font-family: 'Times New Roman'"&gt;Some of the work for this (such as the changes to hardbinding and corresponding the performance work) are included in the beta 1 build, but this feature will really come online once we start servicing FX 4. You can find out more in the &lt;A title="Channel 9 video on Targeted Patching" href="http://channel9.msdn.com/posts/Charles/Surupa-Biswas-CLR-4-Resilient-NGen-and-Targeted-Patching/" mce_href="http://channel9.msdn.com/posts/Charles/Surupa-Biswas-CLR-4-Resilient-NGen-and-Targeted-Patching/"&gt;Channel 9 video on Targeted Patching&lt;/A&gt;.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;B style="mso-bidi-font-weight: normal"&gt;&lt;SPAN style="mso-bidi-font-family: 'Times New Roman'; mso-fareast-font-family: 'Times New Roman'"&gt;NGen in partial trust&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/B&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;SPAN style="mso-bidi-font-family: 'Times New Roman'; mso-fareast-font-family: 'Times New Roman'"&gt;In&amp;nbsp;FX 2&amp;nbsp;NGen images can be generated by running commands such as &lt;B style="mso-bidi-font-weight: normal"&gt;&lt;SPAN style="COLOR: #1f497d; mso-themecolor: text2"&gt;ngen.exe install &amp;lt;Path to assembly on intranet share&amp;gt; &lt;/SPAN&gt;&lt;/B&gt;and the generated image loaded in applications running in partial trust. We believe NGen images aren’t used in partial trust applications very much and our current model was broken, so we’ve disabled loading of NGen images in partial trust in FX 4. In the future (post CLR 4) we intend to rework this as part of simplifying the overall NGen story (i.e. change the model where the only way to generate NGen images is to issue commands from an elevated command prompt). If you’re using NGen in a partial trust application today, we’d like to hear from you!&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;SPAN style="mso-bidi-font-family: 'Times New Roman'; mso-fareast-font-family: 'Times New Roman'"&gt;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;SPAN style="mso-bidi-font-family: 'Times New Roman'; mso-fareast-font-family: 'Times New Roman'"&gt;Surupa Biswas&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;SPAN style="mso-bidi-font-family: 'Times New Roman'; mso-fareast-font-family: 'Times New Roman'"&gt;CLR Codegen Team&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;/SPAN&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&amp;nbsp;&lt;/P&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9584872" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/b/clrcodegeneration/archive/tags/NGen/">NGen</category><category domain="http://blogs.msdn.com/b/clrcodegeneration/archive/tags/-NET+Framework+4/">.NET Framework 4</category><category domain="http://blogs.msdn.com/b/clrcodegeneration/archive/tags/Visual+Studio+2010/">Visual Studio 2010</category></item><item><title>What's in NetFX 3.5 SP1?</title><link>http://blogs.msdn.com/b/clrcodegeneration/archive/2008/08/15/what-s-in-netfx-3-5-sp1.aspx</link><pubDate>Sat, 16 Aug 2008 00:19:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8870749</guid><dc:creator>Kevin Frei</dc:creator><slash:comments>4</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.msdn.com/b/clrcodegeneration/rsscomments.aspx?WeblogPostID=8870749</wfw:commentRss><comments>http://blogs.msdn.com/b/clrcodegeneration/archive/2008/08/15/what-s-in-netfx-3-5-sp1.aspx#comments</comments><description>&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;FONT face=Calibri size=3&gt;Long time, no blog.&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /&gt;&lt;o:p&gt;&lt;FONT face=Calibri size=3&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;FONT face=Calibri size=3&gt;Since the &lt;/FONT&gt;&lt;A href="http://www.microsoft.com/downloads/details.aspx?FamilyId=AB99342F-5D1A-413D-8319-81DA479AB0D7&amp;amp;displaylang=en" mce_href="http://www.microsoft.com/downloads/details.aspx?FamilyId=AB99342F-5D1A-413D-8319-81DA479AB0D7&amp;amp;displaylang=en"&gt;&lt;FONT face=Calibri size=3&gt;NetFX 3.5 Service Pack&lt;/FONT&gt;&lt;/A&gt;&lt;FONT face=Calibri size=3&gt; is available, now, I figured I’d put up a quick rundown of what we (the CLR CodeGen team) contributed to the package.&amp;nbsp; I’m not going into nitty-gritty details, but just to give you an idea of what’s in it, and perhaps inspire you to go install it.&amp;nbsp; A quick note:&amp;nbsp; Unless otherwise noted, all changes impact both x86 &amp;amp; x64.&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;o:p&gt;&lt;FONT face=Calibri size=3&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;FONT face=Calibri size=3&gt;NGen infrastructure rewrite:&amp;nbsp; the new infrastructure uses less memory, produces less fragmented NGen images with&amp;nbsp;much better locality, and does so in dramatically less time.&amp;nbsp; What this means to you:&amp;nbsp; Installing or servicing an NGen image is much faster, and cold startup time of your NGen’ed code is better.&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;o:p&gt;&lt;FONT face=Calibri size=3&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;FONT face=Calibri size=3&gt;Framework Startup Performance Improvements:&amp;nbsp; The framework is now better optimized for startup.&amp;nbsp; We’ve tweaked the framework to consider more scenarios for startup, and now layout both code &amp;amp; data in the framework’s NGen images more optimally.&amp;nbsp; What this means to you:&amp;nbsp; Even your JIT code starts faster!&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;o:p&gt;&lt;FONT face=Calibri size=3&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;FONT face=Calibri size=3&gt;Better OS citizenship:&amp;nbsp; We’ve modified NGen to produce images that are &lt;/FONT&gt;&lt;A href="http://blogs.msdn.com/michael_howard/archive/2006/05/26/address-space-layout-randomization-in-windows-vista.aspx" mce_href="http://blogs.msdn.com/michael_howard/archive/2006/05/26/address-space-layout-randomization-in-windows-vista.aspx"&gt;&lt;FONT face=Calibri size=3&gt;ASLR&lt;/FONT&gt;&lt;/A&gt;&lt;FONT face=Calibri size=3&gt; capable, in an effort to decrease potential security attack surface area.&amp;nbsp; We’ve also started generating stacks that are always walkable using EBP-chaining for x86.&amp;nbsp; What this means to you:&amp;nbsp; Stack traces are more consistent, and NGen images aren’t as easily used to attack the system.&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;o:p&gt;&lt;FONT face=Calibri size=3&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;FONT face=Calibri size=3&gt;Better 32-bit code quality:&amp;nbsp; The x86 JIT has dramatically improved &lt;/FONT&gt;&lt;A href="http://blogs.msdn.com/clrcodegeneration/archive/2007/11/02/how-are-value-types-implemented-in-the-32-bit-clr-what-has-been-done-to-improve-their-performance.aspx" mce_href="http://blogs.msdn.com/clrcodegeneration/archive/2007/11/02/how-are-value-types-implemented-in-the-32-bit-clr-what-has-been-done-to-improve-their-performance.aspx"&gt;&lt;FONT face=Calibri size=3&gt;inlining heuristics&lt;/FONT&gt;&lt;/A&gt;&lt;FONT face=Calibri size=3&gt; that result in generally better code quality, and, in particular, much lower “cost of abstraction”.&amp;nbsp; If you want to author a data type that only manipulates a single integer, you can wrap the thing in a struct, and expect similar performance to code that explicitly uses an integer.&amp;nbsp; There have also been some improvements to the ‘assertion propagation’ portion of the JIT, which means better null/range check elimination, as well as better constant propagation, and slight better ‘smarts’ in the JIT optimizer, overall.&amp;nbsp; What this means to you:&amp;nbsp; Your managed code should run slightly faster (and sometimes dramatically faster!).&amp;nbsp; Note to &lt;/FONT&gt;&lt;A href="http://blogs.msdn.com/freik" mce_href="http://blogs.msdn.com/freik"&gt;&lt;FONT face=Calibri size=3&gt;64 bit junkies&lt;/FONT&gt;&lt;/A&gt;&lt;FONT face=Calibri size=3&gt;: &amp;nbsp;We’re working on getting x64 there, too.&amp;nbsp; The work just wasn’t quite there in time.&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;o:p&gt;&lt;FONT face=Calibri size=3&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;FONT face=Calibri size=3&gt;Anyway, go forth &amp;amp; &lt;/FONT&gt;&lt;A href="http://msdn.microsoft.com/en-us/vstudio/cc533448.aspx" mce_href="http://msdn.microsoft.com/en-us/vstudio/cc533448.aspx"&gt;&lt;FONT face=Calibri size=3&gt;download&lt;/FONT&gt;&lt;/A&gt;&lt;FONT face=Calibri size=3&gt;!&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;FONT face=Calibri size=3&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;FONT face=Calibri size=3&gt;-Kev&lt;/FONT&gt;&lt;/P&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=8870749" width="1" height="1"&gt;</description></item><item><title>Performance implications of unmanaged array accesses</title><link>http://blogs.msdn.com/b/clrcodegeneration/archive/2008/02/08/performance-implications-of-unmanaged-array-accesses.aspx</link><pubDate>Sat, 09 Feb 2008 02:13:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:7548251</guid><dc:creator>CLR Codegen Blogger</dc:creator><slash:comments>2</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.msdn.com/b/clrcodegeneration/rsscomments.aspx?WeblogPostID=7548251</wfw:commentRss><comments>http://blogs.msdn.com/b/clrcodegeneration/archive/2008/02/08/performance-implications-of-unmanaged-array-accesses.aspx#comments</comments><description>&lt;H1 style="MARGIN: 24pt 0in 0pt"&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;&lt;SPAN style="COLOR: #1f497d"&gt;I was recently shown the following code and asked why the loop calling SafeAccess executed significantly faster than the second loop calling UnsafeAccess&lt;/SPAN&gt;&lt;SPAN style="COLOR: #1f497d; mso-themecolor: dark2"&gt;:&lt;/SPAN&gt;&lt;SPAN style="COLOR: #1f497d"&gt;&lt;?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/H1&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="COLOR: #1f497d"&gt;&lt;o:p&gt;&lt;FONT face=Calibri size=3&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="FONT-SIZE: 8pt; COLOR: black; FONT-FAMILY: 'Lucida Console'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; static int [] intarray = new int [&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 8pt; COLOR: #1f497d; FONT-FAMILY: 'Lucida Console'; mso-themecolor: dark2"&gt;5000&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 8pt; COLOR: black; FONT-FAMILY: 'Lucida Console'"&gt;];&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="FONT-SIZE: 8pt; COLOR: black; FONT-FAMILY: 'Lucida Console'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="FONT-SIZE: 8pt; COLOR: black; FONT-FAMILY: 'Lucida Console'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; static void SafeAccess(int a, int b)&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="FONT-SIZE: 8pt; COLOR: black; FONT-FAMILY: 'Lucida Console'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="FONT-SIZE: 8pt; COLOR: black; FONT-FAMILY: 'Lucida Console'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; int temp = intarray[a];&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="FONT-SIZE: 8pt; COLOR: black; FONT-FAMILY: 'Lucida Console'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; intarray[a] = intarray[b];&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="FONT-SIZE: 8pt; COLOR: black; FONT-FAMILY: 'Lucida Console'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; intarray[b] = temp;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="FONT-SIZE: 8pt; COLOR: black; FONT-FAMILY: 'Lucida Console'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="FONT-SIZE: 8pt; COLOR: black; FONT-FAMILY: 'Lucida Console'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;static Unsafe void UnsafeAccess(int a, int b)&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="FONT-SIZE: 8pt; COLOR: black; FONT-FAMILY: 'Lucida Console'"&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="FONT-SIZE: 8pt; COLOR: black; FONT-FAMILY: 'Lucida Console'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; fixed (int* pi = &amp;amp;intarray[0])&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="FONT-SIZE: 8pt; COLOR: black; FONT-FAMILY: 'Lucida Console'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="FONT-SIZE: 8pt; COLOR: black; FONT-FAMILY: 'Lucida Console'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; int temp = pi[a];&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="FONT-SIZE: 8pt; COLOR: black; FONT-FAMILY: 'Lucida Console'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; pi[a] = pi[b];&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="FONT-SIZE: 8pt; COLOR: black; FONT-FAMILY: 'Lucida Console'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; pi[b] = temp;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="FONT-SIZE: 8pt; COLOR: black; FONT-FAMILY: 'Lucida Console'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="FONT-SIZE: 8pt; COLOR: black; FONT-FAMILY: 'Lucida Console'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="FONT-SIZE: 8pt; COLOR: black; FONT-FAMILY: 'Lucida Console'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;static Unsafe void Main(string[] args)&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="FONT-SIZE: 8pt; COLOR: black; FONT-FAMILY: 'Lucida Console'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="FONT-SIZE: 8pt; COLOR: black; FONT-FAMILY: 'Lucida Console'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; for (int i = 0; i &amp;lt; testCount; i++)&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="FONT-SIZE: 8pt; COLOR: black; FONT-FAMILY: 'Lucida Console'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="FONT-SIZE: 8pt; COLOR: black; FONT-FAMILY: 'Lucida Console'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; SafeAccess(0, i);&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="FONT-SIZE: 8pt; COLOR: black; FONT-FAMILY: 'Lucida Console'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="FONT-SIZE: 8pt; COLOR: black; FONT-FAMILY: 'Lucida Console'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; for (int i = 0; i &amp;lt; testCount; i++)&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="FONT-SIZE: 8pt; COLOR: black; FONT-FAMILY: 'Lucida Console'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="FONT-SIZE: 8pt; COLOR: black; FONT-FAMILY: 'Lucida Console'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; UnsafeAccess(0, i);&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="FONT-SIZE: 8pt; COLOR: black; FONT-FAMILY: 'Lucida Console'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="FONT-SIZE: 8pt; COLOR: black; FONT-FAMILY: 'Lucida Console'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="COLOR: #1f497d"&gt;&lt;o:p&gt;&lt;FONT face=Calibri size=3&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;H1 style="MARGIN: 24pt 0in 0pt"&gt;&lt;SPAN style="mso-fareast-font-family: 'Times New Roman'"&gt;&lt;FONT size=5&gt;&lt;FONT color=#365f91&gt;&lt;FONT face=Cambria&gt;Safe Loop:&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/H1&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="COLOR: #1f497d"&gt;&lt;FONT face=Calibri size=3&gt;I examined the code &lt;/FONT&gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: #1f497d; FONT-FAMILY: 'Tahoma','sans-serif'"&gt;generated by the 64-bit JI&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: #1f497d; FONT-FAMILY: 'Tahoma','sans-serif'; mso-themecolor: dark2"&gt;T &lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: #1f497d; FONT-FAMILY: 'Tahoma','sans-serif'"&gt;compiler for the SafeAccess loop (which was inlined into Main by the JIT)&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: #1f497d; FONT-FAMILY: 'Tahoma','sans-serif'; mso-themecolor: dark2"&gt;.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #1f497d; mso-bidi-font-family: 'Times New Roman'; mso-bidi-theme-font: minor-bidi; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-themecolor: dark2; mso-ascii-font-family: Calibri; mso-hansi-font-family: Calibri"&gt;&lt;FONT face=Calibri size=3&gt;Vance Morrison posted a useful article describing how to accomplish this from within Visual Studio: &lt;/FONT&gt;&lt;A href="http://blogs.msdn.com/vancem/archive/2006/02/20/535807.aspx"&gt;&lt;FONT face=Calibri size=3&gt;http://blogs.msdn.com/vancem/archive/2006/02/20/535807.aspx&lt;/FONT&gt;&lt;/A&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="COLOR: #1f497d"&gt;&lt;o:p&gt;&lt;FONT face=Calibri size=3&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="FONT-SIZE: 8pt; COLOR: #1f497d; FONT-FAMILY: 'Lucida Console'"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;B&gt;&lt;SPAN style="FONT-SIZE: 8pt; COLOR: #1f497d; FONT-FAMILY: 'Lucida Console'"&gt;00000642`801501f0&lt;/SPAN&gt;&lt;/B&gt;&lt;SPAN style="FONT-SIZE: 8pt; COLOR: #1f497d; FONT-FAMILY: 'Lucida Console'"&gt; 418b08&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; mov&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ecx,dword ptr [r8]&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="FONT-SIZE: 8pt; COLOR: #1f497d; FONT-FAMILY: 'Lucida Console'"&gt;00000642`801501f3 8b02&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; mov&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; eax,dword ptr [rdx]&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="FONT-SIZE: 8pt; COLOR: #1f497d; FONT-FAMILY: 'Lucida Console'"&gt;00000642`801501f5 418900&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; mov&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; dword ptr [r8],eax&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="FONT-SIZE: 8pt; COLOR: #1f497d; FONT-FAMILY: 'Lucida Console'"&gt;00000642`801501f8 890a&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; mov &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;dword ptr [rdx],ecx&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="FONT-SIZE: 8pt; COLOR: #1f497d; FONT-FAMILY: 'Lucida Console'"&gt;00000642`801501fa 4883c204&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; add&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; rdx,4&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="FONT-SIZE: 8pt; COLOR: #1f497d; FONT-FAMILY: 'Lucida Console'"&gt;00000642`801501fe 493bd1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; cmp&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; rdx,r9&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="FONT-SIZE: 8pt; COLOR: #1f497d; FONT-FAMILY: 'Lucida Console'"&gt;00000642`80150201 7ced&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; jl&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;B&gt;00000642`801501f0&lt;o:p&gt;&lt;/o:p&gt;&lt;/B&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="FONT-SIZE: 8pt; COLOR: #1f497d; FONT-FAMILY: 'Lucida Console'"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: #1f497d; FONT-FAMILY: 'Tahoma','sans-serif'"&gt;There are 7 instructions and 4 memory accesses per loop iteration, with no range checks remaining inside the loop body after optimization.&amp;nbsp; In this case there is no performance cost incurred for safety.&amp;nbsp; &lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;H1 style="MARGIN: 24pt 0in 0pt"&gt;&lt;SPAN style="mso-fareast-font-family: 'Times New Roman'"&gt;&lt;FONT size=5&gt;&lt;FONT color=#365f91&gt;&lt;FONT face=Cambria&gt;Unsafe Loop:&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/H1&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: #1f497d; FONT-FAMILY: 'Tahoma','sans-serif'"&gt;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: #1f497d; FONT-FAMILY: 'Tahoma','sans-serif'"&gt;By contrast, the &lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: #1f497d; FONT-FAMILY: 'Tahoma','sans-serif'; mso-themecolor: dark2"&gt;u&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: #1f497d; FONT-FAMILY: 'Tahoma','sans-serif'"&gt;nsafe version is a mess.&amp;nbsp; UnsafeAccess is larger MSIL (50 bytes vs 31) because Unsafe array accesses require more MSIL instructions than safe ones.&amp;nbsp; Given an array and index on the evaluation stack, safe array accesses require only a single 1-byte instruction: ldelem.&amp;nbsp; The C# compiler generates a much more complex sequence for Unsafe accesses:&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: #1f497d; FONT-FAMILY: 'Tahoma','sans-serif'"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Lucida Console'"&gt;&amp;nbsp; IL_000c:&amp;nbsp; /* 06&amp;nbsp;&amp;nbsp; |&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; */ ldloc.0 // &amp;amp;array[0]&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Lucida Console'"&gt;&amp;nbsp; IL_000d:&amp;nbsp; /* D3&amp;nbsp;&amp;nbsp; |&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; */ conv.i&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Lucida Console'"&gt;&amp;nbsp; IL_000e:&amp;nbsp; /* 02&amp;nbsp;&amp;nbsp; |&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; */ ldarg.0 // index&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Lucida Console'"&gt;&amp;nbsp; IL_000f:&amp;nbsp; /* D3&amp;nbsp;&amp;nbsp; |&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;*/ conv.i&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Lucida Console'"&gt;&amp;nbsp; IL_0010:&amp;nbsp; /* 1A&amp;nbsp;&amp;nbsp; |&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; */ ldc.i4.4&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Lucida Console'"&gt;&amp;nbsp; IL_0011:&amp;nbsp; /* 5A&amp;nbsp;&amp;nbsp; |&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; */ mul&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Lucida Console'"&gt;&amp;nbsp; IL_0012:&amp;nbsp; /* 58&amp;nbsp;&amp;nbsp; |&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; */ add&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Lucida Console'"&gt;&amp;nbsp; IL_0013:&amp;nbsp; /* 4A&amp;nbsp;&amp;nbsp; |&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; */ ldind.i4&lt;B&gt;&lt;SPAN style="COLOR: #1f497d"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/B&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;B&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: #1f497d; FONT-FAMILY: 'Tahoma','sans-serif'"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/B&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: #1f497d; FONT-FAMILY: 'Tahoma','sans-serif'"&gt;Ignoring the first and third instructions&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: #1f497d; FONT-FAMILY: 'Tahoma','sans-serif'; mso-themecolor: dark2"&gt;,&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: #1f497d; FONT-FAMILY: 'Tahoma','sans-serif'"&gt; which are used to get the array and index, there are six instructions (and bytes) required to load an array element.&amp;nbsp; These extra instructions make UnsafeAccess larger than SafeAccess&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: #1f497d; FONT-FAMILY: 'Tahoma','sans-serif'; mso-themecolor: dark2"&gt;.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;When determining which methods should be inlined by the JIT, one of the most highly weighted factors is the size of the inlinee method.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: #1f497d; FONT-FAMILY: 'Tahoma','sans-serif'"&gt;In this case UnsafeAccess was rejected for inlining, and because of this, the range check at &amp;amp;intarray[0] could not be removed.&amp;nbsp; In fact the unsafe loop variant actually caused more runtime range checks to occur than the safe variant! &lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: #1f497d; FONT-FAMILY: 'Tahoma','sans-serif'"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: #1f497d; FONT-FAMILY: 'Tahoma','sans-serif'"&gt;Finally, the presence of a pinned variable inhibits &lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: #1f497d; FONT-FAMILY: 'Tahoma','sans-serif'; mso-themecolor: dark2"&gt;many&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: #1f497d; FONT-FAMILY: 'Tahoma','sans-serif'"&gt; optimizations in the 64-bit JIT.&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: #1f497d; FONT-FAMILY: 'Tahoma','sans-serif'; mso-themecolor: dark2"&gt;As a result, the generated code for &lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: #1f497d; FONT-FAMILY: 'Tahoma','sans-serif'"&gt;UnsafeAccess is far worse than &lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: #1f497d; FONT-FAMILY: 'Tahoma','sans-serif'; mso-themecolor: dark2"&gt;that of &lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: #1f497d; FONT-FAMILY: 'Tahoma','sans-serif'"&gt;the safe variant&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: #1f497d; FONT-FAMILY: 'Tahoma','sans-serif'; mso-themecolor: dark2"&gt;.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: #1f497d; FONT-FAMILY: 'Tahoma','sans-serif'"&gt;Keep in mind that the following &lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: #1f497d; FONT-FAMILY: 'Tahoma','sans-serif'; mso-themecolor: dark2"&gt;excerpt shows only the UnsafeAccess method itself, and does not even include the &lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: #1f497d; FONT-FAMILY: 'Tahoma','sans-serif'"&gt;the loop in Main&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: #1f497d; FONT-FAMILY: 'Tahoma','sans-serif'; mso-themecolor: dark2"&gt;, as the SafeAccess example above does.&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: #1f497d; FONT-FAMILY: 'Tahoma','sans-serif'"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: #1f497d; FONT-FAMILY: 'Tahoma','sans-serif'"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="FONT-SIZE: 8pt; COLOR: #1f497d; FONT-FAMILY: 'Lucida Console'"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;B&gt;&lt;SPAN style="FONT-SIZE: 8pt; COLOR: #1f497d; FONT-FAMILY: 'Lucida Console'"&gt;image00000000_00e40000!Arrays.UnsafeAccess(Int32, Int32): &lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/B&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="FONT-SIZE: 8pt; COLOR: #1f497d; FONT-FAMILY: 'Lucida Console'"&gt;00000642`80150260 4883ec38&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; sub&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; rsp,38h&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="FONT-SIZE: 8pt; COLOR: #1f497d; FONT-FAMILY: 'Lucida Console'"&gt;00000642`80150264 448bc1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; mov&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; r8d,ecx&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="FONT-SIZE: 8pt; COLOR: #1f497d; FONT-FAMILY: 'Lucida Console'"&gt;00000642`80150267 48c744242000000000 mov&amp;nbsp;&amp;nbsp; qword ptr [rsp+20h],0&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="FONT-SIZE: 8pt; COLOR: #1f497d; FONT-FAMILY: 'Lucida Console'"&gt;00000642`80150270 48b9102e352000000000 mov rcx,20352E10h&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="FONT-SIZE: 8pt; COLOR: #1f497d; FONT-FAMILY: 'Lucida Console'"&gt;00000642`8015027a 488b09&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; mov&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; rcx,qword ptr [rcx]&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="FONT-SIZE: 8pt; COLOR: #1f497d; FONT-FAMILY: 'Lucida Console'"&gt;00000642`8015027d 488b4108&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; mov&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; rax,qword ptr [rcx+8]&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="FONT-SIZE: 8pt; COLOR: #1f497d; FONT-FAMILY: 'Lucida Console'"&gt;00000642`80150281 4885c0&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; test&amp;nbsp;&amp;nbsp;&amp;nbsp; rax,rax&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="FONT-SIZE: 8pt; COLOR: #1f497d; FONT-FAMILY: 'Lucida Console'"&gt;00000642`80150284 7641&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; jbe&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 00000642`801502c7&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="FONT-SIZE: 8pt; COLOR: #1f497d; FONT-FAMILY: 'Lucida Console'"&gt;00000642`80150286 488d4110&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; lea&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; rax,[rcx+10h]&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="FONT-SIZE: 8pt; COLOR: #1f497d; FONT-FAMILY: 'Lucida Console'"&gt;00000642`8015028a 4889442420&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; mov&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; qword ptr [rsp+20h],rax&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="FONT-SIZE: 8pt; COLOR: #1f497d; FONT-FAMILY: 'Lucida Console'"&gt;00000642`8015028f 4d63c8&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; movsxd&amp;nbsp; r9,r8d&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="FONT-SIZE: 8pt; COLOR: #1f497d; FONT-FAMILY: 'Lucida Console'"&gt;00000642`80150292 488b442420&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; mov&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;rax,qword ptr [rsp+20h]&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="FONT-SIZE: 8pt; COLOR: #1f497d; FONT-FAMILY: 'Lucida Console'"&gt;00000642`80150297 468b0488&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; mov&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; r8d,dword ptr [rax+r9*4]&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="FONT-SIZE: 8pt; COLOR: #1f497d; FONT-FAMILY: 'Lucida Console'"&gt;00000642`8015029b 4863d2&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; movsxd&amp;nbsp; rdx,edx&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="FONT-SIZE: 8pt; COLOR: #1f497d; FONT-FAMILY: 'Lucida Console'"&gt;00000642`8015029e 488b442420&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; mov&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; rax,qword ptr [rsp+20h]&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="FONT-SIZE: 8pt; COLOR: #1f497d; FONT-FAMILY: 'Lucida Console'"&gt;00000642`801502a3 8b0c90&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; mov&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ecx,dword ptr [rax+rdx*4]&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="FONT-SIZE: 8pt; COLOR: #1f497d; FONT-FAMILY: 'Lucida Console'"&gt;00000642`801502a6 488b442420&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; mov&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; rax,qword ptr [rsp+20h]&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="FONT-SIZE: 8pt; COLOR: #1f497d; FONT-FAMILY: 'Lucida Console'"&gt;00000642`801502ab 42890c88&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; mov&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; dword ptr [rax+r9*4],ecx&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="FONT-SIZE: 8pt; COLOR: #1f497d; FONT-FAMILY: 'Lucida Console'"&gt;00000642`801502af 488b442420&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; mov&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; rax,qword ptr [rsp+20h]&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="FONT-SIZE: 8pt; COLOR: #1f497d; FONT-FAMILY: 'Lucida Console'"&gt;00000642`801502b4 44890490&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; mov&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; dword ptr [rax+rdx*4],r8d&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="FONT-SIZE: 8pt; COLOR: #1f497d; FONT-FAMILY: 'Lucida Console'"&gt;00000642`801502b8 48c744242000000000 mov&amp;nbsp;&amp;nbsp; qword ptr [rsp+20h],0&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="FONT-SIZE: 8pt; COLOR: #1f497d; FONT-FAMILY: 'Lucida Console'"&gt;00000642`801502c1 4883c438&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; add&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; rsp,38h&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="FONT-SIZE: 8pt; COLOR: #1f497d; FONT-FAMILY: 'Lucida Console'"&gt;00000642`801502c5 f3c3&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; rep ret&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="FONT-SIZE: 8pt; COLOR: #1f497d; FONT-FAMILY: 'Lucida Console'"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;H1 style="MARGIN: 24pt 0in 0pt"&gt;&lt;SPAN style="mso-fareast-font-family: 'Times New Roman'"&gt;&lt;FONT size=5&gt;&lt;FONT color=#365f91&gt;&lt;FONT face=Cambria&gt;Conclusion:&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/H1&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;Unsafe array accesses have a lot of potential problems: correctness, GC heap fragmentation due to pinning, and as we have just seen, performance.&amp;nbsp; I hope that this example will help developers understand that safety does not necessarily incur a runtime cost.&amp;nbsp; Before attempting to evade a ‘safety tax’ it is a good idea to check if you are currently paying one. The first step in doing that is viewing disassembly of the optimized code&lt;SPAN style="mso-bidi-font-family: 'Times New Roman'; mso-bidi-theme-font: minor-bidi; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-ascii-font-family: Calibri; mso-hansi-font-family: Calibri"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="COLOR: #1f497d; mso-bidi-font-family: 'Times New Roman'; mso-bidi-theme-font: minor-bidi; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-themecolor: dark2; mso-ascii-font-family: Calibri; mso-hansi-font-family: Calibri"&gt;&lt;o:p&gt;&lt;FONT face=Calibri size=3&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="COLOR: #1f497d; mso-bidi-font-family: 'Times New Roman'; mso-bidi-theme-font: minor-bidi; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-themecolor: dark2; mso-ascii-font-family: Calibri; mso-hansi-font-family: Calibri"&gt;&lt;o:p&gt;&lt;FONT face=Calibri size=3&gt;-Matt Grice&lt;/FONT&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="COLOR: #1f497d; mso-bidi-font-family: 'Times New Roman'; mso-bidi-theme-font: minor-bidi; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-themecolor: dark2; mso-ascii-font-family: Calibri; mso-hansi-font-family: Calibri"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&amp;nbsp;&lt;/P&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=7548251" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/b/clrcodegeneration/archive/tags/arrays/">arrays</category><category domain="http://blogs.msdn.com/b/clrcodegeneration/archive/tags/JIT/">JIT</category><category domain="http://blogs.msdn.com/b/clrcodegeneration/archive/tags/unsafe/">unsafe</category><category domain="http://blogs.msdn.com/b/clrcodegeneration/archive/tags/performance/">performance</category><category domain="http://blogs.msdn.com/b/clrcodegeneration/archive/tags/x64/">x64</category></item><item><title>How are value types implemented in the 32-bit CLR? What has been done to improve their performance?</title><link>http://blogs.msdn.com/b/clrcodegeneration/archive/2007/11/02/how-are-value-types-implemented-in-the-32-bit-clr-what-has-been-done-to-improve-their-performance.aspx</link><pubDate>Fri, 02 Nov 2007 23:24:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:5843972</guid><dc:creator>CLR Codegen Blogger</dc:creator><slash:comments>15</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.msdn.com/b/clrcodegeneration/rsscomments.aspx?WeblogPostID=5843972</wfw:commentRss><comments>http://blogs.msdn.com/b/clrcodegeneration/archive/2007/11/02/how-are-value-types-implemented-in-the-32-bit-clr-what-has-been-done-to-improve-their-performance.aspx#comments</comments><description>&lt;P class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;&lt;B style="mso-bidi-font-weight: normal"&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;By Fei Chen&lt;?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/B&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;&lt;B style="mso-bidi-font-weight: normal"&gt;&lt;SPAN style="FONT-SIZE: 14pt; LINE-HEIGHT: 115%"&gt;&lt;FONT face=Calibri&gt;How are value types implemented in the 32-bit CLR?&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/B&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;&lt;FONT face=Calibri size=3&gt;Value types are the closest thing in the common language runtime model to C++ structures. An instance of a value type is simply a blob of data in memory that contains all the fields in the instance. The main difference between an instance of a value type and an instance of a reference type is that the former does not contain the type ID in its blob (see the example below), because the type information for value types is only needed at compile time. &lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 10pt 13.5pt"&gt;&lt;FONT face=Calibri size=3&gt;struct PointStruct()&amp;nbsp; { int x; int y; }&amp;nbsp; // The memory needed for the instance of this value type is 8 bytes, with 4 bytes for each integer field.&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 10pt 13.5pt"&gt;&lt;FONT face=Calibri size=3&gt;class PointClass()&amp;nbsp; { int x; int y; }&amp;nbsp; // The memory need for the instance of this reference type is 12 bytes, with the first 4 bytes containing the type ID, followed by 4 bytes for each integer field.&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;&lt;FONT face=Calibri size=3&gt;Being a contiguous blob of data in memory, value type instances are referenced internally in the CLR using the pointer to the beginning of the blob of memory.&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;&lt;FONT face=Calibri size=3&gt;A value type instance can live in one of two different places – a value type local variable, or a value type field in a reference type&lt;/FONT&gt;&lt;A class="" title=_ftnref1 style="mso-footnote-id: ftn1" href="http://blogs.msdn.com/tiny_mce/jscripts/tiny_mce/blank.htm#_ftn1" name=_ftnref1 mce_href="http://blogs.msdn.com/tiny_mce/jscripts/tiny_mce/blank.htm#_ftn1"&gt;&lt;SPAN class=MsoFootnoteReference&gt;&lt;FONT face=Calibri size=3&gt;[1]&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/A&gt;&lt;FONT face=Calibri size=3&gt;. When a value type local variable is declared, the prolog of the jitted code reserves a piece of stack memory&lt;/FONT&gt;&lt;A class="" title=_ftnref2 style="mso-footnote-id: ftn2" href="http://blogs.msdn.com/tiny_mce/jscripts/tiny_mce/blank.htm#_ftn2" name=_ftnref2 mce_href="http://blogs.msdn.com/tiny_mce/jscripts/tiny_mce/blank.htm#_ftn2"&gt;&lt;SPAN class=MsoFootnoteReference&gt;&lt;FONT face=Calibri size=3&gt;[2]&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/A&gt;&lt;FONT face=Calibri size=3&gt; (large enough to hold the instance of this value type), and the pointer to this stack location is used in all the places in the jitted code where this local variable is referenced. In the case of a value type field embedded in a reference type, the memory on the heap for this object contains the memory needed for its value type field. See this example:&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 10pt 13.5pt"&gt;&lt;FONT face=Calibri size=3&gt;class PointWithColorClass()&amp;nbsp; { int&amp;nbsp; color; PointStruct point; }&amp;nbsp; &lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;&lt;FONT face=Calibri size=3&gt;The size of the above object is 16 bytes. The first 4 bytes is the type ID; the next 4 bytes is the &lt;I&gt;color&lt;/I&gt; field; and the last 8 bytes is for the &lt;I&gt;point&lt;/I&gt; value type field.&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;&lt;FONT face=Calibri size=3&gt;The pointer to the beginning of &lt;I&gt;point &lt;/I&gt;field is used in all the places in the jitted code where this field is referenced. (Note that this time the pointer points to a location on the heap, instead of the stack.)&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;&lt;FONT face=Calibri size=3&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;&lt;B style="mso-bidi-font-weight: normal"&gt;&lt;SPAN style="FONT-SIZE: 14pt; LINE-HEIGHT: 115%"&gt;&lt;FONT face=Calibri&gt;Common operations on value types&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/B&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;&lt;FONT face=Calibri size=3&gt;There are only a few common operations on value types. Here is how they are implemented internally.&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoListParagraph style="MARGIN: 0in 0in 10pt 0.5in; TEXT-INDENT: -0.25in; mso-list: l2 level1 lfo1"&gt;&lt;SPAN style="FONT-FAMILY: Symbol; mso-fareast-font-family: Symbol; mso-bidi-font-family: Symbol"&gt;&lt;SPAN style="mso-list: Ignore"&gt;&lt;FONT size=3&gt;·&lt;/FONT&gt;&lt;SPAN style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;FONT face=Calibri size=3&gt;Field access&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoListParagraphCxSpMiddle style="MARGIN: 0in 0in 0pt 0.5in"&gt;&lt;FONT face=Calibri size=3&gt;Given that a value type instance is referenced by the pointer to the beginning of its blob, accessing its fields is nothing more than adjusting this pointer with the corresponding field offset. In other word, if a value type local variable &lt;I&gt;p&lt;/I&gt; of type PointStruct lives at [EBP-8], then a “mov eax, [EBP-8]” instruction reads the field &lt;I&gt;x&lt;/I&gt; and a “mov [EBP-4], eax” instruction writes the field &lt;I&gt;y&lt;/I&gt;.&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoListParagraphCxSpMiddle style="MARGIN: 0in 0in 0pt 0.5in"&gt;&lt;o:p&gt;&lt;FONT face=Calibri size=3&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/P&gt;
&lt;P class=MsoListParagraph style="MARGIN: 0in 0in 10pt 0.5in; TEXT-INDENT: -0.25in; mso-list: l2 level1 lfo1"&gt;&lt;SPAN style="FONT-FAMILY: Symbol; mso-fareast-font-family: Symbol; mso-bidi-font-family: Symbol"&gt;&lt;SPAN style="mso-list: Ignore"&gt;&lt;FONT size=3&gt;·&lt;/FONT&gt;&lt;SPAN style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;FONT face=Calibri size=3&gt;Initialization&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoListParagraphCxSpMiddle style="MARGIN: 0in 0in 0pt 0.5in"&gt;&lt;FONT face=Calibri size=3&gt;Zero initialization of a value type instance is done by calling memset on this piece of memory with 0s.&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoListParagraphCxSpMiddle style="MARGIN: 0in 0in 0pt 0.5in"&gt;&lt;o:p&gt;&lt;FONT face=Calibri size=3&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/P&gt;
&lt;P class=MsoListParagraph style="MARGIN: 0in 0in 10pt 0.5in; TEXT-INDENT: -0.25in; mso-list: l2 level1 lfo1"&gt;&lt;SPAN style="FONT-FAMILY: Symbol; mso-fareast-font-family: Symbol; mso-bidi-font-family: Symbol"&gt;&lt;SPAN style="mso-list: Ignore"&gt;&lt;FONT size=3&gt;·&lt;/FONT&gt;&lt;SPAN style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;FONT face=Calibri size=3&gt;Assignment&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoListParagraphCxSpMiddle style="MARGIN: 0in 0in 0pt 0.5in"&gt;&lt;FONT face=Calibri size=3&gt;Assignment from an instance of a value type to another is done by calling memcpy between these two pieces of memory.&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoListParagraphCxSpMiddle style="MARGIN: 0in 0in 0pt 0.5in"&gt;&lt;o:p&gt;&lt;FONT face=Calibri size=3&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/P&gt;
&lt;P class=MsoListParagraph style="MARGIN: 0in 0in 10pt 0.5in; TEXT-INDENT: -0.25in; mso-list: l2 level1 lfo1"&gt;&lt;SPAN style="FONT-FAMILY: Symbol; mso-fareast-font-family: Symbol; mso-bidi-font-family: Symbol"&gt;&lt;SPAN style="mso-list: Ignore"&gt;&lt;FONT size=3&gt;·&lt;/FONT&gt;&lt;SPAN style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;FONT face=Calibri size=3&gt;Calling the instance method&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoListParagraphCxSpMiddle style="MARGIN: 0in 0in 0pt 0.5in"&gt;&lt;FONT face=Calibri size=3&gt;CLR supports calling instance methods on value types. This is internally done by passing the pointer to the instance as a first parameter to the target method. This should sound similar to people who are familiar with C++ instance method calls, where the “this” pointer is passed as the first parameter.&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoListParagraphCxSpMiddle style="MARGIN: 0in 0in 0pt 0.5in"&gt;&lt;FONT face=Calibri size=3&gt;Since JIT owns the code generation for both the caller and the callee methods, it knows how to generate correct code for the value type instance method. In other words, it expects the first parameter to be the pointer to the blob of the value type instance.&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoListParagraphCxSpMiddle style="MARGIN: 0in 0in 0pt 0.5in"&gt;&lt;o:p&gt;&lt;FONT face=Calibri size=3&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/P&gt;
&lt;P class=MsoListParagraph style="MARGIN: 0in 0in 10pt 0.5in; TEXT-INDENT: -0.25in; mso-list: l2 level1 lfo1"&gt;&lt;SPAN style="FONT-FAMILY: Symbol; mso-fareast-font-family: Symbol; mso-bidi-font-family: Symbol"&gt;&lt;SPAN style="mso-list: Ignore"&gt;&lt;FONT size=3&gt;·&lt;/FONT&gt;&lt;SPAN style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;FONT face=Calibri size=3&gt;Passing as an argument by-value&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoListParagraphCxSpMiddle style="MARGIN: 0in 0in 0pt 0.5in"&gt;&lt;FONT face=Calibri size=3&gt;Passing a value type instance as a by-value argument requires making a stack copy and then passing the pointer to this copy to the target method. Consider what needs to be done at the call site of Foo() in the following example:&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoListParagraphCxSpMiddle style="MARGIN: 0in 0in 0pt 0.75in; mso-add-space: auto"&gt;&lt;FONT face=Calibri size=3&gt;static void Foo(int i, string s, PointStruct pointArg) { … }&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoListParagraphCxSpMiddle style="MARGIN: 0in 0in 0pt 0.75in; mso-add-space: auto"&gt;&lt;FONT face=Calibri size=3&gt;static void Main() { PointStruct point; Foo(1, “one”, point); } &lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoListParagraphCxSpMiddle style="MARGIN: 0in 0in 0pt 0.5in"&gt;&lt;FONT face=Calibri size=3&gt;What happens at the call site can be described using the following pseudo code in C++ syntax:&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoListParagraphCxSpMiddle style="MARGIN: 0in 0in 0pt 0.75in; mso-add-space: auto"&gt;&lt;FONT face=Calibri size=3&gt;PointStruct stackCopyOfPoint; // This is a stack local variable.&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoListParagraphCxSpMiddle style="MARGIN: 0in 0in 0pt 0.75in; mso-add-space: auto"&gt;&lt;FONT face=Calibri size=3&gt;stackCopyOfPoint = point;&amp;nbsp; // (or think of it this way) memcpy(&amp;amp;stackCopyOfPoint, &amp;amp;point, 8);&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoListParagraphCxSpMiddle style="MARGIN: 0in 0in 0pt 0.75in; mso-add-space: auto"&gt;&lt;FONT face=Calibri size=3&gt;Foo(1, “one”, &amp;amp;stackCopyOfPoint);&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoListParagraphCxSpMiddle style="MARGIN: 0in 0in 0pt 0.5in"&gt;&lt;FONT face=Calibri size=3&gt;The stack copy is necessary for maintaining the by-value semantics so the callee only sees the copy and hence has no way to affect the original one.&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoListParagraphCxSpMiddle style="MARGIN: 0in 0in 0pt 0.5in"&gt;&lt;o:p&gt;&lt;FONT face=Calibri size=3&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/P&gt;
&lt;P class=MsoListParagraph style="MARGIN: 0in 0in 10pt 0.5in; TEXT-INDENT: -0.25in; mso-list: l2 level1 lfo1"&gt;&lt;SPAN style="FONT-FAMILY: Symbol; mso-fareast-font-family: Symbol; mso-bidi-font-family: Symbol"&gt;&lt;SPAN style="mso-list: Ignore"&gt;&lt;FONT size=3&gt;·&lt;/FONT&gt;&lt;SPAN style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;FONT face=Calibri size=3&gt;Passing as an argument by-reference &lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoListParagraphCxSpMiddle style="MARGIN: 0in 0in 0pt 0.5in"&gt;&lt;FONT face=Calibri size=3&gt;Passing a value type instance as a by-reference argument is easy. Just pass the pointer. Now the callee and the caller see the same instance. So any change done inside the callee will affect the caller.&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoListParagraphCxSpMiddle style="MARGIN: 0in 0in 0pt 0.5in"&gt;&lt;o:p&gt;&lt;FONT face=Calibri size=3&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/P&gt;
&lt;P class=MsoListParagraph style="MARGIN: 0in 0in 10pt 0.5in; TEXT-INDENT: -0.25in; mso-list: l2 level1 lfo1"&gt;&lt;SPAN style="FONT-FAMILY: Symbol; mso-fareast-font-family: Symbol; mso-bidi-font-family: Symbol"&gt;&lt;SPAN style="mso-list: Ignore"&gt;&lt;FONT size=3&gt;·&lt;/FONT&gt;&lt;SPAN style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;FONT face=Calibri size=3&gt;Returning a value type&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoListParagraphCxSpMiddle style="MARGIN: 0in 0in 0pt 0.5in"&gt;&lt;FONT face=Calibri size=3&gt;Returning a value type requires the caller to provide the storage. The pointer of the return storage buffer is then passed in as a hidden parameter to the callee. The callee is responsible of filling in this buffer. Consider this example,&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoListParagraphCxSpMiddle style="MARGIN: 0in 0in 0pt 0.75in; mso-add-space: auto"&gt;&lt;FONT face=Calibri size=3&gt;static PointStruct Bar() { … }&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoListParagraphCxSpMiddle style="MARGIN: 0in 0in 0pt 0.75in; mso-add-space: auto"&gt;&lt;FONT face=Calibri size=3&gt;static void Main() { Bar(); } &lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoListParagraphCxSpMiddle style="MARGIN: 0in 0in 0pt 0.5in"&gt;&lt;FONT face=Calibri size=3&gt;What actually happens at the call site can be described using the following pseudo code:&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoListParagraphCxSpMiddle style="MARGIN: 0in 0in 0pt 0.75in; mso-add-space: auto"&gt;&lt;FONT face=Calibri size=3&gt;PointStruct tempPoint; // A temporary stack local created to hold the return value.&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoListParagraphCxSpMiddle style="MARGIN: 0in 0in 0pt 0.75in; mso-add-space: auto"&gt;&lt;FONT face=Calibri size=3&gt;Bar(&amp;amp;tempPoint);&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoListParagraphCxSpMiddle style="MARGIN: 0in 0in 0pt 0.75in; mso-add-space: auto"&gt;&lt;o:p&gt;&lt;FONT face=Calibri size=3&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/P&gt;
&lt;P class=MsoListParagraphCxSpMiddle style="MARGIN: 0in 0in 0pt 0.5in"&gt;&lt;FONT face=Calibri size=3&gt;In the case of an embedded value type field, consider this example:&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoListParagraphCxSpMiddle style="MARGIN: 0in 0in 0pt 0.75in; mso-add-space: auto"&gt;&lt;FONT face=Calibri size=3&gt;static PointStruct Bar() { … }&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoListParagraphCxSpMiddle style="MARGIN: 0in 0in 0pt 0.75in; mso-add-space: auto"&gt;&lt;FONT face=Calibri size=3&gt;static void Main() { PointWithColorClass obj; obj.point = Bar(); } &lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoListParagraphCxSpMiddle style="MARGIN: 0in 0in 0pt 0.5in"&gt;&lt;FONT face=Calibri size=3&gt;What actually happens at the call site is:&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoListParagraphCxSpLast style="MARGIN: 0in 0in 10pt 0.75in; mso-add-space: auto"&gt;&lt;FONT face=Calibri size=3&gt;Bar(&amp;amp;(obj.point));&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;&lt;B style="mso-bidi-font-weight: normal"&gt;&lt;SPAN style="FONT-SIZE: 14pt; LINE-HEIGHT: 115%"&gt;&lt;FONT face=Calibri&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/B&gt;&amp;nbsp;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;&lt;B style="mso-bidi-font-weight: normal"&gt;&lt;SPAN style="FONT-SIZE: 14pt; LINE-HEIGHT: 115%"&gt;&lt;FONT face=Calibri&gt;Inefficiencies in the code generation with regards to value types in .NET 2.0&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/B&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;&lt;FONT face=Calibri size=3&gt;Code generation for value types in .NET 2.0 has several inefficiencies. &lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoListParagraph style="MARGIN: 0in 0in 10pt 0.5in; TEXT-INDENT: -0.25in; mso-list: l1 level1 lfo2"&gt;&lt;SPAN style="mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin"&gt;&lt;SPAN style="mso-list: Ignore"&gt;&lt;FONT face=Calibri size=3&gt;1)&lt;/FONT&gt;&lt;SPAN style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;FONT face=Calibri size=3&gt;All value type local variables live entirely on the stack.&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoListParagraph style="MARGIN: 0in 0in 10pt 0.5in; TEXT-INDENT: -0.25in; mso-list: l1 level1 lfo2"&gt;&lt;SPAN style="mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin"&gt;&lt;SPAN style="mso-list: Ignore"&gt;&lt;FONT face=Calibri size=3&gt;2)&lt;/FONT&gt;&lt;SPAN style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;FONT face=Calibri size=3&gt;No assertion propagation optimization is ever performed on value type local variables.&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoListParagraph style="MARGIN: 0in 0in 10pt 0.5in; TEXT-INDENT: -0.25in; mso-list: l1 level1 lfo2"&gt;&lt;SPAN style="mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin"&gt;&lt;SPAN style="mso-list: Ignore"&gt;&lt;FONT face=Calibri size=3&gt;3)&lt;/FONT&gt;&lt;SPAN style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;FONT face=Calibri size=3&gt;Methods with value type arguments, local variables, or return values are never inlined.&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;&lt;FONT face=Calibri size=3&gt;While the original intent of supporting value types in the CLR was to provide a means for creating “lightweight” objects, the actual inefficiencies in the code generation make these “lightweight” objects not-so-light.&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;&lt;FONT face=Calibri size=3&gt;For bullet 1), the following code would mean 3 stack operations, one for each field access:&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 10pt 13.5pt"&gt;&lt;FONT face=Calibri size=3&gt;static void MyMethod1(int v) { &lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 10pt 0.5in"&gt;&lt;FONT face=Calibri size=3&gt;PointStruct point;&amp;nbsp; // point will get a stack location.&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 10pt 0.5in"&gt;&lt;FONT face=Calibri size=3&gt;point.x=v; point.y=v*2; &lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 10pt 0.5in"&gt;&lt;FONT face=Calibri size=3&gt;Console.WriteLine(point.x); // All 3 field accesses involve stack operations.&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 10pt 13.5pt"&gt;&lt;FONT face=Calibri size=3&gt;}&amp;nbsp; &lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;&lt;FONT face=Calibri size=3&gt;Wouldn’t it be nice if the jitted code stored both fields of &lt;I&gt;point&lt;/I&gt; into registers and avoided allocating stack space for this value type local variable altogether?&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;&lt;FONT face=Calibri size=3&gt;For bullet 2), the following code would mean 19 useless memcpy’s.&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 10pt 13.5pt"&gt;&lt;FONT face=Calibri size=3&gt;static void MyMethod2() { PointStruct point1, point2, …, point20;&amp;nbsp; point1.x = point1.y = 5;&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 10pt 31.5pt"&gt;&lt;FONT face=Calibri size=3&gt;point2 = point1; point3 = point2; …&amp;nbsp; point20 = point19; &lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 10pt 31.5pt"&gt;&lt;FONT face=Calibri size=3&gt;Console.WriteLine(point20.x + point20.y); }&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;&lt;FONT face=Calibri size=3&gt;Wouldn’t it be nice if the JIT could apply copy-propagation to these value type local variables and morph the above code to “Console.WriteLine(point1.x + point1.y)” instead?&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;&lt;FONT face=Calibri size=3&gt;For bullet 3), a simple field getter of a value type turns into an expensive method call: &lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 10pt 13.5pt"&gt;&lt;FONT face=Calibri size=3&gt;struct PointStruct()&amp;nbsp; { int x; int y; public int XProp { get { return x;} } } &lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 10pt 13.5pt"&gt;&lt;FONT face=Calibri size=3&gt;static void MyMethod3() { PointStruct point;&amp;nbsp; point.x = point.y = 5;&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 10pt 31.5pt"&gt;&lt;FONT face=Calibri size=3&gt;Console.WriteLine(point.XProp); } // point.XProp is a method call which is never inlined.&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;&lt;FONT face=Calibri size=3&gt;Currently the JIT does not perform any assertion propagation to local variables whose addresses have been taken. Common operations on value types, however, do involve taking their addresses.&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 10pt" mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;&lt;SPAN style="FONT-SIZE: 14pt; LINE-HEIGHT: 115%"&gt;&lt;FONT face=Calibri&gt;&lt;STRONG&gt;Improving value type code generation in CLR v.Next&lt;o:p&gt;&lt;/o:p&gt;&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;&lt;FONT face=Calibri size=3&gt;Improving code generation with regards to value types has always been a top customer ask according to MS Connect: &lt;/FONT&gt;&lt;A href="http://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=93858" mce_href="http://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=93858"&gt;&lt;FONT face=Calibri size=3&gt;http://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=93858&lt;/FONT&gt;&lt;/A&gt;&lt;FONT face=Calibri size=3&gt;.&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;&lt;FONT face=Calibri size=3&gt;Over the past year or so, the JIT team has been working on significant improvements to value type code generation, as well as the inlining algorithm. In summary, all of the above limitations are being eliminated. &lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;&lt;FONT face=Calibri size=3&gt;The new inliner will allow inlining methods with value type arguments, local variables or return value. This solves the issue in bullet 3).&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;&lt;FONT face=Calibri size=3&gt;An algorithm called “value type scalar replacement” has been implemented to address the issues in bullets 1) and 2).&amp;nbsp; This algorithm is based on the observation that a value type local variable logically can be viewed as a group of independent local scalars, each representing a field in this value type local variable, if&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoListParagraph style="MARGIN: 0in 0in 10pt 0.5in; TEXT-INDENT: -0.25in; mso-list: l3 level1 lfo3"&gt;&lt;SPAN style="mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin"&gt;&lt;SPAN style="mso-list: Ignore"&gt;&lt;FONT face=Calibri size=3&gt;a)&lt;/FONT&gt;&lt;SPAN style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;FONT face=Calibri size=3&gt;there is no operation in the current method that causes&amp;nbsp;any interaction between these fields; &lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 10pt 0.25in"&gt;&lt;FONT face=Calibri size=3&gt;and&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoListParagraph style="MARGIN: 0in 0in 10pt 0.5in; TEXT-INDENT: -0.25in; mso-list: l3 level1 lfo3"&gt;&lt;SPAN style="mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin"&gt;&lt;SPAN style="mso-list: Ignore"&gt;&lt;FONT face=Calibri size=3&gt;b)&lt;/FONT&gt;&lt;SPAN style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;FONT face=Calibri size=3&gt;The address of this value type local variable is never exposed outside of the current method. &lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;&lt;o:p&gt;&lt;FONT face=Calibri size=3&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;&lt;FONT face=Calibri size=3&gt;When the above conditions are met, the MyMethod1() listed above can be safely transformed to &lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 10pt 13.5pt"&gt;&lt;FONT face=Calibri size=3&gt;static void MyMethod1(int v) { &lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 10pt 0.5in"&gt;&lt;FONT face=Calibri size=3&gt;int x; int y;&amp;nbsp; // Was “PointStruct point;”. Now replaced by x and y.&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 10pt 0.5in"&gt;&lt;FONT face=Calibri size=3&gt;x=v; y=v*2; Console.WriteLine(x); &lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 10pt 13.5pt"&gt;&lt;FONT face=Calibri size=3&gt;}&amp;nbsp; &lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;&lt;FONT face=Calibri size=3&gt;by replacing the value type local variable &lt;I&gt;point&lt;/I&gt; with a group of independent integer local variables, namely x and y.&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;&lt;FONT face=Calibri size=3&gt;And the MyMethod2() listed above will be transformed to&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 10pt 13.5pt"&gt;&lt;FONT face=Calibri size=3&gt;static void MyMethod2() { int x1, y1, x2, y2, …, x20, y20;&amp;nbsp;&amp;nbsp; x1 = y1 = 5;&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 10pt 31.5pt"&gt;&lt;FONT face=Calibri size=3&gt;x2 = x1; y2 = y1; x3 = x2; y3 = y2; …&amp;nbsp; x20 = x19; y20 = y19; &lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 10pt 31.5pt"&gt;&lt;FONT face=Calibri size=3&gt;Console.WriteLine(x20 + y20); }&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;&lt;FONT face=Calibri size=3&gt;Furthermore, the assertion propagation algorithm and the constant folding algorithm will be applied to these scalars, since none of them have their address taken. As a result, the code will be reduced to:&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 10pt 13.5pt"&gt;&lt;FONT face=Calibri size=3&gt;static void MyMethod1(int v) { Console.WriteLine(v); }&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 10pt 13.5pt"&gt;&lt;FONT face=Calibri size=3&gt;static void MyMethod2() { Console.WriteLine(10); }&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;&lt;FONT face=Calibri size=3&gt;In addition, the register allocation algorithm will home the local variable &lt;I&gt;v&lt;/I&gt; into a machine register, so no stack operation will occur in MyMethod1().&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;&lt;FONT face=Calibri size=3&gt;Not all value type local variables can be replaced by scalars, however. Local variables with their address taken, and exposed outside of the current method, cannot be replaced. Consider this example where SomeBigMethod() is an instance method in PointStruct that is not inlined.&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 10pt 13.5pt"&gt;&lt;FONT face=Calibri size=3&gt;static void MyMethod4() { PointStruct point;&amp;nbsp; point.SomeBigMethod(); } &lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;&lt;FONT face=Calibri size=3&gt;The address of &lt;I&gt;point&lt;/I&gt; is taken and passed as the “this” pointer to SomeBigMethod(). What SomeBigMethod() does with this pointer is totally out of the control of MyMethod4(). In this case, &lt;I&gt;point&lt;/I&gt; is not replaced by scalars. Another way to expose the address of a value type local variable is to pass it as a by-reference argument to another method. Taking the address of a value type local variable and storing it in a static variable, or in an object, also exposes the address.&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;&lt;FONT face=Calibri size=3&gt;The JIT in CLR v.Next will be able to perform value type scalar replacement optimization on the following kinds of value types whenever it thinks it will be beneficial:&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoListParagraph style="MARGIN: 0in 0in 10pt 0.5in; TEXT-INDENT: -0.25in; mso-list: l0 level1 lfo4"&gt;&lt;SPAN style="mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin"&gt;&lt;SPAN style="mso-list: Ignore"&gt;&lt;FONT face=Calibri size=3&gt;1)&lt;/FONT&gt;&lt;SPAN style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;FONT face=Calibri size=3&gt;The value type contains no more than 4 fields.&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoListParagraph style="MARGIN: 0in 0in 10pt 0.5in; TEXT-INDENT: -0.25in; mso-list: l0 level1 lfo4"&gt;&lt;SPAN style="mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin"&gt;&lt;SPAN style="mso-list: Ignore"&gt;&lt;FONT face=Calibri size=3&gt;2)&lt;/FONT&gt;&lt;SPAN style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;FONT face=Calibri size=3&gt;The types of the fields in the value type are either primitive types or object references.&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoListParagraph style="MARGIN: 0in 0in 10pt 0.5in; TEXT-INDENT: -0.25in; mso-list: l0 level1 lfo4"&gt;&lt;SPAN style="mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin"&gt;&lt;SPAN style="mso-list: Ignore"&gt;&lt;FONT face=Calibri size=3&gt;3)&lt;/FONT&gt;&lt;SPAN style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;FONT face=Calibri size=3&gt;The value type must be using [StructLayout(LayoutKind.Sequential)], which is the default.&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;&lt;o:p&gt;&lt;FONT face=Calibri size=3&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;&lt;B style="mso-bidi-font-weight: normal"&gt;&lt;SPAN style="FONT-SIZE: 14pt; LINE-HEIGHT: 115%"&gt;&lt;FONT face=Calibri&gt;Guidelines for&lt;SPAN style="COLOR: #1f497d"&gt; &lt;/SPAN&gt;using value types in the CLR&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/B&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;&lt;FONT face=Calibri size=3&gt;The decision around whether to use value types, or not, should be based primarily on the semantics of the program. Value types should be used when the pass-by-value semantics are the most natural, and the most frequently used in the program.&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;&lt;FONT face=Calibri size=3&gt;After the decision has been made to use the value type, it is time to think about the performance implications, and to determine how to help the JIT generate the best possible code. Always keep in mind that the by-value nature of value types means that a lot of copy operations might be happening under the covers. Also, nearly every operation related to a value type will be a memory operation (either operated on the stack or on the heap) if this value type is not replaced by scalars.&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;&lt;FONT face=Calibri size=3&gt;Developers should examine the jitted code of their hot methods under the debugger to make sure the value type stack local variables are indeed homed in registers. &lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;&lt;FONT face=Calibri size=3&gt;Try not to create value types that contain more than 4 fields. Try not to create non-inlineable value type instance methods and call them in the hot path, because doing so will cause the address to be exposed. When a temporary value type instance is needed, try using value type local variables rather than the value type fields embedded in an object, because the latter are never replaced with scalars.&lt;/FONT&gt;&lt;/P&gt;
&lt;DIV style="mso-element: footnote-list"&gt;&lt;BR clear=all&gt;&lt;FONT face=Calibri size=3&gt;
&lt;HR align=left width="33%" SIZE=1&gt;
&lt;/FONT&gt;
&lt;DIV id=ftn1 style="mso-element: footnote"&gt;
&lt;P class=MsoFootnoteText style="MARGIN: 0in 0in 0pt"&gt;&lt;A class="" title=_ftn1 style="mso-footnote-id: ftn1" href="http://blogs.msdn.com/tiny_mce/jscripts/tiny_mce/blank.htm#_ftnref1" name=_ftn1 mce_href="http://blogs.msdn.com/tiny_mce/jscripts/tiny_mce/blank.htm#_ftnref1"&gt;&lt;SPAN class=MsoFootnoteReference&gt;&lt;FONT face=Calibri&gt;[1]&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/A&gt;&lt;FONT face=Calibri&gt; For simplicity, let us ignore the case where a value type field is embedded into another value type.&lt;/FONT&gt;&lt;/P&gt;&lt;/DIV&gt;
&lt;DIV id=ftn2 style="mso-element: footnote"&gt;
&lt;P class=MsoFootnoteText style="MARGIN: 0in 0in 0pt"&gt;&lt;A class="" title=_ftn2 style="mso-footnote-id: ftn2" href="http://blogs.msdn.com/tiny_mce/jscripts/tiny_mce/blank.htm#_ftnref2" name=_ftn2 mce_href="http://blogs.msdn.com/tiny_mce/jscripts/tiny_mce/blank.htm#_ftnref2"&gt;&lt;SPAN class=MsoFootnoteReference&gt;&lt;FONT face=Calibri&gt;[2]&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/A&gt;&lt;FONT face=Calibri&gt; This is not true with the value type scalar replacement optimization newly implemented in CLR v.Next, as described later in this document.&lt;/FONT&gt;&lt;/P&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=5843972" width="1" height="1"&gt;</description></item><item><title>How to see the Assembly code generated by the JIT using Visual Studio</title><link>http://blogs.msdn.com/b/clrcodegeneration/archive/2007/10/19/how-to-see-the-assembly-code-generated-by-the-jit-using-visual-studio.aspx</link><pubDate>Fri, 19 Oct 2007 23:46:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:5528731</guid><dc:creator>CLR Codegen Blogger</dc:creator><slash:comments>1</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.msdn.com/b/clrcodegeneration/rsscomments.aspx?WeblogPostID=5528731</wfw:commentRss><comments>http://blogs.msdn.com/b/clrcodegeneration/archive/2007/10/19/how-to-see-the-assembly-code-generated-by-the-jit-using-visual-studio.aspx#comments</comments><description>&lt;FONT face=Calibri&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal"&gt;&lt;B style="mso-bidi-font-weight: normal"&gt;&lt;SPAN style="FONT-SIZE: 14pt; FONT-FAMILY: 'Times New Roman','serif'; mso-fareast-font-family: 'Times New Roman'"&gt;by Brian Sullivan&lt;/SPAN&gt;&lt;/B&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal"&gt;&lt;B style="mso-bidi-font-weight: normal"&gt;&lt;SPAN style="FONT-SIZE: 14pt; FONT-FAMILY: 'Times New Roman','serif'; mso-fareast-font-family: 'Times New Roman'"&gt;&lt;?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/B&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal"&gt;&lt;B style="mso-bidi-font-weight: normal"&gt;&lt;SPAN style="FONT-SIZE: 14pt; FONT-FAMILY: 'Times New Roman','serif'; mso-fareast-font-family: 'Times New Roman'"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/B&gt;&amp;nbsp;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal"&gt;&lt;SPAN style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman','serif'; mso-fareast-font-family: 'Times New Roman'"&gt;In Visual Studio you can set a breakpoint at any line in your source code.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;When you run your program Visual Studio will break and stop execution when it reaches your breakpoint.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;At this point you can right click on your source code and select &lt;/SPAN&gt;&lt;A href="http://msdn2.microsoft.com/en-us/library/ms889167.aspx" mce_href="http://msdn2.microsoft.com/en-us/library/ms889167.aspx"&gt;&lt;B style="mso-bidi-font-weight: normal"&gt;&lt;SPAN style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman','serif'; mso-fareast-font-family: 'Times New Roman'"&gt;&lt;FONT color=#0000ff&gt;Go To Disassembly&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/B&gt;&lt;/A&gt;&lt;B style="mso-bidi-font-weight: normal"&gt;&lt;SPAN style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman','serif'; mso-fareast-font-family: 'Times New Roman'"&gt;.&lt;/SPAN&gt;&lt;/B&gt;&lt;SPAN style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman','serif'; mso-fareast-font-family: 'Times New Roman'"&gt; &lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;You will see the assembly language instructions that were created by the JIT compiler for this method.&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal"&gt;&lt;SPAN style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman','serif'; mso-fareast-font-family: 'Times New Roman'"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal"&gt;&lt;B style="mso-bidi-font-weight: normal"&gt;&lt;SPAN style="FONT-SIZE: 14pt; FONT-FAMILY: 'Times New Roman','serif'; mso-fareast-font-family: 'Times New Roman'"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/B&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal"&gt;&lt;B style="mso-bidi-font-weight: normal"&gt;&lt;SPAN style="FONT-SIZE: 14pt; FONT-FAMILY: 'Times New Roman','serif'; mso-fareast-font-family: 'Times New Roman'"&gt;The JIT compiler generates either Debug code or Optimized code&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/B&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal"&gt;&lt;B style="mso-bidi-font-weight: normal"&gt;&lt;SPAN style="FONT-SIZE: 14pt; FONT-FAMILY: 'Times New Roman','serif'; mso-fareast-font-family: 'Times New Roman'"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/B&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal"&gt;&lt;SPAN style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman','serif'; mso-fareast-font-family: 'Times New Roman'"&gt;If this is your first time looking at the JIT assembly code you undoubtedly are looking at the Debug code generated by the JIT compiler.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal"&gt;&lt;SPAN style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman','serif'; mso-fareast-font-family: 'Times New Roman'"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal"&gt;&lt;SPAN style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman','serif'; mso-fareast-font-family: 'Times New Roman'"&gt;This Debug code is not the high quality optimized code that the JIT compiler can generate.&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal"&gt;&lt;SPAN style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman','serif'; mso-fareast-font-family: 'Times New Roman'"&gt;Instead it is basic assembly code that does not have any optimizations applied to it.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;All local variables references are references into the local stack frame storage because in Debug code the JIT does not enregister any local variables. Another property of Debug code is that &lt;B style="mso-bidi-font-weight: normal"&gt;nop&lt;/B&gt; instructions are inserted before some source code statements.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal"&gt;&lt;SPAN style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman','serif'; mso-fareast-font-family: 'Times New Roman'"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal"&gt;&lt;SPAN style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman','serif'; mso-fareast-font-family: 'Times New Roman'"&gt;You probably don’t want to spend much time looking at the Debug JIT code.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;Instead you probably want to look at Optimized JIT code.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;By looking at Optimized JIT code you can confirm that the assembly code for your important methods are well optimized.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;And if they are not optimized as well as you want, you can experiment to see if making some source code changes can improve the Optimized JIT code.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal"&gt;&lt;SPAN style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman','serif'; mso-fareast-font-family: 'Times New Roman'"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal"&gt;&lt;SPAN style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman','serif'; mso-fareast-font-family: 'Times New Roman'"&gt;There are several settings that you will need to change in order for you to see the Optimized code generated by the JIT compiler.&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal"&gt;&lt;SPAN style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman','serif'; mso-fareast-font-family: 'Times New Roman'"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoListParagraph style="MARGIN: 0in 0in 0pt 0.5in; TEXT-INDENT: -0.25in; LINE-HEIGHT: normal; mso-add-space: auto; mso-list: l0 level1 lfo1"&gt;&lt;SPAN style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman','serif'; mso-fareast-font-family: 'Times New Roman'"&gt;&lt;SPAN style="mso-list: Ignore"&gt;1.&lt;SPAN style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman','serif'; mso-fareast-font-family: 'Times New Roman'"&gt;The default configuration is &lt;B style="mso-bidi-font-weight: normal"&gt;Debug&lt;/B&gt; and you want to select the &lt;/SPAN&gt;&lt;A href="http://msdn2.microsoft.com/en-us/library/wx0123s5(VS.80).aspx" mce_href="http://msdn2.microsoft.com/en-us/library/wx0123s5(VS.80).aspx"&gt;&lt;B style="mso-bidi-font-weight: normal"&gt;&lt;SPAN style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman','serif'; mso-fareast-font-family: 'Times New Roman'"&gt;Release&lt;/SPAN&gt;&lt;/B&gt;&lt;/A&gt;&lt;SPAN style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman','serif'; mso-fareast-font-family: 'Times New Roman'"&gt; configuration.&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal"&gt;&lt;SPAN style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman','serif'; mso-fareast-font-family: 'Times New Roman'"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoListParagraphCxSpFirst style="MARGIN: 0in 0in 0pt 74.25pt; TEXT-INDENT: -0.25in; LINE-HEIGHT: normal; mso-add-space: auto; mso-list: l1 level1 lfo2"&gt;&lt;SPAN style="FONT-SIZE: 12pt; FONT-FAMILY: Symbol; mso-fareast-font-family: Symbol; mso-bidi-font-family: Symbol"&gt;&lt;SPAN style="mso-list: Ignore"&gt;·&lt;SPAN style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman','serif'; mso-fareast-font-family: 'Times New Roman'"&gt;Select the &lt;B style="mso-bidi-font-weight: normal"&gt;Release&lt;/B&gt; configuration&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoListParagraphCxSpMiddle style="MARGIN: 0in 0in 0pt 0.5in; LINE-HEIGHT: normal; mso-add-space: auto"&gt;&lt;SPAN style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman','serif'; mso-fareast-font-family: 'Times New Roman'"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoListParagraphCxSpMiddle style="MARGIN: 0in 0in 0pt 0.5in; LINE-HEIGHT: normal; mso-add-space: auto"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Times New Roman','serif'; mso-fareast-font-family: 'Times New Roman'"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoListParagraphCxSpMiddle style="MARGIN: 0in 0in 0pt 0.5in; TEXT-INDENT: -0.25in; LINE-HEIGHT: normal; mso-add-space: auto; mso-list: l0 level1 lfo1"&gt;&lt;SPAN style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman','serif'; mso-fareast-font-family: 'Times New Roman'"&gt;&lt;SPAN style="mso-list: Ignore"&gt;2.&lt;SPAN style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman','serif'; mso-fareast-font-family: 'Times New Roman'"&gt;Make sure that PDB files get created for Release builds. &lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoListParagraphCxSpMiddle style="MARGIN: 0in 0in 0pt 0.5in; LINE-HEIGHT: normal; mso-add-space: auto"&gt;&lt;SPAN style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman','serif'; mso-fareast-font-family: 'Times New Roman'"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoListParagraphCxSpLast style="MARGIN: 0in 0in 0pt 74.25pt; TEXT-INDENT: -0.25in; LINE-HEIGHT: normal; mso-add-space: auto; mso-list: l1 level1 lfo2"&gt;&lt;SPAN style="FONT-SIZE: 12pt; FONT-FAMILY: Symbol; mso-fareast-font-family: Symbol; mso-bidi-font-family: Symbol"&gt;&lt;SPAN style="mso-list: Ignore"&gt;·&lt;SPAN style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman','serif'; mso-fareast-font-family: 'Times New Roman'"&gt;Set &lt;/SPAN&gt;&lt;B&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 'Verdana','sans-serif'"&gt;Generate debug info&lt;/SPAN&gt;&lt;/B&gt;&lt;SPAN style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman','serif'; mso-fareast-font-family: 'Times New Roman'"&gt; to&lt;/SPAN&gt;&lt;B&gt;&lt;SPAN style="FONT-SIZE: 8.5pt; COLOR: black; FONT-FAMILY: 'Verdana','sans-serif'"&gt; &lt;/SPAN&gt;&lt;/B&gt;&lt;A href="http://msdn2.microsoft.com/en-us/library/8tt43355(VS.80).aspx" mce_href="http://msdn2.microsoft.com/en-us/library/8tt43355(VS.80).aspx"&gt;&lt;SPAN style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman','serif'; mso-fareast-font-family: 'Times New Roman'"&gt;&lt;FONT color=#0000ff&gt;pdb-only&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/A&gt;&lt;SPAN style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman','serif'; mso-fareast-font-family: 'Times New Roman'"&gt;.&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal"&gt;&lt;SPAN style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman','serif'; mso-fareast-font-family: 'Times New Roman'"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; TEXT-INDENT: 0.5in; LINE-HEIGHT: normal"&gt;&lt;I style="mso-bidi-font-style: normal"&gt;&lt;SPAN style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman','serif'; mso-fareast-font-family: 'Times New Roman'"&gt;More information on why this is necessary:&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/I&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; TEXT-INDENT: 0.5in; LINE-HEIGHT: normal"&gt;&lt;SPAN style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman','serif'; mso-fareast-font-family: 'Times New Roman'"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoListParagraphCxSpFirst style="MARGIN: 0in 0in 0pt 0.5in; LINE-HEIGHT: normal; mso-add-space: auto"&gt;&lt;SPAN style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman','serif'; mso-fareast-font-family: 'Times New Roman'"&gt;Ideally you would have wanted it to be the case that simply changing the configuration in the Solution Configuration window to ‘Release’ would be sufficient.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;However by default the ‘Release’ builds do NOT build a program data base (PDB) file for your program.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;The (PDB) file is essential when using a debugger as it holds the mapping of the source code lines and local variables for your program.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoListParagraphCxSpLast style="MARGIN: 0in 0in 0pt 0.5in; LINE-HEIGHT: normal; mso-add-space: auto"&gt;&lt;SPAN style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman','serif'; mso-fareast-font-family: 'Times New Roman'"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.5in; LINE-HEIGHT: normal"&gt;&lt;SPAN style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman','serif'; mso-fareast-font-family: 'Times New Roman'"&gt;To fix this go to the properties for the project (right click on the project in the Solution Explorer), select the ‘Build’ tab and click the ‘Advanced’ button all the way at the bottom (you may need to scroll to see it).&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;In the dialog box that comes up there will be a line ‘Debug Info’.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;It should be set to ‘pdb-only’.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;This tells the compiler to still compile with optimizations, but to also create the pdb file.&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Times New Roman','serif'; mso-fareast-font-family: 'Times New Roman'"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.5in; LINE-HEIGHT: normal"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Times New Roman','serif'; mso-fareast-font-family: 'Times New Roman'"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoListParagraph style="MARGIN: 0in 0in 0pt 0.5in; TEXT-INDENT: -0.25in; LINE-HEIGHT: normal; mso-add-space: auto; mso-list: l0 level1 lfo1"&gt;&lt;SPAN style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman','serif'; mso-fareast-font-family: 'Times New Roman'"&gt;&lt;SPAN style="mso-list: Ignore"&gt;3.&lt;SPAN style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman','serif'; mso-fareast-font-family: 'Times New Roman'"&gt;Configure the Debugging Options in Visual Studio to allow the JIT to generate optimized code and to allow you to debug the optimized code.&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal"&gt;&lt;B style="mso-bidi-font-weight: normal"&gt;&lt;SPAN style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman','serif'; mso-fareast-font-family: 'Times New Roman'"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/B&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.5in; LINE-HEIGHT: normal"&gt;&lt;SPAN style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman','serif'; mso-fareast-font-family: 'Times New Roman'"&gt;Go to &lt;B style="mso-bidi-font-weight: normal"&gt;Tools&lt;/B&gt; &lt;B style="mso-bidi-font-weight: normal"&gt;=&amp;gt;&lt;/B&gt; &lt;B style="mso-bidi-font-weight: normal"&gt;Options&lt;/B&gt; =&amp;gt; &lt;B style="mso-bidi-font-weight: normal"&gt;Debugging&lt;/B&gt; =&amp;gt; &lt;B style="mso-bidi-font-weight: normal"&gt;General&lt;/B&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoListParagraphCxSpFirst style="MARGIN: 0in 0in 0pt 0.5in; LINE-HEIGHT: normal; mso-add-space: auto"&gt;&lt;SPAN style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman','serif'; mso-fareast-font-family: 'Times New Roman'"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoListParagraphCxSpMiddle style="MARGIN: 0in 0in 0pt 74.25pt; TEXT-INDENT: -0.25in; LINE-HEIGHT: normal; mso-add-space: auto; mso-list: l1 level1 lfo2"&gt;&lt;SPAN style="FONT-SIZE: 12pt; FONT-FAMILY: Symbol; mso-fareast-font-family: Symbol; mso-bidi-font-family: Symbol"&gt;&lt;SPAN style="mso-list: Ignore"&gt;·&lt;SPAN style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman','serif'; mso-fareast-font-family: 'Times New Roman'"&gt;Make sure that box labeled ‘&lt;/SPAN&gt;&lt;A href="http://msdn2.microsoft.com/en-us/library/ms241594(vs.80).aspx" mce_href="http://msdn2.microsoft.com/en-us/library/ms241594(vs.80).aspx"&gt;&lt;SPAN style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman','serif'; mso-fareast-font-family: 'Times New Roman'"&gt;&lt;FONT color=#0000ff&gt;Suppress JIT optimization on module load&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/A&gt;&lt;SPAN style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman','serif'; mso-fareast-font-family: 'Times New Roman'"&gt;’ is Unchecked.&lt;B style="mso-bidi-font-weight: normal"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/B&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoListParagraphCxSpLast style="MARGIN: 0in 0in 0pt 74.25pt; TEXT-INDENT: -0.25in; LINE-HEIGHT: normal; mso-add-space: auto; mso-list: l1 level1 lfo2"&gt;&lt;SPAN style="FONT-SIZE: 12pt; FONT-FAMILY: Symbol; mso-fareast-font-family: Symbol; mso-bidi-font-family: Symbol"&gt;&lt;SPAN style="mso-list: Ignore"&gt;·&lt;SPAN style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman','serif'; mso-fareast-font-family: 'Times New Roman'"&gt;Make sure that the box labeled ‘&lt;/SPAN&gt;&lt;A href="http://msdn2.microsoft.com/en-us/library/h5e30exc(VS.80).aspx" mce_href="http://msdn2.microsoft.com/en-us/library/h5e30exc(VS.80).aspx"&gt;&lt;SPAN style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman','serif'; mso-fareast-font-family: 'Times New Roman'"&gt;&lt;FONT color=#0000ff&gt;Enable Just My Code&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/A&gt;&lt;SPAN style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman','serif'; mso-fareast-font-family: 'Times New Roman'"&gt;’ is Unchecked.&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal"&gt;&lt;SPAN style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman','serif'; mso-fareast-font-family: 'Times New Roman'"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal"&gt;&lt;SPAN style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman','serif'; mso-fareast-font-family: 'Times New Roman'"&gt;&lt;SPAN style="mso-tab-count: 1"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;I style="mso-bidi-font-style: normal"&gt;More information on why this is necessary:&lt;o:p&gt;&lt;/o:p&gt;&lt;/I&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal"&gt;&lt;SPAN style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman','serif'; mso-fareast-font-family: 'Times New Roman'"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.5in; LINE-HEIGHT: normal"&gt;&lt;SPAN style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman','serif'; mso-fareast-font-family: 'Times New Roman'"&gt;The Visual Studio IDE makes debugging optimized code harder than you would like.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.5in; LINE-HEIGHT: normal"&gt;&lt;SPAN style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman','serif'; mso-fareast-font-family: 'Times New Roman'"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.5in; LINE-HEIGHT: normal"&gt;&lt;SPAN style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman','serif'; mso-fareast-font-family: 'Times New Roman'"&gt;Whenever you launch a managed program under Visual Studio using (Start-Debugging or F5), it will by default, force the JIT to create Debug code.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; This is true even when you have selected the 'Release' configuration. The reason for this&amp;nbsp;&lt;/SPAN&gt;is to improve the debugging experience, but it also makes it impossible to see the Optimized code that you will get whenever your program is not running under the Visual Studio debugger. Your alternative of launching the program using (Start Without Debugging or Ctrl+F5) does allow the JIT to create optimized code but Visual Studio won’t set any of your break points in your code.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; Thus you normally won't be able to stop and examine the assembly code for a method.&amp;nbsp; &lt;/SPAN&gt;We actually want do some debugging with the Optimized JIT code.&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.5in; LINE-HEIGHT: normal"&gt;&lt;SPAN style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman','serif'; mso-fareast-font-family: 'Times New Roman'"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.5in; LINE-HEIGHT: normal"&gt;&lt;SPAN style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman','serif'; mso-fareast-font-family: 'Times New Roman'"&gt;Another problem is that Visual Studio 2005 has a new feature called ‘Just My Code’ in which the debugger will not step into any code that it does not believe is being developed. Instead it will step over the code.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;This is also to improve the debugging experience, as most typical users do not want to step into Microsoft code such as the Collections classes, etc…&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;However any optimized code is also not considered as 'Just My Code’ so it too will be step over and is skipped.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;Again this makes it impossible to actually stop and see the optimized code.&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal"&gt;&lt;SPAN style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman','serif'; mso-fareast-font-family: 'Times New Roman'"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal"&gt;&lt;SPAN style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman','serif'; mso-fareast-font-family: 'Times New Roman'"&gt;Note that these are global settings as they affect all solutions; however I have found I don’t miss any of these ‘features’.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;That is because any code that is compiled for the ‘Debug’ configuration is still not optimized by the JIT so you will still get good debugging there.&lt;A class="" title=_ftnref1 style="mso-footnote-id: ftn1" href="http://null/#_ftn1" name=_ftnref1 mce_href="http://null/#_ftn1"&gt;&lt;SPAN class=MsoFootnoteReference&gt;&lt;SPAN style="mso-special-character: footnote"&gt;&lt;SPAN class=MsoFootnoteReference&gt;&lt;SPAN style="FONT-SIZE: 12pt; LINE-HEIGHT: 115%; FONT-FAMILY: 'Times New Roman','serif'; mso-fareast-font-family: 'Times New Roman'; mso-ansi-language: EN-US; mso-fareast-language: EN-US; mso-bidi-language: AR-SA"&gt;&lt;FONT color=#0000ff&gt;[*]&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/A&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal"&gt;&lt;SPAN style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman','serif'; mso-fareast-font-family: 'Times New Roman'"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal"&gt;&lt;SPAN style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman','serif'; mso-fareast-font-family: 'Times New Roman'"&gt;In my next blog entry I will demonstrate some of the optimizations that we perform in the JIT compiler.&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;DIV style="mso-element: footnote-list"&gt;&lt;BR clear=all&gt;
&lt;HR align=left width="33%" SIZE=1&gt;

&lt;DIV id=ftn1 style="mso-element: footnote"&gt;
&lt;P class=MsoEndnoteText style="MARGIN: 0in 0in 0pt"&gt;&lt;A class="" title=_ftn1 style="mso-footnote-id: ftn1" href="http://null/#_ftnref1" name=_ftn1 mce_href="http://null/#_ftnref1"&gt;&lt;SPAN class=MsoFootnoteReference&gt;&lt;SPAN style="mso-special-character: footnote"&gt;&lt;SPAN class=MsoFootnoteReference&gt;&lt;SPAN style="FONT-SIZE: 10pt; LINE-HEIGHT: 115%; FONT-FAMILY: 'Calibri','sans-serif'; mso-fareast-font-family: Calibri; mso-bidi-font-family: 'Times New Roman'; mso-ansi-language: EN-US; mso-fareast-language: EN-US; mso-bidi-language: AR-SA; mso-ascii-theme-font: minor-latin; mso-fareast-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-bidi-theme-font: minor-bidi"&gt;&lt;FONT color=#0000ff&gt;[*]&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/A&gt; Note that much of this article was adapted from an earlier article by Vance Morrison (&lt;A href="http://blogs.msdn.com/vancem/archive/2006/02/20/535807.aspx" mce_href="http://blogs.msdn.com/vancem/archive/2006/02/20/535807.aspx"&gt;What does foreach actually do?&lt;/A&gt;) &lt;/P&gt;
&lt;P class=MsoFootnoteText style="MARGIN: 0in 0in 0pt"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/P&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/FONT&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=5528731" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/b/clrcodegeneration/archive/tags/JIT+Optimized+Assembly+Code+Visual+Studio/">JIT Optimized Assembly Code Visual Studio</category></item><item><title>Running NGen as part of installing a Microsoft Exchange patch roll up takes ~2 hours [Lakshan Fernando]</title><link>http://blogs.msdn.com/b/clrcodegeneration/archive/2007/10/03/running-ngen-as-part-of-installing-a-microsoft-exchange-patch-roll-up-takes-2-hours-lakshan-fernando.aspx</link><pubDate>Wed, 03 Oct 2007 19:04:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:5264310</guid><dc:creator>CLR Codegen Blogger</dc:creator><slash:comments>1</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.msdn.com/b/clrcodegeneration/rsscomments.aspx?WeblogPostID=5264310</wfw:commentRss><comments>http://blogs.msdn.com/b/clrcodegeneration/archive/2007/10/03/running-ngen-as-part-of-installing-a-microsoft-exchange-patch-roll-up-takes-2-hours-lakshan-fernando.aspx#comments</comments><description>&lt;P class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;&lt;FONT face=Calibri size=3&gt;I work in the CodeGen test team and wanted to share a recent customer experience that was related to ngen. One of our Customer Service and Support (CSS) engineers in France contacted us regarding an installation delay with the latest Microsoft Exchange Server 2007 update rollup. Apparently the patch installer was spending 2 hours generating up-to-date NGen images.&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;&lt;FONT face=Calibri size=3&gt;The exchange installer package issues an “ngen update” command at the very end that causes all Exchange assemblies affected by the update to be recompiled synchronously.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;There is a known issue with this approach that had affected some customers whose machines had been updated with a .NET Framework 2.0 patch just prior to installing the Exchange patch. The .NET Framework 2.0 patch issues an “ngen.exe update /queue” command which schedules background assembly compilation at machine idle time. Then when the synchronous NGen command is issued by the Exchange installer package, it triggers compilation of all managed assemblies that don’t have up-to-date NGen images, including the .NET Framework ones. We originally thought that this might have been the reason behind the long time taken to regenerate the NGen images on this customer’s machine too. However, that was ruled out by the CSS engineer after further investigation.&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;&lt;FONT face=Calibri size=3&gt;We then requested the CSS engineer for the two ngen log files created by ngen and its service found at the .Net Framework redistributable installation directory (in this case, ngen.log and ngen_service.log found at %WINDIR%\Microsoft.NET\Framework64\v2.0.50727) and found an interesting anomaly. The ngen compilation worker might sometimes encounter an assembly that is already up-to-date, and the time taken to perform this validation is typically less than a second (the compilation worker exits as soon as it finds that the assembly already has a valid NGen image). But in this customer’s case, each of these assemblies was taking 10-14 seconds to determine that they already had a valid image (see below). These extra 10-14 seconds when multiplied across many different assemblies was resulting in a significant increase in patch install time.&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;&lt;SPAN style="COLOR: #c0504d"&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;08/24/2007 &lt;B&gt;10:36:21&lt;/B&gt; [5660]:&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Compiling assembly &lt;B&gt;Microsoft.Exchange.Data.Common, Version=8.0.681.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35&lt;/B&gt; ...&lt;?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;&lt;SPAN style="COLOR: #c0504d"&gt;08/24/2007 &lt;B&gt;10:36:33&lt;/B&gt; [5660]: Assembly &lt;B&gt;Microsoft.Exchange.Data.Common, Version=8.0.681.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35&lt;/B&gt; is &lt;B&gt;up to date&lt;/B&gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #1f497d"&gt;.&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;&lt;FONT face=Calibri size=3&gt;Around the same time, one of our developers was helping out on a Certificate Revocation List (CRL) issue report by &lt;/FONT&gt;&lt;A href="http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=522726&amp;amp;SiteID=1" mce_href="http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=522726&amp;amp;SiteID=1"&gt;&lt;FONT face=Calibri size=3&gt;another customer&lt;/FONT&gt;&lt;/A&gt;&lt;FONT face=Calibri size=3&gt; and asked the CSS engineer to check the “Software Restriction Policies” (&lt;/FONT&gt;&lt;A href="http://technet.microsoft.com/en-us/library/bb457006.aspx#EAAA" mce_href="http://technet.microsoft.com/en-us/library/bb457006.aspx#EAAA"&gt;&lt;FONT face=Calibri color=#0000ff size=3&gt;http://technet.microsoft.com/en-us/library/bb457006.aspx#EAAA&lt;/FONT&gt;&lt;/A&gt;&lt;FONT face=Calibri size=3&gt;) enabled on the customer’s machine. Sure enough, the delay was due to an Internet Explorer setting called “Check for publisher’s certificate revocation” (Options, Advanced, Security) that was checked on the customer’s machine, and was resulting in network requests to connect to crl.microsoft.com and look up the certificate revocation list at NGen time. The customer’s machine was behind a locked down firewall and did not have access to the internet and the reason for the 10-14 delay for each assembly. This option was unchecked in the IE setting and the install time was reduced to the expected 10 minutes from the 2-hour time. It was considered safe to uncheck this security option in IE since the machine was in a tightly controlled environment.&lt;/FONT&gt;&lt;/P&gt;&lt;SPAN style="FONT-SIZE: 11pt; LINE-HEIGHT: 115%; FONT-FAMILY: 'Calibri','sans-serif'; mso-ascii-theme-font: minor-latin; mso-fareast-font-family: Calibri; mso-fareast-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-bidi-font-family: 'Times New Roman'; mso-bidi-theme-font: minor-bidi; mso-ansi-language: EN-US; mso-fareast-language: EN-US; mso-bidi-language: AR-SA"&gt;Short summary of what we learned from this experience: Issuing a synchronous NGen update command in the patch installer may not be the best option. It might be better to schedule an NGen update for machine idle-time using “ngen.exe update /queue”, and &amp;nbsp;to (optionally) issue separate NGen install commands for perf-critical assemblies whose NGen images need to be regenerated right away.&amp;nbsp;&lt;/SPAN&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=5264310" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/b/clrcodegeneration/archive/tags/NGen/">NGen</category></item><item><title>To NGen or Not to NGen?</title><link>http://blogs.msdn.com/b/clrcodegeneration/archive/2007/09/15/to-ngen-or-not-to-ngen.aspx</link><pubDate>Sat, 15 Sep 2007 10:19:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:4925001</guid><dc:creator>Surupa Biswas</dc:creator><slash:comments>4</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.msdn.com/b/clrcodegeneration/rsscomments.aspx?WeblogPostID=4925001</wfw:commentRss><comments>http://blogs.msdn.com/b/clrcodegeneration/archive/2007/09/15/to-ngen-or-not-to-ngen.aspx#comments</comments><description>&amp;nbsp; 
&lt;P style="FONT-SIZE: 11pt; MARGIN: 0in; FONT-FAMILY: Calibri"&gt;One of the topics we often get questions on is about when it makes sense to invest the extra effort to pre-compile assemblies via NGen instead of simply relying on the JIT compiler to generate native code on the fly at application runtime. I thought I would try to answer that question in our first "real" post.&lt;/P&gt;
&lt;P style="FONT-SIZE: 11pt; MARGIN: 0in; FONT-FAMILY: Calibri" mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P style="FONT-SIZE: 11pt; MARGIN: 0in; FONT-FAMILY: Calibri"&gt;The JIT is optimized to balance code generation time against code quality, and it works well for many scenarios. NGen is essentially a performance optimization; so just like for anything else that's performance-related, you'll want to measure performance with vs. without NGen, and then decide whether it really helps your specific application and scenario. Here are a few general guidelines.&lt;/P&gt;
&lt;P style="FONT-SIZE: 11pt; MARGIN: 0in; FONT-FAMILY: Calibri" mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P style="FONT-SIZE: 11pt; MARGIN: 0in; FONT-FAMILY: Calibri"&gt;When to use NGen:&lt;/P&gt;
&lt;UL style="MARGIN-TOP: 0in; MARGIN-BOTTOM: 0in; MARGIN-LEFT: 0.75in; DIRECTION: ltr; unicode-bidi: embed" type=disc&gt;
&lt;LI style="MARGIN-TOP: 0px; MARGIN-BOTTOM: 0px; VERTICAL-ALIGN: middle"&gt;&lt;SPAN style="FONT-SIZE: 11pt; FONT-FAMILY: Calibri"&gt;Large applications: Applications that run a lot of managed code at start up are likely to see wins in start up time when using NGen. Microsoft Expression Blend for example, uses NGen to minimize start up time. If a large amount of code needs to be JIT-compiled at start up, the time needed to compile the IL might be a substantial portion of the total app launch time (even for cold start up) . Eliminating JIT-compilation from start up can therefore result in warm as well as cold start up wins.&lt;/SPAN&gt;&lt;/LI&gt;
&lt;LI style="MARGIN-TOP: 0px; MARGIN-BOTTOM: 0px; VERTICAL-ALIGN: middle"&gt;&lt;SPAN style="FONT-SIZE: 11pt; FONT-FAMILY: Calibri"&gt;Frameworks, libraries, and other reusable components: Code produced by our JITs cannot be shared across multiple processes; NGen images, on the other hand, can be. Therefore any code that is likely to be used by multiple applications at the same time is likely to consume less memory when pre-compiled via NGen. Almost the entire Microsoft .NET Framework for instance, uses NGen. Also Microsoft Exchange Server pre-compiles its core DLLs that are shared across various Exchange services.&lt;/SPAN&gt;&lt;/LI&gt;
&lt;LI style="MARGIN-TOP: 0px; MARGIN-BOTTOM: 0px; VERTICAL-ALIGN: middle"&gt;&lt;SPAN style="FONT-SIZE: 11pt; FONT-FAMILY: Calibri"&gt;Applications running in terminal server environments: Once again NGen helps in such a scenario because the generated code can be shared across the different instances of the application – that in turn increases the number of simultaneous user sessions the server can support.&lt;/SPAN&gt;&lt;/LI&gt;&lt;/UL&gt;
&lt;P style="FONT-SIZE: 11pt; MARGIN: 0in; FONT-FAMILY: Calibri" mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P style="FONT-SIZE: 11pt; MARGIN: 0in; FONT-FAMILY: Calibri"&gt;When not to use NGen:&lt;/P&gt;
&lt;UL style="MARGIN-TOP: 0in; MARGIN-BOTTOM: 0in; MARGIN-LEFT: 0.75in; DIRECTION: ltr; unicode-bidi: embed" type=disc&gt;
&lt;LI style="MARGIN-TOP: 0px; MARGIN-BOTTOM: 0px; VERTICAL-ALIGN: middle"&gt;&lt;SPAN style="FONT-SIZE: 11pt; FONT-FAMILY: Calibri"&gt;Small applications: Small utilities like caspol.exe in the .NET Framework aren't NGen-ed because the time spent JIT-compiling the code is typically a small portion of the overall start up time. As a matter of fact, since NGen images are substantially bigger in size than the corresponding IL assemblies, using NGen might actually result in increased disk I/O&amp;nbsp;and hurt cold start up time.&lt;/SPAN&gt;&lt;/LI&gt;
&lt;LI style="MARGIN-TOP: 0px; MARGIN-BOTTOM: 0px; VERTICAL-ALIGN: middle"&gt;&lt;SPAN style="FONT-SIZE: 11pt; FONT-FAMILY: Calibri"&gt;Server applications: Server applications that aren't sensitive to long start up times, and don't have shared components are unlikely to benefit significantly from NGen. &amp;nbsp;In such cases,&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;the cost of using NGen (more on this below) may not be worth the benefits. SQL-CLR for example, isn't NGen-ed.&lt;/SPAN&gt;&lt;/LI&gt;&lt;/UL&gt;
&lt;P style="FONT-SIZE: 11pt; MARGIN: 0in; FONT-FAMILY: Calibri" mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P style="FONT-SIZE: 11pt; MARGIN: 0in; FONT-FAMILY: Calibri"&gt;If it seems that your application is likely to benefit from NGen, here are a few things you might want to keep in mind:&lt;/P&gt;
&lt;P style="FONT-SIZE: 11pt; MARGIN: 0in; FONT-FAMILY: Calibri" mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;OL style="MARGIN-TOP: 0in; FONT-SIZE: 12pt; MARGIN-BOTTOM: 0in; MARGIN-LEFT: 0.75in; DIRECTION: ltr; FONT-FAMILY: 'Times New Roman'; unicode-bidi: embed" type=1&gt;
&lt;LI style="MARGIN-TOP: 0px; MARGIN-BOTTOM: 0px; VERTICAL-ALIGN: middle" value=1&gt;&lt;SPAN style="FONT-SIZE: 11pt; FONT-FAMILY: Calibri"&gt;NGen is triggered by issuing commands at install time to the ngen.exe tool in the .NET&amp;nbsp; Framework redistributable. To find out more about hooking NGen into set up, see here: &lt;/SPAN&gt;&lt;A href="http://blogs.msdn.com/astebner/archive/2007/03/03/how-to-ngen-files-in-an-msi-based-setup-package-using-wix.aspx"&gt;&lt;SPAN style="FONT-SIZE: 11pt; FONT-FAMILY: Calibri"&gt;http://blogs.msdn.com/astebner/archive/2007/03/03/how-to-ngen-files-in-an-msi-based-setup-package-using-wix.aspx&lt;/SPAN&gt;&lt;/A&gt;&lt;SPAN style="FONT-SIZE: 11pt; FONT-FAMILY: Calibri"&gt;.&lt;/SPAN&gt;&lt;/LI&gt;&lt;/OL&gt;
&lt;P style="FONT-SIZE: 11pt; MARGIN: 0in 0in 0in 0.75in; FONT-STYLE: italic; FONT-FAMILY: Calibri"&gt;Note: Currently you need admin privileges to issue commands via ngen.exe. &lt;/P&gt;
&lt;OL style="MARGIN-TOP: 0in; FONT-SIZE: 12pt; MARGIN-BOTTOM: 0in; MARGIN-LEFT: 0.75in; DIRECTION: ltr; FONT-FAMILY: 'Times New Roman'; unicode-bidi: embed" type=1&gt;
&lt;LI style="MARGIN-TOP: 0px; MARGIN-BOTTOM: 0px; VERTICAL-ALIGN: middle" value=2&gt;&lt;SPAN style="FONT-SIZE: 11pt; FONT-FAMILY: Calibri"&gt;Just running ngen.exe on your assemblies and then re-running your performance scenarios to measure the wins is very likely not going to give you a true indication of the wins. Basically, it takes some effort to get the best performance out of NGen. For detailed guidelines on how to get the best performance via NGen, please take a look at this article in the MSDN magazine: &lt;/SPAN&gt;&lt;A href="http://msdn.microsoft.com/msdnmag/issues/06/05/CLRInsideOut/default.aspx"&gt;&lt;SPAN style="FONT-SIZE: 11pt; FONT-FAMILY: Calibri"&gt;http://msdn.microsoft.com/msdnmag/issues/06/05/CLRInsideOut/default.aspx&lt;/SPAN&gt;&lt;/A&gt;&lt;SPAN style="FONT-SIZE: 11pt; FONT-FAMILY: Calibri"&gt;.&lt;/SPAN&gt;&lt;/LI&gt;
&lt;LI style="MARGIN-TOP: 0px; MARGIN-BOTTOM: 0px; VERTICAL-ALIGN: middle" value=3&gt;&lt;SPAN style="FONT-SIZE: 11pt; FONT-FAMILY: Calibri"&gt;Using NGen has implications for servicing your application. Your patch installer will need to issue NGen commands to ensure that the images invalidated by the patch get regenerated. .NET Framework 2.0 supports an "ngen.exe update /queue" command that should work well in most cases (this will regenerate all invalid NGen images at machine idle time). If specific assemblies are perf-critical and need to have up-to-date NGen images immediately after the patch install, you can issue separate NGen commands for those ("ngen.exe install &amp;lt;CriticalDLL&amp;gt;"), followed by the "ngen.exe update /queue" command.&lt;/SPAN&gt;&lt;/LI&gt;
&lt;LI style="MARGIN-TOP: 0px; MARGIN-BOTTOM: 0px; VERTICAL-ALIGN: middle" value=4&gt;&lt;SPAN style="FONT-SIZE: 11pt; FONT-FAMILY: Calibri"&gt;Using NGen implies your application's disk footprint will increase (NGen images are fairly big when compared to MSIL assemblies).&lt;/SPAN&gt;&lt;/LI&gt;
&lt;LI style="MARGIN-TOP: 0px; MARGIN-BOTTOM: 0px; VERTICAL-ALIGN: middle" value=5&gt;&lt;SPAN style="FONT-SIZE: 11pt; FONT-FAMILY: Calibri"&gt;In a handful of scenarios, cold start up and/or application execution can get slower when you use NGen, so you'll definitely want to measure the performance with vs. without NGen for all scenarios, and validate that it's a win overall for your application to be using NGen.&lt;/SPAN&gt;&lt;/LI&gt;&lt;/OL&gt;
&lt;P style="FONT-SIZE: 11pt; MARGIN: 0in; FONT-FAMILY: Calibri" mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P style="FONT-SIZE: 11pt; MARGIN: 0in; FONT-FAMILY: Calibri"&gt;Finally, another important thing to keep&amp;nbsp;in mind&amp;nbsp;is that NGen isn't a magic solution for application start up time. NGen can speed up application start up by eliminating the time needed for JIT compiling the code executed at start up.&lt;/P&gt;
&lt;P style="FONT-SIZE: 11pt; MARGIN: 0in; FONT-FAMILY: Calibri" mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P style="FONT-SIZE: 11pt; MARGIN: 0in; FONT-FAMILY: Calibri"&gt;However, regardless of whether you do or don't use NGen, it is important to ensure that your application is architected to be performant. So for instance, if you care about start up time, you should try to minimize the amount of code that needs to get loaded and executed on your application's start up path.&lt;/P&gt;
&lt;P style="FONT-SIZE: 11pt; MARGIN: 0in; FONT-FAMILY: Calibri" mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P style="FONT-SIZE: 11pt; MARGIN: 0in; FONT-FAMILY: Calibri"&gt;Below are some good resources on measuring and optimizing application start up performance: &lt;A href="http://blogs.msdn.com/vancem/archive/tags/Perf/default.aspx"&gt;http://blogs.msdn.com/vancem/archive/tags/Perf/default.aspx&lt;/A&gt;&lt;/P&gt;
&lt;P style="FONT-SIZE: 11pt; MARGIN: 0in; FONT-FAMILY: Calibri"&gt;&lt;A href="http://msdn.microsoft.com/msdnmag/issues/06/02/CLRInsideOut"&gt;http://msdn.microsoft.com/msdnmag/issues/06/02/CLRInsideOut&lt;/A&gt;&lt;/P&gt;
&lt;P style="FONT-SIZE: 11pt; MARGIN: 0in; FONT-FAMILY: Calibri"&gt;&lt;A href="http://msdn.microsoft.com/msdnmag/issues/06/03/WindowsFormsPerformance/"&gt;http://msdn.microsoft.com/msdnmag/issues/06/03/WindowsFormsPerformance/&lt;/A&gt;&lt;/P&gt;
&lt;P style="FONT-SIZE: 11pt; MARGIN: 0in; COLOR: #1f497d; FONT-FAMILY: Calibri" mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P style="FONT-SIZE: 11pt; MARGIN: 0in; FONT-FAMILY: Calibri"&gt;And some for NGen:&lt;/P&gt;
&lt;P style="FONT-SIZE: 11pt; MARGIN: 0in; FONT-FAMILY: Calibri"&gt;NGen internals: &lt;A href="http://msdn.microsoft.com/msdnmag/issues/05/04/NGen/default.aspx"&gt;http://msdn.microsoft.com/msdnmag/issues/05/04/NGen/default.aspx&lt;/A&gt;&lt;/P&gt;
&lt;P style="FONT-SIZE: 11pt; MARGIN: 0in; FONT-FAMILY: Calibri"&gt;NGen Service (NGen-ing your assemblies in the background):&lt;/P&gt;
&lt;P style="FONT-SIZE: 11pt; MARGIN: 0in; FONT-FAMILY: Calibri"&gt;&lt;A href="http://blogs.msdn.com/davidnotario/"&gt;http://blogs.msdn.com/davidnotario/&lt;/A&gt; (David isn't on our team any longer)&lt;/P&gt;
&lt;P style="FONT-SIZE: 11pt; MARGIN: 0in; FONT-FAMILY: Calibri" mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P style="FONT-SIZE: 11pt; MARGIN: 0in; FONT-FAMILY: Calibri"&gt;Thanks for visiting our blog!&lt;/P&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=4925001" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/b/clrcodegeneration/archive/tags/NGen/">NGen</category></item><item><title>Welcome to the CLR Code Generation Team's blog</title><link>http://blogs.msdn.com/b/clrcodegeneration/archive/2007/09/15/welcome-to-the-clr-code-generation-team-s-blog.aspx</link><pubDate>Sat, 15 Sep 2007 10:18:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:4924795</guid><dc:creator>Surupa Biswas</dc:creator><slash:comments>1</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.msdn.com/b/clrcodegeneration/rsscomments.aspx?WeblogPostID=4924795</wfw:commentRss><comments>http://blogs.msdn.com/b/clrcodegeneration/archive/2007/09/15/welcome-to-the-clr-code-generation-team-s-blog.aspx#comments</comments><description>&lt;P style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="FONT-SIZE: 11pt; FONT-FAMILY: 'Calibri','sans-serif'"&gt;This is the first blog post from the code generation feature team working on the Common Language Runtime (CLR). We're the group of individuals that make it possible to generate native code for all binaries that run on top of the Microsoft .NET Framework. Since all managed applications today are distributed in a format known as MSIL (for Microsoft Intermediate Language), the CLR is responsible for compiling MSIL to directly-executable machine code. That's where we come in -- currently we support compiling against 3 different machine architectures -- x86, x64, &amp;amp; IA64, and in 2 different compilation modes -- dynamic compilation using the Just-in-time compiler (JIT), and ahead-of-time/pre-compilation using NGen (for Native Generation). Two examples of&amp;nbsp; design challenges in our space include balancing the quality of the generated code with the time taken to generate it, and balancing the desire to update NGen images soon after MSIL binaries are patched with the desire to keep patch install time at a minimum.&lt;?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="FONT-SIZE: 11pt; FONT-FAMILY: 'Calibri','sans-serif'"&gt;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="FONT-SIZE: 11pt; FONT-FAMILY: 'Calibri','sans-serif'"&gt;Expect posts about our JIT &amp;amp; NGen back-ends over the coming months on this blog. Also, please feel free to let us know what codegen-related topics you're interested in reading about. &lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=4924795" width="1" height="1"&gt;</description></item></channel></rss>
