home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!cis.ohio-state.edu!pacific.mps.ohio-state.edu!zaphod.mps.ohio-state.edu!uakari.primate.wisc.edu!sdd.hp.com!wupost!gumby!yale!mintaka.lcs.mit.edu!spdcc!iecc!compilers-sender
- From: bill@amber.ssd.csd.harris.com (Bill Leonard)
- Newsgroups: comp.compilers
- Subject: Re: Adding garbage collection to C++
- Keywords: C++, GC
- Message-ID: <92-08-076@comp.compilers>
- Date: 14 Aug 92 21:13:51 GMT
- References: <92-08-044@comp.compilers> <92-08-068@comp.compilers>
- Sender: compilers-sender@iecc.cambridge.ma.us
- Reply-To: bill@amber.ssd.csd.harris.com (Bill Leonard)
- Organization: Harris CSD, Ft. Lauderdale, FL
- Lines: 42
- Approved: compilers@iecc.cambridge.ma.us
-
- 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
- --
- Send compilers articles to compilers@iecc.cambridge.ma.us or
- {ima | spdcc | world}!iecc!compilers. Meta-mail to compilers-request.
-