[commit: ghc] wip/T9858-typeable-ben: Generate Typeble info at definition sites (fc903bf)
git at git.haskell.org
git at git.haskell.org
Wed Aug 26 14:12:39 UTC 2015
Repository : ssh://git@git.haskell.org/ghc
On branch : wip/T9858-typeable-ben
Link : http://ghc.haskell.org/trac/ghc/changeset/fc903bf85d1b79b12b974707fc8c2b5ed16651cd/ghc
>---------------------------------------------------------------
commit fc903bf85d1b79b12b974707fc8c2b5ed16651cd
Author: Simon Peyton Jones <simonpj at microsoft.com>
Date: Mon Mar 23 14:50:23 2015 +0000
Generate Typeble info at definition sites
This patch implements the idea floated in #9858, namely that we should
generate type-representation information at the data type declaration
site, rather than when solving a Typeable constraint.
However, this turned out quite a bit harder than I expected. I still
think it's the right thing to do, and it's done now, but it was quite
a struggle.
See particularly
* Note [Grand plan for Typeable] in TcTypeable (which is a new module)
* Note [The overall promotion story] in DataCon (clarifies existing stuff)
The most painful bit was that to generate Typeable instances (ie TyConRepName
bindings) for every TyCon is tricky for types in ghc-prim etc:
- we need to have enough data types around to *define* a TyCon
- many of these types are wired-in
Also, to minimise the code generated for each data type, I wanted to generate
pure data, not CAFs with unpackCString# stuff floating about.
Performance
~~~~~~~~~~~
Three perf/compiler tests start to allocate quite a bit more. This isn't surprising,
because they all allocate zillions of data types, with practically no other code,
esp T1969
T1969: GHC allocates 30% more
T5642: GHC allocates 14% more
T9872d: GHC allocates 5% more
I'm treating this as acceptable. The payoff comes in Typeable-heavy code.
Remaining to do
~~~~~~~~~~~~~~~
* I think that "TyCon" and "Module" are over-generic names to use for
the runtime type representations used in GHC.Typeable. Better might
be "TrTyCon" and "TrModule". But I have not yet done this
* Add more info the the "TyCon" e.g. source location where it was defined
* Use the new "Module" type to help with Trac #10068
* It would be possible to generate TyConRepName (ie Typeable instances)
selectively rather than all the time. We'd need to persist the information
in interface files. Lacking a motivating reason I have not done this, but
it would not be difficult.
Refactoring
~~~~~~~~~~~
As is so often the case, I ended up refactoring more than I intended.
In particular
* In TyCon,
- a type *family* (whether type or data)
is repesented by a FamilyTyCon
- a algebraic data type (including data/newtype instances)
is represented by AlgTyCon
This wasn't true before; a data family was represented as
an AlgTyCon. There are some corresponding changes in IfaceSyn.
Also get rid of the (unhelpfully named) tyConParent.
* In TyCon define 'Promoted', isomorphic to Maybe, used when things
are optionally promoted; and use it elsewhere in GHC.
* Each TyCon, including promoted TyCons, contains its TyConRepName,
if it has one. This is, in effect, the name of its Typeable
instance.
* I added PatSynId, DefMethId, and ReflectionId to the IdInfo.IdDetails
type. They are used for debugging only, namely to suppress excessive
output in -ddump-types.
* Tidy up the generation of PrelInfo.knownKeyNames
* Move newImplicitBinder from IfaceEnv to BuildTyCl
* PrelNames.conName renamed to dcQual for consistency with varQual, tcQual
* Move mkDefaultMethodIds, mkRecSelBinds from TcTyClsDecls to TcTyDecls
Conflicts:
compiler/basicTypes/DataCon.hs
compiler/basicTypes/Unique.hs
compiler/deSugar/DsBinds.hs
compiler/iface/BinIface.hs
compiler/iface/BuildTyCl.hs
compiler/iface/IfaceEnv.hs
compiler/iface/IfaceSyn.hs
compiler/iface/MkIface.hs
compiler/iface/TcIface.hs
compiler/main/HscMain.hs
compiler/prelude/PrelInfo.hs
compiler/prelude/PrelNames.hs
compiler/prelude/TysPrim.hs
compiler/prelude/TysWiredIn.hs
compiler/typecheck/TcBinds.hs
compiler/typecheck/TcEvidence.hs
compiler/typecheck/TcHsSyn.hs
compiler/typecheck/TcInstDcls.hs
compiler/typecheck/TcInteract.hs
compiler/typecheck/TcRnDriver.hs
compiler/typecheck/TcRnTypes.hs
compiler/typecheck/TcTyClsDecls.hs
compiler/typecheck/TcTyDecls.hs
compiler/types/TyCon.hs
compiler/vectorise/Vectorise/Generic/PData.hs
compiler/vectorise/Vectorise/Type/TyConDecl.hs
libraries/base/Data/Typeable/Internal.hs
libraries/ghc-prim/GHC/Classes.hs
libraries/ghc-prim/GHC/Types.hs
>---------------------------------------------------------------
fc903bf85d1b79b12b974707fc8c2b5ed16651cd
compiler/basicTypes/DataCon.hs | 225 ++++++++++----
compiler/basicTypes/IdInfo.hs | 19 +-
compiler/basicTypes/OccName.hs | 19 +-
compiler/basicTypes/Unique.hs | 51 +++-
compiler/deSugar/DsBinds.hs | 277 +++++++++--------
compiler/ghc.cabal.in | 1 +
compiler/hsSyn/HsUtils.hs | 6 +-
compiler/iface/BinIface.hs | 5 +-
compiler/iface/BuildTyCl.hs | 72 +++--
compiler/iface/IfaceEnv.hs | 41 +--
compiler/iface/IfaceSyn.hs | 91 +++---
compiler/iface/MkIface.hs | 24 +-
compiler/iface/TcIface.hs | 93 +++---
compiler/main/HscMain.hs | 12 +-
compiler/main/HscTypes.hs | 20 +-
compiler/prelude/PrelInfo.hs | 100 +++---
compiler/prelude/PrelNames.hs | 112 ++++---
compiler/prelude/TysPrim.hs | 46 +--
compiler/prelude/TysWiredIn.hs | 177 ++++++-----
compiler/typecheck/TcBinds.hs | 35 ++-
compiler/typecheck/TcDeriv.hs | 86 +-----
compiler/typecheck/TcEvidence.hs | 39 +--
compiler/typecheck/TcGenGenerics.hs | 38 ++-
compiler/typecheck/TcHsSyn.hs | 28 +-
compiler/typecheck/TcHsType.hs | 8 +-
compiler/typecheck/TcInstDcls.hs | 19 +-
compiler/typecheck/TcInteract.hs | 111 ++++---
compiler/typecheck/TcPatSyn.hs | 4 +-
compiler/typecheck/TcRnDriver.hs | 40 +--
compiler/typecheck/TcRnMonad.hs | 2 +-
compiler/typecheck/TcRnTypes.hs | 7 +-
compiler/typecheck/TcTyClsDecls.hs | 329 ++++----------------
compiler/typecheck/TcTyDecls.hs | 330 +++++++++++++++-----
compiler/typecheck/TcType.hs | 0
compiler/typecheck/TcTypeNats.hs | 10 +-
compiler/typecheck/TcTypeable.hs | 202 ++++++++++++
compiler/types/TyCon.hs | 406 ++++++++++++++-----------
compiler/types/Type.hs | 12 +
compiler/utils/Binary.hs | 11 +-
compiler/vectorise/Vectorise/Generic/PData.hs | 4 +-
compiler/vectorise/Vectorise/Type/Env.hs | 4 +-
compiler/vectorise/Vectorise/Type/TyConDecl.hs | 7 +-
libraries/base/Data/Typeable.hs | 3 +-
libraries/base/Data/Typeable/Internal.hs | 322 +++++++++++++-------
libraries/base/GHC/Show.hs | 10 +
libraries/ghc-prim/GHC/Classes.hs | 36 ++-
libraries/ghc-prim/GHC/IntWord64.hs | 3 +
libraries/ghc-prim/GHC/Magic.hs | 2 +
libraries/ghc-prim/GHC/Tuple.hs | 3 +
libraries/ghc-prim/GHC/TyCon.hs | 15 +
libraries/ghc-prim/GHC/Types.hs | 52 +++-
51 files changed, 2122 insertions(+), 1447 deletions(-)
Diff suppressed because of size. To see it, use:
git diff-tree --root --patch-with-stat --no-color --find-copies-harder --ignore-space-at-eol --cc fc903bf85d1b79b12b974707fc8c2b5ed16651cd
More information about the ghc-commits
mailing list