diff options
author | Sylvain Henry <sylvain@haskus.fr> | 2020-03-16 15:13:05 +0100 |
---|---|---|
committer | Marge Bot <ben+marge-bot@smart-cactus.org> | 2020-04-21 06:39:32 -0400 |
commit | 70be0fbcefa07ff164437476bf2809ea7c3ff495 (patch) | |
tree | 619f88217125ca6d722df4c16f000e752542729e | |
parent | 6655f93324b7f1d30a6baaedfecae455d5e08e39 (diff) | |
download | haskell-70be0fbcefa07ff164437476bf2809ea7c3ff495.tar.gz |
GHC.Runtime: avoid DynFlags (#17957)
* add `getPlatform :: TcM Platform` helper
* remove unused `DynFlags` parameter from `emptyPLS`
-rw-r--r-- | compiler/GHC/Runtime/Heap/Inspect.hs | 2 | ||||
-rw-r--r-- | compiler/GHC/Runtime/Linker.hs | 20 | ||||
-rw-r--r-- | compiler/GHC/Tc/Types.hs | 7 |
3 files changed, 18 insertions, 11 deletions
diff --git a/compiler/GHC/Runtime/Heap/Inspect.hs b/compiler/GHC/Runtime/Heap/Inspect.hs index 3802baf4df..0c856aa7a5 100644 --- a/compiler/GHC/Runtime/Heap/Inspect.hs +++ b/compiler/GHC/Runtime/Heap/Inspect.hs @@ -865,7 +865,7 @@ extractSubTerms recurse clos = liftM thdOf3 . go 0 0 -- This is a bit involved since we allow packing multiple fields -- within a single word. See also -- GHC.StgToCmm.Layout.mkVirtHeapOffsetsWithPadding - platform <- targetPlatform <$> getDynFlags + platform <- getPlatform let word_size = platformWordSizeInBytes platform endian = platformByteOrder platform size_b = primRepSizeB platform rep diff --git a/compiler/GHC/Runtime/Linker.hs b/compiler/GHC/Runtime/Linker.hs index 5da9a916af..c103feb3fc 100644 --- a/compiler/GHC/Runtime/Linker.hs +++ b/compiler/GHC/Runtime/Linker.hs @@ -127,15 +127,15 @@ modifyMbPLS_ :: DynLinker -> (Maybe PersistentLinkerState -> IO (Maybe PersistentLinkerState)) -> IO () modifyMbPLS_ dl f = modifyMVar_ (dl_mpls dl) f -emptyPLS :: DynFlags -> PersistentLinkerState -emptyPLS _ = PersistentLinkerState { - closure_env = emptyNameEnv, - itbl_env = emptyNameEnv, - pkgs_loaded = init_pkgs, - bcos_loaded = [], - objs_loaded = [], - temp_sos = [] } - +emptyPLS :: PersistentLinkerState +emptyPLS = PersistentLinkerState + { closure_env = emptyNameEnv + , itbl_env = emptyNameEnv + , pkgs_loaded = init_pkgs + , bcos_loaded = [] + , objs_loaded = [] + , temp_sos = [] + } -- Packages that don't need loading, because the compiler -- shares them with the interpreted program. -- @@ -280,7 +280,7 @@ reallyInitDynLinker :: HscEnv -> IO PersistentLinkerState reallyInitDynLinker hsc_env = do -- Initialise the linker state let dflags = hsc_dflags hsc_env - pls0 = emptyPLS dflags + pls0 = emptyPLS -- (a) initialise the C dynamic linker initObjLinker hsc_env diff --git a/compiler/GHC/Tc/Types.hs b/compiler/GHC/Tc/Types.hs index e5f5fdbf50..8c4086a2ca 100644 --- a/compiler/GHC/Tc/Types.hs +++ b/compiler/GHC/Tc/Types.hs @@ -70,6 +70,7 @@ module GHC.Tc.Types( TcId, TcIdSet, NameShape(..), removeBindingShadowing, + getPlatform, -- Constraint solver plugins TcPlugin(..), TcPluginResult(..), TcPluginSolver, @@ -84,6 +85,7 @@ module GHC.Tc.Types( #include "HsVersions.h" import GhcPrelude +import GHC.Platform import GHC.Hs import GHC.Driver.Types @@ -902,6 +904,11 @@ removeBindingShadowing bindings = reverse $ fst $ foldl else (binding:bindingAcc, extendOccSet seenNames (occName binding))) ([], emptyOccSet) bindings + +-- | Get target platform +getPlatform :: TcM Platform +getPlatform = targetPlatform <$> getDynFlags + --------------------------- -- Template Haskell stages and levels --------------------------- |