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

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

Issue 2351953002: Revert of Async/await Promise dependency graph (Closed)
Patch Set: 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 | « src/heap-symbols.h ('k') | src/js/prologue.js » ('j') | no next file with comments »
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 bd754495b7f7cde6e28cbf7e4b52092889dfa92f..dc82249e9fc49595d6a53169fe2ca8b5eca62b51 100644
--- a/src/js/harmony-async-await.js
+++ b/src/js/harmony-async-await.js
@@ -33,10 +33,7 @@
ResolvePromise = from.ResolvePromise;
});
-var promiseHandledBySymbol =
- utils.ImportNow("promise_handled_by_symbol");
-var promiseForwardingHandlerSymbol =
- utils.ImportNow("promise_forwarding_handler_symbol");
+var promiseAwaitHandlerSymbol = utils.ImportNow("promise_await_handler_symbol");
var promiseHandledHintSymbol =
utils.ImportNow("promise_handled_hint_symbol");
var promiseHasHandlerSymbol =
@@ -59,11 +56,10 @@
// Shared logic for the core of await. The parser desugars
// await awaited
// into
-// yield AsyncFunctionAwait{Caught,Uncaught}(.generator, awaited, .promise)
+// yield AsyncFunctionAwait{Caught,Uncaught}(.generator, awaited)
// The 'awaited' parameter is the value; the generator stands in
-// for the asyncContext, and .promise is the larger promise under
-// construction by the enclosing async function.
-function AsyncFunctionAwait(generator, awaited, outerPromise) {
+// for the asyncContext, and mark is metadata for debugging
+function AsyncFunctionAwait(generator, awaited, mark) {
// Promise.resolve(awaited).then(
// value => AsyncFunctionNext(value),
// error => AsyncFunctionThrow(error)
@@ -87,6 +83,12 @@
return;
}
+ 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);
+ }
+
// Just forwarding the exception, so no debugEvent for throwawayCapability
var throwawayCapability = NewPromiseCapability(GlobalPromise, false);
@@ -94,38 +96,24 @@
// unhandled reject events as its work is done
SET_PRIVATE(throwawayCapability.promise, promiseHasHandlerSymbol, true);
- PerformPromiseThen(promise, onFulfilled, onRejected, throwawayCapability);
-
- if (DEBUG_IS_ACTIVE && !IS_UNDEFINED(outerPromise)) {
- if (IsPromise(awaited)) {
- // Mark the reject handler callback to be a forwarding edge, rather
- // than a meaningful catch handler
- SET_PRIVATE(onRejected, promiseForwardingHandlerSymbol, true);
- }
-
- // Mark the dependency to outerPromise in case the throwaway Promise is
- // found on the Promise stack
- SET_PRIVATE(throwawayCapability.promise, promiseHandledBySymbol,
- outerPromise);
- }
+ return PerformPromiseThen(promise, onFulfilled, onRejected,
+ throwawayCapability);
}
// Called by the parser from the desugaring of 'await' when catch
// prediction indicates no locally surrounding catch block
-function AsyncFunctionAwaitUncaught(generator, awaited, outerPromise) {
- AsyncFunctionAwait(generator, awaited, outerPromise);
+function AsyncFunctionAwaitUncaught(generator, awaited) {
+ // TODO(littledan): Install a dependency edge from awaited to outerPromise
+ return AsyncFunctionAwait(generator, awaited, true);
}
// Called by the parser from the desugaring of 'await' when catch
// prediction indicates that there is a locally surrounding catch block
-function AsyncFunctionAwaitCaught(generator, awaited, outerPromise) {
+function AsyncFunctionAwaitCaught(generator, awaited) {
if (DEBUG_IS_ACTIVE && IsPromise(awaited)) {
SET_PRIVATE(awaited, promiseHandledHintSymbol, true);
}
- // Pass undefined for the outer Promise to not waste time setting up
- // or following the dependency chain when this Promise is already marked
- // as handled
- AsyncFunctionAwait(generator, awaited, UNDEFINED);
+ return AsyncFunctionAwait(generator, awaited, false);
}
// How the parser rejects promises from async/await desugaring
« no previous file with comments | « src/heap-symbols.h ('k') | src/js/prologue.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698