What is the effect of “Suppress JIT optimization o

2019-04-21 20:46发布

问题:

What is the effect of the "Suppress JIT optimization on module load" debugging option?

I have recently had to turn it off to deal to be able to successfully debug an app that uses a COM component.

What do I risk by turning it off?

回答1:

Suppressing JIT optimization means you are debugging non-optimized code. The code runs a bit slower because it is not optimized, but your debugging experience is much more thorough. Debugging optimized code is harder and recommended only if you encounter a bug that occurs in optimized code but cannot be reproduced in the non-optimized version.

If you clear the Suppress JIT optimization on module load option, you can debug optimized JIT code, but your ability to debug may be limited because the optimized code does not match the source code. As a result, debugger windows such as the Locals and Autos window may not display as much information as they would if you were debugging non-optimized code.



回答2:

It means that JIT code will not be optimized for debugging. For example:

private int Add(int x, int y)
    {
        int notUsed = 2;
        return x + y;
    }

in this code notUsed variable will be excluded fro JIT code by optimization as this code is not required. If you start debugging optimized code it may look like not the code you have written (but will do the same). Another example of optimization is methods inlining.