Chromium Code Reviews| Index: src/api.cc |
| diff --git a/src/api.cc b/src/api.cc |
| index 4031769904c7fff2a339a783f5f1d7f981f78157..041375c1fcb0e8f61f004c5b6c81c4b22718e436 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"); |
| } |
| @@ -327,6 +325,18 @@ void Utils::ReportApiFailure(const char* location, const char* message) { |
| isolate->SignalFatalError(); |
| } |
| +void Utils::ReportOOMFailure(const char* location, bool is_heap_oom) { |
| + i::Isolate* isolate = i::Isolate::Current(); |
| + OOMErrorCallback callback = isolate->oom_behavior(); |
| + if (callback == nullptr) { |
|
Will Harris
2016/07/12 15:46:10
This will change the signature of OOM errors in v8
Hannes Payer (out of office)
2016/07/13 09:21:11
After landing 2130293003 the signature will change
Will Harris
2016/07/13 20:09:45
now it will fall back to previous behavior if the
|
| + 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()) { |
| @@ -7907,6 +7917,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) { |