summaryrefslogtreecommitdiff
path: root/rts/Linker.c
Commit message (Collapse)AuthorAgeFilesLines
* Fix typo in section name: no leading period.Edward Z. Yang2014-10-031-1/+1
| | | | Signed-off-by: Edward Z. Yang <ezyang@cs.stanford.edu>
* Check for staticclosures section in Windows linker.Edward Z. Yang2014-10-031-0/+1
| | | | Signed-off-by: Edward Z. Yang <ezyang@cs.stanford.edu>
* 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-291-8/+0
| | | | This reverts commit 39b5c1cbd8950755de400933cecca7b8deb4ffcd.
* `M-x delete-trailing-whitespace` & `M-x untabify`Herbert Valerio Riedel2014-09-241-1/+1
|
* Implement `decodeDouble_Int64#` primopHerbert Valerio Riedel2014-09-171-0/+1
| | | | | | | | | | | | | | | The existing `decodeDouble_2Int#` primop is rather inconvenient to use (and in fact is not even used by `integer-gmp`) as the mantissa is split into 3 components which would actually fit in an `Int64#` value. However, `decodeDouble_Int64#` is to be used by the new `integer-gmp2` re-implementation (see #9281). Moreover, `decodeDouble_2Int#` performs direct bit-wise operations on the IEEE representation which can be replaced by a combination of the portable standard C99 `scalbn(3)` and `frexp(3)` functions. Differential Revision: https://phabricator.haskell.org/D160
* Revert "Revert "rts/base: Fix #9423"" and resolve issue that caused the revert.Andreas Voellmy2014-09-161-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* rts/Linker.c: declare 'deRefStablePtr' as an exported 'rts' symbolSergei Trofimovich2014-08-231-0/+1
| | | | | | | | | | | | | | | | | | | | | | $ inplace/bin/ghc-stage2 -fforce-recomp -dcore-lint -dcmm-lint -dno-debug-output -no-user-package-db -rtsopts -optc-fno-builtin -fno-ghci-history \ testsuite/tests/ffi/should_run/T4038.hs --interactive -v0 -ignore-dot-ghci +RTS -I0.1 -RTS *Main> main <interactive>: /tmp/ghc16668_0/ghc16668_5.o: unknown symbol `deRefStablePtr' The reference to 'deRefStablePtr' is generated by 'compiler/deSugar/DsForeign.lhs': the_cfun = case maybe_target of Nothing -> text "(StgClosure*)deRefStablePtr(the_stableptr)" Just hs_fn -> char '&' <> ppr hs_fn <> text "_closure" Patch fixes all broken tests using 'import wrapper': TEST="ffi013 ffi010 ffi011 ffi005 ffi020 ffi006 ffi019 fed001 T1679 T4038" Tests manifested as broken only in DYNAMIC_GHC_PROGRAMS=NO builds, where GHCi's custom linker is used instead of system's linker. Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org>
* Revert "rts/base: Fix #9423"Austin Seipp2014-08-221-1/+0
| | | | | | | | | 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>
* Add a missing newline to a GHCi linker debugBelchReid Barton2014-08-201-1/+1
|
* rts/base: Fix #9423Andreas Voellmy2014-08-191-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* Have the RTS linker search symbols in the originating windows binary.Facundo Domínguez2014-08-181-6/+14
| | | | | | | | | | | | | | | | Summary: In initLinker, this patch adds the handle of the module corresponding to the program binary to the list of DLL handles that lookupSymbol uses to search for symbols. Test Plan: validate Reviewers: simonmar, austin Reviewed By: simonmar, austin Subscribers: phaskell, simonmar, relrod, ezyang, carter Differential Revision: https://phabricator.haskell.org/D103 GHC Trac Issues: #9382
* Revert "Fix typos 'resizze'"Gabor Greif2014-08-161-1/+1
| | | | | | this is z-encoding (as hvr tells me) This reverts commit 425d5178af55620efa00e6e16426f491c63ad533.
* Fix typos 'resizze'Gabor Greif2014-08-161-1/+1
|
* Implement {resize,shrink}MutableByteArray# primopsHerbert Valerio Riedel2014-08-161-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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: add Emacs 'Local Variables' to every .c fileAustin Seipp2014-07-281-0/+8
| | | | | | | | 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>
* Re-add more primops for atomic ops on byte arraysJohan Tibell2014-06-301-1/+0
| | | | | | | | | | | | | | | | | | | | | | | This is the second attempt to add this functionality. The first attempt was reverted in 950fcae46a82569e7cd1fba1637a23b419e00ecd, due to register allocator failure on x86. Given how the register allocator currently works, we don't have enough registers on x86 to support cmpxchg using complicated addressing modes. Instead we fall back to a simpler addressing mode on x86. Adds the following primops: * atomicReadIntArray# * atomicWriteIntArray# * fetchSubIntArray# * fetchOrIntArray# * fetchXorIntArray# * fetchAndIntArray# Makes these pre-existing out-of-line primops inline: * fetchAddIntArray# * casIntArray#
* Revert "Fix obscure problem with using the system linker (#8935)"Austin Seipp2014-06-301-34/+9
| | | | | | This reverts commit 2f8b4c9330b455d4cb31c186c747a7db12a69251. Signed-off-by: Austin Seipp <austin@well-typed.com>
* Revert "Add more primops for atomic ops on byte arrays"Johan Tibell2014-06-261-0/+1
| | | | | | | | This commit caused the register allocator to fail on i386. This reverts commit d8abf85f8ca176854e9d5d0b12371c4bc402aac3 and 04dd7cb3423f1940242fdfe2ea2e3b8abd68a177 (the second being a fix to the first).
* Add more primops for atomic ops on byte arraysJohan Tibell2014-06-241-1/+0
| | | | | | | | | | | | | | | | | | | Summary: Add more primops for atomic ops on byte arrays Adds the following primops: * atomicReadIntArray# * atomicWriteIntArray# * fetchSubIntArray# * fetchOrIntArray# * fetchXorIntArray# * fetchAndIntArray# Makes these pre-existing out-of-line primops inline: * fetchAddIntArray# * casIntArray#
* Fix obscure problem with using the system linker (#8935)Simon Marlow2014-06-081-9/+34
| | | | See Note [RTLD_LOCAL] for a summary of the problem and solution, and
* Add ".text.unlikely" to recognized code sections on Windows.Niklas Larsson2014-06-051-0/+1
| | | | | | Fixes #9080 Signed-off-by: Austin Seipp <austin@well-typed.com>
* Revert "Per-thread allocation counters and limits"Simon Marlow2014-05-041-4/+0
| | | | | | | | 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-021-0/+4
| | | | | | | | | | | | | | | | | | | | | | | 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: Fix memory leak when loading ELF objectsAustin Seipp2014-04-291-0/+1
| | | | | | Issue discovered by Coverity Scan, CID 43168. Signed-off-by: Austin Seipp <austin@well-typed.com>
* rts: Fix leak of file archive handleAustin Seipp2014-04-291-0/+1
| | | | | | Issue discovered by Coverity Scan, CID 43171. Signed-off-by: Austin Seipp <austin@well-typed.com>
* coverity: Suppress some time-of-check-time-of-use reportsAustin Seipp2014-04-271-0/+4
| | | | | | CID 43178 Signed-off-by: Austin Seipp <austin@well-typed.com>
* Fix linked list manipulation code (buggy on consecutive deletion)Edward Z. Yang2014-04-121-2/+4
| | | | Signed-off-by: Edward Z. Yang <ezyang@cs.stanford.edu>
* Ignore repeated loads of the same archive (#8942)Simon Marlow2014-04-071-18/+32
|
* Disable thin archive support on WindowsSimon Marlow2014-04-041-1/+14
|
* Support thin archive formatSimon Marlow2014-04-011-49/+90
| | | | | | | | | | | | This is a patch from FB's internal build of GHC that I'm pushing upstream. Author: Andrew Gallagher <agallagher@fb.com> This diff adds simple thin archive support to ghc's linker code, which basically just entails finding the member data from disk rather than from inside the archive (except for the case of the symbol index and gnu filename index, where the member data is still inline).
* Add more missing linker symbolsJohan Tibell2014-03-291-0/+3
|
* Add missing symbols to linkerJohan Tibell2014-03-291-1/+5
| | | | The copy array family of primops were moved out-of-line.
* Add SmallArray# and SmallMutableArray# typesJohan Tibell2014-03-291-0/+9
| | | | | | | | | | | | | | | 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.
* codeGen: inline allocation optimization for clone array primopsJohan Tibell2014-03-221-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | The inline allocation version is 69% faster than the out-of-line version, when cloning an array of 16 unit elements on a 64-bit machine. Comparing the new and the old primop implementations isn't straightforward. The old version had a missing heap check that I discovered during the development of the new version. Comparing the old and the new version would requiring fixing the old version, which in turn means reimplementing the equivalent of MAYBE_CG in StgCmmPrim. The inline allocation threshold is configurable via -fmax-inline-alloc-size which gives the maximum array size, in bytes, to allocate inline. The size does not include the closure header size. Allowing the same primop to be either inline or out-of-line has some implication for how we lay out heap checks. We always place a heap check around out-of-line primops, as they may allocate outside of our knowledge. However, for the inline primops we only allow allocation via the standard means (i.e. virtHp). Since the clone primops might be either inline or out-of-line the heap check layout code now consults shouldInlinePrimOp to know whether a primop will be inlined.
* linker: Fix indirect calls for x86_64 windows (#2283)Kyrill Briantsev2014-03-211-2/+28
| | | | 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>
* Win64 linker: fix loading foreign imports (#2283)Kyrill Briantsev2014-01-281-0/+17
| | | | 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>
* 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/+16
| | | | | | | | | 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.
* 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>
* Linker.c: add dso_handle to the symbol tableTakano Akio2013-10-251-0/+7
| | | | Signed-off-by: Austin Seipp <austin@well-typed.com>
* ghci: add support for ELF weak symbolsTakano Akio2013-10-251-23/+77
| | | | Signed-off-by: Austin Seipp <austin@well-typed.com>
* Linker.c: remove stablehash, which is no longer usedTakano Akio2013-10-251-29/+2
| | | | Signed-off-by: Austin Seipp <austin@well-typed.com>
* Add rts_isDynamic to the linker symbol listAustin Seipp2013-10-121-0/+1
| | | | | | Spotted by Bertram Felgenhauer. Signed-off-by: Austin Seipp <austin@well-typed.com>