It’s 10 pm, do you know what your JITter is doing?

Ever have that awkward feeling like you don't know what actually gets executed as a result of your managed code? Visual Studio allows you to inspect the JITted code easily but does require a few tweaks first:

  1. First set your project to build in Release mode.
  2. Next go to Tools|Options|Debugging and uncheck both Suppress JIT optimization on module load (Managed only) and Enable Just My Code (Managed only)

Now you can run your project and set a breakpoint where you want to look at code and go to Debug | Windows | Disassembly to get an annotated disassembly like the following: 

    static void Main(string[] args)
00000000 push ebp
00000001 mov ebp,esp
00000003 push esi
00000004 call dword ptr ds:[00159B7Ch]

0000000a mov esi,dword ptr ds:[037D5B20h]
00000010 call 6B20BE78
00000015 mov ecx,eax
00000017 mov edx,esi
00000019 mov eax,dword ptr [ecx]
0000001b call dword ptr [eax+000000D8h]
00000021 pop esi

00000022 pop ebp
00000023 ret  
Skip to main content