summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorFrancis Ricci <francisjricci@gmail.com>2017-09-29 20:55:06 +0000
committerFrancis Ricci <francisjricci@gmail.com>2017-09-29 20:55:06 +0000
commitc9b5e685aed2bf2bd2faa0566b90196f6e9eb7ba (patch)
tree7a718284bce733bc36670e7d3359dcd3caa3d11b /lib
parentfaf993b377cb1212143ea0659c178f0408582351 (diff)
downloadcompiler-rt-c9b5e685aed2bf2bd2faa0566b90196f6e9eb7ba.tar.gz
Move LoadedModule list to a NoCtor vector and initialize on demand.
Unreverting this patch because llvm-clang-lld-x86_64-debian-fast started passing again before the revert hit. Must've been just a flake. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@314556 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r--lib/sanitizer_common/sanitizer_common.h9
-rw-r--r--lib/sanitizer_common/sanitizer_linux_libcdep.cc6
-rw-r--r--lib/sanitizer_common/sanitizer_mac.cc2
-rw-r--r--lib/sanitizer_common/sanitizer_procmaps.h2
-rw-r--r--lib/sanitizer_common/sanitizer_procmaps_common.cc2
-rw-r--r--lib/sanitizer_common/sanitizer_procmaps_mac.cc2
-rw-r--r--lib/sanitizer_common/sanitizer_win.cc2
7 files changed, 15 insertions, 10 deletions
diff --git a/lib/sanitizer_common/sanitizer_common.h b/lib/sanitizer_common/sanitizer_common.h
index 47b02b149..11ee59024 100644
--- a/lib/sanitizer_common/sanitizer_common.h
+++ b/lib/sanitizer_common/sanitizer_common.h
@@ -727,7 +727,7 @@ class LoadedModule {
// filling this information.
class ListOfModules {
public:
- ListOfModules() : modules_(kInitialCapacity) {}
+ ListOfModules() : initialized(false) {}
~ListOfModules() { clear(); }
void init();
const LoadedModule *begin() const { return modules_.begin(); }
@@ -745,10 +745,15 @@ class ListOfModules {
for (auto &module : modules_) module.clear();
modules_.clear();
}
+ void clearOrInit() {
+ initialized ? clear() : modules_.Initialize(kInitialCapacity);
+ initialized = true;
+ }
- InternalMmapVector<LoadedModule> modules_;
+ InternalMmapVectorNoCtor<LoadedModule> modules_;
// We rarely have more than 16K loaded modules.
static const uptr kInitialCapacity = 1 << 14;
+ bool initialized;
};
// Callback type for iterating over a set of memory ranges.
diff --git a/lib/sanitizer_common/sanitizer_linux_libcdep.cc b/lib/sanitizer_common/sanitizer_linux_libcdep.cc
index da715dc6c..0f420875d 100644
--- a/lib/sanitizer_common/sanitizer_linux_libcdep.cc
+++ b/lib/sanitizer_common/sanitizer_linux_libcdep.cc
@@ -424,7 +424,7 @@ typedef ElfW(Phdr) Elf_Phdr;
# endif
struct DlIteratePhdrData {
- InternalMmapVector<LoadedModule> *modules;
+ InternalMmapVectorNoCtor<LoadedModule> *modules;
bool first;
};
@@ -473,13 +473,13 @@ static bool requiresProcmaps() {
#endif
}
-static void procmapsInit(InternalMmapVector<LoadedModule> *modules) {
+static void procmapsInit(InternalMmapVectorNoCtor<LoadedModule> *modules) {
MemoryMappingLayout memory_mapping(false);
memory_mapping.DumpListOfModules(modules);
}
void ListOfModules::init() {
- clear();
+ clearOrInit();
if (requiresProcmaps()) {
procmapsInit(&modules_);
} else {
diff --git a/lib/sanitizer_common/sanitizer_mac.cc b/lib/sanitizer_common/sanitizer_mac.cc
index 1570ae277..cd63cb42f 100644
--- a/lib/sanitizer_common/sanitizer_mac.cc
+++ b/lib/sanitizer_common/sanitizer_mac.cc
@@ -411,7 +411,7 @@ void GetThreadStackAndTls(bool main, uptr *stk_addr, uptr *stk_size,
}
void ListOfModules::init() {
- clear();
+ clearOrInit();
MemoryMappingLayout memory_mapping(false);
memory_mapping.DumpListOfModules(&modules_);
}
diff --git a/lib/sanitizer_common/sanitizer_procmaps.h b/lib/sanitizer_common/sanitizer_procmaps.h
index 96d0b2f9d..d462ad841 100644
--- a/lib/sanitizer_common/sanitizer_procmaps.h
+++ b/lib/sanitizer_common/sanitizer_procmaps.h
@@ -76,7 +76,7 @@ class MemoryMappingLayout {
static void CacheMemoryMappings();
// Adds all mapped objects into a vector.
- void DumpListOfModules(InternalMmapVector<LoadedModule> *modules);
+ void DumpListOfModules(InternalMmapVectorNoCtor<LoadedModule> *modules);
private:
void LoadFromCache();
diff --git a/lib/sanitizer_common/sanitizer_procmaps_common.cc b/lib/sanitizer_common/sanitizer_procmaps_common.cc
index 30663e8c6..b9298d4cc 100644
--- a/lib/sanitizer_common/sanitizer_procmaps_common.cc
+++ b/lib/sanitizer_common/sanitizer_procmaps_common.cc
@@ -120,7 +120,7 @@ void MemoryMappingLayout::LoadFromCache() {
}
void MemoryMappingLayout::DumpListOfModules(
- InternalMmapVector<LoadedModule> *modules) {
+ InternalMmapVectorNoCtor<LoadedModule> *modules) {
Reset();
InternalScopedString module_name(kMaxPathLength);
MemoryMappedSegment segment(module_name.data(), module_name.size());
diff --git a/lib/sanitizer_common/sanitizer_procmaps_mac.cc b/lib/sanitizer_common/sanitizer_procmaps_mac.cc
index 786876f04..3b98ff095 100644
--- a/lib/sanitizer_common/sanitizer_procmaps_mac.cc
+++ b/lib/sanitizer_common/sanitizer_procmaps_mac.cc
@@ -353,7 +353,7 @@ bool MemoryMappingLayout::Next(MemoryMappedSegment *segment) {
}
void MemoryMappingLayout::DumpListOfModules(
- InternalMmapVector<LoadedModule> *modules) {
+ InternalMmapVectorNoCtor<LoadedModule> *modules) {
Reset();
InternalScopedString module_name(kMaxPathLength);
MemoryMappedSegment segment(module_name.data(), kMaxPathLength);
diff --git a/lib/sanitizer_common/sanitizer_win.cc b/lib/sanitizer_common/sanitizer_win.cc
index a144db28c..84065aa0e 100644
--- a/lib/sanitizer_common/sanitizer_win.cc
+++ b/lib/sanitizer_common/sanitizer_win.cc
@@ -524,7 +524,7 @@ static uptr GetPreferredBase(const char *modname) {
}
void ListOfModules::init() {
- clear();
+ clearOrInit();
HANDLE cur_process = GetCurrentProcess();
// Query the list of modules. Start by assuming there are no more than 256