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

Side by Side Diff: src/js/async-await.js

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 unified diff | Download patch
OLDNEW
1 // Copyright 2016 the V8 project authors. All rights reserved. 1 // Copyright 2016 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 (function(global, utils, extrasUtils) { 5 (function(global, utils, extrasUtils) {
6 6
7 "use strict"; 7 "use strict";
8 8
9 %CheckIsBootstrapping(); 9 %CheckIsBootstrapping();
10 10
11 // ------------------------------------------------------------------- 11 // -------------------------------------------------------------------
12 // Imports 12 // Imports
13 13
14 var AsyncFunctionNext; 14 var AsyncFunctionNext;
15 var AsyncFunctionThrow; 15 var AsyncFunctionThrow;
16 var PromiseCreate; 16 var PromiseCreate;
17 var PromiseNextMicrotaskID;
18 var RejectPromise; 17 var RejectPromise;
19 18
20 utils.Import(function(from) { 19 utils.Import(function(from) {
21 AsyncFunctionNext = from.AsyncFunctionNext; 20 AsyncFunctionNext = from.AsyncFunctionNext;
22 AsyncFunctionThrow = from.AsyncFunctionThrow; 21 AsyncFunctionThrow = from.AsyncFunctionThrow;
23 PromiseCreate = from.PromiseCreate; 22 PromiseCreate = from.PromiseCreate;
24 RejectPromise = from.RejectPromise; 23 RejectPromise = from.RejectPromise;
25 }); 24 });
26 25
27 var promiseAsyncStackIDSymbol =
28 utils.ImportNow("promise_async_stack_id_symbol");
29 var promiseHandledBySymbol = 26 var promiseHandledBySymbol =
30 utils.ImportNow("promise_handled_by_symbol"); 27 utils.ImportNow("promise_handled_by_symbol");
31 var promiseForwardingHandlerSymbol = 28 var promiseForwardingHandlerSymbol =
32 utils.ImportNow("promise_forwarding_handler_symbol"); 29 utils.ImportNow("promise_forwarding_handler_symbol");
33 30
34 // ------------------------------------------------------------------- 31 // -------------------------------------------------------------------
35 32
36 function PromiseCastResolved(value) { 33 function PromiseCastResolved(value) {
37 // TODO(caitp): This is non spec compliant. See v8:5694. 34 // TODO(caitp): This is non spec compliant. See v8:5694.
38 if (%is_promise(value)) { 35 if (%is_promise(value)) {
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 function RejectPromiseNoDebugEvent(promise, reason) { 114 function RejectPromiseNoDebugEvent(promise, reason) {
118 return RejectPromise(promise, reason, false); 115 return RejectPromise(promise, reason, false);
119 } 116 }
120 117
121 function AsyncFunctionPromiseCreate() { 118 function AsyncFunctionPromiseCreate() {
122 var promise = PromiseCreate(); 119 var promise = PromiseCreate();
123 if (DEBUG_IS_ACTIVE) { 120 if (DEBUG_IS_ACTIVE) {
124 // Push the Promise under construction in an async function on 121 // Push the Promise under construction in an async function on
125 // the catch prediction stack to handle exceptions thrown before 122 // the catch prediction stack to handle exceptions thrown before
126 // the first await. 123 // the first await.
127 %DebugPushPromise(promise);
128 // Assign ID and create a recurring task to save stack for future 124 // Assign ID and create a recurring task to save stack for future
129 // resumptions from await. 125 // resumptions from await.
130 var id = %DebugNextMicrotaskId(); 126 %DebugAsyncFunctionPromiseCreated(promise);
131 SET_PRIVATE(promise, promiseAsyncStackIDSymbol, id);
132 %DebugAsyncTaskEvent(kEnqueueRecurring, id, kAsyncFunction);
133 } 127 }
134 return promise; 128 return promise;
135 } 129 }
136 130
137 function AsyncFunctionPromiseRelease(promise) { 131 function AsyncFunctionPromiseRelease(promise) {
138 if (DEBUG_IS_ACTIVE) { 132 if (DEBUG_IS_ACTIVE) {
139 // Cancel
140 var id = GET_PRIVATE(promise, promiseAsyncStackIDSymbol);
141
142 // Don't send invalid events when catch prediction is turned on in
143 // the middle of some async operation.
144 if (!IS_UNDEFINED(id)) {
145 %DebugAsyncTaskEvent(kCancel, id, kAsyncFunction);
146 }
147 // Pop the Promise under construction in an async function on 133 // Pop the Promise under construction in an async function on
148 // from catch prediction stack. 134 // from catch prediction stack.
149 %DebugPopPromise(); 135 %DebugPopPromise();
150 } 136 }
151 } 137 }
152 138
153 %InstallToContext([ 139 %InstallToContext([
154 "async_function_await_caught", AsyncFunctionAwaitCaught, 140 "async_function_await_caught", AsyncFunctionAwaitCaught,
155 "async_function_await_uncaught", AsyncFunctionAwaitUncaught, 141 "async_function_await_uncaught", AsyncFunctionAwaitUncaught,
156 "reject_promise_no_debug_event", RejectPromiseNoDebugEvent, 142 "reject_promise_no_debug_event", RejectPromiseNoDebugEvent,
157 "async_function_promise_create", AsyncFunctionPromiseCreate, 143 "async_function_promise_create", AsyncFunctionPromiseCreate,
158 "async_function_promise_release", AsyncFunctionPromiseRelease, 144 "async_function_promise_release", AsyncFunctionPromiseRelease,
159 ]); 145 ]);
160 146
161 }) 147 })
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698