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

Unified Diff: src/api.cc

Issue 11824064: Make v8 handle OOM during Heap construction more gracefully. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 11 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 | src/isolate.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/api.cc
diff --git a/src/api.cc b/src/api.cc
index 352b63dfcac810c01a743edbac698a77214da53c..0563443b8bdf1248a2b3bf78bd837bceb406c6d2 100644
--- a/src/api.cc
+++ b/src/api.cc
@@ -128,8 +128,13 @@ namespace v8 {
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 @@ void i::V8::FatalProcessOutOfMemory(const char* location, bool take_snapshot) {
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();
« no previous file with comments | « no previous file | src/isolate.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698