summaryrefslogtreecommitdiff
path: root/lib/sanitizer_common
diff options
context:
space:
mode:
authorVitaly Buka <vitalybuka@google.com>2019-04-26 18:22:47 +0000
committerVitaly Buka <vitalybuka@google.com>2019-04-26 18:22:47 +0000
commitacdfae73d048c113129784aa6eb32f9cb410dc4c (patch)
treeabbed7e28b96ca92fe2d5539835ac9c71753d582 /lib/sanitizer_common
parent9a964f67336766773653c1abf503223ed3ca29ff (diff)
downloadcompiler-rt-acdfae73d048c113129784aa6eb32f9cb410dc4c.tar.gz
[sanitizer] NFC: add static_assert to confirm that we use optimal ByteMap type
Summary: If bots work we can replace #ifs with template specialization by TwoLevelByteMapSize1. Reviewers: eugenis Subscribers: kubamracek, #sanitizers, llvm-commits Tags: #sanitizers, #llvm Differential Revision: https://reviews.llvm.org/D61200 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@359333 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/sanitizer_common')
-rw-r--r--lib/sanitizer_common/sanitizer_allocator_primary32.h10
1 files changed, 7 insertions, 3 deletions
diff --git a/lib/sanitizer_common/sanitizer_allocator_primary32.h b/lib/sanitizer_common/sanitizer_allocator_primary32.h
index d773815f9..04f032605 100644
--- a/lib/sanitizer_common/sanitizer_allocator_primary32.h
+++ b/lib/sanitizer_common/sanitizer_allocator_primary32.h
@@ -47,6 +47,10 @@ struct SizeClassAllocator32FlagMasks { // Bit masks.
template <class Params>
class SizeClassAllocator32 {
+ private:
+ static const u64 TwoLevelByteMapSize1 =
+ (Params::kSpaceSize >> Params::kRegionSizeLog) >> 12;
+
public:
using AddressSpaceView = typename Params::AddressSpaceView;
static const uptr kSpaceBeg = Params::kSpaceBeg;
@@ -58,12 +62,12 @@ class SizeClassAllocator32 {
typedef typename Params::MapUnmapCallback MapUnmapCallback;
#if SANITIZER_WORDSIZE == 32
+ static_assert(TwoLevelByteMapSize1 <= 128, "FlatByteMap should be used");
using BM = FlatByteMap<(Params::kSpaceSize >> Params::kRegionSizeLog),
AddressSpaceView>;
#elif SANITIZER_WORDSIZE == 64
- using BM =
- TwoLevelByteMap<((Params::kSpaceSize >> Params::kRegionSizeLog) >> 12),
- 1 << 12, AddressSpaceView>;
+ static_assert(TwoLevelByteMapSize1 > 128, "TwoLevelByteMap should be used");
+ using BM = TwoLevelByteMap<TwoLevelByteMapSize1, 1 << 12, AddressSpaceView>;
#endif
static_assert((Params::kFlags & SizeClassAllocator32FlagMasks::kForTest) ||
is_same<BM, ByteMap>::value,