summaryrefslogtreecommitdiff
path: root/rts
Commit message (Collapse)AuthorAgeFilesLines
* rts: Unify stack dirtiness checkBen Gamari2021-10-022-6/+6
| | | | | | This fixes an inconsistency where one dirtiness check would not mask out the STACK_DIRTY flag, meaning it may also be affected by the STACK_SANE flag.
* rts: Add missing write barriers in MVar wake-up pathsBen Gamari2021-10-022-12/+37
| | | | | | | | | | | Previously PerformPut failed to respect the non-moving collector's snapshot invariant, hiding references to an MVar and its new value by overwriting a stack frame without dirtying the stack. Fix this. PerformTake exhibited a similar bug, failing to dirty (and therefore mark) the blocked stack before mutating it. Closes #20399.
* Fix comment typosKirill Zaborsky2021-09-291-2/+2
|
* Remove special case for large objects in allocateForCompactFabian Thorand2021-09-291-11/+0
| | | | | | | | | | | | | | | | | | | | | | | | allocateForCompact() is called when the current allocation for the compact region does not fit in the nursery. It previously had a special case for objects exceeding the large object threshold. In that case, it would allocate a new compact region block just for that object. That led to a lot of small blocks being allocated in compact regions with a larger default block size (`autoBlockW`). This commit removes this special case because having a lot of small compact region blocks contributes significantly to memory fragmentation. The removal should be valid because - a more generic case for allocating a new compact region block follows at the end of allocateForCompact(), and that one takes `autoBlockW` into account - the reason for allocating separate blocks for large objects in the main heap seems to be to avoid copying during GCs, but once inside the compact region, the object will never be copied anyway. Fixes #18757. A regression test T18757 was added.
* rts: Ensure that headers don't refer to undefined __STDC_VERSION__Ben Gamari2021-09-231-0/+6
| | | | | | | | | Previously the C/C++ language version check in STG could throw an undefined macro warning due to __STDC_VERSION__ when compiled with a C++ compiler. Fix this by defining __STDC_VERSION__==0 when compiling with a C++ compiler. Fixes #20394.
* configure: Clarify meaning of CabalHaveLibffiBen Gamari2021-09-232-4/+2
| | | | | Previously the meaning of this flag was unclear and as a result I suspect that CabalHaveLibffi could be incorrectly False.
* Use Info Table Provenances to decode cloned stack (#18163)Sven Tennie2021-09-237-24/+137
| | | | | | | | | | | | | | | | Emit an Info Table Provenance Entry (IPE) for every stack represeted info table if -finfo-table-map is turned on. To decode a cloned stack, lookupIPE() is used. It provides a mapping between info tables and their source location. Please see these notes for details: - [Stacktraces from Info Table Provenance Entries (IPE based stack unwinding)] - [Mapping Info Tables to Source Positions] Metric Increase: T12545
* Introduce stack snapshotting / cloning (#18741)Sven Tennie2021-09-2310-1/+165
| | | | | | | | | | | | | | Add `StackSnapshot#` primitive type that represents a cloned stack (StgStack). The cloning interface consists of two functions, that clone either the treads own stack (cloneMyStack) or another threads stack (cloneThreadStack). The stack snapshot is offline/cold, i.e. it isn't evaluated any further. This is useful for analyses as it prevents concurrent modifications. For technical details, please see Note [Stack Cloning]. Co-authored-by: Ben Gamari <bgamari.foss@gmail.com> Co-authored-by: Matthew Pickering <matthewtpickering@gmail.com>
* Link with libm dynamically (#19877)Sylvain Henry2021-09-221-0/+1
| | | | The compiler should be independent of the target.
* Update error message to suggest the user consider OOM over RTS bug.Thomas M. DuBuisson2021-09-171-1/+3
| | | | Fix #17039
* rts: Factor out TRACE_ cache update logicBen Gamari2021-09-081-8/+18
| | | | Just a small refactoring to perhaps enable code reuse later.
* hadrian: Ensure that settings is regenerated during bindist installationBen Gamari2021-09-071-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | Previously Hadrian would simply install the settings file generated in the build environment during the binary distribution installation. This is wrong since these environments may differ (e.g. different `cc` versions). We noticed on Darwin when installation of a binary distribution produced on a newer Darwin release resulted in a broken compiler due to the installed `settings` file incorrectly claiming that `cc` supported `-no-pie`. Fixing this sadly requires a bit of code duplication since `settings` is produced by Hadrian and not `configure`. For now I have simply duplicated the `settings` generation logic used by the Make build system into Hadrian's bindist Makefile. Ultimately the solution will probably involve shipping a freestanding utility to replace `configure`'s toolchain probing logic and generate a toolchain description file (similar to `settings`) as described in #19877. Fixes #20253.
* Add -Wl,-U,___darwin_check_fd_set_overflow to rts/package.conf.inMatthew Pickering2021-08-191-0/+4
| | | | | | | | | The make build system apparently uses this special package.conf rather than generating it from the cabal file. Ticket: #19950 (cherry picked from commit e316a0f3e7a733fac0c30633767487db086c4cd0)
* Optimize Info Table Provenance Entries (IPEs) Map creation and lookupSven Tennie2021-08-116-57/+199
| | | | | | | | | | | | | | | Using a hash map reduces the complexity of lookupIPE(), making it non linear. On registration each IPE list is added to a temporary IPE lists buffer, reducing registration time. The hash map is built lazily on first lookup. IPE event output to stderr is added with tests. For details, please see Note [The Info Table Provenance Entry (IPE) Map]. A performance test for IPE registration and lookup can be found here: https://gitlab.haskell.org/ghc/ghc/-/merge_requests/5724#note_370806
* Move `/includes` to `/rts/include`, sort per package betterJohn Ericson2021-08-0986-20/+12173
| | | | | | | | | | | | | | | | | | | | | | | | | | | In order to make the packages in this repo "reinstallable", we need to associate source code with a specific packages. Having a top level `/includes` dir that mixes concerns (which packages' includes?) gets in the way of this. To start, I have moved everything to `rts/`, which is mostly correct. There are a few things however that really don't belong in the rts (like the generated constants haskell type, `CodeGen.Platform.h`). Those needed to be manually adjusted. Things of note: - No symlinking for sake of windows, so we hard-link at configure time. - `CodeGen.Platform.h` no longer as `.hs` extension (in addition to being moved to `compiler/`) so as not to confuse anyone, since it is next to Haskell files. - Blanket `-Iincludes` is gone in both build systems, include paths now more strictly respect per-package dependencies. - `deriveConstants` has been taught to not require a `--target-os` flag when generating the platform-agnostic Haskell type. Make takes advantage of this, but Hadrian has yet to.
* Make `PosixSource.h` installed and under `rts/`John Ericson2021-08-0990-135/+97
| | | | | | is used outside of the rts so we do this rather than just fish it out of the repo in ad-hoc way, in order to make packages in this repo more self-contained.
* rts: Fix use of sized array in Heap.hBen Gamari2021-08-091-2/+2
| | | | | | Sized arrays cannot be used in headers that might be imported from C++. Fixes #20199.
* Fix ASSERTS_ENABLED CPPSylvain Henry2021-08-031-1/+1
|
* rts/OSThreads: Fix reference clock of timedWaitConditionBen Gamari2021-08-021-12/+33
| | | | | | | | | | | | | | | Previously `timedWaitCondition` assumed that timeouts were referenced against `CLOCK_MONOTONIC`. This is wrong; by default `pthread_cond_timedwait` references against `CLOCK_REALTIME`, although this can be overridden using `pthread_condattr_setclock`. Fix this and add support for using `CLOCK_MONOTONIC` whenever possible as it is more robust against system time changes and is likely cheaper to query. Unfortunately, this is complicated by the fact that older versions of Darwin did not provide `clock_gettime`, which means we also need to introduce a fallback path using `gettimeofday`. Fixes #20144.
* PrimOps: Add CAS op for all int sizesPeter Trommler2021-08-024-6/+58
| | | | | | | | | | | PPC NCG: Implement CAS inline for 32 and 64 bit testsuite: Add tests for smaller atomic CAS X86 NCG: Catch calls to CAS C fallback Primops: Add atomicCasWord[8|16|32|64]Addr# Add tests for atomicCasWord[8|16|32|64]Addr# Add changelog entry for new primops X86 NCG: Fix MO-Cmpxchg W64 on 32-bit arch ghc-prim: 64-bit CAS C fallback on all archs
* Add configure flag to enable ASSERTs in all waysDaniel Gröber2021-07-294-5/+4
| | | | | | | | Running the test suite with asserts enabled is somewhat tricky at the moment as running it with a GHC compiled the DEBUG way has some hundred failures from the start. These seem to be unrelated to assertions though. So this provides a toggle to make it easier to debug failing assertions using the test suite.
* rts: Allow building with ASSERTs on in non-DEBUG wayDaniel Gröber2021-07-293-8/+2
| | | | | | | | | | We have a couple of places where the conditions in asserts depend on code ifdefed out when DEBUG is off. I'd like to allow compiling assertions into non-DEBUG RTSen so that won't do. Currently if we remove the conditional around the definition of ASSERT() the build will not actually work due to a deadlock caused by initMutex not initializing mutexes with PTHREAD_MUTEX_ERRORCHECK because DEBUG is off.
* rts: Don't rely on configuration when CLEANING=YESBen Gamari2021-07-281-0/+4
| | | | | | | | The make build system doesn't source config.mk when CLEANING=YES, consequently we previously failed to identify an appropriate adjustor implementation to use during cleaning. Fixes #20166.
* rts/OSThreads: Improve error handling consistencyBen Gamari2021-07-272-20/+29
| | | | | | | | | | | | Previously we relied on the caller to check the return value from broadcastCondition and friends, most of whom neglected to do so. Given that these functions should not fail anyways, I've opted to drop the return value entirely and rather move the result check into the OSThreads functions. This slightly changes the semantics of timedWaitCondition which now returns false only in the case of timeout, rather than any error as previously done.
* Use pthread if available on linuxAndreas Klebinger2021-07-271-4/+2
|
* Rename itimer to ticker in rts/posix for consistency.Andreas Klebinger2021-07-276-23/+26
|
* rts: Don't declare libCffi as bundled when using system libffiBen Gamari2021-07-271-4/+10
| | | | | Previously the rts's cabal file would claim that it bundled libffi, even if we are using the system's libffi. Fixes #19869.
* rts: Drop allocateExec and friendsBen Gamari2021-07-272-103/+0
| | | | All uses of these now use ExecPage.
* rts: Introduce and use ExecPage abstractionBen Gamari2021-07-2710-70/+96
| | | | | Here we introduce a very thin abstraction for allocating, filling, and freezing executable pages to replace allocateExec.
* rts/adjustor: Drop redundant commmentsBen Gamari2021-07-275-15/+0
|
* rts: Break up adjustor logicBen Gamari2021-07-2711-1302/+1509
|
* rts: Move libffi interfaces all to AdjustorBen Gamari2021-07-272-90/+51
| | | | | | | Previously the libffi Adjustor implementation would use allocateExec to create executable mappings. However, allocateExec is also used elsewhere in GHC to allocate things other than ffi_closure, which is a use-case which libffi does not support.
* rts: Document CPP guardsBen Gamari2021-07-271-10/+10
|
* RTS: try to fix timer racesSylvain Henry2021-07-262-2/+5
| | | | | | | | | | | | | | | | | | * Pthread based timer was initialized started while some other parts of the RTS assume it is initialized stopped, e.g. in hs_init_ghc: /* Start the "ticker" and profiling timer but don't start until the * scheduler is up. However, the ticker itself needs to be initialized * before the scheduler to ensure that the ticker mutex is initialized as * moreCapabilities will attempt to acquire it. */ * after a fork, don't start the timer before the IOManager is initialized: the timer handler (handle_tick) might call wakeUpRts to perform an idle GC, which calls wakeupIOManager/ioManagerWakeup Found while debugging #18033/#20132 but I couldn't confirm if it fixes them.
* [rts] Untag bq->bh prior to reading the info tableMoritz Angermann2021-07-251-1/+12
| | | | | | | | | | | | | | | | | In `checkBlockingQueues` we must always untag the `bh` field of an `StgBlockingQueue`. While at first glance it might seem a sensible assumption that `bh` will always be a blackhole and therefore never be tagged, the GC could shortcut the indirection and put a tagged pointer into the indirection. This blew up on aarch64-darwin with a misaligned access. `bh` pointed to an address that always ended in 0xa. On architectures that are a little less strict about alignment, this would have read a garbage info table pointer, which very, very unlikely would have been equal to `stg_BLACKHOLE_info` and therefore things accidentally worked. However, on AArch64, the read of the info table pointer resulted in a SIGBUS due to misaligned read. Fixes #20093.
* Support unlifted datatypes in GHCiLuite Stegeman2021-07-021-19/+34
| | | | fixes #19628
* Fix libffi on PowerPCPeter Trommler2021-06-281-13/+3
| | | | | | | | | Update submodule libffi-tarballs to upstream commit 4f9e20a. Remove C compiler flags that suppress warnings in the RTS. Those warnings have been fixed by libffi upstream. Fixes #19885
* rts: Eliminate redundant branchGHC GitLab CI2021-06-261-3/+1
| | | | | | Previously we branched unnecessarily on IF_NONMOVING_WRITE_BARRIER_ENABLED on every trip through the array barrier push loop.
* [aarch64-macho] Fix off-by-one error in the linkerMoritz Angermann2021-06-241-1/+11
| | | | | | We need to be careful about the sign bit for BR26 relocation otherwise we end up encoding a large positive number and reading back a large negative number.
* rts: move xxxHash out of the user namespaceTamar Christina2021-06-243-3/+23
|
* rts: Document --eventlog-flush-interval in RtsFlagsMatthew Pickering2021-06-221-0/+1
| | | | Fixes #19995
* rts: Pass -Wl,_U,___darwin_check_fd_set_overflow on DarwinMatthew Pickering2021-06-201-0/+42
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Note [fd_set_overflow] ~~~~~~~~~~~~~~~~~~~~~~ In this note is the very sad tale of __darwin_fd_set_overflow. The 8.10.5 release was broken because it was built in an environment where the libraries were provided by XCode 12.*, these libraries introduced a reference to __darwin_fd_set_overflow via the FD_SET macro which is used in Select.c. Unfortunately, this symbol is not available with XCode 11.* which led to a linker error when trying to link anything. This is almost certainly a bug in XCode but we still have to work around it. Undefined symbols for architecture x86_64: "___darwin_check_fd_set_overflow", referenced from: _awaitEvent in libHSrts.a(Select.o) ld: symbol(s) not found for architecture x86_64 One way to fix this is to upgrade your version of xcode, but this would force the upgrade on users prematurely. Fortunately it also seems safe to pass the linker option "-Wl,-U,___darwin_check_fd_set_overflow" because the usage of the symbol is guarded by a guard to check if it's defined. __header_always_inline int __darwin_check_fd_set(int _a, const void *_b) { if ((uintptr_t)&__darwin_check_fd_set_overflow != (uintptr_t) 0) { return __darwin_check_fd_set_overflow(_a, _b, 1); return __darwin_check_fd_set_overflow(_a, _b, 0); } else { return 1; } Across the internet there are many other reports of this issue See: https://github.com/mono/mono/issues/19393 , https://github.com/sitsofe/fio/commit/b6a1e63a1ff607692a3caf3c2db2c3d575ba2320 The issue was originally reported in #19950 Fixes #19950
* Guard Allocate Exec via LIBFFI by LIBFFIMoritz Angermann2021-06-201-1/+1
| | | | | | | | | | | | We now have two darwin flavours. AArch64-Darwin, and x86_64-darwin, the latter one which has proper custom adjustor support, the former though relies on libffi. Mixing both leads to odd crashes, as the closures might not fit the size of the libffi closures. Hence this needs to be guarded by the USE_LBFFI_FOR_ADJUSTORS guard. Original patch by Hamish Mackenzie
* RTS: Fix flag parsing for --eventlog-flush-intervalMatthew Pickering2021-06-191-2/+2
| | | | Fixes #20006
* RTS: fix indentation warningSylvain Henry2021-06-191-12/+14
|
* Adds AArch64 Native Code GeneratorMoritz Angermann2021-06-052-3/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In which we add a new code generator to the Glasgow Haskell Compiler. This codegen supports ELF and Mach-O targets, thus covering Linux, macOS, and BSDs in principle. It was tested only on macOS and Linux. The NCG follows a similar structure as the other native code generators we already have, and should therfore be realtively easy to follow. It supports most of the features required for a proper native code generator, but does not claim to be perfect or fully optimised. There are still opportunities for optimisations. Metric Decrease: ManyAlternatives ManyConstructors MultiLayerModules PmSeriesG PmSeriesS PmSeriesT PmSeriesV T10421 T10421a T10858 T11195 T11276 T11303b T11374 T11822 T12227 T12545 T12707 T13035 T13253 T13253-spj T13379 T13701 T13719 T14683 T14697 T15164 T15630 T16577 T17096 T17516 T17836 T17836b T17977 T17977b T18140 T18282 T18304 T18478 T18698a T18698b T18923 T1969 T3064 T5030 T5321FD T5321Fun T5631 T5642 T5837 T783 T9198 T9233 T9630 T9872d T9961 WWRec Metric Increase: T4801
* Put Unique related global variables in the RTS (#19940)Sylvain Henry2021-06-052-0/+5
|
* Work around LLVM backend overlapping register limitationsLuite Stegeman2021-05-292-84/+18
| | | | | | | | The stg_ctoi_t and stg_ret_t procedures which convert unboxed tuples between the bytecode an native calling convention were causing a panic when using the LLVM backend. Fixes #19591
* rts: Remove trailing whitespace from Adjustor.cMatthew Pickering2021-05-111-32/+32
|
* rts: Correctly call pthread_setname_np() on NetBSDPHO2021-05-073-5/+17
| | | | | | NetBSD supports pthread_setname_np() but it expects a printf-style format string and a string argument. Also use pthread for itimer on this platform.