git.iko.soy/rowtype-yoga/purescript-native
on golang help sign in
Merge pull request #323 from garyb/optimize-by-default

Optimize by default and use flags to disable

commit130e8aecf5619398b60cec1d4559aed321e755d3 authorPhil Freeman <paf31@cantab.net> dateTue 25 Mar 2014, 17:10 (13 years ago) parent285a55d4fd30a9
5 files changed+22−22
psc-make/Main.hs+7−7 psc/Main.hs+7−7 src/Language/PureScript/Optimizer/MagicDo.hs+2−2 src/Language/PureScript/Optimizer/TCO.hs+2−2 src/Language/PureScript/Options.hs+4−4
psc-make/Main.hs+7−7
@@ -91,9 +91,9 @@ inputFiles :: Term [FilePath]
9191inputFiles = value $ posAny [] $ posInfo
9292 { posDoc = "The input .ps files" }
9393
94−tco :: Term Bool
95−tco = value $ flag $ (optInfo [ "tco" ])
96− { optDoc = "Perform tail call optimizations" }
94+noTco :: Term Bool
95+noTco = value $ flag $ (optInfo [ "no-tco" ])
96+ { optDoc = "Disable tail call optimizations" }
9797
9898performRuntimeTypeChecks :: Term Bool
9999performRuntimeTypeChecks = value $ flag $ (optInfo [ "runtime-type-checks" ])
@@ -103,9 +103,9 @@ noPrelude :: Term Bool
103103noPrelude = value $ flag $ (optInfo [ "no-prelude" ])
104104 { optDoc = "Omit the Prelude" }
105105
106−magicDo :: Term Bool
107−magicDo = value $ flag $ (optInfo [ "magic-do" ])
108− { optDoc = "Overload the do keyword to generate efficient code specifically for the Eff monad." }
106+noMagicDo :: Term Bool
107+noMagicDo = value $ flag $ (optInfo [ "no-magic-do" ])
108+ { optDoc = "Disable the optimization that overloads the do keyword to generate efficient code specifically for the Eff monad." }
109109
110110noOpts :: Term Bool
111111noOpts = value $ flag $ (optInfo [ "no-opts" ])
@@ -116,7 +116,7 @@ browserNamespace = value $ opt "PS" $ (optInfo [ "browser-namespace" ])
116116 { optDoc = "Specify the namespace that PureScript modules will be exported to when running in the browser." }
117117
118118options :: Term P.Options
119−options = P.Options <$> tco <*> performRuntimeTypeChecks <*> magicDo <*> pure Nothing <*> noOpts <*> browserNamespace <*> pure [] <*> pure []
119+options = P.Options <$> noTco <*> performRuntimeTypeChecks <*> noMagicDo <*> pure Nothing <*> noOpts <*> browserNamespace <*> pure [] <*> pure []
120120
121121inputFilesAndPrelude :: FilePath -> Term [FilePath]
122122inputFilesAndPrelude prelude = combine <$> (not <$> noPrelude) <*> inputFiles
psc/Main.hs+7−7
@@ -86,9 +86,9 @@ externsFile :: Term (Maybe FilePath)
8686externsFile = value $ opt Nothing $ (optInfo [ "e", "externs" ])
8787 { optDoc = "The output .e.ps file" }
8888
89−tco :: Term Bool
90−tco = value $ flag $ (optInfo [ "tco" ])
91− { optDoc = "Perform tail call optimizations" }
89+noTco :: Term Bool
90+noTco = value $ flag $ (optInfo [ "no-tco" ])
91+ { optDoc = "Disable tail call optimizations" }
9292
9393performRuntimeTypeChecks :: Term Bool
9494performRuntimeTypeChecks = value $ flag $ (optInfo [ "runtime-type-checks" ])
@@ -98,9 +98,9 @@ noPrelude :: Term Bool
9898noPrelude = value $ flag $ (optInfo [ "no-prelude" ])
9999 { optDoc = "Omit the Prelude" }
100100
101−magicDo :: Term Bool
102−magicDo = value $ flag $ (optInfo [ "magic-do" ])
103− { optDoc = "Overload the do keyword to generate efficient code specifically for the Eff monad." }
101+noMagicDo :: Term Bool
102+noMagicDo = value $ flag $ (optInfo [ "no-magic-do" ])
103+ { optDoc = "Disable the optimization that overloads the do keyword to generate efficient code specifically for the Eff monad." }
104104
105105runMain :: Term (Maybe String)
106106runMain = value $ defaultOpt (Just "Main") Nothing $ (optInfo [ "main" ])
@@ -123,7 +123,7 @@ codeGenModules = value $ optAll [] $ (optInfo [ "codegen" ])
123123 { optDoc = "A list of modules for which Javascript and externs should be generated. This argument can be used multiple times." }
124124
125125options :: Term P.Options
126−options = P.Options <$> tco <*> performRuntimeTypeChecks <*> magicDo <*> runMain <*> noOpts <*> browserNamespace <*> dceModules <*> codeGenModules
126+options = P.Options <$> noTco <*> performRuntimeTypeChecks <*> noMagicDo <*> runMain <*> noOpts <*> browserNamespace <*> dceModules <*> codeGenModules
127127
128128stdInOrInputFiles :: FilePath -> Term (Maybe [FilePath])
129129stdInOrInputFiles prelude = combine <$> useStdIn <*> (not <$> noPrelude) <*> inputFiles
src/Language/PureScript/Optimizer/MagicDo.hs+2−2
@@ -30,8 +30,8 @@ import Language.PureScript.Names
3030import qualified Language.PureScript.Constants as C
3131
3232magicDo :: Options -> JS -> JS
33−magicDo opts | optionsMagicDo opts = inlineST . magicDo'
34− | otherwise = id
33+magicDo opts | optionsNoMagicDo opts = id
34+ | otherwise = inlineST . magicDo'
3535
3636-- |
3737-- Inline type class dictionaries for >>= and return for the Eff monad
src/Language/PureScript/Optimizer/TCO.hs+2−2
@@ -24,8 +24,8 @@ import Language.PureScript.CodeGen.JS.AST
2424-- Eliminate tail calls
2525--
2626tco :: Options -> JS -> JS
27−tco opts | optionsTco opts = tco'
28− | otherwise = id
27+tco opts | optionsNoTco opts = id
28+ | otherwise = tco'
2929
3030tco' :: JS -> JS
3131tco' = everywhere (mkT convert)
src/Language/PureScript/Options.hs+4−4
@@ -20,17 +20,17 @@ module Language.PureScript.Options where
2020--
2121data Options = Options {
2222 -- |
23− -- Perform tail-call elimination
23+ -- Disable tail-call elimination
2424 --
25− optionsTco :: Bool
25+ optionsNoTco :: Bool
2626 -- |
2727 -- Perform type checks at runtime
2828 --
2929 , optionsPerformRuntimeTypeChecks :: Bool
3030 -- |
31− -- Inline calls to ret and bind for the Eff monad
31+ -- Disable inlining of calls to return and bind for the Eff monad
3232 --
33− , optionsMagicDo :: Bool
33+ , optionsNoMagicDo :: Bool
3434 -- |
3535 -- When specified, checks the type of `main` in the module, and generate a call to run main
3636 -- after the module definitions.