diff options
| author | Kostya Kortchinsky <kostyak@google.com> | 2018-02-01 20:00:42 +0000 |
|---|---|---|
| committer | Kostya Kortchinsky <kostyak@google.com> | 2018-02-01 20:00:42 +0000 |
| commit | 8c4ca0bbea1c2ea3631a6a314e853c13f6bfbe10 (patch) | |
| tree | 72b80ecdf4cccc4719a64c46a0610c48421f20e7 | |
| parent | d7bed1219278f3952b13013feab0a242b4267592 (diff) | |
| download | bcm5719-llvm-8c4ca0bbea1c2ea3631a6a314e853c13f6bfbe10.tar.gz bcm5719-llvm-8c4ca0bbea1c2ea3631a6a314e853c13f6bfbe10.zip | |
[scudo] Minor Secondary changes
Summary:
Few changes to the secondary:
- mark `const` variables as such;
- change some `CHECK` to `DCHECK`: I don't feel we need to be as conservative as
we were with out checks, as they are the results of our own computation.
- mark a condition as `UNLIKELY`.
Reviewers: alekseyshl
Reviewed By: alekseyshl
Subscribers: delcypher, #sanitizers, llvm-commits
Differential Revision: https://reviews.llvm.org/D42696
llvm-svn: 323997
| -rw-r--r-- | compiler-rt/lib/scudo/scudo_allocator_secondary.h | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/compiler-rt/lib/scudo/scudo_allocator_secondary.h b/compiler-rt/lib/scudo/scudo_allocator_secondary.h index f2002ed986c..2415b3f1de2 100644 --- a/compiler-rt/lib/scudo/scudo_allocator_secondary.h +++ b/compiler-rt/lib/scudo/scudo_allocator_secondary.h @@ -41,7 +41,7 @@ class ScudoLargeMmapAllocator { ReservedAddressRange AddressRange; uptr MapBeg = AddressRange.Init(MapSize); - if (MapBeg == ~static_cast<uptr>(0)) + if (UNLIKELY(MapBeg == ~static_cast<uptr>(0))) return ReturnNullOrDieOnFailure::OnOOM(); // A page-aligned pointer is assumed after that, so check it now. CHECK(IsAligned(MapBeg, PageSize)); @@ -58,17 +58,17 @@ class ScudoLargeMmapAllocator { if (Alignment > MinAlignment) { if (!IsAligned(UserBeg, Alignment)) { UserBeg = RoundUpTo(UserBeg, Alignment); - CHECK_GE(UserBeg, MapBeg); - uptr NewMapBeg = RoundDownTo(UserBeg - HeadersSize, PageSize) - + DCHECK_GE(UserBeg, MapBeg); + const uptr NewMapBeg = RoundDownTo(UserBeg - HeadersSize, PageSize) - PageSize; - CHECK_GE(NewMapBeg, MapBeg); + DCHECK_GE(NewMapBeg, MapBeg); if (NewMapBeg != MapBeg) { AddressRange.Unmap(MapBeg, NewMapBeg - MapBeg); MapBeg = NewMapBeg; } UserEnd = UserBeg + UserSize; } - uptr NewMapEnd = RoundUpTo(UserEnd, PageSize) + PageSize; + const uptr NewMapEnd = RoundUpTo(UserEnd, PageSize) + PageSize; if (NewMapEnd != MapEnd) { AddressRange.Unmap(NewMapEnd, MapEnd - NewMapEnd); MapEnd = NewMapEnd; @@ -76,7 +76,7 @@ class ScudoLargeMmapAllocator { MapSize = MapEnd - MapBeg; } - CHECK_LE(UserEnd, MapEnd - PageSize); + DCHECK_LE(UserEnd, MapEnd - PageSize); // Actually mmap the memory, preserving the guard pages on either side CHECK_EQ(MapBeg + PageSize, AddressRange.Map(MapBeg + PageSize, MapSize - 2 * PageSize)); @@ -111,10 +111,10 @@ class ScudoLargeMmapAllocator { } uptr GetActuallyAllocatedSize(void *Ptr) { - ReservedAddressRange *StoredRange = getReservedAddressRange(Ptr); + const ReservedAddressRange *StoredRange = getReservedAddressRange(Ptr); // Deduct PageSize as ReservedAddressRange size includes the trailing guard // page. - uptr MapEnd = reinterpret_cast<uptr>(StoredRange->base()) + + const uptr MapEnd = reinterpret_cast<uptr>(StoredRange->base()) + StoredRange->size() - PageSizeCached; return MapEnd - reinterpret_cast<uptr>(Ptr); } |

