[commit: ghc] wip/merge: Turn CoreWriter into a newtype; fix comment (a9ed294)

git at git.haskell.org git at git.haskell.org
Wed Nov 19 04:27:50 UTC 2014


Repository : ssh://git@git.haskell.org/ghc

On branch  : wip/merge
Link       : http://ghc.haskell.org/trac/ghc/changeset/a9ed294abfbafb32867345dd20ee9a3a90b4e2c1/ghc

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

commit a9ed294abfbafb32867345dd20ee9a3a90b4e2c1
Author: David Feuer <David.Feuer at gmail.com>
Date:   Tue Nov 18 22:19:46 2014 -0600

    Turn CoreWriter into a newtype; fix comment
    
    Summary:
    Turn CoreWriter into a newtype. A comment claimed something is forced
    before returning, but it's actually not. Change comment to match
    reality.
    
    Reviewers: xich, simonpj, ezyang, austin
    
    Reviewed By: ezyang, austin
    
    Subscribers: thomie, carter
    
    Differential Revision: https://phabricator.haskell.org/D453


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

a9ed294abfbafb32867345dd20ee9a3a90b4e2c1
 compiler/simplCore/CoreMonad.lhs | 19 +++++++++++--------
 1 file changed, 11 insertions(+), 8 deletions(-)

diff --git a/compiler/simplCore/CoreMonad.lhs b/compiler/simplCore/CoreMonad.lhs
index 04782f1..0d41d5e 100644
--- a/compiler/simplCore/CoreMonad.lhs
+++ b/compiler/simplCore/CoreMonad.lhs
@@ -776,10 +776,11 @@ data CoreReader = CoreReader {
 #endif
 }
 
-data CoreWriter = CoreWriter {
-        cw_simpl_count :: !SimplCount
-        -- Making this strict fixes a nasty space leak
-        -- See Trac #7702
+-- Note: CoreWriter used to be defined with data, rather than newtype.  If it
+-- is defined that way again, the cw_simpl_count field, at least, must be
+-- strict to avoid a space leak (Trac #7702).
+newtype CoreWriter = CoreWriter {
+        cw_simpl_count :: SimplCount
 }
 
 emptyWriter :: DynFlags -> CoreWriter
@@ -808,12 +809,14 @@ instance Monad CoreM where
     mx >>= f = CoreM $ \s -> do
             (x, s', w1) <- unCoreM mx s
             (y, s'', w2) <- unCoreM (f x) s'
-            let w = w1 `plusWriter` w2 -- forcing w before returning avoids a space leak (Trac #7702)
+            let w = w1 `plusWriter` w2
             return $ seq w (y, s'', w)
-
+            -- forcing w before building the tuple avoids a space leak
+            -- (Trac #7702)
 instance A.Applicative CoreM where
     pure = return
     (<*>) = ap
+    (*>) = (>>)
 
 instance MonadPlus IO => A.Alternative CoreM where
     empty = mzero
@@ -986,8 +989,8 @@ on Windows. On Windows the GHC library tends to export more than 65536 symbols
 (see #5292) which overflows the limit of what we can export from the EXE and
 causes breakage.
 
-(Note that if the GHC exeecutable was dynamically linked this wouldn't be a problem,
-because we could share the GHC library it links to.)
+(Note that if the GHC executable was dynamically linked this wouldn't be a
+problem, because we could share the GHC library it links to.)
 
 We are going to try 2. instead. Unfortunately, this means that every plugin
 will have to say `reinitializeGlobals` before it does anything, but never mind.



More information about the ghc-commits mailing list