summaryrefslogtreecommitdiff
path: root/lib/lsan/lsan_allocator.cc
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
commit3fbf3a4149ca94d84b77797f9e7b3a60b785cddc (patch)
treed007407e76efa030e686cb1a50343fba163cceed /lib/lsan/lsan_allocator.cc
parent82b27a27ce1839468c43b5e41e380a6a88df7dd7 (diff)
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 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@298848 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/lsan/lsan_allocator.cc')
-rw-r--r--lib/lsan/lsan_allocator.cc38
1 files changed, 1 insertions, 37 deletions
diff --git a/lib/lsan/lsan_allocator.cc b/lib/lsan/lsan_allocator.cc
index a08dcf286..640497d40 100644
--- a/lib/lsan/lsan_allocator.cc
+++ b/lib/lsan/lsan_allocator.cc
@@ -24,54 +24,18 @@
extern "C" void *memset(void *ptr, int value, uptr num);
namespace __lsan {
-
-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__)
#if defined(__i386__)
static const uptr kMaxAllowedMallocSize = 1UL << 30;
-#else
+#elif defined(__mips64) || defined(__aarch64__)
static const uptr kMaxAllowedMallocSize = 4UL << 30;
-#endif
-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;
#else
static const uptr kMaxAllowedMallocSize = 8UL << 30;
-
-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;
typedef LargeMmapAllocator<> SecondaryAllocator;
typedef CombinedAllocator<PrimaryAllocator, AllocatorCache,
SecondaryAllocator> Allocator;
static Allocator allocator;
-static THREADLOCAL AllocatorCache allocator_cache;
-AllocatorCache *GetAllocatorCache() { return &allocator_cache; }
void InitializeAllocator() {
allocator.InitLinkerInitialized(