[commit: ghc] master: Add a comment to explain why the FCode monad is lazy (290ec75)

Simon Marlow marlowsd at gmail.com
Mon Aug 6 10:47:50 CEST 2012


Repository : ssh://darcs.haskell.org//srv/darcs/ghc

On branch  : master

http://hackage.haskell.org/trac/ghc/changeset/290ec750343a340d5f2cef8bf844f3822c9629e0

>---------------------------------------------------------------

commit 290ec750343a340d5f2cef8bf844f3822c9629e0
Author: Simon Marlow <marlowsd at gmail.com>
Date:   Thu Aug 2 13:37:57 2012 +0100

    Add a comment to explain why the FCode monad is lazy

>---------------------------------------------------------------

 compiler/codeGen/StgCmmBind.hs  |    3 ++-
 compiler/codeGen/StgCmmMonad.hs |    7 +++++++
 2 files changed, 9 insertions(+), 1 deletions(-)

diff --git a/compiler/codeGen/StgCmmBind.hs b/compiler/codeGen/StgCmmBind.hs
index a0fcc1a..148d53a 100644
--- a/compiler/codeGen/StgCmmBind.hs
+++ b/compiler/codeGen/StgCmmBind.hs
@@ -113,7 +113,8 @@ cgBind (StgRec pairs)
        ; addBindsC new_binds
        ; emit (catAGraphs inits <*> body) }
 
-{- Recursive let-bindings are tricky.
+{- Note [cgBind rec]
+   Recursive let-bindings are tricky.
    Consider the following pseudocode:
      let x = \_ ->  ... y ...
          y = \_ ->  ... z ...
diff --git a/compiler/codeGen/StgCmmMonad.hs b/compiler/codeGen/StgCmmMonad.hs
index 287302f..eb6b9a9 100644
--- a/compiler/codeGen/StgCmmMonad.hs
+++ b/compiler/codeGen/StgCmmMonad.hs
@@ -143,6 +143,13 @@ thenFC (FCode m) k = FCode (
 		in 
 			kcode info_down new_state
 	)
+    -- Note: this is a lazy monad.  We can't easily make it strict due
+    -- to the use of fixC for compiling recursive bindings (see Note
+    -- [cgBind rec]).  cgRhs returns a CgIdInfo which is fed back in
+    -- via the CgBindings, and making the monad strict means that we
+    -- can't look at the CgIdInfo too early.  Things seem to just
+    -- about work when the monad is lazy.  I hate this stuff --SDM
+
 
 listFCs :: [FCode a] -> FCode [a]
 listFCs = Prelude.sequence





More information about the Cvs-ghc mailing list