[Gc] Marking memory as traceable
hans.boehm at hp.com
Tue Apr 20 20:42:09 PDT 2010
> From: Ivan Maidanski
> Locks good, IMHO.
> It's up to Hans whether we should have such thing in BDWGC or not.
This basically looks fine to me, especially with Ivan's suggestions. I would probably rename it to something like "RootPtr", to highlight the fact that it can be used to force object retention, as opposed to just having the collector traverse the pointer, as it usually does with normal pointers.
I'm leaning mildly against including it in the distribution, only because I think we have a slightly better solution in the works. C++0x contains an alternate interface "declare_reachable()" that can be implemented by adding the pointer to a global data structure. I'm still planning on checking in an implementation of that as soon as we finally declare 7.2 done. That has the disadvantage that the implementation is a bit more complicated, mostly to allow for multiprocessor scalability, which isn't much of an issue here, since there is no global data structure. It has the advantage that it doesn't add the indirection.
If someone can come up with an argument that this alternative is better in some cases, I'm OK with including it as well. I suspect this interface could be implemented in terms of declare_reachable, which would eliminate the indirection.
More information about the Gc