summaryrefslogtreecommitdiff
path: root/rts
Commit message (Collapse)AuthorAgeFilesLines
* rts: prevent potential divide-by-zero when tickInterval=0Cheng Shao2023-01-311-4/+5
| | | | | | This patch fixes a few places in RtsFlags.c that may result in divide-by-zero error when tickInterval=0, which is the default on wasm. Fixes #22603.
* rts: Drop long-dead fallback definitions for INFINITY & NANBen Gamari2023-01-271-21/+0
| | | | These are no longer necessary since we now compile as C99.
* rts: Fix typoBen Gamari2023-01-273-3/+3
| | | | "tracingAddCapabilities" was mis-named
* rts: Fix C++ compilation issuesBen Gamari2023-01-274-3/+7
| | | | | Make the RTS compilable with a C++ compiler by inserting necessary casts.
* rts: Fix non-atomic mutation of enabled_capabilitiesBen Gamari2023-01-271-1/+2
|
* rts: Relax Messages assertionBen Gamari2023-01-271-2/+4
| | | | | | | `doneWithMsgThrowTo` was previously too strict in asserting that the `Message` is locked. Specifically, it failed to consider that the `Message` may not be locked if we are deleting all threads during RTS shutdown.
* rts: Use C11-compliant static assertion syntaxBen Gamari2023-01-271-1/+4
| | | | | | | Previously we used `static_assert` which is only available in C23. By contrast, C11 only provides `_Static_assert`. Fixes #22777
* Fix RTS build on WindowsSylvain Henry2023-01-251-2/+0
| | | | | This change fixes a cross-compilation issue from ArchLinux to Windows because these symbols weren't found.
* Allow waiting for timerfd to be interrupted during rts shutdownWander Hillen2023-01-241-12/+56
|
* Give the RTS it's own configure scriptJohn Ericson2023-01-183-1/+79
| | | | | | | | | | | | | Currently it doesn't do much anything, we are just trying to introduce it without breaking the build. Later, we will move functionality from the top-level configure script over to it. We need to bump Cabal for https://github.com/haskell/cabal/pull/8649; to facilitate and existing hack of skipping some configure checks for the RTS we now need to skip just *part* not *all* of the "post configure" hook, as running the configure script (which we definitely want to do) is also implemented as part of the "post configure" hook. But doing this requires exposing functionality that wasn't exposed before.
* Add PrimCallConv support to GHCiLuite Stegeman2023-01-186-15/+62
| | | | | | | | | | | | | This adds support for calling Cmm code from bytecode using the native calling convention, allowing modules that use `foreign import prim` to be loaded and debugged in GHCi. This patch introduces a new `PRIMCALL` bytecode instruction and a helper stack frame `stg_primcall`. The code is based on the existing functionality for dealing with unboxed tuples in bytecode, which has been generalised to handle arbitrary calls. Fixes #22051
* Avoid unnecessary printf warnings in EventLog.cViktor Dukhovni2023-01-171-4/+2
| | | | Fixes #22778
* Only gc sparks locally when we can ensure marking is done.Andreas Klebinger2023-01-122-11/+40
| | | | | | | | When performing GC without work stealing there was no guarantee that spark pruning was happening after marking of the sparks. This could cause us to GC live sparks under certain circumstances. Fixes #22528.
* rts: Drop racy assertionBen Gamari2023-01-121-0/+3
| | | | | | | 0e274c39bf836d5bb846f5fa08649c75f85326ac added an assertion in `dirty_MUT_VAR` checking that the MUT_VAR being dirtied was clean. However, this isn't necessarily the case since another thread may have raced us to dirty the object.
* Revert "rts: Drop racy assertion"Ben Gamari2023-01-121-3/+0
| | | | | | | The logic here was inverted. Reverting the commit to avoid confusion when examining the commit history. This reverts commit b3eacd64fb36724ed6c5d2d24a81211a161abef1.
* rts, tests: limit thread name length to 15 bytesNicolas Trangez2023-01-092-1/+7
| | | | | | | | | | | | | On Linux, `pthread_setname_np` (or rather, the kernel) only allows for thread names up to 16 bytes, including the terminating null byte. This commit adds a note pointing this out in `createOSThread`, and fixes up two instances where a thread name of more than 15 characters long was used (in the RTS, and in a test-case). Fixes: #22366 Fixes: https://gitlab.haskell.org/ghc/ghc/-/issues/22366 See: https://gitlab.haskell.org/ghc/ghc/-/issues/22366#note_460796
* Remove RTS hack for configuringJohn Ericson2023-01-091-0/+36
| | | | | See the brand new Note [Undefined symbols in the RTS] for additional details.
* rts: MUT_VAR is not a StgMutArrPtrsBen Gamari2023-01-061-2/+1
| | | | There was previously a comment claiming that the MUT_VAR closure type had the layout of StgMutArrPtrs.
* Add support for sized literals in the bytecode interpreter.Luite Stegeman2023-01-063-6/+303
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The bytecode interpreter only has branching instructions for word-sized values. These are used for pattern matching. Branching instructions for other types (e.g. Int16# or Word8#) weren't needed, since unoptimized Core or STG never requires branching on types like this. It's now possible for optimized STG to reach the bytecode generator (e.g. fat interface files or certain compiler flag combinations), which requires dealing with various sized literals in branches. This patch improves support for generating bytecode from optimized STG by adding the following new bytecode instructions: TESTLT_I64 TESTEQ_I64 TESTLT_I32 TESTEQ_I32 TESTLT_I16 TESTEQ_I16 TESTLT_I8 TESTEQ_I8 TESTLT_W64 TESTEQ_W64 TESTLT_W32 TESTEQ_W32 TESTLT_W16 TESTEQ_W16 TESTLT_W8 TESTEQ_W8 Fixes #21945
* nonmoving: Make free list counter accesses atomicBen Gamari2022-12-231-1/+1
| | | | Since these may race with the allocator(s).
* nonmoving: Fix race in shortcuttingBen Gamari2022-12-232-1/+8
| | | | | We must use an acquire load to read the info table pointer since if we find an indirection we must be certain that we see the indirectee.
* nonmoving: Fix benign race in update remembered set checkBen Gamari2022-12-231-1/+3
| | | | | Relaxed load is fine here since we will take the lock before looking at the list.
* nonmoving: Make bitmap accesses atomicBen Gamari2022-12-231-2/+2
| | | | | | This is a benign race on any sensible hard since these are byte accesses. Nevertheless, atomic accesses are necessary to satisfy TSAN.
* nonmoving: Ensure that we aren't holding locks when closing themBen Gamari2022-12-231-1/+4
| | | | TSAN complains about this sort of thing.
* nonmoving: Refactor update remembered set initializationBen Gamari2022-12-235-34/+66
| | | | | | | This avoids a lock inversion between the storage manager mutex and the stable pointer table mutex by not dropping the SM_MUTEX in nonmovingCollect. This requires quite a bit of rejiggering but it does seem like a better strategy.
* nonmoving: Make segment state updates atomicBen Gamari2022-12-231-1/+1
|
* nonmoving: Fix races in collector status trackingBen Gamari2022-12-232-7/+10
| | | | | | Mark a number of accesses to do with tracking of the status of the concurrent collection thread as atomic. No interesting races here, merely necessary to satisfy TSAN.
* nonmoving: Ensure that mutable fields have acquire barrierBen Gamari2022-12-231-8/+16
|
* nonmoving: Eliminate race in bump_static_flagBen Gamari2022-12-231-8/+10
| | | | | | | To ensure that we don't race with a mutator entering a new CAF we take the SM mutex before touching static_flag. The other option here would be to instead modify newCAF to use a CAS but the present approach is a bit safer.
* nonmoving: Use atomic when looking at bd->genBen Gamari2022-12-231-1/+4
| | | | Since it may have been mutated by a moving GC.
* nonmoving: Fix segment list racesBen Gamari2022-12-232-6/+12
|
* nonmoving: Fix race in marking of blackholesBen Gamari2022-12-232-2/+8
| | | | | We must use an acquire-fence when marking to ensure that the indirectee is visible.
* rts/m32: Fix sanity checkingBen Gamari2022-12-221-1/+1
| | | | | Previously we would attempt to clear pages which were marked as read-only. Fix this.
* rts: Drop paths from configure from cabal fileBen Gamari2022-12-221-4/+0
| | | | | | | | | | | | | | A long time ago we would rely on substitutions from the configure script to inject paths of the include and library directories of libffi and libdw. However, now these are instead handled inside Hadrian when calling Cabal's `configure` (see the uses of `cabalExtraDirs` in Hadrian's `Settings.Packages.packageArgs`). While the occurrences in the cabal file were redundant, they did no harm. However, since b5c714545abc5f75a1ffdcc39b4bfdc7cd5e64b4 they have no longer been interpolated. @mpickering noticed the suspicious uninterpolated occurrence of `@FFIIncludeDir@` in #22595, prompting this commit to finally remove them.
* Don't consider large byte arrays/compact regions pinned.Andreas Klebinger2022-12-221-1/+4
| | | | | Workaround for #22255 which showed how treating large/compact regions as pinned could cause segfaults.
* rts: explicitly store return value of ccall checkClosure to prevent type ↵Ying-Ruei Liang (TheKK)2022-12-211-1/+2
| | | | error (#22617)
* rts/libdw: Silence uninitialized usage warningsBen Gamari2022-12-181-3/+3
| | | | | | | | As noted in #22538, previously some GCC versions warned that various locals in Libdw.c may be used uninitialized. Although this wasn't strictly true (since they were initialized in an inline assembler block) we fix this by providing explicit empty initializers. Fixes #22538
* rts: Drop racy assertionBen Gamari2022-12-181-0/+3
| | | | | | | 0e274c39bf836d5bb846f5fa08649c75f85326ac added an assertion in `dirty_MUT_VAR` checking that the MUT_VAR being dirtied was clean. However, this isn't necessarily the case since another thread may have raced us to dirty the object.
* rts: Note race with wakeBlockingQueueBen Gamari2022-12-161-1/+2
|
* rts: Ensure that all accesses to pending_sync are atomicBen Gamari2022-12-161-2/+2
|
* rts: Statically allocate capabilitiesBen Gamari2022-12-163-19/+19
| | | | This is a rather simplistic way of solving #17289.
* rts: Use ordered accesses instead of explicit barriersBen Gamari2022-12-162-8/+6
|
* rts: Fix ordering of makeStableNameBen Gamari2022-12-161-5/+3
|
* rts: Style fixBen Gamari2022-12-161-6/+3
|
* PrimOps: Fix benign MutVar raceBen Gamari2022-12-161-2/+2
| | | | Relaxed ordering is fine here since the later CAS implies a release.
* rts: Encapsulate sched_stateBen Gamari2022-12-1610-42/+53
|
* rts: Encapsulate access to capabilities arrayBen Gamari2022-12-1623-148/+156
|
* rts: Encapsulate recent_activity accessBen Gamari2022-12-165-25/+45
| | | | | This makes it easier to ensure that it is accessed using the necessary atomic operations.
* rts/Timer: Always use atomic operationsBen Gamari2022-12-163-17/+41
| | | | | | As noted in #22447, the existence of the pthread-based ITimer implementation means that we cannot assume that the program is single-threaded.
* rts: Always use atomics for context_switch and interruptBen Gamari2022-12-164-12/+17
| | | | Since these are modified by the timer handler.