[commit: ghc] master: Turn CoreWriter into a newtype; fix comment (5db61ea)

git at git.haskell.org git at git.haskell.org
Wed Nov 19 23:03:14 UTC 2014


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

On branch  : master
Link       : http://ghc.haskell.org/trac/ghc/changeset/5db61eac77e1e2532b9c2f3d454a206255687097/ghc

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

commit 5db61eac77e1e2532b9c2f3d454a206255687097
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


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

5db61eac77e1e2532b9c2f3d454a206255687097
 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