on master help sign in
javascript: remove redundant continuations
88e5823raichoo
src/IRTS/CodegenJavaScript.hs+12
@@ -666,6 +666,17 @@ inlineFunctions js =
666 | otherwise = 0
666 | otherwise = 0
667
667
668
668
669+reduceContinuations :: JS -> JS
670+reduceContinuations = transformJS reduceHelper
671+ where
672+ reduceHelper :: JS -> JS
673+ reduceHelper (JSNew "__IDRRT__Cont" [JSFunction [] (
674+ JSReturn js@(JSNew "__IDRRT__Cont" [JSFunction [] body])
675+ )]) = js
676+
677+ reduceHelper js = transformJS reduceHelper js
678+
679+
669reduceConstant :: JS -> JS
680reduceConstant :: JS -> JS
670reduceConstant
681reduceConstant
671 (JSApp (JSIdent "__IDRRT__tailcall") [JSFunction [] (
682 (JSApp (JSIdent "__IDRRT__tailcall") [JSFunction [] (
@@ -853,6 +864,7 @@ codegenJavaScript target definitions filename outputType = do
853 , map (optimizeEvalTailcalls ("__IDR__mAPPLY0", "__IDRRT__APPLYTC"))
864 , map (optimizeEvalTailcalls ("__IDR__mAPPLY0", "__IDRRT__APPLYTC"))
854 , map removeInstanceChecks
865 , map removeInstanceChecks
855 , inlineFunctions
866 , inlineFunctions
867+ , map reduceContinuations
856 ]
868 ]
857
869
858
870