summaryrefslogtreecommitdiff
path: root/deps/v8/src/isolate.cc
diff options
context:
space:
mode:
Diffstat (limited to 'deps/v8/src/isolate.cc')
-rw-r--r--deps/v8/src/isolate.cc42
1 files changed, 30 insertions, 12 deletions
diff --git a/deps/v8/src/isolate.cc b/deps/v8/src/isolate.cc
index 215296d73..2905a0828 100644
--- a/deps/v8/src/isolate.cc
+++ b/deps/v8/src/isolate.cc
@@ -1090,19 +1090,30 @@ void Isolate::DoThrow(Object* exception, MessageLocation* location) {
thread_local_top()->pending_message_end_pos_ = location->end_pos();
}
- // If the abort-on-uncaught-exception flag is specified, abort on any
- // exception not caught by JavaScript, even when an external handler is
- // present. This flag is intended for use by JavaScript developers, so
- // print a user-friendly stack trace (not an internal one).
+ // If the abort-on-uncaught-exception flag is specified, and if the
+ // exception is not caught by JavaScript (even when an external handler is
+ // present).
if (fatal_exception_depth == 0 &&
- FLAG_abort_on_uncaught_exception &&
+ (FLAG_abort_on_uncaught_exception) &&
(report_exception || can_be_caught_externally)) {
- fatal_exception_depth++;
- PrintF(stderr,
- "%s\n\nFROM\n",
- MessageHandler::GetLocalizedMessage(this, message_obj).get());
- PrintCurrentStackTrace(stderr);
- base::OS::Abort();
+ // If the embedder didn't specify a custom uncaught exception callback,
+ // or if the custom callback determined that V8 should abort, then
+ // abort
+ bool should_abort = !abort_on_uncaught_exception_callback_ ||
+ abort_on_uncaught_exception_callback_(
+ reinterpret_cast<v8::Isolate*>(this)
+ );
+
+ if (should_abort) {
+ fatal_exception_depth++;
+ // This flag is intended for use by JavaScript developers, so
+ // print a user-friendly stack trace (not an internal one).
+ PrintF(stderr,
+ "%s\n\nFROM\n",
+ MessageHandler::GetLocalizedMessage(this, message_obj).get());
+ PrintCurrentStackTrace(stderr);
+ base::OS::Abort();
+ }
}
} else if (location != NULL && !location->script().is_null()) {
// We are bootstrapping and caught an error where the location is set
@@ -1299,6 +1310,12 @@ void Isolate::SetCaptureStackTraceForUncaughtExceptions(
}
+void Isolate::SetAbortOnUncaughtException(
+ v8::Isolate::abort_on_uncaught_exception_t callback) {
+ abort_on_uncaught_exception_callback_ = callback;
+}
+
+
Handle<Context> Isolate::native_context() {
return handle(context()->native_context());
}
@@ -1474,7 +1491,8 @@ Isolate::Isolate()
num_sweeper_threads_(0),
stress_deopt_count_(0),
next_optimization_id_(0),
- use_counter_callback_(NULL) {
+ use_counter_callback_(NULL),
+ abort_on_uncaught_exception_callback_(NULL) {
id_ = base::NoBarrier_AtomicIncrement(&isolate_counter_, 1);
TRACE_ISOLATE(constructor);