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

Side by Side Diff: src/isolate.cc

Issue 1375933003: Add SetAbortOnUncaughtExceptionCallback API (Closed) Base URL: git@github.com:v8/v8.git@master
Patch Set: Update after second code review Created 5 years, 2 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 unified diff | Download patch
« no previous file with comments | « src/isolate.h ('k') | test/cctest/test-api.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/isolate.h" 5 #include "src/isolate.h"
6 6
7 #include <stdlib.h> 7 #include <stdlib.h>
8 8
9 #include <fstream> // NOLINT(readability/streams) 9 #include <fstream> // NOLINT(readability/streams)
10 #include <sstream> 10 #include <sstream>
(...skipping 990 matching lines...) Expand 10 before | Expand all | Expand 10 after
1001 1001
1002 if (bootstrapper()->IsActive()) { 1002 if (bootstrapper()->IsActive()) {
1003 // It's not safe to try to make message objects or collect stack traces 1003 // It's not safe to try to make message objects or collect stack traces
1004 // while the bootstrapper is active since the infrastructure may not have 1004 // while the bootstrapper is active since the infrastructure may not have
1005 // been properly initialized. 1005 // been properly initialized.
1006 ReportBootstrappingException(exception_handle, location); 1006 ReportBootstrappingException(exception_handle, location);
1007 } else { 1007 } else {
1008 Handle<Object> message_obj = CreateMessage(exception_handle, location); 1008 Handle<Object> message_obj = CreateMessage(exception_handle, location);
1009 thread_local_top()->pending_message_obj_ = *message_obj; 1009 thread_local_top()->pending_message_obj_ = *message_obj;
1010 1010
1011 // If the abort-on-uncaught-exception flag is specified, abort on any 1011 // For any exception not caught by JavaScript, even when an external
1012 // exception not caught by JavaScript, even when an external handler is 1012 // handler is present:
1013 // present. This flag is intended for use by JavaScript developers, so 1013 // If the abort-on-uncaught-exception flag is specified, and if the
1014 // print a user-friendly stack trace (not an internal one). 1014 // embedder didn't specify a custom uncaught exception callback,
1015 // or if the custom callback determined that V8 should abort, then
1016 // abort.
1015 if (FLAG_abort_on_uncaught_exception && 1017 if (FLAG_abort_on_uncaught_exception &&
1016 PredictExceptionCatcher() != CAUGHT_BY_JAVASCRIPT) { 1018 PredictExceptionCatcher() != CAUGHT_BY_JAVASCRIPT &&
1017 FLAG_abort_on_uncaught_exception = false; // Prevent endless recursion. 1019 (!abort_on_uncaught_exception_callback_ ||
1020 abort_on_uncaught_exception_callback_(
1021 reinterpret_cast<v8::Isolate*>(this)))) {
1022 // Prevent endless recursion.
1023 FLAG_abort_on_uncaught_exception = false;
1024 // This flag is intended for use by JavaScript developers, so
1025 // print a user-friendly stack trace (not an internal one).
1018 PrintF(stderr, "%s\n\nFROM\n", 1026 PrintF(stderr, "%s\n\nFROM\n",
1019 MessageHandler::GetLocalizedMessage(this, message_obj).get()); 1027 MessageHandler::GetLocalizedMessage(this, message_obj).get());
1020 PrintCurrentStackTrace(stderr); 1028 PrintCurrentStackTrace(stderr);
1021 base::OS::Abort(); 1029 base::OS::Abort();
1022 } 1030 }
1023 } 1031 }
1024 } 1032 }
1025 1033
1026 // Set the exception being thrown. 1034 // Set the exception being thrown.
1027 set_pending_exception(*exception_handle); 1035 set_pending_exception(*exception_handle);
(...skipping 567 matching lines...) Expand 10 before | Expand all | Expand 10 after
1595 void Isolate::SetCaptureStackTraceForUncaughtExceptions( 1603 void Isolate::SetCaptureStackTraceForUncaughtExceptions(
1596 bool capture, 1604 bool capture,
1597 int frame_limit, 1605 int frame_limit,
1598 StackTrace::StackTraceOptions options) { 1606 StackTrace::StackTraceOptions options) {
1599 capture_stack_trace_for_uncaught_exceptions_ = capture; 1607 capture_stack_trace_for_uncaught_exceptions_ = capture;
1600 stack_trace_for_uncaught_exceptions_frame_limit_ = frame_limit; 1608 stack_trace_for_uncaught_exceptions_frame_limit_ = frame_limit;
1601 stack_trace_for_uncaught_exceptions_options_ = options; 1609 stack_trace_for_uncaught_exceptions_options_ = options;
1602 } 1610 }
1603 1611
1604 1612
1613 void Isolate::SetAbortOnUncaughtExceptionCallback(
1614 v8::Isolate::AbortOnUncaughtExceptionCallback callback) {
1615 abort_on_uncaught_exception_callback_ = callback;
1616 }
1617
1618
1605 Handle<Context> Isolate::native_context() { 1619 Handle<Context> Isolate::native_context() {
1606 return handle(context()->native_context()); 1620 return handle(context()->native_context());
1607 } 1621 }
1608 1622
1609 1623
1610 Handle<Context> Isolate::GetCallingNativeContext() { 1624 Handle<Context> Isolate::GetCallingNativeContext() {
1611 JavaScriptFrameIterator it(this); 1625 JavaScriptFrameIterator it(this);
1612 if (debug_->in_debug_scope()) { 1626 if (debug_->in_debug_scope()) {
1613 while (!it.done()) { 1627 while (!it.done()) {
1614 JavaScriptFrame* frame = it.frame(); 1628 JavaScriptFrame* frame = it.frame();
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
1763 function_entry_hook_(NULL), 1777 function_entry_hook_(NULL),
1764 deferred_handles_head_(NULL), 1778 deferred_handles_head_(NULL),
1765 optimizing_compile_dispatcher_(NULL), 1779 optimizing_compile_dispatcher_(NULL),
1766 stress_deopt_count_(0), 1780 stress_deopt_count_(0),
1767 vector_store_virtual_register_(NULL), 1781 vector_store_virtual_register_(NULL),
1768 next_optimization_id_(0), 1782 next_optimization_id_(0),
1769 #if TRACE_MAPS 1783 #if TRACE_MAPS
1770 next_unique_sfi_id_(0), 1784 next_unique_sfi_id_(0),
1771 #endif 1785 #endif
1772 use_counter_callback_(NULL), 1786 use_counter_callback_(NULL),
1773 basic_block_profiler_(NULL) { 1787 basic_block_profiler_(NULL),
1788 abort_on_uncaught_exception_callback_(NULL) {
1774 { 1789 {
1775 base::LockGuard<base::Mutex> lock_guard(thread_data_table_mutex_.Pointer()); 1790 base::LockGuard<base::Mutex> lock_guard(thread_data_table_mutex_.Pointer());
1776 CHECK(thread_data_table_); 1791 CHECK(thread_data_table_);
1777 } 1792 }
1778 id_ = base::NoBarrier_AtomicIncrement(&isolate_counter_, 1); 1793 id_ = base::NoBarrier_AtomicIncrement(&isolate_counter_, 1);
1779 TRACE_ISOLATE(constructor); 1794 TRACE_ISOLATE(constructor);
1780 1795
1781 memset(isolate_addresses_, 0, 1796 memset(isolate_addresses_, 0,
1782 sizeof(isolate_addresses_[0]) * (kIsolateAddressCount + 1)); 1797 sizeof(isolate_addresses_[0]) * (kIsolateAddressCount + 1));
1783 1798
(...skipping 1038 matching lines...) Expand 10 before | Expand all | Expand 10 after
2822 // Then check whether this scope intercepts. 2837 // Then check whether this scope intercepts.
2823 if ((flag & intercept_mask_)) { 2838 if ((flag & intercept_mask_)) {
2824 intercepted_flags_ |= flag; 2839 intercepted_flags_ |= flag;
2825 return true; 2840 return true;
2826 } 2841 }
2827 return false; 2842 return false;
2828 } 2843 }
2829 2844
2830 } // namespace internal 2845 } // namespace internal
2831 } // namespace v8 2846 } // namespace v8
OLDNEW
« no previous file with comments | « src/isolate.h ('k') | test/cctest/test-api.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698