1. 16 Jan, 2015 1 commit
    • Alan Zimmerman's avatar
      API Annotations tweaks. · 11881ec6
      Alan Zimmerman authored
      HsTyLit now has SourceText
      Update documentation of HsSyn to reflect which annotations are attached to which element.
      Ensure that the parser always keeps HsSCC and HsTickPragma values, to
      be ignored in the desugar phase if not needed
      Bringing in SourceText for pragmas
      Add Location in NPlusKPat
      Add Location in FunDep
      Make RecCon payload Located
      Explicitly add AnnVal to RdrName where it is compound
      Add Location in IPBind
      Add Location to name in IEThingAbs
      Add Maybe (Located id,Bool) to Match to track fun_id,infix
        This includes converting Match into a record and adding a note about why
        the fun_id needs to be replicated in the Match.
      Add Location in KindedTyVar
      Sort out semi-colons for parsing
        - import statements
        - stmts
        - decls
        - decls_cls
        - decls_inst
      This updates the haddock submodule.
      Test Plan: ./validate
      Reviewers: hvr, austin, goldfire, simonpj
      Reviewed By: simonpj
      Subscribers: thomie, carter
      Differential Revision: https://phabricator.haskell.org/D538
  2. 11 Jan, 2015 1 commit
  3. 08 Jan, 2015 1 commit
    • Simon Peyton Jones's avatar
      Improve HsBang · 9564bb8c
      Simon Peyton Jones authored
      Provoked by questions from Johan
       - Improve comments, fix misleading stuff
       - Add commented synonyms for HsSrcBang, HsImplBang, and use them throughout
       - Rename HsUserBang to HsSrcBang
       - Rename dataConStrictMarks to dataConSrcBangs
                dataConRepBangs    to dataConImplBangs
      This renaming affects Haddock in a trivial way, hence submodule update
  4. 23 Dec, 2014 1 commit
    • Simon Peyton Jones's avatar
      Eliminate so-called "silent superclass parameters" · a6f0f5ab
      Simon Peyton Jones authored
      The purpose of silent superclass parameters was to solve the
      awkward problem of superclass dictinaries being bound to bottom.
      See THE PROBLEM in Note [Recursive superclasses] in TcInstDcls
      Although the silent-superclass idea worked,
        * It had non-local consequences, and had effects even in Haddock,
          where we had to discard silent parameters before displaying
          instance declarations
        * It had unexpected peformance costs, shown up by Trac #3064 and its
          test case.  In monad-transformer code, when constructing a Monad
          dictionary you had to pass an Applicative dictionary; and to
          construct that you neede a Functor dictionary. Yet these extra
          dictionaries were often never used.  (All this got much worse when
          we added Applicative as a superclass of Monad.) Test T3064
          compiled *far* faster after silent superclasses were eliminated.
        * It introduced new bugs.  For example SilentParametersOverlapping,
          T5051, and T7862, all failed to compile because of instance overlap
          directly because of the silent-superclass trick.
      So this patch takes a new approach, which I worked out with Dimitrios
      in the closing hours before Christmas.  It is described in detail
      in THE PROBLEM in Note [Recursive superclasses] in TcInstDcls.
      Seems to work great!
      Quite a bit of knock-on effect
       * The main implementation work is in tcSuperClasses in TcInstDcls
         Everything else is fall-out
       * IdInfo.DFunId no longer needs its n-silent argument
         * Ditto IDFunId in IfaceSyn
         * Hence interface file format changes
       * Now that DFunIds do not have silent superclass parameters, printing
         out instance declarations is simpler. There is tiny knock-on effect
         in Haddock, so that submodule is updated
       * I realised that when computing the "size of a dictionary type"
         in TcValidity.sizePred, we should be rather conservative about
         type functions, which can arbitrarily increase the size of a type.
         Hence the new datatype TypeSize, which has a TSBig constructor for
         "arbitrarily big".
       * instDFunType moves from TcSMonad to Inst
       * Interestingly, CmmNode and CmmExpr both now need a non-silent
         (Ord r) in a couple of instance declarations. These were previously
         silent but must now be explicit.
       * Quite a bit of wibbling in error messages
  5. 03 Dec, 2014 1 commit
  6. 28 Nov, 2014 1 commit
    • Simon Peyton Jones's avatar
      Rename some of the functions in NameSet, to make the uniform with VarSet etc · 7460dafa
      Simon Peyton Jones authored
      For ages NameSet has used different names,
        eg.   addOneToNameSet   rather than    extendNameSet
              nameSetToList     rather than    nameSetElems
      etc.  Other set-like modules use uniform naming conventions.
      This patch makes NameSet follow suit.
      No change in behaviour; this is just renaming.
      I'm doing this just before the fork so that merging is easier.
  7. 21 Nov, 2014 1 commit
  8. 12 Nov, 2014 1 commit
  9. 02 Nov, 2014 1 commit
  10. 27 Sep, 2014 1 commit
    • thomie's avatar
      Stop exporting, and stop using, functions marked as deprecated · 51aa2fa3
      thomie authored
      Don't export `getUs` and `getUniqueUs`. `UniqSM` has a `MonadUnique` instance:
          instance MonadUnique UniqSM where
              getUniqueSupplyM = getUs
              getUniqueM  = getUniqueUs
              getUniquesM = getUniquesUs
      Commandline-fu used:
          git grep -l 'getUs\>' |
              grep -v compiler/basicTypes/UniqSupply.lhs |
              xargs sed -i 's/getUs/getUniqueSupplyM/g
          git grep -l 'getUniqueUs\>' |
              grep -v combiler/basicTypes/UniqSupply.lhs |
              xargs sed -i 's/getUniqueUs/getUniqueM/g'
      Follow up on b522d3a3
      Reviewed By: austin, hvr
      Differential Revision: https://phabricator.haskell.org/D220
  11. 26 Sep, 2014 1 commit
  12. 06 Jun, 2014 1 commit
    • Simon Peyton Jones's avatar
      Make the matcher and wrapper Ids in PatSyn into LocalIds, not GlobalIds · 7ac600d5
      Simon Peyton Jones authored
      This was a serious bug, exposed by Trac #9175.  The matcher and wrapper
      must be LocalIds, like record selectors and dictionary functions, for
      the reasons now documented in Note [Exported LocalIds] in Id.lhs
      In fixing this I found
       - PatSyn should have an Id inside it (apart from the wrapper and matcher)
         It should be a Name.  Hence psId --> psName, with knock-on consequences
       - Tidying of PatSyns in TidyPgm was wrong
       - The keep-alive set in Desugar.deSugar (now) doesn't need pattern synonyms
         in it
      I also cleaned up the interface to PatSyn a little, so there's a tiny knock-on
      effect in Haddock; hence the haddock submodule update.
      It's very hard to make a test for this bug, so I haven't.
  13. 15 May, 2014 1 commit
    • Herbert Valerio Riedel's avatar
      Add LANGUAGE pragmas to compiler/ source files · 23892440
      Herbert Valerio Riedel authored
      In some cases, the layout of the LANGUAGE/OPTIONS_GHC lines has been
      reorganized, while following the convention, to
      - place `{-# LANGUAGE #-}` pragmas at the top of the source file, before
        any `{-# OPTIONS_GHC #-}`-lines.
      - Moreover, if the list of language extensions fit into a single
        `{-# LANGUAGE ... -#}`-line (shorter than 80 characters), keep it on one
        line. Otherwise split into `{-# LANGUAGE ... -#}`-lines for each
        individual language extension. In both cases, try to keep the
        enumeration alphabetically ordered.
        (The latter layout is preferable as it's more diff-friendly)
      While at it, this also replaces obsolete `{-# OPTIONS ... #-}` pragma
      occurences by `{-# OPTIONS_GHC ... #-}` pragmas.
  14. 08 May, 2014 1 commit
  15. 18 Feb, 2014 1 commit
    • Simon Peyton Jones's avatar
      Allow ($) to return an unlifted type (Trac #8739) · 5dd1cbbf
      Simon Peyton Jones authored
      Since ($) simply returns its result, via a tail call, it can
      perfectly well have an unlifted result type; e.g.
          foo $ True    where  foo :: Bool -> Int#
      should be perfectly fine.
      This used to work in GHC 7.2, but caused a Lint failure.  This patch
      makes it work again (which involved removing code in TcExpr), but fixing
      the Lint failure meant I had to make ($) into a wired-in Id.  Which
      is not hard to do (in MkId).
  16. 16 Dec, 2013 2 commits
  17. 12 Dec, 2013 1 commit
    • Simon Peyton Jones's avatar
      Improve the handling of used-once stuff · 80989de9
      Simon Peyton Jones authored
      Joachim and I are committing this onto a branch so that we can share it,
      but we expect to do a bit more work before merging it onto head.
      Nofib staus:
        - Most programs, no change
        - A few improve
        - A couple get worse (cacheprof, tak, rfib)
      Investigating the "get worse" set is what's holding up putting this
      on head.
      The major issue is this.  Consider
          map (f g) ys
      where f's demand signature looks like
         f :: <L,C1(C1(U))> -> <L,U> -> .
      So 'f' is not saturated.  What demand do we place on g?
      That is, the inner C1 should stay, even though f is not saturated.
      I found that this made a significant difference in the demand signatures
      inferred in GHC.IO, which uses lots of higher-order exception handlers.
      I also had to add used-once demand signatures for some of the
      'catch' primops, so that we know their handlers are only called once.
  18. 09 Dec, 2013 1 commit
  19. 22 Nov, 2013 2 commits
    • Simon Peyton Jones's avatar
      Replace (State# RealWorld) with Void# where we just want a 0-bit value · f4384647
      Simon Peyton Jones authored
      We were re-using the super-magical "state token" type (which has
      VoidRep and is zero bits wide) for situations in which we simply want
      to lambda-abstract over a zero-bit argument. For example, join points:
         case (case x of { True -> e1; False -> e2 }) of
            Red  -> f1
            Blue -> True
        let $j1 = \voidArg::Void# -> f1
        case x of
          True -> case e1 of
                    Red -> $j1 void
                    Blue -> True
          False -> case e2 of
                    Red -> $j1 void
                    Blue -> True
      This patch introduces
         * The new primitive type GHC.Prim.Void#, with PrimRep = VoidRep
         * A new global Id GHC.Prim.voidPrimId :: Void#.
           This has no binding because the code generator drops it,
           but is used as an argument (eg in the call of $j1)
         * A new local Id, MkId.voidArgId, which can be lambda-bound
           when you need to lambda-abstract over it.
      and uses them throughout.
      Now the State# thing is used only when we need state!
    • eir@cis.upenn.edu's avatar
  20. 20 Nov, 2013 1 commit
    • Joachim Breitner's avatar
      Make Coercible higher-kinded · 976a1087
      Joachim Breitner authored
      This implements #8541. The changes are fully straight forward and work
      nicely for the examples from the ticket; this is mostly due to the
      existing code not checking for saturation and kindness.
  21. 23 Oct, 2013 1 commit
  22. 10 Oct, 2013 1 commit
    • Iavor S. Diatchki's avatar
      Update and clean-up the implmenation of GHC.TypeLits · c3762fa4
      Iavor S. Diatchki authored
      * Replace class `SingI` with two separate classes: `KnownNat` and `KnownSymbol`
      * Rename `magicSingId` to `magicDictId`.
      * Simplify and clean-up the "magic" implementation.  This version makes
        a lot more sense, at least to me :-)
      * Update notes about how it all works:
        Note [KnownNat & KnownSymbol and EvLit] explains the evidence for the
        built-in classes
        Note [magicDictId magic] explains how we coerce singleton values into
        dictionaries.  This is used to turn run-time integers and strings into
        Proxy singletons of unknwon type (using an existential).
  23. 09 Oct, 2013 1 commit
    • Austin Seipp's avatar
      Use evaldUnfolding for proxyHashId · 99cf4594
      Austin Seipp authored
      Edward and I noticed this - like realWorld#, we want things applied to
      proxy# which are INLINE more likely to be inlined - we do this by
      marking proxy# as having an evaldUnfolding, which in turn makes it look
      like the primitive is evaluated and makes the simplifier more willing to
      do so.
      See Note [evaldUnfoldings] in MkId.
      Signed-off-by: default avatarAustin Seipp <austin@well-typed.com>
  24. 01 Oct, 2013 1 commit
  25. 27 Sep, 2013 1 commit
  26. 13 Sep, 2013 1 commit
  27. 04 Sep, 2013 1 commit
  28. 02 Aug, 2013 1 commit
  29. 06 Jun, 2013 1 commit
    • Simon Peyton Jones's avatar
      Implement cardinality analysis · 99d4e5b4
      Simon Peyton Jones authored
      This major patch implements the cardinality analysis described
      in our paper "Higher order cardinality analysis". It is joint
      work with Ilya Sergey and Dimitrios Vytiniotis.
      The basic is augment the absence-analysis part of the demand
      analyser so that it can tell when something is used
      	 at most once
       	 some other way
      The "at most once" information is used
          a) to enable transformations, and
             in particular to identify one-shot lambdas
          b) to allow updates on thunks to be omitted.
      There are two new flags, mainly there so you can do performance
          -fkill-absence   stops GHC doing absence analysis at all
          -fkill-one-shot  stops GHC spotting one-shot lambdas
                           and single-entry thunks
      The big changes are:
      * The Demand type is substantially refactored.  In particular
        the UseDmd is factored as follows
            data UseDmd
              = UCall Count UseDmd
              | UProd [MaybeUsed]
              | UHead
              | Used
            data MaybeUsed = Abs | Use Count UseDmd
            data Count = One | Many
        Notice that UCall recurses straight to UseDmd, whereas
        UProd goes via MaybeUsed.
        The "Count" embodies the "at most once" or "many" idea.
      * The demand analyser itself was refactored a lot
      * The previously ad-hoc stuff in the occurrence analyser for foldr and
        build goes away entirely.  Before if we had build (\cn -> ...x... )
        then the "\cn" was hackily made one-shot (by spotting 'build' as
        special.  That's essential to allow x to be inlined.  Now the
        occurrence analyser propagates info gotten from 'build's stricness
        signature (so build isn't special); and that strictness sig is
        in turn derived entirely automatically.  Much nicer!
      * The ticky stuff is improved to count single-entry thunks separately.
      One shortcoming is that there is no DEBUG way to spot if an
      allegedly-single-entry thunk is acually entered more than once.  It
      would not be hard to generate a bit of code to check for this, and it
      would be reassuring.  But it's fiddly and I have not done it.
      Despite all this fuss, the performance numbers are rather under-whelming.
      See the paper for more discussion.
             nucleic2          -0.8%    -10.9%      0.10      0.10     +0.0%
               sphere          -0.7%     -1.5%      0.08      0.08     +0.0%
                  Min          -4.7%    -10.9%     -9.3%     -9.3%    -50.0%
                  Max          -0.4%     +0.5%     +2.2%     +2.3%     +7.4%
       Geometric Mean          -0.8%     -0.2%     -1.3%     -1.3%     -1.8%
      I don't quite know how much credence to place in the runtime changes,
      but movement seems generally in the right direction.
  30. 30 May, 2013 2 commits
    • Iavor S. Diatchki's avatar
      Add a primitive for coercing values into dictionaries in a special case. · ac330cb6
      Iavor S. Diatchki authored
      The details of this are described in Note [magicSingIId magic] in basicTypes/MkId.lhs
    • Simon Peyton Jones's avatar
      Make 'SPECIALISE instance' work again · 1ed04090
      Simon Peyton Jones authored
      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
      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!
  31. 30 Jan, 2013 1 commit
  32. 24 Jan, 2013 1 commit
    • Simon Peyton Jones's avatar
      Introduce CPR for sum types (Trac #5075) · d3b8991b
      Simon Peyton Jones authored
      The main payload of this patch is to extend CPR so that it
      detects when a function always returns a result constructed
      with the *same* constructor, even if the constructor comes from
      a sum type.  This doesn't matter very often, but it does improve
      some things (results below).
      Binary sizes increase a little bit, I think because there are more
      wrappers.  This with -split-objs.  Without split-ojbs binary sizes
      increased by 6% even for HelloWorld.hs.  It's hard to see exactly why,
      but I think it was because System.Posix.Types.o got included in the
      linked binary, whereas it didn't before.
              Program           Size    Allocs   Runtime   Elapsed  TotalMem
                fluid          +1.8%     -0.3%      0.01      0.01     +0.0%
                  tak          +2.2%     -0.2%      0.02      0.02     +0.0%
                 ansi          +1.7%     -0.3%      0.00      0.00     +0.0%
            cacheprof          +1.6%     -0.3%     +0.6%     +0.5%     +1.4%
              parstof          +1.4%     -4.4%      0.00      0.00     +0.0%
              reptile          +2.0%     +0.3%      0.02      0.02     +0.0%
                  Min          +1.1%     -4.4%     -4.7%     -4.7%    -15.0%
                  Max          +2.3%     +0.3%     +8.3%     +9.4%    +50.0%
       Geometric Mean          +1.9%     -0.1%     +0.6%     +0.7%     +0.3%
      Other things in this commit
      * Got rid of the Lattice class in Demand
      * Refactored the way that products and newtypes are
        decomposed (no change in functionality)
  33. 17 Jan, 2013 1 commit
    • Simon Peyton Jones's avatar
      Major patch to implement the new Demand Analyser · 0831a12e
      Simon Peyton Jones authored
      This patch is the result of Ilya Sergey's internship at MSR.  It
      constitutes a thorough overhaul and simplification of the demand
      analyser.  It makes a solid foundation on which we can now build.
      Main changes are
      * Instead of having one combined type for Demand, a Demand is
         now a pair (JointDmd) of
            - a StrDmd and
            - an AbsDmd.
         This allows strictness and absence to be though about quite
         orthogonally, and greatly reduces brain melt-down.
      * Similarly in the DmdResult type, it's a pair of
           - a PureResult (indicating only divergence/non-divergence)
           - a CPRResult (which deals only with the CPR property
      * In IdInfo, the
          strictnessInfo field contains a StrictSig, not a Maybe StrictSig
          demandInfo     field contains a Demand, not a Maybe Demand
        We don't need Nothing (to indicate no strictness/demand info)
        any more; topSig/topDmd will do.
      * Remove "boxity" analysis entirely.  This was an attempt to
        avoid "reboxing", but it added complexity, is extremely
        ad-hoc, and makes very little difference in practice.
      * Remove the "unboxing strategy" computation. This was an an
        attempt to ensure that a worker didn't get zillions of
        arguments by unboxing big tuples.  But in fact removing it
        DRAMATICALLY reduces allocation in an inner loop of the
        I/O library (where the threshold argument-count had been
        set just too low).  It's exceptional to have a zillion arguments
        and I don't think it's worth the complexity, especially since
        it turned out to have a serious performance hit.
      * Remove quite a bit of ad-hoc cruft
      * Move worthSplittingFun, worthSplittingThunk from WorkWrap to
        Demand. This allows JointDmd to be fully abstract, examined
        only inside Demand.
      Everything else really follows from these changes.
      All of this is really just refactoring, so we don't expect
      big performance changes, but acutally the numbers look quite
      good.  Here is a full nofib run with some highlights identified:
              Program           Size    Allocs   Runtime   Elapsed  TotalMem
               expert          -2.6%    -15.5%      0.00      0.00     +0.0%
                fluid          -2.4%     -7.1%      0.01      0.01     +0.0%
                   gg          -2.5%    -28.9%      0.02      0.02    -33.3%
            integrate          -2.6%     +3.2%     +2.6%     +2.6%     +0.0%
              mandel2          -2.6%     +4.2%      0.01      0.01     +0.0%
             nucleic2          -2.0%    -16.3%      0.11      0.11     +0.0%
                 para          -2.6%    -20.0%    -11.8%    -11.7%     +0.0%
               parser          -2.5%    -17.9%      0.05      0.05     +0.0%
               prolog          -2.6%    -13.0%      0.00      0.00     +0.0%
               puzzle          -2.6%     +2.2%     +0.8%     +0.8%     +0.0%
              sorting          -2.6%    -35.9%      0.00      0.00     +0.0%
             treejoin          -2.6%    -52.2%     -9.8%     -9.9%     +0.0%
                  Min          -2.7%    -52.2%    -11.8%    -11.7%    -33.3%
                  Max          -1.8%     +4.2%    +10.5%    +10.5%     +7.7%
       Geometric Mean          -2.5%     -2.8%     -0.4%     -0.5%     -0.4%
      Things to note
      * Binary sizes are smaller. I don't know why, but it's good.
      * Allocation is sometiemes a *lot* smaller. I believe that all the big numbers
        (I checked treejoin, gg, sorting) arise from one place, namely a function
        GHC.IO.Encoding.UTF8.utf8_decode, which is strict in two Buffers both of
        which have several arugments.  Not w/w'ing both arguments (which is what
        we did before) has a big effect.  So the big win in actually somewhat
        accidental, gained by removing the "unboxing strategy" code.
      * A couple of benchmarks allocate slightly more.  This turns out
        to be due to reboxing (integrate).  But the biggest increase is
        mandel2, and *that* turned out also to be a somewhat accidental
        loss of CSE, and pointed the way to doing better CSE: see Trac
      * Runtimes are never very reliable, but seem to improve very slightly.
      All in all, a good piece of work.  Thank you Ilya!
  34. 15 Jan, 2013 1 commit
  35. 14 Jan, 2013 1 commit
    • Simon Peyton Jones's avatar
      Be willing to parse {-# UNPACK #-} without '!' · deec5b74
      Simon Peyton Jones authored
      This change gives a more helpful error message when the
      user says    data T = MkT {-# UNPACK #-} Int
      which should have a strictness '!' as well. Rather than
      just a parse error, we get
        T7562.hs:3:14: Warning:
          UNPACK pragma lacks '!' on the first argument of `MkT'
      Fixes Trac #7562
  36. 02 Jan, 2013 1 commit
    • Simon Peyton Jones's avatar
      Define ListSetOps.getNth, and use it · b0c0cae7
      Simon Peyton Jones authored
      I was tracking down an error looking like
        Prelude.(!!): index too large
      which is very unhelpful.  This patch replaces at least some uses
      of (!!) in GHC with getNth, which has a more helpful error
      message (with DEBUG anyway)
  37. 23 Dec, 2012 1 commit
    • Simon Peyton Jones's avatar
      Make {-# UNPACK #-} work for type/data family invocations · 1ee1cd41
      Simon Peyton Jones authored
      This fixes most of Trac #3990.  Consider
        data family D a
        data instance D Double = CD Int Int
        data T = T {-# UNPACK #-} !(D Double)
      Then we want the (D Double unpacked).
      To do this we need to construct a suitable coercion, and it's much
      safer to record that coercion in the interface file, lest the in-scope
      instances differ somehow.  That in turn means elaborating the HsBang
      type to include a coercion.
      To do that I moved HsBang from BasicTypes to DataCon, which caused
      quite a few minor knock-on changes.
      Interface-file format has changed!
      Still to do: need to do knot-tying to allow instances to take effect
      within the same module.