Skip to content
Snippets Groups Projects
  1. Sep 19, 2017
    • Ben Gamari's avatar
      cmm/CBE: Collapse blocks equivalent up to alpha renaming of local registers · 7920a7d9
      Ben Gamari authored and Ben Gamari's avatar Ben Gamari committed
      As noted in #14226, the common block elimination pass currently
      implements an extremely strict equivalence relation, demanding that two
      blocks are equivalent including the names of their local registers. This
      is quite restrictive and severely hampers the effectiveness of the pass.
      
      Here we allow the CBE pass to collapse blocks which are equivalent up to
      alpha renaming of locally-bound local registers. This is completely safe
      and catches many more duplicate blocks.
      
      Test Plan: Validate
      
      Reviewers: austin, simonmar, michalt
      
      Reviewed By: michalt
      
      Subscribers: rwbarton, thomie
      
      GHC Trac Issues: #14226
      
      Differential Revision: https://phabricator.haskell.org/D3973
      7920a7d9
    • Arnaud Spiwack's avatar
      Factor mkCoreApp and mkCoreApps · 3198956d
      Arnaud Spiwack authored and Ben Gamari's avatar Ben Gamari committed
      `mkCoreApps` re-implemented `mkCoreApp` in a recursive function,
      rather than using a simple `foldl'` in order to avoid repeatingly
      computing the type of the function argument. I've factored the two
      logic into a new (internal) function `mkCoreType` which assumes that
      the type is known. `mkCoreApp` and `mkCoreApps` are thin wrappers
      around it.
      
      Differences
      - The assertion failure message of `mkCoreApps` has more
        information in it.
      - `mkCoreApps` now special-cases coercion argument like
        `mkCoreApp` (previously they were given to `mk_val_app` instead)
      
      Reviewers: austin, bgamari
      
      Reviewed By: bgamari
      
      Subscribers: rwbarton, thomie
      
      Differential Revision: https://phabricator.haskell.org/D3971
      3198956d
    • Ben Gamari's avatar
      users-guide: Mention changes necessary due to #13391 · bbb8cb92
      Ben Gamari authored and Ben Gamari's avatar Ben Gamari committed
      Some variant of this should also be added to the migration guide.
      
      [skip ci]
      
      Test Plan: Read it
      
      Reviewers: goldfire, austin
      
      Reviewed By: goldfire
      
      Subscribers: rwbarton, thomie
      
      GHC Trac Issues: #13391
      
      Differential Revision: https://phabricator.haskell.org/D3966
      bbb8cb92
    • Niklas Hambüchen's avatar
      base: Add more detail to FD_SETSIZE related error message · 022455ff
      Niklas Hambüchen authored and Ben Gamari's avatar Ben Gamari committed
      Reviewers: bgamari, austin, hvr
      
      Reviewed By: bgamari
      
      Subscribers: rwbarton, thomie
      
      Differential Revision: https://phabricator.haskell.org/D3960
      022455ff
    • Niklas Hambüchen's avatar
      base: Make it less likely for fdReady() to fail on Windows sockets. · ba4dcc7c
      Niklas Hambüchen authored and Ben Gamari's avatar Ben Gamari committed
      See the added comment for details.
      
      It's "less likely" because it can still fail if the socket happens to
      have an FD larger than 1023, which can happen if many files are opened.
      
      Until now, basic socket programs that use `hWaitForInput` were broken on
      Windows.
      
      That is because on Windows `FD_SETSIZE` defaults to 64, but pretty much
      all GHC programs seem to have > 64 FDs open, so you can't actually
      create a socket on which you can `select()`.
      
      It errors with `fdReady: fd is too big` even with an example as simple
      as the following (in this case, on my machine the `fd` is `284`):
      
        {-# LANGUAGE OverloadedStrings #-}
      
        import Control.Monad (forever)
        import Network.Socket
        import System.IO
      
        -- Simple echo server: Reads up to 10 chars from network, echoes them back.
        -- Uses the Handle API so that `hWaitForInput` can be used.
        main :: IO ()
        main = do
          sock <- socket AF_INET Stream 0
          setSocketOption sock ReuseAddr 1
          bind sock (SockAddrInet 1234 0x0100007f)
            -- 0x0100007f == 127.0.0.1 localhost
          listen sock 2
          forever $ do
            (connSock, _connAddr) <- accept sock
            putStrLn "Got connection"
      
            h <- socketToHandle connSock ReadWriteMode
            hSetBuffering h NoBuffering
      
            ready <- hWaitForInput h (5 * 1000) -- 5 seconds
            putStrLn $ "Ready: " ++ show ready
      
            line <- hGetLine h
            putStrLn "Got line"
            hPutStrLn h ("Got: " ++ line)
            hClose h
      
      I'm not sure how this was not discovered earlier; for #13525 (where
      `fdReady()` breaking completely was also discovered late) at least it
      failed only when the timeout was non-zero, which is not used in ghc
      beyond in `hWaitForInput`, but in this Windows socket case it breaks
      even on the 0-timeout.
      
      Maybe there is not actually anybody who uses sockets as handles on
      Windows?
      
      The workaround for now is to increase `FD_SETSIZE` on Windows;
      increasing it is possible on Windows and BSD, see
      
      https://stackoverflow.com/questions/7976388/increasing-limit-of-fd-setsi
      ze-and-select
      
      A real fix would be to move to IO Completion Ports on Windows, and thus
      get rid of the last uses of `select()` (the other platforms already use
      `poll()` but Windows doesn't have that).
      
      Reviewers: bgamari, austin, hvr, erikd, simonmar
      
      Reviewed By: bgamari
      
      Subscribers: rwbarton, thomie
      
      Differential Revision: https://phabricator.haskell.org/D3959
      ba4dcc7c
    • Niklas Hambüchen's avatar
      rts: Fix typo in comment · b7f2d125
      Niklas Hambüchen authored and Ben Gamari's avatar Ben Gamari committed
      Reviewers: bgamari, austin, erikd, simonmar
      
      Reviewed By: bgamari
      
      Subscribers: rwbarton, thomie
      
      Differential Revision: https://phabricator.haskell.org/D3958
      b7f2d125
    • Niklas Hambüchen's avatar
      rts: Update comment about FreeBSD's unsigned FD_SETSIZE · 11c478b5
      Niklas Hambüchen authored and Ben Gamari's avatar Ben Gamari committed
      Reviewers: bgamari, austin, erikd, simonmar
      
      Reviewed By: bgamari
      
      Subscribers: rwbarton, thomie
      
      Differential Revision: https://phabricator.haskell.org/D3957
      11c478b5
    • Niklas Hambüchen's avatar
      base: Fix fdReady() returning immediately for pipes on Windows. · 66240c9b
      Niklas Hambüchen authored and Ben Gamari's avatar Ben Gamari committed
      See https://ghc.haskell.org/trac/ghc/ticket/13497#comment:17
      
      Until now, the program
      
        import System.IO
        main = hWaitForInput stdin (5 * 1000)
      
      didn't wait 5 seconds for input on Winodws, it terminated immediately.
      
      This was because the `PeekNamedPipe()` function introduced in commit
      94fee9e7 really only peeks, it doesn't block.  So if there's no data,
      `fdReady(fd, msec)` would return immediately even when the given `msec`
      timeout is not zero.
      
      This commit fixes it by looping around `PeekNamedPipe()` with a `sleep(1
      ms)`.
      
      Apparently there's no better way to do this on Windows without switching
      to IOCP.
      
      In any case, this change should be strictly better than what was there
      before.
      
      Reviewers: bgamari, austin, hvr
      
      Reviewed By: bgamari
      
      Subscribers: Phyx, rwbarton, thomie
      
      Differential Revision: https://phabricator.haskell.org/D3956
      66240c9b
    • Niklas Hambüchen's avatar
      base: Fix fdReady() potentially running forever for Windows Char devices. · 826c3b11
      Niklas Hambüchen authored and Ben Gamari's avatar Ben Gamari committed
      Reviewers: bgamari, austin, hvr
      
      Reviewed By: bgamari
      
      Subscribers: rwbarton, thomie
      
      Differential Revision: https://phabricator.haskell.org/D3955
      826c3b11
    • Niklas Hambüchen's avatar
      base: Fix fdReady() potentially running forever on Windows. · c2a1fa7a
      Niklas Hambüchen authored and Ben Gamari's avatar Ben Gamari committed
      This fixes #13497 for Windows -- at least for the `if (isSock)` part; I
      haven't investigated the case where it's not a socket yet.
      
      Solved by copying the new current-time based waiting logic from the
      non-Windows implementation above.
      
      Reviewers: bgamari, austin, hvr
      
      Reviewed By: bgamari
      
      Subscribers: rwbarton, thomie
      
      Differential Revision: https://phabricator.haskell.org/D3954
      c2a1fa7a
    • Niklas Hambüchen's avatar
      base: fdReady(): Improve accuracy and simplify code. · 28a115e5
      Niklas Hambüchen authored and Ben Gamari's avatar Ben Gamari committed
      This is done by reusing the existing cross-platform
      `getProcessElapsedTime()` function, which already provides nanosecond
      monotonic clocks, and fallback for platforms that don't have those.
      
      To do this, `getProcessElapsedTime()` had to be moved from a private RTS
      symbol into the public interface.
      
      Accuracy is improved in 2 ways:
      
      * Use of the monotonic clock where available
      * Measuring the total time spent waiting instead of a sum
        of intervals (between which there are small gaps)
      
      Reviewers: bgamari, austin, hvr, erikd, simonmar
      
      Reviewed By: bgamari
      
      Subscribers: rwbarton, thomie
      
      Differential Revision: https://phabricator.haskell.org/D3953
      28a115e5
    • Ben Gamari's avatar
      7c7914d0
    • Herbert Valerio Riedel's avatar
      compiler: introduce custom "GhcPrelude" Prelude · f63bc730
      Herbert Valerio Riedel authored and Ben Gamari's avatar Ben Gamari committed
      This switches the compiler/ component to get compiled with
      -XNoImplicitPrelude and a `import GhcPrelude` is inserted in all
      modules.
      
      This is motivated by the upcoming "Prelude" re-export of
      `Semigroup((<>))` which would cause lots of name clashes in every
      modulewhich imports also `Outputable`
      
      Reviewers: austin, goldfire, bgamari, alanz, simonmar
      
      Reviewed By: bgamari
      
      Subscribers: goldfire, rwbarton, thomie, mpickering, bgamari
      
      Differential Revision: https://phabricator.haskell.org/D3989
      f63bc730
    • Ben Gamari's avatar
      OccurAnal: Ensure SourceNotes don't interfere with join-point analysis · 12a92fed
      Ben Gamari authored and Ben Gamari's avatar Ben Gamari committed
      In general ticks are problematic for join point analysis as described
      in #14242.  However, source notes are intended to be a best-effort
      annotation which shouldn't interfere with optimization. Special-case
      these to ensure that tail-call information is still correct, even in the
      presence of source note
      ticks.
      
      Test Plan: Validate
      
      Reviewers: simonpj, austin
      
      Reviewed By: simonpj
      
      Subscribers: rwbarton, thomie
      
      GHC Trac Issues: #14242
      
      Differential Revision: https://phabricator.haskell.org/D3978
      12a92fed
    • Ben Gamari's avatar
      nativeGen: Consistently use blockLbl to generate CLabels from BlockIds · 8b007abb
      Ben Gamari authored and Ben Gamari's avatar Ben Gamari committed
      This fixes #14221, where the NCG and the DWARF code were apparently
      giving two different names to the same block.
      
      Test Plan: Validate with DWARF support enabled.
      
      Reviewers: simonmar, austin
      
      Subscribers: rwbarton, thomie
      
      GHC Trac Issues: #14221
      
      Differential Revision: https://phabricator.haskell.org/D3977
      8b007abb
    • Ben Gamari's avatar
      rts/RetainerProfile: Adding missing closure types to isRetainer · 6252292d
      Ben Gamari authored and Ben Gamari's avatar Ben Gamari committed
      orzo in `#ghc` reported seeing a crash due to the retainer profiler encountering
      a BLOCKING_QUEUE closure, which isRetainer didn't know about. I performed an
      audit to make sure that all of the valid closure types were listed; they
      weren't. This is my guess of how they should appear.
      
      Test Plan: Validate
      
      Reviewers: simonmar, austin, erikd
      
      Reviewed By: simonmar
      
      Subscribers: rwbarton, thomie
      
      GHC Trac Issues: #14235
      
      Differential Revision: https://phabricator.haskell.org/D3967
      6252292d
    • Simon Peyton Jones's avatar
      Fix unused-given-constraint bug · 1db0f4a4
      Simon Peyton Jones authored
      This bug was shown up by Trac #14237.  It turned out
      to be an outright error in TcSimplify.neededEvVars,
      easily fixed.
      
      I improved the comments.
      1db0f4a4
    • Herbert Valerio Riedel's avatar
      Remove redundant/obsolete CPP usage · a2f004b6
      Herbert Valerio Riedel authored
      This `#if 0`/`#endif` block has been around for over 10 years and
      it became truly redundant in 36104d7a
      a2f004b6
    • Herbert Valerio Riedel's avatar
      Generalise constraint on `instance Monoid (Maybe a)` to Semigroup · 10ca8018
      Herbert Valerio Riedel authored
      This now becomes possible due to the introduction of the
      Semigroup=>Monoid superclass relation (see #14191).
      
      Reviewers: ekmett, RyanGlScott, austin, bgamari
      
      Reviewed By: ekmett, RyanGlScott, bgamari
      
      Subscribers: rwbarton, thomie
      
      Differential Revision: https://phabricator.haskell.org/D3972
      10ca8018
    • Moritz Angermann's avatar
      Allow opt+llc from LLVM5 · 120c568a
      Moritz Angermann authored
      Summary:
      This bumps our LLVM version requirement to LLVM5,
      which will likely be released before GHC 8.4.
      
      Test Plan: validate
      
      Reviewers: austin, hvr, bgamari
      
      Reviewed By: bgamari
      
      Subscribers: rwbarton, thomie, erikd
      
      Differential Revision: https://phabricator.haskell.org/D3797
      120c568a
  2. Sep 18, 2017
    • niteria's avatar
      [RTS] Add getObjectLoadStatus · cdaf5f20
      niteria authored
      This adds a function to the RTS linker API which lets the
      user check the status of dynamically linked objects.
      
      It was initially proposed by @afarmer in D2068.
      It's useful for testing the linker and also for detecting retention
      problems in production.
      
      It takes a path, because it's easier to use path as key instead of producing
      some stable handle.
      
      It returns an enum instead of bool, because I see no reason for destroying
      information. All the complexity is already out in the open, so there's
      nothing to save the users from.
      
      Test Plan: ./validate
      
      Reviewers: simonmar, Phyx, bgamari, austin, erikd
      
      Reviewed By: Phyx, bgamari
      
      Subscribers: rwbarton, afarmer, thomie
      
      Differential Revision: https://phabricator.haskell.org/D3963
      cdaf5f20
  3. Sep 17, 2017
  4. Sep 16, 2017
    • Ben Gamari's avatar
      base: Enable TypeInType in Data.Type.Equality · b0991714
      Ben Gamari authored
      Otherwise compilation fails with,
      
          libraries/base/Data/Type/Equality.hs:145:4: error:
              • Data constructor ‘HRefl’ constrains the choice of kind parameter:
                  k2 ~ k2
                Use TypeInType to allow this
              • In the definition of data constructor ‘HRefl’
                In the data type declaration for ‘:~~:’
              |
          145 |    HRefl :: a :~~: a
              |    ^
      b0991714
  5. Sep 15, 2017
  6. Sep 14, 2017
Loading