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 // This file relies on the fact that the following declarations have been made | 5 // This file relies on the fact that the following declarations have been made |
6 // in runtime.js: | 6 // in runtime.js: |
7 // var $Object = global.Object; | 7 // var $Object = global.Object; |
8 // var $Boolean = global.Boolean; | 8 // var $Boolean = global.Boolean; |
9 // var $Number = global.Number; | 9 // var $Number = global.Number; |
10 // var $Function = global.Function; | 10 // var $Function = global.Function; |
(...skipping 1868 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1879 var microtasks = microtaskState.queue; | 1879 var microtasks = microtaskState.queue; |
1880 microtaskState.queue = null; | 1880 microtaskState.queue = null; |
1881 | 1881 |
1882 for (var i = 0; i < microtasks.length; i++) { | 1882 for (var i = 0; i < microtasks.length; i++) { |
1883 microtasks[i](); | 1883 microtasks[i](); |
1884 } | 1884 } |
1885 } | 1885 } |
1886 } | 1886 } |
1887 | 1887 |
1888 function EnqueueMicrotask(fn) { | 1888 function EnqueueMicrotask(fn) { |
| 1889 if (!IS_FUNCTION(func)) { |
| 1890 throw new $TypeError('Can only enqueue functions'); |
| 1891 } |
1889 var microtaskState = %GetMicrotaskState(); | 1892 var microtaskState = %GetMicrotaskState(); |
1890 if (IS_UNDEFINED(microtaskState.queue) || IS_NULL(microtaskState.queue)) { | 1893 if (IS_UNDEFINED(microtaskState.queue) || IS_NULL(microtaskState.queue)) { |
1891 microtaskState.queue = new InternalArray; | 1894 microtaskState.queue = new InternalArray; |
1892 } | 1895 } |
1893 microtaskState.queue.push(fn); | 1896 microtaskState.queue.push(fn); |
1894 %SetMicrotaskPending(true); | 1897 %SetMicrotaskPending(true); |
1895 } | 1898 } |
OLD | NEW |