diff options
author | Jason Eisenberg <jasoneisenberg@gmail.com> | 2016-03-05 20:00:38 +0100 |
---|---|---|
committer | Ben Gamari <ben@smart-cactus.org> | 2016-03-05 20:00:56 +0100 |
commit | 6ca9b15f77e58931953edb7c872b803cb261fce9 (patch) | |
tree | 35e118570baaefdc85faf34df0970f3fafdfae1f /compiler/main/GhcMake.hs | |
parent | 120b9cdb31878ecee442c0a4bb9532a9d30c0c64 (diff) | |
download | haskell-6ca9b15f77e58931953edb7c872b803cb261fce9.tar.gz |
GHCi: Fix load/reload space leaks (#4029)
This patch addresses GHCi load/reload space leaks which could be
fixed without adversely affecting performance.
Test Plan: make test "TEST=T4029"
Reviewers: austin, bgamari
Reviewed By: bgamari
Subscribers: mpickering, thomie
Differential Revision: https://phabricator.haskell.org/D1950
GHC Trac Issues: #4029
Diffstat (limited to 'compiler/main/GhcMake.hs')
-rw-r--r-- | compiler/main/GhcMake.hs | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/compiler/main/GhcMake.hs b/compiler/main/GhcMake.hs index 1729a5bfdc..62321195f2 100644 --- a/compiler/main/GhcMake.hs +++ b/compiler/main/GhcMake.hs @@ -367,7 +367,10 @@ load how_much = do liftIO $ intermediateCleanTempFiles dflags mods_to_keep hsc_env1 -- there should be no Nothings where linkables should be, now - ASSERT(all (isJust.hm_linkable) (eltsUFM (hsc_HPT hsc_env))) do + ASSERT( isNoLink (ghcLink dflags) + || all (isJust.hm_linkable) + (filter ((== HsSrcFile).mi_hsc_src.hm_iface) + (eltsUFM hpt4))) do -- Link everything together linkresult <- liftIO $ link (ghcLink dflags) dflags False hpt4 @@ -404,15 +407,18 @@ discardProg hsc_env -- external packages. discardIC :: HscEnv -> HscEnv discardIC hsc_env - = hsc_env { hsc_IC = new_ic { ic_int_print = keep_external_name ic_int_print - , ic_monad = keep_external_name ic_monad } } + = hsc_env { hsc_IC = empty_ic { ic_int_print = new_ic_int_print + , ic_monad = new_ic_monad } } where + -- Force the new values for ic_int_print and ic_monad to avoid leaking old_ic + !new_ic_int_print = keep_external_name ic_int_print + !new_ic_monad = keep_external_name ic_monad dflags = ic_dflags old_ic old_ic = hsc_IC hsc_env - new_ic = emptyInteractiveContext dflags + empty_ic = emptyInteractiveContext dflags keep_external_name ic_name | nameIsFromExternalPackage this_pkg old_name = old_name - | otherwise = ic_name new_ic + | otherwise = ic_name empty_ic where this_pkg = thisPackage dflags old_name = ic_name old_ic @@ -439,7 +445,8 @@ intermediateCleanTempFiles dflags summaries hsc_env guessOutputFile :: GhcMonad m => m () guessOutputFile = modifySession $ \env -> let dflags = hsc_dflags env - mod_graph = hsc_mod_graph env + -- Force mod_graph to avoid leaking env + !mod_graph = hsc_mod_graph env mainModuleSrcPath :: Maybe String mainModuleSrcPath = do let isMain = (== mainModIs dflags) . ms_mod |