[PATCH] D29994: Use pthreads for thread-local lsan allocator cache on darwin
Francis Ricci via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Mar 22 11:55:07 PDT 2017
This revision was automatically updated to reflect the committed changes.
Closed by commit rL298537: Factor lsan allocator cache accesses into a function (authored by fjricci).
Changed prior to commit:
https://reviews.llvm.org/D29994?vs=92669&id=92673#toc
Repository:
rL LLVM
https://reviews.llvm.org/D29994
Files:
compiler-rt/trunk/lib/lsan/lsan_allocator.cc
Index: compiler-rt/trunk/lib/lsan/lsan_allocator.cc
===================================================================
--- compiler-rt/trunk/lib/lsan/lsan_allocator.cc
+++ compiler-rt/trunk/lib/lsan/lsan_allocator.cc
@@ -70,16 +70,17 @@
SecondaryAllocator> Allocator;
static Allocator allocator;
-static THREADLOCAL AllocatorCache cache;
+static THREADLOCAL AllocatorCache allocator_cache;
+AllocatorCache *GetAllocatorCache() { return &allocator_cache; }
void InitializeAllocator() {
allocator.InitLinkerInitialized(
common_flags()->allocator_may_return_null,
common_flags()->allocator_release_to_os_interval_ms);
}
void AllocatorThreadFinish() {
- allocator.SwallowCache(&cache);
+ allocator.SwallowCache(GetAllocatorCache());
}
static ChunkMetadata *Metadata(const void *p) {
@@ -111,7 +112,7 @@
Report("WARNING: LeakSanitizer failed to allocate %zu bytes\n", size);
return nullptr;
}
- void *p = allocator.Allocate(&cache, size, alignment, false);
+ void *p = allocator.Allocate(GetAllocatorCache(), size, alignment, false);
// Do not rely on the allocator to clear the memory (it's slow).
if (cleared && allocator.FromPrimary(p))
memset(p, 0, size);
@@ -125,25 +126,25 @@
if (&__sanitizer_free_hook) __sanitizer_free_hook(p);
RunFreeHooks(p);
RegisterDeallocation(p);
- allocator.Deallocate(&cache, p);
+ allocator.Deallocate(GetAllocatorCache(), p);
}
void *Reallocate(const StackTrace &stack, void *p, uptr new_size,
uptr alignment) {
RegisterDeallocation(p);
if (new_size > kMaxAllowedMallocSize) {
Report("WARNING: LeakSanitizer failed to allocate %zu bytes\n", new_size);
- allocator.Deallocate(&cache, p);
+ allocator.Deallocate(GetAllocatorCache(), p);
return nullptr;
}
- p = allocator.Reallocate(&cache, p, new_size, alignment);
+ p = allocator.Reallocate(GetAllocatorCache(), p, new_size, alignment);
RegisterAllocation(stack, p, new_size);
return p;
}
void GetAllocatorCacheRange(uptr *begin, uptr *end) {
- *begin = (uptr)&cache;
- *end = *begin + sizeof(cache);
+ *begin = (uptr)GetAllocatorCache();
+ *end = *begin + sizeof(AllocatorCache);
}
uptr GetMallocUsableSize(const void *p) {
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D29994.92673.patch
Type: text/x-patch
Size: 2253 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170322/994d5434/attachment-0001.bin>
More information about the llvm-commits
mailing list