[lsan] Use real memset to clear memory in standalone LSan.

Performance improvement. Also, the allocator was using CompactSizeClassMap for
no good reason, so I switched it to DefaultSizeClassMap.

llvm-svn: 195570
This commit is contained in:
Sergey Matveev 2013-11-24 14:28:18 +00:00
parent a787aa2b1e
commit 10548681c0
1 changed files with 7 additions and 2 deletions

View File

@ -20,6 +20,8 @@
#include "sanitizer_common/sanitizer_stacktrace.h"
#include "lsan_common.h"
extern "C" void *memset(void *ptr, int value, uptr num);
namespace __lsan {
static const uptr kMaxAllowedMallocSize = 8UL << 30;
@ -34,7 +36,7 @@ struct ChunkMetadata {
};
typedef SizeClassAllocator64<kAllocatorSpace, kAllocatorSize,
sizeof(ChunkMetadata), CompactSizeClassMap> PrimaryAllocator;
sizeof(ChunkMetadata), DefaultSizeClassMap> PrimaryAllocator;
typedef SizeClassAllocatorLocalCache<PrimaryAllocator> AllocatorCache;
typedef LargeMmapAllocator<> SecondaryAllocator;
typedef CombinedAllocator<PrimaryAllocator, AllocatorCache,
@ -80,7 +82,10 @@ void *Allocate(const StackTrace &stack, uptr size, uptr alignment,
Report("WARNING: LeakSanitizer failed to allocate %zu bytes\n", size);
return 0;
}
void *p = allocator.Allocate(&cache, size, alignment, cleared);
void *p = allocator.Allocate(&cache, size, alignment, false);
// Do not rely on the allocator to clear the memory (it's slow).
if (cleared && allocator.FromPrimary(p))
memset(p, 0, size);
RegisterAllocation(stack, p, size);
return p;
}