From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pf1-x431.google.com (mail-pf1-x431.google.com [IPv6:2607:f8b0:4864:20::431]) by sourceware.org (Postfix) with ESMTPS id EC39F383D83A for ; Sat, 9 Jul 2022 12:34:12 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org EC39F383D83A Received: by mail-pf1-x431.google.com with SMTP id y141so1176054pfb.7 for ; Sat, 09 Jul 2022 05:34:12 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:subject:message-id:mime-version :content-disposition; bh=Wlpqr9zkWFKL8KPsD1rE/BjoxUXjDzVnYTppu6t7/qY=; b=UAqhIglY+hIFVzmJuhXEwYb20fmGoLsuquvT1Dml1O4oetAkoVYMxYGZxobNcRrvRC UwcmiidM8Hxd4jqKDanoMgAnzgkU+XddnYUvvrJJ8bQeXp36/HHHCRR8hwiXsGgejQAg mwzd1u5jpNHZXHVxC20Fyr+XtqOqHvMGXo2TT2t9yiLJntfJVNXOlHgzDDoOM6sCIEoJ 6EsJn4Niwh+hfFxQr+rdDOONRLdGCt8dVazJghRxJDP96dtyxXKF6OfyNeWJDbB77mCO oMMq3FLKEI49Qu+K1tJeZ/vwPukT9GG0hhuiofK8yu0TG1fu4jT2zxBpf9h4qHFPPjw6 vzJA== X-Gm-Message-State: AJIora9UNXTfOcy5qqxvNQrS9aF132iVjtUyQIlCD/hONCT+dOlJs6Hd ARCnEQF9+ZfOAsfv+c7arAv6f12pZ28= X-Google-Smtp-Source: AGRyM1vtAlCjOC2cNLNMl82BUds9XhcOM2xu43bKtDdh7LcW7HFou6vP/nU5gyh39AsX1bwJpukH+Q== X-Received: by 2002:a63:fe13:0:b0:412:1e19:4f9c with SMTP id p19-20020a63fe13000000b004121e194f9cmr7700490pgh.314.1657370051725; Sat, 09 Jul 2022 05:34:11 -0700 (PDT) Received: from squeak.grove.modra.org ([2406:3400:51d:8cc0:4b98:7b4b:d3e3:2ead]) by smtp.gmail.com with ESMTPSA id f10-20020a17090a664a00b001ec85441515sm1077248pjm.24.2022.07.09.05.34.11 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 09 Jul 2022 05:34:11 -0700 (PDT) Received: by squeak.grove.modra.org (Postfix, from userid 1000) id 16CA11143046; Sat, 9 Jul 2022 22:04:09 +0930 (ACST) Date: Sat, 9 Jul 2022 22:04:09 +0930 From: Alan Modra To: binutils@sourceware.org Subject: gas: use notes_calloc in string hash Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-Spam-Status: No, score=-3036.0 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: binutils@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Binutils mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 09 Jul 2022 12:34:14 -0000 Using notes_calloc means all of the string hash table memory should now be freed before gas exits, even though htab_delete isn't called. This also means that the hash table free_f and del_f must be NULL, because freeing notes obstack memory results in all more recently allocated notes memory being freed too. So hash table resizing won't free any memory, and will be a little faster. Also, htab_delete won't do anything (and be quick about it). Since htab_traverse can also resize hash tables (to make another traversal faster if the table is largely empty), stop that happening when only one traversal is done. * as.h: Reorder hash.h after symbols.h for notes_calloc decl. * hash.h (str_htab_create): Use notes_calloc. Do not free. * symbols.c (resolve_local_symbol_values): Don't resize during hash table traversal. * config/obj-elf.c (elf_frob_file_after_relocs): Likewise. * config/tc-ia64.c (ia64_adjust_symtab, ia64_frob_file): Likewise. * config/tc-nds32.c (nds32_elf_analysis_relax_hint): Likewise. diff --git a/gas/as.h b/gas/as.h index d179537f383..ff665c75812 100644 --- a/gas/as.h +++ b/gas/as.h @@ -541,10 +541,10 @@ int generic_force_reloc (struct fix *); #include "write.h" #include "frags.h" -#include "hashtab.h" -#include "hash.h" #include "read.h" #include "symbols.h" +#include "hashtab.h" +#include "hash.h" #include "tc.h" #include "obj.h" diff --git a/gas/config/obj-elf.c b/gas/config/obj-elf.c index e5ab8514de7..82cde271fbb 100644 --- a/gas/config/obj-elf.c +++ b/gas/config/obj-elf.c @@ -3006,7 +3006,7 @@ elf_frob_file_after_relocs (void) } /* Cleanup hash. */ - htab_traverse (groups.indexes, free_section_idx, NULL); + htab_traverse_noresize (groups.indexes, free_section_idx, NULL); htab_delete (groups.indexes); #ifdef NEED_ECOFF_DEBUG diff --git a/gas/config/tc-ia64.c b/gas/config/tc-ia64.c index 7fa7e572a22..3011302ffba 100644 --- a/gas/config/tc-ia64.c +++ b/gas/config/tc-ia64.c @@ -11853,7 +11853,7 @@ do_alias (void **slot, void *arg ATTRIBUTE_UNUSED) void ia64_adjust_symtab (void) { - htab_traverse (alias_hash, do_alias, NULL); + htab_traverse_noresize (alias_hash, do_alias, NULL); } /* It renames the original section name to its alias. */ @@ -11878,7 +11878,7 @@ do_secalias (void **slot, void *arg ATTRIBUTE_UNUSED) void ia64_frob_file (void) { - htab_traverse (secalias_hash, do_secalias, NULL); + htab_traverse_noresize (secalias_hash, do_secalias, NULL); } #ifdef TE_VMS diff --git a/gas/config/tc-nds32.c b/gas/config/tc-nds32.c index 48893a5762e..6b082a3a26c 100644 --- a/gas/config/tc-nds32.c +++ b/gas/config/tc-nds32.c @@ -7480,7 +7480,8 @@ nds32_insert_relax_entry (bfd *abfd ATTRIBUTE_UNUSED, asection *sec, static void nds32_elf_analysis_relax_hint (void) { - htab_traverse (nds32_hint_hash, nds32_elf_append_relax_relocs_traverse, NULL); + htab_traverse_noresize (nds32_hint_hash, + nds32_elf_append_relax_relocs_traverse, NULL); } static void diff --git a/gas/hash.h b/gas/hash.h index 29e882514f4..30404d88928 100644 --- a/gas/hash.h +++ b/gas/hash.h @@ -99,7 +99,7 @@ static inline htab_t str_htab_create (void) { return htab_create_alloc (16, hash_string_tuple, eq_string_tuple, - free, xcalloc, free); + NULL, notes_calloc, NULL); } #endif /* HASH_H */ diff --git a/gas/symbols.c b/gas/symbols.c index 744f6e1260f..6904a3102cf 100644 --- a/gas/symbols.c +++ b/gas/symbols.c @@ -1786,7 +1786,7 @@ resolve_local_symbol (void **slot, void *arg ATTRIBUTE_UNUSED) void resolve_local_symbol_values (void) { - htab_traverse (sy_hash, resolve_local_symbol, NULL); + htab_traverse_noresize (sy_hash, resolve_local_symbol, NULL); } /* Obtain the current value of a symbol without changing any -- Alan Modra Australia Development Lab, IBM