From: Andreas Arnez <arnez@linux.vnet.ibm.com>
To: gdb-patches@sourceware.org
Subject: [PATCH 3/3] Optimize byte-aligned copies in copy_bitwise()
Date: Mon, 14 Nov 2016 15:05:00 -0000 [thread overview]
Message-ID: <1479135786-31150-4-git-send-email-arnez@linux.vnet.ibm.com> (raw)
In-Reply-To: <1479135786-31150-1-git-send-email-arnez@linux.vnet.ibm.com>
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;
+ *(bits_big_endian ? dest-- : dest++) = buf;
+ buf >>= 8;
+ }
}
nbits %= 8;
}
--
2.3.0
next prev parent reply other threads:[~2016-11-14 15:05 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 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: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:05 ` Andreas Arnez [this message]
2016-11-14 15:38 ` [PATCH 3/3] Optimize byte-aligned copies in copy_bitwise() Luis Machado
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=1479135786-31150-4-git-send-email-arnez@linux.vnet.ibm.com \
--to=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