Mercurial > hg > CbC > CbC_gcc
comparison libsanitizer/lsan/lsan_allocator.h @ 145:1830386684a0
gcc-9.2.0
author | anatofuz |
---|---|
date | Thu, 13 Feb 2020 11:34:05 +0900 |
parents | 04ced10e8804 |
children |
comparison
equal
deleted
inserted
replaced
131:84e7813d76e9 | 145:1830386684a0 |
---|---|
1 //=-- lsan_allocator.h ----------------------------------------------------===// | 1 //=-- lsan_allocator.h ----------------------------------------------------===// |
2 // | 2 // |
3 // This file is distributed under the University of Illinois Open Source | 3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
4 // License. See LICENSE.TXT for details. | 4 // See https://llvm.org/LICENSE.txt for license information. |
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
5 // | 6 // |
6 //===----------------------------------------------------------------------===// | 7 //===----------------------------------------------------------------------===// |
7 // | 8 // |
8 // This file is a part of LeakSanitizer. | 9 // This file is a part of LeakSanitizer. |
9 // Allocator for standalone LSan. | 10 // Allocator for standalone LSan. |
48 u32 stack_trace_id; | 49 u32 stack_trace_id; |
49 }; | 50 }; |
50 | 51 |
51 #if defined(__mips64) || defined(__aarch64__) || defined(__i386__) || \ | 52 #if defined(__mips64) || defined(__aarch64__) || defined(__i386__) || \ |
52 defined(__arm__) | 53 defined(__arm__) |
53 static const uptr kRegionSizeLog = 20; | 54 template <typename AddressSpaceViewTy> |
54 static const uptr kNumRegions = SANITIZER_MMAP_RANGE_SIZE >> kRegionSizeLog; | |
55 typedef TwoLevelByteMap<(kNumRegions >> 12), 1 << 12> ByteMap; | |
56 | |
57 struct AP32 { | 55 struct AP32 { |
58 static const uptr kSpaceBeg = 0; | 56 static const uptr kSpaceBeg = 0; |
59 static const u64 kSpaceSize = SANITIZER_MMAP_RANGE_SIZE; | 57 static const u64 kSpaceSize = SANITIZER_MMAP_RANGE_SIZE; |
60 static const uptr kMetadataSize = sizeof(ChunkMetadata); | 58 static const uptr kMetadataSize = sizeof(ChunkMetadata); |
61 typedef __sanitizer::CompactSizeClassMap SizeClassMap; | 59 typedef __sanitizer::CompactSizeClassMap SizeClassMap; |
62 static const uptr kRegionSizeLog = __lsan::kRegionSizeLog; | 60 static const uptr kRegionSizeLog = 20; |
63 typedef __lsan::ByteMap ByteMap; | 61 using AddressSpaceView = AddressSpaceViewTy; |
64 typedef NoOpMapUnmapCallback MapUnmapCallback; | 62 typedef NoOpMapUnmapCallback MapUnmapCallback; |
65 static const uptr kFlags = 0; | 63 static const uptr kFlags = 0; |
66 }; | 64 }; |
67 typedef SizeClassAllocator32<AP32> PrimaryAllocator; | 65 template <typename AddressSpaceView> |
66 using PrimaryAllocatorASVT = SizeClassAllocator32<AP32<AddressSpaceView>>; | |
67 using PrimaryAllocator = PrimaryAllocatorASVT<LocalAddressSpaceView>; | |
68 #elif defined(__x86_64__) || defined(__powerpc64__) | 68 #elif defined(__x86_64__) || defined(__powerpc64__) |
69 # if defined(__powerpc64__) | |
70 const uptr kAllocatorSpace = 0xa0000000000ULL; | |
71 const uptr kAllocatorSize = 0x20000000000ULL; // 2T. | |
72 # else | |
73 const uptr kAllocatorSpace = 0x600000000000ULL; | |
74 const uptr kAllocatorSize = 0x40000000000ULL; // 4T. | |
75 # endif | |
76 template <typename AddressSpaceViewTy> | |
69 struct AP64 { // Allocator64 parameters. Deliberately using a short name. | 77 struct AP64 { // Allocator64 parameters. Deliberately using a short name. |
70 static const uptr kSpaceBeg = 0x600000000000ULL; | 78 static const uptr kSpaceBeg = kAllocatorSpace; |
71 static const uptr kSpaceSize = 0x40000000000ULL; // 4T. | 79 static const uptr kSpaceSize = kAllocatorSize; |
72 static const uptr kMetadataSize = sizeof(ChunkMetadata); | 80 static const uptr kMetadataSize = sizeof(ChunkMetadata); |
73 typedef DefaultSizeClassMap SizeClassMap; | 81 typedef DefaultSizeClassMap SizeClassMap; |
74 typedef NoOpMapUnmapCallback MapUnmapCallback; | 82 typedef NoOpMapUnmapCallback MapUnmapCallback; |
75 static const uptr kFlags = 0; | 83 static const uptr kFlags = 0; |
84 using AddressSpaceView = AddressSpaceViewTy; | |
76 }; | 85 }; |
77 | 86 |
78 typedef SizeClassAllocator64<AP64> PrimaryAllocator; | 87 template <typename AddressSpaceView> |
88 using PrimaryAllocatorASVT = SizeClassAllocator64<AP64<AddressSpaceView>>; | |
89 using PrimaryAllocator = PrimaryAllocatorASVT<LocalAddressSpaceView>; | |
79 #endif | 90 #endif |
80 typedef SizeClassAllocatorLocalCache<PrimaryAllocator> AllocatorCache; | |
81 | 91 |
82 AllocatorCache *GetAllocatorCache(); | 92 template <typename AddressSpaceView> |
93 using AllocatorASVT = CombinedAllocator<PrimaryAllocatorASVT<AddressSpaceView>>; | |
94 using Allocator = AllocatorASVT<LocalAddressSpaceView>; | |
95 using AllocatorCache = Allocator::AllocatorCache; | |
83 | 96 |
97 Allocator::AllocatorCache *GetAllocatorCache(); | |
98 | |
99 int lsan_posix_memalign(void **memptr, uptr alignment, uptr size, | |
100 const StackTrace &stack); | |
101 void *lsan_aligned_alloc(uptr alignment, uptr size, const StackTrace &stack); | |
84 void *lsan_memalign(uptr alignment, uptr size, const StackTrace &stack); | 102 void *lsan_memalign(uptr alignment, uptr size, const StackTrace &stack); |
85 void *lsan_malloc(uptr size, const StackTrace &stack); | 103 void *lsan_malloc(uptr size, const StackTrace &stack); |
86 void lsan_free(void *p); | 104 void lsan_free(void *p); |
87 void *lsan_realloc(void *p, uptr size, const StackTrace &stack); | 105 void *lsan_realloc(void *p, uptr size, const StackTrace &stack); |
106 void *lsan_reallocarray(void *p, uptr nmemb, uptr size, | |
107 const StackTrace &stack); | |
88 void *lsan_calloc(uptr nmemb, uptr size, const StackTrace &stack); | 108 void *lsan_calloc(uptr nmemb, uptr size, const StackTrace &stack); |
89 void *lsan_valloc(uptr size, const StackTrace &stack); | 109 void *lsan_valloc(uptr size, const StackTrace &stack); |
110 void *lsan_pvalloc(uptr size, const StackTrace &stack); | |
90 uptr lsan_mz_size(const void *p); | 111 uptr lsan_mz_size(const void *p); |
91 | 112 |
92 } // namespace __lsan | 113 } // namespace __lsan |
93 | 114 |
94 #endif // LSAN_ALLOCATOR_H | 115 #endif // LSAN_ALLOCATOR_H |