Hannes Siebenhandl pushed to branch wip/fendor/one-shot-no-eps at Glasgow Haskell Compiler / GHC

Commits:

6 changed files:

Changes:

  • compiler/GHC/Driver/Env.hs
    ... ... @@ -349,14 +349,15 @@ prepareAnnotations hsc_env mb_guts = do
    349 349
             -- otherwise load annotations from all home package table
    
    350 350
             -- entries regardless of dependency ordering.
    
    351 351
             get_mod mg = (moduleUnitId (mg_module mg), GWIB (moduleName (mg_module mg)) NotBoot)
    
    352
    -    home_pkg_anns  <- fromMaybe (hugAllAnns (hsc_unit_env hsc_env))
    
    353
    -                      $ uncurry (hugAnnsBelow (hsc_unit_env hsc_env))
    
    354
    -                      . get_mod <$> mb_guts
    
    355
    -    more_home_pkg_anns <- HomePackageTable.hptLoadedAnnEnv $ hsc_HPT hsc_env
    
    352
    +    home_pkg_anns  <- case mb_guts of
    
    353
    +      Nothing   -> hugAllAnns (hsc_unit_env hsc_env)
    
    354
    +      Just guts -> plusAnnEnv
    
    355
    +        <$> uncurry (hugAnnsBelow (hsc_unit_env hsc_env)) (get_mod guts)
    
    356
    +        <*> HomePackageTable.hptLoadedAnnEnv (hsc_HPT hsc_env)
    
    356 357
         let
    
    357 358
             other_pkg_anns = eps_ann_env eps
    
    358 359
             !ann_env       = maybe id plusAnnEnv mb_this_module_anns $!
    
    359
    -            plusAnnEnv home_pkg_anns (plusAnnEnv more_home_pkg_anns other_pkg_anns)
    
    360
    +            plusAnnEnv home_pkg_anns other_pkg_anns
    
    360 361
         return ann_env
    
    361 362
     
    
    362 363
     -- | Find the 'TyThing' for the given 'Name' by using all the resources
    

  • compiler/GHC/Iface/Load.hs
    ... ... @@ -521,8 +521,8 @@ importDecl name
    521 521
     
    
    522 522
             -- Now look it up again; this time we should find it
    
    523 523
             { eps <- getEps -- @fendor: DONE
    
    524
    -        ; loaderTypeEnv <- queryHpt HomePackageTable.hptLoadedTypeEnv
    
    525
    -        ; case lookupTypeEnv loaderTypeEnv name <|> lookupTypeEnv (eps_PTE eps) name of
    
    524
    +        ; mb_home_thing <- queryHpt (`HomePackageTable.hptLookupLoadedType` name)
    
    525
    +        ; case mb_home_thing <|> lookupTypeEnv (eps_PTE eps) name of
    
    526 526
                 Just thing -> return $ Succeeded thing
    
    527 527
                 Nothing    -> return $ Failed $
    
    528 528
                   Can'tFindNameInInterface name
    
    ... ... @@ -915,12 +915,13 @@ addModIfacePartsToHpt gbl_env mod loc iface (new_decls, new_insts, new_defaults,
    915 915
         -- See Note [Interface Files with Core Definitions]
    
    916 916
         mb_bytecode = loadIfaceByteCode hsc_env iface loc (md_types details)
    
    917 917
     
    
    918
    +    final_iface = stripLoadedIface "home package table" iface
    
    919
    +
    
    918 920
       warnPprTrace bad_boot "loadInterface" (ppr mod) $ do
    
    919 921
         hpt <- getHpt
    
    920
    -    when (not bad_boot) $ do
    
    921
    -      let final_iface = stripLoadedIface "home package table" iface
    
    922
    -      liftIO $ addHomeModInfoToHpt (HomeModInfo final_iface details emptyHomeModInfoLinkable) hpt
    
    923
    -    liftIO $ addOnDemandHomeModule hpt mod bad_boot (new_decls, new_insts, new_defaults, new_fam_insts, new_rules, new_anns, new_complete_matches) mb_bytecode
    
    922
    +    liftIO $ if bad_boot
    
    923
    +      then hptAddOwnBootTypes hpt new_decls
    
    924
    +      else addOnDemandHomeModule hpt (HomeModInfo final_iface details emptyHomeModInfoLinkable) mb_bytecode
    
    924 925
     
    
    925 926
     addModIfacePartsToEps :: Module -> ModIface -> ([(Name, TyThing)], [ClsInst], DefaultEnv, [FamInst], [CoreRule],  [Annotation], [CompleteMatch]) -> IfL ()
    
    926 927
     addModIfacePartsToEps mod iface (new_decls, new_insts, new_defaults, new_fam_insts, new_rules, new_anns, new_complete_matches) = do
    

  • compiler/GHC/Tc/Instance/Family.hs
    ... ... @@ -409,9 +409,9 @@ getFamInsts hpt_fam_insts mod
    409 409
       | Just env <- lookupModuleEnv hpt_fam_insts mod = return env
    
    410 410
       | otherwise = do { _ <- initIfaceTcRn (loadSysInterface doc mod)
    
    411 411
                        ; eps <- getEps
    
    412
    -                   ; hpt_extra_mod_fam_insts <- queryHpt HomePackageTable.hptLoadedModFamInstEnv
    
    412
    +                   ; mb_home_fam_insts <- queryHpt (`HomePackageTable.hptLoadedModFamInsts` mod)
    
    413 413
                        ; return (expectJust $
    
    414
    -                             lookupModuleEnv hpt_extra_mod_fam_insts mod <|> lookupModuleEnv (eps_mod_fam_inst_env eps) mod) }
    
    414
    +                             mb_home_fam_insts <|> lookupModuleEnv (eps_mod_fam_inst_env eps) mod) }
    
    415 415
       where
    
    416 416
         doc = ppr mod <+> text "is a family-instance module"
    
    417 417
     
    

  • compiler/GHC/Tc/Module.hs
    ... ... @@ -191,7 +191,7 @@ import qualified Data.Map as M
    191 191
     import Data.Foldable ( for_ )
    
    192 192
     import Data.Traversable ( for )
    
    193 193
     import Data.IORef( newIORef )
    
    194
    -import GHC.Unit.Home.PackageTable (hptSetBootInfo)
    
    194
    +import GHC.Unit.Home.PackageTable (hptSetBootInfo, isOneShotMode)
    
    195 195
     
    
    196 196
     {-
    
    197 197
     ************************************************************************
    
    ... ... @@ -2175,7 +2175,10 @@ runTcInteractive tcm_plugin_handling hsc_env thing_inside
    2175 2175
                                              (renameRawPkgQual (hsc_unit_env hsc_env) (hsModuleName $ unLoc $ ideclName i) (ideclPkgQual i))
    
    2176 2176
     
    
    2177 2177
     
    
    2178
    -       ; (home_insts, home_fam_insts) <- liftIO $ UnitEnv.hugAllInstances (hsc_unit_env hsc_env)
    
    2178
    +       ; (home_insts, home_fam_insts) <-
    
    2179
    +           if isOneShotMode (hsc_HPT hsc_env)
    
    2180
    +             then pure (emptyInstEnv, [])
    
    2181
    +             else liftIO $ UnitEnv.hugAllInstances (hsc_unit_env hsc_env)
    
    2179 2182
     
    
    2180 2183
            ; let imports = emptyImportAvails { imp_orphs = orphs }
    
    2181 2184
     
    

  • compiler/GHC/Tc/Utils/Env.hs
    ... ... @@ -386,8 +386,7 @@ tcGetClsDefaults :: [Module] -> TcM [DefaultEnv]
    386 386
     tcGetClsDefaults mods = do
    
    387 387
       hug <- hsc_HUG <$> getTopEnv
    
    388 388
       module_env_defaults <- eps_defaults <$> getEps
    
    389
    -  more_env_defaults <- queryHpt HomePackageTable.hptLoadedDefaults
    
    390
    -  liftIO $ mapMaybeM (lookupClsDefault hug (module_env_defaults `plusModuleEnv` more_env_defaults)) mods
    
    389
    +  liftIO $ mapMaybeM (lookupClsDefault hug module_env_defaults) mods
    
    391 390
     
    
    392 391
     lookupClsDefault :: HomeUnitGraph -> ModuleEnv DefaultEnv -> Module -> IO (Maybe DefaultEnv)
    
    393 392
     lookupClsDefault hug module_env_defaults mod =
    

  • compiler/GHC/Unit/Home/PackageTable.hs
    ... ... @@ -42,6 +42,7 @@ module GHC.Unit.Home.PackageTable
    42 42
       , addHomeModInfoToHpt
    
    43 43
       , addHomeModInfosToHpt
    
    44 44
       , addOnDemandHomeModule
    
    45
    +  , hptAddOwnBootTypes
    
    45 46
     
    
    46 47
         -- * Restrict the HPT
    
    47 48
       , restrictHpt
    
    ... ... @@ -54,14 +55,13 @@ module GHC.Unit.Home.PackageTable
    54 55
       , hptAllAnnotations
    
    55 56
       , hptSetBootInfo
    
    56 57
       , hptLoadedIsBoot
    
    57
    -  , hptLoadedTypeEnv
    
    58
    +  , hptLookupLoadedType
    
    58 59
       , hptLoadedInstEnv
    
    59 60
       , hptLoadedFamInstEnv
    
    60
    -  , hptLoadedModFamInstEnv
    
    61
    +  , hptLoadedModFamInsts
    
    61 62
       , hptLoadedRuleBase
    
    62 63
       , hptLoadedAnnEnv
    
    63 64
       , hptLoadedCompleteMatches
    
    64
    -  , hptLoadedDefaults
    
    65 65
       , hptLoadedByteCode
    
    66 66
       , HptStats(..)
    
    67 67
       , hptLoadedStats
    
    ... ... @@ -121,8 +121,6 @@ import GHC.Unit.Module.ModIface
    121 121
     import GHC.Utils.Outputable
    
    122 122
     import GHC.Types.Name
    
    123 123
     import GHC.Types.Name.Env (extendNameEnvList)
    
    124
    -import GHC.Types.DefaultEnv (DefaultEnv)
    
    125
    -import GHC.Core
    
    126 124
     
    
    127 125
     -- | Helps us find information about modules in the home package
    
    128 126
     data HomePackageTable
    
    ... ... @@ -157,39 +155,75 @@ emptyOnDemandHomePackageTable = do
    157 155
     
    
    158 156
     data HomeLoaderState = HomeLoaderState
    
    159 157
       { hls_table            :: DModuleNameEnv HomeModInfo
    
    158
    +  , hls_indices          :: !LoaderIndices
    
    160 159
       , hls_is_boot          :: InstalledModuleEnv ModuleNameWithIsBoot
    
    161
    -  , hls_type_env         :: !TypeEnv
    
    160
    +  , hls_boot_type_env    :: !TypeEnv
    
    162 161
       , hls_iface_bytecode   :: !(ModuleEnv (IO Linkable))
    
    163 162
         -- ^ Actions that compile the Core bindings stored in a loaded interface
    
    164 163
         -- to bytecode, for modules whose interface has Core bindings.
    
    165 164
         -- See Note [Interface Files with Core Definitions]
    
    166
    -  , hls_inst_env         :: !InstEnv
    
    167
    -  , hls_fam_inst_env     :: !FamInstEnv
    
    168
    -  , hls_mod_fam_inst_env :: !(ModuleEnv FamInstEnv)
    
    169
    -  , hls_rule_base        :: !RuleBase
    
    170
    -  , hls_ann_env          :: !AnnEnv
    
    171
    -  , hls_complete_matches :: !CompleteMatches
    
    172
    -  , hls_defaults         :: ModuleEnv DefaultEnv
    
    173 165
       , hls_stats            :: !HptStats
    
    174 166
       }
    
    175 167
     
    
    168
    +data LoaderIndices = LoaderIndices
    
    169
    +  { li_inst_env         :: !InstEnv
    
    170
    +  , li_fam_inst_env     :: !FamInstEnv
    
    171
    +  , li_rule_base        :: !RuleBase
    
    172
    +  , li_ann_env          :: !AnnEnv
    
    173
    +  , li_complete_matches :: !CompleteMatches
    
    174
    +  }
    
    175
    +
    
    176
    +emptyLoaderIndices :: LoaderIndices
    
    177
    +emptyLoaderIndices = LoaderIndices
    
    178
    +  { li_inst_env         = emptyInstEnv
    
    179
    +  , li_fam_inst_env     = emptyFamInstEnv
    
    180
    +  , li_rule_base        = emptyRuleBase
    
    181
    +  , li_ann_env          = emptyAnnEnv
    
    182
    +  , li_complete_matches = []
    
    183
    +  }
    
    184
    +
    
    185
    +extendLoaderIndices :: LoaderIndices -> HomeModInfo -> LoaderIndices
    
    186
    +extendLoaderIndices li hmi = LoaderIndices
    
    187
    +  { li_inst_env         = extendInstEnvList (li_inst_env li) (instEnvElts (md_insts details))
    
    188
    +  , li_fam_inst_env     = extendFamInstEnvList (li_fam_inst_env li) (md_fam_insts details)
    
    189
    +  , li_rule_base        = extendRuleBaseList (li_rule_base li) (md_rules details)
    
    190
    +  , li_ann_env          = extendAnnEnvList (li_ann_env li) (md_anns details)
    
    191
    +  , li_complete_matches = li_complete_matches li ++ md_complete_matches details
    
    192
    +  }
    
    193
    +  where
    
    194
    +    details = hm_details hmi
    
    195
    +
    
    176 196
     emptyHomeLoaderState :: HomeLoaderState
    
    177 197
     emptyHomeLoaderState =
    
    178 198
       HomeLoaderState
    
    179 199
         { hls_table = emptyUDFM
    
    200
    +    , hls_indices = emptyLoaderIndices
    
    180 201
         , hls_is_boot = emptyInstalledModuleEnv
    
    181
    -    , hls_type_env = emptyTypeEnv
    
    202
    +    , hls_boot_type_env = emptyTypeEnv
    
    182 203
         , hls_iface_bytecode = emptyModuleEnv
    
    183
    -    , hls_inst_env = emptyInstEnv
    
    184
    -    , hls_fam_inst_env = emptyFamInstEnv
    
    185
    -    , hls_mod_fam_inst_env = emptyModuleEnv
    
    186
    -    , hls_rule_base = emptyRuleBase
    
    187
    -    , hls_ann_env = emptyAnnEnv
    
    188
    -    , hls_complete_matches = []
    
    189
    -    , hls_defaults = emptyModuleEnv
    
    190 204
         , hls_stats = emptyHptStats
    
    191 205
         }
    
    192 206
     
    
    207
    +insertLoadedHomeModInfo :: ModuleName -> HomeModInfo -> HomeLoaderState -> HomeLoaderState
    
    208
    +insertLoadedHomeModInfo mn hmi hls
    
    209
    +  | mn `elemUDFM` hls_table hls
    
    210
    +  = hls { hls_table   = table'
    
    211
    +        , hls_indices = foldl' extendLoaderIndices emptyLoaderIndices (eltsUDFM table')
    
    212
    +        , hls_stats   = stats'
    
    213
    +        }
    
    214
    +  | otherwise
    
    215
    +  = hls { hls_table   = table'
    
    216
    +        , hls_indices = extendLoaderIndices (hls_indices hls) hmi
    
    217
    +        , hls_stats   = stats'
    
    218
    +        }
    
    219
    +  where
    
    220
    +    table' = addToUDFM (hls_table hls) mn hmi
    
    221
    +    details = hm_details hmi
    
    222
    +    stats' = addHptInStats (hls_stats hls)
    
    223
    +                           (length (typeEnvElts (md_types details)))
    
    224
    +                           (length (instEnvElts (md_insts details)))
    
    225
    +                           (length (md_rules details))
    
    226
    +
    
    193 227
     --------------------------------------------------------------------------------
    
    194 228
     -- * Lookups in the HPT
    
    195 229
     --------------------------------------------------------------------------------
    
    ... ... @@ -219,29 +253,36 @@ queryOnDemandHpt a f hpt =
    219 253
     hptLoadedIsBoot :: HomePackageTable -> IO (InstalledModuleEnv ModuleNameWithIsBoot)
    
    220 254
     hptLoadedIsBoot = queryOnDemandHpt emptyInstalledModuleEnv hls_is_boot
    
    221 255
     
    
    222
    -hptLoadedTypeEnv :: HomePackageTable -> IO TypeEnv
    
    223
    -hptLoadedTypeEnv = queryOnDemandHpt emptyTypeEnv hls_type_env
    
    256
    +hptLookupLoadedType :: HomePackageTable -> Name -> IO (Maybe TyThing)
    
    257
    +hptLookupLoadedType HPT_Make{} _ = pure Nothing
    
    258
    +hptLookupLoadedType hpt@HPT_OneShot{loader} name = do
    
    259
    +  mb_hmi <- case nameModule_maybe name of
    
    260
    +    Just modl -> lookupHptByModule hpt modl
    
    261
    +    Nothing  -> pure Nothing
    
    262
    +  case mb_hmi of
    
    263
    +    Just hmi -> pure $! lookupTypeEnv (md_types (hm_details hmi)) name
    
    264
    +    Nothing  -> (`lookupTypeEnv` name) . hls_boot_type_env <$> readIORef loader
    
    265
    +
    
    266
    +hptLoadedModFamInsts :: HomePackageTable -> Module -> IO (Maybe FamInstEnv)
    
    267
    +hptLoadedModFamInsts HPT_Make{} _ = pure Nothing
    
    268
    +hptLoadedModFamInsts hpt@HPT_OneShot{} modl =
    
    269
    +  fmap (extendFamInstEnvList emptyFamInstEnv . md_fam_insts . hm_details)
    
    270
    +    <$> lookupHptByModule hpt modl
    
    224 271
     
    
    225 272
     hptLoadedInstEnv :: HomePackageTable -> IO InstEnv
    
    226
    -hptLoadedInstEnv = queryOnDemandHpt emptyInstEnv hls_inst_env
    
    273
    +hptLoadedInstEnv = queryOnDemandHpt emptyInstEnv (li_inst_env . hls_indices)
    
    227 274
     
    
    228 275
     hptLoadedFamInstEnv :: HomePackageTable -> IO FamInstEnv
    
    229
    -hptLoadedFamInstEnv = queryOnDemandHpt emptyFamInstEnv hls_fam_inst_env
    
    230
    -
    
    231
    -hptLoadedModFamInstEnv :: HomePackageTable -> IO (ModuleEnv FamInstEnv)
    
    232
    -hptLoadedModFamInstEnv = queryOnDemandHpt emptyModuleEnv hls_mod_fam_inst_env
    
    276
    +hptLoadedFamInstEnv = queryOnDemandHpt emptyFamInstEnv (li_fam_inst_env . hls_indices)
    
    233 277
     
    
    234 278
     hptLoadedRuleBase :: HomePackageTable -> IO RuleBase
    
    235
    -hptLoadedRuleBase = queryOnDemandHpt emptyRuleBase hls_rule_base
    
    279
    +hptLoadedRuleBase = queryOnDemandHpt emptyRuleBase (li_rule_base . hls_indices)
    
    236 280
     
    
    237 281
     hptLoadedAnnEnv :: HomePackageTable -> IO AnnEnv
    
    238
    -hptLoadedAnnEnv = queryOnDemandHpt emptyAnnEnv hls_ann_env
    
    282
    +hptLoadedAnnEnv = queryOnDemandHpt emptyAnnEnv (li_ann_env . hls_indices)
    
    239 283
     
    
    240 284
     hptLoadedCompleteMatches :: HomePackageTable -> IO CompleteMatches
    
    241
    -hptLoadedCompleteMatches = queryOnDemandHpt [] hls_complete_matches
    
    242
    -
    
    243
    -hptLoadedDefaults :: HomePackageTable -> IO (ModuleEnv DefaultEnv)
    
    244
    -hptLoadedDefaults = queryOnDemandHpt emptyModuleEnv hls_defaults
    
    285
    +hptLoadedCompleteMatches = queryOnDemandHpt [] (li_complete_matches . hls_indices)
    
    245 286
     
    
    246 287
     -- | The action that compiles the Core bindings of an on-demand loaded home
    
    247 288
     -- module to bytecode, if its interface contains Core bindings.
    
    ... ... @@ -249,8 +290,8 @@ hptLoadedDefaults = queryOnDemandHpt emptyModuleEnv hls_defaults
    249 290
     --
    
    250 291
     -- See Note [Interface Files with Core Definitions]
    
    251 292
     hptLoadedByteCode :: HomePackageTable -> Module -> IO (Maybe (IO Linkable))
    
    252
    -hptLoadedByteCode hpt mod =
    
    253
    -  queryOnDemandHpt Nothing (\ hls -> lookupModuleEnv (hls_iface_bytecode hls) mod) hpt
    
    293
    +hptLoadedByteCode hpt modl =
    
    294
    +  queryOnDemandHpt Nothing (\ hls -> lookupModuleEnv (hls_iface_bytecode hls) modl) hpt
    
    254 295
     
    
    255 296
     hptLoadedStats :: HomePackageTable -> IO (Maybe HptStats)
    
    256 297
     hptLoadedStats = queryOnDemandHpt Nothing (Just . hls_stats)
    
    ... ... @@ -326,8 +367,8 @@ addToHpt HPT_Make{table=hptr} mn hmi = do
    326 367
       atomicModifyIORef' hptr (\hpt -> (addToUDFM hpt mn hmi, ()))
    
    327 368
       -- If the key already existed in the map, this insertion is overwriting
    
    328 369
       -- the HMI of a previously loaded module (likely in rehydration).
    
    329
    -addToHpt HPT_OneShot{loader=hptr} mn hmi = do
    
    330
    -  atomicModifyIORef' hptr (\hpt -> (hpt { hls_table = addToUDFM (hls_table hpt) mn hmi }, ()))
    
    370
    +addToHpt HPT_OneShot{loader} mn hmi =
    
    371
    +  atomicModifyIORef' loader (\hls -> (insertLoadedHomeModInfo mn hmi hls, ()))
    
    331 372
     
    
    332 373
     -- | 'addHomeModInfoToHpt' for multiple module infos.
    
    333 374
     addHomeModInfosToHpt :: HomePackageTable -> [HomeModInfo] -> IO ()
    
    ... ... @@ -353,53 +394,23 @@ restrictHpt HPT_OneShot{} _ = pure ()
    353 394
     addListToHpt :: HomePackageTable -> [(ModuleName, HomeModInfo)] -> IO ()
    
    354 395
     addListToHpt hpt = mapM_ (uncurry (addToHpt hpt))
    
    355 396
     
    
    356
    -addOnDemandHomeModule :: HomePackageTable -> Module -> Bool -> ([(Name, TyThing)], [ClsInst], DefaultEnv, [FamInst], [CoreRule], [Annotation], [CompleteMatch]) -> Maybe (IO Linkable) -> IO ()
    
    357
    -addOnDemandHomeModule HPT_Make{} _ _ _ _ = pure ()
    
    358
    -addOnDemandHomeModule HPT_OneShot{loader} mn bad_boot (new_decls, new_insts, new_defaults, new_fam_insts, new_rules, new_anns, new_complete_matches) mb_bytecode = do
    
    397
    +addOnDemandHomeModule :: HomePackageTable -> HomeModInfo -> Maybe (IO Linkable) -> IO ()
    
    398
    +addOnDemandHomeModule hpt@HPT_Make{} hmi _ = addHomeModInfoToHpt hmi hpt
    
    399
    +addOnDemandHomeModule HPT_OneShot{loader} hmi mb_bytecode =
    
    359 400
       atomicModifyIORef' loader $ \hls ->
    
    360
    -    ( if bad_boot
    
    361
    -        then addHomeModTypeEnv hls
    
    362
    -        else addHomeModData hls
    
    363
    -    , ()
    
    364
    -    )
    
    401
    +    let hls' = insertLoadedHomeModInfo (moduleName modl) hmi hls
    
    402
    +    in ( case mb_bytecode of
    
    403
    +           Nothing     -> hls'
    
    404
    +           Just action -> hls' { hls_iface_bytecode = extendModuleEnv (hls_iface_bytecode hls') modl action }
    
    405
    +       , () )
    
    365 406
       where
    
    366
    -    addHomeModTypeEnv hls = hls
    
    367
    -      { hls_type_env = extendNameEnvList   (hls_type_env hls) new_decls
    
    368
    -      }
    
    369
    -
    
    370
    -    addHomeModData hls = hls {
    
    371
    -      hls_type_env       = extendNameEnvList (hls_type_env hls) new_decls,
    
    372
    -      -- Don't add an entry if the iface doesn't have Core bindings, so that
    
    373
    -      -- 'get_link_deps' knows that it should load object code.
    
    374
    -      hls_iface_bytecode = case mb_bytecode of
    
    375
    -        Nothing     -> hls_iface_bytecode hls
    
    376
    -        Just action -> extendModuleEnv (hls_iface_bytecode hls) mn action,
    
    377
    -      hls_rule_base      = extendRuleBaseList (hls_rule_base hls)
    
    378
    -                                            new_rules,
    
    379
    -      hls_complete_matches
    
    380
    -                         = hls_complete_matches hls ++ new_complete_matches,
    
    381
    -      hls_inst_env       = extendInstEnvList (hls_inst_env hls)
    
    382
    -                                            new_insts,
    
    383
    -      hls_fam_inst_env   = extendFamInstEnvList (hls_fam_inst_env hls)
    
    384
    -                                              new_fam_insts,
    
    385
    -      hls_ann_env        = extendAnnEnvList (hls_ann_env hls)
    
    386
    -                                          new_anns,
    
    387
    -      hls_mod_fam_inst_env
    
    388
    -                         =
    
    389
    -                          let
    
    390
    -                            fam_inst_env =
    
    391
    -                              extendFamInstEnvList emptyFamInstEnv
    
    392
    -                                                  new_fam_insts
    
    393
    -                          in
    
    394
    -                          extendModuleEnv (hls_mod_fam_inst_env hls)
    
    395
    -                                          mn
    
    396
    -                                          fam_inst_env,
    
    397
    -      hls_defaults       =  extendModuleEnv (hls_defaults hls) mn new_defaults,
    
    398
    -      hls_stats          = addHptInStats (hls_stats hls)
    
    399
    -                                         (length new_decls)
    
    400
    -                                         (length new_insts)
    
    401
    -                                         (length new_rules)
    
    402
    -  }
    
    407
    +    modl = mi_module (hm_iface hmi)
    
    408
    +
    
    409
    +hptAddOwnBootTypes :: HomePackageTable -> [(Name, TyThing)] -> IO ()
    
    410
    +hptAddOwnBootTypes HPT_Make{} _ = pure ()
    
    411
    +hptAddOwnBootTypes HPT_OneShot{loader} decls =
    
    412
    +  atomicModifyIORef' loader $ \hls ->
    
    413
    +    (hls { hls_boot_type_env = extendNameEnvList (hls_boot_type_env hls) decls }, ())
    
    403 414
     
    
    404 415
     hptSetBootInfo :: HomePackageTable -> InstalledModuleEnv ModuleNameWithIsBoot -> IO ()
    
    405 416
     hptSetBootInfo HPT_Make{} _ = pure ()
    
    ... ... @@ -414,11 +425,15 @@ hptSetBootInfo HPT_OneShot{loader} is_boot_env =
    414 425
     -- | Get all 'CompleteMatches' (arising from COMPLETE pragmas) present in all
    
    415 426
     -- modules from this unit's HPT.
    
    416 427
     hptCompleteSigs :: HomePackageTable -> IO CompleteMatches
    
    417
    -hptCompleteSigs = concatHpt (md_complete_matches . hm_details)
    
    428
    +hptCompleteSigs HPT_OneShot{loader} = li_complete_matches . hls_indices <$> readIORef loader
    
    429
    +hptCompleteSigs hpt@HPT_Make{} = concatHpt (md_complete_matches . hm_details) hpt
    
    418 430
     
    
    419 431
     -- | Find all the instance declarations (of classes and families) from this Home Package Table
    
    420 432
     hptAllInstances :: HomePackageTable -> IO (InstEnv, [FamInst])
    
    421
    -hptAllInstances hpt = do
    
    433
    +hptAllInstances HPT_OneShot{loader} = do
    
    434
    +  li <- hls_indices <$> readIORef loader
    
    435
    +  return (li_inst_env li, famInstEnvElts (li_fam_inst_env li))
    
    436
    +hptAllInstances hpt@HPT_Make{} = do
    
    422 437
       hits <- flip concatHpt hpt $ \mod_info -> do
    
    423 438
          let details = hm_details mod_info
    
    424 439
          return (md_insts details, md_fam_insts details)
    
    ... ... @@ -435,7 +450,8 @@ hptAllFamInstances = fmap mkModuleEnv . concatHpt (\hmi -> [(hmiModule hmi, hmiF
    435 450
     
    
    436 451
     -- | All annotations from the HPT
    
    437 452
     hptAllAnnotations :: HomePackageTable -> IO AnnEnv
    
    438
    -hptAllAnnotations = fmap mkAnnEnv . concatHpt (md_anns . hm_details)
    
    453
    +hptAllAnnotations HPT_OneShot{loader} = li_ann_env . hls_indices <$> readIORef loader
    
    454
    +hptAllAnnotations hpt@HPT_Make{} = mkAnnEnv <$> concatHpt (md_anns . hm_details) hpt
    
    439 455
     
    
    440 456
     --------------------------------------------------------------------------------
    
    441 457
     -- * Traversal-based queries