Value reference counting

Tom Tromey tromey@redhat.com
Fri Jul 17 19:04:00 GMT 2009


>>>>> "Daniel" == Daniel Jacobowitz <drow@false.org> writes:

Daniel> This patch, based on an old patch from Vladimir, implements
Daniel> reference counting for values.  Tom, this is the approach I
Daniel> discussed with you on IRC: instead of treating the value chain
Daniel> as a normal reference and using release_value to take
Daniel> references, this separates the value chain (which is boolean; a
Daniel> value is either on it or not) from references (which are
Daniel> counted).

Daniel> So you take a reference with value_incref.  release_value
Daniel> transforms the value chain's reference into a normal reference.
Daniel> That's an entirely theoretical operation, by which I mean
Daniel> release_value doesn't have to do anything special.

Daniel> Does this look OK?  Tom, will it work for the Python code?

This will work fine for Python.  Also, I think that this model is
clearer than what I did.

It seems to me that at this point, release_value is doing a walk of a
linked list for no particular benefit.  Suppose we deleted release_value
and replaced all calls to it with calls to value_incref?

This might result in some values living slightly longer than they
otherwise would have (they will live until free_all_values, whereas
currently they will be deleted at value_free time, which might or might
not be sooner).

The only thing I could think of is whether this would affect watchpoint
operation, since IIUC the watchpoint code examines all_values.  But, if
this problem exists, it could be worked around by examining the
reference count of values on the chain.

What do you think?

Tom



More information about the Gdb-patches mailing list