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 using AddressSpaceView = LocalAddressSpaceView;
41 using ByteMap = __sanitizer::ByteMap;
42 typedef NoOpMapUnmapCallback MapUnmapCallback;
43 static const uptr kFlags = 0;
45 typedef SizeClassAllocator32<AP32> PrimaryInternalAllocator;
47 typedef SizeClassAllocatorLocalCache<PrimaryInternalAllocator>
48 InternalAllocatorCache;
50 typedef LargeMmapAllocator<NoOpMapUnmapCallback,
51 LargeMmapAllocatorPtrArrayStatic>
52 SecondaryInternalAllocator;
54 typedef CombinedAllocator<PrimaryInternalAllocator, InternalAllocatorCache,
55 SecondaryInternalAllocator> InternalAllocator;
57 void *InternalAlloc(uptr size, InternalAllocatorCache *cache = nullptr,
59 void *InternalRealloc(void *p, uptr size,
60 InternalAllocatorCache *cache = nullptr);
61 void *InternalCalloc(uptr countr, uptr size,
62 InternalAllocatorCache *cache = nullptr);
63 void InternalFree(void *p, InternalAllocatorCache *cache = nullptr);
64 InternalAllocator *internal_allocator();
66 } // namespace __sanitizer
68 #endif // SANITIZER_ALLOCATOR_INTERNAL_H