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

Side by Side Diff: src/v8natives.js

Issue 290633010: Move microtask queueing logic from JavaScript to C++ (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Handle comments Created 6 years, 7 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 | Annotate | Revision Log
« no previous file with comments | « src/runtime.cc ('k') | test/cctest/test-api.cc » ('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 // 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 1844 matching lines...) Expand 10 before | Expand all | Expand 10 after
1855 %SetCode($Function, FunctionConstructor); 1855 %SetCode($Function, FunctionConstructor);
1856 %SetProperty($Function.prototype, "constructor", $Function, DONT_ENUM); 1856 %SetProperty($Function.prototype, "constructor", $Function, DONT_ENUM);
1857 1857
1858 InstallFunctions($Function.prototype, DONT_ENUM, $Array( 1858 InstallFunctions($Function.prototype, DONT_ENUM, $Array(
1859 "bind", FunctionBind, 1859 "bind", FunctionBind,
1860 "toString", FunctionToString 1860 "toString", FunctionToString
1861 )); 1861 ));
1862 } 1862 }
1863 1863
1864 SetUpFunction(); 1864 SetUpFunction();
1865
1866
1867 //----------------------------------------------------------------------------
1868
1869 // TODO(rossberg): very simple abstraction for generic microtask queue.
1870 // Eventually, we should move to a real event queue that allows to maintain
1871 // relative ordering of different kinds of tasks.
1872
1873 function RunMicrotasksJS() {
1874 while (%SetMicrotaskPending(false)) {
1875 var microtaskState = %GetMicrotaskState();
1876 if (IS_UNDEFINED(microtaskState.queue))
1877 return;
1878
1879 var microtasks = microtaskState.queue;
1880 microtaskState.queue = null;
1881
1882 for (var i = 0; i < microtasks.length; i++) {
1883 microtasks[i]();
1884 }
1885 }
1886 }
1887
1888 function EnqueueMicrotask(fn) {
1889 var microtaskState = %GetMicrotaskState();
1890 if (IS_UNDEFINED(microtaskState.queue) || IS_NULL(microtaskState.queue)) {
1891 microtaskState.queue = new InternalArray;
1892 }
1893 microtaskState.queue.push(fn);
1894 %SetMicrotaskPending(true);
1895 }
OLDNEW
« no previous file with comments | « src/runtime.cc ('k') | test/cctest/test-api.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698