summaryrefslogtreecommitdiff
path: root/includes/rts
Commit message (Collapse)AuthorAgeFilesLines
* Implement -XStaticValues.wip/static-pointersFacundo Domínguez2014-12-021-0/+32
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Contains contributions from Alexander Vershilov and Mathieu Boespflug. As proposed in [1], this extension introduces a new syntactic form `static e`, where `e :: a` can be any closed expression. The static form produces a value of type `StaticPtr a`, which works as a reference that programs can "dereference" to get the value of `e` back. References are like `Ptr`s, except that they are stable across invocations of a program. In essence the extension collects the arguments of the static form into a global static pointer table. The expressions can be looked up by a fingerprint computed from the package, the module and a fresh name given to the expression. For more details we refer to the users guide section contained in the patch. The extension is a contribution to the Cloud Haskell ecosystem (distributed-process and related), and thus has the potential to foster Haskell as a programming language for distributed systems. The immediate improvement brought by the extension is the elimination of remote tables from Cloud Haskell applications. Such applications contain table fragments spread throughout multiple modules and packages. Eliminating these fragments saves the programmer the burden required to construct and assemble the global remote table, a verbose and error-prone process, even with the help of Template Haskell, that moreover pollutes the export lists of all modules. [1] Jeff Epstein, Andrew P. Black, and Simon Peyton-Jones. Towards Haskell in the cloud. SIGPLAN Not., 46(12):118–129, September 2011. ISSN 0362-1340.
* Per-thread allocation counters and limitsSimon Marlow2014-11-124-11/+42
| | | | | | | | This reverts commit f0fcc41d755876a1b02d1c7c79f57515059f6417. New changes: now works on 32-bit platforms too. I added some basic support for 64-bit subtraction and comparison operations to the x86 NCG.
* Revert "Rename _closure to _static_closure, apply naming consistently."Edward Z. Yang2014-10-203-38/+3
| | | | | | | This reverts commit 35672072b4091d6f0031417bc160c568f22d0469. Conflicts: compiler/main/DriverPipeline.hs
* Name worker threads using pthread_setname_npSimon Marlow2014-10-101-1/+1
| | | | | This helps identify threads in gdb particularly in processes with a lot of threads.
* Make the linker more robust to errorsSimon Marlow2014-10-081-1/+1
| | | | | | | | | | | | | | | | | | | | Summary: When linking fails because there was a problem with the supplied object file, then we should not barf() or exit, we should emit a suitable error message and return an error code to the caller. We should also free all memory that might have been allocated during linking, and generally not do any damage. This patch fixes most common instances of this problem. Test Plan: validate Reviewers: rwbarton, austin, ezyang Reviewed By: ezyang Subscribers: simonmar, ezyang, carter, thomie Differential Revision: https://phabricator.haskell.org/D294
* Rename _closure to _static_closure, apply naming consistently.Edward Z. Yang2014-10-013-3/+38
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: In preparation for indirecting all references to closures, we rename _closure to _static_closure to ensure any old code will get an undefined symbol error. In order to reference a closure foobar_closure (which is now undefined), you should instead use STATIC_CLOSURE(foobar). For convenience, a number of these old identifiers are macro'd. Across C-- and C (Windows and otherwise), there were differing conventions on whether or not foobar_closure or &foobar_closure was the address of the closure. Now, all foobar_closure references are addresses, and no & is necessary. CHARLIKE/INTLIKE were not changed, simply alpha-renamed. Part of remove HEAP_ALLOCED patch set (#8199) Depends on D265 Signed-off-by: Edward Z. Yang <ezyang@mit.edu> Test Plan: validate Reviewers: simonmar, austin Subscribers: simonmar, ezyang, carter, thomie Differential Revision: https://phabricator.haskell.org/D267 GHC Trac Issues: #8199
* Revert "Revert "rts/base: Fix #9423"" and resolve issue that caused the revert.Andreas Voellmy2014-09-161-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: This reverts commit 4748f5936fe72d96edfa17b153dbfd84f2c4c053. The fix for #9423 was reverted because this commit introduced a C function setIOManagerControlFd() (defined in Schedule.c) defined for all OS types, while the prototype (in includes/rts/IOManager.h) was only included when mingw32_HOST_OS is not defined. This broke Windows builds. This commit reverts the original commit and resolves the problem by only defining setIOManagerControlFd() when mingw32_HOST_OS is defined. Hence the missing prototype error should not occur on Windows. In addition, since the io_manager_control_wr_fd field of the Capability struct is only usd by the setIOManagerControlFd, this commit includes the io_manager_control_wr_fd field in the Capability struct only when mingw32_HOST_OS is not defined. Test Plan: Try to compile successfully on all platforms. Reviewers: austin Reviewed By: austin Subscribers: simonmar, ezyang, carter Differential Revision: https://phabricator.haskell.org/D174
* Revert "rts/base: Fix #9423"Austin Seipp2014-08-221-2/+1
| | | | | | | | | This should fix the Windows fallout, and hopefully this will be fixed once that's sorted out. This reverts commit f9f89b7884ccc8ee5047cf4fffdf2b36df6832df. Signed-off-by: Austin Seipp <austin@well-typed.com>
* includes: detabify/dewhitespace rts/storage/ClosureMacros.hAustin Seipp2014-08-201-44/+44
| | | | Signed-off-by: Austin Seipp <austin@well-typed.com>
* [ci skip] includes: detabify/dewhitespace rts/storage/InfoTables.hAustin Seipp2014-08-201-34/+34
| | | | Signed-off-by: Austin Seipp <austin@well-typed.com>
* [ci skip] includes: detabify/dewhitespace rts/storage/Block.hAustin Seipp2014-08-201-4/+4
| | | | Signed-off-by: Austin Seipp <austin@well-typed.com>
* [ci skip] includes: detabify/dewhitespace rts/storage/GC.hAustin Seipp2014-08-201-27/+27
| | | | Signed-off-by: Austin Seipp <austin@well-typed.com>
* [ci skip] includes: detabify/dewhitespace rts/storage/Closures.hAustin Seipp2014-08-201-17/+17
| | | | Signed-off-by: Austin Seipp <austin@well-typed.com>
* [ci skip] includes: detabify/dewhitespace rts/storage/TSO.hAustin Seipp2014-08-201-13/+13
| | | | Signed-off-by: Austin Seipp <austin@well-typed.com>
* [ci skip] includes: detabify/dewhitespace rts/storage/MBlock.hAustin Seipp2014-08-201-3/+3
| | | | Signed-off-by: Austin Seipp <austin@well-typed.com>
* [ci skip] includes: detabify/dewhitespace rts/prof/LDV.hAustin Seipp2014-08-201-1/+1
| | | | Signed-off-by: Austin Seipp <austin@well-typed.com>
* [ci skip] includes: detabify/dewhitespace rts/prof/CCS.hAustin Seipp2014-08-201-35/+34
| | | | Signed-off-by: Austin Seipp <austin@well-typed.com>
* [ci skip] includes: detabify/dewhitespace rts/Hpc.hAustin Seipp2014-08-201-3/+3
| | | | Signed-off-by: Austin Seipp <austin@well-typed.com>
* [ci skip] includes: detabify/dewhitespace rts/OSThreads.hAustin Seipp2014-08-201-10/+10
| | | | Signed-off-by: Austin Seipp <austin@well-typed.com>
* [ci skip] includes: detabify/dewhitespace rts/Stable.hAustin Seipp2014-08-201-3/+3
| | | | Signed-off-by: Austin Seipp <austin@well-typed.com>
* [ci skip] includes: detabify/dewhitespace rts/Threads.hAustin Seipp2014-08-201-4/+4
| | | | Signed-off-by: Austin Seipp <austin@well-typed.com>
* [ci skip] includes: detabify/dewhitespace rts/Ticky.hAustin Seipp2014-08-201-8/+7
| | | | Signed-off-by: Austin Seipp <austin@well-typed.com>
* rts/base: Fix #9423Andreas Voellmy2014-08-191-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: Fix #9423. The problem in #9423 is caused when code invoked by `hs_exit()` waits on all foreign calls to return, but some IO managers are in `safe` foreign calls and do not return. The previous design signaled to the timer manager (via its control pipe) that it should "die" and when the timer manager returned to Haskell-land, the Haskell code in timer manager then signalled to the IO manager threads that they should return from foreign calls and `die`. Unfortunately, in the shutdown sequence the timer manager is unable to return to Haskell-land fast enough and so the code that signals to the IO manager threads (via their control pipes) is never executed and the IO manager threads remain out in the foreign calls. This patch solves this problem by having the RTS signal to all the IO manager threads (via their control pipes; and in addition to signalling to the timer manager thread) that they should shutdown (in `ioManagerDie()` in `rts/Signals.c`. To do this, we arrange for each IO manager thread to register its control pipe with the RTS (in `GHC.Thread.startIOManagerThread`). In addition, `GHC.Thread.startTimerManagerThread` registers its control pipe. These are registered via C functions `setTimerManagerControlFd` (in `rts/Signals.c`) and `setIOManagerControlFd` (in `rts/Capability.c`). The IO manager control pipe file descriptors are stored in a new field of the `Capability_ struct`. Test Plan: See the notes on #9423 to recreate the problem and to verify that it no longer occurs with the fix. Auditors: simonmar Reviewers: simonmar, edsko, ezyang, austin Reviewed By: austin Subscribers: phaskell, simonmar, ezyang, carter, relrod Differential Revision: https://phabricator.haskell.org/D129 GHC Trac Issues: #9423, #9284
* Implement {resize,shrink}MutableByteArray# primopsHerbert Valerio Riedel2014-08-161-0/+33
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | The two new primops with the type-signatures resizeMutableByteArray# :: MutableByteArray# s -> Int# -> State# s -> (# State# s, MutableByteArray# s #) shrinkMutableByteArray# :: MutableByteArray# s -> Int# -> State# s -> State# s allow to resize MutableByteArray#s in-place (when possible), and are useful for algorithms where memory is temporarily over-allocated. The motivating use-case is for implementing integer backends, where the final target size of the result is either N or N+1, and only known after the operation has been performed. A future commit will implement a stateful variant of the `sizeofMutableByteArray#` operation (see #9447 for details), since now the size of a `MutableByteArray#` may change over its lifetime (i.e before it gets frozen or GCed). Test Plan: ./validate --slow Reviewers: ezyang, austin, simonmar Reviewed By: austin, simonmar Differential Revision: https://phabricator.haskell.org/D133
* rts: drop unused 'SpinLockCount' typedefSergei Trofimovich2014-07-201-2/+0
| | | | | | | | | | | | | | Summary: Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org> Test Plan: git grep, git log -SSpinLockCount, build test Reviewers: austin, simonmar Reviewed By: austin, simonmar Subscribers: phaskell, simonmar, relrod, carter Differential Revision: https://phabricator.haskell.org/D76
* rts: Fix #9003 with an annoying hackAustin Seipp2014-07-091-1/+3
| | | | | | | The TL;DR is that by adding this, we can distinguish GHC 7.8.3 from 7.8.2, which had a buggy implementation. See the ticket for details. Signed-off-by: Austin Seipp <austin@well-typed.com>
* Partially fix #9003 by reverting bad numbering.Edward Z. Yang2014-07-011-13/+15
| | | | Signed-off-by: Edward Z. Yang <ezyang@cs.stanford.edu>
* Revert "Per-thread allocation counters and limits"Simon Marlow2014-05-044-42/+11
| | | | | | | | Problems were found on 32-bit platforms, I'll commit again when I have a fix. This reverts the following commits: 54b31f744848da872c7c6366dea840748e01b5cf b0534f78a73f972e279eed4447a5687bd6a8308e
* Per-thread allocation counters and limitsSimon Marlow2014-05-024-11/+42
| | | | | | | | | | | | | | | | | | | | | | | This tracks the amount of memory allocation by each thread in a counter stored in the TSO. Optionally, when the counter drops below zero (it counts down), the thread can be sent an asynchronous exception: AllocationLimitExceeded. When this happens, given a small additional limit so that it can handle the exception. See documentation in GHC.Conc for more details. Allocation limits are similar to timeouts, but - timeouts use real time, not CPU time. Allocation limits do not count anything while the thread is blocked or in foreign code. - timeouts don't re-trigger if the thread catches the exception, allocation limits do. - timeouts can catch non-allocating loops, if you use -fno-omit-yields. This doesn't work for allocation limits. I couldn't measure any impact on benchmarks with these changes, even for nofib/smp.
* Rts: Consistently use StgWord for sizes of bitmapsArash Rouhani2014-04-291-0/+5
| | | | | | | | | | | | | | | | | | A long debate is in issue #8742, but the main motivation is that this allows for applying a patch to reuse the function scavenge_small_bitmap without changing the .o-file output. Similarly, I changed the types in rts/sm/Compact.c, so I can create a STATIC_INLINE function for the redundant code block: while (size > 0) { if ((bitmap & 1) == 0) { thread((StgClosure **)p); } p++; bitmap = bitmap >> 1; size--; }
* Add SmallArray# and SmallMutableArray# typesJohan Tibell2014-03-293-1/+20
| | | | | | | | | | | | | | | These array types are smaller than Array# and MutableArray# and are faster when the array size is small, as they don't have the overhead of a card table. Having no card table reduces the closure size with 2 words in the typical small array case and leads to less work when updating or GC:ing the array. Reduces both the runtime and memory allocation by 8.8% on my insert benchmark for the HashMap type in the unordered-containers package, which makes use of lots of small arrays. With tuned GC settings (i.e. `+RTS -A6M`) the runtime reduction is 15%. Fixes #8923.
* Fix incorrect blocksize calculation on Win64Kyrill Briantsev2014-03-131-2/+12
| | | | | | Fixes #8839 Signed-off-by: Austin Seipp <austin@well-typed.com>
* Make `#include "Rts.h"` C++-compatible again (re #8676)Herbert Valerio Riedel2014-01-193-9/+9
| | | | Signed-off-by: Herbert Valerio Riedel <hvr@gnu.org>
* Move the allocation of CAF blackholes into 'newCAF' (#8590)Patrick Palka2013-12-041-2/+2
| | | | | | | | | | We now do the allocation of the blackhole indirection closure inside the RTS procedure 'newCAF' instead of generating the allocation code inline in the closure body of each CAF. This slightly decreases code size in modules with a lot of CAFs. As a result of this change, for example, the size of DynFlags.o drops by ~60KB and HsExpr.o by ~100KB.
* Untab ClosureTypes.h and ClosureFlags.cPatrick Palka2013-12-041-38/+38
|
* Comment on StgArrWords vs StgArrBytesArash Rouhani2013-11-221-1/+8
| | | | | | | See #8552 Signed-off-by: Arash Rouhani <rarash@student.chalmers.se> Reviewed-by: Austin Seipp <austin@well-typed.com>
* GHCi: Properly generate jump code for ARM (#8380)Austin Seipp2013-11-221-0/+1
| | | | | | | | | | | | | | | | | | | | This adds code for jumping to given addresses for ARM, written by Ben Gamari. However, when allocating new infotables for bytecode (which is where this jump code occurs), we need to be sure to flush the cache on the execute pointer returned from allocateExec() - on systems like ARM, the processor won't reliably read back code or automatically cache flush, where x86 will. So we add a new flushExec primitive to call out to GCC's __builtin___clear_cache primitive, which will properly generate the correct code (nothing on x86, and a call to libgcc's __clear_cache on ARM) and make sure we use it after writing the code out. Authored-by: Ben Gamari <bgamari.foss@gmail.com> Authored-by: Austin Seipp <austin@well-typed.com> Signed-off-by: Austin Seipp <austin@well-typed.com>
* Grammar in commentsGabor Greif2013-11-221-1/+1
|
* Allow the linker to be used without retaining CAFs unconditionallySimon Marlow2013-11-211-2/+19
| | | | | | | | | This creates a new C API: initLinker_ (int retain_cafs) The old initLinker() was left as-is for backwards compatibility. See documentation in Linker.h.
* In the DEBUG rts, track when CAFs are GC'dSimon Marlow2013-11-211-2/+2
| | | | | | | | | | | | This resurrects some old code and makes it work again. The idea is that we want to get an error message if we ever enter a CAF that has been GC'd, rather than following its indirection which will likely cause a segfault. Without this patch, these bugs are hard to track down in gdb, because the IND_STATIC code overwrites R1 (the pointer to the CAF) with its indirectee before jumping into bad memory, so we've lost the address of the CAF that got GC'd. Some associated refactoring while I was here.
* Linker.c: remove stablehash, which is no longer usedTakano Akio2013-10-251-3/+0
| | | | Signed-off-by: Austin Seipp <austin@well-typed.com>
* Make integer overflow less likely to happen (#7762)Simon Marlow2013-10-251-0/+24
| | | | | | | | | | | | | | | The particular problematic code in #7762 was this: nat newSize = size - n; char *freeAddr = MBLOCK_ROUND_DOWN(bd->start); freeAddr += newSize * MBLOCK_SIZE; ^^^^^^^^^^^^^^^^^^^^^^ OVERFLOW!!! For good measure, I'm going to fix the bug twice. This patch fixes the class of bugs of this kind, by making sure that any expressions involving BLOCK_SIZE or MBLOCK_SIZE are promoted to unsigned long. In a separate patch, I'll fix a bunch of individual instances (including the one above).
* Another attempt to fix the conditions for slop-zeroingSimon Marlow2013-10-251-3/+6
| | | | | Also refactor the #defines to hopefully make it clearer what's going on.
* Fix up the conditions for zeroing slop (#8402)Simon Marlow2013-10-111-10/+26
|
* Use dynamic linking only if the GHC package is compiled with -dynamic (#8376)Simon Marlow2013-10-111-3/+0
|
* Globally replace "hackage.haskell.org" with "ghc.haskell.org"Simon Marlow2013-10-0128-29/+29
|
* Fix linker_unload now that we are running constructors in the linker (#8291)Simon Marlow2013-09-231-0/+3
| | | | | | | See also #5435. Now we have to remember the the StablePtrs that get created by the module initializer so that we can free them again in unloadObj().
* Add support for 512-bit-wide vectors.Geoffrey Mainland2013-09-221-17/+18
|
* Add support for 256-bit-wide vectors.Geoffrey Mainland2013-09-221-17/+18
|
* Fix freeHaskellFunPtr crash on iOS.Austin Seipp2013-09-151-0/+3
| | | | | Authored-by: Stephen Blackheath <...@blacksapphire.com> Signed-off-by: Austin Seipp <austin@well-typed.com>