On 27/08/2014 08:14, Marvin Humphrey wrote:
Haha, this is backwards from how I would have conceived it -- I figured we'd
keep a list of host objects only referenced from C-space.

I think this means we have to differentiate between these two situations:

*   refcount falls to 0 but host wrapper is still live so don't invoke
     Destroy.
*   refcount falls to 0 and no host wrapper exists so invoke Destroy.

Exactly.

A "visit" function which defaults to visiting instance variables which descend
from Obj* could be reused for both "mark" and "destroy".  It could take a
function pointer which either DECREFs or marks before following non-NULL refs.

Classes like Hash and VArray would need custom implementations.

Right, the mark functions could be autogenerated for most classes. But this would mean that we have to visit every Clownfish object in the marking phase, even if it hasn't been passed to the host language.

For a project like Lucy, for example, only a handful of objects will typically cross the host language boundary. Internally, there can easily be tens of thousands, so having to visit all of them would be wasteful.

OTOH, this might allow us to use the host language's GC for all Clownfish objects and make refcounting a no-op which seems like an interesting idea.

Nick

Reply via email to