public inbox for binutils-cvs@sourceware.org
help / color / mirror / Atom feed
From: Alan Modra <amodra@sourceware.org>
To: bfd-cvs@sourceware.org
Subject: [binutils-gdb] gas: use notes_calloc in string hash
Date: Sat,  9 Jul 2022 12:36:36 +0000 (GMT)	[thread overview]
Message-ID: <20220709123636.53BCA38485B5@sourceware.org> (raw)

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=0edfd2985b3ce036bcee5e5d3518eab317018b4d

commit 0edfd2985b3ce036bcee5e5d3518eab317018b4d
Author: Alan Modra <amodra@gmail.com>
Date:   Thu Jul 7 08:49:09 2022 +0930

    gas: use notes_calloc in string hash
    
    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:
---
 gas/as.h              | 4 ++--
 gas/config/obj-elf.c  | 2 +-
 gas/config/tc-ia64.c  | 4 ++--
 gas/config/tc-nds32.c | 3 ++-
 gas/hash.h            | 2 +-
 gas/symbols.c         | 2 +-
 6 files changed, 9 insertions(+), 8 deletions(-)

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


                 reply	other threads:[~2022-07-09 12:36 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220709123636.53BCA38485B5@sourceware.org \
    --to=amodra@sourceware.org \
    --cc=bfd-cvs@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).