[commit: ghc] master: Explicitly tell 'getNameToInstances' mods to load (c971e11)

git at git.haskell.org git at git.haskell.org
Tue Aug 21 22:56:52 UTC 2018


Repository : ssh://git@git.haskell.org/ghc

On branch  : master
Link       : http://ghc.haskell.org/trac/ghc/changeset/c971e1193fa44bb507d1806d5bb61768670dc912/ghc

>---------------------------------------------------------------

commit c971e1193fa44bb507d1806d5bb61768670dc912
Author: Alec Theriault <alec.theriault at gmail.com>
Date:   Tue Aug 21 16:03:40 2018 -0400

    Explicitly tell 'getNameToInstances' mods to load
    
    Calculating which modules to load based on the InteractiveContext means
    maintaining a potentially very large GblRdrEnv.
    
    In Haddock's case, it is much cheaper (from a memory perspective) to
    just keep track of which modules interfaces we want loaded then hand
    these off explicitly to 'getNameToInstancesIndex'.
    
    Bumps haddock submodule.
    
    Reviewers: alexbiehl, bgamari
    
    Reviewed By: alexbiehl
    
    Subscribers: rwbarton, thomie, carter
    
    Differential Revision: https://phabricator.haskell.org/D5003


>---------------------------------------------------------------

c971e1193fa44bb507d1806d5bb61768670dc912
 compiler/main/GHC.hs | 18 +++++++++++++-----
 utils/haddock        |  2 +-
 2 files changed, 14 insertions(+), 6 deletions(-)

diff --git a/compiler/main/GHC.hs b/compiler/main/GHC.hs
index 0e20e21..29921de 100644
--- a/compiler/main/GHC.hs
+++ b/compiler/main/GHC.hs
@@ -300,7 +300,8 @@ import HscMain
 import GhcMake
 import DriverPipeline   ( compileOne' )
 import GhcMonad
-import TcRnMonad        ( finalSafeMode, fixSafeInstances )
+import TcRnMonad        ( finalSafeMode, fixSafeInstances, initIfaceTcRn )
+import LoadIface        ( loadSysInterface )
 import TcRnTypes
 import Packages
 import NameSet
@@ -1247,13 +1248,20 @@ getGRE = withSession $ \hsc_env-> return $ ic_rn_gbl_env (hsc_IC hsc_env)
 -- by 'Name'. Each name's lists will contain every instance in which that name
 -- is mentioned in the instance head.
 getNameToInstancesIndex :: GhcMonad m
-  => [Module]  -- ^ visible modules. An orphan instance will be returned if and
-               -- only it is visible from at least one module in the list.
+  => [Module]        -- ^ visible modules. An orphan instance will be returned
+                     -- if it is visible from at least one module in the list.
+  -> Maybe [Module]  -- ^ modules to load. If this is not specified, we load
+                     -- modules for everything that is in scope unqualified.
   -> m (Messages, Maybe (NameEnv ([ClsInst], [FamInst])))
-getNameToInstancesIndex visible_mods = do
+getNameToInstancesIndex visible_mods mods_to_load = do
   hsc_env <- getSession
   liftIO $ runTcInteractive hsc_env $
-    do { loadUnqualIfaces hsc_env (hsc_IC hsc_env)
+    do { case mods_to_load of
+           Nothing -> loadUnqualIfaces hsc_env (hsc_IC hsc_env)
+           Just mods ->
+             let doc = text "Need interface for reporting instances in scope"
+             in initIfaceTcRn $ mapM_ (loadSysInterface doc) mods
+
        ; InstEnvs {ie_global, ie_local} <- tcGetInstEnvs
        ; let visible_mods' = mkModuleSet visible_mods
        ; (pkg_fie, home_fie) <- tcGetFamInstEnvs
diff --git a/utils/haddock b/utils/haddock
index 488aa22..9ef12f3 160000
--- a/utils/haddock
+++ b/utils/haddock
@@ -1 +1 @@
-Subproject commit 488aa22f393c0addb4c0e0b63cfe0aaea32b85d7
+Subproject commit 9ef12f3c2f0ef2948e6f4bd38fdfa002c416ab09



More information about the ghc-commits mailing list