summaryrefslogtreecommitdiff
path: root/rts/CheckUnload.c
Commit message (Collapse)AuthorAgeFilesLines
* rts: use allocation helpers from RtsUtilsnineonine2021-12-101-3/+3
| | | | | | | Just a tiny cleanup inspired by the following comment: https://gitlab.haskell.org/ghc/ghc/-/issues/19437#note_334271 I was just getting familiar with rts code base so I thought might as well do this.
* Fix comment typosKirill Zaborsky2021-09-291-2/+2
|
* Make `PosixSource.h` installed and under `rts/`John Ericson2021-08-091-1/+1
| | | | | | is used outside of the rts so we do this rather than just fish it out of the repo in ad-hoc way, in order to make packages in this repo more self-contained.
* rts: Make markLiveObject thread-safeBen Gamari2021-03-041-2/+8
| | | | | | | | markLiveObject is called by GC worker threads and therefore must be thread-safe. This was a rather egregious oversight which the testsuite missed. (cherry picked from commit fe28a062e47bd914a6879f2d01ff268983c075ad)
* Add loadNativeObj and unloadNativeObjRay Shih2020-11-111-10/+35
| | | | | | | | | | | | | | | | | | | (This change is originally written by niteria) This adds two functions: * `loadNativeObj` * `unloadNativeObj` and implements them for Linux. They are useful if you want to load a shared object with Haskell code using the system linker and have GHC call dlclose() after the code is no longer referenced from the heap. Using the system linker allows you to load the shared object above outside the low-mem region. It also loads the DWARF sections in a way that `perf` understands. `dl_iterate_phdr` is what makes this implementation Linux specific.
* Fix and enable object unloading in GHCiÖmer Sinan Ağacan2020-11-111-359/+355
| | | | | | | Fixes #16525 by tracking dependencies between object file symbols and marking symbol liveness during garbage collection See Note [Object unloading] in CheckUnload.c for details.
* Fix #16525: ObjectCode freed wrongly because of lack of info header checkPhuong Trinh2019-06-131-0/+1
| | | | | | | `checkUnload` currently doesn't check the info header of static objects. Thus, it may free an `ObjectCode` struct wrongly even if there's still a live static object whose info header lies in a mapped section of that `ObjectCode`. This fixes the issue by adding an appropriate check.
* Fix an error message in CheckUnload.c:searchHeapBlocksÖmer Sinan Ağacan2019-06-111-1/+1
|
* Apply suggestion to rts/CheckUnload.cTrịnh Tuấn Phương2019-05-301-1/+2
|
* Apply suggestion to rts/CheckUnload.cTrịnh Tuấn Phương2019-05-301-1/+1
|
* Use binary search to speedup checkUnloadPhuong Trinh2019-05-301-32/+135
| | | | | | | | | We are iterating through all object code for each heap objects when checking whether object code can be unloaded. For large projects in GHCi, this can be very expensive due to the large number of object code that needs to be loaded/unloaded. To speed it up, this arrangess all mapped sections of unloaded object code in a sorted array and use binary search to check if an address location fall on them.
* Rename some mutable closure types for consistencyÖmer Sinan Ağacan2018-06-051-4/+4
| | | | | | | | | | | | | | | | | | | | | | | SMALL_MUT_ARR_PTRS_FROZEN0 -> SMALL_MUT_ARR_PTRS_FROZEN_DIRTY SMALL_MUT_ARR_PTRS_FROZEN -> SMALL_MUT_ARR_PTRS_FROZEN_CLEAN MUT_ARR_PTRS_FROZEN0 -> MUT_ARR_PTRS_FROZEN_DIRTY MUT_ARR_PTRS_FROZEN -> MUT_ARR_PTRS_FROZEN_CLEAN Naming is now consistent with other CLEAR/DIRTY objects (MVAR, MUT_VAR, MUT_ARR_PTRS). (alternatively we could rename MVAR_DIRTY/MVAR_CLEAN etc. to MVAR0/MVAR) Removed a few comments in Scav.c about FROZEN0 being on the mut_list because it's now clear from the closure type. Reviewers: bgamari, simonmar, erikd Reviewed By: simonmar Subscribers: rwbarton, thomie, carter Differential Revision: https://phabricator.haskell.org/D4784
* Prefer #if defined to #ifdefBen Gamari2017-04-281-2/+2
| | | | Our new CPP linter enforces this.
* Use C99's boolBen Gamari2016-11-291-16/+16
| | | | | | | | | | | | Test Plan: Validate on lots of platforms Reviewers: erikd, simonmar, austin Reviewed By: erikd, simonmar Subscribers: michalt, thomie Differential Revision: https://phabricator.haskell.org/D2699
* Remove CONSTR_STATICSimon Marlow2016-11-141-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: We currently have two info tables for a constructor * XXX_con_info: the info table for a heap-resident instance of the constructor, It has type CONSTR, or one of the specialised types like CONSTR_1_0 * XXX_static_info: the info table for a static instance of this constructor, which has type CONSTR_STATIC or CONSTR_STATIC_NOCAF. I'm getting rid of the latter, and using the `con_info` info table for both static and dynamic constructors. For rationale and more details see Note [static constructors] in SMRep.hs. I also removed these macros: `isSTATIC()`, `ip_STATIC()`, `closure_STATIC()`, since they relied on the CONSTR/CONSTR_STATIC distinction, and anyway HEAP_ALLOCED() does the same job. Test Plan: validate Reviewers: bgamari, simonpj, austin, gcampax, hvr, niteria, erikd Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D2690 GHC Trac Issues: #12455
* rts: More const correct-ness fixesErik de Castro Lopo2016-05-181-3/+3
| | | | | | | | | | | | | | | | | | | | In addition to more const-correctness fixes this patch fixes an infelicity of the previous const-correctness patch (995cf0f356) which left `UNTAG_CLOSURE` taking a `const StgClosure` pointer parameter but returning a non-const pointer. Here we restore the original type signature of `UNTAG_CLOSURE` and add a new function `UNTAG_CONST_CLOSURE` which takes and returns a const `StgClosure` pointer and uses that wherever possible. Test Plan: Validate on Linux, OS X and Windows Reviewers: Phyx, hsyl20, bgamari, austin, simonmar, trofi Reviewed By: simonmar, trofi Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D2231
* rts: Replace `nat` with `uint32_t`Erik de Castro Lopo2016-05-051-2/+2
| | | | | | | | | | | | The `nat` type was an alias for `unsigned int` with a comment saying it was at least 32 bits. We keep the typedef in case client code is using it but mark it as deprecated. Test Plan: Validated on Linux, OS X and Windows Reviewers: simonmar, austin, thomie, hvr, bgamari, hsyl20 Differential Revision: https://phabricator.haskell.org/D2166
* Check CCS tree for pointers into shared object during checkUnloadAndrew Farmer2016-04-171-0/+31
| | | | | | | | | | | | | | | | | | | Prevent shared objects from being unloaded if cost centre stacks point at the object. This will prevent segfault in #11776, but also prevents objects from ever being unloaded when profiling. Pruning CCS tree will enable that in another diff. Test Plan: make TEST=linker_profiled, examine linker_profiled.run.stderr Reviewers: austin, simonmar, bgamari Reviewed By: simonmar, bgamari Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D2069 GHC Trac Issues: #11776
* Remove unused IND_PERMJoachim Breitner2016-01-231-1/+0
| | | | | | | | | | | | | | | | | it seems that this closure type has not been in use since 5d52d9, so all this is dead and untested code. This removes it. Some of the code might be useful for a counting indirection as described in #10613, so when implementing that, have a look at what this commit removes. Test Plan: validate on harbormaster Reviewers: austin, bgamari, simonmar Reviewed By: simonmar Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D1821
* ELF/x86_64: map object file sections separately into the low 2GBSimon Marlow2015-10-151-4/+10
| | | | | | | | | | | | | | | | | | | | | | | On 64-bit ELF we need to link object files into the low 2GB due to the small memory model. Previously we would map the entire object file using MAP_32BIT, but the object file can consist of 75% or more symbols, which only need to be present during linking, so this is wasteful. In our particular application, we're already running out of space here. This patch changes the way we load object files on ELF platforms so that the object is first mapped above the 2GB boundary, parsed, and then the important sections are re-mapped into the low 2GB area. Test Plan: validate (also needs testing on OS X & Windows, preferably 32 & 64 bit) Reviewers: Phyx, trommler, bgamari, austin Subscribers: hsyl20, thomie, bgamari Differential Revision: https://phabricator.haskell.org/D975
* s/StgArrWords/StgArrBytes/Siddhanathan Shanmugam2015-09-111-1/+1
| | | | | | | | | | Rename StgArrWords to StgArrBytes (see Trac #8552) Reviewed By: austin Differential Revision: https://phabricator.haskell.org/D1233 GHC Trac Issues: #8552
* Eliminate zero_static_objects_list()Simon Marlow2015-07-281-2/+4
| | | | | | | | | | | | | | | | | | | | | | | | | Summary: [Revised version of D1076 that was committed and then backed out] In a workload with a large amount of code, zero_static_objects_list() takes a significant amount of time, and furthermore it is in the single-threaded part of the GC. This patch uses a slightly fiddly scheme for marking objects on the static object lists, using a flag in the low 2 bits that flips between two states to indicate whether an object has been visited during this GC or not. We also have to take into account objects that have not been visited yet, which might appear at any time due to runtime linking. Test Plan: validate Reviewers: austin, ezyang, rwbarton, bgamari, thomie Reviewed By: bgamari, thomie Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D1106
* Revert "Eliminate zero_static_objects_list()"Simon Marlow2015-07-271-4/+2
| | | | This reverts commit b949c96b4960168a3b399fe14485b24a2167b982.
* Eliminate zero_static_objects_list()Simon Marlow2015-07-221-2/+4
| | | | | | | | | | | | | | | | | | | | | Summary: In a workload with a large amount of code, zero_static_objects_list() takes a significant amount of time, and furthermore it is in the single-threaded part of the GC. This patch uses a slightly fiddly scheme for marking objects on the static object lists, using a flag in the low 2 bits that flips between two states to indicate whether an object has been visited during this GC or not. We also have to take into account objects that have not been visited yet, which might appear at any time due to runtime linking. Test Plan: validate Reviewers: austin, bgamari, ezyang, rwbarton Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D1076
* Allow the linker to run concurrently with the GCSimon Marlow2015-01-131-2/+2
|
* Revert "Revert "Make the linker API thread-safe""Simon Marlow2014-12-051-0/+4
| | | | | | | Also includes a fix for the segfaults on Windows caused by the original version of this patch. This reverts commit 4b51194df4090d984f02c12128e868077660fb8b.
* Revert "Make the linker API thread-safe"Simon Peyton Jones2014-12-021-4/+0
| | | | | | | | | | | | | | | | This reverts commit b5e8b3b162b3ff15ae6caf1afc659565365f54a8. I reverted it because one of these two patches 9e6e4796437a7fc23e83605a45db9b2663570123 Add purgeObj() b5e8b3b162b3ff15ae6caf1afc659565365f54a8 Make the linker API thread-safe causes a seg-fault on Windows. The seg-fault happens immediately the linker is invoked, in ghci or in Template Haskell. I believe that it is the "linker API thread-safe" commit that causes the seg-fault; it happens even if the "purgeObj" commit alone is reverted. But since the two patches mess with the same code, to revert the "linker API" patch I had revert both.
* Make the linker API thread-safeSimon Marlow2014-11-281-0/+4
| | | | | | We used to be able to rely on the client to use the API in a single-threaded way, but now that the GC calls into the linker to unload objects this isn't a safe assumption.
* [skip ci] rts: Detabify CheckUnload.cAustin Seipp2014-10-211-96/+96
| | | | Signed-off-by: Austin Seipp <austin@well-typed.com>
* Revert "rts: add Emacs 'Local Variables' to every .c file"Simon Marlow2014-09-291-8/+0
| | | | This reverts commit 39b5c1cbd8950755de400933cecca7b8deb4ffcd.
* 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>
* Fix linked list manipulation code (buggy on consecutive deletion)Edward Z. Yang2014-04-121-1/+2
| | | | Signed-off-by: Edward Z. Yang <ezyang@cs.stanford.edu>
* Add SmallArray# and SmallMutableArray# typesJohan Tibell2014-03-291-0/+8
| | | | | | | | | | | | | | | 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.
* CheckUnload needs to look at revertible_caf_listSimon Marlow2013-11-211-0/+7
| | | | Retained CAFs must keep an object file alive.
* Don't refer to oc->next after freeing oc.Simon Marlow2013-09-041-2/+3
|
* Fix printf formats for pathchar on Windows (where it's wchar_t, not char)Simon Marlow2013-09-041-4/+4
|
* Really unload object code when it is safe to do so (#8039)Simon Marlow2013-08-221-0/+303
The next major GC after an unloadObj() will do a traversal of the heap to determine whether the object code can be removed from memory or not. We'll keep doing these until it is safe to remove the object code. In my experiments with GHCi, the objects get unloaded immediately, which is a good sign: we're not accidentally holding on to any references anywhere in the GHC data structures. Changes relative to the patch earlier posted on the ticket: - fix two memory leaks discovered with Valgrind, after testing with tests/rts/linker_unload.c