开发者

Architecture that can optimize tail calls for C#

开发者 https://www.devze.com 2023-03-29 02:51 出处:网络
Reading a blog entry by Eric Lippert, I came across this snippet: ...you\'re going to either loop forever (if you\'re on an architecture

Reading a blog entry by Eric Lippert, I came across this snippet:

...you're going to either loop forever (if you're on an architecture that can optimize tail calls) or run out of stack 开发者_StackOverflowand crash the process.

I'm aware that a compiler can optimize tail recursion, but what does an architecture that can optimize tail calls mean?


It means that the .NET JIT on x64 behaves differently to the JIT on x86 - the x64 one applies tail call optimizations much more aggressively.

See this blog post from 2007 and this one from 2009 for some implementation details (not to be depended upon) for some of the rules that are followed.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号