Commit bc585ae9 authored by Vlad Tsyrklevich's avatar Vlad Tsyrklevich Committed by Commit Bot

GWP-ASan: Delete unnecessary function

The custom version of bits::CountTrailingZeroBits64 is deprecated by
upstream support from https://crrev.com/c/1321253

Change-Id: Id091afc2c5bd2d8ba8969ec12248b4c89d4d9ee1
Reviewed-on: https://chromium-review.googlesource.com/c/1355248
Commit-Queue: Vitaly Buka <vitalybuka@chromium.org>
Reviewed-by: default avatarVitaly Buka <vitalybuka@chromium.org>
Cr-Commit-Position: refs/heads/master@{#612502}
parent da4a2384
...@@ -136,7 +136,7 @@ size_t GuardedPageAllocator::ReserveSlot() { ...@@ -136,7 +136,7 @@ size_t GuardedPageAllocator::ReserveSlot() {
uint64_t rot = base::RandGenerator(AllocatorState::kGpaMaxPages); uint64_t rot = base::RandGenerator(AllocatorState::kGpaMaxPages);
BitMap rotated_bitmap = (free_pages_ << rot) | BitMap rotated_bitmap = (free_pages_ << rot) |
(free_pages_ >> (AllocatorState::kGpaMaxPages - rot)); (free_pages_ >> (AllocatorState::kGpaMaxPages - rot));
int rotated_selection = CountTrailingZeroBits64(rotated_bitmap); int rotated_selection = base::bits::CountTrailingZeroBits(rotated_bitmap);
size_t selection = (rotated_selection - rot + AllocatorState::kGpaMaxPages) % size_t selection = (rotated_selection - rot + AllocatorState::kGpaMaxPages) %
AllocatorState::kGpaMaxPages; AllocatorState::kGpaMaxPages;
DCHECK_LT(selection, AllocatorState::kGpaMaxPages); DCHECK_LT(selection, AllocatorState::kGpaMaxPages);
......
...@@ -18,11 +18,6 @@ ...@@ -18,11 +18,6 @@
namespace gwp_asan { namespace gwp_asan {
namespace internal { namespace internal {
// Method to count trailing zero bits in a uint64_t (identical to
// base::bits::CountTrailingZeroBits64 except that it also works on 32-bit
// platforms.)
unsigned CountTrailingZeroBits64(uint64_t x);
// This class encompasses the allocation and deallocation logic on top of the // This class encompasses the allocation and deallocation logic on top of the
// AllocatorState. Its members are not inspected or used by the crash handler. // AllocatorState. Its members are not inspected or used by the crash handler.
class GWP_ASAN_EXPORT GuardedPageAllocator { class GWP_ASAN_EXPORT GuardedPageAllocator {
......
...@@ -6,30 +6,12 @@ ...@@ -6,30 +6,12 @@
#include "components/gwp_asan/client/guarded_page_allocator.h" #include "components/gwp_asan/client/guarded_page_allocator.h"
#include "base/bits.h"
#include "base/logging.h" #include "base/logging.h"
#include "build/build_config.h" #include "build/build_config.h"
namespace gwp_asan { namespace gwp_asan {
namespace internal { namespace internal {
unsigned CountTrailingZeroBits64(uint64_t x) {
#if defined(ARCH_CPU_64_BITS)
return base::bits::CountTrailingZeroBits(x);
#else
// Windows 32-bit builds do not support CountTrailingZeroBits on a uint64_t.
// TODO(vtsyrklevich): Fix this in base::bits instead.
uint32_t right = static_cast<uint32_t>(x);
unsigned right_trailing = base::bits::CountTrailingZeroBits(right);
if (right_trailing < 32)
return right_trailing;
uint32_t left = static_cast<uint32_t>(x >> 32);
unsigned left_trailing = base::bits::CountTrailingZeroBits(left);
return left_trailing + right_trailing;
#endif
}
// TODO(vtsyrklevich): See if the platform-specific memory allocation and // TODO(vtsyrklevich): See if the platform-specific memory allocation and
// protection routines can be broken out in base/ and merged with those used for // protection routines can be broken out in base/ and merged with those used for
// PartionAlloc/ProtectedMemory. // PartionAlloc/ProtectedMemory.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment