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

Side by Side Diff: src/js/promise.js

Issue 2267033002: Remove --promise-extra flag (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fix syntax for skip 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 | « src/js/prologue.js ('k') | src/js/promise-extra.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 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 328 matching lines...) Expand 10 before | Expand all | Expand 10 after
339 result.resolve = resolve; 339 result.resolve = resolve;
340 result.reject = reject; 340 result.reject = reject;
341 }); 341 });
342 342
343 if (!IS_CALLABLE(result.resolve) || !IS_CALLABLE(result.reject)) 343 if (!IS_CALLABLE(result.resolve) || !IS_CALLABLE(result.reject))
344 throw %make_type_error(kPromiseNonCallable); 344 throw %make_type_error(kPromiseNonCallable);
345 345
346 return result; 346 return result;
347 } 347 }
348 348
349 // Unspecified V8-specific legacy function
350 function PromiseDefer() {
351 %IncrementUseCounter(kPromiseDefer);
352 return NewPromiseCapability(this);
353 }
354
355 // Unspecified V8-specific legacy function
356 function PromiseAccept(x) {
357 %IncrementUseCounter(kPromiseAccept);
358 return %_Call(PromiseResolve, this, x);
359 }
360
361 // ES#sec-promise.reject 349 // ES#sec-promise.reject
362 // Promise.reject ( x ) 350 // Promise.reject ( x )
363 function PromiseReject(r) { 351 function PromiseReject(r) {
364 if (!IS_RECEIVER(this)) { 352 if (!IS_RECEIVER(this)) {
365 throw %make_type_error(kCalledOnNonObject, PromiseResolve); 353 throw %make_type_error(kCalledOnNonObject, PromiseResolve);
366 } 354 }
367 if (this === GlobalPromise) { 355 if (this === GlobalPromise) {
368 // Optimized case, avoid extra closure. 356 // Optimized case, avoid extra closure.
369 var promise = PromiseCreateAndSet(kRejected, r); 357 var promise = PromiseCreateAndSet(kRejected, r);
370 // The debug event for this would always be an uncaught promise reject, 358 // The debug event for this would always be an uncaught promise reject,
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
436 var status = GET_PRIVATE(this, promiseStateSymbol); 424 var status = GET_PRIVATE(this, promiseStateSymbol);
437 if (IS_UNDEFINED(status)) { 425 if (IS_UNDEFINED(status)) {
438 throw %make_type_error(kNotAPromise, this); 426 throw %make_type_error(kNotAPromise, this);
439 } 427 }
440 428
441 var constructor = SpeciesConstructor(this, GlobalPromise); 429 var constructor = SpeciesConstructor(this, GlobalPromise);
442 var resultCapability = NewPromiseCapability(constructor); 430 var resultCapability = NewPromiseCapability(constructor);
443 return PerformPromiseThen(this, onResolve, onReject, resultCapability); 431 return PerformPromiseThen(this, onResolve, onReject, resultCapability);
444 } 432 }
445 433
446 // Unspecified V8-specific legacy function
447 // Chain is left around for now as an alias for then
448 function PromiseChain(onResolve, onReject) {
449 %IncrementUseCounter(kPromiseChain);
450 return %_Call(PromiseThen, this, onResolve, onReject);
451 }
452
453 // ES#sec-promise.prototype.catch 434 // ES#sec-promise.prototype.catch
454 // Promise.prototype.catch ( onRejected ) 435 // Promise.prototype.catch ( onRejected )
455 function PromiseCatch(onReject) { 436 function PromiseCatch(onReject) {
456 return this.then(UNDEFINED, onReject); 437 return this.then(UNDEFINED, onReject);
457 } 438 }
458 439
459 // Combinators. 440 // Combinators.
460 441
461 // ES#sec-promise.resolve 442 // ES#sec-promise.resolve
462 // Promise.resolve ( x ) 443 // Promise.resolve ( x )
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
608 589
609 utils.InstallGetter(GlobalPromise, speciesSymbol, PromiseSpecies); 590 utils.InstallGetter(GlobalPromise, speciesSymbol, PromiseSpecies);
610 591
611 utils.InstallFunctions(GlobalPromise.prototype, DONT_ENUM, [ 592 utils.InstallFunctions(GlobalPromise.prototype, DONT_ENUM, [
612 "then", PromiseThen, 593 "then", PromiseThen,
613 "catch", PromiseCatch 594 "catch", PromiseCatch
614 ]); 595 ]);
615 596
616 %InstallToContext([ 597 %InstallToContext([
617 "promise_catch", PromiseCatch, 598 "promise_catch", PromiseCatch,
618 "promise_chain", PromiseChain,
619 "promise_create", PromiseCreate, 599 "promise_create", PromiseCreate,
620 "promise_has_user_defined_reject_handler", PromiseHasUserDefinedRejectHandler, 600 "promise_has_user_defined_reject_handler", PromiseHasUserDefinedRejectHandler,
621 "promise_reject", RejectPromise, 601 "promise_reject", RejectPromise,
622 "promise_resolve", ResolvePromise, 602 "promise_resolve", ResolvePromise,
623 "promise_then", PromiseThen, 603 "promise_then", PromiseThen,
624 "promise_create_rejected", PromiseCreateRejected, 604 "promise_create_rejected", PromiseCreateRejected,
625 "promise_create_resolved", PromiseCreateResolved 605 "promise_create_resolved", PromiseCreateResolved
626 ]); 606 ]);
627 607
628 // This allows extras to create promises quickly without building extra 608 // This allows extras to create promises quickly without building extra
629 // resolve/reject closures, and allows them to later resolve and reject any 609 // resolve/reject closures, and allows them to later resolve and reject any
630 // promise without having to hold on to those closures forever. 610 // promise without having to hold on to those closures forever.
631 utils.InstallFunctions(extrasUtils, 0, [ 611 utils.InstallFunctions(extrasUtils, 0, [
632 "createPromise", PromiseCreate, 612 "createPromise", PromiseCreate,
633 "resolvePromise", ResolvePromise, 613 "resolvePromise", ResolvePromise,
634 "rejectPromise", RejectPromise 614 "rejectPromise", RejectPromise
635 ]); 615 ]);
636 616
637 // TODO(v8:4567): Allow experimental natives to remove function prototype
638 [PromiseChain, PromiseDefer, PromiseAccept].forEach(
639 fn => %FunctionRemovePrototype(fn));
640
641 utils.Export(function(to) { 617 utils.Export(function(to) {
642 to.PromiseChain = PromiseChain;
643 to.PromiseDefer = PromiseDefer;
644 to.PromiseAccept = PromiseAccept;
645
646 to.PromiseCastResolved = PromiseCastResolved; 618 to.PromiseCastResolved = PromiseCastResolved;
647 to.PromiseThen = PromiseThen; 619 to.PromiseThen = PromiseThen;
648 620
649 to.GlobalPromise = GlobalPromise; 621 to.GlobalPromise = GlobalPromise;
650 to.NewPromiseCapability = NewPromiseCapability; 622 to.NewPromiseCapability = NewPromiseCapability;
651 to.PerformPromiseThen = PerformPromiseThen; 623 to.PerformPromiseThen = PerformPromiseThen;
652 }); 624 });
653 625
654 }) 626 })
OLDNEW
« no previous file with comments | « src/js/prologue.js ('k') | src/js/promise-extra.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698