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

Unified Diff: src/runtime/runtime-internal.cc

Issue 2244003003: Change which ExceptionEvents are triggered by Promises (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fixed typos Created 4 years, 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/runtime/runtime.h ('k') | test/mjsunit/es6/debug-promises/promise-all-uncaught.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/runtime/runtime-internal.cc
diff --git a/src/runtime/runtime-internal.cc b/src/runtime/runtime-internal.cc
index 3de0f16b1e63233ca72bdb4ab8fa311e3d9653b5..6a105024baeb586cc3af13b5a38d80e1b08d5493 100644
--- a/src/runtime/runtime-internal.cc
+++ b/src/runtime/runtime-internal.cc
@@ -272,23 +272,51 @@ RUNTIME_FUNCTION(Runtime_ThrowApplyNonFunction) {
isolate, NewTypeError(MessageTemplate::kApplyNonFunction, object, type));
}
+namespace {
-RUNTIME_FUNCTION(Runtime_PromiseRejectEvent) {
- DCHECK(args.length() == 3);
- HandleScope scope(isolate);
- CONVERT_ARG_HANDLE_CHECKED(JSObject, promise, 0);
- CONVERT_ARG_HANDLE_CHECKED(Object, value, 1);
- CONVERT_BOOLEAN_ARG_CHECKED(debug_event, 2);
- if (debug_event) isolate->debug()->OnPromiseReject(promise, value);
+void PromiseRejectEvent(Isolate* isolate, Handle<JSObject> promise,
+ Handle<JSObject> rejected_promise, Handle<Object> value,
+ bool debug_event) {
+ if (isolate->debug()->is_active() && debug_event) {
+ isolate->debug()->OnPromiseReject(rejected_promise, value);
+ }
Handle<Symbol> key = isolate->factory()->promise_has_handler_symbol();
// Do not report if we actually have a handler.
if (JSReceiver::GetDataProperty(promise, key)->IsUndefined(isolate)) {
isolate->ReportPromiseReject(promise, value,
v8::kPromiseRejectWithNoHandler);
}
+}
+
+} // namespace
+
+RUNTIME_FUNCTION(Runtime_PromiseRejectEvent) {
+ DCHECK(args.length() == 3);
+ HandleScope scope(isolate);
+ CONVERT_ARG_HANDLE_CHECKED(JSObject, promise, 0);
+ CONVERT_ARG_HANDLE_CHECKED(Object, value, 1);
+ CONVERT_BOOLEAN_ARG_CHECKED(debug_event, 2);
+
+ PromiseRejectEvent(isolate, promise, promise, value, debug_event);
return isolate->heap()->undefined_value();
}
+RUNTIME_FUNCTION(Runtime_PromiseRejectEventFromStack) {
+ DCHECK(args.length() == 2);
+ HandleScope scope(isolate);
+ CONVERT_ARG_HANDLE_CHECKED(JSObject, promise, 0);
+ CONVERT_ARG_HANDLE_CHECKED(Object, value, 1);
+
+ Handle<JSObject> rejected_promise = promise;
+ if (isolate->debug()->is_active()) {
+ Handle<Object> promise_on_stack = isolate->GetPromiseOnStackOnThrow();
+ if (promise_on_stack->IsJSObject()) {
+ rejected_promise = Handle<JSObject>::cast(promise_on_stack);
+ }
+ }
+ PromiseRejectEvent(isolate, promise, rejected_promise, value, true);
+ return isolate->heap()->undefined_value();
+}
RUNTIME_FUNCTION(Runtime_PromiseRevokeReject) {
DCHECK(args.length() == 1);
« no previous file with comments | « src/runtime/runtime.h ('k') | test/mjsunit/es6/debug-promises/promise-all-uncaught.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698