From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 46676 invoked by alias); 29 May 2015 13:33:14 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 46582 invoked by uid 89); 29 May 2015 13:33:13 -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: 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; Fri, 29 May 2015 13:33:12 +0000 Received: from relay2.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 96E12AC69; Fri, 29 May 2015 13:33:08 +0000 (UTC) Message-ID: <55686A94.2090907@suse.cz> Date: Fri, 29 May 2015 13:34:00 -0000 From: =?windows-1252?Q?Martin_Li=9Aka?= User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.6.0 MIME-Version: 1.0 To: Jeff Law , gcc-patches@gcc.gnu.org Subject: Re: [PATCH 05/35] Change use to type-based pool allocator in ira-color.c. References: <83d59ba92a3c4b3ba831ebc2fce325f0416848d0.1432735040.git.mliska@suse.cz> <70c6311fb68ec28e3eeb7cf28fe9f690229749d2.1432735040.git.mliska@suse.cz> <55660417.7000205@redhat.com> In-Reply-To: <55660417.7000205@redhat.com> Content-Type: multipart/mixed; boundary="------------080408040300090106050007" X-IsSubscribed: yes X-SW-Source: 2015-05/txt/msg02761.txt.bz2 This is a multi-part message in MIME format. --------------080408040300090106050007 Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit Content-length: 428 On 05/27/2015 07:51 PM, Jeff Law wrote: > On 05/27/2015 07:56 AM, mliska wrote: >> gcc/ChangeLog: >> >> 2015-04-30 Martin Liska >> >> * ira-color.c (init_update_cost_records):Use new type-based pool allocator. >> (get_update_cost_record) Likewise. >> (free_update_cost_record_list) Likewise. >> (finish_update_cost_records) Likewise. >> (initiate_cost_update) Likewise. > OK. > jeff > v2 --------------080408040300090106050007 Content-Type: text/x-patch; name="0005-Change-use-to-type-based-pool-allocator-in-ira-color.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename*0="0005-Change-use-to-type-based-pool-allocator-in-ira-color.pa"; filename*1="tch" Content-length: 3083 >From b2142d4d3939a81405f562a0970f7223069f130f Mon Sep 17 00:00:00 2001 From: mliska Date: Wed, 27 May 2015 15:56:46 +0200 Subject: [PATCH 05/32] Change use to type-based pool allocator in ira-color.c. gcc/ChangeLog: 2015-04-30 Martin Liska * ira-color.c (init_update_cost_records):Use new type-based pool allocator. (get_update_cost_record) Likewise. (free_update_cost_record_list) Likewise. (finish_update_cost_records) Likewise. (initiate_cost_update) Likewise. --- gcc/ira-color.c | 34 ++++++++++++++++++++-------------- 1 file changed, 20 insertions(+), 14 deletions(-) diff --git a/gcc/ira-color.c b/gcc/ira-color.c index 4750714..543440d 100644 --- a/gcc/ira-color.c +++ b/gcc/ira-color.c @@ -123,6 +123,21 @@ struct update_cost_record int divisor; /* Next record for given allocno. */ struct update_cost_record *next; + + /* 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 ((update_cost_record *) ptr); + } + + /* Memory allocation pool. */ + static pool_allocator pool; }; /* To decrease footprint of ira_allocno structure we store all data @@ -1166,16 +1181,8 @@ setup_profitable_hard_regs (void) allocnos. */ /* Pool for update cost records. */ -static alloc_pool update_cost_record_pool; - -/* Initiate update cost records. */ -static void -init_update_cost_records (void) -{ - update_cost_record_pool - = create_alloc_pool ("update cost records", - sizeof (struct update_cost_record), 100); -} +static pool_allocator update_cost_record_pool + ("update cost records", 100); /* Return new update cost record with given params. */ static struct update_cost_record * @@ -1184,7 +1191,7 @@ get_update_cost_record (int hard_regno, int divisor, { struct update_cost_record *record; - record = (struct update_cost_record *) pool_alloc (update_cost_record_pool); + record = update_cost_record_pool.allocate (); record->hard_regno = hard_regno; record->divisor = divisor; record->next = next; @@ -1200,7 +1207,7 @@ free_update_cost_record_list (struct update_cost_record *list) while (list != NULL) { next = list->next; - pool_free (update_cost_record_pool, list); + update_cost_record_pool.remove (list); list = next; } } @@ -1209,7 +1216,7 @@ free_update_cost_record_list (struct update_cost_record *list) static void finish_update_cost_records (void) { - free_alloc_pool (update_cost_record_pool); + update_cost_record_pool.release (); } /* Array whose element value is TRUE if the corresponding hard @@ -1264,7 +1271,6 @@ initiate_cost_update (void) = (struct update_cost_queue_elem *) ira_allocate (size); memset (update_cost_queue_elems, 0, size); update_cost_check = 0; - init_update_cost_records (); } /* Deallocate data used by function update_costs_from_copies. */ -- 2.1.4 --------------080408040300090106050007--