1. 11 Dec, 2016 1 commit
    • Moritz Angermann's avatar
      Make globals use sharedCAF · c3c70244
      Moritz Angermann authored
      Summary:
      The use of globals is quite painful when multiple rts are loaded, e.g.
      when plugins are loaded, which bring in a second rts. The sharedCAF
      appraoch was employed for the FastStringTable; I've taken the libery
      to extend this to the other globals I could find.
      
      This is a reboot of D2575, that should hopefully not exhibit the same
      windows build issues.
      
      Reviewers: Phyx, simonmar, goldfire, bgamari, austin, hvr, erikd
      
      Reviewed By: Phyx, simonmar, bgamari
      
      Subscribers: mpickering, thomie
      
      Differential Revision: https://phabricator.haskell.org/D2773
      c3c70244
  2. 07 Dec, 2016 1 commit
    • Simon Marlow's avatar
      Overhaul of Compact Regions (#12455) · 7036fde9
      Simon Marlow authored
      Summary:
      This commit makes various improvements and addresses some issues with
      Compact Regions (aka Compact Normal Forms).
      
      This was the most important thing I wanted to fix.  Compaction
      previously prevented GC from running until it was complete, which
      would be a problem in a multicore setting.  Now, we compact using a
      hand-written Cmm routine that can be interrupted at any point.  When a
      GC is triggered during a sharing-enabled compaction, the GC has to
      traverse and update the hash table, so this hash table is now stored
      in the StgCompactNFData object.
      
      Previously, compaction consisted of a deepseq using the NFData class,
      followed by a traversal in C code to copy the data.  This is now done
      in a single pass with hand-written Cmm (see rts/Compact.cmm). We no
      longer use the NFData instances, instead the Cmm routine evaluates
      components directly as it compacts.
      
      The new compaction is about 50% faster than the old one with no
      sharing, and a little faster on average with sharing (the cost of the
      hash table dominates when we're doing sharing).
      
      Static objects that don't (transitively) refer to any CAFs don't need
      to be copied into the compact region.  In particular this means we
      often avoid copying Char values and small Int values, because these
      are static closures in the runtime.
      
      Each Compact# object can support a single compactAdd# operation at any
      given time, so the Data.Compact library now enforces mutual exclusion
      using an MVar stored in the Compact object.
      
      We now get exceptions rather than killing everything with a barf()
      when we encounter an object that cannot be compacted (a function, or a
      mutable object).  We now also detect pinned objects, which can't be
      compacted either.
      
      The Data.Compact API has been refactored and cleaned up.  A new
      compactSize operation returns the size (in bytes) of the compact
      object.
      
      Most of the documentation is in the Haddock docs for the compact
      library, which I've expanded and improved here.
      
      Various comments in the code have been improved, especially the main
      Note [Compact Normal Forms] in rts/sm/CNF.c.
      
      I've added a few tests, and expanded a few of the tests that were
      there.  We now also run the tests with GHCi, and in a new test way
      that enables sanity checking (+RTS -DS).
      
      There's a benchmark in libraries/compact/tests/compact_bench.hs for
      measuring compaction speed and comparing sharing vs. no sharing.
      
      The field totalDataW in StgCompactNFData was unnecessary.
      
      Test Plan:
      * new unit tests
      * validate
      * tested manually that we can compact Data.Aeson data
      
      Reviewers: gcampax, bgamari, ezyang, austin, niteria, hvr, erikd
      
      Subscribers: thomie, simonpj
      
      Differential Revision: https://phabricator.haskell.org/D2751
      
      GHC Trac Issues: #12455
      7036fde9
  3. 06 Dec, 2016 1 commit
    • Simon Marlow's avatar
      Overhaul GC stats · 24e6594c
      Simon Marlow authored
      Summary:
      Visible API changes:
      
      * The C struct `GCDetails` gives the stats about a single GC.  This is
        passed to the `gcDone()` callback if one is set via the
        RtsConfig. (previously we just passed a collection of values, so this
        is more extensible, at the expense of breaking the existing API)
      
      * `RTSStats` gives cumulative stats since the start of the program,
        and includes the `GCDetails` for the most recent GC.  This struct
        can be obtained via `getRTSStats()` (the old `getGCStats()` has been
        removed, and `getGCStatsEnabled()` has been renamed to
        `getRTSStatsEnabled()`)
      
      Improvements:
      
      * The per-GC stats and cumulative stats are now cleanly separated.
      
      * Inside the RTS we have a top-level `RTSStats` struct to keep all our
        stats in, previously this was just a collection of strangely-named
        variables.  This struct is mostly just copied in `getRTSStats()`, so
        the implementation of that function is a lot shorter.
      
      * Types are more consistent.  We use a uint64_t byte count for all
        memory values, and Time for all time values.
      
      * Names are more consistent.  We use a suffix `_bytes` for all byte
        counts and `_ns` for all time values.
      
      * We now collect information about the amount of memory in large
        objects and compact objects in `GCDetails`. (the latter was the reason
        I started doing this patch but it seems to have ballooned a bit!)
      
      * I fixed a bug in the calculation of the elapsed MUT time, and added
        an ASSERT to stop the calculations going wrong in the future.
      
      For now I kept the Haskell API in `GHC.Stats` the same, by
      impedence-matching with the new API.  We could either break that API
      and make it match the C API more closely, or we could add a new API
      and deprecate the old one.  Opinions welcome.
      
      This stuff is very easy to get wrong, and it's hard to test.  Reviews
      welcome!
      
      Test Plan:
      manual testing
      validate
      
      Reviewers: bgamari, niteria, austin, ezyang, hvr, erikd, rwbarton, Phyx
      
      Subscribers: thomie
      
      Differential Revision: https://phabricator.haskell.org/D2756
      24e6594c
  4. 01 Dec, 2016 1 commit
    • Kai Ruemmler's avatar
      Fix naming of the native latin1 encodings · 747e77c9
      Kai Ruemmler authored
      textEncodingName is notjust a string, it must be a valid input for
      mkTextEncoding, as stated in libraries/base/GHC/IO/Encoding/Types.hs.
      
      Test Plan:
      A working latin1 locale is required on the system.  Reason: ghc's
      initial locale encoding defaults to ASCII, if either an unknown locale
      or unknown charset is used.  For the bug to show up, ghc must start up
      using the latin1 encoding.
      
      From main directory in ghc do:
      $ ./configure && make clean && make boot && make inplace/bin/ghc-stage2
      $ LC_CTYPE="de_DE.ISO-8859-1" ./inplace/bin/ghc-stage2
      
      Before the patch, the last line leads to the exception thrown:
      ghc-stage2: mkTextEncoding: does not exist (unknown
      encoding:ISO8859-1(checked)//TRANSLIT)
      
      After the patch, ghc-stage2 prints a short usage summary as expected.
      Moreover,
      $ make test TEST=encoding005
      continues to  pass after the patch.
      
      Reviewers: austin, hvr, rwbarton, bgamari
      
      Reviewed By: bgamari
      
      Subscribers: mpickering, rwbarton, thomie
      
      Differential Revision: https://phabricator.haskell.org/D2667
      747e77c9
  5. 30 Nov, 2016 1 commit
  6. 29 Nov, 2016 1 commit
    • Moritz Angermann's avatar
      Make globals use sharedCAF · 6f7ed1e5
      Moritz Angermann authored
      The use of globals is quite painful when multiple rts are loaded, e.g.
      when plugins are loaded, which bring in a second rts. The sharedCAF
      appraoch was employed for the FastStringTable; I've taken the libery
      to extend this to the other globals I could find.
      
      Reviewers: rwbarton, simonmar, austin, hvr, erikd, bgamari
      
      Reviewed By: simonmar, bgamari
      
      Subscribers: thomie
      
      Differential Revision: https://phabricator.haskell.org/D2575
      6f7ed1e5
  7. 23 Nov, 2016 1 commit
    • Alexander Vershilov's avatar
      Allow to unregister threadWaitReadSTM action. · f4302534
      Alexander Vershilov authored
      Allow to unregister threadWaitReadSTM/threadWaitWriteSTM on
      a non-threaded runtime. Previosly noop action was returned,
      as a result it was not possible to unregister action, unless
      data arrives to Fd or it's closed.
      
      Fixes #12852.
      
      Reviewers: simonmar, hvr, austin, bgamari, trofi
      
      Reviewed By: bgamari, trofi
      
      Subscribers: thomie
      
      Differential Revision: https://phabricator.haskell.org/D2729
      
      GHC Trac Issues: #12852
      f4302534
  8. 10 Nov, 2016 1 commit
    • David Feuer's avatar
      Read parentheses better · bef7e784
      David Feuer authored
      Instead of pulling a token and looking for `'('` or `')'`,
      just look for the character itself. This prevents us from
      lexing every single item twice, once to see if it's a
      left parenthesis and once to actually parse it.
      
      Partially fixes #12665
      
      Make parens faster more aggressively
      
      * Strip spaces before parsing, so we never have to strip
      the same spaces twice.
      
      * String parsers together manually, to try to avoid unnecessary closure
      creation.
      
      Test Plan: Validate
      
      Reviewers: austin, hvr, bgamari
      
      Reviewed By: bgamari
      
      Subscribers: thomie
      
      Differential Revision: https://phabricator.haskell.org/D2630
      
      GHC Trac Issues: #12665
      bef7e784
  9. 14 Oct, 2016 1 commit
    • Ben Gamari's avatar
      Clean up handling of known-key Names in interface files · 34d933d6
      Ben Gamari authored
      Previously BinIface had some dedicated logic for handling tuple names in
      the symbol table. As it turns out, this logic was essentially dead code
      as it was superceded by the special handling of known-key things. Here
      we cull the tuple code-path and use the known-key codepath for all
      tuple-ish things.
      
      This had a surprising number of knock-on effects,
      
       * constraint tuple datacons had to be made known-key (previously they
         were not)
      
       * IfaceTopBndr was changed from being a synonym of OccName to a
         synonym of Name (since we now need to be able to deserialize Names
         directly from interface files)
      
       * the change to IfaceTopBndr complicated fingerprinting, since we need
         to ensure that we don't go looking for the fingerprint of the thing
         we are currently fingerprinting in the fingerprint environment (see
         notes in MkIface). Handling this required distinguishing between
         binding and non-binding Name occurrences in the Binary serializers.
      
       * the original name cache logic which previously lived in IfaceEnv has
         been moved to a new NameCache module
      
       * I ripped tuples and sums out of knownKeyNames since they introduce a
         very large number of entries. During interface file deserialization
         we use static functions (defined in the new KnownUniques module) to
         map from a Unique to a known-key Name (the Unique better correspond
         to a known-key name!) When we need to do an original name cache
         lookup we rely on the parser implemented in isBuiltInOcc_maybe.
      
       * HscMain.allKnownKeyNames was folded into PrelInfo.knownKeyNames.
      
       * Lots of comments were sprinkled about describing the new scheme.
      
      Updates haddock submodule.
      
      Test Plan: Validate
      
      Reviewers: niteria, simonpj, austin, hvr
      
      Reviewed By: simonpj
      
      Subscribers: simonmar, niteria, thomie
      
      Differential Revision: https://phabricator.haskell.org/D2467
      
      GHC Trac Issues: #12532, #12415
      34d933d6
  10. 09 Oct, 2016 1 commit
  11. 07 Oct, 2016 1 commit
    • niteria's avatar
      Fix memory leak from #12664 · e41b9c61
      niteria authored
      This fixes the leak with `setProgArgv`. The problem was
      that `setProgArgv` would not free the objects pointed
      to by `prog_argc`, `prog_argv` when the globals were
      changed resulting in a leak.
      
      The only strictly necessary change is in `rts/RtsFlags.c`, but
      the code in `System.Environment` was a bit confusing and not
      exception safe, so I refactored it.
      
      Test Plan: ./validate
      
      Reviewers: simonmar, ezyang, austin, hvr, bgamari, erikd
      
      Subscribers: thomie
      
      Differential Revision: https://phabricator.haskell.org/D2576
      
      GHC Trac Issues: #12664
      e41b9c61
  12. 24 Sep, 2016 1 commit
    • Joachim Breitner's avatar
      Replace INLINEABLE by INLINABLE (#12613) · 68f72f10
      Joachim Breitner authored
      as the latter is the official, correct spelling, and the former just a
      misspelling accepted by GHC.
      
      Also document in the user’s guide that the alternative spelling is
      accepted
      
      This commit was brough to you by HIW 2016.
      68f72f10
  13. 12 Sep, 2016 1 commit
    • Simon Marlow's avatar
      Add hs_try_putmvar() · 454033b5
      Simon Marlow authored
      Summary:
      This is a fast, non-blocking, asynchronous, interface to tryPutMVar that
      can be called from C/C++.
      
      It's useful for callback-based C/C++ APIs: the idea is that the callback
      invokes hs_try_putmvar(), and the Haskell code waits for the callback to
      run by blocking in takeMVar.
      
      The callback doesn't block - this is often a requirement of
      callback-based APIs.  The callback wakes up the Haskell thread with
      minimal overhead and no unnecessary context-switches.
      
      There are a couple of benchmarks in
      testsuite/tests/concurrent/should_run.  Some example results comparing
      hs_try_putmvar() with using a standard foreign export:
      
          ./hs_try_putmvar003 1 64 16 100 +RTS -s -N4     0.49s
          ./hs_try_putmvar003 2 64 16 100 +RTS -s -N4     2.30s
      
      hs_try_putmvar() is 4x faster for this workload (see the source for
      hs_try_putmvar003.hs for details of the workload).
      
      An alternative solution is to use the IO Manager for this.  We've tried
      it, but there are problems with that approach:
      * Need to create a new file descriptor for each callback
      * The IO Manger thread(s) become a bottleneck
      * More potential for things to go wrong, e.g. throwing an exception in
        an IO Manager callback kills the IO Manager thread.
      
      Test Plan: validate; new unit tests
      
      Reviewers: niteria, erikd, ezyang, bgamari, austin, hvr
      
      Subscribers: thomie
      
      Differential Revision: https://phabricator.haskell.org/D2501
      454033b5
  14. 31 Aug, 2016 1 commit
    • Ryan Scott's avatar
      Add Read1/Read2 methods defined in terms of ReadPrec · 9cfef167
      Ryan Scott authored
      This adds new methods `liftReadList(2)` and `liftReadListPrec(2)` to the
      `Read1`/`Read2` classes which are defined in terms of `ReadPrec` instead
      of `ReadS`. This also adds related combinators and changes existing
      `Read1` and `Read2` instances to be defined in terms of the new methods.
      
      Reviewers: hvr, austin, bgamari
      
      Reviewed By: bgamari
      
      Subscribers: thomie
      
      Differential Revision: https://phabricator.haskell.org/D2379
      
      GHC Trac Issues: #12358
      9cfef167
  15. 04 Aug, 2016 1 commit
  16. 27 Jul, 2016 1 commit
  17. 18 Jul, 2016 1 commit
  18. 16 Jul, 2016 1 commit
  19. 08 Jul, 2016 1 commit
  20. 04 Jul, 2016 1 commit
  21. 20 Jun, 2016 1 commit
    • Ryan Scott's avatar
      Remove use of KProxy in GHC.Generics · 0e92af91
      Ryan Scott authored
      Summary:
      With `-XTypeInType`, the singletons machinery that `GHC.Generics` uses
      no longer needs `KProxy` to hack around the use of `k` as both a type
      and a kind. This is simply changing the code to match what's currently
      in the upstream `singletons` repo.
      
      Reviewers: austin, hvr, bgamari
      
      Reviewed By: bgamari
      
      Subscribers: thomie, goldfire
      
      Differential Revision: https://phabricator.haskell.org/D2347
      0e92af91
  22. 17 Jun, 2016 1 commit
    • Simon Marlow's avatar
      NUMA cleanups · 498ed266
      Simon Marlow authored
      - Move the numaMap and nNumaNodes out of RtsFlags to Capability.c
      - Add a test to tests/rts
      498ed266
  23. 10 Jun, 2016 1 commit
    • Simon Marlow's avatar
      Rts flags cleanup · c88f31a0
      Simon Marlow authored
      * Remove unused/old flags from the structs
      * Update old comments
      * Add missing flags to GHC.RTS
      * Simplify GHC.RTS, remove C code and use hsc2hs instead
      * Make ParFlags unconditional, and add support to GHC.RTS
      c88f31a0
  24. 06 Jun, 2016 1 commit
  25. 04 Jun, 2016 1 commit
    • Ryan Scott's avatar
      Replace hand-written Bounded instances with derived ones · 59651173
      Ryan Scott authored
      Summary:
      The spiritual successor to D2291, since deriving `Bounded` instances
      in `GHC.Enum` wasn't possible prior to changes made in that Diff.
      
      This Diff finds every manually implemented `Bounded` instance in `base` that is
      completely equivalent to the derived instances, and replaces it.
      
      Reviewers: bgamari, goldfire, austin, hvr
      
      Reviewed By: austin, hvr
      
      Subscribers: thomie, rwbarton
      
      Differential Revision: https://phabricator.haskell.org/D2301
      59651173
  26. 24 May, 2016 2 commits
  27. 19 May, 2016 1 commit
  28. 12 May, 2016 1 commit
    • Ryan Scott's avatar
      Make Generic1 poly-kinded · b8e25651
      Ryan Scott authored
      This generalizes the `Generic1` typeclass to be of kind `k -> *`, and
      this also makes the relevant datatypes and typeclasses in `GHC.Generics`
      poly-kinded. If `PolyKinds` is enabled, `DeriveGeneric` derives
      `Generic1` instances such that they use the most general kind possible.
      Otherwise, deriving `Generic1` defaults to make an instance where the
      argument is of kind `* -> *` (the current behavior).
      
      Fixes #10604. Depends on D2117.
      
      Test Plan: ./validate
      
      Reviewers: kosmikus, dreixel, goldfire, austin, hvr, simonpj, bgamari
      
      Reviewed By: simonpj, bgamari
      
      Subscribers: thomie, ekmett
      
      Differential Revision: https://phabricator.haskell.org/D2168
      
      GHC Trac Issues: #10604
      b8e25651
  29. 04 May, 2016 2 commits
  30. 02 May, 2016 1 commit
    • Facundo Domínguez's avatar
      StaticPointers: Allow closed vars in the static form. · 36d29f7c
      Facundo Domínguez authored
      Summary:
      With this patch closed variables are allowed regardless of whether
      they are bound at the top level or not.
      
      The FloatOut pass is always performed. When optimizations are
      disabled, only expressions that go to the top level are floated.
      Thus, the applications of the StaticPtr data constructor are always
      floated.
      
      The CoreTidy pass makes sure the floated applications appear in the
      symbol table of object files. It also collects the floated bindings
      and inserts them in the static pointer table.
      
      The renamer does not check anymore if free variables appearing in the
      static form are top-level. Instead, the typechecker looks at the
      tct_closed flag to decide if the free variables are closed.
      
      The linter checks that applications of StaticPtr only occur at the
      top of top-level bindings after the FloatOut pass.
      
      The field spInfoName of StaticPtrInfo has been removed. It used to
      contain the name of the top-level binding that contains the StaticPtr
      application. However, this information is no longer available when the
      StaticPtr is constructed, as the binding name is determined now by the
      FloatOut pass.
      
      Test Plan: ./validate
      
      Reviewers: goldfire, simonpj, austin, hvr, bgamari
      
      Reviewed By: simonpj
      
      Subscribers: thomie, mpickering, mboes
      
      Differential Revision: https://phabricator.haskell.org/D2104
      
      GHC Trac Issues: #11656
      36d29f7c
  31. 19 Apr, 2016 1 commit
  32. 11 Apr, 2016 1 commit
  33. 10 Apr, 2016 1 commit
  34. 08 Apr, 2016 2 commits
  35. 04 Apr, 2016 1 commit
    • Eric Seidel's avatar
      Don't infer CallStacks · 7407a66d
      Eric Seidel authored
      We originally wanted CallStacks to be opt-in, but dealing with let
      binders complicated things, forcing us to infer CallStacks. It turns
      out that the inference is actually unnecessary though, we can let the
      wanted CallStacks bubble up to the outer context by refusing to
      quantify over them. Eventually they'll be solved from a given CallStack
      or defaulted to the empty CallStack if they reach the top.
      
      So this patch prevents GHC from quantifying over CallStacks, getting us
      back to the original plan. There's a small ugliness to do with
      PartialTypeSignatures, if the partial theta contains a CallStack
      constraint, we *do* want to quantify over the CallStack; the user asked
      us to!
      
      Note that this means that
      
        foo :: _ => CallStack
        foo = getCallStack callStack
      
      will be an *empty* CallStack, since we won't infer a CallStack for the
      hole in the theta. I think this is the right move though, since we want
      CallStacks to be opt-in. One can always write
      
        foo :: (HasCallStack, _) => CallStack
        foo = getCallStack callStack
      
      to get the CallStack and still have GHC infer the rest of the theta.
      
      Test Plan: ./validate
      
      Reviewers: goldfire, simonpj, austin, hvr, bgamari
      
      Reviewed By: simonpj, bgamari
      
      Subscribers: bitemyapp, thomie
      
      Projects: #ghc
      
      Differential Revision: https://phabricator.haskell.org/D1912
      
      GHC Trac Issues: #11573
      7407a66d
  36. 30 Mar, 2016 2 commits
    • Ben Gamari's avatar
      Kill the magic of Any · 24d76153
      Ben Gamari authored
      This turns `Any` into a standard wired-in type family defined in
      `GHC.Types`, instead its current incarnation as a magical creature
      provided by the `GHC.Prim`.  Also kill `AnyK`.
      
      See #10886.
      
      Test Plan: Validate
      
      Reviewers: simonpj, goldfire, austin, hvr
      
      Reviewed By: simonpj
      
      Subscribers: goldfire, thomie
      
      Differential Revision: https://phabricator.haskell.org/D2049
      
      GHC Trac Issues: #10886
      24d76153
    • Ben Gamari's avatar
      Defer inlining of Ord methods · c0e3e63e
      Ben Gamari authored
      This performs the same refactoring performed in D1980 for Eq on Ord,
      rewriting the class operations in terms of monomorphic helpers than can
      be reliably matched in rewrite rules.
      c0e3e63e