| 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/debug/debug.h" | 5 #include "src/debug/debug.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 | 8 |
| 9 #include "src/api.h" | 9 #include "src/api.h" |
| 10 #include "src/arguments.h" | 10 #include "src/arguments.h" |
| (...skipping 1664 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1675 if (isolate_->has_scheduled_exception()) { | 1675 if (isolate_->has_scheduled_exception()) { |
| 1676 scheduled_exception = handle(isolate_->scheduled_exception(), isolate_); | 1676 scheduled_exception = handle(isolate_->scheduled_exception(), isolate_); |
| 1677 isolate_->clear_scheduled_exception(); | 1677 isolate_->clear_scheduled_exception(); |
| 1678 } | 1678 } |
| 1679 OnException(exception, isolate_->GetPromiseOnStackOnThrow()); | 1679 OnException(exception, isolate_->GetPromiseOnStackOnThrow()); |
| 1680 if (!scheduled_exception.is_null()) { | 1680 if (!scheduled_exception.is_null()) { |
| 1681 isolate_->thread_local_top()->scheduled_exception_ = *scheduled_exception; | 1681 isolate_->thread_local_top()->scheduled_exception_ = *scheduled_exception; |
| 1682 } | 1682 } |
| 1683 } | 1683 } |
| 1684 | 1684 |
| 1685 | 1685 void Debug::OnPromiseReject(Handle<Object> promise, Handle<Object> value) { |
| 1686 void Debug::OnPromiseReject(Handle<JSObject> promise, Handle<Object> value) { | |
| 1687 if (in_debug_scope() || ignore_events()) return; | 1686 if (in_debug_scope() || ignore_events()) return; |
| 1688 HandleScope scope(isolate_); | 1687 HandleScope scope(isolate_); |
| 1689 // Check whether the promise has been marked as having triggered a message. | 1688 // Check whether the promise has been marked as having triggered a message. |
| 1690 Handle<Symbol> key = isolate_->factory()->promise_debug_marker_symbol(); | 1689 Handle<Symbol> key = isolate_->factory()->promise_debug_marker_symbol(); |
| 1691 if (JSReceiver::GetDataProperty(promise, key)->IsUndefined(isolate_)) { | 1690 if (!promise->IsJSObject() || |
| 1691 JSReceiver::GetDataProperty(Handle<JSObject>::cast(promise), key) |
| 1692 ->IsUndefined(isolate_)) { |
| 1692 OnException(value, promise); | 1693 OnException(value, promise); |
| 1693 } | 1694 } |
| 1694 } | 1695 } |
| 1695 | 1696 |
| 1696 | 1697 |
| 1697 MaybeHandle<Object> Debug::PromiseHasUserDefinedRejectHandler( | |
| 1698 Handle<JSObject> promise) { | |
| 1699 Handle<JSFunction> fun = isolate_->promise_has_user_defined_reject_handler(); | |
| 1700 return Execution::Call(isolate_, fun, promise, 0, NULL); | |
| 1701 } | |
| 1702 | |
| 1703 | |
| 1704 void Debug::OnException(Handle<Object> exception, Handle<Object> promise) { | 1698 void Debug::OnException(Handle<Object> exception, Handle<Object> promise) { |
| 1705 Isolate::CatchType catch_type = isolate_->PredictExceptionCatcher(); | 1699 Isolate::CatchType catch_type = isolate_->PredictExceptionCatcher(); |
| 1706 | 1700 |
| 1707 // Don't notify listener of exceptions that are internal to a desugaring. | 1701 // Don't notify listener of exceptions that are internal to a desugaring. |
| 1708 if (catch_type == Isolate::CAUGHT_BY_DESUGARING) return; | 1702 if (catch_type == Isolate::CAUGHT_BY_DESUGARING) return; |
| 1709 | 1703 |
| 1710 bool uncaught = (catch_type == Isolate::NOT_CAUGHT); | 1704 bool uncaught = catch_type == Isolate::NOT_CAUGHT; |
| 1711 if (promise->IsJSObject()) { | 1705 if (promise->IsJSObject()) { |
| 1712 Handle<JSObject> jspromise = Handle<JSObject>::cast(promise); | 1706 Handle<JSObject> jspromise = Handle<JSObject>::cast(promise); |
| 1713 // Mark the promise as already having triggered a message. | 1707 // Mark the promise as already having triggered a message. |
| 1714 Handle<Symbol> key = isolate_->factory()->promise_debug_marker_symbol(); | 1708 Handle<Symbol> key = isolate_->factory()->promise_debug_marker_symbol(); |
| 1715 JSObject::SetProperty(jspromise, key, key, STRICT).Assert(); | 1709 JSObject::SetProperty(jspromise, key, key, STRICT).Assert(); |
| 1716 // Check whether the promise reject is considered an uncaught exception. | 1710 // Check whether the promise reject is considered an uncaught exception. |
| 1717 Handle<Object> has_reject_handler; | 1711 uncaught = !isolate_->PromiseHasUserDefinedRejectHandler(jspromise); |
| 1718 ASSIGN_RETURN_ON_EXCEPTION_VALUE( | |
| 1719 isolate_, has_reject_handler, | |
| 1720 PromiseHasUserDefinedRejectHandler(jspromise), /* void */); | |
| 1721 uncaught = has_reject_handler->IsFalse(isolate_); | |
| 1722 } | 1712 } |
| 1723 // Bail out if exception breaks are not active | 1713 // Bail out if exception breaks are not active |
| 1724 if (uncaught) { | 1714 if (uncaught) { |
| 1725 // Uncaught exceptions are reported by either flags. | 1715 // Uncaught exceptions are reported by either flags. |
| 1726 if (!(break_on_uncaught_exception_ || break_on_exception_)) return; | 1716 if (!(break_on_uncaught_exception_ || break_on_exception_)) return; |
| 1727 } else { | 1717 } else { |
| 1728 // Caught exceptions are reported is activated. | 1718 // Caught exceptions are reported is activated. |
| 1729 if (!break_on_exception_) return; | 1719 if (!break_on_exception_) return; |
| 1730 } | 1720 } |
| 1731 | 1721 |
| (...skipping 835 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2567 } | 2557 } |
| 2568 | 2558 |
| 2569 | 2559 |
| 2570 void LockingCommandMessageQueue::Clear() { | 2560 void LockingCommandMessageQueue::Clear() { |
| 2571 base::LockGuard<base::Mutex> lock_guard(&mutex_); | 2561 base::LockGuard<base::Mutex> lock_guard(&mutex_); |
| 2572 queue_.Clear(); | 2562 queue_.Clear(); |
| 2573 } | 2563 } |
| 2574 | 2564 |
| 2575 } // namespace internal | 2565 } // namespace internal |
| 2576 } // namespace v8 | 2566 } // namespace v8 |
| OLD | NEW |