summaryrefslogtreecommitdiff
path: root/rts
Commit message (Collapse)AuthorAgeFilesLines
* rts/m32: Fix sanity checkingwip/m32-debugBen Gamari2022-12-201-1/+1
| | | | | Previously we would attempt to clear pages which were marked as read-only. Fix this.
* 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.
* rts: Introduce getNumCapabilitiesBen Gamari2022-12-1632-122/+130
| | | | | | And ensure accesses to n_capabilities are atomic (although with relaxed ordering). This is necessary as RTS API callers may concurrently call into the RTS without holding a capability.
* Improve heap memory barrier NoteBen Gamari2022-12-165-105/+193
| | | | | Also introduce MUT_FIELD marker in Closures.h to document mutable fields.
* rts/stm: Fix memory ordering in readTVarIO#Ben Gamari2022-12-161-2/+1
| | | | See #22421.
* rts: Use fences instead of explicit barriersBen Gamari2022-12-165-31/+44
|
* Introduce SET_INFO_RELEASE for CmmBen Gamari2022-12-163-4/+3
|
* eventlog: Silence spurious data raceBen Gamari2022-12-161-1/+3
|
* rts/ThreadPaused: Ordering fixesBen Gamari2022-12-161-2/+2
|
* rts/Messages: RefactorBen Gamari2022-12-161-27/+20
| | | | This doesn't change behavior but makes the code a bit easier to follow.
* rts: Ensure that global regs are never passed as fun call argsBen Gamari2022-12-151-3/+3
| | | | | This is in general unsafe as they may be clobbered if they are mapped to caller-saved machine registers. See Note [Register parameter passing].
* codeGen: Introduce ThreadSanitizer instrumentationBen Gamari2022-12-153-0/+45
| | | | | | This introduces a new Cmm pass which instruments the program with ThreadSanitizer annotations, allowing full tracking of mutator memory accesses via TSAN.
* Fix bound thread statusLuite Stegeman2022-12-091-1/+1
|
* Add support for environments that don't have setImmediateLuite Stegeman2022-12-091-4/+13
|
* Delete `rts/package.conf.in`John Ericson2022-12-081-331/+0
| | | | | It is a relic of the Make build system. The RTS now uses a `package.conf` file generated the usual way by Cabal.
* Add initial support for LoongArch Architecture.lrzlin2022-12-086-1/+188
|
* Truncate eventlog event for large payload (#20221)Ian-Woo Kim2022-12-081-1/+11
| | | | | | | | | | | | | | RTS eventlog events for postCapsetVecEvent are truncated if payload is larger than EVENT_PAYLOAD_SIZE_MAX Previously, postCapsetVecEvent records eventlog event with payload of variable size larger than EVENT_PAYLOAD_SIZE_MAX (2^16) without any validation, resulting in corrupted data. For example, this happens when a Haskell binary is invoked with very long command line arguments exceeding 2^16 bytes (see #20221). Now we check the size of accumulated payload messages incrementally, and truncate the message just before the payload size exceeds EVENT_PAYLOAD_SIZE_MAX. RTS will warn the user with a message showing how many arguments are truncated.
* Add Javascript backendSylvain Henry2022-11-2927-554/+9416
| | | | | | | | | | | | | | | Add JS backend adapted from the GHCJS project by Luite Stegeman. Some features haven't been ported or implemented yet. Tests for these features have been disabled with an associated gitlab ticket. Bump array submodule Work funded by IOG. Co-authored-by: Jeffrey Young <jeffrey.young@iohk.io> Co-authored-by: Luite Stegeman <stegeman@gmail.com> Co-authored-by: Josh Meredith <joshmeredith2008@gmail.com>
* Move hs_mulIntMayOflo cbits to ghc-primCheng Shao2022-11-282-10/+0
| | | | | | It's only used by wasm NCG at the moment, but ghc-prim is a more reasonable place for hosting out-of-line primops. Also, we only need a single version of hs_mulIntMayOflo.
* rts: fix missing Arena.h symbols in RtsSymbols.cCheng Shao2022-11-241-0/+4
| | | | It was an unfortunate oversight in !8961 and broke devel2 builds.
* Fix eventlog all optionTeo Camarasu2022-11-231-0/+4
| | | | | | Previously it didn't enable/disable nonmoving_gc and ticky event types Fixes #21813
* Reveiew feedback: improve one of the TODO commentsDuncan Coutts2022-11-221-6/+14
| | | | | | The one about the nonsense (const False) test on WinIO for there being any IO or timers pending, leading to unnecessary complication later in the scheduler.
* Pass the Capability *cap explicitly to appendToIOBlockedQueueDuncan Coutts2022-11-223-18/+20
| | | | | | And to insertIntoSleepingQueue. Again, it's a bit cleaner and simpler though not strictly necessary given that these primops are currently only used in the non-threaded RTS.
* Pass the Capability *cap explicitly to awaitEventDuncan Coutts2022-11-224-30/+30
| | | | | | It is currently only used in the non-threaded RTS so it works to use MainCapability, but it's a bit nicer to pass the cap anyway. It's certainly shorter.
* Move the awaitEvent declaration into IOManager.hDuncan Coutts2022-11-225-35/+36
| | | | And add or adjust comments at the use sites of awaitEvent.
* Expand emptyThreadQueues inline for clarityDuncan Coutts2022-11-221-12/+4
| | | | | | | | It was not really adding anything. The name no longer meant anything since those I/O and timeout queues do not belong to the scheuler. In one of the two places it was used, the comments already had to explain what it did, whereas now the code matches the comment nicely.
* Replace EMPTY_{BLOCKED,SLEEPING}_QUEUE macros by functionDuncan Coutts2022-11-223-20/+36
| | | | | | | | | | | These are the macros originaly from Scheduler.h, previously moved to IOManager.h, and now replaced with a single inline function anyPendingTimeoutsOrIO(). We can use a single function since the two macros were always checked together. Note that since anyPendingTimeoutsOrIO is defined for all IO manager cases, including threaded, we do not need to guard its use by cpp #if !defined(THREADED_RTS)
* Move macros for checking for pending IO or timersDuncan Coutts2022-11-223-16/+29
| | | | | | | | | | | from Schedule.h to Schedule.c and IOManager.h This is just moving, the next step will be to rejig them slightly. For the non-threaded RTS the scheduler needs to be able to test for there being pending I/O operation or pending timers. The implementation of these tests should really be considered to be part of the I/O managers and not part of the scheduler.
* Remove the now-unused markSchedulerDuncan Coutts2022-11-225-13/+0
| | | | | The global vars {blocked,sleeping}_queue are now in the Capability and so get marked there via markCapabilityIOManager.
* Move {blocked,sleeping}_queue from scheduler global vars to CapIOManagerDuncan Coutts2022-11-227-64/+80
| | | | | | | | | | | | | | | | | | The blocked_queue_{hd,tl} and the sleeping_queue are currently cooperatively managed between the scheduler and (some but not all of) the non-threaded I/O manager implementations. They lived as global vars with the scheduler, but are poked by I/O primops and the I/O manager backends. This patch is a step on the path towards making the management of I/O or timer blocking belong to the I/O managers and not the scheduler. Specifically, this patch moves the {blocked,sleeping}_queue from being global vars in the scheduler to being members of the CapIOManager struct within each Capability. They are not yet exclusively used by the I/O managers: they are still poked from a couple other places, notably in the scheduler before calling awaitEvent.
* Move APPEND_TO_BLOCKED_QUEUE from cmm to CDuncan Coutts2022-11-224-51/+58
| | | | | | | | | | | | | | The I/O and delay blocking primitives for the non-threaded way currently access the blocked_queue and sleeping_queue directly. We want to move where those queues are to make their ownership clearer: to have them clearly belong to the I/O manager impls rather than to the scheduler. Ultimately we will want to change their representation too. It's inconvenient to do that if these queues are accessed directly from cmm code. So as a first step, replace the APPEND_TO_BLOCKED_QUEUE with a C version appendToIOBlockedQueue(), and replace the open-coded sleeping_queue insertion with insertIntoSleepingQueue().
* Add hook markCapabilityIOManagerDuncan Coutts2022-11-223-0/+17
| | | | | | | To allow I/O managers to have GC roots in the Capability, within the CapIOManager structure. Not yet used in this patch.
* Introduce CapIOManager as the per-cap I/O mangager stateDuncan Coutts2022-11-225-12/+60
| | | | | | | | | | | | | | | Rather than each I/O manager adding things into the Capability structure ad-hoc, we should have a common CapIOManager iomgr member of the Capability structure, with a common interface to initialise etc. The content of the CapIOManager struct will be defined differently for each I/O manager implementation. Eventually we should be able to have the CapIOManager be opaque to the rest of the RTS, and known just to the I/O manager implementation. We plan for that by making the Capability contain a pointer to the CapIOManager rather than containing the structure directly. Initially just move the Unix threaded I/O manager's control FD.
* base: make Foreign.Marshal.Pool use RTS internal arena for allocationCheng Shao2022-11-161-3/+3
| | | | | | | | | | | | | | | | | | `Foreign.Marshal.Pool` used to call `malloc` once for each allocation request. Each `Pool` maintained a list of allocated pointers, and traverses the list to `free` each one of those pointers. The extra O(n) overhead is apparently bad for a `Pool` that serves a lot of small allocation requests. This patch uses the RTS internal arena to implement `Pool`, with these benefits: - Gets rid of the extra O(n) overhead. - The RTS arena is simply a bump allocator backed by the block allocator, each allocation request is likely faster than a libc `malloc` call. Closes #14762 #18338.
* eventlog: Ensure that IPE output contains actual info table pointersBen Gamari2022-11-142-1/+5
| | | | | | | | | The refactoring in 866c736e introduced a rather subtle change in the semantics of the IPE eventlog output, changing the eventlog field from encoding info table pointers to "TNTC pointers" (which point to entry code when tables-next-to-code is enabled). Fix this. Fixes #22452.
* rts: Check for program_invocation_short_name via autoconfBen Gamari2022-11-111-1/+1
| | | | Instead of assuming support on all Linuxes.
* rts: wasm32 specific logicCheng Shao2022-11-117-0/+214
| | | | This patch adds the rest of wasm32 specific logic in rts.