1 //===-- sanitizer_allocator_internal.h --------------------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This allocator is used inside run-times.
12 //===----------------------------------------------------------------------===//
14 #ifndef SANITIZER_ALLOCATOR_INTERNAL_H
15 #define SANITIZER_ALLOCATOR_INTERNAL_H
17 #include "sanitizer_allocator.h"
18 #include "sanitizer_internal_defs.h"
20 namespace __sanitizer {
22 // FIXME: Check if we may use even more compact size class map for internal
24 typedef CompactSizeClassMap InternalSizeClassMap;
26 static const uptr kInternalAllocatorRegionSizeLog = 20;
27 static const uptr kInternalAllocatorNumRegions =
28 SANITIZER_MMAP_RANGE_SIZE >> kInternalAllocatorRegionSizeLog;
29 #if SANITIZER_WORDSIZE == 32
30 typedef FlatByteMap<kInternalAllocatorNumRegions> ByteMap;
32 typedef TwoLevelByteMap<(kInternalAllocatorNumRegions >> 12), 1 << 12> ByteMap;
35 static const uptr kSpaceBeg = 0;
36 static const u64 kSpaceSize = SANITIZER_MMAP_RANGE_SIZE;
37 static const uptr kMetadataSize = 0;
38 typedef InternalSizeClassMap SizeClassMap;
39 static const uptr kRegionSizeLog = kInternalAllocatorRegionSizeLog;
40 typedef __sanitizer::ByteMap ByteMap;
41 typedef NoOpMapUnmapCallback MapUnmapCallback;
42 static const uptr kFlags = 0;
44 typedef SizeClassAllocator32<AP32> PrimaryInternalAllocator;
46 typedef SizeClassAllocatorLocalCache<PrimaryInternalAllocator>
47 InternalAllocatorCache;
49 typedef LargeMmapAllocator<NoOpMapUnmapCallback,
50 LargeMmapAllocatorPtrArrayStatic>
51 SecondaryInternalAllocator;
53 typedef CombinedAllocator<PrimaryInternalAllocator, InternalAllocatorCache,
54 SecondaryInternalAllocator> InternalAllocator;
56 void *InternalAlloc(uptr size, InternalAllocatorCache *cache = nullptr,
58 void *InternalRealloc(void *p, uptr size,
59 InternalAllocatorCache *cache = nullptr);
60 void *InternalCalloc(uptr countr, uptr size,
61 InternalAllocatorCache *cache = nullptr);
62 void InternalFree(void *p, InternalAllocatorCache *cache = nullptr);
63 InternalAllocator *internal_allocator();
65 } // namespace __sanitizer
67 #endif // SANITIZER_ALLOCATOR_INTERNAL_H