Will the .NET JIT compiler optimize a method call?

The stack trace returned from the ASP.NET application created from ArgumentNullException gives the impression that an error occurs in the last line of the code below. As far as I can tell, this is not possible, but if the JIT optimized the call Bar, which leads to a different stack trace, this will explain everything. I know for sure that this is not a C # compiler, since CIL looks exactly as I expected. Is it possible that the JIT compiler has removed the call in Bar?

C # 4, .NET 4.0.30319.1, ASP.NET 4.0.30319.1

EDIT: I should have mentioned that this is a release version, with optimizations code = on, Debug Info = pdb-only.

Stack Trace:

[ArgumentNullException: Value cannot be null. Parameter name: value]
CreateHiddenField(HtmlTextWriter tr, String name, String value) in Foo.cs:129
Foo(IHttpContext context, HtmlTextWriter writer) in Foo.cs:106

private static void Foo(IHttpContext context, HtmlTextWriter writer)
{ // line 103
  Bar(writer, AuthorizationServerResponseDetailsHttpRequestParser.RequestSAMLFieldName, context);
  Bar(writer, AuthorizationServerResponseDetailsHttpRequestParser.RequestTargetFieldName, context);
  // line 106 - blank line in source code.
  CreateHiddenField(tr, name, string.Empty); // looks like its here
}

private static void Bar(HtmlTextWriter tr,string name, IHttpContext context)
{ // line 116
   #region Sanitation
   if (tr == null) { throw new System.ArgumentNullException("tr"); }
   if (name == null) { throw new System.ArgumentNullException("name"); }
   if (context == null) { throw new System.ArgumentNullException("context"); }
   #endregion

   CreateHiddenField(tr, name, context.RequestQueryString(name));
}

private static void CreateHiddenField(HtmlTextWriter tr, string name, string value)
{ // line 127
   #region Sanitation
   if (tr == null) { throw new System.ArgumentNullException("tr"); }
   if (name == null) { throw new System.ArgumentNullException("name"); }
   if (value == null) { throw new System.ArgumentNullException("value"); }
   #endregion

   // payload...
}
+5
source share
2 answers

http://www.hanselman.com/blog/ReleaseISNOTDebug64bitOptimizationsAndCMethodInliningInReleaseBuildCallStacks.aspx, JITTER , . , (, , ),

[MethodImpl(MethodImplOptions.NoInlining)] 

. exe INI , JITTER ( ), , ASP.NET.

+4

, JIT , . , , JIT , , - .

, null , CreateHiddenField, value. , ( , ). , CreateHiddenField .:)

, . MSDN

+2

All Articles