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 ;
@@ -71,20 +71,27 @@ void ManualDWARFIndex::Index() {
71
71
clear_cu_dies[cu_idx] = units_to_index[cu_idx]->ExtractDIEsScoped ();
72
72
};
73
73
74
+ // Share one thread pool across operations to avoid the overhead of
75
+ // recreating the threads.
76
+ llvm::ThreadPool pool;
77
+
74
78
// Create a task runner that extracts dies for each DWARF unit in a
75
- // separate thread
79
+ // separate thread.
76
80
// First figure out which units didn't have their DIEs already
77
81
// parsed and remember this. If no DIEs were parsed prior to this index
78
82
// function call, we are going to want to clear the CU dies after we are
79
83
// done indexing to make sure we don't pull in all DWARF dies, but we need
80
84
// to wait until all units have been indexed in case a DIE in one
81
85
// unit refers to another and the indexes accesses those DIEs.
82
- TaskMapOverInt (0 , units_to_index.size (), extract_fn);
86
+ for (size_t i = 0 ; i < units_to_index.size (); ++i)
87
+ pool.async (extract_fn, i);
88
+ pool.wait ();
83
89
84
90
// Now create a task runner that can index each DWARF unit in a
85
91
// separate thread so we can index quickly.
86
-
87
- TaskMapOverInt (0 , units_to_index.size (), parser_fn);
92
+ for (size_t i = 0 ; i < units_to_index.size (); ++i)
93
+ pool.async (parser_fn, i);
94
+ pool.wait ();
88
95
89
96
auto finalize_fn = [this , &sets](NameToDIE (IndexSet::*index )) {
90
97
NameToDIE &result = m_set.*index ;
@@ -93,14 +100,15 @@ void ManualDWARFIndex::Index() {
93
100
result.Finalize ();
94
101
};
95
102
96
- TaskPool::RunTasks ([&]() { finalize_fn (&IndexSet::function_basenames); },
97
- [&]() { finalize_fn (&IndexSet::function_fullnames); },
98
- [&]() { finalize_fn (&IndexSet::function_methods); },
99
- [&]() { finalize_fn (&IndexSet::function_selectors); },
100
- [&]() { finalize_fn (&IndexSet::objc_class_selectors); },
101
- [&]() { finalize_fn (&IndexSet::globals); },
102
- [&]() { finalize_fn (&IndexSet::types); },
103
- [&]() { finalize_fn (&IndexSet::namespaces); });
103
+ pool.async (finalize_fn, &IndexSet::function_basenames);
104
+ pool.async (finalize_fn, &IndexSet::function_fullnames);
105
+ pool.async (finalize_fn, &IndexSet::function_methods);
106
+ pool.async (finalize_fn, &IndexSet::function_selectors);
107
+ pool.async (finalize_fn, &IndexSet::objc_class_selectors);
108
+ pool.async (finalize_fn, &IndexSet::globals);
109
+ pool.async (finalize_fn, &IndexSet::types);
110
+ pool.async (finalize_fn, &IndexSet::namespaces);
111
+ pool.wait ();
104
112
}
105
113
106
114
void ManualDWARFIndex::IndexUnit (DWARFUnit &unit, SymbolFileDWARFDwo *dwp,
0 commit comments