summaryrefslogtreecommitdiff
path: root/rts
Commit message (Collapse)AuthorAgeFilesLines
* RTS: Fix failed inlining of copy_tag.Andreas Klebinger2020-11-261-7/+12
| | | | | | | | | | | | | | | On windows using gcc-10 gcc failed to inline copy_tag into evacuate. To fix this we now set the always_inline attribute for the various copy* functions in Evac.c. The main motivation here is not the overhead of the function call, but rather that this allows the code to "specialize" for the size of the closure we copy which is often known at compile time. An earlier commit also tried to avoid evacuate_large inlining. But didn't quite succeed. So I also marked evacuate_large as noinline. Fixes #12416
* [Sized Cmm] properly retain sizes.Moritz Angermann2020-11-261-0/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | This replaces all Word<N> = W<N># Word# and Int<N> = I<N># Int# with Word<N> = W<N># Word<N># and Int<N> = I<N># Int<N>#, thus providing us with properly sized primitives in the codegenerator instead of pretending they are all full machine words. This came up when implementing darwinpcs for arm64. The darwinpcs reqires us to pack function argugments in excess of registers on the stack. While most procedure call standards (pcs) assume arguments are just passed in 8 byte slots; and thus the caller does not know the exact signature to make the call, darwinpcs requires us to adhere to the prototype, and thus have the correct sizes. If we specify CInt in the FFI call, it should correspond to the C int, and not just be Word sized, when it's only half the size. This does change the expected output of T16402 but the new result is no less correct as it eliminates the narrowing (instead of the `and` as was previously done). Bumps the array, bytestring, text, and binary submodules. Co-Authored-By: Ben Gamari <ben@well-typed.com> Metric Increase: T13701 T14697
* CmmToLlvm: Declare signature for memcmpwip/angerman/arm64Ben Gamari2020-11-243-4/+12
| | | | | | Otherwise `opt` fails with: error: use of undefined value '@memcmp$def'
* rts: Flush eventlog buffers from flushEventLogBen Gamari2020-11-248-9/+58
| | | | | | | | | | | | As noted in #18043, flushTrace failed flush anything beyond the writer. This means that a significant amount of data sitting in capability-local event buffers may never get flushed, despite the users' pleads for us to flush. Fix this by making flushEventLog flush all of the event buffers before flushing the writer. Fixes #18043.
* rts: Post ticky entry counts to the eventlogBen Gamari2020-11-219-2/+150
| | | | | | | | We currently only post the entry counters, not the other global counters as in my experience the former are more useful. We use the heap profiler's census period to decide when to dump. Also spruces up the documentation surrounding ticky-ticky a bit.
* rts/linker: Align bssSize to page size when mapping symbol extrasBen Gamari2020-11-201-1/+3
| | | | | | | We place symbol_extras right after bss. We also need to ensure that symbol_extras can be mprotect'd independently from the rest of the image. To ensure this we round up the size of bss to a page boundary, thus ensuring that symbol_extras is also page-aligned.
* AArch64/arm64 adjustmentsMoritz Angermann2020-11-157-12/+12
| | | | | | | | This addes the necessary logic to support aarch64 on elf, as well as aarch64 on mach-o, which Apple calls arm64. We change architecture name to AArch64, which is the official arm naming scheme.
* Add rts_listThreads and rts_listMiscRoots to RtsAPI.hDavid Eichmann2020-11-131-0/+53
| | | | | | | | These are used to find the current roots of the garbage collector. Co-authored-by: Sven Tennie's avatarSven Tennie <sven.tennie@gmail.com> Co-authored-by: Matthew Pickering's avatarMatthew Pickering <matthewtpickering@gmail.com> Co-authored-by: default avatarBen Gamari <bgamari.foss@gmail.com>
* rts: Introduce highMemDynamicGHC GitLab CI2020-11-111-1/+8
|
* Add loadNativeObj and unloadNativeObjRay Shih2020-11-114-15/+261
| | | | | | | | | | | | | | | | | | | (This change is originally written by niteria) This adds two functions: * `loadNativeObj` * `unloadNativeObj` and implements them for Linux. They are useful if you want to load a shared object with Haskell code using the system linker and have GHC call dlclose() after the code is no longer referenced from the heap. Using the system linker allows you to load the shared object above outside the low-mem region. It also loads the DWARF sections in a way that `perf` understands. `dl_iterate_phdr` is what makes this implementation Linux specific.
* Fix and enable object unloading in GHCiÖmer Sinan Ağacan2020-11-1115-485/+584
| | | | | | | Fixes #16525 by tracking dependencies between object file symbols and marking symbol liveness during garbage collection See Note [Object unloading] in CheckUnload.c for details.
* ghc-heap: expose decoding from heap representationDavid Eichmann2020-11-101-18/+23
| | | | | | Co-authored-by: Sven Tennie <sven.tennie@gmail.com> Co-authored-by: Matthew Pickering <matthewtpickering@gmail.com> Co-authored-by: Ben Gamari <bgamari.foss@gmail.com>
* rts/linker: Fix relocation overflow in PE linkerBen Gamari2020-11-101-4/+6
| | | | | | | | | | | | | | | | | | | | | | | Previously the overflow check for the IMAGE_REL_AMD64_ADDR32NB relocation failed to account for the signed nature of the value. Specifically, the overflow check was: uint64_t v; v = S + A; if (v >> 32) { ... } However, `v` ultimately needs to fit into 32-bits as a signed value. Consequently, values `v > 2^31` in fact overflow yet this is not caught by the existing overflow check. Here we rewrite the overflow check to rather ensure that `INT32_MIN <= v <= INT32_MAX`. There is now quite a bit of repetition between the `IMAGE_REL_AMD64_REL32` and `IMAGE_REL_AMD64_ADDR32` cases but I am leaving fixing this for future work. This bug was first noticed by @awson. Fixes #15808.
* Merge remote-tracking branch 'origin/wip/tsan/all'Ben Gamari2020-11-0844-743/+1054
|\
| * Merge branch 'wip/tsan/stats' into wip/tsan/allBen Gamari2020-11-014-27/+62
| |\
| | * rts: Tear down stats_mutex after exitHeapProfilingwip/tsan/statsBen Gamari2020-11-014-5/+14
| | | | | | | | | | | | Since the latter wants to call getRTSStats.
| | * rts/Stats: Protect with mutexBen Gamari2020-11-011-3/+55
| | | | | | | | | | | | | | | While on face value this seems a bit heavy, I think it's far better than enforcing ordering on every access.
| | * rts/Stats: Hide a few unused unnecessarily global functionsBen Gamari2020-10-242-22/+0
| | |
| * | Merge branch 'wip/tsan/timer' into wip/tsan/allBen Gamari2020-11-017-34/+65
| |\ \
| | * | rts: Fix races in Pthread timer backend shudownwip/tsan/timerBen Gamari2020-10-241-8/+11
| | | | | | | | | | | | | | | | | | | | We can generally be pretty relaxed in the barriers here since the timer thread is a loop.
| | * | rts: Fix timer initializationBen Gamari2020-10-241-1/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Previously `initScheduler` would attempt to pause the ticker and in so doing acquire the ticker mutex. However, initTicker, which is responsible for initializing said mutex, hadn't been called yet.
| | * | suppress #17289 (ticker) raceBen Gamari2020-10-241-0/+4
| | | |
| | * | Fix #17289Ben Gamari2020-10-242-11/+19
| | | |
| | * | rts: Pause timer while changing capability countBen Gamari2020-10-242-11/+21
| | | | | | | | | | | | | | | | This avoids #17289.
| | * | rts: Accept benign races in ProftimerBen Gamari2020-10-241-5/+5
| | |/
| * | Merge branch 'wip/tsan/event-mgr' into wip/tsan/allBen Gamari2020-11-013-21/+30
| |\ \
| | * | Suppress data race due to closeBen Gamari2020-11-011-0/+1
| | | | | | | | | | | | | | | | This suppresses the other side of a race during shutdown.
| | * | Mitigate data races in event manager startup/shutdownwip/tsan/event-mgrBen Gamari2020-10-242-21/+29
| | |/
| * | Merge branch 'wip/tsan/stm' into wip/tsan/allBen Gamari2020-11-011-37/+55
| |\ \
| | * | rts/stm: Strengthen orderings to SEQ_CST instead of volatilewip/tsan/stmBen Gamari2020-10-241-20/+20
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Previously the `current_value`, `first_watch_queue_entry`, and `num_updates` fields of `StgTVar` were marked as `volatile` in an attempt to provide strong ordering. Of course, this isn't sufficient. We now use proper atomic operations. In most of these cases I strengthen the ordering all the way to SEQ_CST although it's possible that some could be weakened with some thought.
| | * | rts/STM: Use atomicsBen Gamari2020-10-241-27/+45
| | |/ | | | | | | | | | | | | | | | | | | | | | This fixes a potentially harmful race where we failed to synchronize before looking at a TVar's current_value. Also did a bit of refactoring to avoid abstract over management of max_commits.
| * | Merge branch 'wip/tsan/misc' into wip/tsan/allBen Gamari2020-11-014-6/+10
| |\ \
| | * | rts: Use proper relaxe operations in getCurrentThreadCPUTimewip/tsan/miscGHC GitLab CI2020-10-241-2/+4
| | | | | | | | | | | | | | | | | | | | Here we are doing lazy initialization; it's okay if we do the check more than once, hence relaxed operation is fine.
| | * | rts: Avoid lock order inversion during forkBen Gamari2020-10-241-1/+3
| | | | | | | | | | | | | | | | Fixes #17275.
| | * | rts: Use relaxed atomics for whitehole spin statsBen Gamari2020-10-242-3/+3
| | |/
| * | Merge branch 'wip/tsan/wsdeque' into wip/tsan/allBen Gamari2020-11-013-174/+96
| |\ \
| | * | rts/WSDeque: Rewrite with proper atomicswip/tsan/wsdequeBen Gamari2020-10-243-174/+96
| | |/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | After a few attempts at shoring up the previous implementation, I ended up turning to the literature and now use the proven implementation, > N.M. Lê, A. Pop, A.Cohen, and F.Z. Nardelli. "Correct and Efficient > Work-Stealing for Weak Memory Models". PPoPP'13, February 2013, > ACM 978-1-4503-1922/13/02. Note only is this approach formally proven correct under C11 semantics but it is also proved to be a bit faster in practice.
| * | Merge branch 'wip/tsan/storage' into wip/tsan/allBen Gamari2020-11-0122-267/+415
| |\ \
| | * | Strengthen ordering in releaseGCThreadsBen Gamari2020-11-011-2/+2
| | | |
| | * | rts: Annotate hopefully "benign" races in freeGroupBen Gamari2020-11-011-0/+25
| | | |
| | * | rts: Use relaxed ordering on spinlock counterswip/tsan/storageBen Gamari2020-10-301-2/+2
| | | |
| | * | rts/SpinLock: Separate out slow pathBen Gamari2020-10-302-0/+42
| | | | | | | | | | | | | | | | | | | | | | | | Not only is this in general a good idea, but it turns out that GCC unrolls the retry loop, resulting is massive code bloat in critical parts of the RTS (e.g. `evacuate`).
| | * | rts: Fix race in GC CPU time accountingGHC GitLab CI2020-10-301-3/+6
| | | | | | | | | | | | | | | | | | | | Ensure that the GC leader synchronizes with workers before calling stat_endGC.
| | * | rts: Join to concurrent mark thread during shutdownBen Gamari2020-10-303-0/+18
| | | | | | | | | | | | | | | | | | | | Previously we would take all capabilities but fail to join on the thread itself, potentially resulting in a leaked thread.
| | * | rts/Storage: Accept races on heap size countersBen Gamari2020-10-301-5/+8
| | | |
| | * | rts: Use RELEASE ordering in unlockClosureBen Gamari2020-10-301-3/+2
| | | |
| | * | rts/GC: Use atomicsBen Gamari2020-10-3010-172/+189
| | | |
| | * | rts/Weak: Eliminate data racesBen Gamari2020-10-242-18/+14
| | | | | | | | | | | | | | | | | | | | By taking all_tasks_mutex in stat_exit. Also better-document the fact that the task statistics are protected by all_tasks_mutex.
| | * | rts/Updates: Use proper atomic operationsBen Gamari2020-10-241-4/+2
| | | |
| | * | rts/Storage: Use atomicsBen Gamari2020-10-241-18/+17
| | | |