[Git][ghc/ghc][wip/T24726] 9 commits: Refactor the Binary serialisation interface
Simon Peyton Jones (@simonpj)
gitlab at gitlab.haskell.org
Fri Apr 26 22:19:13 UTC 2024
Simon Peyton Jones pushed to branch wip/T24726 at Glasgow Haskell Compiler / GHC
Commits:
fa03b1fb by Fendor at 2024-04-26T18:03:13-04:00
Refactor the Binary serialisation interface
The goal is simplifiy adding deduplication tables to `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 https://gitlab.haskell.org/ghc/ghc/-/issues/24540
for more motivation.
In addition to this refactoring, we split `UserData` into `ReaderUserData`
and `WriterUserData`, to avoid partial functions and reduce overall
memory usage, as we need fewer mutable variables.
Bump haddock submodule to accomodate for `UserData` split.
-------------------------
Metric Increase:
MultiLayerModulesTH_Make
MultiLayerModulesRecomp
T21839c
-------------------------
- - - - -
bac57298 by Fendor at 2024-04-26T18:03:13-04:00
Split `BinHandle` into `ReadBinHandle` and `WriteBinHandle`
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.
- - - - -
4d6394dd by Simon Peyton Jones at 2024-04-26T18:03:49-04:00
Fix missing escaping-kind check in tcPatSynSig
Note [Escaping kind in type signatures] explains how we deal
with escaping kinds in type signatures, e.g.
f :: forall r (a :: TYPE r). a
where the kind of the body is (TYPE r), but `r` is not in
scope outside the forall-type.
I had missed this subtlety in tcPatSynSig, leading to #24686.
This MR fixes it; and a similar bug in tc_top_lhs_type. (The
latter is tested by T24686a.)
- - - - -
981c2c2c by Alan Zimmerman at 2024-04-26T18:04:25-04:00
EPA: check-exact: check that the roundtrip reproduces the source
Closes #24670
- - - - -
a8616747 by Andrew Lelechenko at 2024-04-26T18:05:01-04:00
Document that setEnv is not thread-safe
- - - - -
1e41de83 by Bryan Richter at 2024-04-26T18:05:37-04:00
CI: Work around frequent Signal 9 errors
- - - - -
f1861000 by Simon Peyton Jones at 2024-04-26T23:19:05+01:00
Track in-scope variables in ruleCheckProgram
This small patch fixes #24726, by tracking in-scope variables
properly in -drule-check. Not hard to do!
- - - - -
eaa2b476 by Simon Peyton Jones at 2024-04-26T23:19:05+01:00
Add a couple more HasCallStack constraints in SimpleOpt
Just for debugging, no effect on normal code
- - - - -
8a8e6bbb by Simon Peyton Jones at 2024-04-26T23:19:05+01:00
Add comments to Prep.hs
This documentation patch fixes a TODO left over from !12364
- - - - -
30 changed files:
- .gitlab-ci.yml
- compiler/GHC/Core/Rules.hs
- compiler/GHC/Core/SimpleOpt.hs
- compiler/GHC/CoreToStg/Prep.hs
- compiler/GHC/Iface/Binary.hs
- compiler/GHC/Iface/Ext/Binary.hs
- compiler/GHC/Iface/Ext/Fields.hs
- compiler/GHC/Iface/Recomp.hs
- compiler/GHC/Iface/Recomp/Binary.hs
- compiler/GHC/Iface/Recomp/Flags.hs
- compiler/GHC/Iface/Syntax.hs
- compiler/GHC/Iface/Type.hs
- compiler/GHC/StgToJS/Object.hs
- compiler/GHC/Tc/Gen/HsType.hs
- compiler/GHC/Tc/Gen/Sig.hs
- compiler/GHC/Types/Basic.hs
- compiler/GHC/Types/FieldLabel.hs
- compiler/GHC/Types/Name.hs
- compiler/GHC/Utils/Binary.hs
- compiler/GHC/Utils/Binary/Typeable.hs
- libraries/ghc-internal/src/GHC/Internal/System/Environment.hs
- libraries/ghc-internal/src/GHC/Internal/System/Environment/Blank.hsc
- + testsuite/tests/polykinds/T24686.hs
- + testsuite/tests/polykinds/T24686.stderr
- + testsuite/tests/polykinds/T24686a.hs
- + testsuite/tests/polykinds/T24686a.stderr
- testsuite/tests/polykinds/all.T
- testsuite/tests/printer/PprExportWarn.hs
- testsuite/tests/rep-poly/RepPolyPatSynRes.stderr
- + testsuite/tests/simplCore/should_compile/T24726.hs
The diff was not included because it is too large.
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/68820dd43b3162ebbc8fedf66a527b56070bb14c...8a8e6bbb656339524a5ec23be06df7ff243833d5
--
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/68820dd43b3162ebbc8fedf66a527b56070bb14c...8a8e6bbb656339524a5ec23be06df7ff243833d5
You're receiving this email because of your account on gitlab.haskell.org.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/ghc-commits/attachments/20240426/988400db/attachment.html>
More information about the ghc-commits
mailing list