asan: always pass allocator cache to Allocate()
llvm-svn: 172193
This commit is contained in:
parent
b1c0dbe2c6
commit
008dba6aa0
|
|
@ -337,8 +337,15 @@ static void *Allocate(uptr size, uptr alignment, StackTrace *stack,
|
||||||
}
|
}
|
||||||
|
|
||||||
AsanThread *t = asanThreadRegistry().GetCurrent();
|
AsanThread *t = asanThreadRegistry().GetCurrent();
|
||||||
AllocatorCache *cache = t ? GetAllocatorCache(&t->malloc_storage()) : 0;
|
void *allocated;
|
||||||
void *allocated = allocator.Allocate(cache, needed_size, 8, false);
|
if (t) {
|
||||||
|
AllocatorCache *cache = GetAllocatorCache(&t->malloc_storage());
|
||||||
|
allocated = allocator.Allocate(cache, needed_size, 8, false);
|
||||||
|
} else {
|
||||||
|
SpinMutexLock l(&fallback_mutex);
|
||||||
|
AllocatorCache *cache = &fallback_cache;
|
||||||
|
allocated = allocator.Allocate(cache, needed_size, 8, false);
|
||||||
|
}
|
||||||
uptr alloc_beg = reinterpret_cast<uptr>(allocated);
|
uptr alloc_beg = reinterpret_cast<uptr>(allocated);
|
||||||
uptr alloc_end = alloc_beg + needed_size;
|
uptr alloc_end = alloc_beg + needed_size;
|
||||||
uptr beg_plus_redzone = alloc_beg + rz_size;
|
uptr beg_plus_redzone = alloc_beg + rz_size;
|
||||||
|
|
|
||||||
|
|
@ -728,6 +728,7 @@ class LargeMmapAllocator {
|
||||||
internal_memset(this, 0, sizeof(*this));
|
internal_memset(this, 0, sizeof(*this));
|
||||||
page_size_ = GetPageSizeCached();
|
page_size_ = GetPageSizeCached();
|
||||||
}
|
}
|
||||||
|
|
||||||
void *Allocate(uptr size, uptr alignment) {
|
void *Allocate(uptr size, uptr alignment) {
|
||||||
CHECK(IsPowerOfTwo(alignment));
|
CHECK(IsPowerOfTwo(alignment));
|
||||||
uptr map_size = RoundUpMapSize(size);
|
uptr map_size = RoundUpMapSize(size);
|
||||||
|
|
@ -899,14 +900,10 @@ class CombinedAllocator {
|
||||||
if (alignment > 8)
|
if (alignment > 8)
|
||||||
size = RoundUpTo(size, alignment);
|
size = RoundUpTo(size, alignment);
|
||||||
void *res;
|
void *res;
|
||||||
if (primary_.CanAllocate(size, alignment)) {
|
if (primary_.CanAllocate(size, alignment))
|
||||||
if (cache) // Allocate from cache.
|
|
||||||
res = cache->Allocate(&primary_, primary_.ClassID(size));
|
res = cache->Allocate(&primary_, primary_.ClassID(size));
|
||||||
else // No thread-local cache, allocate directly from primary allocator.
|
else
|
||||||
res = primary_.Allocate(size, alignment);
|
|
||||||
} else { // Secondary allocator does not use cache.
|
|
||||||
res = secondary_.Allocate(size, alignment);
|
res = secondary_.Allocate(size, alignment);
|
||||||
}
|
|
||||||
if (alignment > 8)
|
if (alignment > 8)
|
||||||
CHECK_EQ(reinterpret_cast<uptr>(res) & (alignment - 1), 0);
|
CHECK_EQ(reinterpret_cast<uptr>(res) & (alignment - 1), 0);
|
||||||
if (cleared && res)
|
if (cleared && res)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue