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: 477130 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 9CB351402B2 for ; Thu, 28 May 2015 00:01:35 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=qvE/9Iz4; 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= TXfZvGaG4Zwr5ul52aj/6kCn+BJIOxjFRJorqweCuIbDWzA3qmVbOEk/zYC42AHH rs0aZF4obGreY80erw5Bsqaxe+nsv0lf9rU2Bu9zvggudCU0HZsDAbC6m+Wp16z4 n+Gvi3Q8U44IrHHDm/4oAiXh6/xEs6n77SIX1JD1e8s= 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=yhu7 3YLlm2GD/+f31hstbPiubnc=; b=qvE/9Iz4htyTc9FXbHfOY/whceTkWQlvnpiL ty6SJhHn2LNpEa5VyKCXeWuww4BuobdRi2xpPlfYwiuPNlD9M8Cv8n+pEGZ0q+WM Pkrlhp7UA90ebXPA/7VvLHS+BQs/2qKwH10AHBkRkbDE5ytvx3kRz5EbVPnXtaSV vIbdb88= Received: (qmail 70560 invoked by alias); 27 May 2015 14:00:17 -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 70475 invoked by uid 89); 27 May 2015 14:00:17 -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:00:07 +0000 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YxbsG-00076v-W2 for gcc-patches@gcc.gnu.org; Wed, 27 May 2015 10:00:04 -0400 Received: from cantor2.suse.de ([195.135.220.15]:57445 helo=mx2.suse.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YxbsG-000731-PM for gcc-patches@gcc.gnu.org; Wed, 27 May 2015 10:00:00 -0400 Received: from relay1.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 7C4D0ADEB 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.5090608@suse.cz> Resent-User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.6.0 Message-Id: <70c6311fb68ec28e3eeb7cf28fe9f690229749d2.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 05/35] Change use to type-based pool allocator in ira-color.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-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 | 35 ++++++++++++++++++++--------------- 1 file changed, 20 insertions(+), 15 deletions(-) diff --git a/gcc/ira-color.c b/gcc/ira-color.c index 4750714..b719e7a 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,25 +1181,16 @@ 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); -} +pool_allocator update_cost_record::pool + ("update cost records", 100); /* Return new update cost record with given params. */ static struct update_cost_record * get_update_cost_record (int hard_regno, int divisor, struct update_cost_record *next) { - struct update_cost_record *record; + update_cost_record *record = new update_cost_record; - record = (struct update_cost_record *) pool_alloc (update_cost_record_pool); record->hard_regno = hard_regno; record->divisor = divisor; record->next = next; @@ -1200,7 +1206,7 @@ free_update_cost_record_list (struct update_cost_record *list) while (list != NULL) { next = list->next; - pool_free (update_cost_record_pool, list); + delete list; list = next; } } @@ -1209,7 +1215,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 +1270,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. */