summaryrefslogtreecommitdiffstats
path: root/compiler-rt/lib/lsan/lsan_allocator.h
diff options
context:
space:
mode:
authorFrancis Ricci <francisjricci@gmail.com>2017-03-27 14:07:50 +0000
committerFrancis Ricci <francisjricci@gmail.com>2017-03-27 14:07:50 +0000
commitd668a018f736118ebd3abbf0511076a1a5f61ca2 (patch)
tree568b4ff82638fda9b49e39862b288b4115651a40 /compiler-rt/lib/lsan/lsan_allocator.h
parent0add37927c8b391a3785eae78be1885637f02310 (diff)
downloadbcm5719-llvm-d668a018f736118ebd3abbf0511076a1a5f61ca2.tar.gz
bcm5719-llvm-d668a018f736118ebd3abbf0511076a1a5f61ca2.zip
Use pthreads for thread-local lsan allocator cache on darwin
Summary: This patch allows us to move away from using __thread on darwin, which is requiring for building lsan for darwin on ios version 7 and on iossim i386. Reviewers: kubamracek, kcc Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D31291 llvm-svn: 298848
Diffstat (limited to 'compiler-rt/lib/lsan/lsan_allocator.h')
-rw-r--r--compiler-rt/lib/lsan/lsan_allocator.h37
1 files changed, 37 insertions, 0 deletions
diff --git a/compiler-rt/lib/lsan/lsan_allocator.h b/compiler-rt/lib/lsan/lsan_allocator.h
index f564601193b..9c3dce97a09 100644
--- a/compiler-rt/lib/lsan/lsan_allocator.h
+++ b/compiler-rt/lib/lsan/lsan_allocator.h
@@ -15,8 +15,10 @@
#ifndef LSAN_ALLOCATOR_H
#define LSAN_ALLOCATOR_H
+#include "sanitizer_common/sanitizer_allocator.h"
#include "sanitizer_common/sanitizer_common.h"
#include "sanitizer_common/sanitizer_internal_defs.h"
+#include "lsan_common.h"
namespace __lsan {
@@ -34,6 +36,41 @@ void GetAllocatorCacheRange(uptr *begin, uptr *end);
void AllocatorThreadFinish();
void InitializeAllocator();
+struct ChunkMetadata {
+ u8 allocated : 8; // Must be first.
+ ChunkTag tag : 2;
+#if SANITIZER_WORDSIZE == 64
+ uptr requested_size : 54;
+#else
+ uptr requested_size : 32;
+ uptr padding : 22;
+#endif
+ u32 stack_trace_id;
+};
+
+#if defined(__mips64) || defined(__aarch64__) || defined(__i386__)
+static const uptr kRegionSizeLog = 20;
+static const uptr kNumRegions = SANITIZER_MMAP_RANGE_SIZE >> kRegionSizeLog;
+typedef TwoLevelByteMap<(kNumRegions >> 12), 1 << 12> ByteMap;
+typedef CompactSizeClassMap SizeClassMap;
+typedef SizeClassAllocator32<0, SANITIZER_MMAP_RANGE_SIZE,
+ sizeof(ChunkMetadata), SizeClassMap, kRegionSizeLog, ByteMap>
+ PrimaryAllocator;
+#elif defined(__x86_64__)
+struct AP64 { // Allocator64 parameters. Deliberately using a short name.
+ static const uptr kSpaceBeg = 0x600000000000ULL;
+ static const uptr kSpaceSize = 0x40000000000ULL; // 4T.
+ static const uptr kMetadataSize = sizeof(ChunkMetadata);
+ typedef DefaultSizeClassMap SizeClassMap;
+ typedef NoOpMapUnmapCallback MapUnmapCallback;
+ static const uptr kFlags = 0;
+};
+
+typedef SizeClassAllocator64<AP64> PrimaryAllocator;
+#endif
+typedef SizeClassAllocatorLocalCache<PrimaryAllocator> AllocatorCache;
+
+AllocatorCache *GetAllocatorCache();
} // namespace __lsan
#endif // LSAN_ALLOCATOR_H
OpenPOWER on IntegriCloud