From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 5087 invoked by alias); 24 Oct 2003 12:07:14 -0000 Mailing-List: contact gcc-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-owner@gcc.gnu.org Received: (qmail 5079 invoked from network); 24 Oct 2003 12:07:12 -0000 Received: from unknown (HELO kirk.baltic.net) (193.189.247.10) by sources.redhat.com with SMTP; 24 Oct 2003 12:07:12 -0000 Received: (qmail 11110 invoked from network); 24 Oct 2003 12:02:35 -0000 Received: from waldorf.gecko.de (HELO kermit.int.gecko.de) (193.189.247.200) by kirk.baltic.net with SMTP; 24 Oct 2003 12:02:35 -0000 Received: from lorien.int.gecko.de (lorien [192.168.120.159]) by kermit.int.gecko.de (8.10.1/8.10.1) with ESMTP id h9OC9b727366; Fri, 24 Oct 2003 14:09:37 +0200 (MET DST) Received: from lorien.int.gecko.de (localhost [127.0.0.1]) by lorien.int.gecko.de (8.12.9/8.12.9) with ESMTP id h9OC7KqR030850; Fri, 24 Oct 2003 14:07:20 +0200 (MEST) (envelope-from munk@lorien.int.gecko.de) Received: (from munk@localhost) by lorien.int.gecko.de (8.12.9/8.12.9/Submit) id h9OC7KtG030849; Fri, 24 Oct 2003 14:07:20 +0200 (MEST) Date: Fri, 24 Oct 2003 13:49:00 -0000 From: Gunther Nikl To: Bernardo Innocenti Cc: GCC Mailing List Subject: Re: Testing m68k changes on AmigaOS and Linux/m68k Message-ID: <20031024120720.GA30830@lorien.int.gecko.de> References: <3F8C28AE.4060301@develer.com> <20031015093247.GA41502@lorien.int.gecko.de> <20031015164848.GA7684@lorien.int.gecko.de> <3F8D97C6.5020406@develer.com> <20031016133157.GA14232@lorien.int.gecko.de> <3F8ECE9E.1080500@develer.com> <20031021120030.GA31365@lorien.int.gecko.de> <3F9570DD.4050700@develer.com> <20031023131324.GA28408@lorien.int.gecko.de> <3F981300.9030306@develer.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <3F981300.9030306@develer.com> User-Agent: Mutt/1.4.1i X-SW-Source: 2003-10/txt/msg01185.txt.bz2 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