Stack frames

rex ballard rb at ccivax.UUCP
Fri Feb 21 04:27:24 AEST 1986


In article <139200021 at uiucdcsb> robison at uiucdcsb.CS.UIUC.EDU writes:
>
>The output from C compilers I have seen indicates there is no penalty for
>{} blocks with declarations.  All allocation can be done at the function entry.
>I.e., the source code:
>
>     int f(x,y)
>        int x,y;
>	{
>           int a,b;
>	   ...
>	   {
>	      int m,n;
>	      ...
>	   } 
>	   ...
>	}
>
>generates assembly code which allocates a,b,m, and n on the stack upon entry.
>The only difference between a,b and m,n is that m,n is visible
>only within the inner block.

I know of two compilers, one for RT-11, that will allocate the
additional stack space separately.  A 'goto' in or out of an inner
block will cause the stack space to be adjusted before the loop.  This
makes the parser simpler, but requires extra code.  If no
variables are declared, the block is transparent.  Conditional blocks
are better defined inside "allocation local blocks" in this case.



More information about the Comp.lang.c mailing list