[compiler-rt] ff8c0e6 - [scudo] Pass MapPlatformData in more calls
Dominic Chen via llvm-commits
llvm-commits at lists.llvm.org
Thu Jul 7 10:43:15 PDT 2022
Author: Dominic Chen
Date: 2022-07-07T10:43:07-07:00
New Revision: ff8c0e6eb5a820c012c9de81608648d3ffc78600
URL: https://github.com/llvm/llvm-project/commit/ff8c0e6eb5a820c012c9de81608648d3ffc78600
DIFF: https://github.com/llvm/llvm-project/commit/ff8c0e6eb5a820c012c9de81608648d3ffc78600.diff
LOG: [scudo] Pass MapPlatformData in more calls
Allow platforms to avoid looking up private data by providing private context
Differential Revision: https://reviews.llvm.org/D129237
Added:
Modified:
compiler-rt/lib/scudo/standalone/release.h
compiler-rt/lib/scudo/standalone/vector.h
Removed:
################################################################################
diff --git a/compiler-rt/lib/scudo/standalone/release.h b/compiler-rt/lib/scudo/standalone/release.h
index 293a8bc27bab5..9dad3c36520fe 100644
--- a/compiler-rt/lib/scudo/standalone/release.h
+++ b/compiler-rt/lib/scudo/standalone/release.h
@@ -82,7 +82,7 @@ class PackedCounterArray {
} else {
Buffer = reinterpret_cast<uptr *>(
map(nullptr, roundUpTo(BufferSize, getPageSizeCached()),
- "scudo:counters", MAP_ALLOWNOMEM));
+ "scudo:counters", MAP_ALLOWNOMEM, &MapData));
}
}
~PackedCounterArray() {
@@ -92,7 +92,7 @@ class PackedCounterArray {
Mutex.unlock();
else
unmap(reinterpret_cast<void *>(Buffer),
- roundUpTo(BufferSize, getPageSizeCached()));
+ roundUpTo(BufferSize, getPageSizeCached()), 0, &MapData);
}
bool isAllocated() const { return !!Buffer; }
@@ -138,6 +138,7 @@ class PackedCounterArray {
uptr SizePerRegion;
uptr BufferSize;
uptr *Buffer;
+ MapPlatformData MapData = {};
static HybridMutex Mutex;
static uptr StaticBuffer[StaticBufferCount];
diff --git a/compiler-rt/lib/scudo/standalone/vector.h b/compiler-rt/lib/scudo/standalone/vector.h
index eae774b56e280..84e9c537d28d6 100644
--- a/compiler-rt/lib/scudo/standalone/vector.h
+++ b/compiler-rt/lib/scudo/standalone/vector.h
@@ -27,7 +27,7 @@ template <typename T> class VectorNoCtor {
}
void destroy() {
if (Data != &LocalData[0])
- unmap(Data, CapacityBytes);
+ unmap(Data, CapacityBytes, 0, &MapData);
}
T &operator[](uptr I) {
DCHECK_LT(I, Size);
@@ -83,8 +83,8 @@ template <typename T> class VectorNoCtor {
DCHECK_GT(NewCapacity, 0);
DCHECK_LE(Size, NewCapacity);
NewCapacity = roundUpTo(NewCapacity * sizeof(T), getPageSizeCached());
- T *NewData =
- reinterpret_cast<T *>(map(nullptr, NewCapacity, "scudo:vector"));
+ T *NewData = reinterpret_cast<T *>(
+ map(nullptr, NewCapacity, "scudo:vector", 0, &MapData));
memcpy(NewData, Data, Size * sizeof(T));
destroy();
Data = NewData;
@@ -95,6 +95,7 @@ template <typename T> class VectorNoCtor {
T LocalData[256 / sizeof(T)] = {};
uptr CapacityBytes = 0;
uptr Size = 0;
+ MapPlatformData MapData = {};
};
template <typename T> class Vector : public VectorNoCtor<T> {
More information about the llvm-commits
mailing list