diff options
author | Sylvain Henry <sylvain@haskus.fr> | 2021-03-25 17:25:31 +0100 |
---|---|---|
committer | Marge Bot <ben+marge-bot@smart-cactus.org> | 2021-04-10 05:31:14 -0400 |
commit | 085983e63bfe6af23f8b85fbfcca8db4872d2f60 (patch) | |
tree | 0d41072c2830e5825f4e6f28c1ed528e29ca54dd /compiler/GHC.hs | |
parent | 9c762f27d5468ab692e390b16420c9e304993993 (diff) | |
download | haskell-085983e63bfe6af23f8b85fbfcca8db4872d2f60.tar.gz |
Read constants header instead of global platformConstants
With this patch we switch from reading the globally installed
platformConstants file to reading the DerivedConstants.h header file
that is bundled in the RTS unit. When we build the RTS unit itself, we
get it from its includes directories.
The new parser is more efficient and strict than the Read instance for
PlatformConstants and we get about 2.2MB less allocations in every
cases. However it only really shows in tests that don't allocate much,
hence the following metric decreases.
Metric Decrease:
Naperian
T10421
T10547
T12150
T12234
T12425
T13035
T18304
T18923
T5837
T6048
T18140
Diffstat (limited to 'compiler/GHC.hs')
-rw-r--r-- | compiler/GHC.hs | 23 |
1 files changed, 14 insertions, 9 deletions
diff --git a/compiler/GHC.hs b/compiler/GHC.hs index 134580c653..59f49453ed 100644 --- a/compiler/GHC.hs +++ b/compiler/GHC.hs @@ -639,11 +639,13 @@ checkBrokenTablesNextToCode' logger dflags setSessionDynFlags :: GhcMonad m => DynFlags -> m () setSessionDynFlags dflags0 = do logger <- getLogger - dflags <- checkNewDynFlags logger dflags0 + dflags1 <- checkNewDynFlags logger dflags0 hsc_env <- getSession let old_unit_env = hsc_unit_env hsc_env let cached_unit_dbs = ue_unit_dbs old_unit_env - (dbs,unit_state,home_unit) <- liftIO $ initUnits logger dflags cached_unit_dbs + (dbs,unit_state,home_unit,mconstants) <- liftIO $ initUnits logger dflags1 cached_unit_dbs + + dflags <- liftIO $ updatePlatformConstants dflags1 mconstants -- Interpreter interp <- if gopt Opt_ExternalInterpreter dflags @@ -711,27 +713,30 @@ setProgramDynFlags dflags = setProgramDynFlags_ True dflags setProgramDynFlags_ :: GhcMonad m => Bool -> DynFlags -> m Bool setProgramDynFlags_ invalidate_needed dflags = do logger <- getLogger - dflags' <- checkNewDynFlags logger dflags + dflags0 <- checkNewDynFlags logger dflags dflags_prev <- getProgramDynFlags - let changed = packageFlagsChanged dflags_prev dflags' + let changed = packageFlagsChanged dflags_prev dflags0 if changed then do old_unit_env <- hsc_unit_env <$> getSession let cached_unit_dbs = ue_unit_dbs old_unit_env - (dbs,unit_state,home_unit) <- liftIO $ initUnits logger dflags' cached_unit_dbs + (dbs,unit_state,home_unit,mconstants) <- liftIO $ initUnits logger dflags0 cached_unit_dbs + + dflags1 <- liftIO $ updatePlatformConstants dflags0 mconstants + let unit_env = UnitEnv - { ue_platform = targetPlatform dflags' - , ue_namever = ghcNameVersion dflags' + { ue_platform = targetPlatform dflags1 + , ue_namever = ghcNameVersion dflags1 , ue_home_unit = Just home_unit , ue_hpt = ue_hpt old_unit_env , ue_eps = ue_eps old_unit_env , ue_units = unit_state , ue_unit_dbs = Just dbs } - modifySession $ \h -> h{ hsc_dflags = dflags' + modifySession $ \h -> h{ hsc_dflags = dflags1 , hsc_unit_env = unit_env } - else modifySession $ \h -> h{ hsc_dflags = dflags' } + else modifySession $ \h -> h{ hsc_dflags = dflags0 } when invalidate_needed $ invalidateModSummaryCache return changed |