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

Side by Side Diff: src/debug/debug.cc

Issue 2276243002: Mark await expressions as caught or uncaught (Closed)
Patch Set: Format Created 4 years, 3 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
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/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
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 ||
1705 catch_type == Isolate::CAUGHT_BY_ASYNC_AWAIT);
jgruber 2016/09/08 10:19:58 Could you add a comment about why CAUGHT_BY_ASYNC_
1711 if (promise->IsJSObject()) { 1706 if (promise->IsJSObject()) {
1712 Handle<JSObject> jspromise = Handle<JSObject>::cast(promise); 1707 Handle<JSObject> jspromise = Handle<JSObject>::cast(promise);
1713 // Mark the promise as already having triggered a message. 1708 // Mark the promise as already having triggered a message.
1714 Handle<Symbol> key = isolate_->factory()->promise_debug_marker_symbol(); 1709 Handle<Symbol> key = isolate_->factory()->promise_debug_marker_symbol();
1715 JSObject::SetProperty(jspromise, key, key, STRICT).Assert(); 1710 JSObject::SetProperty(jspromise, key, key, STRICT).Assert();
1716 // Check whether the promise reject is considered an uncaught exception. 1711 // Check whether the promise reject is considered an uncaught exception.
1717 Handle<Object> has_reject_handler; 1712 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 } 1713 }
1723 // Bail out if exception breaks are not active 1714 // Bail out if exception breaks are not active
1724 if (uncaught) { 1715 if (uncaught) {
1725 // Uncaught exceptions are reported by either flags. 1716 // Uncaught exceptions are reported by either flags.
1726 if (!(break_on_uncaught_exception_ || break_on_exception_)) return; 1717 if (!(break_on_uncaught_exception_ || break_on_exception_)) return;
1727 } else { 1718 } else {
1728 // Caught exceptions are reported is activated. 1719 // Caught exceptions are reported is activated.
1729 if (!break_on_exception_) return; 1720 if (!break_on_exception_) return;
1730 } 1721 }
1731 1722
(...skipping 835 matching lines...) Expand 10 before | Expand all | Expand 10 after
2567 } 2558 }
2568 2559
2569 2560
2570 void LockingCommandMessageQueue::Clear() { 2561 void LockingCommandMessageQueue::Clear() {
2571 base::LockGuard<base::Mutex> lock_guard(&mutex_); 2562 base::LockGuard<base::Mutex> lock_guard(&mutex_);
2572 queue_.Clear(); 2563 queue_.Clear();
2573 } 2564 }
2574 2565
2575 } // namespace internal 2566 } // namespace internal
2576 } // namespace v8 2567 } // namespace v8
OLDNEW
« no previous file with comments | « src/debug/debug.h ('k') | src/heap-symbols.h » ('j') | src/js/harmony-async-await.js » ('J')

Powered by Google App Engine
This is Rietveld 408576698