3 ms·
Eliminating the stack frame is a pretty effective speed optimization for "traditional" languages. It costs a non-trivial amount of instructions (execution time
by gvb 17y ago
Eliminating the stack frame is a pretty effective speed optimization for "traditional" languages.
It costs a non-trivial amount of instructions (execution time) and cache space (potentially casting out more useful data - data fetch time) to build an unneeded stack frame, and then a couple more instructions to throw the frame away. Even for processors that have a "build a stack frame" instruction like the x86, the instruction is a pretty expensive one in terms of clocks required to execute.
With a "traditional" language, stack frames can be eliminated in the leaf nodes of the calling trees. These routines tend to be the very small utility routines so building an unneeded stack frame to execute a three line (often only a handful of assy instructions) routine is measurably wasteful.
Thus, I would add a third type of code that benefits from stack frame optimization: small leaf node functions, i.e. functions don't call anything other function.