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

Unified Diff: src/js/promise.js

Issue 2567333002: [promises] port NewPromiseCapability to TF (Closed)
Patch Set: Make gcmole happy Created 3 years, 12 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/objects-visiting.cc ('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 08b4c3c2e07122205be4657ff9ff84b8ac75ee53..0e1e67739932e7b618d3cf361b865027d44b4ae7 100644
--- a/src/js/promise.js
+++ b/src/js/promise.js
@@ -79,36 +79,6 @@ function DoRejectPromise(promise, reason) {
%PromiseReject(promise, reason, true);
}
-// ES#sec-newpromisecapability
-// NewPromiseCapability ( C )
-function NewPromiseCapability(C, debugEvent) {
- if (C === GlobalPromise) {
- // Optimized case, avoid extra closure.
- var promise = %promise_internal_constructor(UNDEFINED);
- // TODO(gsathya): Remove container for callbacks when this is
- // moved to CPP/TF.
- var callbacks = %create_resolving_functions(promise, debugEvent);
- return {
- promise: promise,
- resolve: callbacks[kResolveCallback],
- reject: callbacks[kRejectCallback]
- };
- }
-
- var result = {promise: UNDEFINED, resolve: UNDEFINED, reject: UNDEFINED };
- result.promise = new C((resolve, reject) => {
- if (!IS_UNDEFINED(result.resolve) || !IS_UNDEFINED(result.reject))
- throw %make_type_error(kPromiseExecutorAlreadyInvoked);
- result.resolve = resolve;
- result.reject = reject;
- });
-
- if (!IS_CALLABLE(result.resolve) || !IS_CALLABLE(result.reject))
- throw %make_type_error(kPromiseNonCallable);
-
- return result;
-}
-
// ES#sec-promise.reject
// Promise.reject ( x )
function PromiseReject(r) {
@@ -123,7 +93,7 @@ function PromiseReject(r) {
%PromiseRejectEventFromStack(promise, r);
return promise;
} else {
- var promiseCapability = NewPromiseCapability(this, true);
+ var promiseCapability = %new_promise_capability(this, true);
%_Call(promiseCapability.reject, UNDEFINED, r);
return promiseCapability.promise;
}
@@ -147,7 +117,7 @@ function PromiseResolve(x) {
}
// debugEvent is not so meaningful here as it will be resolved
- var promiseCapability = NewPromiseCapability(this, true);
+ var promiseCapability = %new_promise_capability(this, true);
%_Call(promiseCapability.resolve, UNDEFINED, x);
return promiseCapability.promise;
}
@@ -161,7 +131,7 @@ function PromiseAll(iterable) {
// false debugEvent so that forwarding the rejection through all does not
// trigger redundant ExceptionEvents
- var deferred = NewPromiseCapability(this, false);
+ var deferred = %new_promise_capability(this, false);
var resolutions = new InternalArray();
var count;
@@ -225,7 +195,7 @@ function PromiseRace(iterable) {
// false debugEvent so that forwarding the rejection through race does not
// trigger redundant ExceptionEvents
- var deferred = NewPromiseCapability(this, false);
+ var deferred = %new_promise_capability(this, false);
// For catch prediction, don't treat the .then calls as handling it;
// instead, recurse outwards.
@@ -270,7 +240,6 @@ utils.InstallFunctions(GlobalPromise, DONT_ENUM, [
// TODO(gsathya): Remove this once we update the promise builtin.
"promise_internal_reject", RejectPromise,
"promise_debug_get_info", PromiseDebugGetInfo,
- "new_promise_capability", NewPromiseCapability,
"promise_id_resolve_handler", PromiseIdResolveHandler,
"promise_id_reject_handler", PromiseIdRejectHandler
]);
@@ -286,7 +255,6 @@ utils.InstallFunctions(extrasUtils, 0, [
utils.Export(function(to) {
to.PromiseCreate = PromiseCreate;
-
to.RejectPromise = RejectPromise;
});
« no previous file with comments | « src/heap/objects-visiting.cc ('k') | src/objects.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698