This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: gc problem with nested functions


On Tue, 30 Nov 1999, Jeffrey A Law wrote:

>   In message <Pine.LNX.4.10.9909131632570.3332-100000@biriani.cygnus.co.uk>you 
> write:
>   > Here's a patch that changes varasm.c so that all constants get allocated on
>   > a different, permanent obstack.  This means we are leaking a bit of memory.
> It could be significant for languages where nested functions are common;
> pascal and modula 2 come immediately to mind, there may be others.

Unfortunately, _all_ constants would be allocated on this new obstack and
never freed.  All languages are affected.

>   > An alternative would be to have per-function obstacks for constants, but
>   > I'm not entirely sure whether this would cause problems for static 
> variables
>   > declared inside a function (i.e. if we allocate constants for their
>   > initializers, do we need to keep these constants around past the
>   > compilation of the enclosing function?).
> I believe you would have to keep the constants, or at least provide some way
> to mark those entries as invalid to prevent a parent function from trying to
> re-use that constant.

I've looked into this after I wrote the above paragraph, and all I got was a
severe case of obstackophobia.  At the moment, I don't see a way that works
correctly and doesn't leak memory in both garbage collected/non garbage
collected compilers.

>   > 	* varasm.c (constants_obstack): New.
>   > 	(init_varasm_once): Initialize it.
>   > 	(immed_double_const): Allocate constants on this obstack.
>   > 	(immed_real_const_1): Likewise.
> I can live with this patch if you're reasonably happy with it.  

Not really happy.  The best solution is to convert all frontends which use
nested functions to use GC as soon as possible.

Bernd


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]