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

Unified Diff: src/js/harmony-async-await.js

Issue 2317383002: Async/await Promise dependency graph (Closed)
Patch Set: Only if debug is active 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | src/js/promise.js » ('j') | src/js/promise.js » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/js/harmony-async-await.js
diff --git a/src/js/harmony-async-await.js b/src/js/harmony-async-await.js
index 3cacaf19e6f3dbadc9aa3583e0b26ba6728b89c3..35860c2251fc539903f9b1d603508b17f877eeee 100644
--- a/src/js/harmony-async-await.js
+++ b/src/js/harmony-async-await.js
@@ -50,7 +50,7 @@ function PromiseCastResolved(value) {
}
}
-function AsyncFunctionAwait(generator, awaited, mark) {
+function AsyncFunctionAwait(generator, awaited, outerPromise) {
// Promise.resolve(awaited).then(
// value => AsyncFunctionNext(value),
// error => AsyncFunctionThrow(error)
@@ -62,28 +62,35 @@ function AsyncFunctionAwait(generator, awaited, mark) {
var onRejected =
(sentError) => %_Call(AsyncFunctionThrow, generator, sentError);
- if (mark && DEBUG_IS_ACTIVE && IsPromise(awaited)) {
- // Mark the reject handler callback such that it does not influence
- // catch prediction.
- SET_PRIVATE(onRejected, promiseAwaitHandlerSymbol, true);
+ if (!IS_UNDEFINED(outerPromise) && DEBUG_IS_ACTIVE && IsPromise(awaited)) {
+ // Mark the reject handler callback to continue recursing to outerPromise
+ SET_PRIVATE(onRejected, promiseAwaitHandlerSymbol, outerPromise);
}
// Just forwarding the exception, so no debugEvent for throwawayCapability
var throwawayCapability = NewPromiseCapability(GlobalPromise, false);
- return PerformPromiseThen(promise, onFulfilled, onRejected,
adamk 2016/09/08 22:07:31 AsyncFunctionAwait used to return something, but n
Dan Ehrenberg 2016/09/08 22:34:46 No one calls this; they call AsyncFunctionAwaitCau
+ PerformPromiseThen(promise, onFulfilled, onRejected,
throwawayCapability);
+
+ if (DEBUG_IS_ACTIVE) {
+ // Mark the dependency to outerPromise in case the throwaway Promise is
+ // found on the Promise stack
+ SET_PRIVATE(throwawayCapability.promise, promiseAwaitHandlerSymbol,
+ outerPromise);
+ }
}
-function AsyncFunctionAwaitUncaught(generator, awaited) {
- // TODO(littledan): Install a dependency edge from awaited to outerPromise
- return AsyncFunctionAwait(generator, awaited, true);
+function AsyncFunctionAwaitUncaught(generator, awaited, outerPromise) {
+ AsyncFunctionAwait(generator, awaited, outerPromise);
+ return outerPromise;
}
-function AsyncFunctionAwaitCaught(generator, awaited) {
+function AsyncFunctionAwaitCaught(generator, awaited, outerPromise) {
if (DEBUG_IS_ACTIVE && IsPromise(awaited)) {
SET_PRIVATE(awaited, promiseHandledHintSymbol, true);
}
- return AsyncFunctionAwait(generator, awaited, false);
+ AsyncFunctionAwait(generator, awaited, outerPromise);
+ return outerPromise;
}
// How the parser rejects promises from async/await desugaring
« no previous file with comments | « no previous file | src/js/promise.js » ('j') | src/js/promise.js » ('J')

Powered by Google App Engine
This is Rietveld 408576698