on master help sign in
javascript: schedule continuation every 1000 calls
ac7c313raichoo
jsrts/Runtime-browser.js−1
@@ -2,7 +2,6 @@ var i$putStr = function(s) {
2 console.log(s);
2 console.log(s);
3};
3};
4
4
5−
6var i$systemInfo = function(index) {
5var i$systemInfo = function(index) {
7 switch(index) {
6 switch(index) {
8 case 0:
7 case 0:
jsrts/Runtime-common.js+11
@@ -104,3 +104,14 @@ var i$fromCharCode = function(chr) {
104 else
104 else
105 return String.fromCharCode(chr);
105 return String.fromCharCode(chr);
106}
106}
107+
108+var i$RUN = function () {
109+ for (var i = 0; i < 1000 && i$callstack.length; i++) {
110+ var func = i$callstack.pop();
111+ var args = i$callstack.pop();
112+ func.apply(this,args);
113+ };
114+
115+ if (i$callstack.length)
116+ setTimeout(i$RUN, 0);
117+}
src/IRTS/CodegenJavaScript.hs+1−6
@@ -250,12 +250,7 @@ codegenJS_all target definitions includes libs filename outputType = do
250 , JSApp (
250 , JSApp (
251 JSIdent (translateName (sMN 0 "runMain"))
251 JSIdent (translateName (sMN 0 "runMain"))
252 ) [JSNew "i$POINTER" [JSNum (JSInt 0)]]
252 ) [JSNew "i$POINTER" [JSNum (JSInt 0)]]
253− , JSWhile (JSProj jsCALLSTACK "length") (
254− JSSeq [ JSAlloc "func" (Just jsPOP)
255− , JSAlloc "args" (Just jsPOP)
256− , JSApp (JSProj (JSIdent "func") "apply") [JSThis, JSIdent "args"]
253+ , JSApp (JSIdent "i$RUN") []
257− ]
258− )
259 ]
254 ]
260
255
261 invokeMain :: T.Text
256 invokeMain :: T.Text