From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 19391 invoked by alias); 7 Jul 2009 01:49:26 -0000 Received: (qmail 18983 invoked by uid 22791); 7 Jul 2009 01:49:25 -0000 X-SWARE-Spam-Status: No, hits=-2.5 required=5.0 tests=AWL,BAYES_00 X-Spam-Check-By: sourceware.org Received: from NaN.false.org (HELO nan.false.org) (208.75.86.248) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 07 Jul 2009 01:49:18 +0000 Received: from nan.false.org (localhost [127.0.0.1]) by nan.false.org (Postfix) with ESMTP id 171CD108AF; Tue, 7 Jul 2009 01:49:16 +0000 (GMT) Received: from caradoc.them.org (209.195.188.212.nauticom.net [209.195.188.212]) by nan.false.org (Postfix) with ESMTP id B33F3104E1; Tue, 7 Jul 2009 01:49:15 +0000 (GMT) Received: from drow by caradoc.them.org with local (Exim 4.69) (envelope-from ) id 1MNzo2-00083c-UU; Mon, 06 Jul 2009 21:49:14 -0400 Date: Tue, 07 Jul 2009 01:49:00 -0000 From: Daniel Jacobowitz To: Tom Tromey Cc: gdb-patches@sourceware.org Subject: Re: RFC: reference counting for value Message-ID: <20090707014914.GA30559@caradoc.them.org> Mail-Followup-To: Tom Tromey , gdb-patches@sourceware.org References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.20 (2009-06-14) X-IsSubscribed: yes Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2009-07/txt/msg00168.txt.bz2 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