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

Unified Diff: runtime/vm/pages.cc

Issue 1118843004: Propagate failures from VirtualMemory::Commit. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 5 years, 8 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 | « runtime/vm/pages.h ('k') | runtime/vm/virtual_memory.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/pages.cc
===================================================================
--- runtime/vm/pages.cc (revision 45514)
+++ runtime/vm/pages.cc (working copy)
@@ -46,11 +46,14 @@
DEFINE_FLAG(bool, log_growth, false, "Log PageSpace growth policy decisions.");
HeapPage* HeapPage::Initialize(VirtualMemory* memory, PageType type) {
+ ASSERT(memory != NULL);
ASSERT(memory->size() > VirtualMemory::PageSize());
bool is_executable = (type == kExecutable);
- memory->Commit(is_executable);
-
+ if (!memory->Commit(is_executable)) {
+ return NULL;
+ }
HeapPage* result = reinterpret_cast<HeapPage*>(memory->address());
+ ASSERT(result != NULL);
result->memory_ = memory;
result->next_ = NULL;
result->executable_ = is_executable;
@@ -64,7 +67,12 @@
if (memory == NULL) {
return NULL;
}
- return Initialize(memory, type);
+ HeapPage* result = Initialize(memory, type);
+ if (result == NULL) {
+ delete memory; // Release reservation to OS.
+ return NULL;
+ }
+ return result;
}
« no previous file with comments | « runtime/vm/pages.h ('k') | runtime/vm/virtual_memory.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698