home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #18 / NN_1992_18.iso / spool / comp / lang / cplus / 12622 < prev    next >
Encoding:
Internet Message Format  |  1992-08-19  |  3.4 KB

  1. Path: sparky!uunet!synaptx!synaptics.com!daveg
  2. From: daveg@synaptics.com (Dave Gillespie)
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: Garbage Collection for C++
  5. Message-ID: <DAVEG.92Aug20024954@synaptx.synaptics.com>
  6. Date: 20 Aug 92 09:49:54 GMT
  7. References: <1992Aug6.014619.2111@ucc.su.OZ.AU>
  8.     <DAVEG.92Aug13025629@synaptx.synaptics.com>
  9.     <1992Aug14.021547.15215@news.mentorg.com>
  10.     <DAVEG.92Aug14194411@synaptx.synaptics.com> <2009@appli.se>
  11.     <TMB.92Aug17204854@arolla.idiap.ch> <2135@appli.se>
  12. Sender: daveg@synaptx.Synaptics.Com
  13. Organization: Synaptics, Inc., San Jose, CA
  14. Lines: 63
  15. In-reply-to: niklas@appli.se's message of 19 Aug 92 08:54:52 GMT
  16.  
  17. In article <2135@appli.se> niklas@appli.se (Niklas Hallqvist) writes:
  18.  
  19. > >niklas@appli.se (Niklas Hallqvist) writes:
  20.  
  21. >>   Instead of having two pointers
  22. >>   for the link in each node, take the "previous" and "next" pointers
  23. >>   and XOR them, and store the result!
  24.  
  25. >> You didn't take that seriously, did you? In any case, it's an old hat
  26. >> and it's unportable (*).
  27.  
  28. > Well, I did mean it seriously, in order to show C++ rules need to be changed
  29. > to allow even conservative GC.  It's only unportable between environments
  30. > which don't have sufficiently sized integers to store pointers in.  If you
  31. > restrict your program to only work on more "normal" architectures it IS
  32. > defined.  Read ARM 5.4!
  33.  
  34. Well, being semi-portable doesn't stop it from being completely
  35. demented.  :-)
  36.  
  37. > Of course, this means conservative GC is
  38. > implementable on architectures where no integer type can hold a void pointer,
  39. > but otherwise it is NOT.  Do I miss anything in my thinking?
  40.  
  41. No, it's implementable only if you include some fine print warning that
  42. such tricks will fool the garbage collector.  After all, there will
  43. always be *some* things the garbage collector won't be able to get:
  44. Suppose you allocate an object, mail its hex address to another user,
  45. and then refer to it later when the user mails back a request including
  46. that address?  (Not a good idea, I know, but it's a simple example of
  47. the sorts of unusual cases one would run into.  By Max Skaller's
  48. description, Microsoft Windows sounds like one of those "unusual"
  49. cases...)
  50.  
  51. It would probably be wise to say that any pointer which is stored as
  52. an integer (or other non-pointer type) is not GC-safe.  This allows
  53. the compiler to put non-pointers in a different area of memory that
  54. the GC doesn't need to scan, if it so chooses.
  55.  
  56. The point is, saying you can't make a 100% bulletproof garbage
  57. collector should not be enough to veto the idea in C++.  It should
  58. be enough to show that a) if you live by a fairly reasonable and
  59. well-defined set of rules of "decent behavior," the feature will
  60. work, and b) if you choose to ignore those rules, but don't use
  61. the new feature anyway, it won't matter.  The latter is one of the
  62. main reason I think GC-able allocation should be something a
  63. program has to ask for, not the default.
  64.  
  65. > So you had read this section, and still think GC can be done, if the text
  66. > isn't changed to something like:
  67.  
  68. > "All pointer to integer conversions and back are implementation defined."
  69.  
  70. How about "it is unsafe to cast a pointer to GC-allocated object to
  71. a non-pointer type."  Even this is conservative, and I don't think
  72. anybody would mind this mild restriction.  As long as GC-allocated
  73. objects only come by explicit request, no old code will be broken.
  74.  
  75.                                 -- Dave
  76. --
  77. Dave Gillespie
  78.   daveg@synaptics.com, uunet!synaptx!daveg
  79.   or: daveg@csvax.cs.caltech.edu
  80.