summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKostya Serebryany <kcc@google.com>2012-12-10 13:52:55 +0000
committerKostya Serebryany <kcc@google.com>2012-12-10 13:52:55 +0000
commit14282a91d55cdd9eb6b138c28df615681e49ce2a (patch)
tree3a39d47264a6852588430adfab1f4eb1bfd12669
parent1746f555ee5eb19893c2aa64599d48b7273a6ded (diff)
downloadbcm5719-llvm-14282a91d55cdd9eb6b138c28df615681e49ce2a.tar.gz
bcm5719-llvm-14282a91d55cdd9eb6b138c28df615681e49ce2a.zip
[asan] introduce asan_allocator2.cc, which will have the replacement for asan allocator (now, just a bit of boilerplate)
llvm-svn: 169733
-rw-r--r--compiler-rt/lib/asan/CMakeLists.txt1
-rw-r--r--compiler-rt/lib/asan/asan_allocator.cc4
-rw-r--r--compiler-rt/lib/asan/asan_allocator.h6
-rw-r--r--compiler-rt/lib/asan/asan_allocator2.cc43
4 files changed, 53 insertions, 1 deletions
diff --git a/compiler-rt/lib/asan/CMakeLists.txt b/compiler-rt/lib/asan/CMakeLists.txt
index 884a718987d..57a6c9a9c37 100644
--- a/compiler-rt/lib/asan/CMakeLists.txt
+++ b/compiler-rt/lib/asan/CMakeLists.txt
@@ -2,6 +2,7 @@
set(ASAN_SOURCES
asan_allocator.cc
+ asan_allocator2.cc
asan_globals.cc
asan_interceptors.cc
asan_linux.cc
diff --git a/compiler-rt/lib/asan/asan_allocator.cc b/compiler-rt/lib/asan/asan_allocator.cc
index 6e9f26d46ce..66c2aa2106c 100644
--- a/compiler-rt/lib/asan/asan_allocator.cc
+++ b/compiler-rt/lib/asan/asan_allocator.cc
@@ -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
diff --git a/compiler-rt/lib/asan/asan_allocator.h b/compiler-rt/lib/asan/asan_allocator.h
index 1c6c30b2288..803aa239275 100644
--- a/compiler-rt/lib/asan/asan_allocator.h
+++ b/compiler-rt/lib/asan/asan_allocator.h
@@ -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;
diff --git a/compiler-rt/lib/asan/asan_allocator2.cc b/compiler-rt/lib/asan/asan_allocator2.cc
new file mode 100644
index 00000000000..bb3a15edcdc
--- /dev/null
+++ b/compiler-rt/lib/asan/asan_allocator2.cc
@@ -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
OpenPOWER on IntegriCloud