diff options
author | Moritz Angermann <moritz.angermann@gmail.com> | 2016-12-11 11:32:28 +0000 |
---|---|---|
committer | Tamar Christina <tamar@zhox.com> | 2016-12-11 15:29:17 +0000 |
commit | c3c702441137dc8f7ee0dd5ac313be96d625459a (patch) | |
tree | a59633ac90b97a7df7c09db560bf8030c15ebf2e /compiler/ghci/Linker.hs | |
parent | 490b9429a8ed3c55d17bf0964fb14582eb206a3d (diff) | |
download | haskell-c3c702441137dc8f7ee0dd5ac313be96d625459a.tar.gz |
Make globals use sharedCAF
Summary:
The use of globals is quite painful when multiple rts are loaded, e.g.
when plugins are loaded, which bring in a second rts. The sharedCAF
appraoch was employed for the FastStringTable; I've taken the libery
to extend this to the other globals I could find.
This is a reboot of D2575, that should hopefully not exhibit the same
windows build issues.
Reviewers: Phyx, simonmar, goldfire, bgamari, austin, hvr, erikd
Reviewed By: Phyx, simonmar, bgamari
Subscribers: mpickering, thomie
Differential Revision: https://phabricator.haskell.org/D2773
Diffstat (limited to 'compiler/ghci/Linker.hs')
-rw-r--r-- | compiler/ghci/Linker.hs | 44 |
1 files changed, 22 insertions, 22 deletions
diff --git a/compiler/ghci/Linker.hs b/compiler/ghci/Linker.hs index 4a0b62f904..7379c46772 100644 --- a/compiler/ghci/Linker.hs +++ b/compiler/ghci/Linker.hs @@ -1,11 +1,10 @@ {-# LANGUAGE CPP, NondecreasingIndentation, TupleSections, RecordWildCards #-} {-# OPTIONS_GHC -fno-cse #-} +-- -fno-cse is needed for GLOBAL_VAR's to behave properly + -- -- (c) The University of Glasgow 2002-2006 -- - --- -fno-cse is needed for GLOBAL_VAR's to behave properly - -- | The dynamic linker for GHCi. -- -- This module deals with the top-level issues of dynamic linking, @@ -16,10 +15,7 @@ module Linker ( getHValue, showLinkerState, extendLinkEnv, deleteFromLinkEnv, extendLoadedPkgs, linkPackages,initDynLinker,linkModule, - linkCmdLineLibs, - - -- Saving/restoring globals - PersistentLinkerState, saveLinkerGlobals, restoreLinkerGlobals + linkCmdLineLibs ) where #include "HsVersions.h" @@ -66,6 +62,11 @@ import System.Directory import Exception +#if __GLASGOW_HASKELL__ >= 709 +import Foreign +#else +import Foreign.Safe +#endif {- ********************************************************************** @@ -84,9 +85,22 @@ library to side-effect the PLS and for those changes to be reflected here. The PersistentLinkerState maps Names to actual closures (for interpreted code only), for use during linking. -} - +#if STAGE < 2 GLOBAL_VAR_M(v_PersistentLinkerState, newMVar (panic "Dynamic linker not initialised"), MVar PersistentLinkerState) GLOBAL_VAR(v_InitLinkerDone, False, Bool) -- Set True when dynamic linker is initialised +#else +SHARED_GLOBAL_VAR_M( v_PersistentLinkerState + , getOrSetLibHSghcPersistentLinkerState + , "getOrSetLibHSghcPersistentLinkerState" + , newMVar (panic "Dynamic linker not initialised") + , MVar PersistentLinkerState) +-- Set True when dynamic linker is initialised +SHARED_GLOBAL_VAR( v_InitLinkerDone + , getOrSetLibHSghcInitLinkerDone + , "getOrSetLibHSghcInitLinkerDone" + , False + , Bool) +#endif modifyPLS_ :: (PersistentLinkerState -> IO PersistentLinkerState) -> IO () modifyPLS_ f = readIORef v_PersistentLinkerState >>= flip modifyMVar_ f @@ -1428,17 +1442,3 @@ maybePutStr dflags s maybePutStrLn :: DynFlags -> String -> IO () maybePutStrLn dflags s = maybePutStr dflags (s ++ "\n") - -{- ********************************************************************** - - Tunneling global variables into new instance of GHC library - - ********************************************************************* -} - -saveLinkerGlobals :: IO (MVar PersistentLinkerState, Bool) -saveLinkerGlobals = liftM2 (,) (readIORef v_PersistentLinkerState) (readIORef v_InitLinkerDone) - -restoreLinkerGlobals :: (MVar PersistentLinkerState, Bool) -> IO () -restoreLinkerGlobals (pls, ild) = do - writeIORef v_PersistentLinkerState pls - writeIORef v_InitLinkerDone ild |