diff options
author | Matthew Pickering <matthewtpickering@gmail.com> | 2023-01-23 18:57:59 +0000 |
---|---|---|
committer | Marge Bot <ben+marge-bot@smart-cactus.org> | 2023-01-26 12:34:56 -0500 |
commit | 1262d3f8c03799a04d3c5fcf33d4d4db715ca9a1 (patch) | |
tree | 1411ac2e00207228602eea194c9f1e3ebcce9a60 /compiler/GHC/ByteCode | |
parent | 1bd32a355bd5fc484b641270ca7186e01d1b0c06 (diff) | |
download | haskell-1262d3f8c03799a04d3c5fcf33d4d4db715ca9a1.tar.gz |
Store dehydrated data structures in CgModBreaks
This fixes a tricky leak in GHCi where we were retaining old copies of
HscEnvs when reloading. If not all modules were recompiled then these
hydrated fields in break points would retain a reference to the old
HscEnv which could double memory usage.
Fixes #22530
Diffstat (limited to 'compiler/GHC/ByteCode')
-rw-r--r-- | compiler/GHC/ByteCode/Types.hs | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/compiler/GHC/ByteCode/Types.hs b/compiler/GHC/ByteCode/Types.hs index a4b025ce92..a100e72085 100644 --- a/compiler/GHC/ByteCode/Types.hs +++ b/compiler/GHC/ByteCode/Types.hs @@ -23,12 +23,10 @@ import GHC.Prelude import GHC.Data.FastString import GHC.Data.SizedSeq -import GHC.Types.Id import GHC.Types.Name import GHC.Types.Name.Env import GHC.Utils.Outputable import GHC.Builtin.PrimOps -import GHC.Core.Type import GHC.Types.SrcLoc import GHCi.BreakArray import GHCi.RemoteTypes @@ -41,10 +39,10 @@ import Data.Array.Base ( UArray(..) ) import Data.ByteString (ByteString) import Data.IntMap (IntMap) import qualified Data.IntMap as IntMap -import Data.Maybe (catMaybes) import qualified GHC.Exts.Heap as Heap import GHC.Stack.CCS import GHC.Cmm.Expr ( GlobalRegSet, emptyRegSet, regSetToList ) +import GHC.Iface.Syntax -- ----------------------------------------------------------------------------- -- Compiled Byte Code @@ -174,18 +172,22 @@ instance NFData BCONPtr where rnf x = x `seq` () -- | Information about a breakpoint that we know at code-generation time +-- In order to be used, this needs to be hydrated relative to the current HscEnv by +-- 'hydrateCgBreakInfo'. Everything here can be fully forced and that's critical for +-- preventing space leaks (see #22530) data CgBreakInfo = CgBreakInfo - { cgb_vars :: [Maybe (Id,Word16)] - , cgb_resty :: Type + { cgb_tyvars :: ![IfaceTvBndr] -- ^ Type variables in scope at the breakpoint + , cgb_vars :: ![Maybe (IfaceIdBndr, Word16)] + , cgb_resty :: !IfaceType } -- See Note [Syncing breakpoint info] in GHC.Runtime.Eval --- Not a real NFData instance because we can't rnf Id or Type seqCgBreakInfo :: CgBreakInfo -> () seqCgBreakInfo CgBreakInfo{..} = - rnf (map snd (catMaybes (cgb_vars))) `seq` - seqType cgb_resty + rnf cgb_tyvars `seq` + rnf cgb_vars `seq` + rnf cgb_resty instance Outputable UnlinkedBCO where ppr (UnlinkedBCO nm _arity _insns _bitmap lits ptrs) |