Make v8 handle OOM during Heap construction more gracefully.

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

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@13356 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent b64765eb
...@@ -128,8 +128,13 @@ namespace v8 { ...@@ -128,8 +128,13 @@ namespace v8 {
static void DefaultFatalErrorHandler(const char* location, static void DefaultFatalErrorHandler(const char* location,
const char* message) { const char* message) {
i::VMState __state__(i::Isolate::Current(), i::OTHER); i::Isolate* isolate = i::Isolate::Current();
if (isolate->IsInitialized()) {
i::VMState __state__(isolate, i::OTHER);
API_Fatal(location, message);
} else {
API_Fatal(location, message); API_Fatal(location, message);
}
} }
...@@ -202,15 +207,21 @@ void i::V8::FatalProcessOutOfMemory(const char* location, bool take_snapshot) { ...@@ -202,15 +207,21 @@ void i::V8::FatalProcessOutOfMemory(const char* location, bool take_snapshot) {
int end_marker; int end_marker;
heap_stats.end_marker = &end_marker; heap_stats.end_marker = &end_marker;
i::Isolate* isolate = i::Isolate::Current(); i::Isolate* isolate = i::Isolate::Current();
// BUG(1718): if (isolate->heap()->HasBeenSetUp()) {
// Don't use the take_snapshot since we don't support HeapIterator here // BUG(1718): Don't use the take_snapshot since we don't support
// without doing a special GC. // HeapIterator here without doing a special GC.
isolate->heap()->RecordStats(&heap_stats, false); isolate->heap()->RecordStats(&heap_stats, false);
}
i::V8::SetFatalError(); i::V8::SetFatalError();
FatalErrorCallback callback = GetFatalErrorHandler(); FatalErrorCallback callback = GetFatalErrorHandler();
const char* message = "Allocation failed - process out of memory";
{ {
if (isolate->IsInitialized()) {
LEAVE_V8(isolate); LEAVE_V8(isolate);
callback(location, "Allocation failed - process out of memory"); callback(location, message);
} else {
callback(location, message);
}
} }
// If the callback returns, we stop execution. // If the callback returns, we stop execution.
UNREACHABLE(); UNREACHABLE();
......
...@@ -2003,7 +2003,7 @@ bool Isolate::Init(Deserializer* des) { ...@@ -2003,7 +2003,7 @@ bool Isolate::Init(Deserializer* des) {
const bool create_heap_objects = (des == NULL); const bool create_heap_objects = (des == NULL);
ASSERT(!heap_.HasBeenSetUp()); ASSERT(!heap_.HasBeenSetUp());
if (!heap_.SetUp(create_heap_objects)) { if (!heap_.SetUp(create_heap_objects)) {
V8::SetFatalError(); V8::FatalProcessOutOfMemory("heap setup");
return false; return false;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment