summaryrefslogtreecommitdiff
path: root/compiler/GHC/Runtime/Loader.hs
diff options
context:
space:
mode:
authorSylvain Henry <sylvain@haskus.fr>2020-02-17 18:12:30 +0100
committerMarge Bot <ben+marge-bot@smart-cactus.org>2020-02-29 05:09:25 -0500
commit18757cab04c5c5c48eaceea19469d4811c5d0371 (patch)
tree5437de47247b8fe69f8b83db6a66524cabddee3f /compiler/GHC/Runtime/Loader.hs
parentb5fb58fd1a4a24b9273d9d2de65b6347e1654e98 (diff)
downloadhaskell-18757cab04c5c5c48eaceea19469d4811c5d0371.tar.gz
Refactor runtime interpreter code
In #14335 we want to be able to use both the internal interpreter (for the plugins) and the external interpreter (for TH and GHCi) at the same time. This patch performs some preliminary refactoring: the `hsc_interp` field of HscEnv replaces `hsc_iserv` and is now used to indicate which interpreter (internal, external) to use to execute TH and GHCi. Opt_ExternalInterpreter flag and iserv options in DynFlags are now queried only when we set the session DynFlags. It should help making GHC multi-target in the future by selecting an interpreter according to the selected target.
Diffstat (limited to 'compiler/GHC/Runtime/Loader.hs')
-rw-r--r--compiler/GHC/Runtime/Loader.hs20
1 files changed, 10 insertions, 10 deletions
diff --git a/compiler/GHC/Runtime/Loader.hs b/compiler/GHC/Runtime/Loader.hs
index 15d0b7d5dc..c595b53c4e 100644
--- a/compiler/GHC/Runtime/Loader.hs
+++ b/compiler/GHC/Runtime/Loader.hs
@@ -24,9 +24,10 @@ import GhcPrelude
import GHC.Driver.Session
import GHC.Runtime.Linker ( linkModule, getHValue )
-import GHC.Runtime.Interpreter ( wormhole )
+import GHC.Runtime.Interpreter ( wormhole, withInterp )
+import GHC.Runtime.Interpreter.Types
import SrcLoc ( noSrcSpan )
-import GHC.Driver.Finder ( findPluginModule, cannotFindModule )
+import GHC.Driver.Finder( findPluginModule, cannotFindModule )
import TcRnMonad ( initTcInteractive, initIfaceTcRn )
import GHC.Iface.Load ( loadPluginInterface )
import RdrName ( RdrName, ImportSpec(..), ImpDeclSpec(..)
@@ -52,7 +53,7 @@ import Outputable
import Exception
import GHC.Driver.Hooks
-import Control.Monad ( when, unless )
+import Control.Monad ( unless )
import Data.Maybe ( mapMaybe )
import Unsafe.Coerce ( unsafeCoerce )
@@ -103,12 +104,11 @@ loadFrontendPlugin hsc_env mod_name = do
-- #14335
checkExternalInterpreter :: HscEnv -> IO ()
-checkExternalInterpreter hsc_env =
- when (gopt Opt_ExternalInterpreter dflags) $
- throwCmdLineError $ showSDoc dflags $
- text "Plugins require -fno-external-interpreter"
- where
- dflags = hsc_dflags hsc_env
+checkExternalInterpreter hsc_env
+ | Just (ExternalInterp _) <- hsc_interp hsc_env
+ = throwIO (InstallationError "Plugins require -fno-external-interpreter")
+ | otherwise
+ = pure ()
loadPlugin' :: OccName -> Name -> HscEnv -> ModuleName -> IO (a, ModIface)
loadPlugin' occ_name plugin_name hsc_env mod_name
@@ -206,7 +206,7 @@ getHValueSafely hsc_env val_name expected_type = do
return ()
Nothing -> return ()
-- Find the value that we just linked in and cast it given that we have proved it's type
- hval <- getHValue hsc_env val_name >>= wormhole dflags
+ hval <- withInterp hsc_env $ \interp -> getHValue hsc_env val_name >>= wormhole interp
return (Just hval)
else return Nothing
Just val_thing -> throwCmdLineErrorS dflags $ wrongTyThingError val_name val_thing