• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
Keine Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

GNU Binutils with patches for OS216


Commit MetaInfo

Revision85f7818c32fdf5b9fbd24f08320c54e9f9d50b4c (tree)
Zeit2019-10-03 06:59:04
AutorChristian Biesinger <cbiesinger@goog...>
CommiterChristian Biesinger

Log Message

Compute msymbol hash codes in parallel

This is for the msymbol_hash and msymbol_demangled_hash hashtables
in objfile_per_bfd_storage. This basically computes those hash
codes together with the demangled symbol name in the background,
before it inserts the symbols in the hash table.

gdb/ChangeLog:

2019-09-30 Christian Biesinger <cbiesinger@google.com>

* minsyms.c (add_minsym_to_hash_table): Use a previously computed
hash code if possible.
(add_minsym_to_demangled_hash_table): Likewise.
(minimal_symbol_reader::install): Compute the hash codes for msymbol
on the background thread.
* symtab.h (struct minimal_symbol) <hash_value, demangled_hash_value>:
Add these fields.

Ändern Zusammenfassung

Diff

--- a/gdb/minsyms.c
+++ b/gdb/minsyms.c
@@ -152,12 +152,12 @@ msymbol_hash (const char *string)
152152 /* Add the minimal symbol SYM to an objfile's minsym hash table, TABLE. */
153153 static void
154154 add_minsym_to_hash_table (struct minimal_symbol *sym,
155- struct minimal_symbol **table)
155+ struct minimal_symbol **table,
156+ unsigned int hash_value)
156157 {
157158 if (sym->hash_next == NULL)
158159 {
159- unsigned int hash
160- = msymbol_hash (MSYMBOL_LINKAGE_NAME (sym)) % MINIMAL_SYMBOL_HASH_SIZE;
160+ unsigned int hash = hash_value % MINIMAL_SYMBOL_HASH_SIZE;
161161
162162 sym->hash_next = table[hash];
163163 table[hash] = sym;
@@ -168,18 +168,16 @@ add_minsym_to_hash_table (struct minimal_symbol *sym,
168168 TABLE. */
169169 static void
170170 add_minsym_to_demangled_hash_table (struct minimal_symbol *sym,
171- struct objfile *objfile)
171+ struct objfile *objfile,
172+ unsigned int hash_value)
172173 {
173174 if (sym->demangled_hash_next == NULL)
174175 {
175- unsigned int hash = search_name_hash (MSYMBOL_LANGUAGE (sym),
176- MSYMBOL_SEARCH_NAME (sym));
177-
178176 objfile->per_bfd->demangled_hash_languages.set (MSYMBOL_LANGUAGE (sym));
179177
180178 struct minimal_symbol **table
181179 = objfile->per_bfd->msymbol_demangled_hash;
182- unsigned int hash_index = hash % MINIMAL_SYMBOL_HASH_SIZE;
180+ unsigned int hash_index = hash_value % MINIMAL_SYMBOL_HASH_SIZE;
183181 sym->demangled_hash_next = table[hash_index];
184182 table[hash_index] = sym;
185183 }
@@ -1242,7 +1240,9 @@ compact_minimal_symbols (struct minimal_symbol *msymbol, int mcount,
12421240 thus causing the internal minimal_symbol pointers to become jumbled. */
12431241
12441242 static void
1245-build_minimal_symbol_hash_tables (struct objfile *objfile)
1243+build_minimal_symbol_hash_tables
1244+ (struct objfile *objfile,
1245+ std::vector<std::pair<unsigned, unsigned>>& hash_codes)
12461246 {
12471247 int i;
12481248 struct minimal_symbol *msym;
@@ -1255,17 +1255,20 @@ build_minimal_symbol_hash_tables (struct objfile *objfile)
12551255 }
12561256
12571257 /* Now, (re)insert the actual entries. */
1258- for ((i = objfile->per_bfd->minimal_symbol_count,
1258+ int mcount = objfile->per_bfd->minimal_symbol_count;
1259+ for ((i = 0,
12591260 msym = objfile->per_bfd->msymbols.get ());
1260- i > 0;
1261- i--, msym++)
1261+ i < mcount;
1262+ i++, msym++)
12621263 {
12631264 msym->hash_next = 0;
1264- add_minsym_to_hash_table (msym, objfile->per_bfd->msymbol_hash);
1265+ add_minsym_to_hash_table (msym, objfile->per_bfd->msymbol_hash,
1266+ hash_codes[i].first);
12651267
12661268 msym->demangled_hash_next = 0;
12671269 if (MSYMBOL_SEARCH_NAME (msym) != MSYMBOL_LINKAGE_NAME (msym))
1268- add_minsym_to_demangled_hash_table (msym, objfile);
1270+ add_minsym_to_demangled_hash_table (msym, objfile,
1271+ hash_codes[i].second);
12691272 }
12701273 }
12711274
@@ -1347,6 +1350,8 @@ minimal_symbol_reader::install ()
13471350 m_objfile->per_bfd->minimal_symbol_count = mcount;
13481351 m_objfile->per_bfd->msymbols = std::move (msym_holder);
13491352
1353+ std::vector<std::pair<unsigned, unsigned>> hash_codes (mcount);
1354+
13501355 msymbols = m_objfile->per_bfd->msymbols.get ();
13511356 gdb::parallel_for_each
13521357 (&msymbols[0], &msymbols[mcount],
@@ -1367,6 +1372,11 @@ minimal_symbol_reader::install ()
13671372 &m_objfile->per_bfd->storage_obstack);
13681373 msym->name_set = 1;
13691374 }
1375+ size_t idx = msym - msymbols;
1376+ hash_codes[idx].first = msymbol_hash (MSYMBOL_LINKAGE_NAME (msym));
1377+ hash_codes[idx].second
1378+ = search_name_hash (MSYMBOL_LANGUAGE (msym),
1379+ MSYMBOL_SEARCH_NAME (msym));
13701380 }
13711381 {
13721382 /* To limit how long we hold the lock, we only acquire it here
@@ -1383,7 +1393,7 @@ minimal_symbol_reader::install ()
13831393 }
13841394 });
13851395
1386- build_minimal_symbol_hash_tables (m_objfile);
1396+ build_minimal_symbol_hash_tables (m_objfile, hash_codes);
13871397 }
13881398 }
13891399