Commit 465ca09f authored by Clemens Backes's avatar Clemens Backes Committed by V8 LUCI CQ

[base] Downgrade CHECKs to DCHECKs in BoundedPageAllocator

BoundedPageAllocator was added in https://crrev.com/c/1226915 with lots
of CHECKs. There was no special reason given for that, and it's
inconsistent with the default choice for DCHECKs that we have in other
parts of the code.
Hence this CL degrades most of these CHECKs to DCHECKs, except for the
{SetPermissions} calls which we need to execute in all configurations,
and where checking the return value makes sense to detect memory bugs or
OOM situations.

R=ishell@chromium.org
CC=bikineev@chromium.org

Bug: v8:11879
Change-Id: I23e3a961f2f5a6893bceaa4fb75be61fe895d5f8
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3059691Reviewed-by: 's avatarIgor Sheludko <ishell@chromium.org>
Commit-Queue: Clemens Backes <clemensb@chromium.org>
Cr-Commit-Position: refs/heads/master@{#76159}
parent 26285e2f
......@@ -14,9 +14,9 @@ BoundedPageAllocator::BoundedPageAllocator(v8::PageAllocator* page_allocator,
commit_page_size_(page_allocator->CommitPageSize()),
page_allocator_(page_allocator),
region_allocator_(start, size, allocate_page_size_) {
CHECK_NOT_NULL(page_allocator);
CHECK(IsAligned(allocate_page_size, page_allocator->AllocatePageSize()));
CHECK(IsAligned(allocate_page_size_, commit_page_size_));
DCHECK_NOT_NULL(page_allocator);
DCHECK(IsAligned(allocate_page_size, page_allocator->AllocatePageSize()));
DCHECK(IsAligned(allocate_page_size_, commit_page_size_));
}
BoundedPageAllocator::Address BoundedPageAllocator::begin() const {
......@@ -29,11 +29,11 @@ void* BoundedPageAllocator::AllocatePages(void* hint, size_t size,
size_t alignment,
PageAllocator::Permission access) {
MutexGuard guard(&mutex_);
CHECK(IsAligned(alignment, region_allocator_.page_size()));
DCHECK(IsAligned(alignment, region_allocator_.page_size()));
// Region allocator does not support alignments bigger than it's own
// allocation alignment.
CHECK_LE(alignment, allocate_page_size_);
DCHECK_LE(alignment, allocate_page_size_);
// TODO(ishell): Consider using randomized version here.
Address address = region_allocator_.AllocateRegion(size);
......@@ -47,12 +47,12 @@ void* BoundedPageAllocator::AllocatePages(void* hint, size_t size,
bool BoundedPageAllocator::AllocatePagesAt(Address address, size_t size,
PageAllocator::Permission access) {
CHECK(IsAligned(address, allocate_page_size_));
CHECK(IsAligned(size, allocate_page_size_));
DCHECK(IsAligned(address, allocate_page_size_));
DCHECK(IsAligned(size, allocate_page_size_));
{
MutexGuard guard(&mutex_);
CHECK(region_allocator_.contains(address, size));
DCHECK(region_allocator_.contains(address, size));
if (!region_allocator_.AllocateRegionAt(address, size)) {
return false;
......@@ -67,12 +67,12 @@ bool BoundedPageAllocator::AllocatePagesAt(Address address, size_t size,
bool BoundedPageAllocator::ReserveForSharedMemoryMapping(void* ptr,
size_t size) {
Address address = reinterpret_cast<Address>(ptr);
CHECK(IsAligned(address, allocate_page_size_));
CHECK(IsAligned(size, commit_page_size_));
DCHECK(IsAligned(address, allocate_page_size_));
DCHECK(IsAligned(size, commit_page_size_));
{
MutexGuard guard(&mutex_);
CHECK(region_allocator_.contains(address, size));
DCHECK(region_allocator_.contains(address, size));
// Region allocator requires page size rather than commit size so just over-
// allocate there since any extra space couldn't be used anyway.
......@@ -102,7 +102,7 @@ bool BoundedPageAllocator::FreePages(void* raw_address, size_t size) {
bool BoundedPageAllocator::ReleasePages(void* raw_address, size_t size,
size_t new_size) {
Address address = reinterpret_cast<Address>(raw_address);
CHECK(IsAligned(address, allocate_page_size_));
DCHECK(IsAligned(address, allocate_page_size_));
DCHECK_LT(new_size, size);
DCHECK(IsAligned(size - new_size, commit_page_size_));
......@@ -116,7 +116,7 @@ bool BoundedPageAllocator::ReleasePages(void* raw_address, size_t size,
// There must be an allocated region at given |address| of a size not
// smaller than |size|.
MutexGuard guard(&mutex_);
CHECK_EQ(allocated_size, region_allocator_.CheckRegion(address));
DCHECK_EQ(allocated_size, region_allocator_.CheckRegion(address));
}
#endif
......
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