summaryrefslogtreecommitdiff
path: root/compiler/cmm/DFMonad.hs
diff options
context:
space:
mode:
authordias@eecs.tufts.edu <unknown>2009-03-18 21:01:38 +0000
committerdias@eecs.tufts.edu <unknown>2009-03-18 21:01:38 +0000
commit2c8d42f32022f4950606d75d53e45a4c30d210df (patch)
tree325b96e7a7c454ae411a048d5e43ee34ff91ff59 /compiler/cmm/DFMonad.hs
parent1d34bd56c9dde4dad72d3e8a4cfabdf11337dfb3 (diff)
downloadhaskell-2c8d42f32022f4950606d75d53e45a4c30d210df.tar.gz
Comment explaining use of seq in DFMonad
Diffstat (limited to 'compiler/cmm/DFMonad.hs')
-rw-r--r--compiler/cmm/DFMonad.hs4
1 files changed, 4 insertions, 0 deletions
diff --git a/compiler/cmm/DFMonad.hs b/compiler/cmm/DFMonad.hs
index 0cf1ead0fc..263d0d4856 100644
--- 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))
+ -- 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