From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gproxy2-pub.mail.unifiedlayer.com (gproxy2-pub.mail.unifiedlayer.com [69.89.18.3]) by sourceware.org (Postfix) with ESMTPS id 11FF13858C39 for ; Fri, 7 Apr 2023 15:25:43 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 11FF13858C39 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=tromey.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=tromey.com Received: from cmgw12.mail.unifiedlayer.com (unknown [10.0.90.127]) by progateway4.mail.pro1.eigbox.com (Postfix) with ESMTP id 5366A10047E07 for ; Fri, 7 Apr 2023 15:25:42 +0000 (UTC) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTP id knyApLk5pChTwknyAplpWm; Fri, 07 Apr 2023 15:25:42 +0000 X-Authority-Reason: nr=8 X-Authority-Analysis: v=2.4 cv=BK12EHcG c=1 sm=1 tr=0 ts=643035f6 a=ApxJNpeYhEAb1aAlGBBbmA==:117 a=ApxJNpeYhEAb1aAlGBBbmA==:17 a=dLZJa+xiwSxG16/P+YVxDGlgEgI=:19 a=IkcTkHD0fZMA:10:nop_charset_1 a=dKHAf1wccvYA:10:nop_rcvd_month_year a=Qbun_eYptAEA:10:endurance_base64_authed_username_1 a=PJTVvGXVjnd0oxVvKrAA:9 a=QEXdDO2ut3YA:10:nop_charset_2 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tromey.com; s=default; h=To:In-Reply-To:References:Message-Id:Content-Transfer-Encoding: Content-Type:MIME-Version:Subject:Date:From:Sender:Reply-To:Cc:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=lZAGdiJv1mfzfjLecLKit/0OJxjIvuFu59MnMH90I9Q=; b=up1lP7qNZON/27pm5qVAw11NCs DajmgBmax8TvoKfTfDFgF61Ekrtcu6xmiDKMoPS5w8EK1wuXiG34v7D7AoRm5hUY4IMT/RgQmA+7E o6rpqMVIeTG1xPK3ssgR6MFGT; Received: from 75-166-159-36.hlrn.qwest.net ([75.166.159.36]:60392 helo=[192.168.0.21]) by box5379.bluehost.com with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1pknyA-001hDU-1I for gdb-patches@sourceware.org; Fri, 07 Apr 2023 09:25:42 -0600 From: Tom Tromey Date: Fri, 07 Apr 2023 09:25:44 -0600 Subject: [PATCH 12/19] Convert static links to new hash table MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20230407-t-robin-hood-hash-v1-12-900d93ef1510@tromey.com> References: <20230407-t-robin-hood-hash-v1-0-900d93ef1510@tromey.com> In-Reply-To: <20230407-t-robin-hood-hash-v1-0-900d93ef1510@tromey.com> To: gdb-patches@sourceware.org X-Mailer: b4 0.12.1 X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - box5379.bluehost.com X-AntiAbuse: Original Domain - sourceware.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - tromey.com X-BWhitelist: no X-Source-IP: 75.166.159.36 X-Source-L: No X-Exim-ID: 1pknyA-001hDU-1I X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 75-166-159-36.hlrn.qwest.net ([192.168.0.21]) [75.166.159.36]:60392 X-Source-Auth: tom+tromey.com X-Email-Count: 13 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-Spam-Status: No, score=-3026.6 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,GIT_PATCH_0,JMQ_SPF_NEUTRAL,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: This converts the objfile static link table to the new hash map. --- gdb/objfiles.c | 74 +++++++--------------------------------------------------- gdb/objfiles.h | 4 +++- gdb/symfile.c | 2 +- 3 files changed, 13 insertions(+), 67 deletions(-) diff --git a/gdb/objfiles.c b/gdb/objfiles.c index 9caebfefd59..7de90f26c33 100644 --- a/gdb/objfiles.c +++ b/gdb/objfiles.c @@ -158,39 +158,6 @@ set_objfile_main_name (struct objfile *objfile, objfile->per_bfd->language_of_main = lang; } -/* Helper structure to map blocks to static link properties in hash tables. */ - -struct static_link_htab_entry -{ - const struct block *block; - const struct dynamic_prop *static_link; -}; - -/* Return a hash code for struct static_link_htab_entry *P. */ - -static hashval_t -static_link_htab_entry_hash (const void *p) -{ - const struct static_link_htab_entry *e - = (const struct static_link_htab_entry *) p; - - return htab_hash_pointer (e->block); -} - -/* Return whether P1 an P2 (pointers to struct static_link_htab_entry) are - mappings for the same block. */ - -static int -static_link_htab_entry_eq (const void *p1, const void *p2) -{ - const struct static_link_htab_entry *e1 - = (const struct static_link_htab_entry *) p1; - const struct static_link_htab_entry *e2 - = (const struct static_link_htab_entry *) p2; - - return e1->block == e2->block; -} - /* Register STATIC_LINK as the static link for BLOCK, which is part of OBJFILE. Must not be called more than once for each BLOCK. */ @@ -199,25 +166,10 @@ objfile_register_static_link (struct objfile *objfile, const struct block *block, const struct dynamic_prop *static_link) { - void **slot; - struct static_link_htab_entry lookup_entry; - struct static_link_htab_entry *entry; - - if (objfile->static_links == NULL) - objfile->static_links.reset (htab_create_alloc - (1, &static_link_htab_entry_hash, static_link_htab_entry_eq, NULL, - xcalloc, xfree)); - - /* Create a slot for the mapping, make sure it's the first mapping for this - block and then create the mapping itself. */ - lookup_entry.block = block; - slot = htab_find_slot (objfile->static_links.get (), &lookup_entry, INSERT); - gdb_assert (*slot == NULL); - - entry = XOBNEW (&objfile->objfile_obstack, static_link_htab_entry); - entry->block = block; - entry->static_link = static_link; - *slot = (void *) entry; + /* Enter the mapping and make sure it's the first mapping for this + block. */ + auto insert_pair = objfile->static_links.insert (block, static_link); + gdb_assert (insert_pair.second); } /* Look for a static link for BLOCK, which is part of OBJFILE. Return NULL if @@ -227,19 +179,11 @@ const struct dynamic_prop * objfile_lookup_static_link (struct objfile *objfile, const struct block *block) { - struct static_link_htab_entry *entry; - struct static_link_htab_entry lookup_entry; - - if (objfile->static_links == NULL) - return NULL; - lookup_entry.block = block; - entry = ((struct static_link_htab_entry *) - htab_find (objfile->static_links.get (), &lookup_entry)); - if (entry == NULL) - return NULL; - - gdb_assert (entry->block == block); - return entry->static_link; + auto iter = objfile->static_links.find (block); + if (iter == objfile->static_links.end ()) + return nullptr; + gdb_assert (iter->first == block); + return iter->second; } diff --git a/gdb/objfiles.h b/gdb/objfiles.h index 342aa09ac6a..79c701905fe 100644 --- a/gdb/objfiles.h +++ b/gdb/objfiles.h @@ -39,6 +39,7 @@ #include "jit.h" #include "quick-symbol.h" #include +#include "gdbsupport/hash-table.h" struct htab; struct objfile_data; @@ -769,7 +770,8 @@ struct objfile Very few blocks have a static link, so it's more memory efficient to store these here rather than in struct block. Static links must be allocated on the objfile's obstack. */ - htab_up static_links; + gdb::hash_map static_links; /* JIT-related data for this objfile, if the objfile is a JITer; that is, it produces JITed objfiles. */ diff --git a/gdb/symfile.c b/gdb/symfile.c index bb9981a4634..b2fc917d5ed 100644 --- a/gdb/symfile.c +++ b/gdb/symfile.c @@ -2562,7 +2562,7 @@ reread_symbols (int from_tty) objfile->sect_index_text = -1; objfile->compunit_symtabs = NULL; objfile->template_symbols = NULL; - objfile->static_links.reset (nullptr); + objfile->static_links.clear (); /* obstack_init also initializes the obstack so it is empty. We could use obstack_specify_allocation but -- 2.39.2