[llvm-commits] [compiler-rt] r169733 - in /compiler-rt/trunk/lib/asan: CMakeLists.txt asan_allocator.cc asan_allocator.h asan_allocator2.cc
Kostya Serebryany
kcc at google.com
Mon Dec 10 05:52:56 PST 2012
Author: kcc
Date: Mon Dec 10 07:52:55 2012
New Revision: 169733
URL: http://llvm.org/viewvc/llvm-project?rev=169733&view=rev
Log:
[asan] introduce asan_allocator2.cc, which will have the replacement for asan allocator (now, just a bit of boilerplate)
Added:
compiler-rt/trunk/lib/asan/asan_allocator2.cc
Modified:
compiler-rt/trunk/lib/asan/CMakeLists.txt
compiler-rt/trunk/lib/asan/asan_allocator.cc
compiler-rt/trunk/lib/asan/asan_allocator.h
Modified: compiler-rt/trunk/lib/asan/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/CMakeLists.txt?rev=169733&r1=169732&r2=169733&view=diff
==============================================================================
--- compiler-rt/trunk/lib/asan/CMakeLists.txt (original)
+++ compiler-rt/trunk/lib/asan/CMakeLists.txt Mon Dec 10 07:52:55 2012
@@ -2,6 +2,7 @@
set(ASAN_SOURCES
asan_allocator.cc
+ asan_allocator2.cc
asan_globals.cc
asan_interceptors.cc
asan_linux.cc
Modified: compiler-rt/trunk/lib/asan/asan_allocator.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/asan_allocator.cc?rev=169733&r1=169732&r2=169733&view=diff
==============================================================================
--- compiler-rt/trunk/lib/asan/asan_allocator.cc (original)
+++ compiler-rt/trunk/lib/asan/asan_allocator.cc Mon Dec 10 07:52:55 2012
@@ -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 @@
}
return allocated_size;
}
+#endif // ASAN_ALLOCATOR_VERSION
Modified: compiler-rt/trunk/lib/asan/asan_allocator.h
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/asan_allocator.h?rev=169733&r1=169732&r2=169733&view=diff
==============================================================================
--- compiler-rt/trunk/lib/asan/asan_allocator.h (original)
+++ compiler-rt/trunk/lib/asan/asan_allocator.h Mon Dec 10 07:52:55 2012
@@ -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;
Added: compiler-rt/trunk/lib/asan/asan_allocator2.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/asan_allocator2.cc?rev=169733&view=auto
==============================================================================
--- compiler-rt/trunk/lib/asan/asan_allocator2.cc (added)
+++ compiler-rt/trunk/lib/asan/asan_allocator2.cc Mon Dec 10 07:52:55 2012
@@ -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
More information about the llvm-commits
mailing list