Correctly report some internal OOM conditions.
authormstarzinger <mstarzinger@chromium.org>
Thu, 5 Feb 2015 09:51:53 +0000 (01:51 -0800)
committerCommit bot <commit-bot@chromium.org>
Thu, 5 Feb 2015 09:51:59 +0000 (09:51 +0000)
R=hpayer@chromium.org
BUG=chromium:454615
LOG=N

Review URL: https://codereview.chromium.org/900793004

Cr-Commit-Position: refs/heads/master@{#26452}

src/heap/mark-compact.cc
src/heap/store-buffer.cc
src/v8.h

index fa366ee..1992c23 100644 (file)
@@ -2128,11 +2128,12 @@ void MarkCompactCollector::EnsureMarkingDequeIsCommittedAndInitialize() {
     marking_deque_memory_ = new base::VirtualMemory(4 * MB);
   }
   if (!marking_deque_memory_committed_) {
-    bool success = marking_deque_memory_->Commit(
-        reinterpret_cast<Address>(marking_deque_memory_->address()),
-        marking_deque_memory_->size(),
-        false);  // Not executable.
-    CHECK(success);
+    if (!marking_deque_memory_->Commit(
+            reinterpret_cast<Address>(marking_deque_memory_->address()),
+            marking_deque_memory_->size(),
+            false)) {  // Not executable.
+      V8::FatalProcessOutOfMemory("EnsureMarkingDequeIsCommitted");
+    }
     marking_deque_memory_committed_ = true;
     InitializeMarkingDeque();
   }
index d126551..591d28f 100644 (file)
@@ -55,9 +55,11 @@ void StoreBuffer::SetUp() {
   old_limit_ = old_start_ + initial_length;
   old_reserved_limit_ = old_start_ + kOldStoreBufferLength;
 
-  CHECK(old_virtual_memory_->Commit(reinterpret_cast<void*>(old_start_),
-                                    (old_limit_ - old_start_) * kPointerSize,
-                                    false));
+  if (!old_virtual_memory_->Commit(reinterpret_cast<void*>(old_start_),
+                                   (old_limit_ - old_start_) * kPointerSize,
+                                   false)) {
+    V8::FatalProcessOutOfMemory("StoreBuffer::SetUp");
+  }
 
   DCHECK(reinterpret_cast<Address>(start_) >= virtual_memory_->address());
   DCHECK(reinterpret_cast<Address>(limit_) >= virtual_memory_->address());
@@ -71,9 +73,11 @@ void StoreBuffer::SetUp() {
   DCHECK((reinterpret_cast<uintptr_t>(limit_ - 1) & kStoreBufferOverflowBit) ==
          0);
 
-  CHECK(virtual_memory_->Commit(reinterpret_cast<Address>(start_),
-                                kStoreBufferSize,
-                                false));  // Not executable.
+  if (!virtual_memory_->Commit(reinterpret_cast<Address>(start_),
+                               kStoreBufferSize,
+                               false)) {  // Not executable.
+    V8::FatalProcessOutOfMemory("StoreBuffer::SetUp");
+  }
   heap_->public_set_store_buffer_top(start_);
 
   hash_set_1_ = new uintptr_t[kHashSetLength];
@@ -133,8 +137,10 @@ void StoreBuffer::EnsureSpace(intptr_t space_needed) {
   while (old_limit_ - old_top_ < space_needed &&
          old_limit_ < old_reserved_limit_) {
     size_t grow = old_limit_ - old_start_;  // Double size.
-    CHECK(old_virtual_memory_->Commit(reinterpret_cast<void*>(old_limit_),
-                                      grow * kPointerSize, false));
+    if (!old_virtual_memory_->Commit(reinterpret_cast<void*>(old_limit_),
+                                     grow * kPointerSize, false)) {
+      V8::FatalProcessOutOfMemory("StoreBuffer::EnsureSpace");
+    }
     old_limit_ += grow;
   }
 
index 17398ed..211f3c6 100644 (file)
--- a/src/v8.h
+++ b/src/v8.h
@@ -56,6 +56,7 @@ class V8 : public AllStatic {
   static void TearDown();
 
   // Report process out of memory. Implementation found in api.cc.
+  // This function will not return, but will terminate the execution.
   static void FatalProcessOutOfMemory(const char* location,
                                       bool take_snapshot = false);