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();
|
||||
AllocatorCache *cache = t ? GetAllocatorCache(&t->malloc_storage()) : 0;
|
||||
void *allocated = allocator.Allocate(cache, needed_size, 8, false);
|
||||
void *allocated;
|
||||
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_end = alloc_beg + needed_size;
|
||||
uptr beg_plus_redzone = alloc_beg + rz_size;
|
||||
|
|
|
|||
|
|
@ -728,6 +728,7 @@ class LargeMmapAllocator {
|
|||
internal_memset(this, 0, sizeof(*this));
|
||||
page_size_ = GetPageSizeCached();
|
||||
}
|
||||
|
||||
void *Allocate(uptr size, uptr alignment) {
|
||||
CHECK(IsPowerOfTwo(alignment));
|
||||
uptr map_size = RoundUpMapSize(size);
|
||||
|
|
@ -899,14 +900,10 @@ class CombinedAllocator {
|
|||
if (alignment > 8)
|
||||
size = RoundUpTo(size, alignment);
|
||||
void *res;
|
||||
if (primary_.CanAllocate(size, alignment)) {
|
||||
if (cache) // Allocate from cache.
|
||||
res = cache->Allocate(&primary_, primary_.ClassID(size));
|
||||
else // No thread-local cache, allocate directly from primary allocator.
|
||||
res = primary_.Allocate(size, alignment);
|
||||
} else { // Secondary allocator does not use cache.
|
||||
if (primary_.CanAllocate(size, alignment))
|
||||
res = cache->Allocate(&primary_, primary_.ClassID(size));
|
||||
else
|
||||
res = secondary_.Allocate(size, alignment);
|
||||
}
|
||||
if (alignment > 8)
|
||||
CHECK_EQ(reinterpret_cast<uptr>(res) & (alignment - 1), 0);
|
||||
if (cleared && res)
|
||||
|
|
|
|||
Loading…
Reference in New Issue