summaryrefslogtreecommitdiff
path: root/compiler/GHC.hs
diff options
context:
space:
mode:
authorSylvain Henry <sylvain@haskus.fr>2021-03-15 18:19:16 +0100
committerMarge Bot <ben+marge-bot@smart-cactus.org>2021-03-23 13:01:15 -0400
commit05c5c0549bee022be84344cef46f0eded5564c3b (patch)
tree1c50af925a1993c602b78c96155126b65c477af7 /compiler/GHC.hs
parent7a6577513633b943202fc82ab7aa162e1d293c0a (diff)
downloadhaskell-05c5c0549bee022be84344cef46f0eded5564c3b.tar.gz
Move loader state into Interp
The loader state was stored into HscEnv. As we need to have two interpreters and one loader state per interpreter in #14335, it's natural to make the loader state a field of the Interp type. As a side effect, many functions now only require a Interp parameter instead of HscEnv. Sadly we can't fully free GHC.Linker.Loader of HscEnv yet because the loader is initialised lazily from the HscEnv the first time it is used. This is left as future work. HscEnv may not contain an Interp value (i.e. hsc_interp :: Maybe Interp). So a side effect of the previous side effect is that callers of the modified functions now have to provide an Interp. It is satisfying as it pushes upstream the handling of the case where HscEnv doesn't contain an Interpreter. It is better than raising a panic (less partial functions, "parse, don't validate", etc.).
Diffstat (limited to 'compiler/GHC.hs')
-rw-r--r--compiler/GHC.hs13
1 files changed, 8 insertions, 5 deletions
diff --git a/compiler/GHC.hs b/compiler/GHC.hs
index 9d2d6fb65f..7a237b2146 100644
--- a/compiler/GHC.hs
+++ b/compiler/GHC.hs
@@ -319,11 +319,11 @@ import GHC.Driver.Monad
import GHC.Driver.Ppr
import GHC.ByteCode.Types
+import qualified GHC.Linker.Loader as Loader
import GHC.Runtime.Loader
import GHC.Runtime.Eval
import GHC.Runtime.Eval.Types
import GHC.Runtime.Interpreter
-import GHC.Runtime.Interpreter.Types
import GHC.Runtime.Context
import GHCi.RemoteTypes
@@ -535,7 +535,7 @@ withCleanupSession ghc = ghc `MC.finally` cleanup
liftIO $ do
cleanTempFiles logger tmpfs dflags
cleanTempDirs logger tmpfs dflags
- stopInterp hsc_env -- shut down the IServ
+ traverse_ stopInterp (hsc_interp hsc_env)
-- exceptions will be blocked while we clean the temporary files,
-- so there shouldn't be any difficulty if we receive further
-- signals.
@@ -642,7 +642,7 @@ setSessionDynFlags dflags0 = do
(dbs,unit_state,home_unit) <- liftIO $ initUnits logger dflags (hsc_unit_dbs hsc_env)
-- Interpreter
- interp <- if gopt Opt_ExternalInterpreter dflags
+ interp <- if gopt Opt_ExternalInterpreter dflags
then do
let
prog = pgm_i dflags ++ flavour
@@ -666,10 +666,13 @@ setSessionDynFlags dflags0 = do
, iservConfTrace = tr
}
s <- liftIO $ newMVar IServPending
- return (Just (ExternalInterp conf (IServ s)))
+ loader <- liftIO Loader.uninitializedLoader
+ return (Just (Interp (ExternalInterp conf (IServ s)) loader))
else
#if defined(HAVE_INTERNAL_INTERPRETER)
- return (Just InternalInterp)
+ do
+ loader <- liftIO Loader.uninitializedLoader
+ return (Just (Interp InternalInterp loader))
#else
return Nothing
#endif