Skip to content

Commit 5ec2b6c

Browse files
committed
Unload once per linkable instead of once per splice
1 parent f7d0219 commit 5ec2b6c

File tree

2 files changed

+5
-8
lines changed

2 files changed

+5
-8
lines changed

Diff for: ghcide/src/Development/IDE/Core/Compile.hs

+1-7
Original file line numberDiff line numberDiff line change
@@ -160,8 +160,7 @@ computePackageDeps env pkg = do
160160

161161
data TypecheckHelpers
162162
= TypecheckHelpers
163-
{ getLinkablesToKeep :: !(IO (ModuleEnv UTCTime))
164-
, getLinkables :: !([NormalizedFilePath] -> IO [LinkableResult])
163+
{ getLinkables :: !([NormalizedFilePath] -> IO [LinkableResult])
165164
}
166165

167166
typecheckModule :: IdeDefer
@@ -327,11 +326,6 @@ captureSplicesAndDeps TypecheckHelpers{..} env k = do
327326
]
328327
; let hsc_env' = loadModulesHome (map linkableHomeMod lbs) hsc_env
329328

330-
-- Essential to do this here after we load the linkables
331-
; keep_lbls <- getLinkablesToKeep
332-
333-
; unload hsc_env' $ map (\(mod, time) -> LM time mod []) $ moduleEnvToList keep_lbls
334-
335329
#if MIN_VERSION_ghc(9,3,0)
336330
{- load it -}
337331
; (fv_hvs, lbss, pkgs) <- loadDecls (hscInterp hsc_env') hsc_env' srcspan bcos

Diff for: ghcide/src/Development/IDE/Core/Rules.hs

+4-1
Original file line numberDiff line numberDiff line change
@@ -1119,7 +1119,10 @@ getLinkableRule recorder =
11191119
-- Record the linkable so we know not to unload it
11201120
whenJust (hm_linkable =<< hmi) $ \(LM time mod _) -> do
11211121
compiledLinkables <- getCompiledLinkables <$> getIdeGlobalAction
1122-
liftIO $ void $ modifyVar' compiledLinkables $ \old -> extendModuleEnv old mod time
1122+
liftIO $ modifyVar compiledLinkables $ \old -> do
1123+
let !to_keep = extendModuleEnv old mod time
1124+
unload (hscEnv session) (map (\(mod, time) -> LM time mod []) $ moduleEnvToList to_keep)
1125+
return (to_keep, ())
11231126
return (hash <$ hmi, (warns, LinkableResult <$> hmi <*> pure hash))
11241127

11251128
-- | For now we always use bytecode unless something uses unboxed sums and tuples along with TH

0 commit comments

Comments
 (0)