正在编制发布和调试会产生不同的IL code +不同的机器code? [英] Is compiling Release and Debug going to generate different IL code + different machine code?

查看:133
本文介绍了正在编制发布和调试会产生不同的IL code +不同的机器code?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我听说在编制发布模式生成优化的code比在调试模式,这是很好的。

I heard compiling in Release mode generates optimized code than in Debug mode, which is fine.

但是,这种优化的IL?它是在机器code一旦CLR运行呢?是元数据结构不同,PE在发布和调试编译?

But is this optimization in the IL? is it in the machine code once the CLR runs it? is the metadata structure different from PE compiled in Release and Debug?

感谢

推荐答案

大厦发布版本将打开/优化编译选项,C#编译器。具有的几个的副作用,白细胞介素的确变化,但不是很大。值得注意的是,编译器不再用力,使code完全可调试。它例如跳过一个空的静态构造函数,它不再发出的NOP运算codeS,可以让你在大括号设置一个断点,并允许不同范围的局部变量在堆栈帧重叠。小东东。

Building in Release build turns on the /optimize compile option for the C# compiler. That has a few side-effects, the IL indeed changes but not a great deal. Notable is that the compiler no longer makes an effort to make the code perfectly debuggable. It for example skips an empty static constructor, it no longer emits the NOP opcodes that allows you to set a breakpoint on a curly brace and allows local variables with different scopes to overlap in a stack frame. Small stuff.

最重要的区别是[可调试]这是发出的程序集属性,其IsJITOptimizerDisabled属性为false。

The most important difference is the [Debuggable] attribute that's emitted for the assembly, its IsJITOptimizerDisabled property is false.

这将打开的真正的优化,这是建立在抖动之一。你会发现优化它这个答案的列表。请注意,这种方法的有效性,任何的从具有在抖动,而不是编译器的code优化语言的好处。

Which turns on the real optimizer, the one that's built into the jitter. You'll find the list of optimizations it performs in this answer. Do note the usefulness of this approach, any language benefits from having the code optimizer in the jitter instead of the compiler.

所以,简单地说,在IL非常小的变化,变化非常大,在生成的机器code。

So in a nutshell, very minor changes in the IL, very large changes in the generated machine code.

这篇关于正在编制发布和调试会产生不同的IL code +不同的机器code?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆