summaryrefslogtreecommitdiff
path: root/rts/Linker.c
Commit message (Collapse)AuthorAgeFilesLines
...
* 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>
* Typo in commentGabor Greif2013-09-241-1/+1
|
* Fix linker_unload now that we are running constructors in the linker (#8291)Simon Marlow2013-09-231-0/+49
| | | | | | | 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-0/+3
|
* Add support for 256-bit-wide vectors.Geoffrey Mainland2013-09-221-0/+3
|
* Add warning comment about Mach-O section name hack.Edward Z. Yang2013-09-171-0/+5
| | | | Signed-off-by: Edward Z. Yang <ezyang@mit.edu>
* Implement ctors support for Linux.Edward Z. Yang2013-09-161-6/+21
| | | | Signed-off-by: Edward Z. Yang <ezyang@mit.edu>
* Run ctors initializers backwards, see #5435.Edward Z. Yang2013-09-151-5/+5
| | | | Signed-off-by: Edward Z. Yang <ezyang@mit.edu>
* add stg_MUT_VAR_CLEAN_info and stg_MUT_VAR_DIRTY_info to the symbol tableSimon Marlow2013-09-141-0/+2
|
* Implement __mod_init_func for Mach-O. Finishes support for init in #5435.Edward Z. Yang2013-09-131-24/+57
| | | | Signed-off-by: Edward Z. Yang <ezyang@mit.edu>
* Implement .ctor support for PEi386.Edward Z. Yang2013-09-131-5/+50
| | | | Signed-off-by: Edward Z. Yang <ezyang@mit.edu>
* Implement .init/.init_array support for ELF.Edward Z. Yang2013-09-131-0/+59
| | | | Signed-off-by: Edward Z. Yang <ezyang@mit.edu>