[asan] introduce asan_allocator2.cc, which will have the replacement for asan allocator (now, just a bit of boilerplate)

llvm-svn: 169733
This commit is contained in:
Kostya Serebryany 2012-12-10 13:52:55 +00:00
parent 1746f555ee
commit 14282a91d5
4 changed files with 53 additions and 1 deletions

View File

@ -2,6 +2,7 @@
set(ASAN_SOURCES
asan_allocator.cc
asan_allocator2.cc
asan_globals.cc
asan_interceptors.cc
asan_linux.cc

View File

@ -24,8 +24,9 @@
// Once freed, the body of the chunk contains the stack trace of the free call.
//
//===----------------------------------------------------------------------===//
#include "asan_allocator.h"
#if ASAN_ALLOCATOR_VERSION == 1
#include "asan_interceptors.h"
#include "asan_internal.h"
#include "asan_lock.h"
@ -1049,3 +1050,4 @@ uptr __asan_get_allocated_size(const void *p) {
}
return allocated_size;
}
#endif // ASAN_ALLOCATOR_VERSION

View File

@ -18,6 +18,12 @@
#include "asan_internal.h"
#include "asan_interceptors.h"
// We are in the process of transitioning from the old allocator (version 1)
// to a new one (version 2). The change is quite intrusive so both allocators
// will co-exist in the source base for a while. The actual allocator is chosen
// at build time by redefining this macrozz.
#define ASAN_ALLOCATOR_VERSION 1
namespace __asan {
static const uptr kNumberOfSizeClasses = 255;

View File

@ -0,0 +1,43 @@
//===-- asan_allocator2.cc ------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This file is a part of AddressSanitizer, an address sanity checker.
//
// Implementation of ASan's memory allocator, 2-nd version.
// This variant uses the allocator from sanitizer_common, i.e. the one shared
// with ThreadSanitizer and MemorySanitizer.
//
// Status: under development, not enabled by default yet.
//===----------------------------------------------------------------------===//
#include "asan_allocator.h"
#if ASAN_ALLOCATOR_VERSION == 2
#include "sanitizer_common/sanitizer_allocator.h"
namespace __asan {
#if SANITIZER_WORDSIZE == 64
const uptr kAllocatorSpace = 0x600000000000ULL;
const uptr kAllocatorSize = 0x10000000000ULL; // 1T.
typedef SizeClassAllocator64<kAllocatorSpace, kAllocatorSize, 0 /*metadata*/,
DefaultSizeClassMap> PrimaryAllocator;
#elif SANITIZER_WORDSIZE == 32
static const u64 kAddressSpaceSize = 1ULL << 32;
typedef SizeClassAllocator32<
0, kAddressSpaceSize, 16, CompactSizeClassMap> PrimaryAllocator;
#endif
typedef SizeClassAllocatorLocalCache<PrimaryAllocator> AllocatorCache;
typedef LargeMmapAllocator SecondaryAllocator;
typedef CombinedAllocator<PrimaryAllocator, AllocatorCache,
SecondaryAllocator> Allocator;
} // namespace __asan
#endif // ASAN_ALLOCATOR_VERSION