projects
/
ghc-hetmet.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
1d34bd5
)
Comment explaining use of seq in DFMonad
author
dias@eecs.tufts.edu
<unknown>
Wed, 18 Mar 2009 21:01:38 +0000
(21:01 +0000)
committer
dias@eecs.tufts.edu
<unknown>
Wed, 18 Mar 2009 21:01:38 +0000
(21:01 +0000)
compiler/cmm/DFMonad.hs
patch
|
blob
|
history
diff --git
a/compiler/cmm/DFMonad.hs
b/compiler/cmm/DFMonad.hs
index
0cf1ead
..
263d0d4
100644
(file)
--- a/
compiler/cmm/DFMonad.hs
+++ b/
compiler/cmm/DFMonad.hs
@@
-192,6
+192,10
@@
instance Monad m => Monad (DFM' m f) where
DFM' f >>= k = DFM' (\l s -> do (a, s') <- f l s
s' `seq` case k a of DFM' f' -> f' l s')
return a = DFM' (\_ s -> return (a, s))
DFM' f >>= k = DFM' (\l s -> do (a, s') <- f l s
s' `seq` case k a of DFM' f' -> f' l s')
return a = DFM' (\_ s -> return (a, s))
+ -- The `seq` is essential to ensure that entire passes of the dataflow engine
+ -- aren't postponed in a thunk. By making the sequence strict in the state,
+ -- we ensure that each action in the monad is executed immediately, preventing
+ -- stack overflows that previously occurred when finally forcing the old state thunks.
instance FuelUsingMonad (DFM' FuelMonad f) where
fuelRemaining = liftToDFM' fuelRemaining
instance FuelUsingMonad (DFM' FuelMonad f) where
fuelRemaining = liftToDFM' fuelRemaining