summaryrefslogtreecommitdiff
path: root/rts
Commit message (Collapse)AuthorAgeFilesLines
* Add hs_thread_done() (#8124)Simon Marlow2014-02-274-11/+78
| | | | See documentation for details.
* fix comment on allocate() (#8254)Simon Marlow2014-02-271-12/+14
|
* RetainerProfile.c: include missing header (#8810)Sergei Trofimovich2014-02-201-0/+1
| | | | | | | | | | | | | Found by clang: rts_dist_HC rts/dist/build/RetainerProfile.p_o rts/RetainerProfile.c:1779:5: error: implicit declaration of function 'markStableTables' is invalid in C99 [-Werror,-Wimplicit-function-declaration] markStableTables(retainRoot, NULL); Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org> Signed-off-by: Austin Seipp <austin@well-typed.com>
* 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>
* rts/package.conf.in: fix UNREG on --with-system-libffi when include-dir is ↵Sergei Trofimovich2014-02-171-2/+2
| | | | | | | | | passed explicitely Issue #8748 Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org> Signed-off-by: Austin Seipp <austin@well-typed.com>
* rts/Capability.c: fix crash in -threaded mode on UNREG buildSergei Trofimovich2014-02-171-9/+13
| | | | | | | | | | | | | UNREG mode has quite nasty invariant to maintain: capabilities[0] == &MainCapability and it's a non-heap memory, while other capabilities are dynamically allocated. Issue #8748 Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org> 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 #8698 by properly handling long section names and reenabling .ctors handlingEdward Z. Yang2014-02-041-23/+36
| | | | | | | | Our old function for searching for sections could only deal with section names that were eight bytes or shorter; this patch adds support for long section names. Signed-off-by: Edward Z. Yang <ezyang@cs.stanford.edu>
* Final fix to #7134 (and #8717 as well.)Kyrill Briantsev2014-02-041-12/+4
| | | | Signed-off-by: Austin Seipp <austin@well-typed.com>
* Fix some edge cases in 8f8bd88c (#7134)Kyrill Briantsev2014-01-301-7/+12
| | | | 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>
* Win64 linker: fix loading foreign imports (#2283)Kyrill Briantsev2014-01-281-0/+17
| | | | Signed-off-by: Austin Seipp <austin@well-typed.com>
* Fix inplace dynamic linking on OS X (#8266)Christiaan Baaj2014-01-281-2/+4
| | | | 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>
* Fix the Win64 RTS linker & disable .ctorsKyrill Briantsev2014-01-271-40/+145
| | | | | | This fixes #7134 Signed-off-by: Austin Seipp <austin@well-typed.com>
* Add a way to reserve temporary stack space in high-level CmmSimon Marlow2014-01-161-22/+33
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We occasionally need to reserve some temporary memory in a primop for passing to a foreign function. We've been using the stack for this, but when we moved to high-level Cmm it became quite fragile because primops are in high-level Cmm and the stack is supposed to be under the control of the Cmm pipeline. So this change puts things on a firmer footing by adding a new Cmm construct 'reserve'. e.g. in decodeFloat_Int#: reserve 2 = tmp { mp_tmp1 = tmp + WDS(1); mp_tmp_w = tmp; /* Perform the operation */ ccall __decodeFloat_Int(mp_tmp1 "ptr", mp_tmp_w "ptr", arg); r1 = W_[mp_tmp1]; r2 = W_[mp_tmp_w]; } reserve is described in CmmParse.y. Unfortunately the argument to reserve must be a compile-time constant. We might have to extend the parser to allow expressions with arithmetic operators if this is too restrictive. Note also that the return instruction for the procedure must be outside the scope of the reserved stack area, so we have to extract the values from the reserved area before we close the scope. This means some more local variables (r1, r2 in the example above). The generated code is more or less identical to what we had before though.
* In rts/Printer.c, print exact UPDATE_FRAME typeArash Rouhani2014-01-152-1/+20
| | | | | | | | When printing an update frame in printClosure(), it will not print the unspecific UPDATE_FRAME, instead it prints BH_UPDATE_FRAME, NORMAL_UPDATE_FRAME or MARKED_UPDATE_FRAME. Signed-off-by: Austin Seipp <austin@well-typed.com>
* Fix typo in error messageHerbert Valerio Riedel2014-01-111-1/+1
| | | | Signed-off-by: Herbert Valerio Riedel <hvr@gnu.org>
* Fix specification of -z origin for gold.Austin Seipp2014-01-071-1/+1
| | | | | | | Gold apparently doesn't recognize `-z origin`, only `-zorigin` it seems. Authored-by: Ben Gamari <bgamari.foss@gmail.com> 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>
* Fix compiler warnings due to integer size mismatchChristopher Rodrigues2013-12-041-2/+2
| | | | 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.
* Untab ClosureTypes.h and ClosureFlags.cPatrick Palka2013-12-041-41/+41
|
* 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>
* Extend getPhysicalMemorySize to iOS (#8533)Austin Seipp2013-11-221-1/+1
| | | | | Authored-by: Authored-by: Luke Iannini <lukexi@me.com> Signed-off-by: Austin Seipp <austin@well-typed.com>
* Fix formatting (fixes #8551)Arash Rouhani2013-11-221-1/+1
| | | | | 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-222-3/+31
| | | | | | | | | | | | | | | | | | | | 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-212-6/+20
| | | | | | | | | 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.
* CheckUnload needs to look at revertible_caf_listSimon Marlow2013-11-211-0/+7
| | | | Retained CAFs must keep an object file alive.
* In the DEBUG rts, track when CAFs are GC'dSimon Marlow2013-11-215-53/+96
| | | | | | | | | | | | 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.
* Improve the shutdownHaskellAndSignal and add fast exitDuncan Coutts2013-11-142-10/+56
| | | | | | | | | | | | | | | | | | | | | This is the RTS part of a patch to base's topHandler to handle exiting by a signal. The intended behaviour is that on Unix, throwing ExitFailure (-sig) results in the process terminating with that signal. Previously shutdownHaskellAndSignal was only used for exiting with SIGINT due to the UserInterrupt exception. Improve shutdownHaskellAndSignal to do the signal part more carefully. In particular, it (should) now reliably terminates the process one way or another. Previusly if the signal was blocked, ignored or handled then shutdownHaskellAndSignal would actually return! Also, the topHandler code has two paths a careful shutdown and a "fast exit" where it does not give finalisers a chance to run. We want to support that mode also when we want to exit by signal. So rather than the base code directly calling stg_exit as it did before, we have a fastExit bool paramater for both shutdownHaskellAnd{Exit,Signal}.
* simplify processNurseryForDeadSimon Marlow2013-11-141-13/+8
| | | | It wasn't actually broken, but it wasn't obviously right either.
* fix a small memory leak with +RTS -hbSimon Marlow2013-11-141-10/+9
|
* Remove superfluous #ifdef from Takano's patch.Austin Seipp2013-11-021-2/+0
| | | | Signed-off-by: Austin Seipp <austin@well-typed.com>
* rts_apply uses CCS_MAIN rather than CCS_SYSTEM (#7753)Takano Akio2013-11-021-1/+6
| | | | Signed-off-by: Austin Seipp <austin@well-typed.com>
* Fix loop on 64bit Big-Endian platforms (#8134)Austin Seipp2013-11-021-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is a fun one. In the RTS, `cas` expects a pointer to StgWord which will translate to unsigned long (8 bytes under LP64.) But we had previously declared token_locked as *StgBool* - which evaluates to 'int' (4 bytes under LP64.) That means we fail to provide enough storage for the cas primitive, causing it to corrupt memory on a 64bit platform. Hilariously, this somehow did not affect little-endian platforms (ARM, x86, etc) before. That's because to clear our lock token, we would say: token_locked = 0; But because token_locked is 32bits technically, this only writes to half of the 64bit quantity. On a Big-Endian machine, this won't do anything. That is, token_locked starts as 0: / token_locked | v 0x00000000 and the first cas modifies the memory to: / valid / corrupted | | v v 0x00000000 0x00000001 We then clear token_locked, but this doesn't change the corrupted 4 bytes of memory. And then we try to lock the token again, spinning until it is released - clearly a deadlock. Related: Windows (amd64) doesn't follow LP64, but LLP64, where both int and long are 4 bytes, so this shouldn't change anything on these platforms. Thanks to Reid Barton for helping the diagnosis. Also, thanks to Jens Peterson who confirmed this also fixes building GHC on Fedora/ppc64 and Fedora/s390x. Authored-by: Gustavo Luiz Duarte <gustavold@linux.vnet.ibm.com> Signed-off-by: Austin Seipp <austin@well-typed.com>
* Fix a race condition when PROFILING (#8453)Takano Akio2013-11-021-3/+9
| | | | Signed-off-by: Austin Seipp <austin@well-typed.com>
* Minor typos (fixes #8496)Kirill Boltaev2013-11-011-3/+3
|
* rts: Add casts to prevent compiler warnings in printfs.Erik de Castro Lopo2013-10-282-2/+2
|
* Untabify and delete trailing whitespace.Austin Seipp2013-10-261-23/+23
| | | | Signed-off-by: Austin Seipp <austin@well-typed.com>
* Fix Windows build.Austin Seipp2013-10-263-3/+5
| | | | | | | | | GlobalMemoryStatusEx actually requires _WIN32_WINNT to be defined as 0x0501 (Windows XP) for availability. For completeness, I bumped WIN32_WINNT in Ticker and OSThreads as well. Signed-off-by: Austin Seipp <austin@well-typed.com>
* Fix getPhysicalMemorySize on OS X (#8481)Austin Seipp2013-10-261-3/+19
| | | | | | | Darwin doesn't support _SC_PHYS_PAGES, but we can get the exact number of bytes of physical memory via 'hw.memsize', so we use that instead. Signed-off-by: Austin Seipp <austin@well-typed.com>
* Untabify RtsFlags.cAustin Seipp2013-10-251-513/+513
| | | | Signed-off-by: Austin Seipp <austin@well-typed.com>
* Untabify Linker.cAustin Seipp2013-10-251-68/+68
| | | | Signed-off-by: Austin Seipp <austin@well-typed.com>
* Make sure to #include Stable.h in Linker.cAustin Seipp2013-10-251-0/+1
| | | | | | | | It needs freeStablePtr, which tripped my validate build, due to an implicit declaration warning. I'm quite surprised this somehow did not trip the build before. Signed-off-by: Austin Seipp <austin@well-typed.com>