[AArch64] Add cost handling of CALLER_SAVE_REGS and POINTER_REGS
[official-gcc.git] / libsanitizer / sanitizer_common / sanitizer_allocator_internal.h
blob74e4402f7366c4a8e820da40c986483a0a3a2e08
1 //===-- sanitizer_allocator_internal.h -------------------------- C++ -----===//
2 //
3 // This file is distributed under the University of Illinois Open Source
4 // License. See LICENSE.TXT for details.
5 //
6 //===----------------------------------------------------------------------===//
7 //
8 // This allocator is used inside run-times.
9 //
10 //===----------------------------------------------------------------------===//
12 #ifndef SANITIZER_ALLOCATOR_INTERNAL_H
13 #define SANITIZER_ALLOCATOR_INTERNAL_H
15 #include "sanitizer_allocator.h"
16 #include "sanitizer_internal_defs.h"
18 namespace __sanitizer {
20 // FIXME: Check if we may use even more compact size class map for internal
21 // purposes.
22 typedef CompactSizeClassMap InternalSizeClassMap;
24 static const uptr kInternalAllocatorSpace = 0;
25 static const u64 kInternalAllocatorSize = SANITIZER_MMAP_RANGE_SIZE;
26 #if SANITIZER_WORDSIZE == 32
27 static const uptr kInternalAllocatorRegionSizeLog = 20;
28 static const uptr kInternalAllocatorNumRegions =
29 kInternalAllocatorSize >> kInternalAllocatorRegionSizeLog;
30 typedef FlatByteMap<kInternalAllocatorNumRegions> ByteMap;
31 #else
32 static const uptr kInternalAllocatorRegionSizeLog = 24;
33 static const uptr kInternalAllocatorNumRegions =
34 kInternalAllocatorSize >> kInternalAllocatorRegionSizeLog;
35 typedef TwoLevelByteMap<(kInternalAllocatorNumRegions >> 12), 1 << 12> ByteMap;
36 #endif
37 typedef SizeClassAllocator32<
38 kInternalAllocatorSpace, kInternalAllocatorSize, 16, InternalSizeClassMap,
39 kInternalAllocatorRegionSizeLog, ByteMap> PrimaryInternalAllocator;
41 typedef SizeClassAllocatorLocalCache<PrimaryInternalAllocator>
42 InternalAllocatorCache;
44 // We don't want our internal allocator to do any map/unmap operations from
45 // LargeMmapAllocator.
46 struct CrashOnMapUnmap {
47 void OnMap(uptr p, uptr size) const {
48 RAW_CHECK_MSG(0, "Unexpected mmap in InternalAllocator!\n");
50 void OnUnmap(uptr p, uptr size) const {
51 RAW_CHECK_MSG(0, "Unexpected munmap in InternalAllocator!\n");
55 typedef CombinedAllocator<PrimaryInternalAllocator, InternalAllocatorCache,
56 LargeMmapAllocator<CrashOnMapUnmap> >
57 InternalAllocator;
59 void *InternalAlloc(uptr size, InternalAllocatorCache *cache = 0);
60 void InternalFree(void *p, InternalAllocatorCache *cache = 0);
61 InternalAllocator *internal_allocator();
63 } // namespace __sanitizer
65 #endif // SANITIZER_ALLOCATOR_INTERNAL_H