[Git][ghc/ghc][wip/24107] compiler: Force IfGlobalRdrEnv in NFData instance.
Zubin (@wz1000)
gitlab at gitlab.haskell.org
Thu Dec 7 08:51:21 UTC 2023
Zubin pushed to branch wip/24107 at Glasgow Haskell Compiler / GHC
Commits:
59e7b766 by Zubin Duggal at 2023-12-07T14:21:14+05:30
compiler: Force IfGlobalRdrEnv in NFData instance.
- - - - -
2 changed files:
- compiler/GHC/Types/Name/Reader.hs
- compiler/GHC/Unit/Module/ModIface.hs
Changes:
=====================================
compiler/GHC/Types/Name/Reader.hs
=====================================
@@ -574,6 +574,9 @@ data GlobalRdrEltX info
-- Note [Retrieving the GREInfo from interfaces] in GHC.Types.GREInfo.
} deriving (Data)
+instance NFData a => NFData (GlobalRdrEltX a) where
+ rnf (GRE name par _ imp info) = rnf name `seq` rnf par `seq` rnf imp `seq` rnf info
+
{- Note [IfGlobalRdrEnv]
~~~~~~~~~~~~~~~~~~~~~~~~
@@ -620,18 +623,19 @@ greParent = gre_par
greInfo :: GlobalRdrElt -> GREInfo
greInfo = gre_info
-instance NFData IfGlobalRdrElt where
- rnf !_ = ()
-
-- | See Note [Parents]
data Parent = NoParent
- | ParentIs { par_is :: Name }
+ | ParentIs { par_is :: !Name }
deriving (Eq, Data)
instance Outputable Parent where
ppr NoParent = empty
ppr (ParentIs n) = text "parent:" <> ppr n
+instance NFData Parent where
+ rnf NoParent = ()
+ rnf (ParentIs n) = rnf n
+
plusParent :: Parent -> Parent -> Parent
-- See Note [Combining parents]
plusParent p1@(ParentIs _) p2 = hasParent p1 p2
@@ -934,11 +938,10 @@ globalRdrEnvElts env = nonDetFoldOccEnv (++) [] env
-- | Drop all 'GREInfo' fields in a 'GlobalRdrEnv' in order to
-- avoid space leaks.
--- Also forces the bag in gre_imp.
-- See Note [Forcing GREInfo] in GHC.Types.GREInfo.
forceGlobalRdrEnv :: GlobalRdrEnvX info -> IfGlobalRdrEnv
forceGlobalRdrEnv rdrs =
- strictMapOccEnv (strictMap (\ gre -> rnf (gre_imp gre) `seq` gre { gre_info = ()})) rdrs
+ strictMapOccEnv (strictMap (\ gre -> gre { gre_info = ()})) rdrs
-- | Hydrate a previously dehydrated 'GlobalRdrEnv',
-- by (lazily!) looking up the 'GREInfo' using the provided function.
=====================================
compiler/GHC/Unit/Module/ModIface.hs
=====================================
@@ -575,11 +575,7 @@ instance ( NFData (IfaceBackendExts (phase :: ModIfacePhase))
`seq` rnf mi_anns
`seq` rnf mi_decls
`seq` rnf mi_extra_decls
- `seq` mi_globals
- -- NB: we already removed any potential space leaks in 'mi_globals' by
- -- dehydrating, that is, by turning the 'GlobalRdrEnv' into a 'IfGlobalRdrEnv'.
- -- This means we don't need to use 'rnf' here.
- -- See Note [Forcing GREInfo] in GHC.Types.GREInfo.
+ `seq` rnf mi_globals
`seq` rnf mi_insts
`seq` rnf mi_fam_insts
`seq` rnf mi_rules
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/59e7b76695677b6173d2cbd5b8a8b14dcfcf4842
--
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/59e7b76695677b6173d2cbd5b8a8b14dcfcf4842
You're receiving this email because of your account on gitlab.haskell.org.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/ghc-commits/attachments/20231207/e7f2469b/attachment-0001.html>
More information about the ghc-commits
mailing list