1. 18 Oct, 2013 1 commit
  2. 11 Sep, 2013 1 commit
  3. 16 Aug, 2013 2 commits
    • Jan Stolarek's avatar
      Comments only · 82d5aa03
      Jan Stolarek authored
      I restored part of documentation that describes what is a let-no-escape
      and which was deleted 10 months ago together with the old codegen. Then
      I removed lots of Literate Haskell clutter (like empty \begin{code} -
      \end{code} blocks) and finally decided to remove all the Literate Haskell
      markup because there wasn't much of it left, but it made comments so
      difficult to read.
      82d5aa03
    • Jan Stolarek's avatar
      Comments only · ec621f3c
      Jan Stolarek authored
      ec621f3c
  4. 19 Jun, 2013 1 commit
  5. 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
      	 never
      	 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
      comparisons:
          -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.
      99d4e5b4
  6. 14 May, 2013 1 commit
    • ian@well-typed.com's avatar
      Fix the GHC package DLL-splitting · 60b86b04
      ian@well-typed.com authored
      There's now an internal -dll-split flag, which we use to tell GHC how
      the GHC package is split into 2 separate DLLs. This is used by
      Packages.isDllName to determine whether a call is within the same
      DLL, or whether it is a call to another DLL.
      60b86b04
  7. 06 Apr, 2013 1 commit
  8. 18 Sep, 2012 2 commits
    • Simon Peyton Jones's avatar
      Undo making Any into a type family, for now · 1b5c8337
      Simon Peyton Jones authored
      Making Any a type family is the right thing to do, but it messes up
      the proxy kind arguments in TypeLits and Singletons, so I'm backing it
      out for now.
      
      More thought required!
      1b5c8337
    • Simon Peyton Jones's avatar
      Make a start towards eta-rules and injective families · 58470fb7
      Simon Peyton Jones authored
      * Make Any into a type family (which it should always have been)
        This is to support the future introduction of eta rules for
        product types (see email on ghc-users title "PolyKind issue"
        early Sept 2012)
      
      * Add the *internal* data type support for
          (a) closed type families [so that you can't give
              type instance for 'Any']
          (b) injective type families [because Any is really
              injective]
        This amounts to two boolean flags on the SynFamilyTyCon
        constructor of TyCon.SynTyConRhs.
      
      There is some knock-on effect, but all of a routine nature.
      
      It remains to offer source syntax for either closed or
      injective families.
      58470fb7
  9. 15 Sep, 2012 1 commit
    • Simon Peyton Jones's avatar
      Fix Trac #7237; mixup with empty tuples · 84bb8541
      Simon Peyton Jones authored
      When converting from Core to STG, we swith pattern matching on
      on a *nullary* unboxed tuple into matching using a PrimAlt on RealWorld#
         case e (RealWorld#) of { DEFAULT -> ... }
      This semms messy to me, but it works.  There was a bug in that we were
      changing to PrimAlt, but not using a DEFAULT AltCon.
      84bb8541
  10. 15 May, 2012 2 commits
  11. 02 May, 2012 1 commit
    • Simon Peyton Jones's avatar
      Allow cases with empty alterantives · ac230c5e
      Simon Peyton Jones authored
      This patch allows, for the first time, case expressions with an empty
      list of alternatives. Max suggested the idea, and Trac #6067 showed
      that it is really quite important.
      
      So I've implemented the idea, fixing #6067. Main changes
      
       * See Note [Empty case alternatives] in CoreSyn
      
       * Various foldr1's become foldrs
      
       * IfaceCase does not record the type of the alternatives.
         I added IfaceECase for empty-alternative cases.
      
       * Core Lint does not complain about empty cases
      
       * MkCore.castBottomExpr constructs an empty-alternative case
         expression   (case e of ty {})
      
       * CoreToStg converts '(case e of {})' to just 'e'
      ac230c5e
  12. 26 Feb, 2012 1 commit
    • Ian Lynagh's avatar
      Implement "value" imports with the CAPI · ae04bd43
      Ian Lynagh authored
      This allows us to import values (i.e. non-functions) with the CAPI.
      This means we can access values even if (on some or all platforms)
      they are simple #defines.
      ae04bd43
  13. 04 Nov, 2011 1 commit
  14. 02 Nov, 2011 1 commit
    • Simon Marlow's avatar
      Overhaul of infrastructure for profiling, coverage (HPC) and breakpoints · 7bb0447d
      Simon Marlow authored
      User visible changes
      ====================
      
      Profilng
      --------
      
      Flags renamed (the old ones are still accepted for now):
      
        OLD            NEW
        ---------      ------------
        -auto-all      -fprof-auto
        -auto          -fprof-exported
        -caf-all       -fprof-cafs
      
      New flags:
      
        -fprof-auto              Annotates all bindings (not just top-level
                                 ones) with SCCs
      
        -fprof-top               Annotates just top-level bindings with SCCs
      
        -fprof-exported          Annotates just exported bindings with SCCs
      
        -fprof-no-count-entries  Do not maintain entry counts when profiling
                                 (can make profiled code go faster; useful with
                                 heap profiling where entry counts are not used)
      
      Cost-centre stacks have a new semantics, which should in most cases
      result in more useful and intuitive profiles.  If you find this not to
      be the case, please let me know.  This is the area where I have been
      experimenting most, and the current solution is probably not the
      final version, however it does address all the outstanding bugs and
      seems to be better than GHC 7.2.
      
      Stack traces
      ------------
      
      +RTS -xc now gives more information.  If the exception originates from
      a CAF (as is common, because GHC tends to lift exceptions out to the
      top-level), then the RTS walks up the stack and reports the stack in
      the enclosing update frame(s).
      
      Result: +RTS -xc is much more useful now - but you still have to
      compile for profiling to get it.  I've played around a little with
      adding 'head []' to GHC itself, and +RTS -xc does pinpoint the problem
      quite accurately.
      
      I plan to add more facilities for stack tracing (e.g. in GHCi) in the
      future.
      
      Coverage (HPC)
      --------------
      
       * derived instances are now coloured yellow if they weren't used
       * likewise record field names
       * entry counts are more accurate (hpc --fun-entry-count)
       * tab width is now correct (markup was previously off in source with
         tabs)
      
      Internal changes
      ================
      
      In Core, the Note constructor has been replaced by
      
              Tick (Tickish b) (Expr b)
      
      which is used to represent all the kinds of source annotation we
      support: profiling SCCs, HPC ticks, and GHCi breakpoints.
      
      Depending on the properties of the Tickish, different transformations
      apply to Tick.  See CoreUtils.mkTick for details.
      
      Tickets
      =======
      
      This commit closes the following tickets, test cases to follow:
      
        - Close #2552: not a bug, but the behaviour is now more intuitive
          (test is T2552)
      
        - Close #680 (test is T680)
      
        - Close #1531 (test is result001)
      
        - Close #949 (test is T949)
      
        - Close #2466: test case has bitrotted (doesn't compile against current
          version of vector-space package)
      7bb0447d
  15. 23 Oct, 2011 1 commit
  16. 14 Oct, 2011 1 commit
  17. 23 Sep, 2011 1 commit
    • Simon Peyton Jones's avatar
      Make a new type synonym CoreProgram = [CoreBind] · 488e21c8
      Simon Peyton Jones authored
      and comment its invariants in Note [CoreProgram] in CoreSyn
      
      I'm not totally convinced that CoreProgram is the right name
      (perhaps CoreTopBinds might better), but it is useful to have
      a clue that you are looking at the top-level bindings.
      
      This is only a matter of a type synonym change; no deep
      refactoring here.
      488e21c8
  18. 17 Sep, 2011 1 commit
    • Ian Lynagh's avatar
      Improve the handling of Integer literals · 1e87c0a6
      Ian Lynagh authored
      LitInteger now carries around the id of mkInteger, which it uses
      to construct the core to build Integer literals. This way we don't
      have to build in info about lots of Ids.
      
      We also no longer have any special-casing for integer-simple, so
      there is less code involved.
      1e87c0a6
  19. 13 Sep, 2011 1 commit
    • Ian Lynagh's avatar
      change how Integer's are handled in Core · fdac48f3
      Ian Lynagh authored
      We now treat them as literals until CorePrep, when we finally
      convert them into the real Core representation. This makes it a lot
      simpler to implement built-in rules on them.
      fdac48f3
  20. 05 Sep, 2011 1 commit
  21. 03 Aug, 2011 1 commit
  22. 12 May, 2011 1 commit
    • Simon Peyton Jones's avatar
      The final batch of changes for the new coercion representation · c8c2f6bb
      Simon Peyton Jones authored
      * Fix bugs in the packing and unpacking of data
        constructors with equality predicates in their types
      
      * Remove PredCo altogether; instead, coercions between predicated
        types (like  (Eq a, [a]~b) => blah) are treated as if they
        were precisely their underlying representation type
             Eq a -> ((~) [a] b) -> blah
        in this case
      
      * Similarly, Type.coreView no longer treats equality
        predciates specially.
      
      * Implement the cast-of-coercion optimisation in
        Simplify.simplCoercionF
      
      Numerous other small bug-fixes and refactorings.
      
      Annoyingly, OptCoercion had Windows line endings, and this
      patch switches to Unix, so it looks as if every line has changed.
      c8c2f6bb
  23. 19 Apr, 2011 1 commit
    • Simon Peyton Jones's avatar
      This BIG PATCH contains most of the work for the New Coercion Representation · fdf86568
      Simon Peyton Jones authored
      See the paper "Practical aspects of evidence based compilation in System FC"
      
      * Coercion becomes a data type, distinct from Type
      
      * Coercions become value-level things, rather than type-level things,
        (although the value is zero bits wide, like the State token)
        A consequence is that a coerion abstraction increases the arity by 1
        (just like a dictionary abstraction)
      
      * There is a new constructor in CoreExpr, namely Coercion, to inject
        coercions into terms
      fdf86568
  24. 21 Oct, 2010 1 commit
  25. 19 Oct, 2010 3 commits
  26. 23 Sep, 2010 1 commit
    • simonpj@microsoft.com's avatar
      Avoid ASSERT black hole · 528db2ad
      simonpj@microsoft.com authored
      When this ASSERT tripped in CoreToStg it tried to print out
      too much, which tripped the asssertion again.  Result: an
      infinite loop with no output at all.  Hard to debug!
      528db2ad
  27. 22 Sep, 2010 1 commit
    • simonpj@microsoft.com's avatar
      Fix an ASSERT failure with profiling · 9e6ca39b
      simonpj@microsoft.com authored
      The problem arose with this kind of thing
      
         x = (,) (scc "blah" Nothing)
      
      Then 'x' is marked NoCafRefs by CoreTidy, becuase it has 
      arity 1, and doesn't mention any caffy things.
      
      That in turns means that CorePrep must not float out the
      sat binding to give
      
        sat = scc "blah" Nothing
        x = (,) sat
      
      Rather we must generate
      
        x = \eta. let sat = scc "blah" Nothing 
                  in (,) sat eta
      
      URGH! This Caf stuff is such a mess.
      9e6ca39b
  28. 13 Sep, 2010 1 commit
  29. 04 Jan, 2010 1 commit
  30. 02 Jan, 2010 1 commit
  31. 15 Oct, 2009 1 commit
    • simonpj@microsoft.com's avatar
      Fix Trac #959: a long-standing bug in instantiating otherwise-unbound type variables · 388e3356
      simonpj@microsoft.com authored
          
         DO NOT MERGE TO GHC 6.12 branch
         (Reason: interface file format change.)
      
      The typechecker needs to instantiate otherwise-unconstraint type variables to
      an appropriately-kinded constant type, but we didn't have a supply of 
      arbitrarily-kinded tycons for this purpose.  Now we do.
      
      The details are described in Note [Any types] in TysPrim.  The
      fundamental change is that there is a new sort of TyCon, namely
      AnyTyCon, defined in TyCon.
      
      Ter's a small change to interface-file binary format, because the new
      AnyTyCons have to be serialised.
      
      I tided up the handling of uniques a bit too, so that mkUnique is not
      exported, so that we can see all the different name spaces in one module.
      388e3356
  32. 09 Jun, 2009 1 commit
    • Duncan Coutts's avatar
      Add PrimCall to the STG layer and update Core -> STG translation · cbbee4e8
      Duncan Coutts authored
      It adds a third case to StgOp which already hold StgPrimOp and StgFCallOp.
      The code generation for the new StgPrimCallOp case is almost exactly the
      same as for out-of-line primops. They now share the tailCallPrim function.
      In the Core -> STG translation we map foreign calls using the "prim"
      calling convention to the StgPrimCallOp case. This is because in Core we
      represent prim calls using the ForeignCall stuff. At the STG level however
      the prim calls are really much more like primops than foreign calls.
      cbbee4e8
  33. 13 Jan, 2009 1 commit
    • simonpj@microsoft.com's avatar
      Rewrite CorePrep and improve eta expansion · 62eeda5a
      simonpj@microsoft.com authored
      This patch does two main things
      
      a) Rewrite most of CorePrep to be much easier to understand (I hope!).
         The invariants established by CorePrep are now written out, and
         the code is more perspicuous.  It is surpringly hard to get right,
         and the old code had become quite incomprehensible.
      
      b) Rewrite the eta-expander so that it does a bit of simplifying
         on-the-fly, and thereby guarantees to maintain the CorePrep
         invariants.  This make it much easier to use from CorePrep, and
         is a generally good thing anyway.
      
      A couple of pieces of re-structuring:
      
      *  I moved the eta-expander and arity analysis stuff into a new
         module coreSyn/CoreArity.
      
         Max will find that the type CoreArity.EtaInfo looks strangely 
         familiar.
      
      *  I moved a bunch of comments from Simplify to OccurAnal; that's
         why it looks as though there's a lot of lines changed in those
         modules.
      
      On the way I fixed various things
      
        - Function arguments are eta expanded
             f (map g)  ===>  let s = \x. map g x in f s
      
        - Trac #2368
      
      The result is a modest performance gain, I think mainly due
      to the first of these changes:
      
      --------------------------------------------------------------------------------
              Program           Size    Allocs   Runtime   Elapsed
      --------------------------------------------------------------------------------
                  Min          -1.0%    -17.4%    -19.1%    -46.4%
                  Max          +0.3%     +0.5%     +5.4%    +53.8%
       Geometric Mean          -0.1%     -0.3%     -7.0%    -10.2%
      
      
      62eeda5a
  34. 02 Jan, 2009 1 commit
    • simonpj@microsoft.com's avatar
      Make record selectors into ordinary functions · 9ffadf21
      simonpj@microsoft.com authored
      This biggish patch addresses Trac #2670.  The main effect is to make
      record selectors into ordinary functions, whose unfoldings appear in
      interface files, in contrast to their previous existence as magic
      "implicit Ids".  This means that the usual machinery of optimisation,
      analysis, and inlining applies to them, which was failing before when
      the selector was somewhat complicated.  (Which it can be when
      strictness annotations, unboxing annotations, and GADTs are involved.)
      
      The change involves the following points
      
      * Changes in Var.lhs to the representation of Var.  Now a LocalId can
        have an IdDetails as well as a GlobalId.  In particular, the
        information that an Id is a record selector is kept in the
        IdDetails.  While compiling the current module, the record selector
        *must* be a LocalId, so that it participates properly in compilation
        (free variables etc).
      
        This led me to change the (hidden) representation of Var, so that there
        is now only one constructor for Id, not two.
      
      * The IdDetails is persisted into interface files, so that an
        importing module can see which Ids are records selectors.
      
      * In TcTyClDecls, we generate the record-selector bindings in renamed,
        but not typechecked form.  In this way, we can get the typechecker
        to add all the types and so on, which is jolly helpful especially
        when GADTs or type families are involved.  Just like derived
        instance declarations.
      
        This is the big new chunk of 180 lines of code (much of which is
        commentary).  A call to the same function, mkAuxBinds, is needed in
        TcInstDcls for associated types.
      
      * The typechecker therefore has to pin the correct IdDetails on to 
        the record selector, when it typechecks it.  There was a neat way
        to do this, by adding a new sort of signature to HsBinds.Sig, namely
        IdSig.  This contains an Id (with the correct Name, Type, and IdDetails);
        the type checker uses it as the binder for the final binding.  This
        worked out rather easily.
      
      * Record selectors are no longer "implicit ids", which entails changes to
           IfaceSyn.ifaceDeclSubBndrs
           HscTypes.implicitTyThings
           TidyPgm.getImplicitBinds
        (These three functions must agree.)
      
      * MkId.mkRecordSelectorId is deleted entirely, some 300+ lines (incl
        comments) of very error prone code.  Happy days.
      
      * A TyCon no longer contains the list of record selectors: 
        algTcSelIds is gone
      
      The renamer is unaffected, including the way that import and export of
      record selectors is handled.
      
      Other small things
      
      * IfaceSyn.ifaceDeclSubBndrs had a fragile test for whether a data
        constructor had a wrapper.  I've replaced that with an explicit flag
        in the interface file. More robust I hope.
      
      * I renamed isIdVar to isId, which touched a few otherwise-unrelated files.
      
      9ffadf21
  35. 08 Dec, 2008 1 commit
    • simonpj@microsoft.com's avatar
      Add assertion for arity match (checks Trac #2844) · 60881299
      simonpj@microsoft.com authored
      The exported arity of a function must match the arity for the
      STG function.  Trac #2844 was a pretty obscure manifestation of
      the failure of this invariant. This patch doesn't cure the bug;
      rather it adds an assertion to CoreToStg to check the invariant
      so we should get an earlier and less obscure warning if this
      fails in future.
      60881299