Leaf routine: Difference between revisions

Content deleted Content added
add more context on why anybody would care, and a reference
Restrictive clause, so use "that".
 
(6 intermediate revisions by 3 users not shown)
Line 1:
{{short description|Subroutines in computer science}}
 
A '''leaf routine''', '''leaf subroutine''', '''leaf function''', or '''leaf procedure''' is a [[subroutinefunction (computer programming)|function]] whichthat cannotdoes not in turn call another subroutinefunction. Some compilers can apply special program optimizations to leaf subroutinesroutines to make them more efficient, such as the use of [[link register]]s to avoid having to push the return address on the stack, or not allocating a [[register window]] on CPU architectures descended from [[Berkeley RISC]].<ref>{{cite web|url=https://gcc.gnu.org/onlinedocs/gccint/Leaf-Functions.html|title=Leaf Functions (GCC (GNU Compiler Collection) Internals Manual)}}</ref>
 
The term "leaf" refers to their position as [[leaf node]]s in the [[call graph]] of the program.
 
Usually, most non-leaf subroutinesroutines call more than one other subroutinefunction. When this is the case, the majority of subroutinefunction calls in the call graph are calls to leaf subroutinesroutines, because a [[binary tree]] has more leaf nodes than non-leaf nodes (assuming that all non-leaf nodes have two children). Consequently, the efficiency of calls to leaf subroutineroutines often has a significant effect on the efficiency of the whole program. {{fact|date=July 2025}}
 
== References ==
{{Reflist}}
 
[[Category:Subroutines]]