1. 15 Apr, 2016 1 commit
    • niteria's avatar
      Kill some unnecessary varSetElems · 928d7473
      niteria authored
      When you do `varSetElems (tyCoVarsOfType x)` it's equivalent to
      `tyCoVarsOfTypeList x`.
      
      Why? If you look at the implementation:
      ```
      tyCoVarsOfTypeList ty = runFVList $ tyCoVarsOfTypeAcc ty
      tyCoVarsOfType ty = runFVSet $ tyCoVarsOfTypeAcc ty
      ```
      they use the same helper function. The helper function returns a
      deterministically ordered list and a set. The only difference
      between the two is which part of the result they take. It is redundant
      to take the set and then immediately convert it to a list.
      
      This helps with determinism and we eventually want to replace the uses
      of `varSetElems` with functions that don't leak the values of uniques.
      This change gets rid of some instances that are easy to kill.
      
      I chose not to annotate every place where I got rid of `varSetElems`
      with a comment about non-determinism, because once we get rid of
      `varSetElems` it will not be possible to do the wrong thing.
      
      Test Plan: ./validate
      
      Reviewers: goldfire, austin, simonmar, bgamari, simonpj
      
      Reviewed By: simonpj
      
      Subscribers: thomie
      
      Differential Revision: https://phabricator.haskell.org/D2115
      
      GHC Trac Issues: #4012
      928d7473
  2. 14 Apr, 2016 5 commits
    • Joachim Breitner's avatar
      Add a final demand analyzer run right before TidyCore · f4fd98c7
      Joachim Breitner authored
      in order to have precise used-once information in the exported
      strictness signatures, as well as precise used-once information on
      thunks. This avoids the bad effects of #11731.
      
      The subsequent worker-wrapper pass is responsible for removing the
      demand environment part of the strictness signature. It does not run
      after the final demand analyzer pass, so remove this also in CoreTidy.
      
      The subsequent worker-wrapper pass is also responsible for removing
      used-once-information from the demands and strictness signatures, as
      these might not be preserved by the simplifier. This is _not_ done by
      CoreTidy, because we _do_ want this information, as produced by the last
      round of the demand analyzer, to be available to the code generator.
      
      Differential Revision: https://phabricator.haskell.org/D2073
      f4fd98c7
    • Joachim Breitner's avatar
      Add a test case for #11731. · 3a34b5c3
      Joachim Breitner authored
      3a34b5c3
    • niteria's avatar
      Remove some old commented out code in StgLint · 20f90560
      niteria authored
      This looks like some traces of an experiment to check if shadowing is good for
      STG. The code refers to things that don't exist anymore and this part of
      code hasn't been touched for ages, so I think this should be safe to
      remove.
      
      Test Plan: just comments
      
      Reviewers: austin, bgamari, simonpj
      
      Reviewed By: simonpj
      
      Subscribers: thomie, simonmar
      
      Differential Revision: https://phabricator.haskell.org/D2114
      20f90560
    • niteria's avatar
      Fix typos: tyars -> tyvars · 227a29d1
      niteria authored
      227a29d1
    • niteria's avatar
      Fix commented out debugging code in ByteCodeGen · 49560ba7
      niteria authored
      It changed from VarSet to DVarSet some time ago.
      49560ba7
  3. 12 Apr, 2016 7 commits
    • eir@cis.upenn.edu's avatar
      d81cdc22
    • eir@cis.upenn.edu's avatar
      0b6dcf6d
    • eir@cis.upenn.edu's avatar
      Fix #11797. · dd99f2ec
      eir@cis.upenn.edu authored
      DsMeta curiously omitted quantified tyvars in certain circumstances.
      This patch means it doesn't.
      
      Test case: th/T11797
      dd99f2ec
    • eir@cis.upenn.edu's avatar
      Fix #11811. · b1084fd7
      eir@cis.upenn.edu authored
      Previously, I had forgotten to omit variables already in scope
      from the TypeInType CUSK check. Simple enough to fix.
      
      Test case: typecheck/should_compile/T11811
      b1084fd7
    • Simon Marlow's avatar
      Allocate blocks in the GC in batches · f4446c5b
      Simon Marlow authored
      Avoids contention for the block allocator lock in the GC; this can be
      seen in the gc_alloc_block_sync counter emitted by +RTS -s.
      
      I experimented with this a while ago, and there was already
      commented-out code for it in GCUtils.c, but I've now improved it so that
      it doesn't result in significantly worse memory usage.
      
      * The old method of putting spare blocks on ws->part_list was wasteful,
        the spare blocks are now shared between all generations and retained
        between GCs.
      
      * repeated allocGroup() results in fragmentation, so I switched to using
        allocLargeChunk() instead which is fragmentation-friendly; we already
        use it for the same reason in nursery allocation.
      f4446c5b
    • Simon Marlow's avatar
      Cache the size of part_list/scavd_list (#11783) · 5c4cd0e4
      Simon Marlow authored
      After a parallel GC, it is possible to have a long list of blocks in
      ws->part_list, if we did a lot of work stealing but didn't fill up the
      blocks we stole.  These blocks persist until the next load-balanced GC,
      which might be a long time, and during every GC we were traversing this
      list to find its size.  The fix is to maintain the size all the time, so
      we don't have to compute it.
      5c4cd0e4
    • Simon Marlow's avatar
      Small simplification (#11777) · 83eb4fd9
      Simon Marlow authored
      DEAD_WEAK used to have a different layout, see
      d61c623e
      83eb4fd9
  4. 11 Apr, 2016 6 commits
    • Tamar Christina's avatar
      Add linker notes · c6e579bc
      Tamar Christina authored
      Summary: Add linker notes following #11223 and D1805
      
      Reviewers: austin, bgamari, erikd
      
      Subscribers: thomie
      
      Differential Revision: https://phabricator.haskell.org/D2102
      
      GHC Trac Issues: #11223
      c6e579bc
    • Herbert Valerio Riedel's avatar
      Use `@since` annotation in GHC.ExecutionStack · 2ef35d8f
      Herbert Valerio Riedel authored
      While ad532ded fixed the version
      number, this fixes the markup...
      2ef35d8f
    • Ryan Scott's avatar
      Deriving Functor-like classes should unify kind variables · aadde2b9
      Ryan Scott authored
      While the deriving machinery always unifies the kind of the typeclass
      argument with the kind of the datatype, this proves not to be sufficient
      to produce well kinded instances for some poly-kinded datatypes. For
      example:
      
      ```
      newtype Compose (f :: k2 -> *) (g :: k1 -> k2) (a :: k1)
        = Compose (f (g a)) deriving Functor
      ```
      
      would fail because only `k1` would get unified with `*`, causing the
      following
      ill kinded instance to be generated:
      
      ```
      instance (Functor (f :: k2 -> *), Functor (g :: * -> k2)) =>
        Functor (Compose f g) where ...
      ```
      
      To prevent this, we need to take the subtypes and unify their kinds with
      `* -> *`.
      
      Fixes #10524 for good.
      
      Test Plan: ./validate
      
      Reviewers: simonpj, hvr, austin, bgamari
      
      Subscribers: thomie
      
      Differential Revision: https://phabricator.haskell.org/D2097
      
      GHC Trac Issues: #10524, #10561
      aadde2b9
    • duairc's avatar
      Added (more) missing instances for Identity and Const · 8b57cac5
      duairc authored
        * `Identity` and `Const` now have `Num`, `Real`, `Integral`,
          `Fractional`, `Floating`, `RealFrac` and `RealFloat` instances
      
        * `Identity` and `Const` now have `Bits` and `FiniteBits` instances
      
        * `Identity` and `Const` now have `IsString` instances
      
      Reviewers: RyanGlScott, austin, hvr, bgamari, ekmett
      
      Reviewed By: ekmett
      
      Subscribers: nomeata, ekmett, RyanGlScott, thomie
      
      Differential Revision: https://phabricator.haskell.org/D2079
      
      GHC Trac Issues: #11790
      8b57cac5
    • Ryan Scott's avatar
      Filter out invisible kind arguments during TH reification · 02a5c580
      Ryan Scott authored
      Previously, all kind arguments were being reified, which would cause
      something like this:
      
      ```
      type Id a = a
      data Proxy (a :: Id k) = Proxy
      ```
      
      to output
      
      ```
      data Proxy (a :: Id * k) = Proxy
      ```
      
      when `Proxy`'s `Info` is reified. The fix is simple: simply call
      `filterOutInvisibleTypes` on the kind arguments of a kind synonym
      application.
      
      Fixes #11463.
      
      Test Plan: ./validate
      
      Reviewers: austin, bgamari, goldfire
      
      Reviewed By: goldfire
      
      Subscribers: thomie
      
      Differential Revision: https://phabricator.haskell.org/D2081
      
      GHC Trac Issues: #11463
      02a5c580
    • Rik Steenkamp's avatar
      Fix a closed type family error message · 46e8f199
      Rik Steenkamp authored
      Now we check whether a closed type family's equation is headed with
      the correct type before we kind-check the equation.
      
      Also, instead of "expected only no parameters" we now generate the
      message "expected no parameters".
      
      Fixes #11623.
      
      Reviewers: simonpj, austin, bgamari
      
      Reviewed By: simonpj, bgamari
      
      Subscribers: simonpj, goldfire, thomie
      
      Differential Revision: https://phabricator.haskell.org/D2089
      
      GHC Trac Issues: #11623
      46e8f199
  5. 10 Apr, 2016 15 commits
    • Tamar Christina's avatar
      Change runtime linker to perform lazy loading of symbols/sections · 90538d86
      Tamar Christina authored
      The Runtime Linker is currently eagerly loading all object files on all
      platforms which do not use the system linker for `GHCi`.
      
      The problem with this approach is that it requires all symbols to be
      found.  Even those of functions never used/called. This makes the number
      of libraries required to link things like `mingwex` quite high.
      
      To work around this the `rts` was relying on a trick. It itself was
      compiled with `MingW64-w`'s `GCC`. So it was already linked against
      `mingwex`.  As such, it re-exported the symbols from itself.
      
      While this worked it made it impossible to link against `mingwex` in
      user libraries. And with this means no `C99` code could ever run in
      `GHCi` on Windows without having the required symbols re-exported from
      the rts.
      
      Consequently this rules out a large number of packages on Windows.
      SDL2, HMatrix etc.
      
      After talking with @rwbarton I have taken the approach of loading entire
      object files when a symbol is needed instead of doing the dependency
      tracking on a per symbol basis. This is a lot less fragile and a lot
      less complicated to implement.
      
      The changes come down to the following steps:
      
      1) modify the linker to and introduce a new state for ObjectCode:
         `Needed`.  A Needed object is one that is required for the linking to
         succeed.  The initial set consists of all Object files passed as
         arguments to the link.
      
      2) Change `ObjectCode`'s to be indexed but not initialized or resolved.
         This means we know where we would load the symbols,
         but haven't actually done so.
      
      3) Mark any `ObjectCode` belonging to `.o` passed as argument
         as required: ObjectState `NEEDED`.
      
      4) During `Resolve` object calls, mark all `ObjectCode`
         containing the required symbols as `NEEDED`
      
      5) During `lookupSymbol` lookups, (which is called from `linkExpr`
         and `linkDecl` in `GHCI.hs`) is the symbol is in a not-yet-loaded
         `ObjectCode` then load the `ObjectCode` on demand and return the
         address of the symbol. Otherwise produce an unresolved symbols error
         as expected.
      
      6) On `unloadObj` we then change the state of the object and remove
         it's symbols from the `reqSymHash` table so it can be reloaded.
      
      This change affects all platforms and OSes which use the runtime linker.
      It seems there are no real perf tests for `GHCi`, but performance
      shouldn't be impacted much. We gain a lot of time not loading all `obj`
      files, and we lose some time in `lookupSymbol` when we're finding
      sections that have to be loaded. The actual finding itself is O(1)
      (Assuming the hashtnl is perfect)
      
      It also consumes slighly more memory as instead of storing just the
      address of a symbol I also store some other information, like if the
      symbol is weak or not.
      
      This change will break any packages relying on renamed POSIX functions
      that were re-named and re-exported by the rts. Any packages following
      the proper naming for functions as found on MSDN will work fine.
      
      Test Plan: ./validate on all platforms which use the Runtime linker.
      
      Reviewers: thomie, rwbarton, simonmar, erikd, bgamari, austin, hvr
      
      Reviewed By: erikd
      
      Subscribers: kgardas, gridaphobe, RyanGlScott, simonmar,
                   rwbarton, #ghc_windows_task_force
      
      Differential Revision: https://phabricator.haskell.org/D1805
      
      GHC Trac Issues: #11223
      90538d86
    • Joachim Breitner's avatar
      Typos in Note · 8987ce06
      Joachim Breitner authored
      8987ce06
    • Ben Gamari's avatar
      RtsFlags: Un-constify temporary buffer · 378091c9
      Ben Gamari authored
      Otherwise we get a const-ness mismatch when we free the buffer, which
      for some reason gcc 5.3 didn't notice.
      378091c9
    • Ryan Scott's avatar
      Remove the instantiation check when deriving Generic(1) · 7443e5c8
      Ryan Scott authored
      Previously, deriving `Generic(1)` bailed out when attempting to
      instantiate visible type parameters (#5939), but this instantiation
      check was quite fragile and doesn't interact well with `-XTypeInType`.
      It has been decided that `Generic(1)` shouldn't be subjected to this
      check anyway, so it has been removed, and `gen_Generic_binds`'s
      machinery has been updated to substitute the type variables in a
      generated `Rep`/`Rep1` instance with the user-supplied type arguments.
      
      In addition, this also refactors `Condition` in `TcDeriv` a bit. Namely,
      since we no longer need `tc_args` to check any conditions, the `[Type]`
      component of `Condition` has been removed.
      
      Fixes #11732.
      
      Test Plan: ./validate
      
      Reviewers: goldfire, kosmikus, simonpj, bgamari, austin
      
      Reviewed By: simonpj, bgamari
      
      Subscribers: thomie
      
      Differential Revision: https://phabricator.haskell.org/D2061
      
      GHC Trac Issues: #5939, #11732
      7443e5c8
    • Ben Gamari's avatar
      base: Fix "since" annotation on GHC.ExecutionStack · ad532ded
      Ben Gamari authored
      I have no idea where "4.11" came from.
      ad532ded
    • Ben Gamari's avatar
      Bump haddock submodule · cf5ff08f
      Ben Gamari authored
      Fixes #11818, where haddock's documentation broke `make install` when
      Sphinx is not available.
      cf5ff08f
    • Jason Eisenberg's avatar
      Fix suggestions for unbound variables (#11680) · 470d4d5b
      Jason Eisenberg authored
      When the typechecker generates the error message for an out-of-scope
      variable, it now uses the GlobalRdrEnv with respect to which the
      variable is unbound, not the GlobalRdrEnv which is available at the time
      the error is reported.  Doing so ensures we do not provide suggestions
      which themselves are out-of-scope (because they are bound in a later
      inter-splice group).
      
      Nonetheless, we do note in the error message if an unambiguous, exact
      match to the out-of-scope variable is found in a later inter-splice
      group, and we specify where that match is not in scope.
      
      Test Plan: ./validate
      
      Reviewers: goldfire, austin, bgamari
      
      Reviewed By: goldfire
      
      Subscribers: thomie
      
      Differential Revision: https://phabricator.haskell.org/D2000
      
      GHC Trac Issues: #11680
      470d4d5b
    • conal's avatar
      Export zonkEvBinds from TcHsSyn. · 5a1add13
      conal authored
      Needed for constructing correct constraint-satisfying code
      (particularly type class instances) in a Core-to-Core transformation.
      
      Reviewers: simonpj, austin, bgamari
      
      Reviewed By: austin, bgamari
      
      Subscribers: thomie
      
      Differential Revision: https://phabricator.haskell.org/D2088
      
      GHC Trac Issues: #11804
      5a1add13
    • Herbert Valerio Riedel's avatar
      Reduce default for -fmax-pmcheck-iterations from 1e7 to 2e6 · d2e05c6b
      Herbert Valerio Riedel authored
      The commit 28f951ed introduced the
      `-fmax-pmcheck-iterations` flag and set the default limit to 1e7
      iterations.
      
      However, this value is still high enough that it can result GHC to
      exhibit memory spikes beyond 1 GiB of RAM usage (heap profile showed
      several `(:)`s, as well as `THUNK_2_0`, and `PmCon` during the memory
      spikes)
      
      A value of 2e6 seems to be a safer upper bound which still manages to
      let the checker not run into the limit in most cases.
      
      Test Plan: Validate, try building a few Hackage packages
      
      Reviewers: austin, gkaracha, bgamari
      
      Reviewed By: bgamari
      
      Subscribers: thomie
      
      Differential Revision: https://phabricator.haskell.org/D2095
      d2e05c6b
    • bollmann's avatar
      Fix Template Haskell bug reported in #11809. · 2f82da76
      bollmann authored
      Record selectors of data types spliced in with Template Haskell are not
      renamer-resolved correctly in GHC HEAD. The culprit is
      `newRecordSelector` which violates notes `Note [Binders in Template
      Haskell] in Convert.hs` and `Note [Looking up Exact RdrNames] in
      RnEnv.hs`. This commit fixes `newRecordSelector` accordingly.
      
      Test Plan: ./validate
      
      Reviewers: thomie, mpickering, bgamari, austin, simonpj, goldfire
      
      Reviewed By: goldfire
      
      Differential Revision: https://phabricator.haskell.org/D2091
      
      GHC Trac Issues: #11809
      2f82da76
    • wereHamster's avatar
      Remove spurious STG_UNUSED annotation · 6d7fda5e
      wereHamster authored
      Reviewers: austin, bgamari
      
      Reviewed By: bgamari
      
      Subscribers: thomie
      
      Differential Revision: https://phabricator.haskell.org/D2096
      6d7fda5e
    • Herbert Valerio Riedel's avatar
      Remove left-over shell-tools.c · f3beed35
      Herbert Valerio Riedel authored
      The last user of this file was the "-dynload wrapper"
      which was removed in 169f5972
      for addressing #4275
      
      Reviewers: austin, erikd, bgamari
      
      Reviewed By: bgamari
      
      Subscribers: thomie
      
      Differential Revision: https://phabricator.haskell.org/D2098
      
      GHC Trac Issues: #4275
      f3beed35
    • Chris Martin's avatar
      Add doc to (<=<) comparing its type to (.) · 90d66ded
      Chris Martin authored
      This is another documentation addition similar to D1989, this time
      comparing the type of the Kleisli composition operator (<=<) to that
      of plain function composition (.).
      
      Reviewers: hvr, austin, bgamari
      
      Reviewed By: bgamari
      
      Subscribers: thomie
      
      Differential Revision: https://phabricator.haskell.org/D2100
      90d66ded
    • Michael Snoyman's avatar
      Provide an optimized replicateM_ implementation #11795 · c4a7520e
      Michael Snoyman authored
      In my testing, the worker/wrapper transformation applied here
      significantly decreases the number of allocations performed when using
      replicateM_. Additionally, this version of the function behaves
      correctly for negative numbers (namely, it will behave the same as
      replicateM_ 0, which is what previous versions of base have done).
      
      Reviewers: bgamari, simonpj, hvr, austin
      
      Reviewed By: bgamari, simonpj, austin
      
      Subscribers: nomeata, simonpj, mpickering, thomie
      
      Differential Revision: https://phabricator.haskell.org/D2086
      
      GHC Trac Issues: #11795
      c4a7520e
    • Simon Marlow's avatar
      Refactor comments about shutdown · 485608d3
      Simon Marlow authored
      485608d3
  6. 08 Apr, 2016 3 commits
  7. 07 Apr, 2016 3 commits