mirror of
https://github.com/bminor/binutils-gdb.git
synced 2025-12-05 15:15:42 +00:00
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-10-03 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
This commit is contained in:
@@ -1258,6 +1258,12 @@ clear_minimal_symbol_hash_tables (struct objfile *objfile)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
struct computed_hash_values
|
||||||
|
{
|
||||||
|
size_t name_length;
|
||||||
|
hashval_t mangled_name_hash;
|
||||||
|
};
|
||||||
|
|
||||||
/* Build (or rebuild) the minimal symbol hash tables. This is necessary
|
/* Build (or rebuild) the minimal symbol hash tables. This is necessary
|
||||||
after compacting or sorting the table since the entries move around
|
after compacting or sorting the table since the entries move around
|
||||||
thus causing the internal minimal_symbol pointers to become jumbled. */
|
thus causing the internal minimal_symbol pointers to become jumbled. */
|
||||||
@@ -1370,6 +1376,8 @@ minimal_symbol_reader::install ()
|
|||||||
std::mutex demangled_mutex;
|
std::mutex demangled_mutex;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
std::vector<computed_hash_values> hash_values (mcount);
|
||||||
|
|
||||||
msymbols = m_objfile->per_bfd->msymbols.get ();
|
msymbols = m_objfile->per_bfd->msymbols.get ();
|
||||||
gdb::parallel_for_each
|
gdb::parallel_for_each
|
||||||
(&msymbols[0], &msymbols[mcount],
|
(&msymbols[0], &msymbols[mcount],
|
||||||
@@ -1377,6 +1385,8 @@ minimal_symbol_reader::install ()
|
|||||||
{
|
{
|
||||||
for (minimal_symbol *msym = start; msym < end; ++msym)
|
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)
|
if (!msym->name_set)
|
||||||
{
|
{
|
||||||
/* This will be freed later, by symbol_set_names. */
|
/* This will be freed later, by symbol_set_names. */
|
||||||
@@ -1386,6 +1396,9 @@ minimal_symbol_reader::install ()
|
|||||||
(msym, demangled_name,
|
(msym, demangled_name,
|
||||||
&m_objfile->per_bfd->storage_obstack);
|
&m_objfile->per_bfd->storage_obstack);
|
||||||
msym->name_set = 1;
|
msym->name_set = 1;
|
||||||
|
|
||||||
|
hash_values[idx].mangled_name_hash
|
||||||
|
= fast_hash (msym->name, hash_values[idx].name_length);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
@@ -1396,8 +1409,14 @@ minimal_symbol_reader::install ()
|
|||||||
#endif
|
#endif
|
||||||
for (minimal_symbol *msym = start; msym < end; ++msym)
|
for (minimal_symbol *msym = start; msym < end; ++msym)
|
||||||
{
|
{
|
||||||
symbol_set_names (msym, msym->name, false,
|
size_t idx = msym - msymbols;
|
||||||
m_objfile->per_bfd);
|
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -826,7 +826,8 @@ symbol_find_demangled_name (struct general_symbol_info *gsymbol,
|
|||||||
void
|
void
|
||||||
symbol_set_names (struct general_symbol_info *gsymbol,
|
symbol_set_names (struct general_symbol_info *gsymbol,
|
||||||
gdb::string_view linkage_name, bool copy_name,
|
gdb::string_view linkage_name, 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;
|
struct demangled_name_entry **slot;
|
||||||
|
|
||||||
@@ -854,9 +855,11 @@ symbol_set_names (struct general_symbol_info *gsymbol,
|
|||||||
create_demangled_names_hash (per_bfd);
|
create_demangled_names_hash (per_bfd);
|
||||||
|
|
||||||
struct demangled_name_entry entry (linkage_name);
|
struct demangled_name_entry entry (linkage_name);
|
||||||
|
if (!hash.has_value ())
|
||||||
|
hash = hash_demangled_name_entry (&entry);
|
||||||
slot = ((struct demangled_name_entry **)
|
slot = ((struct demangled_name_entry **)
|
||||||
htab_find_slot (per_bfd->demangled_names_hash.get (),
|
htab_find_slot_with_hash (per_bfd->demangled_names_hash.get (),
|
||||||
&entry, INSERT));
|
&entry, *hash, INSERT));
|
||||||
|
|
||||||
/* If this name is not in the hash table, add it. */
|
/* If this name is not in the hash table, add it. */
|
||||||
if (*slot == NULL
|
if (*slot == NULL
|
||||||
|
|||||||
@@ -529,7 +529,9 @@ extern char *symbol_find_demangled_name (struct general_symbol_info *gsymbol,
|
|||||||
(objfile)->per_bfd)
|
(objfile)->per_bfd)
|
||||||
extern void symbol_set_names (struct general_symbol_info *symbol,
|
extern void symbol_set_names (struct general_symbol_info *symbol,
|
||||||
gdb::string_view linkage_name, bool copy_name,
|
gdb::string_view linkage_name, 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
|
/* 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
|
use which: Use SYMBOL_NATURAL_NAME to refer to the name of the
|
||||||
|
|||||||
Reference in New Issue
Block a user