GNU Binutils with patches for OS216
Revision | b4fbb96b58d152194f0ffeefd35eea9a1bd89a52 (tree) |
---|---|
Time | 2019-10-04 03:17:12 |
Author | Christian Biesinger <cbiesinger@goog...> |
Commiter | Christian Biesinger |
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.
@@ -1342,6 +1342,11 @@ minimal_symbol_reader::install () | ||
1342 | 1342 | std::mutex demangled_mutex; |
1343 | 1343 | #endif |
1344 | 1344 | |
1345 | + struct computed_hash_values { | |
1346 | + hashval_t mangled_name_hash; | |
1347 | + }; | |
1348 | + std::vector<computed_hash_values> hash_values (mcount); | |
1349 | + | |
1345 | 1350 | msymbols = m_objfile->per_bfd->msymbols.get (); |
1346 | 1351 | gdb::parallel_for_each |
1347 | 1352 | (&msymbols[0], &msymbols[mcount], |
@@ -1361,6 +1366,9 @@ minimal_symbol_reader::install () | ||
1361 | 1366 | symbol_set_demangled_name (msym, demangled_name, |
1362 | 1367 | &m_objfile->per_bfd->storage_obstack); |
1363 | 1368 | msym->name_set = 1; |
1369 | + | |
1370 | + size_t idx = msym - msymbols; | |
1371 | + hash_values[idx].mangled_name_hash = htab_hash_string (msym->name); | |
1364 | 1372 | } |
1365 | 1373 | } |
1366 | 1374 | { |
@@ -1371,9 +1379,11 @@ minimal_symbol_reader::install () | ||
1371 | 1379 | #endif |
1372 | 1380 | for (minimal_symbol *msym = start; msym < end; ++msym) |
1373 | 1381 | { |
1382 | + size_t idx = msym - msymbols; | |
1374 | 1383 | symbol_set_names (msym, msym->name, |
1375 | 1384 | strlen (msym->name), 0, |
1376 | - m_objfile->per_bfd); | |
1385 | + m_objfile->per_bfd, | |
1386 | + hash_values[idx].mangled_name_hash); | |
1377 | 1387 | } |
1378 | 1388 | } |
1379 | 1389 | }); |
@@ -808,7 +808,7 @@ symbol_find_demangled_name (struct general_symbol_info *gsymbol, | ||
808 | 808 | void |
809 | 809 | symbol_set_names (struct general_symbol_info *gsymbol, |
810 | 810 | const char *linkage_name, int len, bool copy_name, |
811 | - struct objfile_per_bfd_storage *per_bfd) | |
811 | + struct objfile_per_bfd_storage *per_bfd, hashval_t hash) | |
812 | 812 | { |
813 | 813 | struct demangled_name_entry **slot; |
814 | 814 | /* A 0-terminated copy of the linkage name. */ |
@@ -854,9 +854,11 @@ symbol_set_names (struct general_symbol_info *gsymbol, | ||
854 | 854 | create_demangled_names_hash (per_bfd); |
855 | 855 | |
856 | 856 | entry.mangled = linkage_name_copy; |
857 | + if (hash == 0) | |
858 | + hash = hash_demangled_name_entry (&entry); | |
857 | 859 | slot = ((struct demangled_name_entry **) |
858 | - htab_find_slot (per_bfd->demangled_names_hash.get (), | |
859 | - &entry, INSERT)); | |
860 | + htab_find_slot_with_hash (per_bfd->demangled_names_hash.get (), | |
861 | + &entry, hash, INSERT)); | |
860 | 862 | |
861 | 863 | /* If this name is not in the hash table, add it. */ |
862 | 864 | if (*slot == NULL |
@@ -502,13 +502,16 @@ extern char *symbol_find_demangled_name (struct general_symbol_info *gsymbol, | ||
502 | 502 | (symbol)->ginfo.name = (linkage_name) |
503 | 503 | |
504 | 504 | /* Set the linkage and natural names of a symbol, by demangling |
505 | - the linkage name. */ | |
505 | + the linkage name. Optionally, HASH can be set to the value | |
506 | + of htab_hash_string (linkage_name) (if nullterminated), to | |
507 | + speed up this function. */ | |
506 | 508 | #define SYMBOL_SET_NAMES(symbol,linkage_name,len,copy_name,objfile) \ |
507 | 509 | symbol_set_names (&(symbol)->ginfo, linkage_name, len, copy_name, \ |
508 | 510 | (objfile)->per_bfd) |
509 | 511 | extern void symbol_set_names (struct general_symbol_info *symbol, |
510 | 512 | const char *linkage_name, int len, bool copy_name, |
511 | - struct objfile_per_bfd_storage *per_bfd); | |
513 | + struct objfile_per_bfd_storage *per_bfd, | |
514 | + hashval_t hash = 0); | |
512 | 515 | |
513 | 516 | /* Now come lots of name accessor macros. Short version as to when to |
514 | 517 | use which: Use SYMBOL_NATURAL_NAME to refer to the name of the |