Quoting Florian Weimer <fwei...@redhat.com>:
On 11/18/2012 07:06 PM, NightStrike wrote:
What's wrong with std::shared_ptr?
The pointer needs two words, and the per-object overhead for the
reference counts etc. is four words, if I'm counting correctly.
(Other forms of reference counting have less overhead, of course, but
you were asking about std::shared_ptr.)
How about we require that in general, use of raw pointers to GC-able objects
are banned, and instead we require the use of a class (maybe obtained
by template?) that is a pointer to the GC-able object, with a
special copy-constructor. The copy-constructor marks the pointed - to
object as live. GC traverses an object by performing a dummy copy and
destroying it.
If we need more than one operation, or mark-things-live when copying
during normal operation causes too much overhead, we could select
operations
to be performed by the copy constructor by adjusting some global state
(need not literally be a global variable - it might be a static member
variable in some class).