[Sanitizer] Rename InternalVector to InternalMmapVector
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@183972 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/asan/asan_globals.cc b/lib/asan/asan_globals.cc
index 301ea44..3c3d620 100644
--- a/lib/asan/asan_globals.cc
+++ b/lib/asan/asan_globals.cc
@@ -41,7 +41,7 @@
Global g;
bool initialized;
};
-typedef InternalVector<DynInitGlobal> VectorOfGlobals;
+typedef InternalMmapVector<DynInitGlobal> VectorOfGlobals;
// Lazy-initialized and never deleted.
static VectorOfGlobals *dynamic_init_globals;
diff --git a/lib/lsan/lsan_common.cc b/lib/lsan/lsan_common.cc
index c686994..84d3152 100644
--- a/lib/lsan/lsan_common.cc
+++ b/lib/lsan/lsan_common.cc
@@ -87,7 +87,8 @@
// chunks (tag = kReachable or kIgnored) and finding indirectly leaked chunks
// (tag = kIndirectlyLeaked). In the second case, there's no flood fill,
// so frontier = 0.
-void ScanRangeForPointers(uptr begin, uptr end, InternalVector<uptr> *frontier,
+void ScanRangeForPointers(uptr begin, uptr end,
+ InternalMmapVector<uptr> *frontier,
const char *region_type, ChunkTag tag) {
const uptr alignment = flags()->pointer_alignment();
if (flags()->log_pointers)
@@ -116,7 +117,7 @@
// Scan thread data (stacks and TLS) for heap pointers.
static void ProcessThreads(SuspendedThreadsList const &suspended_threads,
- InternalVector<uptr> *frontier) {
+ InternalMmapVector<uptr> *frontier) {
InternalScopedBuffer<uptr> registers(SuspendedThreadsList::RegisterCount());
uptr registers_begin = reinterpret_cast<uptr>(registers.data());
uptr registers_end = registers_begin + registers.size();
@@ -183,7 +184,7 @@
}
}
-static void FloodFillTag(InternalVector<uptr> *frontier, ChunkTag tag) {
+static void FloodFillTag(InternalMmapVector<uptr> *frontier, ChunkTag tag) {
while (frontier->size()) {
uptr next_chunk = frontier->back();
frontier->pop_back();
@@ -214,7 +215,7 @@
// Set the appropriate tag on each chunk.
static void ClassifyAllChunks(SuspendedThreadsList const &suspended_threads) {
// Holds the flood fill frontier.
- InternalVector<uptr> frontier(GetPageSizeCached());
+ InternalMmapVector<uptr> frontier(GetPageSizeCached());
if (flags()->use_globals)
ProcessGlobalRegions(&frontier);
diff --git a/lib/lsan/lsan_common.h b/lib/lsan/lsan_common.h
index 9ac2946..09a72a1 100644
--- a/lib/lsan/lsan_common.h
+++ b/lib/lsan/lsan_common.h
@@ -77,7 +77,7 @@
void InitCommonLsan();
// Testing interface. Find leaked chunks and dump their addresses to vector.
-void ReportLeaked(InternalVector<void *> *leaked, uptr sources);
+void ReportLeaked(InternalMmapVector<void *> *leaked, uptr sources);
// Normal leak check. Find leaks and print a report according to flags.
void DoLeakCheck();
@@ -97,15 +97,16 @@
void PrintSummary();
bool IsEmpty() { return leaks_.size() == 0; }
private:
- InternalVector<Leak> leaks_;
+ InternalMmapVector<Leak> leaks_;
};
// Platform-specific functions.
void InitializePlatformSpecificModules();
-void ProcessGlobalRegions(InternalVector<uptr> *frontier);
-void ProcessPlatformSpecificAllocations(InternalVector<uptr> *frontier);
+void ProcessGlobalRegions(InternalMmapVector<uptr> *frontier);
+void ProcessPlatformSpecificAllocations(InternalMmapVector<uptr> *frontier);
-void ScanRangeForPointers(uptr begin, uptr end, InternalVector<uptr> *frontier,
+void ScanRangeForPointers(uptr begin, uptr end,
+ InternalMmapVector<uptr> *frontier,
const char *region_type, ChunkTag tag);
// Callables for iterating over chunks. Those classes are used as template
@@ -116,11 +117,12 @@
// as reachable and adds them to the frontier.
class ProcessPlatformSpecificAllocationsCb {
public:
- explicit ProcessPlatformSpecificAllocationsCb(InternalVector<uptr> *frontier)
+ explicit ProcessPlatformSpecificAllocationsCb(
+ InternalMmapVector<uptr> *frontier)
: frontier_(frontier) {}
void operator()(void *p) const;
private:
- InternalVector<uptr> *frontier_;
+ InternalMmapVector<uptr> *frontier_;
};
// Prints addresses of unreachable chunks.
@@ -149,11 +151,11 @@
// Finds all chunk marked as kIgnored and adds their addresses to frontier.
class CollectSuppressedCb {
public:
- explicit CollectSuppressedCb(InternalVector<uptr> *frontier)
+ explicit CollectSuppressedCb(InternalMmapVector<uptr> *frontier)
: frontier_(frontier) {}
void operator()(void *p) const;
private:
- InternalVector<uptr> *frontier_;
+ InternalMmapVector<uptr> *frontier_;
};
enum IgnoreObjectResult {
diff --git a/lib/lsan/lsan_common_linux.cc b/lib/lsan/lsan_common_linux.cc
index 9570810..087ea3e 100644
--- a/lib/lsan/lsan_common_linux.cc
+++ b/lib/lsan/lsan_common_linux.cc
@@ -53,8 +53,8 @@
static int ProcessGlobalRegionsCallback(struct dl_phdr_info *info, size_t size,
void *data) {
- InternalVector<uptr> *frontier =
- reinterpret_cast<InternalVector<uptr> *>(data);
+ InternalMmapVector<uptr> *frontier =
+ reinterpret_cast<InternalMmapVector<uptr> *>(data);
for (uptr j = 0; j < info->dlpi_phnum; j++) {
const ElfW(Phdr) *phdr = &(info->dlpi_phdr[j]);
// We're looking for .data and .bss sections, which reside in writeable,
@@ -83,7 +83,7 @@
}
// Scan global variables for heap pointers.
-void ProcessGlobalRegions(InternalVector<uptr> *frontier) {
+void ProcessGlobalRegions(InternalMmapVector<uptr> *frontier) {
// FIXME: dl_iterate_phdr acquires a linker lock, so we run a risk of
// deadlocking by running this under StopTheWorld. However, the lock is
// reentrant, so we should be able to fix this by acquiring the lock before
@@ -114,7 +114,7 @@
// Handle dynamically allocated TLS blocks by treating all chunks allocated from
// ld-linux.so as reachable.
-void ProcessPlatformSpecificAllocations(InternalVector<uptr> *frontier) {
+void ProcessPlatformSpecificAllocations(InternalMmapVector<uptr> *frontier) {
if (!flags()->use_tls) return;
if (!linker) return;
ForEachChunk(ProcessPlatformSpecificAllocationsCb(frontier));
diff --git a/lib/sanitizer_common/sanitizer_common.h b/lib/sanitizer_common/sanitizer_common.h
index 1b22d58..7fbd1ba 100644
--- a/lib/sanitizer_common/sanitizer_common.h
+++ b/lib/sanitizer_common/sanitizer_common.h
@@ -274,15 +274,15 @@
// small vectors.
// WARNING: The current implementation supports only POD types.
template<typename T>
-class InternalVector {
+class InternalMmapVector {
public:
- explicit InternalVector(uptr initial_capacity) {
+ explicit InternalMmapVector(uptr initial_capacity) {
CHECK_GT(initial_capacity, 0);
capacity_ = initial_capacity;
size_ = 0;
- data_ = (T *)MmapOrDie(capacity_ * sizeof(T), "InternalVector");
+ data_ = (T *)MmapOrDie(capacity_ * sizeof(T), "InternalMmapVector");
}
- ~InternalVector() {
+ ~InternalMmapVector() {
UnmapOrDie(data_, capacity_ * sizeof(T));
}
T &operator[](uptr i) {
@@ -324,7 +324,7 @@
CHECK_GT(new_capacity, 0);
CHECK_LE(size_, new_capacity);
T *new_data = (T *)MmapOrDie(new_capacity * sizeof(T),
- "InternalVector");
+ "InternalMmapVector");
internal_memcpy(new_data, data_, size_ * sizeof(T));
T *old_data = data_;
data_ = new_data;
@@ -332,15 +332,15 @@
capacity_ = new_capacity;
}
// Disallow evil constructors.
- InternalVector(const InternalVector&);
- void operator=(const InternalVector&);
+ InternalMmapVector(const InternalMmapVector&);
+ void operator=(const InternalMmapVector&);
T *data_;
uptr capacity_;
uptr size_;
};
-// HeapSort for arrays and InternalVector.
+// HeapSort for arrays and InternalMmapVector.
template<class Container, class Compare>
void InternalSort(Container *v, uptr size, Compare comp) {
if (size < 2)
diff --git a/lib/sanitizer_common/sanitizer_stoptheworld.h b/lib/sanitizer_common/sanitizer_stoptheworld.h
index cc9408b..a326467 100644
--- a/lib/sanitizer_common/sanitizer_stoptheworld.h
+++ b/lib/sanitizer_common/sanitizer_stoptheworld.h
@@ -46,7 +46,7 @@
}
private:
- InternalVector<SuspendedThreadID> thread_ids_;
+ InternalMmapVector<SuspendedThreadID> thread_ids_;
// Prohibit copy and assign.
SuspendedThreadsList(const SuspendedThreadsList&);
diff --git a/lib/sanitizer_common/tests/sanitizer_common_test.cc b/lib/sanitizer_common/tests/sanitizer_common_test.cc
index 424c279..ee913dc 100644
--- a/lib/sanitizer_common/tests/sanitizer_common_test.cc
+++ b/lib/sanitizer_common/tests/sanitizer_common_test.cc
@@ -97,8 +97,8 @@
}
#endif
-TEST(SanitizerCommon, InternalVector) {
- InternalVector<uptr> vector(1);
+TEST(SanitizerCommon, InternalMmapVector) {
+ InternalMmapVector<uptr> vector(1);
for (uptr i = 0; i < 100; i++) {
EXPECT_EQ(i, vector.size());
vector.push_back(i);