Revision: 13356 Author: [email protected] Date: Thu Jan 10 07:53:11 2013 Log: Make v8 handle OOM during Heap construction more gracefully.
Review URL: https://codereview.chromium.org/11824064 http://code.google.com/p/v8/source/detail?r=13356 Modified: /branches/bleeding_edge/src/api.cc /branches/bleeding_edge/src/isolate.cc ======================================= --- /branches/bleeding_edge/src/api.cc Wed Jan 9 07:47:53 2013 +++ /branches/bleeding_edge/src/api.cc Thu Jan 10 07:53:11 2013 @@ -128,8 +128,13 @@ static void DefaultFatalErrorHandler(const char* location, const char* message) { - i::VMState __state__(i::Isolate::Current(), i::OTHER); - API_Fatal(location, message); + i::Isolate* isolate = i::Isolate::Current(); + if (isolate->IsInitialized()) { + i::VMState __state__(isolate, i::OTHER); + API_Fatal(location, message); + } else { + API_Fatal(location, message); + } } @@ -202,15 +207,21 @@ int end_marker; heap_stats.end_marker = &end_marker; i::Isolate* isolate = i::Isolate::Current(); - // BUG(1718): - // Don't use the take_snapshot since we don't support HeapIterator here - // without doing a special GC. - isolate->heap()->RecordStats(&heap_stats, false); + if (isolate->heap()->HasBeenSetUp()) { + // BUG(1718): Don't use the take_snapshot since we don't support + // HeapIterator here without doing a special GC. + isolate->heap()->RecordStats(&heap_stats, false); + } i::V8::SetFatalError(); FatalErrorCallback callback = GetFatalErrorHandler(); + const char* message = "Allocation failed - process out of memory"; { - LEAVE_V8(isolate); - callback(location, "Allocation failed - process out of memory"); + if (isolate->IsInitialized()) { + LEAVE_V8(isolate); + callback(location, message); + } else { + callback(location, message); + } } // If the callback returns, we stop execution. UNREACHABLE(); ======================================= --- /branches/bleeding_edge/src/isolate.cc Wed Jan 9 07:47:53 2013 +++ /branches/bleeding_edge/src/isolate.cc Thu Jan 10 07:53:11 2013 @@ -2003,7 +2003,7 @@ const bool create_heap_objects = (des == NULL); ASSERT(!heap_.HasBeenSetUp()); if (!heap_.SetUp(create_heap_objects)) { - V8::SetFatalError(); + V8::FatalProcessOutOfMemory("heap setup"); return false; } -- v8-dev mailing list [email protected] http://groups.google.com/group/v8-dev
