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



In article <47C869B8.AD1D36AD@xxxxxxxx>,
Morris Dovey <mrdovey@xxxxxxxx> wrote:

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.

But what would be the point?

It'd allow re-use of that memory by another (subsequent) inlined
procedure or function call. Waste not, want not.

Multiple inlined functions can use the same stack space without
adjusting the stack pointer. It's not significantly different from:

void foo(int a)
{
...
{
int b;
...
}
...
{
double c;
...
}
...
}

But actually I'd misread the article; it is indeed quite reasonable to
adjust the stack pointer during the execution of a function, and it
can be done even when there are no inline function calls or nested
blocks, at the end of some variable's useful life. I don't know if
any C implementations do that, but some implementations of other
languages do.

-- Richard

--
:wq
.



Relevant Pages

  • Re: Is there stack associated when a executing an inline function?
    ... moves the stack pointer by some delta to enlarge the current frame, ... then references all of its locals with respect to the current frame, ...
    (comp.lang.c)
  • Re: Is there stack associated when a executing an inline function?
    ... moves the stack pointer by some delta to enlarge the current frame, ... then references all of its locals with respect to the current frame, ...
    (comp.lang.c)
  • Re: Is there stack associated when a executing an inline function?
    ... frame since there is no function call. ... moves the stack pointer by some delta to enlarge the current frame, ... jacob at jacob point remcomp point fr ...
    (comp.lang.c)
  • Re: Is there stack associated when a executing an inline function?
    ... frame since there is no function call. ... moves the stack pointer by some delta to enlarge the current frame, ... termination to release the storage. ...
    (comp.lang.c)
  • Re: need help with stack pointers
    ... subtract the offset value from the current stack pointer value to get the ... You can see evidence of this when the BSR instruction subtracts from the stack pointer as it pushes a return address, and the RTS instruction adds to the stack pointer as it pops that address back into PC. ... So if you're going to establish a frame on "top" of such a stack, you have to avoid the higher addresses which are already in use, and put your frame in locations below the current SP value. ... It would be possible to locate a "frame base" one frame size below the SP value, get that in a register, and index up from there, but that wastes a register for no benefit. ...
    (comp.arch.embedded)