summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthew Pickering <matthewtpickering@gmail.com>2021-10-15 09:39:18 +0100
committerMarge Bot <ben+marge-bot@smart-cactus.org>2021-10-19 03:31:27 -0400
commitfdfb3b03baaa81a532a7e4554e13ccd4d342461e (patch)
treefdf0489b85308ece564d3aa128159f6ca3f3f5ad
parent53c0e771afa97083ce2addf8d30c7526025869a5 (diff)
downloadhaskell-fdfb3b03baaa81a532a7e4554e13ccd4d342461e.tar.gz
Make the fields of Target and TargetId strict
Targets are long-lived through GHC sessions so we don't want to end up retaining In particular in 'guessTarget', the call to `unitIdOrHomeUnit` was retaining reference to an entire stale HscEnv, which in turn retained reference to a stale HomePackageTable. Making the fields strict forces that place promptly and helps ensure that mistakes like this don't happen again.
-rw-r--r--compiler/GHC/Types/Target.hs14
1 files changed, 8 insertions, 6 deletions
diff --git a/compiler/GHC/Types/Target.hs b/compiler/GHC/Types/Target.hs
index 6599bdac4a..191f84eb2f 100644
--- a/compiler/GHC/Types/Target.hs
+++ b/compiler/GHC/Types/Target.hs
@@ -21,12 +21,14 @@ import Data.Time
-- module. If so, use this instead of the file contents (this
-- is for use in an IDE where the file hasn't been saved by
-- the user yet).
+--
+-- These fields are strict because Targets are long lived.
data Target
= Target {
- targetId :: TargetId, -- ^ module or filename
- targetAllowObjCode :: Bool, -- ^ object code allowed?
- targetUnitId :: UnitId, -- ^ id of the unit this target is part of
- targetContents :: Maybe (InputFileBuffer, UTCTime)
+ targetId :: !TargetId, -- ^ module or filename
+ targetAllowObjCode :: !Bool, -- ^ object code allowed?
+ targetUnitId :: !UnitId, -- ^ id of the unit this target is part of
+ targetContents :: !(Maybe (InputFileBuffer, UTCTime))
-- ^ Optional in-memory buffer containing the source code GHC should
-- use for this target instead of reading it from disk.
--
@@ -40,9 +42,9 @@ data Target
}
data TargetId
- = TargetModule ModuleName
+ = TargetModule !ModuleName
-- ^ A module name: search for the file
- | TargetFile FilePath (Maybe Phase)
+ | TargetFile !FilePath !(Maybe Phase)
-- ^ A filename: preprocess & parse it to find the module name.
-- If specified, the Phase indicates how to compile this file
-- (which phase to start from). Nothing indicates the starting phase