Re: Is there stack associated when a executing an inline function?



jacob navia <jacob@xxxxxxxxxx> writes:
Kaz Kylheku wrote:
On Feb 29, 11:08 am, jacob navia <ja...@xxxxxxxxxx> wrote:
It would be completely weird that in an inline procedure the compiler
would save the current stack pointer and establish a new stack
frame since there is no function call.

However, it wouldn't be weird at all if the inlined procedure simply
moves the stack pointer by some delta to enlarge the current frame,
then references all of its locals with respect to the current frame,
and then moves the stack pointer back by the same delta upon
termination to release the storage.

That is normal, but that is not a stack frame!

That is just increasing the stack, like when you use
alloca().

That function (alloca()) doesn't create a stack frame.

So you have some specific definition of the term "stack frame" in
mind, one that includes the storage reserved by an ordinary function
call, but that excludes the storage that might be reserved in other
circumstances, such as a call to an inline function or a call to the
non-standard alloca() function.

Perhaps you can tell us what this definition is, preferably by citing
the standard.

There are a number of ways that inline functions, and calls to them,
could be implemented. For that matter, I understand that not
generating a new stack frame is a fairly common optimization for calls
to some ordinary functions. I see no particular reason why allocating
a stack frame and executing a call instruction must be tied together;
either could be done without the other if it's convenient.

The gory details would, of course, be perfectly topical in some
system-specific newsgroup.

--
Keith Thompson (The_Other_Keith) <kst-u@xxxxxxx>
Nokia
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
.



Relevant Pages

  • Re: stack pointer and frame pointer
    ... Stacks and frames are artifacts of particular implementations ... A stack pointer usually changes during the execution of any one ... and the storage space could be released ... A frame pointer, on the other hand, usually points to the beginning ...
    (comp.lang.c)
  • Re: [OT] [Question]activities of stack pointer and frame pointer when function called
    ... >>I suspect you don't understand what as stack frame is. ... A function stack frame is a method to keep track of function ... At the point of creation the caller is ... When the callee returns to its ...
    (comp.lang.c)
  • Re: [PATCH 2/2] function-graph: add stack frame test
    ... In case gcc does something funny with the stack frames, ... frame of the parent function, and will test that frame on exit. ... This modifies the parameters of one of the functions that the arch ... movl 0xc, %edx ...
    (Linux-Kernel)
  • Re: What is a stack frame?
    ... There is no need for a separate "this frame" pointer. ... In any case, the more general term, which covers what a C compiler ... hardware-provided stack to implement the stack-like data structure ... manner since the current stack frame is "deformed" by alloca. ...
    (comp.lang.c)
  • Re: [9fans] pointer to the last TOS
    ... the stack pointer is there. ... a positive offset from ... pointer to the virtual frame pointer to find the return address. ...
    (comp.os.plan9)