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

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

Issue 2578923002: [inspector] async stacks for Promise.then calls... (Closed)
Patch Set: async-stacks Created 3 years, 11 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
Index: src/runtime/runtime-promise.cc
diff --git a/src/runtime/runtime-promise.cc b/src/runtime/runtime-promise.cc
index ace8db8b89bb288cdd7f910b9d65355665f3a507..f923d4f56f112e1d3fd2dfce211058244044866c 100644
--- a/src/runtime/runtime-promise.cc
+++ b/src/runtime/runtime-promise.cc
@@ -43,6 +43,9 @@ RUNTIME_FUNCTION(Runtime_PromiseRejectEventFromStack) {
// undefined, which will be interpreted by PromiseRejectEvent
// as being a caught exception event.
rejected_promise = isolate->GetPromiseOnStackOnThrow();
+ isolate->debug()->OnAsyncTaskEvent(
+ debug::kDebugEnqueueRecurring,
+ isolate->debug()->NextAsyncTaskId(promise), kDebugPromiseReject);
}
PromiseRejectEvent(isolate, promise, rejected_promise, value, true);
return isolate->heap()->undefined_value();
@@ -108,20 +111,17 @@ bool GetDebugIdForAsyncFunction(Isolate* isolate,
}
void SetDebugInfo(Isolate* isolate, Handle<PromiseReactionJobInfo> info,
gsathya 2017/01/09 19:24:35 info->promise() == promise right? can we just reus
kozy 2017/01/10 00:11:38 Done.
- int status) {
+ Handle<JSPromise> promise, int status) {
int id;
PromiseDebugActionName name;
if (GetDebugIdForAsyncFunction(isolate, info, &id)) {
name = kDebugAsyncFunction;
} else {
- id = isolate->GetNextDebugMicrotaskId();
-
+ id = isolate->debug()->NextAsyncTaskId(promise);
DCHECK(status != v8::Promise::kPending);
name = status == v8::Promise::kFulfilled ? kDebugPromiseResolve
: kDebugPromiseReject;
-
- isolate->debug()->OnAsyncTaskEvent(kDebugEnqueue, id, name);
}
info->set_debug_id(id);
@@ -130,9 +130,9 @@ void SetDebugInfo(Isolate* isolate, Handle<PromiseReactionJobInfo> info,
void EnqueuePromiseReactionJob(Isolate* isolate,
Handle<PromiseReactionJobInfo> info,
- int status) {
+ Handle<JSPromise> promise, int status) {
if (isolate->debug()->is_active()) {
- SetDebugInfo(isolate, info, status);
+ SetDebugInfo(isolate, info, promise, status);
}
isolate->EnqueueMicrotask(info);
@@ -151,6 +151,13 @@ void PromiseSet(Isolate* isolate, Handle<JSPromise> promise, int status,
void PromiseFulfill(Isolate* isolate, Handle<JSPromise> promise, int status,
Handle<Object> value) {
+ if (isolate->debug()->is_active()) {
+ isolate->debug()->OnAsyncTaskEvent(
+ debug::kDebugEnqueueRecurring,
+ isolate->debug()->NextAsyncTaskId(promise),
+ status == v8::Promise::kFulfilled ? kDebugPromiseResolve
+ : kDebugPromiseReject);
+ }
// Check if there are any callbacks.
if (!promise->deferred_promise()->IsUndefined(isolate)) {
Handle<Object> tasks((status == v8::Promise::kFulfilled)
@@ -163,7 +170,7 @@ void PromiseFulfill(Isolate* isolate, Handle<JSPromise> promise, int status,
handle(promise->deferred_on_resolve(), isolate),
handle(promise->deferred_on_reject(), isolate),
isolate->native_context());
- EnqueuePromiseReactionJob(isolate, info, status);
+ EnqueuePromiseReactionJob(isolate, info, promise, status);
}
PromiseSet(isolate, promise, status, value);
@@ -186,10 +193,11 @@ RUNTIME_FUNCTION(Runtime_PromiseReject) {
RUNTIME_FUNCTION(Runtime_EnqueuePromiseReactionJob) {
HandleScope scope(isolate);
- DCHECK_EQ(2, args.length());
+ DCHECK_EQ(3, args.length());
CONVERT_ARG_HANDLE_CHECKED(PromiseReactionJobInfo, info, 0);
- CONVERT_SMI_ARG_CHECKED(status, 1);
- EnqueuePromiseReactionJob(isolate, info, status);
+ CONVERT_ARG_HANDLE_CHECKED(JSPromise, promise, 1);
+ CONVERT_SMI_ARG_CHECKED(status, 2);
+ EnqueuePromiseReactionJob(isolate, info, promise, status);
return isolate->heap()->undefined_value();
}

Powered by Google App Engine
This is Rietveld 408576698