13
13
#include " Plugins/SymbolFile/DWARF/LogChannelDWARF.h"
14
14
#include " Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.h"
15
15
#include " lldb/Core/Module.h"
16
- #include " lldb/Host/TaskPool.h"
17
16
#include " lldb/Symbol/ObjectFile.h"
18
17
#include " lldb/Utility/Stream.h"
19
18
#include " lldb/Utility/Timer.h"
19
+ #include " llvm/Support/ThreadPool.h"
20
20
21
21
using namespace lldb_private ;
22
22
using namespace lldb ;
@@ -55,25 +55,29 @@ void ManualDWARFIndex::Index() {
55
55
clear_cu_dies[cu_idx] = units_to_index[cu_idx]->ExtractDIEsScoped ();
56
56
};
57
57
58
+ // Share one thread pool across operations to avoid the overhead of
59
+ // recreating the threads.
60
+ llvm::ThreadPool pool;
61
+
58
62
// Create a task runner that extracts dies for each DWARF unit in a
59
- // separate thread
63
+ // separate thread.
60
64
// First figure out which units didn't have their DIEs already
61
65
// parsed and remember this. If no DIEs were parsed prior to this index
62
66
// function call, we are going to want to clear the CU dies after we are
63
67
// done indexing to make sure we don't pull in all DWARF dies, but we need
64
- // to wait until all compile units have been indexed in case a DIE in one
65
- // compile unit refers to another and the indexes accesses those DIEs.
66
- // ----------------------------------------------------------------------
67
- for (int i=0 ; i<units_to_index.size (); ++i) {
68
- extract_fn (i);
69
- }
70
- // This call can deadlock because we are sometimes holding the module lock.
71
- // TaskMapOverInt(0, units_to_index.size(), extract_fn);
68
+ // to wait until all units have been indexed in case a DIE in one
69
+ // unit refers to another and the indexes accesses those DIEs.
70
+ //
71
+ // This call can deadlock because we are sometimes holding the module lock so
72
+ // don't do it asynchronously.
73
+ for (size_t i = 0 ; i < units_to_index.size (); ++i)
74
+ extract_fn (i);
72
75
73
76
// Now create a task runner that can index each DWARF unit in a
74
77
// separate thread so we can index quickly.
75
-
76
- TaskMapOverInt (0 , units_to_index.size (), parser_fn);
78
+ for (size_t i = 0 ; i < units_to_index.size (); ++i)
79
+ pool.async (parser_fn, i);
80
+ pool.wait ();
77
81
78
82
auto finalize_fn = [this , &sets](NameToDIE (IndexSet::*index )) {
79
83
NameToDIE &result = m_set.*index ;
@@ -82,14 +86,15 @@ void ManualDWARFIndex::Index() {
82
86
result.Finalize ();
83
87
};
84
88
85
- TaskPool::RunTasks ([&]() { finalize_fn (&IndexSet::function_basenames); },
86
- [&]() { finalize_fn (&IndexSet::function_fullnames); },
87
- [&]() { finalize_fn (&IndexSet::function_methods); },
88
- [&]() { finalize_fn (&IndexSet::function_selectors); },
89
- [&]() { finalize_fn (&IndexSet::objc_class_selectors); },
90
- [&]() { finalize_fn (&IndexSet::globals); },
91
- [&]() { finalize_fn (&IndexSet::types); },
92
- [&]() { finalize_fn (&IndexSet::namespaces); });
89
+ pool.async (finalize_fn, &IndexSet::function_basenames);
90
+ pool.async (finalize_fn, &IndexSet::function_fullnames);
91
+ pool.async (finalize_fn, &IndexSet::function_methods);
92
+ pool.async (finalize_fn, &IndexSet::function_selectors);
93
+ pool.async (finalize_fn, &IndexSet::objc_class_selectors);
94
+ pool.async (finalize_fn, &IndexSet::globals);
95
+ pool.async (finalize_fn, &IndexSet::types);
96
+ pool.async (finalize_fn, &IndexSet::namespaces);
97
+ pool.wait ();
93
98
}
94
99
95
100
void ManualDWARFIndex::IndexUnit (DWARFUnit &unit, IndexSet &set) {
0 commit comments