Re: Adding garbage collection to C++

bill@amber.ssd.csd.harris.com (Bill Leonard)
Fri, 14 Aug 1992 21:13:51 GMT

          From comp.compilers

Related articles
Adding garbage collection to C++ Dain.Samples@UC.EDU (1992-08-11)
Re: Adding garbage collection to C++ tmb@arolla.idiap.ch (1992-08-12)
Re: Adding garbage collection to C++ mw@ki.fht-mannheim.de (1992-08-13)
Re: Adding garbage collection to C++ kelvin@kickapoo.cs.iastate.edu (1992-08-13)
Re: Adding garbage collection to C++ fjh@cs.mu.OZ.AU (1992-08-14)
Re: Adding garbage collection to C++ jos@and.nl (1992-08-14)
Re: Adding garbage collection to C++ henry@zoo.toronto.edu (1992-08-14)
Re: Adding garbage collection to C++ bill@amber.ssd.csd.harris.com (1992-08-14)
Re: Adding garbage collection to C++ pardo@cs.washington.edu (1992-08-15)
Re: Adding garbage collection to C++ tmb@idiap.ch (1992-08-17)
Re: Adding garbage collection to C++ tmb@idiap.ch (1992-08-17)
Re: Adding garbage collection to C++ hudson@cs.umass.edu (1992-08-17)
Re: Adding garbage collection to C++ fjh@munta.cs.mu.OZ.AU (1992-08-18)
Re: Adding garbage collection to C++ tmb@arolla.idiap.ch (1992-08-18)
[3 later articles]
| List of all articles for this month |

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
--


Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.