home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #18 / NN_1992_18.iso / spool / comp / compiler / 1358 < prev    next >
Encoding:
Text File  |  1992-08-12  |  1.7 KB  |  37 lines

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