Index: src/api.cc |
diff --git a/src/api.cc b/src/api.cc |
index 4031769904c7fff2a339a783f5f1d7f981f78157..1525000981d9852e23c68b76b25e3d1ec7e642a0 100644 |
--- a/src/api.cc |
+++ b/src/api.cc |
@@ -243,7 +243,7 @@ void i::FatalProcessOutOfMemory(const char* location) { |
// When V8 cannot allocated memory FatalProcessOutOfMemory is called. |
-// The default fatal error handler is called and execution is stopped. |
+// The default OOM error handler is called and execution is stopped. |
void i::V8::FatalProcessOutOfMemory(const char* location, bool is_heap_oom) { |
i::Isolate* isolate = i::Isolate::Current(); |
char last_few_messages[Heap::kTraceRingBufferSize + 1]; |
@@ -306,9 +306,7 @@ void i::V8::FatalProcessOutOfMemory(const char* location, bool is_heap_oom) { |
PrintF("\n<--- Last few GCs --->\n%s\n", first_newline); |
PrintF("\n<--- JS stacktrace --->\n%s\n", js_stacktrace); |
} |
- Utils::ApiCheck(false, location, is_heap_oom |
- ? "Allocation failed - JavaScript heap out of memory" |
- : "Allocation failed - process out of memory"); |
+ Utils::ReportOOMFailure(location, is_heap_oom); |
// If the fatal error handler returns, we stop execution. |
FATAL("API fatal error handler returned after process out of memory"); |
} |
@@ -328,6 +326,19 @@ void Utils::ReportApiFailure(const char* location, const char* message) { |
} |
+void Utils::ReportOOMFailure(const char* location, bool is_heap_oom) { |
+ i::Isolate* isolate = i::Isolate::Current(); |
+ OOMErrorCallback callback = isolate->oom_behavior(); |
+ if (callback == NULL) { |
jochen (gone - plz use gerrit)
2016/07/12 15:11:30
nullptr
Will Harris
2016/07/12 15:42:53
Done.
|
+ base::OS::PrintError("\n#\n# Fatal %s OOM in %s\n#\n\n", |
+ is_heap_oom ? "javascript" : "process", location); |
+ base::OS::Abort(); |
+ } else { |
+ callback(location, is_heap_oom); |
+ } |
+ isolate->SignalFatalError(); |
+} |
+ |
static inline bool IsExecutionTerminatingCheck(i::Isolate* isolate) { |
if (isolate->has_scheduled_exception()) { |
return isolate->scheduled_exception() == |
@@ -7907,6 +7918,10 @@ void Isolate::SetFatalErrorHandler(FatalErrorCallback that) { |
isolate->set_exception_behavior(that); |
} |
+void Isolate::SetOOMErrorHandler(OOMErrorCallback that) { |
+ i::Isolate* isolate = reinterpret_cast<i::Isolate*>(this); |
+ isolate->set_oom_behavior(that); |
+} |
void Isolate::SetAllowCodeGenerationFromStringsCallback( |
AllowCodeGenerationFromStringsCallback callback) { |