Matthew Pickering pushed to branch wip/iface-patch-9.10-backport at Glasgow Haskell Compiler / GHC
Commits:
-
dde170fc
by Matthew Pickering at 2025-12-18T16:24:12+00:00
11 changed files:
- compiler/GHC/Driver/Main.hs
- compiler/GHC/Iface/Load.hs
- compiler/GHC/Iface/Recomp.hs
- compiler/GHC/Iface/Rename.hs
- compiler/GHC/Iface/Syntax.hs
- compiler/GHC/IfaceToCore.hs
- compiler/GHC/IfaceToCore.hs-boot
- compiler/GHC/Tc/Utils/Backpack.hs
- compiler/GHC/Unit/Module/ModIface.hs
- compiler/GHC/Utils/Binary.hs
- utils/haddock
Changes:
| ... | ... | @@ -1398,7 +1398,7 @@ hscMaybeWriteIface logger dflags is_simple iface old_iface mod_location = do |
| 1398 | 1398 | GHC.Utils.Touch.touch hie_file
|
| 1399 | 1399 | else
|
| 1400 | 1400 | -- See Note [Strictness in ModIface]
|
| 1401 | - forceModIface iface
|
|
| 1401 | + return ()
|
|
| 1402 | 1402 | |
| 1403 | 1403 | --------------------------------------------------------------
|
| 1404 | 1404 | -- NoRecomp handlers
|
| ... | ... | @@ -1172,7 +1172,7 @@ pprModIface unit_state iface |
| 1172 | 1172 | , vcat (map pprUsage (mi_usages iface))
|
| 1173 | 1173 | , vcat (map pprIfaceAnnotation (mi_anns iface))
|
| 1174 | 1174 | , pprFixities (mi_fixities iface)
|
| 1175 | - , vcat [ppr ver $$ nest 2 (ppr decl) | (ver,decl) <- mi_decls iface]
|
|
| 1175 | + , vcat [ppr ver $$ nest 2 (ppr decl) | (IfaceDeclBoxed ver _name _implicitBndrs decl) <- mi_decls iface]
|
|
| 1176 | 1176 | , case mi_extra_decls iface of
|
| 1177 | 1177 | Nothing -> empty
|
| 1178 | 1178 | Just eds -> text "extra decls:"
|
| ... | ... | @@ -1061,31 +1061,36 @@ addFingerprints hsc_env iface0 |
| 1061 | 1061 | -- take a strongly-connected group of declarations and compute
|
| 1062 | 1062 | -- its fingerprint.
|
| 1063 | 1063 | |
| 1064 | + mkBoxedDecl :: Fingerprint -> IfaceDecl -> IfaceDeclBoxed
|
|
| 1065 | + mkBoxedDecl fingerprint decl = IfaceDeclBoxed fingerprint (ifName decl) (ifaceDeclImplicitBndrs decl) decl
|
|
| 1066 | + |
|
| 1064 | 1067 | fingerprint_group :: (OccEnv (OccName,Fingerprint),
|
| 1065 | - [(Fingerprint,IfaceDecl)])
|
|
| 1068 | + [IfaceDeclBoxed])
|
|
| 1066 | 1069 | -> SCC IfaceDeclABI
|
| 1067 | 1070 | -> IO (OccEnv (OccName,Fingerprint),
|
| 1068 | - [(Fingerprint,IfaceDecl)])
|
|
| 1071 | + [IfaceDeclBoxed])
|
|
| 1069 | 1072 | |
| 1070 | 1073 | fingerprint_group (local_env, decls_w_hashes) (AcyclicSCC abi)
|
| 1071 | 1074 | = do let hash_fn = mk_put_name local_env
|
| 1072 | 1075 | decl = abiDecl abi
|
| 1073 | 1076 | --pprTrace "fingerprinting" (ppr (ifName decl) ) $ do
|
| 1074 | 1077 | hash <- computeFingerprint hash_fn abi
|
| 1075 | - env' <- extend_hash_env local_env (hash,decl)
|
|
| 1076 | - return (env', (hash,decl) : decls_w_hashes)
|
|
| 1078 | + env' <- extend_hash_env local_env (mkBoxedDecl hash decl)
|
|
| 1079 | + return (env', mkBoxedDecl hash decl : decls_w_hashes)
|
|
| 1080 | + |
|
| 1081 | + |
|
| 1077 | 1082 | |
| 1078 | 1083 | fingerprint_group (local_env, decls_w_hashes) (CyclicSCC abis)
|
| 1079 | 1084 | = do let stable_abis = sortBy cmp_abiNames abis
|
| 1080 | 1085 | stable_decls = map abiDecl stable_abis
|
| 1081 | 1086 | local_env1 <- foldM extend_hash_env local_env
|
| 1082 | - (zip (map mkRecFingerprint [0..]) stable_decls)
|
|
| 1087 | + (zipWith mkBoxedDecl (map mkRecFingerprint [0..]) stable_decls)
|
|
| 1083 | 1088 | -- See Note [Fingerprinting recursive groups]
|
| 1084 | 1089 | let hash_fn = mk_put_name local_env1
|
| 1085 | 1090 | -- pprTrace "fingerprinting" (ppr (map ifName decls) ) $ do
|
| 1086 | 1091 | -- put the cycle in a canonical order
|
| 1087 | 1092 | hash <- computeFingerprint hash_fn stable_abis
|
| 1088 | - let pairs = zip (map (bumpFingerprint hash) [0..]) stable_decls
|
|
| 1093 | + let pairs = zipWith mkBoxedDecl (map (bumpFingerprint hash) [0..]) stable_decls
|
|
| 1089 | 1094 | -- See Note [Fingerprinting recursive groups]
|
| 1090 | 1095 | local_env2 <- foldM extend_hash_env local_env pairs
|
| 1091 | 1096 | return (local_env2, pairs ++ decls_w_hashes)
|
| ... | ... | @@ -1102,11 +1107,11 @@ addFingerprints hsc_env iface0 |
| 1102 | 1107 | -- use when referencing those OccNames in later declarations.
|
| 1103 | 1108 | --
|
| 1104 | 1109 | extend_hash_env :: OccEnv (OccName,Fingerprint)
|
| 1105 | - -> (Fingerprint,IfaceDecl)
|
|
| 1106 | - -> IO (OccEnv (OccName,Fingerprint))
|
|
| 1107 | - extend_hash_env env0 (hash,d) =
|
|
| 1110 | + -> IfaceDeclBoxed
|
|
| 1111 | + -> IO (OccEnv (OccName,Fingerprint))
|
|
| 1112 | + extend_hash_env env0 boxed =
|
|
| 1108 | 1113 | return (foldr (\(b,fp) env -> extendOccEnv env b (b,fp)) env0
|
| 1109 | - (ifaceDeclFingerprints hash d))
|
|
| 1114 | + (ifaceDeclFingerprints boxed))
|
|
| 1110 | 1115 | |
| 1111 | 1116 | --
|
| 1112 | 1117 | (local_env, decls_w_hashes) <-
|
| ... | ... | @@ -1179,38 +1184,11 @@ addFingerprints hsc_env iface0 |
| 1179 | 1184 | mi_trust iface0)
|
| 1180 | 1185 | -- Make sure change of Safe Haskell mode causes recomp.
|
| 1181 | 1186 | |
| 1182 | - -- Note [Export hash depends on non-orphan family instances]
|
|
| 1183 | - -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
| 1184 | - --
|
|
| 1185 | - -- Suppose we have:
|
|
| 1186 | - --
|
|
| 1187 | - -- module A where
|
|
| 1188 | - -- type instance F Int = Bool
|
|
| 1189 | - --
|
|
| 1190 | - -- module B where
|
|
| 1191 | - -- import A
|
|
| 1192 | - --
|
|
| 1193 | - -- module C where
|
|
| 1194 | - -- import B
|
|
| 1195 | - --
|
|
| 1196 | - -- The family instance consistency check for C depends on the dep_finsts of
|
|
| 1197 | - -- B. If we rename module A to A2, when the dep_finsts of B changes, we need
|
|
| 1198 | - -- to make sure that C gets rebuilt. Effectively, the dep_finsts are part of
|
|
| 1199 | - -- the exports of B, because C always considers them when checking
|
|
| 1200 | - -- consistency.
|
|
| 1201 | - --
|
|
| 1202 | - -- A full discussion is in #12723.
|
|
| 1203 | - --
|
|
| 1204 | - -- We do NOT need to hash dep_orphs, because this is implied by
|
|
| 1205 | - -- dep_orphan_hashes, and we do not need to hash ordinary class instances,
|
|
| 1206 | - -- because there is no eager consistency check as there is with type families
|
|
| 1207 | - -- (also we didn't store it anywhere!)
|
|
| 1208 | - --
|
|
| 1209 | 1187 | |
| 1210 | 1188 | -- put the declarations in a canonical order, sorted by OccName
|
| 1211 | - let sorted_decls :: [(Fingerprint, IfaceDecl)]
|
|
| 1189 | + let sorted_decls :: [IfaceDeclBoxed]
|
|
| 1212 | 1190 | sorted_decls = Map.elems $ Map.fromList $
|
| 1213 | - [(getOccName d, e) | e@(_, d) <- decls_w_hashes]
|
|
| 1191 | + [(getOccName name, e) | e@(IfaceDeclBoxed _ name _ _) <- decls_w_hashes]
|
|
| 1214 | 1192 | |
| 1215 | 1193 | -- This key is safe because mi_extra_decls contains tidied things.
|
| 1216 | 1194 | getOcc (IfGblTopBndr b) = getOccName b
|
| ... | ... | @@ -1246,7 +1224,7 @@ addFingerprints hsc_env iface0 |
| 1246 | 1224 | -- - flag abi hash
|
| 1247 | 1225 | -- - foreign stubs and files
|
| 1248 | 1226 | mod_hash <- computeFingerprint putNameLiterally
|
| 1249 | - (map fst sorted_decls,
|
|
| 1227 | + (map ifBoxedFingerprint sorted_decls,
|
|
| 1250 | 1228 | export_hash, -- includes orphan_hash
|
| 1251 | 1229 | mi_warns iface0,
|
| 1252 | 1230 | mi_foreign iface0)
|
| ... | ... | @@ -38,7 +38,6 @@ import GHC.Types.Name.Shape |
| 38 | 38 | import GHC.Utils.Outputable
|
| 39 | 39 | import GHC.Utils.Misc
|
| 40 | 40 | import GHC.Utils.Error
|
| 41 | -import GHC.Utils.Fingerprint
|
|
| 42 | 41 | import GHC.Utils.Panic
|
| 43 | 42 | |
| 44 | 43 | import qualified Data.Traversable as T
|
| ... | ... | @@ -416,8 +415,8 @@ rnIfaceFamInst d = do |
| 416 | 415 | axiom <- rnIfaceGlobal (ifFamInstAxiom d)
|
| 417 | 416 | return d { ifFamInstFam = fam, ifFamInstTys = tys, ifFamInstAxiom = axiom }
|
| 418 | 417 | |
| 419 | -rnIfaceDecl' :: Rename (Fingerprint, IfaceDecl)
|
|
| 420 | -rnIfaceDecl' (fp, decl) = (,) fp <$> rnIfaceDecl decl
|
|
| 418 | +rnIfaceDecl' :: Rename IfaceDeclBoxed
|
|
| 419 | +rnIfaceDecl' (IfaceDeclBoxed fp _ _ decl) = mkBoxedDecl fp <$> rnIfaceDecl decl
|
|
| 421 | 420 | |
| 422 | 421 | rnIfaceDecl :: Rename IfaceDecl
|
| 423 | 422 | rnIfaceDecl d@IfaceId{} = do
|
| ... | ... | @@ -28,6 +28,8 @@ module GHC.Iface.Syntax ( |
| 28 | 28 | IfaceImport(..),
|
| 29 | 29 | ImpIfaceList(..),
|
| 30 | 30 | |
| 31 | + IfaceDeclBoxed(..), mkBoxedDecl,
|
|
| 32 | + |
|
| 31 | 33 | -- * Binding names
|
| 32 | 34 | IfaceTopBndr,
|
| 33 | 35 | putIfaceTopBndr, getIfaceTopBndr,
|
| ... | ... | @@ -139,6 +141,31 @@ putIfaceTopBndr bh name = |
| 139 | 141 | --pprTrace "putIfaceTopBndr" (ppr name) $
|
| 140 | 142 | putEntry tbl bh (BindingName name)
|
| 141 | 143 | |
| 144 | +-- | A wrapper around IfaceDecl which separates parts which are needed eagerly from parts which are needed lazily.
|
|
| 145 | +data IfaceDeclBoxed
|
|
| 146 | + = IfaceDeclBoxed {
|
|
| 147 | + ifBoxedFingerprint :: !Fingerprint,
|
|
| 148 | + ifBoxedName :: !IfaceTopBndr,
|
|
| 149 | + ifBoxedImplicitBndrs :: ![OccName],
|
|
| 150 | + ifBoxedDecl :: IfaceDecl
|
|
| 151 | + }
|
|
| 152 | + |
|
| 153 | +mkBoxedDecl :: Fingerprint -> IfaceDecl -> IfaceDeclBoxed
|
|
| 154 | +mkBoxedDecl fingerprint decl = IfaceDeclBoxed fingerprint (ifName decl) (ifaceDeclImplicitBndrs decl) decl
|
|
| 155 | + |
|
| 156 | +instance Binary IfaceDeclBoxed where
|
|
| 157 | + put_ bh (IfaceDeclBoxed fingerprint name implicitBndrs decl) = do
|
|
| 158 | + put_ bh fingerprint
|
|
| 159 | + put_ bh name
|
|
| 160 | + put_ bh implicitBndrs
|
|
| 161 | + lazyPut bh decl
|
|
| 162 | + get bh = do
|
|
| 163 | + fingerprint <- get bh
|
|
| 164 | + name <- get bh
|
|
| 165 | + implicitBndrs <- get @[OccName] bh
|
|
| 166 | + decl <- lazyGet bh
|
|
| 167 | + return $ IfaceDeclBoxed fingerprint name implicitBndrs decl
|
|
| 168 | + |
|
| 142 | 169 | data IfaceDecl
|
| 143 | 170 | = IfaceId { ifName :: IfaceTopBndr,
|
| 144 | 171 | ifType :: IfaceType,
|
| ... | ... | @@ -587,11 +614,12 @@ ifaceConDeclImplicitBndrs (IfCon { |
| 587 | 614 | -- different fingerprint! So we calculate the fingerprint of
|
| 588 | 615 | -- each binder by combining the fingerprint of the whole
|
| 589 | 616 | -- declaration with the name of the binder. (#5614, #7215)
|
| 590 | -ifaceDeclFingerprints :: Fingerprint -> IfaceDecl -> [(OccName,Fingerprint)]
|
|
| 591 | -ifaceDeclFingerprints hash decl
|
|
| 592 | - = (getOccName decl, hash) :
|
|
| 617 | +ifaceDeclFingerprints :: IfaceDeclBoxed -> [(OccName,Fingerprint)]
|
|
| 618 | +ifaceDeclFingerprints (IfaceDeclBoxed hash name implicitBndrs _)
|
|
| 619 | + = (getOccName name, hash) :
|
|
| 593 | 620 | [ (occ, computeFingerprint' (hash,occ))
|
| 594 | - | occ <- ifaceDeclImplicitBndrs decl ]
|
|
| 621 | + -- TODO: maybe more laziness here
|
|
| 622 | + | occ <- implicitBndrs ]
|
|
| 595 | 623 | where
|
| 596 | 624 | computeFingerprint' =
|
| 597 | 625 | unsafeDupablePerformIO
|
| ... | ... | @@ -421,17 +421,17 @@ typecheckIfacesForMerging mod ifaces tc_env_vars = |
| 421 | 421 | -- serialize them out. See Note [rnIfaceNeverExported] in GHC.Iface.Rename
|
| 422 | 422 | -- NB: But coercions are OK, because they will have the right OccName.
|
| 423 | 423 | let mk_decl_env decls
|
| 424 | - = mkOccEnv [ (getOccName decl, decl)
|
|
| 425 | - | decl <- decls
|
|
| 424 | + = mkOccEnv [ (getOccName name, decl)
|
|
| 425 | + | (name, decl) <- decls
|
|
| 426 | 426 | , case decl of
|
| 427 | 427 | IfaceId { ifIdDetails = IfDFunId } -> False -- exclude DFuns
|
| 428 | 428 | _ -> True ]
|
| 429 | - decl_envs = map (mk_decl_env . map snd . mi_decls) ifaces
|
|
| 429 | + decl_envs = map (mk_decl_env . map (\(IfaceDeclBoxed _ name _ decl) -> (name, decl)) . mi_decls) ifaces
|
|
| 430 | 430 | :: [OccEnv IfaceDecl]
|
| 431 | 431 | decl_env = foldl' mergeIfaceDecls emptyOccEnv decl_envs
|
| 432 | 432 | :: OccEnv IfaceDecl
|
| 433 | 433 | -- TODO: change tcIfaceDecls to accept w/o Fingerprint
|
| 434 | - names_w_things <- tcIfaceDecls ignore_prags (map (\x -> (fingerprint0, x))
|
|
| 434 | + names_w_things <- tcIfaceDecls ignore_prags (map (\x -> mkBoxedDecl fingerprint0 x)
|
|
| 435 | 435 | (nonDetOccEnvElts decl_env))
|
| 436 | 436 | let global_type_env = mkNameEnv names_w_things
|
| 437 | 437 | case lookupKnotVars tc_env_vars mod of
|
| ... | ... | @@ -947,19 +947,18 @@ mk_top_id (IfLclTopBndr raw_name iface_type info details) = do |
| 947 | 947 | return new_id
|
| 948 | 948 | |
| 949 | 949 | tcIfaceDecls :: Bool
|
| 950 | - -> [(Fingerprint, IfaceDecl)]
|
|
| 950 | + -> [IfaceDeclBoxed]
|
|
| 951 | 951 | -> IfL [(Name,TyThing)]
|
| 952 | 952 | tcIfaceDecls ignore_prags ver_decls
|
| 953 | 953 | = concatMapM (tc_iface_decl_fingerprint ignore_prags) ver_decls
|
| 954 | 954 | |
| 955 | 955 | tc_iface_decl_fingerprint :: Bool -- Don't load pragmas into the decl pool
|
| 956 | - -> (Fingerprint, IfaceDecl)
|
|
| 956 | + -> IfaceDeclBoxed
|
|
| 957 | 957 | -> IfL [(Name,TyThing)] -- The list can be poked eagerly, but the
|
| 958 | 958 | -- TyThings are forkM'd thunks
|
| 959 | -tc_iface_decl_fingerprint ignore_prags (_version, decl)
|
|
| 959 | +tc_iface_decl_fingerprint ignore_prags (IfaceDeclBoxed _fingerprint main_name implicitBndrs decl)
|
|
| 960 | 960 | = do { -- Populate the name cache with final versions of all
|
| 961 | 961 | -- the names associated with the decl
|
| 962 | - let main_name = ifName decl
|
|
| 963 | 962 | |
| 964 | 963 | -- Typecheck the thing, lazily
|
| 965 | 964 | -- NB. Firstly, the laziness is there in case we never need the
|
| ... | ... | @@ -1032,7 +1031,7 @@ tc_iface_decl_fingerprint ignore_prags (_version, decl) |
| 1032 | 1031 | Nothing ->
|
| 1033 | 1032 | pprPanic "tc_iface_decl_fingerprint" (ppr main_name <+> ppr n $$ ppr (decl))
|
| 1034 | 1033 | |
| 1035 | - ; implicit_names <- mapM lookupIfaceTop (ifaceDeclImplicitBndrs decl)
|
|
| 1034 | + ; implicit_names <- mapM lookupIfaceTop implicitBndrs
|
|
| 1036 | 1035 | |
| 1037 | 1036 | -- ; traceIf (text "Loading decl for " <> ppr main_name $$ ppr implicit_names)
|
| 1038 | 1037 | ; return $ (main_name, thing) :
|
| ... | ... | @@ -2,7 +2,7 @@ module GHC.IfaceToCore where |
| 2 | 2 | |
| 3 | 3 | import GHC.Prelude
|
| 4 | 4 | import GHC.Iface.Syntax ( IfaceDecl, IfaceClsInst, IfaceFamInst, IfaceRule
|
| 5 | - , IfaceAnnotation, IfaceCompleteMatch )
|
|
| 5 | + , IfaceAnnotation, IfaceCompleteMatch, IfaceDeclBoxed )
|
|
| 6 | 6 | import GHC.Types.TyThing ( TyThing )
|
| 7 | 7 | import GHC.Tc.Types ( IfL )
|
| 8 | 8 | import GHC.Core.InstEnv ( ClsInst )
|
| ... | ... | @@ -11,7 +11,6 @@ import GHC.Core ( CoreRule ) |
| 11 | 11 | import GHC.Types.CompleteMatch
|
| 12 | 12 | import GHC.Types.Annotations ( Annotation )
|
| 13 | 13 | import GHC.Types.Name
|
| 14 | -import GHC.Fingerprint.Type
|
|
| 15 | 14 | |
| 16 | 15 | tcIfaceDecl :: Bool -> IfaceDecl -> IfL TyThing
|
| 17 | 16 | tcIfaceRules :: Bool -> [IfaceRule] -> IfL [CoreRule]
|
| ... | ... | @@ -19,4 +18,4 @@ tcIfaceInst :: IfaceClsInst -> IfL ClsInst |
| 19 | 18 | tcIfaceFamInst :: IfaceFamInst -> IfL FamInst
|
| 20 | 19 | tcIfaceAnnotations :: [IfaceAnnotation] -> IfL [Annotation]
|
| 21 | 20 | tcIfaceCompleteMatches :: [IfaceCompleteMatch] -> IfL [CompleteMatch]
|
| 22 | -tcIfaceDecls :: Bool -> [(Fingerprint, IfaceDecl)] -> IfL [(Name,TyThing)] |
|
| 21 | +tcIfaceDecls :: Bool -> [IfaceDeclBoxed] -> IfL [(Name,TyThing)] |
| ... | ... | @@ -379,12 +379,12 @@ thinModIface avails iface = |
| 379 | 379 | -- perhaps there might be two IfaceTopBndr that are the same
|
| 380 | 380 | -- OccName but different Name. Requires better understanding
|
| 381 | 381 | -- of invariants here.
|
| 382 | - & set_mi_decls (exported_decls ++ non_exported_decls ++ dfun_decls)
|
|
| 382 | + & set_mi_decls (exported_decls ++ non_exported_decls ++ dfun_decls)
|
|
| 383 | 383 | -- mi_insts = ...,
|
| 384 | 384 | -- mi_fam_insts = ...,
|
| 385 | 385 | where
|
| 386 | - decl_pred occs decl = nameOccName (ifName decl) `elemOccSet` occs
|
|
| 387 | - filter_decls occs = filter (decl_pred occs . snd) (mi_decls iface)
|
|
| 386 | + decl_pred occs name = nameOccName name `elemOccSet` occs
|
|
| 387 | + filter_decls occs = filter (decl_pred occs . ifBoxedName) (mi_decls iface)
|
|
| 388 | 388 | |
| 389 | 389 | exported_occs = mkOccSet [ nameOccName n
|
| 390 | 390 | | a <- avails
|
| ... | ... | @@ -392,13 +392,13 @@ thinModIface avails iface = |
| 392 | 392 | exported_decls = filter_decls exported_occs
|
| 393 | 393 | |
| 394 | 394 | non_exported_occs = mkOccSet [ occName n
|
| 395 | - | (_, d) <- exported_decls
|
|
| 395 | + | IfaceDeclBoxed _ _ _ d <- exported_decls
|
|
| 396 | 396 | , n <- ifaceDeclNeverExportedRefs d ]
|
| 397 | 397 | non_exported_decls = filter_decls non_exported_occs
|
| 398 | 398 | |
| 399 | 399 | dfun_pred IfaceId{ ifIdDetails = IfDFunId } = True
|
| 400 | 400 | dfun_pred _ = False
|
| 401 | - dfun_decls = filter (dfun_pred . snd) (mi_decls iface)
|
|
| 401 | + dfun_decls = filter (dfun_pred . ifBoxedDecl) (mi_decls iface)
|
|
| 402 | 402 | |
| 403 | 403 | -- | The list of 'Name's of *non-exported* 'IfaceDecl's which this
|
| 404 | 404 | -- 'IfaceDecl' may refer to. A non-exported 'IfaceDecl' should be kept
|
| ... | ... | @@ -121,8 +121,6 @@ import GHC.Utils.Fingerprint |
| 121 | 121 | import GHC.Utils.Binary
|
| 122 | 122 | |
| 123 | 123 | import Control.DeepSeq
|
| 124 | -import Control.Exception
|
|
| 125 | -import qualified GHC.Data.Strict as Strict
|
|
| 126 | 124 | |
| 127 | 125 | {- Note [Interface file stages]
|
| 128 | 126 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
| ... | ... | @@ -198,7 +196,7 @@ data ModIfacePhase |
| 198 | 196 | -- a fingerprint, which is used for recompilation checks.
|
| 199 | 197 | type family IfaceDeclExts (phase :: ModIfacePhase) = decl | decl -> phase where
|
| 200 | 198 | IfaceDeclExts 'ModIfaceCore = IfaceDecl
|
| 201 | - IfaceDeclExts 'ModIfaceFinal = (Fingerprint, IfaceDecl)
|
|
| 199 | + IfaceDeclExts 'ModIfaceFinal = IfaceDeclBoxed
|
|
| 202 | 200 | |
| 203 | 201 | type family IfaceBackendExts (phase :: ModIfacePhase) = bk | bk -> phase where
|
| 204 | 202 | IfaceBackendExts 'ModIfaceCore = ()
|
| ... | ... | @@ -656,13 +654,13 @@ emptyFullModIface mod = |
| 656 | 654 | mi_hash_fn = emptyIfaceHashCache } }
|
| 657 | 655 | |
| 658 | 656 | -- | Constructs cache for the 'mi_hash_fn' field of a 'ModIface'
|
| 659 | -mkIfaceHashCache :: [(Fingerprint,IfaceDecl)]
|
|
| 657 | +mkIfaceHashCache :: [IfaceDeclBoxed]
|
|
| 660 | 658 | -> (OccName -> Maybe (OccName, Fingerprint))
|
| 661 | 659 | mkIfaceHashCache pairs
|
| 662 | 660 | = \occ -> lookupOccEnv env occ
|
| 663 | 661 | where
|
| 664 | 662 | env = foldl' add_decl emptyOccEnv pairs
|
| 665 | - add_decl env0 (v,d) = foldl' add env0 (ifaceDeclFingerprints v d)
|
|
| 663 | + add_decl env0 v = foldl' add env0 (ifaceDeclFingerprints v)
|
|
| 666 | 664 | where
|
| 667 | 665 | add env0 (occ,hash) = extendOccEnv env0 occ (occ,hash)
|
| 668 | 666 | |
| ... | ... | @@ -729,9 +727,8 @@ instance NFData (ModIfaceBackend) where |
| 729 | 727 | `seq` rnf mi_fix_fn
|
| 730 | 728 | `seq` rnf mi_hash_fn
|
| 731 | 729 | |
| 732 | - |
|
| 733 | 730 | forceModIface :: ModIface -> IO ()
|
| 734 | -forceModIface iface = () <$ (evaluate $ force iface)
|
|
| 731 | +forceModIface _ = return ()
|
|
| 735 | 732 | |
| 736 | 733 | -- | Records whether a module has orphans. An \"orphan\" is one of:
|
| 737 | 734 | --
|
| ... | ... | @@ -774,7 +771,7 @@ to serialise the 'ModIface' to disk again. |
| 774 | 771 | -- | Given a 'PartialModIface', turn it into a 'ModIface' by completing
|
| 775 | 772 | -- missing fields.
|
| 776 | 773 | completePartialModIface :: PartialModIface
|
| 777 | - -> [(Fingerprint, IfaceDecl)]
|
|
| 774 | + -> [IfaceDeclBoxed]
|
|
| 778 | 775 | -> Maybe [IfaceBindingX IfaceMaybeRhs IfaceTopBndrInfo]
|
| 779 | 776 | -> ModIfaceBackend
|
| 780 | 777 | -> ModIface
|
| ... | ... | @@ -124,6 +124,8 @@ import GHC.Types.SrcLoc |
| 124 | 124 | import GHC.Types.Unique
|
| 125 | 125 | import qualified GHC.Data.Strict as Strict
|
| 126 | 126 | import GHC.Utils.Outputable( JoinPointHood(..) )
|
| 127 | +import GHCi.FFI
|
|
| 128 | +import GHCi.Message
|
|
| 127 | 129 | |
| 128 | 130 | import Control.DeepSeq
|
| 129 | 131 | import Control.Monad ( when, (<$!>), unless, forM_, void )
|
| ... | ... | @@ -157,6 +159,9 @@ import qualified Data.IntMap as IntMap |
| 157 | 159 | #if MIN_VERSION_base(4,15,0)
|
| 158 | 160 | import GHC.ForeignPtr ( unsafeWithForeignPtr )
|
| 159 | 161 | #endif
|
| 162 | +import GHC.Stack
|
|
| 163 | +import GHC.Utils.Outputable
|
|
| 164 | + |
|
| 160 | 165 | |
| 161 | 166 | import Unsafe.Coerce (unsafeCoerce)
|
| 162 | 167 | |
| ... | ... | @@ -1321,7 +1326,7 @@ forwardGetRel bh get_A = do |
| 1321 | 1326 | lazyPut :: Binary a => WriteBinHandle -> a -> IO ()
|
| 1322 | 1327 | lazyPut = lazyPut' put_
|
| 1323 | 1328 | |
| 1324 | -lazyGet :: Binary a => ReadBinHandle -> IO a
|
|
| 1329 | +lazyGet :: (HasCallStack, Binary a) => ReadBinHandle -> IO a
|
|
| 1325 | 1330 | lazyGet = lazyGet' get
|
| 1326 | 1331 | |
| 1327 | 1332 | lazyPut' :: (WriteBinHandle -> a -> IO ()) -> WriteBinHandle -> a -> IO ()
|
| ... | ... | @@ -1334,13 +1339,20 @@ lazyPut' f bh a = do |
| 1334 | 1339 | putAtRel bh pre_a q -- fill in slot before a with ptr to q
|
| 1335 | 1340 | seekBinWriter bh q -- finally carry on writing at q
|
| 1336 | 1341 | |
| 1337 | -lazyGet' :: (ReadBinHandle -> IO a) -> ReadBinHandle -> IO a
|
|
| 1342 | +lazyGet' :: HasCallStack =>(ReadBinHandle -> IO a) -> ReadBinHandle -> IO a
|
|
| 1338 | 1343 | lazyGet' f bh = do
|
| 1339 | 1344 | p <- getRelBin bh -- a BinPtr
|
| 1340 | 1345 | p_a <- tellBinReader bh
|
| 1341 | 1346 | a <- unsafeInterleaveIO $ do
|
| 1342 | 1347 | -- NB: Use a fresh rbm_off_r variable in the child thread, for thread
|
| 1343 | 1348 | -- safety.
|
| 1349 | + {-
|
|
| 1350 | + stack <- cloneMyStack
|
|
| 1351 | + decoded_stack <- decode stack
|
|
| 1352 | + let printId (StackEntry fn mn _ _) = text fn <+> text mn
|
|
| 1353 | + pprTraceM "lazyGet" (callStackDoc $$ vcat (map printId decoded_stack))
|
|
| 1354 | + -}
|
|
| 1355 | + |
|
| 1344 | 1356 | off_r <- newFastMutInt 0
|
| 1345 | 1357 | let bh' = bh { rbm_off_r = off_r }
|
| 1346 | 1358 | seekBinReader bh' p_a
|
| 1 | -Subproject commit ba88561db028296eaf1ad58e9a0d51ef385b7eea |
|
| 1 | +Subproject commit 4da264f42c35e3e302f8a8579d41f6521c7337ee |