This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: RFC: reference counting for value


On Tue, Jun 23, 2009 at 02:26:31PM -0600, Tom Tromey wrote:
> The "increment reference" function is called "release_value" for
> historical reasons (I can change this if anybody cares).  Most code
> does not require any change, as one always had to pair release_value
> and value_free calls anyhow.

IMO it would be nice to rename it (separately).

I am trying to resurrect an old patch of Vladimir's, which gives
bitfield values a parent pointer.  We fetch the parent once, instead
of once per bitfield.  That raised an interesting question:

> +  /* The reference count.  A value that is still on the `all_values'
> +     list will have a reference count of 0.  A call to `release_value'
> +     will increment the reference count (and remove the value from the
> +     list, the first time).  A call to `value_free' will decrement the
> +     reference count, and will free the value when there are no more
> +     references.  */
> +  int refcount;
> +
>    /* Register number if the value is from a register.  */
>    short regnum;
>  

If we release_value the parent every time we create a child, and
value_free it every time we collect a child, the parent will be freed
as soon as its last child is.  This is a change in the value behavior,
because otherwise it would hang around until value_free_to_mark or
free_all_values.

Is this going to bite us?  We could, instead, record release_value
references separately from parent references and leave the value on
the chain.  But if it doesn't matter, I'd rather not.

-- 
Daniel Jacobowitz
CodeSourcery


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]