Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 996 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 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 // If the abort-on-uncaught-exception flag is specified, abort on any |
| 1012 // exception not caught by JavaScript, even when an external handler is | 1012 // exception not caught by JavaScript, even when an external handler is |
| 1013 // present. This flag is intended for use by JavaScript developers, so | 1013 // present. This flag is intended for use by JavaScript developers, so |
| 1014 // print a user-friendly stack trace (not an internal one). | 1014 // print a user-friendly stack trace (not an internal one). |
| 1015 if (FLAG_abort_on_uncaught_exception && | 1015 if (FLAG_abort_on_uncaught_exception && |
| 1016 PredictExceptionCatcher() != CAUGHT_BY_JAVASCRIPT) { | 1016 PredictExceptionCatcher() != CAUGHT_BY_JAVASCRIPT) { |
| 1017 FLAG_abort_on_uncaught_exception = false; // Prevent endless recursion. | 1017 // If the embedder didn't specify a custom uncaught exception callback, |
| 1018 PrintF(stderr, "%s\n\nFROM\n", | 1018 // or if the custom callback determined that V8 should abort, then |
| 1019 MessageHandler::GetLocalizedMessage(this, message_obj).get()); | 1019 // abort |
|
Michael Starzinger
2015/10/01 16:34:38
nit: Punctuation.
julien.gilli
2015/10/01 19:18:11
Acknowledged.
julien.gilli
2015/10/05 17:24:24
Done.
| |
| 1020 PrintCurrentStackTrace(stderr); | 1020 bool should_abort = !abort_on_uncaught_exception_callback_ || |
| 1021 base::OS::Abort(); | 1021 abort_on_uncaught_exception_callback_( |
| 1022 reinterpret_cast<v8::Isolate*>(this)); | |
| 1023 | |
| 1024 if (should_abort) { | |
| 1025 // Prevent endless recursion. | |
| 1026 FLAG_abort_on_uncaught_exception = false; | |
| 1027 PrintF(stderr, "%s\n\nFROM\n", | |
| 1028 MessageHandler::GetLocalizedMessage(this, message_obj).get()); | |
| 1029 PrintCurrentStackTrace(stderr); | |
| 1030 base::OS::Abort(); | |
| 1031 } | |
| 1022 } | 1032 } |
| 1023 } | 1033 } |
| 1024 } | 1034 } |
| 1025 | 1035 |
| 1026 // Set the exception being thrown. | 1036 // Set the exception being thrown. |
| 1027 set_pending_exception(*exception_handle); | 1037 set_pending_exception(*exception_handle); |
| 1028 return heap()->exception(); | 1038 return heap()->exception(); |
| 1029 } | 1039 } |
| 1030 | 1040 |
| 1031 | 1041 |
| (...skipping 563 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1595 void Isolate::SetCaptureStackTraceForUncaughtExceptions( | 1605 void Isolate::SetCaptureStackTraceForUncaughtExceptions( |
| 1596 bool capture, | 1606 bool capture, |
| 1597 int frame_limit, | 1607 int frame_limit, |
| 1598 StackTrace::StackTraceOptions options) { | 1608 StackTrace::StackTraceOptions options) { |
| 1599 capture_stack_trace_for_uncaught_exceptions_ = capture; | 1609 capture_stack_trace_for_uncaught_exceptions_ = capture; |
| 1600 stack_trace_for_uncaught_exceptions_frame_limit_ = frame_limit; | 1610 stack_trace_for_uncaught_exceptions_frame_limit_ = frame_limit; |
| 1601 stack_trace_for_uncaught_exceptions_options_ = options; | 1611 stack_trace_for_uncaught_exceptions_options_ = options; |
| 1602 } | 1612 } |
| 1603 | 1613 |
| 1604 | 1614 |
| 1615 void Isolate::SetAbortOnUncaughtExceptionCallback( | |
| 1616 v8::Isolate::AbortOnUncaughtExceptionCallback callback) { | |
| 1617 abort_on_uncaught_exception_callback_ = callback; | |
| 1618 } | |
| 1619 | |
| 1620 | |
| 1605 Handle<Context> Isolate::native_context() { | 1621 Handle<Context> Isolate::native_context() { |
| 1606 return handle(context()->native_context()); | 1622 return handle(context()->native_context()); |
| 1607 } | 1623 } |
| 1608 | 1624 |
| 1609 | 1625 |
| 1610 Handle<Context> Isolate::GetCallingNativeContext() { | 1626 Handle<Context> Isolate::GetCallingNativeContext() { |
| 1611 JavaScriptFrameIterator it(this); | 1627 JavaScriptFrameIterator it(this); |
| 1612 if (debug_->in_debug_scope()) { | 1628 if (debug_->in_debug_scope()) { |
| 1613 while (!it.done()) { | 1629 while (!it.done()) { |
| 1614 JavaScriptFrame* frame = it.frame(); | 1630 JavaScriptFrame* frame = it.frame(); |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1763 function_entry_hook_(NULL), | 1779 function_entry_hook_(NULL), |
| 1764 deferred_handles_head_(NULL), | 1780 deferred_handles_head_(NULL), |
| 1765 optimizing_compile_dispatcher_(NULL), | 1781 optimizing_compile_dispatcher_(NULL), |
| 1766 stress_deopt_count_(0), | 1782 stress_deopt_count_(0), |
| 1767 vector_store_virtual_register_(NULL), | 1783 vector_store_virtual_register_(NULL), |
| 1768 next_optimization_id_(0), | 1784 next_optimization_id_(0), |
| 1769 #if TRACE_MAPS | 1785 #if TRACE_MAPS |
| 1770 next_unique_sfi_id_(0), | 1786 next_unique_sfi_id_(0), |
| 1771 #endif | 1787 #endif |
| 1772 use_counter_callback_(NULL), | 1788 use_counter_callback_(NULL), |
| 1773 basic_block_profiler_(NULL) { | 1789 basic_block_profiler_(NULL), |
| 1790 abort_on_uncaught_exception_callback_(NULL) { | |
| 1774 { | 1791 { |
| 1775 base::LockGuard<base::Mutex> lock_guard(thread_data_table_mutex_.Pointer()); | 1792 base::LockGuard<base::Mutex> lock_guard(thread_data_table_mutex_.Pointer()); |
| 1776 CHECK(thread_data_table_); | 1793 CHECK(thread_data_table_); |
| 1777 } | 1794 } |
| 1778 id_ = base::NoBarrier_AtomicIncrement(&isolate_counter_, 1); | 1795 id_ = base::NoBarrier_AtomicIncrement(&isolate_counter_, 1); |
| 1779 TRACE_ISOLATE(constructor); | 1796 TRACE_ISOLATE(constructor); |
| 1780 | 1797 |
| 1781 memset(isolate_addresses_, 0, | 1798 memset(isolate_addresses_, 0, |
| 1782 sizeof(isolate_addresses_[0]) * (kIsolateAddressCount + 1)); | 1799 sizeof(isolate_addresses_[0]) * (kIsolateAddressCount + 1)); |
| 1783 | 1800 |
| (...skipping 1038 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2822 // Then check whether this scope intercepts. | 2839 // Then check whether this scope intercepts. |
| 2823 if ((flag & intercept_mask_)) { | 2840 if ((flag & intercept_mask_)) { |
| 2824 intercepted_flags_ |= flag; | 2841 intercepted_flags_ |= flag; |
| 2825 return true; | 2842 return true; |
| 2826 } | 2843 } |
| 2827 return false; | 2844 return false; |
| 2828 } | 2845 } |
| 2829 | 2846 |
| 2830 } // namespace internal | 2847 } // namespace internal |
| 2831 } // namespace v8 | 2848 } // namespace v8 |
| OLD | NEW |