on develop help sign in
More performance tweaks
85a3aa6Ryan Trinkle
reflex-dom-core/reflex-dom-core.cabal+1−1
@@ -119,7 +119,7 @@ library
119 Reflex.Dom.Xhr.ResponseType
119 Reflex.Dom.Xhr.ResponseType
120 Reflex.Dom.Xhr.Exception
120 Reflex.Dom.Xhr.Exception
121
121
122− ghc-options: -Wall -fwarn-tabs -funbox-strict-fields -O2 -ferror-spans
122+ ghc-options: -Wall -fwarn-tabs -funbox-strict-fields -O2 -ferror-spans -fspecialise-aggressively -ddump-simpl -ddump-to-file -dsuppress-coercions -dsuppress-idinfo
123 ghc-prof-options: -fprof-auto
123 ghc-prof-options: -fprof-auto
124
124
125 if flag(expose-all-unfoldings)
125 if flag(expose-all-unfoldings)
reflex-dom-core/src/Foreign/JavaScript/TH.hs+4
@@ -170,6 +170,10 @@ instance MonadHold t m => MonadHold t (WithJSContextSingleton x m) where
170 holdDyn v0 = lift . holdDyn v0
170 holdDyn v0 = lift . holdDyn v0
171 {-# INLINABLE holdIncremental #-}
171 {-# INLINABLE holdIncremental #-}
172 holdIncremental v0 = lift . holdIncremental v0
172 holdIncremental v0 = lift . holdIncremental v0
173+ {-# INLINABLE buildDynamic #-}
174+ buildDynamic a0 = lift . buildDynamic a0
175+ {-# INLINABLE headE #-}
176+ headE = lift . headE
173
177
174instance MonadTransControl (WithJSContextSingleton x) where
178instance MonadTransControl (WithJSContextSingleton x) where
175 type StT (WithJSContextSingleton x) a = StT (ReaderT (JSContextSingleton x)) a
179 type StT (WithJSContextSingleton x) a = StT (ReaderT (JSContextSingleton x)) a
reflex-dom-core/src/Reflex/Dom/Builder/Class.hs+1−1
@@ -610,7 +610,7 @@ class HasDomEvent t target eventName where
610instance Reflex t => HasDomEvent t (Element EventResult d t) en where
610instance Reflex t => HasDomEvent t (Element EventResult d t) en where
611 type DomEventType (Element EventResult d t) en = EventResultType en
611 type DomEventType (Element EventResult d t) en = EventResultType en
612 {-# INLINABLE domEvent #-}
612 {-# INLINABLE domEvent #-}
613− domEvent en e = unEventResult <$> Reflex.select (_element_events e) (WrapArg en)
613+ domEvent en e = coerceEvent $ Reflex.select (_element_events e) (WrapArg en)
614
614
615instance Reflex t => HasDomEvent t (InputElement EventResult d t) en where
615instance Reflex t => HasDomEvent t (InputElement EventResult d t) en where
616 type DomEventType (InputElement EventResult d t) en = EventResultType en
616 type DomEventType (InputElement EventResult d t) en = EventResultType en
reflex-dom-core/src/Reflex/Dom/Builder/Immediate.hs+18−22
@@ -22,6 +22,10 @@
22{-# LANGUAGE TypeFamilies #-}
22{-# LANGUAGE TypeFamilies #-}
23{-# LANGUAGE TypeOperators #-}
23{-# LANGUAGE TypeOperators #-}
24{-# LANGUAGE UndecidableInstances #-}
24{-# LANGUAGE UndecidableInstances #-}
25+#ifdef ghcjs_HOST_OS
26+{-# LANGUAGE ForeignFunctionInterface #-}
27+{-# LANGUAGE JavaScriptFFI #-}
28+#endif
25module Reflex.Dom.Builder.Immediate
29module Reflex.Dom.Builder.Immediate
26 ( EventTriggerRef (..)
30 ( EventTriggerRef (..)
27 , ImmediateDomBuilderEnv (..)
31 , ImmediateDomBuilderEnv (..)
@@ -297,16 +301,7 @@ deleteBetweenExclusive s e = liftJSM $ do
297-- and e will not be moved
301-- and e will not be moved
298extractBetweenExclusive :: (MonadJSM m, IsNode start, IsNode end) => DOM.DocumentFragment -> start -> end -> m ()
302extractBetweenExclusive :: (MonadJSM m, IsNode start, IsNode end) => DOM.DocumentFragment -> start -> end -> m ()
299extractBetweenExclusive df s e = liftJSM $ do
303extractBetweenExclusive df s e = liftJSM $ do
300− f <- eval $ T.unlines
304+ f <- eval ("(function(df,s,e) { var x; for(;;) { x = s['nextSibling']; if(e===x) { break; }; df['appendChild'](x); } })" :: Text)
301− [ "(function(df,s,e){"
302− , " var x;"
303− , " for(;;){"
304− , " x = s.nextSibling;"
305− , " if(e===x) break;"
306− , " df.appendChild(x);"
307− , " }"
308− , "})"
309− ]
310 void $ call f f (df, s, e)
305 void $ call f f (df, s, e)
311
306
312-- | s and e must both be children of the same node and s must precede e;
307-- | s and e must both be children of the same node and s must precede e;
@@ -318,20 +313,17 @@ deleteUpTo s e = do
318 extractUpTo df s e -- In many places in ImmediateDomBuilderT, we assume that things always have a parent; by adding them to this DocumentFragment, we maintain that invariant
313 extractUpTo df s e -- In many places in ImmediateDomBuilderT, we assume that things always have a parent; by adding them to this DocumentFragment, we maintain that invariant
319
314
320extractUpTo :: (MonadJSM m, IsNode start, IsNode end) => DOM.DocumentFragment -> start -> end -> m ()
315extractUpTo :: (MonadJSM m, IsNode start, IsNode end) => DOM.DocumentFragment -> start -> end -> m ()
316+#ifdef ghcjs_HOST_OS
317+--NOTE: Although wrapping this javascript in a function seems unnecessary, GHCJS's optimizer will break it if it is entered without that wrapping (as of 2017-09-04)
318+foreign import javascript unsafe
319+ "(function() { var x = $2; while(x !== $3) { var y = x['nextSibling']; $1['appendChild'](x); x = y; } })()"
320+ extractUpTo_ :: DOM.DocumentFragment -> DOM.Node -> DOM.Node -> IO ()
321+extractUpTo df s e = liftJSM $ extractUpTo_ df (toNode s) (toNode e)
322+#else
321extractUpTo df s e = liftJSM $ do
323extractUpTo df s e = liftJSM $ do
322− f <- eval $ T.unlines
324+ f <- eval ("(function(df,s,e){ var x = s; var y; for(;;) { y = x['nextSibling']; df['appendChild'](x); if(e===y) { break; } x = y; } })" :: Text)
323− [ "(function(df,s,e){"
324− , " var x = s;"
325− , " var y;"
326− , " for(;;) {"
327− , " y = x.nextSibling;"
328− , " df.appendChild(x);"
329− , " if(e===y) break;"
330− , " x = y;"
331− , " }"
332− , "})"
333− ]
334 void $ call f f (df, s, e)
325 void $ call f f (df, s, e)
326+#endif
335
327
336type SupportsImmediateDomBuilder t m = (Reflex t, MonadJSM m, MonadHold t m, MonadFix m, MonadReflexCreateTrigger t m, MonadRef m, Ref m ~ Ref JSM, MonadAdjust t m, PrimMonad m)
328type SupportsImmediateDomBuilder t m = (Reflex t, MonadJSM m, MonadHold t m, MonadFix m, MonadReflexCreateTrigger t m, MonadRef m, Ref m ~ Ref JSM, MonadAdjust t m, PrimMonad m)
337
329
@@ -1567,6 +1559,10 @@ instance MonadHold t m => MonadHold t (ImmediateDomBuilderT t m) where
1567 holdDyn v0 v' = lift $ holdDyn v0 v'
1559 holdDyn v0 v' = lift $ holdDyn v0 v'
1568 {-# INLINABLE holdIncremental #-}
1560 {-# INLINABLE holdIncremental #-}
1569 holdIncremental v0 v' = lift $ holdIncremental v0 v'
1561 holdIncremental v0 v' = lift $ holdIncremental v0 v'
1562+ {-# INLINABLE buildDynamic #-}
1563+ buildDynamic a0 = lift . buildDynamic a0
1564+ {-# INLINABLE headE #-}
1565+ headE = lift . headE
1570
1566
1571data WindowConfig t = WindowConfig -- No config options yet
1567data WindowConfig t = WindowConfig -- No config options yet
1572
1568
reflex-dom-core/src/Reflex/Dom/Builder/Static.hs+4
@@ -100,6 +100,10 @@ instance MonadHold t m => MonadHold t (StaticDomBuilderT t m) where
100 holdDyn v0 v' = lift $ holdDyn v0 v'
100 holdDyn v0 v' = lift $ holdDyn v0 v'
101 {-# INLINABLE holdIncremental #-}
101 {-# INLINABLE holdIncremental #-}
102 holdIncremental v0 v' = lift $ holdIncremental v0 v'
102 holdIncremental v0 v' = lift $ holdIncremental v0 v'
103+ {-# INLINABLE buildDynamic #-}
104+ buildDynamic a0 = lift . buildDynamic a0
105+ {-# INLINABLE headE #-}
106+ headE = lift . headE
103
107
104instance (Monad m, Ref m ~ Ref IO, Reflex t) => TriggerEvent t (StaticDomBuilderT t m) where
108instance (Monad m, Ref m ~ Ref IO, Reflex t) => TriggerEvent t (StaticDomBuilderT t m) where
105 {-# INLINABLE newTriggerEvent #-}
109 {-# INLINABLE newTriggerEvent #-}
reflex-dom-core/src/Reflex/Dom/Main.hs+1
@@ -12,6 +12,7 @@
12{-# LANGUAGE TypeFamilies #-}
12{-# LANGUAGE TypeFamilies #-}
13{-# LANGUAGE TypeOperators #-}
13{-# LANGUAGE TypeOperators #-}
14{-# LANGUAGE UndecidableInstances #-}
14{-# LANGUAGE UndecidableInstances #-}
15+{-# OPTIONS_GHC -fspecialise-aggressively #-}
15module Reflex.Dom.Main where
16module Reflex.Dom.Main where
16
17
17import Prelude hiding (concat, mapM, mapM_, sequence, sequence_)
18import Prelude hiding (concat, mapM, mapM_, sequence, sequence_)
reflex-dom/benchmarks/krausest.hs+1−1
@@ -2,7 +2,7 @@
2{-# LANGUAGE OverloadedStrings #-}
2{-# LANGUAGE OverloadedStrings #-}
3{-# LANGUAGE ScopedTypeVariables #-}
3{-# LANGUAGE ScopedTypeVariables #-}
4{-# LANGUAGE FlexibleContexts #-}
4{-# LANGUAGE FlexibleContexts #-}
5−{-# OPTIONS_GHC -ddump-simpl -ddump-rules -ddump-spec -ddump-to-file -dsuppress-coercions -dsuppress-idinfo #-}
5+{-# OPTIONS_GHC -fmax-simplifier-iterations=5 -ddump-simpl -ddump-to-file -dsuppress-coercions -dsuppress-idinfo #-}
6import Control.Monad.State
6import Control.Monad.State
7import Data.Monoid
7import Data.Monoid
8import Data.IntMap (IntMap, assocs, elems, empty, fromList, size, singleton)
8import Data.IntMap (IntMap, assocs, elems, empty, fromList, size, singleton)
reflex-dom/reflex-dom.cabal+2−2
@@ -100,7 +100,7 @@ executable sortableList
100 , transformers
100 , transformers
101 hs-source-dirs: examples
101 hs-source-dirs: examples
102 main-is: sortableList.hs
102 main-is: sortableList.hs
103− ghc-options: -Wall -fwarn-tabs -funbox-strict-fields -O2 -ferror-spans
103+ ghc-options: -Wall -fwarn-tabs -funbox-strict-fields -O2 -ferror-spans -fspecialise-aggressively
104 ghc-prof-options: -fprof-auto
104 ghc-prof-options: -fprof-auto
105 if !flag(build-examples)
105 if !flag(build-examples)
106 buildable: False
106 buildable: False
@@ -121,7 +121,7 @@ benchmark krausest
121 build-depends: base, reflex, reflex-dom, text, prim-uniq, dependent-map, containers, transformers, mtl, ghcjs-dom, ghc-prim, random, dependent-sum, vector
121 build-depends: base, reflex, reflex-dom, text, prim-uniq, dependent-map, containers, transformers, mtl, ghcjs-dom, ghc-prim, random, dependent-sum, vector
122 hs-source-dirs: benchmarks
122 hs-source-dirs: benchmarks
123 main-is: krausest.hs
123 main-is: krausest.hs
124− ghc-options: -O2 -fspecialise-aggressively
124+ ghc-options: -O2 -fspecialise-aggressively -DGHCJS_GC_INTERVAL=60000
125 type: exitcode-stdio-1.0
125 type: exitcode-stdio-1.0
126
126
127source-repository head
127source-repository head