Thursday, June 19, 2003

Tail Calls in Objective-C

Andrew Pinski informed me that although not required to by the language standard, GCC 3.1 does optimize most tail calls in Objective-C. This gives a little performance boost for recursive algorithms coded in the right form (take a look with gcc -S), and it can be the difference between correctness and a crash for deep recursions. Dan Sugalski has promised to discuss this at some point. GCC does not optimize tail calls in methods that catch exceptions or use AltiVec. Andreas Bauer’s master’s thesis describes how a future version of GCC may do better.

Comments RSS · Twitter

Leave a Comment