@@ -1249,6 +1249,12 @@
return (mcount);
}
+struct computed_hash_values
+{
+ size_t name_length;
+ 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. */
@@ -1365,6 +1371,8 @@
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],
@@ -1372,6 +1380,8 @@
{
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. */
@@ -1381,6 +1391,9 @@
(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);
}
}
{
@@ -1391,9 +1404,11 @@
#endif
for (minimal_symbol *msym = start; msym < end; ++msym)
{
+ size_t idx = msym - msymbols;
symbol_set_names (msym, msym->name,
- strlen (msym->name), 0,
- m_objfile->per_bfd);
+ hash_values[idx].name_length, 0,
+ m_objfile->per_bfd,
+ hash_values[idx].mangled_name_hash);
}
}
});
@@ -825,7 +825,8 @@
void
symbol_set_names (struct general_symbol_info *gsymbol,
const char *linkage_name, int len, bool copy_name,
- struct objfile_per_bfd_storage *per_bfd)
+ struct objfile_per_bfd_storage *per_bfd,
+ gdb::optional<hashval_t> hash)
{
struct demangled_name_entry **slot;
/* A 0-terminated copy of the linkage name. */
@@ -868,9 +869,11 @@
linkage_name_copy = linkage_name;
struct demangled_name_entry entry (gdb::string_view (linkage_name_copy, len));
+ if (!hash.has_value ())
+ hash = hash_demangled_name_entry (&entry);
slot = ((struct demangled_name_entry **)
- htab_find_slot (per_bfd->demangled_names_hash.get (),
- &entry, INSERT));
+ htab_find_slot_with_hash (per_bfd->demangled_names_hash.get (),
+ &entry, *hash, INSERT));
/* If this name is not in the hash table, add it. */
if (*slot == NULL
@@ -514,13 +514,16 @@
(symbol)->ginfo.name = (linkage_name)
/* Set the linkage and natural names of a symbol, by demangling
- the linkage name. */
+ the linkage name. Optionally, HASH can be set to the value
+ of fast_hash (linkage_name), to speed up this function. */
#define SYMBOL_SET_NAMES(symbol,linkage_name,len,copy_name,objfile) \
symbol_set_names (&(symbol)->ginfo, linkage_name, len, copy_name, \
(objfile)->per_bfd)
extern void symbol_set_names (struct general_symbol_info *symbol,
const char *linkage_name, int len, bool copy_name,
- struct objfile_per_bfd_storage *per_bfd);
+ struct objfile_per_bfd_storage *per_bfd,
+ gdb::optional<hashval_t> hash
+ = gdb::optional<hashval_t> ());
/* Now come lots of name accessor macros. Short version as to when to
use which: Use SYMBOL_NATURAL_NAME to refer to the name of the