GNU Binutils with patches for OS216
Revision | 85f7818c32fdf5b9fbd24f08320c54e9f9d50b4c (tree) |
---|---|
Zeit | 2019-10-03 06:59:04 |
Autor | Christian Biesinger <cbiesinger@goog...> |
Commiter | Christian Biesinger |
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.
@@ -152,12 +152,12 @@ msymbol_hash (const char *string) | ||
152 | 152 | /* Add the minimal symbol SYM to an objfile's minsym hash table, TABLE. */ |
153 | 153 | static void |
154 | 154 | add_minsym_to_hash_table (struct minimal_symbol *sym, |
155 | - struct minimal_symbol **table) | |
155 | + struct minimal_symbol **table, | |
156 | + unsigned int hash_value) | |
156 | 157 | { |
157 | 158 | if (sym->hash_next == NULL) |
158 | 159 | { |
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; | |
161 | 161 | |
162 | 162 | sym->hash_next = table[hash]; |
163 | 163 | table[hash] = sym; |
@@ -168,18 +168,16 @@ add_minsym_to_hash_table (struct minimal_symbol *sym, | ||
168 | 168 | TABLE. */ |
169 | 169 | static void |
170 | 170 | add_minsym_to_demangled_hash_table (struct minimal_symbol *sym, |
171 | - struct objfile *objfile) | |
171 | + struct objfile *objfile, | |
172 | + unsigned int hash_value) | |
172 | 173 | { |
173 | 174 | if (sym->demangled_hash_next == NULL) |
174 | 175 | { |
175 | - unsigned int hash = search_name_hash (MSYMBOL_LANGUAGE (sym), | |
176 | - MSYMBOL_SEARCH_NAME (sym)); | |
177 | - | |
178 | 176 | objfile->per_bfd->demangled_hash_languages.set (MSYMBOL_LANGUAGE (sym)); |
179 | 177 | |
180 | 178 | struct minimal_symbol **table |
181 | 179 | = 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; | |
183 | 181 | sym->demangled_hash_next = table[hash_index]; |
184 | 182 | table[hash_index] = sym; |
185 | 183 | } |
@@ -1242,7 +1240,9 @@ compact_minimal_symbols (struct minimal_symbol *msymbol, int mcount, | ||
1242 | 1240 | thus causing the internal minimal_symbol pointers to become jumbled. */ |
1243 | 1241 | |
1244 | 1242 | 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) | |
1246 | 1246 | { |
1247 | 1247 | int i; |
1248 | 1248 | struct minimal_symbol *msym; |
@@ -1255,17 +1255,20 @@ build_minimal_symbol_hash_tables (struct objfile *objfile) | ||
1255 | 1255 | } |
1256 | 1256 | |
1257 | 1257 | /* 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, | |
1259 | 1260 | msym = objfile->per_bfd->msymbols.get ()); |
1260 | - i > 0; | |
1261 | - i--, msym++) | |
1261 | + i < mcount; | |
1262 | + i++, msym++) | |
1262 | 1263 | { |
1263 | 1264 | 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); | |
1265 | 1267 | |
1266 | 1268 | msym->demangled_hash_next = 0; |
1267 | 1269 | 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); | |
1269 | 1272 | } |
1270 | 1273 | } |
1271 | 1274 |
@@ -1347,6 +1350,8 @@ minimal_symbol_reader::install () | ||
1347 | 1350 | m_objfile->per_bfd->minimal_symbol_count = mcount; |
1348 | 1351 | m_objfile->per_bfd->msymbols = std::move (msym_holder); |
1349 | 1352 | |
1353 | + std::vector<std::pair<unsigned, unsigned>> hash_codes (mcount); | |
1354 | + | |
1350 | 1355 | msymbols = m_objfile->per_bfd->msymbols.get (); |
1351 | 1356 | gdb::parallel_for_each |
1352 | 1357 | (&msymbols[0], &msymbols[mcount], |
@@ -1367,6 +1372,11 @@ minimal_symbol_reader::install () | ||
1367 | 1372 | &m_objfile->per_bfd->storage_obstack); |
1368 | 1373 | msym->name_set = 1; |
1369 | 1374 | } |
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)); | |
1370 | 1380 | } |
1371 | 1381 | { |
1372 | 1382 | /* To limit how long we hold the lock, we only acquire it here |
@@ -1383,7 +1393,7 @@ minimal_symbol_reader::install () | ||
1383 | 1393 | } |
1384 | 1394 | }); |
1385 | 1395 | |
1386 | - build_minimal_symbol_hash_tables (m_objfile); | |
1396 | + build_minimal_symbol_hash_tables (m_objfile, hash_codes); | |
1387 | 1397 | } |
1388 | 1398 | } |
1389 | 1399 |