summaryrefslogtreecommitdiff
path: root/rts/Exception.cmm
Commit message (Collapse)AuthorAgeFilesLines
* Make profiling work with multiple capabilities (+RTS -N)Simon Marlow2011-11-291-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | This means that both time and heap profiling work for parallel programs. Main internal changes: - CCCS is no longer a global variable; it is now another pseudo-register in the StgRegTable struct. Thus every Capability has its own CCCS. - There is a new built-in CCS called "IDLE", which records ticks for Capabilities in the idle state. If you profile a single-threaded program with +RTS -N2, you'll see about 50% of time in "IDLE". - There is appropriate locking in rts/Profiling.c to protect the shared cost-centre-stack data structures. This patch does enough to get it working, I have cut one big corner: the cost-centre-stack data structure is still shared amongst all Capabilities, which means that multiple Capabilities will race when updating the "allocations" and "entries" fields of a CCS. Not only does this give unpredictable results, but it runs very slowly due to cache line bouncing. It is strongly recommended that you use -fno-prof-count-entries to disable the "entries" count when profiling parallel programs. (I shall add a note to this effect to the docs).
* Fix trashing of the masking state in STM (#5238)Simon Marlow2011-11-161-18/+21
|
* +RTS -xc: print a the closure type of the exception tooSimon Marlow2011-11-141-1/+3
|
* Overhaul of infrastructure for profiling, coverage (HPC) and breakpointsSimon Marlow2011-11-021-1/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | User visible changes ==================== Profilng -------- Flags renamed (the old ones are still accepted for now): OLD NEW --------- ------------ -auto-all -fprof-auto -auto -fprof-exported -caf-all -fprof-cafs New flags: -fprof-auto Annotates all bindings (not just top-level ones) with SCCs -fprof-top Annotates just top-level bindings with SCCs -fprof-exported Annotates just exported bindings with SCCs -fprof-no-count-entries Do not maintain entry counts when profiling (can make profiled code go faster; useful with heap profiling where entry counts are not used) Cost-centre stacks have a new semantics, which should in most cases result in more useful and intuitive profiles. If you find this not to be the case, please let me know. This is the area where I have been experimenting most, and the current solution is probably not the final version, however it does address all the outstanding bugs and seems to be better than GHC 7.2. Stack traces ------------ +RTS -xc now gives more information. If the exception originates from a CAF (as is common, because GHC tends to lift exceptions out to the top-level), then the RTS walks up the stack and reports the stack in the enclosing update frame(s). Result: +RTS -xc is much more useful now - but you still have to compile for profiling to get it. I've played around a little with adding 'head []' to GHC itself, and +RTS -xc does pinpoint the problem quite accurately. I plan to add more facilities for stack tracing (e.g. in GHCi) in the future. Coverage (HPC) -------------- * derived instances are now coloured yellow if they weren't used * likewise record field names * entry counts are more accurate (hpc --fun-entry-count) * tab width is now correct (markup was previously off in source with tabs) Internal changes ================ In Core, the Note constructor has been replaced by Tick (Tickish b) (Expr b) which is used to represent all the kinds of source annotation we support: profiling SCCs, HPC ticks, and GHCi breakpoints. Depending on the properties of the Tickish, different transformations apply to Tick. See CoreUtils.mkTick for details. Tickets ======= This commit closes the following tickets, test cases to follow: - Close #2552: not a bug, but the behaviour is now more intuitive (test is T2552) - Close #680 (test is T680) - Close #1531 (test is result001) - Close #949 (test is T949) - Close #2466: test case has bitrotted (doesn't compile against current version of vector-space package)
* Fix #4988: we were wrongly running exception handlers in theSimon Marlow2011-09-011-7/+9
| | | | | | | | | | maskUninterruptible state instead of ordinary mask, due to a misinterpretation of the way the TSO_INTERRUPTIBLE flag works. Remarkably this must have been broken for quite some time. Indeed we even had a test that demonstrated the wrong behaviour (conc015a) but presumably I didn't look hard enough at the output to notice that it was wrong.
* Implement stack chunks and separate TSO/STACK objectsSimon Marlow2010-12-151-9/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch makes two changes to the way stacks are managed: 1. The stack is now stored in a separate object from the TSO. This means that it is easier to replace the stack object for a thread when the stack overflows or underflows; we don't have to leave behind the old TSO as an indirection any more. Consequently, we can remove ThreadRelocated and deRefTSO(), which were a pain. This is obviously the right thing, but the last time I tried to do it it made performance worse. This time I seem to have cracked it. 2. Stacks are now represented as a chain of chunks, rather than a single monolithic object. The big advantage here is that individual chunks are marked clean or dirty according to whether they contain pointers to the young generation, and the GC can avoid traversing clean stack chunks during a young-generation collection. This means that programs with deep stacks will see a big saving in GC overhead when using the default GC settings. A secondary advantage is that there is much less copying involved as the stack grows. Programs that quickly grow a deep stack will see big improvements. In some ways the implementation is simpler, as nothing special needs to be done to reclaim stack as the stack shrinks (the GC just recovers the dead stack chunks). On the other hand, we have to manage stack underflow between chunks, so there's a new stack frame (UNDERFLOW_FRAME), and we now have separate TSO and STACK objects. The total amount of code is probably about the same as before. There are new RTS flags: -ki<size> Sets the initial thread stack size (default 1k) Egs: -ki4k -ki2m -kc<size> Sets the stack chunk size (default 32k) -kb<size> Sets the stack chunk buffer size (default 1k) -ki was previously called just -k, and the old name is still accepted for backwards compatibility. These new options are documented.
* Follow GHC.Bool/GHC.Types mergeIan Lynagh2010-10-231-3/+3
|
* remove unnecessary stg_noForceIO (#3508)Simon Marlow2010-09-241-4/+3
|
* New asynchronous exception control API (ghc parts)Simon Marlow2010-07-081-45/+111
| | | | | | | | | | | | | | | | | | | | | | | | As discussed on the libraries/haskell-cafe mailing lists http://www.haskell.org/pipermail/libraries/2010-April/013420.html This is a replacement for block/unblock in the asychronous exceptions API to fix a problem whereby a function could unblock asynchronous exceptions even if called within a blocked context. The new terminology is "mask" rather than "block" (to avoid confusion due to overloaded meanings of the latter). In GHC, we changed the names of some primops: blockAsyncExceptions# -> maskAsyncExceptions# unblockAsyncExceptions# -> unmaskAsyncExceptions# asyncExceptionsBlocked# -> getMaskingState# and added one new primop: maskUninterruptible# See the accompanying patch to libraries/base for the API changes.
* add a MAYBE_GC() in killThread#, fixes throwto003(threaded2) loopingSimon Marlow2010-05-051-0/+2
|
* Use message-passing to implement throwTo in the RTSSimon Marlow2010-03-111-24/+19
| | | | | | | | | | | | | | | | | | | | | | | | | | | | This replaces some complicated locking schemes with message-passing in the implementation of throwTo. The benefits are - previously it was impossible to guarantee that a throwTo from a thread running on one CPU to a thread running on another CPU would be noticed, and we had to rely on the GC to pick up these forgotten exceptions. This no longer happens. - the locking regime is simpler (though the code is about the same size) - threads can be unblocked from a blocked_exceptions queue without having to traverse the whole queue now. It's a rare case, but replaces an O(n) operation with an O(1). - generally we move in the direction of sharing less between Capabilities (aka HECs), which will become important with other changes we have planned. Also in this patch I replaced several STM-specific closure types with a generic MUT_PRIM closure type, which allowed a lot of code in the GC and other places to go away, hence the line-count reduction. The message-passing changes resulted in about a net zero line-count difference.
* micro-opt: replace stmGetEnclosingTRec() with a field accessSimon Marlow2009-10-141-2/+2
| | | | | While fixing #3578 I noticed that this function was just a field access to StgTRecHeader, so I inlined it manually.
* Fix #3429: a tricky race conditionSimon Marlow2009-08-181-0/+10
| | | | | | | | | | | | | | | | | | There were two bugs, and had it not been for the first one we would not have noticed the second one, so this is quite fortunate. The first bug is in stg_unblockAsyncExceptionszh_ret, when we found a pending exception to raise, but don't end up raising it, there was a missing adjustment to the stack pointer. The second bug was that this case was actually happening at all: it ought to be incredibly rare, because the pending exception thread would have to be killed between us finding it and attempting to raise the exception. This made me suspicious. It turned out that there was a race condition on the tso->flags field; multiple threads were updating this bitmask field non-atomically (one of the bits is the dirty-bit for the generational GC). The fix is to move the dirty bit into its own field of the TSO, making the TSO one word larger (sadly).
* Rename primops from foozh_fast to stg_foozhSimon Marlow2009-08-031-17/+17
| | | | For consistency with other RTS exported symbols
* rts_stop_on_exception is a C int, not a W_Simon Marlow2009-08-031-1/+1
| | | | amazing this hasn't caused any problems before now
* Fix #3279, #3288: fix crash encountered when calling unblock inside ↵Simon Marlow2009-06-161-8/+35
| | | | | | unsafePerformIO See comments for details
* Make killThread# cmm primop use local stack allocationDuncan Coutts2009-06-101-2/+3
| | | | | | | It using the mp_tmp_w register/global as a convenient temporary variable. This is naughty because those vars are supposed to be for gmp. Also, we want to remove the gmp temp vars so we must now use a local stack slot instead.
* Merging in the new codegen branchdias@eecs.harvard.edu2008-08-141-2/+2
| | | | | | | | | | | | | | | | | | This merge does not turn on the new codegen (which only compiles a select few programs at this point), but it does introduce some changes to the old code generator. The high bits: 1. The Rep Swamp patch is finally here. The highlight is that the representation of types at the machine level has changed. Consequently, this patch contains updates across several back ends. 2. The new Stg -> Cmm path is here, although it appears to have a fair number of bugs lurking. 3. Many improvements along the CmmCPSZ path, including: o stack layout o some code for infotables, half of which is right and half wrong o proc-point splitting
* Change the calling conventions for unboxed tuples slightlySimon Marlow2008-07-281-48/+0
| | | | | | | | | | When returning an unboxed tuple with a single non-void component, we now use the same calling convention as for returning a value of the same type as that component. This means that the return convention for IO now doesn't vary depending on the platform, which make some parts of the RTS simpler, and fixes a problem I was having with making the FFI work in unregisterised GHCi (the byte-code compiler makes some assumptions about calling conventions to keep things simple).
* add new primop: asyncExceptionsBlocked# :: IO BoolSimon Marlow2008-07-091-0/+9
|
* tso->link is now tso->_link (fix after merge with HEAD)Simon Marlow2008-04-171-1/+1
|
* Do some stack fiddling in stg_unblockAsyncExceptionszh_retIan Lynagh2008-05-231-0/+8
| | | | This fixes a segfault in #1657
* Do not #include external header files when compiling via CSimon Marlow2008-04-021-2/+0
| | | | | | | | | | | | | | | | | | | | | | | This has several advantages: - -fvia-C is consistent with -fasm with respect to FFI declarations: both bind to the ABI, not the API. - foreign calls can now be inlined freely across module boundaries, since a header file is not required when compiling the call. - bootstrapping via C will be more reliable, because this difference in behavour between the two backends has been removed. There is one disadvantage: - we get no checking by the C compiler that the FFI declaration is correct. So now, the c-includes field in a .cabal file is always ignored by GHC, as are header files specified in an FFI declaration. This was previously the case only for -fasm compilations, now it is also the case for -fvia-C too.
* Follow library changesIan Lynagh2008-03-231-3/+3
| | | | | Integer, Bool and Unit/Inl/Inr are now in new packages integer and ghc-prim.
* FIX #1980: must check for ThreadRelocated in killThread#Simon Marlow2007-12-171-0/+5
|
* fix -fbreak-on-exception for unregsterisedSimon Marlow2007-10-181-4/+5
|
* Properly guard imports because they have to be precise on Windows and Darwin ↵Clemens Fruhwirth2007-08-101-0/+2
| | | | sets __PIC__ automatically
* Add explicit imports for RTS-external variablesClemens Fruhwirth2007-08-061-0/+2
|
* Implemented and fixed bugs in CmmInfo handlingMichael D. Adams2007-06-271-25/+17
|
* Cleanup Hpc sub-system, remove hpc-tracer implementation.andy@galois.com2007-06-261-3/+0
|
* remove old comments and commented-out codeSimon Marlow2007-05-181-10/+1
|
* raise#: break *after* stripping the stack, not beforeSimon Marlow2007-05-161-23/+29
| | | | | | This means that thunks under evaluation will have been updated with the exception when we come to inspect them in GHCi. Blackholes are much less friendly.
* GHCi debugger: new flag -fbreak-on-exceptionSimon Marlow2007-05-151-12/+48
| | | | | | | | | | When -fbreak-on-exception is set, an exception will cause GHCi to suspend the current computation and return to the prompt, where the history of the current evaluation can be inspected (if we are in :trace). This isn't on by default, because the behaviour could be confusing: for example, ^C will cause a breakpoint. It can be very useful for finding the cause of a "head []" or a "fromJust Nothing", though.
* MERGE: Fix a few uses of the wrong return convention for the schedulerSimon Marlow2007-04-161-11/+4
| | | | | | | | | | We changed the convention a while ago so that BaseReg is returned to the scheduler in R1, because BaseReg may change during the run of a thread, e.g. during a foreign call. A few places got missed, mostly for very rare events. Should fix concprog001, although I'm not able to reliably reproduce the failure.
* add missing %ENTRY_CODE()Simon Marlow2007-03-081-2/+2
| | | | fixes unreg way in HEAD
* Remove vectored returns.Simon Marlow2007-02-281-42/+15
| | | | | We recently discovered that they aren't a win any more, and just cost code size.
* addition to "Eagerly raise a blocked exception" to fix unreg caseSimon Marlow2007-01-171-0/+19
|
* Adding command channel for the hpc debugger to the hpc part of the RTSandy@galois.com2007-01-091-1/+1
|
* Eagerly raise a blocked exception when entering 'unblock' or exiting 'block'Simon Marlow2007-01-051-5/+50
| | | | This fixes #1047
* Updating rix output to new standard.andy@galois.com2006-12-141-1/+1
|
* Misc Hpc improvement to dynamic tracer outputandy@galois.com2006-12-131-1/+1
| | | | | | | - Added HPCRIX support for passing tracer filename. - Added thread tracing support. - Cleaned up use of HsFFI.h
* Adding tracing supportandy@galois.com2006-12-091-0/+3
|
* STM invariantstharris@microsoft.com2006-10-071-2/+24
|
* Control.Exception.unblock wasn't unblocking exceptionsSimon Marlow2006-08-101-0/+3
|
* fix a lint-oSimon Marlow2006-06-201-1/+1
|
* fix sloppy conditionalsSimon Marlow2006-06-201-2/+2
|
* fix a few sloppy conditionals caught by new test in CmmLintSimon Marlow2006-06-201-1/+1
|
* fix one-character error in stack checkSimon Marlow2006-06-161-1/+1
|
* Asynchronous exception support for SMPSimon Marlow2006-06-161-99/+87
| | | | | | | | | | | | | | | | | This patch makes throwTo work with -threaded, and also refactors large parts of the concurrency support in the RTS to clean things up. We have some new files: RaiseAsync.{c,h} asynchronous exception support Threads.{c,h} general threading-related utils Some of the contents of these new files used to be in Schedule.c, which is smaller and cleaner as a result of the split. Asynchronous exception support in the presence of multiple running Haskell threads is rather tricky. In fact, to my annoyance there are still one or two bugs to track down, but the majority of the tests run now.
* Reorganisation of the source treeSimon Marlow2006-04-071-0/+446
Most of the other users of the fptools build system have migrated to Cabal, and with the move to darcs we can now flatten the source tree without losing history, so here goes. The main change is that the ghc/ subdir is gone, and most of what it contained is now at the top level. The build system now makes no pretense at being multi-project, it is just the GHC build system. No doubt this will break many things, and there will be a period of instability while we fix the dependencies. A straightforward build should work, but I haven't yet fixed binary/source distributions. Changes to the Building Guide will follow, too.