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

Unified Diff: src/js/promise.js

Issue 2143553002: [promises] Avoid creating resolving functions in Promise.resolve (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: update comment Created 4 years, 4 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 | « no previous file | no next file » | 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 e1f35fd17d0a2cba20c3ef4b69a2baf2ed76cdc4..466912d5eb6eaba98a8e4d9fe41c90ead55c4667 100644
--- a/src/js/promise.js
+++ b/src/js/promise.js
@@ -449,6 +449,13 @@ function PromiseResolve(x) {
}
if (IsPromise(x) && x.constructor === this) return x;
+ // Avoid creating resolving functions.
+ if (this === GlobalPromise) {
+ var promise = PromiseInit(new GlobalPromise(promiseRawSymbol));
+ var resolveResult = ResolvePromise(promise, x);
+ return promise;
+ }
+
var promiseCapability = NewPromiseCapability(this);
var resolveResult = %_Call(promiseCapability.resolve, UNDEFINED, x);
return promiseCapability.promise;
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698