Path: utzoo!mnetor!tmsoft!torsqnt!news-server.csri.toronto.edu!cs.utexas.edu!sun-barr!olivea!uunet!cbmvax!cbmehq!cbmdeo!lenler!moria!bojsen From: bojsen@moria.UUCP (Per Bojsen) Newsgroups: comp.sys.amiga.programmer Subject: Re: AmigaGCC stack hogging Keywords: alloca(), GNU, gcc, alloca.c, Gwyn Message-ID: <188c411d.ARN1c22@moria.UUCP> Date: 19 Jan 91 16:21:33 GMT References: <1882f287.ARN1979@moria.UUCP> <1991Jan14.212254.9779@csun.edu> <18887df5.ARN1ad7@moria.UUCP> <1991Jan17.141218.19953@zorch.SF-Bay.ORG> Reply-To: bojsen@moria.UUCP Followup-To: comp.sys.amiga.programmer Organization: IDUN-Soft Aps. Lines: 62 Distribution: In article <1991Jan17.141218.19953@zorch.SF-Bay.ORG>, Kent Paul Dolan writes: > bojsen@moria.UUCP writes: > > > Using this special version of alloca() should make it possible to > > reduce the stack needs of the GNU utilities substantially, so my > > question stands: does the Amiga ports of gcc use this > > non-stack-allocating alloca(), or do they allocate _on_ the stack? > > Maybe I'm missing the point here. The _purpose_ of alloca() is to > allow extremely low overhead grabbing and releasing of extremely > temporary memory, and to do a super cheap form of resource tracking. > Yes, I understand that! However, in the case of Amiga, see below. > Why replace it by putting back something that installs the very same > problems alloca() was trying to solve, and possibly gets you into other > trouble if code makes assumptions that things pushed on the stack and > things alloca()ed on the stack are in consecutive storage locations? > Ok, Gwyn's alloca() implementation will break if the code makes such `nasty' assumptions . . . Are you aware of any such code in GNU? > If the gnu code is doing inappropriate things with alloca() replace the > calls with malloc() calls explicitly. Otherwise you are just creating > big performance hits that will have to be cleared up by still further > efforts later on. > Here is why I think Gwyn's alloca() would be better on the Amiga under the current OS versions (including 2.0): * The stack does not grow automatically. * It is _dangerous_ to fall off the bottom of the stack. * It is usually difficult to predict how much stack a specific invocation of a command, like gcc, needs. So you'll have to allocate `enough' stack, which usually is too much, i.e., there is some amount of resource wasting, although it's possible to live with if you have RAM enough. * Gwyn's alloca() _does_ track memory resources, and releases memory previously allocated in the way one would expect (almost). So, for the time being---when the AmigaOS does not grow stacks---I would prefer Gwyn's approach. I don't think your point about the `bad' assumptions on relative alignment of alloca()'ed blocks is valid for the various GNU programs, because Gwyn's alloca() is distributed with most GNU products including gcc, gawk, diff, and gnused; I assume FSF wouldn't distribute this module with the programs if it didn't work. Well, that's just my opinion, and given that I have the source, I can allways recompile the different programs using the alloca() that I want, so there's really no problem! -- .------------------------------------------------------------------------------. | Greetings from Per Bojsen. | +-------------------------------+----------------------------------------------+ | EMail: cbmehq!lenler!bojsen |"Zen is a feeling. It's the feeling you get | | Or: bojsen@dc.dth.dk | when you know you're going to get a feeling."| `-------------------------------+----------------------------------------------'