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); |