Skip to content
Snippets Groups Projects
Commit 60b99c8a authored by Paul Bone's avatar Paul Bone
Browse files

Bug 1828599 - Fix control flow in MaybePageAlloc r=glandium

parent b1004312
No related branches found
No related tags found
No related merge requests found
......@@ -1099,32 +1099,36 @@ static void* MaybePageAlloc(const Maybe<arena_id_t>& aArenaId, size_t aReqSize,
#else
mprotect(pagePtr, kPageSize, PROT_READ | PROT_WRITE) == 0;
#endif
if (!ok) {
pagePtr = nullptr;
continue;
}
size_t usableSize = sMallocTable.malloc_good_size(aReqSize);
if (ok) {
MOZ_ASSERT(usableSize > 0);
// Put the allocation as close to the end of the page as possible,
// allowing for alignment requirements.
ptr = pagePtr + kPageSize - usableSize;
if (aAlignment != 1) {
ptr = reinterpret_cast<uint8_t*>(
(reinterpret_cast<uintptr_t>(ptr) & ~(aAlignment - 1)));
}
MOZ_ASSERT(usableSize > 0);
// Put the allocation as close to the end of the page as possible,
// allowing for alignment requirements.
ptr = pagePtr + kPageSize - usableSize;
if (aAlignment != 1) {
ptr = reinterpret_cast<uint8_t*>(
(reinterpret_cast<uintptr_t>(ptr) & ~(aAlignment - 1)));
}
#if PHC_LOGGING
Time then = gMut->GetFreeTime(i);
lifetime = then != 0 ? now - then : 0;
Time then = gMut->GetFreeTime(i);
lifetime = then != 0 ? now - then : 0;
#endif
gMut->SetPageInUse(lock, i, aArenaId, ptr, allocStack);
gMut->SetPageInUse(lock, i, aArenaId, ptr, allocStack);
if (aZero) {
memset(ptr, 0, usableSize);
} else {
if (aZero) {
memset(ptr, 0, usableSize);
} else {
#ifdef DEBUG
memset(ptr, kAllocJunk, usableSize);
memset(ptr, kAllocJunk, usableSize);
#endif
}
}
gMut->IncPageAllocHits(lock);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment