summaryrefslogtreecommitdiff
path: root/includes
Commit message (Collapse)AuthorAgeFilesLines
* Add support for bitreverse primopAlexandre2019-04-011-0/+8
| | | | | | This commit includes the necessary changes in code and documentation to support a primop that reverses a word's bits. It also includes a test.
* Update Wiki URLs to point to GitLabTakenobu Tani2019-03-2549-53/+53
| | | | | | | | | | | | | | | | | | | | | | | This moves all URL references to Trac Wiki to their corresponding GitLab counterparts. This substitution is classified as follows: 1. Automated substitution using sed with Ben's mapping rule [1] Old: ghc.haskell.org/trac/ghc/wiki/XxxYyy... New: gitlab.haskell.org/ghc/ghc/wikis/xxx-yyy... 2. Manual substitution for URLs containing `#` index Old: ghc.haskell.org/trac/ghc/wiki/XxxYyy...#Zzz New: gitlab.haskell.org/ghc/ghc/wikis/xxx-yyy...#zzz 3. Manual substitution for strings starting with `Commentary` Old: Commentary/XxxYyy... New: commentary/xxx-yyy... See also !539 [1]: https://gitlab.haskell.org/bgamari/gitlab-migration/blob/master/wiki-mapping.json
* Fix specification of load_load_barrier [skip-ci]Peter Trommler2019-03-201-1/+1
|
* ghc-heap: Introduce closureSizeBen Gamari2019-03-171-0/+1
| | | | | | This function allows the user to compute the (non-transitive) size of a heap object in words. The "closure" in the name is admittedly confusing but we are stuck with this nomenclature at this point.
* PPC NCG: Use liveness information in CmmCallPeter Trommler2019-03-152-77/+8
| | | | | | | | | | | | | | | | | We make liveness information for global registers available on `JMP` and `BCTR`, which were the last instructions missing. With complete liveness information we do not need to reserve global registers in `freeReg` anymore. Moreover we assign R9 and R10 to callee saves registers. Cleanup by removing `Reg_Su`, which was unused, from `freeReg` and removing unused register definitions. The calculation of the number of floating point registers is too conservative. Just follow X86 and specify the constants directly. Overall on PowerPC this results in 0.3 % smaller code size in nofib while runtime is slightly better in some tests.
* Update Trac ticket URLs to point to GitLabRyan Scott2019-03-152-3/+3
| | | | | This moves all URL references to Trac tickets to their corresponding GitLab counterparts.
* Add a RTS option -xp to load PIC object anywhere in address spaceZejun Wu2019-01-301-0/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: This re-applies {D5195} with fixes for i386: * Fix unused label warnings, see {D5230} or {D5273} * Fix a silly bug introduced by moving `#if` {P190} Add a RTS option -xp to load PIC object anywhere in address space. We do this by relaxing the requirement of <0x80000000 result of `mmapForLinker` and implying USE_CONTIGUOUS_MMAP. We also need to change calls to `ocInit` and `ocGetNames` to avoid dangling pointers when the address of `oc->image` is changed by `ocAllocateSymbolExtra`. Test Plan: See {D5195}, also test under i386: ``` $ uname -a Linux watashi-arch32 4.18.5-arch1-1.0-ARCH #1 SMP PREEMPT Tue Aug 28 20:45:30 CEST 2018 i686 GNU/Linux $ cd testsuite/tests/th/ && make test ... ``` will run `./validate` on stacked diff. Reviewers: simonmar, bgamari, alpmestan, trommler, hvr, erikd Reviewed By: simonmar Subscribers: rwbarton, carter Differential Revision: https://phabricator.haskell.org/D5289
* Revert "Batch merge"Ben Gamari2019-01-301-12/+0
| | | | This reverts commit 76c8fd674435a652c75a96c85abbf26f1f221876.
* Batch mergeBen Gamari2019-01-301-0/+12
|
* Documentation for StgRetFunÖmer Sinan Ağacan2019-01-161-0/+3
|
* Fix filename in comment againPeter Trommler2019-01-161-1/+1
|
* Fix reference to stack code in commentPeter Trommler2019-01-161-1/+1
|
* Documentation and refactoring in CCS related codeÖmer Sinan Ağacan2019-01-122-36/+0
| | | | | | | | | - Remove REGISTER_CC and REGISTER_CCS macros, add functions registerCC and registerCCS to Profiling.c. - Reduce scope of symbols: CC_LIST, CCS_LIST, CC_ID, CCS_ID - Document CC_LIST and CCS_LIST
* Minor refactoring and documentation in profiling RTS codeÖmer Sinan Ağacan2019-01-031-5/+9
|
* PPC NCG: Remove Darwin supportPeter Trommler2019-01-012-22/+3
| | | | | | | Support for Mac OS X on PowerPC has been dropped by Apple years ago. We follow suit and remove PowerPC support for Darwin. Fixes #16106.
* rts: Disable fallthrough attribute when compiling with ClangBen Gamari2018-12-111-1/+5
| | | | | | Apparently clang doesn't enable implicitly fallthrough warnings by default http://llvm.org/viewvc/llvm-project?revision=167655&view=revision when compiling C and the attribute cause warnings of their own (#16019).
* Remove redundant include of Rts.h in EventLogWriter.hZejun Wu2018-12-071-2/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | `EventLogWriter.h` doesn't use anything from `Rts.h`, the include is redundant. This include is ignored when we include ``` Rts.h -> RtsAPI.h -> rts/EventLogWriter.h -> Rts.h ``` but can can cause problem when we include `RtsApi.h` directly with errors like ``` In file included from /usr/lib/ghc-8.6.2/include/RtsAPI.h:20: In file included from /usr/lib/ghc-8.6.2/include/rts/EventLogWriter.h:14: In file included from /usr/lib/ghc-8.6.2/include/Rts.h:185: /usr/lib/ghc-8.6.2/include/rts/storage/GC.h:187:29: error: unknown type name 'Capability' StgPtr allocate ( Capability *cap, W_ n ); ``` Test Plan: ./validate Reviewers: simonmar, bgamari, afarmer, erikd, alexbiehl Reviewed By: bgamari, alexbiehl Subscribers: rwbarton, carter Differential Revision: https://phabricator.haskell.org/D5395
* More efficient, non-allocating unsafeLookupStaticPtrÖmer Sinan Ağacan2018-11-161-1/+1
| | | | | | | | | | | | | | | | We now allocate the key to spt on C stack rather than in Haskell heap, avoiding allocating in `unsafeLookupStaticPtr`. This should be slightly more efficient. Test Plan: Validated locally Reviewers: simonmar, hvr, bgamari, erikd Reviewed By: simonmar Subscribers: rwbarton, carter Differential Revision: https://phabricator.haskell.org/D5333
* Add Int8# and Word8#Michal Terepeta2018-11-021-3/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is the first step of implementing: https://github.com/ghc-proposals/ghc-proposals/pull/74 The main highlights/changes: primops.txt.pp gets two new sections for two new primitive types for signed and unsigned 8-bit integers (Int8# and Word8 respectively) along with basic arithmetic and comparison operations. PrimRep/RuntimeRep get two new constructors for them. All of the primops translate into the existing MachOPs. For CmmCalls the codegen will now zero-extend the values at call site (so that they can be moved to the right register) and then truncate them back their original width. x86 native codegen needed some updates, since it wasn't able to deal with the new widths, but all the changes are quite localized. LLVM backend seems to just work. This is the second attempt at merging this, after the first attempt in D4475 had to be backed out due to regressions on i386. Bumps binary submodule. Signed-off-by: Michal Terepeta <michal.terepeta@gmail.com> Test Plan: ./validate (on both x86-{32,64}) Reviewers: bgamari, hvr, goldfire, simonmar Subscribers: rwbarton, carter Differential Revision: https://phabricator.haskell.org/D5258
* rts: Add FALLTHROUGH macroBen Gamari2018-11-021-0/+7
| | | | | | | | | | | | | | | | | | | Instead of using the GCC `/* fallthrough */` syntax we now use the `__attribute__((fallthrough))`, which Phyx says should be more portable than the former. Also adds a missing fallthrough annotation in the MachO linker, fixing #14613. Reviewers: erikd, simonmar Reviewed By: simonmar Subscribers: rwbarton, carter GHC Trac Issues: #14613 Differential Revision: https://phabricator.haskell.org/D5292
* rts: Allow output filename of eventlog to be given by command-lineBen Gamari2018-11-021-0/+1
| | | | | | | | | | | | | | | This introduces the `+RTS -ol` flag, which allows user to specify the destination file for eventlog output. Test Plan: Validate with included test Reviewers: simonmar, erikd Reviewed By: simonmar Subscribers: rwbarton, carter Differential Revision: https://phabricator.haskell.org/D5293
* Revert "Add a RTS option -xp to load PIC object anywhere in address space"Ben Gamari2018-10-301-12/+0
| | | | This reverts commit 5403a8636fe82f971234873564f3a05393b89b7a.
* includes: Allow headers to be built with C++11 compilersBen Gamari2018-10-281-2/+2
| | | | | | | | | | | | | | | | | | | | | | Summary: Fixes #14784. Note that C++11 is quite conservative; we could likely accept C++03 as well. Test Plan: ``` $ cat >hi.c <<EOF #include <Rts.h> EOF $ g++ -std=c++11 hi.c ``` Reviewers: simonmar, hvr Subscribers: rwbarton, carter GHC Trac Issues: #14784 Differential Revision: https://phabricator.haskell.org/D5244
* Add a RTS option -xp to load PIC object anywhere in address spaceZejun Wu2018-10-151-0/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Add a RTS option -xp to load PIC object anywhere in address space. We do this by relaxing the requirement of <0x80000000 result of `mmapForLinker` and implying USE_CONTIGUOUS_MMAP. We also need to change calls to `ocInit` and `ocGetNames` to avoid dangling pointers when the address of `oc->image` is changed by `ocAllocateSymbolExtra`. Test Plan: ``` $ uname -a Linux localhost 4.18.8-arch1-1-ARCH #1 SMP PREEMPT Sat Sep 15 20:34:48 UTC 2018 x86_64 GNU/Linux $ cat mk/build.mk DYNAMIC_GHC_PROGRAMS = NO DYNAMIC_BY_DEFAULT = NO GhcRTSWays += thr_debug EXTRA_HC_OPTS += -debug WAY_p_HC_OPTS += -fPIC -fexternal-dynamic-refs $ inplace/bin/ghc-stage2 --interactive -prof +RTS -xp GHCi, version 8.7.20180928: http://www.haskell.org/ghc/ :? for help ghc-stage2: R_X86_64_32 relocation out of range: ghczmprim_GHCziTypes_ZMZN_closure = 7f690bffab59 Recompile /data/users/watashi/ghc/libraries/ghc-prim/dist-install/build/HSghc-prim -0.5.3.o with -fPIC -fexternal-dynamic-refs. ghc-stage2: unable to load package `ghc-prim-0.5.3' $ strace -f -e open,mmap inplace/bin/ghc-stage2 --interactive -prof -fexternal-interpreter -opti+RTS -opti-xp ... [pid 1355283] open("/data/users/watashi/ghc/libraries/base/dist-install/build/libHSbas e-4.12.0.0_p.a", O_RDONLY) = 14 [pid 1355283] mmap(NULL, 8192, PROT_READ|PROT_WRITE|PROT_EXEC, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f6a84842000 [pid 1355283] open("/data/users/watashi/ghc/libraries/base/dist-install/build/libHSbas e-4.12.0.0_p.a", O_RDONLY) = 14 [pid 1355283] mmap(NULL, 8192, PROT_READ|PROT_WRITE|PROT_EXEC, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f6a84676000 ... Prelude> System.Posix.Process.getProcessID ... [pid 1355283] open("/data/users/watashi/ghc/libraries/unix/dist-install/build/libHSuni x-2.7.2.2_p.a", O_RDONLY) = 14 [pid 1355283] mmap(NULL, 45056, PROT_READ|PROT_WRITE|PROT_EXEC, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f6a67d60000 [pid 1355283] open("/data/users/watashi/ghc/libraries/unix/dist-install/build/libHSuni x-2.7.2.2_p.a", O_RDONLY) = 14 [pid 1355283] mmap(NULL, 57344, PROT_READ|PROT_WRITE|PROT_EXEC, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f6a67d52000 ... ``` ``` $ uname -a Darwin watashis-iMac.local 18.0.0 Darwin Kernel Version 18.0.0: Wed Aug 22 20:13:40 PDT 2018; root:xnu-4903.201.2~1/RELEASE_X86_64 x86_64 $ mv /Users/watashi/gao/ghc/libraries/integer-gmp/dist-install/build/HSintege r-gmp-1.0.2.0.o{,._DISABLE_GHC_ISSUE_15105} $ inplace/bin/ghc-stage2 --interactive +RTS -xp GHCi, version 8.7.20181003: http://www.haskell.org/ghc/ :? for help Prelude> System.Posix.Process.getProcessID 42791 Prelude> Data.Set.fromList [1 .. 10] fromList [1,2,3,4,5,6,7,8,9,10] Prelude> Leaving GHCi. $ inplace/bin/ghc-stage2 --interactive -prof -fexternal-interpreter GHCi, version 8.7.20181003: http://www.haskell.org/ghc/ :? for help Prelude> System.Posix.Process.getProcessID 42806 Prelude> Data.Set.fromList [1 .. 10] fromList [1,2,3,4,5,6,7,8,9,10] Prelude> Leaving GHCi. ``` Also test with something that used to hit the 2Gb limit and it loads and runs without problem. Reviewers: simonmar, bgamari, angerman, Phyx, hvr, erikd Reviewed By: simonmar Subscribers: rwbarton, carter Differential Revision: https://phabricator.haskell.org/D5195
* CodeGen: Teach CodeGen about aliasing of XMM/YMM/ZMM registersBen Gamari2018-10-011-32/+34
| | | | | | | | | | Reviewers: simonmar Reviewed By: simonmar Subscribers: rwbarton, carter Differential Revision: https://phabricator.haskell.org/D5186
* Fix a MSG_BLACKHOLE sanity check, add some commentsÖmer Sinan Ağacan2018-09-241-1/+6
| | | | | | | | | | | | Reviewers: simonmar, bgamari, erikd Reviewed By: simonmar Subscribers: rwbarton, carter GHC Trac Issues: #15508 Differential Revision: https://phabricator.haskell.org/D5178
* Fix slop zeroing for AP_STACK eager blackholes in debug buildÖmer Sinan Ağacan2018-09-212-29/+23
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | As #15571 reports, eager blackholing breaks sanity checks as we can't zero the payload when eagerly blackholing (because we'll be using the payload after blackholing), but by the time we blackhole a previously eagerly blackholed object (in `threadPaused()`) we don't have the correct size information for the object (because the object's type becomes BLACKHOLE when we eagerly blackhole it) so can't properly zero the slop. This problem can be solved for AP_STACK eager blackholing (which unlike eager blackholing in general, is not optional) by zeroing the payload after entering the stack. This patch implements this idea. Fixes #15571. Test Plan: Previously concprog001 when compiled and run with sanity checks ghc-stage2 Mult.hs -debug -rtsopts ./Mult +RTS -DS was failing with Mult: internal error: checkClosure: stack frame (GHC version 8.7.20180821 for x86_64_unknown_linux) Please report this as a GHC bug: http://www.haskell.org/ghc/reportabug thic patch fixes this panic. The test still panics, but it runs for a while before panicking (instead of directly panicking as before), and the new problem seems unrelated: Mult: internal error: ASSERTION FAILED: file rts/sm/Sanity.c, line 296 (GHC version 8.7.20180919 for x86_64_unknown_linux) Please report this as a GHC bug: http://www.haskell.org/ghc/reportabug The new problem will be fixed in another diff. I also tried slow validate (which requires D5164): this does not introduce any new failures. Reviewers: simonmar, bgamari, erikd Reviewed By: simonmar Subscribers: rwbarton, carter GHC Trac Issues: #15571 Differential Revision: https://phabricator.haskell.org/D5165
* Finish stable splitDavid Feuer2018-08-295-19/+59
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Long ago, the stable name table and stable pointer tables were one. Now, they are separate, and have significantly different implementations. I believe the time has come to finish the split that began in #7674. * Divide `rts/Stable` into `rts/StableName` and `rts/StablePtr`. * Give each table its own mutex. * Add FFI functions `hs_lock_stable_ptr_table` and `hs_unlock_stable_ptr_table` and document them. These are intended to replace the previously undocumented `hs_lock_stable_tables` and `hs_lock_stable_tables`, which are now documented as deprecated synonyms. * Make `eqStableName#` use pointer equality instead of unnecessarily comparing stable name table indices. Reviewers: simonmar, bgamari, erikd Reviewed By: bgamari Subscribers: rwbarton, carter GHC Trac Issues: #15555 Differential Revision: https://phabricator.haskell.org/D5084
* Add traceBinaryEvent# primopMitsutoshi Aoe2018-08-212-1/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | This adds a new primop called traceBinaryEvent# that takes the length of binary data and a pointer to the data, then emits it to the eventlog. There is some example code that uses this primop and the new event: * [traceBinaryEventIO][1] that calls `traceBinaryEvent#` * [A patch to ghc-events][2] that parses the new `EVENT_USER_BINARY_MSG` There's no corresponding issue on Trac but it was discussed at ghc-devs [3]. [1] https://github.com/maoe/ghc-trace-events/blob /fb226011ef1f85a97b4da7cc9d5f98f9fe6316ae/src/Debug/Trace/Binary.hs#L29) [2] https://github.com/maoe/ghc-events/commit /239ca77c24d18cdd10d6d85a0aef98e4a7c56ae6) [3] https://mail.haskell.org/pipermail/ghc-devs/2018-May/015791.html Reviewers: bgamari, erikd, simonmar Reviewed By: bgamari Subscribers: rwbarton, thomie, carter Differential Revision: https://phabricator.haskell.org/D5007
* Disable GNUC_ATTR_HOT when compiling with DEBUGBen Gamari2018-07-271-1/+1
| | | | | | | | | | | | Test Plan: Validate Reviewers: simonmar Reviewed By: simonmar Subscribers: rwbarton, thomie, carter Differential Revision: https://phabricator.haskell.org/D5000
* Replace atomicModifyMutVar#David Feuer2018-07-151-1/+2
| | | | | | | | | | | | Reviewers: simonmar, hvr, bgamari, erikd, fryguybob, rrnewton Reviewed By: simonmar Subscribers: fryguybob, rwbarton, thomie, carter GHC Trac Issues: #15364 Differential Revision: https://phabricator.haskell.org/D4884
* rts: Update some comments, minor refactoringÖmer Sinan Ağacan2018-06-271-1/+6
|
* Use __FILE__ for Cmm assertion locations, fix #8619Ömer Sinan Ağacan2018-06-171-1/+1
| | | | | | | | | | | | | | | | | | | | It seems like we currently support string literals in Cmm, so we can use __LINE__ CPP macro in assertion macros. This improves error messages that previously looked like ASSERTION FAILED: file (null), line 1302 (null) part now shows the actual file name. Also inline some single-use string literals in PrimOps.cmm. Reviewers: bgamari, simonmar, erikd Reviewed By: bgamari Subscribers: rwbarton, thomie, carter Differential Revision: https://phabricator.haskell.org/D4862
* Rename some mutable closure types for consistencyÖmer Sinan Ağacan2018-06-053-12/+12
| | | | | | | | | | | | | | | | | | | | | | | 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
* rts: Rip out support for STM invariantsBen Gamari2018-06-023-23/+1
| | | | | | | | | | | | | | | | | | | | | | | This feature has some very serious correctness issues (#14310), introduces a great deal of complexity, and hasn't seen wide usage. Consequently we are removing it, as proposed in Proposal #77 [1]. This is heavily based on a patch from fryguybob. Updates stm submodule. [1] https://github.com/ghc-proposals/ghc-proposals/pull/77 Test Plan: Validate Reviewers: erikd, simonmar, hvr Reviewed By: simonmar Subscribers: rwbarton, thomie, carter GHC Trac Issues: #14310 Differential Revision: https://phabricator.haskell.org/D4760
* Update GHC.Stats docsÖmer Sinan Ağacan2018-05-281-2/+5
| | | | | | | | | | | | | | Make it clear that max_live_bytes is updated after a major GC whereas live_bytes is updated after all GCs (including minor collections) and considers data in uncollected generations as live. Reviewers: bgamari, simonmar, hvr Reviewed By: bgamari Subscribers: rwbarton, thomie, carter Differential Revision: https://phabricator.haskell.org/D4734
* Disable the SRT offset optimisation on MachO platformsBen Gamari2018-05-231-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | Unfortunately, this optimisation is infeasible on MachO platforms (e.g. Darwin) due to an object format limitation. Specifically, linking fails with errors of the form: error: unsupported relocation with subtraction expression, symbol '_integerzmgmp_GHCziIntegerziType_quotInteger_closure' can not be undefined in a subtraction expression Apparently MachO does not permit relocations' subtraction expressions to refer to undefined symbols. As far as I can tell this means that it is essentially impossible to express an offset between symbols living in different compilation units. This means that we lively can't use this optimisation on MachO platforms. Test Plan: Validate on Darwin Reviewers: simonmar, erikd Subscribers: rwbarton, thomie, carter, angerman GHC Trac Issues: #15169 Differential Revision: https://phabricator.haskell.org/D4715
* Add HeapView functionalityPatrick Dougherty2018-05-202-0/+19
| | | | | | | | | | | | | | | | | | | | | This pulls parts of Joachim Breitner's ghc-heap-view library inside GHC. The bits added are the C hooks into the RTS and a basic Haskell wrapper to these C hooks. The main reason for these to be added to GHC proper is that the code needs to be kept in sync with the closure types defined by the RTS. It is expected that the version of HeapView shipped with GHC will always work with that version of GHC and that extra functionality can be layered on top with a library like ghc-heap-view distributed via Hackage. Test Plan: validate Reviewers: simonmar, hvr, nomeata, austin, Phyx, bgamari, erikd Reviewed By: bgamari Subscribers: carter, patrickdoc, tmcgilchrist, rwbarton, thomie Differential Revision: https://phabricator.haskell.org/D3055
* Fix unwinding of C -> Haskell FFI calls with -threaded (2nd try)Bartosz Nitka2018-05-171-0/+13
| | | | | | | | | | | | | | | | | Summary: See the new note. This should fix cb5c2fe875965b7aedbc189012803fc62e48fb3f enough to unbreak Windows and OS X builds. Test Plan: manual testing with patched gdb Reviewers: bgamari, simonmar, erikd Reviewed By: bgamari Subscribers: rwbarton, thomie, carter Differential Revision: https://phabricator.haskell.org/D4694
* InfoTables: Fix #if uses introduced by D4634Ben Gamari2018-05-161-2/+2
|
* Merge FUN_STATIC closure with its SRTSimon Marlow2018-05-161-3/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | Summary: The idea here is to save a little code size and some work in the GC, by collapsing FUN_STATIC closures and their SRTs. This is (4) in a series; see D4632 for more details. There's a tradeoff here: more complexity in the compiler in exchange for a modest code size reduction (probably around 0.5%). Results: * GHC binary itself (statically linked) is 1% smaller * -0.2% binary sizes in nofib (-0.5% module sizes) Full nofib results comparing D4634 with this: P177 (ignore runtimes, these aren't stable on my laptop) Test Plan: validate, nofib Reviewers: bgamari, niteria, simonpj, erikd Subscribers: thomie, carter Differential Revision: https://phabricator.haskell.org/D4637
* Save a word in the info table on x86_64Simon Marlow2018-05-162-10/+40
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: An info table with an SRT normally looks like this: StgWord64 srt_offset StgClosureInfo layout StgWord32 layout StgWord32 has_srt But we only need 32 bits for srt_offset on x86_64, because the small memory model requires that code segments are at most 2GB. So we can optimise this to StgClosureInfo layout StgWord32 layout StgWord32 srt_offset saving a word. We can tell whether the info table has an SRT or not, because zero is not a valid srt_offset, so zero still indicates that there's no SRT. Test Plan: * validate * For results, see D4632. Reviewers: bgamari, niteria, osa1, erikd Subscribers: thomie, carter Differential Revision: https://phabricator.haskell.org/D4634
* An overhaul of the SRT representationSimon Marlow2018-05-163-39/+32
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: - Previously we would hvae a single big table of pointers per module, with a set of bitmaps to reference entries within it. The new representation is identical to a static constructor, which is much simpler for the GC to traverse, and we get to remove the complicated bitmap-traversal code from the GC. - Rewrite all the code to generate SRTs in CmmBuildInfoTables, and document it much better (see Note [SRTs]). This has been something I've wanted to do since we moved to the new code generator, I finally had the opportunity to finish it while on a transatlantic flight recently :) There are a series of 4 diffs: 1. D4632 (this one), which does the bulk of the changes 2. D4633 which adds support for smaller `CmmLabelDiffOff` constants 3. D4634 which takes advantage of D4632 and D4633 to save a word in info tables that have an SRT on x86_64. This is where most of the binary size improvement comes from. 4. D4637 which makes a further optimisation to merge some SRTs with static FUN closures. This adds some complexity and the benefits are fairly modest, so it's not clear yet whether we should do this. Results (after (3), on x86_64) - GHC itself (staticaly linked) is 5.2% smaller - -1.7% binary sizes in nofib, -2.9% module sizes. Full nofib results: P176 - I measured the overhead of traversing all the static objects in a major GC in GHC itself by doing `replicateM_ 1000 performGC` as the first thing in `Main.main`. The new version was 5-10% faster, but the results did vary quite a bit. - I'm not sure if there's a compile-time difference, the results are too unreliable. Test Plan: validate Reviewers: bgamari, michalt, niteria, simonpj, erikd, osa1 Subscribers: thomie, carter Differential Revision: https://phabricator.haskell.org/D4632
* Fix a few GCC warningsMichal Terepeta2018-05-131-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | GCC 8 now generates warnings for incompatible function pointer casts [-Werror=cast-function-type]. Apparently there are a few of those in rts code, which makes `./validate` unhappy (since we compile with `-Werror`) This commit tries to fix these issues by changing the functions to have the correct type (and, if necessary, moving the casts into those functions). For instance, hash/comparison function are declared (`Hash.h`) to take `StgWord` but we want to use `StgWord64[2]` in `StaticPtrTable.c`. Instead of casting the function pointers, we can cast the `StgWord` parameter to `StgWord*`. I think this should be ok since `StgWord` should be the same size as a pointer. Signed-off-by: Michal Terepeta <michal.terepeta@gmail.com> Test Plan: ./validate Reviewers: bgamari, erikd, simonmar Reviewed By: bgamari Subscribers: rwbarton, thomie, carter Differential Revision: https://phabricator.haskell.org/D4673
* Revert "Fix unwinding of C -> Haskell FFI calls with -threaded"Bartosz Nitka2018-05-121-13/+0
| | | | | | This reverts commit cb5c2fe875965b7aedbc189012803fc62e48fb3f. It appears to have broken OSX and Windows builds.
* Fix unwinding of C -> Haskell FFI calls with -threadedBartosz Nitka2018-05-111-0/+13
| | | | | | | | | | | | | See the new note. Test Plan: manual testing with patched gdb Reviewers: bgamari, simonmar, erikd Subscribers: rwbarton, thomie, carter Differential Revision: https://phabricator.haskell.org/D4666
* rts: remove unused round_up_to_mblocks functionÖmer Sinan Ağacan2018-05-101-9/+0
|
* Stable.c: minor refactoring, add/update some commentsÖmer Sinan Ağacan2018-04-251-4/+12
| | | | | | | | | | | | Test Plan: Passes validate Reviewers: simonmar, bgamari, erikd Subscribers: thomie, carter GHC Trac Issues: #10296 Differential Revision: https://phabricator.haskell.org/D4627
* rts: Comment wibblesBen Gamari2018-04-161-1/+1
|
* Remove unused bdescr flag BF_FREEÖmer Sinan Ağacan2018-04-051-2/+0
| | | | | | | | | | Reviewers: bgamari, simonmar, erikd Reviewed By: bgamari, simonmar Subscribers: thomie, carter Differential Revision: https://phabricator.haskell.org/D4539