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

Side by Side Diff: src/promise.js

Issue 777703002: Fix Promise.resolve/Promise.reject unnecessarily scheduling a microtask. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 6 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 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 "use strict"; 5 "use strict";
6 6
7 // This file relies on the fact that the following declaration has been made 7 // This file relies on the fact that the following declaration has been made
8 // in runtime.js: 8 // in runtime.js:
9 // var $Object = global.Object 9 // var $Object = global.Object
10 // var $WeakMap = global.WeakMap 10 // var $WeakMap = global.WeakMap
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 return promise; 67 return promise;
68 } 68 }
69 69
70 function PromiseInit(promise) { 70 function PromiseInit(promise) {
71 return PromiseSet( 71 return PromiseSet(
72 promise, 0, UNDEFINED, new InternalArray, new InternalArray) 72 promise, 0, UNDEFINED, new InternalArray, new InternalArray)
73 } 73 }
74 74
75 function PromiseDone(promise, status, value, promiseQueue) { 75 function PromiseDone(promise, status, value, promiseQueue) {
76 if (GET_PRIVATE(promise, promiseStatus) === 0) { 76 if (GET_PRIVATE(promise, promiseStatus) === 0) {
77 PromiseEnqueue(value, GET_PRIVATE(promise, promiseQueue), status); 77 var tasks = GET_PRIVATE(promise, promiseQueue);
78 if (tasks.length) PromiseEnqueue(value, tasks, status);
78 PromiseSet(promise, status, value); 79 PromiseSet(promise, status, value);
79 } 80 }
80 } 81 }
81 82
82 function PromiseCoerce(constructor, x) { 83 function PromiseCoerce(constructor, x) {
83 if (!IsPromise(x) && IS_SPEC_OBJECT(x)) { 84 if (!IsPromise(x) && IS_SPEC_OBJECT(x)) {
84 var then; 85 var then;
85 try { 86 try {
86 then = x.then; 87 then = x.then;
87 } catch(r) { 88 } catch(r) {
(...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after
383 "race", PromiseOne, 384 "race", PromiseOne,
384 "resolve", PromiseCast 385 "resolve", PromiseCast
385 ]); 386 ]);
386 InstallFunctions($Promise.prototype, DONT_ENUM, [ 387 InstallFunctions($Promise.prototype, DONT_ENUM, [
387 "chain", PromiseChain, 388 "chain", PromiseChain,
388 "then", PromiseThen, 389 "then", PromiseThen,
389 "catch", PromiseCatch 390 "catch", PromiseCatch
390 ]); 391 ]);
391 392
392 })(); 393 })();
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