summaryrefslogtreecommitdiff
path: root/rts
Commit message (Collapse)AuthorAgeFilesLines
* Typos [ci skip]Gabor Greif2017-02-152-2/+2
|
* Fix ExtraSymbols jump table on Windows.Tamar Christina2017-02-141-16/+21
| | | | | | | | | | | | | | | | | | | This corrects the `jump islands` calculations for Windows. The code was incorrectly creating a new entry for every `usage` of a symbol instead of every used symbol. e.g. if a symbol is used 5 times it used to create 5 jump islands. This is incorrect and not in line with what the `ELF` and `Mach-O` linkers do. Also since we allocate `n` spaces where `n` is number of symbols, we would quickly run out of space and abort. Test Plan: ./validate Reviewers: simonmar, hvr, erikd, bgamari, austin Reviewed By: bgamari Subscribers: thomie, #ghc_windows_task_force Differential Revision: https://phabricator.haskell.org/D3026
* Expand list of always loaded Windows shared libsTamar Christina2017-02-141-0/+6
| | | | | | | | | | | | | | | | | | | | | | | | When the `GCC` driver envokes the pipeline a `SPEC` is used to determine how to configure the compiler and which libraries to pass along. For Windows/mingw, this specfile is https://github.com/gcc-mirror/gcc/blob/master/gcc/config/i386/mingw32.h This expands the list of base DLLs with the ones that GCC always links, and adds extra sibling dlls of `stdc++` in case it is linked in. Following D3028 this patch only needs to load the always load only the top level individual shared libs. Test Plan: ./validate Reviewers: RyanGlScott, austin, bgamari, erikd, simonmar Reviewed By: bgamari Subscribers: RyanGlScott, thomie, #ghc_windows_task_force Differential Revision: https://phabricator.haskell.org/D3029
* Typecast covers entire expression to fix format warning.bollu2017-02-141-10/+15
| | | | | | | | | | | | | | - Fixes (#12636). - changes all the typecasts to _unsinged long long_ to have the format specifiers work. Reviewers: austin, bgamari, erikd, simonmar, Phyx Reviewed By: erikd, Phyx Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D3129
* Apply SplitSections to all C compilationsSimon Brenner2017-02-111-4/+0
| | | | | | | | | | | | | | | | | | | Previously this was added only to the RTS's C files (those are the bulk of it though), but there are C bits in ghc-prim, integer-gmp and base too. Followup for #8405, allows the large table of character properties in base to be stripped when not used. Test Plan: validate Reviewers: austin, bgamari, simonmar Reviewed By: bgamari Subscribers: thomie, snowleopard Differential Revision: https://phabricator.haskell.org/D3121
* rts/Profiling: Factor out report generationBen Gamari2017-02-114-318/+374
| | | | | | | | | | | | | | | | | | | | | Here we move the actual report generation logic to `rts/ProfilerReport.c`. This break is actually quite clean, void writeCCSReport( FILE *prof_file, CostCentreStack const *ccs, ProfilerTotals totals ); This is more profiler refactoring in preparation for machine-readable output. Test Plan: Validate Reviewers: austin, erikd, simonmar Reviewed By: simonmar Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D3097
* rts/Profiling: Kill a few globals and add constsBen Gamari2017-02-112-51/+70
| | | | | | | | | | | | | | | | | | | Previously it was quite difficult to follow the dataflow through this file due to global mutation and rather non-descriptive types. This is a cleanup in preparation for factoring out the report-generating logic, which is itself in preparation for somedayteaching the profiler to produce more machine-readable reports (JSON perhaps?). Test Plan: Validate Reviewers: austin, erikd, simonmar Reviewed By: simonmar Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D3096
* Spelling in comments [ci skip]Gabor Greif2017-02-101-1/+1
|
* Fix stop_thread unwinding informationBen Gamari2017-02-082-8/+12
| | | | | | | | | | | | | | | | This corrects the unwind information for `stg_stop_thread`, which allows us to unwind back to the C stack after reaching the end of the STG stack. Test Plan: Validate Reviewers: simonmar, austin, erikd Reviewed By: simonmar Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D2746
* Cmm: Add support for undefined unwinding statementsBen Gamari2017-02-081-0/+2
| | | | | | | | | | | | | | And use to mark `stg_stack_underflow_frame`, which we are unable to determine a caller from. To simplify parsing at the moment we steal the `return` keyword to indicate an undefined unwind value. Perhaps this should be revisited. Reviewers: scpmw, simonmar, austin, erikd Subscribers: dfeuer, thomie Differential Revision: https://phabricator.haskell.org/D2738
* Generalize CmmUnwind and pass unwind information through NCGBen Gamari2017-02-081-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | As discussed in D1532, Trac Trac #11337, and Trac Trac #11338, the stack unwinding information produced by GHC is currently quite approximate. Essentially we assume that register values do not change at all within a basic block. While this is somewhat true in normal Haskell code, blocks containing foreign calls often break this assumption. This results in unreliable call stacks, especially in the code containing foreign calls. This is worse than it sounds as unreliable unwinding information can at times result in segmentation faults. This patch set attempts to improve this situation by tracking unwinding information with finer granularity. By dispensing with the assumption of one unwinding table per block, we allow the compiler to accurately represent the areas surrounding foreign calls. Towards this end we generalize the representation of unwind information in the backend in three ways, * Multiple CmmUnwind nodes can occur per block * CmmUnwind nodes can now carry unwind information for multiple registers (while not strictly necessary; this makes emitting unwinding information a bit more convenient in the compiler) * The NCG backend is given an opportunity to modify the unwinding records since it may need to make adjustments due to, for instance, native calling convention requirements for foreign calls (see #11353). This sets the stage for resolving #11337 and #11338. Test Plan: Validate Reviewers: scpmw, simonmar, austin, erikd Subscribers: qnikst, thomie Differential Revision: https://phabricator.haskell.org/D2741
* Fix comment (old file names) in rts/Takenobu Tani2017-02-047-8/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | [skip ci] There ware some old file names (.lhs, ...) at comments. * rts/win32/ThrIOManager.c - Conc.lhs -> Conc.hs * rts/PrimOps.cmm - ByteCodeLink.lhs -> ByteCodeLink.hs - StgMiscClosures.hc -> StgMiscClosures.cmm * rts/AutoApply.h - AutoApply.hc -> AutoApply.cmm * rts/HeapStackCheck.cmm - PrimOps.hc -> PrimOps.cmm * rts/LdvProfile.h - Updates.hc -> Updates.cmm * rts/Schedule.c - StgStartup.hc -> StgStartup.cmm * rts/Weak.c - StgMiscClosures.hc -> StgMiscClosures.cmm Reviewers: bgamari, austin, erikd, simonmar Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D3075
* Ditch static flagsSylvain Henry2017-02-021-2/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | This patch converts the 4 lasting static flags (read from the command line and unsafely stored in immutable global variables) into dynamic flags. Most use cases have been converted into reading them from a DynFlags. In cases for which we don't have easy access to a DynFlags, we read from 'unsafeGlobalDynFlags' that is set at the beginning of each 'runGhc'. It's not perfect (not thread-safe) but it is still better as we can set/unset these 4 flags before each run when using GHC API. Updates haddock submodule. Rebased and finished by: bgamari Test Plan: validate Reviewers: goldfire, erikd, hvr, austin, simonmar, bgamari Reviewed By: simonmar Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D2839 GHC Trac Issues: #8440
* Add support for StaticPointers in GHCiBen Gamari2017-02-022-4/+9
| | | | | | | | | | | | | | | | | | | | | Here we add support to GHCi for StaticPointers. This process begins by adding remote GHCi messages for adding entries to the static pointer table. We then collect binders needing SPT entries after linking and send the interpreter a message adding entries with the appropriate fingerprints. Test Plan: `make test TEST=StaticPtr` Reviewers: facundominguez, mboes, simonpj, simonmar, goldfire, austin, hvr, erikd Reviewed By: simonpj, simonmar Subscribers: RyanGlScott, simonpj, thomie Differential Revision: https://phabricator.haskell.org/D2504 GHC Trac Issues: #12356
* Abstract over the way eventlogs are flushedalexbiehl2017-01-315-81/+194
| | | | | | | | | | | | | | | | | | | | Currently eventlog data is always written to a file `progname.eventlog`. This patch introduces the `flushEventLog` field in `RtsConfig` which allows to customize the writing of eventlog data. One possible scenario is the ongoing live-profile-monitor effort by @NCrashed which slurps all eventlog data through `fluchEventLog`. `flushEventLog` takes a buffer with eventlog data and its size and returns `false` (0) in case eventlog data could not be procesed. Reviewers: simonmar, austin, erikd, bgamari Reviewed By: simonmar, bgamari Subscribers: qnikst, thomie, NCrashed Differential Revision: https://phabricator.haskell.org/D2934
* Slighly clean up symbol loading error.Tamar Christina2017-01-302-3/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The symbol not found error that is triggered during lazy-loading was a bit chaotic before. This reformats it a bit to: ``` ghc-stage2.exe: | E:\...\libLLVMSupport.a: unknown symbol `_ZN4llvm5APIntC1Ejyb' ghc-stage2.exe: | E:\...\libLLVMCore.a: unknown symbol `_ZN4llvm5APInt14AssignSlowCaseERKS0_' ghc-stage2.exe: | E:\...\libLLVMCore.a: unknown symbol `_ZN4llvm13ConstantRangeC1ENS_5APIntES1_' ghc-stage2.exe: | E:\...\libLLVMCore.a: unknown symbol `_ZN4llvm14FoldingSetImplC2Ej' ghc-stage2.exe: | E:\...\libLLVMCore.a: unknown symbol `_ZN4llvm15LLVMContextImplD1Ev' ghc-stage2.exe: | E:\...\libLLVMLTO.a: unknown symbol `_ZN4llvm11LLVMContextD1Ev' ghc-stage2.exe: | E:\...\libLLVMCore.a: unknown symbol `_ZNK4llvm5Value10getContextEv' ghc-stage2.exe: ^^ Could not load 'LLVMIsMultithreaded', dependency unresolved. See top entry above. ``` I have also thought about also showing the demangled names, as it may be useful for the end user. `libgcc` seems to provide a method for this so we wouldn't need any extra dependency. Any thoughts on this or would it not be useful? Reviewers: austin, erikd, simonmar, bgamari Reviewed By: bgamari Subscribers: RyanGlScott, thomie, #ghc_windows_task_force Differential Revision: https://phabricator.haskell.org/D3027 GHC Trac Issues: #13093, #13113
* Fatal if we try to reinitialize the RTSSimon Marlow2017-01-261-0/+6
| | | | | | | | | | | | | | | This isn't supported, and fatalling with an error is better than segfaulting later. Test Plan: validate Reviewers: JonCoens, austin, erikd, niteria, bgamari Reviewed By: niteria, bgamari Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D3020
* Clean up RTS Linker Windows.Tamar Christina2017-01-182-356/+263
| | | | | | | | | | | | | | | | | | | | | | Clean up the linker code for PE. 1. Stop copying structures from the windows header and use those that are in the headers. There's no point in copying them and we got a few types wrong. 2. Replace custom typedef with C99 types. If we're not going to use the Windows type aliases, at least use standard ones. Test Plan: ./validate Reviewers: simonmar, austin, erikd, bgamari Reviewed By: simonmar, bgamari Subscribers: dfeuer, thomie, #ghc_windows_task_force Differential Revision: https://phabricator.haskell.org/D2944
* Spelling fixes in comments [ci skip]Gabor Greif2017-01-181-1/+1
|
* Unbreak libGHCi by adding missing symbol.Tamar Christina2017-01-161-0/+1
| | | | | | | | | | | | | | | | Summary: Someone committed a new public symbol `purgeObj` again without adding it to the symbols table. Test Plan: ./validate Reviewers: austin, bgamari, simonmar, erikd Reviewed By: erikd Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D2980
* Improve access violation reporting on WindowsRyan Scott2017-01-151-1/+7
| | | | | | | | | | | | | | | | | | | | | | | | | Summary: This patch is courtesy of @awson. Currently, whenever GHC catches a segfault on Windows, it simply reports the somewhat uninformative message `Segmentation fault/access violation in generated code`. This patch adds to the message the type of violation (read/write/dep) and location information, which should help debugging segfaults in the future. Fixes #13108. Test Plan: Build on Windows Reviewers: austin, erikd, bgamari, simonmar, Phyx Reviewed By: bgamari, Phyx Subscribers: awson, thomie, #ghc_windows_task_force Differential Revision: https://phabricator.haskell.org/D2969 GHC Trac Issues: #13108
* Fix abort and import lib search on WindowsTamar Christina2017-01-151-2/+3
| | | | | | | | | | | | | | | | | | | | | | Summary: Apparently `sysErrorBelch` doesn't terminate the program anymore making previously unreachable code now execute. If a dll is not found the error message we return needs to be a heap value. Secondly also allow the pattern `lib<name>` to be allowed for finding an import library with the name `lib<name>.dll.a`. Test Plan: ./validate, new tests T13082_good and T13082_fail Reviewers: austin, RyanGlScott, hvr, erikd, simonmar, bgamari Reviewed By: RyanGlScott, bgamari Subscribers: thomie, #ghc_windows_task_force Differential Revision: https://phabricator.haskell.org/D2941 GHC Trac Issues: #13082
* Typos in commentsGabor Greif2017-01-131-1/+1
|
* Throw an exception on heap overflowDemi Obenour2017-01-106-25/+164
| | | | | | | | | | | | | | | | | This changes heap overflow to throw a HeapOverflow exception instead of killing the process. Test Plan: GHC CI Reviewers: simonmar, austin, hvr, erikd, bgamari Reviewed By: simonmar, bgamari Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D2790 GHC Trac Issues: #1791
* More fixes for #5654Simon Marlow2017-01-065-7/+113
| | | | | | | | | | | | | | * In stg_ap_0_fast, if we're evaluating a thunk, the thunk might evaluate to a function in which case we may have to adjust its CCS. * The interpreter has its own implementation of stg_ap_0_fast, so we have to do the same shenanigans with creating empty PAPs and copying PAPs there. * GHCi creates Cost Centres as children of CCS_MAIN, which enterFunCCS() wrongly assumed to imply that they were CAFs. Now we use the is_caf flag for this, which we have to correctly initialise when we create a Cost Centre in GHCi.
* Testsuite: Skip failing tests on PowerPC 64-bitPeter Trommler2016-12-272-7/+17
| | | | | | | | | | | | | | | | | | | The Power ISA says the result of a division by zero is undefined. So ignore stdout on PowerPC 64-bit systems. Disable ext-interp tests on 64-bit PowerPC. We don't have support for PowerPC 64-bit ELF in the RTS linker, which is needed for the external interpreter. Test Plan: ./validate Reviewers: austin, simonmar, hvr, erikd, bgamari Reviewed By: bgamari Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D2782
* Define MAP_ANONYMOUS on systems that only provide MAP_ANONGracjan Polak2016-12-232-5/+10
| | | | | | | | | | | | Reviewers: simonmar, erikd, austin, bgamari Reviewed By: bgamari Subscribers: gracjan, rwbarton, thomie Differential Revision: https://phabricator.haskell.org/D2881 GHC Trac Issues: #13005
* Fix bug in previous fix for #5654Simon Marlow2016-12-171-4/+9
| | | | | | | | | | | | | | | | | | | | | | | | | I forgot to account for BCOs, which have a different layout from functions. This caused crashes when using profiling with GHCi (via -fexternal-interpreter -prof), which unfortunately is not tested at all by validate, even when profiling is enabled. I'm going to add some testing that would have caught this in a separate patch. Test Plan: ``` cd nofib/spectral/puzzle && make NoFibWithGHCi=YES EXTRA_RUNTEST_OPTS='-fexternal-interpreter -prof' ``` New testsuite tests coming in a separate diff. Reviewers: niteria, austin, erikd, bgamari Reviewed By: bgamari Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D2868 GHC Trac Issues: #5654
* rts/win32/IOManager: Fix integer typesBen Gamari2016-12-174-27/+27
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This code has been broken on 64-bit systems for some time: the length and timeout arguments of `addIORequest` and `addDelayRequest`, respectively, were declared as `int`. However, they were passed Haskell integers from their respective primops. Integer overflow and madness ensued. This resulted in #7325 and who knows what else. Also, there were a few left-over `BOOL`s in here which were not passed to Windows system calls; these were changed to C99 `bool`s. However, there is still a bit of signedness inconsistency within the `delay#` call-chain, * `GHC.Conc.IO.threadDelay` and the `delay#` primop accept `Int` arguments * The `delay#` implementation in `PrimOps.cmm` expects the timeout as a `W_` * `AsyncIO.c:addDelayRequest` expects an `HsInt` (was `int` prior to this patch) * `IOManager.c:AddDelayRequest` expects an `HsInt`` (was `int`) * The Windows `Sleep` function expects a `DWORD` (which is unsigned) Test Plan: Validate on Windows Reviewers: erikd, austin, simonmar, Phyx Reviewed By: Phyx Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D2861 GHC Trac Issues: #7325
* rts/Compact.cmm: fix UNREG build failureSergei Trofimovich2016-12-171-54/+55
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | The change does the following: - Add explicit declaration of exception closures from base. C backend needs those symbols to be visible. - Reorder cmm functions in use order. Again C backend needs symbol declaration/definition before use. even for module-local cmm functions. Fixes the following build failure: rts_dist_HC rts/dist/build/Compact.o In file included from /tmp/ghc3348_0/ghc_4.hc:3:0: error: /tmp/ghc3348_0/ghc_4.hc: In function 'stg_compactAddWithSharingzh': /tmp/ghc3348_0/ghc_4.hc:27:11: error: error: 'stg_compactAddWorkerzh' undeclared (first use in this function) JMP_((W_)&stg_compactAddWorkerzh); ^ ... /tmp/ghc3348_0/ghc_4.hc:230:13: error: error: 'base_GHCziIOziException_cannotCompactMutable_closure' undeclared (first use in this function) R1.w = (W_)&base_GHCziIOziException_cannotCompactMutable_closure; ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Signed-off-by: Sergei Trofimovich <siarheit@google.com>
* Fix cost-centre-stacks bug (#5654)Simon Marlow2016-12-151-0/+107
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This fixes some cases of wrong stacks being generated by the profiler. For background and details on the fix see `Note [Evaluating functions with profiling]` in `rts/Apply.cmm`. This does have an impact on allocations for some programs when profiling. nofib results: ``` k-nucleotide +0.0% +8.8% +11.0% +11.0% 0.0% puzzle +0.0% +12.5% 0.244 0.246 0.0% typecheck 0.0% +8.7% +16.1% +16.2% 0.0% ------------------------------------------------------------------------ -------- Min -0.0% -0.0% -34.4% -35.5% -25.0% Max +0.0% +12.5% +48.9% +49.4% +10.6% Geometric Mean +0.0% +0.6% +2.0% +1.8% -0.3% ``` But runtimes don't seem to be affected much, and the examples I looked at were completely legitimate. For example, in puzzle we have this: ``` position :: ItemType -> StateType -> BankType position Bono = bonoPos position Edge = edgePos position Larry = larryPos position Adam = adamPos ``` where the identifiers on the rhs are all record selectors. Previously the profiler gave a stack that looked like ``` position bonoPos ... ``` i.e. `bonoPos` was at the same level of the call stack as `position`, but now it looks like ``` position bonoPos ... ``` I used the normaliser from the testsuite to diff the profiling output from other nofib programs and they all looked better. Test Plan: * the broken test passes * validate * compiled and ran all of nofib, measured perf, diff'd several .prof files Reviewers: niteria, erikd, austin, scpmw, bgamari Reviewed By: bgamari Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D2804 GHC Trac Issues: #5654, #10007
* Reset FPU precision back to MSVCRT defaultsTamar Christina2016-12-151-4/+30
| | | | | | | | | | | | | | | | | | | | | | Mingw-w64 does a stupid thing. They set the FPU precision to extended mode by default. The reasoning is that it's for compatibility with GNU Linux ported libraries. However the problem is this is incompatible with the standard Windows double precision mode. In fact, if we create a new OS thread then Windows will reset the FPU to double precision mode. So we end up with a weird state where the main thread by default has a different precision than any child threads. Test Plan: ./validate new test T7289 Reviewers: simonmar, austin, bgamari, erikd Reviewed By: simonmar Subscribers: thomie, #ghc_windows_task_force Differential Revision: https://phabricator.haskell.org/D2819 GHC Trac Issues: #7289
* Fix Win32 x86 build validation after D2756Tamar Christina2016-12-131-1/+1
| | | | | | | | | | | | Test Plan: ./validate Reviewers: austin, bgamari, erikd, simonmar Reviewed By: simonmar Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D2825
* Make globals use sharedCAFMoritz Angermann2016-12-112-54/+30
| | | | | | | | | | | | | | | | | | | Summary: The use of globals is quite painful when multiple rts are loaded, e.g. when plugins are loaded, which bring in a second rts. The sharedCAF appraoch was employed for the FastStringTable; I've taken the libery to extend this to the other globals I could find. This is a reboot of D2575, that should hopefully not exhibit the same windows build issues. Reviewers: Phyx, simonmar, goldfire, bgamari, austin, hvr, erikd Reviewed By: Phyx, simonmar, bgamari Subscribers: mpickering, thomie Differential Revision: https://phabricator.haskell.org/D2773
* Add `_unlock_file` to RTS symbolsTamar Christina2016-12-101-1/+2
| | | | | | | | Reviewers: bgamari, austin, erikd, simonmar Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D2818
* rts: Provide _lock_file in symbol table on WindowsBen Gamari2016-12-091-1/+24
| | | | | | | | | | Test Plan: Validate on Windows, ensure that linking works. Reviewers: Phyx, austin, erikd, simonmar Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D2817
* rts/PosixSource.h: Define __USE_MINGW_ANSI_STDIO on WindowsBen Gamari2016-12-081-0/+13
| | | | | | | | | | | | | | | | | This was removed in 8dc72f3c33b0e724ddb690c9d494969980c10afd which cleaned up PosixSource.h. Strangely, this only started breaking for me now. Test Plan: Validate on Windows Reviewers: simonmar, erikd, austin, Phyx Reviewed By: Phyx Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D2812 GHC Trac Issues: #12951
* rts/linker: Fix LoadArchive build on WindowsBen Gamari2016-12-082-20/+25
| | | | | | | | | | | | Test Plan: Validate on Windows. Reviewers: austin, erikd, simonmar Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D2798 GHC Trac Issues: #12388
* Don't barf() on failures in loadArchive()Ben Gamari2016-12-072-190/+288
| | | | | | | | | | | | | | | | | | | This patch replaces calls to barf() in loadArchive() with proper error handling. Test Plan: GHC CI Reviewers: rwbarton, erikd, hvr, austin, simonmar, bgamari Reviewed By: bgamari Subscribers: thomie Tags: #ghc Differential Revision: https://phabricator.haskell.org/D2652 GHC Trac Issues: #12388
* rts: Use pthread itimer implementation on DarwinBen Gamari2016-12-071-0/+9
| | | | | | | | | | | | | | | | | We want to avoid using SIGALRM whenever possible since we will interrupt long-running system calls. See #10840. Test Plan: Validate on Darwin Reviewers: austin, erikd, simonmar Reviewed By: simonmar Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D2796 GHC Trac Issues: #10840
* Fix crashes in hash table scanning with THREADED_RTSSimon Marlow2016-12-071-3/+19
| | | | See comments.
* Overhaul of Compact Regions (#12455)Simon Marlow2016-12-0721-695/+1001
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: This commit makes various improvements and addresses some issues with Compact Regions (aka Compact Normal Forms). This was the most important thing I wanted to fix. Compaction previously prevented GC from running until it was complete, which would be a problem in a multicore setting. Now, we compact using a hand-written Cmm routine that can be interrupted at any point. When a GC is triggered during a sharing-enabled compaction, the GC has to traverse and update the hash table, so this hash table is now stored in the StgCompactNFData object. Previously, compaction consisted of a deepseq using the NFData class, followed by a traversal in C code to copy the data. This is now done in a single pass with hand-written Cmm (see rts/Compact.cmm). We no longer use the NFData instances, instead the Cmm routine evaluates components directly as it compacts. The new compaction is about 50% faster than the old one with no sharing, and a little faster on average with sharing (the cost of the hash table dominates when we're doing sharing). Static objects that don't (transitively) refer to any CAFs don't need to be copied into the compact region. In particular this means we often avoid copying Char values and small Int values, because these are static closures in the runtime. Each Compact# object can support a single compactAdd# operation at any given time, so the Data.Compact library now enforces mutual exclusion using an MVar stored in the Compact object. We now get exceptions rather than killing everything with a barf() when we encounter an object that cannot be compacted (a function, or a mutable object). We now also detect pinned objects, which can't be compacted either. The Data.Compact API has been refactored and cleaned up. A new compactSize operation returns the size (in bytes) of the compact object. Most of the documentation is in the Haddock docs for the compact library, which I've expanded and improved here. Various comments in the code have been improved, especially the main Note [Compact Normal Forms] in rts/sm/CNF.c. I've added a few tests, and expanded a few of the tests that were there. We now also run the tests with GHCi, and in a new test way that enables sanity checking (+RTS -DS). There's a benchmark in libraries/compact/tests/compact_bench.hs for measuring compaction speed and comparing sharing vs. no sharing. The field totalDataW in StgCompactNFData was unnecessary. Test Plan: * new unit tests * validate * tested manually that we can compact Data.Aeson data Reviewers: gcampax, bgamari, ezyang, austin, niteria, hvr, erikd Subscribers: thomie, simonpj Differential Revision: https://phabricator.haskell.org/D2751 GHC Trac Issues: #12455
* Overhaul GC statsSimon Marlow2016-12-066-229/+247
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: Visible API changes: * The C struct `GCDetails` gives the stats about a single GC. This is passed to the `gcDone()` callback if one is set via the RtsConfig. (previously we just passed a collection of values, so this is more extensible, at the expense of breaking the existing API) * `RTSStats` gives cumulative stats since the start of the program, and includes the `GCDetails` for the most recent GC. This struct can be obtained via `getRTSStats()` (the old `getGCStats()` has been removed, and `getGCStatsEnabled()` has been renamed to `getRTSStatsEnabled()`) Improvements: * The per-GC stats and cumulative stats are now cleanly separated. * Inside the RTS we have a top-level `RTSStats` struct to keep all our stats in, previously this was just a collection of strangely-named variables. This struct is mostly just copied in `getRTSStats()`, so the implementation of that function is a lot shorter. * Types are more consistent. We use a uint64_t byte count for all memory values, and Time for all time values. * Names are more consistent. We use a suffix `_bytes` for all byte counts and `_ns` for all time values. * We now collect information about the amount of memory in large objects and compact objects in `GCDetails`. (the latter was the reason I started doing this patch but it seems to have ballooned a bit!) * I fixed a bug in the calculation of the elapsed MUT time, and added an ASSERT to stop the calculations going wrong in the future. For now I kept the Haskell API in `GHC.Stats` the same, by impedence-matching with the new API. We could either break that API and make it match the C API more closely, or we could add a new API and deprecate the old one. Opinions welcome. This stuff is very easy to get wrong, and it's hard to test. Reviews welcome! Test Plan: manual testing validate Reviewers: bgamari, niteria, austin, ezyang, hvr, erikd, rwbarton, Phyx Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D2756
* Fix x86 Windows build and testsuiteTamar Christina2016-12-065-14/+16
| | | | | | | | | | | | | | | | Summary: Fix issues preventing x86 GHC to build on Windows and fix segfault in the testsuite. Test Plan: ./validate Reviewers: austin, erikd, simonmar, bgamari Reviewed By: bgamari Subscribers: #ghc_windows_task_force, thomie Differential Revision: https://phabricator.haskell.org/D2789
* Install toplevel handler inside fork.Alexander Vershilov2016-12-025-1/+38
| | | | | | | | | | | | | | | | | | | | When rts is forked it doesn't update toplevel handler, so UserInterrupt exception is sent to Thread1 that doesn't exist in forked process. We install toplevel handler when fork so signal will be delivered to the new main thread. Fixes #12903 Reviewers: simonmar, austin, erikd, bgamari Reviewed By: bgamari Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D2770 GHC Trac Issues: #12903
* rts: Ensure we always give MADV_DONTNEED a chance in osDecommitMemoryBen Gamari2016-12-011-3/+16
| | | | | | | | | | | | | | | | | | | | | As described in #12865, newer Linux kernels support both MADV_FREE and MADV_DONTNEED. Previously a runtime would fail to try MADV_DONTNEED if MADV_FREE failed (e.g. since the kernel which the image is running on doesn't support the latter). Now we try MADV_DONTNEED if MADV_FREE failed to ensure that binaries compiled on a kernel supporting MADV_FREE don't fail on decommit. Test Plan: Validate Reviewers: austin, erikd, simonmar Reviewed By: simonmar Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D2780 GHC Trac Issues: #12865
* rts: Fix type of bool literalBen Gamari2016-12-011-1/+1
| | | | | | | | | | | | Test Plan: Build `p` way Reviewers: austin, erikd, simonmar Reviewed By: simonmar Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D2779
* Revert "Make globals use sharedCAF"Ben Gamari2016-11-301-25/+54
| | | | | This reverts commit 6f7ed1e51bf360621a3c2a447045ab3012f68575 due to breakage of the build on Windows.
* Update Mingw-w64 bindist for WindowsTamar Christina2016-11-291-1/+0
| | | | | | | | | | | | | | | | | This updates the binary dists for windows to GCC 6.2.0 and binutils 2.27.2 which has fixes required for LLVM. Test Plan: ./validate Reviewers: simonmar, erikd, austin, bgamari Reviewed By: simonmar, bgamari Subscribers: thomie, #ghc_windows_task_force Differential Revision: https://phabricator.haskell.org/D2749 GHC Trac Issues: #12871, #8974
* rts: Add missing #include <stdbool.h>Ben Gamari2016-11-291-0/+1
|