Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Tom Tromey <tromey@redhat.com>
To: gdb-patches@sourceware.org
Subject: Re: RFC: reference counting for value
Date: Tue, 07 Jul 2009 14:26:00 -0000	[thread overview]
Message-ID: <m3iqi4r2mv.fsf@fleche.redhat.com> (raw)
In-Reply-To: <20090707014914.GA30559@caradoc.them.org> (Daniel Jacobowitz's message of "Mon\, 6 Jul 2009 21\:49\:14 -0400")

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

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

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

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

Daniel> Is this going to bite us?

Yes, I think so.

Daniel> We could, instead, record release_value
Daniel> references separately from parent references and leave the value on
Daniel> the chain.  But if it doesn't matter, I'd rather not.

Another idea I've been kicking around a bit is to also reference count
the contents.  This would solve this particular problem without
needing a bitfield->parent reference, as the two would just share some
structure.

My reasons for considering this change are, first, it would be more
memory-efficient in some value_copy cases; and, second, I think it
would let us merge val_print and value_print.

I was also thinking that it would help with properly implementing
unavailable pieces via DW_OP_piece (I thought: removing val_print
would make it simpler to handle all this via the value API, and
structure sharing seemed necessary for removing val_print), but now
I'm not as sure.  It is probably just as easy to pass a "valid" bitmap
through the val_print hierarchy.

BTW, I have not checked in the value reference counting patch.  I plan
to it until I've dealt with the python/varojb regression it
introduces.

Tom


  reply	other threads:[~2009-07-07 14:26 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-06-23 20:26 Tom Tromey
2009-07-07  1:49 ` Daniel Jacobowitz
2009-07-07 14:26   ` Tom Tromey [this message]
2009-07-07 14:59     ` Daniel Jacobowitz
2009-07-07 17:03       ` Tom Tromey

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=m3iqi4r2mv.fsf@fleche.redhat.com \
    --to=tromey@redhat.com \
    --cc=gdb-patches@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox