NOP in release build of F# code

◇◆丶佛笑我妖孽 提交于 2019-11-30 20:36:54

The maxstack difference is due to the fact that the C# compiler compiles the first method with a «light» method body header, that is used whenever the code is small, has no exceptions and no locals. In that case, the maxstack is not specified and defaults to 8.

The F# compiler is using a «fat» method body header, and specifies the maxstack it has computed.

As for the nop, it's because you're compiling in debug mode. They always start a method body with a nop. See from fsharp/ilxgen.ml:

// Add a nop to make way for the first sequence point. There is always such a 
// sequence point even when zapFirstSeqPointToStart=false
do if mgbuf.cenv.generateDebugSymbols  then codebuf.Add(i_nop);

If I compile your factorial without debug symbols, I don't get a nop.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!