diff options
author | Dmitry Vyukov <dvyukov@google.com> | 2012-08-24 15:53:14 +0000 |
---|---|---|
committer | Dmitry Vyukov <dvyukov@google.com> | 2012-08-24 15:53:14 +0000 |
commit | 7d3d94454c423046d3ce00052b74ed0d722b2518 (patch) | |
tree | 876a3a9e5bce0fd08a1160a0acde8e4ce2e601b8 | |
parent | ab24b6e24e5a2bea7ee5bfd09930060e994841c7 (diff) | |
download | bcm5719-llvm-7d3d94454c423046d3ce00052b74ed0d722b2518.tar.gz bcm5719-llvm-7d3d94454c423046d3ce00052b74ed0d722b2518.zip |
tsan: improve memory allocator a bit
llvm-svn: 162561
-rw-r--r-- | compiler-rt/lib/sanitizer_common/sanitizer_allocator64.h | 14 |
1 files 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 68a52a3d53a..2e12afd4c44 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()); } |