diff options
author | Phuong Trinh <lolotp@fb.com> | 2019-03-05 15:48:46 +0000 |
---|---|---|
committer | Marge Bot <ben+marge-bot@smart-cactus.org> | 2019-03-07 14:01:42 -0500 |
commit | 7a68254a7284db5bf8f1fa82aba4a6825d8f050a (patch) | |
tree | f5c7e7a51f305514376f4ff09b63465b93621e96 /libraries/ghci | |
parent | 25c3dd39f7d446f66b5c967be81f80cd7facb509 (diff) | |
download | haskell-7a68254a7284db5bf8f1fa82aba4a6825d8f050a.tar.gz |
Fix #16392: revertCAFs in external interpreter when necessary
We revert CAFs when loading/adding modules in ghci (presumably to refresh
execution states and to allow for object code to be unloaded from the runtime).
However, with `-fexternal-interpreter` enabled, we are only doing it in the
ghci process instead of the external interpreter process where the cafs are
allocated and computed. This makes sure that revertCAFs is done in the
appropriate process no matter if that flag is present or not.
Diffstat (limited to 'libraries/ghci')
-rw-r--r-- | libraries/ghci/GHCi/Message.hs | 6 | ||||
-rw-r--r-- | libraries/ghci/GHCi/Run.hs | 4 |
2 files changed, 9 insertions, 1 deletions
diff --git a/libraries/ghci/GHCi/Message.hs b/libraries/ghci/GHCi/Message.hs index 959942e858..319eebdfc0 100644 --- a/libraries/ghci/GHCi/Message.hs +++ b/libraries/ghci/GHCi/Message.hs @@ -61,6 +61,7 @@ import System.IO.Error data Message a where -- | Exit the iserv process Shutdown :: Message () + RtsRevertCAFs :: Message () -- RTS Linker ------------------------------------------- @@ -485,7 +486,9 @@ getMessage = do 33 -> Msg <$> (AddSptEntry <$> get <*> get) 34 -> Msg <$> (RunTH <$> get <*> get <*> get <*> get) 35 -> Msg <$> (GetClosure <$> get) - _ -> Msg <$> (Seq <$> get) + 36 -> Msg <$> (Seq <$> get) + 37 -> Msg <$> return RtsRevertCAFs + _ -> error $ "Unknown Message code " ++ (show b) putMessage :: Message a -> Put putMessage m = case m of @@ -526,6 +529,7 @@ putMessage m = case m of RunTH st q loc ty -> putWord8 34 >> put st >> put q >> put loc >> put ty GetClosure a -> putWord8 35 >> put a Seq a -> putWord8 36 >> put a + RtsRevertCAFs -> putWord8 37 -- ----------------------------------------------------------------------------- -- Reading/writing messages diff --git a/libraries/ghci/GHCi/Run.hs b/libraries/ghci/GHCi/Run.hs index 72099b205f..a931e620cc 100644 --- a/libraries/ghci/GHCi/Run.hs +++ b/libraries/ghci/GHCi/Run.hs @@ -44,9 +44,13 @@ import Unsafe.Coerce -- ----------------------------------------------------------------------------- -- Implement messages +foreign import ccall "revertCAFs" rts_revertCAFs :: IO () + -- Make it "safe", just in case + run :: Message a -> IO a run m = case m of InitLinker -> initObjLinker RetainCAFs + RtsRevertCAFs -> rts_revertCAFs LookupSymbol str -> fmap toRemotePtr <$> lookupSymbol str LookupClosure str -> lookupClosure str LoadDLL str -> loadDLL str |