summaryrefslogtreecommitdiff
path: root/gdb/minsyms.c
diff options
context:
space:
mode:
authorChristian Biesinger <cbiesinger@google.com>2019-10-03 13:05:06 -0500
committerChristian Biesinger <cbiesinger@google.com>2019-11-27 15:36:59 -0600
commite76b224615f88255a3fd20d613983dde6cc240b3 (patch)
tree054769222cac115cdeaa6a89e46d5172a9e64ce6 /gdb/minsyms.c
parent640ab94712483457b99bd1039b52821c510b28a7 (diff)
downloadbinutils-gdb-e76b224615f88255a3fd20d613983dde6cc240b3.tar.gz
Precompute hash value for symbol_set_names
We can also compute the hash for the mangled name on a background thread so make this function even faster (about a 7% speedup). gdb/ChangeLog: 2019-11-27 Christian Biesinger <cbiesinger@google.com> * minsyms.c (minimal_symbol_reader::install): Also compute the hash of the mangled name on the background thread. * symtab.c (symbol_set_names): Allow passing in the hash of the linkage_name. * symtab.h (symbol_set_names): Likewise. Change-Id: I044449e7eb60cffc1c43efd3412f2b485bd9faac
Diffstat (limited to 'gdb/minsyms.c')
-rw-r--r--gdb/minsyms.c27
1 files changed, 25 insertions, 2 deletions
diff --git a/gdb/minsyms.c b/gdb/minsyms.c
index 03a193270e5..141c3d21935 100644
--- a/gdb/minsyms.c
+++ b/gdb/minsyms.c
@@ -1258,6 +1258,16 @@ clear_minimal_symbol_hash_tables (struct objfile *objfile)
}
}
+/* This struct is used to store values we compute for msymbols on the
+ background threads but don't need to keep around long term. */
+struct computed_hash_values
+{
+ /* Length of the linkage_name of the symbol. */
+ size_t name_length;
+ /* Hash code (using fast_hash) of the linkage_name. */
+ hashval_t mangled_name_hash;
+};
+
/* Build (or rebuild) the minimal symbol hash tables. This is necessary
after compacting or sorting the table since the entries move around
thus causing the internal minimal_symbol pointers to become jumbled. */
@@ -1370,6 +1380,8 @@ minimal_symbol_reader::install ()
std::mutex demangled_mutex;
#endif
+ std::vector<computed_hash_values> hash_values (mcount);
+
msymbols = m_objfile->per_bfd->msymbols.get ();
gdb::parallel_for_each
(&msymbols[0], &msymbols[mcount],
@@ -1377,6 +1389,8 @@ minimal_symbol_reader::install ()
{
for (minimal_symbol *msym = start; msym < end; ++msym)
{
+ size_t idx = msym - msymbols;
+ hash_values[idx].name_length = strlen (msym->name);
if (!msym->name_set)
{
/* This will be freed later, by symbol_set_names. */
@@ -1386,6 +1400,9 @@ minimal_symbol_reader::install ()
(msym, demangled_name,
&m_objfile->per_bfd->storage_obstack);
msym->name_set = 1;
+
+ hash_values[idx].mangled_name_hash
+ = fast_hash (msym->name, hash_values[idx].name_length);
}
}
{
@@ -1396,8 +1413,14 @@ minimal_symbol_reader::install ()
#endif
for (minimal_symbol *msym = start; msym < end; ++msym)
{
- symbol_set_names (msym, msym->name, false,
- m_objfile->per_bfd);
+ size_t idx = msym - msymbols;
+ symbol_set_names
+ (msym,
+ gdb::string_view(msym->name,
+ hash_values[idx].name_length),
+ false,
+ m_objfile->per_bfd,
+ hash_values[idx].mangled_name_hash);
}
}
});