From patchwork Wed May 27 13:56:44 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: 477127 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 4142A14029D for ; Thu, 28 May 2015 00:00:54 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=K2AqMeVX; 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= oySvEGbjN4YFNMtazOjHMqcm2wrjkPNHFf+PEiGho4TwJuOmTcZITHaP3YpMw7Uy dmh/E+RhZdOCe0i3bBMZsImpRxF1PDv+bCfyEUy3ou2DP3kdB2FrYOK0xxb1KWPw QITIkoc0E4rK+gzFcnFvMpBLuGtPVyyIvTs8wcYFz7g= 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=DCBD aOz1H/owYRFkol1ORR6s6N4=; b=K2AqMeVXMIo193+gHu9CoDw61h/mGy97R6hF Awrfp3jpZlwp/Yvfq2QcV3dWRh0iGOhfrnbs8agRaNVlQ48x0RQW4+odC9xlIYLw cPq2P4OiF0OK34SjdBL/XMABTr276m7J2hh+yT7xzV6HlW4QM/z6x46Dc0Elu2ty 0hJoKx4= Received: (qmail 69753 invoked by alias); 27 May 2015 14:00:10 -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 69321 invoked by uid 89); 27 May 2015 14:00:06 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=0.6 required=5.0 tests=AWL, BAYES_50, KAM_LAZY_DOMAIN_SECURITY autolearn=no version=3.3.2 X-HELO: mx2.suse.de Received: from cantor2.suse.de (HELO mx2.suse.de) (195.135.220.15) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (CAMELLIA256-SHA encrypted) ESMTPS; Wed, 27 May 2015 13:59:59 +0000 Received: from relay2.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 8EC05ADEE 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.80906@suse.cz> Resent-User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.6.0 Message-Id: <5036c3a4b12a867a32cd3b53ad43a0e9f152fef4.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:44 +0200 Subject: [PATCH 02/35] Change use to type-based pool allocator in et-forest.c. To: gcc-patches@gcc.gnu.org X-IsSubscribed: yes gcc/ChangeLog: 2015-04-30 Martin Liska * et-forest.c (et_new_occ): Use new type-based pool allocator. (et_new_tree): Likewise. (et_free_tree): Likewise. (et_free_tree_force): Likewise. (et_free_pools): Likewise. (et_split): Likewise. --- gcc/dominance.c | 1 + gcc/et-forest.c | 48 +++++++++++++++++++++++++++++------------------- gcc/et-forest.h | 15 +++++++++++++++ 3 files changed, 45 insertions(+), 19 deletions(-) diff --git a/gcc/dominance.c b/gcc/dominance.c index 09c8c90..f3c99ba 100644 --- a/gcc/dominance.c +++ b/gcc/dominance.c @@ -51,6 +51,7 @@ #include "cfganal.h" #include "basic-block.h" #include "diagnostic-core.h" +#include "alloc-pool.h" #include "et-forest.h" #include "timevar.h" #include "hash-map.h" diff --git a/gcc/et-forest.c b/gcc/et-forest.c index da6b7d7..fd451b8 100644 --- a/gcc/et-forest.c +++ b/gcc/et-forest.c @@ -25,8 +25,8 @@ License along with libiberty; see the file COPYING3. If not see #include "config.h" #include "system.h" #include "coretypes.h" -#include "et-forest.h" #include "alloc-pool.h" +#include "et-forest.h" /* We do not enable this with ENABLE_CHECKING, since it is awfully slow. */ #undef DEBUG_ET @@ -59,10 +59,26 @@ struct et_occ on the path to the root. */ struct et_occ *min_occ; /* The occurrence in the subtree with the minimal depth. */ + + /* Pool allocation new operator. */ + inline void *operator new (size_t) + { + return pool.allocate (); + } + + /* Delete operator utilizing pool allocation. */ + inline void operator delete (void *ptr) + { + pool.remove((et_occ *) ptr); + } + + /* Memory allocation pool. */ + static pool_allocator pool; + }; -static alloc_pool et_nodes; -static alloc_pool et_occurrences; +pool_allocator et_node::pool ("et_nodes pool", 300); +pool_allocator et_occ::pool ("et_occ pool", 300); /* Changes depth of OCC to D. */ @@ -449,11 +465,7 @@ et_splay (struct et_occ *occ) static struct et_occ * et_new_occ (struct et_node *node) { - struct et_occ *nw; - - if (!et_occurrences) - et_occurrences = create_alloc_pool ("et_occ pool", sizeof (struct et_occ), 300); - nw = (struct et_occ *) pool_alloc (et_occurrences); + et_occ *nw = new et_occ; nw->of = node; nw->parent = NULL; @@ -474,9 +486,7 @@ et_new_tree (void *data) { struct et_node *nw; - if (!et_nodes) - et_nodes = create_alloc_pool ("et_node pool", sizeof (struct et_node), 300); - nw = (struct et_node *) pool_alloc (et_nodes); + nw = new et_node; nw->data = data; nw->father = NULL; @@ -501,8 +511,8 @@ et_free_tree (struct et_node *t) if (t->father) et_split (t); - pool_free (et_occurrences, t->rightmost_occ); - pool_free (et_nodes, t); + delete t->rightmost_occ; + delete t; } /* Releases et tree T without maintaining other nodes. */ @@ -510,10 +520,10 @@ et_free_tree (struct et_node *t) void et_free_tree_force (struct et_node *t) { - pool_free (et_occurrences, t->rightmost_occ); + delete t->rightmost_occ; if (t->parent_occ) - pool_free (et_occurrences, t->parent_occ); - pool_free (et_nodes, t); + delete t->parent_occ; + delete t; } /* Release the alloc pools, if they are empty. */ @@ -521,8 +531,8 @@ et_free_tree_force (struct et_node *t) void et_free_pools (void) { - free_alloc_pool_if_empty (&et_occurrences); - free_alloc_pool_if_empty (&et_nodes); + et_occ::pool.release_if_empty (); + et_node::pool.release_if_empty (); } /* Sets father of et tree T to FATHER. */ @@ -614,7 +624,7 @@ et_split (struct et_node *t) rmost->depth = 0; rmost->min = 0; - pool_free (et_occurrences, p_occ); + delete p_occ; /* Update the tree. */ if (father->son == t) diff --git a/gcc/et-forest.h b/gcc/et-forest.h index b507c64..1b3a16c 100644 --- a/gcc/et-forest.h +++ b/gcc/et-forest.h @@ -66,6 +66,21 @@ struct et_node struct et_occ *rightmost_occ; /* The rightmost occurrence. */ struct et_occ *parent_occ; /* The occurrence of the parent node. */ + + /* Pool allocation new operator. */ + inline void *operator new (size_t) + { + return pool.allocate (); + } + + /* Delete operator utilizing pool allocation. */ + inline void operator delete (void *ptr) + { + pool.remove((et_node *) ptr); + } + + /* Memory allocation pool. */ + static pool_allocator pool; }; struct et_node *et_new_tree (void *data);