summaryrefslogtreecommitdiffstats
path: root/compiler-rt/lib/scudo/scudo_tsd_exclusive.inc
diff options
context:
space:
mode:
authorKostya Kortchinsky <kostyak@google.com>2017-09-26 17:20:02 +0000
committerKostya Kortchinsky <kostyak@google.com>2017-09-26 17:20:02 +0000
commitb59abb2590898d1325f1b67b6ea2f75a1bfbd78c (patch)
tree24744bbdb1fb7bf6680ec4498b70a53e46d3ab7e /compiler-rt/lib/scudo/scudo_tsd_exclusive.inc
parentbab95c70874e3890dfac0fb03246aa1fb88f9506 (diff)
downloadbcm5719-llvm-b59abb2590898d1325f1b67b6ea2f75a1bfbd78c.tar.gz
bcm5719-llvm-b59abb2590898d1325f1b67b6ea2f75a1bfbd78c.zip
[scudo] Scudo thread specific data refactor, part 3
Summary: Previous parts: D38139, D38183. In this part of the refactor, we abstract the Linux vs Android TSD dissociation in favor of a Exclusive vs Shared one, allowing for easier platform introduction and configuration. Most of this change consist of shuffling the files around to reflect the new organization. We introduce `scudo_platform.h` where platform specific definition lie. This involves the TSD model and the platform specific allocator parameters. In an upcoming CL, those will be configurable via defines, but we currently stick with conservative defaults. Reviewers: alekseyshl, dvyukov Reviewed By: alekseyshl, dvyukov Subscribers: srhines, llvm-commits, mgorny Differential Revision: https://reviews.llvm.org/D38244 llvm-svn: 314224
Diffstat (limited to 'compiler-rt/lib/scudo/scudo_tsd_exclusive.inc')
-rw-r--r--compiler-rt/lib/scudo/scudo_tsd_exclusive.inc46
1 files changed, 46 insertions, 0 deletions
diff --git a/compiler-rt/lib/scudo/scudo_tsd_exclusive.inc b/compiler-rt/lib/scudo/scudo_tsd_exclusive.inc
new file mode 100644
index 00000000000..567b6a1edd1
--- /dev/null
+++ b/compiler-rt/lib/scudo/scudo_tsd_exclusive.inc
@@ -0,0 +1,46 @@
+//===-- scudo_tsd_exclusive.inc ---------------------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+///
+/// Scudo exclusive TSD fastpath functions implementation.
+///
+//===----------------------------------------------------------------------===//
+
+#ifndef SCUDO_TSD_H_
+# error "This file must be included inside scudo_tsd.h."
+#endif // SCUDO_TSD_H_
+
+#if SCUDO_TSD_EXCLUSIVE
+
+enum ThreadState : u8 {
+ ThreadNotInitialized = 0,
+ ThreadInitialized,
+ ThreadTornDown,
+};
+__attribute__((tls_model("initial-exec")))
+extern THREADLOCAL ThreadState ScudoThreadState;
+__attribute__((tls_model("initial-exec")))
+extern THREADLOCAL ScudoTSD TSD;
+
+extern ScudoTSD FallbackTSD;
+
+ALWAYS_INLINE void initThreadMaybe(bool MinimalInit = false) {
+ if (LIKELY(ScudoThreadState != ThreadNotInitialized))
+ return;
+ initThread(MinimalInit);
+}
+
+ALWAYS_INLINE ScudoTSD *getTSDAndLock() {
+ if (UNLIKELY(ScudoThreadState != ThreadInitialized)) {
+ FallbackTSD.lock();
+ return &FallbackTSD;
+ }
+ return &TSD;
+}
+
+#endif // SCUDO_TSD_EXCLUSIVE
OpenPOWER on IntegriCloud