This is the mail archive of the gcc@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]
Other format: [Raw text]

Question on function-at-a-time and GC


I'm running into problems with the interaction of GC and generating trees for
functions in the presence of nested functions.

It seems to me that you need to generate the entire *file* as a tree before
you can generate code for any function and/or do a GC unless you do peculiar
stuff with local variables.

In Ada, we want to translate the Ada tree directly into a GCC tree.  So for
binary operators, for example, we'd want to translate the LHS into a tree, do
the same for the RHS, then make a new tree node for those.  Indeed this is
what we do now.  The natural way of doing that is something like:

	build_binary_op (translate_ada_to_gnu_tree (lhs),
		         translate_ada_to_gnu_tree (rhs))

But if you do this, you have a serious problem if the second of those calls
to be evaluated contains a nested function because the pointer to the first
tree will be in the local stack and hence subject to GC.

Is it really necessary to put all such temporaries into global variables so
that GC can find it even when evaluating binary operators?

Consider the C case:

int sub1 (int i)
{
  return ({int sub2 (int j) { return j + 7;}; sub2 (12);}) + i;
}

How do the other front ends that support nested functions handle this?  Do
they always avoid using local variables for trees during tree generation, do
they never do a GC until the entire file has been compiled, or do they just
have lots of bugs that haven't been run into yet?


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