summaryrefslogtreecommitdiffstats
path: root/compiler-rt/lib/scudo/scudo_tls_linux.cpp
diff options
context:
space:
mode:
authorKostya Kortchinsky <kostyak@google.com>2017-09-25 15:12:08 +0000
committerKostya Kortchinsky <kostyak@google.com>2017-09-25 15:12:08 +0000
commit22396c2f4798436ed86be1345f60b098be48b155 (patch)
tree1436f5b52806b0bda7470accc4e9a7ff1883a55b /compiler-rt/lib/scudo/scudo_tls_linux.cpp
parent4a97df01c43170eed51d2cca0dc779d9d2ca6419 (diff)
downloadbcm5719-llvm-22396c2f4798436ed86be1345f60b098be48b155.tar.gz
bcm5719-llvm-22396c2f4798436ed86be1345f60b098be48b155.zip
[scudo] Scudo thread specific data refactor, part 2
Summary: Following D38139, we now consolidate the TSD definition, merging the shared TSD definition with the exclusive TSD definition. We introduce a boolean set at initializaton denoting the need for the TSD to be unlocked or not. This adds some unused members to the exclusive TSD, but increases consistency and reduces the definitions fragmentation. We remove the fallback mechanism from `scudo_allocator.cpp` and add a fallback TSD in the non-shared version. Since the shared version doesn't require one, this makes overall more sense. There are a couple of additional cosmetic changes: removing the header guards from the remaining `.inc` files, added error string to a `CHECK`. Question to reviewers: I thought about friending `getTSDAndLock` in `ScudoTSD` so that the `FallbackTSD` could `Mutex.Lock()` directly instead of `lock()` which involved zeroing out the `Precedence`, which is unused otherwise. Is it worth doing? Reviewers: alekseyshl, dvyukov, kcc Reviewed By: dvyukov Subscribers: srhines, llvm-commits Differential Revision: https://reviews.llvm.org/D38183 llvm-svn: 314110
Diffstat (limited to 'compiler-rt/lib/scudo/scudo_tls_linux.cpp')
-rw-r--r--compiler-rt/lib/scudo/scudo_tls_linux.cpp7
1 files changed, 6 insertions, 1 deletions
diff --git a/compiler-rt/lib/scudo/scudo_tls_linux.cpp b/compiler-rt/lib/scudo/scudo_tls_linux.cpp
index 84553945797..1f51cccbcc8 100644
--- a/compiler-rt/lib/scudo/scudo_tls_linux.cpp
+++ b/compiler-rt/lib/scudo/scudo_tls_linux.cpp
@@ -30,6 +30,10 @@ THREADLOCAL ThreadState ScudoThreadState = ThreadNotInitialized;
__attribute__((tls_model("initial-exec")))
THREADLOCAL ScudoTSD TSD;
+// Fallback TSD for when the thread isn't initialized yet or is torn down. It
+// can be shared between multiple threads and as such must be locked.
+ScudoTSD FallbackTSD;
+
static void teardownThread(void *Ptr) {
uptr I = reinterpret_cast<uptr>(Ptr);
// The glibc POSIX thread-local-storage deallocation routine calls user
@@ -51,6 +55,7 @@ static void teardownThread(void *Ptr) {
static void initOnce() {
CHECK_EQ(pthread_key_create(&PThreadKey, teardownThread), 0);
initScudo();
+ FallbackTSD.init(/*Shared=*/true);
}
void initThread(bool MinimalInit) {
@@ -59,7 +64,7 @@ void initThread(bool MinimalInit) {
return;
CHECK_EQ(pthread_setspecific(PThreadKey, reinterpret_cast<void *>(
GetPthreadDestructorIterations())), 0);
- TSD.init();
+ TSD.init(/*Shared=*/false);
ScudoThreadState = ThreadInitialized;
}
OpenPOWER on IntegriCloud