[commit: ghc] master: Make 'SPECIALISE instance' work again (1ed0409)
Simon Peyton Jones
simonpj at microsoft.com
Thu May 30 13:31:33 CEST 2013
Repository : http://darcs.haskell.org/ghc.git/
On branch : master
https://github.com/ghc/ghc/commit/1ed0409010afeaa318676e351b833aea659bf93a
>---------------------------------------------------------------
commit 1ed0409010afeaa318676e351b833aea659bf93a
Author: Simon Peyton Jones <simonpj at microsoft.com>
Date: Thu May 30 12:08:39 2013 +0100
Make 'SPECIALISE instance' work again
This is a long-standing regression (Trac #7797), which meant that in
particular the Eq [Char] instance does not get specialised.
(The *methods* do, but the dictionary itself doesn't.) So when you
call a function
f :: Eq a => blah
on a string type (ie a=[Char]), 7.6 passes a dictionary of un-specialised
methods.
This only matters when calling an overloaded function from a
specialised context, but that does matter in some programs. I
remember (though I cannot find the details) that Nick Frisby discovered
this to be the source of some pretty solid performanc regresisons.
Anyway it works now. The key change is that a DFunUnfolding now takes
a form that is both simpler than before (the DFunArg type is eliminated)
and more general:
data Unfolding
= ...
| DFunUnfolding { -- The Unfolding of a DFunId
-- See Note [DFun unfoldings]
-- df = /\a1..am. \d1..dn. MkD t1 .. tk
-- (op1 a1..am d1..dn)
-- (op2 a1..am d1..dn)
df_bndrs :: [Var], -- The bound variables [a1..m],[d1..dn]
df_con :: DataCon, -- The dictionary data constructor (never a newtype datacon)
df_args :: [CoreExpr] -- Args of the data con: types, superclasses and methods,
} -- in positional order
That in turn allowed me to re-enable the DFunUnfolding specialisation in
DsBinds. Lots of details here in TcInstDcls:
Note [SPECIALISE instance pragmas]
I also did some refactoring, in particular to pass the InScopeSet to
exprIsConApp_maybe (which in turn means it has to go to a RuleFun).
NB: Interface file format has changed!
compiler/basicTypes/MkId.lhs | 8 +-
compiler/coreSyn/CoreFVs.lhs | 33 +++--
compiler/coreSyn/CoreSubst.lhs | 65 +++++----
compiler/coreSyn/CoreSyn.lhs | 39 ++----
compiler/coreSyn/CoreTidy.lhs | 7 +-
compiler/coreSyn/CoreUnfold.lhs | 11 +-
compiler/coreSyn/PprCore.lhs | 10 +-
compiler/deSugar/DsBinds.lhs | 39 +++---
compiler/iface/BinIface.hs | 15 +--
compiler/iface/IfaceSyn.lhs | 9 +-
compiler/iface/MkIface.lhs | 4 +-
compiler/iface/TcIface.lhs | 10 +-
compiler/main/TidyPgm.lhs | 3 +-
compiler/prelude/PrelRules.lhs | 180 +++++++------------------
compiler/simplCore/OccurAnal.lhs | 2 +-
compiler/simplCore/SimplUtils.lhs | 12 +-
compiler/simplCore/Simplify.lhs | 12 +-
compiler/specialise/Rules.lhs | 76 +++++------
compiler/specialise/Specialise.lhs | 20 ++-
compiler/typecheck/TcInstDcls.lhs | 120 ++++++++++-------
compiler/vectorise/Vectorise/Generic/PADict.hs | 24 ++--
21 files changed, 316 insertions(+), 383 deletions(-)
Diff suppressed because of size. To see it, use:
git show 1ed0409010afeaa318676e351b833aea659bf93a
More information about the ghc-commits
mailing list