summaryrefslogtreecommitdiff
path: root/rts/sm
Commit message (Collapse)AuthorAgeFilesLines
* Rename _closure to _static_closure, apply naming consistently.Edward Z. Yang2014-10-011-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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 "rts: add Emacs 'Local Variables' to every .c file"Simon Marlow2014-09-2926-208/+0
| | | | This reverts commit 39b5c1cbd8950755de400933cecca7b8deb4ffcd.
* rts: detabify/dewhitespace sm/MBlock.cAustin Seipp2014-08-201-12/+12
| | | | Signed-off-by: Austin Seipp <austin@well-typed.com>
* rts: detabify/dewhitespace sm/GCUtils.cAustin Seipp2014-08-201-16/+16
| | | | Signed-off-by: Austin Seipp <austin@well-typed.com>
* rts: detabify/dewhitespace sm/GCUtils.hAustin Seipp2014-08-201-6/+6
| | | | Signed-off-by: Austin Seipp <austin@well-typed.com>
* rts: detabify/dewhitespace sm/GCAux.cAustin Seipp2014-08-201-19/+19
| | | | Signed-off-by: Austin Seipp <austin@well-typed.com>
* rts: detabify/dewhitespace sm/MarkWeak.cAustin Seipp2014-08-201-15/+15
| | | | Signed-off-by: Austin Seipp <austin@well-typed.com>
* rts: detabify/dewhitespace sm/BlockAlloc.cAustin Seipp2014-08-201-35/+35
| | | | Signed-off-by: Austin Seipp <austin@well-typed.com>
* rts: detabify/dewhitespace sm/Storage.hAustin Seipp2014-08-201-4/+4
| | | | Signed-off-by: Austin Seipp <austin@well-typed.com>
* rts: add Emacs 'Local Variables' to every .c fileAustin Seipp2014-07-2826-0/+208
| | | | | | | | This will hopefully help ensure some basic consistency in the forward by overriding buffer variables. In particular, it sets the wrap length, the offset to 4, and turns off tabs. Signed-off-by: Austin Seipp <austin@well-typed.com>
* Avoid unnecessary clock_gettime() syscalls in GC stats.Brian Brooks2014-07-102-7/+1
| | | | | | | | | | | | | | Summary: Avoid unnecessary clock_gettime() syscalls in GC stats. Test Plan: Use strace. Reviewers: simonmar, austin Reviewed By: simonmar, austin Subscribers: simonmar, relrod, carter Differential Revision: https://phabricator.haskell.org/D39
* Fix variable name in allocate()Reid Barton2014-07-011-3/+3
|
* Check for integer overflow in allocate() (#9172)Reid Barton2014-07-011-1/+9
| | | | | | | | | | | | | | Summary: Check for integer overflow in allocate() (#9172) Test Plan: validate Reviewers: austin Reviewed By: austin Subscribers: simonmar, relrod, carter Differential Revision: https://phabricator.haskell.org/D36
* Per-capability nursery weak pointer lists, fixes #9075Edward Z. Yang2014-05-293-0/+39
| | | | Signed-off-by: Edward Z. Yang <ezyang@cs.stanford.edu>
* Revert "Per-thread allocation counters and limits"Simon Marlow2014-05-041-7/+1
| | | | | | | | Problems were found on 32-bit platforms, I'll commit again when I have a fix. This reverts the following commits: 54b31f744848da872c7c6366dea840748e01b5cf b0534f78a73f972e279eed4447a5687bd6a8308e
* Update comment now that we have per-gen weak pointer lists.Edward Z. Yang2014-05-041-4/+2
| | | | Signed-off-by: Edward Z. Yang <ezyang@cs.stanford.edu>
* Per-thread allocation counters and limitsSimon Marlow2014-05-021-1/+7
| | | | | | | | | | | | | | | | | | | | | | | 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: Reuse scavenge_small_bitmap (#8742)Arash Rouhani2014-04-292-53/+33
| | | | | | | | | | | | | | | | The function was inlined at two places already. And the function is having the STATIC_INLINE annotation, so the assembly output should. be the same. To convince myself, I did diff the output of the object files before and after the patch and they matched on my 64-bit Ubuntu 13.10 machine, running gcc 4.8.1-10ubuntu9. Also, I had to move scavenge_small_bitmap up a bit since it's not in any .h-file. While I was at it, I also applied the analogous patch for Compact.c. Though I had to write `thread_small_bitmap` instead of just moving it.
* Rts: Consistently use StgWord for sizes of bitmapsArash Rouhani2014-04-292-15/+15
| | | | | | | | | | | | | | | | | | 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--; }
* rts: Fix possible int overflow in resize_nurseryAustin Seipp2014-04-271-1/+2
| | | | | | | | | | | n_capabilities is declared as unsigned int (32bit), and so multiplication is 32-bit before being stored in a 64bit integer (StgWord). Instead, cast n_capabilities to StgWord before multiplying. Discovered by Coverity. CID 43164. Signed-off-by: Austin Seipp <austin@well-typed.com>
* Make BlockAlloc.c comment slightly more accurate (fixes #8491)Edward Z. Yang2014-04-131-1/+1
| | | | Signed-off-by: Edward Z. Yang <ezyang@cs.stanford.edu>
* Add SmallArray# and SmallMutableArray# typesJohan Tibell2014-03-293-0/+187
| | | | | | | | | | | | | | | 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 comment on allocate() (#8254)Simon Marlow2014-02-271-12/+14
|
* Fix check for TLS support in Storage.cAustin Seipp2014-02-171-2/+2
| | | | | | | This should have manifested earlier, but for some reason it only seemed to trigger on Mavericks. Signed-off-by: Austin Seipp <austin@well-typed.com>
* Remove ios_HOST check for GCTDecl.hAustin Seipp2014-02-061-1/+1
| | | | | | | Following 298a25bdf and #8722 as Peter mentioned, this probably isn't needed anymore. Signed-off-by: Austin Seipp <austin@well-typed.com>
* Fix iOS build (fallout from 28b031c506)Austin Seipp2014-01-301-2/+5
| | | | | | | | As Luke Iannini reported, the Clang iOS cross compiler apparently doesn't support __thread for some bizarre reason, so unfortunately they too must fall back to pthread_{get,set}specific. Signed-off-by: Austin Seipp <austin@well-typed.com>
* Refactor GCTDecl.h, and mitigate #7602 a bitAustin Seipp2014-01-281-59/+93
| | | | | | | | | | | | | | | | | | | | | | | | | This basically cleans a lot of GCTDecl up - I found it quite hard to read and a bit confusing. The changes are mostly cosmetic: better delineation between the alternative cases and light touchups, and tries to make every branch as consistent as possible. However, this patch does have one significant effect: it will ensure that any LLVM-based compilers will use __thread if they support it. Before, they would simply always use pthread_getspecific and pthread_setspecific, which are almost surely even *more* inefficient. The details are a bit too long and boring to go into here; see #7602. After talking with Simon, we decided to play it safe - __thread can at least be optimized by future clang releases even further on OS X if they choose, and it's safer until we can investigate the pthread implementation further on Mavericks. For Linux, the story isn't so bleak if you use Clang (for whatever reason) - Linux directly writes to `%fs` for __thread slots (while OS X will perform a load followed by an indirect call.) So it should still be fairly competitive, speed-wise. Signed-off-by: Austin Seipp <austin@well-typed.com>
* Clean up block allocator, fixes #8609Edward Z. Yang2013-12-311-4/+30
| | | | Signed-off-by: Edward Z. Yang <ezyang@cs.stanford.edu>
* Fix windows x86_64 build.Austin Seipp2013-12-091-1/+1
| | | | | | | On win64 sizeof(long) != sizeof(void*), so debugTrace was casting a value of incorrect size causing a validate failure. Signed-off-by: Austin Seipp <austin@well-typed.com>
* Use new flushExec implementation on all operating systems (#8562)Christopher Rodrigues2013-12-041-37/+19
| | | | | | | An earlier patch fixes a bug in flushExec on linux only. This patch uses the fixed code on all operating systems. Signed-off-by: Austin Seipp <austin@well-typed.com>
* Update and deduplicate the comments on CAF management (#8590)Patrick Palka2013-12-041-6/+10
|
* Move the allocation of CAF blackholes into 'newCAF' (#8590)Patrick Palka2013-12-041-13/+27
| | | | | | | | | | 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.
* Call busy_wait_nop() in the spin-wait loop in shutdown_gc_threads()Patrick Palka2013-11-291-1/+4
|
* Rejigger flushExec implementation (#8562, #8561)Austin Seipp2013-11-261-3/+19
| | | | | | | | Instead, just don't do anything on x86/amd64, and on !x86, use either A) __clear_cache from libgcc, or B) sys_icache_invalidate for OS X (and iOS.) Signed-off-by: Austin Seipp <austin@well-typed.com>
* GHCi: Properly generate jump code for ARM (#8380)Austin Seipp2013-11-221-3/+30
| | | | | | | | | | | | | | | | | | | | 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>
* Allow the linker to be used without retaining CAFs unconditionallySimon Marlow2013-11-211-4/+4
| | | | | | | | | 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-214-53/+89
| | | | | | | | | | | | 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.
* Fix a race condition when PROFILING (#8453)Takano Akio2013-11-021-3/+9
| | | | Signed-off-by: Austin Seipp <austin@well-typed.com>
* rts: Add casts to prevent compiler warnings in printfs.Erik de Castro Lopo2013-10-281-1/+1
|
* rts: Add getPhysicalMemorySizeBen Gamari2013-10-251-0/+1
|
* Turn several nats into StgWord to avoid potential integer overflow (#7762)Simon Marlow2013-10-251-12/+13
|
* Change backslash to vertical bar in commentSimon Peyton Jones2013-10-081-2/+2
| | | | | | | | | This is to avoid rts/sm/Storage.c: In function ‘allocate’: rts/sm/Storage.c:725:13: error: multi-line comment [-Werror=comment] cc1: all warnings being treated as errors
* More clarity on CurrentAlloc docs.Edward Z. Yang2013-10-061-0/+22
| | | | Signed-off-by: Edward Z. Yang <ezyang@mit.edu>
* Tiny comment on the change from StgWord8 to StgWordSimon Peyton Jones2013-10-031-1/+1
| | | | c.f. commit 0b0fec536e35769b64b8bc5397c84138fa512155
* Initialize gc_thread.mut_spin to the 'acquired' statePatrick Palka2013-10-021-0/+1
|
* comment updateSimon Marlow2013-10-011-1/+1
|
* Globally replace "hackage.haskell.org" with "ghc.haskell.org"Simon Marlow2013-10-0118-18/+18
|
* use StgWord not StgWord8 for wakeupSimon Marlow2013-10-011-1/+1
| | | | volatile StgWord8 is not guaranteed to be atomic.
* Fix build when PROF_SPIN is unsetPatrick Palka2013-09-231-0/+2
| | | | whitehole_spin is only defined when PROF_SPIN is set.
* Revert "Default to infinite stack size (#8189)"Austin Seipp2013-09-081-39/+16
| | | | This reverts commit d85044f6b201eae0a9e453b89c0433608e0778f0.