Commits on Source (2)
-
Hannes Siebenhandl authored
The end goal is to dynamically add deduplication tables for `ModIface` interface serialisation. We identify two main points of interest that make this difficult: 1. UserData hardcodes what `Binary` instances can have deduplication tables. Moreover, it heavily uses partial functions. 2. GHC.Iface.Binary hardcodes the deduplication tables for 'Name' and 'FastString', making it difficult to add more deduplication. Instead of having a single `UserData` record with fields for all the types that can have deduplication tables, we allow to provide custom serialisers for any `Typeable`. These are wrapped in existentials and stored in a `Map` indexed by their respective `TypeRep`. The `Binary` instance of the type to deduplicate still needs to explicitly look up the decoder via `findUserDataReader` and `findUserDataWriter`, which is no worse than the status-quo. `Map` was chosen as microbenchmarks indicate it is the fastest for a small number of keys (< 10). To generalise the deduplication table serialisation mechanism, we introduce the types `ReaderTable` and `WriterTable` which provide a simple interface that is sufficient to implement a general purpose deduplication mechanism for `writeBinIface` and `readBinIface`. This allows us to provide a list of deduplication tables for serialisation that can be extended more easily, for example for `IfaceTyCon`, see the issue #24540 for more motivation. In addition to ths refactoring, we split `UserData` into `ReaderUserData` and `WriterUserData`, to avoid partial functions. Bump haddock submodule to accomodate for `UserData` split. ------------------------- Metric Increase: MultiLayerModulesTH_Make MultiLayerModulesRecomp T21839c -------------------------
c6e1bbf1 -
Hannes Siebenhandl authored
A `BinHandle` contains too much information for reading data. For example, it needs to keep a `FastMutInt` and a `IORef BinData`, when the non-mutable variants would suffice. Additionally, this change has the benefit that anyone can immediately tell whether the `BinHandle` is used for reading or writing. Bump haddock submodule BinHandle split.
6df52a0a
Showing
- compiler/GHC/Iface/Binary.hs 277 additions, 73 deletionscompiler/GHC/Iface/Binary.hs
- compiler/GHC/Iface/Ext/Binary.hs 31 additions, 29 deletionscompiler/GHC/Iface/Ext/Binary.hs
- compiler/GHC/Iface/Ext/Fields.hs 6 additions, 6 deletionscompiler/GHC/Iface/Ext/Fields.hs
- compiler/GHC/Iface/Recomp.hs 1 addition, 1 deletioncompiler/GHC/Iface/Recomp.hs
- compiler/GHC/Iface/Recomp/Binary.hs 4 additions, 4 deletionscompiler/GHC/Iface/Recomp/Binary.hs
- compiler/GHC/Iface/Recomp/Flags.hs 3 additions, 3 deletionscompiler/GHC/Iface/Recomp/Flags.hs
- compiler/GHC/Iface/Syntax.hs 8 additions, 7 deletionscompiler/GHC/Iface/Syntax.hs
- compiler/GHC/Iface/Type.hs 7 additions, 7 deletionscompiler/GHC/Iface/Type.hs
- compiler/GHC/StgToJS/Object.hs 21 additions, 20 deletionscompiler/GHC/StgToJS/Object.hs
- compiler/GHC/Types/Basic.hs 1 addition, 1 deletioncompiler/GHC/Types/Basic.hs
- compiler/GHC/Types/FieldLabel.hs 1 addition, 3 deletionscompiler/GHC/Types/FieldLabel.hs
- compiler/GHC/Types/Name.hs 4 additions, 4 deletionscompiler/GHC/Types/Name.hs
- compiler/GHC/Utils/Binary.hs 444 additions, 226 deletionscompiler/GHC/Utils/Binary.hs
- compiler/GHC/Utils/Binary/Typeable.hs 2 additions, 2 deletionscompiler/GHC/Utils/Binary/Typeable.hs
- utils/haddock 1 addition, 1 deletionutils/haddock