Commit f83b184b authored by Bartek Nowierski's avatar Bartek Nowierski Committed by Commit Bot

Implement IsManagedByPartitionAllocAndNotDirectMapped

Bug: 1086388
Change-Id: Ib506d39f21dcfabab4e207ee72cd57da23435799
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2239734
Commit-Queue: Bartek Nowierski <bartekn@chromium.org>
Auto-Submit: Bartek Nowierski <bartekn@chromium.org>
Reviewed-by: default avatarTakashi Sakamoto <tasak@google.com>
Reviewed-by: default avatarKentaro Hara <haraken@chromium.org>
Cr-Commit-Position: refs/heads/master@{#777276}
parent 622075a4
......@@ -38,8 +38,11 @@ uintptr_t PartitionAddressSpace::reserved_address_start_ = 0;
// reserved address space. So initially make reserved_base_address_ to
// be kReservedAddressSpaceOffsetMask. So PartitionAddressSpace::Contains()
// always returns false.
// Do something similar for normal_bucket_pool_base_address_.
uintptr_t PartitionAddressSpace::reserved_base_address_ =
kReservedAddressSpaceOffsetMask;
uintptr_t PartitionAddressSpace::normal_bucket_pool_base_address_ =
kNormalBucketPoolOffsetMask;
pool_handle PartitionAddressSpace::direct_map_pool_ = 0;
pool_handle PartitionAddressSpace::normal_bucket_pool_ = 0;
......@@ -66,6 +69,7 @@ void PartitionAddressSpace::Init() {
DCHECK(direct_map_pool_);
current += kDirectMapPoolSize;
normal_bucket_pool_base_address_ = current;
normal_bucket_pool_ = internal::AddressPoolManager::GetInstance()->Add(
current, kNormalBucketPoolSize);
DCHECK(normal_bucket_pool_);
......
......@@ -39,6 +39,11 @@ class BASE_EXPORT PartitionAddressSpace {
kReservedAddressSpaceBaseMask) == reserved_base_address_;
}
static ALWAYS_INLINE bool IsInNormalBucketPool(const void* address) {
return (reinterpret_cast<uintptr_t>(address) & kNormalBucketPoolBaseMask) ==
normal_bucket_pool_base_address_;
}
// PartitionAddressSpace is static_only class.
PartitionAddressSpace() = delete;
PartitionAddressSpace(const PartitionAddressSpace&) = delete;
......@@ -73,6 +78,11 @@ class BASE_EXPORT PartitionAddressSpace {
static constexpr size_t kGigaBytes = 1024 * 1024 * 1024;
static constexpr size_t kDirectMapPoolSize = 16 * kGigaBytes;
static constexpr size_t kNormalBucketPoolSize = 16 * kGigaBytes;
static constexpr uintptr_t kNormalBucketPoolOffsetMask =
static_cast<uintptr_t>(kNormalBucketPoolSize) - 1;
static constexpr uintptr_t kNormalBucketPoolBaseMask =
~kNormalBucketPoolOffsetMask;
// Reserves 32GB aligned address space.
// Alignment should be the smallest power of two greater than or equal to the
// desired size, so that we can check containment with a single bitmask
......@@ -93,6 +103,8 @@ class BASE_EXPORT PartitionAddressSpace {
static uintptr_t reserved_address_start_;
static uintptr_t reserved_base_address_;
static uintptr_t normal_bucket_pool_base_address_;
static internal::pool_handle direct_map_pool_;
static internal::pool_handle normal_bucket_pool_;
};
......
......@@ -442,6 +442,15 @@ ALWAYS_INLINE bool IsManagedByPartitionAlloc(const void* address) {
#endif
}
ALWAYS_INLINE bool IsManagedByPartitionAllocAndNotDirectMapped(
const void* address) {
#if defined(ARCH_CPU_64_BITS)
return internal::PartitionAddressSpace::IsInNormalBucketPool(address);
#else
return false;
#endif
}
} // namespace base
#endif // BASE_ALLOCATOR_PARTITION_ALLOCATOR_PARTITION_ALLOC_H_
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