Newsgroups: | comp.compilers |
From: | nfsun!gchamber@uunet.UU.NET (Glenn Chambers) |
Organization: | Intelligent Technology Group, Pittsburgh, PA |
Date: | Tue, 4 Aug 1992 11:43:33 GMT |
References: | 92-07-064 92-08-004 |
Keywords: | translator, design |
>[Somebody suggested that it might be possible to define some extensions to
>C that would make it easier to garbage collect. Any thoughts? -John]
In the interests of getting the obvious out of the way, the easiest
optimization is to allocate global and static local variables that point
to GC'able objects in a special data area that the GC system knows about.
Auto local can be dealt with by maintaining two stacks: non-pointer and
pointer, at a relatively minor cost.
This leaves, of course the minor problem of finding pointers inside of the
pointed-to structs. The much nastier problem of finding them inside of
unions is probably avoidable in the current case, as we're talking about
'C-as-intermediate-code', and the parent code-generator can presumably be
coded not to use unions.
Adding a '#pragma flush-registers' to deal with the optimizer seems to be
the only actual extension to the language that I can see. One would put
this just before a call to any function that could perform memory
allocation. Absent some kind of global optimizer, this would, of course,
be all of them, with a possibly non-trivial loss of performance.
Is there some simpler and cheaper technique I'm unaware of?
--
Return to the
comp.compilers page.
Search the
comp.compilers archives again.