1. 28 Nov, 2014 2 commits
    • Simon Marlow's avatar
      Add purgeObj() to remove the symbol table entries for an object · 9e6e4796
      Simon Marlow authored
      This allows us to replace an object without actually unloading the old
      object, which is necessary when we know we have references to the old
      object so it can't be completely unloaded.  Using unloadObj() would
      cause the GC (CheckUnload) to repeatedly and fruitlessly try to unload
      the old object.
      9e6e4796
    • Simon Marlow's avatar
      Make the linker API thread-safe · b5e8b3b1
      Simon Marlow authored
      We used to be able to rely on the client to use the API in a
      single-threaded way, but now that the GC calls into the linker to
      unload objects this isn't a safe assumption.
      b5e8b3b1
  2. 12 Nov, 2014 1 commit
  3. 30 Oct, 2014 1 commit
    • gintas's avatar
      Use snwprintf instead of swprintf in rts/Linker.c. · 5ce1266a
      gintas authored
      Summary:
      swprintf has different signatures in mingw32, where it does not include the
      buffer size, and in mingw-w64, where it does. That of course breaks the code
      as mingw-w64 treats the pointer to the format string as a size_t.
      
      snwprintf is available in both environments and is consistent, so use that
      instead.
      
      Reviewers: simonmar, austin
      
      Reviewed By: austin
      
      Subscribers: #ghc_windows_task_force, thomie, carter, simonmar
      
      Differential Revision: https://phabricator.haskell.org/D372
      
      GHC Trac Issues: #9726
      5ce1266a
  4. 29 Oct, 2014 1 commit
  5. 25 Oct, 2014 1 commit
  6. 20 Oct, 2014 3 commits
  7. 12 Oct, 2014 1 commit
  8. 08 Oct, 2014 1 commit
    • Simon Marlow's avatar
      Make the linker more robust to errors · 5300099e
      Simon Marlow authored
      Summary:
      When linking fails because there was a problem with the supplied
      object file, then we should not barf() or exit, we should emit a
      suitable error message and return an error code to the caller.  We
      should also free all memory that might have been allocated during
      linking, and generally not do any damage.  This patch fixes most
      common instances of this problem.
      
      Test Plan: validate
      
      Reviewers: rwbarton, austin, ezyang
      
      Reviewed By: ezyang
      
      Subscribers: simonmar, ezyang, carter, thomie
      
      Differential Revision: https://phabricator.haskell.org/D294
      5300099e
  9. 03 Oct, 2014 2 commits
  10. 02 Oct, 2014 1 commit
    • Edward Z. Yang's avatar
      Rename _closure to _static_closure, apply naming consistently. · 35672072
      Edward Z. Yang authored
      Summary:
      In preparation for indirecting all references to closures,
      we rename _closure to _static_closure to ensure any old code
      will get an undefined symbol error.  In order to reference
      a closure foobar_closure (which is now undefined), you should instead
      use STATIC_CLOSURE(foobar).  For convenience, a number of these
      old identifiers are macro'd.
      
      Across C-- and C (Windows and otherwise), there were differing
      conventions on whether or not foobar_closure or &foobar_closure
      was the address of the closure.  Now, all foobar_closure references
      are addresses, and no & is necessary.
      
      CHARLIKE/INTLIKE were not changed, simply alpha-renamed.
      
      Part of remove HEAP_ALLOCED patch set (#8199)
      
      Depends on D265
      Signed-off-by: Edward Z. Yang's avatarEdward Z. Yang <ezyang@mit.edu>
      
      Test Plan: validate
      
      Reviewers: simonmar, austin
      
      Subscribers: simonmar, ezyang, carter, thomie
      
      Differential Revision: https://phabricator.haskell.org/D267
      
      GHC Trac Issues: #8199
      35672072
  11. 29 Sep, 2014 1 commit
  12. 24 Sep, 2014 1 commit
  13. 17 Sep, 2014 1 commit
    • Herbert Valerio Riedel's avatar
      Implement `decodeDouble_Int64#` primop · b62bd5ec
      Herbert Valerio Riedel authored
      The existing `decodeDouble_2Int#` primop is rather inconvenient to use
      (and in fact is not even used by `integer-gmp`) as the mantissa is split
      into 3 components which would actually fit in an `Int64#` value.
      
      However, `decodeDouble_Int64#` is to be used by the new `integer-gmp2`
      re-implementation (see #9281).
      
      Moreover, `decodeDouble_2Int#` performs direct bit-wise operations on the
      IEEE representation which can be replaced by a combination of the
      portable standard C99 `scalbn(3)` and `frexp(3)` functions.
      
      Differential Revision: https://phabricator.haskell.org/D160
      b62bd5ec
  14. 16 Sep, 2014 1 commit
    • AndreasVoellmy's avatar
      Revert "Revert "rts/base: Fix #9423"" and resolve issue that caused the revert. · 7e658bc1
      AndreasVoellmy authored
      Summary:
      This reverts commit 4748f593. The fix for #9423
      was reverted because this commit introduced a C function setIOManagerControlFd()
      (defined in Schedule.c) defined for all OS types, while the prototype
      (in includes/rts/IOManager.h) was only included when mingw32_HOST_OS is
      not defined. This broke Windows builds.
      
      This commit reverts the original commit and resolves the problem by only defining
      setIOManagerControlFd() when mingw32_HOST_OS is defined. Hence the missing prototype
      error should not occur on Windows.
      
      In addition, since the io_manager_control_wr_fd field of the Capability struct is only
      usd by the setIOManagerControlFd, this commit includes the io_manager_control_wr_fd
      field in the Capability struct only when mingw32_HOST_OS is not defined.
      
      Test Plan: Try to compile successfully on all platforms.
      
      Reviewers: austin
      
      Reviewed By: austin
      
      Subscribers: simonmar, ezyang, carter
      
      Differential Revision: https://phabricator.haskell.org/D174
      7e658bc1
  15. 23 Aug, 2014 1 commit
    • Sergei Trofimovich's avatar
      rts/Linker.c: declare 'deRefStablePtr' as an exported 'rts' symbol · 104a66a4
      Sergei Trofimovich authored
          $ inplace/bin/ghc-stage2 -fforce-recomp -dcore-lint -dcmm-lint -dno-debug-output -no-user-package-db -rtsopts -optc-fno-builtin -fno-ghci-history \
              testsuite/tests/ffi/should_run/T4038.hs --interactive -v0 -ignore-dot-ghci +RTS -I0.1 -RTS
      
          *Main> main
          <interactive>: /tmp/ghc16668_0/ghc16668_5.o: unknown symbol `deRefStablePtr'
      
      The reference to 'deRefStablePtr' is generated by 'compiler/deSugar/DsForeign.lhs':
          the_cfun
             = case maybe_target of
                Nothing    -> text "(StgClosure*)deRefStablePtr(the_stableptr)"
                Just hs_fn -> char '&' <> ppr hs_fn <> text "_closure"
      
      Patch fixes all broken tests using 'import wrapper':
          TEST="ffi013 ffi010 ffi011 ffi005 ffi020 ffi006 ffi019 fed001 T1679 T4038"
      
      Tests manifested as broken only in DYNAMIC_GHC_PROGRAMS=NO builds,
      where GHCi's custom linker is used instead of system's linker.
      Signed-off-by: default avatarSergei Trofimovich <slyfox@gentoo.org>
      104a66a4
  16. 22 Aug, 2014 1 commit
  17. 20 Aug, 2014 1 commit
  18. 19 Aug, 2014 2 commits
    • AndreasVoellmy's avatar
      rts/base: Fix #9423 · f9f89b78
      AndreasVoellmy authored
      Summary:
      Fix #9423.
      
      The problem in #9423 is caused when code invoked by `hs_exit()` waits
      on all foreign calls to return, but some IO managers are in `safe` foreign
      calls and do not return. The previous design signaled to the timer manager
      (via its control pipe) that it should "die" and when the timer manager
      returned to Haskell-land, the Haskell code in timer manager then signalled
      to the IO manager threads that they should return from foreign calls and
      `die`. Unfortunately, in the shutdown sequence the timer manager is unable
      to return to Haskell-land fast enough and so the code that signals to the
      IO manager threads (via their control pipes) is never executed and the IO
      manager threads remain out in the foreign calls.
      
      This patch solves this problem by having the RTS signal to all the IO
      manager threads (via their control pipes; and in addition to signalling
      to the timer manager thread) that they should shutdown (in `ioManagerDie()`
      in `rts/Signals.c`. To do this, we arrange for each IO manager thread to
      register its control pipe with the RTS (in `GHC.Thread.startIOManagerThread`).
      In addition, `GHC.Thread.startTimerManagerThread` registers its control pipe.
      These are registered via C functions `setTimerManagerControlFd` (in
      `rts/Signals.c`) and `setIOManagerControlFd` (in `rts/Capability.c`). The IO
      manager control pipe file descriptors are stored in a new field of the
      `Capability_ struct`.
      
      Test Plan: See the notes on #9423 to recreate the problem and to verify that it no longer occurs with the fix.
      
      Auditors: simonmar
      
      Reviewers: simonmar, edsko, ezyang, austin
      
      Reviewed By: austin
      
      Subscribers: phaskell, simonmar, ezyang, carter, relrod
      
      Differential Revision: https://phabricator.haskell.org/D129
      
      GHC Trac Issues: #9423, #9284
      f9f89b78
    • Facundo Domínguez's avatar
      Have the RTS linker search symbols in the originating windows binary. · d2f01000
      Facundo Domínguez authored
      Summary: In initLinker, this patch adds the handle of the module corresponding to the program binary to the list of DLL handles that lookupSymbol uses to search for symbols.
      
      Test Plan: validate
      
      Reviewers: simonmar, austin
      
      Reviewed By: simonmar, austin
      
      Subscribers: phaskell, simonmar, relrod, ezyang, carter
      
      Differential Revision: https://phabricator.haskell.org/D103
      
      GHC Trac Issues: #9382
      d2f01000
  19. 16 Aug, 2014 3 commits
    • Gabor Greif's avatar
      Revert "Fix typos 'resizze'" · 53cc943a
      Gabor Greif authored
      this is z-encoding (as hvr tells me)
      
      This reverts commit 425d5178.
      53cc943a
    • Gabor Greif's avatar
      Fix typos 'resizze' · 425d5178
      Gabor Greif authored
      425d5178
    • Herbert Valerio Riedel's avatar
      Implement {resize,shrink}MutableByteArray# primops · 246436f1
      Herbert Valerio Riedel authored
      The two new primops with the type-signatures
      
        resizeMutableByteArray# :: MutableByteArray# s -> Int#
                                -> State# s -> (# State# s, MutableByteArray# s #)
      
        shrinkMutableByteArray# :: MutableByteArray# s -> Int#
                                -> State# s -> State# s
      
      allow to resize MutableByteArray#s in-place (when possible), and are useful
      for algorithms where memory is temporarily over-allocated. The motivating
      use-case is for implementing integer backends, where the final target size of
      the result is either N or N+1, and only known after the operation has been
      performed.
      
      A future commit will implement a stateful variant of the
      `sizeofMutableByteArray#` operation (see #9447 for details), since now the
      size of a `MutableByteArray#` may change over its lifetime (i.e before
      it gets frozen or GCed).
      
      Test Plan: ./validate --slow
      
      Reviewers: ezyang, austin, simonmar
      
      Reviewed By: austin, simonmar
      
      Differential Revision: https://phabricator.haskell.org/D133
      246436f1
  20. 28 Jul, 2014 1 commit
  21. 30 Jun, 2014 2 commits
  22. 26 Jun, 2014 1 commit
  23. 24 Jun, 2014 1 commit
    • tibbe's avatar
      Add more primops for atomic ops on byte arrays · d8abf85f
      tibbe authored
      Summary:
      Add more primops for atomic ops on byte arrays
      
      Adds the following primops:
      
       * atomicReadIntArray#
       * atomicWriteIntArray#
       * fetchSubIntArray#
       * fetchOrIntArray#
       * fetchXorIntArray#
       * fetchAndIntArray#
      
      Makes these pre-existing out-of-line primops inline:
      
       * fetchAddIntArray#
       * casIntArray#
      d8abf85f
  24. 08 Jun, 2014 1 commit
  25. 05 Jun, 2014 1 commit
  26. 04 May, 2014 1 commit
  27. 02 May, 2014 1 commit
    • Simon Marlow's avatar
      Per-thread allocation counters and limits · b0534f78
      Simon Marlow authored
      This tracks the amount of memory allocation by each thread in a
      counter stored in the TSO.  Optionally, when the counter drops below
      zero (it counts down), the thread can be sent an asynchronous
      exception: AllocationLimitExceeded.  When this happens, given a small
      additional limit so that it can handle the exception.  See
      documentation in GHC.Conc for more details.
      
      Allocation limits are similar to timeouts, but
      
        - timeouts use real time, not CPU time.  Allocation limits do not
          count anything while the thread is blocked or in foreign code.
      
        - timeouts don't re-trigger if the thread catches the exception,
          allocation limits do.
      
        - timeouts can catch non-allocating loops, if you use
          -fno-omit-yields.  This doesn't work for allocation limits.
      
      I couldn't measure any impact on benchmarks with these changes, even
      for nofib/smp.
      b0534f78
  28. 29 Apr, 2014 2 commits
  29. 27 Apr, 2014 1 commit
  30. 13 Apr, 2014 1 commit
  31. 07 Apr, 2014 1 commit