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

Unified Diff: src/js/promise.js

Issue 2276243002: Mark await expressions as caught or uncaught (Closed)
Patch Set: Revert "Tests for caught exception" 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/js/prologue.js ('k') | src/objects.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/js/promise.js
diff --git a/src/js/promise.js b/src/js/promise.js
index c057238af696d78416a6198b3c0f68dabb8c31c1..e020028c244f8f0d45bf429316ae916757012de5 100644
--- a/src/js/promise.js
+++ b/src/js/promise.js
@@ -12,6 +12,8 @@
// Imports
var InternalArray = utils.InternalArray;
+var promiseAwaitHandlerSymbol =
+ utils.ImportNow("promise_await_handler_symbol");
var promiseCombinedDeferredSymbol =
utils.ImportNow("promise_combined_deferred_symbol");
var promiseHasHandlerSymbol =
@@ -22,6 +24,8 @@ var promiseFulfillReactionsSymbol =
utils.ImportNow("promise_fulfill_reactions_symbol");
var promiseDeferredReactionsSymbol =
utils.ImportNow("promise_deferred_reactions_symbol");
+var promiseHandledHintSymbol =
+ utils.ImportNow("promise_handled_hint_symbol");
var promiseRawSymbol = utils.ImportNow("promise_raw_symbol");
var promiseStateSymbol = utils.ImportNow("promise_state_symbol");
var promiseResultSymbol = utils.ImportNow("promise_result_symbol");
@@ -381,16 +385,6 @@ function PromiseReject(r) {
}
}
-function PromiseCastResolved(value) {
- if (IsPromise(value)) {
- return value;
- } else {
- var promise = PromiseInit(new GlobalPromise(promiseRawSymbol));
- var resolveResult = ResolvePromise(promise, value);
- return promise;
- }
-}
-
function PerformPromiseThen(promise, onResolve, onReject, resultCapability) {
if (!IS_CALLABLE(onResolve)) onResolve = PromiseIdResolveHandler;
if (!IS_CALLABLE(onReject)) onReject = PromiseIdRejectHandler;
@@ -543,6 +537,9 @@ function PromiseRace(iterable) {
// Utility for debugger
function PromiseHasUserDefinedRejectHandlerCheck(handler, deferred) {
+ // If this handler was installed by async/await, it does not indicate
+ // that there is a user-defined reject handler.
+ if (GET_PRIVATE(handler, promiseAwaitHandlerSymbol)) return false;
if (handler !== PromiseIdRejectHandler) {
var combinedDeferred = GET_PRIVATE(handler, promiseCombinedDeferredSymbol);
if (IS_UNDEFINED(combinedDeferred)) return true;
@@ -556,16 +553,22 @@ function PromiseHasUserDefinedRejectHandlerCheck(handler, deferred) {
}
function PromiseHasUserDefinedRejectHandlerRecursive(promise) {
+ // If this promise was marked as being handled by a catch block
+ // in an async function, then it has a user-defined reject handler.
+ if (GET_PRIVATE(promise, promiseHandledHintSymbol)) return true;
+
var queue = GET_PRIVATE(promise, promiseRejectReactionsSymbol);
var deferreds = GET_PRIVATE(promise, promiseDeferredReactionsSymbol);
+
if (IS_UNDEFINED(queue)) return false;
+
if (!IS_ARRAY(queue)) {
return PromiseHasUserDefinedRejectHandlerCheck(queue, deferreds);
- } else {
- for (var i = 0; i < queue.length; i += 2) {
- if (PromiseHasUserDefinedRejectHandlerCheck(queue[i], queue[i + 1])) {
- return true;
- }
+ }
+
+ for (var i = 0; i < queue.length; i += 2) {
+ if (PromiseHasUserDefinedRejectHandlerCheck(queue[i], queue[i + 1])) {
+ return true;
}
}
return false;
@@ -623,12 +626,14 @@ utils.InstallFunctions(extrasUtils, 0, [
]);
utils.Export(function(to) {
- to.PromiseCastResolved = PromiseCastResolved;
+ to.IsPromise = IsPromise;
+ to.PromiseCreate = PromiseCreate;
to.PromiseThen = PromiseThen;
to.GlobalPromise = GlobalPromise;
to.NewPromiseCapability = NewPromiseCapability;
to.PerformPromiseThen = PerformPromiseThen;
+ to.ResolvePromise = ResolvePromise;
to.RejectPromise = RejectPromise;
});
« no previous file with comments | « src/js/prologue.js ('k') | src/objects.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698