diff options
author | Kostya Serebryany <kcc@google.com> | 2016-08-23 21:19:47 +0000 |
---|---|---|
committer | Kostya Serebryany <kcc@google.com> | 2016-08-23 21:19:47 +0000 |
commit | f46d50e360ac909ac55adee05b87f7166abb3fdc (patch) | |
tree | 72b6210471845968401c4f634bfbd5cb96c49741 /compiler-rt/lib/sanitizer_common/tests/sanitizer_allocator_test.cc | |
parent | 3f6865a8b07b3f3077f7e6a4f1654aabd126b355 (diff) | |
download | bcm5719-llvm-f46d50e360ac909ac55adee05b87f7166abb3fdc.tar.gz bcm5719-llvm-f46d50e360ac909ac55adee05b87f7166abb3fdc.zip |
[sanitizer] change the 64-bit allocator to use a single array for free-d chunks instead of a lock-free linked list of tranfer batches. This change simplifies the code, makes the allocator more 'hardened', and will allow simpler code to release RAM to OS. This may also slowdown malloc stress tests due to lock contension, but I did not observe noticeable slowdown on various real multi-threaded benchmarks.
llvm-svn: 279572
Diffstat (limited to 'compiler-rt/lib/sanitizer_common/tests/sanitizer_allocator_test.cc')
-rw-r--r-- | compiler-rt/lib/sanitizer_common/tests/sanitizer_allocator_test.cc | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/compiler-rt/lib/sanitizer_common/tests/sanitizer_allocator_test.cc b/compiler-rt/lib/sanitizer_common/tests/sanitizer_allocator_test.cc index a558f0836bf..08bca919c6f 100644 --- a/compiler-rt/lib/sanitizer_common/tests/sanitizer_allocator_test.cc +++ b/compiler-rt/lib/sanitizer_common/tests/sanitizer_allocator_test.cc @@ -99,8 +99,10 @@ void TestSizeClassAllocator() { memset(&cache, 0, sizeof(cache)); cache.Init(0); - static const uptr sizes[] = {1, 16, 30, 40, 100, 1000, 10000, - 50000, 60000, 100000, 120000, 300000, 500000, 1000000, 2000000}; + static const uptr sizes[] = { + 1, 16, 30, 40, 100, 1000, 10000, + 50000, 60000, 100000, 120000, 300000, 500000, 1000000, 2000000 + }; std::vector<void *> allocated; @@ -300,8 +302,11 @@ TEST(SanitizerCommon, SizeClassAllocator64MapUnmapCallback) { cache.Init(0); AllocatorStats stats; stats.Init(); - a->AllocateBatch(&stats, &cache, 32); - EXPECT_EQ(TestMapUnmapCallback::map_count, 3); // State + alloc + metadata. + const size_t kNumChunks = 128; + uint32_t chunks[kNumChunks]; + a->GetFromAllocator(&stats, 32, chunks, kNumChunks); + // State + alloc + metadata + freearray. + EXPECT_EQ(TestMapUnmapCallback::map_count, 4); a->TestOnlyUnmap(); EXPECT_EQ(TestMapUnmapCallback::unmap_count, 1); // The whole thing. delete a; @@ -360,8 +365,10 @@ void FailInAssertionOnOOM() { cache.Init(0); AllocatorStats stats; stats.Init(); + const size_t kNumChunks = 128; + uint32_t chunks[kNumChunks]; for (int i = 0; i < 1000000; i++) { - a.AllocateBatch(&stats, &cache, 52); + a.GetFromAllocator(&stats, 52, chunks, kNumChunks); } a.TestOnlyUnmap(); |