OLD | NEW |
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 Loading... |
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 Loading... |
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 })(); |
OLD | NEW |