From patchwork Mon Nov 14 15:02:26 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Arnez X-Patchwork-Id: 17458 Received: (qmail 61448 invoked by alias); 14 Nov 2016 15:05:18 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 61434 invoked by uid 89); 14 Nov 2016 15:05:17 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.5 required=5.0 tests=AWL, BAYES_00, KAM_LAZY_DOMAIN_SECURITY, RCVD_IN_DNSWL_LOW autolearn=no version=3.3.2 spammy=2.3.0, dwarf2locc, dwarf2loc.c, UD:dwarf2loc.c X-HELO: mx0a-001b2d01.pphosted.com Received: from mx0b-001b2d01.pphosted.com (HELO mx0a-001b2d01.pphosted.com) (148.163.158.5) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 14 Nov 2016 15:05:16 +0000 Received: from pps.filterd (m0098421.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.17/8.16.0.17) with SMTP id uAEF4bMC114062 for ; Mon, 14 Nov 2016 10:05:15 -0500 Received: from e06smtp08.uk.ibm.com (e06smtp08.uk.ibm.com [195.75.94.104]) by mx0a-001b2d01.pphosted.com with ESMTP id 26qdekeq1w-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Mon, 14 Nov 2016 10:05:14 -0500 Received: from localhost by e06smtp08.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 14 Nov 2016 15:05:13 -0000 Received: from d06dlp03.portsmouth.uk.ibm.com (9.149.20.15) by e06smtp08.uk.ibm.com (192.168.101.138) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Mon, 14 Nov 2016 15:05:09 -0000 Received: from b06cxnps3074.portsmouth.uk.ibm.com (d06relay09.portsmouth.uk.ibm.com [9.149.109.194]) by d06dlp03.portsmouth.uk.ibm.com (Postfix) with ESMTP id CCF431B0806E for ; Mon, 14 Nov 2016 15:07:23 +0000 (GMT) Received: from d06av04.portsmouth.uk.ibm.com (d06av04.portsmouth.uk.ibm.com [9.149.37.216]) by b06cxnps3074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id uAEF58Ak43253878 for ; Mon, 14 Nov 2016 15:05:08 GMT Received: from d06av04.portsmouth.uk.ibm.com (localhost [127.0.0.1]) by d06av04.portsmouth.uk.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id uAEF58Jt016530 for ; Mon, 14 Nov 2016 08:05:08 -0700 Received: from oc1027705133.ibm.com (dyn-9-152-212-182.boeblingen.de.ibm.com [9.152.212.182]) by d06av04.portsmouth.uk.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with ESMTP id uAEF37dk016044 for ; Mon, 14 Nov 2016 08:05:08 -0700 From: Andreas Arnez To: gdb-patches@sourceware.org Subject: [PATCH 3/3] Optimize byte-aligned copies in copy_bitwise() Date: Mon, 14 Nov 2016 16:02:26 +0100 In-Reply-To: <1479135786-31150-1-git-send-email-arnez@linux.vnet.ibm.com> References: <1479135786-31150-1-git-send-email-arnez@linux.vnet.ibm.com> X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 16111415-0032-0000-0000-00000241DB09 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 16111415-0033-0000-0000-00001DB7772A Message-Id: <1479135786-31150-4-git-send-email-arnez@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2016-11-14_09:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=1 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1609300000 definitions=main-1611140308 X-IsSubscribed: yes 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; }