summaryrefslogtreecommitdiff
path: root/compiler/GHC/Iface
diff options
context:
space:
mode:
authorSylvain Henry <sylvain@haskus.fr>2020-10-08 16:46:51 +0200
committerMarge Bot <ben+marge-bot@smart-cactus.org>2020-10-09 08:55:21 -0400
commit6a243e9daaa6c17c0859f47ae3a098e680aa28cf (patch)
tree170e2a707534c1bc4c45abd11ae2438c39c6274d /compiler/GHC/Iface
parentdb236ffc03e5e17f71295469040da96b03ec2f87 (diff)
downloadhaskell-6a243e9daaa6c17c0859f47ae3a098e680aa28cf.tar.gz
Cache HomeUnit in HscEnv (#17957)
Instead of recreating the HomeUnit from the DynFlags every time we need it, we store it in the HscEnv.
Diffstat (limited to 'compiler/GHC/Iface')
-rw-r--r--compiler/GHC/Iface/Load.hs15
-rw-r--r--compiler/GHC/Iface/Make.hs4
-rw-r--r--compiler/GHC/Iface/Recomp.hs12
-rw-r--r--compiler/GHC/Iface/Rename.hs2
-rw-r--r--compiler/GHC/Iface/Tidy.hs2
-rw-r--r--compiler/GHC/Iface/Tidy/StaticPtrTable.hs4
6 files changed, 19 insertions, 20 deletions
diff --git a/compiler/GHC/Iface/Load.hs b/compiler/GHC/Iface/Load.hs
index 85b8b524f6..212bcb78ac 100644
--- a/compiler/GHC/Iface/Load.hs
+++ b/compiler/GHC/Iface/Load.hs
@@ -121,7 +121,7 @@ tcLookupImported_maybe :: Name -> TcM (MaybeErr MsgDoc TyThing)
-- Returns (Failed err) if we can't find the interface file for the thing
tcLookupImported_maybe name
= do { hsc_env <- getTopEnv
- ; mb_thing <- liftIO (lookupTypeHscEnv hsc_env name)
+ ; mb_thing <- liftIO (lookupType hsc_env name)
; case mb_thing of
Just thing -> return (Succeeded thing)
Nothing -> tcImportDecl_maybe name }
@@ -402,8 +402,8 @@ loadInterface :: SDoc -> Module -> WhereFrom
loadInterface doc_str mod from
| isHoleModule mod
-- Hole modules get special treatment
- = do dflags <- getDynFlags
- let home_unit = mkHomeUnitFromFlags dflags
+ = do hsc_env <- getTopEnv
+ let home_unit = hsc_home_unit hsc_env
-- Redo search for our local hole module
loadInterface doc_str (mkHomeModule home_unit (moduleName mod)) from
| otherwise
@@ -416,7 +416,8 @@ loadInterface doc_str mod from
-- Check whether we have the interface already
; dflags <- getDynFlags
- ; let home_unit = mkHomeUnitFromFlags dflags
+ ; hsc_env <- getTopEnv
+ ; let home_unit = hsc_home_unit hsc_env
; case lookupIfaceByModule hpt (eps_PIT eps) mod of {
Just iface
-> return (Succeeded iface) ; -- Already loaded
@@ -643,8 +644,8 @@ computeInterface ::
-> TcRnIf gbl lcl (MaybeErr MsgDoc (ModIface, FilePath))
computeInterface doc_str hi_boot_file mod0 = do
MASSERT( not (isHoleModule mod0) )
- dflags <- getDynFlags
- let home_unit = mkHomeUnitFromFlags dflags
+ hsc_env <- getTopEnv
+ let home_unit = hsc_home_unit hsc_env
case getModuleInstantiation mod0 of
(imod, Just indef) | isHomeUnitIndefinite home_unit -> do
r <- findAndReadIface doc_str imod mod0 hi_boot_file
@@ -925,7 +926,7 @@ findAndReadIface doc_str mod wanted_mod_with_insts hi_boot_file
-- Look for the file
hsc_env <- getTopEnv
mb_found <- liftIO (findExactModule hsc_env mod)
- let home_unit = mkHomeUnitFromFlags dflags
+ let home_unit = hsc_home_unit hsc_env
case mb_found of
InstalledFound loc mod -> do
-- Found file, so read it
diff --git a/compiler/GHC/Iface/Make.hs b/compiler/GHC/Iface/Make.hs
index 941aa4083c..cdcf80bb1f 100644
--- a/compiler/GHC/Iface/Make.hs
+++ b/compiler/GHC/Iface/Make.hs
@@ -172,7 +172,7 @@ mkIfaceTc hsc_env safe_mode mod_details
= do
let used_names = mkUsedNames tc_result
let pluginModules = map lpModule (cachedPlugins (hsc_dflags hsc_env))
- let home_unit = mkHomeUnitFromFlags (hsc_dflags hsc_env)
+ let home_unit = hsc_home_unit hsc_env
deps <- mkDependencies (homeUnitId home_unit)
(map mi_module pluginModules) tc_result
let hpc_info = emptyHpcInfo other_hpc_info
@@ -228,7 +228,7 @@ mkIface_ hsc_env
-- to expose in the interface
= do
- let home_unit = mkHomeUnitFromFlags (hsc_dflags hsc_env)
+ let home_unit = hsc_home_unit hsc_env
semantic_mod = homeModuleNameInstantiation home_unit (moduleName this_mod)
entities = typeEnvElts type_env
show_linear_types = xopt LangExt.LinearTypes (hsc_dflags hsc_env)
diff --git a/compiler/GHC/Iface/Recomp.hs b/compiler/GHC/Iface/Recomp.hs
index eca2d2c875..68df3e2fbd 100644
--- a/compiler/GHC/Iface/Recomp.hs
+++ b/compiler/GHC/Iface/Recomp.hs
@@ -256,7 +256,7 @@ checkVersions hsc_env mod_summary iface
; return (recomp, Just iface)
}}}}}}}}}}
where
- home_unit = mkHomeUnitFromFlags (hsc_dflags hsc_env)
+ home_unit = hsc_home_unit hsc_env
-- This is a bit of a hack really
mod_deps :: ModuleNameEnv ModuleNameWithIsBoot
mod_deps = mkModDeps (dep_mods (mi_deps iface))
@@ -335,8 +335,8 @@ pluginRecompileToRecompileRequired old_fp new_fp pr
-- implementing module has changed.
checkHsig :: ModSummary -> ModIface -> IfG RecompileRequired
checkHsig mod_summary iface = do
- dflags <- getDynFlags
- let home_unit = mkHomeUnitFromFlags dflags
+ hsc_env <- getTopEnv
+ let home_unit = hsc_home_unit hsc_env
outer_mod = ms_mod mod_summary
inner_mod = homeModuleNameInstantiation home_unit (moduleName outer_mod)
MASSERT( isHomeModule home_unit outer_mod )
@@ -453,7 +453,7 @@ checkDependencies hsc_env summary iface
prev_dep_mods = dep_mods (mi_deps iface)
prev_dep_plgn = dep_plgins (mi_deps iface)
prev_dep_pkgs = dep_pkgs (mi_deps iface)
- home_unit = mkHomeUnitFromFlags (hsc_dflags hsc_env)
+ home_unit = hsc_home_unit hsc_env
dep_missing (mb_pkg, L _ mod) = do
find_res <- liftIO $ findImportedModule hsc_env mod (mb_pkg)
@@ -486,7 +486,6 @@ checkDependencies hsc_env summary iface
isOldHomeDeps = flip Set.member old_deps
checkForNewHomeDependency (L _ mname) = do
let
- home_unit = mkHomeUnitFromFlags (hsc_dflags hsc_env)
mod = mkHomeModule home_unit mname
str_mname = moduleNameString mname
reason = str_mname ++ " changed"
@@ -1359,8 +1358,7 @@ mkHashFun hsc_env eps name
| otherwise
= lookup orig_mod
where
- dflags = hsc_dflags hsc_env
- home_unit = mkHomeUnitFromFlags dflags
+ home_unit = hsc_home_unit hsc_env
hpt = hsc_HPT hsc_env
pit = eps_PIT eps
occ = nameOccName name
diff --git a/compiler/GHC/Iface/Rename.hs b/compiler/GHC/Iface/Rename.hs
index 7a511fdc49..cac4f6e438 100644
--- a/compiler/GHC/Iface/Rename.hs
+++ b/compiler/GHC/Iface/Rename.hs
@@ -300,7 +300,7 @@ rnIfaceGlobal :: Name -> ShIfM Name
rnIfaceGlobal n = do
hsc_env <- getTopEnv
let dflags = hsc_dflags hsc_env
- home_unit = mkHomeUnitFromFlags dflags
+ home_unit = hsc_home_unit hsc_env
iface_semantic_mod <- fmap sh_if_semantic_module getGblEnv
mb_nsubst <- fmap sh_if_shape getGblEnv
hmap <- getHoleSubst
diff --git a/compiler/GHC/Iface/Tidy.hs b/compiler/GHC/Iface/Tidy.hs
index 68386a69ae..df1db23b33 100644
--- a/compiler/GHC/Iface/Tidy.hs
+++ b/compiler/GHC/Iface/Tidy.hs
@@ -371,7 +371,7 @@ tidyProgram hsc_env (ModGuts { mg_module = mod
; expose_all = gopt Opt_ExposeAllUnfoldings dflags
; print_unqual = mkPrintUnqualified
(unitState dflags)
- (mkHomeUnitFromFlags dflags)
+ (hsc_home_unit hsc_env)
rdr_env
; implicit_binds = concatMap getImplicitBinds tcs
}
diff --git a/compiler/GHC/Iface/Tidy/StaticPtrTable.hs b/compiler/GHC/Iface/Tidy/StaticPtrTable.hs
index 965140e6f2..5e40bed45e 100644
--- a/compiler/GHC/Iface/Tidy/StaticPtrTable.hs
+++ b/compiler/GHC/Iface/Tidy/StaticPtrTable.hs
@@ -241,11 +241,11 @@ sptCreateStaticBinds hsc_env this_mod binds
PW8 -> mkWordLit platform . toInteger
lookupIdHscEnv :: Name -> IO Id
- lookupIdHscEnv n = lookupTypeHscEnv hsc_env n >>=
+ lookupIdHscEnv n = lookupType hsc_env n >>=
maybe (getError n) (return . tyThingId)
lookupDataConHscEnv :: Name -> IO DataCon
- lookupDataConHscEnv n = lookupTypeHscEnv hsc_env n >>=
+ lookupDataConHscEnv n = lookupType hsc_env n >>=
maybe (getError n) (return . tyThingDataCon)
getError n = pprPanic "sptCreateStaticBinds.get: not found" $