diff options
author | Kostya Kortchinsky <kostyak@google.com> | 2017-06-30 16:05:40 +0000 |
---|---|---|
committer | Kostya Kortchinsky <kostyak@google.com> | 2017-06-30 16:05:40 +0000 |
commit | 63de5fcd7287d033a1667de42831c293137e00e4 (patch) | |
tree | 9ed37f9dc6c6ac3b02a5e60f2f602266c363b6e3 /lib/sanitizer_common/sanitizer_allocator_primary64.h | |
parent | cf40d9536af9ddc8da4f8d0a919cacc1a57888a5 (diff) |
[sanitizer] Small tweaks and fixes to allocator related functions
Summary:
In `sanitizer_allocator_primary32.h`:
- rounding up in `MapWithCallback` is not needed as `MmapOrDie` does it. Note
that the 64-bit counterpart doesn't round up, this keeps the behavior
consistent;
- since `IsAligned` exists, use it in `AllocateRegion`;
- in `PopulateFreeList`:
- checking `b->Count` to be greater than 0 when `b->Count() == max_count` is
redundant when done more than once. Just check that `max_count` is greater
than 0 out of the loop; the compiler (at least on ARM) didn't optimize it;
- mark the batch creation failure as `UNLIKELY`;
In `sanitizer_allocator_primary64.h`:
- in `MapWithCallback`, mark the failure condition as `UNLIKELY`;
In `sanitizer_posix.h`:
- mark a bunch of Mmap related failure conditions as `UNLIKELY`;
- in `MmapAlignedOrDieOnFatalError`, we have `IsAligned`, so use it; rearrange
the conditions as one test was redudant;
- in `MmapFixedImpl`, 30 chars was not large enough to hold the message and a
full 64-bit address (or at least a 48-bit usermode address), increase to 40.
Reviewers: alekseyshl
Reviewed By: alekseyshl
Subscribers: aemerson, kubamracek, kristof.beyls, llvm-commits
Differential Revision: https://reviews.llvm.org/D34840
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@306834 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/sanitizer_common/sanitizer_allocator_primary64.h')
-rw-r--r-- | lib/sanitizer_common/sanitizer_allocator_primary64.h | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/lib/sanitizer_common/sanitizer_allocator_primary64.h b/lib/sanitizer_common/sanitizer_allocator_primary64.h index efa2258dd..0c2e72ce7 100644 --- a/lib/sanitizer_common/sanitizer_allocator_primary64.h +++ b/lib/sanitizer_common/sanitizer_allocator_primary64.h @@ -389,7 +389,7 @@ class SizeClassAllocator64 { bool MapWithCallback(uptr beg, uptr size) { uptr mapped = reinterpret_cast<uptr>(MmapFixedOrDieOnFatalError(beg, size)); - if (!mapped) + if (UNLIKELY(!mapped)) return false; CHECK_EQ(beg, mapped); MapUnmapCallback().OnMap(beg, size); |