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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 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 431 matching lines...) Expand 10 before | Expand all | Expand 10 after
442 // Combinators. 442 // Combinators.
443 443
444 // ES#sec-promise.resolve 444 // ES#sec-promise.resolve
445 // Promise.resolve ( x ) 445 // Promise.resolve ( x )
446 function PromiseResolve(x) { 446 function PromiseResolve(x) {
447 if (!IS_RECEIVER(this)) { 447 if (!IS_RECEIVER(this)) {
448 throw MakeTypeError(kCalledOnNonObject, PromiseResolve); 448 throw MakeTypeError(kCalledOnNonObject, PromiseResolve);
449 } 449 }
450 if (IsPromise(x) && x.constructor === this) return x; 450 if (IsPromise(x) && x.constructor === this) return x;
451 451
452 // Avoid creating resolving functions.
453 if (this === GlobalPromise) {
454 var promise = PromiseInit(new GlobalPromise(promiseRawSymbol));
455 var resolveResult = ResolvePromise(promise, x);
456 return promise;
457 }
458
452 var promiseCapability = NewPromiseCapability(this); 459 var promiseCapability = NewPromiseCapability(this);
453 var resolveResult = %_Call(promiseCapability.resolve, UNDEFINED, x); 460 var resolveResult = %_Call(promiseCapability.resolve, UNDEFINED, x);
454 return promiseCapability.promise; 461 return promiseCapability.promise;
455 } 462 }
456 463
457 // ES#sec-promise.all 464 // ES#sec-promise.all
458 // Promise.all ( iterable ) 465 // Promise.all ( iterable )
459 function PromiseAll(iterable) { 466 function PromiseAll(iterable) {
460 if (!IS_RECEIVER(this)) { 467 if (!IS_RECEIVER(this)) {
461 throw MakeTypeError(kCalledOnNonObject, "Promise.all"); 468 throw MakeTypeError(kCalledOnNonObject, "Promise.all");
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
618 to.PromiseChain = PromiseChain; 625 to.PromiseChain = PromiseChain;
619 to.PromiseDefer = PromiseDefer; 626 to.PromiseDefer = PromiseDefer;
620 to.PromiseAccept = PromiseAccept; 627 to.PromiseAccept = PromiseAccept;
621 628
622 to.PromiseCreateRejected = PromiseCreateRejected; 629 to.PromiseCreateRejected = PromiseCreateRejected;
623 to.PromiseCreateResolved = PromiseCreateResolved; 630 to.PromiseCreateResolved = PromiseCreateResolved;
624 to.PromiseThen = PromiseThen; 631 to.PromiseThen = PromiseThen;
625 }); 632 });
626 633
627 }) 634 })
OLDNEW
« 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