From 7d3d94454c423046d3ce00052b74ed0d722b2518 Mon Sep 17 00:00:00 2001 From: Dmitry Vyukov Date: Fri, 24 Aug 2012 15:53:14 +0000 Subject: [PATCH] tsan: improve memory allocator a bit llvm-svn: 162561 --- .../lib/sanitizer_common/sanitizer_allocator64.h | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_allocator64.h b/compiler-rt/lib/sanitizer_common/sanitizer_allocator64.h index 68a52a3d53af..2e12afd4c44c 100644 --- a/compiler-rt/lib/sanitizer_common/sanitizer_allocator64.h +++ b/compiler-rt/lib/sanitizer_common/sanitizer_allocator64.h @@ -147,11 +147,15 @@ class SizeClassAllocator64 { PopulateFreeList(class_id, region); } CHECK(!region->free_list.empty()); - const uptr count = SizeClassMap::MaxCached(class_id); - for (uptr i = 0; i < count && !region->free_list.empty(); i++) { - AllocatorListNode *node = region->free_list.front(); - region->free_list.pop_front(); - free_list->push_front(node); + uptr count = SizeClassMap::MaxCached(class_id); + if (region->free_list.size() <= count) { + free_list->append_front(®ion->free_list); + } else { + for (uptr i = 0; i < count; i++) { + AllocatorListNode *node = region->free_list.front(); + region->free_list.pop_front(); + free_list->push_front(node); + } } CHECK(!free_list->empty()); }