public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Richard Henderson <rth@redhat.com>
To: Aldy Hernandez <aldyh@redhat.com>
Cc: gcc-patches@gcc.gnu.org
Subject: Re: [trans-mem] implement _ITM_dropReferences
Date: Wed, 23 Jun 2010 19:29:00 -0000	[thread overview]
Message-ID: <4C22597E.3030009@redhat.com> (raw)
In-Reply-To: <20100623171245.GA19259@redhat.com>

On 06/23/2010 10:12 AM, Aldy Hernandez wrote:
> +void ITM_REGPARM
> +_ITM_dropReferences (const void *ptr, size_t len)
> +{
> +  gtm_transaction *tx = gtm_tx();
> +  tx->drop_references_local (ptr, len);
> +  tx->drop_references_allocations (ptr);
> +}

The primary thing missing here is dropping references inside
the actual transactional memory backend, i.e. gtm_dispatch.

> +/* Forget any references to PTR in the allocations tree.
> +
> +   ?? We ignore the chunk length.  Pray this doesn't wreck havoc.  */
> +
> +void
> +gtm_transaction::drop_references_allocations (const void *ptr)
> +{
> +  uintptr_t iptr = (uintptr_t) ptr;
> +
> +  gtm_alloc_action *a = this->alloc_actions.find(iptr);
> +  if (a == 0)
> +    {
> +      a = this->alloc_actions.insert(iptr);
> +      a->free_fn = NULL;
> +      a->allocated = false;
> +    }
> +
> +  a->ignore = true;
> +}

Why add the ignore field when you could simply alloc_actions.erase?

> @@ -65,13 +66,36 @@ gtm_transaction::rollback_local (void)
>        for (i = n; i-- > 0; )
>  	{
>  	  gtm_local_undo *u = local_undo[i];
> -	  memcpy (u->addr, u->saved, u->len);
> +	  if (!u->ignore)
> +	    memcpy (u->addr, u->saved, u->len);
>  	  free (u);
>  	}
>        this->n_local_undo = 0;
>      }
>  }
>  
> +/* Forget any references to PTR in the local log.  */
> +
> +void
> +gtm_transaction::drop_references_local (const void *ptr, size_t len)
> +{
> +  gtm_local_undo **local_undo = this->local_undo;
> +  size_t i, n = this->n_local_undo;
> +
> +  if (n > 0)
> +    {
> +      for (i = n; i > 0; i--)
> +	{
> +	  gtm_local_undo *u = local_undo[i];
> +	  /* ?? Do we need such granularity, or can we get away with
> +	     just comparing PTR and LEN. ??  */
> +	  if ((const char *)u->addr >= (const char *)ptr
> +	      && ((const char *)u->addr + u->len <= (const char *)ptr + len))
> +	    u->ignore = true;
> +	}
> +    }
> +}

Similarly, it seems easy enough to free the one element and test instead
in rollback_local for u == NULL.



r~

  reply	other threads:[~2010-06-23 18:59 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-06-23 17:49 Aldy Hernandez
2010-06-23 19:29 ` Richard Henderson [this message]
2010-06-24 16:47   ` Aldy Hernandez
2010-06-24 17:42     ` Richard Henderson
2010-06-24 17:58       ` Aldy Hernandez

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=4C22597E.3030009@redhat.com \
    --to=rth@redhat.com \
    --cc=aldyh@redhat.com \
    --cc=gcc-patches@gcc.gnu.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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).