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 17:03:00 -0000	[thread overview]
Message-ID: <m3vdm4pgs0.fsf@fleche.redhat.com> (raw)
In-Reply-To: <20090707145930.GA18388@caradoc.them.org> (Daniel Jacobowitz's message of "Tue\, 7 Jul 2009 10\:59\:30 -0400")

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

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

Daniel> Would it?  We need to be able to fetch the contents in response to a
Daniel> request from the bitfield, so everything needed to unlazy would
Daniel> have to be in the shared structure; I guess that's address and length,
Daniel> here.  Also lval type.  Would we have to duplicate these in the value
Daniel> and the shared contents?

I hadn't been thinking about the lazy case, but after thinking about
it a bit, it still doesn't seem so bad to me.

Yeah, you'd have to push this stuff into the contents (lval type?  I
dunno).

Something like

struct value_contents
{
  enum lval_type lval : 8;
  unsigned int lazy : 1;
  unsigned int refcount : 23;  // or whatever
  CORE_ADDR address;
  gdb_byte contents[1];  // should perhaps use the aligner stuff from before
};

struct value
{
...
  struct value_contents *contents;
}

value::offset would continue to be an offset into the contents; when
doing something like a field reference, we'd make a new reference to
'contents' and set the offset in the new value appropriately.

For unavailable pieces, we'd also stick the validity bitmap (or
something) into value_contents.

Daniel> If two values have a shared contents structure, I'm not sure
Daniel> what point there is having them different value structures in
Daniel> the first place.

To act as a content cache, so we can avoid duplicating large contents
when copying (and slicing, etc) values and avoid (as in your case)
redundant fetches.

Some other caching approach may work just as well.  That's how I
understand the parent-pointer idea as well -- a specialized cache.

I'm not really wedded to this.  I'm not even sure I want to get rid of
val_print -- I find it to be a strange wart, but it would probably be
a lot of work for not much benefit (unless it really does simplify the
unavailable piece thing).

Tom


      reply	other threads:[~2009-07-07 17:03 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
2009-07-07 14:59     ` Daniel Jacobowitz
2009-07-07 17:03       ` Tom Tromey [this message]

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=m3vdm4pgs0.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