Wolfgang Jeltsch pushed to branch wip/jeltsch/smaller-pit at Glasgow Haskell Compiler / GHC

Commits:

3 changed files:

Changes:

  • compiler/GHC/Iface/Binary.hs
    ... ... @@ -197,7 +197,7 @@ getIfaceWithExtFields name_cache bh = do
    197 197
       modIfaceBinData <- freezeBinHandle bh start
    
    198 198
       pure $ mod_iface
    
    199 199
         & set_mi_ext_fields extFields
    
    200
    -    & set_mi_hi_bytes (FullIfaceBinHandle $ Strict.Just modIfaceBinData)
    
    200
    +    & set_mi_hi_bytes (Strict.Just modIfaceBinData)
    
    201 201
     
    
    202 202
     -- | This performs a get action after reading the dictionary and symbol
    
    203 203
     -- table. It is necessary to run this before trying to deserialise any
    
    ... ... @@ -276,10 +276,10 @@ writeBinIface profile traceBinIface compressionLevel hi_path mod_iface = do
    276 276
     putIfaceWithExtFields :: TraceBinIFace -> CompressionIFace -> WriteBinHandle -> ModIface -> IO ()
    
    277 277
     putIfaceWithExtFields traceBinIface compressionLevel bh mod_iface =
    
    278 278
       case mi_hi_bytes mod_iface of
    
    279
    -    FullIfaceBinHandle Strict.Nothing -> do
    
    279
    +    Strict.Nothing -> do
    
    280 280
           forwardPutRel_ bh (\_ -> put_ bh (mi_ext_fields mod_iface)) $ do
    
    281 281
             putWithUserData traceBinIface compressionLevel bh mod_iface
    
    282
    -    FullIfaceBinHandle (Strict.Just binData) -> putFullBinData bh binData
    
    282
    +    Strict.Just binData -> putFullBinData bh binData
    
    283 283
     
    
    284 284
     -- | Put a piece of data with an initialised `UserData` field. This
    
    285 285
     -- is necessary if you want to serialise Names or FastStrings.
    

  • compiler/GHC/Iface/Make.hs
    ... ... @@ -77,6 +77,7 @@ import GHC.Iface.Binary
    77 77
     
    
    78 78
     import GHC.Data.FastString
    
    79 79
     import GHC.Data.Maybe
    
    80
    +import qualified GHC.Data.Strict as Strict
    
    80 81
     
    
    81 82
     import GHC.HsToCore.Docs
    
    82 83
     import GHC.HsToCore.Usage
    
    ... ... @@ -394,7 +395,7 @@ mkIface_ hsc_env
    394 395
               & set_mi_docs             docs
    
    395 396
               & set_mi_abi_hashes       ()
    
    396 397
               & set_mi_ext_fields       emptyExtensibleFields
    
    397
    -          & set_mi_hi_bytes         PartialIfaceBinHandle
    
    398
    +          & set_mi_hi_bytes         Strict.Nothing
    
    398 399
     
    
    399 400
       where
    
    400 401
          cmp_rule     = lexicalCompareFS `on` ifRuleName
    

  • compiler/GHC/Unit/Module/ModIface.hs
    ... ... @@ -70,7 +70,7 @@ module GHC.Unit.Module.ModIface
    70 70
        , set_mi_hash_fn
    
    71 71
        , completePartialModIface
    
    72 72
        , shrinkModIface
    
    73
    -   , IfaceBinHandle(..)
    
    73
    +   , IfaceBinHandle
    
    74 74
        , PartialModIface
    
    75 75
        , RetainedModIface
    
    76 76
        , IfaceAbiHashes (..)
    
    ... ... @@ -160,6 +160,7 @@ import GHC.Utils.Binary
    160 160
     
    
    161 161
     import Control.DeepSeq
    
    162 162
     import Control.Exception
    
    163
    +import Data.Void (Void)
    
    163 164
     
    
    164 165
     
    
    165 166
     {- Note [Interface file stages]
    
    ... ... @@ -236,15 +237,10 @@ data ModIfacePhase
    236 237
     -- | In-memory byte array representation of a 'ModIface'.
    
    237 238
     --
    
    238 239
     -- See Note [Sharing of ModIface] for why we need this.
    
    239
    -data IfaceBinHandle (phase :: ModIfacePhase) where
    
    240
    -  -- | A partial 'ModIface' cannot be serialised to disk.
    
    241
    -  PartialIfaceBinHandle :: IfaceBinHandle 'ModIfaceCore
    
    242
    -  -- | Optional 'FullBinData' that can be serialised to disk directly.
    
    243
    -  --
    
    244
    -  -- See Note [Private fields in ModIface] for when this fields needs to be cleared
    
    245
    -  -- (e.g., set to 'Nothing').
    
    246
    -  FullIfaceBinHandle :: !(Strict.Maybe FullBinData) -> IfaceBinHandle 'ModIfaceFinal
    
    247
    -  RetainedIfaceBinHandle :: IfaceBinHandle 'ModIfaceRetained
    
    240
    +type family IfaceBinHandle (phase :: ModIfacePhase) where
    
    241
    +  IfaceBinHandle 'ModIfaceCore     = Void
    
    242
    +  IfaceBinHandle 'ModIfaceFinal    = FullBinData
    
    243
    +  IfaceBinHandle 'ModIfaceRetained = Void
    
    248 244
     
    
    249 245
     type family IfaceSelfRecompData (phase :: ModIfacePhase) where
    
    250 246
       IfaceSelfRecompData 'ModIfaceCore     = Maybe IfaceSelfRecomp
    
    ... ... @@ -322,11 +318,12 @@ withSelfRecomp iface nk jk =
    322 318
     -- fields.
    
    323 319
     data ModIface_ (phase :: ModIfacePhase)
    
    324 320
       = PrivateModIface {
    
    325
    -        mi_hi_bytes_ :: !(IfaceBinHandle phase),
    
    321
    +        mi_hi_bytes_ :: !(Strict.Maybe (IfaceBinHandle phase)),
    
    326 322
                     -- ^ A serialised in-memory buffer of this 'ModIface'.
    
    327 323
                     -- If this handle is given, we can avoid serialising the 'ModIface'
    
    328 324
                     -- when writing this 'ModIface' to disk, and write this buffer to disk instead.
    
    329
    -                -- See Note [Sharing of ModIface].
    
    325
    +                -- See Note [Sharing of ModIface] and
    
    326
    +                -- Note [Private fields in ModIface].
    
    330 327
             mi_iface_hash_  :: Fingerprint, -- A hash of the whole interface
    
    331 328
     
    
    332 329
             mi_mod_info_     :: IfaceModInfo,
    
    ... ... @@ -718,7 +715,7 @@ instance Binary ModIface where
    718 715
                      -- We can't populate this field here, as we are
    
    719 716
                      -- missing the 'mi_ext_fields_' field, which is
    
    720 717
                      -- handled in 'getIfaceWithExtFields'.
    
    721
    -                 mi_hi_bytes_    = FullIfaceBinHandle Strict.Nothing
    
    718
    +                 mi_hi_bytes_    = Strict.Nothing
    
    722 719
                      })
    
    723 720
     
    
    724 721
     instance Binary IfaceModInfo where
    
    ... ... @@ -833,7 +830,7 @@ emptyPartialModIface mod
    833 830
       = PrivateModIface
    
    834 831
           { mi_mod_info_    = emptyIfaceModInfo mod,
    
    835 832
             mi_iface_hash_  = fingerprint0,
    
    836
    -        mi_hi_bytes_    = PartialIfaceBinHandle,
    
    833
    +        mi_hi_bytes_    = Strict.Nothing,
    
    837 834
             mi_deps_        = noDependencies,
    
    838 835
             mi_public_      = emptyPublicModIface [] [] [] [] [] [] [] (),
    
    839 836
             mi_simplified_core_ = Nothing,
    
    ... ... @@ -907,7 +904,7 @@ emptyFullModIface :: Module -> ModIface
    907 904
     emptyFullModIface mod =
    
    908 905
         (emptyPartialModIface mod)
    
    909 906
           { mi_public_ = emptyPublicModIface [] [] [] [] [] [] [] emptyIfaceBackend
    
    910
    -      , mi_hi_bytes_ = FullIfaceBinHandle Strict.Nothing
    
    907
    +      , mi_hi_bytes_ = Strict.Nothing
    
    911 908
           }
    
    912 909
     
    
    913 910
     
    
    ... ... @@ -940,7 +937,7 @@ instance ( NFData (IfaceSelfRecompData phase)
    940 937
              , NFData (IfaceAbiHashesData phase)
    
    941 938
              ) => NFData (ModIface_ phase) where
    
    942 939
       rnf (PrivateModIface a1 a2 a3 a4 a5 a6 a7 a8 a9 a10)
    
    943
    -    = (a1 :: IfaceBinHandle phase)
    
    940
    +    = a1
    
    944 941
         `seq` rnf a2
    
    945 942
         `seq` rnf a3
    
    946 943
         `seq` rnf a4
    
    ... ... @@ -1051,7 +1048,7 @@ completePartialModIface :: PartialModIface
    1051 1048
     completePartialModIface partial iface_hash decls extra_decls final_exts cache = partial
    
    1052 1049
       { mi_public_ = completePublicModIface decls final_exts cache (mi_public_ partial)
    
    1053 1050
       , mi_simplified_core_ = extra_decls
    
    1054
    -  , mi_hi_bytes_ = FullIfaceBinHandle Strict.Nothing
    
    1051
    +  , mi_hi_bytes_ = Strict.Nothing
    
    1055 1052
       , mi_iface_hash_ = iface_hash
    
    1056 1053
       }
    
    1057 1054
     
    
    ... ... @@ -1072,7 +1069,7 @@ shrinkModIface :: ModIface -> RetainedModIface
    1072 1069
     shrinkModIface PrivateModIface {..}
    
    1073 1070
       = PrivateModIface
    
    1074 1071
         {
    
    1075
    -      mi_hi_bytes_        = RetainedIfaceBinHandle,
    
    1072
    +      mi_hi_bytes_        = Strict.Nothing,
    
    1076 1073
           mi_public_          = shrinkIfacePublic mi_public_,
    
    1077 1074
           mi_self_recomp_     = (),
    
    1078 1075
           mi_simplified_core_ = (),
    
    ... ... @@ -1100,7 +1097,7 @@ set_mi_mod_info val iface = clear_mi_hi_bytes $ iface { mi_mod_info_ = val }
    1100 1097
     set_mi_self_recomp :: IfaceSelfRecompData phase -> ModIface_ phase -> ModIface_ phase
    
    1101 1098
     set_mi_self_recomp val iface = clear_mi_hi_bytes $ iface { mi_self_recomp_ = val }
    
    1102 1099
     
    
    1103
    -set_mi_hi_bytes :: IfaceBinHandle phase -> ModIface_ phase -> ModIface_ phase
    
    1100
    +set_mi_hi_bytes :: Strict.Maybe (IfaceBinHandle phase) -> ModIface_ phase -> ModIface_ phase
    
    1104 1101
     set_mi_hi_bytes val iface = iface { mi_hi_bytes_ = val }
    
    1105 1102
     
    
    1106 1103
     set_mi_deps :: Dependencies -> ModIface_ phase -> ModIface_ phase
    
    ... ... @@ -1203,12 +1200,7 @@ set_mi_mod_info_field f iface = clear_mi_hi_bytes $ iface { mi_mod_info_ = f (mi
    1203 1200
     
    
    1204 1201
     -- | Invalidate any byte array buffer we might have.
    
    1205 1202
     clear_mi_hi_bytes :: ModIface_ phase -> ModIface_ phase
    
    1206
    -clear_mi_hi_bytes iface = iface
    
    1207
    -  { mi_hi_bytes_ = case mi_hi_bytes iface of
    
    1208
    -      PartialIfaceBinHandle  -> PartialIfaceBinHandle
    
    1209
    -      FullIfaceBinHandle _   -> FullIfaceBinHandle Strict.Nothing
    
    1210
    -      RetainedIfaceBinHandle -> RetainedIfaceBinHandle
    
    1211
    -  }
    
    1203
    +clear_mi_hi_bytes iface = iface { mi_hi_bytes_ = Strict.Nothing }
    
    1212 1204
     
    
    1213 1205
     -- ----------------------------------------------------------------------------
    
    1214 1206
     -- 'ModIface' pattern synonyms to keep breakage low.
    
    ... ... @@ -1319,7 +1311,7 @@ pattern ModIface ::
    1319 1311
       -> Maybe Docs
    
    1320 1312
       -> IfaceAbiHashesData phase
    
    1321 1313
       -> ExtensibleFieldsData phase
    
    1322
    -  -> IfaceBinHandle phase
    
    1314
    +  -> Strict.Maybe (IfaceBinHandle phase)
    
    1323 1315
       -> IfaceSelfRecompData phase
    
    1324 1316
       -> (OccName -> Maybe Fixity)
    
    1325 1317
       -> (OccName -> Maybe (OccName, Fingerprint))