From patchwork Wed May 27 13:56:56 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: 477137 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 61FEB14012C for ; Thu, 28 May 2015 00:16:03 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=URTw7sKC; 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= uWVXsFDraPEXzEcrX2tXqYPtmnh9iSnp3konsTs0zTMraOfTs3JrzkR3S4ARlbvj d09kthVYO9fY+nZjXJCBYPw3kWsiomAEl4ze0e+11cHu+TEGJuN2Xf/mqORmtNId 3+tRxUJ3qliYTTFxJ26ZNrjiJ318/i/yMTdUjrlef9s= 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=A9Bm 3DHvggcIWb2JAifK8E4PzQM=; b=URTw7sKCEfptHVgjlaXchvfsgJ1zC8ZfwrGU +vj+oFLcU5lOPP6AkB/J9z22pBpgqyYqd7ObVtzuT/NTI0t7RIWYfZSA5rV5AuJn TxhnLhpyhaCc0gilLp7s3Mg+kZabIoKWpgCLaVqa7HZF+XGIgNqEYgU8KEOk7NvG u1GITO8= Received: (qmail 77931 invoked by alias); 27 May 2015 14:15:52 -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 77861 invoked by uid 89); 27 May 2015 14:15:52 -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: 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:15:48 +0000 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YxbsJ-0007Ki-Ip for gcc-patches@gcc.gnu.org; Wed, 27 May 2015 10:00:12 -0400 Received: from cantor2.suse.de ([195.135.220.15]:57524 helo=mx2.suse.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YxbsJ-0007ET-A4 for gcc-patches@gcc.gnu.org; Wed, 27 May 2015 10:00:03 -0400 Received: from relay1.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 67D28AE0B for ; Wed, 27 May 2015 13:59:58 +0000 (UTC) Resent-From: =?UTF-8?B?TWFydGluIExpxaFrYQ==?= Resent-To: GCC Patches Resent-Date: Wed, 27 May 2015 15:59:58 +0200 Resent-Message-ID: <5565CDDE.7070001@suse.cz> Resent-User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.6.0 Message-Id: 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:56 +0200 Subject: [PATCH 34/35] Change use to type-based pool allocator in ira-build.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 * ira-build.c (initiate_allocnos): Use new type-based pool allocator. (ira_create_object): Likewise. (ira_create_allocno): Likewise. (ira_create_live_range): Likewise. (copy_live_range): Likewise. (ira_finish_live_range): Likewise. (ira_free_allocno_costs): Likewise. (finish_allocno): Likewise. (finish_allocnos): Likewise. (initiate_prefs): Likewise. (ira_create_pref): Likewise. (finish_pref): Likewise. (finish_prefs): Likewise. (initiate_copies): Likewise. (ira_create_copy): Likewise. (finish_copy): Likewise. (finish_copies): Likewise. --- gcc/ira-build.c | 51 +++++++++++++++++++++------------------------------ 1 file changed, 21 insertions(+), 30 deletions(-) diff --git a/gcc/ira-build.c b/gcc/ira-build.c index ec718e1..534d0bc 100644 --- a/gcc/ira-build.c +++ b/gcc/ira-build.c @@ -428,7 +428,9 @@ rebuild_regno_allocno_maps (void) /* Pools for allocnos, allocno live ranges and objects. */ -static alloc_pool allocno_pool, live_range_pool, object_pool; +static pool_allocator live_range_pool ("live ranges", 100); +static pool_allocator allocno_pool ("allocnos", 100); +static pool_allocator object_pool ("objects", 100); /* Vec containing references to all created allocnos. It is a container of array allocnos. */ @@ -442,13 +444,6 @@ static vec ira_object_id_map_vec; static void initiate_allocnos (void) { - live_range_pool - = create_alloc_pool ("live ranges", - sizeof (struct live_range), 100); - allocno_pool - = create_alloc_pool ("allocnos", sizeof (struct ira_allocno), 100); - object_pool - = create_alloc_pool ("objects", sizeof (struct ira_object), 100); allocno_vec.create (max_reg_num () * 2); ira_allocnos = NULL; ira_allocnos_num = 0; @@ -466,7 +461,7 @@ static ira_object_t ira_create_object (ira_allocno_t a, int subword) { enum reg_class aclass = ALLOCNO_CLASS (a); - ira_object_t obj = (ira_object_t) pool_alloc (object_pool); + ira_object_t obj = object_pool.allocate (); OBJECT_ALLOCNO (obj) = a; OBJECT_SUBWORD (obj) = subword; @@ -501,7 +496,7 @@ ira_create_allocno (int regno, bool cap_p, { ira_allocno_t a; - a = (ira_allocno_t) pool_alloc (allocno_pool); + a = allocno_pool.allocate (); ALLOCNO_REGNO (a) = regno; ALLOCNO_LOOP_TREE_NODE (a) = loop_tree_node; if (! cap_p) @@ -943,7 +938,7 @@ ira_create_live_range (ira_object_t obj, int start, int finish, { live_range_t p; - p = (live_range_t) pool_alloc (live_range_pool); + p = live_range_pool.allocate (); p->object = obj; p->start = start; p->finish = finish; @@ -968,7 +963,7 @@ copy_live_range (live_range_t r) { live_range_t p; - p = (live_range_t) pool_alloc (live_range_pool); + p = live_range_pool.allocate (); *p = *r; return p; } @@ -1089,7 +1084,7 @@ ira_live_ranges_intersect_p (live_range_t r1, live_range_t r2) void ira_finish_live_range (live_range_t r) { - pool_free (live_range_pool, r); + live_range_pool.remove (r); } /* Free list of allocno live ranges starting with R. */ @@ -1136,7 +1131,7 @@ ira_free_allocno_costs (ira_allocno_t a) ira_object_id_map[OBJECT_CONFLICT_ID (obj)] = NULL; if (OBJECT_CONFLICT_ARRAY (obj) != NULL) ira_free (OBJECT_CONFLICT_ARRAY (obj)); - pool_free (object_pool, obj); + object_pool.remove (obj); } ira_allocnos[ALLOCNO_NUM (a)] = NULL; @@ -1160,7 +1155,7 @@ static void finish_allocno (ira_allocno_t a) { ira_free_allocno_costs (a); - pool_free (allocno_pool, a); + allocno_pool.remove (a); } /* Free the memory allocated for all allocnos. */ @@ -1175,15 +1170,15 @@ finish_allocnos (void) ira_free (ira_regno_allocno_map); ira_object_id_map_vec.release (); allocno_vec.release (); - delete allocno_pool; - delete object_pool; - delete live_range_pool; + allocno_pool.release (); + object_pool.release (); + live_range_pool.release (); } /* Pools for allocno preferences. */ -static alloc_pool pref_pool; +static pool_allocator pref_pool ("prefs", 100); /* Vec containing references to all created preferences. It is a container of array ira_prefs. */ @@ -1193,8 +1188,6 @@ static vec pref_vec; static void initiate_prefs (void) { - pref_pool - = create_alloc_pool ("prefs", sizeof (struct ira_allocno_pref), 100); pref_vec.create (get_max_uid ()); ira_prefs = NULL; ira_prefs_num = 0; @@ -1218,7 +1211,7 @@ ira_create_pref (ira_allocno_t a, int hard_regno, int freq) { ira_pref_t pref; - pref = (ira_pref_t) pool_alloc (pref_pool); + pref = pref_pool.allocate (); pref->num = ira_prefs_num; pref->allocno = a; pref->hard_regno = hard_regno; @@ -1316,7 +1309,7 @@ static void finish_pref (ira_pref_t pref) { ira_prefs[pref->num] = NULL; - pool_free (pref_pool, pref); + pref_pool.remove (pref); } /* Remove PREF from the list of allocno prefs and free memory for @@ -1366,13 +1359,13 @@ finish_prefs (void) FOR_EACH_PREF (pref, pi) finish_pref (pref); pref_vec.release (); - delete pref_pool; + pref_pool.release (); } /* Pools for copies. */ -static alloc_pool copy_pool; +static pool_allocator copy_pool ("copies", 100); /* Vec containing references to all created copies. It is a container of array ira_copies. */ @@ -1382,8 +1375,6 @@ static vec copy_vec; static void initiate_copies (void) { - copy_pool - = create_alloc_pool ("copies", sizeof (struct ira_allocno_copy), 100); copy_vec.create (get_max_uid ()); ira_copies = NULL; ira_copies_num = 0; @@ -1428,7 +1419,7 @@ ira_create_copy (ira_allocno_t first, ira_allocno_t second, int freq, { ira_copy_t cp; - cp = (ira_copy_t) pool_alloc (copy_pool); + cp = copy_pool.allocate (); cp->num = ira_copies_num; cp->first = first; cp->second = second; @@ -1613,7 +1604,7 @@ ira_debug_allocno_copies (ira_allocno_t a) static void finish_copy (ira_copy_t cp) { - pool_free (copy_pool, cp); + copy_pool.remove (cp); } @@ -1627,7 +1618,7 @@ finish_copies (void) FOR_EACH_COPY (cp, ci) finish_copy (cp); copy_vec.release (); - delete copy_pool; + copy_pool.release (); }