Ask Learn
Preview
Ask Learn is an AI assistant that can answer questions, clarify concepts, and define terms using trusted Microsoft documentation.
Please sign in to use Ask Learn.
Sign inThis browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Here are the full details I received from Grant Richins and Fei Chen when I asked how the JIT decides whether to employ the tail call optimization. Note that these statements apply to the JITs as they were when Grant and Fei looked through the code base, and are prone to change at whim. You must not take dependencies on this behavior. Use this information for your own personal entertainment only.
First, Grant talked about the 64-bit JITs (one for x64, one for ia64):
For the 64-bit JIT, we tail call whenever we’re allowed to. Here’s what prevents us from tail calling (in no particular order):
If all of those conditions are satisfied, we will perform a tail call. Also note that for verifiability, if the code uses a “tail.” prefix, the subsequent call opcode must be immediately followed by a ret opcode (no intermediate nops or prefixs are allowed, although there might be additional prefixes between the “tail.” prefix and the actual call opcode).
Fei has this to add about the 32-bit JIT:
I looked at the code briefly and here are the cases I saw where tailcall is disallowed:
Anonymous
July 03, 2007
For most people the idea of entering or returning from a function seems straightforward. Your profiler's
Anonymous
July 28, 2007
What's tail recursion If you know its nothing to do with any of your pet's tail then get onto the next
Anonymous
October 04, 2008
Web YUI 2.6.0 Released Practical Functional JavaScript: Code Samples Removing unused CSS Classes from
Anonymous
April 07, 2009
After all the buzz around F# I was refreshing my knowledge about functional programming. I used F# to
Anonymous
June 12, 2009
First a little background reading before going into tail call improvements in CLR 4 - David Broman did
Anonymous
June 12, 2009
First a little background reading before going into tail call improvements in CLR 4 - David Broman did
Ask Learn is an AI assistant that can answer questions, clarify concepts, and define terms using trusted Microsoft documentation.
Please sign in to use Ask Learn.
Sign in