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

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

Issue 2338273007: async/await: Don't trigger uncaught rejection handlers on throwaway Promises (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 unified diff | Download patch
« no previous file with comments | « no previous file | src/js/prologue.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
(...skipping 18 matching lines...) Expand all
29 NewPromiseCapability = from.NewPromiseCapability; 29 NewPromiseCapability = from.NewPromiseCapability;
30 PromiseCreate = from.PromiseCreate; 30 PromiseCreate = from.PromiseCreate;
31 PerformPromiseThen = from.PerformPromiseThen; 31 PerformPromiseThen = from.PerformPromiseThen;
32 RejectPromise = from.RejectPromise; 32 RejectPromise = from.RejectPromise;
33 ResolvePromise = from.ResolvePromise; 33 ResolvePromise = from.ResolvePromise;
34 }); 34 });
35 35
36 var promiseAwaitHandlerSymbol = utils.ImportNow("promise_await_handler_symbol"); 36 var promiseAwaitHandlerSymbol = utils.ImportNow("promise_await_handler_symbol");
37 var promiseHandledHintSymbol = 37 var promiseHandledHintSymbol =
38 utils.ImportNow("promise_handled_hint_symbol"); 38 utils.ImportNow("promise_handled_hint_symbol");
39 var promiseHasHandlerSymbol =
40 utils.ImportNow("promise_has_handler_symbol");
39 41
40 // ------------------------------------------------------------------- 42 // -------------------------------------------------------------------
41 43
42 function PromiseCastResolved(value) { 44 function PromiseCastResolved(value) {
43 if (IsPromise(value)) { 45 if (IsPromise(value)) {
44 return value; 46 return value;
45 } else { 47 } else {
46 var promise = PromiseCreate(); 48 var promise = PromiseCreate();
47 ResolvePromise(promise, value); 49 ResolvePromise(promise, value);
48 return promise; 50 return promise;
(...skipping 21 matching lines...) Expand all
70 (sentError) => %_Call(AsyncFunctionThrow, generator, sentError); 72 (sentError) => %_Call(AsyncFunctionThrow, generator, sentError);
71 73
72 if (mark && DEBUG_IS_ACTIVE && IsPromise(awaited)) { 74 if (mark && DEBUG_IS_ACTIVE && IsPromise(awaited)) {
73 // Mark the reject handler callback such that it does not influence 75 // Mark the reject handler callback such that it does not influence
74 // catch prediction. 76 // catch prediction.
75 SET_PRIVATE(onRejected, promiseAwaitHandlerSymbol, true); 77 SET_PRIVATE(onRejected, promiseAwaitHandlerSymbol, true);
76 } 78 }
77 79
78 // Just forwarding the exception, so no debugEvent for throwawayCapability 80 // Just forwarding the exception, so no debugEvent for throwawayCapability
79 var throwawayCapability = NewPromiseCapability(GlobalPromise, false); 81 var throwawayCapability = NewPromiseCapability(GlobalPromise, false);
82
83 // The Promise will be thrown away and not handled, but it shouldn't trigger
84 // unhandled reject events as its work is done
85 SET_PRIVATE(throwawayCapability.promise, promiseHasHandlerSymbol, true);
86
80 return PerformPromiseThen(promise, onFulfilled, onRejected, 87 return PerformPromiseThen(promise, onFulfilled, onRejected,
81 throwawayCapability); 88 throwawayCapability);
82 } 89 }
83 90
84 // Called by the parser from the desugaring of 'await' when catch 91 // Called by the parser from the desugaring of 'await' when catch
85 // prediction indicates no locally surrounding catch block 92 // prediction indicates no locally surrounding catch block
86 function AsyncFunctionAwaitUncaught(generator, awaited) { 93 function AsyncFunctionAwaitUncaught(generator, awaited) {
87 // TODO(littledan): Install a dependency edge from awaited to outerPromise 94 // TODO(littledan): Install a dependency edge from awaited to outerPromise
88 return AsyncFunctionAwait(generator, awaited, true); 95 return AsyncFunctionAwait(generator, awaited, true);
89 } 96 }
(...skipping 12 matching lines...) Expand all
102 return RejectPromise(promise, reason, false); 109 return RejectPromise(promise, reason, false);
103 } 110 }
104 111
105 %InstallToContext([ 112 %InstallToContext([
106 "async_function_await_caught", AsyncFunctionAwaitCaught, 113 "async_function_await_caught", AsyncFunctionAwaitCaught,
107 "async_function_await_uncaught", AsyncFunctionAwaitUncaught, 114 "async_function_await_uncaught", AsyncFunctionAwaitUncaught,
108 "reject_promise_no_debug_event", RejectPromiseNoDebugEvent, 115 "reject_promise_no_debug_event", RejectPromiseNoDebugEvent,
109 ]); 116 ]);
110 117
111 }) 118 })
OLDNEW
« no previous file with comments | « no previous file | src/js/prologue.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698