From patchwork Wed May 27 13:56:46 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Martin_Li=C5=A1ka?= X-Patchwork-Id: 477148 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 7B16914029D for ; Thu, 28 May 2015 00:17:46 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=kgMcEqmN; dkim-atps=neutral DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :resent-from:resent-to:resent-date:resent-message-id:message-id :in-reply-to:references:from:date:subject:to; q=dns; s=default; b= hOvekXB/lgOphkIA1UDufRXPiPeoI4dPcXtwa61lUBRvGD7EuuQfpPqqFhEa6QgI zmvlNf/lebEpxvS60tWI/4U0XApLmvOH4IekaU6FKZYmmUjs2nyvLEUmMTcTfaRE Yz9RlKa/n3Q5m4/H3CMyegfcWMPr6cz4TewNrNcTzuQ= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :resent-from:resent-to:resent-date:resent-message-id:message-id :in-reply-to:references:from:date:subject:to; s=default; bh=nRqo NZm//BWJEkx4SruTjeHux7I=; b=kgMcEqmNOZaYOXJ/LwlTaKFrTuVOkX6fjIOc 2CDb4ByIQV+l+6P8lrdcheLwOM/lOR8mFIz6z4T6F2/s4rAxjhRZhlWD9lGtRxvO g1/dWtLqtUb9ZASX3oIahX5OsMb8zUBGvj0kpvDWI0lQu+XDACuiCKqyZDN99v/F +60oUXI= Received: (qmail 87827 invoked by alias); 27 May 2015 14:16:58 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 87736 invoked by uid 89); 27 May 2015 14:16:58 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=0.7 required=5.0 tests=AWL, BAYES_50, KAM_LAZY_DOMAIN_SECURITY autolearn=no version=3.3.2 X-HELO: eggs.gnu.org Received: from eggs.gnu.org (HELO eggs.gnu.org) (208.118.235.92) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-SHA encrypted) ESMTPS; Wed, 27 May 2015 14:16:53 +0000 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YxbsI-0007Bu-3B for gcc-patches@gcc.gnu.org; Wed, 27 May 2015 10:00:09 -0400 Received: from cantor2.suse.de ([195.135.220.15]:57515 helo=mx2.suse.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YxbsH-00078k-Lx for gcc-patches@gcc.gnu.org; Wed, 27 May 2015 10:00:02 -0400 Received: from relay1.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id DB462ADF2 for ; Wed, 27 May 2015 13:59:56 +0000 (UTC) Resent-From: =?UTF-8?B?TWFydGluIExpxaFrYQ==?= Resent-To: GCC Patches Resent-Date: Wed, 27 May 2015 15:59:56 +0200 Resent-Message-ID: <5565CDDC.7020707@suse.cz> Resent-User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.6.0 Message-Id: <33da40026598d852ceb57720468b82a3c85f2d7b.1432735040.git.mliska@suse.cz> In-Reply-To: <83d59ba92a3c4b3ba831ebc2fce325f0416848d0.1432735040.git.mliska@suse.cz> References: <83d59ba92a3c4b3ba831ebc2fce325f0416848d0.1432735040.git.mliska@suse.cz> From: mliska Date: Wed, 27 May 2015 15:56:46 +0200 Subject: [PATCH 08/35] Change use to type-based pool allocator in asan.c. To: gcc-patches@gcc.gnu.org X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x (no timestamps) [generic] X-Received-From: 195.135.220.15 X-IsSubscribed: yes gcc/ChangeLog: 2015-04-30 Martin Liska * asan.c (asan_mem_ref_get_alloc_pool):Use new type-based pool allocator. (asan_mem_ref_new) Likewise. (free_mem_ref_resources) Likewise. --- gcc/asan.c | 44 ++++++++++++++++++++------------------------ 1 file changed, 20 insertions(+), 24 deletions(-) diff --git a/gcc/asan.c b/gcc/asan.c index 479301a..19c8d95 100644 --- a/gcc/asan.c +++ b/gcc/asan.c @@ -176,7 +176,7 @@ along with GCC; see the file COPYING3. If not see where '(...){n}' means the content inside the parenthesis occurs 'n' times, with 'n' being the number of variables on the stack. - + 3/ The following 8 bytes contain the PC of the current function which will be used by the run-time library to print an error message. @@ -281,7 +281,7 @@ bool set_asan_shadow_offset (const char *val) { char *endp; - + errno = 0; #ifdef HAVE_LONG_LONG asan_shadow_offset_value = strtoull (val, &endp, 0); @@ -372,23 +372,24 @@ struct asan_mem_ref /* The size of the access. */ HOST_WIDE_INT access_size; -}; -static alloc_pool asan_mem_ref_alloc_pool; + /* Pool allocation new operator. */ + inline void *operator new (size_t) + { + return pool.allocate (); + } -/* This creates the alloc pool used to store the instances of - asan_mem_ref that are stored in the hash table asan_mem_ref_ht. */ + /* Delete operator utilizing pool allocation. */ + inline void operator delete (void *ptr) + { + pool.remove((asan_mem_ref *) ptr); + } -static alloc_pool -asan_mem_ref_get_alloc_pool () -{ - if (asan_mem_ref_alloc_pool == NULL) - asan_mem_ref_alloc_pool = create_alloc_pool ("asan_mem_ref", - sizeof (asan_mem_ref), - 10); - return asan_mem_ref_alloc_pool; - -} + /* Memory allocation pool. */ + static pool_allocator pool; +}; + +pool_allocator asan_mem_ref::pool ("asan_mem_ref", 10); /* Initializes an instance of asan_mem_ref. */ @@ -408,8 +409,7 @@ asan_mem_ref_init (asan_mem_ref *ref, tree start, HOST_WIDE_INT access_size) static asan_mem_ref* asan_mem_ref_new (tree start, HOST_WIDE_INT access_size) { - asan_mem_ref *ref = - (asan_mem_ref *) pool_alloc (asan_mem_ref_get_alloc_pool ()); + asan_mem_ref *ref = new asan_mem_ref; asan_mem_ref_init (ref, start, access_size); return ref; @@ -501,11 +501,7 @@ free_mem_ref_resources () delete asan_mem_ref_ht; asan_mem_ref_ht = NULL; - if (asan_mem_ref_alloc_pool) - { - free_alloc_pool (asan_mem_ref_alloc_pool); - asan_mem_ref_alloc_pool = NULL; - } + asan_mem_ref::pool.release (); } /* Return true iff the memory reference REF has been instrumented. */ @@ -2035,7 +2031,7 @@ maybe_instrument_assignment (gimple_stmt_iterator *iter) is_store); is_instrumented = true; } - + if (gimple_assign_load_p (s)) { ref_expr = gimple_assign_rhs1 (s);