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

Unified Diff: src/js/promise.js

Issue 2541283002: [promises] Port ResolvePromise to TF (Closed)
Patch Set: add comments Created 4 years 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
Index: src/js/promise.js
diff --git a/src/js/promise.js b/src/js/promise.js
index fe945b535d49efa3380060be9b566a1235d52cf8..f0c33b5e5fbb19c51fe8320700daa77e31492602 100644
--- a/src/js/promise.js
+++ b/src/js/promise.js
@@ -118,56 +118,7 @@ function PromiseCreate() {
// ES#sec-promise-resolve-functions
// Promise Resolve Functions, steps 6-13
function ResolvePromise(promise, resolution) {
- if (resolution === promise) {
- var exception = %make_type_error(kPromiseCyclic, resolution);
- %PromiseReject(promise, exception, true);
- return;
- }
- if (IS_RECEIVER(resolution)) {
- // 25.4.1.3.2 steps 8-12
- try {
- var then = resolution.then;
- } catch (e) {
- %PromiseReject(promise, e, true);
- return;
- }
-
- // Resolution is a native promise and if it's already resolved or
- // rejected, shortcircuit the resolution procedure by directly
- // reusing the value from the promise.
- if (%is_promise(resolution) && then === PromiseThen) {
- var thenableState = %PromiseStatus(resolution);
- if (thenableState === kFulfilled) {
- // This goes inside the if-else to save one symbol lookup in
- // the slow path.
- var thenableValue = %PromiseResult(resolution);
- %PromiseFulfill(promise, kFulfilled, thenableValue);
- SET_PRIVATE(promise, promiseHasHandlerSymbol, true);
- return;
- } else if (thenableState === kRejected) {
- var thenableValue = %PromiseResult(resolution);
- if (!HAS_DEFINED_PRIVATE(resolution, promiseHasHandlerSymbol)) {
- // Promise has already been rejected, but had no handler.
- // Revoke previously triggered reject event.
- %PromiseRevokeReject(resolution);
- }
- // Don't cause a debug event as this case is forwarding a rejection
- %PromiseReject(promise, thenableValue, false);
- SET_PRIVATE(resolution, promiseHasHandlerSymbol, true);
- return;
- }
- }
-
- if (IS_CALLABLE(then)) {
- if (DEBUG_IS_ACTIVE && %is_promise(resolution)) {
- // Mark the dependency of the new promise on the resolution
- SET_PRIVATE(resolution, promiseHandledBySymbol, promise);
- }
- %EnqueuePromiseResolveThenableJob(promise, resolution, then);
- return;
- }
- }
- %PromiseFulfill(promise, kFulfilled, resolution);
+ %resolve_promise(promise, resolution);
jgruber 2016/12/05 09:25:17 Can we replace calls to ResolvePromise by %resolve
gsathya 2016/12/05 16:03:05 Nope. We use this in async-await and v8-extras
caitp 2016/12/05 16:22:51 Couldn't we just export %resolve_promise from the
}
// Only used by async-await.js
@@ -451,9 +402,7 @@ utils.InstallFunctions(GlobalPromise, DONT_ENUM, [
utils.InstallGetter(GlobalPromise, speciesSymbol, PromiseSpecies);
-utils.InstallFunctions(GlobalPromise.prototype, DONT_ENUM, [
- "catch", PromiseCatch
-]);
+%SetCode(GlobalPromise.prototype.catch, PromiseCatch);
jgruber 2016/12/05 09:25:17 This and below + corresponding changes in bootstra
gsathya 2016/12/05 16:03:05 I need to install an empty .catch in bootstrapper
jgruber 2016/12/07 12:59:38 Acknowledged.
%InstallToContext([
"promise_catch", PromiseCatch,
@@ -463,7 +412,6 @@ utils.InstallFunctions(GlobalPromise.prototype, DONT_ENUM, [
// TODO(gsathya): Remove this once we update the promise builtin.
"promise_internal_reject", RejectPromise,
"promise_resolve", ResolvePromise,
- "promise_then", PromiseThen,
"promise_handle", PromiseHandle,
"promise_debug_get_info", PromiseDebugGetInfo,
"new_promise_capability", NewPromiseCapability,
« src/builtins/builtins-promise.cc ('K') | « src/heap-symbols.h ('k') | src/promise-utils.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698