Re: Profiling and inlining
- From: Barry Kelly <barry.j.kelly@xxxxxxxxx>
- Date: Thu, 20 Jul 2006 23:20:33 +0100
ti@xxxxxxxxxxx wrote:
I'm trying to figure out what the JIT will inline at what it won't. 2
questions:
1. Will the JIT inline this function? (from actual software):
public int GetEdgeCostIndex(bool isConnector, bool isForward)
It might, but then, it might not.
2. How do I get CorDbg to show dissaembly for the JIT's optimized code?
You should probably use WinDbg and SOS. Typically, to check out compiled
code, I stick a native breakpoint in an application (be sure it breaks
after the code has been called at least once, so that it has been
JITted) and run it under WinDbg until it breaks. I then do:
..load sos
!name2ee Test.exe Program.Main // or whatever
!u <methodAddressFromName2EE>
For my native breakpoints, I typically use WinDbg to break in WriteFile
(bp kernel32!WriteFile), and is typically triggered by a console write.
Alternatively, you can PInvoke to DebugBreak in kernel32.dll.
I tried the sample program below. The TestMethod() function should a be
prime candidate for inlining, but cordbg doesn't show that.
class Program
{
static void Main(string[] args)
{
for (int i = 0; i < 1000000; i++)
Program.TestMethod();
System.Console.WriteLine("x");
}
public static void TestMethod()
{
return;
}
}
I built this program with optimizations enabled (/optimize+) and I
debugged it with WinDbg. Here's a reduced-size dump:
---8<---
0:000> bp kernel32!WriteFile
0:000> g
Breakpoint 0 hit
0:000> .load sos
0:000> !name2ee Test.exe Program.Main
Module: 00922c14 (Test.exe)
Token: 0x06000001
MethodDesc: 00922fd8
Name: Program.Main(System.String[])
JITTED Code Address: 00ca0070
0:000> !u 00ca0070
Normal JIT generated code
Program.Main(System.String[])
Begin 00ca0070, size 28
00ca0077 750a jne 00ca008300ca0070 833d8410280200 cmp dword ptr ds:[2281084h],0
00ca0079 b901000000 mov ecx,1
00ca007e e889d76a78 call mscorlib_ni+0x28d80c (7934d80c)
(System.Console.InitializeStdOutError(Boolean), mdToken: 0600070f)
00ca0083 8b0d84102802 mov ecx,dword ptr ds:[2281084h]
00ca0089 8b153c302802 mov edx,dword ptr ds:[228303Ch]
00ca008f 8b01 mov eax,dword ptr [ecx]
00ca0091 ff90d8000000 call dword ptr [eax+0D8h]
00ca0097 c3 ret
--->8---
You can see here that the code has been completely removed, the loop
too.
-- Barry
--
http://barrkel.blogspot.com/
.
- Follow-Ups:
- Re: Profiling and inlining
- From: ti
- Re: Profiling and inlining
- References:
- Profiling and inlining
- From: ti
- Re: Profiling and inlining
- From: ti
- Profiling and inlining
- Prev by Date: Re: Profiling and inlining
- Next by Date: Re: Profiling and inlining
- Previous by thread: Re: Profiling and inlining
- Next by thread: Re: Profiling and inlining
- Index(es):