Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1549)

Unified Diff: Source/wtf/PartitionAlloc.cpp

Issue 295803005: Handle allocation failure with PartitionAllocReturnNull. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/wtf/PartitionAlloc.cpp
diff --git a/Source/wtf/PartitionAlloc.cpp b/Source/wtf/PartitionAlloc.cpp
index f55d77d1a8376db2db0f7790415b823667ae9606..a63a684c51980189aed9ab281b326c9f54d06ac4 100644
--- a/Source/wtf/PartitionAlloc.cpp
+++ b/Source/wtf/PartitionAlloc.cpp
@@ -308,7 +308,7 @@ static NEVER_INLINE void partitionFull()
IMMEDIATE_CRASH();
}
-static ALWAYS_INLINE void* partitionAllocPartitionPages(PartitionRootBase* root, size_t numPartitionPages)
+static ALWAYS_INLINE void* partitionAllocPartitionPages(PartitionRootBase* root, int flags, size_t numPartitionPages)
{
ASSERT(!(reinterpret_cast<uintptr_t>(root->nextPartitionPage) % kPartitionPageSize));
ASSERT(!(reinterpret_cast<uintptr_t>(root->nextPartitionPageEnd) % kPartitionPageSize));
@@ -329,9 +329,11 @@ static ALWAYS_INLINE void* partitionAllocPartitionPages(PartitionRootBase* root,
partitionFull();
char* requestedAddress = root->nextSuperPage;
char* superPage = reinterpret_cast<char*>(allocPages(requestedAddress, kSuperPageSize, kSuperPageSize));
- // TODO: handle allocation failure here with PartitionAllocReturnNull.
- if (!superPage)
+ if (UNLIKELY(!superPage)) {
+ if (flags & PartitionAllocReturnNull)
+ return 0;
partitionOutOfMemory();
+ }
root->nextSuperPage = superPage + kSuperPageSize;
char* ret = superPage + kPartitionPageSize;
root->nextPartitionPage = ret + totalSize;
@@ -677,7 +679,11 @@ void* partitionAllocSlowPath(PartitionRootBase* root, int flags, size_t size, Pa
} else {
// Third. If we get here, we need a brand new page.
size_t numPartitionPages = partitionBucketPartitionPages(bucket);
- void* rawNewPage = partitionAllocPartitionPages(root, numPartitionPages);
+ void* rawNewPage = partitionAllocPartitionPages(root, flags, numPartitionPages);
+ if (UNLIKELY(!rawNewPage)) {
+ ASSERT(returnNull);
+ return 0;
+ }
// Skip the alignment check because it depends on page->bucket, which is not yet set.
newPage = partitionPointerToPageNoAlignmentCheck(rawNewPage);
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698