[Git][ghc/ghc][wip/js-th] Remove InteractiveContext update

Sylvain Henry (@hsyl20) gitlab at gitlab.haskell.org
Fri May 26 13:06:04 UTC 2023



Sylvain Henry pushed to branch wip/js-th at Glasgow Haskell Compiler / GHC


Commits:
f411c496 by Sylvain Henry at 2023-05-26T15:10:51+02:00
Remove InteractiveContext update

- - - - -


1 changed file:

- compiler/GHC/Driver/Main.hs


Changes:

=====================================
compiler/GHC/Driver/Main.hs
=====================================
@@ -1858,7 +1858,7 @@ hscGenHardCode hsc_env cgguts location output_filename = do
                         c `seqList`
                         d `seqList`
                         (seqEltsUFM (seqTagSig) tag_env))
-                   (myCoreToStg logger dflags (hsc_IC hsc_env) False this_mod location prepd_binds)
+                   (myCoreToStg logger dflags (interactiveInScope (hsc_IC hsc_env)) False this_mod location prepd_binds)
 
         let cost_centre_info =
               (late_local_ccs ++ caf_ccs, caf_cc_stacks)
@@ -1980,7 +1980,7 @@ hscInteractive hsc_env cgguts location = do
     -- omit it here
     (stg_binds, _infotable_prov, _caf_ccs__caf_cc_stacks, _ignore_stg_cg_infos)
       <- {-# SCC "CoreToStg" #-}
-          myCoreToStg logger dflags (hsc_IC hsc_env) True this_mod location prepd_binds
+          myCoreToStg logger dflags (interactiveInScope (hsc_IC hsc_env)) True this_mod location prepd_binds
     -----------------  Generate byte code ------------------
     comp_bc <- byteCodeGen hsc_env this_mod stg_binds data_tycons mod_breaks
     ------------------ Create f-x-dynamic C-side stuff -----
@@ -2155,21 +2155,21 @@ doCodeGen hsc_env this_mod denv data_tycons
 
     return $ Stream.mapM dump2 $ generateCgIPEStub hsc_env this_mod denv pipeline_stream
 
-myCoreToStg :: Logger -> DynFlags -> InteractiveContext
+myCoreToStg :: Logger -> DynFlags -> [Var]
             -> Bool
             -> Module -> ModLocation -> CoreProgram
             -> IO ( [CgStgTopBinding] -- output program
                   , InfoTableProvMap
                   , CollectedCCs -- CAF cost centre info (declared and used)
                   , StgCgInfos )
-myCoreToStg logger dflags ictxt for_bytecode this_mod ml prepd_binds = do
+myCoreToStg logger dflags ic_inscope for_bytecode this_mod ml prepd_binds = do
     let (stg_binds, denv, cost_centre_info)
          = {-# SCC "Core2Stg" #-}
            coreToStg (initCoreToStgOpts dflags) this_mod ml prepd_binds
 
     (stg_binds_with_fvs,stg_cg_info)
         <- {-# SCC "Stg2Stg" #-}
-           stg2stg logger (interactiveInScope ictxt) (initStgPipelineOpts dflags for_bytecode)
+           stg2stg logger ic_inscope (initStgPipelineOpts dflags for_bytecode)
                    this_mod stg_binds
 
     putDumpFileMaybe logger Opt_D_dump_stg_cg "CodeGenInput STG:" FormatSTG
@@ -2330,7 +2330,7 @@ hscParsedDecls hsc_env decls = runInteractiveHsc hsc_env $ do
         <- {-# SCC "CoreToStg" #-}
            liftIO $ myCoreToStg (hsc_logger hsc_env)
                                 (hsc_dflags hsc_env)
-                                (hsc_IC hsc_env)
+                                (interactiveInScope (hsc_IC hsc_env))
                                 True
                                 this_mod
                                 iNTERACTIVELoc
@@ -2575,24 +2575,23 @@ hscCompileCoreExpr' hsc_env srcspan ds_expr = do
                               ml_dyn_hi_file  = panic "hscCompileCoreExpr': ml_dyn_hi_file",
                               ml_hie_file  = panic "hscCompileCoreExpr':ml_hie_file" }
 
-  let ictxt = (hsc_IC hsc_env) {
-                ic_mod_index = getKey u
-                  -- Ensure module uniqueness ("GhciNNNN") by reusing the unique
-                  -- we've used for the binding. If ic_mod_index was mutable, we
-                  -- would simply bump it here after its use.
-                  --
-                  -- This uniqueness is needed by the JS linker. Without it we
-                  -- break the 1-1 relationship between modules and object
-                  -- files, i.e. we get different object files for the same module
-                  -- and the JS linker doesn't support this.
-               }
-  let this_mod = icInteractiveModule ictxt
+  -- Ensure module uniqueness by giving it a name like "GhciNNNN".
+  -- This uniqueness is needed by the JS linker. Without it we break the 1-1
+  -- relationship between modules and object files, i.e. we get different object
+  -- files for the same module and the JS linker doesn't support this.
+  --
+  -- Note that we can't use icInteractiveModule because the ic_mod_index value
+  -- isn't bumped between invocations of hscCompileExpr, so uniqueness isn't
+  -- guaranteed.
+  --
+  -- We reuse the unique we obtained for the binding, but any unique would do.
+  let this_mod = mkInteractiveModule (getKey u)
   let for_bytecode = True
 
   (stg_binds, _prov_map, _collected_ccs, _stg_cg_infos) <-
        myCoreToStg logger
                    dflags
-                   ictxt
+                   (interactiveInScope (hsc_IC hsc_env))
                    for_bytecode
                    this_mod
                    this_loc



View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/f411c496451d6b9aafaad3520aa2b25434e49a0d

-- 
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/f411c496451d6b9aafaad3520aa2b25434e49a0d
You're receiving this email because of your account on gitlab.haskell.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/ghc-commits/attachments/20230526/ae43aa30/attachment-0001.html>


More information about the ghc-commits mailing list