Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Luis Machado <lgustavo@codesourcery.com>
To: Andreas Arnez <arnez@linux.vnet.ibm.com>, <gdb-patches@sourceware.org>
Subject: Re: [PATCH 3/3] Optimize byte-aligned copies in copy_bitwise()
Date: Mon, 14 Nov 2016 15:38:00 -0000	[thread overview]
Message-ID: <a60ce94a-5256-c4ef-e0a4-23c5383d826b@codesourcery.com> (raw)
In-Reply-To: <1479135786-31150-4-git-send-email-arnez@linux.vnet.ibm.com>

On 11/14/2016 09:02 AM, Andreas Arnez wrote:
> The function copy_bitwise used for copying DWARF pieces can potentially
> be invoked for large chunks of data.  For instance, consider a large
> struct one of whose members is currently located in a register.  In this
> case copy_bitwise would still copy the data bitwise in a loop, which is
> much slower than necessary.
>
> This change uses memcpy for the large part instead, if possible.
>
> gdb/ChangeLog:
>
> 	* dwarf2loc.c (copy_bitwise): Use memcpy for the middle part, if
> 	it is byte-aligned.
> ---
>  gdb/dwarf2loc.c | 27 +++++++++++++++++++++++----
>  1 file changed, 23 insertions(+), 4 deletions(-)
>
> diff --git a/gdb/dwarf2loc.c b/gdb/dwarf2loc.c
> index 3a241a8..26f6bd8 100644
> --- a/gdb/dwarf2loc.c
> +++ b/gdb/dwarf2loc.c
> @@ -1547,11 +1547,30 @@ copy_bitwise (gdb_byte *dest, ULONGEST dest_offset,
>      {
>        size_t len = nbits / 8;
>
> -      while (len--)
> +      /* Use a faster method for byte-aligned copies.  */
> +      if (avail == 0)
>  	{
> -	  buf |= *(bits_big_endian ? source-- : source++) << avail;
> -	  *(bits_big_endian ? dest-- : dest++) = buf;
> -	  buf >>= 8;
> +	  if (bits_big_endian)
> +	    {
> +	      dest -= len;
> +	      source -= len;
> +	      memcpy (dest + 1, source + 1, len);
> +	    }
> +	  else
> +	    {
> +	      memcpy (dest, source, len);
> +	      dest += len;
> +	      source += len;
> +	    }
> +	}
> +      else
> +	{
> +	  while (len--)
> +	    {
> +	      buf |= *(bits_big_endian ? source-- : source++) << avail;

Same as patch 2/3 about the construct.

> +	      *(bits_big_endian ? dest-- : dest++) = buf;
> +	      buf >>= 8;
> +	    }
>  	}
>        nbits %= 8;
>      }
>

Otherwise looks sane to me.


      reply	other threads:[~2016-11-14 15:38 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-11-14 15:03 [PATCH 0/3] Support DW_AT_data_bit_offset Andreas Arnez
2016-11-14 15:04 ` [PATCH 2/3] Fix copy_bitwise() Andreas Arnez
2016-11-14 15:38   ` Luis Machado
2016-11-14 17:54     ` Andreas Arnez
2016-11-14 17:58       ` Luis Machado
2016-11-15 18:58   ` Andreas Arnez
2016-11-15 19:42   ` Pedro Alves
2016-11-17 19:36     ` Andreas Arnez
2016-11-17 20:30       ` Pedro Alves
2016-11-18 15:06         ` Andreas Arnez
2016-11-22 23:18           ` Pedro Alves
2016-11-24 16:15             ` Andreas Arnez
2016-11-24 16:32               ` Pedro Alves
2016-11-24 16:55                 ` Andreas Arnez
2016-11-14 15:04 ` [PATCH 1/3] Fix PR12616 - gdb does not implement DW_AT_data_bit_offset Andreas Arnez
2016-11-14 15:38   ` Luis Machado
2016-11-14 15:05 ` [PATCH 3/3] Optimize byte-aligned copies in copy_bitwise() Andreas Arnez
2016-11-14 15:38   ` Luis Machado [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=a60ce94a-5256-c4ef-e0a4-23c5383d826b@codesourcery.com \
    --to=lgustavo@codesourcery.com \
    --cc=arnez@linux.vnet.ibm.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