Just adding my two cents to the already good answers.
It is part of a good language architecture to have a stack frame chain. BP points to the current block where local subroutine variables are stored. (Locales are in negative offsets, and arguments are in positive offsets.)
The idea that it prevents the use of an excellent register in optimization poses the question: when and where is the optimization really worth it?
Optimization is only in tight cycles that 1) do not call the function, 2) where the program counter spends a significant part of its time, and 3) in the code that the compiler has ever seen (i.e. non-library functions), usually a very small part of the general code, especially on large systems.
Other code can be twisted and compressed to get rid of loops, and it just doesn't matter, because the program counter practically does not exist.
I know that you did not ask this, but in my experience, 99% of performance problems have nothing to do with compiler optimization. They have everything associated with excessive design.
Mike Dunlavey Feb 24 '09 at 21:43 2009-02-24 21:43
source share