The following illustration shows the stack frame layout.
The following list gives more information about the stack frame layout.
Frame pointer is a convenience for referencing local variables in a
subrouting, usually all the args are pushed onto the stack then BP
(the frame, or Base pointer) is pushed , then SP
(the stack pointer) is copied to BP, so all variables can easily be
referenced via BP+x, BP+y, etc. It is especially useful if you are
debugging since BP will give you an idea of where the parameters to
the current subroutine are located. It is also useful if you are doing
a stack traceback since the values of BP have been pushed onto the stack
for each stack frame.
On the otherhand, there are otherways of accessing those variables by
referencing off of "SP" and using BP as a general purpose register
to do other things -- this can result in faster code that is less
easy to debug.
If you aren't doing kernel debugging and/or are not expecting to be
generating stack traces, allowing the compiler to use BP (Base/Frame
Pointer) is usually a good thing for optimizing memory and CPU
execution time.
阅读(1422) | 评论(0) | 转发(0) |