Newsgroups: | comp.compilers |
From: | bill@amber.ssd.csd.harris.com (Bill Leonard) |
Organization: | Harris CSD, Ft. Lauderdale, FL |
Date: | Fri, 14 Aug 1992 21:13:51 GMT |
References: | 92-08-044 92-08-068 |
Keywords: | C++, GC |
kelvin@kickapoo.cs.iastate.edu (Kelvin Don Nilsen) writes:
> >[I'd be interested how you trace through unions containing pointers. -John]
>
> We have implemented copying garbage collection for the C++ language
> standard, making only a few minor restrictions on normal C++ usage. We
> are able, for example, to compile Gnu groff by fixing fewer than five
> "sloppy" programming tricks. We handle unions that may contain either
> pointers or raw seething bits by adding an explicit tag to distinguish
> between the two. Each assignment to one of these unions incurs the cost
> of updating the tag. We do not check the tag on reads. Further, we do
> not update the tag if the union is known always to contain pointers, or
> always to contain raw seething bits.
This would be a pretty nasty thing to do if one is using the union to map
data stored in an external device, such as data read from a file or in the
case of memory-mapped I/O. You may consider this a "minor restriction",
but there are many programmers, whose applications would become invalid,
who would disagree with you.
We have come across another case wherein garbage collection becomes
difficult, if not impossible. We have two C++ programs that communicate
through shared memory. There are some cases where program A allocates an
object, then sends a pointer to that object (through shared memory) to
program B, who stores the pointer in a variable that does not reside in
shared memory. Program A then forgets about the object (i.e., it retains
no pointers to it). Program B will randomly send messages to this object
by sending the pointer back over to program A, but otherwise program A
will have no references to this object in *its* address space.
I think you basically have to give up on garbage collecting such strange
objects. But their existence forces me to advocate that garbage
collection only happen if I specifically ask for it (thus begging for
language extensions), rather than automatically.
--
Bill Leonard
Harris Computer Systems Division
2101 W. Cypress Creek Road
Fort Lauderdale, FL 33309
bill@ssd.csd.harris.com
--
Return to the
comp.compilers page.
Search the
comp.compilers archives again.