This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Testing m68k changes on AmigaOS and Linux/m68k
On Thu, Oct 23, 2003 at 07:42:24PM +0200, Bernardo Innocenti wrote:
> Gunther Nikl wrote:
> > The approach with the array is nasty :-/ Every usage of such macro
> > will create a distinc array and this will eat up stackspace. Thats
> > why I always disabled these macros.
>
> I don't quite understand. There's (almost) no difference in stack
^^^^^^
Thats the import difference.
> space usage between this:
>
> {
> int v[] = { 1, 2, 3, 4, 5 };
> extern foo(int *);
> foo(v);
> }
>
> ...and this:
>
> {
> extern foo(...);
> foo(1, 2, 3, 4, 5);
> }
>
> With the varargs form, the compiler will push all arguments on the
> stack before calling foo(), effectively wasting the same amount of
> stack space of the local array.
The array is allocated at _frame generation_. Now imagine using a lot
of such calls where every array is only used _one_ time. The varargs
form uses the stackspace only temorary when making the call and cleans
up soon after the call returns.
> When I had to pass a taglist made entirely of constant values, I used to
> do this instead:
>
> {
> static const int tags[] = {...};
> ...
> }
This is of course much better since the array is created a compile time
and placed in readonly-memory.
Gunther