diff options
author | Ben Gamari <ben@smart-cactus.org> | 2016-11-30 10:54:45 -0500 |
---|---|---|
committer | Ben Gamari <ben@smart-cactus.org> | 2016-11-30 10:56:10 -0500 |
commit | e2330b6dde805a5507898c3c4ddf38599df969da (patch) | |
tree | d52c52b99f510553b2d1733d006747d75be68a6d /compiler/utils | |
parent | 03766cdbd26855e50719bd8ffcaf19898bd33f16 (diff) | |
download | haskell-e2330b6dde805a5507898c3c4ddf38599df969da.tar.gz |
Revert "Make globals use sharedCAF"
This reverts commit 6f7ed1e51bf360621a3c2a447045ab3012f68575 due to breakage of
the build on Windows.
Diffstat (limited to 'compiler/utils')
-rw-r--r-- | compiler/utils/FastString.hs | 7 | ||||
-rw-r--r-- | compiler/utils/Util.hs | 34 |
2 files changed, 7 insertions, 34 deletions
diff --git a/compiler/utils/FastString.hs b/compiler/utils/FastString.hs index 8f76584875..1496a8686e 100644 --- a/compiler/utils/FastString.hs +++ b/compiler/utils/FastString.hs @@ -285,6 +285,13 @@ originally assigned to those FastStrings. Thus the lookup fails since the domain of the GlobalRdrEnv is affected by the RdrName's OccName's FastString's unique. +The old `reinitializeGlobals` mechanism is enough to provide the plugin with +read-access to the table, but it insufficient in the general case where the +plugin may allocate FastStrings. This mutates the supply for the FastStrings' +unique, and that needs to be propagated back to the compiler's instance of the +global variable. Such propagation is beyond the `reinitializeGlobals` +mechanism. + Maintaining synchronization of the two instances of this global is rather difficult because of the uses of `unsafePerformIO` in this module. Not synchronizing them risks breaking the rather major invariant that two diff --git a/compiler/utils/Util.hs b/compiler/utils/Util.hs index 88b5090f0a..3104c747a1 100644 --- a/compiler/utils/Util.hs +++ b/compiler/utils/Util.hs @@ -104,7 +104,6 @@ module Util ( hSetTranslit, global, consIORef, globalM, - sharedGlobal, sharedGlobalM, -- * Filenames and paths Suffix, @@ -145,7 +144,6 @@ import qualified GHC.Stack import Control.Applicative ( liftA2 ) import Control.Monad ( liftM ) import GHC.IO.Encoding (mkTextEncoding, textEncodingName) -import GHC.Conc.Sync ( sharedCAF ) import System.IO (Handle, hGetEncoding, hSetEncoding) import System.IO.Error as IO ( isDoesNotExistError ) import System.Directory ( doesDirectoryExist, getModificationTime ) @@ -932,28 +930,6 @@ seqList :: [a] -> b -> b seqList [] b = b seqList (x:xs) b = x `seq` seqList xs b - -{- -************************************************************************ -* * - Globals and the RTS -* * -************************************************************************ - -When a plugin is loaded, it currently gets linked against a *newly -loaded* copy of the GHC package. This would not be a problem, except -that the new copy has its own mutable state that is not shared with -that state that has already been initialized by the original GHC -package. - -(Note that if the GHC executable was dynamically linked this -wouldn't be a problem, because we could share the GHC library it -links to; this is only a problem if DYNAMIC_GHC_PROGRAMS=NO.) - -The solution is to make use of @sharedCAF@ through @sharedGlobal@ -for globals that are shared between multiple copies of ghc packages. --} - -- Global variables: global :: a -> IORef a @@ -966,16 +942,6 @@ consIORef var x = do globalM :: IO a -> IORef a globalM ma = unsafePerformIO (ma >>= newIORef) --- Shared global variables: - -sharedGlobal :: a -> (Ptr (IORef a) -> IO (Ptr (IORef a))) -> IORef a -sharedGlobal a get_or_set = unsafePerformIO $ - newIORef a >>= flip sharedCAF get_or_set - -sharedGlobalM :: IO a -> (Ptr (IORef a) -> IO (Ptr (IORef a))) -> IORef a -sharedGlobalM ma get_or_set = unsafePerformIO $ - ma >>= newIORef >>= flip sharedCAF get_or_set - -- Module names: looksLikeModuleName :: String -> Bool |