home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.compilers
- Path: sparky!uunet!think.com!spdcc!iecc!compilers-sender
- From: meissner@osf.org
- Subject: Re: Garbage collectable C
- Reply-To: meissner@osf.org
- Organization: Compilers Central
- Date: Wed, 12 Aug 1992 16:12:45 GMT
- Approved: compilers@iecc.cambridge.ma.us
- Message-ID: <92-08-057@comp.compilers>
- References: <92-08-015@comp.compilers> <92-08-045@comp.compilers>
- Keywords: C, storage, GC
- Sender: compilers-sender@iecc.cambridge.ma.us
- Lines: 22
-
- Most of the replies that I have seen about garbage collectable C are ways
- to force variables into the stack (including emacs' GCPRO macros). One
- thought that I've had is to shadow the variables when they get modified.
- Ie, if you have a variable foo that is local to the function, the
- meta-compiler would create both 'foo' and 'shadow_foo' variables, where
- 'shadow_foo' is a structure that contain's foo's current value, and a
- dynamic link to other shadowed structures in this or previous activation
- frames. Whenever 'foo' is modified, you update 'shadow_foo' as well.
- That way, to search for the live values, all you have to do is search the
- shadow chain. Setjmps would be handled by having the setjmp calling
- routines save the current shadow chain head pointer in a volatile
- variable, and restoring it after longjmp yanks you back.
-
- The cost of this method is to have the shadow chains on the stack, the
- initial setup, and an extra store everytime the local variable gets
- changed (and mods usually are rarer than accesses)
- --
- Michael Meissner email: meissner@osf.org phone: 617-621-8861
- Open Software Foundation, 11 Cambridge Center, Cambridge, MA, 02142
- --
- Send compilers articles to compilers@iecc.cambridge.ma.us or
- {ima | spdcc | world}!iecc!compilers. Meta-mail to compilers-request.
-